"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[8358],{78358:(e,t,a)=>{a.r(t),a.d(t,{default:()=>s});var l=a(51609),n=a(37489),r=a(27723),o=a(9588),u=a(86087),c=a(22589),d=a(45111),i=a(4219),m=a(7320);const s=(0,u.memo)((({id:e,value:t,options:a,defaultValue:s,disabled:p})=>{const[g,_]=(0,u.useState)(!1),[h,v]=(0,u.useState)(""),[E,b]=(0,u.useState)([]),[f,y]=(0,u.useState)(!1),[z,A]=(0,u.useState)(!1),[C,T]=(0,u.useState)(null),k=(0,u.useRef)(t),{updateField:F,setChangedField:N}=(0,i.default)(),S=a=>{let l=k.current!==t||a;if("custom"!==t||f||(k.current=t,l&&w(!1)),"url"===t&&!z){let a={};k.current=t,a.type=e,o.doAction("get_custom_legal_document_url",a).then((e=>{v(e.pageUrl),A(!0)}))}};(0,u.useEffect)((()=>{a.map((e=>e.value)).includes(t)||F(e,s),S(!0)}),[]),(0,c.A)((()=>{S(!1)}));const w=t=>{let a={};return a.type=e,a.search=t,o.doAction("get_pages_list",a).then((e=>{let t=e.pages.filter((function(t){return t.value===e.pageId}));return _(t),y(!0),b(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)(m.default,{id:e,options:L,value:t,onChange:t=>{F(e,t),N(e,t)},disabled:p}),"custom"===t&&!f&&(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&&f&&(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),o.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:h,onChange:t=>{let a={},l=t.target.value;a.pageUrl=l,a.type=e,v(l),clearTimeout(C);const n=setTimeout((()=>{o.doAction("update_custom_legal_document_url",a).then((e=>{}))}),500);T(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:o,defaultValue:u,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:o,default:u},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)))))))}}]);