{"version":3,"file":"SpotifyThemeEmbed.CIIdWSoh.mjs","names":["useRef","useState","useCallback","useMemo","__esmMin","ne","init_npm_react_18_3_1","te","pe","window","_e","de","c","ce","init_ssg_sandbox_shims","addPropertyControls","init_framer_BpuvUAiZ","ControlType","resolveThemeValue","raw","normalized","parseSpotifyEmbedUrl","input","parsed","first","second","third","isLocaleSegment","type","id","SUPPORTED_TYPES","theme","SpotifyThemeEmbed","props","rootRef","setTheme","detectTheme","updateTheme","next","observer","scopedAncestor","mediaQuery","onMediaChange","embedSrc","url","style","radius","init_SpotifyThemeEmbed","init_jsx_runtime"],"sources":["https:/framerusercontent.com/modules/hrQ318uz6ajg5d7PqaTP/wOi677yGI44s6QFFfIMM/SpotifyThemeEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useEffect,useMemo,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const SUPPORTED_TYPES=new Set([\"episode\",\"show\",\"playlist\",\"album\",\"track\"]);function resolveThemeValue(raw){if(!raw)return null;const normalized=raw.toLowerCase().trim();if(normalized.includes(\"dark\")||normalized.includes(\"contrast\"))return\"dark\";if(normalized.includes(\"light\"))return\"light\";return null;}function parseSpotifyEmbedUrl(input,theme){if(!input)return null;try{const parsed=new URL(input);if(parsed.hostname!==\"open.spotify.com\")return null;const parts=parsed.pathname.split(\"/\").filter(Boolean);const[first,second,third]=parts;const isLocaleSegment=first?.toLowerCase().startsWith(\"intl-\");const type=isLocaleSegment?second:first;const id=isLocaleSegment?third:second;if(!type||!id||!SUPPORTED_TYPES.has(type))return null;const spotifyTheme=theme===\"dark\"?\"0\":\"1\";return`https://open.spotify.com/embed/${type}/${id}?utm_source=generator&theme=${spotifyTheme}`;}catch(_error){return null;}}/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function SpotifyThemeEmbed(props){const{url,radius,style}=props;const rootRef=useRef(null);const[theme,setTheme]=useState(\"light\");const detectTheme=useCallback(()=>{if(typeof document===\"undefined\")return\"light\";const rootTheme=resolveThemeValue(document.documentElement.getAttribute(\"data-framer-theme\"));if(rootTheme)return rootTheme;const bodyTheme=resolveThemeValue(document.body?.getAttribute(\"data-framer-theme\")??null);if(bodyTheme)return bodyTheme;const ancestor=rootRef.current?.closest(\"[data-framer-theme]\")??null;const ancestorTheme=resolveThemeValue(ancestor?.getAttribute(\"data-framer-theme\")??null);if(ancestorTheme)return ancestorTheme;if(typeof window!==\"undefined\"&&typeof window.matchMedia===\"function\"){return window.matchMedia(\"(prefers-color-scheme: dark)\").matches?\"dark\":\"light\";}return\"light\";},[]);useEffect(()=>{if(typeof document===\"undefined\")return;const updateTheme=()=>{const next=detectTheme();startTransition(()=>{setTheme(next);});};updateTheme();const observer=new MutationObserver(()=>{updateTheme();});observer.observe(document.documentElement,{attributes:true,attributeFilter:[\"data-framer-theme\"],subtree:true});if(document.body){observer.observe(document.body,{attributes:true,attributeFilter:[\"data-framer-theme\"],subtree:true});}const scopedAncestor=rootRef.current?.closest(\"[data-framer-theme]\")??null;if(scopedAncestor){observer.observe(scopedAncestor,{attributes:true,attributeFilter:[\"data-framer-theme\"],subtree:true});}let mediaQuery=null;let onMediaChange=null;const hasThemeAttribute=document.documentElement.hasAttribute(\"data-framer-theme\")||document.body?.hasAttribute(\"data-framer-theme\")||Boolean(scopedAncestor?.hasAttribute(\"data-framer-theme\"));if(!hasThemeAttribute&&typeof window!==\"undefined\"&&typeof window.matchMedia===\"function\"){mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");onMediaChange=()=>updateTheme();mediaQuery.addEventListener(\"change\",onMediaChange);}return()=>{observer.disconnect();if(mediaQuery&&onMediaChange){mediaQuery.removeEventListener(\"change\",onMediaChange);}};},[detectTheme]);const embedSrc=useMemo(()=>parseSpotifyEmbedUrl(url,theme),[url,theme]);if(!embedSrc){return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",borderRadius:radius,...style},\"aria-hidden\":true});}return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",...style},children:/*#__PURE__*/_jsx(\"iframe\",{src:embedSrc,title:\"Spotify audio player\",allow:\"autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture\",loading:\"lazy\",frameBorder:0,style:{width:\"100%\",height:\"100%\",border:0,borderRadius:radius,display:\"block\"}},embedSrc)});}SpotifyThemeEmbed.defaultProps={width:\"100%\",height:352,url:\"https://open.spotify.com/show/6EI9f0e6MRx2b0esg7CCD5\",radius:12};addPropertyControls(SpotifyThemeEmbed,{url:{type:ControlType.String,title:\"Spotify URL\",defaultValue:\"https://open.spotify.com/show/6EI9f0e6MRx2b0esg7CCD5\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:12,min:0,max:64,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SpotifyThemeEmbed\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SpotifyThemeEmbed.map"],"mappings":"A,sNAA6P,SAASkB,EAAkB,EAAI,CAAC,GAAG,CAACC,EAAI,OAAO,KAAK,IAAMC,EAAWD,EAAI,YAAY,CAAC,CAAC,KAAK,EAA6H,OAAxHC,EAAW,SAAS,MAAM,GAAGA,EAAW,SAAS,UAAU,EAAQ,OAAUA,EAAW,SAAS,OAAO,EAAQ,QAAe,IAAK,CAAC,SAASC,EAAqB,EAAM,EAAM,CAAC,GAAG,CAACC,EAAM,OAAO,KAAK,GAAG,CAAC,IAAMC,EAAO,IAAI,IAAID,CAAK,EAAE,GAAGC,EAAO,WAAW,mBAAmB,OAAO,KAA4D,GAAK,CAACC,EAAMC,EAAOC,GAA9DH,EAAO,SAAS,MAAM,GAAG,CAAC,CAAC,OAAO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