"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[800],{10800:(e,t,a)=>{a.r(t),a.d(t,{default:()=>_});var c=a(51609),r=a(86087),n=a(58168),s=a(9957),l=a(91071),o=a(62133),d=a(81351),u=a(85357),i=a(31769),p=a(12579);const h="Switch",[b,m]=(0,o.A)(h),[f,k]=b(h),v=(0,c.forwardRef)(((e,t)=>{const{__scopeSwitch:a,name:r,checked:o,defaultChecked:u,required:i,disabled:h,value:b="on",onCheckedChange:m,...k}=e,[v,E]=(0,c.useState)(null),C=(0,l.s)(t,(e=>E(e))),y=(0,c.useRef)(!1),_=!v||Boolean(v.closest("form")),[z=!1,S]=(0,d.i)({prop:o,defaultProp:u,onChange:m});return(0,c.createElement)(f,{scope:a,checked:z,disabled:h},(0,c.createElement)(p.sG.button,(0,n.A)({type:"button",role:"switch","aria-checked":z,"aria-required":i,"data-state":w(z),"data-disabled":h?"":void 0,disabled:h,value:b},k,{ref:C,onClick:(0,s.m)(e.onClick,(e=>{S((e=>!e)),_&&(y.current=e.isPropagationStopped(),y.current||e.stopPropagation())}))})),_&&(0,c.createElement)(g,{control:v,bubbles:!y.current,name:r,value:b,checked:z,required:i,disabled:h,style:{transform:"translateX(-100%)"}}))})),g=e=>{const{control:t,checked:a,bubbles:r=!0,...s}=e,l=(0,c.useRef)(null),o=(0,u.Z)(a),d=(0,i.X)(t);return(0,c.useEffect)((()=>{const e=l.current,t=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(t,"checked").set;if(o!==a&&c){const t=new Event("click",{bubbles:r});c.call(e,a),e.dispatchEvent(t)}}),[o,a,r]),(0,c.createElement)("input",(0,n.A)({type:"checkbox","aria-hidden":!0,defaultChecked:a},s,{tabIndex:-1,ref:l,style:{...e.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function w(e){return e?"checked":"unchecked"}const E=v,C=(0,c.forwardRef)(((e,t)=>{const{__scopeSwitch:a,...r}=e,s=k("SwitchThumb",a);return(0,c.createElement)(p.sG.span,(0,n.A)({"data-state":w(s.checked),"data-disabled":s.disabled?"":void 0},r,{ref:t}))}));var y=a(4219);const _=(0,r.memo)((({value:e,onChange:t,required:a,disabled:r,className:n,label:s,id:l})=>{const{getField:o}=(0,y.default)();let d=e;return"0"!==e&&"1"!==e||(d="1"===e),(0,c.createElement)("div",{className:"cmplz-input-group cmplz-switch-group"},(0,c.createElement)(E,{className:"cmplz-switch-root "+n,checked:d,onCheckedChange:e=>{"banner"===o(l).data_target&&(e=e?"1":"0"),t(e)},disabled:r,required:a},(0,c.createElement)(C,{className:"cmplz-switch-thumb"})))}))},85357:(e,t,a)=>{a.d(t,{Z:()=>r});var c=a(51609);function r(e){const t=(0,c.useRef)({value:e,previous:e});return(0,c.useMemo)((()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous)),[e])}}}]);