{"version":3,"file":"Switch.C3dCD8ms.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/q6JsC6GlJqcMKEEE0AH5/ph4BOGT1ugz3udbOuxJR/Switch.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";// Get the user's preferred theme\nconst getUserPreferredTheme=()=>{if(typeof window!==\"undefined\"){return window.matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";}return\"dark\";};export function themeSwitcher(Component){return props=>{const[theme,setTheme]=useState(()=>{if(typeof window!==\"undefined\"){return sessionStorage.getItem(\"currentToggleState\")||getUserPreferredTheme();}return\"dark\";});const toggle=()=>{const newTheme=theme===\"light\"?\"dark\":\"light\";setTheme(newTheme);if(typeof window!==\"undefined\"){sessionStorage.setItem(\"currentToggleState\",newTheme);window.dispatchEvent(new CustomEvent(\"themeChange\",{detail:newTheme}));}};useEffect(()=>{if(typeof document!==\"undefined\"){const styleSheets=Array.from(document.styleSheets);styleSheets.forEach(styleSheet=>{try{const cssRules=Array.from(styleSheet.cssRules);cssRules.forEach((rule,index)=>{if(rule instanceof CSSMediaRule&&rule.conditionText.includes(\"prefers-color-scheme\")){const newRule=`@media (prefers-color-scheme: ${getUserPreferredTheme()===\"light\"?theme===\"dark\"?\"light\":\"dark\":theme}) { ${rule.cssText.replace(/^@media[^{]+{|}$/g,\"\")} }`;styleSheet.deleteRule(index);styleSheet.insertRule(newRule,index);}});}catch(e){console.warn(e.message);}});}},[theme]);return /*#__PURE__*/_jsx(Component,{...props,onClick:toggle});};}export function variantSwitcher(Component){return props=>{const[isLoading,setIsLoading]=useState(true);const[currentToggleState,setCurrentToggleState]=useState(null);useEffect(()=>{if(typeof window!==\"undefined\"){const initialTheme=sessionStorage.getItem(\"currentToggleState\")||getUserPreferredTheme();setCurrentToggleState(initialTheme);setIsLoading(false);}},[]);useEffect(()=>{const handleThemeChange=event=>{setCurrentToggleState(event.detail);};window.addEventListener(\"themeChange\",handleThemeChange);return()=>window.removeEventListener(\"themeChange\",handleThemeChange);},[]);//Opacity based component transition for preventing race condition.\nreturn /*#__PURE__*/_jsx(\"div\",{className:\"transition-opacity duration-200\",style:{opacity:isLoading||currentToggleState===null?0:1},children:/*#__PURE__*/_jsx(Component,{...props,variant:currentToggleState===\"dark\"?\"Dark\":\"Light\"})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"variantSwitcher\":{\"type\":\"reactHoc\",\"name\":\"variantSwitcher\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"themeSwitcher\":{\"type\":\"reactHoc\",\"name\":\"themeSwitcher\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Switch.map"],"mappings":"uIACiK,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAM,GAAUA,MAAwB,IAAS,OAAiG,OAA7E,eAAe,QAAQ,qBAAqB,EAAE,GAAuB,CAAiB,CAAO,MAAW,CAAC,IAAM,EAAS,IAAQ,QAAQ,OAAO,QAAQ,EAAS,EAAS,CAAW,IAAS,SAAa,eAAe,QAAQ,qBAAqB,EAAS,CAAC,EAAO,cAAc,IAAI,YAAY,cAAc,CAAC,OAAO,EAAS,CAAC,CAAC,GAAslB,OAAllB,MAAc,CAAI,OAAO,SAAW,KAA+B,MAAM,KAAK,SAAS,YAAY,CAAa,QAAQ,GAAY,CAAC,GAAG,CAAgB,MAAM,KAAK,EAAW,SAAS,CAAU,SAAS,EAAK,IAAQ,CAAC,GAAG,aAAgB,cAAc,EAAK,cAAc,SAAS,uBAAuB,CAAC,CAAC,IAAM,EAAQ,iCAAiC,GAAuB,GAAG,QAAQ,IAAQ,OAAO,QAAQ,OAAO,EAAM,MAAM,EAAK,QAAQ,QAAQ,oBAAoB,GAAG,CAAC,IAAI,EAAW,WAAW,EAAM,CAAC,EAAW,WAAW,EAAQ,EAAM,GAAI,OAAQ,EAAE,CAAC,QAAQ,KAAK,EAAE,QAAQ,GAAI,EAAI,CAAC,EAAM,CAAC,CAAqB,EAAK,EAAU,CAAC,GAAG,EAAM,QAAQ,EAAO,CAAC,yBADltC,IAAsC,CAC3E,MAAqC,IAAS,QAAoB,EAAO,WAAW,+BAA+B,CAAC,QAA8B,OAAf"}