{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/jS3tHhNtXRKzQkREUlrf/dxkCMDAVAX0FvVj5w5BJ/Switch_1.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{Frame,addPropertyControls,ControlType}from\"framer\";function getStoredTheme(){return localStorage.getItem(\"currentToggleState\");}function SystemThemeDetector({onThemeDetected}){const[systemTheme,setSystemTheme]=React.useState(null);const[errorMessage,setErrorMessage]=React.useState(null);React.useEffect(()=>{const darkModeMediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");const handleThemeChange=e=>{const theme=e.matches?\"dark\":\"light\";setSystemTheme(theme);setErrorMessage(null);onThemeDetected(theme);};try{if(darkModeMediaQuery.media===\"not all\"){setErrorMessage(\"System theme detection not supported\");onThemeDetected(null);}else{handleThemeChange(darkModeMediaQuery);darkModeMediaQuery.addListener(handleThemeChange);}}catch(error){setErrorMessage(\"Error detecting system theme\");onThemeDetected(null);}return()=>{darkModeMediaQuery.removeListener(handleThemeChange);};},[onThemeDetected]);return null;}export function ThemeSwitch({backgroundColor,iconColor,switchSize,circleColor}){const[isOn,setIsOn]=React.useState(false);const[isThemeSet,setIsThemeSet]=React.useState(false);const[systemTheme,setSystemTheme]=React.useState(null);const toggle=()=>{const newToggleState=isOn?\"dark\":\"light\";setIsOn(!isOn);localStorage.setItem(\"currentToggleState\",newToggleState);updateTheme(newToggleState);};const updateTheme=theme=>{if(typeof document!==\"undefined\"){const styleTag=document.getElementsByTagName(\"style\")[0];const newCSS=styleTag.innerHTML.replace(/prefers-color-scheme: \\w+/,`prefers-color-scheme: ${theme}`);styleTag.innerHTML=newCSS;}window.dispatchEvent(new CustomEvent(\"themeChange\"));};const handleSystemThemeChange=theme=>{setSystemTheme(theme);if(!isThemeSet){setIsOn(theme===\"light\");updateTheme(theme);setIsThemeSet(true);}};React.useEffect(()=>{const storedTheme=getStoredTheme();if(storedTheme){setIsOn(storedTheme===\"light\");updateTheme(storedTheme);setIsThemeSet(true);}else{handleSystemThemeChange(null);}},[]);const circleSize=switchSize/2-switchSize/8;const iconSize=circleSize;return /*#__PURE__*/_jsx(Frame,{width:switchSize,height:switchSize/2,background:backgroundColor,style:{borderRadius:switchSize/4,cursor:\"pointer\",position:\"relative\",display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",padding:`0 ${switchSize/8}px`},onClick:toggle,children:isThemeSet&&/*#__PURE__*/_jsx(Frame,{width:circleSize,height:circleSize,background:circleColor,style:{borderRadius:\"50%\",position:\"absolute\",left:isOn?`calc(100% - ${circleSize+switchSize/16}px)`:`${switchSize/16}px`,transition:\"left 0.2s\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},initial:false,animate:{left:isOn?`calc(100% - ${circleSize+switchSize/16}px)`:`${switchSize/16}px`},children:/*#__PURE__*/_jsx(Frame,{width:iconSize,height:iconSize,background:\"transparent\",style:{overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",viewBox:\"0 0 24 24\",fill:iconColor,width:iconSize,height:iconSize})})})});}ThemeSwitch.defaultProps={backgroundColor:\"#e0e0e0\",iconColor:\"#000000\",switchSize:60,circleColor:\"#ffffff\"};addPropertyControls(ThemeSwitch,{backgroundColor:{title:\"Background Color\",type:ControlType.Color,defaultValue:\"#e0e0e0\"},switchSize:{title:\"Switch Size\",type:ControlType.Number,defaultValue:60,min:20,max:200,step:1},circleColor:{title:\"Circle Color\",type:ControlType.Color,defaultValue:\"#ffffff\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"ThemeSwitch\":{\"type\":\"reactComponent\",\"name\":\"ThemeSwitch\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Switch_1.map"],
  "mappings": "uJAAiI,SAASA,GAAgB,CAAC,OAAO,aAAa,QAAQ,oBAAoB,CAAE,CAAiyB,SAASC,EAAY,CAAC,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MAAM,CAAC,aAAa,MAAM,SAAS,WAAW,KAAKC,EAAK,eAAekB,EAAWpB,EAAW,EAAE,MAAM,GAAGA,EAAW,EAAE,KAAK,WAAW,YAAY,QAAQ,OAAO,WAAW,SAAS,eAAe,QAAQ,EAAE,QAAQ,GAAM,QAAQ,CAAC,KAAKE,EAAK,eAAekB,EAAWpB,EAAW,EAAE,MAAM,GAAGA,EAAW,EAAE,IAAI,EAAE,SAAsBsB,EAAKC,EAAM,CAAC,MAAMF,EAAS,OAAOA,EAAS,WAAW,cAAc,MAAM,CAAC,SAAS,QAAQ,EAAE,SAAsBC,EAAK,MAAM,CAAC,MAAM,6BAA6B,QAAQ,YAAY,KAAKvB,EAAU,MAAMsB,EAAS,OAAOA,CAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAACxB,EAAY,aAAa,CAAC,gBAAgB,UAAU,UAAU,UAAU,WAAW,GAAG,YAAY,SAAS,EAAE2B,EAAoB3B,EAAY,CAAC,gBAAgB,CAAC,MAAM,mBAAmB,KAAK4B,EAAY,MAAM,aAAa,SAAS,EAAE,WAAW,CAAC,MAAM,cAAc,KAAKA,EAAY,OAAO,aAAa,GAAG,IAAI,GAAG,IAAI,IAAI,KAAK,CAAC,EAAE,YAAY,CAAC,MAAM,eAAe,KAAKA,EAAY,MAAM,aAAa,SAAS,CAAC,CAAC",
  "names": ["getStoredTheme", "ThemeSwitch", "backgroundColor", "iconColor", "switchSize", "circleColor", "isOn", "setIsOn", "ye", "isThemeSet", "setIsThemeSet", "systemTheme", "setSystemTheme", "toggle", "newToggleState", "updateTheme", "theme", "styleTag", "newCSS", "window", "handleSystemThemeChange", "ue", "storedTheme", "getStoredTheme", "circleSize", "iconSize", "p", "Frame", "addPropertyControls", "ControlType"]
}
