{"version":3,"file":"ThemeVariants.Bp7g0jyy.mjs","names":["mediaQuery"],"sources":["https:/framerusercontent.com/modules/57wf7vVSsscumOXz4NV8/kLLe9w97bPfPTwFHjkRV/ThemeVariants.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect,cloneElement}from\"react\";import{EmptyState}from\"https://framerusercontent.com/modules/n9cR4gFLy0DjoxfkLrIe/eDj1MxSfupkYrrIeXQ6b/Shared.js\";const THEME_ATTRIBUTE=\"framestack-theme\";const SIGNAL_NAME=\"framestack-theme-changed\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function ThemeVariants(props){var _props_light,_props_dark,_props_dark1,_props_light1,_props_style,_props_style1;const[isDarkTheme,setIsDarkTheme]=useState(null);useEffect(()=>{const updateTheme=()=>{// For compatibility with the Theme Toggle component.\n// https://Framestack.co/components/theme-toggle\n// If the site does not have a theme toggle, the device theme will be used.\nconst currentToggleState=document.body.getAttribute(THEME_ATTRIBUTE);// Check if page has the theme toggle attribute.\nif(!currentToggleState||currentToggleState==\"deviceTheme\"){if(document.body.hasAttribute(\"data-framer-theme\")){setIsDarkTheme(document.body.getAttribute(\"data-framer-theme\")==\"dark\");}else{const mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");setIsDarkTheme(mediaQuery.matches);}}else{// Use device theme\nsetIsDarkTheme(currentToggleState==\"dark\")// light or dark\n;}};// Event listener for changes in the device theme\nconst osThemeChange=e=>{setIsDarkTheme(e.matches);};// Update the theme when the page loads\nupdateTheme();// Listen for theme changes made by the theme toggle component\nwindow.addEventListener(SIGNAL_NAME,updateTheme);// Listen for changes in the device theme\nconst mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");mediaQuery.addListener(osThemeChange);// Clean up the event listeners when the theme toggle component unmounts\nreturn()=>{window.removeEventListener(SIGNAL_NAME,updateTheme);mediaQuery.removeListener(osThemeChange);};},[]);// Before the theme has been determined, render nothing.\n// This prevents flashing while the page loads.\nif(isDarkTheme===null){return null;}// Empty state\nif(!((_props_light=props.light)===null||_props_light===void 0?void 0:_props_light[0])||!((_props_dark=props.dark)===null||_props_dark===void 0?void 0:_props_dark[0])){return /*#__PURE__*/_jsx(EmptyState,{title:\"Add dark and light layers.\",subtitle:\"Use the properties panel on the right side to connect layers for dark and light theme.\"});}let layer=isDarkTheme?(_props_dark1=props.dark)===null||_props_dark1===void 0?void 0:_props_dark1[0]:(_props_light1=props.light)===null||_props_light1===void 0?void 0:_props_light1[0];if(layer&&(((_props_style=props.style)===null||_props_style===void 0?void 0:_props_style.width)||((_props_style1=props.style)===null||_props_style1===void 0?void 0:_props_style1.height))){layer=/*#__PURE__*/cloneElement(layer,{style:{...layer.props.style,...props.style}});}if(!layer){return /*#__PURE__*/_jsx(\"div\",{style:{minWidth:100,minHeight:100}});}return layer;}ThemeVariants.displayName=\"Theme Variants\";addPropertyControls(ThemeVariants,{light:{type:ControlType.ComponentInstance,title:\"Light\"},dark:{type:ControlType.ComponentInstance,title:\"Dark\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ThemeVariants\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"6XAGG,SAAwB,EAAc,EAAM,CAAC,IAAI,EAAa,EAAY,EAAa,EAAc,EAAa,EAAc,GAAK,CAAC,EAAY,EAAe,CAAC,EAAS,KAAK,CAanL,GAboL,EAAU,IAAI,CAAC,IAAM,EAAY,IAAI,CAGzN,IAAM,EAAmB,SAAS,KAAK,aAAa,EAAgB,CACpE,IAAI,GAAoB,GAAoB,cAAe,GAAG,SAAS,KAAK,aAAa,oBAAoB,CAAE,EAAe,SAAS,KAAK,aAAa,oBAAoB,EAAE,OAAO,KAAM,CAAC,IAAMA,EAAW,EAA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