{"version":3,"file":"ThemeSwitch.DGbUNPKJ.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/fqun8jd4zJkmoIEPxBqW/bSuMInEBQT7E74zFVPxG/ThemeSwitch.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,startTransition,useCallback,useEffect,useRef,useState}from\"react\";const STORAGE_KEY=\"currentToggleState\";const THEME_OVERRIDE_STYLE_ID=\"framer-theme-token-override\";const TOKEN_VALUES={\"4795dafb-4261-43d3-aa0c-b3831681376e\":{light:\"rgb(255, 255, 255)\",dark:\"rgb(26, 26, 27)\"},\"a9f688eb-778b-4a71-929e-ebf8a014b4cf\":{light:\"rgb(48, 48, 48)\",dark:\"rgb(255, 255, 255)\"},\"54672876-03f0-4dca-8fdb-32c421a5c4d1\":{light:\"rgb(94, 103, 230)\",dark:\"rgb(208, 255, 113)\"},\"861b2ae9-dee3-4143-a255-6faa9a39d943\":{light:\"rgb(255, 255, 255)\",dark:\"rgb(48, 48, 48)\"},\"7d1fd828-621c-47fc-b270-6f2c2fff9ca2\":{light:\"rgb(143, 143, 143)\",dark:\"rgb(181, 181, 181)\"},\"621c2752-e263-492f-8440-f4105a55d3f1\":{light:\"rgb(218, 218, 218)\",dark:\"rgb(15, 15, 15)\"},\"63c1aa9b-b60d-46e8-b1c7-6d9c05a923bd\":{light:\"rgb(255, 34, 68)\",dark:\"rgb(255, 34, 68)\"},\"ffb0ff11-cab3-40ad-af6c-69f4ede46c1e\":{light:\"rgb(0, 0, 0)\",dark:\"rgb(0, 0, 0)\"},\"39a5a1be-d79a-43ee-a7a4-d32ef142beed\":{light:\"rgb(255, 255, 255)\",dark:\"rgb(255, 255, 255)\"},\"dd08076e-6859-4f97-84b7-c05dcc1e773f\":{light:\"rgba(255, 255, 255, 0.9)\",dark:\"rgba(15, 15, 15, 0.9)\"},\"cb6b9558-1df0-4f97-98cb-2fe80cc3b90c\":{light:\"rgb(245, 245, 245)\",dark:\"rgb(51, 51, 51)\"}};const getUserPreferredTheme=()=>{if(typeof window!==\"undefined\"){return window.matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";}return\"light\";};const readStoredTheme=()=>{if(typeof window===\"undefined\")return null;try{const saved=window.localStorage.getItem(STORAGE_KEY)||window.sessionStorage.getItem(STORAGE_KEY);return saved===\"dark\"||saved===\"light\"?saved:null;}catch(_error){return null;}};const persistTheme=theme=>{if(typeof window===\"undefined\")return;try{window.localStorage.setItem(STORAGE_KEY,theme);window.sessionStorage.setItem(STORAGE_KEY,theme);}catch(_error){// No-op (storage might be blocked)\n}};const applyThemeToDocument=theme=>{if(typeof document===\"undefined\")return;const root=document.documentElement;const body=document.body;root.setAttribute(\"data-theme\",theme);root.classList.toggle(\"dark\",theme===\"dark\");root.classList.toggle(\"light\",theme===\"light\");root.style.colorScheme=theme;if(body){body.setAttribute(\"data-theme\",theme);body.classList.toggle(\"dark\",theme===\"dark\");body.classList.toggle(\"light\",theme===\"light\");body.style.colorScheme=theme;}};const mediaConditionToTheme=conditionText=>{const condition=conditionText.toLowerCase();if(!condition.includes(\"prefers-color-scheme\"))return null;if(condition.includes(\"dark\"))return\"dark\";if(condition.includes(\"light\"))return\"light\";return null;};const collectThemeMediaRules=(styleSheet,theme,output)=>{let cssRules;try{cssRules=styleSheet.cssRules;}catch(_error){return;}for(const rule of Array.from(cssRules)){if(rule instanceof CSSImportRule&&rule.styleSheet){collectThemeMediaRules(rule.styleSheet,theme,output);continue;}if(rule instanceof CSSMediaRule){const ruleTheme=mediaConditionToTheme(rule.conditionText);if(ruleTheme!==theme)continue;const nestedRules=Array.from(rule.cssRules).map(nestedRule=>nestedRule.cssText).join(\"\\n\");if(nestedRules.trim().length>0)output.push(nestedRules);}}};const applyTokenThemeOverride=theme=>{if(typeof document===\"undefined\")return;const root=document.documentElement;const body=document.body;const cssVariableLines=[];for(const[tokenId,values]of Object.entries(TOKEN_VALUES)){const value=values[theme];const tokenVarName=`--token-${tokenId}`;root.style.setProperty(tokenVarName,value,\"important\");if(body)body.style.setProperty(tokenVarName,value,\"important\");cssVariableLines.push(`  ${tokenVarName}: ${value} !important;`);}let styleTag=document.getElementById(THEME_OVERRIDE_STYLE_ID);if(!styleTag){styleTag=document.createElement(\"style\");styleTag.id=THEME_OVERRIDE_STYLE_ID;styleTag.type=\"text/css\";document.head.appendChild(styleTag);}const collected=[];const styleSheets=Array.from(document.styleSheets);for(const styleSheet of styleSheets){collectThemeMediaRules(styleSheet,theme,collected);}styleTag.setAttribute(\"data-theme\",theme);styleTag.textContent=`/* Framer forced token theme: ${theme} */\n:root,\nbody {\n${cssVariableLines.join(\"\\n\")}\n}\n${collected.join(\"\\n\")}`;};export function themeSwitcher(Component){return /*#__PURE__*/forwardRef(function ThemeSwitcherOverride(props,ref){const[theme,setTheme]=useState(()=>{return readStoredTheme()||getUserPreferredTheme();});const lastTapTimeRef=useRef(0);const toggle=useCallback(()=>{const newTheme=theme===\"light\"?\"dark\":\"light\";startTransition(()=>setTheme(newTheme));applyThemeToDocument(newTheme);applyTokenThemeOverride(newTheme);persistTheme(newTheme);if(typeof window!==\"undefined\"){window.dispatchEvent(new CustomEvent(\"themeChange\",{detail:newTheme}));}},[theme]);useEffect(()=>{applyThemeToDocument(theme);applyTokenThemeOverride(theme);persistTheme(theme);},[theme]);const handleTap=useCallback(event=>{lastTapTimeRef.current=Date.now();toggle();if(typeof props.onTap===\"function\")props.onTap(event);},[props,toggle]);const handleClick=useCallback(event=>{if(Date.now()-lastTapTimeRef.current>250){toggle();}if(typeof props.onClick===\"function\")props.onClick(event);},[props,toggle]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onTap:handleTap,onClick:handleClick});});}export function variantSwitcher(Component){return /*#__PURE__*/forwardRef(function VariantSwitcherOverride(props,ref){const[isLoading,setIsLoading]=useState(true);const[currentToggleState,setCurrentToggleState]=useState(null);useEffect(()=>{const initialTheme=readStoredTheme()||getUserPreferredTheme();startTransition(()=>{setCurrentToggleState(initialTheme);setIsLoading(false);});},[]);useEffect(()=>{if(typeof window===\"undefined\")return;const handleThemeChange=event=>{const detail=event.detail;if(detail===\"light\"||detail===\"dark\"){startTransition(()=>setCurrentToggleState(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,{ref:ref,...props,variant:currentToggleState===\"dark\"?\"Dark\":\"Light\"})});});}export function scrollToTopOnProjectLoad(Component){return /*#__PURE__*/forwardRef(function ScrollToTopOnProjectLoadOverride(props,ref){useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\"){return;}if(\"scrollRestoration\"in window.history){window.history.scrollRestoration=\"manual\";}const forceTop=()=>{window.scrollTo(0,0);if(document.documentElement){document.documentElement.scrollTop=0;}if(document.body){document.body.scrollTop=0;}};forceTop();const rafId=window.requestAnimationFrame(()=>{forceTop();});const timeoutId=window.setTimeout(()=>{forceTop();},80);return()=>{window.cancelAnimationFrame(rafId);window.clearTimeout(timeoutId);};},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}export function goBackOrProjects(Component){return /*#__PURE__*/forwardRef(function GoBackOrProjectsOverride(props,ref){const lastTapTimeRef=useRef(0);const navigateBackOrProjects=useCallback(()=>{if(typeof window===\"undefined\")return;if(window.history.length>1){window.history.back();}else{window.location.href=\"/projects\";}},[]);const preventDefaultIfPossible=event=>{if(event&&typeof event.preventDefault===\"function\"){event.preventDefault();}if(event&&typeof event.stopPropagation===\"function\"){event.stopPropagation();}};const handleTap=useCallback(event=>{lastTapTimeRef.current=Date.now();preventDefaultIfPossible(event);navigateBackOrProjects();if(typeof props.onTap===\"function\")props.onTap(event);},[navigateBackOrProjects,props]);const handleClick=useCallback(event=>{preventDefaultIfPossible(event);if(Date.now()-lastTapTimeRef.current>250){navigateBackOrProjects();}if(typeof props.onClick===\"function\")props.onClick(event);},[navigateBackOrProjects,props]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onTap:handleTap,onClick:handleClick});});}\nexport const __FramerMetadata__ = {\"exports\":{\"variantSwitcher\":{\"type\":\"reactHoc\",\"name\":\"variantSwitcher\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"scrollToTopOnProjectLoad\":{\"type\":\"reactHoc\",\"name\":\"scrollToTopOnProjectLoad\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"goBackOrProjects\":{\"type\":\"reactHoc\",\"name\":\"goBackOrProjects\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"themeSwitcher\":{\"type\":\"reactHoc\",\"name\":\"themeSwitcher\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ThemeSwitch.map"],"mappings":"8JAM2B,SAAgB,EAAc,EAAU,CAAC,OAAoB,EAAW,SAA+B,EAAM,EAAI,CAAC,GAAK,CAAC,EAAM,GAAUA,MAAqB,EAAgB,GAAG,EAAsB,CAAG,EAAQ,EAAeC,EAAO,CAAC,EAAQ,EAAOC,MAAgB,CAAC,IAAM,EAAS,IAAQ,QAAQ,OAAO,QAAQ,MAAoB,EAAS,CAAQ,CAAC,EAAE,EAAqB,CAAQ,EAAE,EAAwB,CAAQ,EAAE,EAAa,CAAQ,EAAY,IAAS,QAAa,EAAO,cAAc,IAAI,YAAY,cAAc,CAAC,OAAO,CAAQ,CAAC,CAAC,CAAG,EAAE,CAAC,CAAK,CAAC,EAAE,MAAc,CAAC,EAAqB,CAAK,EAAE,EAAwB,CAAK,EAAE,EAAa,CAAK,CAAE,EAAE,CAAC,CAAK,CAAC,EAAE,IAAM,EAAUA,EAAY,GAAO,CAAC,EAAe,QAAQ,KAAK,IAAI,EAAE,EAAO,EAAK,OAAO,EAAM,OAAQ,YAAW,EAAM,MAAM,CAAK,CAAE,EAAE,CAAC,EAAM,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