var et=Object.defineProperty;var it=(e,s,t)=>s in e?et(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t;var M=(e,s,t)=>(it(e,typeof s!="symbol"?s+"":s,t),t),V=(e,s,t)=>{if(!s.has(e))throw TypeError("Cannot "+t)};var c=(e,s,t)=>(V(e,s,"read from private field"),t?t.call(e):s.get(e)),m=(e,s,t)=>{if(s.has(e))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(e):s.set(e,t)},l=(e,s,t,i)=>(V(e,s,"write to private field"),i?i.call(e,t):s.set(e,t),t);var W=(e,s,t)=>(V(e,s,"access private method"),t);import{c as st}from"./vendor-react-ece1c85f.js";import{M as nt}from"./index-3faf039c.js";const ot="https://www.youtube.com/embed",rt="https://www.youtube-nocookie.com/embed",at="https://www.youtube.com/iframe_api",lt="YT",ut="onYouTubeIframeAPIReady",q=/(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|shorts\/|live\/))((\w|-){11})/,ct=/(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/.*?[?&]list=)([\w_-]+)/;function dt(e){if(!e)return;const s=e.match(/[?&]t=([\dms]+)/i);if(!s)return;const t=s[1].toLowerCase();let i=0,n=!1;const u=t.match(/(\d+)m/);u&&(i+=parseInt(u[1],10)*60,n=!0);const d=t.match(/(\d+)s?$/);return d&&(i+=parseInt(d[1],10),n=!0),n?i:void 0}function z(e,s={}){var t;const i={src:X(e,s),frameborder:0,width:"100%",height:"100%",allow:"accelerometer; fullscreen; autoplay; encrypted-media; gyroscope; picture-in-picture"};return(t=s.config)!=null&&t.referrerpolicy&&(i.referrerpolicy=s.config.referrerpolicy),s.config&&(i["data-config"]=JSON.stringify(s.config)),`
    <style>
      :host {
        display: inline-block;
        line-height: 0;
        position: relative;
        min-width: 300px;
        min-height: 150px;
      }
      iframe {
        position: absolute;
        top: 0;
        left: 0;
      }
    </style>
    <iframe${ht(i)}></iframe>
  `}function X(e,s){if(!e.src)return;const t=e.src.includes("-nocookie")?rt:ot,i={controls:e.controls===""?null:0,autoplay:e.autoplay,loop:e.loop,mute:e.muted,playsinline:e.playsinline,preload:e.preload??"metadata",enablejsapi:1,cc_load_policy:1,showinfo:0,rel:0,iv_load_policy:3,modestbranding:1,start:dt(e.src),...s.config};if(q.test(e.src)){const g=e.src.match(q),b=g&&g[1];return`${t}/${b}?${J(i)}`}const n=e.src.match(ct),d={listType:"playlist",list:n&&n[1],...i};return`${t}?${J(d)}`}var S,C,_,T,y,B,R,P,L,$,Z;class x extends nt(globalThis.HTMLElement??class{}){constructor(){super();m(this,$);M(this,"loadComplete",new F);m(this,S,void 0);m(this,C,void 0);m(this,_,0);m(this,T,!1);m(this,y,void 0);M(this,"isLoaded",!1);m(this,B,null);m(this,R,null);m(this,P,null);m(this,L,1);W(this,$,Z).call(this,"config")}get config(){return c(this,R)}set config(t){l(this,R,t)}async load(){if(c(this,S))return;this.shadowRoot||this.attachShadow({mode:"open"});const t=!c(this,C);c(this,C)&&(this.loadComplete=new F,this.isLoaded=!1),l(this,C,!0),await l(this,S,Promise.resolve()),l(this,S,null),l(this,_,0),this.dispatchEvent(new Event("emptied"));let i=this.api;if(this.api=null,!this.src){i==null||i.destroy();return}l(this,P,document.createElement("video")),this.textTracks=c(this,P).textTracks,this.textTracks.addEventListener("change",()=>{var o;const f=Array.from(this.textTracks).find(p=>p.mode==="showing");(o=this.api)==null||o.setOption("captions","track",f?{languageCode:f.language}:{})}),this.dispatchEvent(new Event("loadstart"));let n=this.shadowRoot.querySelector("iframe"),u=pt(this.attributes);t&&n&&l(this,R,JSON.parse(n.getAttribute("data-config")||"{}")),(!(n!=null&&n.src)||n.src!==X(u,this))&&(this.shadowRoot.innerHTML=z(u,this),n=this.shadowRoot.querySelector("iframe"));const d=await vt(at,lt,ut);this.api=new d.Player(n,{events:{onReady:()=>{var o;l(this,_,1),this.dispatchEvent(new Event("loadedmetadata")),this.dispatchEvent(new Event("durationchange")),c(this,L)!==1&&((o=this.api)==null||o.setVolume(c(this,L)*100)),this.dispatchEvent(new Event("volumechange")),this.dispatchEvent(new Event("loadcomplete")),this.isLoaded=!0,this.loadComplete.resolve()},onError:o=>{console.error(o),l(this,B,{code:o.data,message:`YouTube iframe player error #${o.data}; visit https://developers.google.com/youtube/iframe_api_reference#onError for the full error message.`}),this.dispatchEvent(new Event("error"))}}});let g=!1;this.api.addEventListener("onStateChange",o=>{var f;const p=o.data;if((p===d.PlayerState.PLAYING||p===d.PlayerState.BUFFERING)&&(g||(g=!0,this.dispatchEvent(new Event("play"))),(this.api.getOption("captions","tracklist")||[]).forEach(k=>{[...this.textTracks].some(O=>O.language===k.languageCode)||c(this,P).addTextTrack("subtitles",k.displayName,k.languageCode),this.textTracks=c(this,P).textTracks}),this.dispatchEvent(new Event("loadstart"))),p===d.PlayerState.PLAYING)this.seeking&&(l(this,T,!1),(f=c(this,y))==null||f.resolve(),this.dispatchEvent(new Event("seeked"))),l(this,_,3),this.dispatchEvent(new Event("playing"));else if(p===d.PlayerState.PAUSED){const v=Math.abs(this.currentTime-b);!this.seeking&&v>.1&&(l(this,T,!0),this.dispatchEvent(new Event("seeking"))),g=!1,this.dispatchEvent(new Event("pause"))}p===d.PlayerState.ENDED&&(g=!1,this.dispatchEvent(new Event("pause")),this.dispatchEvent(new Event("ended")),this.loop&&this.play())}),this.api.addEventListener("onPlaybackRateChange",()=>{this.dispatchEvent(new Event("ratechange"))}),this.api.addEventListener("onVolumeChange",()=>{var o;const f=((o=this.api)==null?void 0:o.getVolume())/100;l(this,L,f),this.dispatchEvent(new Event("volumechange"))}),this.api.addEventListener("onVideoProgress",()=>{this.dispatchEvent(new Event("timeupdate"))}),await this.loadComplete;let b=0;setInterval(()=>{var o;const f=Math.abs(this.currentTime-b),p=this.buffered.end(this.buffered.length-1);this.seeking&&p>.1?(l(this,T,!1),(o=c(this,y))==null||o.resolve(),this.dispatchEvent(new Event("seeked"))):!this.seeking&&f>.1&&(l(this,T,!0),this.dispatchEvent(new Event("seeking"))),b=this.currentTime},50);let I;const N=setInterval(()=>{const o=this.buffered.end(this.buffered.length-1);o>=this.duration&&(clearInterval(N),l(this,_,4)),I!=o&&(I=o,this.dispatchEvent(new Event("progress")))},100)}async attributeChangedCallback(t,i,n){if(i!==n)switch(t){case"src":case"autoplay":case"controls":case"loop":case"playsinline":this.load()}}async play(){var t;return l(this,y,null),await this.loadComplete,(t=this.api)==null||t.playVideo(),yt(this)}async pause(){var t;return await this.loadComplete,(t=this.api)==null?void 0:t.pauseVideo()}get seeking(){return c(this,T)}get readyState(){return c(this,_)}get src(){return this.getAttribute("src")}set src(t){this.src!=t&&this.setAttribute("src",t)}get error(){return c(this,B)}get paused(){var t,i;return this.isLoaded?[-1,0,2,5].includes((i=(t=this.api)==null?void 0:t.getPlayerState)==null?void 0:i.call(t)):!this.autoplay}get duration(){var t,i;return((i=(t=this.api)==null?void 0:t.getDuration)==null?void 0:i.call(t))??NaN}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(t){this.autoplay!=t&&this.toggleAttribute("autoplay",!!t)}get buffered(){var t,i;if(!this.isLoaded)return Y();const n=((t=this.api)==null?void 0:t.getVideoLoadedFraction())*((i=this.api)==null?void 0:i.getDuration());return n>0?Y(0,n):Y()}get controls(){return this.hasAttribute("controls")}set controls(t){this.controls!=t&&this.toggleAttribute("controls",!!t)}get currentTime(){var t,i;return((i=(t=this.api)==null?void 0:t.getCurrentTime)==null?void 0:i.call(t))??0}set currentTime(t){this.currentTime!=t&&(l(this,y,new F),this.loadComplete.then(()=>{var i,n;(i=this.api)==null||i.seekTo(t,!0),this.paused&&((n=c(this,y))==null||n.then(()=>{var u;c(this,y)&&((u=this.api)==null||u.pauseVideo())}))}))}set defaultMuted(t){this.defaultMuted!=t&&this.toggleAttribute("muted",!!t)}get defaultMuted(){return this.hasAttribute("muted")}get loop(){return this.hasAttribute("loop")}set loop(t){this.loop!=t&&this.toggleAttribute("loop",!!t)}set muted(t){this.muted!=t&&this.loadComplete.then(()=>{var i,n;t?(i=this.api)==null||i.mute():(n=this.api)==null||n.unMute()})}get muted(){var t,i;return this.isLoaded?(i=(t=this.api)==null?void 0:t.isMuted)==null?void 0:i.call(t):this.defaultMuted}get playbackRate(){var t,i;return((i=(t=this.api)==null?void 0:t.getPlaybackRate)==null?void 0:i.call(t))??1}set playbackRate(t){this.playbackRate!=t&&this.loadComplete.then(()=>{var i;(i=this.api)==null||i.setPlaybackRate(t)})}get playsInline(){return this.hasAttribute("playsinline")}set playsInline(t){this.playsInline!=t&&this.toggleAttribute("playsinline",!!t)}get poster(){return this.getAttribute("poster")}set poster(t){this.poster!=t&&this.setAttribute("poster",`${t}`)}set volume(t){this.volume!=t&&(l(this,L,t),this.loadComplete.then(()=>{var i;(i=this.api)==null||i.setVolume(t*100)}))}get volume(){var t;return this.isLoaded?((t=this.api)==null?void 0:t.getVolume())/100:c(this,L)}}S=new WeakMap,C=new WeakMap,_=new WeakMap,T=new WeakMap,y=new WeakMap,B=new WeakMap,R=new WeakMap,P=new WeakMap,L=new WeakMap,$=new WeakSet,Z=function(t){if(Object.prototype.hasOwnProperty.call(this,t)){const i=this[t];delete this[t],this[t]=i}},M(x,"getTemplateHTML",z),M(x,"shadowRootOptions",{mode:"open"}),M(x,"observedAttributes",["autoplay","controls","crossorigin","loop","muted","playsinline","poster","preload","src"]);function ht(e){let s="";for(const t in e){const i=e[t];i===""?s+=` ${D(t)}`:s+=` ${D(t)}="${D(`${i}`)}"`}return s}function D(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/`/g,"&#x60;")}function J(e){return String(new URLSearchParams(ft(e)))}function ft(e){let s={};for(let t in e){let i=e[t];i===!0||i===""?s[t]=1:i===!1?s[t]=0:i!=null&&(s[t]=i)}return s}function pt(e){let s={};for(let t of e)s[t.name]=t.value;return s}const j={};async function vt(e,s,t){return j[e]?j[e]:s&&self[s]?(await mt(0),self[s]):j[e]=new Promise(function(i,n){const u=document.createElement("script");u.src=e;const d=()=>i(self[s]);t&&(self[t]=d),u.onload=()=>!t&&d(),u.onerror=n,document.head.append(u)})}const mt=e=>new Promise(s=>setTimeout(s,e));function gt(e){return(...s)=>new Promise(t=>{e(...s,(...i)=>{i.length>1?t(i):t(i[0])})})}function yt(e){return gt((s,t)=>{let i;e.addEventListener(s,i=()=>{e.removeEventListener(s,i),t()})})("playing")}class F extends Promise{constructor(s=()=>{}){let t,i;super((n,u)=>{s(n,u),t=n,i=u}),this.resolve=t,this.reject=i}}function Y(e,s){return Array.isArray(e)?G(e):e==null||s==null||e===0&&s===0?G([[0,0]]):G([[e,s]])}function G(e){return Object.defineProperties(e,{start:{value:s=>e[s][0]},end:{value:s=>e[s][1]}}),e}globalThis.customElements&&!globalThis.customElements.get("youtube-video")&&globalThis.customElements.define("youtube-video",x);var bt=x,Et=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),wt={className:"class",htmlFor:"for"};function tt(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 _t({react:e,tagName:s,elementClass:t,events:i,displayName:n,defaultProps:u,toAttributeName:d=tt,toAttributeValue:g=K}){const b=Number.parseInt(e.version)>=19,I=e.forwardRef((N,o)=>{var f,p;const v=e.useRef(null),k=e.useRef(new Map),O={},U={},E={},H={};for(const[r,a]of Object.entries(N)){if(Et.has(r)){E[r]=a;continue}const h=d(wt[r]??r);if(t.prototype&&r in t.prototype&&!(r in(((f=globalThis.HTMLElement)==null?void 0:f.prototype)??{}))&&!((p=t.observedAttributes)!=null&&p.some(A=>A===h))){H[r]=a;continue}if(r.startsWith("on")){O[r]=a;continue}const w=g(a);if(h&&w!=null&&(U[h]=String(w),b||(E[h]=w)),h&&b){const A=K(a);w!==A?E[h]=w:E[h]=a}}if(typeof window<"u"){for(const r in O){const a=O[r],h=r.endsWith("Capture"),w=((i==null?void 0:i[r])??r.slice(2).toLowerCase()).slice(0,h?-7:void 0);e.useLayoutEffect(()=>{const A=v==null?void 0:v.current;if(!(!A||typeof a!="function"))return A.addEventListener(w,a,h),()=>{A.removeEventListener(w,a,h)}},[v==null?void 0:v.current,a])}e.useLayoutEffect(()=>{if(v.current===null)return;const r=new Map;for(const a in H)Q(v.current,a,H[a]),k.current.delete(a),r.set(a,H[a]);for(const[a,h]of k.current)Q(v.current,a,void 0);k.current=r})}if(typeof window>"u"&&(t!=null&&t.getTemplateHTML)&&(t!=null&&t.shadowRootOptions)){const{mode:r,delegatesFocus:a}=t.shadowRootOptions,h=e.createElement("template",{shadowrootmode:r,shadowrootdelegatesfocus:a,dangerouslySetInnerHTML:{__html:t.getTemplateHTML(U,N)},key:"ce-la-react-ssr-template-shadow-root"});E.children=[h,E.children]}return e.createElement(s,{...u,...E,ref:e.useCallback(r=>{v.current=r,typeof o=="function"?o(r):o!==null&&(o.current=r)},[o])},E.children)});return I.displayName=n??t.name,I}function Q(e,s,t){var i;e[s]=t,t==null&&s in(((i=globalThis.HTMLElement)==null?void 0:i.prototype)??{})&&e.removeAttribute(s)}var At=_t({react:st,tagName:"youtube-video",elementClass:bt,toAttributeName(e){return e==="muted"?"":e==="defaultMuted"?"muted":tt(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{At as default};
