quickvo-player 0.2.7 → 0.2.9

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.
package/dist/index.js CHANGED
@@ -2,20 +2,20 @@ var Q = Object.defineProperty;
2
2
  var X = (h) => {
3
3
  throw TypeError(h);
4
4
  };
5
- var tt = (h, o, a) => o in h ? Q(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a;
6
- var m = (h, o, a) => tt(h, typeof o != "symbol" ? o + "" : o, a), Z = (h, o, a) => o.has(h) || X("Cannot " + a);
7
- var I = (h, o, a) => (Z(h, o, "read from private field"), a ? a.call(h) : o.get(h)), J = (h, o, a) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), H = (h, o, a, u) => (Z(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
5
+ var tt = (h, o, u) => o in h ? Q(h, o, { enumerable: !0, configurable: !0, writable: !0, value: u }) : h[o] = u;
6
+ var m = (h, o, u) => tt(h, typeof o != "symbol" ? o + "" : o, u), Z = (h, o, u) => o.has(h) || X("Cannot " + u);
7
+ var I = (h, o, u) => (Z(h, o, "read from private field"), u ? u.call(h) : o.get(h)), J = (h, o, u) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, u), H = (h, o, u, a) => (Z(h, o, "write to private field"), a ? a.call(h, u) : o.set(h, u), u);
8
8
  const D = '(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>1e3&&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', _ = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
9
9
  function L(h) {
10
10
  let o;
11
11
  try {
12
12
  if (o = _ && (self.URL || self.webkitURL).createObjectURL(_), !o) throw "";
13
- const a = new Worker(o, {
13
+ const u = new Worker(o, {
14
14
  name: h == null ? void 0 : h.name
15
15
  });
16
- return a.addEventListener("error", () => {
16
+ return u.addEventListener("error", () => {
17
17
  (self.URL || self.webkitURL).revokeObjectURL(o);
18
- }), a;
18
+ }), u;
19
19
  } catch {
20
20
  return new Worker(
21
21
  "data:text/javascript;charset=utf-8," + encodeURIComponent(D),
@@ -35,19 +35,19 @@ class V {
35
35
  this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
36
36
  });
37
37
  this.worker.onmessage = (o) => {
38
- const { action: a, data: u } = o.data;
39
- switch (a) {
38
+ const { action: u, data: a } = o.data;
39
+ switch (u) {
40
40
  case "on.info":
41
- this.on.info && this.on.info(u);
41
+ this.on.info && this.on.info(a);
42
42
  break;
43
43
  case "on.config":
44
- this.on.config && this.on.config(u);
44
+ this.on.config && this.on.config(a);
45
45
  break;
46
46
  case "on.chunk":
47
- this.on.chunk && this.on.chunk(u);
47
+ this.on.chunk && this.on.chunk(a);
48
48
  break;
49
49
  case "on.debug":
50
- this.on.debug && this.on.debug(u);
50
+ this.on.debug && this.on.debug(a);
51
51
  break;
52
52
  }
53
53
  };
@@ -59,12 +59,12 @@ function F(h) {
59
59
  let o;
60
60
  try {
61
61
  if (o = C && (self.URL || self.webkitURL).createObjectURL(C), !o) throw "";
62
- const a = new Worker(o, {
62
+ const u = new Worker(o, {
63
63
  name: h == null ? void 0 : h.name
64
64
  });
65
- return a.addEventListener("error", () => {
65
+ return u.addEventListener("error", () => {
66
66
  (self.URL || self.webkitURL).revokeObjectURL(o);
67
- }), a;
67
+ }), u;
68
68
  } catch {
69
69
  return new Worker(
70
70
  "data:text/javascript;charset=utf-8," + encodeURIComponent(S),
@@ -87,95 +87,95 @@ class N {
87
87
  this.worker.postMessage({ action: "destroy" }), this.worker.terminate();
88
88
  });
89
89
  this.worker.onmessage = (o) => {
90
- const { action: a, data: u } = o.data;
91
- switch (a) {
90
+ const { action: u, data: a } = o.data;
91
+ switch (u) {
92
92
  case "on.audio.decode":
93
- this.on.audio.decode && this.on.audio.decode(u);
93
+ this.on.audio.decode && this.on.audio.decode(a);
94
94
  break;
95
95
  case "on.audio.error":
96
- this.on.audio.error && this.on.audio.error(u);
96
+ this.on.audio.error && this.on.audio.error(a);
97
97
  break;
98
98
  case "on.video.decode":
99
- this.on.video.decode && this.on.video.decode(u);
99
+ this.on.video.decode && this.on.video.decode(a);
100
100
  break;
101
101
  case "on.video.error":
102
- this.on.video.error && this.on.video.error(u);
102
+ this.on.video.error && this.on.video.error(a);
103
103
  break;
104
104
  case "on.nalus":
105
- this.on.nalus && this.on.nalus(u);
105
+ this.on.nalus && this.on.nalus(a);
106
106
  break;
107
107
  case "on.analysis":
108
- this.on.analysis && this.on.analysis(u);
108
+ this.on.analysis && this.on.analysis(a);
109
109
  break;
110
110
  }
111
111
  };
112
112
  }
113
113
  }
114
- var B = Object.defineProperty, G = (h, o, a) => o in h ? B(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a, y = (h, o, a) => G(h, typeof o != "symbol" ? o + "" : o, a);
114
+ var B = Object.defineProperty, G = (h, o, u) => o in h ? B(h, o, { enumerable: !0, configurable: !0, writable: !0, value: u }) : h[o] = u, y = (h, o, u) => G(h, typeof o != "symbol" ? o + "" : o, u);
115
115
  class O {
116
- constructor(o, a) {
117
- y(this, "inputStream", new MediaStream()), y(this, "outputStream", new MediaStream()), y(this, "inputGain", 1), y(this, "enhanceGain", 1), y(this, "bgsGain", 1), y(this, "bgmGain", 1), y(this, "outputGain", 1), y(this, "mixAudioMap", /* @__PURE__ */ new Map()), y(this, "audioContext", new AudioContext()), y(this, "sourceNode"), y(this, "inputGainNode"), y(this, "enhanceGainNode"), y(this, "bgsGainNode"), y(this, "bgmGainNode"), y(this, "analyserNode"), y(this, "analyserArrayData"), y(this, "outputGainNode"), y(this, "destinationNode"), y(this, "filterStream", (u) => u), y(this, "stop", () => {
116
+ constructor(o, u) {
117
+ y(this, "inputStream", new MediaStream()), y(this, "outputStream", new MediaStream()), y(this, "inputGain", 1), y(this, "enhanceGain", 1), y(this, "bgsGain", 1), y(this, "bgmGain", 1), y(this, "outputGain", 1), y(this, "mixAudioMap", /* @__PURE__ */ new Map()), y(this, "audioContext", new AudioContext()), y(this, "sourceNode"), y(this, "inputGainNode"), y(this, "enhanceGainNode"), y(this, "bgsGainNode"), y(this, "bgmGainNode"), y(this, "analyserNode"), y(this, "analyserArrayData"), y(this, "outputGainNode"), y(this, "destinationNode"), y(this, "filterStream", (a) => a), y(this, "stop", () => {
118
118
  {
119
- const u = this.inputStream.getTracks();
120
- for (const n of u)
119
+ const a = this.inputStream.getTracks();
120
+ for (const n of a)
121
121
  n.stop(), this.inputStream.removeTrack(n);
122
122
  }
123
- }), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (u = !0) => {
124
- u ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
125
- }), y(this, "setInputGain", (u) => {
126
- this.inputGain = u, this.inputGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
127
- }), y(this, "setEnhanceGain", async (u) => {
128
- this.enhanceGain = u + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
129
- }), y(this, "setBgsGain", (u) => {
130
- this.bgsGain = u, this.bgsGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
131
- }), y(this, "setBgmGain", (u) => {
132
- this.bgmGain = u, this.bgmGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
133
- }), y(this, "setOutputGain", (u) => {
134
- this.outputGain = u, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
123
+ }), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (a = !0) => {
124
+ a ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
125
+ }), y(this, "setInputGain", (a) => {
126
+ this.inputGain = a, this.inputGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
127
+ }), y(this, "setEnhanceGain", async (a) => {
128
+ this.enhanceGain = a + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
129
+ }), y(this, "setBgsGain", (a) => {
130
+ this.bgsGain = a, this.bgsGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
131
+ }), y(this, "setBgmGain", (a) => {
132
+ this.bgmGain = a, this.bgmGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
133
+ }), y(this, "setOutputGain", (a) => {
134
+ this.outputGain = a, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
135
135
  }), y(this, "getVolume", () => {
136
- const { analyserNode: u, analyserArrayData: n } = this;
137
- u.getByteFrequencyData(n);
136
+ const { analyserNode: a, analyserArrayData: n } = this;
137
+ a.getByteFrequencyData(n);
138
138
  let r = 0;
139
139
  for (let i = 0; i < n.length; i++)
140
140
  r += n[i];
141
141
  return Math.ceil(r / n.length);
142
- }), y(this, "mixAudio", (u, n = "bgm") => new Promise(async (r, i) => {
142
+ }), y(this, "mixAudio", (a, n = "bgm") => new Promise(async (r, i) => {
143
143
  try {
144
144
  {
145
145
  const s = this.mixAudioMap.get(n);
146
146
  s && s.stop();
147
147
  }
148
148
  const t = n === "bgs" ? this.bgsGainNode : this.bgmGainNode, e = this.audioContext.createBufferSource();
149
- this.mixAudioMap.set(n, e), e.buffer = u, e.connect(t), e.onended = () => {
149
+ this.mixAudioMap.set(n, e), e.buffer = a, e.connect(t), e.onended = () => {
150
150
  e.disconnect(t), this.mixAudioMap.delete(n), r(!0);
151
151
  }, e.start(0);
152
152
  } catch (t) {
153
153
  i(t);
154
154
  }
155
- })), y(this, "mixAudioStop", (u) => {
156
- const n = this.mixAudioMap.get(u);
155
+ })), y(this, "mixAudioStop", (a) => {
156
+ const n = this.mixAudioMap.get(a);
157
157
  n == null || n.stop();
158
- }), y(this, "changeMix", (u, n) => {
159
- const r = u === "bgs" ? this.bgsGainNode : this.bgmGainNode;
158
+ }), y(this, "changeMix", (a, n) => {
159
+ const r = a === "bgs" ? this.bgsGainNode : this.bgmGainNode;
160
160
  n ? r.connect(this.destinationNode) : r.disconnect(this.destinationNode);
161
- }), a && (this.audioContext = a), this.inputStream = o, 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;
161
+ }), u && (this.audioContext = u), this.inputStream = o, 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;
162
162
  {
163
- const { sourceNode: u, inputGainNode: n, enhanceGainNode: r, bgsGainNode: i, bgmGainNode: t, analyserNode: e, outputGainNode: s, destinationNode: l } = this;
164
- u.connect(n), n.connect(r), r.connect(e), i.connect(e), t.connect(e), r.connect(l), i.connect(l), t.connect(l), e.connect(s), s.connect(this.audioContext.destination);
163
+ const { sourceNode: a, inputGainNode: n, enhanceGainNode: r, bgsGainNode: i, bgmGainNode: t, analyserNode: e, outputGainNode: s, destinationNode: l } = this;
164
+ a.connect(n), n.connect(r), r.connect(e), i.connect(e), t.connect(e), r.connect(l), i.connect(l), t.connect(l), e.connect(s), s.connect(this.audioContext.destination);
165
165
  }
166
166
  this.setMute(!0), this.audioContext.resume();
167
167
  }
168
168
  }
169
169
  const E = async (h, o) => {
170
170
  try {
171
- const { format: a, numberOfChannels: u, numberOfFrames: n, sampleRate: r } = o, i = h.createBuffer(u, n, r);
172
- for (let t = 0; t < u; t++) {
171
+ const { format: u, numberOfChannels: a, numberOfFrames: n, sampleRate: r } = o, i = h.createBuffer(a, n, r);
172
+ for (let t = 0; t < a; t++) {
173
173
  const e = o.allocationSize({ planeIndex: t }), s = new Uint8Array(e);
174
174
  o.copyTo(s, { planeIndex: t });
175
175
  const l = new DataView(s.buffer), c = i.getChannelData(t);
176
176
  for (let d = 0; d < n; d++) {
177
177
  let p;
178
- switch (a) {
178
+ switch (u) {
179
179
  case "s16":
180
180
  // 16-bit signed PCM (范围: -32768 ~ 32767)
181
181
  case "s16-planar":
@@ -192,14 +192,14 @@ const E = async (h, o) => {
192
192
  p = (l.getUint8(d) - 128) / 128;
193
193
  break;
194
194
  default:
195
- throw new Error(`Unsupported audio format: ${a}`);
195
+ throw new Error(`Unsupported audio format: ${u}`);
196
196
  }
197
197
  c[d] = Math.max(-1, Math.min(1, p));
198
198
  }
199
199
  }
200
200
  return i;
201
- } catch (a) {
202
- throw console.error("Failed to convert AudioData to AudioBuffer:", a), a;
201
+ } catch (u) {
202
+ throw console.error("Failed to convert AudioData to AudioBuffer:", u), u;
203
203
  }
204
204
  };
205
205
  class W {
@@ -219,26 +219,22 @@ class W {
219
219
  });
220
220
  }
221
221
  async push(o) {
222
- const { audioData: a, playbackRate: u = 1 } = o;
223
- try {
224
- if (!this.audioContext || !this.destination) return;
225
- let n = await E(this.audioContext, a);
226
- if (!n) return;
227
- const r = this.audioContext.createBufferSource();
228
- r.buffer = n, r.playbackRate.value = u;
229
- const i = -1200 * Math.log2(u);
230
- r.detune.value = i, r.connect(this.destination);
231
- const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration / u;
232
- this.nextStartTime = t + e, r.start(t), this.pendingSources.push(r), r.onended = () => {
233
- this.pendingSources = this.pendingSources.filter((s) => s !== r);
234
- }, this.audioContext.state === "suspended" && await this.audioContext.resume();
235
- } finally {
236
- a.close();
237
- }
222
+ const { audioData: u, playbackRate: a = 1 } = o;
223
+ if (!this.audioContext || !this.destination) return;
224
+ let n = await E(this.audioContext, u);
225
+ if (u.close(), !n) return;
226
+ const r = this.audioContext.createBufferSource();
227
+ r.buffer = n, r.playbackRate.value = a;
228
+ const i = -1200 * Math.log2(a);
229
+ r.detune.value = i, r.connect(this.destination);
230
+ const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration / a;
231
+ this.nextStartTime = t + e, r.start(t), this.pendingSources.push(r), r.onended = () => {
232
+ this.pendingSources = this.pendingSources.filter((s) => s !== r);
233
+ }, this.audioContext.state === "suspended" && await this.audioContext.resume();
238
234
  }
239
235
  destroy() {
240
- var o, a;
241
- (o = this.audioContext) == null || o.close(), this.audioContext = void 0, this.destination = void 0, this.nextStartTime = 0, (a = this.prAudioStream) == null || a.stop(), this.pendingSources.forEach((u) => u.stop()), this.pendingSources = [];
236
+ var o, u;
237
+ (o = this.audioContext) == null || o.close(), this.audioContext = void 0, this.destination = void 0, this.nextStartTime = 0, (u = this.prAudioStream) == null || u.stop(), this.pendingSources.forEach((a) => a.stop()), this.pendingSources = [];
242
238
  }
243
239
  }
244
240
  const R = `(function(){"use strict";class o{writable;writer;cutOption;pause=!1;constructor(){}init=({writable:t})=>{this.destroy(),this.writable=t,this.writer=this.writable.getWriter()};push=async t=>{if(this.pause)return;const{timestamp:s}=t;let{bitmap:i}=t;if(this.cutOption){const{sx:n=0,sy:c=0,sw:h=i.width,sh:u=i.height}=this.cutOption;i=await createImageBitmap(i,n,c,h,u)}const r=new VideoFrame(i,{timestamp:s});this.cutOption&&i.close(),this.writer.write(r),r.close()};setCut=t=>{this.cutOption=t};setPause=t=>{this.pause=t};destroy=()=>{this.writable=void 0,this.writer=void 0,this.cutOption=void 0}}const a=new o;onmessage=e=>{const{action:t,data:s}=e.data,i=a[t];i&&i(s)}})();
@@ -247,12 +243,12 @@ function j(h) {
247
243
  let o;
248
244
  try {
249
245
  if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
250
- const a = new Worker(o, {
246
+ const u = new Worker(o, {
251
247
  name: h == null ? void 0 : h.name
252
248
  });
253
- return a.addEventListener("error", () => {
249
+ return u.addEventListener("error", () => {
254
250
  (self.URL || self.webkitURL).revokeObjectURL(o);
255
- }), a;
251
+ }), u;
256
252
  } catch {
257
253
  return new Worker(
258
254
  "data:text/javascript;charset=utf-8," + encodeURIComponent(R),
@@ -279,12 +275,12 @@ const q = (h) => {
279
275
  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";
280
276
  }, M = (h) => {
281
277
  const o = (h == null ? void 0 : h.getTracks()) || [];
282
- for (const a of o)
283
- a.stop();
278
+ for (const u of o)
279
+ u.stop();
284
280
  }, A = () => {
285
- const h = new MediaStreamTrackGenerator({ kind: "video" }), o = new MediaStream([h]), a = new z();
286
- return a.init({ writable: h.writable }), { worker: a, stream: o, destroy: () => {
287
- a.destroy(), M(o);
281
+ const h = new MediaStreamTrackGenerator({ kind: "video" }), o = new MediaStream([h]), u = new z();
282
+ return u.init({ writable: h.writable }), { worker: u, stream: o, destroy: () => {
283
+ u.destroy(), M(o);
288
284
  } };
289
285
  };
290
286
  class $ {
@@ -298,44 +294,44 @@ class $ {
298
294
  * @param timeout 超时时间 ms
299
295
  * @returns
300
296
  */
301
- m(this, "add", (o, a = () => !1, u = 0) => new Promise((n) => {
297
+ m(this, "add", (o, u = () => !1, a = 0) => new Promise((n) => {
302
298
  var t, e;
303
- if (a()) return n(!0);
299
+ if (u()) return n(!0);
304
300
  this.resolvesMap.has(o) || this.resolvesMap.set(o, /* @__PURE__ */ new Map()), this.index++;
305
301
  const r = `${this.index}`;
306
- if (u = Math.max(0, u), u === 0) {
302
+ if (a = Math.max(0, a), a === 0) {
307
303
  (t = this.resolvesMap.get(o)) == null || t.set(r, { resolve: n, timer: 0 });
308
304
  return;
309
305
  }
310
306
  const i = window.setTimeout(() => {
311
307
  this.emit(o);
312
- }, u);
308
+ }, a);
313
309
  (e = this.resolvesMap.get(o)) == null || e.set(r, { resolve: n, timer: i });
314
310
  }));
315
311
  m(this, "emit", async (o) => {
316
- const a = this.resolvesMap.get(o);
317
- if (!a) return;
318
- const u = [...a.keys()];
319
- for (const n of u) {
320
- const r = a.get(n);
321
- r && (clearTimeout(r.timer), r.resolve(), a.delete(n));
312
+ const u = this.resolvesMap.get(o);
313
+ if (!u) return;
314
+ const a = [...u.keys()];
315
+ for (const n of a) {
316
+ const r = u.get(n);
317
+ r && (clearTimeout(r.timer), r.resolve(), u.delete(n));
322
318
  }
323
319
  });
324
320
  }
325
321
  }
326
322
  const Y = (h) => {
327
323
  const o = new DataView(h.buffer);
328
- let a = 0, u, n, r;
329
- u = o.getUint32(a, !1), a += 4;
324
+ let u = 0, a, n, r;
325
+ a = o.getUint32(u, !1), u += 4;
330
326
  {
331
- const i = o.getUint8(a), t = i >> 7 & 1, e = i >> 5 & 3, s = i & 31;
332
- n = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s }, a += 1;
327
+ const i = o.getUint8(u), t = i >> 7 & 1, e = i >> 5 & 3, s = i & 31;
328
+ n = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s }, u += 1;
333
329
  }
334
330
  {
335
- const i = u - 1;
336
- r = new Uint8Array(o.buffer.slice(a, a + i));
331
+ const i = a - 1;
332
+ r = new Uint8Array(o.buffer.slice(u, u + i));
337
333
  }
338
- return { size: u, header: n, data: r };
334
+ return { size: a, header: n, data: r };
339
335
  };
340
336
  var P, U;
341
337
  class x {
@@ -349,7 +345,7 @@ class x {
349
345
  * @param input string | URL | Request
350
346
  * @param init RequestInit
351
347
  */
352
- m(this, "check", (o, a) => new Promise(async (u, n) => {
348
+ m(this, "check", (o, u) => new Promise(async (a, n) => {
353
349
  var i;
354
350
  this.stop(), H(this, U, new AbortController());
355
351
  const r = window.setTimeout(() => {
@@ -357,8 +353,8 @@ class x {
357
353
  (t = I(this, U)) == null || t.abort("Timeout."), n({ status: "timeout", reason: "" });
358
354
  }, I(this, P).timeout);
359
355
  try {
360
- const t = await fetch(o, { ...a, method: "HEAD", signal: (i = I(this, U)) == null ? void 0 : i.signal });
361
- t.status === 200 ? u({ status: "successed", reason: "" }) : n({ status: "failed", reason: `${t.status}` });
356
+ const t = await fetch(o, { ...u, method: "HEAD", signal: (i = I(this, U)) == null ? void 0 : i.signal });
357
+ t.status === 200 ? a({ status: "successed", reason: "" }) : n({ status: "failed", reason: `${t.status}` });
362
358
  } catch (t) {
363
359
  n({ status: "error", reason: t.message });
364
360
  }
@@ -369,12 +365,12 @@ class x {
369
365
  * @param input string | URL | Request
370
366
  * @param init RequestInit
371
367
  */
372
- m(this, "request", async (o, a) => new Promise(async (u, n) => {
368
+ m(this, "request", async (o, u) => new Promise(async (a, n) => {
373
369
  var r;
374
370
  try {
375
- await this.check(o, a), H(this, U, new AbortController());
376
- const i = await fetch(o, { ...a, signal: (r = I(this, U)) == null ? void 0 : r.signal });
377
- u(i);
371
+ await this.check(o, u), H(this, U, new AbortController());
372
+ const i = await fetch(o, { ...u, signal: (r = I(this, U)) == null ? void 0 : r.signal });
373
+ a(i);
378
374
  } catch (i) {
379
375
  this.stop(), n(i);
380
376
  }
@@ -415,9 +411,9 @@ class et {
415
411
  */
416
412
  m(this, "start", async (o) => {
417
413
  await this.stop(), this.url = o;
418
- const a = q(o);
419
- if (a === "unknown") throw new Error("This address cannot be parsed.");
420
- switch (this.init(a), a) {
414
+ const u = q(o);
415
+ if (u === "unknown") throw new Error("This address cannot be parsed.");
416
+ switch (this.init(u), u) {
421
417
  case "flv":
422
418
  this.flv.start();
423
419
  break;
@@ -430,13 +426,13 @@ class et {
430
426
  * 停止
431
427
  */
432
428
  m(this, "stop", async () => {
433
- var a, u, n, r, i;
429
+ var u, a, n, r, i;
434
430
  try {
435
431
  this.url = "", clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop(), this.getSegmentsFetch.stop();
436
432
  } catch (t) {
437
433
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: error", t);
438
434
  }
439
- (a = this.demuxerWorker) == null || a.destroy(), (u = this.decoderWorker) == null || u.destroy(), (n = this.renderWorker) == null || n.destroy();
435
+ (u = this.demuxerWorker) == null || u.destroy(), (a = this.decoderWorker) == null || a.destroy(), (n = this.renderWorker) == null || n.destroy();
440
436
  const o = [...this.cutRenders.keys()];
441
437
  for (const t of o)
442
438
  (r = this.cutRenders.get(t)) == null || r.worker.destroy(), this.cutRenders.delete(t);
@@ -451,32 +447,32 @@ class et {
451
447
  * @param pause: boolean
452
448
  */
453
449
  m(this, "setPause", (o) => {
454
- var a;
455
- (a = this.renderWorker) == null || a.setPause(o);
450
+ var u;
451
+ (u = this.renderWorker) == null || u.setPause(o);
456
452
  });
457
453
  /**
458
454
  * 是否静音 默认为true
459
455
  * @param state?: boolean
460
456
  */
461
457
  m(this, "setMute", (o) => {
462
- var a, u;
463
- return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(o);
458
+ var u, a;
459
+ return (a = (u = this.audioPlayer) == null ? void 0 : u.prAudioStream) == null ? void 0 : a.setMute(o);
464
460
  });
465
461
  /**
466
462
  * 是否开启追帧
467
463
  * @param frameTrack?: boolean
468
464
  */
469
465
  m(this, "setFrameTrack", (o) => {
470
- var a;
471
- this.option.frameTrack = o, (a = this.decoderWorker) == null || a.setFrameTrack(o);
466
+ var u;
467
+ this.option.frameTrack = o, (u = this.decoderWorker) == null || u.setFrameTrack(o);
472
468
  });
473
469
  /**
474
470
  * 是否已准备好
475
471
  */
476
472
  m(this, "isReady", () => {
477
473
  const o = () => {
478
- var a;
479
- return ((a = this.stream) == null ? void 0 : a.active) === !0;
474
+ var u;
475
+ return ((u = this.stream) == null ? void 0 : u.active) === !0;
480
476
  };
481
477
  return this.prResolves.add("isReady", o);
482
478
  });
@@ -484,31 +480,31 @@ class et {
484
480
  /**
485
481
  * 创建剪切
486
482
  */
487
- create: (o, a) => {
488
- let u = this.cutRenders.get(o);
489
- return u ? (u.worker.setCut(a), u.worker.setPause(!1), u) : (u = A(), u.worker.setCut(a), this.cutRenders.set(o, u), u);
483
+ create: (o, u) => {
484
+ let a = this.cutRenders.get(o);
485
+ return a ? (a.worker.setCut(u), a.worker.setPause(!1), a) : (a = A(), a.worker.setCut(u), this.cutRenders.set(o, a), a);
490
486
  },
491
487
  /**
492
488
  * 获取媒体流
493
489
  */
494
490
  getStream: (o) => {
495
- var a;
496
- return (a = this.cutRenders.get(o)) == null ? void 0 : a.stream;
491
+ var u;
492
+ return (u = this.cutRenders.get(o)) == null ? void 0 : u.stream;
497
493
  },
498
494
  /**
499
495
  * 设置暂停
500
496
  * @param pause: boolean
501
497
  */
502
- setPause: (o, a) => {
503
- var u;
504
- (u = this.cutRenders.get(o)) == null || u.worker.setPause(a);
498
+ setPause: (o, u) => {
499
+ var a;
500
+ (a = this.cutRenders.get(o)) == null || a.worker.setPause(u);
505
501
  },
506
502
  /**
507
503
  * 移除剪切
508
504
  */
509
505
  remove: (o) => {
510
- var a;
511
- (a = this.cutRenders.get(o)) == null || a.destroy(), this.cutRenders.delete(o);
506
+ var u;
507
+ (u = this.cutRenders.get(o)) == null || u.destroy(), this.cutRenders.delete(o);
512
508
  }
513
509
  });
514
510
  /**
@@ -521,42 +517,42 @@ class et {
521
517
  * 初始化解复器
522
518
  */
523
519
  m(this, "initDemuxer", (o) => {
524
- this.demuxerWorker = new V(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
525
- this.option.debug && this.on.debug && this.on.debug(a);
526
- }, this.demuxerWorker.on.info = (a) => {
527
- 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);
528
- }, this.demuxerWorker.on.config = (a) => {
520
+ this.demuxerWorker = new V(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (u) => {
521
+ this.option.debug && this.on.debug && this.on.debug(u);
522
+ }, this.demuxerWorker.on.info = (u) => {
523
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: info", u), this.on.demuxer.info && this.on.demuxer.info(u);
524
+ }, this.demuxerWorker.on.config = (u) => {
529
525
  var n, r;
530
- 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);
531
- const { kind: u } = a;
532
- switch (u) {
526
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: config", u), this.on.demuxer.config && this.on.demuxer.config(u);
527
+ const { kind: a } = u;
528
+ switch (a) {
533
529
  case "audio":
534
530
  {
535
- const { codec: i, sampleRate: t, numberOfChannels: e } = a;
531
+ const { codec: i, sampleRate: t, numberOfChannels: e } = u;
536
532
  (n = this.decoderWorker) == null || n.initAudio({ codec: i, sampleRate: t, numberOfChannels: e });
537
533
  }
538
534
  break;
539
535
  case "video":
540
536
  {
541
- const { codec: i, description: t } = a;
537
+ const { codec: i, description: t } = u;
542
538
  (r = this.decoderWorker) == null || r.initVideo({ codec: i, description: t });
543
539
  }
544
540
  break;
545
541
  }
546
- }, this.demuxerWorker.on.chunk = (a) => {
547
- if (this.on.demuxer.chunk && this.on.demuxer.chunk(a), !this.decoderWorker) return;
548
- const { kind: u } = a;
549
- switch (u) {
542
+ }, this.demuxerWorker.on.chunk = (u) => {
543
+ if (this.on.demuxer.chunk && this.on.demuxer.chunk(u), !this.decoderWorker) return;
544
+ const { kind: a } = u;
545
+ switch (a) {
550
546
  case "audio":
551
547
  {
552
- const { type: n, dts: r, data: i } = a, t = r * 1e3;
553
- this.decoderWorker.push({ kind: u, init: { type: n, timestamp: t, data: i } });
548
+ const { type: n, dts: r, data: i } = u, t = r * 1e3;
549
+ this.decoderWorker.push({ kind: a, init: { type: n, timestamp: t, data: i } });
554
550
  }
555
551
  break;
556
552
  case "video":
557
553
  {
558
- const { type: n, dts: r, data: i, nalus: t = [] } = a, e = r * 1e3;
559
- this.decoderWorker.push({ kind: u, init: { type: n, timestamp: e, data: i }, nalus: t });
554
+ const { type: n, dts: r, data: i, nalus: t = [] } = u, e = r * 1e3;
555
+ this.decoderWorker.push({ kind: a, init: { type: n, timestamp: e, data: i }, nalus: t });
560
556
  }
561
557
  break;
562
558
  }
@@ -567,53 +563,53 @@ class et {
567
563
  */
568
564
  m(this, "initDecoder", (o) => {
569
565
  this.decoderWorker = new N(), this.decoderWorker.init(o);
570
- const { frameTrack: a = !1 } = this.option;
571
- this.decoderWorker.setFrameTrack(a), this.decoderWorker.on.audio.decode = (u) => {
566
+ const { frameTrack: u = !1 } = this.option;
567
+ this.decoderWorker.setFrameTrack(u), this.decoderWorker.on.audio.decode = (a) => {
572
568
  var n;
573
- (n = this.audioPlayer) == null || n.push(u), this.on.decoder.audio && this.on.decoder.audio(u);
574
- }, this.decoderWorker.on.audio.error = (u) => {
575
- 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);
576
- }, this.decoderWorker.on.video.decode = async (u) => {
569
+ (n = this.audioPlayer) == null || n.push(a), this.on.decoder.audio && this.on.decoder.audio(a);
570
+ }, this.decoderWorker.on.audio.error = (a) => {
571
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: audio.error ", a), this.on.error && this.on.error(a);
572
+ }, this.decoderWorker.on.video.decode = async (a) => {
577
573
  var r, i;
578
- (r = this.renderWorker) == null || r.push(u);
574
+ (r = this.renderWorker) == null || r.push(a);
579
575
  const n = [...this.cutRenders.keys()];
580
576
  for (const t of n)
581
- (i = this.cutRenders.get(t)) == null || i.worker.push(u);
582
- this.on.decoder.video && this.on.decoder.video(u), u.bitmap.close();
583
- }, this.decoderWorker.on.video.error = (u) => {
584
- this.on.error && this.on.error(u);
585
- }, this.decoderWorker.on.nalus = async (u) => {
586
- for (const n of u) {
577
+ (i = this.cutRenders.get(t)) == null || i.worker.push(a);
578
+ this.on.decoder.video && this.on.decoder.video(a), a.bitmap.close();
579
+ }, this.decoderWorker.on.video.error = (a) => {
580
+ this.on.error && this.on.error(a);
581
+ }, this.decoderWorker.on.nalus = async (a) => {
582
+ for (const n of a) {
587
583
  if (n.byteLength <= 4) continue;
588
584
  const { header: r, data: i } = Y(n), { nal_unit_type: t } = r;
589
585
  t === 6 && this.on.decoder.sei && this.on.decoder.sei(i);
590
586
  }
591
- }, this.decoderWorker.on.analysis = (u) => {
592
- this.on.decoder.analysis && this.on.decoder.analysis(u);
587
+ }, this.decoderWorker.on.analysis = (a) => {
588
+ this.on.decoder.analysis && this.on.decoder.analysis(a);
593
589
  };
594
590
  });
595
591
  /**
596
592
  * 初始化渲染器
597
593
  */
598
594
  m(this, "initRender", () => {
599
- const { worker: o, stream: a } = A();
600
- this.renderWorker = o, this.stream = a, this.renderWorker.setPause(!1);
595
+ const { worker: o, stream: u } = A();
596
+ this.renderWorker = o, this.stream = u, this.renderWorker.setPause(!1);
601
597
  });
602
598
  m(this, "flv", {
603
599
  start: async () => {
604
- var o, a;
600
+ var o, u;
605
601
  try {
606
- let u = await this.prFetch.request(this.url);
607
- if (u.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), u = await this.prFetch.request(this.url)), u.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), u = await this.prFetch.request(this.url)), u.status !== 200) throw new Error("request is error.");
608
- const n = (o = u.body) == null ? void 0 : o.getReader();
602
+ let a = await this.prFetch.request(this.url);
603
+ if (a.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), a = await this.prFetch.request(this.url)), a.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), a = await this.prFetch.request(this.url)), a.status !== 200) throw new Error("request is error.");
604
+ const n = (o = a.body) == null ? void 0 : o.getReader();
609
605
  if (!n) throw new Error("reader is error.");
610
606
  for (; ; ) {
611
607
  const { done: r, value: i } = await n.read();
612
- if (i && ((a = this.demuxerWorker) == null || a.push(i)), r || this.url === "") break;
608
+ if (i && ((u = this.demuxerWorker) == null || u.push(i)), r || this.url === "") break;
613
609
  }
614
- } catch (u) {
615
- if ((u == null ? void 0 : u.name) !== "AbortError") throw Error(u);
616
- this.on.error && this.on.error(u);
610
+ } catch (a) {
611
+ if ((a == null ? void 0 : a.name) !== "AbortError") throw Error(a);
612
+ this.on.error && this.on.error(a);
617
613
  }
618
614
  }
619
615
  });
@@ -623,27 +619,27 @@ class et {
623
619
  url: "",
624
620
  getSegmentsTimer: 0,
625
621
  parse: async (o) => {
626
- const a = new TextDecoder("utf-8").decode(o).split(`
627
- `).map((e) => e.replace("\r", "")), u = this.url.substring(0, this.url.lastIndexOf("/") + 1);
622
+ const u = new TextDecoder("utf-8").decode(o).split(`
623
+ `).map((e) => e.replace("\r", "")), a = this.url.substring(0, this.url.lastIndexOf("/") + 1);
628
624
  let n = 4, r = 0, i = !1;
629
625
  const t = [];
630
- for (const e of a)
626
+ for (const e of u)
631
627
  e.startsWith("#EXTINF:") ? n = parseFloat(e.split(":")[1].split(",")[0]) : e.startsWith("#EXT-X-TARGETDURATION:") ? r = parseInt(e.split(":")[1]) : e.startsWith("#EXT-X-ENDLIST") ? i = !1 : e.startsWith("#EXT-X-MEDIA-SEQUENCE:") ? i = !0 : e.includes(".ts") && !e.startsWith("#") && t.push({
632
- url: e.startsWith("http") ? e : u + e,
628
+ url: e.startsWith("http") ? e : a + e,
633
629
  duration: n,
634
630
  isLive: i
635
631
  });
636
- return { baseUrl: u, targetDuration: r, isLive: i, segments: t };
632
+ return { baseUrl: a, targetDuration: r, isLive: i, segments: t };
637
633
  },
638
634
  getSegments: async () => {
639
635
  var o;
640
636
  try {
641
- let a = await this.getSegmentsFetch.request(this.url);
642
- if (a.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), a = await this.getSegmentsFetch.request(this.url)), a.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), a = await this.getSegmentsFetch.request(this.url)), a.status !== 200) throw new Error("request is error.");
643
- const u = (o = a.body) == null ? void 0 : o.getReader();
644
- if (!u) throw new Error("reader is error.");
637
+ let u = await this.getSegmentsFetch.request(this.url);
638
+ if (u.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), u = await this.getSegmentsFetch.request(this.url)), u.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), u = await this.getSegmentsFetch.request(this.url)), u.status !== 200) throw new Error("request is error.");
639
+ const a = (o = u.body) == null ? void 0 : o.getReader();
640
+ if (!a) throw new Error("reader is error.");
645
641
  for (; ; ) {
646
- const { done: n, value: r } = await u.read();
642
+ const { done: n, value: r } = await a.read();
647
643
  if (r) {
648
644
  const i = await this.hls.parse(r), { segments: t = [], isLive: e = !1 } = i;
649
645
  this.hls.isLive = e, e === !1 && (this.option.frameTrack = !1);
@@ -653,22 +649,22 @@ class et {
653
649
  }
654
650
  if (n || this.url === "") break;
655
651
  }
656
- } catch (a) {
657
- this.on.error && this.on.error(a);
652
+ } catch (u) {
653
+ this.on.error && this.on.error(u);
658
654
  }
659
655
  },
660
656
  start: async () => {
661
- var o, a, u;
657
+ var o, u, a;
662
658
  try {
663
659
  for (await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (o = this.decoderWorker) == null ? void 0 : o.setFrameTrack(!1)); ; ) {
664
660
  const n = this.hls.urls.shift();
665
661
  if (n) {
666
662
  this.hls.url = n;
667
- const r = (a = (await this.prFetch.request(n)).body) == null ? void 0 : a.getReader();
663
+ const r = (u = (await this.prFetch.request(n)).body) == null ? void 0 : u.getReader();
668
664
  if (!r) throw new Error("segment reader is error.");
669
665
  for (; ; ) {
670
666
  const { done: i, value: t } = await r.read();
671
- if (t && ((u = this.demuxerWorker) == null || u.push(t)), i || this.url === "") break;
667
+ if (t && ((a = this.demuxerWorker) == null || a.push(t)), i || this.url === "") break;
672
668
  }
673
669
  } else
674
670
  await new Promise((r) => setTimeout(() => r(!0), 300));
@@ -678,19 +674,19 @@ class et {
678
674
  }
679
675
  }
680
676
  });
681
- const { debug: a = !1 } = o;
682
- this.option.debug = a;
677
+ const { debug: u = !1 } = o;
678
+ this.option.debug = u;
683
679
  }
684
680
  }
685
681
  var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, indexMinimal = {}, minimal$1 = {}, aspromise, hasRequiredAspromise;
686
682
  function requireAspromise() {
687
683
  if (hasRequiredAspromise) return aspromise;
688
684
  hasRequiredAspromise = 1, aspromise = h;
689
- function h(o, a) {
690
- for (var u = new Array(arguments.length - 1), n = 0, r = 2, i = !0; r < arguments.length; )
691
- u[n++] = arguments[r++];
685
+ function h(o, u) {
686
+ for (var a = new Array(arguments.length - 1), n = 0, r = 2, i = !0; r < arguments.length; )
687
+ a[n++] = arguments[r++];
692
688
  return new Promise(function(e, s) {
693
- u[n] = function(c) {
689
+ a[n] = function(c) {
694
690
  if (i)
695
691
  if (i = !1, c)
696
692
  s(c);
@@ -701,7 +697,7 @@ function requireAspromise() {
701
697
  }
702
698
  };
703
699
  try {
704
- o.apply(a || null, u);
700
+ o.apply(u || null, a);
705
701
  } catch (l) {
706
702
  i && (i = !1, s(l));
707
703
  }
@@ -721,25 +717,25 @@ function requireBase64() {
721
717
  ++s;
722
718
  return Math.ceil(t.length * 3) / 4 - s;
723
719
  };
724
- for (var a = new Array(64), u = new Array(123), n = 0; n < 64; )
725
- u[a[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
720
+ for (var u = new Array(64), a = new Array(123), n = 0; n < 64; )
721
+ a[u[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
726
722
  o.encode = function(t, e, s) {
727
723
  for (var l = null, c = [], d = 0, p = 0, f; e < s; ) {
728
724
  var w = t[e++];
729
725
  switch (p) {
730
726
  case 0:
731
- c[d++] = a[w >> 2], f = (w & 3) << 4, p = 1;
727
+ c[d++] = u[w >> 2], f = (w & 3) << 4, p = 1;
732
728
  break;
733
729
  case 1:
734
- c[d++] = a[f | w >> 4], f = (w & 15) << 2, p = 2;
730
+ c[d++] = u[f | w >> 4], f = (w & 15) << 2, p = 2;
735
731
  break;
736
732
  case 2:
737
- c[d++] = a[f | w >> 6], c[d++] = a[w & 63], p = 0;
733
+ c[d++] = u[f | w >> 6], c[d++] = u[w & 63], p = 0;
738
734
  break;
739
735
  }
740
736
  d > 8191 && ((l || (l = [])).push(String.fromCharCode.apply(String, c)), d = 0);
741
737
  }
742
- return p && (c[d++] = a[f], c[d++] = 61, p === 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));
738
+ return p && (c[d++] = u[f], c[d++] = 61, p === 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));
743
739
  };
744
740
  var r = "invalid encoding";
745
741
  o.decode = function(t, e, s) {
@@ -747,7 +743,7 @@ function requireBase64() {
747
743
  var f = t.charCodeAt(p++);
748
744
  if (f === 61 && c > 1)
749
745
  break;
750
- if ((f = u[f]) === void 0)
746
+ if ((f = a[f]) === void 0)
751
747
  throw Error(r);
752
748
  switch (c) {
753
749
  case 0:
@@ -779,27 +775,27 @@ function requireEventemitter() {
779
775
  function h() {
780
776
  this._listeners = {};
781
777
  }
782
- return h.prototype.on = function(a, u, n) {
783
- return (this._listeners[a] || (this._listeners[a] = [])).push({
784
- fn: u,
778
+ return h.prototype.on = function(u, a, n) {
779
+ return (this._listeners[u] || (this._listeners[u] = [])).push({
780
+ fn: a,
785
781
  ctx: n || this
786
782
  }), this;
787
- }, h.prototype.off = function(a, u) {
788
- if (a === void 0)
783
+ }, h.prototype.off = function(u, a) {
784
+ if (u === void 0)
789
785
  this._listeners = {};
790
- else if (u === void 0)
791
- this._listeners[a] = [];
786
+ else if (a === void 0)
787
+ this._listeners[u] = [];
792
788
  else
793
- for (var n = this._listeners[a], r = 0; r < n.length; )
794
- n[r].fn === u ? n.splice(r, 1) : ++r;
789
+ for (var n = this._listeners[u], r = 0; r < n.length; )
790
+ n[r].fn === a ? n.splice(r, 1) : ++r;
795
791
  return this;
796
- }, h.prototype.emit = function(a) {
797
- var u = this._listeners[a];
798
- if (u) {
792
+ }, h.prototype.emit = function(u) {
793
+ var a = this._listeners[u];
794
+ if (a) {
799
795
  for (var n = [], r = 1; r < arguments.length; )
800
796
  n.push(arguments[r++]);
801
- for (r = 0; r < u.length; )
802
- u[r].fn.apply(u[r++].ctx, n);
797
+ for (r = 0; r < a.length; )
798
+ a[r].fn.apply(a[r++].ctx, n);
803
799
  }
804
800
  return this;
805
801
  }, eventemitter;
@@ -847,12 +843,12 @@ function requireFloat() {
847
843
  e((d << 31 | p + 127 << 23 | f) >>> 0, l, c);
848
844
  }
849
845
  }
850
- r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, a);
846
+ r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, u);
851
847
  function t(e, s, l) {
852
848
  var c = e(s, l), d = (c >> 31) * 2 + 1, p = c >>> 23 & 255, f = c & 8388607;
853
849
  return p === 255 ? f ? NaN : d * (1 / 0) : p === 0 ? d * 1401298464324817e-60 * f : d * Math.pow(2, p - 150) * (f + 8388608);
854
850
  }
855
- r.readFloatLE = t.bind(null, u), r.readFloatBE = t.bind(null, n);
851
+ r.readFloatLE = t.bind(null, a), r.readFloatBE = t.bind(null, n);
856
852
  }(), typeof Float64Array < "u" ? function() {
857
853
  var i = new Float64Array([-0]), t = new Uint8Array(i.buffer), e = t[7] === 128;
858
854
  function s(p, f, w) {
@@ -894,21 +890,21 @@ function requireFloat() {
894
890
  }
895
891
  }
896
892
  }
897
- r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, a, 4, 0);
893
+ r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, u, 4, 0);
898
894
  function t(e, s, l, c, d) {
899
895
  var p = e(c, d + s), f = e(c, d + l), w = (f >> 31) * 2 + 1, b = f >>> 20 & 2047, g = 4294967296 * (f & 1048575) + p;
900
896
  return b === 2047 ? g ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * g : w * Math.pow(2, b - 1075) * (g + 4503599627370496);
901
897
  }
902
- r.readDoubleLE = t.bind(null, u, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
898
+ r.readDoubleLE = t.bind(null, a, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
903
899
  }(), r;
904
900
  }
905
901
  function o(r, i, t) {
906
902
  i[t] = r & 255, i[t + 1] = r >>> 8 & 255, i[t + 2] = r >>> 16 & 255, i[t + 3] = r >>> 24;
907
903
  }
908
- function a(r, i, t) {
904
+ function u(r, i, t) {
909
905
  i[t] = r >>> 24, i[t + 1] = r >>> 16 & 255, i[t + 2] = r >>> 8 & 255, i[t + 3] = r & 255;
910
906
  }
911
- function u(r, i) {
907
+ function a(r, i) {
912
908
  return (r[i] | r[i + 1] << 8 | r[i + 2] << 16 | r[i + 3] << 24) >>> 0;
913
909
  }
914
910
  function n(r, i) {
@@ -935,20 +931,20 @@ var utf8 = {}, hasRequiredUtf8;
935
931
  function requireUtf8() {
936
932
  return hasRequiredUtf8 || (hasRequiredUtf8 = 1, function(h) {
937
933
  var o = h;
938
- o.length = function(u) {
939
- for (var n = 0, r = 0, i = 0; i < u.length; ++i)
940
- 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;
934
+ o.length = function(a) {
935
+ for (var n = 0, r = 0, i = 0; i < a.length; ++i)
936
+ r = a.charCodeAt(i), r < 128 ? n += 1 : r < 2048 ? n += 2 : (r & 64512) === 55296 && (a.charCodeAt(i + 1) & 64512) === 56320 ? (++i, n += 4) : n += 3;
941
937
  return n;
942
- }, o.read = function(u, n, r) {
938
+ }, o.read = function(a, n, r) {
943
939
  var i = r - n;
944
940
  if (i < 1)
945
941
  return "";
946
942
  for (var t = null, e = [], s = 0, l; n < r; )
947
- l = u[n++], l < 128 ? e[s++] = l : l > 191 && l < 224 ? e[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, e[s++] = 55296 + (l >> 10), e[s++] = 56320 + (l & 1023)) : e[s++] = (l & 15) << 12 | (u[n++] & 63) << 6 | u[n++] & 63, s > 8191 && ((t || (t = [])).push(String.fromCharCode.apply(String, e)), s = 0);
943
+ l = a[n++], l < 128 ? e[s++] = l : l > 191 && l < 224 ? e[s++] = (l & 31) << 6 | a[n++] & 63 : l > 239 && l < 365 ? (l = ((l & 7) << 18 | (a[n++] & 63) << 12 | (a[n++] & 63) << 6 | a[n++] & 63) - 65536, e[s++] = 55296 + (l >> 10), e[s++] = 56320 + (l & 1023)) : e[s++] = (l & 15) << 12 | (a[n++] & 63) << 6 | a[n++] & 63, s > 8191 && ((t || (t = [])).push(String.fromCharCode.apply(String, e)), s = 0);
948
944
  return t ? (s && t.push(String.fromCharCode.apply(String, e.slice(0, s))), t.join("")) : String.fromCharCode.apply(String, e.slice(0, s));
949
- }, o.write = function(u, n, r) {
950
- for (var i = r, t, e, s = 0; s < u.length; ++s)
951
- t = u.charCodeAt(s), t < 128 ? n[r++] = t : t < 2048 ? (n[r++] = t >> 6 | 192, n[r++] = t & 63 | 128) : (t & 64512) === 55296 && ((e = u.charCodeAt(s + 1)) & 64512) === 56320 ? (t = 65536 + ((t & 1023) << 10) + (e & 1023), ++s, n[r++] = t >> 18 | 240, n[r++] = t >> 12 & 63 | 128, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128) : (n[r++] = t >> 12 | 224, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128);
945
+ }, o.write = function(a, n, r) {
946
+ for (var i = r, t, e, s = 0; s < a.length; ++s)
947
+ t = a.charCodeAt(s), t < 128 ? n[r++] = t : t < 2048 ? (n[r++] = t >> 6 | 192, n[r++] = t & 63 | 128) : (t & 64512) === 55296 && ((e = a.charCodeAt(s + 1)) & 64512) === 56320 ? (t = 65536 + ((t & 1023) << 10) + (e & 1023), ++s, n[r++] = t >> 18 | 240, n[r++] = t >> 12 & 63 | 128, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128) : (n[r++] = t >> 12 | 224, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128);
952
948
  return r - i;
953
949
  };
954
950
  }(utf8)), utf8;
@@ -957,13 +953,13 @@ var pool_1, hasRequiredPool;
957
953
  function requirePool() {
958
954
  if (hasRequiredPool) return pool_1;
959
955
  hasRequiredPool = 1, pool_1 = h;
960
- function h(o, a, u) {
961
- var n = u || 8192, r = n >>> 1, i = null, t = n;
956
+ function h(o, u, a) {
957
+ var n = a || 8192, r = n >>> 1, i = null, t = n;
962
958
  return function(s) {
963
959
  if (s < 1 || s > r)
964
960
  return o(s);
965
961
  t + s > n && (i = o(n), t = 0);
966
- var l = a.call(i, t, t += s);
962
+ var l = u.call(i, t, t += s);
967
963
  return t & 7 && (t = (t | 7) + 1), l;
968
964
  };
969
965
  }
@@ -977,18 +973,18 @@ function requireLongbits() {
977
973
  function o(r, i) {
978
974
  this.lo = r >>> 0, this.hi = i >>> 0;
979
975
  }
980
- var a = o.zero = new o(0, 0);
981
- a.toNumber = function() {
976
+ var u = o.zero = new o(0, 0);
977
+ u.toNumber = function() {
982
978
  return 0;
983
- }, a.zzEncode = a.zzDecode = function() {
979
+ }, u.zzEncode = u.zzDecode = function() {
984
980
  return this;
985
- }, a.length = function() {
981
+ }, u.length = function() {
986
982
  return 1;
987
983
  };
988
- var u = o.zeroHash = "\0\0\0\0\0\0\0\0";
984
+ var a = o.zeroHash = "\0\0\0\0\0\0\0\0";
989
985
  o.fromNumber = function(i) {
990
986
  if (i === 0)
991
- return a;
987
+ return u;
992
988
  var t = i < 0;
993
989
  t && (i = -i);
994
990
  var e = i >>> 0, s = (i - e) / 4294967296 >>> 0;
@@ -1001,7 +997,7 @@ function requireLongbits() {
1001
997
  i = h.Long.fromString(i);
1002
998
  else
1003
999
  return o.fromNumber(parseInt(i, 10));
1004
- return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) : a;
1000
+ return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) : u;
1005
1001
  }, o.prototype.toNumber = function(i) {
1006
1002
  if (!i && this.hi >>> 31) {
1007
1003
  var t = ~this.lo + 1 >>> 0, e = ~this.hi >>> 0;
@@ -1013,7 +1009,7 @@ function requireLongbits() {
1013
1009
  };
1014
1010
  var n = String.prototype.charCodeAt;
1015
1011
  return o.fromHash = function(i) {
1016
- return i === u ? a : new o(
1012
+ return i === a ? u : new o(
1017
1013
  (n.call(i, 0) | n.call(i, 1) << 8 | n.call(i, 2) << 16 | n.call(i, 3) << 24) >>> 0,
1018
1014
  (n.call(i, 4) | n.call(i, 5) << 8 | n.call(i, 6) << 16 | n.call(i, 7) << 24) >>> 0
1019
1015
  );
@@ -1086,21 +1082,21 @@ function requireMinimal$1() {
1086
1082
  var t = o.LongBits.fromHash(r);
1087
1083
  return o.Long ? o.Long.fromBits(t.lo, t.hi, i) : t.toNumber(!!i);
1088
1084
  };
1089
- function a(n, r, i) {
1085
+ function u(n, r, i) {
1090
1086
  for (var t = Object.keys(r), e = 0; e < t.length; ++e)
1091
1087
  (n[t[e]] === void 0 || !i) && (n[t[e]] = r[t[e]]);
1092
1088
  return n;
1093
1089
  }
1094
- o.merge = a, o.lcFirst = function(r) {
1090
+ o.merge = u, o.lcFirst = function(r) {
1095
1091
  return r.charAt(0).toLowerCase() + r.substring(1);
1096
1092
  };
1097
- function u(n) {
1093
+ function a(n) {
1098
1094
  function r(i, t) {
1099
1095
  if (!(this instanceof r))
1100
1096
  return new r(i, t);
1101
1097
  Object.defineProperty(this, "message", { get: function() {
1102
1098
  return i;
1103
- } }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && a(this, t);
1099
+ } }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && u(this, t);
1104
1100
  }
1105
1101
  return r.prototype = Object.create(Error.prototype, {
1106
1102
  constructor: {
@@ -1131,7 +1127,7 @@ function requireMinimal$1() {
1131
1127
  }
1132
1128
  }), r;
1133
1129
  }
1134
- o.newError = u, o.ProtocolError = u("ProtocolError"), o.oneOfGetter = function(r) {
1130
+ o.newError = a, o.ProtocolError = a("ProtocolError"), o.oneOfGetter = function(r) {
1135
1131
  for (var i = {}, t = 0; t < r.length; ++t)
1136
1132
  i[r[t]] = 1;
1137
1133
  return function() {
@@ -1169,7 +1165,7 @@ var writer, hasRequiredWriter;
1169
1165
  function requireWriter() {
1170
1166
  if (hasRequiredWriter) return writer;
1171
1167
  hasRequiredWriter = 1, writer = e;
1172
- var h = requireMinimal$1(), o, a = h.LongBits, u = h.base64, n = h.utf8;
1168
+ var h = requireMinimal$1(), o, u = h.LongBits, a = h.base64, n = h.utf8;
1173
1169
  function r(b, g, k) {
1174
1170
  this.fn = b, this.len = g, this.next = void 0, this.val = k;
1175
1171
  }
@@ -1212,7 +1208,7 @@ function requireWriter() {
1212
1208
  g
1213
1209
  )).len, this;
1214
1210
  }, e.prototype.int32 = function(g) {
1215
- return g < 0 ? this._push(p, 10, a.fromNumber(g)) : this.uint32(g);
1211
+ return g < 0 ? this._push(p, 10, u.fromNumber(g)) : this.uint32(g);
1216
1212
  }, e.prototype.sint32 = function(g) {
1217
1213
  return this.uint32((g << 1 ^ g >> 31) >>> 0);
1218
1214
  };
@@ -1224,10 +1220,10 @@ function requireWriter() {
1224
1220
  g[k++] = b.lo;
1225
1221
  }
1226
1222
  e.prototype.uint64 = function(g) {
1227
- var k = a.from(g);
1223
+ var k = u.from(g);
1228
1224
  return this._push(p, k.length(), k);
1229
1225
  }, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(g) {
1230
- var k = a.from(g).zzEncode();
1226
+ var k = u.from(g).zzEncode();
1231
1227
  return this._push(p, k.length(), k);
1232
1228
  }, e.prototype.bool = function(g) {
1233
1229
  return this._push(l, 1, g ? 1 : 0);
@@ -1238,7 +1234,7 @@ function requireWriter() {
1238
1234
  e.prototype.fixed32 = function(g) {
1239
1235
  return this._push(f, 4, g >>> 0);
1240
1236
  }, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(g) {
1241
- var k = a.from(g);
1237
+ var k = u.from(g);
1242
1238
  return this._push(f, 4, k.lo)._push(f, 4, k.hi);
1243
1239
  }, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(g) {
1244
1240
  return this._push(h.float.writeFloatLE, 4, g);
@@ -1256,8 +1252,8 @@ function requireWriter() {
1256
1252
  if (!k)
1257
1253
  return this._push(l, 1, 0);
1258
1254
  if (h.isString(g)) {
1259
- var T = e.alloc(k = u.length(g));
1260
- u.decode(g, T, 0), g = T;
1255
+ var T = e.alloc(k = a.length(g));
1256
+ a.decode(g, T, 0), g = T;
1261
1257
  }
1262
1258
  return this.uint32(k)._push(w, k, g);
1263
1259
  }, e.prototype.string = function(g) {
@@ -1281,15 +1277,15 @@ function requireWriter() {
1281
1277
  var writer_buffer, hasRequiredWriter_buffer;
1282
1278
  function requireWriter_buffer() {
1283
1279
  if (hasRequiredWriter_buffer) return writer_buffer;
1284
- hasRequiredWriter_buffer = 1, writer_buffer = a;
1280
+ hasRequiredWriter_buffer = 1, writer_buffer = u;
1285
1281
  var h = requireWriter();
1286
- (a.prototype = Object.create(h.prototype)).constructor = a;
1282
+ (u.prototype = Object.create(h.prototype)).constructor = u;
1287
1283
  var o = requireMinimal$1();
1288
- function a() {
1284
+ function u() {
1289
1285
  h.call(this);
1290
1286
  }
1291
- a._configure = function() {
1292
- a.alloc = o._Buffer_allocUnsafe, a.writeBytesBuffer = o.Buffer && o.Buffer.prototype instanceof Uint8Array && o.Buffer.prototype.set.name === "set" ? function(r, i, t) {
1287
+ u._configure = function() {
1288
+ u.alloc = o._Buffer_allocUnsafe, u.writeBytesBuffer = o.Buffer && o.Buffer.prototype instanceof Uint8Array && o.Buffer.prototype.set.name === "set" ? function(r, i, t) {
1293
1289
  i.set(r, t);
1294
1290
  } : function(r, i, t) {
1295
1291
  if (r.copy)
@@ -1297,24 +1293,24 @@ function requireWriter_buffer() {
1297
1293
  else for (var e = 0; e < r.length; )
1298
1294
  i[t++] = r[e++];
1299
1295
  };
1300
- }, a.prototype.bytes = function(r) {
1296
+ }, u.prototype.bytes = function(r) {
1301
1297
  o.isString(r) && (r = o._Buffer_from(r, "base64"));
1302
1298
  var i = r.length >>> 0;
1303
- return this.uint32(i), i && this._push(a.writeBytesBuffer, i, r), this;
1299
+ return this.uint32(i), i && this._push(u.writeBytesBuffer, i, r), this;
1304
1300
  };
1305
- function u(n, r, i) {
1301
+ function a(n, r, i) {
1306
1302
  n.length < 40 ? o.utf8.write(n, r, i) : r.utf8Write ? r.utf8Write(n, i) : r.write(n, i);
1307
1303
  }
1308
- return a.prototype.string = function(r) {
1304
+ return u.prototype.string = function(r) {
1309
1305
  var i = o.Buffer.byteLength(r);
1310
- return this.uint32(i), i && this._push(u, i, r), this;
1311
- }, a._configure(), writer_buffer;
1306
+ return this.uint32(i), i && this._push(a, i, r), this;
1307
+ }, u._configure(), writer_buffer;
1312
1308
  }
1313
1309
  var reader, hasRequiredReader;
1314
1310
  function requireReader() {
1315
1311
  if (hasRequiredReader) return reader;
1316
1312
  hasRequiredReader = 1, reader = r;
1317
- var h = requireMinimal$1(), o, a = h.LongBits, u = h.utf8;
1313
+ var h = requireMinimal$1(), o, u = h.LongBits, a = h.utf8;
1318
1314
  function n(c, d) {
1319
1315
  return RangeError("index out of range: " + c.pos + " + " + (d || 1) + " > " + c.len);
1320
1316
  }
@@ -1352,7 +1348,7 @@ function requireReader() {
1352
1348
  return d >>> 1 ^ -(d & 1) | 0;
1353
1349
  };
1354
1350
  function e() {
1355
- var c = new a(0, 0), d = 0;
1351
+ var c = new u(0, 0), d = 0;
1356
1352
  if (this.len - this.pos > 4) {
1357
1353
  for (; d < 4; ++d)
1358
1354
  if (c.lo = (c.lo | (this.buf[this.pos] & 127) << d * 7) >>> 0, this.buf[this.pos++] < 128)
@@ -1400,7 +1396,7 @@ function requireReader() {
1400
1396
  function l() {
1401
1397
  if (this.pos + 8 > this.len)
1402
1398
  throw n(this, 8);
1403
- return new a(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
1399
+ return new u(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
1404
1400
  }
1405
1401
  return r.prototype.float = function() {
1406
1402
  if (this.pos + 4 > this.len)
@@ -1425,7 +1421,7 @@ function requireReader() {
1425
1421
  return this._slice.call(this.buf, p, f);
1426
1422
  }, r.prototype.string = function() {
1427
1423
  var d = this.bytes();
1428
- return u.read(d, 0, d.length);
1424
+ return a.read(d, 0, d.length);
1429
1425
  }, r.prototype.skip = function(d) {
1430
1426
  if (typeof d == "number") {
1431
1427
  if (this.pos + d > this.len)
@@ -1488,19 +1484,19 @@ function requireReader() {
1488
1484
  var reader_buffer, hasRequiredReader_buffer;
1489
1485
  function requireReader_buffer() {
1490
1486
  if (hasRequiredReader_buffer) return reader_buffer;
1491
- hasRequiredReader_buffer = 1, reader_buffer = a;
1487
+ hasRequiredReader_buffer = 1, reader_buffer = u;
1492
1488
  var h = requireReader();
1493
- (a.prototype = Object.create(h.prototype)).constructor = a;
1489
+ (u.prototype = Object.create(h.prototype)).constructor = u;
1494
1490
  var o = requireMinimal$1();
1495
- function a(u) {
1496
- h.call(this, u);
1491
+ function u(a) {
1492
+ h.call(this, a);
1497
1493
  }
1498
- return a._configure = function() {
1499
- o.Buffer && (a.prototype._slice = o.Buffer.prototype.slice);
1500
- }, a.prototype.string = function() {
1494
+ return u._configure = function() {
1495
+ o.Buffer && (u.prototype._slice = o.Buffer.prototype.slice);
1496
+ }, u.prototype.string = function() {
1501
1497
  var n = this.uint32();
1502
1498
  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));
1503
- }, a._configure(), reader_buffer;
1499
+ }, u._configure(), reader_buffer;
1504
1500
  }
1505
1501
  var rpc = {}, service, hasRequiredService;
1506
1502
  function requireService() {
@@ -1508,17 +1504,17 @@ function requireService() {
1508
1504
  hasRequiredService = 1, service = o;
1509
1505
  var h = requireMinimal$1();
1510
1506
  (o.prototype = Object.create(h.EventEmitter.prototype)).constructor = o;
1511
- function o(a, u, n) {
1512
- if (typeof a != "function")
1507
+ function o(u, a, n) {
1508
+ if (typeof u != "function")
1513
1509
  throw TypeError("rpcImpl must be a function");
1514
- h.EventEmitter.call(this), this.rpcImpl = a, this.requestDelimited = !!u, this.responseDelimited = !!n;
1510
+ h.EventEmitter.call(this), this.rpcImpl = u, this.requestDelimited = !!a, this.responseDelimited = !!n;
1515
1511
  }
1516
- return o.prototype.rpcCall = function a(u, n, r, i, t) {
1512
+ return o.prototype.rpcCall = function u(a, n, r, i, t) {
1517
1513
  if (!i)
1518
1514
  throw TypeError("request must be specified");
1519
1515
  var e = this;
1520
1516
  if (!t)
1521
- return h.asPromise(a, e, u, n, r, i);
1517
+ return h.asPromise(u, e, a, n, r, i);
1522
1518
  if (!e.rpcImpl) {
1523
1519
  setTimeout(function() {
1524
1520
  t(Error("already ended"));
@@ -1527,11 +1523,11 @@ function requireService() {
1527
1523
  }
1528
1524
  try {
1529
1525
  return e.rpcImpl(
1530
- u,
1526
+ a,
1531
1527
  n[e.requestDelimited ? "encodeDelimited" : "encode"](i).finish(),
1532
1528
  function(l, c) {
1533
1529
  if (l)
1534
- return e.emit("error", l, u), t(l);
1530
+ return e.emit("error", l, a), t(l);
1535
1531
  if (c === null) {
1536
1532
  e.end(
1537
1533
  /* endedByRPC */
@@ -1543,19 +1539,19 @@ function requireService() {
1543
1539
  try {
1544
1540
  c = r[e.responseDelimited ? "decodeDelimited" : "decode"](c);
1545
1541
  } catch (d) {
1546
- return e.emit("error", d, u), t(d);
1542
+ return e.emit("error", d, a), t(d);
1547
1543
  }
1548
- return e.emit("data", c, u), t(null, c);
1544
+ return e.emit("data", c, a), t(null, c);
1549
1545
  }
1550
1546
  );
1551
1547
  } catch (s) {
1552
- e.emit("error", s, u), setTimeout(function() {
1548
+ e.emit("error", s, a), setTimeout(function() {
1553
1549
  t(s);
1554
1550
  }, 0);
1555
1551
  return;
1556
1552
  }
1557
- }, o.prototype.end = function(u) {
1558
- return this.rpcImpl && (u || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
1553
+ }, o.prototype.end = function(a) {
1554
+ return this.rpcImpl && (a || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
1559
1555
  }, service;
1560
1556
  }
1561
1557
  var hasRequiredRpc;
@@ -1573,11 +1569,11 @@ var hasRequiredIndexMinimal;
1573
1569
  function requireIndexMinimal() {
1574
1570
  return hasRequiredIndexMinimal || (hasRequiredIndexMinimal = 1, function(h) {
1575
1571
  var o = h;
1576
- 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;
1577
- function a() {
1572
+ 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 = u;
1573
+ function u() {
1578
1574
  o.util._configure(), o.Writer._configure(o.BufferWriter), o.Reader._configure(o.BufferReader);
1579
1575
  }
1580
- a();
1576
+ u();
1581
1577
  }(indexMinimal)), indexMinimal;
1582
1578
  }
1583
1579
  var minimal, hasRequiredMinimal;
@@ -1590,10 +1586,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1590
1586
  return h.quick = function() {
1591
1587
  const o = {};
1592
1588
  return o.voice = function() {
1593
- const a = {};
1594
- return a.proto = function() {
1595
- const u = {};
1596
- return u.SeiData = function() {
1589
+ const u = {};
1590
+ return u.proto = function() {
1591
+ const a = {};
1592
+ return a.SeiData = function() {
1597
1593
  function n(r) {
1598
1594
  if (r) for (let i = Object.keys(r), t = 0; t < i.length; ++t) r[i[t]] != null && (this[i[t]] = r[i[t]]);
1599
1595
  }
@@ -1686,10 +1682,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1686
1682
  }, n.getTypeUrl = function(i) {
1687
1683
  return i === void 0 && (i = "type.googleapis.com"), i + "/com.quick.voice.proto.SeiData";
1688
1684
  }, n;
1689
- }(), u.EventType = function() {
1685
+ }(), a.EventType = function() {
1690
1686
  const n = {}, r = Object.create(n);
1691
1687
  return r[n[0] = "Layout"] = 0, r[n[1] = "Custom"] = 1, r;
1692
- }(), u.LayoutData = function() {
1688
+ }(), a.LayoutData = function() {
1693
1689
  function n(i) {
1694
1690
  if (this.userMap = {}, i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
1695
1691
  }
@@ -1848,7 +1844,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1848
1844
  }, n.getTypeUrl = function(t) {
1849
1845
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.LayoutData";
1850
1846
  }, n;
1851
- }(), u.UserInfo = function() {
1847
+ }(), a.UserInfo = function() {
1852
1848
  function n(i) {
1853
1849
  if (this.audios = [], this.videos = [], i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
1854
1850
  }
@@ -1971,7 +1967,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1971
1967
  }, n.getTypeUrl = function(t) {
1972
1968
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.UserInfo";
1973
1969
  }, n;
1974
- }(), u.AudioInfo = function() {
1970
+ }(), a.AudioInfo = function() {
1975
1971
  function n(i) {
1976
1972
  if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
1977
1973
  }
@@ -2076,7 +2072,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2076
2072
  }, n.getTypeUrl = function(t) {
2077
2073
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.AudioInfo";
2078
2074
  }, n;
2079
- }(), u.VideoInfo = function() {
2075
+ }(), a.VideoInfo = function() {
2080
2076
  function n(i) {
2081
2077
  if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
2082
2078
  }
@@ -2202,7 +2198,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2202
2198
  }, n.getTypeUrl = function(t) {
2203
2199
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.VideoInfo";
2204
2200
  }, n;
2205
- }(), u.CustomInfo = function() {
2201
+ }(), a.CustomInfo = function() {
2206
2202
  function n(i) {
2207
2203
  if (this.customKeyMap = {}, i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
2208
2204
  }
@@ -2309,17 +2305,17 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2309
2305
  }, n.getTypeUrl = function(t) {
2310
2306
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.CustomInfo";
2311
2307
  }, n;
2312
- }(), u.LayoutType = function() {
2308
+ }(), a.LayoutType = function() {
2313
2309
  const n = {}, r = Object.create(n);
2314
2310
  return r[n[0] = "AudioAndVideo"] = 0, r[n[1] = "OnlyAudio"] = 1, r[n[2] = "OnlyVideo"] = 2, r;
2315
- }(), u.AudioType = function() {
2311
+ }(), a.AudioType = function() {
2316
2312
  const n = {}, r = Object.create(n);
2317
2313
  return r[n[0] = "Microphone"] = 0, r[n[1] = "SystemVoice"] = 1, r;
2318
- }(), u.VideoType = function() {
2314
+ }(), a.VideoType = function() {
2319
2315
  const n = {}, r = Object.create(n);
2320
2316
  return r[n[0] = "Camera"] = 0, r[n[1] = "Screen"] = 1, r;
2321
- }(), u;
2322
- }(), a;
2317
+ }(), a;
2318
+ }(), u;
2323
2319
  }(), o;
2324
2320
  }(), h;
2325
2321
  })(), createAudioInfo = () => ({
@@ -2356,11 +2352,11 @@ class RoomUser {
2356
2352
  });
2357
2353
  m(this, "init", (o) => {
2358
2354
  var t, e, s, l;
2359
- const { id: a, audios: u = [], videos: n = [] } = o;
2360
- this.userId = a;
2355
+ const { id: u, audios: a = [], videos: n = [] } = o;
2356
+ this.userId = u;
2361
2357
  const r = this.getUpdateTimeKey();
2362
2358
  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);
2363
- for (const c of u) {
2359
+ for (const c of a) {
2364
2360
  const { type: d = 0, isEnable: p = !1, isMute: f = !1, updateTime: w, volume: b = 0 } = c;
2365
2361
  switch (d) {
2366
2362
  case 0:
@@ -2399,26 +2395,26 @@ class RoomUser {
2399
2395
  r !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
2400
2396
  });
2401
2397
  m(this, "destroy", () => {
2402
- var o, a;
2403
- (o = this.mc_video) != null && o.destroy && this.mc_video.destroy(), (a = this.ss_video) != null && a.destroy && this.ss_video.destroy(), this.mc_audio = void 0, this.mc_video = void 0, this.ss_audio = void 0, this.ss_video = void 0;
2398
+ var o, u;
2399
+ (o = this.mc_video) != null && o.destroy && this.mc_video.destroy(), (u = this.ss_video) != null && u.destroy && this.ss_video.destroy(), this.mc_audio = void 0, this.mc_video = void 0, this.ss_audio = void 0, this.ss_video = void 0;
2404
2400
  });
2405
2401
  }
2406
2402
  }
2407
2403
  const parseSEI = (h) => {
2408
- let o = 0, a = 0;
2404
+ let o = 0, u = 0;
2409
2405
  for (; ; ) {
2410
2406
  const n = h[o];
2411
- if (a = a + n, o = o + 1, n !== 255) break;
2407
+ if (u = u + n, o = o + 1, n !== 255) break;
2412
2408
  }
2413
- let u = 0;
2409
+ let a = 0;
2414
2410
  for (; ; ) {
2415
2411
  const n = h[o];
2416
- if (u = u + n, o = o + 1, n !== 255) break;
2412
+ if (a = a + n, o = o + 1, n !== 255) break;
2417
2413
  }
2418
- if (a === 5) {
2414
+ if (u === 5) {
2419
2415
  const n = h.slice(o, o + 16), i = Array.from(n, (f) => f.toString(16).padStart(2, "0")).join("");
2420
2416
  o = o + 16;
2421
- const t = u - 16, e = h.slice(o, o + t), s = com.quick.voice.proto.SeiData.decode(e), { event: l = 0 } = s, c = s.data;
2417
+ const t = a - 16, e = h.slice(o, o + t), s = com.quick.voice.proto.SeiData.decode(e), { event: l = 0 } = s, c = s.data;
2422
2418
  let d;
2423
2419
  switch (l) {
2424
2420
  case 0:
@@ -2463,47 +2459,44 @@ class QuickVoPlayer {
2463
2459
  m(this, "getStream", () => this.prPlayer.getStream());
2464
2460
  m(this, "getAllUseUpdateKey", () => {
2465
2461
  const o = [...this.usersMap.values()];
2466
- return Array.from(o, (u) => u.updateTime).join("_");
2462
+ return Array.from(o, (a) => a.updateTime).join("_");
2467
2463
  });
2468
- m(this, "checkAndCreateUser", (o, a) => {
2469
- var u, n;
2470
- if (this.usersMap.has(o)) {
2471
- const r = this.usersMap.get(o);
2472
- if (r == null || r.init(a), r != null && r.mc_video) {
2473
- const { sx: i, sy: t, sw: e, sh: s } = r.mc_video;
2474
- (u = r == null ? void 0 : r.mc_video.worker) == null || u.setCut({ sx: i, sy: t, sw: e, sh: s });
2464
+ m(this, "checkAndCreateUser", (o, u) => {
2465
+ var n, r;
2466
+ !this.usersMap.has(o) && this.usersMap.set(o, new RoomUser());
2467
+ const a = this.usersMap.get(o);
2468
+ if (a) {
2469
+ if (a.init(u), a.mc_video && a.mc_video.worker === void 0) {
2470
+ const { sx: i, sy: t, sw: e, sh: s } = a.mc_video, l = `${a.userId}_mc_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2471
+ a.mc_video.worker = c, this.displayMode === "original" && c.setPause(!0), a.mc_video.stream = d, a.mc_video.destroy = () => {
2472
+ p(), this.prPlayer.cut.remove(l), a.mc_video = void 0;
2473
+ };
2475
2474
  }
2476
- if (r != null && r.ss_video) {
2477
- const { sx: i, sy: t, sw: e, sh: s } = r.ss_video;
2478
- (n = r == null ? void 0 : r.ss_video.worker) == null || n.setCut({ sx: i, sy: t, sw: e, sh: s });
2475
+ if (a.ss_video && a.ss_video.worker === void 0) {
2476
+ const { sx: i, sy: t, sw: e, sh: s } = a.ss_video, l = `${a.userId}_ss_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2477
+ a.ss_video.worker = c, this.displayMode === "original" && c.setPause(!0), a.ss_video.stream = d, a.ss_video.destroy = () => {
2478
+ p(), this.prPlayer.cut.remove(l), a.ss_video = void 0;
2479
+ };
2479
2480
  }
2480
- } else {
2481
- const r = new RoomUser();
2482
- if (this.usersMap.set(o, r), r.init(a), r) {
2483
- if (r.mc_video) {
2484
- const { sx: i, sy: t, sw: e, sh: s } = r.mc_video, l = `${r.userId}_mc_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2485
- r.mc_video.worker = c, this.displayMode === "original" && c.setPause(!0), r.mc_video.stream = d, r.mc_video.destroy = () => {
2486
- p(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2487
- };
2488
- }
2489
- if (r.ss_video) {
2490
- const { sx: i, sy: t, sw: e, sh: s } = r.ss_video, l = `${r.userId}_ss_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2491
- r.ss_video.worker = c, this.displayMode === "original" && c.setPause(!0), r.ss_video.stream = d, r.ss_video.destroy = () => {
2492
- p(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2493
- };
2494
- }
2481
+ if (a != null && a.mc_video) {
2482
+ const { sx: i, sy: t, sw: e, sh: s } = a.mc_video;
2483
+ (n = a == null ? void 0 : a.mc_video.worker) == null || n.setCut({ sx: i, sy: t, sw: e, sh: s });
2484
+ }
2485
+ if (a != null && a.ss_video) {
2486
+ const { sx: i, sy: t, sw: e, sh: s } = a.ss_video;
2487
+ (r = a == null ? void 0 : a.ss_video.worker) == null || r.setCut({ sx: i, sy: t, sw: e, sh: s });
2495
2488
  }
2496
2489
  }
2497
2490
  });
2498
2491
  m(this, "setDisplayMode", (o) => {
2499
- var a, u, n, r, i, t, e, s;
2492
+ var u, a, n, r, i, t, e, s;
2500
2493
  switch (this.displayMode = o, o) {
2501
2494
  case "original":
2502
2495
  {
2503
2496
  this.prPlayer.setPause(!1);
2504
2497
  const l = [...this.usersMap.values()];
2505
2498
  for (const c of l)
2506
- (u = (a = c.mc_video) == null ? void 0 : a.worker) == null || u.setPause(!0), (r = (n = c.ss_video) == null ? void 0 : n.worker) == null || r.setPause(!0);
2499
+ (a = (u = c.mc_video) == null ? void 0 : u.worker) == null || a.setPause(!0), (r = (n = c.ss_video) == null ? void 0 : n.worker) == null || r.setPause(!0);
2507
2500
  }
2508
2501
  break;
2509
2502
  case "cut":
@@ -2521,10 +2514,10 @@ class QuickVoPlayer {
2521
2514
  */
2522
2515
  m(this, "onSEI", (o) => {
2523
2516
  try {
2524
- const a = parseSEI(o);
2525
- if (!a) return;
2526
- const { event: u, data: n } = a;
2527
- switch (u) {
2517
+ const u = parseSEI(o);
2518
+ if (!u) return;
2519
+ const { event: a, data: n } = u;
2520
+ switch (a) {
2528
2521
  case 0:
2529
2522
  {
2530
2523
  const { roomId: r, userMap: i } = n;
@@ -2533,7 +2526,7 @@ class QuickVoPlayer {
2533
2526
  {
2534
2527
  const l = [...this.usersMap.values()];
2535
2528
  for (const c of l)
2536
- e.includes(c.userId) || c == null || c.destroy();
2529
+ e.includes(c.userId) || (c == null || c.destroy(), this.usersMap.delete(c.userId));
2537
2530
  }
2538
2531
  for (const l of e) {
2539
2532
  const c = i[l];
@@ -2553,15 +2546,15 @@ class QuickVoPlayer {
2553
2546
  }
2554
2547
  break;
2555
2548
  }
2556
- } catch (a) {
2557
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", a);
2549
+ } catch (u) {
2550
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", u);
2558
2551
  }
2559
2552
  });
2560
2553
  m(this, "onAnalysis", (o) => {
2561
2554
  this.on.analysis && this.on.analysis(o);
2562
2555
  });
2563
- const { debug: a = !1 } = o;
2564
- this.option.debug = a, this.prPlayer = new et({ debug: a }), this.prPlayer.on.demuxer.chunk = (u) => {
2556
+ const { debug: u = !1 } = o;
2557
+ this.option.debug = u, this.prPlayer = new et({ debug: u }), this.prPlayer.on.demuxer.chunk = (a) => {
2565
2558
  }, this.prPlayer.on.decoder.sei = this.onSEI, this.prPlayer.on.decoder.analysis = this.onAnalysis;
2566
2559
  }
2567
2560
  }