"use strict";(self.webpackChunkcomplianz_gdpr=self.webpackChunkcomplianz_gdpr||[]).push([[8358],{78358:(e,t,a)=>{a.r(t),a.d(t,{default:()=>i});var l=a(51609),n=a(37489),r=a(27723),u=a(9588),o=a(86087),c=a(22589),d=a(45111),m=a(4219),s=a(7320);const i=(0,o.memo)((({id:e,value:t,options:a,defaultValue:i,disabled:p})=>{const[g,_]=(0,o.useState)(!1),[v,f]=(0,o.useState)(""),[E,h]=(0,o.useState)([]),[y,b]=(0,o.useState)(!1),[z,A]=(0,o.useState)(!1),[C,k]=(0,o.useState)(null),F=(0,o.useRef)(t),{updateField:N,setChangedField:S}=(0,m.default)(),T=a=>{let l=F.current!==t||a;if("custom"!==t||y||(F.current=t,l&&w(!1)),"url"===t&&!z){let a={};F.current=t,a.type=e,u.doAction("get_custom_legal_document_url",a).then((e=>{f(e.pageUrl),A(!0)}))}};(0,o.useEffect)((()=>{a.map((e=>e.value)).includes(t)||N(e,i),T(!0)}),[]),(0,c.A)((()=>{T(!1)}));const w=t=>{let a={};return a.type=e,a.search=t,u.doAction("get_pages_list",a).then((e=>{let t=e.pages.filter((function(t){return t.value===e.pageId}));return _(t),b(!0),h(e.pages),e.pages}))},L={};for(const e in a){const t=a[e];L[t.value]=t.label}return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(s.default,{id:e,options:L,value:t,onChange:t=>{N(e,t),S(e,t)},disabled:p}),"custom"===t&&!y&&(0,l.createElement)("div",{className:"cmplz-documents-loader"},(0,l.createElement)("div",null,(0,l.createElement)(d.default,{name:"loading",color:"grey"})),(0,l.createElement)("div",null,(0,r.__)("Loading...","complianz-gdpr"))),"custom"===t&&y&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(n.A,{label:(0,r.__)("Link to custom page","complianz-gdpr"),defaultOptions:E,loadOptions:e=>new Promise((t=>{setTimeout((()=>{t(w(e))}),1e3)})),menuPortalTarget:document.body,menuPosition:"fixed",placeholder:(0,r.__)("Type at least two characters","complianz-gdpr"),onChange:t=>(t=>{let a={};a.pageId=t.value,a.type=e,_(t),u.doAction("update_custom_legal_document_id",a).then((e=>{}))})(t),value:g,styles:{menuPortal:e=>({...e,zIndex:9999})}})),"url"===t&&!z&&(0,l.createElement)("div",{className:"cmplz-documents-loader"},(0,l.createElement)("div",null,(0,l.createElement)(d.default,{name:"loading",color:"grey"})),(0,l.createElement)("div",null,(0,r.__)("Loading...","complianz-gdpr"))),"url"===t&&z&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)("input",{type:"text",value:v,onChange:t=>{let a={},l=t.target.value;a.pageUrl=l,a.type=e,f(l),clearTimeout(C);const n=setTimeout((()=>{u.doAction("update_custom_legal_document_url",a).then((e=>{}))}),500);k(n)},placeholder:"https://domain.com/your-policy"})))}))},7320:(e,t,a)=>{a.r(t),a.d(t,{default:()=>r});var l=a(51609),n=a(62848);const r=(0,a(86087).memo)((({label:e,id:t,value:a,onChange:r,required:u,defaultValue:o,disabled:c,options:d={}})=>(0,l.createElement)(n.bL,{disabled:c&&!Array.isArray(c),className:"cmplz-input-group cmplz-radio-group",value:a,"aria-label":e,onValueChange:r,required:u,default:o},Object.entries(d).map((([e,a])=>(0,l.createElement)("div",{key:e,className:"cmplz-radio-group__item"},(0,l.createElement)(n.q7,{disabled:Array.isArray(c)&&c.includes(e),value:e,id:t+"_"+e},(0,l.createElement)(n.C1,{className:"cmplz-radio-group__indicator"})),(0,l.createElement)("label",{className:"cmplz-radio-label",htmlFor:t+"_"+e},a)))))))}}]);