"use strict";(self.webpackChunkReactFormBuilder=self.webpackChunkReactFormBuilder||[]).push([[998],{52998:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var i=n(70885),a=n(90359),s=n.n(a),l=(n(69333),n(90872)),r=n(90742),d=n(3966),o=n(71103),u=function(e){var t=(0,a.useState)(e.element),n=(0,i.Z)(t,2),u=n[0],c=n[1],m=(0,a.useState)(e.data),f=(0,i.Z)(m,2),p=(f[0],f[1],(0,a.useState)(!1)),g=(0,i.Z)(p,2),b=g[0],h=(g[1],(0,a.useState)(null)),k=(0,i.Z)(h,2),v=k[0],E=k[1];(0,a.useEffect)((function(){v||(0,r.Z)().request({url:"/sign-permissions?populate=*&sort=order:asc",method:"get"}).then((function(e){var t=e.data.data.map((function(e){var t=e.attributes.name,n=(e.id,e.attributes.sign_permission,e.attributes.name.replace(/\w+/g,(function(e){return e.charAt(0).toUpperCase()+e.substr(1)})).replace(/\s/g,""));return e.attributes.attrName=n,e.attributes.displayName=t,e}));E(t)})).catch((function(e){E(null)})).finally((function(){}))}),[]),(0,a.useEffect)((function(){for(var t=function(t){var n=o.default.getInstance(document.getElementById("checkBox"+v[t].id));null===v[t].attributes.sign_permission.data||!1===v[t].checkDisabled?n.option("disabled",!1):n.option("disabled",!0),e.element.sign&&e.element.sign.find((function(e){return e.id===v[t].id}))&&n.option("value",!0)},n=0;n<(null==v?void 0:v.length);n++)t(n)}),[v]);return b&&(e.element.dirty=!0),s().createElement("div",null,s().createElement("div",{className:"edit-permission-panel"}),s().createElement(l.Popup,{visible:!0,dragEnabled:!1,hideOnOutsideClick:!0,showCloseButton:!0,showTitle:!0,title:e.element.text,container:".edit-permission-panel",width:600,height:600,onHiding:e.manualEditPermissionModeOff},s().createElement(l.Position,{at:"center",my:"center",collision:"fit"}),null==v?void 0:v.map((function(t,n){return t.id,s().createElement(d.Jg,{className:"CheckBoxField",key:"checkBox".concat(t.id),id:"checkBox".concat(t.id),onValueChange:function(n){return function(t,n){if(t)if(e.element.sign||(e.element.sign=[]),e.element.sign.length>0&&e.element.sign.find((function(e){return e.id===n.id}))){var i=e.element.sign.find((function(e){return e.id===n.id}));i.attributes.permissions=n.attributes.users_permissions_roles.data.map((function(e){return{key:e.id,name:e.attributes.name}})),i.checkClicked=!0}else{var a=n.attributes.users_permissions_roles.data.map((function(e){return{key:e.id,name:e.attributes.name}}));n.attributes.permissions=a,n.checkClicked=!0,e.element.sign.push(n)}else{var s=-1;e.element.sign.find((function(e,t){e.id===n.id&&(s=t)})),e.element.sign.splice(s,1)}c(e.element),e.updateElement(u),function(e,t){e||v.forEach((function(e){var n;(null===(n=e.attributes.sign_permission.data)||void 0===n?void 0:n.id)===t.id&&o.default.getInstance(document.getElementById("checkBox"+e.id)).option("value",!1)}));for(var n=0;n<v.length;n++){var i=o.default.getInstance(document.getElementById("checkBox"+v[n].id));null!=v[n].attributes.sign_permission.data&&(v[n].attributes.sign_permission.data.id===t.id?!0===e?(i.option("disabled",!1),v[n].checkDisabled=!1):(i.option("disabled",!0),v[n].checkDisabled=!0):!0===o.default.getInstance(document.getElementById("checkBox"+v[n].attributes.sign_permission.data.id))._props.value?(i.option("disabled",!1),v[n].checkDisabled=!1):(i.option("disabled",!0),v[n].checkDisabled=!0))}}(t,n)}(n,t)},text:t.attributes.displayName})}))))};u.defaultProps={className:"edit-element-fields"};const c=u}}]);