Liferay.Loader.define("commerce-organization-web@5.0.37/js/OrganizationChart",["module","exports","require","@frontend-taglib-clay$clayui/button","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./ChartContext","./D3OrganizationChart","./ManagementBar/ManagementBar","./data/organizations","./menu/MenuProvider","./modals/ModalProvider","./utils/constants","../style/main.scss"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=y(a("@frontend-taglib-clay$clayui/button")),r=p(a("liferay!frontend-js-react-web$classnames")),l=(p(a("liferay!frontend-js-react-web$prop-types")),y(a("liferay!frontend-js-react-web$react"))),o=p(a("./ChartContext")),u=p(a("./D3OrganizationChart")),s=p(a("./ManagementBar/ManagementBar")),i=a("./data/organizations"),c=p(a("./menu/MenuProvider")),f=p(a("./modals/ModalProvider")),d=a("./utils/constants");function p(e){return e&&e.__esModule?e:{default:e}}function m(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return m=function(){return e},e}function y(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function g({pageSize:e,rootOrganizationId:t,spritemap:a}){const[p,m]=(0,l.useState)(!1),[y,g]=(0,l.useState)(null),[v,b]=(0,l.useState)(d.VIEWS[0]),[O,h]=(0,l.useState)(!1),[w,z]=(0,l.useState)(null),[E,j]=(0,l.useState)(null),[M,C]=(0,l.useState)(null),P=(0,l.useRef)(null),S=(0,l.useRef)(null),D=(0,l.useRef)(null),I=(0,l.useRef)(null),$=(0,l.useRef)(null);return(0,l.useEffect)((()=>{Number(t)?(0,i.getOrganization)(t).then(C):(0,i.getOrganizations)(e).then((e=>C(e.items)))}),[t,e]),(0,l.useLayoutEffect)((()=>(M&&S.current&&(D.current=new u.default(M,{svg:S.current,zoomIn:$.current,zoomOut:I.current},a,{open:(e,t)=>{g({parentData:e,type:t}),m(!0)}},{close:()=>{P.current=null,z(null),j(null)},open:(e,t,a)=>{P.current=e,z(t),j(a)}})),()=>{var e;return null===(e=D.current)||void 0===e?void 0:e.cleanUp()})),[e,M,a]),l.default.createElement(o.default.Provider,{value:{chartInstanceRef:D,currentView:v,setCurrentView:b}},l.default.createElement(s.default,null),l.default.createElement("div",{className:(0,r.default)("org-chart-container",{expanded:O})},l.default.createElement("svg",{className:"svg-chart",ref:S}),l.default.createElement("div",{className:"zoom-controls"},l.default.createElement(n.ClayButtonWithIcon,{displayType:"secondary",onClick:()=>h(!O),small:!0,symbol:"expand"}),l.default.createElement(n.default.Group,{className:"ml-3"},l.default.createElement(n.ClayButtonWithIcon,{displayType:"secondary",ref:I,small:!0,symbol:"hr"}),l.default.createElement(n.ClayButtonWithIcon,{displayType:"secondary",ref:$,small:!0,symbol:"plus"})))),l.default.createElement(c.default,{alignElementRef:P,data:w,parentData:E}),l.default.createElement(f.default,{active:p,closeModal:()=>m(!1),parentData:null==y?void 0:y.parentData,type:null==y?void 0:y.type}))}a("../style/main.scss"),g.defaultProps={pageSize:10,rootOrganizationId:0};var v=g;t.default=v}}));
//# sourceMappingURL=OrganizationChart.js.map