{"version":3,"file":"SelectAll.Dql2oLRk.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/3u3IyRpFoi60EIcSPuim/l29FWRgM6OKlUkjePFVx/SelectAll.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";// Applied to the \"전체 동의\" checkbox. Two-way sync:\n//  - toggling 전체 동의 sets every other checkbox to the same state\n//  - toggling any individual box re-checks 전체 동의 only when all are checked\nexport function withSelectAll(Component){return props=>{const ref=useRef(null);useEffect(()=>{const root=ref.current;if(!root)return;const master=root.querySelector('input[type=\"checkbox\"]');if(!master)return;const scope=master.closest(\"form\")||document;const others=()=>Array.from(scope.querySelectorAll('input[type=\"checkbox\"]')).filter(el=>el!==master);let programmatic=false;const setChecked=(el,val)=>{if(el.checked===val)return;el.checked=val;programmatic=true;el.dispatchEvent(new Event(\"input\",{bubbles:true}));el.dispatchEvent(new Event(\"change\",{bubbles:true}));programmatic=false;};const onMaster=()=>{if(programmatic)return;others().forEach(el=>setChecked(el,master.checked));};const onOther=()=>{if(programmatic)return;const all=others().every(el=>el.checked);setChecked(master,all);};master.addEventListener(\"change\",onMaster);const os=others();os.forEach(el=>el.addEventListener(\"change\",onOther));return()=>{master.removeEventListener(\"change\",onMaster);os.forEach(el=>el.removeEventListener(\"change\",onOther));};},[]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withSelectAll\":{\"type\":\"reactHoc\",\"name\":\"withSelectAll\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SelectAll.map"],"mappings":"yHAGA,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAIA,EAAO,IAAI,EAA87B,OAA57B,MAAc,CAAC,IAAM,EAAK,EAAI,QAAQ,GAAG,CAAC,EAAK,O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