import{d3 as N}from"./index-Cq8aT7Ma.js";const O="https://open.spotify.com",$=/open\.spotify\.com\/(\w+)\/(\w+)/i,B="https://open.spotify.com/embed-podcast/iframe-api/v1",j="SpotifyIframeApi",W="onSpotifyIframeApiReady";function L(e,t={}){const i={src:C(e,t),scrolling:"no",frameborder:0,width:"100%",height:"100%",allow:"accelerometer; fullscreen; autoplay; encrypted-media; gyroscope; picture-in-picture"};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${x(i)}></iframe>
  `}function C(e,t){var i,s,u;if(!e.src)return;const a=e.src.match($),c=a&&a[1],f=a&&a[2],r={t:(i=t.config)==null?void 0:i.startAt,theme:((s=t.config)==null?void 0:s.theme)==="dark"?"0":null},g=(u=t.config)!=null&&u.preferVideo?"/video":"";return`${O}/embed/${c}/${f}${g}?${z(r)}`}class H extends(globalThis.HTMLElement??class{}){static getTemplateHTML=L;static shadowRootOptions={mode:"open"};static observedAttributes=["controls","loop","src"];loadComplete=new S;#r;#a;#l;#t=!1;#e=!1;#i=!0;#s=0;#n=NaN;#o=!1;#u=null;constructor(){super(),this.#c("config")}async load(){var t,i,s;if(this.#r)return;this.#a&&(this.loadComplete=new S),this.#a=!0,await(this.#r=Promise.resolve()),this.#r=null,this.#t=!1,this.#e=!1,this.#s=0,this.#n=NaN,this.#o=!1,this.dispatchEvent(new Event("emptied"));let u=this.api;if(this.api=null,!this.src)return;this.dispatchEvent(new Event("loadstart"));const a={t:(t=this.config)==null?void 0:t.startAt,theme:((i=this.config)==null?void 0:i.theme)==="dark"?"0":null,preferVideo:(s=this.config)==null?void 0:s.preferVideo};if(this.#l)this.api=u,this.api.iframeElement.src=C(M(this.attributes),this);else{this.#l=!0,this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML=L(M(this.attributes),this));let c=this.shadowRoot.querySelector("iframe");const f=await U(B,j,W);this.api=await new Promise(r=>f.createController(c,a,r)),this.api.iframeElement=c,this.api.addListener("ready",()=>{this.dispatchEvent(new Event("loadedmetadata")),this.dispatchEvent(new Event("durationchange")),this.dispatchEvent(new Event("volumechange"))}),this.api.addListener("playback_update",r=>{if(this.#e&&this.#i&&(r.data.isBuffering||!r.data.isPaused)){this.#e=!1,this.currentTime=1;return}if(r.data.duration/1e3!==this.#n&&(this.#e=!1,this.#n=r.data.duration/1e3,this.dispatchEvent(new Event("durationchange"))),r.data.position/1e3!==this.#s&&(this.#o=!1,this.#e=!1,this.#s=r.data.position/1e3,this.dispatchEvent(new Event("timeupdate"))),!this.#t&&!this.#i&&r.data.isPaused){this.#i=!0,this.dispatchEvent(new Event("pause"));return}if(this.#i&&(r.data.isBuffering||!r.data.isPaused)){this.#i=!1,this.dispatchEvent(new Event("play")),this.#t=r.data.isBuffering,this.#t?this.dispatchEvent(new Event("waiting")):this.dispatchEvent(new Event("playing"));return}if(this.#t&&!r.data.isPaused){this.#t=!1,this.dispatchEvent(new Event("playing"));return}if(!this.paused&&!this.seeking&&!this.#e&&Math.ceil(this.currentTime)>=this.duration){if(this.#e=!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(t,i,s){if(i!==s)switch(t){case"src":{this.load();return}}}async play(){var t;return this.#i=!1,this.#t=!0,this.dispatchEvent(new Event("play")),await this.loadComplete,(t=this.api)==null?void 0:t.resume()}async pause(){var t;return await this.loadComplete,(t=this.api)==null?void 0:t.pause()}get config(){return this.#u}set config(t){this.#u=t}get paused(){return this.#i??!0}get muted(){return!1}set muted(t){}get volume(){return 1}set volume(t){}get ended(){return Math.ceil(this.currentTime)>=this.duration}get seeking(){return this.#o}get loop(){return this.hasAttribute("loop")}set loop(t){this.loop!=t&&this.toggleAttribute("loop",!!t)}get currentTime(){return this.#s}set currentTime(t){if(this.currentTime==t)return;this.#o=!0;let i=this.#s;this.#s=t,this.dispatchEvent(new Event("timeupdate")),this.#s=i,this.loadComplete.then(()=>{var s;(s=this.api)==null||s.seek(t)})}get duration(){return this.#n}get src(){return this.getAttribute("src")}set src(t){this.setAttribute("src",`${t}`)}#c(t){if(Object.prototype.hasOwnProperty.call(this,t)){const i=this[t];delete this[t],this[t]=i}}}function x(e){let t="";for(const i in e){const s=e[i];s===""?t+=` ${i}`:t+=` ${i}="${s}"`}return t}function z(e){return String(new URLSearchParams(D(e)))}function D(e){let t={};for(let i in e){let s=e[i];s===!0||s===""?t[i]=1:s===!1?t[i]=0:s!=null&&(t[i]=s)}return t}function M(e){let t={};for(let i of e)t[i.name]=i.value;return t}const b={};async function U(e,t,i){return b[e]?b[e]:self[t]?Promise.resolve(self[t]):b[e]=new Promise(function(s,u){const a=document.createElement("script");a.src=e;const c=f=>s(f);self[i]=c,a.onload=()=>!i,a.onerror=u,document.head.append(a)})}class S extends Promise{constructor(t=()=>{}){let i,s;super((u,a)=>{t(u,a),i=u,s=a}),this.resolve=i,this.reject=s}}globalThis.customElements&&!globalThis.customElements.get("spotify-audio")&&globalThis.customElements.define("spotify-audio",H);var q=H,F=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),G={className:"class",htmlFor:"for"};function I(e){return e.toLowerCase()}function k(e){if(typeof e=="boolean")return e?"":void 0;if(typeof e!="function"&&!(typeof e=="object"&&e!==null))return e}function V({react:e,tagName:t,elementClass:i,events:s,displayName:u,defaultProps:a,toAttributeName:c=I,toAttributeValue:f=k}){const r=Number.parseInt(e.version)>=19,g=e.forwardRef((T,v)=>{var _,A;const h=e.useRef(null),w=e.useRef(new Map),E={},P={},p={},y={};for(const[n,o]of Object.entries(T)){if(F.has(n)){p[n]=o;continue}const l=c(G[n]??n);if(n in i.prototype&&!(n in(((_=globalThis.HTMLElement)==null?void 0:_.prototype)??{}))&&!((A=i.observedAttributes)!=null&&A.some(m=>m===l))){y[n]=o;continue}if(n.startsWith("on")){E[n]=o;continue}const d=f(o);if(l&&d!=null&&(P[l]=String(d),r||(p[l]=d)),l&&r){const m=k(o);d!==m?p[l]=d:p[l]=o}}if(typeof window<"u"){for(const n in E){const o=E[n],l=n.endsWith("Capture"),d=(s?.[n]??n.slice(2).toLowerCase()).slice(0,l?-7:void 0);e.useLayoutEffect(()=>{const m=h?.current;if(!(!m||typeof o!="function"))return m.addEventListener(d,o,l),()=>{m.removeEventListener(d,o,l)}},[h?.current,o])}e.useLayoutEffect(()=>{if(h.current===null)return;const n=new Map;for(const o in y)R(h.current,o,y[o]),w.current.delete(o),n.set(o,y[o]);for(const[o,l]of w.current)R(h.current,o,void 0);w.current=n})}if(typeof window>"u"&&i?.getTemplateHTML&&i?.shadowRootOptions){const{mode:n,delegatesFocus:o}=i.shadowRootOptions,l=e.createElement("template",{shadowrootmode:n,shadowrootdelegatesfocus:o,dangerouslySetInnerHTML:{__html:i.getTemplateHTML(P,T)}});p.children=[l,p.children]}return e.createElement(t,{...a,...p,ref:e.useCallback(n=>{h.current=n,typeof v=="function"?v(n):v!==null&&(v.current=n)},[v])})});return g.displayName=u??i.name,g}function R(e,t,i){var s;e[t]=i,i==null&&t in(((s=globalThis.HTMLElement)==null?void 0:s.prototype)??{})&&e.removeAttribute(t)}var J=V({react:N,tagName:"spotify-audio",elementClass:q,toAttributeName(e){return e==="muted"?"":e==="defaultMuted"?"muted":I(e)}});/*! Bundled license information:

ce-la-react/dist/ce-la-react.js:
  (**
   * @license
   * Copyright 2018 Google LLC
   * SPDX-License-Identifier: BSD-3-Clause
   *
   * Modified version of `@lit/react` for vanilla custom elements with support for SSR.
   *)
*/export{J as default};
