quickvo-player 0.3.5 → 0.3.6

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,4 +1,5 @@
1
- (function(p,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(p=typeof globalThis<"u"?globalThis:p||self,o(p["quickvo-player"]={}))})(this,(function(exports){"use strict";const x='(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>100&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;parser;on={};constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n',T=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",x],{type:"text/javascript;charset=utf-8"});function R(p){let o;try{if(o=T&&(self.URL||self.webkitURL).createObjectURL(T),!o)throw"";const a=new Worker(o,{name:p?.name});return a.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(o)}),a}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(x),{name:p?.name})}}class P{worker=new R;on={};constructor(){this.worker.onmessage=o=>{const{action:a,data:u}=o.data;switch(a){case"on.info":this.on.info&&this.on.info(u);break;case"on.config":this.on.config&&this.on.config(u);break;case"on.chunk":this.on.chunk&&this.on.chunk(u);break;case"on.debug":this.on.debug&&this.on.debug(u);break}}}init=o=>this.worker.postMessage({action:"init",data:o});push=o=>this.worker.postMessage({action:"push",data:o});destroy=()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()}}const A=`(function(){"use strict";class a{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const o=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:o})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);try{const o=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);if(i.close(),!s.width||!s.height)return s.close();this.on.video.decode&&this.on.video.decode({timestamp:o,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)}catch{i.close()}},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const o=this.lastRenderTime-this.nextRenderTime;e-=o}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;this.currentChunk=this.pendingChunks.shift(),!!this.currentChunk;){const e=this.pendingChunks.length;if(this.frameTrack){const[s,n]=this.fameTrackOption[this.pattern];if(e<=s&&(this.isFrameTrack=!1),e>=n&&(this.isFrameTrack=!0),this.isFrameTrack){const r=Math.min(1+(e-s)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(r.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.analysis){const{decodingSpeed:s,decodingSpeedRatio:n,fps:r}=this;this.on.analysis({decodingSpeed:s,decodingSpeedRatio:n,fps:r,cacheLength:e})}const{kind:i,init:o}=this.currentChunk;switch(i){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new a;d.on.audio.decode=t=>postMessage({action:"on.audio.decode",data:t},[t.audioData]),d.on.audio.error=t=>postMessage({action:"on.audio.error",data:t}),d.on.video.decode=t=>postMessage({action:"on.video.decode",data:t},[t.bitmap]),d.on.video.error=t=>postMessage({action:"on.video.error",data:t}),d.on.nalus=t=>postMessage({action:"on.nalus",data:t}),d.on.analysis=t=>postMessage({action:"on.analysis",data:t}),onmessage=t=>{const{action:e,data:i}=t.data,o=d[e];o&&o(i)}})();
2
- `,_=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",A],{type:"text/javascript;charset=utf-8"});function I(p){let o;try{if(o=_&&(self.URL||self.webkitURL).createObjectURL(_),!o)throw"";const a=new Worker(o,{name:p?.name});return a.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(o)}),a}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(A),{name:p?.name})}}class N{worker=new I;on={audio:{},video:{}};constructor(){this.worker.onmessage=o=>{const{action:a,data:u}=o.data;switch(a){case"on.audio.decode":this.on.audio.decode&&this.on.audio.decode(u);break;case"on.audio.error":this.on.audio.error&&this.on.audio.error(u);break;case"on.video.decode":this.on.video.decode&&this.on.video.decode(u);break;case"on.video.error":this.on.video.error&&this.on.video.error(u);break;case"on.nalus":this.on.nalus&&this.on.nalus(u);break;case"on.analysis":this.on.analysis&&this.on.analysis(u);break}}}init=o=>this.worker.postMessage({action:"init",data:o});initAudio=o=>this.worker.postMessage({action:"initAudio",data:o});initVideo=o=>this.worker.postMessage({action:"initVideo",data:o});push=o=>this.worker.postMessage({action:"push",data:o});setFrameTrack=o=>this.worker.postMessage({action:"setFrameTrack",data:o});destroy=()=>{this.worker.postMessage({action:"destroy"}),this.worker.terminate()}}const S=`(function(){"use strict";class w{renderMap=new Map;constructor(){}push=async t=>{const{timestamp:s}=t,{bitmap:e}=t;try{const n=[...this.renderMap.keys()];for(const a of n){const i=this.renderMap.get(a);if(!i)continue;const{pause:y=!1,writer:u,offscreen:o,option:f}=i;if(y===!0)continue;const h=async r=>{if(u){const c=new VideoFrame(r,{timestamp:s});try{await u.write(c)}catch{}c.close()}else o&&(o.width=r.width,o.height=r.height,o?.getContext("2d")?.drawImage(r,0,0))};if(a==="default")await h(e);else if(f){const{sx:r=0,sy:c=0,sw:p=e.width,sh:M=e.height}=f,g=await createImageBitmap(e,r,c,p,M);await h(g)}}}catch{}e.close()};addCut=t=>{const{key:s,writable:e,offscreen:n,option:a}={key:"default",...t};if(e){const i=e.getWriter();this.renderMap.set(s,{writer:i,option:a,pause:!1})}else this.renderMap.set(s,{offscreen:n,option:a,pause:!1})};delCut=t=>{this.renderMap.delete(t)};setCut=t=>{const{key:s,cutOption:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,option:e})};setPause=t=>{const{key:s,pause:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,pause:e})};destroy=()=>{this.renderMap=new Map}}const l=new w;onmessage=d=>{const{action:t,data:s}=d.data,e=l[t];e&&e(s)}})();
3
- `,C=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",S],{type:"text/javascript;charset=utf-8"});function L(p){let o;try{if(o=C&&(self.URL||self.webkitURL).createObjectURL(C),!o)throw"";const a=new Worker(o,{name:p?.name});return a.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(o)}),a}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(S),{name:p?.name})}}class V{worker=new L;constructor(){}push=o=>this.worker.postMessage({action:"push",data:o},[o.bitmap]);addCut=o=>{const a=[];o.writable&&a.push(o.writable),o.offscreen&&a.push(o.offscreen),this.worker.postMessage({action:"addCut",data:o},a)};delCut=o=>this.worker.postMessage({action:"delCut",data:o});setCut=o=>this.worker.postMessage({action:"setCut",data:o});setPause=o=>this.worker.postMessage({action:"setPause",data:o});destroy=()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()}}class W{inputStream=new MediaStream;outputStream=new MediaStream;inputGain=1;enhanceGain=1;bgsGain=1;bgmGain=1;outputGain=1;mixAudioMap=new Map;audioContext=new AudioContext;sourceNode;inputGainNode;enhanceGainNode;bgsGainNode;bgmGainNode;rnnoiseNode;analyserNode;analyserArrayData;outputGainNode;destinationNode;denoise=!1;mute=!0;rnnoiseWorklet;rnnoiseWorkletNode;filterStream=o=>o;constructor(o,a){this.inputStream=o,a&&(this.audioContext=a),this.sourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.inputGainNode=this.audioContext.createGain(),this.inputGainNode.gain.setValueAtTime(this.inputGain,this.audioContext.currentTime),this.enhanceGainNode=this.audioContext.createGain(),this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime),this.bgsGainNode=this.audioContext.createGain(),this.bgsGainNode.gain.setValueAtTime(this.bgsGain,this.audioContext.currentTime),this.bgmGainNode=this.audioContext.createGain(),this.bgmGainNode.gain.setValueAtTime(this.bgmGain,this.audioContext.currentTime),this.analyserNode=this.audioContext.createAnalyser(),this.analyserNode.fftSize=512,this.analyserArrayData=new Uint8Array(this.analyserNode.frequencyBinCount),this.outputGainNode=this.audioContext.createGain(),this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime),this.destinationNode=this.audioContext.createMediaStreamDestination(),this.outputStream=this.destinationNode.stream;{const{sourceNode:u,inputGainNode:n,enhanceGainNode:r,bgsGainNode:i,bgmGainNode:e,analyserNode:t,outputGainNode:s,destinationNode:l}=this;u.connect(n),n.connect(r),r.connect(t),i.connect(t),e.connect(t),r.connect(l),i.connect(l),e.connect(l),s.connect(this.audioContext.destination)}this.audioContext.resume()}use=({rnnoise:o})=>{this.rnnoiseWorklet=new o.RnnoiseWorklet};_changeSource=()=>{this.sourceNode.disconnect(),this.sourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.sourceNode.connect(this.inputGainNode)};replaceTrack=o=>{const a=this.inputStream.getTracks();for(const u of a)this.inputStream.removeTrack(u);this.inputStream.addTrack(o),this._changeSource()};stop=()=>{{const o=this.inputStream.getTracks();for(const a of o)a.stop(),this.inputStream.removeTrack(a)}};pause=async o=>{const a=this.inputStream.getTracks();for(const u of a)u.enabled=!o};getStream=()=>this.filterStream(this.outputStream);setMute=(o=!0)=>{this.mute=o,this.analyserNode.disconnect(),o===!1&&this.analyserNode.connect(this.outputGainNode)};setDenoise=async(o=!0)=>{this.rnnoiseWorklet&&(this.inputGainNode.disconnect(),this.rnnoiseWorklet.destroy(),o?(this.rnnoiseWorkletNode=await this.rnnoiseWorklet.createRnnoiseWorkletNode(this.audioContext),this.inputGainNode.connect(this.rnnoiseWorkletNode),this.rnnoiseWorkletNode.connect(this.enhanceGainNode)):this.inputGainNode.connect(this.enhanceGainNode),this.denoise=o)};setInputGain=o=>{this.inputGain=o,this.inputGainNode.gain.setValueAtTime(o,this.audioContext.currentTime)};setEnhanceGain=async o=>{this.enhanceGain=o+1,this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime)};setBgsGain=o=>{this.bgsGain=o,this.bgsGainNode.gain.setValueAtTime(o,this.audioContext.currentTime)};setBgmGain=o=>{this.bgmGain=o,this.bgmGainNode.gain.setValueAtTime(o,this.audioContext.currentTime)};setOutputGain=o=>{this.outputGain=o,this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime)};getVolume=()=>{const{analyserNode:o,analyserArrayData:a}=this;o.getByteFrequencyData(a);let u=0;for(let n=0;n<a.length;n++)u+=a[n];return Math.ceil(u/a.length)};mixAudio=(o,a="bgm")=>new Promise(async(u,n)=>{try{{const e=this.mixAudioMap.get(a);e&&e.stop()}const r=a==="bgs"?this.bgsGainNode:this.bgmGainNode,i=this.audioContext.createBufferSource();this.mixAudioMap.set(a,i),i.buffer=o,i.connect(r),i.onended=()=>{i.disconnect(r),this.mixAudioMap.delete(a),u(!0)},i.start(0)}catch(r){n(r)}});mixAudioStop=o=>{this.mixAudioMap.get(o)?.stop()};changeMix=(o,a)=>{const u=o==="bgs"?this.bgsGainNode:this.bgmGainNode;a?u.connect(this.destinationNode):u.disconnect(this.destinationNode)}}const F=async(p,o)=>{try{const{format:a,numberOfChannels:u,numberOfFrames:n,sampleRate:r}=o,i=p.createBuffer(u,n,r);for(let e=0;e<u;e++){const t=o.allocationSize({planeIndex:e}),s=new Uint8Array(t);o.copyTo(s,{planeIndex:e});const l=new DataView(s.buffer),c=i.getChannelData(e);for(let d=0;d<n;d++){let f;switch(a){case"s16":case"s16-planar":f=l.getInt16(d*2,!0)/32768;break;case"f32":case"f32-planar":f=l.getFloat32(d*4,!0);break;case"u8":case"u8-planar":f=(l.getUint8(d)-128)/128;break;default:throw new Error(`Unsupported audio format: ${a}`)}c[d]=Math.max(-1,Math.min(1,f))}}return i}catch(a){throw console.error("Failed to convert AudioData to AudioBuffer:",a),a}};class B{prAudioStream;audioContext;destination;stream=new MediaStream;nextStartTime=0;pendingSources=[];constructor(){}init=o=>{o||(o=new(window.AudioContext||window.webkitAudioContext)),this.audioContext=o,this.destination=this.audioContext.createMediaStreamDestination(),this.stream=new MediaStream,this.stream.addTrack(this.destination.stream.getAudioTracks()[0]),this.prAudioStream=new W(this.stream,this.audioContext),this.nextStartTime=0,this.pendingSources=[]};async push(o){const{audioData:a,playbackRate:u=1}=o;if(!this.audioContext||!this.destination)return;let n=await F(this.audioContext,a);if(a.close(),!n)return;const r=this.audioContext.createBufferSource();r.buffer=n,r.playbackRate.value=u;const i=-1200*Math.log2(u);r.detune.value=i,r.connect(this.destination);const e=Math.max(this.nextStartTime,this.audioContext.currentTime),t=n.duration/u;this.nextStartTime=e+t,r.start(e),this.pendingSources.push(r),r.onended=()=>{this.pendingSources=this.pendingSources.filter(s=>s!==r)},this.audioContext.state==="suspended"&&await this.audioContext.resume()}getStream=()=>this.prAudioStream?.getStream();destroy(){this.audioContext?.close(),this.audioContext=void 0,this.destination=void 0,this.nextStartTime=0,this.prAudioStream?.stop(),this.pendingSources.forEach(o=>o.stop()),this.pendingSources=[]}}const G=p=>{const o=p.toLowerCase();return o.includes(".m3u8")||o.includes("hls")||o.includes("master.m3u8")||o.match(/index\d*\.m3u8/)?"hls":o.includes(".mpd")||o.includes("dash")?"dash":o.startsWith("rtmp://")||o.startsWith("rtmps://")?"rtmp":o.includes(".flv")||o.includes("flv")&&!o.includes("flash")?"flv":"unknown"},E=p=>{const o=p?.getTracks()||[];for(const a of o)a.stop()};class O{resolvesMap=new Map;index=0;constructor(){}add=(o,a=()=>!1,u=0)=>new Promise(n=>{if(a())return n(!0);this.resolvesMap.has(o)||this.resolvesMap.set(o,new Map),this.index++;const r=`${this.index}`;if(u=Math.max(0,u),u===0){this.resolvesMap.get(o)?.set(r,{resolve:n,timer:0});return}const i=window.setTimeout(()=>{this.emit(o)},u);this.resolvesMap.get(o)?.set(r,{resolve:n,timer:i})});emit=async o=>{const a=this.resolvesMap.get(o);if(!a)return;const u=[...a.keys()];for(const n of u){const r=a.get(n);r&&(clearTimeout(r.timer),r.resolve(),a.delete(n))}}}const q=p=>{const o=new DataView(p.buffer);let a=0,u,n,r;u=o.getUint32(a,!1),a+=4;{const i=o.getUint8(a),e=i>>7&1,t=i>>5&3,s=i&31;n={forbidden_zero_bit:e,nal_ref_idc:t,nal_unit_type:s},a+=1}{const i=u-1;r=new Uint8Array(o.buffer.slice(a,a+i))}return{size:u,header:n,data:r}};class v{#t={timeout:5*1e3,check:!1};#e=null;constructor(o={}){this.#t={...this.#t,...o}}#i=(o,a)=>new Promise(async u=>{this.#e=new AbortController;const{signal:n}=this.#e,r=this.#t.timeout,i=setTimeout(()=>{this.#e?.abort(`Timeout (${r}ms)`)},r);await fetch(o,{cache:"no-store",...a,method:"HEAD",signal:n}).then(e=>{clearTimeout(i),u({status:e.status===200?"successed":"failed",reason:e.status===200?"":`HTTP ${e.status}`})}).catch(e=>{if(clearTimeout(i),e.name==="AbortError"){const t=n.reason||"Actively stopped";u({status:t.includes("Timeout")?"timeout":"stopped",reason:t})}else u({status:"error",reason:e.message})})});request=(o,a)=>new Promise(async(u,n)=>{try{this.stop(),this.#t.check&&await this.#i(o),this.#e=new AbortController;const{signal:r}=this.#e,i=await fetch(o,{cache:"no-store",...a,signal:r});u(i)}catch(r){n(r)}});stop=()=>{if(this.#e?.signal.aborted===!1){const o=new Error("Actively stopped.");o.name="AbortError",this.#e.abort(o)}}}class Q{option={debug:!1,frameTrack:!1};converter="MediaStreamTrackGenerator"in window?"generator":"canvas";prFetch=new v;getSegmentsFetch=new v;prResolves=new O;url="";start_resolve;demuxerWorker;decoderWorker;audioPlayer;renderWorker;stream;on={demuxer:{},decoder:{}};cutRenders=new Map;trackGenerator;constructor(o={}){const{debug:a=!1}=o;this.option.debug=a}start=async o=>{await this.stop(),this.url=o;const a=G(o);if(a==="unknown")throw new Error("This address cannot be parsed.");switch(this.init(a),a){case"flv":this.flv.start();break;case"hls":this.hls.start();break}};stop=async()=>{try{this.url="",clearInterval(this.hls.getSegmentsTimer),this.prFetch.stop(),this.getSegmentsFetch.stop(),this.demuxerWorker?.destroy(),this.decoderWorker?.destroy(),this.renderWorker?.destroy(),this.cutRenders=new Map,E(this.stream),this.audioPlayer?.destroy()}catch(o){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: error",o)}};getStream=()=>this.stream;setPause=o=>{this.renderWorker?.setPause({pause:o})};setMute=o=>this.audioPlayer?.prAudioStream?.setMute(o);setOutputGain=o=>{this.audioPlayer?.prAudioStream?.setOutputGain(o)};setFrameTrack=o=>{this.option.frameTrack=o,this.decoderWorker?.setFrameTrack(o)};isReady=()=>{const o=()=>this.stream?.active===!0;return this.prResolves.add("isReady",o)};cut={create:(o,a)=>{if(this.converter==="generator"){const i=new MediaStreamTrackGenerator({kind:"video"}),e=new MediaStream([i]);return this.renderWorker?.addCut({key:o,writable:i.writable,option:a}),this.cutRenders.set(o,{stream:e}),e}const u=document.createElement("canvas"),n=u.captureStream(),r=u.transferControlToOffscreen();return this.renderWorker?.addCut({key:o,offscreen:r,option:a}),this.cutRenders.set(o,{stream:n}),n},setCut:(o,a)=>{this.renderWorker?.setCut({key:o,cutOption:a})},getStream:o=>this.cutRenders.get(o)?.stream,remove:o=>{this.renderWorker?.delCut(o),this.cutRenders.delete(o)},setPause:(o,a)=>{this.renderWorker?.setPause({key:o,pause:a})}};init=o=>{this.initRender(),this.initDecoder(o),this.initDemuxer(o),this.audioPlayer=new B,this.audioPlayer.init()};initDemuxer=o=>{this.demuxerWorker=new P,this.demuxerWorker.init(o),this.demuxerWorker.on.debug=a=>{this.option.debug&&this.on.debug&&this.on.debug(a)},this.demuxerWorker.on.info=a=>{this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: info",a),this.on.demuxer.info&&this.on.demuxer.info(a)},this.demuxerWorker.on.config=a=>{this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: config",a),this.on.demuxer.config&&this.on.demuxer.config(a);const{kind:u}=a;switch(u){case"audio":{const{codec:n,sampleRate:r,numberOfChannels:i}=a;this.decoderWorker?.initAudio({codec:n,sampleRate:r,numberOfChannels:i})}break;case"video":{const{codec:n,description:r}=a;this.decoderWorker?.initVideo({codec:n,description:r})}break}},this.demuxerWorker.on.chunk=a=>{if(this.on.demuxer.chunk&&this.on.demuxer.chunk(a),!this.decoderWorker)return;const{kind:u}=a;switch(u){case"audio":{const{type:n,dts:r,data:i}=a,e=r*1e3;this.decoderWorker.push({kind:u,init:{type:n,timestamp:e,data:i}})}break;case"video":{const{type:n,dts:r,data:i,nalus:e=[]}=a,t=r*1e3;this.decoderWorker.push({kind:u,init:{type:n,timestamp:t,data:i},nalus:e})}break}}};initDecoder=o=>{this.decoderWorker=new N,this.decoderWorker.init(o);const{frameTrack:a=!1}=this.option;this.decoderWorker.setFrameTrack(a),this.decoderWorker.on.audio.decode=u=>{this.audioPlayer?.push(u),this.on.decoder.audio&&this.on.decoder.audio(u)},this.decoderWorker.on.audio.error=u=>{this.option.debug&&console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->pr-player: audio.error ",u),this.on.error&&this.on.error(u)},this.decoderWorker.on.video.decode=async u=>{this.start_resolve&&(this.start_resolve(!0),this.start_resolve=void 0),this.renderWorker?.push(u),this.on.decoder.video&&this.on.decoder.video(u)},this.decoderWorker.on.video.error=u=>{this.on.error&&this.on.error(u)},this.decoderWorker.on.nalus=async u=>{for(const n of u){if(n.byteLength<=4)continue;const{header:r,data:i}=q(n),{nal_unit_type:e}=r;e===6&&this.on.decoder.sei&&this.on.decoder.sei(i)}},this.decoderWorker.on.analysis=u=>{this.on.decoder.analysis&&this.on.decoder.analysis(u)}};initRender=()=>{if(this.renderWorker=new V,this.converter==="generator"){const o=new MediaStreamTrackGenerator({kind:"video"}),a=new MediaStream([o]);this.renderWorker?.addCut({writable:o.writable}),this.stream=a}else{const o=document.createElement("canvas"),a=o.captureStream(),u=o.transferControlToOffscreen();this.renderWorker?.addCut({offscreen:u}),this.stream=a}this.renderWorker?.setPause({pause:!1})};flv={start:()=>new Promise(async(o,a)=>{try{this.start_resolve=o;let u,n=0;for(;;){n+=1;try{u=await this.prFetch.request(this.url)}catch(i){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->Breathe: error",i)}if(u?.status===200||n===3)break;await new Promise(i=>setTimeout(()=>i(!0),500))}if(!u||u.status!==200)return a("request is error.");const r=u.body?.getReader();if(!r)return a("reader is error.");for(;;){const{done:i,value:e}=await r.read();if(e&&this.demuxerWorker?.push(e),i||this.url==="")break}}catch(u){u.name!=="AbortError"&&a(u)}})};hls={isLive:!1,urls:[],url:"",getSegmentsTimer:0,parse:async o=>{const a=new TextDecoder("utf-8").decode(o).split(`
4
- `).map(t=>t.replace("\r","")),u=this.url.substring(0,this.url.lastIndexOf("/")+1);let n=4,r=0,i=!1;const e=[];for(const t of a)t.startsWith("#EXTINF:")?n=parseFloat(t.split(":")[1].split(",")[0]):t.startsWith("#EXT-X-TARGETDURATION:")?r=parseInt(t.split(":")[1]):t.startsWith("#EXT-X-ENDLIST")?i=!1:t.startsWith("#EXT-X-MEDIA-SEQUENCE:")?i=!0:t.includes(".ts")&&!t.startsWith("#")&&e.push({url:t.startsWith("http")?t:u+t,duration:n,isLive:i});return{baseUrl:u,targetDuration:r,isLive:i,segments:e}},getSegments:async()=>{try{let o,a=0;for(;;){a+=1;try{o=await this.getSegmentsFetch.request(this.url)}catch(n){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->Breathe: error",n)}if(o?.status===200||a===3)break;await new Promise(n=>setTimeout(()=>n(!0),500))}if(!o||o.status!==200)throw new Error("request is error.");const u=o.body?.getReader();if(!u)throw new Error("reader is error.");for(;;){const{done:n,value:r}=await u.read();if(r){const i=await this.hls.parse(r),{segments:e=[],isLive:t=!1}=i;this.hls.isLive=t,t===!1&&(this.option.frameTrack=!1);let s=Array.from(e,c=>c.url);const l=s.findIndex(c=>c===this.hls.url);l!==-1&&(s=s.slice(l+1)),this.hls.urls=s}if(n||this.url==="")break}}catch(o){o.name!=="AbortError"&&this.on.error&&this.on.error(o)}},start:()=>new Promise(async(o,a)=>{try{for(this.start_resolve=o,this.hls.url="",this.hls.urls=[],await this.hls.getSegments(),this.hls.getSegmentsTimer=window.setInterval(this.hls.getSegments,500),this.hls.isLive===!1&&(clearInterval(this.hls.getSegmentsTimer),this.decoderWorker?.setFrameTrack(!1));;){const u=this.hls.urls.shift();if(u){this.hls.url=u;const n=(await this.prFetch.request(u)).body?.getReader();if(!n)throw new Error("segment reader is error.");for(;;){const{done:r,value:i}=await n.read();if(i&&this.demuxerWorker?.push(i),r||this.url==="")break}}else await new Promise(n=>setTimeout(()=>n(!0),300))}}catch(u){u.name!=="AbortError"&&a(u)}})}}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},indexMinimal={},minimal$1={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=p;function p(o,a){for(var u=new Array(arguments.length-1),n=0,r=2,i=!0;r<arguments.length;)u[n++]=arguments[r++];return new Promise(function(t,s){u[n]=function(c){if(i)if(i=!1,c)s(c);else{for(var d=new Array(arguments.length-1),f=0;f<d.length;)d[f++]=arguments[f];t.apply(null,d)}};try{o.apply(a||null,u)}catch(l){i&&(i=!1,s(l))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,(function(p){var o=p;o.length=function(e){var t=e.length;if(!t)return 0;for(var s=0;--t%4>1&&e.charAt(t)==="=";)++s;return Math.ceil(e.length*3)/4-s};for(var a=new Array(64),u=new Array(123),n=0;n<64;)u[a[n]=n<26?n+65:n<52?n+71:n<62?n-4:n-59|43]=n++;o.encode=function(e,t,s){for(var l=null,c=[],d=0,f=0,h;t<s;){var g=e[t++];switch(f){case 0:c[d++]=a[g>>2],h=(g&3)<<4,f=1;break;case 1:c[d++]=a[h|g>>4],h=(g&15)<<2,f=2;break;case 2:c[d++]=a[h|g>>6],c[d++]=a[g&63],f=0;break}d>8191&&((l||(l=[])).push(String.fromCharCode.apply(String,c)),d=0)}return f&&(c[d++]=a[h],c[d++]=61,f===1&&(c[d++]=61)),l?(d&&l.push(String.fromCharCode.apply(String,c.slice(0,d))),l.join("")):String.fromCharCode.apply(String,c.slice(0,d))};var r="invalid encoding";o.decode=function(e,t,s){for(var l=s,c=0,d,f=0;f<e.length;){var h=e.charCodeAt(f++);if(h===61&&c>1)break;if((h=u[h])===void 0)throw Error(r);switch(c){case 0:d=h,c=1;break;case 1:t[s++]=d<<2|(h&48)>>4,d=h,c=2;break;case 2:t[s++]=(d&15)<<4|(h&60)>>2,d=h,c=3;break;case 3:t[s++]=(d&3)<<6|h,c=0;break}}if(c===1)throw Error(r);return s-l},o.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}})(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=p;function p(){this._listeners={}}return p.prototype.on=function(a,u,n){return(this._listeners[a]||(this._listeners[a]=[])).push({fn:u,ctx:n||this}),this},p.prototype.off=function(a,u){if(a===void 0)this._listeners={};else if(u===void 0)this._listeners[a]=[];else for(var n=this._listeners[a],r=0;r<n.length;)n[r].fn===u?n.splice(r,1):++r;return this},p.prototype.emit=function(a){var u=this._listeners[a];if(u){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<u.length;)u[r].fn.apply(u[r++].ctx,n)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=p(p);function p(r){return typeof Float32Array<"u"?(function(){var i=new Float32Array([-0]),e=new Uint8Array(i.buffer),t=e[3]===128;function s(f,h,g){i[0]=f,h[g]=e[0],h[g+1]=e[1],h[g+2]=e[2],h[g+3]=e[3]}function l(f,h,g){i[0]=f,h[g]=e[3],h[g+1]=e[2],h[g+2]=e[1],h[g+3]=e[0]}r.writeFloatLE=t?s:l,r.writeFloatBE=t?l:s;function c(f,h){return e[0]=f[h],e[1]=f[h+1],e[2]=f[h+2],e[3]=f[h+3],i[0]}function d(f,h){return e[3]=f[h],e[2]=f[h+1],e[1]=f[h+2],e[0]=f[h+3],i[0]}r.readFloatLE=t?c:d,r.readFloatBE=t?d:c})():(function(){function i(t,s,l,c){var d=s<0?1:0;if(d&&(s=-s),s===0)t(1/s>0?0:2147483648,l,c);else if(isNaN(s))t(2143289344,l,c);else if(s>34028234663852886e22)t((d<<31|2139095040)>>>0,l,c);else if(s<11754943508222875e-54)t((d<<31|Math.round(s/1401298464324817e-60))>>>0,l,c);else{var f=Math.floor(Math.log(s)/Math.LN2),h=Math.round(s*Math.pow(2,-f)*8388608)&8388607;t((d<<31|f+127<<23|h)>>>0,l,c)}}r.writeFloatLE=i.bind(null,o),r.writeFloatBE=i.bind(null,a);function e(t,s,l){var c=t(s,l),d=(c>>31)*2+1,f=c>>>23&255,h=c&8388607;return f===255?h?NaN:d*(1/0):f===0?d*1401298464324817e-60*h:d*Math.pow(2,f-150)*(h+8388608)}r.readFloatLE=e.bind(null,u),r.readFloatBE=e.bind(null,n)})(),typeof Float64Array<"u"?(function(){var i=new Float64Array([-0]),e=new Uint8Array(i.buffer),t=e[7]===128;function s(f,h,g){i[0]=f,h[g]=e[0],h[g+1]=e[1],h[g+2]=e[2],h[g+3]=e[3],h[g+4]=e[4],h[g+5]=e[5],h[g+6]=e[6],h[g+7]=e[7]}function l(f,h,g){i[0]=f,h[g]=e[7],h[g+1]=e[6],h[g+2]=e[5],h[g+3]=e[4],h[g+4]=e[3],h[g+5]=e[2],h[g+6]=e[1],h[g+7]=e[0]}r.writeDoubleLE=t?s:l,r.writeDoubleBE=t?l:s;function c(f,h){return e[0]=f[h],e[1]=f[h+1],e[2]=f[h+2],e[3]=f[h+3],e[4]=f[h+4],e[5]=f[h+5],e[6]=f[h+6],e[7]=f[h+7],i[0]}function d(f,h){return e[7]=f[h],e[6]=f[h+1],e[5]=f[h+2],e[4]=f[h+3],e[3]=f[h+4],e[2]=f[h+5],e[1]=f[h+6],e[0]=f[h+7],i[0]}r.readDoubleLE=t?c:d,r.readDoubleBE=t?d:c})():(function(){function i(t,s,l,c,d,f){var h=c<0?1:0;if(h&&(c=-c),c===0)t(0,d,f+s),t(1/c>0?0:2147483648,d,f+l);else if(isNaN(c))t(0,d,f+s),t(2146959360,d,f+l);else if(c>17976931348623157e292)t(0,d,f+s),t((h<<31|2146435072)>>>0,d,f+l);else{var g;if(c<22250738585072014e-324)g=c/5e-324,t(g>>>0,d,f+s),t((h<<31|g/4294967296)>>>0,d,f+l);else{var m=Math.floor(Math.log(c)/Math.LN2);m===1024&&(m=1023),g=c*Math.pow(2,-m),t(g*4503599627370496>>>0,d,f+s),t((h<<31|m+1023<<20|g*1048576&1048575)>>>0,d,f+l)}}}r.writeDoubleLE=i.bind(null,o,0,4),r.writeDoubleBE=i.bind(null,a,4,0);function e(t,s,l,c,d){var f=t(c,d+s),h=t(c,d+l),g=(h>>31)*2+1,m=h>>>20&2047,y=4294967296*(h&1048575)+f;return m===2047?y?NaN:g*(1/0):m===0?g*5e-324*y:g*Math.pow(2,m-1075)*(y+4503599627370496)}r.readDoubleLE=e.bind(null,u,0,4),r.readDoubleBE=e.bind(null,n,4,0)})(),r}function o(r,i,e){i[e]=r&255,i[e+1]=r>>>8&255,i[e+2]=r>>>16&255,i[e+3]=r>>>24}function a(r,i,e){i[e]=r>>>24,i[e+1]=r>>>16&255,i[e+2]=r>>>8&255,i[e+3]=r&255}function u(r,i){return(r[i]|r[i+1]<<8|r[i+2]<<16|r[i+3]<<24)>>>0}function n(r,i){return(r[i]<<24|r[i+1]<<16|r[i+2]<<8|r[i+3])>>>0}return float}var inquire_1,hasRequiredInquire;function requireInquire(){if(hasRequiredInquire)return inquire_1;hasRequiredInquire=1,inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(p){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,(function(p){var o=p;o.length=function(u){for(var n=0,r=0,i=0;i<u.length;++i)r=u.charCodeAt(i),r<128?n+=1:r<2048?n+=2:(r&64512)===55296&&(u.charCodeAt(i+1)&64512)===56320?(++i,n+=4):n+=3;return n},o.read=function(u,n,r){var i=r-n;if(i<1)return"";for(var e=null,t=[],s=0,l;n<r;)l=u[n++],l<128?t[s++]=l:l>191&&l<224?t[s++]=(l&31)<<6|u[n++]&63:l>239&&l<365?(l=((l&7)<<18|(u[n++]&63)<<12|(u[n++]&63)<<6|u[n++]&63)-65536,t[s++]=55296+(l>>10),t[s++]=56320+(l&1023)):t[s++]=(l&15)<<12|(u[n++]&63)<<6|u[n++]&63,s>8191&&((e||(e=[])).push(String.fromCharCode.apply(String,t)),s=0);return e?(s&&e.push(String.fromCharCode.apply(String,t.slice(0,s))),e.join("")):String.fromCharCode.apply(String,t.slice(0,s))},o.write=function(u,n,r){for(var i=r,e,t,s=0;s<u.length;++s)e=u.charCodeAt(s),e<128?n[r++]=e:e<2048?(n[r++]=e>>6|192,n[r++]=e&63|128):(e&64512)===55296&&((t=u.charCodeAt(s+1))&64512)===56320?(e=65536+((e&1023)<<10)+(t&1023),++s,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=e&63|128):(n[r++]=e>>12|224,n[r++]=e>>6&63|128,n[r++]=e&63|128);return r-i}})(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=p;function p(o,a,u){var n=u||8192,r=n>>>1,i=null,e=n;return function(s){if(s<1||s>r)return o(s);e+s>n&&(i=o(n),e=0);var l=a.call(i,e,e+=s);return e&7&&(e=(e|7)+1),l}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=o;var p=requireMinimal$1();function o(r,i){this.lo=r>>>0,this.hi=i>>>0}var a=o.zero=new o(0,0);a.toNumber=function(){return 0},a.zzEncode=a.zzDecode=function(){return this},a.length=function(){return 1};var u=o.zeroHash="\0\0\0\0\0\0\0\0";o.fromNumber=function(i){if(i===0)return a;var e=i<0;e&&(i=-i);var t=i>>>0,s=(i-t)/4294967296>>>0;return e&&(s=~s>>>0,t=~t>>>0,++t>4294967295&&(t=0,++s>4294967295&&(s=0))),new o(t,s)},o.from=function(i){if(typeof i=="number")return o.fromNumber(i);if(p.isString(i))if(p.Long)i=p.Long.fromString(i);else return o.fromNumber(parseInt(i,10));return i.low||i.high?new o(i.low>>>0,i.high>>>0):a},o.prototype.toNumber=function(i){if(!i&&this.hi>>>31){var e=~this.lo+1>>>0,t=~this.hi>>>0;return e||(t=t+1>>>0),-(e+t*4294967296)}return this.lo+this.hi*4294967296},o.prototype.toLong=function(i){return p.Long?new p.Long(this.lo|0,this.hi|0,!!i):{low:this.lo|0,high:this.hi|0,unsigned:!!i}};var n=String.prototype.charCodeAt;return o.fromHash=function(i){return i===u?a:new o((n.call(i,0)|n.call(i,1)<<8|n.call(i,2)<<16|n.call(i,3)<<24)>>>0,(n.call(i,4)|n.call(i,5)<<8|n.call(i,6)<<16|n.call(i,7)<<24)>>>0)},o.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},o.prototype.zzEncode=function(){var i=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^i)>>>0,this.lo=(this.lo<<1^i)>>>0,this},o.prototype.zzDecode=function(){var i=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^i)>>>0,this.hi=(this.hi>>>1^i)>>>0,this},o.prototype.length=function(){var i=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,t=this.hi>>>24;return t===0?e===0?i<16384?i<128?1:2:i<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:t<128?9:10},longbits}var hasRequiredMinimal$1;function requireMinimal$1(){return hasRequiredMinimal$1||(hasRequiredMinimal$1=1,(function(p){var o=p;o.asPromise=requireAspromise(),o.base64=requireBase64(),o.EventEmitter=requireEventemitter(),o.float=requireFloat(),o.inquire=requireInquire(),o.utf8=requireUtf8(),o.pool=requirePool(),o.LongBits=requireLongbits(),o.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),o.global=o.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal$1,o.emptyArray=Object.freeze?Object.freeze([]):[],o.emptyObject=Object.freeze?Object.freeze({}):{},o.isInteger=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r},o.isString=function(r){return typeof r=="string"||r instanceof String},o.isObject=function(r){return r&&typeof r=="object"},o.isset=o.isSet=function(r,i){var e=r[i];return e!=null&&r.hasOwnProperty(i)?typeof e!="object"||(Array.isArray(e)?e.length:Object.keys(e).length)>0:!1},o.Buffer=(function(){try{var n=o.inquire("buffer").Buffer;return n.prototype.utf8Write?n:null}catch{return null}})(),o._Buffer_from=null,o._Buffer_allocUnsafe=null,o.newBuffer=function(r){return typeof r=="number"?o.Buffer?o._Buffer_allocUnsafe(r):new o.Array(r):o.Buffer?o._Buffer_from(r):typeof Uint8Array>"u"?r:new Uint8Array(r)},o.Array=typeof Uint8Array<"u"?Uint8Array:Array,o.Long=o.global.dcodeIO&&o.global.dcodeIO.Long||o.global.Long||o.inquire("long"),o.key2Re=/^true|false|0|1$/,o.key32Re=/^-?(?:0|[1-9][0-9]*)$/,o.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,o.longToHash=function(r){return r?o.LongBits.from(r).toHash():o.LongBits.zeroHash},o.longFromHash=function(r,i){var e=o.LongBits.fromHash(r);return o.Long?o.Long.fromBits(e.lo,e.hi,i):e.toNumber(!!i)};function a(n,r,i){for(var e=Object.keys(r),t=0;t<e.length;++t)(n[e[t]]===void 0||!i)&&(n[e[t]]=r[e[t]]);return n}o.merge=a,o.lcFirst=function(r){return r.charAt(0).toLowerCase()+r.substring(1)};function u(n){function r(i,e){if(!(this instanceof r))return new r(i,e);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,r):Object.defineProperty(this,"stack",{value:new Error().stack||""}),e&&a(this,e)}return r.prototype=Object.create(Error.prototype,{constructor:{value:r,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return n},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),r}o.newError=u,o.ProtocolError=u("ProtocolError"),o.oneOfGetter=function(r){for(var i={},e=0;e<r.length;++e)i[r[e]]=1;return function(){for(var t=Object.keys(this),s=t.length-1;s>-1;--s)if(i[t[s]]===1&&this[t[s]]!==void 0&&this[t[s]]!==null)return t[s]}},o.oneOfSetter=function(r){return function(i){for(var e=0;e<r.length;++e)r[e]!==i&&delete this[r[e]]}},o.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},o._configure=function(){var n=o.Buffer;if(!n){o._Buffer_from=o._Buffer_allocUnsafe=null;return}o._Buffer_from=n.from!==Uint8Array.from&&n.from||function(i,e){return new n(i,e)},o._Buffer_allocUnsafe=n.allocUnsafe||function(i){return new n(i)}}})(minimal$1)),minimal$1}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=t;var p=requireMinimal$1(),o,a=p.LongBits,u=p.base64,n=p.utf8;function r(m,y,b){this.fn=m,this.len=y,this.next=void 0,this.val=b}function i(){}function e(m){this.head=m.head,this.tail=m.tail,this.len=m.len,this.next=m.states}function t(){this.len=0,this.head=new r(i,0,0),this.tail=this.head,this.states=null}var s=function(){return p.Buffer?function(){return(t.create=function(){return new o})()}:function(){return new t}};t.create=s(),t.alloc=function(y){return new p.Array(y)},p.Array!==Array&&(t.alloc=p.pool(t.alloc,p.Array.prototype.subarray)),t.prototype._push=function(y,b,k){return this.tail=this.tail.next=new r(y,b,k),this.len+=b,this};function l(m,y,b){y[b]=m&255}function c(m,y,b){for(;m>127;)y[b++]=m&127|128,m>>>=7;y[b]=m}function d(m,y){this.len=m,this.next=void 0,this.val=y}d.prototype=Object.create(r.prototype),d.prototype.fn=c,t.prototype.uint32=function(y){return this.len+=(this.tail=this.tail.next=new d((y=y>>>0)<128?1:y<16384?2:y<2097152?3:y<268435456?4:5,y)).len,this},t.prototype.int32=function(y){return y<0?this._push(f,10,a.fromNumber(y)):this.uint32(y)},t.prototype.sint32=function(y){return this.uint32((y<<1^y>>31)>>>0)};function f(m,y,b){for(;m.hi;)y[b++]=m.lo&127|128,m.lo=(m.lo>>>7|m.hi<<25)>>>0,m.hi>>>=7;for(;m.lo>127;)y[b++]=m.lo&127|128,m.lo=m.lo>>>7;y[b++]=m.lo}t.prototype.uint64=function(y){var b=a.from(y);return this._push(f,b.length(),b)},t.prototype.int64=t.prototype.uint64,t.prototype.sint64=function(y){var b=a.from(y).zzEncode();return this._push(f,b.length(),b)},t.prototype.bool=function(y){return this._push(l,1,y?1:0)};function h(m,y,b){y[b]=m&255,y[b+1]=m>>>8&255,y[b+2]=m>>>16&255,y[b+3]=m>>>24}t.prototype.fixed32=function(y){return this._push(h,4,y>>>0)},t.prototype.sfixed32=t.prototype.fixed32,t.prototype.fixed64=function(y){var b=a.from(y);return this._push(h,4,b.lo)._push(h,4,b.hi)},t.prototype.sfixed64=t.prototype.fixed64,t.prototype.float=function(y){return this._push(p.float.writeFloatLE,4,y)},t.prototype.double=function(y){return this._push(p.float.writeDoubleLE,8,y)};var g=p.Array.prototype.set?function(y,b,k){b.set(y,k)}:function(y,b,k){for(var w=0;w<y.length;++w)b[k+w]=y[w]};return t.prototype.bytes=function(y){var b=y.length>>>0;if(!b)return this._push(l,1,0);if(p.isString(y)){var k=t.alloc(b=u.length(y));u.decode(y,k,0),y=k}return this.uint32(b)._push(g,b,y)},t.prototype.string=function(y){var b=n.length(y);return b?this.uint32(b)._push(n.write,b,y):this._push(l,1,0)},t.prototype.fork=function(){return this.states=new e(this),this.head=this.tail=new r(i,0,0),this.len=0,this},t.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new r(i,0,0),this.len=0),this},t.prototype.ldelim=function(){var y=this.head,b=this.tail,k=this.len;return this.reset().uint32(k),k&&(this.tail.next=y.next,this.tail=b,this.len+=k),this},t.prototype.finish=function(){for(var y=this.head.next,b=this.constructor.alloc(this.len),k=0;y;)y.fn(y.val,b,k),k+=y.len,y=y.next;return b},t._configure=function(m){o=m,t.create=s(),o._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=a;var p=requireWriter();(a.prototype=Object.create(p.prototype)).constructor=a;var o=requireMinimal$1();function a(){p.call(this)}a._configure=function(){a.alloc=o._Buffer_allocUnsafe,a.writeBytesBuffer=o.Buffer&&o.Buffer.prototype instanceof Uint8Array&&o.Buffer.prototype.set.name==="set"?function(r,i,e){i.set(r,e)}:function(r,i,e){if(r.copy)r.copy(i,e,0,r.length);else for(var t=0;t<r.length;)i[e++]=r[t++]}},a.prototype.bytes=function(r){o.isString(r)&&(r=o._Buffer_from(r,"base64"));var i=r.length>>>0;return this.uint32(i),i&&this._push(a.writeBytesBuffer,i,r),this};function u(n,r,i){n.length<40?o.utf8.write(n,r,i):r.utf8Write?r.utf8Write(n,i):r.write(n,i)}return a.prototype.string=function(r){var i=o.Buffer.byteLength(r);return this.uint32(i),i&&this._push(u,i,r),this},a._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=r;var p=requireMinimal$1(),o,a=p.LongBits,u=p.utf8;function n(c,d){return RangeError("index out of range: "+c.pos+" + "+(d||1)+" > "+c.len)}function r(c){this.buf=c,this.pos=0,this.len=c.length}var i=typeof Uint8Array<"u"?function(d){if(d instanceof Uint8Array||Array.isArray(d))return new r(d);throw Error("illegal buffer")}:function(d){if(Array.isArray(d))return new r(d);throw Error("illegal buffer")},e=function(){return p.Buffer?function(f){return(r.create=function(g){return p.Buffer.isBuffer(g)?new o(g):i(g)})(f)}:i};r.create=e(),r.prototype._slice=p.Array.prototype.subarray||p.Array.prototype.slice,r.prototype.uint32=(function(){var d=4294967295;return function(){if(d=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(d=(d|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return d;if((this.pos+=5)>this.len)throw this.pos=this.len,n(this,10);return d}})(),r.prototype.int32=function(){return this.uint32()|0},r.prototype.sint32=function(){var d=this.uint32();return d>>>1^-(d&1)|0};function t(){var c=new a(0,0),d=0;if(this.len-this.pos>4){for(;d<4;++d)if(c.lo=(c.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return c;if(c.lo=(c.lo|(this.buf[this.pos]&127)<<28)>>>0,c.hi=(c.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return c;d=0}else{for(;d<3;++d){if(this.pos>=this.len)throw n(this);if(c.lo=(c.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return c}return c.lo=(c.lo|(this.buf[this.pos++]&127)<<d*7)>>>0,c}if(this.len-this.pos>4){for(;d<5;++d)if(c.hi=(c.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return c}else for(;d<5;++d){if(this.pos>=this.len)throw n(this);if(c.hi=(c.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return c}throw Error("invalid varint encoding")}r.prototype.bool=function(){return this.uint32()!==0};function s(c,d){return(c[d-4]|c[d-3]<<8|c[d-2]<<16|c[d-1]<<24)>>>0}r.prototype.fixed32=function(){if(this.pos+4>this.len)throw n(this,4);return s(this.buf,this.pos+=4)},r.prototype.sfixed32=function(){if(this.pos+4>this.len)throw n(this,4);return s(this.buf,this.pos+=4)|0};function l(){if(this.pos+8>this.len)throw n(this,8);return new a(s(this.buf,this.pos+=4),s(this.buf,this.pos+=4))}return r.prototype.float=function(){if(this.pos+4>this.len)throw n(this,4);var d=p.float.readFloatLE(this.buf,this.pos);return this.pos+=4,d},r.prototype.double=function(){if(this.pos+8>this.len)throw n(this,4);var d=p.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,d},r.prototype.bytes=function(){var d=this.uint32(),f=this.pos,h=this.pos+d;if(h>this.len)throw n(this,d);if(this.pos+=d,Array.isArray(this.buf))return this.buf.slice(f,h);if(f===h){var g=p.Buffer;return g?g.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,f,h)},r.prototype.string=function(){var d=this.bytes();return u.read(d,0,d.length)},r.prototype.skip=function(d){if(typeof d=="number"){if(this.pos+d>this.len)throw n(this,d);this.pos+=d}else do if(this.pos>=this.len)throw n(this);while(this.buf[this.pos++]&128);return this},r.prototype.skipType=function(c){switch(c){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(c=this.uint32()&7)!==4;)this.skipType(c);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+c+" at offset "+this.pos)}return this},r._configure=function(c){o=c,r.create=e(),o._configure();var d=p.Long?"toLong":"toNumber";p.merge(r.prototype,{int64:function(){return t.call(this)[d](!1)},uint64:function(){return t.call(this)[d](!0)},sint64:function(){return t.call(this).zzDecode()[d](!1)},fixed64:function(){return l.call(this)[d](!0)},sfixed64:function(){return l.call(this)[d](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=a;var p=requireReader();(a.prototype=Object.create(p.prototype)).constructor=a;var o=requireMinimal$1();function a(u){p.call(this,u)}return a._configure=function(){o.Buffer&&(a.prototype._slice=o.Buffer.prototype.slice)},a.prototype.string=function(){var n=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+n,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+n,this.len))},a._configure(),reader_buffer}var rpc={},service,hasRequiredService;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=o;var p=requireMinimal$1();(o.prototype=Object.create(p.EventEmitter.prototype)).constructor=o;function o(a,u,n){if(typeof a!="function")throw TypeError("rpcImpl must be a function");p.EventEmitter.call(this),this.rpcImpl=a,this.requestDelimited=!!u,this.responseDelimited=!!n}return o.prototype.rpcCall=function a(u,n,r,i,e){if(!i)throw TypeError("request must be specified");var t=this;if(!e)return p.asPromise(a,t,u,n,r,i);if(!t.rpcImpl){setTimeout(function(){e(Error("already ended"))},0);return}try{return t.rpcImpl(u,n[t.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(l,c){if(l)return t.emit("error",l,u),e(l);if(c===null){t.end(!0);return}if(!(c instanceof r))try{c=r[t.responseDelimited?"decodeDelimited":"decode"](c)}catch(d){return t.emit("error",d,u),e(d)}return t.emit("data",c,u),e(null,c)})}catch(s){t.emit("error",s,u),setTimeout(function(){e(s)},0);return}},o.prototype.end=function(u){return this.rpcImpl&&(u||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,(function(p){var o=p;o.Service=requireService()})(rpc)),rpc}var roots,hasRequiredRoots;function requireRoots(){return hasRequiredRoots||(hasRequiredRoots=1,roots={}),roots}var hasRequiredIndexMinimal;function requireIndexMinimal(){return hasRequiredIndexMinimal||(hasRequiredIndexMinimal=1,(function(p){var o=p;o.build="minimal",o.Writer=requireWriter(),o.BufferWriter=requireWriter_buffer(),o.Reader=requireReader(),o.BufferReader=requireReader_buffer(),o.util=requireMinimal$1(),o.rpc=requireRpc(),o.roots=requireRoots(),o.configure=a;function a(){o.util._configure(),o.Writer._configure(o.BufferWriter),o.Reader._configure(o.BufferReader)}a()})(indexMinimal)),indexMinimal}var minimal,hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,minimal=requireIndexMinimal()),minimal}var minimalExports=requireMinimal();const $Reader=minimalExports.Reader,$Writer=minimalExports.Writer,$util=minimalExports.util,$root=minimalExports.roots.default||(minimalExports.roots.default={}),com=$root.com=(()=>{const p={};return p.quick=(function(){const o={};return o.voice=(function(){const a={};return a.proto=(function(){const u={};return u.SeiData=(function(){function n(r){if(r)for(let i=Object.keys(r),e=0;e<i.length;++e)r[i[e]]!=null&&(this[i[e]]=r[i[e]])}return n.prototype.event=0,n.prototype.data=$util.newBuffer([]),n.prototype.compress=!1,n.prototype.version=0,n.create=function(i){return new n(i)},n.encode=function(i,e){return e||(e=$Writer.create()),i.event!=null&&Object.hasOwnProperty.call(i,"event")&&e.uint32(8).int32(i.event),i.data!=null&&Object.hasOwnProperty.call(i,"data")&&e.uint32(18).bytes(i.data),i.compress!=null&&Object.hasOwnProperty.call(i,"compress")&&e.uint32(24).bool(i.compress),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&e.uint32(32).int32(i.version),e},n.encodeDelimited=function(i,e){return this.encode(i,e).ldelim()},n.decode=function(i,e,t){i instanceof $Reader||(i=$Reader.create(i));let s=e===void 0?i.len:i.pos+e,l=new $root.com.quick.voice.proto.SeiData;for(;i.pos<s;){let c=i.uint32();if(c===t)break;switch(c>>>3){case 1:{l.event=i.int32();break}case 2:{l.data=i.bytes();break}case 3:{l.compress=i.bool();break}case 4:{l.version=i.int32();break}default:i.skipType(c&7);break}}return l},n.decodeDelimited=function(i){return i instanceof $Reader||(i=new $Reader(i)),this.decode(i,i.uint32())},n.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.event!=null&&i.hasOwnProperty("event"))switch(i.event){default:return"event: enum value expected";case 0:case 1:break}return i.data!=null&&i.hasOwnProperty("data")&&!(i.data&&typeof i.data.length=="number"||$util.isString(i.data))?"data: buffer expected":i.compress!=null&&i.hasOwnProperty("compress")&&typeof i.compress!="boolean"?"compress: boolean expected":i.version!=null&&i.hasOwnProperty("version")&&!$util.isInteger(i.version)?"version: integer expected":null},n.fromObject=function(i){if(i instanceof $root.com.quick.voice.proto.SeiData)return i;let e=new $root.com.quick.voice.proto.SeiData;switch(i.event){default:if(typeof i.event=="number"){e.event=i.event;break}break;case"Layout":case 0:e.event=0;break;case"Custom":case 1:e.event=1;break}return i.data!=null&&(typeof i.data=="string"?$util.base64.decode(i.data,e.data=$util.newBuffer($util.base64.length(i.data)),0):i.data.length>=0&&(e.data=i.data)),i.compress!=null&&(e.compress=!!i.compress),i.version!=null&&(e.version=i.version|0),e},n.toObject=function(i,e){e||(e={});let t={};return e.defaults&&(t.event=e.enums===String?"Layout":0,e.bytes===String?t.data="":(t.data=[],e.bytes!==Array&&(t.data=$util.newBuffer(t.data))),t.compress=!1,t.version=0),i.event!=null&&i.hasOwnProperty("event")&&(t.event=e.enums===String?$root.com.quick.voice.proto.EventType[i.event]===void 0?i.event:$root.com.quick.voice.proto.EventType[i.event]:i.event),i.data!=null&&i.hasOwnProperty("data")&&(t.data=e.bytes===String?$util.base64.encode(i.data,0,i.data.length):e.bytes===Array?Array.prototype.slice.call(i.data):i.data),i.compress!=null&&i.hasOwnProperty("compress")&&(t.compress=i.compress),i.version!=null&&i.hasOwnProperty("version")&&(t.version=i.version),t},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/com.quick.voice.proto.SeiData"},n})(),u.EventType=(function(){const n={},r=Object.create(n);return r[n[0]="Layout"]=0,r[n[1]="Custom"]=1,r})(),u.LayoutData=(function(){function n(i){if(this.userMap={},i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}n.prototype.roomId="",n.prototype.type=0,n.prototype.userMap=$util.emptyObject,n.prototype.globalCustom=null;let r;return Object.defineProperty(n.prototype,"_globalCustom",{get:$util.oneOfGetter(r=["globalCustom"]),set:$util.oneOfSetter(r)}),n.create=function(e){return new n(e)},n.encode=function(e,t){if(t||(t=$Writer.create()),e.roomId!=null&&Object.hasOwnProperty.call(e,"roomId")&&t.uint32(10).string(e.roomId),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(16).int32(e.type),e.userMap!=null&&Object.hasOwnProperty.call(e,"userMap"))for(let s=Object.keys(e.userMap),l=0;l<s.length;++l)t.uint32(26).fork().uint32(10).string(s[l]),$root.com.quick.voice.proto.UserInfo.encode(e.userMap[s[l]],t.uint32(18).fork()).ldelim().ldelim();return e.globalCustom!=null&&Object.hasOwnProperty.call(e,"globalCustom")&&$root.com.quick.voice.proto.CustomInfo.encode(e.globalCustom,t.uint32(34).fork()).ldelim(),t},n.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},n.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,c=new $root.com.quick.voice.proto.LayoutData,d,f;for(;e.pos<l;){let h=e.uint32();if(h===s)break;switch(h>>>3){case 1:{c.roomId=e.string();break}case 2:{c.type=e.int32();break}case 3:{c.userMap===$util.emptyObject&&(c.userMap={});let g=e.uint32()+e.pos;for(d="",f=null;e.pos<g;){let m=e.uint32();switch(m>>>3){case 1:d=e.string();break;case 2:f=$root.com.quick.voice.proto.UserInfo.decode(e,e.uint32());break;default:e.skipType(m&7);break}}c.userMap[d]=f;break}case 4:{c.globalCustom=$root.com.quick.voice.proto.CustomInfo.decode(e,e.uint32());break}default:e.skipType(h&7);break}}return c},n.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.roomId!=null&&e.hasOwnProperty("roomId")&&!$util.isString(e.roomId))return"roomId: string expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:break}if(e.userMap!=null&&e.hasOwnProperty("userMap")){if(!$util.isObject(e.userMap))return"userMap: object expected";let t=Object.keys(e.userMap);for(let s=0;s<t.length;++s){let l=$root.com.quick.voice.proto.UserInfo.verify(e.userMap[t[s]]);if(l)return"userMap."+l}}if(e.globalCustom!=null&&e.hasOwnProperty("globalCustom")){let t=$root.com.quick.voice.proto.CustomInfo.verify(e.globalCustom);if(t)return"globalCustom."+t}return null},n.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.LayoutData)return e;let t=new $root.com.quick.voice.proto.LayoutData;switch(e.roomId!=null&&(t.roomId=String(e.roomId)),e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"AudioAndVideo":case 0:t.type=0;break;case"OnlyAudio":case 1:t.type=1;break;case"OnlyVideo":case 2:t.type=2;break}if(e.userMap){if(typeof e.userMap!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");t.userMap={};for(let s=Object.keys(e.userMap),l=0;l<s.length;++l){if(typeof e.userMap[s[l]]!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");t.userMap[s[l]]=$root.com.quick.voice.proto.UserInfo.fromObject(e.userMap[s[l]])}}if(e.globalCustom!=null){if(typeof e.globalCustom!="object")throw TypeError(".com.quick.voice.proto.LayoutData.globalCustom: object expected");t.globalCustom=$root.com.quick.voice.proto.CustomInfo.fromObject(e.globalCustom)}return t},n.toObject=function(e,t){t||(t={});let s={};(t.objects||t.defaults)&&(s.userMap={}),t.defaults&&(s.roomId="",s.type=t.enums===String?"AudioAndVideo":0),e.roomId!=null&&e.hasOwnProperty("roomId")&&(s.roomId=e.roomId),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.LayoutType[e.type]===void 0?e.type:$root.com.quick.voice.proto.LayoutType[e.type]:e.type);let l;if(e.userMap&&(l=Object.keys(e.userMap)).length){s.userMap={};for(let c=0;c<l.length;++c)s.userMap[l[c]]=$root.com.quick.voice.proto.UserInfo.toObject(e.userMap[l[c]],t)}return e.globalCustom!=null&&e.hasOwnProperty("globalCustom")&&(s.globalCustom=$root.com.quick.voice.proto.CustomInfo.toObject(e.globalCustom,t),t.oneofs&&(s._globalCustom="globalCustom")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.LayoutData"},n})(),u.UserInfo=(function(){function n(i){if(this.audios=[],this.videos=[],i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}n.prototype.id="",n.prototype.audios=$util.emptyArray,n.prototype.videos=$util.emptyArray,n.prototype.custom=null;let r;return Object.defineProperty(n.prototype,"_custom",{get:$util.oneOfGetter(r=["custom"]),set:$util.oneOfSetter(r)}),n.create=function(e){return new n(e)},n.encode=function(e,t){if(t||(t=$Writer.create()),e.id!=null&&Object.hasOwnProperty.call(e,"id")&&t.uint32(10).string(e.id),e.audios!=null&&e.audios.length)for(let s=0;s<e.audios.length;++s)$root.com.quick.voice.proto.AudioInfo.encode(e.audios[s],t.uint32(18).fork()).ldelim();if(e.videos!=null&&e.videos.length)for(let s=0;s<e.videos.length;++s)$root.com.quick.voice.proto.VideoInfo.encode(e.videos[s],t.uint32(26).fork()).ldelim();return e.custom!=null&&Object.hasOwnProperty.call(e,"custom")&&$root.com.quick.voice.proto.CustomInfo.encode(e.custom,t.uint32(34).fork()).ldelim(),t},n.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},n.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,c=new $root.com.quick.voice.proto.UserInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{c.id=e.string();break}case 2:{c.audios&&c.audios.length||(c.audios=[]),c.audios.push($root.com.quick.voice.proto.AudioInfo.decode(e,e.uint32()));break}case 3:{c.videos&&c.videos.length||(c.videos=[]),c.videos.push($root.com.quick.voice.proto.VideoInfo.decode(e,e.uint32()));break}case 4:{c.custom=$root.com.quick.voice.proto.CustomInfo.decode(e,e.uint32());break}default:e.skipType(d&7);break}}return c},n.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.id!=null&&e.hasOwnProperty("id")&&!$util.isString(e.id))return"id: string expected";if(e.audios!=null&&e.hasOwnProperty("audios")){if(!Array.isArray(e.audios))return"audios: array expected";for(let t=0;t<e.audios.length;++t){let s=$root.com.quick.voice.proto.AudioInfo.verify(e.audios[t]);if(s)return"audios."+s}}if(e.videos!=null&&e.hasOwnProperty("videos")){if(!Array.isArray(e.videos))return"videos: array expected";for(let t=0;t<e.videos.length;++t){let s=$root.com.quick.voice.proto.VideoInfo.verify(e.videos[t]);if(s)return"videos."+s}}if(e.custom!=null&&e.hasOwnProperty("custom")){let t=$root.com.quick.voice.proto.CustomInfo.verify(e.custom);if(t)return"custom."+t}return null},n.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.UserInfo)return e;let t=new $root.com.quick.voice.proto.UserInfo;if(e.id!=null&&(t.id=String(e.id)),e.audios){if(!Array.isArray(e.audios))throw TypeError(".com.quick.voice.proto.UserInfo.audios: array expected");t.audios=[];for(let s=0;s<e.audios.length;++s){if(typeof e.audios[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.audios: object expected");t.audios[s]=$root.com.quick.voice.proto.AudioInfo.fromObject(e.audios[s])}}if(e.videos){if(!Array.isArray(e.videos))throw TypeError(".com.quick.voice.proto.UserInfo.videos: array expected");t.videos=[];for(let s=0;s<e.videos.length;++s){if(typeof e.videos[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.videos: object expected");t.videos[s]=$root.com.quick.voice.proto.VideoInfo.fromObject(e.videos[s])}}if(e.custom!=null){if(typeof e.custom!="object")throw TypeError(".com.quick.voice.proto.UserInfo.custom: object expected");t.custom=$root.com.quick.voice.proto.CustomInfo.fromObject(e.custom)}return t},n.toObject=function(e,t){t||(t={});let s={};if((t.arrays||t.defaults)&&(s.audios=[],s.videos=[]),t.defaults&&(s.id=""),e.id!=null&&e.hasOwnProperty("id")&&(s.id=e.id),e.audios&&e.audios.length){s.audios=[];for(let l=0;l<e.audios.length;++l)s.audios[l]=$root.com.quick.voice.proto.AudioInfo.toObject(e.audios[l],t)}if(e.videos&&e.videos.length){s.videos=[];for(let l=0;l<e.videos.length;++l)s.videos[l]=$root.com.quick.voice.proto.VideoInfo.toObject(e.videos[l],t)}return e.custom!=null&&e.hasOwnProperty("custom")&&(s.custom=$root.com.quick.voice.proto.CustomInfo.toObject(e.custom,t),t.oneofs&&(s._custom="custom")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.UserInfo"},n})(),u.AudioInfo=(function(){function n(i){if(i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}n.prototype.type=0,n.prototype.isEnable=!1,n.prototype.isMute=!1,n.prototype.volume=0,n.prototype.updateTime=null;let r;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),n.create=function(e){return new n(e)},n.encode=function(e,t){return t||(t=$Writer.create()),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),e.isEnable!=null&&Object.hasOwnProperty.call(e,"isEnable")&&t.uint32(16).bool(e.isEnable),e.isMute!=null&&Object.hasOwnProperty.call(e,"isMute")&&t.uint32(24).bool(e.isMute),e.volume!=null&&Object.hasOwnProperty.call(e,"volume")&&t.uint32(33).double(e.volume),e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(40).int64(e.updateTime),t},n.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},n.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,c=new $root.com.quick.voice.proto.AudioInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{c.type=e.int32();break}case 2:{c.isEnable=e.bool();break}case 3:{c.isMute=e.bool();break}case 4:{c.volume=e.double();break}case 5:{c.updateTime=e.int64();break}default:e.skipType(d&7);break}}return c},n.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:break}return e.isEnable!=null&&e.hasOwnProperty("isEnable")&&typeof e.isEnable!="boolean"?"isEnable: boolean expected":e.isMute!=null&&e.hasOwnProperty("isMute")&&typeof e.isMute!="boolean"?"isMute: boolean expected":e.volume!=null&&e.hasOwnProperty("volume")&&typeof e.volume!="number"?"volume: number expected":e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.AudioInfo)return e;let t=new $root.com.quick.voice.proto.AudioInfo;switch(e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"Microphone":case 0:t.type=0;break;case"SystemVoice":case 1:t.type=1;break}return e.isEnable!=null&&(t.isEnable=!!e.isEnable),e.isMute!=null&&(t.isMute=!!e.isMute),e.volume!=null&&(t.volume=Number(e.volume)),e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},n.toObject=function(e,t){t||(t={});let s={};return t.defaults&&(s.type=t.enums===String?"Microphone":0,s.isEnable=!1,s.isMute=!1,s.volume=0),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.AudioType[e.type]===void 0?e.type:$root.com.quick.voice.proto.AudioType[e.type]:e.type),e.isEnable!=null&&e.hasOwnProperty("isEnable")&&(s.isEnable=e.isEnable),e.isMute!=null&&e.hasOwnProperty("isMute")&&(s.isMute=e.isMute),e.volume!=null&&e.hasOwnProperty("volume")&&(s.volume=t.json&&!isFinite(e.volume)?String(e.volume):e.volume),e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.AudioInfo"},n})(),u.VideoInfo=(function(){function n(i){if(i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}n.prototype.type=0,n.prototype.isEnable=!1,n.prototype.isMute=!1,n.prototype.width=0,n.prototype.height=0,n.prototype.x=0,n.prototype.y=0,n.prototype.updateTime=null;let r;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),n.create=function(e){return new n(e)},n.encode=function(e,t){return t||(t=$Writer.create()),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),e.isEnable!=null&&Object.hasOwnProperty.call(e,"isEnable")&&t.uint32(16).bool(e.isEnable),e.isMute!=null&&Object.hasOwnProperty.call(e,"isMute")&&t.uint32(24).bool(e.isMute),e.width!=null&&Object.hasOwnProperty.call(e,"width")&&t.uint32(32).int32(e.width),e.height!=null&&Object.hasOwnProperty.call(e,"height")&&t.uint32(40).int32(e.height),e.x!=null&&Object.hasOwnProperty.call(e,"x")&&t.uint32(48).int32(e.x),e.y!=null&&Object.hasOwnProperty.call(e,"y")&&t.uint32(56).int32(e.y),e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(64).int64(e.updateTime),t},n.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},n.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,c=new $root.com.quick.voice.proto.VideoInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{c.type=e.int32();break}case 2:{c.isEnable=e.bool();break}case 3:{c.isMute=e.bool();break}case 4:{c.width=e.int32();break}case 5:{c.height=e.int32();break}case 6:{c.x=e.int32();break}case 7:{c.y=e.int32();break}case 8:{c.updateTime=e.int64();break}default:e.skipType(d&7);break}}return c},n.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:break}return e.isEnable!=null&&e.hasOwnProperty("isEnable")&&typeof e.isEnable!="boolean"?"isEnable: boolean expected":e.isMute!=null&&e.hasOwnProperty("isMute")&&typeof e.isMute!="boolean"?"isMute: boolean expected":e.width!=null&&e.hasOwnProperty("width")&&!$util.isInteger(e.width)?"width: integer expected":e.height!=null&&e.hasOwnProperty("height")&&!$util.isInteger(e.height)?"height: integer expected":e.x!=null&&e.hasOwnProperty("x")&&!$util.isInteger(e.x)?"x: integer expected":e.y!=null&&e.hasOwnProperty("y")&&!$util.isInteger(e.y)?"y: integer expected":e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.VideoInfo)return e;let t=new $root.com.quick.voice.proto.VideoInfo;switch(e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"Camera":case 0:t.type=0;break;case"Screen":case 1:t.type=1;break}return e.isEnable!=null&&(t.isEnable=!!e.isEnable),e.isMute!=null&&(t.isMute=!!e.isMute),e.width!=null&&(t.width=e.width|0),e.height!=null&&(t.height=e.height|0),e.x!=null&&(t.x=e.x|0),e.y!=null&&(t.y=e.y|0),e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},n.toObject=function(e,t){t||(t={});let s={};return t.defaults&&(s.type=t.enums===String?"Camera":0,s.isEnable=!1,s.isMute=!1,s.width=0,s.height=0,s.x=0,s.y=0),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.VideoType[e.type]===void 0?e.type:$root.com.quick.voice.proto.VideoType[e.type]:e.type),e.isEnable!=null&&e.hasOwnProperty("isEnable")&&(s.isEnable=e.isEnable),e.isMute!=null&&e.hasOwnProperty("isMute")&&(s.isMute=e.isMute),e.width!=null&&e.hasOwnProperty("width")&&(s.width=e.width),e.height!=null&&e.hasOwnProperty("height")&&(s.height=e.height),e.x!=null&&e.hasOwnProperty("x")&&(s.x=e.x),e.y!=null&&e.hasOwnProperty("y")&&(s.y=e.y),e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.VideoInfo"},n})(),u.CustomInfo=(function(){function n(i){if(this.customKeyMap={},i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}n.prototype.roomId="",n.prototype.customKeyMap=$util.emptyObject,n.prototype.updateTime=null;let r;return Object.defineProperty(n.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),n.create=function(e){return new n(e)},n.encode=function(e,t){if(t||(t=$Writer.create()),e.roomId!=null&&Object.hasOwnProperty.call(e,"roomId")&&t.uint32(10).string(e.roomId),e.customKeyMap!=null&&Object.hasOwnProperty.call(e,"customKeyMap"))for(let s=Object.keys(e.customKeyMap),l=0;l<s.length;++l)t.uint32(18).fork().uint32(10).string(s[l]).uint32(18).string(e.customKeyMap[s[l]]).ldelim();return e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(24).int64(e.updateTime),t},n.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},n.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,c=new $root.com.quick.voice.proto.CustomInfo,d,f;for(;e.pos<l;){let h=e.uint32();if(h===s)break;switch(h>>>3){case 1:{c.roomId=e.string();break}case 2:{c.customKeyMap===$util.emptyObject&&(c.customKeyMap={});let g=e.uint32()+e.pos;for(d="",f="";e.pos<g;){let m=e.uint32();switch(m>>>3){case 1:d=e.string();break;case 2:f=e.string();break;default:e.skipType(m&7);break}}c.customKeyMap[d]=f;break}case 3:{c.updateTime=e.int64();break}default:e.skipType(h&7);break}}return c},n.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},n.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.roomId!=null&&e.hasOwnProperty("roomId")&&!$util.isString(e.roomId))return"roomId: string expected";if(e.customKeyMap!=null&&e.hasOwnProperty("customKeyMap")){if(!$util.isObject(e.customKeyMap))return"customKeyMap: object expected";let t=Object.keys(e.customKeyMap);for(let s=0;s<t.length;++s)if(!$util.isString(e.customKeyMap[t[s]]))return"customKeyMap: string{k:string} expected"}return e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},n.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.CustomInfo)return e;let t=new $root.com.quick.voice.proto.CustomInfo;if(e.roomId!=null&&(t.roomId=String(e.roomId)),e.customKeyMap){if(typeof e.customKeyMap!="object")throw TypeError(".com.quick.voice.proto.CustomInfo.customKeyMap: object expected");t.customKeyMap={};for(let s=Object.keys(e.customKeyMap),l=0;l<s.length;++l)t.customKeyMap[s[l]]=String(e.customKeyMap[s[l]])}return e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},n.toObject=function(e,t){t||(t={});let s={};(t.objects||t.defaults)&&(s.customKeyMap={}),t.defaults&&(s.roomId=""),e.roomId!=null&&e.hasOwnProperty("roomId")&&(s.roomId=e.roomId);let l;if(e.customKeyMap&&(l=Object.keys(e.customKeyMap)).length){s.customKeyMap={};for(let c=0;c<l.length;++c)s.customKeyMap[l[c]]=e.customKeyMap[l[c]]}return e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},n.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},n.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.CustomInfo"},n})(),u.LayoutType=(function(){const n={},r=Object.create(n);return r[n[0]="AudioAndVideo"]=0,r[n[1]="OnlyAudio"]=1,r[n[2]="OnlyVideo"]=2,r})(),u.AudioType=(function(){const n={},r=Object.create(n);return r[n[0]="Microphone"]=0,r[n[1]="SystemVoice"]=1,r})(),u.VideoType=(function(){const n={},r=Object.create(n);return r[n[0]="Camera"]=0,r[n[1]="Screen"]=1,r})(),u})(),a})(),o})(),p})(),createAudioInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,volume:0}),createVideoInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,sx:0,sy:0,sw:0,sh:0});class RoomUser{userId="";mc_audio;mc_video;ss_audio;ss_video;updateTime=0;constructor(){}getUpdateTimeKey=()=>{const o=[];return this.mc_audio&&o.push(this.mc_audio.updateTime),this.mc_video&&o.push(this.mc_video.updateTime),this.ss_audio&&o.push(this.ss_audio.updateTime),this.ss_video&&o.push(this.ss_video.updateTime),o.join("_")};init=o=>{const{id:a,audios:u=[],videos:n=[]}=o;this.userId=a;const r=this.getUpdateTimeKey();this.mc_audio&&(this.mc_audio.remove=!0),this.mc_video&&(this.mc_video.remove=!0),this.ss_audio&&(this.ss_audio.remove=!0),this.ss_video&&(this.ss_video.remove=!0);for(const e of u){const{type:t=0,isEnable:s=!1,isMute:l=!1,updateTime:c,volume:d=0}=e;switch(t){case 0:{if(this.mc_audio||(this.mc_audio=createAudioInfo()),this.mc_audio.remove=!1,this.mc_audio.updateTime===c)break;this.mc_audio.isEnable=!!s,this.mc_audio.isMute=!!l,this.mc_audio.updateTime=Number(c),this.mc_audio.volume=Number(d)}break;case 1:{if(this.ss_audio||(this.ss_audio=createAudioInfo()),this.ss_audio.remove=!1,this.ss_audio.updateTime===c)break;this.ss_audio.isEnable=!!s,this.ss_audio.isMute=!!l,this.ss_audio.updateTime=Number(c),this.ss_audio.volume=Number(d)}break}}for(const e of n){const{type:t=0,isEnable:s,isMute:l,updateTime:c,width:d,height:f,x:h,y:g}=e;switch(t){case 0:{if(this.mc_video||(this.mc_video=createVideoInfo()),this.mc_video.remove=!1,this.mc_video.updateTime===c)break;this.mc_video.isEnable=!!s,this.mc_video.isMute=!!l,this.mc_video.updateTime=Number(c)||0,this.mc_video.sx=h||0,this.mc_video.sy=g||0,this.mc_video.sw=d||0,this.mc_video.sh=f||0}break;case 1:{if(this.ss_video||(this.ss_video=createVideoInfo()),this.ss_video.remove=!1,this.ss_video.updateTime===c)break;this.ss_video.isEnable=!!s,this.ss_video.isMute=!!l,this.ss_video.updateTime=Number(c)||0,this.ss_video.sx=h||0,this.ss_video.sy=g||0,this.ss_video.sw=d||0,this.ss_video.sh=f||0}break}}this.mc_audio?.remove&&(this.mc_audio=void 0),this.mc_video?.remove&&(this.mc_video=void 0),this.ss_audio?.remove&&(this.ss_audio=void 0),this.ss_video?.remove&&(this.ss_video=void 0);const i=this.getUpdateTimeKey();r!==i&&(this.updateTime=new Date().getTime())};destroy=()=>{this.mc_audio=void 0,this.mc_video=void 0,this.ss_audio=void 0,this.ss_video=void 0}}const parseSEI=p=>{let o=0,a=0;for(;;){const n=p[o];if(a=a+n,o=o+1,n!==255)break}let u=0;for(;;){const n=p[o];if(u=u+n,o=o+1,n!==255)break}if(a===5){const n=p.slice(o,o+16),i=Array.from(n,h=>h.toString(16).padStart(2,"0")).join("");o=o+16;const e=u-16,t=p.slice(o,o+e),s=com.quick.voice.proto.SeiData.decode(t),{event:l=0}=s,c=s.data;let d;switch(l){case 0:d=com.quick.voice.proto.LayoutData.decode(s.data);break;case 1:d=com.quick.voice.proto.CustomInfo.decode(s.data);break}return{uuid:i,...s,event:l,data_remote:c,data:d}}};class QuickVoPlayer{option={debug:!1,ws:"wss://livep2p.devplay.cc/websocket"};displayMode="original";prPlayer;dom;room={roomId:"",updateTime:"",author:"",version:""};usersMap=new Map;on={users:o=>{},analysis:o=>{}};constructor(o={}){const{debug:a=!1}=o;this.option.debug=a,this.prPlayer=new Q({debug:a}),this.prPlayer.on.demuxer.chunk=u=>{},this.prPlayer.on.decoder.sei=this.onSEI,this.prPlayer.on.decoder.analysis=this.onAnalysis}start=async o=>(this.stop(),this.prPlayer.start(o));stop=()=>{this.prPlayer.stop(),this.usersMap=new Map,this.room.roomId="",this.room.author="",this.room.updateTime="",this.room.version=""};setMute=o=>{this.prPlayer.setMute(o)};setOutputGain=o=>{this.prPlayer.audioPlayer?.prAudioStream?.setOutputGain(o)};getStream=()=>this.prPlayer.getStream();getAllUseUpdateKey=()=>{const o=[...this.usersMap.values()];return Array.from(o,u=>u.updateTime).join("_")};checkAndCreateUser=(o,a)=>{!this.usersMap.has(o)&&this.usersMap.set(o,new RoomUser);const u=this.usersMap.get(o);if(u){if(u.init(a),u.mc_video&&u.mc_video.stream===void 0){const{sx:n,sy:r,sw:i,sh:e}=u.mc_video,t=`${u.userId}_mc_video`,s=this.prPlayer.cut.create(t,{sx:n,sy:r,sw:i,sh:e});this.displayMode==="original"&&this.prPlayer.cut.setPause(t,!0),u.mc_video.stream=s}if(u.ss_video&&u.ss_video.stream===void 0){const{sx:n,sy:r,sw:i,sh:e}=u.ss_video,t=`${u.userId}_ss_video`,s=this.prPlayer.cut.create(t,{sx:n,sy:r,sw:i,sh:e});this.displayMode==="original"&&this.prPlayer.cut.setPause(t,!0),u.ss_video.stream=s}if(u?.mc_video){const n=`${u.userId}_mc_video`,{sx:r,sy:i,sw:e,sh:t}=u.mc_video;this.prPlayer.cut.setCut(n,{sx:r,sy:i,sw:e,sh:t})}if(u?.ss_video){const n=`${u.userId}_ss_video`,{sx:r,sy:i,sw:e,sh:t}=u.ss_video;this.prPlayer.cut.setCut(n,{sx:r,sy:i,sw:e,sh:t})}}};setDisplayMode=o=>{switch(this.displayMode=o,o){case"original":{this.prPlayer.setPause(!1);const a=[...this.usersMap.keys()];for(const u of a)this.prPlayer.cut.setPause(`${u}_mc_video`,!0),this.prPlayer.cut.setPause(`${u}_ss_video`,!0)}break;case"cut":{this.prPlayer.setPause(!0);const a=[...this.usersMap.keys()];for(const u of a)this.prPlayer.cut.setPause(`${u}_mc_video`,!1),this.prPlayer.cut.setPause(`${u}_ss_video`,!1)}break}};onSEI=o=>{try{const a=parseSEI(o);if(!a)return;const{event:u,data:n}=a;switch(u){case 0:{const{roomId:r,userMap:i}=n;if(r!==this.room.roomId)return;const e=this.getAllUseUpdateKey(),t=Object.keys(i);{const l=[...this.usersMap.keys()];for(const c of l)t.includes(c)||(this.prPlayer.cut.remove(`${c}_mc_video`),this.prPlayer.cut.remove(`${c}_ss_video`),this.usersMap.delete(c))}for(const l of t){const c=i[l];this.checkAndCreateUser(l,c)}const s=this.getAllUseUpdateKey();if(e!==s&&this.on.users){const l=[...this.usersMap.values()],c=Array.from(l,({userId:d,mc_audio:f,mc_video:h,ss_audio:g,ss_video:m,updateTime:y})=>({userId:d,mc_audio:f,mc_video:h,ss_audio:g,ss_video:m,updateTime:y}));this.on.users(c)}}break;case 1:{const{roomId:r,updateTime:i}=n,{author:e,version:t}=n.customKeyMap;this.room.roomId=r,this.room.updateTime=i,this.room.author=e,this.room.version=t}break}}catch(a){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->onSEI: error",a)}};onAnalysis=o=>{this.on.analysis&&this.on.analysis(o)}}exports.QuickVoPlayer=QuickVoPlayer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`quickvo-player`]={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){return typeof e==`object`&&e&&`$typeName`in e&&typeof e.$typeName==`string`?t===void 0?!0:t.typeName===e.$typeName:!1}var n;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(n||={});function r(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}var i=4294967296;function a(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,a=0;function o(t,o){let s=Number(e.slice(t,o));a*=n,r=r*n+s,r>=i&&(a+=r/i|0,r%=i)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?u(r,a):l(r,a)}function o(e,t){let n=l(e,t),r=n.hi&2147483648;r&&(n=u(n.lo,n.hi));let i=s(n.lo,n.hi);return r?`-`+i:i}function s(e,t){if({lo:e,hi:t}=c(e,t),t<=2097151)return String(i*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,a=t>>16&65535,o=n+r*6777216+a*6710656,s=r+a*8147497,l=a*2,u=1e7;return o>=u&&(s+=Math.floor(o/u),o%=u),s>=u&&(l+=Math.floor(s/u),s%=u),l.toString()+ee(s)+ee(o)}function c(e,t){return{lo:e>>>0,hi:t>>>0}}function l(e,t){return{lo:e|0,hi:t|0}}function u(e,t){return t=~t,e?e=~e+1:t+=1,l(e,t)}var ee=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function te(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function ne(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}var d=re();function re(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),ie(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),ae(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),ie(e),a(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),ae(e),a(e)},dec(e,t){return o(e,t)},uDec(e,t){return s(e,t)}}}function ie(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function ae(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}function f(e,t){switch(e){case n.STRING:return``;case n.BOOL:return!1;case n.DOUBLE:case n.FLOAT:return 0;case n.INT64:case n.UINT64:case n.SFIXED64:case n.FIXED64:case n.SINT64:return t?`0`:d.zero;case n.BYTES:return new Uint8Array;default:return 0}}function oe(e,t){switch(e){case n.BOOL:return t===!1;case n.STRING:return t===``;case n.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}var se=2,p=Symbol.for(`reflect unsafe local`);function ce(e,t){let n=e[t.localName].case;return n===void 0?n:t.fields.find(e=>e.localName===n)}function le(e,t){let n=t.localName;if(t.oneof)return e[t.oneof.localName].case===n;if(t.presence!=se)return e[n]!==void 0&&Object.prototype.hasOwnProperty.call(e,n);switch(t.fieldKind){case`list`:return e[n].length>0;case`map`:return Object.keys(e[n]).length>0;case`scalar`:return!oe(t.scalar,e[n]);case`enum`:return e[n]!==t.enum.values[0].number}throw Error(`message field with implicit presence`)}function m(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==void 0}function ue(e,t){if(t.oneof){let n=e[t.oneof.localName];return n.case===t.localName?n.value:void 0}return e[t.localName]}function de(e,t,n){t.oneof?e[t.oneof.localName]={case:t.localName,value:n}:e[t.localName]=n}function fe(e,t){let n=t.localName;if(t.oneof){let r=t.oneof.localName;e[r].case===n&&(e[r]={case:void 0})}else if(t.presence!=se)delete e[n];else switch(t.fieldKind){case`map`:e[n]={};break;case`list`:e[n]=[];break;case`enum`:e[n]=t.enum.values[0].number;break;case`scalar`:e[n]=f(t.scalar,t.longAsString);break}}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(e,t){if(h(e)&&p in e&&`add`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.listKind==r.listKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function pe(e,t){if(h(e)&&p in e&&`has`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.mapKey===r.mapKey&&n.mapKind==r.mapKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function _(e,t){return h(e)&&p in e&&`desc`in e&&h(e.desc)&&e.desc.kind===`message`&&(t===void 0||e.desc.typeName==t.typeName)}function me(e){return ge(e.$typeName)}function he(e){let t=e.fields[0];return ge(e.typeName)&&t!==void 0&&t.fieldKind==`scalar`&&t.name==`value`&&t.number==1}function ge(e){return e.startsWith(`google.protobuf.`)&&[`DoubleValue`,`FloatValue`,`Int64Value`,`UInt64Value`,`Int32Value`,`UInt32Value`,`BoolValue`,`StringValue`,`BytesValue`].includes(e.substring(16))}var _e=999,ve=998,v=2;function ye(e,n){if(t(n,e))return n;let r=De(e);return n!==void 0&&be(e,r,n),r}function be(e,t,n){for(let r of e.members){let e=n[r.localName];if(e==null)continue;let i;if(r.kind==`oneof`){let t=ce(n,r);if(!t)continue;i=t,e=ue(n,t)}else i=r;switch(i.fieldKind){case`message`:e=y(i,e);break;case`scalar`:e=xe(i,e);break;case`list`:e=Ce(i,e);break;case`map`:e=Se(i,e);break}de(t,i,e)}return t}function xe(e,t){return e.scalar==n.BYTES?b(t):t}function Se(e,t){if(h(t)){if(e.scalar==n.BYTES)return we(t,b);if(e.mapKind==`message`)return we(t,t=>y(e,t))}return t}function Ce(e,t){if(Array.isArray(t)){if(e.scalar==n.BYTES)return t.map(b);if(e.listKind==`message`)return t.map(t=>y(e,t))}return t}function y(e,n){if(e.fieldKind==`message`&&!e.oneof&&he(e.message))return xe(e.message.fields[0],n);if(h(n)){if(e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!==`google.protobuf.Value`)return n;if(!t(n,e.message))return ye(e.message,n)}return n}function b(e){return Array.isArray(e)?new Uint8Array(e):e}function we(e,t){let n={};for(let r of Object.entries(e))n[r[0]]=t(r[1]);return n}var Te=Symbol(),Ee=new WeakMap;function De(e){let t;if(Oe(e)){let n=Ee.get(e),r,i;if(n)({prototype:r,members:i}=n);else{r={},i=new Set;for(let t of e.members)t.kind!=`oneof`&&(t.fieldKind!=`scalar`&&t.fieldKind!=`enum`||t.presence!=v&&(i.add(t),r[t.localName]=x(t)));Ee.set(e,{prototype:r,members:i})}t=Object.create(r),t.$typeName=e.typeName;for(let n of e.members)i.has(n)||n.kind==`field`&&(n.fieldKind==`message`||(n.fieldKind==`scalar`||n.fieldKind==`enum`)&&n.presence!=v)||(t[n.localName]=x(n))}else{t={$typeName:e.typeName};for(let n of e.members)(n.kind==`oneof`||n.presence==v)&&(t[n.localName]=x(n))}return t}function Oe(e){switch(e.file.edition){case _e:return!1;case ve:return!0;default:return e.fields.some(e=>e.presence!=v&&e.fieldKind!=`message`&&!e.oneof)}}function x(e){if(e.kind==`oneof`)return{case:void 0};if(e.fieldKind==`list`)return[];if(e.fieldKind==`map`)return{};if(e.fieldKind==`message`)return Te;let t=e.getDefaultValue();return t===void 0?e.fieldKind==`scalar`?f(e.scalar,e.longAsString):e.enum.values[0].number:e.fieldKind==`scalar`&&e.longAsString?t.toString():t}var S=class extends Error{constructor(e,t,n=`FieldValueInvalidError`){super(t),this.name=n,this.field=()=>e}},ke=Symbol.for(`@bufbuild/protobuf/text-encoding`);function Ae(){if(globalThis[ke]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[ke]={encodeUtf8(t){return e.encode(t)},decodeUtf8(e){return t.decode(e)},checkUtf8(e){try{return!0}catch{return!1}}}}return globalThis[ke]}var C;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(C||={});var je=class{constructor(e,t=Ae().decodeUtf8){this.decodeUtf8=t,this.varint64=r,this.uint32=ne,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case C.Varint:for(;this.buf[this.pos++]&128;);break;case C.Bit64:this.pos+=4;case C.Bit32:this.pos+=4;break;case C.LengthDelimited:let n=this.uint32();this.pos+=n;break;case C.StartGroup:for(;;){let[e,n]=this.tag();if(n===C.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(n,e)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return d.dec(...this.varint64())}uint64(){return d.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,d.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return d.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return d.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}};function Me(e,t){let n=e.fieldKind==`list`?g(t,e):e.fieldKind==`map`?pe(t,e):Fe(e,t);if(n===!0)return;let r;switch(e.fieldKind){case`list`:r=`expected ${Re(e)}, got ${T(t)}`;break;case`map`:r=`expected ${ze(e)}, got ${T(t)}`;break;default:r=w(e,t,n)}return new S(e,r)}function Ne(e,t,n){let r=Fe(e,n);if(r!==!0)return new S(e,`list item #${t+1}: ${w(e,n,r)}`)}function Pe(e,t,n){let r=Ie(t,e.mapKey);if(r!==!0)return new S(e,`invalid map key: ${w({scalar:e.mapKey},t,r)}`);let i=Fe(e,n);if(i!==!0)return new S(e,`map entry ${T(t)}: ${w(e,n,i)}`)}function Fe(e,t){return e.scalar===void 0?e.enum===void 0?_(t,e.message):e.enum.open?Number.isInteger(t):e.enum.values.some(e=>e.number===t):Ie(t,e.scalar)}function Ie(e,t){switch(t){case n.DOUBLE:return typeof e==`number`;case n.FLOAT:return typeof e==`number`?Number.isNaN(e)||!Number.isFinite(e)?!0:e>34028234663852886e22||e<-34028234663852886e22?`${e.toFixed()} out of range`:!0:!1;case n.INT32:case n.SFIXED32:case n.SINT32:return typeof e!=`number`||!Number.isInteger(e)?!1:e>2147483647||e<-2147483648?`${e.toFixed()} out of range`:!0;case n.FIXED32:case n.UINT32:return typeof e!=`number`||!Number.isInteger(e)?!1:e>4294967295||e<0?`${e.toFixed()} out of range`:!0;case n.BOOL:return typeof e==`boolean`;case n.STRING:return typeof e==`string`?Ae().checkUtf8(e)||`invalid UTF8`:!1;case n.BYTES:return e instanceof Uint8Array;case n.INT64:case n.SFIXED64:case n.SINT64:if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return d.parse(e),!0}catch{return`${e} out of range`}return!1;case n.FIXED64:case n.UINT64:if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return d.uParse(e),!0}catch{return`${e} out of range`}return!1}}function w(e,t,n){return n=typeof n==`string`?`: ${n}`:`, got ${T(t)}`,e.scalar===void 0?e.enum===void 0?`expected ${Le(e.message)}`+n:`expected ${e.enum.toString()}`+n:`expected ${Be(e.scalar)}`+n}function T(e){switch(typeof e){case`object`:return e===null?`null`:e instanceof Uint8Array?`Uint8Array(${e.length})`:Array.isArray(e)?`Array(${e.length})`:g(e)?Re(e.field()):pe(e)?ze(e.field()):_(e)?Le(e.desc):t(e)?`message ${e.$typeName}`:`object`;case`string`:return e.length>30?`string`:`"${e.split(`"`).join(`\\"`)}"`;case`boolean`:return String(e);case`number`:return String(e);case`bigint`:return String(e)+`n`;default:return typeof e}}function Le(e){return`ReflectMessage (${e.typeName})`}function Re(e){switch(e.listKind){case`message`:return`ReflectList (${e.message.toString()})`;case`enum`:return`ReflectList (${e.enum.toString()})`;case`scalar`:return`ReflectList (${n[e.scalar]})`}}function ze(e){switch(e.mapKind){case`message`:return`ReflectMap (${n[e.mapKey]}, ${e.message.toString()})`;case`enum`:return`ReflectMap (${n[e.mapKey]}, ${e.enum.toString()})`;case`scalar`:return`ReflectMap (${n[e.mapKey]}, ${n[e.scalar]})`}}function Be(e){switch(e){case n.STRING:return`string`;case n.BOOL:return`boolean`;case n.INT64:case n.SINT64:case n.SFIXED64:return`bigint (int64)`;case n.UINT64:case n.FIXED64:return`bigint (uint64)`;case n.BYTES:return`Uint8Array`;case n.DOUBLE:return`number (float64)`;case n.FLOAT:return`number (float32)`;case n.FIXED32:case n.UINT32:return`number (uint32)`;case n.INT32:case n.SFIXED32:case n.SINT32:return`number (int32)`}}function E(e,t,n=!0){return new He(e,t,n)}var Ve=new WeakMap,He=class{get sortedFields(){let e=Ve.get(this.desc);if(e)return e;let t=this.desc.fields.concat().sort((e,t)=>e.number-t.number);return Ve.set(this.desc,t),t}constructor(e,t,n=!0){this.lists=new Map,this.maps=new Map,this.check=n,this.desc=e,this.message=this[p]=t??ye(e),this.fields=e.fields,this.oneofs=e.oneofs,this.members=e.members}findNumber(e){return this._fieldsByNumber||=new Map(this.desc.fields.map(e=>[e.number,e])),this._fieldsByNumber.get(e)}oneofCase(e){return D(this.message,e),ce(this.message,e)}isSet(e){return D(this.message,e),le(this.message,e)}clear(e){D(this.message,e),fe(this.message,e)}get(e){D(this.message,e);let t=ue(this.message,e);switch(e.fieldKind){case`list`:let n=this.lists.get(e);return(!n||n[p]!==t)&&this.lists.set(e,n=new Ue(e,t,this.check)),n;case`map`:let r=this.maps.get(e);return(!r||r[p]!==t)&&this.maps.set(e,r=new We(e,t,this.check)),r;case`message`:return k(e,t,this.check);case`scalar`:return t===void 0?f(e.scalar,!1):N(e,t);case`enum`:return t??e.enum.values[0].number}}set(e,t){if(D(this.message,e),this.check){let n=Me(e,t);if(n)throw n}let n;n=e.fieldKind==`message`?O(e,t):pe(t)||g(t)?t[p]:P(e,t),de(this.message,e,n)}getUnknown(){return this.message.$unknown}setUnknown(e){this.message.$unknown=e}};function D(e,t){if(t.parent.typeName!==e.$typeName)throw new S(t,`cannot use ${t.toString()} with message ${e.$typeName}`,`ForeignFieldError`)}var Ue=class{field(){return this._field}get size(){return this._arr.length}constructor(e,t,n){this._field=e,this._arr=this[p]=t,this.check=n}get(e){let t=this._arr[e];return t===void 0?void 0:A(this._field,t,this.check)}set(e,t){if(e<0||e>=this._arr.length)throw new S(this._field,`list item #${e+1}: out of range`);if(this.check){let n=Ne(this._field,e,t);if(n)throw n}this._arr[e]=Ge(this._field,t)}add(e){if(this.check){let t=Ne(this._field,this._arr.length,e);if(t)throw t}this._arr.push(Ge(this._field,e))}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let e of this._arr)yield A(this._field,e,this.check)}*entries(){for(let e=0;e<this._arr.length;e++)yield[e,A(this._field,this._arr[e],this.check)]}},We=class{constructor(e,t,n=!0){this.obj=this[p]=t??{},this.check=n,this._field=e}field(){return this._field}set(e,t){if(this.check){let n=Pe(this._field,e,t);if(n)throw n}return this.obj[M(e)]=Ke(this._field,t),this}delete(e){let t=M(e),n=Object.prototype.hasOwnProperty.call(this.obj,t);return n&&delete this.obj[t],n}clear(){for(let e of Object.keys(this.obj))delete this.obj[e]}get(e){let t=this.obj[M(e)];return t!==void 0&&(t=j(this._field,t,this.check)),t}has(e){return Object.prototype.hasOwnProperty.call(this.obj,M(e))}*keys(){for(let e of Object.keys(this.obj))yield qe(e,this._field.mapKey)}*entries(){for(let e of Object.entries(this.obj))yield[qe(e[0],this._field.mapKey),j(this._field,e[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let e of Object.values(this.obj))yield j(this._field,e,this.check)}forEach(e,t){for(let n of this.entries())e.call(t,n[1],n[0],this)}};function O(e,t){return _(t)?me(t.message)&&!e.oneof&&e.fieldKind==`message`?t.message.value:t.desc.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`?Ye(t.message):t.message:t}function k(e,t,n){return t!==void 0&&(he(e.message)&&!e.oneof&&e.fieldKind==`message`?t={$typeName:e.message.typeName,value:N(e.message.fields[0],t)}:e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`&&h(t)&&(t=Je(t))),new He(e.message,t,n)}function Ge(e,t){return e.listKind==`message`?O(e,t):P(e,t)}function A(e,t,n){return e.listKind==`message`?k(e,t,n):N(e,t)}function Ke(e,t){return e.mapKind==`message`?O(e,t):P(e,t)}function j(e,t,n){return e.mapKind==`message`?k(e,t,n):t}function M(e){return typeof e==`string`||typeof e==`number`?e:String(e)}function qe(e,t){switch(t){case n.STRING:return e;case n.INT32:case n.FIXED32:case n.UINT32:case n.SFIXED32:case n.SINT32:{let t=Number.parseInt(e);if(Number.isFinite(t))return t;break}case n.BOOL:switch(e){case`true`:return!0;case`false`:return!1}break;case n.UINT64:case n.FIXED64:try{return d.uParse(e)}catch{}break;default:try{return d.parse(e)}catch{}break}return e}function N(e,t){switch(e.scalar){case n.INT64:case n.SFIXED64:case n.SINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=d.parse(t));break;case n.FIXED64:case n.UINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=d.uParse(t));break}return t}function P(e,t){switch(e.scalar){case n.INT64:case n.SFIXED64:case n.SINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=d.parse(t));break;case n.FIXED64:case n.UINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=d.uParse(t));break}return t}function Je(e){let t={$typeName:`google.protobuf.Struct`,fields:{}};if(h(e))for(let[n,r]of Object.entries(e))t.fields[n]=Ze(r);return t}function Ye(e){let t={};for(let[n,r]of Object.entries(e.fields))t[n]=Xe(r);return t}function Xe(e){switch(e.kind.case){case`structValue`:return Ye(e.kind.value);case`listValue`:return e.kind.value.values.map(Xe);case`nullValue`:case void 0:return null;default:return e.kind.value}}function Ze(e){let t={$typeName:`google.protobuf.Value`,kind:{case:void 0}};switch(typeof e){case`number`:t.kind={case:`numberValue`,value:e};break;case`string`:t.kind={case:`stringValue`,value:e};break;case`boolean`:t.kind={case:`boolValue`,value:e};break;case`object`:if(e===null)t.kind={case:`nullValue`,value:0};else if(Array.isArray(e)){let n={$typeName:`google.protobuf.ListValue`,values:[]};if(Array.isArray(e))for(let t of e)n.values.push(Ze(t));t.kind={case:`listValue`,value:n}}else t.kind={case:`structValue`,value:Je(e)};break}return t}function Qe(e){let t=tt(),n=e.length*3/4;e[e.length-2]==`=`?n-=2:e[e.length-1]==`=`&&--n;let r=new Uint8Array(n),i=0,a=0,o,s=0;for(let n=0;n<e.length;n++){if(o=t[e.charCodeAt(n)],o===void 0)switch(e[n]){case`=`:a=0;case`
2
+ `:case`\r`:case` `:case` `:continue;default:throw Error(`invalid base64 string`)}switch(a){case 0:s=o,a=1;break;case 1:r[i++]=s<<2|(o&48)>>4,s=o,a=2;break;case 2:r[i++]=(s&15)<<4|(o&60)>>2,s=o,a=3;break;case 3:r[i++]=(s&3)<<6|o,a=0;break}}if(a==1)throw Error(`invalid base64 string`);return r.subarray(0,i)}var F,$e,I;function et(e){return F||(F=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),$e=F.slice(0,-2).concat(`-`,`_`)),e==`url`?$e:F}function tt(){if(!I){I=[];let e=et(`std`);for(let t=0;t<e.length;t++)I[e[t].charCodeAt(0)]=t;I[45]=e.indexOf(`+`),I[95]=e.indexOf(`/`)}return I}function L(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);switch(i){case`_`:t=!0;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i);break}}return n.join(``)}var nt=new Set([`constructor`,`toString`,`toJSON`,`valueOf`]);function R(e){return nt.has(e)?e+`$`:e}function z(e){for(let t of e.field)m(t,`jsonName`)||(t.jsonName=L(t.name));e.nestedType.forEach(z)}function rt(e,t){let n=e.values.find(e=>e.name===t);if(!n)throw Error(`cannot parse ${e} default value: ${t}`);return n.number}function it(e,t){switch(e){case n.STRING:return t;case n.BYTES:{let r=at(t);if(r===!1)throw Error(`cannot parse ${n[e]} default value: ${t}`);return r}case n.INT64:case n.SFIXED64:case n.SINT64:return d.parse(t);case n.UINT64:case n.FIXED64:return d.uParse(t);case n.DOUBLE:case n.FLOAT:switch(t){case`inf`:return 1/0;case`-inf`:return-1/0;case`nan`:return NaN;default:return parseFloat(t)}case n.BOOL:return t===`true`;case n.INT32:case n.UINT32:case n.SINT32:case n.FIXED32:case n.SFIXED32:return parseInt(t,10)}}function at(e){let t=[],n={tail:e,c:``,next(){return this.tail.length==0?!1:(this.c=this.tail[0],this.tail=this.tail.substring(1),!0)},take(e){if(this.tail.length>=e){let t=this.tail.substring(0,e);return this.tail=this.tail.substring(e),t}return!1}};for(;n.next();)switch(n.c){case`\\`:if(n.next())switch(n.c){case`\\`:t.push(n.c.charCodeAt(0));break;case`b`:t.push(8);break;case`f`:t.push(12);break;case`n`:t.push(10);break;case`r`:t.push(13);break;case`t`:t.push(9);break;case`v`:t.push(11);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let e=n.c,r=n.take(2);if(r===!1)return!1;let i=parseInt(e+r,8);if(Number.isNaN(i))return!1;t.push(i);break}case`x`:{let e=n.c,r=n.take(2);if(r===!1)return!1;let i=parseInt(e+r,16);if(Number.isNaN(i))return!1;t.push(i);break}case`u`:{let e=n.c,r=n.take(4);if(r===!1)return!1;let i=parseInt(e+r,16);if(Number.isNaN(i))return!1;let a=new Uint8Array(4);new DataView(a.buffer).setInt32(0,i,!0),t.push(a[0],a[1],a[2],a[3]);break}case`U`:{let e=n.c,r=n.take(8);if(r===!1)return!1;let i=d.uEnc(e+r),a=new Uint8Array(8),o=new DataView(a.buffer);o.setInt32(0,i.lo,!0),o.setInt32(4,i.hi,!0),t.push(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]);break}}break;default:t.push(n.c.charCodeAt(0))}return new Uint8Array(t)}function*B(e){switch(e.kind){case`file`:for(let t of e.messages)yield t,yield*B(t);yield*e.enums,yield*e.services,yield*e.extensions;break;case`message`:for(let t of e.nestedMessages)yield t,yield*B(t);yield*e.nestedEnums,yield*e.nestedExtensions;break}}function ot(...e){let t=st();if(!e.length)return t;if(`$typeName`in e[0]&&e[0].$typeName==`google.protobuf.FileDescriptorSet`){for(let n of e[0].file)Ct(n,t);return t}if(`$typeName`in e[0]){let n=e[0],r=e[1],i=new Set;function a(e){let n=[];for(let a of e.dependency){if(t.getFile(a)!=null||i.has(a))continue;let o=r(a);if(!o)throw Error(`Unable to resolve ${a}, imported by ${e.name}`);`kind`in o?t.addFile(o,!1,!0):(i.add(o.name),n.push(o))}return n.concat(...n.map(a))}for(let e of[n,...a(n)].reverse())Ct(e,t)}else for(let n of e)for(let e of n.files)t.addFile(e);return t}function st(){let e=new Map,t=new Map,n=new Map;return{kind:`registry`,types:e,extendees:t,[Symbol.iterator](){return e.values()},get files(){return n.values()},addFile(e,t,r){if(n.set(e.proto.name,e),!t)for(let t of B(e))this.add(t);if(r)for(let n of e.dependencies)this.addFile(n,t,r)},add(n){if(n.kind==`extension`){let e=t.get(n.extendee.typeName);e||t.set(n.extendee.typeName,e=new Map),e.set(n.number,n)}e.set(n.typeName,n)},get(t){return e.get(t)},getFile(e){return n.get(e)},getMessage(t){let n=e.get(t);return n?.kind==`message`?n:void 0},getEnum(t){let n=e.get(t);return n?.kind==`enum`?n:void 0},getExtension(t){let n=e.get(t);return n?.kind==`extension`?n:void 0},getExtensionFor(e,n){return t.get(e.typeName)?.get(n)},getService(t){let n=e.get(t);return n?.kind==`service`?n:void 0}}}var ct=998,lt=999,ut=9,V=10,H=11,dt=12,ft=14,U=3,pt=2,mt=1,ht=0,gt=1,_t=2,vt=3,yt=1,bt=2,xt=1,St={998:{fieldPresence:1,enumType:2,repeatedFieldEncoding:2,utf8Validation:3,messageEncoding:1,jsonFormat:2,enforceNamingStyle:2,defaultSymbolVisibility:1},999:{fieldPresence:2,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1},1e3:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1},1001:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:1,defaultSymbolVisibility:2}};function Ct(e,t){let n={kind:`file`,proto:e,deprecated:e.options?.deprecated??!1,edition:kt(e),name:e.name.replace(/\.proto$/,``),dependencies:At(e,t),enums:[],messages:[],extensions:[],services:[],toString(){return`file ${e.name}`}},r=new Map,i={get(e){return r.get(e)},add(e){X(e.proto.options?.mapEntry===!0),r.set(e.typeName,e)}};for(let r of e.enumType)wt(r,n,void 0,t);for(let r of e.messageType)Tt(r,n,void 0,t,i);for(let r of e.service)Et(r,n,t);W(n,t);for(let e of r.values())G(e,t,i);for(let e of n.messages)G(e,t,i),W(e,t);t.addFile(n,!0)}function W(e,t){switch(e.kind){case`file`:for(let n of e.proto.extension){let r=K(n,e,t);e.extensions.push(r),t.add(r)}break;case`message`:for(let n of e.proto.extension){let r=K(n,e,t);e.nestedExtensions.push(r),t.add(r)}for(let n of e.nestedMessages)W(n,t);break}}function G(e,t,n){let r=e.proto.oneofDecl.map(t=>Ot(t,e)),i=new Set;for(let a of e.proto.field){let o=Nt(a,r),s=K(a,e,t,o,n);e.fields.push(s),e.field[s.localName]=s,o===void 0?e.members.push(s):(o.fields.push(s),i.has(o)||(i.add(o),e.members.push(o)))}for(let t of r.filter(e=>i.has(e)))e.oneofs.push(t);for(let r of e.nestedMessages)G(r,t,n)}function wt(e,t,n,r){let i=jt(e.name,e.value),a={kind:`enum`,proto:e,deprecated:e.options?.deprecated??!1,file:t,parent:n,open:!0,name:e.name,typeName:q(e,n,t),value:{},values:[],sharedPrefix:i,toString(){return`enum ${this.typeName}`}};a.open=Lt(a),r.add(a);for(let t of e.value){let e=t.name;a.values.push(a.value[t.number]={kind:`enum_value`,proto:t,deprecated:t.options?.deprecated??!1,parent:a,name:e,localName:R(i==null?e:e.substring(i.length)),number:t.number,toString(){return`enum value ${a.typeName}.${e}`}})}(n?.nestedEnums??t.enums).push(a)}function Tt(e,t,n,r,i){let a={kind:`message`,proto:e,deprecated:e.options?.deprecated??!1,file:t,parent:n,name:e.name,typeName:q(e,n,t),fields:[],field:{},oneofs:[],members:[],nestedEnums:[],nestedMessages:[],nestedExtensions:[],toString(){return`message ${this.typeName}`}};e.options?.mapEntry===!0?i.add(a):((n?.nestedMessages??t.messages).push(a),r.add(a));for(let n of e.enumType)wt(n,t,a,r);for(let n of e.nestedType)Tt(n,t,a,r,i)}function Et(e,t,n){let r={kind:`service`,proto:e,deprecated:e.options?.deprecated??!1,file:t,name:e.name,typeName:q(e,void 0,t),methods:[],method:{},toString(){return`service ${this.typeName}`}};t.services.push(r),n.add(r);for(let t of e.method){let e=Dt(t,r,n);r.methods.push(e),r.method[e.localName]=e}}function Dt(e,t,n){let r;r=e.clientStreaming&&e.serverStreaming?`bidi_streaming`:e.clientStreaming?`client_streaming`:e.serverStreaming?`server_streaming`:`unary`;let i=n.getMessage(J(e.inputType)),a=n.getMessage(J(e.outputType));X(i,`invalid MethodDescriptorProto: input_type ${e.inputType} not found`),X(a,`invalid MethodDescriptorProto: output_type ${e.inputType} not found`);let o=e.name;return{kind:`rpc`,proto:e,deprecated:e.options?.deprecated??!1,parent:t,name:o,localName:R(o.length?R(o[0].toLowerCase()+o.substring(1)):o),methodKind:r,input:i,output:a,idempotency:e.options?.idempotencyLevel??ht,toString(){return`rpc ${t.typeName}.${o}`}}}function Ot(e,t){return{kind:`oneof`,proto:e,deprecated:!1,parent:t,fields:[],name:e.name,localName:R(L(e.name)),toString(){return`oneof ${t.typeName}.${this.name}`}}}function K(e,t,n,r,i){let a=i===void 0,o={kind:`field`,proto:e,deprecated:e.options?.deprecated??!1,name:e.name,number:e.number,scalar:void 0,message:void 0,enum:void 0,presence:Pt(e,r,a,t),listKind:void 0,mapKind:void 0,mapKey:void 0,delimitedEncoding:void 0,packed:void 0,longAsString:!1,getDefaultValue:void 0};if(a){let r=t.kind==`file`?t:t.file,i=t.kind==`file`?void 0:t,a=q(e,i,r);o.kind=`extension`,o.file=r,o.parent=i,o.oneof=void 0,o.typeName=a,o.jsonName=`[${a}]`,o.toString=()=>`extension ${a}`;let s=n.getMessage(J(e.extendee));X(s,`invalid FieldDescriptorProto: extendee ${e.extendee} not found`),o.extendee=s}else{let n=t;X(n.kind==`message`),o.parent=n,o.oneof=r,o.localName=r?L(e.name):R(L(e.name)),o.jsonName=e.jsonName,o.toString=()=>`field ${n.typeName}.${e.name}`}let s=e.label,c=e.type,l=e.options?.jstype;if(s===U){let r=c==H?i?.get(J(e.typeName)):void 0;if(r){o.fieldKind=`map`;let{key:e,value:t}=It(r);return o.mapKey=e.scalar,o.mapKind=t.fieldKind,o.message=t.message,o.delimitedEncoding=!1,o.enum=t.enum,o.scalar=t.scalar,o}switch(o.fieldKind=`list`,c){case H:case V:o.listKind=`message`,o.message=n.getMessage(J(e.typeName)),X(o.message),o.delimitedEncoding=Rt(e,t);break;case ft:o.listKind=`enum`,o.enum=n.getEnum(J(e.typeName)),X(o.enum);break;default:o.listKind=`scalar`,o.scalar=c,o.longAsString=l==mt;break}return o.packed=Ft(e,t),o}switch(c){case H:case V:o.fieldKind=`message`,o.message=n.getMessage(J(e.typeName)),X(o.message,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),o.delimitedEncoding=Rt(e,t),o.getDefaultValue=()=>void 0;break;case ft:{let t=n.getEnum(J(e.typeName));X(t!==void 0,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),o.fieldKind=`enum`,o.enum=n.getEnum(J(e.typeName)),o.getDefaultValue=()=>m(e,`defaultValue`)?rt(t,e.defaultValue):void 0;break}default:o.fieldKind=`scalar`,o.scalar=c,o.longAsString=l==mt,o.getDefaultValue=()=>m(e,`defaultValue`)?it(c,e.defaultValue):void 0;break}return o}function kt(e){switch(e.syntax){case``:case`proto2`:return ct;case`proto3`:return lt;case`editions`:if(e.edition in St)return e.edition;throw Error(`${e.name}: unsupported edition`);default:throw Error(`${e.name}: unsupported syntax "${e.syntax}"`)}}function At(e,t){return e.dependency.map(n=>{let r=t.getFile(n);if(!r)throw Error(`Cannot find ${n}, imported by ${e.name}`);return r})}function jt(e,t){let n=Mt(e)+`_`;for(let e of t){if(!e.name.toLowerCase().startsWith(n))return;let t=e.name.substring(n.length);if(t.length==0||/^\d/.test(t))return}return n}function Mt(e){return(e.substring(0,1)+e.substring(1).replace(/[A-Z]/g,e=>`_`+e)).toLowerCase()}function q(e,t,n){let r;return r=t?`${t.typeName}.${e.name}`:n.proto.package.length>0?`${n.proto.package}.${e.name}`:`${e.name}`,r}function J(e){return e.startsWith(`.`)?e.substring(1):e}function Nt(e,t){if(!m(e,`oneofIndex`)||e.proto3Optional)return;let n=t[e.oneofIndex];return X(n,`invalid FieldDescriptorProto: oneof #${e.oneofIndex} for field #${e.number} not found`),n}function Pt(e,t,n,r){if(e.label==pt)return vt;if(e.label==U)return _t;if(t||e.proto3Optional||n)return gt;let i=Y(`fieldPresence`,{proto:e,parent:r});return i==_t&&(e.type==H||e.type==V)?gt:i}function Ft(e,t){if(e.label!=U)return!1;switch(e.type){case ut:case dt:case V:case H:return!1}let n=e.options;return n&&m(n,`packed`)?n.packed:yt==Y(`repeatedFieldEncoding`,{proto:e,parent:t})}function It(e){let t=e.fields.find(e=>e.number===1),r=e.fields.find(e=>e.number===2);return X(t&&t.fieldKind==`scalar`&&t.scalar!=n.BYTES&&t.scalar!=n.FLOAT&&t.scalar!=n.DOUBLE&&r&&r.fieldKind!=`list`&&r.fieldKind!=`map`),{key:t,value:r}}function Lt(e){return xt==Y(`enumType`,{proto:e.proto,parent:e.parent??e.file})}function Rt(e,t){return e.type==V?!0:bt==Y(`messageEncoding`,{proto:e,parent:t})}function Y(e,t){let n=t.proto.options?.features;if(n){let t=n[e];if(t!=0)return t}if(`kind`in t){if(t.kind==`message`)return Y(e,t.parent??t.file);let n=St[t.edition];if(!n)throw Error(`feature default for edition ${t.edition} not found`);return n[e]}return Y(e,t.parent)}function X(e,t){if(!e)throw Error(t)}function zt(e){let t=Bt(e);return t.messageType.forEach(z),ot(t,()=>void 0).getFile(t.name)}function Bt(e){return Object.assign(Object.create({syntax:``,edition:0}),Object.assign(Object.assign({$typeName:`google.protobuf.FileDescriptorProto`,dependency:[],publicDependency:[],weakDependency:[],optionDependency:[],service:[],extension:[]},e),{messageType:e.messageType.map(Vt),enumType:e.enumType.map(Wt)}))}function Vt(e){return Object.assign(Object.create({visibility:0}),{$typeName:`google.protobuf.DescriptorProto`,name:e.name,field:e.field?.map(Ht)??[],extension:[],nestedType:e.nestedType?.map(Vt)??[],enumType:e.enumType?.map(Wt)??[],extensionRange:e.extensionRange?.map(e=>Object.assign({$typeName:`google.protobuf.DescriptorProto.ExtensionRange`},e))??[],oneofDecl:[],reservedRange:[],reservedName:[]})}function Ht(e){return Object.assign(Object.create({label:1,typeName:``,extendee:``,defaultValue:``,oneofIndex:0,jsonName:``,proto3Optional:!1}),Object.assign(Object.assign({$typeName:`google.protobuf.FieldDescriptorProto`},e),{options:e.options?Ut(e.options):void 0}))}function Ut(e){return Object.assign(Object.create({ctype:0,packed:!1,jstype:0,lazy:!1,unverifiedLazy:!1,deprecated:!1,weak:!1,debugRedact:!1,retention:0}),Object.assign(Object.assign({$typeName:`google.protobuf.FieldOptions`},e),{targets:e.targets??[],editionDefaults:e.editionDefaults?.map(e=>Object.assign({$typeName:`google.protobuf.FieldOptions.EditionDefault`},e))??[],uninterpretedOption:[]}))}function Wt(e){return Object.assign(Object.create({visibility:0}),{$typeName:`google.protobuf.EnumDescriptorProto`,name:e.name,reservedName:[],reservedRange:[],value:e.value.map(e=>Object.assign({$typeName:`google.protobuf.EnumValueDescriptorProto`},e))})}function Z(e,t,...n){return n.reduce((e,t)=>e.nestedMessages[t],e.messages[t])}var Gt=Z(zt({name:`google/protobuf/descriptor.proto`,package:`google.protobuf`,messageType:[{name:`FileDescriptorSet`,field:[{name:`file`,number:1,type:11,label:3,typeName:`.google.protobuf.FileDescriptorProto`}],extensionRange:[{start:536e6,end:536000001}]},{name:`FileDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`package`,number:2,type:9,label:1},{name:`dependency`,number:3,type:9,label:3},{name:`public_dependency`,number:10,type:5,label:3},{name:`weak_dependency`,number:11,type:5,label:3},{name:`option_dependency`,number:15,type:9,label:3},{name:`message_type`,number:4,type:11,label:3,typeName:`.google.protobuf.DescriptorProto`},{name:`enum_type`,number:5,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto`},{name:`service`,number:6,type:11,label:3,typeName:`.google.protobuf.ServiceDescriptorProto`},{name:`extension`,number:7,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`options`,number:8,type:11,label:1,typeName:`.google.protobuf.FileOptions`},{name:`source_code_info`,number:9,type:11,label:1,typeName:`.google.protobuf.SourceCodeInfo`},{name:`syntax`,number:12,type:9,label:1},{name:`edition`,number:14,type:14,label:1,typeName:`.google.protobuf.Edition`}]},{name:`DescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`field`,number:2,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`extension`,number:6,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`nested_type`,number:3,type:11,label:3,typeName:`.google.protobuf.DescriptorProto`},{name:`enum_type`,number:4,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto`},{name:`extension_range`,number:5,type:11,label:3,typeName:`.google.protobuf.DescriptorProto.ExtensionRange`},{name:`oneof_decl`,number:8,type:11,label:3,typeName:`.google.protobuf.OneofDescriptorProto`},{name:`options`,number:7,type:11,label:1,typeName:`.google.protobuf.MessageOptions`},{name:`reserved_range`,number:9,type:11,label:3,typeName:`.google.protobuf.DescriptorProto.ReservedRange`},{name:`reserved_name`,number:10,type:9,label:3},{name:`visibility`,number:11,type:14,label:1,typeName:`.google.protobuf.SymbolVisibility`}],nestedType:[{name:`ExtensionRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.ExtensionRangeOptions`}]},{name:`ReservedRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1}]}]},{name:`ExtensionRangeOptions`,field:[{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`},{name:`declaration`,number:2,type:11,label:3,typeName:`.google.protobuf.ExtensionRangeOptions.Declaration`,options:{retention:2}},{name:`features`,number:50,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`verification`,number:3,type:14,label:1,typeName:`.google.protobuf.ExtensionRangeOptions.VerificationState`,defaultValue:`UNVERIFIED`,options:{retention:2}}],nestedType:[{name:`Declaration`,field:[{name:`number`,number:1,type:5,label:1},{name:`full_name`,number:2,type:9,label:1},{name:`type`,number:3,type:9,label:1},{name:`reserved`,number:5,type:8,label:1},{name:`repeated`,number:6,type:8,label:1}]}],enumType:[{name:`VerificationState`,value:[{name:`DECLARATION`,number:0},{name:`UNVERIFIED`,number:1}]}],extensionRange:[{start:1e3,end:536870912}]},{name:`FieldDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`number`,number:3,type:5,label:1},{name:`label`,number:4,type:14,label:1,typeName:`.google.protobuf.FieldDescriptorProto.Label`},{name:`type`,number:5,type:14,label:1,typeName:`.google.protobuf.FieldDescriptorProto.Type`},{name:`type_name`,number:6,type:9,label:1},{name:`extendee`,number:2,type:9,label:1},{name:`default_value`,number:7,type:9,label:1},{name:`oneof_index`,number:9,type:5,label:1},{name:`json_name`,number:10,type:9,label:1},{name:`options`,number:8,type:11,label:1,typeName:`.google.protobuf.FieldOptions`},{name:`proto3_optional`,number:17,type:8,label:1}],enumType:[{name:`Type`,value:[{name:`TYPE_DOUBLE`,number:1},{name:`TYPE_FLOAT`,number:2},{name:`TYPE_INT64`,number:3},{name:`TYPE_UINT64`,number:4},{name:`TYPE_INT32`,number:5},{name:`TYPE_FIXED64`,number:6},{name:`TYPE_FIXED32`,number:7},{name:`TYPE_BOOL`,number:8},{name:`TYPE_STRING`,number:9},{name:`TYPE_GROUP`,number:10},{name:`TYPE_MESSAGE`,number:11},{name:`TYPE_BYTES`,number:12},{name:`TYPE_UINT32`,number:13},{name:`TYPE_ENUM`,number:14},{name:`TYPE_SFIXED32`,number:15},{name:`TYPE_SFIXED64`,number:16},{name:`TYPE_SINT32`,number:17},{name:`TYPE_SINT64`,number:18}]},{name:`Label`,value:[{name:`LABEL_OPTIONAL`,number:1},{name:`LABEL_REPEATED`,number:3},{name:`LABEL_REQUIRED`,number:2}]}]},{name:`OneofDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`options`,number:2,type:11,label:1,typeName:`.google.protobuf.OneofOptions`}]},{name:`EnumDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`value`,number:2,type:11,label:3,typeName:`.google.protobuf.EnumValueDescriptorProto`},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.EnumOptions`},{name:`reserved_range`,number:4,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto.EnumReservedRange`},{name:`reserved_name`,number:5,type:9,label:3},{name:`visibility`,number:6,type:14,label:1,typeName:`.google.protobuf.SymbolVisibility`}],nestedType:[{name:`EnumReservedRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1}]}]},{name:`EnumValueDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`number`,number:2,type:5,label:1},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.EnumValueOptions`}]},{name:`ServiceDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`method`,number:2,type:11,label:3,typeName:`.google.protobuf.MethodDescriptorProto`},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.ServiceOptions`}]},{name:`MethodDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`input_type`,number:2,type:9,label:1},{name:`output_type`,number:3,type:9,label:1},{name:`options`,number:4,type:11,label:1,typeName:`.google.protobuf.MethodOptions`},{name:`client_streaming`,number:5,type:8,label:1,defaultValue:`false`},{name:`server_streaming`,number:6,type:8,label:1,defaultValue:`false`}]},{name:`FileOptions`,field:[{name:`java_package`,number:1,type:9,label:1},{name:`java_outer_classname`,number:8,type:9,label:1},{name:`java_multiple_files`,number:10,type:8,label:1,defaultValue:`false`},{name:`java_generate_equals_and_hash`,number:20,type:8,label:1,options:{deprecated:!0}},{name:`java_string_check_utf8`,number:27,type:8,label:1,defaultValue:`false`},{name:`optimize_for`,number:9,type:14,label:1,typeName:`.google.protobuf.FileOptions.OptimizeMode`,defaultValue:`SPEED`},{name:`go_package`,number:11,type:9,label:1},{name:`cc_generic_services`,number:16,type:8,label:1,defaultValue:`false`},{name:`java_generic_services`,number:17,type:8,label:1,defaultValue:`false`},{name:`py_generic_services`,number:18,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:23,type:8,label:1,defaultValue:`false`},{name:`cc_enable_arenas`,number:31,type:8,label:1,defaultValue:`true`},{name:`objc_class_prefix`,number:36,type:9,label:1},{name:`csharp_namespace`,number:37,type:9,label:1},{name:`swift_prefix`,number:39,type:9,label:1},{name:`php_class_prefix`,number:40,type:9,label:1},{name:`php_namespace`,number:41,type:9,label:1},{name:`php_metadata_namespace`,number:44,type:9,label:1},{name:`ruby_package`,number:45,type:9,label:1},{name:`features`,number:50,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],enumType:[{name:`OptimizeMode`,value:[{name:`SPEED`,number:1},{name:`CODE_SIZE`,number:2},{name:`LITE_RUNTIME`,number:3}]}],extensionRange:[{start:1e3,end:536870912}]},{name:`MessageOptions`,field:[{name:`message_set_wire_format`,number:1,type:8,label:1,defaultValue:`false`},{name:`no_standard_descriptor_accessor`,number:2,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`map_entry`,number:7,type:8,label:1},{name:`deprecated_legacy_json_field_conflicts`,number:11,type:8,label:1,options:{deprecated:!0}},{name:`features`,number:12,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:1e3,end:536870912}]},{name:`FieldOptions`,field:[{name:`ctype`,number:1,type:14,label:1,typeName:`.google.protobuf.FieldOptions.CType`,defaultValue:`STRING`},{name:`packed`,number:2,type:8,label:1},{name:`jstype`,number:6,type:14,label:1,typeName:`.google.protobuf.FieldOptions.JSType`,defaultValue:`JS_NORMAL`},{name:`lazy`,number:5,type:8,label:1,defaultValue:`false`},{name:`unverified_lazy`,number:15,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`weak`,number:10,type:8,label:1,defaultValue:`false`,options:{deprecated:!0}},{name:`debug_redact`,number:16,type:8,label:1,defaultValue:`false`},{name:`retention`,number:17,type:14,label:1,typeName:`.google.protobuf.FieldOptions.OptionRetention`},{name:`targets`,number:19,type:14,label:3,typeName:`.google.protobuf.FieldOptions.OptionTargetType`},{name:`edition_defaults`,number:20,type:11,label:3,typeName:`.google.protobuf.FieldOptions.EditionDefault`},{name:`features`,number:21,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`feature_support`,number:22,type:11,label:1,typeName:`.google.protobuf.FieldOptions.FeatureSupport`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],nestedType:[{name:`EditionDefault`,field:[{name:`edition`,number:3,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`value`,number:2,type:9,label:1}]},{name:`FeatureSupport`,field:[{name:`edition_introduced`,number:1,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`edition_deprecated`,number:2,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`deprecation_warning`,number:3,type:9,label:1},{name:`edition_removed`,number:4,type:14,label:1,typeName:`.google.protobuf.Edition`}]}],enumType:[{name:`CType`,value:[{name:`STRING`,number:0},{name:`CORD`,number:1},{name:`STRING_PIECE`,number:2}]},{name:`JSType`,value:[{name:`JS_NORMAL`,number:0},{name:`JS_STRING`,number:1},{name:`JS_NUMBER`,number:2}]},{name:`OptionRetention`,value:[{name:`RETENTION_UNKNOWN`,number:0},{name:`RETENTION_RUNTIME`,number:1},{name:`RETENTION_SOURCE`,number:2}]},{name:`OptionTargetType`,value:[{name:`TARGET_TYPE_UNKNOWN`,number:0},{name:`TARGET_TYPE_FILE`,number:1},{name:`TARGET_TYPE_EXTENSION_RANGE`,number:2},{name:`TARGET_TYPE_MESSAGE`,number:3},{name:`TARGET_TYPE_FIELD`,number:4},{name:`TARGET_TYPE_ONEOF`,number:5},{name:`TARGET_TYPE_ENUM`,number:6},{name:`TARGET_TYPE_ENUM_ENTRY`,number:7},{name:`TARGET_TYPE_SERVICE`,number:8},{name:`TARGET_TYPE_METHOD`,number:9}]}],extensionRange:[{start:1e3,end:536870912}]},{name:`OneofOptions`,field:[{name:`features`,number:1,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:1e3,end:536870912}]},{name:`EnumOptions`,field:[{name:`allow_alias`,number:2,type:8,label:1},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`deprecated_legacy_json_field_conflicts`,number:6,type:8,label:1,options:{deprecated:!0}},{name:`features`,number:7,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:1e3,end:536870912}]},{name:`EnumValueOptions`,field:[{name:`deprecated`,number:1,type:8,label:1,defaultValue:`false`},{name:`features`,number:2,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`debug_redact`,number:3,type:8,label:1,defaultValue:`false`},{name:`feature_support`,number:4,type:11,label:1,typeName:`.google.protobuf.FieldOptions.FeatureSupport`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:1e3,end:536870912}]},{name:`ServiceOptions`,field:[{name:`features`,number:34,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`deprecated`,number:33,type:8,label:1,defaultValue:`false`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:1e3,end:536870912}]},{name:`MethodOptions`,field:[{name:`deprecated`,number:33,type:8,label:1,defaultValue:`false`},{name:`idempotency_level`,number:34,type:14,label:1,typeName:`.google.protobuf.MethodOptions.IdempotencyLevel`,defaultValue:`IDEMPOTENCY_UNKNOWN`},{name:`features`,number:35,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],enumType:[{name:`IdempotencyLevel`,value:[{name:`IDEMPOTENCY_UNKNOWN`,number:0},{name:`NO_SIDE_EFFECTS`,number:1},{name:`IDEMPOTENT`,number:2}]}],extensionRange:[{start:1e3,end:536870912}]},{name:`UninterpretedOption`,field:[{name:`name`,number:2,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption.NamePart`},{name:`identifier_value`,number:3,type:9,label:1},{name:`positive_int_value`,number:4,type:4,label:1},{name:`negative_int_value`,number:5,type:3,label:1},{name:`double_value`,number:6,type:1,label:1},{name:`string_value`,number:7,type:12,label:1},{name:`aggregate_value`,number:8,type:9,label:1}],nestedType:[{name:`NamePart`,field:[{name:`name_part`,number:1,type:9,label:2},{name:`is_extension`,number:2,type:8,label:2}]}]},{name:`FeatureSet`,field:[{name:`field_presence`,number:1,type:14,label:1,typeName:`.google.protobuf.FeatureSet.FieldPresence`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`EXPLICIT`,edition:900},{value:`IMPLICIT`,edition:999},{value:`EXPLICIT`,edition:1e3}]}},{name:`enum_type`,number:2,type:14,label:1,typeName:`.google.protobuf.FeatureSet.EnumType`,options:{retention:1,targets:[6,1],editionDefaults:[{value:`CLOSED`,edition:900},{value:`OPEN`,edition:999}]}},{name:`repeated_field_encoding`,number:3,type:14,label:1,typeName:`.google.protobuf.FeatureSet.RepeatedFieldEncoding`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`EXPANDED`,edition:900},{value:`PACKED`,edition:999}]}},{name:`utf8_validation`,number:4,type:14,label:1,typeName:`.google.protobuf.FeatureSet.Utf8Validation`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`NONE`,edition:900},{value:`VERIFY`,edition:999}]}},{name:`message_encoding`,number:5,type:14,label:1,typeName:`.google.protobuf.FeatureSet.MessageEncoding`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`LENGTH_PREFIXED`,edition:900}]}},{name:`json_format`,number:6,type:14,label:1,typeName:`.google.protobuf.FeatureSet.JsonFormat`,options:{retention:1,targets:[3,6,1],editionDefaults:[{value:`LEGACY_BEST_EFFORT`,edition:900},{value:`ALLOW`,edition:999}]}},{name:`enforce_naming_style`,number:7,type:14,label:1,typeName:`.google.protobuf.FeatureSet.EnforceNamingStyle`,options:{retention:2,targets:[1,2,3,4,5,6,7,8,9],editionDefaults:[{value:`STYLE_LEGACY`,edition:900},{value:`STYLE2024`,edition:1001}]}},{name:`default_symbol_visibility`,number:8,type:14,label:1,typeName:`.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility`,options:{retention:2,targets:[1],editionDefaults:[{value:`EXPORT_ALL`,edition:900},{value:`EXPORT_TOP_LEVEL`,edition:1001}]}}],nestedType:[{name:`VisibilityFeature`,enumType:[{name:`DefaultSymbolVisibility`,value:[{name:`DEFAULT_SYMBOL_VISIBILITY_UNKNOWN`,number:0},{name:`EXPORT_ALL`,number:1},{name:`EXPORT_TOP_LEVEL`,number:2},{name:`LOCAL_ALL`,number:3},{name:`STRICT`,number:4}]}]}],enumType:[{name:`FieldPresence`,value:[{name:`FIELD_PRESENCE_UNKNOWN`,number:0},{name:`EXPLICIT`,number:1},{name:`IMPLICIT`,number:2},{name:`LEGACY_REQUIRED`,number:3}]},{name:`EnumType`,value:[{name:`ENUM_TYPE_UNKNOWN`,number:0},{name:`OPEN`,number:1},{name:`CLOSED`,number:2}]},{name:`RepeatedFieldEncoding`,value:[{name:`REPEATED_FIELD_ENCODING_UNKNOWN`,number:0},{name:`PACKED`,number:1},{name:`EXPANDED`,number:2}]},{name:`Utf8Validation`,value:[{name:`UTF8_VALIDATION_UNKNOWN`,number:0},{name:`VERIFY`,number:2},{name:`NONE`,number:3}]},{name:`MessageEncoding`,value:[{name:`MESSAGE_ENCODING_UNKNOWN`,number:0},{name:`LENGTH_PREFIXED`,number:1},{name:`DELIMITED`,number:2}]},{name:`JsonFormat`,value:[{name:`JSON_FORMAT_UNKNOWN`,number:0},{name:`ALLOW`,number:1},{name:`LEGACY_BEST_EFFORT`,number:2}]},{name:`EnforceNamingStyle`,value:[{name:`ENFORCE_NAMING_STYLE_UNKNOWN`,number:0},{name:`STYLE2024`,number:1},{name:`STYLE_LEGACY`,number:2}]}],extensionRange:[{start:1e3,end:9995},{start:9995,end:1e4},{start:1e4,end:10001}]},{name:`FeatureSetDefaults`,field:[{name:`defaults`,number:1,type:11,label:3,typeName:`.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault`},{name:`minimum_edition`,number:4,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`maximum_edition`,number:5,type:14,label:1,typeName:`.google.protobuf.Edition`}],nestedType:[{name:`FeatureSetEditionDefault`,field:[{name:`edition`,number:3,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`overridable_features`,number:4,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`fixed_features`,number:5,type:11,label:1,typeName:`.google.protobuf.FeatureSet`}]}]},{name:`SourceCodeInfo`,field:[{name:`location`,number:1,type:11,label:3,typeName:`.google.protobuf.SourceCodeInfo.Location`}],nestedType:[{name:`Location`,field:[{name:`path`,number:1,type:5,label:3,options:{packed:!0}},{name:`span`,number:2,type:5,label:3,options:{packed:!0}},{name:`leading_comments`,number:3,type:9,label:1},{name:`trailing_comments`,number:4,type:9,label:1},{name:`leading_detached_comments`,number:6,type:9,label:3}]}],extensionRange:[{start:536e6,end:536000001}]},{name:`GeneratedCodeInfo`,field:[{name:`annotation`,number:1,type:11,label:3,typeName:`.google.protobuf.GeneratedCodeInfo.Annotation`}],nestedType:[{name:`Annotation`,field:[{name:`path`,number:1,type:5,label:3,options:{packed:!0}},{name:`source_file`,number:2,type:9,label:1},{name:`begin`,number:3,type:5,label:1},{name:`end`,number:4,type:5,label:1},{name:`semantic`,number:5,type:14,label:1,typeName:`.google.protobuf.GeneratedCodeInfo.Annotation.Semantic`}],enumType:[{name:`Semantic`,value:[{name:`NONE`,number:0},{name:`SET`,number:1},{name:`ALIAS`,number:2}]}]}]}],enumType:[{name:`Edition`,value:[{name:`EDITION_UNKNOWN`,number:0},{name:`EDITION_LEGACY`,number:900},{name:`EDITION_PROTO2`,number:998},{name:`EDITION_PROTO3`,number:999},{name:`EDITION_2023`,number:1e3},{name:`EDITION_2024`,number:1001},{name:`EDITION_UNSTABLE`,number:9999},{name:`EDITION_1_TEST_ONLY`,number:1},{name:`EDITION_2_TEST_ONLY`,number:2},{name:`EDITION_99997_TEST_ONLY`,number:99997},{name:`EDITION_99998_TEST_ONLY`,number:99998},{name:`EDITION_99999_TEST_ONLY`,number:99999},{name:`EDITION_MAX`,number:2147483647}]},{name:`SymbolVisibility`,value:[{name:`VISIBILITY_UNSET`,number:0},{name:`VISIBILITY_LOCAL`,number:1},{name:`VISIBILITY_EXPORT`,number:2}]}]}),1),Kt;(function(e){e[e.DECLARATION=0]=`DECLARATION`,e[e.UNVERIFIED=1]=`UNVERIFIED`})(Kt||={});var qt;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.GROUP=10]=`GROUP`,e[e.MESSAGE=11]=`MESSAGE`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.ENUM=14]=`ENUM`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(qt||={});var Jt;(function(e){e[e.OPTIONAL=1]=`OPTIONAL`,e[e.REPEATED=3]=`REPEATED`,e[e.REQUIRED=2]=`REQUIRED`})(Jt||={});var Yt;(function(e){e[e.SPEED=1]=`SPEED`,e[e.CODE_SIZE=2]=`CODE_SIZE`,e[e.LITE_RUNTIME=3]=`LITE_RUNTIME`})(Yt||={});var Xt;(function(e){e[e.STRING=0]=`STRING`,e[e.CORD=1]=`CORD`,e[e.STRING_PIECE=2]=`STRING_PIECE`})(Xt||={});var Zt;(function(e){e[e.JS_NORMAL=0]=`JS_NORMAL`,e[e.JS_STRING=1]=`JS_STRING`,e[e.JS_NUMBER=2]=`JS_NUMBER`})(Zt||={});var Qt;(function(e){e[e.RETENTION_UNKNOWN=0]=`RETENTION_UNKNOWN`,e[e.RETENTION_RUNTIME=1]=`RETENTION_RUNTIME`,e[e.RETENTION_SOURCE=2]=`RETENTION_SOURCE`})(Qt||={});var $t;(function(e){e[e.TARGET_TYPE_UNKNOWN=0]=`TARGET_TYPE_UNKNOWN`,e[e.TARGET_TYPE_FILE=1]=`TARGET_TYPE_FILE`,e[e.TARGET_TYPE_EXTENSION_RANGE=2]=`TARGET_TYPE_EXTENSION_RANGE`,e[e.TARGET_TYPE_MESSAGE=3]=`TARGET_TYPE_MESSAGE`,e[e.TARGET_TYPE_FIELD=4]=`TARGET_TYPE_FIELD`,e[e.TARGET_TYPE_ONEOF=5]=`TARGET_TYPE_ONEOF`,e[e.TARGET_TYPE_ENUM=6]=`TARGET_TYPE_ENUM`,e[e.TARGET_TYPE_ENUM_ENTRY=7]=`TARGET_TYPE_ENUM_ENTRY`,e[e.TARGET_TYPE_SERVICE=8]=`TARGET_TYPE_SERVICE`,e[e.TARGET_TYPE_METHOD=9]=`TARGET_TYPE_METHOD`})($t||={});var en;(function(e){e[e.IDEMPOTENCY_UNKNOWN=0]=`IDEMPOTENCY_UNKNOWN`,e[e.NO_SIDE_EFFECTS=1]=`NO_SIDE_EFFECTS`,e[e.IDEMPOTENT=2]=`IDEMPOTENT`})(en||={});var tn;(function(e){e[e.DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0]=`DEFAULT_SYMBOL_VISIBILITY_UNKNOWN`,e[e.EXPORT_ALL=1]=`EXPORT_ALL`,e[e.EXPORT_TOP_LEVEL=2]=`EXPORT_TOP_LEVEL`,e[e.LOCAL_ALL=3]=`LOCAL_ALL`,e[e.STRICT=4]=`STRICT`})(tn||={});var nn;(function(e){e[e.FIELD_PRESENCE_UNKNOWN=0]=`FIELD_PRESENCE_UNKNOWN`,e[e.EXPLICIT=1]=`EXPLICIT`,e[e.IMPLICIT=2]=`IMPLICIT`,e[e.LEGACY_REQUIRED=3]=`LEGACY_REQUIRED`})(nn||={});var rn;(function(e){e[e.ENUM_TYPE_UNKNOWN=0]=`ENUM_TYPE_UNKNOWN`,e[e.OPEN=1]=`OPEN`,e[e.CLOSED=2]=`CLOSED`})(rn||={});var an;(function(e){e[e.REPEATED_FIELD_ENCODING_UNKNOWN=0]=`REPEATED_FIELD_ENCODING_UNKNOWN`,e[e.PACKED=1]=`PACKED`,e[e.EXPANDED=2]=`EXPANDED`})(an||={});var on;(function(e){e[e.UTF8_VALIDATION_UNKNOWN=0]=`UTF8_VALIDATION_UNKNOWN`,e[e.VERIFY=2]=`VERIFY`,e[e.NONE=3]=`NONE`})(on||={});var sn;(function(e){e[e.MESSAGE_ENCODING_UNKNOWN=0]=`MESSAGE_ENCODING_UNKNOWN`,e[e.LENGTH_PREFIXED=1]=`LENGTH_PREFIXED`,e[e.DELIMITED=2]=`DELIMITED`})(sn||={});var cn;(function(e){e[e.JSON_FORMAT_UNKNOWN=0]=`JSON_FORMAT_UNKNOWN`,e[e.ALLOW=1]=`ALLOW`,e[e.LEGACY_BEST_EFFORT=2]=`LEGACY_BEST_EFFORT`})(cn||={});var ln;(function(e){e[e.ENFORCE_NAMING_STYLE_UNKNOWN=0]=`ENFORCE_NAMING_STYLE_UNKNOWN`,e[e.STYLE2024=1]=`STYLE2024`,e[e.STYLE_LEGACY=2]=`STYLE_LEGACY`})(ln||={});var un;(function(e){e[e.NONE=0]=`NONE`,e[e.SET=1]=`SET`,e[e.ALIAS=2]=`ALIAS`})(un||={});var dn;(function(e){e[e.EDITION_UNKNOWN=0]=`EDITION_UNKNOWN`,e[e.EDITION_LEGACY=900]=`EDITION_LEGACY`,e[e.EDITION_PROTO2=998]=`EDITION_PROTO2`,e[e.EDITION_PROTO3=999]=`EDITION_PROTO3`,e[e.EDITION_2023=1e3]=`EDITION_2023`,e[e.EDITION_2024=1001]=`EDITION_2024`,e[e.EDITION_UNSTABLE=9999]=`EDITION_UNSTABLE`,e[e.EDITION_1_TEST_ONLY=1]=`EDITION_1_TEST_ONLY`,e[e.EDITION_2_TEST_ONLY=2]=`EDITION_2_TEST_ONLY`,e[e.EDITION_99997_TEST_ONLY=99997]=`EDITION_99997_TEST_ONLY`,e[e.EDITION_99998_TEST_ONLY=99998]=`EDITION_99998_TEST_ONLY`,e[e.EDITION_99999_TEST_ONLY=99999]=`EDITION_99999_TEST_ONLY`,e[e.EDITION_MAX=2147483647]=`EDITION_MAX`})(dn||={});var fn;(function(e){e[e.VISIBILITY_UNSET=0]=`VISIBILITY_UNSET`,e[e.VISIBILITY_LOCAL=1]=`VISIBILITY_LOCAL`,e[e.VISIBILITY_EXPORT=2]=`VISIBILITY_EXPORT`})(fn||={});var pn={readUnknownFields:!0};function mn(e){return e?Object.assign(Object.assign({},pn),e):pn}function Q(e,t,n){let r=E(e,void 0,!1);return hn(r,new je(t),mn(n),!1,t.byteLength),r.message}function hn(e,t,n,r,i){let a=r?t.len:t.pos+i,o,s,c=e.getUnknown()??[];for(;t.pos<a&&([o,s]=t.tag(),!(r&&s==C.EndGroup));){let r=e.findNumber(o);if(!r){let e=t.skip(s,o);n.readUnknownFields&&c.push({no:o,wireType:s,data:e});continue}gn(e,t,r,s,n)}if(r&&(s!=C.EndGroup||o!==i))throw Error(`invalid end group tag`);c.length>0&&e.setUnknown(c)}function gn(e,t,r,i,a){switch(r.fieldKind){case`scalar`:e.set(r,$(t,r.scalar));break;case`enum`:let o=$(t,n.INT32);if(r.enum.open)e.set(r,o);else if(r.enum.values.some(e=>e.number===o))e.set(r,o);else if(a.readUnknownFields){let t=[];te(o,t);let n=e.getUnknown()??[];n.push({no:r.number,wireType:i,data:new Uint8Array(t)}),e.setUnknown(n)}break;case`message`:e.set(r,yn(t,a,r,e.get(r)));break;case`list`:vn(t,i,e.get(r),a);break;case`map`:_n(t,e.get(r),a);break}}function _n(e,t,n){let r=t.field(),i,a,o=e.uint32(),s=e.pos+o;for(;e.pos<s;){let[t]=e.tag();switch(t){case 1:i=$(e,r.mapKey);break;case 2:switch(r.mapKind){case`scalar`:a=$(e,r.scalar);break;case`enum`:a=e.int32();break;case`message`:a=yn(e,n,r);break}break}}if(i===void 0&&(i=f(r.mapKey,!1)),a===void 0)switch(r.mapKind){case`scalar`:a=f(r.scalar,!1);break;case`enum`:a=r.enum.values[0].number;break;case`message`:a=E(r.message,void 0,!1);break}t.set(i,a)}function vn(e,t,r,i){let a=r.field();if(a.listKind===`message`){r.add(yn(e,i,a));return}let o=a.scalar??n.INT32;if(!(t==C.LengthDelimited&&o!=n.STRING&&o!=n.BYTES)){r.add($(e,o));return}let s=e.uint32()+e.pos;for(;e.pos<s;)r.add($(e,o))}function yn(e,t,n,r){let i=n.delimitedEncoding,a=r??E(n.message,void 0,!1);return hn(a,e,t,i,i?n.number:e.uint32()),a}function $(e,t){switch(t){case n.STRING:return e.string();case n.BOOL:return e.bool();case n.DOUBLE:return e.double();case n.FLOAT:return e.float();case n.INT32:return e.int32();case n.INT64:return e.int64();case n.UINT64:return e.uint64();case n.FIXED64:return e.fixed64();case n.BYTES:return e.bytes();case n.FIXED32:return e.fixed32();case n.SFIXED32:return e.sfixed32();case n.SFIXED64:return e.sfixed64();case n.SINT64:return e.sint64();case n.UINT32:return e.uint32();case n.SINT32:return e.sint32()}}function bn(e,t){let n=Q(Gt,Qe(e));return n.messageType.forEach(z),n.dependency=t?.map(e=>e.proto.name)??[],ot(n,e=>t?.find(t=>t.proto.name===e)).getFile(n.name)}var xn='(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>100&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;parser;on={};constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n',Sn=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,xn],{type:`text/javascript;charset=utf-8`});function Cn(e){let t;try{if(t=Sn&&(self.URL||self.webkitURL).createObjectURL(Sn),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(xn),{name:e?.name})}}var wn=class{worker=new Cn;on={};constructor(){this.worker.onmessage=e=>{let{action:t,data:n}=e.data;switch(t){case`on.info`:this.on.info&&this.on.info(n);break;case`on.config`:this.on.config&&this.on.config(n);break;case`on.chunk`:this.on.chunk&&this.on.chunk(n);break;case`on.debug`:this.on.debug&&this.on.debug(n);break}}}init=e=>this.worker.postMessage({action:`init`,data:e});push=e=>this.worker.postMessage({action:`push`,data:e});destroy=()=>{this.worker.postMessage({action:`destroy`,data:{}}),this.worker.terminate()}},Tn=`(function(){"use strict";class a{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const o=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:o})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);try{const o=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);if(i.close(),!s.width||!s.height)return s.close();this.on.video.decode&&this.on.video.decode({timestamp:o,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)}catch{i.close()}},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const o=this.lastRenderTime-this.nextRenderTime;e-=o}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;this.currentChunk=this.pendingChunks.shift(),!!this.currentChunk;){const e=this.pendingChunks.length;if(this.frameTrack){const[s,n]=this.fameTrackOption[this.pattern];if(e<=s&&(this.isFrameTrack=!1),e>=n&&(this.isFrameTrack=!0),this.isFrameTrack){const r=Math.min(1+(e-s)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(r.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.analysis){const{decodingSpeed:s,decodingSpeedRatio:n,fps:r}=this;this.on.analysis({decodingSpeed:s,decodingSpeedRatio:n,fps:r,cacheLength:e})}const{kind:i,init:o}=this.currentChunk;switch(i){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new a;d.on.audio.decode=t=>postMessage({action:"on.audio.decode",data:t},[t.audioData]),d.on.audio.error=t=>postMessage({action:"on.audio.error",data:t}),d.on.video.decode=t=>postMessage({action:"on.video.decode",data:t},[t.bitmap]),d.on.video.error=t=>postMessage({action:"on.video.error",data:t}),d.on.nalus=t=>postMessage({action:"on.nalus",data:t}),d.on.analysis=t=>postMessage({action:"on.analysis",data:t}),onmessage=t=>{const{action:e,data:i}=t.data,o=d[e];o&&o(i)}})();
3
+ `,En=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,Tn],{type:`text/javascript;charset=utf-8`});function Dn(e){let t;try{if(t=En&&(self.URL||self.webkitURL).createObjectURL(En),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(Tn),{name:e?.name})}}var On=class{worker=new Dn;on={audio:{},video:{}};constructor(){this.worker.onmessage=e=>{let{action:t,data:n}=e.data;switch(t){case`on.audio.decode`:this.on.audio.decode&&this.on.audio.decode(n);break;case`on.audio.error`:this.on.audio.error&&this.on.audio.error(n);break;case`on.video.decode`:this.on.video.decode&&this.on.video.decode(n);break;case`on.video.error`:this.on.video.error&&this.on.video.error(n);break;case`on.nalus`:this.on.nalus&&this.on.nalus(n);break;case`on.analysis`:this.on.analysis&&this.on.analysis(n);break}}}init=e=>this.worker.postMessage({action:`init`,data:e});initAudio=e=>this.worker.postMessage({action:`initAudio`,data:e});initVideo=e=>this.worker.postMessage({action:`initVideo`,data:e});push=e=>this.worker.postMessage({action:`push`,data:e});setFrameTrack=e=>this.worker.postMessage({action:`setFrameTrack`,data:e});destroy=()=>{this.worker.postMessage({action:`destroy`}),this.worker.terminate()}},kn=`(function(){"use strict";class w{renderMap=new Map;constructor(){}push=async t=>{const{timestamp:s}=t,{bitmap:e}=t;try{const n=[...this.renderMap.keys()];for(const a of n){const i=this.renderMap.get(a);if(!i)continue;const{pause:y=!1,writer:u,offscreen:o,option:f}=i;if(y===!0)continue;const h=async r=>{if(u){const c=new VideoFrame(r,{timestamp:s});try{await u.write(c)}catch{}c.close()}else o&&(o.width=r.width,o.height=r.height,o?.getContext("2d")?.drawImage(r,0,0))};if(a==="default")await h(e);else if(f){const{sx:r=0,sy:c=0,sw:p=e.width,sh:M=e.height}=f,g=await createImageBitmap(e,r,c,p,M);await h(g)}}}catch{}e.close()};addCut=t=>{const{key:s,writable:e,offscreen:n,option:a}={key:"default",...t};if(e){const i=e.getWriter();this.renderMap.set(s,{writer:i,option:a,pause:!1})}else this.renderMap.set(s,{offscreen:n,option:a,pause:!1})};delCut=t=>{this.renderMap.delete(t)};setCut=t=>{const{key:s,cutOption:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,option:e})};setPause=t=>{const{key:s,pause:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,pause:e})};destroy=()=>{this.renderMap=new Map}}const l=new w;onmessage=d=>{const{action:t,data:s}=d.data,e=l[t];e&&e(s)}})();
4
+ `,An=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,kn],{type:`text/javascript;charset=utf-8`});function jn(e){let t;try{if(t=An&&(self.URL||self.webkitURL).createObjectURL(An),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(kn),{name:e?.name})}}var Mn=class{worker=new jn;constructor(){}push=e=>this.worker.postMessage({action:`push`,data:e},[e.bitmap]);addCut=e=>{let t=[];e.writable&&t.push(e.writable),e.offscreen&&t.push(e.offscreen),this.worker.postMessage({action:`addCut`,data:e},t)};delCut=e=>this.worker.postMessage({action:`delCut`,data:e});setCut=e=>this.worker.postMessage({action:`setCut`,data:e});setPause=e=>this.worker.postMessage({action:`setPause`,data:e});destroy=()=>{this.worker.postMessage({action:`destroy`,data:{}}),this.worker.terminate()}},Nn=class{inputStream=new MediaStream;outputStream=new MediaStream;inputGain=1;enhanceGain=1;bgsGain=1;bgmGain=1;outputGain=1;mixAudioMap=new Map;audioContext=new AudioContext;sourceNode;inputGainNode;enhanceGainNode;bgsGainNode;bgmGainNode;rnnoiseNode;analyserNode;analyserArrayData;outputGainNode;destinationNode;denoise=!1;mute=!0;rnnoiseWorklet;rnnoiseWorkletNode;filterStream=e=>e;constructor(e,t){this.inputStream=e,t&&(this.audioContext=t),this.sourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.inputGainNode=this.audioContext.createGain(),this.inputGainNode.gain.setValueAtTime(this.inputGain,this.audioContext.currentTime),this.enhanceGainNode=this.audioContext.createGain(),this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime),this.bgsGainNode=this.audioContext.createGain(),this.bgsGainNode.gain.setValueAtTime(this.bgsGain,this.audioContext.currentTime),this.bgmGainNode=this.audioContext.createGain(),this.bgmGainNode.gain.setValueAtTime(this.bgmGain,this.audioContext.currentTime),this.analyserNode=this.audioContext.createAnalyser(),this.analyserNode.fftSize=512,this.analyserArrayData=new Uint8Array(this.analyserNode.frequencyBinCount),this.outputGainNode=this.audioContext.createGain(),this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime),this.destinationNode=this.audioContext.createMediaStreamDestination(),this.outputStream=this.destinationNode.stream;{let{sourceNode:e,inputGainNode:t,enhanceGainNode:n,bgsGainNode:r,bgmGainNode:i,analyserNode:a,outputGainNode:o,destinationNode:s}=this;e.connect(t),t.connect(n),n.connect(a),r.connect(a),i.connect(a),n.connect(s),r.connect(s),i.connect(s),o.connect(this.audioContext.destination)}this.audioContext.resume()}use=({rnnoise:e})=>{this.rnnoiseWorklet=new e.RnnoiseWorklet};_changeSource=()=>{this.sourceNode.disconnect(),this.sourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.sourceNode.connect(this.inputGainNode)};replaceTrack=e=>{let t=this.inputStream.getTracks();for(let e of t)this.inputStream.removeTrack(e);this.inputStream.addTrack(e),this._changeSource()};stop=()=>{{let e=this.inputStream.getTracks();for(let t of e)t.stop(),this.inputStream.removeTrack(t)}};pause=async e=>{let t=this.inputStream.getTracks();for(let n of t)n.enabled=!e};getStream=()=>this.filterStream(this.outputStream);setMute=(e=!0)=>{this.mute=e,this.analyserNode.disconnect(),e===!1&&this.analyserNode.connect(this.outputGainNode)};setDenoise=async(e=!0)=>{this.rnnoiseWorklet&&(this.inputGainNode.disconnect(),this.rnnoiseWorklet.destroy(),e?(this.rnnoiseWorkletNode=await this.rnnoiseWorklet.createRnnoiseWorkletNode(this.audioContext),this.inputGainNode.connect(this.rnnoiseWorkletNode),this.rnnoiseWorkletNode.connect(this.enhanceGainNode)):this.inputGainNode.connect(this.enhanceGainNode),this.denoise=e)};setInputGain=e=>{this.inputGain=e,this.inputGainNode.gain.setValueAtTime(e,this.audioContext.currentTime)};setEnhanceGain=async e=>{this.enhanceGain=e+1,this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime)};setBgsGain=e=>{this.bgsGain=e,this.bgsGainNode.gain.setValueAtTime(e,this.audioContext.currentTime)};setBgmGain=e=>{this.bgmGain=e,this.bgmGainNode.gain.setValueAtTime(e,this.audioContext.currentTime)};setOutputGain=e=>{this.outputGain=e,this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime)};getVolume=()=>{let{analyserNode:e,analyserArrayData:t}=this;e.getByteFrequencyData(t);let n=0;for(let e=0;e<t.length;e++)n+=t[e];return Math.ceil(n/t.length)};mixAudio=(e,t=`bgm`)=>new Promise(async(n,r)=>{try{{let e=this.mixAudioMap.get(t);e&&e.stop()}let r=t===`bgs`?this.bgsGainNode:this.bgmGainNode,i=this.audioContext.createBufferSource();this.mixAudioMap.set(t,i),i.buffer=e,i.connect(r),i.onended=()=>{i.disconnect(r),this.mixAudioMap.delete(t),n(!0)},i.start(0)}catch(e){r(e)}});mixAudioStop=e=>{this.mixAudioMap.get(e)?.stop()};changeMix=(e,t)=>{let n=e===`bgs`?this.bgsGainNode:this.bgmGainNode;t?n.connect(this.destinationNode):n.disconnect(this.destinationNode)}},Pn=async(e,t)=>{try{let{format:n,numberOfChannels:r,numberOfFrames:i,sampleRate:a}=t,o=e.createBuffer(r,i,a);for(let e=0;e<r;e++){let r=t.allocationSize({planeIndex:e}),a=new Uint8Array(r);t.copyTo(a,{planeIndex:e});let s=new DataView(a.buffer),c=o.getChannelData(e);for(let e=0;e<i;e++){let t;switch(n){case`s16`:case`s16-planar`:t=s.getInt16(e*2,!0)/32768;break;case`f32`:case`f32-planar`:t=s.getFloat32(e*4,!0);break;case`u8`:case`u8-planar`:t=(s.getUint8(e)-128)/128;break;default:throw Error(`Unsupported audio format: ${n}`)}c[e]=Math.max(-1,Math.min(1,t))}}return o}catch(e){throw console.error(`Failed to convert AudioData to AudioBuffer:`,e),e}},Fn=class{prAudioStream;audioContext;destination;stream=new MediaStream;nextStartTime=0;pendingSources=[];constructor(){}init=e=>{e||=new(window.AudioContext||window.webkitAudioContext),this.audioContext=e,this.destination=this.audioContext.createMediaStreamDestination(),this.stream=new MediaStream,this.stream.addTrack(this.destination.stream.getAudioTracks()[0]),this.prAudioStream=new Nn(this.stream,this.audioContext),this.nextStartTime=0,this.pendingSources=[]};async push(e){let{audioData:t,playbackRate:n=1}=e;if(!this.audioContext||!this.destination)return;let r=await Pn(this.audioContext,t);if(t.close(),!r)return;let i=this.audioContext.createBufferSource();i.buffer=r,i.playbackRate.value=n;let a=-1200*Math.log2(n);i.detune.value=a,i.connect(this.destination);let o=Math.max(this.nextStartTime,this.audioContext.currentTime);this.nextStartTime=o+r.duration/n,i.start(o),this.pendingSources.push(i),i.onended=()=>{this.pendingSources=this.pendingSources.filter(e=>e!==i)},this.audioContext.state===`suspended`&&await this.audioContext.resume()}getStream=()=>this.prAudioStream?.getStream();destroy(){this.audioContext?.close(),this.audioContext=void 0,this.destination=void 0,this.nextStartTime=0,this.prAudioStream?.stop(),this.pendingSources.forEach(e=>e.stop()),this.pendingSources=[]}},In=e=>{let t=e.toLowerCase();return t.includes(`.m3u8`)||t.includes(`hls`)||t.includes(`master.m3u8`)||t.match(/index\d*\.m3u8/)?`hls`:t.includes(`.mpd`)||t.includes(`dash`)?`dash`:t.startsWith(`rtmp://`)||t.startsWith(`rtmps://`)?`rtmp`:t.includes(`.flv`)||t.includes(`flv`)&&!t.includes(`flash`)?`flv`:`unknown`},Ln=e=>{let t=e?.getTracks()||[];for(let e of t)e.stop()},Rn=class{resolvesMap=new Map;index=0;constructor(){}add=(e,t=()=>!1,n=0)=>new Promise(r=>{if(t())return r(!0);this.resolvesMap.has(e)||this.resolvesMap.set(e,new Map),this.index++;let i=`${this.index}`;if(n=Math.max(0,n),n===0){this.resolvesMap.get(e)?.set(i,{resolve:r,timer:0});return}let a=window.setTimeout(()=>{this.emit(e)},n);this.resolvesMap.get(e)?.set(i,{resolve:r,timer:a})});emit=async e=>{let t=this.resolvesMap.get(e);if(!t)return;let n=[...t.keys()];for(let e of n){let n=t.get(e);n&&(clearTimeout(n.timer),n.resolve(),t.delete(e))}}},zn=e=>{let t=new DataView(e.buffer),n=0,r,i,a;r=t.getUint32(n,!1),n+=4;{let e=t.getUint8(n);i={forbidden_zero_bit:e>>7&1,nal_ref_idc:e>>5&3,nal_unit_type:e&31},n+=1}{let e=r-1;a=new Uint8Array(t.buffer.slice(n,n+e))}return{size:r,header:i,data:a}},Bn=class{#e={timeout:5*1e3,check:!1};#t=null;constructor(e={}){this.#e={...this.#e,...e}}#n=(e,t)=>new Promise(async n=>{this.#t=new AbortController;let{signal:r}=this.#t,i=this.#e.timeout,a=setTimeout(()=>{this.#t?.abort(`Timeout (${i}ms)`)},i);await fetch(e,{cache:`no-store`,...t,method:`HEAD`,signal:r}).then(e=>{clearTimeout(a),n({status:e.status===200?`successed`:`failed`,reason:e.status===200?``:`HTTP ${e.status}`})}).catch(e=>{if(clearTimeout(a),e.name===`AbortError`){let e=r.reason||`Actively stopped`;n({status:e.includes(`Timeout`)?`timeout`:`stopped`,reason:e})}else n({status:`error`,reason:e.message})})});request=(e,t)=>new Promise(async(n,r)=>{try{this.stop(),this.#e.check&&await this.#n(e),this.#t=new AbortController;let{signal:r}=this.#t;n(await fetch(e,{cache:`no-store`,...t,signal:r}))}catch(e){r(e)}});stop=()=>{if(this.#t?.signal.aborted===!1){let e=Error(`Actively stopped.`);e.name=`AbortError`,this.#t.abort(e)}}},Vn=class{option={debug:!1,frameTrack:!1};converter=`MediaStreamTrackGenerator`in window?`generator`:`canvas`;prFetch=new Bn;getSegmentsFetch=new Bn;prResolves=new Rn;url=``;start_resolve;demuxerWorker;decoderWorker;audioPlayer;renderWorker;stream;on={demuxer:{},decoder:{}};cutRenders=new Map;trackGenerator;constructor(e={}){let{debug:t=!1}=e;this.option.debug=t}start=async e=>{await this.stop(),this.url=e;let t=In(e);if(t===`unknown`)throw Error(`This address cannot be parsed.`);switch(this.init(t),t){case`flv`:this.flv.start();break;case`hls`:this.hls.start();break}};stop=async()=>{try{this.url=``,clearInterval(this.hls.getSegmentsTimer),this.prFetch.stop(),this.getSegmentsFetch.stop(),this.demuxerWorker?.destroy(),this.decoderWorker?.destroy(),this.renderWorker?.destroy(),this.cutRenders=new Map,Ln(this.stream),this.audioPlayer?.destroy()}catch(e){console.log(`\x1B[38;2;0;151;255m%c%s\x1B[0m`,`color:#0097ff;`,`------->pr-player: error`,e)}};getStream=()=>this.stream;setPause=e=>{this.renderWorker?.setPause({pause:e})};setMute=e=>this.audioPlayer?.prAudioStream?.setMute(e);setOutputGain=e=>{this.audioPlayer?.prAudioStream?.setOutputGain(e)};setFrameTrack=e=>{this.option.frameTrack=e,this.decoderWorker?.setFrameTrack(e)};isReady=()=>this.prResolves.add(`isReady`,()=>this.stream?.active===!0);cut={create:(e,t)=>{if(this.converter===`generator`){let n=new MediaStreamTrackGenerator({kind:`video`}),r=new MediaStream([n]);return this.renderWorker?.addCut({key:e,writable:n.writable,option:t}),this.cutRenders.set(e,{stream:r}),r}let n=document.createElement(`canvas`),r=n.captureStream(),i=n.transferControlToOffscreen();return this.renderWorker?.addCut({key:e,offscreen:i,option:t}),this.cutRenders.set(e,{stream:r}),r},setCut:(e,t)=>{this.renderWorker?.setCut({key:e,cutOption:t})},getStream:e=>this.cutRenders.get(e)?.stream,remove:e=>{this.renderWorker?.delCut(e),this.cutRenders.delete(e)},setPause:(e,t)=>{this.renderWorker?.setPause({key:e,pause:t})}};init=e=>{this.initRender(),this.initDecoder(e),this.initDemuxer(e),this.audioPlayer=new Fn,this.audioPlayer.init()};initDemuxer=e=>{this.demuxerWorker=new wn,this.demuxerWorker.init(e),this.demuxerWorker.on.debug=e=>{this.option.debug&&this.on.debug&&this.on.debug(e)},this.demuxerWorker.on.info=e=>{this.option.debug&&console.log(`\x1B[38;2;0;151;255m%c%s\x1B[0m`,`color:#0097ff;`,`------->pr-player: info`,e),this.on.demuxer.info&&this.on.demuxer.info(e)},this.demuxerWorker.on.config=e=>{this.option.debug&&console.log(`\x1B[38;2;0;151;255m%c%s\x1B[0m`,`color:#0097ff;`,`------->pr-player: config`,e),this.on.demuxer.config&&this.on.demuxer.config(e);let{kind:t}=e;switch(t){case`audio`:{let{codec:t,sampleRate:n,numberOfChannels:r}=e;this.decoderWorker?.initAudio({codec:t,sampleRate:n,numberOfChannels:r})}break;case`video`:{let{codec:t,description:n}=e;this.decoderWorker?.initVideo({codec:t,description:n})}break}},this.demuxerWorker.on.chunk=e=>{if(this.on.demuxer.chunk&&this.on.demuxer.chunk(e),!this.decoderWorker)return;let{kind:t}=e;switch(t){case`audio`:{let{type:n,dts:r,data:i}=e,a=r*1e3;this.decoderWorker.push({kind:t,init:{type:n,timestamp:a,data:i}})}break;case`video`:{let{type:n,dts:r,data:i,nalus:a=[]}=e,o=r*1e3;this.decoderWorker.push({kind:t,init:{type:n,timestamp:o,data:i},nalus:a})}break}}};initDecoder=e=>{this.decoderWorker=new On,this.decoderWorker.init(e);let{frameTrack:t=!1}=this.option;this.decoderWorker.setFrameTrack(t),this.decoderWorker.on.audio.decode=e=>{this.audioPlayer?.push(e),this.on.decoder.audio&&this.on.decoder.audio(e)},this.decoderWorker.on.audio.error=e=>{this.option.debug&&console.log(`\x1B[38;2;0;151;255m%c%s\x1B[0m`,`color:#0097ff;`,`------->pr-player: audio.error `,e),this.on.error&&this.on.error(e)},this.decoderWorker.on.video.decode=async e=>{this.start_resolve&&=(this.start_resolve(!0),void 0),this.renderWorker?.push(e),this.on.decoder.video&&this.on.decoder.video(e)},this.decoderWorker.on.video.error=e=>{this.on.error&&this.on.error(e)},this.decoderWorker.on.nalus=async e=>{for(let t of e){if(t.byteLength<=4)continue;let{header:e,data:n}=zn(t),{nal_unit_type:r}=e;r===6&&this.on.decoder.sei&&this.on.decoder.sei(n)}},this.decoderWorker.on.analysis=e=>{this.on.decoder.analysis&&this.on.decoder.analysis(e)}};initRender=()=>{if(this.renderWorker=new Mn,this.converter===`generator`){let e=new MediaStreamTrackGenerator({kind:`video`}),t=new MediaStream([e]);this.renderWorker?.addCut({writable:e.writable}),this.stream=t}else{let e=document.createElement(`canvas`),t=e.captureStream(),n=e.transferControlToOffscreen();this.renderWorker?.addCut({offscreen:n}),this.stream=t}this.renderWorker?.setPause({pause:!1})};flv={start:()=>new Promise(async(e,t)=>{try{this.start_resolve=e;let n,r=0;for(;;){r+=1;try{n=await this.prFetch.request(this.url)}catch(e){console.log(`\x1B[38;2;0;151;255m%c%s\x1B[0m`,`color:#0097ff;`,`------->Breathe: error`,e)}if(n?.status===200||r===3)break;await new Promise(e=>setTimeout(()=>e(!0),500))}if(!n||n.status!==200)return t(`request is error.`);let i=n.body?.getReader();if(!i)return t(`reader is error.`);for(;;){let{done:e,value:t}=await i.read();if(t&&this.demuxerWorker?.push(t),e||this.url===``)break}}catch(e){e.name!==`AbortError`&&t(e)}})};hls={isLive:!1,urls:[],url:``,getSegmentsTimer:0,parse:async e=>{let t=new TextDecoder(`utf-8`).decode(e).split(`
5
+ `).map(e=>e.replace(`\r`,``)),n=this.url.substring(0,this.url.lastIndexOf(`/`)+1),r=4,i=0,a=!1,o=[];for(let e of t)e.startsWith(`#EXTINF:`)?r=parseFloat(e.split(`:`)[1].split(`,`)[0]):e.startsWith(`#EXT-X-TARGETDURATION:`)?i=parseInt(e.split(`:`)[1]):e.startsWith(`#EXT-X-ENDLIST`)?a=!1:e.startsWith(`#EXT-X-MEDIA-SEQUENCE:`)?a=!0:e.includes(`.ts`)&&!e.startsWith(`#`)&&o.push({url:e.startsWith(`http`)?e:n+e,duration:r,isLive:a});return{baseUrl:n,targetDuration:i,isLive:a,segments:o}},getSegments:async()=>{try{let e,t=0;for(;;){t+=1;try{e=await this.getSegmentsFetch.request(this.url)}catch(e){console.log(`\x1B[38;2;0;151;255m%c%s\x1B[0m`,`color:#0097ff;`,`------->Breathe: error`,e)}if(e?.status===200||t===3)break;await new Promise(e=>setTimeout(()=>e(!0),500))}if(!e||e.status!==200)throw Error(`request is error.`);let n=e.body?.getReader();if(!n)throw Error(`reader is error.`);for(;;){let{done:e,value:t}=await n.read();if(t){let{segments:e=[],isLive:n=!1}=await this.hls.parse(t);this.hls.isLive=n,n===!1&&(this.option.frameTrack=!1);let r=Array.from(e,e=>e.url),i=r.findIndex(e=>e===this.hls.url);i!==-1&&(r=r.slice(i+1)),this.hls.urls=r}if(e||this.url===``)break}}catch(e){e.name!==`AbortError`&&this.on.error&&this.on.error(e)}},start:()=>new Promise(async(e,t)=>{try{for(this.start_resolve=e,this.hls.url=``,this.hls.urls=[],await this.hls.getSegments(),this.hls.getSegmentsTimer=window.setInterval(this.hls.getSegments,500),this.hls.isLive===!1&&(clearInterval(this.hls.getSegmentsTimer),this.decoderWorker?.setFrameTrack(!1));;){let e=this.hls.urls.shift();if(e){this.hls.url=e;let t=(await this.prFetch.request(e)).body?.getReader();if(!t)throw Error(`segment reader is error.`);for(;;){let{done:e,value:n}=await t.read();if(n&&this.demuxerWorker?.push(n),e||this.url===``)break}}else await new Promise(e=>setTimeout(()=>e(!0),300))}}catch(e){e.name!==`AbortError`&&t(e)}})}},Hn=bn(`Cg1DZG5EYXRhLnByb3RvEhVjb20ucXVpY2sudm9pY2UucHJvdG8iawoHU2VpRGF0YRIvCgVldmVudBgBIAEoDjIgLmNvbS5xdWljay52b2ljZS5wcm90by5FdmVudFR5cGUSDAoEZGF0YRgCIAEoDBIQCghjb21wcmVzcxgDIAEoCBIPCgd2ZXJzaW9uGAQgASgFIq4CCgpMYXlvdXREYXRhEg4KBnJvb21JZBgBIAEoCRIvCgR0eXBlGAIgASgOMiEuY29tLnF1aWNrLnZvaWNlLnByb3RvLkxheW91dFR5cGUSPwoHdXNlck1hcBgDIAMoCzIuLmNvbS5xdWljay52b2ljZS5wcm90by5MYXlvdXREYXRhLlVzZXJNYXBFbnRyeRI8CgxnbG9iYWxDdXN0b20YBCABKAsyIS5jb20ucXVpY2sudm9pY2UucHJvdG8uQ3VzdG9tSW5mb0gAiAEBGk8KDFVzZXJNYXBFbnRyeRILCgNrZXkYASABKAkSLgoFdmFsdWUYAiABKAsyHy5jb20ucXVpY2sudm9pY2UucHJvdG8uVXNlckluZm86AjgBQg8KDV9nbG9iYWxDdXN0b20ivQEKCFVzZXJJbmZvEgoKAmlkGAEgASgJEjAKBmF1ZGlvcxgCIAMoCzIgLmNvbS5xdWljay52b2ljZS5wcm90by5BdWRpb0luZm8SMAoGdmlkZW9zGAMgAygLMiAuY29tLnF1aWNrLnZvaWNlLnByb3RvLlZpZGVvSW5mbxI2CgZjdXN0b20YBCABKAsyIS5jb20ucXVpY2sudm9pY2UucHJvdG8uQ3VzdG9tSW5mb0gAiAEBQgkKB19jdXN0b20ilQEKCUF1ZGlvSW5mbxIuCgR0eXBlGAEgASgOMiAuY29tLnF1aWNrLnZvaWNlLnByb3RvLkF1ZGlvVHlwZRIQCghpc0VuYWJsZRgCIAEoCBIOCgZpc011dGUYAyABKAgSDgoGdm9sdW1lGAQgASgBEhcKCnVwZGF0ZVRpbWUYBSABKANIAIgBAUINCgtfdXBkYXRlVGltZSK6AQoJVmlkZW9JbmZvEi4KBHR5cGUYASABKA4yIC5jb20ucXVpY2sudm9pY2UucHJvdG8uVmlkZW9UeXBlEhAKCGlzRW5hYmxlGAIgASgIEg4KBmlzTXV0ZRgDIAEoCBINCgV3aWR0aBgEIAEoBRIOCgZoZWlnaHQYBSABKAUSCQoBeBgGIAEoBRIJCgF5GAcgASgFEhcKCnVwZGF0ZVRpbWUYCCABKANIAIgBAUINCgtfdXBkYXRlVGltZSLEAQoKQ3VzdG9tSW5mbxIOCgZyb29tSWQYASABKAkSSQoMY3VzdG9tS2V5TWFwGAIgAygLMjMuY29tLnF1aWNrLnZvaWNlLnByb3RvLkN1c3RvbUluZm8uQ3VzdG9tS2V5TWFwRW50cnkSFwoKdXBkYXRlVGltZRgDIAEoA0gAiAEBGjMKEUN1c3RvbUtleU1hcEVudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCToCOAFCDQoLX3VwZGF0ZVRpbWUqIwoJRXZlbnRUeXBlEgoKBkxheW91dBAAEgoKBkN1c3RvbRABKj0KCkxheW91dFR5cGUSEQoNQXVkaW9BbmRWaWRlbxAAEg0KCU9ubHlBdWRpbxABEg0KCU9ubHlWaWRlbxACKiwKCUF1ZGlvVHlwZRIOCgpNaWNyb3Bob25lEAASDwoLU3lzdGVtVm9pY2UQASojCglWaWRlb1R5cGUSCgoGQ2FtZXJhEAASCgoGU2NyZWVuEAFCPwoWY29tLnF1aWNrLnBsYXllci5wcm90b0IHQ2RuRGF0YVoWY29tLnF1aWNrLnBsYXllci5wcm90b7oCA0NkbmIGcHJvdG8z`),Un=Z(Hn,0),Wn=Z(Hn,1),Gn=Z(Hn,5),Kn=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,volume:0}),qn=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,sx:0,sy:0,sw:0,sh:0}),Jn=class{userId=``;mc_audio;mc_video;ss_audio;ss_video;updateTime=0;constructor(){}getUpdateTimeKey=()=>{let e=[];return this.mc_audio&&e.push(this.mc_audio.updateTime),this.mc_video&&e.push(this.mc_video.updateTime),this.ss_audio&&e.push(this.ss_audio.updateTime),this.ss_video&&e.push(this.ss_video.updateTime),e.join(`_`)};init=e=>{let{id:t,audios:n=[],videos:r=[]}=e;this.userId=t;let i=this.getUpdateTimeKey();this.mc_audio&&(this.mc_audio.remove=!0),this.mc_video&&(this.mc_video.remove=!0),this.ss_audio&&(this.ss_audio.remove=!0),this.ss_video&&(this.ss_video.remove=!0);for(let e of n){let{type:t=0,isEnable:n=!1,isMute:r=!1,updateTime:i,volume:a=0}=e;switch(t){case 0:if(this.mc_audio||=Kn(),this.mc_audio.remove=!1,this.mc_audio.updateTime===Number(i))break;this.mc_audio.isEnable=!!n,this.mc_audio.isMute=!!r,this.mc_audio.updateTime=Number(i),this.mc_audio.volume=Number(a);break;case 1:if(this.ss_audio||=Kn(),this.ss_audio.remove=!1,this.ss_audio.updateTime===Number(i))break;this.ss_audio.isEnable=!!n,this.ss_audio.isMute=!!r,this.ss_audio.updateTime=Number(i),this.ss_audio.volume=Number(a);break}}for(let e of r){let{type:t=0,isEnable:n,isMute:r,updateTime:i,width:a,height:o,x:s,y:c}=e;switch(t){case 0:if(this.mc_video||=qn(),this.mc_video.remove=!1,this.mc_video.updateTime===Number(i))break;this.mc_video.isEnable=!!n,this.mc_video.isMute=!!r,this.mc_video.updateTime=Number(i)||0,this.mc_video.sx=s||0,this.mc_video.sy=c||0,this.mc_video.sw=a||0,this.mc_video.sh=o||0;break;case 1:if(this.ss_video||=qn(),this.ss_video.remove=!1,this.ss_video.updateTime===Number(i))break;this.ss_video.isEnable=!!n,this.ss_video.isMute=!!r,this.ss_video.updateTime=Number(i)||0,this.ss_video.sx=s||0,this.ss_video.sy=c||0,this.ss_video.sw=a||0,this.ss_video.sh=o||0;break}}this.mc_audio?.remove&&(this.mc_audio=void 0),this.mc_video?.remove&&(this.mc_video=void 0),this.ss_audio?.remove&&(this.ss_audio=void 0),this.ss_video?.remove&&(this.ss_video=void 0),i!==this.getUpdateTimeKey()&&(this.updateTime=new Date().getTime())};destroy=()=>{this.mc_audio=void 0,this.mc_video=void 0,this.ss_audio=void 0,this.ss_video=void 0}},Yn=e=>{let t=0,n=0;for(;;){let r=e[t];if(n+=r,t+=1,r!==255)break}let r=0;for(;;){let n=e[t];if(r+=n,t+=1,n!==255)break}if(n===5){let n=e.slice(t,t+16),i=Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``);t+=16;let a=r-16,o=Q(Un,e.slice(t,t+a)),{event:s=0}=o,c=o.data,l;switch(s){case 0:l=Q(Wn,o.data);break;case 1:l=Q(Gn,o.data);break}return{uuid:i,...o,event:s,data_remote:c,data:l}}};e.QuickVoPlayer=class{option={debug:!1,ws:`wss://livep2p.devplay.cc/websocket`};displayMode=`original`;prPlayer;dom;room={roomId:``,updateTime:``,author:``,version:``};usersMap=new Map;on={users:e=>{},analysis:e=>{}};constructor(e={}){let{debug:t=!1}=e;this.option.debug=t,this.prPlayer=new Vn({debug:t}),this.prPlayer.on.demuxer.chunk=e=>{},this.prPlayer.on.decoder.sei=this.onSEI,this.prPlayer.on.decoder.analysis=this.onAnalysis}start=async e=>(this.stop(),this.prPlayer.start(e));stop=()=>{this.prPlayer.stop(),this.usersMap=new Map,this.room.roomId=``,this.room.author=``,this.room.updateTime=``,this.room.version=``};setMute=e=>{this.prPlayer.setMute(e)};setOutputGain=e=>{this.prPlayer.audioPlayer?.prAudioStream?.setOutputGain(e)};getStream=()=>this.prPlayer.getStream();getAllUseUpdateKey=()=>{let e=[...this.usersMap.values()];return Array.from(e,e=>e.updateTime).join(`_`)};checkAndCreateUser=(e,t)=>{!this.usersMap.has(e)&&this.usersMap.set(e,new Jn);let n=this.usersMap.get(e);if(n){if(n.init(t),n.mc_video&&n.mc_video.stream===void 0){let{sx:e,sy:t,sw:r,sh:i}=n.mc_video,a=`${n.userId}_mc_video`,o=this.prPlayer.cut.create(a,{sx:e,sy:t,sw:r,sh:i});this.displayMode===`original`&&this.prPlayer.cut.setPause(a,!0),n.mc_video.stream=o}if(n.ss_video&&n.ss_video.stream===void 0){let{sx:e,sy:t,sw:r,sh:i}=n.ss_video,a=`${n.userId}_ss_video`,o=this.prPlayer.cut.create(a,{sx:e,sy:t,sw:r,sh:i});this.displayMode===`original`&&this.prPlayer.cut.setPause(a,!0),n.ss_video.stream=o}if(n?.mc_video){let e=`${n.userId}_mc_video`,{sx:t,sy:r,sw:i,sh:a}=n.mc_video;this.prPlayer.cut.setCut(e,{sx:t,sy:r,sw:i,sh:a})}if(n?.ss_video){let e=`${n.userId}_ss_video`,{sx:t,sy:r,sw:i,sh:a}=n.ss_video;this.prPlayer.cut.setCut(e,{sx:t,sy:r,sw:i,sh:a})}}};setDisplayMode=e=>{switch(this.displayMode=e,e){case`original`:{this.prPlayer.setPause(!1);let e=[...this.usersMap.keys()];for(let t of e)this.prPlayer.cut.setPause(`${t}_mc_video`,!0),this.prPlayer.cut.setPause(`${t}_ss_video`,!0)}break;case`cut`:{this.prPlayer.setPause(!0);let e=[...this.usersMap.keys()];for(let t of e)this.prPlayer.cut.setPause(`${t}_mc_video`,!1),this.prPlayer.cut.setPause(`${t}_ss_video`,!1)}break}};onSEI=e=>{try{let t=Yn(e);if(!t)return;let{event:n,data:r}=t;switch(n){case 0:{let{roomId:e,userMap:t}=r;if(e!==this.room.roomId)return;let n=this.getAllUseUpdateKey(),i=Object.keys(t);{let e=[...this.usersMap.keys()];for(let t of e)i.includes(t)||(this.prPlayer.cut.remove(`${t}_mc_video`),this.prPlayer.cut.remove(`${t}_ss_video`),this.usersMap.delete(t))}for(let e of i){let n=t[e];this.checkAndCreateUser(e,n)}if(n!==this.getAllUseUpdateKey()&&this.on.users){let e=[...this.usersMap.values()],t=Array.from(e,({userId:e,mc_audio:t,mc_video:n,ss_audio:r,ss_video:i,updateTime:a})=>({userId:e,mc_audio:t,mc_video:n,ss_audio:r,ss_video:i,updateTime:a}));this.on.users(t)}}break;case 1:{let{roomId:e,updateTime:t}=r,{author:n,version:i}=r.customKeyMap;this.room.roomId=e,this.room.updateTime=t,this.room.author=n,this.room.version=i}break}}catch(e){console.log(`\x1B[38;2;0;151;255m%c%s\x1B[0m`,`color:#0097ff;`,`------->onSEI: error`,e)}};onAnalysis=e=>{this.on.analysis&&this.on.analysis(e)}}});