{"version":3,"file":"DynamicThemeImage.6On37vUT.mjs","names":["useState","__esmMin","init_npm_react_18_3_1","te","window","init_ssg_sandbox_shims","ce","init_jsx_runtime","_e","addPropertyControls","init_framer_BpuvUAiZ","ControlType","DynamicThemeImage","props","defaultImage","hasLightImage","lightImage","hasDarkImage","darkImage","effectiveLightSrc","effectiveDarkSrc","effectiveLightSrcSet","effectiveDarkSrcSet","imageAlt","alt","currentTheme","setCurrentTheme","detectTheme","htmlElement","bodyElement","htmlTheme","bodyTheme","storedTheme","prefersDark","handleThemeChange","handleStorageChange","e","mediaQuery","handleMediaChange","init_DynamicThemeImage"],"sources":["https:/framerusercontent.com/modules/QMXZ0PwkgEAx86FDeasB/TGpcZaCSBk3sJUeJdy9h/DynamicThemeImage.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useState,startTransition}from\"react\";/**\n * Dynamic Theme Image\n *\n * A component that displays different images based on the user's color scheme preference.\n * Works with both system theme and custom theme toggles (like Framestack Theme Toggle).\n * Uses semantic HTML for SEO optimization with JavaScript-based theme detection.\n *\n * Features:\n * - Fully crawlable by search engines (uses semantic <img> tag with alt text)\n * - Supports system theme via prefers-color-scheme media query\n * - Supports custom theme toggles via data attributes and events\n * - Listens for \"themeChange\" events from toggle components\n * - Optimal performance with lazy loading and async decoding options\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */// @framerDisableUnlink\nexport default function DynamicThemeImage(props){const{lightImage,darkImage,alt=\"\",loading=\"lazy\",decoding=\"async\",objectFit=\"cover\"}=props;// Default image to use when neither light nor dark is provided\nconst defaultImage=\"https://framerusercontent.com/images/Bnqo3uyTwLsA8j4q5Pb5wCD6NE.png\";// Check if images are actually provided (not undefined/empty)\nconst hasLightImage=lightImage?.src&&lightImage.src.trim()!==\"\";const hasDarkImage=darkImage?.src&&darkImage.src.trim()!==\"\";// Determine effective sources with fallback logic:\n// 1. If theme is dark and dark image exists, use dark\n// 2. If theme is light and light image exists, use light\n// 3. If only one image exists, use it for both themes\n// 4. If neither exists, use default\nconst effectiveLightSrc=hasLightImage?lightImage.src:hasDarkImage?darkImage.src:defaultImage;const effectiveDarkSrc=hasDarkImage?darkImage.src:hasLightImage?lightImage.src:defaultImage;const effectiveLightSrcSet=hasLightImage?lightImage?.srcSet:hasDarkImage?darkImage?.srcSet:undefined;const effectiveDarkSrcSet=hasDarkImage?darkImage?.srcSet:hasLightImage?lightImage?.srcSet:undefined;// Use provided alt or fall back to image alts\nconst imageAlt=alt||(hasLightImage?lightImage?.alt:hasDarkImage?darkImage?.alt:\"\")||\"\";// State to track current theme\nconst[currentTheme,setCurrentTheme]=useState(\"light\");useEffect(()=>{// Function to determine current theme\nconst detectTheme=()=>{// Check for custom toggle theme first\nif(typeof document!==\"undefined\"){const htmlElement=document.getElementsByTagName(\"html\")[0];const bodyElement=document.getElementsByTagName(\"body\")[0];const htmlTheme=htmlElement?.getAttribute(\"toggle-theme\");const bodyTheme=bodyElement?.getAttribute(\"toggle-theme\");// Use toggle-theme attribute if set to light or dark\nif(htmlTheme===\"dark\"||bodyTheme===\"dark\"){startTransition(()=>setCurrentTheme(\"dark\"));return;}else if(htmlTheme===\"light\"||bodyTheme===\"light\"){startTransition(()=>setCurrentTheme(\"light\"));return;}// Check localStorage as fallback\ntry{const storedTheme=localStorage.getItem(\"theme\");if(storedTheme===\"dark\"){startTransition(()=>setCurrentTheme(\"dark\"));return;}else if(storedTheme===\"light\"){startTransition(()=>setCurrentTheme(\"light\"));return;}}catch(e){// localStorage not available\n}}// Fall back to system preference\nif(typeof window!==\"undefined\"){const prefersDark=window.matchMedia(\"(prefers-color-scheme: dark)\").matches;startTransition(()=>setCurrentTheme(prefersDark?\"dark\":\"light\"));}};// Detect initial theme\ndetectTheme();// Listen for theme change events from toggle component\nconst handleThemeChange=()=>{detectTheme();};// Listen for storage events (in case theme changes in another tab)\nconst handleStorageChange=e=>{if(e.key===\"theme\"){detectTheme();}};// Listen for system theme changes\nconst mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");const handleMediaChange=e=>{// Only apply system theme if no custom theme is set\nconst htmlElement=document.getElementsByTagName(\"html\")[0];const bodyElement=document.getElementsByTagName(\"body\")[0];const htmlTheme=htmlElement?.getAttribute(\"toggle-theme\");const bodyTheme=bodyElement?.getAttribute(\"toggle-theme\");if(!htmlTheme&&!bodyTheme){startTransition(()=>setCurrentTheme(e.matches?\"dark\":\"light\"));}};window.addEventListener(\"themeChange\",handleThemeChange);window.addEventListener(\"storage\",handleStorageChange);mediaQuery.addEventListener(\"change\",handleMediaChange);return()=>{window.removeEventListener(\"themeChange\",handleThemeChange);window.removeEventListener(\"storage\",handleStorageChange);mediaQuery.removeEventListener(\"change\",handleMediaChange);};},[]);// Determine current image source based on theme and available images\nconst currentSrc=currentTheme===\"dark\"?effectiveDarkSrc:effectiveLightSrc;const currentSrcSet=currentTheme===\"dark\"?effectiveDarkSrcSet:effectiveLightSrcSet;return /*#__PURE__*/_jsx(\"img\",{src:currentSrc,srcSet:currentSrcSet,alt:imageAlt,loading:loading,decoding:decoding,style:{width:\"100%\",height:\"100%\",objectFit,display:\"block\",...props.style}});}addPropertyControls(DynamicThemeImage,{lightImage:{type:ControlType.ResponsiveImage,title:\"Light Mode Image\"},darkImage:{type:ControlType.ResponsiveImage,title:\"Dark Mode Image\"},alt:{type:ControlType.String,title:\"Alt Text\",description:\"Descriptive text for screen readers and SEO\",defaultValue:\"\",placeholder:\"Describe the image...\"},loading:{type:ControlType.Enum,title:\"Loading\",description:\"eager = load immediately, lazy = load when visible\",options:[\"eager\",\"lazy\"],optionTitles:[\"Eager\",\"Lazy\"],defaultValue:\"lazy\",displaySegmentedControl:true},decoding:{type:ControlType.Enum,title:\"Decoding\",description:\"async = decode off main thread for better performance\",options:[\"async\",\"sync\",\"auto\"],optionTitles:[\"Async\",\"Sync\",\"Auto\"],defaultValue:\"async\",displaySegmentedControl:true},objectFit:{type:ControlType.Enum,title:\"Object Fit\",description:\"How the image should fill its container\",options:[\"contain\",\"cover\",\"fill\",\"none\",\"scale-down\"],optionTitles:[\"Contain\",\"Cover\",\"Fill\",\"None\",\"Scale Down\"],defaultValue:\"cover\"}});DynamicThemeImage.displayName=\"Dynamic Theme Image\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DynamicThemeImage\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DynamicThemeImage.map"],"mappings":"A,iMAiBA,SAAwBY,EAAkB,EAAM,CAAC,GAAK,CAAC,aAAW,YAAU,MAAI,GAAG,UAAQ,OAAO,WAAS,QAAQ,YAAU,SAASC,EAChIC,EAAa,sEACbC,EAAcC,GAAY,KAAKA,EAAW,IAAI,KAAK,IAAI,GAASC,EAAaC,GAAW,KAAKA,EAAU,IAAI,KAAK,IAAI,GAKpHC,EAAkBJ,EAAcC,EAAW,IAAIC,EAAaC,EAAU,IAAIJ,EAAmBM,EAAiBH,EAAaC,EAAU,IAAIH,EAAcC,EAAW,IAAIF,EAAmBO,EAAqBN,EAAcC,GAAY,OAAOC,EAAaC,GAAW,OAAO,IAAA,GAAgBI,EAAoBL,EAAaC,GAAW,OAAOH,EAAcC,GAAY,OAAO,IAAA,GAClXO,EAASC,IAAMT,EAAcC,GAAY,IAAIC,EAAaC,GAAW,IAAI,KAAK,GAC/E,CAACO,EAAaC,GAAiB1B,EAAS,OAAO,EAYyG,OAZvGM,MAAc,CACpE,IAAMqB,MAAgB,CACtB,GAAG,OAAO,SAAW,IAAY,CAAC,IAAMC,EAAY,SAAS,qBAAqB,MAAM,CAAC,CAAC,GAASC,EAAY,SAAS,qBAAqB,MAAM,CAAC,CAAC,GAASC,EAA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