@broadcastingplatforms/player 1.4.7 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * BP Player (v1.4.7)
2
+ * BP Player (v1.4.8)
3
3
  * Universal video player web component
4
4
  */
5
5
  var Fb=Object.defineProperty;var kx=Object.getOwnPropertyDescriptor;var Bb=n=>{throw TypeError(n)};var Ax=(n,e,t)=>e in n?Fb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Se=(n,e,t,i)=>{for(var s=i>1?void 0:i?kx(e,t):e,r=n.length-1,a;r>=0;r--)(a=n[r])&&(s=(i?a(e,t,s):a(s))||s);return i&&s&&Fb(e,t,s),s};var we=(n,e,t)=>Ax(n,typeof e!="symbol"?e+"":e,t),rp=(n,e,t)=>e.has(n)||Bb("Cannot "+t);var P=(n,e,t)=>(rp(n,e,"read from private field"),t?t.call(n):e.get(n)),ne=(n,e,t)=>e.has(n)?Bb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),F=(n,e,t,i)=>(rp(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),pe=(n,e,t)=>(rp(n,e,"access private method"),t);var jd=globalThis,Yd=jd.ShadowRoot&&(jd.ShadyCSS===void 0||jd.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ap=Symbol(),$b=new WeakMap,Il=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==ap)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Yd&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=$b.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&$b.set(t,e))}return e}toString(){return this.cssText}},Vb=n=>new Il(typeof n=="string"?n:n+"",void 0,ap),Rl=(n,...e)=>{let t=n.length===1?n[0]:e.reduce((i,s,r)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[r+1],n[0]);return new Il(t,n,ap)},Hb=(n,e)=>{if(Yd)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=jd.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,n.appendChild(i)}},op=Yd?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return Vb(t)})(n):n;var{is:Cx,defineProperty:Ix,getOwnPropertyDescriptor:Rx,getOwnPropertyNames:xx,getOwnPropertySymbols:Lx,getPrototypeOf:Px}=Object,Is=globalThis,Gb=Is.trustedTypes,wx=Gb?Gb.emptyScript:"",lp=Is.reactiveElementPolyfillSupport,xl=(n,e)=>n,Ll={toAttribute(n,e){switch(e){case Boolean:n=n?wx:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},zd=(n,e)=>!Cx(n,e),Kb={attribute:!0,type:String,converter:Ll,reflect:!1,useDefault:!1,hasChanged:zd};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Is.litPropertyMetadata??(Is.litPropertyMetadata=new WeakMap);var ns=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Kb){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&Ix(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:r}=Rx(this.prototype,e)??{get(){return this[t]},set(a){this[t]=a}};return{get:s,set(a){let o=s==null?void 0:s.call(this);r==null||r.call(this,a),this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Kb}static _$Ei(){if(this.hasOwnProperty(xl("elementProperties")))return;let e=Px(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(xl("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(xl("properties"))){let t=this.properties,i=[...xx(t),...Lx(t)];for(let s of i)this.createProperty(s,t[s])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let s of i)t.unshift(op(s))}else e!==void 0&&t.push(op(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Hb(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var r;let i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){let a=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:Ll).toAttribute(t,i.type);this._$Em=e,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(e,t){var r,a;let i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){let o=i.getPropertyOptions(s),l=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:Ll;this._$Em=s;let c=l.fromAttribute(t,o.type);this[s]=c??((a=this._$Ej)==null?void 0:a.get(s))??c,this._$Em=null}}requestUpdate(e,t,i,s=!1,r){var a;if(e!==void 0){let o=this.constructor;if(s===!1&&(r=this[e]),i??(i=o.getPropertyOptions(e)),!((i.hasChanged??zd)(r,t)||i.useDefault&&i.reflect&&r===((a=this._$Ej)==null?void 0:a.get(e))&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:r},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,a??t??this[e]),r!==!0||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[r,a]of this._$Ep)this[r]=a;this._$Ep=void 0}let s=this.constructor.elementProperties;if(s.size>0)for(let[r,a]of s){let{wrapped:o}=a,l=this[r];o!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,a,l)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};ns.elementStyles=[],ns.shadowRootOptions={mode:"open"},ns[xl("elementProperties")]=new Map,ns[xl("finalized")]=new Map,lp==null||lp({ReactiveElement:ns}),(Is.reactiveElementVersions??(Is.reactiveElementVersions=[])).push("2.1.2");var wl=globalThis,Wb=n=>n,Qd=wl.trustedTypes,qb=Qd?Qd.createPolicy("lit-html",{createHTML:n=>n}):void 0,Jb="$lit$",Rs=`lit$${Math.random().toFixed(9).slice(2)}$`,Zb="?"+Rs,Dx=`<${Zb}>`,Pr=document,Dl=()=>Pr.createComment(""),Ml=n=>n===null||typeof n!="object"&&typeof n!="function",gp=Array.isArray,Mx=n=>gp(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",cp=`[
6
6
  \f\r]`,Pl=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,jb=/-->/g,Yb=/>/g,xr=RegExp(`>|${cp}(?:([^\\s"'>=/]+)(${cp}*=${cp}*(?:[^
7
- \f\r"'\`<>=]|("|')|))|$)`,"g"),zb=/'/g,Qb=/"/g,eT=/^(?:script|style|textarea|title)$/i,vp=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),Fi=vp(1),fB=vp(2),mB=vp(3),wr=Symbol.for("lit-noChange"),Dt=Symbol.for("lit-nothing"),Xb=new WeakMap,Lr=Pr.createTreeWalker(Pr,129);function tT(n,e){if(!gp(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return qb!==void 0?qb.createHTML(e):e}var Ox=(n,e)=>{let t=n.length-1,i=[],s,r=e===2?"<svg>":e===3?"<math>":"",a=Pl;for(let o=0;o<t;o++){let l=n[o],c,d,u=-1,h=0;for(;h<l.length&&(a.lastIndex=h,d=a.exec(l),d!==null);)h=a.lastIndex,a===Pl?d[1]==="!--"?a=jb:d[1]!==void 0?a=Yb:d[2]!==void 0?(eT.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=xr):d[3]!==void 0&&(a=xr):a===xr?d[0]===">"?(a=s??Pl,u=-1):d[1]===void 0?u=-2:(u=a.lastIndex-d[2].length,c=d[1],a=d[3]===void 0?xr:d[3]==='"'?Qb:zb):a===Qb||a===zb?a=xr:a===jb||a===Yb?a=Pl:(a=xr,s=void 0);let f=a===xr&&n[o+1].startsWith("/>")?" ":"";r+=a===Pl?l+Dx:u>=0?(i.push(c),l.slice(0,u)+Jb+l.slice(u)+Rs+f):l+Rs+(u===-2?o:f)}return[tT(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Ol=class n{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,a=0,o=e.length-1,l=this.parts,[c,d]=Ox(e,t);if(this.el=n.createElement(c,i),Lr.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Lr.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(let u of s.getAttributeNames())if(u.endsWith(Jb)){let h=d[a++],f=s.getAttribute(u).split(Rs),m=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:m[2],strings:f,ctor:m[1]==="."?hp:m[1]==="?"?fp:m[1]==="@"?mp:Na}),s.removeAttribute(u)}else u.startsWith(Rs)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(eT.test(s.tagName)){let u=s.textContent.split(Rs),h=u.length-1;if(h>0){s.textContent=Qd?Qd.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],Dl()),Lr.nextNode(),l.push({type:2,index:++r});s.append(u[h],Dl())}}}else if(s.nodeType===8)if(s.data===Zb)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(Rs,u+1))!==-1;)l.push({type:7,index:r}),u+=Rs.length-1}r++}}static createElement(e,t){let i=Pr.createElement("template");return i.innerHTML=e,i}};function Oa(n,e,t=n,i){var a,o;if(e===wr)return e;let s=i!==void 0?(a=t._$Co)==null?void 0:a[i]:t._$Cl,r=Ml(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((o=s==null?void 0:s._$AO)==null||o.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=Oa(n,s._$AS(n,e.values),s,i)),e}var up=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??Pr).importNode(t,!0);Lr.currentNode=s;let r=Lr.nextNode(),a=0,o=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new Nl(r,r.nextSibling,this,e):l.type===1?c=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(c=new pp(r,this,e)),this._$AV.push(c),l=i[++o]}a!==(l==null?void 0:l.index)&&(r=Lr.nextNode(),a++)}return Lr.currentNode=Pr,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},Nl=class n{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Dt,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Oa(this,e,t),Ml(e)?e===Dt||e==null||e===""?(this._$AH!==Dt&&this._$AR(),this._$AH=Dt):e!==this._$AH&&e!==wr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Mx(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Dt&&Ml(this._$AH)?this._$AA.nextSibling.data=e:this.T(Pr.createTextNode(e)),this._$AH=e}$(e){var r;let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Ol.createElement(tT(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{let a=new up(s,this),o=a.u(this.options);a.p(t),this.T(o),this._$AH=a}}_$AC(e){let t=Xb.get(e.strings);return t===void 0&&Xb.set(e.strings,t=new Ol(e)),t}k(e){gp(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let r of e)s===t.length?t.push(i=new n(this.O(Dl()),this.O(Dl()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){let s=Wb(e).nextSibling;Wb(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Na=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Dt,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Dt}_$AI(e,t=this,i,s){let r=this.strings,a=!1;if(r===void 0)e=Oa(this,e,t,0),a=!Ml(e)||e!==this._$AH&&e!==wr,a&&(this._$AH=e);else{let o=e,l,c;for(e=r[0],l=0;l<r.length-1;l++)c=Oa(this,o[i+l],t,l),c===wr&&(c=this._$AH[l]),a||(a=!Ml(c)||c!==this._$AH[l]),c===Dt?e=Dt:e!==Dt&&(e+=(c??"")+r[l+1]),this._$AH[l]=c}a&&!s&&this.j(e)}j(e){e===Dt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},hp=class extends Na{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Dt?void 0:e}},fp=class extends Na{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Dt)}},mp=class extends Na{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=Oa(this,e,t,0)??Dt)===wr)return;let i=this._$AH,s=e===Dt&&i!==Dt||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Dt&&(i===Dt||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},pp=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){Oa(this,e)}};var dp=wl.litHtmlPolyfillSupport;dp==null||dp(Ol,Nl),(wl.litHtmlVersions??(wl.litHtmlVersions=[])).push("3.3.2");var iT=(n,e,t)=>{let i=(t==null?void 0:t.renderBefore)??e,s=i._$litPart$;if(s===void 0){let r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new Nl(e.insertBefore(Dl(),r),r,void 0,t??{})}return s._$AI(n),s};var Dr=globalThis,li=class extends ns{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=iT(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return wr}},nT;li._$litElement$=!0,li.finalized=!0,(nT=Dr.litElementHydrateSupport)==null||nT.call(Dr,{LitElement:li});var yp=Dr.litElementPolyfillSupport;yp==null||yp({LitElement:li});(Dr.litElementVersions??(Dr.litElementVersions=[])).push("4.2.2");var xs=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};var Nx={attribute:!0,type:String,converter:Ll,reflect:!1,hasChanged:zd},Ux=(n=Nx,e,t)=>{let{kind:i,metadata:s}=t,r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(t.name,n),i==="accessor"){let{name:a}=t;return{set(o){let l=e.get.call(this);e.set.call(this,o),this.requestUpdate(a,l,n,!0,o)},init(o){return o!==void 0&&this.C(a,void 0,n,o),o}}}if(i==="setter"){let{name:a}=t;return function(o){let l=this[a];e.call(this,o),this.requestUpdate(a,l,n,!0,o)}}throw Error("Unsupported decorator location: "+i)};function Fe(n){return(e,t)=>typeof t=="object"?Ux(n,e,t):((i,s,r)=>{let a=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),a?Object.getOwnPropertyDescriptor(s,r):void 0})(n,e,t)}function Ls(n){return Fe({...n,state:!0,attribute:!1})}var Fx=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Ep(n){return n===1005||n===1007||n===1009?"autoplay":n>=2001&&n<=2004?"offline":n>=3e3&&n<=3999?"media":n>=4900&&n<=4999?"security":n>=4e3&&n<=4899?"network":n>=5e3&&n<=5999?"setup":n>=1e3&&n<=1999?"media":"unknown"}function bp(n){return n===4e3||n===4001?"network":"unknown"}function Jd(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function Zd(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"streamId"in n}function eu(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"clipId"in n}function Tp(n){return Zd(n)||eu(n)}var Tn=class extends Error{constructor(t,i,s){super(t);this.code=i;this.status=s;this.name="BPLiveError"}},Ul=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new Tn("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,i={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let a=await this._network.intercept({url:t,method:"GET",type:"api",headers:i});if(a.response)return a.response.body;t=a.url,i=a.headers}let s=new AbortController,r=setTimeout(()=>s.abort(),3e4);try{let a=await fetch(t,{method:"GET",headers:i,signal:s.signal});if(!a.ok)throw new Tn(`HTTP ${a.status}: ${a.statusText}`,"HTTP_ERROR",a.status);let o=await a.json();return this._network&&(o=(await this._network.interceptResponse({url:t,status:a.status,headers:Object.fromEntries(a.headers),body:o})).body),o}catch(a){throw a instanceof Error&&a.name==="AbortError"?new Tn("Request timeout after 30s","TIMEOUT"):a}finally{clearTimeout(r)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...i}=e;return{type:"nano",source:i}}throw new Tn(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let i=e.filter(o=>o.type==="clip");if(i.length===0)return null;let s=i.find(o=>o.orientation===t);if(s)return s;let r=t==="landscape"?"portrait":"landscape",a=i.find(o=>o.orientation===r);return a||i[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,Zd(e))return this.resolveStreamSource(e);if(eu(e))return this.resolveClipSource(e);throw new Tn("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var o,l,c,d,u,h,f,m,p;let i=(await this.getStream(e.streamId)).data;this._stream=i;let s=this.extractStreamPoster(i);if(!!i.ended_at&&((l=(o=i.media)==null?void 0:o.vod)==null?void 0:l.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(c=g.dimension)==null?void 0:c.width,videoHeight:(d=g.dimension)==null?void 0:d.height}}let a=i.player_source??((u=i.active_stream)==null?void 0:u.player_source);if(a)return{source:this.mapPlayerSourceToResolvedSource(a),contentType:"stream",poster:s};if(((f=(h=i.media)==null?void 0:h.vod)==null?void 0:f.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(m=g.dimension)==null?void 0:m.width,videoHeight:(p=g.dimension)==null?void 0:p.height}}throw new Tn("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let i=(await this.getClip(e.clipId)).data;this._clip=i;let s=this.selectClipMedia(i.media,e.preferredOrientation);if(!s)throw new Tn("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(s),contentType:"clip",poster:s.thumbnail??void 0,videoWidth:s.width,videoHeight:s.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function Fl(n){return n!=null&&typeof n.then=="function"}function sT(n){return new Promise((e,t)=>{let i=!1,s=r=>{i||(i=!0,r?t(r):e())};try{let r=n(s);Fl(r)&&(i=!0,r.then(()=>e(),t))}catch(r){s(r)}})}var Sp=class{constructor(e,t,i){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((s,r)=>{this._resolve=s,this._reject=r}),this._state=e,this._interceptor=t,this._canModify=i,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Fl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");Fl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(sT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},_p=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((i,s)=>{this._resolve=i,this._reject=s}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Fl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");Fl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(sT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},Bl=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},i=!1,s=null;for(let r of this._requestInterceptors.slice()){let a=new Sp(t,r,!i);try{await a.promise}catch{continue}a.responseResult&&!i&&(i=!0,s=a.responseResult),a.redirectResult&&!i&&(t=a.redirectResult)}return{url:t.url,headers:t.headers,response:s}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let i of this._responseInterceptors.slice()){let s=new _p(t,i);try{await s.promise}catch{continue}s.responseResult&&(t={...t,status:s.responseResult.status!==void 0?s.responseResult.status:t.status,headers:s.responseResult.headers!==void 0?s.responseResult.headers:t.headers,body:"body"in s.responseResult?s.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Bx(n){if(typeof n=="string")return"video";switch(n.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function rT(n){return typeof n=="object"&&n!==null&&n.type==="bplive"}var $x=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],kp=class{constructor(){this._mediaElement=null;this._container=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new Bl;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=Jd()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i)this._listeners.has(s)||this._listeners.set(s,new Set),this._listeners.get(s).add(t)}removeEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i){let r=this._listeners.get(s);r&&(r.delete(t),r.size===0&&this._listeners.delete(s))}}dispatch(e,t){let i=this._listeners.get(e);if(i)for(let s of i)try{s(t)}catch(r){console.error(`[PlayerCore] Error in event listener for "${e}":`,r)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,i){if(this._destroyed)return;let s=++this._loadGeneration,r=t??this._container,a=i??this._config;if(!r){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=r,a&&(this._config=a);let o=rT(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...o&&{contentType:o}}),this.dispatch("sourcechange",{source:e});try{let l=e,c=this._state.contentType,d,u,h;if(rT(e)){if(a!=null&&a.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new Ul(a.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let v=await this._bpLive.resolveSource(e);if(s!==this._loadGeneration)return;l=v.source,c=v.contentType,d=v.poster,u=v.videoWidth,h=v.videoHeight}let f=Bx(l),g=f==="nano"||f==="livekit"||c==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=f,this.updateState({providerType:f,contentType:c,streamType:g,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(f,l,a),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),r.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:d,videoWidth:u,videoHeight:h}}catch(l){if(s!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",l);let c={code:-1,message:l instanceof Error?l.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:c,connectionState:"failed"}),this.dispatch("error",c)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,i){switch(e){case"nano":{let s=document.createElement("nano-video"),r=t;return s.libraryLocation=(i==null?void 0:i.libraryLocation)??"/vendor/bp-player",r.source?s.sourceConfig=r.source:r.streamid&&(s.streamid=r.streamid),i!=null&&i.nano&&(s.config=i.nano),s}case"livekit":{let s=document.createElement("livekit-video"),r=t;return s.url=r.url,s.token=r.token,i!=null&&i.livekit&&(s.config=i.livekit),s}case"video":default:{let s=document.createElement("hls-video"),r=typeof t=="string"?t:t.url;s.src=r;let a={...i==null?void 0:i.video},o=this._network,l=a.xhrSetup;return a.xhrSetup=async(c,d)=>{let u=d.includes(".m3u8")?"manifest":d.includes(".ts")||d.includes(".m4s")||d.includes(".fmp4")?"segment":"other",h=await o.intercept({url:d,method:"GET",type:u,headers:{}});h.url!==d&&c.open("GET",h.url,!0);for(let[f,m]of Object.entries(h.headers))c.setRequestHeader(f,m);l&&await l(c,h.url)},s.config=a,s}}}attachMediaElementListeners(e){for(let t of $x){let i=s=>this.handleMediaEvent(t,e,s);e.addEventListener(t,i),this._eventCleanup.push(()=>e.removeEventListener(t,i))}}attachActiveVideoElementForwarding(e){let t=i=>{let s=i.detail;this.dispatch("activevideoelementchange",{video:(s==null?void 0:s.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,i){var s,r,a,o;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:l}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:l}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let l=-1,c="Unknown error",d="none";i instanceof ErrorEvent&&i.error?(l=i.error.code??-1,c=i.error.message??i.message??"Unknown error",d="ErrorEvent"):t.error&&(l=t.error.code??-1,c=t.error.message??"Unknown error",d="element.error");let u=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(s=i.target)==null?void 0:s.tagName,source:d,code:l,message:c,eventIsErrorEvent:i instanceof ErrorEvent,eventErrorCode:i instanceof ErrorEvent?(r=i.error)==null?void 0:r.code:void 0,elementErrorCode:(a=t.error)==null?void 0:a.code,nativeElTag:u==null?void 0:u.tagName,nativeElErrorCode:(o=u==null?void 0:u.error)==null?void 0:o.code,nativeElSrc:u==null?void 0:u.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let h="media",f=!0;this._state.providerType==="nano"&&l>0?(h=Ep(l),f=h!=="offline"&&h!=="autoplay"):this._state.providerType==="livekit"&&l>0&&(h=bp(l),f=!0);let m={code:l,message:c,fatal:f,category:h};this.updateState({error:m}),this.dispatch("error",m);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...Jd(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"});let t=this._getFullscreenTarget();t&&(e&&!document.fullscreenElement?await t.requestFullscreen():!e&&document.fullscreenElement&&await document.exitFullscreen())}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){this._destroyed||(this._destroyed=!0,this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function Ap(){return new kp}var Ua="bpPlayerObservedProperties";function Cp(n){return Ua in n&&Array.isArray(n[Ua])}function Vx(n,e){class t extends n{get[Ua](){return e}}return t}function Hx(n){if(n.shadowRoot)return Array.from(n.shadowRoot.children);if(n.localName==="slot"){let t=n.assignedNodes();if(t.length>0)return t.filter(i=>i.nodeType===Node.ELEMENT_NODE)}return Array.from(n.children)}async function Fa(n,e,t){if(e!=null&&e.contains(n))return;n.nodeName.includes("-")&&!Cp(n)&&(await Promise.resolve(),await customElements.whenDefined(n.nodeName.toLowerCase()),customElements.upgrade(n)),Cp(n)&&t(n);let i=Hx(n);i.length>0&&await Promise.all(i.map(s=>Fa(s,e,t)))}function tu(n,e,t){let i=n[Ua];i.includes("player")&&(n.player=e),i.includes("paused")&&(n.paused=t.paused),i.includes("playing")&&(n.playing=t.playing),i.includes("ended")&&(n.ended=t.ended),i.includes("seeking")&&(n.seeking=t.seeking),i.includes("currentTime")&&(n.currentTime=t.currentTime),i.includes("duration")&&(n.duration=t.duration),i.includes("volume")&&(n.volume=t.volume),i.includes("muted")&&(n.muted=t.muted),i.includes("playbackRate")&&(n.playbackRate=t.playbackRate),i.includes("readyState")&&(n.readyState=t.readyState),i.includes("videoWidth")&&(n.videoWidth=t.videoWidth),i.includes("videoHeight")&&(n.videoHeight=t.videoHeight),i.includes("qualities")&&(n.qualities=t.qualities),i.includes("currentQuality")&&(n.currentQuality=t.currentQuality),i.includes("targetQuality")&&(n.targetQuality=t.targetQuality),i.includes("fullscreen")&&(n.fullscreen=t.fullscreen),i.includes("presentationMode")&&(n.presentationMode=t.presentationMode),i.includes("connectionState")&&(n.connectionState=t.connectionState),i.includes("streamType")&&(n.streamType=t.streamType),i.includes("error")&&(n.error=t.error)}function iu(n){n[Ua].includes("player")&&(n.player=void 0)}var aT=`/**
7
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),zb=/'/g,Qb=/"/g,eT=/^(?:script|style|textarea|title)$/i,vp=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),Fi=vp(1),fB=vp(2),mB=vp(3),wr=Symbol.for("lit-noChange"),Dt=Symbol.for("lit-nothing"),Xb=new WeakMap,Lr=Pr.createTreeWalker(Pr,129);function tT(n,e){if(!gp(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return qb!==void 0?qb.createHTML(e):e}var Ox=(n,e)=>{let t=n.length-1,i=[],s,r=e===2?"<svg>":e===3?"<math>":"",a=Pl;for(let o=0;o<t;o++){let l=n[o],c,d,u=-1,h=0;for(;h<l.length&&(a.lastIndex=h,d=a.exec(l),d!==null);)h=a.lastIndex,a===Pl?d[1]==="!--"?a=jb:d[1]!==void 0?a=Yb:d[2]!==void 0?(eT.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=xr):d[3]!==void 0&&(a=xr):a===xr?d[0]===">"?(a=s??Pl,u=-1):d[1]===void 0?u=-2:(u=a.lastIndex-d[2].length,c=d[1],a=d[3]===void 0?xr:d[3]==='"'?Qb:zb):a===Qb||a===zb?a=xr:a===jb||a===Yb?a=Pl:(a=xr,s=void 0);let f=a===xr&&n[o+1].startsWith("/>")?" ":"";r+=a===Pl?l+Dx:u>=0?(i.push(c),l.slice(0,u)+Jb+l.slice(u)+Rs+f):l+Rs+(u===-2?o:f)}return[tT(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Ol=class n{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,a=0,o=e.length-1,l=this.parts,[c,d]=Ox(e,t);if(this.el=n.createElement(c,i),Lr.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Lr.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(let u of s.getAttributeNames())if(u.endsWith(Jb)){let h=d[a++],f=s.getAttribute(u).split(Rs),m=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:m[2],strings:f,ctor:m[1]==="."?hp:m[1]==="?"?fp:m[1]==="@"?mp:Na}),s.removeAttribute(u)}else u.startsWith(Rs)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(eT.test(s.tagName)){let u=s.textContent.split(Rs),h=u.length-1;if(h>0){s.textContent=Qd?Qd.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],Dl()),Lr.nextNode(),l.push({type:2,index:++r});s.append(u[h],Dl())}}}else if(s.nodeType===8)if(s.data===Zb)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(Rs,u+1))!==-1;)l.push({type:7,index:r}),u+=Rs.length-1}r++}}static createElement(e,t){let i=Pr.createElement("template");return i.innerHTML=e,i}};function Oa(n,e,t=n,i){var a,o;if(e===wr)return e;let s=i!==void 0?(a=t._$Co)==null?void 0:a[i]:t._$Cl,r=Ml(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((o=s==null?void 0:s._$AO)==null||o.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=Oa(n,s._$AS(n,e.values),s,i)),e}var up=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??Pr).importNode(t,!0);Lr.currentNode=s;let r=Lr.nextNode(),a=0,o=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new Nl(r,r.nextSibling,this,e):l.type===1?c=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(c=new pp(r,this,e)),this._$AV.push(c),l=i[++o]}a!==(l==null?void 0:l.index)&&(r=Lr.nextNode(),a++)}return Lr.currentNode=Pr,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},Nl=class n{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Dt,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Oa(this,e,t),Ml(e)?e===Dt||e==null||e===""?(this._$AH!==Dt&&this._$AR(),this._$AH=Dt):e!==this._$AH&&e!==wr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Mx(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Dt&&Ml(this._$AH)?this._$AA.nextSibling.data=e:this.T(Pr.createTextNode(e)),this._$AH=e}$(e){var r;let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Ol.createElement(tT(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{let a=new up(s,this),o=a.u(this.options);a.p(t),this.T(o),this._$AH=a}}_$AC(e){let t=Xb.get(e.strings);return t===void 0&&Xb.set(e.strings,t=new Ol(e)),t}k(e){gp(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let r of e)s===t.length?t.push(i=new n(this.O(Dl()),this.O(Dl()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){let s=Wb(e).nextSibling;Wb(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Na=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Dt,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Dt}_$AI(e,t=this,i,s){let r=this.strings,a=!1;if(r===void 0)e=Oa(this,e,t,0),a=!Ml(e)||e!==this._$AH&&e!==wr,a&&(this._$AH=e);else{let o=e,l,c;for(e=r[0],l=0;l<r.length-1;l++)c=Oa(this,o[i+l],t,l),c===wr&&(c=this._$AH[l]),a||(a=!Ml(c)||c!==this._$AH[l]),c===Dt?e=Dt:e!==Dt&&(e+=(c??"")+r[l+1]),this._$AH[l]=c}a&&!s&&this.j(e)}j(e){e===Dt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},hp=class extends Na{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Dt?void 0:e}},fp=class extends Na{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Dt)}},mp=class extends Na{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=Oa(this,e,t,0)??Dt)===wr)return;let i=this._$AH,s=e===Dt&&i!==Dt||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Dt&&(i===Dt||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},pp=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){Oa(this,e)}};var dp=wl.litHtmlPolyfillSupport;dp==null||dp(Ol,Nl),(wl.litHtmlVersions??(wl.litHtmlVersions=[])).push("3.3.2");var iT=(n,e,t)=>{let i=(t==null?void 0:t.renderBefore)??e,s=i._$litPart$;if(s===void 0){let r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new Nl(e.insertBefore(Dl(),r),r,void 0,t??{})}return s._$AI(n),s};var Dr=globalThis,li=class extends ns{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=iT(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return wr}},nT;li._$litElement$=!0,li.finalized=!0,(nT=Dr.litElementHydrateSupport)==null||nT.call(Dr,{LitElement:li});var yp=Dr.litElementPolyfillSupport;yp==null||yp({LitElement:li});(Dr.litElementVersions??(Dr.litElementVersions=[])).push("4.2.2");var xs=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};var Nx={attribute:!0,type:String,converter:Ll,reflect:!1,hasChanged:zd},Ux=(n=Nx,e,t)=>{let{kind:i,metadata:s}=t,r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(t.name,n),i==="accessor"){let{name:a}=t;return{set(o){let l=e.get.call(this);e.set.call(this,o),this.requestUpdate(a,l,n,!0,o)},init(o){return o!==void 0&&this.C(a,void 0,n,o),o}}}if(i==="setter"){let{name:a}=t;return function(o){let l=this[a];e.call(this,o),this.requestUpdate(a,l,n,!0,o)}}throw Error("Unsupported decorator location: "+i)};function Fe(n){return(e,t)=>typeof t=="object"?Ux(n,e,t):((i,s,r)=>{let a=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),a?Object.getOwnPropertyDescriptor(s,r):void 0})(n,e,t)}function Ls(n){return Fe({...n,state:!0,attribute:!1})}var Fx=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Ep(n){return n===1005||n===1007||n===1009?"autoplay":n>=2001&&n<=2004?"offline":n>=3e3&&n<=3999?"media":n>=4900&&n<=4999?"security":n>=4e3&&n<=4899?"network":n>=5e3&&n<=5999?"setup":n>=1e3&&n<=1999?"media":"unknown"}function bp(n){return n===4e3||n===4001?"network":"unknown"}function Jd(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function Zd(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"streamId"in n}function eu(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"clipId"in n}function Tp(n){return Zd(n)||eu(n)}var Tn=class extends Error{constructor(t,i,s){super(t);this.code=i;this.status=s;this.name="BPLiveError"}},Ul=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new Tn("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,i={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let a=await this._network.intercept({url:t,method:"GET",type:"api",headers:i});if(a.response)return a.response.body;t=a.url,i=a.headers}let s=new AbortController,r=setTimeout(()=>s.abort(),3e4);try{let a=await fetch(t,{method:"GET",headers:i,signal:s.signal});if(!a.ok)throw new Tn(`HTTP ${a.status}: ${a.statusText}`,"HTTP_ERROR",a.status);let o=await a.json();return this._network&&(o=(await this._network.interceptResponse({url:t,status:a.status,headers:Object.fromEntries(a.headers),body:o})).body),o}catch(a){throw a instanceof Error&&a.name==="AbortError"?new Tn("Request timeout after 30s","TIMEOUT"):a}finally{clearTimeout(r)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...i}=e;return{type:"nano",source:i}}throw new Tn(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let i=e.filter(o=>o.type==="clip");if(i.length===0)return null;let s=i.find(o=>o.orientation===t);if(s)return s;let r=t==="landscape"?"portrait":"landscape",a=i.find(o=>o.orientation===r);return a||i[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,Zd(e))return this.resolveStreamSource(e);if(eu(e))return this.resolveClipSource(e);throw new Tn("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var o,l,c,d,u,h,f,m,p;let i=(await this.getStream(e.streamId)).data;this._stream=i;let s=this.extractStreamPoster(i);if(!!i.ended_at&&((l=(o=i.media)==null?void 0:o.vod)==null?void 0:l.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(c=g.dimension)==null?void 0:c.width,videoHeight:(d=g.dimension)==null?void 0:d.height}}let a=i.player_source??((u=i.active_stream)==null?void 0:u.player_source);if(a)return{source:this.mapPlayerSourceToResolvedSource(a),contentType:"stream",poster:s};if(((f=(h=i.media)==null?void 0:h.vod)==null?void 0:f.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(m=g.dimension)==null?void 0:m.width,videoHeight:(p=g.dimension)==null?void 0:p.height}}throw new Tn("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let i=(await this.getClip(e.clipId)).data;this._clip=i;let s=this.selectClipMedia(i.media,e.preferredOrientation);if(!s)throw new Tn("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(s),contentType:"clip",poster:s.thumbnail??void 0,videoWidth:s.width,videoHeight:s.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function Fl(n){return n!=null&&typeof n.then=="function"}function sT(n){return new Promise((e,t)=>{let i=!1,s=r=>{i||(i=!0,r?t(r):e())};try{let r=n(s);Fl(r)&&(i=!0,r.then(()=>e(),t))}catch(r){s(r)}})}var Sp=class{constructor(e,t,i){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((s,r)=>{this._resolve=s,this._reject=r}),this._state=e,this._interceptor=t,this._canModify=i,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Fl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");Fl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(sT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},_p=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((i,s)=>{this._resolve=i,this._reject=s}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Fl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");Fl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(sT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},Bl=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},i=!1,s=null;for(let r of this._requestInterceptors.slice()){let a=new Sp(t,r,!i);try{await a.promise}catch{continue}a.responseResult&&!i&&(i=!0,s=a.responseResult),a.redirectResult&&!i&&(t=a.redirectResult)}return{url:t.url,headers:t.headers,response:s}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let i of this._responseInterceptors.slice()){let s=new _p(t,i);try{await s.promise}catch{continue}s.responseResult&&(t={...t,status:s.responseResult.status!==void 0?s.responseResult.status:t.status,headers:s.responseResult.headers!==void 0?s.responseResult.headers:t.headers,body:"body"in s.responseResult?s.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Bx(n){if(typeof n=="string")return"video";switch(n.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function rT(n){return typeof n=="object"&&n!==null&&n.type==="bplive"}var $x=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],kp=class{constructor(){this._mediaElement=null;this._container=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new Bl;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=Jd()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i)this._listeners.has(s)||this._listeners.set(s,new Set),this._listeners.get(s).add(t)}removeEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i){let r=this._listeners.get(s);r&&(r.delete(t),r.size===0&&this._listeners.delete(s))}}dispatch(e,t){let i=this._listeners.get(e);if(i)for(let s of i)try{s(t)}catch(r){console.error(`[PlayerCore] Error in event listener for "${e}":`,r)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,i){if(this._destroyed)return;let s=++this._loadGeneration,r=t??this._container,a=i??this._config;if(!r){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=r,a&&(this._config=a);let o=rT(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...o&&{contentType:o}}),this.dispatch("sourcechange",{source:e});try{let l=e,c=this._state.contentType,d,u,h;if(rT(e)){if(a!=null&&a.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new Ul(a.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let v=await this._bpLive.resolveSource(e);if(s!==this._loadGeneration)return;l=v.source,c=v.contentType,d=v.poster,u=v.videoWidth,h=v.videoHeight}let f=Bx(l),g=f==="nano"||f==="livekit"||c==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=f,this.updateState({providerType:f,contentType:c,streamType:g,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(f,l,a),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),r.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:d,videoWidth:u,videoHeight:h}}catch(l){if(s!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",l);let c={code:-1,message:l instanceof Error?l.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:c,connectionState:"failed"}),this.dispatch("error",c)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,i){switch(e){case"nano":{let s=document.createElement("nano-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=t;return s.libraryLocation=(i==null?void 0:i.libraryLocation)??"/vendor/bp-player",r.source?s.sourceConfig=r.source:r.streamid&&(s.streamid=r.streamid),i!=null&&i.nano&&(s.config=i.nano),s}case"livekit":{let s=document.createElement("livekit-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=t;return s.url=r.url,s.token=r.token,i!=null&&i.livekit&&(s.config=i.livekit),s}case"video":default:{let s=document.createElement("hls-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=typeof t=="string"?t:t.url;s.src=r;let a={...i==null?void 0:i.video},o=this._network,l=a.xhrSetup;return a.xhrSetup=async(c,d)=>{let u=d.includes(".m3u8")?"manifest":d.includes(".ts")||d.includes(".m4s")||d.includes(".fmp4")?"segment":"other",h=await o.intercept({url:d,method:"GET",type:u,headers:{}});h.url!==d&&c.open("GET",h.url,!0);for(let[f,m]of Object.entries(h.headers))c.setRequestHeader(f,m);l&&await l(c,h.url)},s.config=a,s}}}attachMediaElementListeners(e){for(let t of $x){let i=s=>this.handleMediaEvent(t,e,s);e.addEventListener(t,i),this._eventCleanup.push(()=>e.removeEventListener(t,i))}}attachActiveVideoElementForwarding(e){let t=i=>{let s=i.detail;this.dispatch("activevideoelementchange",{video:(s==null?void 0:s.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,i){var s,r,a,o;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:l}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:l}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let l=-1,c="Unknown error",d="none";i instanceof ErrorEvent&&i.error?(l=i.error.code??-1,c=i.error.message??i.message??"Unknown error",d="ErrorEvent"):t.error&&(l=t.error.code??-1,c=t.error.message??"Unknown error",d="element.error");let u=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(s=i.target)==null?void 0:s.tagName,source:d,code:l,message:c,eventIsErrorEvent:i instanceof ErrorEvent,eventErrorCode:i instanceof ErrorEvent?(r=i.error)==null?void 0:r.code:void 0,elementErrorCode:(a=t.error)==null?void 0:a.code,nativeElTag:u==null?void 0:u.tagName,nativeElErrorCode:(o=u==null?void 0:u.error)==null?void 0:o.code,nativeElSrc:u==null?void 0:u.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let h="media",f=!0;this._state.providerType==="nano"&&l>0?(h=Ep(l),f=h!=="offline"&&h!=="autoplay"):this._state.providerType==="livekit"&&l>0&&(h=bp(l),f=!0);let m={code:l,message:c,fatal:f,category:h};this.updateState({error:m}),this.dispatch("error",m);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...Jd(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"});let t=this._getFullscreenTarget();t&&(e&&!document.fullscreenElement?await t.requestFullscreen():!e&&document.fullscreenElement&&await document.exitFullscreen())}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){this._destroyed||(this._destroyed=!0,this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function Ap(){return new kp}var Ua="bpPlayerObservedProperties";function Cp(n){return Ua in n&&Array.isArray(n[Ua])}function Vx(n,e){class t extends n{get[Ua](){return e}}return t}function Hx(n){if(n.shadowRoot)return Array.from(n.shadowRoot.children);if(n.localName==="slot"){let t=n.assignedNodes();if(t.length>0)return t.filter(i=>i.nodeType===Node.ELEMENT_NODE)}return Array.from(n.children)}async function Fa(n,e,t){if(e!=null&&e.contains(n))return;n.nodeName.includes("-")&&!Cp(n)&&(await Promise.resolve(),await customElements.whenDefined(n.nodeName.toLowerCase()),customElements.upgrade(n)),Cp(n)&&t(n);let i=Hx(n);i.length>0&&await Promise.all(i.map(s=>Fa(s,e,t)))}function tu(n,e,t){let i=n[Ua];i.includes("player")&&(n.player=e),i.includes("paused")&&(n.paused=t.paused),i.includes("playing")&&(n.playing=t.playing),i.includes("ended")&&(n.ended=t.ended),i.includes("seeking")&&(n.seeking=t.seeking),i.includes("currentTime")&&(n.currentTime=t.currentTime),i.includes("duration")&&(n.duration=t.duration),i.includes("volume")&&(n.volume=t.volume),i.includes("muted")&&(n.muted=t.muted),i.includes("playbackRate")&&(n.playbackRate=t.playbackRate),i.includes("readyState")&&(n.readyState=t.readyState),i.includes("videoWidth")&&(n.videoWidth=t.videoWidth),i.includes("videoHeight")&&(n.videoHeight=t.videoHeight),i.includes("qualities")&&(n.qualities=t.qualities),i.includes("currentQuality")&&(n.currentQuality=t.currentQuality),i.includes("targetQuality")&&(n.targetQuality=t.targetQuality),i.includes("fullscreen")&&(n.fullscreen=t.fullscreen),i.includes("presentationMode")&&(n.presentationMode=t.presentationMode),i.includes("connectionState")&&(n.connectionState=t.connectionState),i.includes("streamType")&&(n.streamType=t.streamType),i.includes("error")&&(n.error=t.error)}function iu(n){n[Ua].includes("player")&&(n.player=void 0)}var aT=`/**
8
8
  * BP Player CSS Custom Properties
9
9
  *
10
10
  * All styling can be customized by overriding these CSS variables.
@@ -227,7 +227,7 @@ bp-player[waiting] {
227
227
  bp-player[has-error] {
228
228
  /* Styles when player has an error */
229
229
  }
230
- `;var dT=!1;function Yx(){if(dT||(dT=!0,document.getElementById("bp-player-styles")))return;$l();let n=document.createElement("style");n.id="bp-player-styles",n.textContent=cT,document.head.appendChild(n)}var zx=["emptied","loadstart","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","volumechange","ratechange","ended","loadedmetadata","loadeddata","canplay","canplaythrough","progress","error","resize"],ci=class extends li{constructor(){super(...arguments);this.autoplay=!1;this.defaultMuted=!1;this.loop=!1;this.scaling="letterbox";this.debug=!1;this._playerCore=null;this.containerRef=null;this.providerContainer=null;this.eventCleanup=[];this.stateReceivers=[];this._mutationObserver=null;this._videoRenditions=null;this._hasDispatchedReady=!1;this.handleMutation=t=>{for(let i of t)if(i.type==="childList"){for(let s of i.addedNodes)s.nodeType===Node.ELEMENT_NODE&&Fa(s,this.providerContainer,this.registerStateReceiver);for(let s of i.removedNodes)s.nodeType===Node.ELEMENT_NODE&&Fa(s,this.providerContainer,this.unregisterStateReceiver)}};this.registerStateReceiver=t=>{this.stateReceivers.includes(t)||(this.stateReceivers.push(t),this._playerCore&&tu(t,this._playerCore,this._playerCore.state))};this.unregisterStateReceiver=t=>{let i=this.stateReceivers.indexOf(t);i>=0&&(this.stateReceivers.splice(i,1),iu(t))}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Yx(),this._mutationObserver=new MutationObserver(this.handleMutation),this._mutationObserver.observe(this,{childList:!0,subtree:!0})}get player(){return this._playerCore}get playerState(){var t;return((t=this._playerCore)==null?void 0:t.state)??null}get bpLive(){var t;return((t=this._playerCore)==null?void 0:t.bpLive)??null}async play(){var t;this.debug&&console.log("[BPPlayer] play() called"),await((t=this._playerCore)==null?void 0:t.play())}pause(){var t;this.debug&&console.log("[BPPlayer] pause() called"),(t=this._playerCore)==null||t.pause()}get paused(){var i;let t=((i=this._playerCore)==null?void 0:i.state.paused)??!0;return this.debug&&console.log("[BPPlayer] paused getter:",t),t}get ended(){var t;return((t=this._playerCore)==null?void 0:t.state.ended)??!1}get seeking(){var t;return((t=this._playerCore)==null?void 0:t.state.seeking)??!1}get waiting(){var t;return((t=this._playerCore)==null?void 0:t.state.waiting)??!1}get currentTime(){var t;return((t=this._playerCore)==null?void 0:t.state.currentTime)??0}set currentTime(t){var i;(i=this._playerCore)==null||i.seek(t)}get duration(){var t;return((t=this._playerCore)==null?void 0:t.state.duration)??NaN}get volume(){var t;return((t=this._playerCore)==null?void 0:t.state.volume)??1}set volume(t){var i;(i=this._playerCore)==null||i.setVolume(t)}get muted(){var t;return((t=this._playerCore)==null?void 0:t.state.muted)??this.defaultMuted}set muted(t){var i;(i=this._playerCore)==null||i.setMuted(t)}get playbackRate(){var t;return((t=this._playerCore)==null?void 0:t.state.playbackRate)??1}set playbackRate(t){var i;(i=this._playerCore)==null||i.setPlaybackRate(t)}get readyState(){var t;return((t=this._playerCore)==null?void 0:t.state.readyState)??0}get buffered(){var i;let t=(i=this._playerCore)==null?void 0:i.state.buffered;return t||{length:0,start:s=>{throw new DOMException(`Index ${s} is out of bounds`,"IndexSizeError")},end:s=>{throw new DOMException(`Index ${s} is out of bounds`,"IndexSizeError")}}}get videoWidth(){var s,r,a;let t=(s=this._playerCore)==null?void 0:s.videoElement;if(t!=null&&t.videoWidth)return t.videoWidth;let i=(r=this._playerCore)==null?void 0:r.state.currentQuality;return i!=null&&i.width?i.width:((a=this._playerCore)==null?void 0:a.state.videoWidth)??0}get videoHeight(){var s,r,a;let t=(s=this._playerCore)==null?void 0:s.videoElement;if(t!=null&&t.videoHeight)return t.videoHeight;let i=(r=this._playerCore)==null?void 0:r.state.currentQuality;return i!=null&&i.height?i.height:((a=this._playerCore)==null?void 0:a.state.videoHeight)??0}get videoElement(){var t;return((t=this._playerCore)==null?void 0:t.videoElement)??null}get providerType(){var t;return((t=this._playerCore)==null?void 0:t.state.providerType)??null}get videoRenditions(){return this._videoRenditions}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._mutationObserver)==null||t.disconnect(),this.destroyPlayer()}firstUpdated(t){super.firstUpdated(t),this.containerRef=this.renderRoot.querySelector(".bp-player-container"),this.containerRef&&!this.providerContainer&&(this.providerContainer=document.createElement("div"),this.providerContainer.className="bp-player-provider",this.providerContainer.style.cssText="width: 100%; height: 100%; position: absolute; top: 0; left: 0;",this.containerRef.appendChild(this.providerContainer)),this.initPlayerCore()}updated(t){super.updated(t),t.has("source")&&this.loadSource(),t.has("defaultMuted")&&this._playerCore&&this._playerCore.setMuted(this.defaultMuted),t.has("loop")&&this._playerCore&&this._playerCore.setLoop(this.loop)}initPlayerCore(){var t;if(!(this._playerCore||!this.providerContainer))try{this._playerCore=Ap(),this.defaultMuted&&this._playerCore.setMuted(!0),this.loop&&this._playerCore.setLoop(!0),this._playerCore.attach(this.providerContainer,this.config),this.setupEventForwarding(),this._videoRenditions=new au(this),this._hasDispatchedReady||(this._hasDispatchedReady=!0,Fa(this,this.providerContainer,this.registerStateReceiver),this.dispatchEvent(Mr(ql,{detail:this._playerCore})),this.debug&&console.log("[BPPlayer] Player ready",(t=this._playerCore)==null?void 0:t.state))}catch(i){console.error("[BPPlayer] Failed to initialize player:",i),this.dispatchEvent(Xi(i instanceof Error?i:new Error(String(i))))}}async loadSource(){var i,s,r,a,o,l;let t=(s=(i=this.source)==null?void 0:i.sources)==null?void 0:s[0];if(!t){(r=this._playerCore)!=null&&r.ready&&this._playerCore.unloadSource();return}if(!this._playerCore||!this.providerContainer){this.debug&&console.log("[BPPlayer] loadSource skipped - player not initialized");return}this.debug&&console.log("[BPPlayer] loadSource:",t);try{let c=await this._playerCore.loadSource(t);if(!this._playerCore)return;if(c!=null&&c.videoWidth&&(c!=null&&c.videoHeight)&&(this.updateVideoDimensions(c.videoWidth,c.videoHeight),this.debug&&console.log("[BPPlayer] Source video dimensions:",{width:c.videoWidth,height:c.videoHeight})),(a=this._videoRenditions)==null||a._setupListeners(),this.propagateStateToAllReceivers(),this.updateStateAttributes(),(l=(o=this._playerCore)==null?void 0:o.state)!=null&&l.paused&&this.dispatchEvent(Ve(Or)),this.autoplay&&this._playerCore)try{await this._playerCore.play()}catch{}}catch(c){console.error("[BPPlayer] Failed to load source:",c),this.dispatchEvent(Xi(c instanceof Error?c:new Error(String(c))))}}propagateStateToAllReceivers(){if(!this._playerCore)return;let t=this._playerCore.state;for(let i of this.stateReceivers)tu(i,this._playerCore,t)}setupEventForwarding(){if(!this._playerCore)return;let t=this._playerCore;for(let a of zx){let o=()=>{this.debug&&!["durationchange","timeupdate"].includes(a)&&console.log(`[BPPlayer] Forwarding event: ${a}`,t.state),this.dispatchEvent(Ve(a))};t.addEventListener(a,o),this.eventCleanup.push(()=>t.removeEventListener(a,o))}let i=()=>{let a=t.videoElement;a&&this.updateVideoDimensions(a.videoWidth,a.videoHeight)};t.addEventListener("resize",i),t.addEventListener("loadedmetadata",i),this.eventCleanup.push(()=>t.removeEventListener("resize",i)),this.eventCleanup.push(()=>t.removeEventListener("loadedmetadata",i)),i();let s=()=>{this.dispatchEvent(Ve(ws))};t.addEventListener("qualitychange",s),this.eventCleanup.push(()=>t.removeEventListener("qualitychange",s));let r=()=>{this.propagateStateToAllReceivers(),this.updateStateAttributes()};t.addEventListener("statechange",r),this.eventCleanup.push(()=>t.removeEventListener("statechange",r))}updateStateAttributes(){if(!this._playerCore)return;let t=this._playerCore.state;Mt(this,"paused",t.paused),Mt(this,"playing",t.playing),Mt(this,"ended",t.ended),Mt(this,"seeking",t.seeking),Mt(this,"waiting",t.waiting),Mt(this,"has-error",t.error!==null),Mt(this,"ready",this._playerCore.ready),this.setAttribute("stream-type",t.streamType),this.setAttribute("content-type",t.contentType),t.providerType&&this.setAttribute("provider-type",t.providerType)}destroyPlayer(){var t;this.eventCleanup.forEach(i=>i()),this.eventCleanup=[],(t=this._videoRenditions)==null||t._destroy(),this._videoRenditions=null;for(let i of this.stateReceivers)iu(i);if(this.stateReceivers=[],this._playerCore&&(this._playerCore.destroy(),this._playerCore=null),this.providerContainer)for(;this.providerContainer.firstChild;)this.providerContainer.removeChild(this.providerContainer.firstChild);this.clearVideoDimensions(),this._hasDispatchedReady=!1}updateVideoDimensions(t,i){t>0&&i>0?(this.style.setProperty("--bp-video-width",String(t)),this.style.setProperty("--bp-video-height",String(i)),this.debug&&console.log("[BPPlayer] Set video dimensions:",{width:t,height:i})):(this.style.removeProperty("--bp-video-width"),this.style.removeProperty("--bp-video-height"),this.debug&&console.log("[BPPlayer] Cleared video dimensions"))}clearVideoDimensions(){this.style.removeProperty("--bp-video-width"),this.style.removeProperty("--bp-video-height")}getContainerClasses(){return["bp-player-container",`bp-player-container--${this.scaling}`].join(" ")}getContainerStyle(){return this.aspectRatio?`aspect-ratio: ${this.aspectRatio}`:""}render(){return Fi`
230
+ `;var dT=!1;function Yx(){if(dT||(dT=!0,document.getElementById("bp-player-styles")))return;$l();let n=document.createElement("style");n.id="bp-player-styles",n.textContent=cT,document.head.appendChild(n)}var zx=["emptied","loadstart","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","volumechange","ratechange","ended","loadedmetadata","loadeddata","canplay","canplaythrough","progress","error","resize"],ci=class extends li{constructor(){super(...arguments);this.autoplay=!1;this.defaultMuted=!1;this.loop=!1;this.scaling="letterbox";this.debug=!1;this._playerCore=null;this.containerRef=null;this.providerContainer=null;this.eventCleanup=[];this.stateReceivers=[];this._mutationObserver=null;this._videoRenditions=null;this._hasDispatchedReady=!1;this.handleMutation=t=>{for(let i of t)if(i.type==="childList"){for(let s of i.addedNodes)s.nodeType===Node.ELEMENT_NODE&&Fa(s,this.providerContainer,this.registerStateReceiver);for(let s of i.removedNodes)s.nodeType===Node.ELEMENT_NODE&&Fa(s,this.providerContainer,this.unregisterStateReceiver)}};this.registerStateReceiver=t=>{this.stateReceivers.includes(t)||(this.stateReceivers.push(t),this._playerCore&&tu(t,this._playerCore,this._playerCore.state))};this.unregisterStateReceiver=t=>{let i=this.stateReceivers.indexOf(t);i>=0&&(this.stateReceivers.splice(i,1),iu(t))}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Yx(),this._mutationObserver=new MutationObserver(this.handleMutation),this._mutationObserver.observe(this,{childList:!0,subtree:!0})}get player(){return this._playerCore}get playerState(){var t;return((t=this._playerCore)==null?void 0:t.state)??null}get bpLive(){var t;return((t=this._playerCore)==null?void 0:t.bpLive)??null}async play(){var t;this.debug&&console.log("[BPPlayer] play() called"),await((t=this._playerCore)==null?void 0:t.play())}pause(){var t;this.debug&&console.log("[BPPlayer] pause() called"),(t=this._playerCore)==null||t.pause()}get paused(){var i;let t=((i=this._playerCore)==null?void 0:i.state.paused)??!0;return this.debug&&console.log("[BPPlayer] paused getter:",t),t}get ended(){var t;return((t=this._playerCore)==null?void 0:t.state.ended)??!1}get seeking(){var t;return((t=this._playerCore)==null?void 0:t.state.seeking)??!1}get waiting(){var t;return((t=this._playerCore)==null?void 0:t.state.waiting)??!1}get currentTime(){var t;return((t=this._playerCore)==null?void 0:t.state.currentTime)??0}set currentTime(t){var i;(i=this._playerCore)==null||i.seek(t)}get duration(){var t;return((t=this._playerCore)==null?void 0:t.state.duration)??NaN}get volume(){var t;return((t=this._playerCore)==null?void 0:t.state.volume)??1}set volume(t){var i;(i=this._playerCore)==null||i.setVolume(t)}get muted(){var t;return((t=this._playerCore)==null?void 0:t.state.muted)??this.defaultMuted}set muted(t){var i;(i=this._playerCore)==null||i.setMuted(t)}get playbackRate(){var t;return((t=this._playerCore)==null?void 0:t.state.playbackRate)??1}set playbackRate(t){var i;(i=this._playerCore)==null||i.setPlaybackRate(t)}get readyState(){var t;return((t=this._playerCore)==null?void 0:t.state.readyState)??0}get buffered(){var i;let t=(i=this._playerCore)==null?void 0:i.state.buffered;return t||{length:0,start:s=>{throw new DOMException(`Index ${s} is out of bounds`,"IndexSizeError")},end:s=>{throw new DOMException(`Index ${s} is out of bounds`,"IndexSizeError")}}}get videoWidth(){var s,r,a;let t=(s=this._playerCore)==null?void 0:s.videoElement;if(t!=null&&t.videoWidth)return t.videoWidth;let i=(r=this._playerCore)==null?void 0:r.state.currentQuality;return i!=null&&i.width?i.width:((a=this._playerCore)==null?void 0:a.state.videoWidth)??0}get videoHeight(){var s,r,a;let t=(s=this._playerCore)==null?void 0:s.videoElement;if(t!=null&&t.videoHeight)return t.videoHeight;let i=(r=this._playerCore)==null?void 0:r.state.currentQuality;return i!=null&&i.height?i.height:((a=this._playerCore)==null?void 0:a.state.videoHeight)??0}get videoElement(){var t;return((t=this._playerCore)==null?void 0:t.videoElement)??null}webkitEnterFullscreen(){var i,s;let t=(i=this._playerCore)==null?void 0:i.activeVideoElement;(s=t==null?void 0:t.webkitEnterFullscreen)==null||s.call(t)}get webkitDisplayingFullscreen(){var i;let t=(i=this._playerCore)==null?void 0:i.activeVideoElement;return(t==null?void 0:t.webkitDisplayingFullscreen)??!1}get webkitPresentationMode(){var i;let t=(i=this._playerCore)==null?void 0:i.activeVideoElement;return(t==null?void 0:t.webkitPresentationMode)??"inline"}get providerType(){var t;return((t=this._playerCore)==null?void 0:t.state.providerType)??null}get videoRenditions(){return this._videoRenditions}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._mutationObserver)==null||t.disconnect(),this.destroyPlayer()}firstUpdated(t){super.firstUpdated(t),this.containerRef=this.renderRoot.querySelector(".bp-player-container"),this.containerRef&&!this.providerContainer&&(this.providerContainer=document.createElement("div"),this.providerContainer.className="bp-player-provider",this.providerContainer.style.cssText="width: 100%; height: 100%; position: absolute; top: 0; left: 0;",this.containerRef.appendChild(this.providerContainer)),this.initPlayerCore()}updated(t){super.updated(t),t.has("source")&&this.loadSource(),t.has("defaultMuted")&&this._playerCore&&this._playerCore.setMuted(this.defaultMuted),t.has("loop")&&this._playerCore&&this._playerCore.setLoop(this.loop)}initPlayerCore(){var t;if(!(this._playerCore||!this.providerContainer))try{this._playerCore=Ap(),this.defaultMuted&&this._playerCore.setMuted(!0),this.loop&&this._playerCore.setLoop(!0),this._playerCore.attach(this.providerContainer,this.config),this.setupEventForwarding(),this._videoRenditions=new au(this),this._hasDispatchedReady||(this._hasDispatchedReady=!0,Fa(this,this.providerContainer,this.registerStateReceiver),this.dispatchEvent(Mr(ql,{detail:this._playerCore})),this.debug&&console.log("[BPPlayer] Player ready",(t=this._playerCore)==null?void 0:t.state))}catch(i){console.error("[BPPlayer] Failed to initialize player:",i),this.dispatchEvent(Xi(i instanceof Error?i:new Error(String(i))))}}async loadSource(){var i,s,r,a,o,l;let t=(s=(i=this.source)==null?void 0:i.sources)==null?void 0:s[0];if(!t){(r=this._playerCore)!=null&&r.ready&&this._playerCore.unloadSource();return}if(!this._playerCore||!this.providerContainer){this.debug&&console.log("[BPPlayer] loadSource skipped - player not initialized");return}this.debug&&console.log("[BPPlayer] loadSource:",t);try{let c=await this._playerCore.loadSource(t);if(!this._playerCore)return;if(c!=null&&c.videoWidth&&(c!=null&&c.videoHeight)&&(this.updateVideoDimensions(c.videoWidth,c.videoHeight),this.debug&&console.log("[BPPlayer] Source video dimensions:",{width:c.videoWidth,height:c.videoHeight})),(a=this._videoRenditions)==null||a._setupListeners(),this.propagateStateToAllReceivers(),this.updateStateAttributes(),(l=(o=this._playerCore)==null?void 0:o.state)!=null&&l.paused&&this.dispatchEvent(Ve(Or)),this.autoplay&&this._playerCore)try{await this._playerCore.play()}catch{}}catch(c){console.error("[BPPlayer] Failed to load source:",c),this.dispatchEvent(Xi(c instanceof Error?c:new Error(String(c))))}}propagateStateToAllReceivers(){if(!this._playerCore)return;let t=this._playerCore.state;for(let i of this.stateReceivers)tu(i,this._playerCore,t)}setupEventForwarding(){if(!this._playerCore)return;let t=this._playerCore;for(let l of zx){let c=()=>{this.debug&&!["durationchange","timeupdate"].includes(l)&&console.log(`[BPPlayer] Forwarding event: ${l}`,t.state),this.dispatchEvent(Ve(l))};t.addEventListener(l,c),this.eventCleanup.push(()=>t.removeEventListener(l,c))}let i=()=>{let l=t.videoElement;l&&this.updateVideoDimensions(l.videoWidth,l.videoHeight)};t.addEventListener("resize",i),t.addEventListener("loadedmetadata",i),this.eventCleanup.push(()=>t.removeEventListener("resize",i)),this.eventCleanup.push(()=>t.removeEventListener("loadedmetadata",i)),i();let s=()=>{this.dispatchEvent(Ve(ws))};t.addEventListener("qualitychange",s),this.eventCleanup.push(()=>t.removeEventListener("qualitychange",s));let r=()=>{this.propagateStateToAllReceivers(),this.updateStateAttributes()};t.addEventListener("statechange",r),this.eventCleanup.push(()=>t.removeEventListener("statechange",r));let a=[],o=()=>{a.forEach(c=>c()),a=[];let l=t.activeVideoElement;if(l)for(let c of["webkitbeginfullscreen","webkitendfullscreen"]){let d=()=>this.dispatchEvent(new Event(c));l.addEventListener(c,d),a.push(()=>l.removeEventListener(c,d))}};o(),t.addEventListener("activevideoelementchange",o),this.eventCleanup.push(()=>t.removeEventListener("activevideoelementchange",o)),this.eventCleanup.push(()=>a.forEach(l=>l()))}updateStateAttributes(){if(!this._playerCore)return;let t=this._playerCore.state;Mt(this,"paused",t.paused),Mt(this,"playing",t.playing),Mt(this,"ended",t.ended),Mt(this,"seeking",t.seeking),Mt(this,"waiting",t.waiting),Mt(this,"has-error",t.error!==null),Mt(this,"ready",this._playerCore.ready),this.setAttribute("stream-type",t.streamType),this.setAttribute("content-type",t.contentType),t.providerType&&this.setAttribute("provider-type",t.providerType)}destroyPlayer(){var t;this.eventCleanup.forEach(i=>i()),this.eventCleanup=[],(t=this._videoRenditions)==null||t._destroy(),this._videoRenditions=null;for(let i of this.stateReceivers)iu(i);if(this.stateReceivers=[],this._playerCore&&(this._playerCore.destroy(),this._playerCore=null),this.providerContainer)for(;this.providerContainer.firstChild;)this.providerContainer.removeChild(this.providerContainer.firstChild);this.clearVideoDimensions(),this._hasDispatchedReady=!1}updateVideoDimensions(t,i){t>0&&i>0?(this.style.setProperty("--bp-video-width",String(t)),this.style.setProperty("--bp-video-height",String(i)),this.debug&&console.log("[BPPlayer] Set video dimensions:",{width:t,height:i})):(this.style.removeProperty("--bp-video-width"),this.style.removeProperty("--bp-video-height"),this.debug&&console.log("[BPPlayer] Cleared video dimensions"))}clearVideoDimensions(){this.style.removeProperty("--bp-video-width"),this.style.removeProperty("--bp-video-height")}getContainerClasses(){return["bp-player-container",`bp-player-container--${this.scaling}`].join(" ")}getContainerStyle(){return this.aspectRatio?`aspect-ratio: ${this.aspectRatio}`:""}render(){return Fi`
231
231
  <div
232
232
  class="${this.getContainerClasses()}"
233
233
  style="${this.getContainerStyle()}"
@@ -2990,7 +2990,7 @@ a=extmap-allow-mixed`)!==-1){let r=s.sdp.split(`
2990
2990
  ${JSON.stringify(i.config||{})}
2991
2991
  <\/script>
2992
2992
  ${pi.getTemplateHTML(a)}
2993
- `}get activeVideoElement(){return P(this,it)}get config(){return P(this,Ni)}set config(t){F(this,Ni,t)}get url(){return this.getAttribute("url")}set url(t){t?this.setAttribute("url",t):this.removeAttribute("url")}get token(){return this.getAttribute("token")}set token(t){t?this.setAttribute("token",t):this.removeAttribute("token")}attributeChangedCallback(t,i,s){(t==="url"||t==="token")&&i!==s?this.url&&this.token?this.load():P(this,Pe)&&pe(this,pt,ep).call(this):t!=="url"&&t!=="token"&&super.attributeChangedCallback(t,i,s)}async load(){var b,T,S;let t=!P(this,Pe);pe(this,pt,ep).call(this);let i=this.url,s=this.token;if(!i||!s)return;if(F(this,Pa,new Promise(k=>{F(this,Ir,k)})),t&&!P(this,Ni))try{F(this,Ni,JSON.parse(((T=(b=this.shadowRoot)==null?void 0:b.getElementById("config"))==null?void 0:T.textContent)||"{}"))}catch(k){console.error("[livekit-video] Failed to parse config:",k),F(this,Ni,{})}let r=pe(this,pt,Tx).call(this),a=pe(this,pt,Sx).call(this);F(this,Pe,new kl(r)),this.room=P(this,Pe);let o=()=>{F(this,is,"connected")},l=k=>{let I=k!=null?Mi[k]??String(k):"undefined";console.log("[livekit-video] Disconnected",{reason:k,reasonName:I,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState}),F(this,is,"disconnected"),k?this.dispatchEvent(Xi(new Error(`LiveKit disconnected: ${I} (${k})`),4001)):this.dispatchEvent(Ve(Hl))},c=()=>{console.log("[livekit-video] Reconnecting",{documentHidden:document.hidden,documentHasFocus:document.hasFocus()}),F(this,is,"reconnecting"),this.dispatchEvent(Ve($a))},d=()=>{console.log("[livekit-video] Reconnected"),F(this,is,"connected"),this.dispatchEvent(Ve(Ps))},u=()=>{console.log("[livekit-video] SignalReconnecting")},h=k=>{console.log("[livekit-video] ConnectionStateChanged",k)},f=k=>{console.error("[livekit-video] MediaDevicesError",k)},m=(k,I,A)=>{console.error("[livekit-video] TrackSubscriptionFailed",{trackSid:k,reason:A})},p=k=>{console.log("[livekit-video] TrackMuted",{sid:k.trackSid,kind:k.kind})},g=k=>{console.log("[livekit-video] TrackUnmuted",{sid:k.trackSid,kind:k.kind})},v=(k,I)=>{var A,R,C;if(k.kind===$.Kind.Video){let w=k.attach();w.style.width="100%",w.style.height="100%",w.style.objectFit="contain",w.style.position="absolute",w.style.top="0",w.style.left="0",this.nativeEl.muted&&(w.muted=!0),this.nativeEl.style.display="none",(A=this.shadowRoot)==null||A.appendChild(w),F(this,it,w),pe(this,pt,Ex).call(this,w),pe(this,pt,bx).call(this,I),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:w}})),this.dispatchEvent(Ve(xp)),this.dispatchEvent(Ve(ws)),this.dispatchEvent(Ve(Kl)),this.dispatchEvent(Ve(Ps)),(R=P(this,Ir))==null||R.call(this)}else if(k.kind===$.Kind.Audio){let w=k.attach();w.style.display="none";let O=P(this,it)??this.nativeEl;w.muted=O.muted,w.volume=O.volume,(C=this.shadowRoot)==null||C.appendChild(w),F(this,_i,w)}},E=k=>{k.kind===$.Kind.Video?(k.detach(),pe(this,pt,tp).call(this),P(this,it)&&(P(this,Yi).forEach(I=>I()),F(this,Yi,[]),P(this,it).remove(),F(this,it,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}})))):k.kind===$.Kind.Audio&&(k.detach(),P(this,_i)&&(P(this,_i).remove(),F(this,_i,null)))};P(this,Pe).on(U.Connected,o),P(this,Pe).on(U.Disconnected,l),P(this,Pe).on(U.Reconnecting,c),P(this,Pe).on(U.Reconnected,d),P(this,Pe).on(U.SignalReconnecting,u),P(this,Pe).on(U.ConnectionStateChanged,h),P(this,Pe).on(U.MediaDevicesError,f),P(this,Pe).on(U.TrackSubscribed,v),P(this,Pe).on(U.TrackUnsubscribed,E),P(this,Pe).on(U.TrackSubscriptionFailed,m),P(this,Pe).on(U.TrackMuted,p),P(this,Pe).on(U.TrackUnmuted,g),F(this,Cl,[()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Connected,o)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Disconnected,l)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Reconnecting,c)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Reconnected,d)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.SignalReconnecting,u)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.ConnectionStateChanged,h)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.MediaDevicesError,f)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackSubscribed,v)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackUnsubscribed,E)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackSubscriptionFailed,m)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackMuted,p)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackUnmuted,g)}]),F(this,is,"connecting"),this.dispatchEvent(Ve(Rp));try{await P(this,Pe).connect(i,s,a)}catch(k){F(this,is,"failed"),console.error("[livekit-video] Failed to connect:",k);let I=k instanceof Error?k.message:"Failed to connect to LiveKit room";this.dispatchEvent(Xi(new Error(I),4e3)),(S=P(this,Ir))==null||S.call(this)}}async play(){return P(this,Pa)&&await P(this,Pa),P(this,it)?P(this,it).play():super.play()}pause(){if(P(this,it)){P(this,it).pause();return}super.pause()}get currentTime(){var t;return((t=P(this,it))==null?void 0:t.currentTime)??super.currentTime}set currentTime(t){P(this,Pe)||(super.currentTime=t)}get duration(){return 1/0}get paused(){var t;return((t=P(this,it))==null?void 0:t.paused)??super.paused}get volume(){var t;return((t=P(this,it))==null?void 0:t.volume)??super.volume}set volume(t){P(this,it)?P(this,it).volume=t:super.volume=t,P(this,_i)&&(P(this,_i).volume=t)}get muted(){var t;return((t=P(this,it))==null?void 0:t.muted)??super.muted}set muted(t){P(this,it)?P(this,it).muted=t:super.muted=t,P(this,_i)&&(P(this,_i).muted=t)}get videoWidth(){var t;return((t=P(this,it))==null?void 0:t.videoWidth)??super.videoWidth}get videoHeight(){var t;return((t=P(this,it))==null?void 0:t.videoHeight)??super.videoHeight}disconnectedCallback(){var t;pe(this,pt,ep).call(this),(t=super.disconnectedCallback)==null||t.call(this)}};Ni=new WeakMap,Pe=new WeakMap,it=new WeakMap,_i=new WeakMap,Yi=new WeakMap,Al=new WeakMap,Cl=new WeakMap,is=new WeakMap,Pa=new WeakMap,Ir=new WeakMap,pt=new WeakSet,ep=function(){var t;(t=P(this,Ir))==null||t.call(this),F(this,Pa,null),F(this,Ir,null),P(this,Yi).forEach(i=>i()),F(this,Yi,[]),pe(this,pt,tp).call(this),P(this,Cl).forEach(i=>i()),F(this,Cl,[]),P(this,Pe)&&(P(this,Pe).disconnect(),F(this,Pe,null),this.room=null),P(this,it)&&(P(this,it).remove(),F(this,it,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}}))),P(this,_i)&&(P(this,_i).remove(),F(this,_i,null)),F(this,is,"disconnected")},Ex=function(t){P(this,Yi).forEach(a=>a()),F(this,Yi,[]);let i=[Gl,Wl,Vl,Ps,Or,ws];for(let a of i){let o=()=>{this.dispatchEvent(Ve(a))};t.addEventListener(a,o),P(this,Yi).push(()=>t.removeEventListener(a,o))}let s=()=>{var o,l,c;let a=t.srcObject;console.error("[livekit-video] attached <video> error",{code:(o=t.error)==null?void 0:o.code,message:(l=t.error)==null?void 0:l.message,readyState:t.readyState,networkState:t.networkState,paused:t.paused,srcObjectActive:a==null?void 0:a.active,tracks:a==null?void 0:a.getTracks().map(d=>({kind:d.kind,readyState:d.readyState,muted:d.muted,enabled:d.enabled})),documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState,roomState:(c=P(this,Pe))==null?void 0:c.state})};t.addEventListener("error",s),P(this,Yi).push(()=>t.removeEventListener("error",s));let r=()=>{console.warn("[livekit-video] attached <video> stalled",{readyState:t.readyState,networkState:t.networkState,documentHidden:document.hidden})};t.addEventListener("stalled",r),P(this,Yi).push(()=>t.removeEventListener("stalled",r))},bx=function(t){var o;pe(this,pt,tp).call(this);let i=(o=t.trackInfo)==null?void 0:o.layers;if(!i||i.length===0)return;let s=this.addVideoTrack("main");s.id="main",s.selected=!0;let r=[...i].sort((l,c)=>l.quality-c.quality);for(let l of r){let c=s.addRendition("",l.width,l.height,void 0,l.bitrate);c.id=`${l.quality}`}let a=()=>{let l=this.videoRenditions.selectedIndex;if(l<0)t.setVideoQuality(oi.HIGH);else{let c=r[l];c&&t.setVideoQuality(c.quality)}};this.videoRenditions.addEventListener("change",a),P(this,Al).push(()=>this.videoRenditions.removeEventListener("change",a))},tp=function(){P(this,Al).forEach(t=>t()),F(this,Al,[]);for(let t of this.videoTracks)this.removeVideoTrack(t);for(let t of this.audioTracks)this.removeAudioTrack(t)},Tx=function(){var t,i,s;return{adaptiveStream:((t=P(this,Ni))==null?void 0:t.adaptiveStream)??!1,dynacast:((i=P(this,Ni))==null?void 0:i.dynacast)??!0,disconnectOnPageLeave:((s=P(this,Ni))==null?void 0:s.disconnectOnPageLeave)??!1}},Sx=function(){var t,i;return{autoSubscribe:!0,peerConnectionTimeout:((t=P(this,Ni))==null?void 0:t.peerConnectionTimeout)??8e3,rtcConfig:{iceTransportPolicy:((i=P(this,Ni))==null?void 0:i.iceTransportPolicy)??"all"}}},ip=function(t){if(Object.prototype.hasOwnProperty.call(this,t)){let i=this[t];delete this[t],this[t]=i}},wa.shadowRootOptions={...pi.shadowRootOptions};globalThis.customElements&&!globalThis.customElements.get("livekit-video")&&globalThis.customElements.define("livekit-video",wa);var _x=wa;export{nu as Attribute,at as BPDefaultUI,qs as BPErrorDisplay,Tn as BPLiveError,Ul as BPLiveService,ds as BPOverlay,ci as BPPlayer,Kt as Hls,ba as HlsVideo,RC as HlsVideoElement,wa as LiveKitVideo,_x as LiveKitVideoElement,Fx as NANOPLAYER_NO_REPLAY_CODES,ka as NanoVideo,DC as NanoVideoElement,Vx as StateReceiverMixin,Ua as StateReceiverProps,$l as addGlobalStyles,bp as classifyLiveKitError,Ep as classifyNanoPlayerError,Jd as createInitialState,Ap as createPlayerCore,Wx as createTemplate,Fa as forEachStateReceiverElement,eu as isBPLiveClipSource,Tp as isBPLiveSource,Zd as isBPLiveStreamSource,Cp as isStateReceiverElement,tu as propagateStateToReceiver,iu as removeStateFromReceiver,qx as templateWithStyles,Mt as toggleAttribute};
2993
+ `}get activeVideoElement(){return P(this,it)}get config(){return P(this,Ni)}set config(t){F(this,Ni,t)}get url(){return this.getAttribute("url")}set url(t){t?this.setAttribute("url",t):this.removeAttribute("url")}get token(){return this.getAttribute("token")}set token(t){t?this.setAttribute("token",t):this.removeAttribute("token")}attributeChangedCallback(t,i,s){(t==="url"||t==="token")&&i!==s?this.url&&this.token?this.load():P(this,Pe)&&pe(this,pt,ep).call(this):t!=="url"&&t!=="token"&&super.attributeChangedCallback(t,i,s)}async load(){var b,T,S;let t=!P(this,Pe);pe(this,pt,ep).call(this);let i=this.url,s=this.token;if(!i||!s)return;if(F(this,Pa,new Promise(k=>{F(this,Ir,k)})),t&&!P(this,Ni))try{F(this,Ni,JSON.parse(((T=(b=this.shadowRoot)==null?void 0:b.getElementById("config"))==null?void 0:T.textContent)||"{}"))}catch(k){console.error("[livekit-video] Failed to parse config:",k),F(this,Ni,{})}let r=pe(this,pt,Tx).call(this),a=pe(this,pt,Sx).call(this);F(this,Pe,new kl(r)),this.room=P(this,Pe);let o=()=>{F(this,is,"connected")},l=k=>{let I=k!=null?Mi[k]??String(k):"undefined";console.log("[livekit-video] Disconnected",{reason:k,reasonName:I,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState}),F(this,is,"disconnected"),k?this.dispatchEvent(Xi(new Error(`LiveKit disconnected: ${I} (${k})`),4001)):this.dispatchEvent(Ve(Hl))},c=()=>{console.log("[livekit-video] Reconnecting",{documentHidden:document.hidden,documentHasFocus:document.hasFocus()}),F(this,is,"reconnecting"),this.dispatchEvent(Ve($a))},d=()=>{console.log("[livekit-video] Reconnected"),F(this,is,"connected"),this.dispatchEvent(Ve(Ps))},u=()=>{console.log("[livekit-video] SignalReconnecting")},h=k=>{console.log("[livekit-video] ConnectionStateChanged",k)},f=k=>{console.error("[livekit-video] MediaDevicesError",k)},m=(k,I,A)=>{console.error("[livekit-video] TrackSubscriptionFailed",{trackSid:k,reason:A})},p=k=>{console.log("[livekit-video] TrackMuted",{sid:k.trackSid,kind:k.kind})},g=k=>{console.log("[livekit-video] TrackUnmuted",{sid:k.trackSid,kind:k.kind})},v=(k,I)=>{var A,R,C;if(k.kind===$.Kind.Video){let w=k.attach();w.style.width="100%",w.style.height="100%",w.style.objectFit="contain",w.style.position="absolute",w.style.top="0",w.style.left="0",w.playsInline=!0,w.setAttribute("playsinline",""),w.setAttribute("webkit-playsinline",""),this.nativeEl.muted&&(w.muted=!0),this.nativeEl.style.display="none",(A=this.shadowRoot)==null||A.appendChild(w),F(this,it,w),pe(this,pt,Ex).call(this,w),pe(this,pt,bx).call(this,I),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:w}})),this.dispatchEvent(Ve(xp)),this.dispatchEvent(Ve(ws)),this.dispatchEvent(Ve(Kl)),this.dispatchEvent(Ve(Ps)),(R=P(this,Ir))==null||R.call(this)}else if(k.kind===$.Kind.Audio){let w=k.attach();w.style.display="none";let O=P(this,it)??this.nativeEl;w.muted=O.muted,w.volume=O.volume,(C=this.shadowRoot)==null||C.appendChild(w),F(this,_i,w)}},E=k=>{k.kind===$.Kind.Video?(k.detach(),pe(this,pt,tp).call(this),P(this,it)&&(P(this,Yi).forEach(I=>I()),F(this,Yi,[]),P(this,it).remove(),F(this,it,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}})))):k.kind===$.Kind.Audio&&(k.detach(),P(this,_i)&&(P(this,_i).remove(),F(this,_i,null)))};P(this,Pe).on(U.Connected,o),P(this,Pe).on(U.Disconnected,l),P(this,Pe).on(U.Reconnecting,c),P(this,Pe).on(U.Reconnected,d),P(this,Pe).on(U.SignalReconnecting,u),P(this,Pe).on(U.ConnectionStateChanged,h),P(this,Pe).on(U.MediaDevicesError,f),P(this,Pe).on(U.TrackSubscribed,v),P(this,Pe).on(U.TrackUnsubscribed,E),P(this,Pe).on(U.TrackSubscriptionFailed,m),P(this,Pe).on(U.TrackMuted,p),P(this,Pe).on(U.TrackUnmuted,g),F(this,Cl,[()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Connected,o)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Disconnected,l)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Reconnecting,c)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.Reconnected,d)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.SignalReconnecting,u)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.ConnectionStateChanged,h)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.MediaDevicesError,f)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackSubscribed,v)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackUnsubscribed,E)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackSubscriptionFailed,m)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackMuted,p)},()=>{var k;return(k=P(this,Pe))==null?void 0:k.off(U.TrackUnmuted,g)}]),F(this,is,"connecting"),this.dispatchEvent(Ve(Rp));try{await P(this,Pe).connect(i,s,a)}catch(k){F(this,is,"failed"),console.error("[livekit-video] Failed to connect:",k);let I=k instanceof Error?k.message:"Failed to connect to LiveKit room";this.dispatchEvent(Xi(new Error(I),4e3)),(S=P(this,Ir))==null||S.call(this)}}async play(){return P(this,Pa)&&await P(this,Pa),P(this,it)?P(this,it).play():super.play()}pause(){if(P(this,it)){P(this,it).pause();return}super.pause()}get currentTime(){var t;return((t=P(this,it))==null?void 0:t.currentTime)??super.currentTime}set currentTime(t){P(this,Pe)||(super.currentTime=t)}get duration(){return 1/0}get paused(){var t;return((t=P(this,it))==null?void 0:t.paused)??super.paused}get volume(){var t;return((t=P(this,it))==null?void 0:t.volume)??super.volume}set volume(t){P(this,it)?P(this,it).volume=t:super.volume=t,P(this,_i)&&(P(this,_i).volume=t)}get muted(){var t;return((t=P(this,it))==null?void 0:t.muted)??super.muted}set muted(t){P(this,it)?P(this,it).muted=t:super.muted=t,P(this,_i)&&(P(this,_i).muted=t)}get videoWidth(){var t;return((t=P(this,it))==null?void 0:t.videoWidth)??super.videoWidth}get videoHeight(){var t;return((t=P(this,it))==null?void 0:t.videoHeight)??super.videoHeight}disconnectedCallback(){var t;pe(this,pt,ep).call(this),(t=super.disconnectedCallback)==null||t.call(this)}};Ni=new WeakMap,Pe=new WeakMap,it=new WeakMap,_i=new WeakMap,Yi=new WeakMap,Al=new WeakMap,Cl=new WeakMap,is=new WeakMap,Pa=new WeakMap,Ir=new WeakMap,pt=new WeakSet,ep=function(){var t;(t=P(this,Ir))==null||t.call(this),F(this,Pa,null),F(this,Ir,null),P(this,Yi).forEach(i=>i()),F(this,Yi,[]),pe(this,pt,tp).call(this),P(this,Cl).forEach(i=>i()),F(this,Cl,[]),P(this,Pe)&&(P(this,Pe).disconnect(),F(this,Pe,null),this.room=null),P(this,it)&&(P(this,it).remove(),F(this,it,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}}))),P(this,_i)&&(P(this,_i).remove(),F(this,_i,null)),F(this,is,"disconnected")},Ex=function(t){P(this,Yi).forEach(a=>a()),F(this,Yi,[]);let i=[Gl,Wl,Vl,Ps,Or,ws];for(let a of i){let o=()=>{this.dispatchEvent(Ve(a))};t.addEventListener(a,o),P(this,Yi).push(()=>t.removeEventListener(a,o))}let s=()=>{var o,l,c;let a=t.srcObject;console.error("[livekit-video] attached <video> error",{code:(o=t.error)==null?void 0:o.code,message:(l=t.error)==null?void 0:l.message,readyState:t.readyState,networkState:t.networkState,paused:t.paused,srcObjectActive:a==null?void 0:a.active,tracks:a==null?void 0:a.getTracks().map(d=>({kind:d.kind,readyState:d.readyState,muted:d.muted,enabled:d.enabled})),documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState,roomState:(c=P(this,Pe))==null?void 0:c.state})};t.addEventListener("error",s),P(this,Yi).push(()=>t.removeEventListener("error",s));let r=()=>{console.warn("[livekit-video] attached <video> stalled",{readyState:t.readyState,networkState:t.networkState,documentHidden:document.hidden})};t.addEventListener("stalled",r),P(this,Yi).push(()=>t.removeEventListener("stalled",r))},bx=function(t){var o;pe(this,pt,tp).call(this);let i=(o=t.trackInfo)==null?void 0:o.layers;if(!i||i.length===0)return;let s=this.addVideoTrack("main");s.id="main",s.selected=!0;let r=[...i].sort((l,c)=>l.quality-c.quality);for(let l of r){let c=s.addRendition("",l.width,l.height,void 0,l.bitrate);c.id=`${l.quality}`}let a=()=>{let l=this.videoRenditions.selectedIndex;if(l<0)t.setVideoQuality(oi.HIGH);else{let c=r[l];c&&t.setVideoQuality(c.quality)}};this.videoRenditions.addEventListener("change",a),P(this,Al).push(()=>this.videoRenditions.removeEventListener("change",a))},tp=function(){P(this,Al).forEach(t=>t()),F(this,Al,[]);for(let t of this.videoTracks)this.removeVideoTrack(t);for(let t of this.audioTracks)this.removeAudioTrack(t)},Tx=function(){var t,i,s;return{adaptiveStream:((t=P(this,Ni))==null?void 0:t.adaptiveStream)??!1,dynacast:((i=P(this,Ni))==null?void 0:i.dynacast)??!0,disconnectOnPageLeave:((s=P(this,Ni))==null?void 0:s.disconnectOnPageLeave)??!1}},Sx=function(){var t,i;return{autoSubscribe:!0,peerConnectionTimeout:((t=P(this,Ni))==null?void 0:t.peerConnectionTimeout)??8e3,rtcConfig:{iceTransportPolicy:((i=P(this,Ni))==null?void 0:i.iceTransportPolicy)??"all"}}},ip=function(t){if(Object.prototype.hasOwnProperty.call(this,t)){let i=this[t];delete this[t],this[t]=i}},wa.shadowRootOptions={...pi.shadowRootOptions};globalThis.customElements&&!globalThis.customElements.get("livekit-video")&&globalThis.customElements.define("livekit-video",wa);var _x=wa;export{nu as Attribute,at as BPDefaultUI,qs as BPErrorDisplay,Tn as BPLiveError,Ul as BPLiveService,ds as BPOverlay,ci as BPPlayer,Kt as Hls,ba as HlsVideo,RC as HlsVideoElement,wa as LiveKitVideo,_x as LiveKitVideoElement,Fx as NANOPLAYER_NO_REPLAY_CODES,ka as NanoVideo,DC as NanoVideoElement,Vx as StateReceiverMixin,Ua as StateReceiverProps,$l as addGlobalStyles,bp as classifyLiveKitError,Ep as classifyNanoPlayerError,Jd as createInitialState,Ap as createPlayerCore,Wx as createTemplate,Fa as forEachStateReceiverElement,eu as isBPLiveClipSource,Tp as isBPLiveSource,Zd as isBPLiveStreamSource,Cp as isStateReceiverElement,tu as propagateStateToReceiver,iu as removeStateFromReceiver,qx as templateWithStyles,Mt as toggleAttribute};
2994
2994
  /*! Bundled license information:
2995
2995
 
2996
2996
  @lit/reactive-element/css-tag.js:
@@ -56,6 +56,9 @@ export declare class BPPlayer extends LitElement {
56
56
  get videoWidth(): number;
57
57
  get videoHeight(): number;
58
58
  get videoElement(): HTMLVideoElement | null;
59
+ webkitEnterFullscreen(): void;
60
+ get webkitDisplayingFullscreen(): boolean;
61
+ get webkitPresentationMode(): 'inline' | 'fullscreen' | 'picture-in-picture';
59
62
  get providerType(): ProviderType | null;
60
63
  get videoRenditions(): VideoRenditionList | null;
61
64
  disconnectedCallback(): void;
@@ -0,0 +1,2 @@
1
+ import './bp-player';
2
+ //# sourceMappingURL=bp-player.test.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@broadcastingplatforms/player",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "Universal video player web component built with Lit",
5
5
  "type": "module",
6
6
  "main": "dist/bp-player.js",