"use strict";

exports.__esModule = true;
exports.CustomFieldModalPrimaryButton = void 0;
var _react = _interopRequireWildcard(require("react"));
var _designSystem = require("@wix/design-system");
var _mobxReactLite = require("mobx-react-lite");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CustomFieldModal/CustomFieldModalPrimaryButton.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const useElementWidth = (initialWidth = 0) => {
  const [width, setWidth] = (0, _react.useState)(initialWidth);
  const ref = (0, _react.useRef)(null);
  (0, _react.useEffect)(() => {
    if (ref.current) {
      setWidth(ref.current.clientWidth);
    }
  }, [ref.current]);
  return [width, ref];
};
const CustomFieldModalPrimaryButton = exports.CustomFieldModalPrimaryButton = (0, _mobxReactLite.observer)(props => {
  const {
    state: {
      isSubmitting
    },
    content
  } = props;
  const [width, ref] = useElementWidth();
  return /*#__PURE__*/_react.default.createElement("div", {
    ref: ref,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 42,
      columnNumber: 7
    }
  }, isSubmitting ? /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    verticalAlign: "middle",
    align: "center",
    width: width,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 44,
      columnNumber: 11
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.Loader, {
    dataHook: "custom-field-modal-status-submitting",
    size: "tiny",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 45,
      columnNumber: 13
    }
  })) : content);
});
//# sourceMappingURL=CustomFieldModalPrimaryButton.js.map