import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
import { u as useViewHandler, a as useAnalyzerComponents, M as MissingAnalyzerComponent } from './index-bbdfb97a.js';
import 'react';
import ReactDOM from 'react-dom';
import FloatingWindow from './index-78918709.js';
import { jsx, Fragment } from 'react/jsx-runtime';
import 'react-dynamic-multi-render';
import '@crystaldesign/diva-core';
import 'mobx-react-lite';
import '@babel/runtime/helpers/asyncToGenerator';
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 '@crystaldesign/diva-utils';
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';
import 'react-rnd';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var TITLES = {
  PartList: 'Stückliste',
  PriceAnalyzer: 'Preise',
  DecisionAnalyzer: 'Decisions',
  OptionTreeTable: 'Option Tree',
  ErrorWarningOverview: 'Errors & Warnings',
  ekText: 'Ek Text',
  PriceList: 'Price list'
};
var WINDOW_TO_COMPONENT = {
  PartList: 'PartlistDebug',
  DecisionAnalyzer: 'DecisionAnalyzer',
  OptionTreeTable: 'OptionTreeTable',
  PriceAnalyzer: 'PriceAnalyzer',
  ErrorWarningOverview: 'ErrorAndWarningOverview',
  PriceList: 'PriceList',
  ekText: 'EkTextViewer'
};
var ToolContainer = function ToolContainer(_ref) {
  _objectDestructuringEmpty(_ref);
  var viewHandler = useViewHandler();
  var analyzerComponents = useAnalyzerComponents();
  var windows = Array.from(viewHandler.wysiwygDebugState.activeWysiwygWindows.entries());
  var renderContent = function renderContent(windowType) {
    var componentKey = WINDOW_TO_COMPONENT[windowType];
    var Component = analyzerComponents[componentKey];
    if (!Component) return /*#__PURE__*/jsx(MissingAnalyzerComponent, {
      name: componentKey
    });
    var commonProps = windowType === 'ErrorWarningOverview' ? {} : {
      className: ''
    };
    return /*#__PURE__*/jsx(Component, _objectSpread({}, commonProps));
  };
  var floatingWindows = windows.map(function (_ref2) {
    var _ref3 = _slicedToArray(_ref2, 2),
      windowType = _ref3[0],
      bounds = _ref3[1];
    return /*#__PURE__*/jsx(FloatingWindow, {
      windowType: windowType,
      title: TITLES[windowType],
      bounds: bounds,
      children: renderContent(windowType)
    }, windowType);
  });
  if (floatingWindows.length === 0) return null;
  return /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/jsx(Fragment, {
    children: floatingWindows
  }), document.body);
};

export { ToolContainer as default };
