import{d as Je,c as x,f as we,h as et,o as tt,j as it,Z as C,a1 as E,a7 as S,a6 as W,a9 as V,ay as G,av as Q,cE as st,cI as nt,cJ as rt,a2 as at,a3 as ot,at as lt}from"./index-8a67e3df.js";import{V as ut,A as ct,a as ht,b as ae,c as dt}from"./canvas-2aaf4e1d.js";var H={},gt={get exports(){return H},set exports(u){H=u}};(function(u){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function i(r,a,c){this.fn=r,this.context=a,this.once=c||!1}function n(r,a,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var d=new i(c,h||r,p),f=e?e+a:a;return r._events[f]?r._events[f].fn?r._events[f]=[r._events[f],d]:r._events[f].push(d):(r._events[f]=d,r._eventsCount++),r}function o(r,a){--r._eventsCount===0?r._events=new s:delete r._events[a]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var a=[],c,h;if(this._eventsCount===0)return a;for(h in c=this._events)t.call(c,h)&&a.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(c)):a},l.prototype.listeners=function(a){var c=e?e+a:a,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,d=h.length,f=new Array(d);pu();function ft(){this.dispose()}const mt=()=>typeof __FASTRX_DEVTOOLS__<"u";let vt=1;class N extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){const e=new xt(t,this,this.streamId++);return B.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}}class he{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=b,this.error=b,this.next=b,this.dispose=b,this.subscribe=b,this.doDefer()}subscribe(t){return t instanceof N?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(pt),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}}class I extends he{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}}class yt extends he{constructor(t,e=b,s=b,i=b){if(super(),this._next=e,this._error=s,this._complete=i,this.then=b,t instanceof N){const n={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{B.defer(n,0)}),B.create(n),B.pipe(n),this.sourceId=n.id,this.subscribe(t),B.subscribe({id:n.id,end:!0}),e==b?this._next=o=>B.next(n,0,o):this.next=o=>{B.next(n,0,o),e(o)},i==b?this._complete=()=>B.complete(n,0):this.complete=()=>{this.dispose(),B.complete(n,0),i()},s==b?this._error=o=>B.complete(n,0,o):this.error=o=>{this.dispose(),B.complete(n,0,o),s()}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}}function _(u,...t){return t.reduce((e,s)=>s(e),u)}function A(u,t,e){if(mt()){const s=Object.defineProperties(Object.setPrototypeOf(u,N.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});B.create(s);for(let i=0;i{if(s instanceof N){const i=A(n=>{const o=new u(n,...e);o.sourceId=i.id,o.subscribe(s)},t,arguments);return i.source=s,B.pipe(i),i}else return i=>s(new u(i,...e))}}}function M(u,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:u,payload:t}})}class xt extends I{constructor(t,e,s){super(t),this.source=e,this.id=s,this.sourceId=t.sourceId,this.defer(()=>{B.defer(this.source,this.id)})}next(t){B.next(this.source,this.id,t),this.sink.next(t)}complete(){B.complete(this.source,this.id),this.sink.complete()}error(t){B.complete(this.source,this.id,t),this.sink.error(t)}}const B={addSource(u,t){M("addSource",{id:u.id,name:u.toString(),source:{id:t.id,name:t.toString()}})},next(u,t,e){M("next",{id:u.id,streamId:t,data:e&&e.toString()})},subscribe({id:u,end:t},e){M("subscribe",{id:u,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(u,t,e){M("complete",{id:u.id,streamId:t,err:e?e.toString():null})},defer(u,t){M("defer",{id:u.id,streamId:t})},pipe(u){M("pipe",{name:u.toString(),id:u.id,source:{id:u.source.id,name:u.source.toString()}})},update(u){M("update",{id:u.id,name:u.toString()})},create(u){u.id||(u.id=vt++),M("create",{name:u.toString(),id:u.id})}};class St extends he{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}}function wt(){return u=>{const t=new St(u);if(u instanceof N){const e=A(s=>{t.add(s)},"share",arguments);return t.sourceId=e.id,e.source=u,B.pipe(e),e}return A(t.add.bind(t),"share",arguments)}}function z(...u){return A(t=>{const e=new I(t);let s=u.length;e.complete=()=>{--s===0&&t.complete()},u.forEach(e.bindSubscribe)},"merge",arguments)}globalThis&&globalThis.__awaiter;function Te(u){const t=arguments,e=wt()(A(s=>{e.next=i=>s.next(i),e.complete=()=>s.complete(),e.error=i=>s.error(i),u&&s.subscribe(u)},"subject",t));return e.next=b,e.complete=b,e.error=b,e}const q={promise:u=>{Promise.resolve().then(u)},setImmediate:typeof setImmediate<"u"?u=>setImmediate(u):null,setTimeout:u=>setTimeout(u,0)},Tt=()=>typeof Promise<"u"?q.promise:q.setImmediate?q.setImmediate:q.setTimeout;let Bt=Tt();const bt=u=>t=>{Bt(()=>u(t))},kt=u=>bt(t=>{for(let e=0;!t.disposed&&e{let e=0;const s=setInterval(()=>t.next(e++),u);return t.defer(()=>{clearInterval(s)}),"interval"},"interval",arguments)}function oe(u,t){return e=>{const s=i=>e.next(i);e.defer(()=>t(s)),u(s)}}function $(u,t){if("on"in u&&"off"in u)return A(oe(e=>u.on(t,e),e=>u.off(t,e)),"fromEvent",arguments);if("addListener"in u&&"removeListener"in u)return A(oe(e=>u.addListener(t,e),e=>u.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in u)return A(oe(e=>u.addEventListener(t,e),e=>u.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}function ke(){return A(()=>{},"never",arguments)}class Ut extends I{constructor(t,e,s){super(t),this.filter=e,this.thisArg=s}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}}const le=F(Ut,"filter");class Ct extends I{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&this.complete()}}const Et=F(Ct,"take");class _t extends I{constructor(t,e){super(t);const s=new I(t);s.next=()=>t.complete(),s.complete=ft,s.subscribe(e)}}const ue=F(_t,"takeUntil");class Le extends I{constructor(t,e,s){super(t),this.mapper=e,this.thisArg=s}next(t){super.next(this.mapper.call(this.thisArg,t))}}const Ue=F(Le,"map"),Ce=u=>F(Le,"mapTo")(t=>u);class Re extends I{constructor(t,e,s){super(t),this.data=e,this.context=s}next(t){const e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}}class Z extends I{constructor(t,e,s){super(t),this.makeSource=e,this.combineResults=s,this.index=0}subInner(t,e){const s=this.currentSink=new e(this.sink,t,this);this.complete===Z.prototype.complete&&(this.complete=this.tryComplete),s.complete=s.tryComplete,s.subscribe(this.makeSource(t,this.index++))}complete(){this.sink.complete()}tryComplete(){this.currentSink.resetComplete(),this.dispose()}}class Ee extends Re{}class Ie extends Z{next(t){this.subInner(t,Ee),this.next=e=>{this.currentSink.dispose(),this.subInner(e,Ee)}}}const _e=F(Ie,"switchMap");function Dt(u){return(t,e)=>u(()=>t,e)}const Y=Dt(F(Ie,"switchMapTo"));class At extends Re{tryComplete(){const t=this.context.inners.delete(this);super.dispose(),t&&this.context.checkComplete()}next(t){this.sink.next(t),this.context.expandValue(t)}}class Lt extends Z{constructor(t,e){super(t,e),this.project=e,this.inners=new Set,this.sourceCompleted=!1}next(t){this.sink.next(t),this.expandValue(t)}expandValue(t){const e=new At(this.sink,t,this);this.currentSink=e,this.complete=this.tryComplete,e.complete=e.tryComplete,this.inners.add(e),e.subscribe(this.makeSource(t,this.index++))}complete(){this.sourceCompleted=!0,this.checkComplete()}checkComplete(){this.sourceCompleted&&this.inners.size===0&&(this.resetComplete(),super.complete())}tryComplete(){this.sourceCompleted=!0,this.checkComplete()}}const De=F(Lt,"expand"),ce=(u=b,t=b,e=b)=>s=>new yt(s,u,t,e);class Rt extends I{constructor(t,e){super(t),e instanceof Function?this.next=s=>{e(s),t.next(s)}:(e.next&&(this.next=s=>{e.next(s),t.next(s)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=s=>{e.error(s),t.error(s)}))}}const K=F(Rt,"tap");class It{constructor(t){this.id=t,this.type="",this.codec="",this.timescale=0,this.duration=0,this.language="und",this.samples=[]}addSample(t){this.samples.push(t)}addSamples(t){this.samples.push(...t)}getSampleCount(){return this.samples.length}getTotalDuration(){return this.samples.reduce((t,e)=>t+(e.duration||0),0)}}class Pt{constructor(t=!1){this.HEADER_SIZE=8,this.sourceUint8Array=null,this.tracks=new Map,this.debug=t}setDebug(t){this.debug=t}parse(t){this.sourceUint8Array=new Uint8Array(t),this.tracks.clear();const e=[];let s=0;for(;si.type==="moov");if(!e?.children)return;const s=e.children.filter(i=>i.type==="trak");for(const i of s){if(!i.children)continue;const n=this.findBox(i,"tkhd");if(!n?.data)continue;const o=n.data.trackID,l=new It(o),r=this.findBox(i,"mdia");if(!r?.children)continue;const a=this.findBox(r,"hdlr");a?.data&&(l.type=a.data.handlerType==="vide"?"video":a.data.handlerType==="soun"?"audio":"unknown");const c=this.findBox(r,"mdhd");c?.data&&(l.timescale=c.data.timescale,l.duration=Number(c.data.duration),l.language=c.data.language);const h=this.findBox(i,"stsd");if(h?.data?.entries?.[0]){const p=h.data.entries[0];p.data&&(l.type==="video"?(l.width=p.data.width,l.height=p.data.height):l.type==="audio"&&(l.channelCount=p.data.channelCount,l.sampleRate=p.data.sampleRate))}this.tracks.set(o,l)}}processCodecInfo(t){const e=this.generateCodecStrings(t);for(const s of this.tracks.values()){const i=e.find(n=>s.type==="video"&&n.mimeType==="video/mp4"||s.type==="audio"&&n.mimeType==="audio/mp4");i&&(s.codecInfo=i,s.codec=i.codecString)}}findBox(t,e){if(t.children)return t.children.find(s=>s.type===e)}processSampleData(t){for(let e=0;e=s.end){this.debug&&console.warn(`Data offset ${a} is outside mdat box range`);return}let c=a;for(const h of r.samples){const p=h.size||i.data.defaultSampleSize||0;if(p<=0)continue;const d=c,f=d+p;f<=s.end&&this.sourceUint8Array&&(h.dataStart=d,h.dataEnd=f,h.data=this.sourceUint8Array.subarray(d,f),l.addSample(h)),c+=p}}parseBox(t,e){if(e+this.HEADER_SIZE>t.byteLength)return null;const i=new DataView(t).getUint32(e,!1),n=new Uint8Array(t,e+4,4),o=String.fromCharCode(...n),l=e,r=e+i,a={type:o,size:i,start:l,end:r};return this.isContainerBox(o)?a.children=this.parseChildren(t,e+this.HEADER_SIZE,r):a.data=this.parseBoxData(t,o,e+this.HEADER_SIZE,r),a}parseChildren(t,e,s){const i=[];let n=e;for(;n>24&3;p.keyFrame=d===2,r+=4}else if(h===0&&a.firstSampleFlags!==void 0){const d=a.firstSampleFlags>>24&3;p.keyFrame=d===2}o&2048&&(n===0?p.compositionTimeOffset=i.getUint32(r,!1):p.compositionTimeOffset=i.getInt32(r,!1),r+=4),c.push(p)}return a.samples=c,a}parseLanguage(t){const e=String.fromCharCode((t>>10&31)+96),s=String.fromCharCode((t>>5&31)+96),i=String.fromCharCode((t&31)+96);return e+s+i}readFourCC(t,e){const s=new Uint8Array(t,e,4);return String.fromCharCode(...s)}logBox(t,e=0){if(!this.debug)return;const s=" ".repeat(e);if(`${s}${t.type}${t.size}${t.start}${t.end}`,t.data&&(`${s}`,t.data),t.children&&t.children.length>0){`${s}${t.children.length}`;for(const i of t.children)this.logBox(i,e+2)}}printBoxes(t){let e=`FMP4 Structure: `;const s=(i,n=0)=>{const o=" ".repeat(n);if(e+=`${o}${i.type} (${i.size} bytes) `,i.data){const l=JSON.stringify(i.data,(r,a)=>typeof a=="bigint"?a.toString():r==="data"&&a instanceof Uint8Array?`Uint8Array(${a.byteLength} bytes)`:a,2);e+=`${o} Data: ${l} `}if(i.children&&i.children.length>0)for(const l of i.children)s(l,n+1)};for(const i of t)s(i);return e}getSamples(t,e){const s=[];return this.findBoxes(t,"moof").forEach(i=>{i.children&&i.children.filter(n=>n.type==="traf").forEach(n=>{if(!n.children)return;const o=n.children.find(r=>r.type==="tfhd");if(!o||!o.data||e!==void 0&&o.data.trackID!==e)return;n.children.filter(r=>r.type==="trun").forEach(r=>{!r.data||!r.data.samples||r.data.samples.forEach(a=>{a.data&&a.data.byteLength>0&&s.push(a)})})})}),s}findBoxes(t,e){const s=[],i=n=>{for(const o of n)o.type===e&&s.push(o),o.children&&o.children.length>0&&i(o.children)};return i(t),s}parseStsdBox(t,e,s){const i=new DataView(t),n=i.getUint8(e),o=i.getUint8(e+1)<<16|i.getUint8(e+2)<<8|i.getUint8(e+3),l=i.getUint32(e+4,!1);let r=e+8;const a=[];for(let c=0;cr+8+78){const f=this.parseBox(t,r+8+78);f&&f.type==="avcC"&&(d.avcC=f.data)}break;case"hev1":case"hvc1":if(d=this.parseHevcBox(t,r+8,r+h),r+h>r+8+78){const f=this.parseBox(t,r+8+78);f&&f.type==="hvcC"&&(d.hvcC=f.data)}break;case"mp4a":if(d=this.parseMp4aBox(t,r+8,r+h),r+h>r+8+28){const f=this.parseBox(t,r+8+28);f&&f.type==="esds"&&(d.esds=f.data)}break;default:d=new Uint8Array(t.slice(r+8,r+h))}a.push({size:h,type:p,data:d}),r+=h}return{version:n,flags:o,entryCount:l,entries:a}}parseAvcBox(t,e,s){const i=new DataView(t);e+=6;const n=i.getUint16(e,!1);e+=2,e+=16;const o=i.getUint16(e,!1),l=i.getUint16(e+2,!1),r=i.getUint32(e+4,!1),a=i.getUint32(e+8,!1);e+=12,e+=4;const c=i.getUint16(e,!1);e+=2;const h=i.getUint8(e),p=this.readString(t,e+1,h);e+=32;const d=i.getUint16(e,!1),f=i.getInt16(e+2,!1);return{dataReferenceIndex:n,width:o,height:l,horizresolution:r,vertresolution:a,frameCount:c,compressorName:p,depth:d,preDefined:f}}parseHevcBox(t,e,s){return this.parseAvcBox(t,e,s)}parseMp4aBox(t,e,s){const i=new DataView(t);e+=6;const n=i.getUint16(e,!1);e+=2,e+=8;const o=i.getUint16(e,!1),l=i.getUint16(e+2,!1);e+=4,e+=4;const r=i.getUint32(e,!1)>>16;return{dataReferenceIndex:n,channelCount:o,sampleSize:l,sampleRate:r}}readString(t,e,s){const i=new Uint8Array(t,e,s);return String.fromCharCode(...i).replace(/\0+$/,"")}parseAvcCBox(t,e,s){const i=new DataView(t);return{data:new Uint8Array(t,e,s-e),configurationVersion:i.getUint8(e),profileIndication:i.getUint8(e+1),profileCompatibility:i.getUint8(e+2),levelIndication:i.getUint8(e+3)}}parseHvcCBox(t,e,s){const i=new DataView(t);return{data:new Uint8Array(t,e,s-e),configurationVersion:i.getUint8(e),generalProfileSpace:i.getUint8(e+1)>>6&3,generalTierFlag:i.getUint8(e+1)>>5&1,generalProfileIdc:i.getUint8(e+1)&31,generalProfileCompatibilityFlags:i.getUint32(e+2),generalConstraintIndicatorFlags:new Uint8Array(t,e+6,6),generalLevelIdc:i.getUint8(e+12),minSpatialSegmentationIdc:i.getUint16(e+13,!1)&4095,parallelismType:i.getUint8(e+15)&3}}parseEsdsBox(t,e,s){const i=new DataView(t);if(e+=4,i.getUint8(e)===3){const n=this.parseExpandableLength(t,e+1);if(e+=1+n.bytesRead,e+=3,i.getUint8(e)===4){const o=this.parseExpandableLength(t,e+1);e+=1+o.bytesRead;const l={objectTypeIndication:(i.getUint8(e)>>6)+1,streamType:i.getUint8(e+1)>>2&63,bufferSizeDB:(i.getUint8(e+1)&3)<<16|i.getUint8(e+2)<<8|i.getUint8(e+3),maxBitrate:i.getUint32(e+4,!1),avgBitrate:i.getUint32(e+8,!1)};if(e+=13,e>=1;return e}generateCodecStrings(t){const e=[],s=this.findBoxes(t,"stsd");for(const i of s)if(i.data?.entries)for(const n of i.data.entries){const{type:o,data:l}=n;switch(o){case"avc1":case"avc3":{if(l?.avcC){const{profileIndication:r,profileCompatibility:a,levelIndication:c}=l.avcC,h=`${o}.`+r.toString(16).padStart(2,"0")+a.toString(16).padStart(2,"0")+c.toString(16).padStart(2,"0");e.push({codecString:h,mimeType:"video/mp4",extraData:l.avcC.data})}break}case"hev1":case"hvc1":{if(l?.hvcC){const{generalProfileSpace:r,generalProfileIdc:a,generalProfileCompatibilityFlags:c,generalConstraintIndicatorFlags:h,generalLevelIdc:p}=l.hvcC,d=a,f=this.reverseBits(c).toString(16),w=`L${p}`,g=h[0].toString(16).padStart(2,"0"),k=`${o}.${d}.${f}.${w}.${g}`;e.push({codecString:k,mimeType:"video/mp4",extraData:l.hvcC.data})}break}case"mp4a":{if(l?.esds?.decoderConfig){const{objectTypeIndication:r}=l.esds.decoderConfig,a=`mp4a.40.${r}`;e.push({codecString:a,mimeType:"audio/mp4",extraData:l.esds.data})}break}}}return e}}class Ft extends H{constructor(t,e){super(),this.index=t,this.fmp4Parser=new Pt(!1),this.tracks=[],this.loadingProgress={loaded:0,total:0},this.url=e.url,this.duration=e.duration,this.virtualStartTime=0,this.virtualEndTime=0,this.physicalTime=e.physicalTime}async fetchWithProgress(t){const e=await fetch(t),s=e.body.getReader(),i=+e.headers.get("Content-Length");let n=0;const o=[];for(;;){const{done:a,value:c}=await s.read();if(a)break;o.push(c),n+=c.length,this.loadingProgress={loaded:n,total:i},this.emit("progress",this.loadingProgress)}const l=new Uint8Array(n);let r=0;for(const a of o)l.set(a,r),r+=a.length;return l.buffer}async _load(){this.index,this.data||(this.data=this.fetchWithProgress(this.url));const t=await this.data;return this.tracks.length===0&&(this.tracks=this.fmp4Parser.parse(t)),t}load(t,e){return async s=>{const i=await this._load();if(!s.disposed&&(await e,!s.disposed)){if(!t.initialized){const n=`video/mp4; codecs="${this.tracks.map(o=>o.codec).join(", ")}"`;if(MediaSource.isTypeSupported(n))t.init(n);else{s.error(new Error(`Unsupported codec: ${n}`));return}}try{await t.appendBuffer({data:i,tracks:this.tracks}),s.next(!0),s.complete()}catch(n){s.error(n)}}}}downgrade(t){this.load=function(){return async e=>{if(await this._load(),e.disposed)return;const s=this.tracks.filter(n=>n.type==="video"),i=this.tracks.filter(n=>n.type==="audio");for(const n of s){if(t.videoDecoder.state!=="configured"){if(await t.videoDecoder.initialize(),e.disposed||(await t.videoDecoder.configure({codec:n.codec.startsWith("avc1")?"avc":"hevc",description:n.codecInfo?.extraData}),e.disposed))return;t.canvas.width=n.width??1920,t.canvas.height=n.height??1080}let o=this.virtualStartTime*1e3;n.samples.forEach(l=>{t.decodeVideo({data:l.data,timestamp:o,type:l.keyFrame?"key":"delta"}),o+=l.duration??0})}for(const n of i){if(t.audioDecoder.state!=="configured"&&(await t.audioDecoder.initialize(),e.disposed||(await t.audioDecoder.configure({codec:"aac",description:n.codecInfo?.extraData,numberOfChannels:n.channelCount??2,sampleRate:n.sampleRate??44100}),e.disposed)))return;let o=this.virtualStartTime*1e3;n.samples.forEach(l=>{t.decodeAudio({data:l.data,timestamp:o,type:"key"}),o+=l.duration??0})}e.next(!0),e.complete()}}}}const Mt=/#EXTINF:(\d+\.\d+),(.*?)\s*$/;function Ot(u,t){const e=u.split(` `),s=[];let i=0,n=0,o=0,l=null;for(let r=0;r{if(this.currentWaiting?.(),this.removeQueue.length>0){const{start:e,end:s,resolve:i,reject:n}=this.removeQueue.shift();this.sourceBuffer.remove(e,s),this.currentWaiting=i,this.currentError=n}else if(this.queue.length>0){const{data:e,resolve:s,reject:i}=this.queue.shift();this.sourceBuffer.appendBuffer(e),this.currentWaiting=s,this.currentError=i}else delete this.currentWaiting}),this.sourceBuffer.addEventListener("error",e=>{this.currentError(e)})}appendBuffer(t){return this.currentWaiting?new Promise((e,s)=>{this.queue.push({data:t.data,resolve:e,reject:s})}):(this.sourceBuffer.appendBuffer(t.data),new Promise((e,s)=>{this.currentWaiting=e,this.currentError=s}))}remove(t,e){return this.currentWaiting?new Promise((s,i)=>{this.removeQueue.push({start:t,end:e,resolve:s,reject:i})}):(this.sourceBuffer.remove(t,e),new Promise((s,i)=>{this.currentWaiting=s,this.currentError=i}))}destroy(){if(this.sourceBuffer){try{this.mediaSource.removeSourceBuffer(this.sourceBuffer)}catch{}this.sourceBuffer=void 0}this.queue=[],this.removeQueue=[],delete this.currentWaiting,this.currentError=()=>{}}}class Vt extends H{constructor(t,e={debug:!1}){super(),this.video=t,this.mediaSource=new MediaSource,this.sourceBufferProxy=new Ae(this.mediaSource),this.urlSource=URL.createObjectURL(this.mediaSource),this.debug=!1,this.ready=this.init(),this.debug=e.debug,t.src=this.urlSource}appendSegment(t){return t.load(this.sourceBufferProxy,this.ready)}async removeBuffer(t,e){if(!this.sourceBufferProxy)throw new Error("SourceBufferProxy not initialized");return this.sourceBufferProxy.remove(t,e)}destroy(){this.video.src="",this.mediaSource.readyState==="open"&&this.mediaSource.endOfStream(),this.urlSource&&URL.revokeObjectURL(this.urlSource),this.sourceBufferProxy.destroy(),this.emit("destroyed")}get readyState(){return this.mediaSource.readyState}endOfStream(){this.mediaSource.readyState==="open"&&this.mediaSource.endOfStream()}reset(){this.destroy(),this.mediaSource=new MediaSource,this.sourceBufferProxy=new Ae(this.mediaSource),this.urlSource=URL.createObjectURL(this.mediaSource),this.video.src=this.urlSource,this.ready=this.init()}init(){return this.mediaSource.addEventListener("sourceended",()=>{this.emit("ended")}),this.mediaSource.addEventListener("sourceclose",()=>{this.emit("closed")}),new Promise((t,e)=>{this.mediaSource.addEventListener("sourceopen",()=>{this.emit("sourceopen"),t()})})}}class $t{constructor(t){this.gl=null,this.program=null,this.yTexture=null,this.uTexture=null,this.vTexture=null,this.positionBuffer=null,this.texCoordBuffer=null,this.width=0,this.height=0,this.setupWebGL(t)}setupWebGL(t){try{if(this.gl=t.getContext("webgl",{preserveDrawingBuffer:!0}),!this.gl)throw new Error("WebGL not supported");const e=this.createShader(this.gl.VERTEX_SHADER,` attribute vec4 a_position; attribute vec2 a_texCoord; varying vec2 v_texCoord; void main() { gl_Position = a_position; v_texCoord = a_texCoord; } `),s=this.createShader(this.gl.FRAGMENT_SHADER,` precision mediump float; uniform sampler2D y_texture; uniform sampler2D u_texture; uniform sampler2D v_texture; varying vec2 v_texCoord; void main() { float y = texture2D(y_texture, v_texCoord).r; float u = texture2D(u_texture, v_texCoord).r - 0.5; float v = texture2D(v_texture, v_texCoord).r - 0.5; // YUV to RGB conversion float r = y + 1.402 * v; float g = y - 0.344 * u - 0.714 * v; float b = y + 1.772 * u; gl_FragColor = vec4(r, g, b, 1.0); } `);if(!e||!s)throw new Error("Failed to create shaders");if(this.program=this.createProgram(e,s),!this.program)throw new Error("Failed to create shader program");this.createBuffers(),this.yTexture=this.createTexture(),this.uTexture=this.createTexture(),this.vTexture=this.createTexture()}catch(e){console.error("Error initializing WebGL:",e),this.gl=null}}createShader(t,e){if(!this.gl)return null;const s=this.gl.createShader(t);return s?(this.gl.shaderSource(s,e),this.gl.compileShader(s),this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS)?s:(console.error("Shader compile error:",this.gl.getShaderInfoLog(s)),this.gl.deleteShader(s),null)):null}createProgram(t,e){if(!this.gl)return null;const s=this.gl.createProgram();return s?(this.gl.attachShader(s,t),this.gl.attachShader(s,e),this.gl.linkProgram(s),this.gl.getProgramParameter(s,this.gl.LINK_STATUS)?s:(console.error("Program link error:",this.gl.getProgramInfoLog(s)),this.gl.deleteProgram(s),null)):null}createTexture(){if(!this.gl)return null;const t=this.gl.createTexture();return t?(this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),t):null}createBuffers(){if(!this.gl||!this.program)return;this.positionBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer);const t=[-1,-1,1,-1,-1,1,1,1];this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(t),this.gl.STATIC_DRAW),this.texCoordBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.texCoordBuffer);const e=[0,1,1,1,0,0,1,0];this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(e),this.gl.STATIC_DRAW)}setDimensions(t,e){this.width=t,this.height=e,this.gl&&this.gl.viewport(0,0,t,e)}render(t,e,s,i,n){if(!this.gl||!this.program||!this.yTexture||!this.uTexture||!this.vTexture){console.error("WebGL not initialized properly");return}this.gl.useProgram(this.program),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.positionBuffer);const o=this.gl.getAttribLocation(this.program,"a_position");this.gl.enableVertexAttribArray(o),this.gl.vertexAttribPointer(o,2,this.gl.FLOAT,!1,0,0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.texCoordBuffer);const l=this.gl.getAttribLocation(this.program,"a_texCoord");this.gl.enableVertexAttribArray(l),this.gl.vertexAttribPointer(l,2,this.gl.FLOAT,!1,0,0),this.updateTexture(this.yTexture,0,t,this.width,this.height,i),this.updateTexture(this.uTexture,1,e,this.width/2,this.height/2,n),this.updateTexture(this.vTexture,2,s,this.width/2,this.height/2,n);const r=this.gl.getUniformLocation(this.program,"y_texture"),a=this.gl.getUniformLocation(this.program,"u_texture"),c=this.gl.getUniformLocation(this.program,"v_texture");this.gl.uniform1i(r,0),this.gl.uniform1i(a,1),this.gl.uniform1i(c,2),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}updateTexture(t,e,s,i,n,o){if(this.gl)if(this.gl.activeTexture(this.gl.TEXTURE0+e),this.gl.bindTexture(this.gl.TEXTURE_2D,t),o===i)this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.LUMINANCE,i,n,0,this.gl.LUMINANCE,this.gl.UNSIGNED_BYTE,s);else{const l=new Uint8Array(i*n);for(let r=0;r{if(!this.isPlaying)return;const s=this.getCurrentTime();if(this.seekTime!==null){for(;this.videoBuffer.length>0&&this.videoBuffer[0].timestamp0&&this.audioBuffer[0].timestamp0&&this.videoBuffer[0].timestamp<=s){const i=this.videoBuffer.shift();i&&this.videoDecoder.decode(i)}if(this.videoBuffer.length>0){const i=this.videoBuffer.findIndex((n,o)=>o>0&&n.type==="key");i!==-1&&this.videoBuffer.slice(0,i).every(l=>l.timestamp<=s)&&this.videoBuffer.splice(0,i)}if(this.audioBuffer.length>0&&this.audioBuffer[0].timestamp<=s){const i=this.audioBuffer.shift();i&&this.audioDecoder.decode(i)}this.audioContext&&this.audioContext.currentTime-this.lastAudioScheduleTime>this.audioScheduleAheadTime/2&&this.scheduleAudioPlayback(),this.animationFrameId=requestAnimationFrame(this.processNextFrame)},this.canvas=document.createElement("canvas"),this.canvas.style.width="160px",this.canvas.style.height="120px",e?.yuvMode?this.yuvRenderer=new $t(this.canvas):this.gl=this.canvas.getContext("2d"),this.videoDecoder=new ut({workerMode:!1,yuvMode:!!this.yuvRenderer,canvas:this.canvas,wasmPath:t}),this.audioDecoder=typeof AudioDecoder>"u"?new ct:new ht,this.videoDecoder.on(ae.VideoFrame,s=>{if(this.yuvRenderer){const{y:i,u:n,v:o}=s;this.yuvRenderer.render(i,n,o,this.canvas.width,this.canvas.width/2)}else this.gl&&(this.gl.drawImage(s,0,0),s.close())}),this.videoDecoder.on(ae.VideoCodecInfo,s=>{this.canvas.width=s.width,this.canvas.height=s.height,this.yuvRenderer&&this.yuvRenderer.setDimensions(s.width,s.height)}),this.videoDecoder.on(ae.Error,s=>{console.error(s)}),this.audioDecoder.on(dt.AudioFrame,s=>{this.audioContext||this.initAudioContext();const i=this.audioContext.createBuffer(s.numberOfChannels,s.numberOfFrames,s.sampleRate);for(let n=0;nthis.audioContext.currentTime+this.audioScheduleAheadTime)){for(;this.audioQueue.length>0;){const t=this.audioQueue[0],e=this.audioQueueTimestamps[0],s=this.audioContext.createBufferSource();s.buffer=t,s.connect(this.audioGain),s.playbackRate.value=this.playbackSpeed;const i=performance.now(),n=e*this.playbackSpeed,o=this.audioContext.currentTime+Math.max(0,(n-(i-this.startTime))/1e3),l=Math.max(this.audioContext.currentTime,Math.max(o,this.nextAudioStartTime));if(s.start(l),this.nextAudioStartTime=l+t.duration/this.playbackSpeed,this.audioQueue.shift(),this.audioQueueTimestamps.shift(),this.nextAudioStartTime>this.audioContext.currentTime+this.audioScheduleAheadTime)break}this.lastAudioScheduleTime=this.audioContext.currentTime}}setPlaybackSpeed(t){if(t<=0)throw new Error("Playback speed must be greater than 0");const e=this.getCurrentTime();this.startTime=performance.now()-e/t,this.playbackSpeed=t,this.playbackSpeed}seek(t){if(!this.isPlaying)return;const e=this.findNearestKeyFrame(t*1e3);this.videoBuffer=this.videoBuffer.filter(s=>s.timestamp>=e),this.audioBuffer=this.audioBuffer.filter(s=>s.timestamp>=e),this.audioQueue=[],this.audioQueueTimestamps=[],this.audioContext&&(this.nextAudioStartTime=this.audioContext.currentTime),this.timeOffset=t*1e3,this.startTime=performance.now()-t*1e3,this.seekTime=e}findNearestKeyFrame(t){for(let e=this.keyFrameList.length-1;e>=0;e--)if(this.keyFrameList[e]<=t)return this.keyFrameList[e];return this.keyFrameList[0]||0}start(){this.isPlaying||(this.isPlaying=!0,this.pausedAt!==null?(this.startTime=performance.now()-this.pausedAt,this.pausedAt=null):this.startTime=performance.now()-this.timeOffset,this.processNextFrame(),this.audioContext?this.audioContext.state==="suspended"&&this.audioContext.resume():this.initAudioContext(),this.scheduleAudioPlayback())}stop(){this.isPlaying&&(this.isPlaying=!1,this.pausedAt=this.getCurrentTime(),this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.audioContext&&this.audioContext.state==="running"&&this.audioContext.suspend())}getCurrentTime(){return this.pausedAt!==null?this.pausedAt:(performance.now()-this.startTime+this.timeOffset)*this.playbackSpeed}processInitialFrame(){if(this.videoBuffer.length>0){const t=this.videoBuffer.shift();t&&this.videoDecoder.decode(t)}}decodeVideo(t){if(this.videoBuffer.length>=this.maxBufferSize){console.warn("Video buffer full, dropping frame");return}t.type==="key"&&this.keyFrameList.push(t.timestamp),this.videoBuffer.push(t)}decodeAudio(t){if(this.audioBuffer.length>=this.maxBufferSize){console.warn("Audio buffer full, dropping frame");return}this.audioBuffer.push(t)}dispose(){this.stop(),this.videoBuffer=[],this.audioBuffer=[],this.audioQueue=[],this.audioQueueTimestamps=[],this.yuvRenderer&&(this.yuvRenderer.dispose(),this.yuvRenderer=null),this.audioContext&&(this.audioContext.close(),this.audioContext=null),this.gl=null,this.audioGain=null}}class zt extends H{constructor(t,e={debug:!1,autoPlay:!1}){super(),this.video=t,this.segments=[],this.totalDuration=0,this.position=0,this.debug=!1,this.autoPlay=!1,this.isPlaying=!1,this._playbackRate=1,this.minBufferLength=30,this.offset=0,this.seekOB=Te(),this.destroyOB=Te(),this.debug=e.debug,this.autoPlay=e.autoPlay,this.log("Engine initialized with options:",e);const s=new Vt(t,{debug:this.debug}),i=_($(t,"error"),Ue(()=>{const r=this.position;return s.reset(),this.offset=0,r+1})),n=_($(t,"waiting"),le(()=>this.totalDuration-this.position<1),Ue(()=>(s.reset(),this.offset=0,this.pause(),0))),o=r=>{this.position=r;const{currentSegment:a,bufferStart:c,bufferEnd:h}=this,p=r-a.virtualStartTime,d=p+h;this.log("Seek requested to time:",r,`[${c},${h}]`,"offsetInSegment",p,"targetTime",d);const f=this.segments.slice(a.index+1),w=_(Be(0),De(g=>(this.log(`Expand called with index: ${g}`),g>=f.length?(this.log("No more segments to load"),ke()):_(z($(this.video,"timeupdate"),be(1e3)),le(()=>{const k=this.bufferedLengththis.log(`Loaded segment ${f[g].index}, buffer: ${this.bufferedLength}s`)),Ce(g+1)))))));return t.pause(),this.offset=r-d,_(s.appendSegment(a),K(()=>{t.currentTime=d,h>c&&s.removeBuffer(c,h),this.isPlaying&&t.play(),t.playbackRate=this._playbackRate}),Y(z($(this.video,"timeupdate"),w)))},l=r=>{this.position=r;const{currentSegment:a,softDecoder:c}=this,h=this.segments.slice(a.index+1),p=_(Be(0),De(d=>(this.log(`Expand (soft) called with index: ${d}`),d>=h.length?(this.log("No more segments to load (soft decoder)"),ke()):_(z($(this.video,"timeupdate"),be(1e3)),le(()=>{const f=this.bufferedLengththis.log(`Loaded segment ${h[d].index} (soft), buffer: ${this.bufferedLength}s`)),Ce(d+1)))))));return t.pause(),_(s.appendSegment(a),K(()=>{this.isPlaying&&(this.log("processInitialFrame",c?.videoBuffer.length),c?.processInitialFrame(),t.play().then(()=>{c?.start(),c?.seek(r)}))}),Y(z($(this.video,"timeupdate"),p)))};_(z(this.seekOB,i,n),_e(o),ue(this.destroyOB),ce(()=>{this.position=t.currentTime+this.offset},r=>{this.log(r,"downgrade"),this.softDecoder=new Wt("",{yuvMode:!0}),this.video.srcObject=this.softDecoder.canvas.captureStream(),this.segments.forEach(a=>a.downgrade(this.softDecoder)),_(this.seekOB,_e(l),ue(this.destroyOB),ce(()=>{this.position=(this.softDecoder?.getCurrentTime()??0)/1e3})),this.seekOB.next(this.position)}))}get minimumBufferLength(){return this.minBufferLength}set minimumBufferLength(t){this.minBufferLength=Math.max(0,t)}log(...t){this.debug&&[...t]}get loadingProgress(){const t=this.segments.map(e=>e.loadingProgress).reduce((e,s)=>({loaded:e.loaded+s.loaded,total:e.total+s.total}),{loaded:0,total:0});return{...t,percent:t.total?t.loaded*100/t.total:0}}get currentSegment(){return this.segments.find(t=>t.virtualEndTime>this.position)}get bufferStart(){return this.video.buffered.length>0?this.video.buffered.start(0):0}get bufferEnd(){return this.video.buffered.length>0?this.video.buffered.end(this.video.buffered.length-1):0}set playbackRate(t){this._playbackRate=t,this.softDecoder?this.softDecoder.setPlaybackSpeed(t):this.video.playbackRate=t}get bufferedLength(){return this.bufferEnd-this.video.currentTime}get minBufferThreshold(){return this.minBufferLength}set minBufferThreshold(t){this.minBufferLength=t,this.log("Min buffer threshold set to:",t,"seconds")}async load(t){this.log("Loading URL:",t);let e;try{e=new URL(t)}catch{e=new URL(t,window.location.href)}switch(e.pathname.split(".").pop()){case"m3u8":this.log("Processing M3U8 playlist");const s=await fetch(e.toString()).then(n=>n.text()),i=Ot(s,e.origin+e.pathname.split("/").slice(0,-1).join("/"));this.log("Playlist created:",i),this.segments=i.segments,this.totalDuration=i.totalDuration,_(z(...this.segments.map(n=>$(n,"progress"))),ue(this.destroyOB),ce(()=>{this.emit("progress",this.loadingProgress)})),this.autoPlay?(this.log("Auto-play enabled, starting playback"),this.play()):(this.log("Seeking to start position"),this.seek(0));break}}play(){this.log("Play requested"),this.isPlaying=!0,this.seekOB.next(this.position)}pause(){this.log("Pause requested"),this.isPlaying=!1,this.video.pause(),this.softDecoder?.stop()}seek(t){const e=t-this.offset;this.log("Seek requested to:",t,`[${this.bufferStart},${this.bufferEnd}]`,e),this.bufferEnd>e&&this.bufferStart{d.value?.seek(m),w.value=m}});const pe=e,Pe=we(()=>se(w.value)),Fe=we(()=>se(g.value)),Me=[.5,1,1.5,2,3,4];function se(m){const v=Math.floor(m/3600),T=Math.floor(m%3600/60),U=Math.floor(m%60);return v>0?`${v.toString().padStart(2,"0")}:${T.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`:`${T.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`}function fe(){n.value&&(ee.value=n.value.offsetWidth>=400)}function me(){if(!o.value||!l.value||!r.value||!d.value)return;w.value=d.value.position,g.value!==d.value.totalDuration&&(g.value=d.value.totalDuration);const m=d.value.position/g.value*100;l.value.style.width=`${m}%`;const v=(d.value.position+d.value.bufferedLength)/g.value*100;r.value.style.width=`${v}%`,pe("timeupdate",d.value.position),f.value=!i.value?.paused}function ve(m){if(!o.value||!d.value)return;const v=o.value.getBoundingClientRect(),U=(m.clientX-v.left)/v.width*g.value;d.value.seek(U),w.value=U}function Oe(m){c.value=!0,ne(m),document.addEventListener("mousemove",ne),document.addEventListener("mouseup",ye)}function ne(m){if(!c.value||!o.value||!d.value)return;const v=o.value.getBoundingClientRect(),T=(m.clientX-v.left)/v.width,U=Math.max(0,Math.min(T*g.value,g.value));w.value=U;const P=U/g.value*100;l.value&&(l.value.style.width=`${P}%`)}function ye(m){c.value&&(ve(m),document.removeEventListener("mousemove",ne),document.removeEventListener("mouseup",ye),c.value=!1)}function Ve(){h.value=!0,ie.value=!0}function $e(){h.value=!1,ie.value=!1}function We(m){if(!o.value||!d.value)return;const v=o.value.getBoundingClientRect(),U=(m.clientX-v.left)/v.width*g.value;te.value={x:m.clientX-v.left,y:-30},ge.value=se(U)}function ze(m){i.value&&(p.value=m,d.value&&(d.value.playbackRate=m),L.value=!1)}function Ne(){L.value=!L.value}function xe(){!i.value||!d.value||(d.value.isPlaying?d.value.pause():d.value.play())}function He(){i.value&&(O.value=!O.value,i.value.muted=O.value)}function Xe(m){if(!i.value)return;const T=m.currentTarget.getBoundingClientRect();re(m.clientY,T)}function re(m,v){const T=v.height,U=1-Math.max(0,Math.min(1,(m-v.top)/T)),P=Math.max(0,Math.min(1,U));y.value=P,i.value&&(i.value.volume=P,O.value=P===0,i.value.muted=P===0)}function je(m){m.preventDefault(),j.value=!0;const T=m.currentTarget.getBoundingClientRect();re(m.clientY,T);const U=Ze=>{j.value&&re(Ze.clientY,T)};document.addEventListener("mousemove",U);const P=()=>{j.value=!1,document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",P),setTimeout(()=>{document.querySelector(".volume-control:hover")||(X.value=!1)},500)};document.addEventListener("mouseup",P)}function Ge(){if(!d.value)return;const m=Math.min(d.value.position+10,g.value);d.value.seek(m),w.value=m}function Qe(){if(!d.value)return;const m=Math.max(d.value.position-10,0);d.value.seek(m),w.value=m}function Se(){k.value=!0,D.value!==null&&(window.clearTimeout(D.value),D.value=null)}function qe(){c.value||(D.value=window.setTimeout(()=>{k.value=!1},2e3))}function Ye(){Se()}function Ke(){n.value&&(document.fullscreenElement?document.exitFullscreen().then(()=>{J.value=!1}).catch(m=>{console.error(`Error attempting to exit fullscreen: ${m.message}`)}):n.value.requestFullscreen().then(()=>{J.value=!0}).catch(m=>{console.error(`Error attempting to enable fullscreen: ${m.message}`)}))}return et(()=>i.value?s.src:null,m=>{if(d.value&&d.value.destroy(),!!m&&i.value){R.value=!0;const v=new zt(i.value,{debug:s.debug,autoPlay:s.debug});v.on("progress",T=>{a.value=T.percent}),d.value=v,w.value=0,g.value=0,v.load(m).then(()=>{g.value=v.totalDuration,pe("segments",v.segments),R.value=!1}).catch(T=>{console.error("Failed to load video:",T),R.value=!1})}}),tt(()=>{i.value&&(i.value.addEventListener("timeupdate",me),i.value.addEventListener("play",()=>{f.value=!0,R.value=!1}),i.value.addEventListener("pause",()=>{f.value=!1,d.value?.isPlaying&&(R.value=!0)}),i.value.addEventListener("canplay",()=>{R.value=!1}),i.value.addEventListener("playing",()=>{R.value=!1}),i.value.addEventListener("error",m=>{console.error("Video error occurred:",m),R.value=!1}),i.value.addEventListener("waiting",()=>{R.value=!0}),i.value.volume=y.value,n.value&&(new ResizeObserver(()=>{fe()}).observe(n.value),fe()))}),it(()=>{d.value&&d.value.destroy(),i.value&&i.value.removeEventListener("timeupdate",me)}),(m,v)=>(C(),E("div",{class:"video-player",ref_key:"playerRef",ref:n,onMouseenter:Se,onMouseleave:qe,onMousemove:Ye},[S("video",{ref_key:"video",ref:i,onClick:xe,controls:de.value},null,8,Nt),R.value?(C(),E("div",Ht,[S("div",Xt,[v[2]||(v[2]=S("div",{class:"spinner"},null,-1)),v[3]||(v[3]=S("span",{class:"loading-text"},"加载中...",-1)),d.value?(C(),E("div",jt,W(a.value.toFixed(2))+"%",1)):V("",!0)])])):V("",!0),d.value&&!de.value?(C(),E("div",{key:1,class:G(["controls-overlay",{"show-controls":k.value||c.value}])},[S("div",{class:G(["timeline",{"timeline-hover":h.value}]),ref_key:"timelineRef",ref:o,onClick:ve,onMouseenter:Ve,onMousemove:We,onMouseleave:$e},[S("div",{class:"timeline-buffer",ref_key:"bufferRef",ref:r},null,512),S("div",{class:"timeline-progress",ref_key:"progressRef",ref:l},null,512),S("div",{class:G(["timeline-handle",{"timeline-handle-hover":h.value||c.value}]),style:Q({left:`${w.value/(g.value||1)*100}%`}),onMousedown:st(Oe,["stop"])},null,38),nt(S("div",{class:"timeline-tooltip",style:Q({left:`${te.value.x}px`,top:`${te.value.y}px`})},W(ge.value),5),[[rt,ie.value]])],34),S("div",Gt,[S("div",Qt,[S("button",{class:"control-button",onClick:xe},[f.value?(C(),E("i",qt,"▮▮")):(C(),E("i",Yt,"▶"))]),ee.value?(C(),E("button",{key:0,class:"control-button",onClick:Qe},v[4]||(v[4]=[S("i",{class:"icon-backward"},"◀◀",-1)]))):V("",!0),ee.value?(C(),E("button",{key:1,class:"control-button",onClick:Ge},v[5]||(v[5]=[S("i",{class:"icon-forward"},"▶▶",-1)]))):V("",!0),S("div",Kt,W(Pe.value)+" / "+W(Fe.value),1)]),S("div",Zt,[S("div",Jt,[S("button",{class:"control-button playback-rate-button",onClick:Ne},[S("span",null,W(p.value)+"x",1)]),L.value?(C(),E("div",ei,[(C(),E(at,null,ot(Me,T=>S("button",{key:T,onClick:U=>ze(T),class:G([{active:p.value===T},"playback-rate-option"])},W(T)+"x ",11,ti)),64))])):V("",!0)]),S("div",{class:"volume-control",onMouseenter:v[0]||(v[0]=T=>X.value=!0),onMouseleave:v[1]||(v[1]=()=>{j.value||(X.value=!1)})},[S("button",{class:"control-button",onClick:He},[O.value||y.value===0?(C(),E("i",ii)):y.value<.5?(C(),E("i",si)):(C(),E("i",ni))]),X.value?(C(),E("div",ri,[S("div",{class:"volume-slider",onClick:Xe,onMousedown:je},[v[6]||(v[6]=S("div",{class:"volume-slider-track"},null,-1)),S("div",{class:"volume-slider-fill",style:Q({height:`${y.value*100}%`})},null,4),S("div",{class:"volume-slider-thumb",style:Q({bottom:`${y.value*100}%`})},null,4)],32)])):V("",!0)],32),S("button",{class:"control-button",onClick:Ke},[J.value?(C(),E("i",ai,"⤓")):(C(),E("i",oi,"⤢"))])])])],2)):V("",!0)],544))}});const hi=lt(li,[["__scopeId","data-v-5ae43e26"]]);export{hi as V}; //# sourceMappingURL=VideoPlayer-ced8f94f.js.map