"use strict";

exports.__esModule = true;
exports.toolComponents = exports.default = exports.ToolbarRadioWrapper = exports.ToolbarRadio = exports.ToolbarLabel = exports.ToolbarInput = exports.ToolbarButton = exports.Toolbar = exports.ToolGroup = exports.Spacer = exports.Separator = exports.Bar = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _utils = require("../utils");
var _IconButton = _interopRequireDefault(require("./IconButton"));
var _Input = _interopRequireDefault(require("./Input"));
var _Text = _interopRequireWildcard(require("./Text"));
var _Radio = _interopRequireDefault(require("./MaterialUI/Inputs/Radio"));
var _RadioProps = _interopRequireDefault(require("./MaterialUI/Inputs/RadioProps"));
var _excluded = ["key", "type", "subType"],
  _excluded2 = ["label"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var Bar = exports.Bar = _styledComponents.default.div.withConfig({
  displayName: "Toolbar__Bar",
  componentId: "sc-1appttk-0"
})(["flex:0 0 auto;min-height:64px;border-bottom:1px solid ", ";display:flex;align-items:center;padding:5px 24px;box-sizing:border-box;"], (0, _utils.getThemeProp)(["colors", "borderLight"], "#cccccc"));
var ToolGroup = exports.ToolGroup = _styledComponents.default.div.withConfig({
  displayName: "Toolbar__ToolGroup",
  componentId: "sc-1appttk-1"
})(["flex:0 0 auto;display:flex;& > *:not(:last-child){margin-right:-1px;border-top-right-radius:0;border-bottom-right-radius:0;}& > *:not(:first-child){margin-left:0;border-top-left-radius:0;border-bottom-left-radius:0;}"]);
var ToolbarButton = exports.ToolbarButton = (0, _styledComponents.default)(_IconButton.default).withConfig({
  displayName: "Toolbar__ToolbarButton",
  componentId: "sc-1appttk-2"
})(["flex:0 0 auto;margin:0 5px;min-width:auto;&:focus,&:hover{z-index:10;}"]);
var ToolbarInput = exports.ToolbarInput = (0, _styledComponents.default)(_Input.default).withConfig({
  displayName: "Toolbar__ToolbarInput",
  componentId: "sc-1appttk-3"
})(["height:30px;flex:0 0 auto;margin:0 5px;&:focus{z-index:10;}"]);
var ToolbarRadioWrapper = exports.ToolbarRadioWrapper = _styledComponents.default.div.withConfig({
  displayName: "Toolbar__ToolbarRadioWrapper",
  componentId: "sc-1appttk-4"
})(["min-width:250px;padding-left:10px;"]);
var ToolbarRadio = exports.ToolbarRadio = (0, _styledComponents.default)(_Radio.default).withConfig({
  displayName: "Toolbar__ToolbarRadio",
  componentId: "sc-1appttk-5"
})(["height:30px;flex:0 0 auto;margin:0 5px;&:focus{z-index:10;}"]);
var Separator = exports.Separator = _styledComponents.default.div.withConfig({
  displayName: "Toolbar__Separator",
  componentId: "sc-1appttk-6"
})(["flex:0 0 1px;height:30px;margin:0 16px;background-color:", ";"], (0, _utils.getThemeProp)(["colors", "borderLight"], "#cccccc"));
var Spacer = exports.Spacer = _styledComponents.default.div.withConfig({
  displayName: "Toolbar__Spacer",
  componentId: "sc-1appttk-7"
})(["flex:100%;"]);
var ToolbarLabel = exports.ToolbarLabel = _styledComponents.default.div.withConfig({
  displayName: "Toolbar__ToolbarLabel",
  componentId: "sc-1appttk-8"
})(["font-family:", ";font-size:14px;color:", ";"], (0, _utils.getThemeProp)(["fonts", "base"], "sans-serif"), (0, _utils.getThemeProp)(["colors", "application", "base"], "#999999"));

// Define the dictionary so we can use it below
var toolComponents = exports.toolComponents = {};

// Turns a tool definition into a rendered React element
var renderToolComponent = function renderToolComponent(_ref) {
  var key = _ref.key,
    type = _ref.type,
    subType = _ref.subType,
    props = _objectWithoutProperties(_ref, _excluded);
  var Comp = toolComponents[type];
  return /*#__PURE__*/_react.default.createElement(Comp, _extends({
    key: key,
    type: subType
  }, props));
};

// Fill in the tool types
toolComponents.input = ToolbarInput;
toolComponents.input.displayName = "ToolInput";
toolComponents.button = function (_ref2) {
  var _ref2$label = _ref2.label,
    label = _ref2$label === void 0 ? {} : _ref2$label,
    props = _objectWithoutProperties(_ref2, _excluded2);
  return /*#__PURE__*/_react.default.createElement(ToolbarButton, _extends({}, props, {
    icon: label.icon,
    label: label.text
  }));
};
toolComponents.button.displayName = "ToolButton";
toolComponents.radio = function (props) {
  var radioProps = new _RadioProps.default();
  radioProps.set(_RadioProps.default.propNames.name, props == null ? void 0 : props.name);
  radioProps.set(_RadioProps.default.propNames.label, props == null ? void 0 : props.label);
  radioProps.set(_RadioProps.default.propNames.defaultVal, props == null ? void 0 : props.defaultVal);
  radioProps.set(_RadioProps.default.propNames.value, props == null ? void 0 : props.value);
  radioProps.set(_RadioProps.default.propNames.update, props == null ? void 0 : props.update);
  radioProps.set(_RadioProps.default.propNames.radios, props == null ? void 0 : props.radios);
  radioProps.set(_RadioProps.default.propNames.row, props == null ? void 0 : props.row);
  radioProps.set(_RadioProps.default.propNames.error, props == null ? void 0 : props.error);
  return /*#__PURE__*/_react.default.createElement(ToolbarRadioWrapper, null, /*#__PURE__*/_react.default.createElement(ToolbarRadio, {
    radioProps: radioProps
  }));
};
toolComponents.radio.displayName = "ToolRadio";
toolComponents.group = function (_ref3) {
  var tools = _ref3.tools;
  return /*#__PURE__*/_react.default.createElement(ToolGroup, null, tools.map(renderToolComponent));
};
toolComponents.group.displayName = "ToolGroup";
toolComponents.spacer = function () {
  return /*#__PURE__*/_react.default.createElement(Spacer, null);
};
toolComponents.spacer.displayName = "ToolSpacer";
toolComponents.separator = function () {
  return /*#__PURE__*/_react.default.createElement(Separator, null);
};
toolComponents.separator.displayName = "ToolSeparator";
var Toolbar = exports.Toolbar = function Toolbar(_ref4) {
  var tools = _ref4.tools;
  return /*#__PURE__*/_react.default.createElement(Bar, null, tools.map(renderToolComponent));
};
toolComponents.label = function (_ref5) {
  var label = _ref5.label;
  return /*#__PURE__*/_react.default.createElement(ToolbarLabel, null, /*#__PURE__*/_react.default.createElement(_Text.default, {
    message: label
  }));
};
toolComponents.label.displayName = "ToolLabel";

// These tools are allowed inside tool groups
var ptTool = _propTypes.default.oneOfType([_propTypes.default.shape({
  type: _propTypes.default.oneOf(["input"]).isRequired
}), _propTypes.default.shape({
  type: _propTypes.default.oneOf(["radio"]).isRequired
}), _propTypes.default.shape({
  type: _propTypes.default.oneOf(["button"]).isRequired,
  label: _propTypes.default.oneOfType([_propTypes.default.shape({
    icon: _propTypes.default.string.isRequired,
    text: _Text.ptLabel
  }), _propTypes.default.shape({
    icon: _propTypes.default.string,
    text: _Text.ptLabel.isRequired
  })]).isRequired
})]);

// These tools are only allowed outside groups
var ptToolWithGroup = _propTypes.default.oneOfType([ptTool, _propTypes.default.shape({
  type: _propTypes.default.oneOf(["label"]).isRequired,
  label: _Text.ptLabel.isRequired
}), _propTypes.default.shape({
  type: _propTypes.default.oneOf(["separator", "spacer"]).isRequired
}), _propTypes.default.shape({
  type: _propTypes.default.oneOf(["group"]).isRequired,
  tools: _propTypes.default.arrayOf(ptTool)
})]);
Toolbar.propTypes = {
  tools: _propTypes.default.arrayOf(ptToolWithGroup).isRequired
};
var _default = Toolbar;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(Bar, "Bar", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolGroup, "ToolGroup", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarButton, "ToolbarButton", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarInput, "ToolbarInput", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarRadioWrapper, "ToolbarRadioWrapper", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarRadio, "ToolbarRadio", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(Separator, "Separator", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(Spacer, "Spacer", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarLabel, "ToolbarLabel", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(toolComponents, "toolComponents", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(renderToolComponent, "renderToolComponent", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(Toolbar, "Toolbar", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ptTool, "ptTool", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ptToolWithGroup, "ptToolWithGroup", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/Toolbar.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(Bar, "Bar", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolGroup, "ToolGroup", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarButton, "ToolbarButton", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarInput, "ToolbarInput", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarRadioWrapper, "ToolbarRadioWrapper", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarRadio, "ToolbarRadio", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(Separator, "Separator", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(Spacer, "Spacer", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ToolbarLabel, "ToolbarLabel", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(toolComponents, "toolComponents", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(renderToolComponent, "renderToolComponent", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(Toolbar, "Toolbar", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ptTool, "ptTool", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(ptToolWithGroup, "ptToolWithGroup", "/home/vsts/work/1/s/src/components/Toolbar.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/Toolbar.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();