// 隐藏工具栏按钮
export default (store) => (dataElements) => {
  const headerItems = [
    ...store.getActiveHeaderItems,
    ...store.getTools,
    ...store.getActiveRightHeaderItems,
    ...store.getToolItems.annotation,
    ...store.getToolItems.form,
    ...store.getPopupItems('textPopup'),
    ...store.getPopupItems('cropPagePopup')
  ];

  if (Array.isArray(dataElements)) {
    for (let i = 0; i < headerItems.length; i++) {
      dataElements.forEach(element => {
        if (store.getDisabledElementsObj[dataElements]) {
          store.setDisabledElements(dataElements)
        } else if (headerItems[i].dataElement === element) {
          headerItems[i].hidden = true;
        }
      });
    }
  } else if (typeof dataElements === 'string') {
    if (store.getDisabledElementsObj[dataElements]) {
      store.setDisabledElements(dataElements)
      return
    }
    const obj = headerItems.find(obj => obj.dataElement === dataElements);
    if (obj) {
      obj.hidden = true;
      if (store.toolMode === obj.element) {
        store.setActiveToolMode(store.tools[0]?.element);
      }
    } else {
      console.warn('DataElement not found.');
    }
  } else {
    console.error('Wrong dataElements type.');
  }
};
