"use strict";

exports.__esModule = true;
exports.useCustomFieldsViewWidget = void 0;
var _bexCore = require("@wix/bex-core");
var _react = require("@wix/bex-core/react");
var _react2 = require("react");
const useCustomFieldsViewWidget = ({
  fqdn,
  extendedFields,
  theme,
  extensionPoint
}) => {
  const container = (0, _react.useWixPatternsContainer)();
  const [state] = (0, _react2.useState)(() => new _bexCore.CustomFieldsViewWidgetState({
    container,
    fqdn: (0, _bexCore.parseFqdn)(fqdn),
    url: window.location.href,
    route: window.location.pathname,
    theme,
    extensionPoint
  }));
  (0, _react2.useEffect)(() => state.init(), []);
  const userCustomFields = state.dataExtension.availableUserCustomFields;
  const appsCustomFields = state.dataExtension.availableAppsCustomFields;
  const areAllCustomFieldsEmpty = (0, _react2.useMemo)(() => {
    return state.dataExtension.allNamespaces.every(namespace => state.getExtendedFieldsToDisplayForNamespace(namespace, extendedFields).length === 0);
  }, [extendedFields, userCustomFields, state.dataExtension.appSchemas]);
  return {
    state,
    userCustomFields,
    appsCustomFields,
    container,
    areAllCustomFieldsEmpty
  };
};
exports.useCustomFieldsViewWidget = useCustomFieldsViewWidget;
//# sourceMappingURL=useCustomFieldsViewWidget.js.map