Liferay.Loader.define("data-engine-taglib@3.3.53/data_layout_builder/js/FormBuilder",["module","exports","require","@frontend-taglib-clay$clayui/layout","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$classnames","data-engine-js-components-web","data-engine-js-components-web/js/core/thunks/fieldDelete.es","liferay!frontend-js-react-web$react","./components/sidebar/MultiPanelSidebar.es","./components/sidebar/initializeSidebarConfig.es","./drag-and-drop/DragLayer.es","./eventTypes","./utils/client.es"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.FormBuilder=function FormBuilder(){const e=(0,l.useForm)(),[{onClose:a},t]=(0,s.useContext)(r.Context),{focusedField:b,rules:m,sidebarPanels:y}=(0,l.useFormState)(),{allowFieldSets:g,contentType:E,dataDefinitionId:P,groupId:_,portletNamespace:D}=(0,l.useConfig)(),[{sidebarOpen:j,sidebarPanelId:I},w]=(0,s.useState)({sidebarOpen:!0,sidebarPanelId:"fields"}),{panels:v,sidebarPanels:h,sidebarVariant:O}=(0,s.useMemo)((()=>(0,u.default)({portletNamespace:D,sidebarPanels:y})),[y,D]);return(0,s.useEffect)((()=>{if(g&&E){let a=[];_&&(a=(0,p.getItem)("/o/data-engine/v2.0/sites/".concat(_,"/data-definitions/by-content-type/").concat(E)));const t=_===themeDisplay.getCompanyGroupId()?Promise.resolve({}):(0,p.getItem)("/o/data-engine/v2.0/data-definitions/by-content-type/".concat(E));(async()=>{try{const[{items:n=[]},{items:r=[]}]=await Promise.all([a,t]),i=[...n,...r].filter((({id:e})=>e!==parseInt(P,10)));e({payload:{fieldSets:i},type:f.EVENT_TYPES.FIELD_SET.UPDATE_LIST})}catch(e){}})()}}),[g,E,P,e,_]),(0,s.useEffect)((()=>{const e=document.querySelector(".data-engine-form-builder-messages");e&&(e.className=(0,i.default)("data-engine-form-builder-messages",{"data-engine-form-builder-messages--collapsed":j}))}),[j]),(0,s.useEffect)((()=>{!!Object.keys(b).length&&w((({sidebarPanelId:e})=>({sidebarOpen:!0,sidebarPanelId:e})))}),[b]),s.default.createElement("div",{className:(0,i.default)("data-engine-form-builder ddm-form-builder pb-5",{"ddm-form-builder--sidebar-open":j})},s.default.createElement(n.default.Sheet,null,s.default.createElement("div",{className:"ddm-form-builder-wrapper"},s.default.createElement("div",{className:"container ddm-form-builder"},s.default.createElement(c.default,null),s.default.createElement(l.Pages,{editable:!0,fieldActions:[{action:a=>e({payload:a,type:l.EVENT_TYPES.FIELD.DUPLICATE}),label:Liferay.Language.get("duplicate")},{action:n=>e((0,d.default)({action:{payload:n,type:l.EVENT_TYPES.FIELD.DELETE},modalDispatch:t,onClose:a,rules:m})),label:Liferay.Language.get("delete")}]}),s.default.createElement(o.default,{createPlugin:({panel:a,sidebarOpen:t,sidebarPanelId:n})=>({dispatch:e,panel:a,sidebarOpen:t,sidebarPanelId:n}),currentPanelId:I,onChange:w,open:j,panels:v,sidebarPanels:h,variant:O})))))};var n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/layout")),r=t("@frontend-taglib-clay$clayui/modal"),i=_interopRequireDefault(t("liferay!frontend-js-react-web$classnames")),l=t("data-engine-js-components-web"),d=_interopRequireDefault(t("data-engine-js-components-web/js/core/thunks/fieldDelete.es")),s=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var a=_getRequireWildcardCache();if(a&&a.has(e))return a.get(e);var t={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=n?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(t,r,i):t[r]=e[r]}t.default=e,a&&a.set(e,t);return t}(t("liferay!frontend-js-react-web$react")),o=_interopRequireDefault(t("./components/sidebar/MultiPanelSidebar.es")),u=_interopRequireDefault(t("./components/sidebar/initializeSidebarConfig.es")),c=_interopRequireDefault(t("./drag-and-drop/DragLayer.es")),f=t("./eventTypes"),p=t("./utils/client.es");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=FormBuilder.js.map