import { s as styleInject, u as useViewHandler, T as Toggle } from './index-bbdfb97a.js';
import 'react';
import { observer } from 'mobx-react-lite';
import { getLogger } from '@crystaldesign/diva-core';
import { DivaError } from '@crystaldesign/diva-utils';
import { jsx, Fragment } from 'react/jsx-runtime';
import '@babel/runtime/helpers/defineProperty';
import 'react-dynamic-multi-render';
import '@babel/runtime/helpers/asyncToGenerator';
import '@babel/runtime/helpers/slicedToArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/regenerator';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@babel/runtime/helpers/toConsumableArray';
import 'mobx';
import '@crystaldesign/web-planner-logic';
import 'classnames';
import 'qrcode.react';
import '@babel/runtime/helpers/typeof';
import 'flat';
import 'react-switch';
import 'react-countup';

var headerToggle = "header-toggle-W-6CA";
var css_248z = ".header-toggle-W-6CA {\n  float: right;\n}\n";
styleInject(css_248z);

var LOG = getLogger('Planner', 'ToggleHandler');
var ToggleHeader = function ToggleHeader(_ref) {
  var item = _ref.item;
  var viewHandler = useViewHandler();
  var items = item.groups[0].items;
  var yesItem;
  var noItem;
  if (!items) return /*#__PURE__*/jsx(Fragment, {});
  for (var i = 0; i < items.length; i++) {
    var _items$i$codex, _items$i$codex2;
    if ((_items$i$codex = items[i].codex) !== null && _items$i$codex !== void 0 && _items$i$codex.startsWith('OPVNEIN')) {
      noItem = items[i];
    }
    if ((_items$i$codex2 = items[i].codex) !== null && _items$i$codex2 !== void 0 && _items$i$codex2.startsWith('OPVJA')) {
      yesItem = items[i];
    }
  }
  if (!noItem || !yesItem) {
    if (items.length == 2) {
      noItem = items[0];
      yesItem = items[1];
    }
    if (!noItem || !yesItem) {
      LOG.error(new DivaError('Achtung! Bei der Option: ' + items[0].op + ' gibt es keine eindeutige werte für JA und NEIN', {
        code: 'WC_0011'
      }));
      return /*#__PURE__*/jsx(Fragment, {});
    }
  }
  return /*#__PURE__*/jsx("div", {
    className: headerToggle,
    children: /*#__PURE__*/jsx(Toggle, {
      onChange: function onChange() {
        viewHandler.paletteViewHandler.clickedOnConfigPalette(noItem.sel ? yesItem : noItem, undefined, item.id);
      },
      val: item,
      state: noItem.sel == false,
      off: noItem.text,
      on: yesItem.text
    })
  });
};
var ToggleHeader$1 = observer(ToggleHeader);

export { ToggleHeader$1 as default };
