"use strict";(self.webpackChunkReactFormBuilder=self.webpackChunkReactFormBuilder||[]).push([[608],{31608:(e,t,n)=>{n.r(t),n.d(t,{default:()=>u});var i=n(70885),a=n(90359),s=n.n(a),r=(n(69333),n(90872)),o=n(71257);var l=n(3966),d=n(71103),c=function(e){var t=(0,a.useState)(e.element),n=(0,i.Z)(t,2),c=n[0],u=n[1],m=(0,a.useState)(e.data),p=(0,i.Z)(m,2),f=(p[0],p[1],(0,a.useState)(!1)),g=(0,i.Z)(f,2),h=g[0],b=(g[1],(0,a.useState)(null)),v=(0,i.Z)(b,2),k=v[0],E=v[1];(0,a.useEffect)((function(){var e,t;k||o.Z.create({baseURL:"".concat(process.env.REACT_APP_BACKEND_URL,"/api"),headers:(e=localStorage.getItem("jwt"),t={"Content-type":"application/json"},e&&(t.Authorization="Bearer ".concat(e)),t)}).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=d.default.getInstance(document.getElementById("checkBox"+k[t].id));null===k[t].attributes.sign_permission.data||!1===k[t].checkDisabled?n.option("disabled",!1):n.option("disabled",!0),e.element.sign&&e.element.sign.find((function(e){return e.id===k[t].id}))&&n.option("value",!0)},n=0;n<(null==k?void 0:k.length);n++)t(n)}),[k]);return h&&(e.element.dirty=!0),s().createElement("div",null,s().createElement("div",{className:"edit-permission-panel"}),s().createElement(r.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(r.Position,{at:"center",my:"center",collision:"fit"}),null==k?void 0:k.map((function(t,n){return t.id,s().createElement(l.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)}u(e.element),e.updateElement(c),function(e,t){e||k.forEach((function(e){var n;(null===(n=e.attributes.sign_permission.data)||void 0===n?void 0:n.id)===t.id&&d.default.getInstance(document.getElementById("checkBox"+e.id)).option("value",!1)}));for(var n=0;n<k.length;n++){var i=d.default.getInstance(document.getElementById("checkBox"+k[n].id));null!=k[n].attributes.sign_permission.data&&(k[n].attributes.sign_permission.data.id===t.id?!0===e?(i.option("disabled",!1),k[n].checkDisabled=!1):(i.option("disabled",!0),k[n].checkDisabled=!0):!0===d.default.getInstance(document.getElementById("checkBox"+k[n].attributes.sign_permission.data.id))._props.value?(i.option("disabled",!1),k[n].checkDisabled=!1):(i.option("disabled",!0),k[n].checkDisabled=!0))}}(t,n)}(n,t)},text:t.attributes.displayName})}))))};c.defaultProps={className:"edit-element-fields"};const u=c}}]);