import{o as e}from"./rolldown-runtime-Bhmf7a9N.js";import{KM as t}from"./lucide-7srpeIMw.js";var n=e(t(),1),r=`https://open.spotify.com`,i=/open\.spotify\.com\/(\w+)\/(\w+)/i,a=`https://open.spotify.com/embed-podcast/iframe-api/v1`,o=`SpotifyIframeApi`,s=`onSpotifyIframeApiReady`;function c(e,t={}){return`
    <style>
      :host {
        display: inline-block;
        min-width: 160px;
        min-height: 80px;
        position: relative;
      }
      iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
      }
      :host(:not([controls])) {
        display: none !important;
      }
    </style>
    <iframe${d({src:l(e,t),scrolling:`no`,frameborder:0,width:`100%`,height:`100%`,allow:`accelerometer; fullscreen; autoplay; encrypted-media; gyroscope; picture-in-picture`})}></iframe>
  `}function l(e,t){if(!e.src)return;let n=e.src.match(i),a=n&&n[1],o=n&&n[2],s={t:t.config?.startAt,theme:t.config?.theme===`dark`?`0`:null};return`${r}/embed/${a}/${o}${t.config?.preferVideo?`/video`:``}?${f(s)}`}var u=class extends (globalThis.HTMLElement??class{}){static getTemplateHTML=c;static shadowRootOptions={mode:`open`};static observedAttributes=[`controls`,`loop`,`src`];loadComplete=new _;#loadRequested;#hasLoaded;#isInit;#isWaiting=!1;#closeToEnded=!1;#paused=!0;#currentTime=0;#duration=NaN;#seeking=!1;#config=null;constructor(){super(),this.#upgradeProperty(`config`)}async load(){if(this.#loadRequested)return;this.#hasLoaded&&(this.loadComplete=new _),this.#hasLoaded=!0,await(this.#loadRequested=Promise.resolve()),this.#loadRequested=null,this.#isWaiting=!1,this.#closeToEnded=!1,this.#currentTime=0,this.#duration=NaN,this.#seeking=!1,this.dispatchEvent(new Event(`emptied`));let e=this.api;if(this.api=null,!this.src)return;this.dispatchEvent(new Event(`loadstart`));let t={t:this.config?.startAt,theme:this.config?.theme===`dark`?`0`:null,preferVideo:this.config?.preferVideo};if(this.#isInit)this.api=e,this.api.iframeElement.src=l(m(this.attributes),this);else{this.#isInit=!0,this.shadowRoot||(this.attachShadow({mode:`open`}),this.shadowRoot.innerHTML=c(m(this.attributes),this));let e=this.shadowRoot.querySelector(`iframe`),n=await g(a,o,s);this.api=await new Promise(r=>n.createController(e,t,r)),this.api.iframeElement=e,this.api.addListener(`ready`,()=>{this.dispatchEvent(new Event(`loadedmetadata`)),this.dispatchEvent(new Event(`durationchange`)),this.dispatchEvent(new Event(`volumechange`))}),this.api.addListener(`playback_update`,e=>{if(this.#closeToEnded&&this.#paused&&(e.data.isBuffering||!e.data.isPaused)){this.#closeToEnded=!1,this.currentTime=1;return}if(e.data.duration/1e3!==this.#duration&&(this.#closeToEnded=!1,this.#duration=e.data.duration/1e3,this.dispatchEvent(new Event(`durationchange`))),e.data.position/1e3!==this.#currentTime&&(this.#seeking=!1,this.#closeToEnded=!1,this.#currentTime=e.data.position/1e3,this.dispatchEvent(new Event(`timeupdate`))),!this.#isWaiting&&!this.#paused&&e.data.isPaused){this.#paused=!0,this.dispatchEvent(new Event(`pause`));return}if(this.#paused&&(e.data.isBuffering||!e.data.isPaused)){this.#paused=!1,this.dispatchEvent(new Event(`play`)),this.#isWaiting=e.data.isBuffering,this.#isWaiting?this.dispatchEvent(new Event(`waiting`)):this.dispatchEvent(new Event(`playing`));return}if(this.#isWaiting&&!e.data.isPaused){this.#isWaiting=!1,this.dispatchEvent(new Event(`playing`));return}if(!this.paused&&!this.seeking&&!this.#closeToEnded&&Math.ceil(this.currentTime)>=this.duration){if(this.#closeToEnded=!0,this.loop){this.currentTime=1;return}this.continuous||(this.pause(),this.dispatchEvent(new Event(`ended`)));return}})}this.loadComplete.resolve(),await this.loadComplete}async attributeChangedCallback(e,t,n){if(t!==n)switch(e){case`src`:this.load();return}}async play(){return this.#paused=!1,this.#isWaiting=!0,this.dispatchEvent(new Event(`play`)),await this.loadComplete,this.api?.resume()}async pause(){return await this.loadComplete,this.api?.pause()}get config(){return this.#config}set config(e){this.#config=e}get paused(){return this.#paused??!0}get muted(){return!1}set muted(e){}get volume(){return 1}set volume(e){}get ended(){return Math.ceil(this.currentTime)>=this.duration}get seeking(){return this.#seeking}get loop(){return this.hasAttribute(`loop`)}set loop(e){this.loop!=e&&this.toggleAttribute(`loop`,!!e)}get currentTime(){return this.#currentTime}set currentTime(e){if(this.currentTime==e)return;this.#seeking=!0;let t=this.#currentTime;this.#currentTime=e,this.dispatchEvent(new Event(`timeupdate`)),this.#currentTime=t,this.loadComplete.then(()=>{var t;(t=this.api)==null||t.seek(e)})}get duration(){return this.#duration}get src(){return this.getAttribute(`src`)}set src(e){this.setAttribute(`src`,`${e}`)}#upgradeProperty(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}}};function d(e){let t=``;for(let n in e){let r=e[n];r===``?t+=` ${n}`:t+=` ${n}="${r}"`}return t}function f(e){return String(new URLSearchParams(p(e)))}function p(e){let t={};for(let n in e){let r=e[n];r===!0||r===``?t[n]=1:r===!1?t[n]=0:r!=null&&(t[n]=r)}return t}function m(e){let t={};for(let n of e)t[n.name]=n.value;return t}var h={};async function g(e,t,n){return h[e]?h[e]:t&&self[t]?Promise.resolve(self[t]):h[e]=new Promise(function(t,r){let i=document.createElement(`script`);i.src=e;let a=e=>t(e);n&&(self[n]=a),i.onload=()=>!n&&a(),i.onerror=r,document.head.append(i)})}var _=class extends Promise{constructor(e=()=>{}){let t,n;super((r,i)=>{e(r,i),t=r,n=i}),this.resolve=t,this.reject=n}};globalThis.customElements&&!globalThis.customElements.get(`spotify-audio`)&&globalThis.customElements.define(`spotify-audio`,u);var v=u,y=new Set([`style`,`children`,`ref`,`key`,`suppressContentEditableWarning`,`suppressHydrationWarning`,`dangerouslySetInnerHTML`]),b={className:`class`,htmlFor:`for`};function x(e){return e.toLowerCase()}function S(e){if(typeof e==`boolean`)return e?``:void 0;if(typeof e!=`function`&&!(typeof e==`object`&&e))return e}function C({react:e,tagName:t,elementClass:n,events:r,displayName:i,defaultProps:a,toAttributeName:o=x,toAttributeValue:s=S}){let c=Number.parseInt(e.version)>=19,l=e.forwardRef((i,l)=>{let u=e.useRef(null),d=e.useRef(new Map),f={},p={},m={},h={};for(let[e,t]of Object.entries(i)){if(y.has(e)){m[e]=t;continue}let r=o(b[e]??e);if(n.prototype&&e in n.prototype&&!(e in(globalThis.HTMLElement?.prototype??{}))&&!n.observedAttributes?.some(e=>e===r)){h[e]=t;continue}if(e.startsWith(`on`)){f[e]=t;continue}let i=s(t);r&&i!=null&&(p[r]=String(i),c||(m[r]=i)),r&&c&&(i===S(t)?m[r]=t:m[r]=i)}if(typeof window<`u`){for(let t in f){let n=f[t],i=t.endsWith(`Capture`),a=(r?.[t]??t.slice(2).toLowerCase()).slice(0,i?-7:void 0);e.useLayoutEffect(()=>{let e=u?.current;if(!(!e||typeof n!=`function`))return e.addEventListener(a,n,i),()=>{e.removeEventListener(a,n,i)}},[u?.current,n])}e.useLayoutEffect(()=>{if(u.current===null)return;let e=new Map;for(let t in h)w(u.current,t,h[t]),d.current.delete(t),e.set(t,h[t]);for(let[e,t]of d.current)w(u.current,e,void 0);d.current=e})}if(typeof window>`u`&&n?.getTemplateHTML&&n?.shadowRootOptions){let{mode:t,delegatesFocus:r}=n.shadowRootOptions;m.children=[e.createElement(`template`,{shadowrootmode:t,shadowrootdelegatesfocus:r,dangerouslySetInnerHTML:{__html:n.getTemplateHTML(p,i)},key:`ce-la-react-ssr-template-shadow-root`}),m.children]}return e.createElement(t,{...a,...m,ref:e.useCallback(e=>{u.current=e,typeof l==`function`?l(e):l!==null&&(l.current=e)},[l])},m.children)});return l.displayName=i??n.name,l}function w(e,t,n){e[t]=n,n==null&&t in(globalThis.HTMLElement?.prototype??{})&&e.removeAttribute(t)}var T=C({react:n.default,tagName:`spotify-audio`,elementClass:v,toAttributeName(e){return e===`muted`?``:e===`defaultMuted`?`muted`:x(e)}});export{T as default};