diff --git a/.gitignore b/.gitignore index 49b38a2..46002b9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ coverage .nyc_output .DS_Store *.log -.vscode .idea dist compiled diff --git a/README.md b/README.md index e23e918..5c00043 100644 --- a/README.md +++ b/README.md @@ -270,7 +270,7 @@ themeData将主题数据本地化,设置本地数据,需要删除template参 languageString多语言 (zh | en), 默认zh (v8.0.8版本及以上支持)N debugDownloadDataboolean下载原始码流, 调试码流使用, 默认 false (v8.1.1版本及以上支持)N disableRenderPrivateDataboolean禁止渲染私有数据(如智能分析, 移动侦测, 火点信息等), 默认 false (v8.1.1版本及以上支持)N -quality0 | 1 | 2 | 3 | 4 | 5 | 6 | pp | qp预览初始化支持指定清晰度进行播放, 默认 undefined (v8.1.5版本及以上支持), 0: 流畅; 1: 标清; 2: 高清; 3: 超清; 4: 极清; 5: 3K; 6: 4K ; "pp": "性能优先 (Performance Priority)"; "qp": "画质优先(Quality Priority)"。N +quality0 | 1 | 2 | 3 | 4 | 5 | 6 | pp | qp预览初始化支持指定清晰度进行播放, 默认 undefined (v8.1.5版本及以上支持), 0: 流畅; 1: 标清; 2: 高清; 3: 超清; 4: 极清; 5: 3K; 6: 4K ; "pp": "性能优先 (Performance Priority)"; "qp": "画质优先(Quality Priority)"。 如果没有命中,默认取上次的设置N loggerOptions {name: string, level: "INFO" | "LOG" | "WARN" | "ERROR" , showTime: boolean}本地日志设置, 默认值 {name: "ezuikit", level: "INFO", showTime: true}, 支持动态设置请参考 setLoggerOptions(options) (v8.1.9版本及以上支持)N streamInfoCBType 0 | 1 流信息回调类型,监听 streamInfoCB 事件, 0 : 每次都回调(会影响性能), 1 : 只回调一次, 默认值 1 (v8.1.9版本及以上支持)N diff --git a/demos/base-demo/ezuikit.js b/demos/base-demo/ezuikit.js index 45a90e8..d30a5a6 100644 --- a/demos/base-demo/ezuikit.js +++ b/demos/base-demo/ezuikit.js @@ -1,7 +1,7 @@ /* -* ezuikit.js v8.1.12 +* ezuikit.js v8.1.12-beta.2 * ezuikit javascript for npm -* Copyright (c) 2025-07-02 Ezviz-OpenBiz +* Copyright (c) 2025-07-10 Ezviz-OpenBiz * Released under the MIT License. */ !function(e,A){"object"==typeof exports&&"undefined"!=typeof module?module.exports=A():"function"==typeof define&&define.amd?define(A):(e="undefined"!=typeof globalThis?globalThis:e||self).EZUIKit=A()}(this,(function(){"use strict";function e(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}Date.prototype.Format=function(e){var A={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};for(var t in/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),A)new RegExp("("+t+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?A[t]:("00"+A[t]).substr((""+A[t]).length)));return e};var A=function(e,A,t,i){var n=document.getElementsByTagName("head")[0].getElementsByTagName("script"),a=!1;if(t)a=t();else for(var r=0;r3){var t=A[1],i=A[2],n="1"===A[3],a="live";return e.indexOf("rec=local")>-1?a="rec":e.indexOf("rec=cloud")>-1&&(a="cloud.rec"),{deviceSerial:t,channelNo:i,hd:n,type:a}}return{}};var c=function(A,t,i,n,a,r){var o=A,s=new XMLHttpRequest;s.onreadystatechange=function(){if(4==s.readyState&&200==s.status)if(function(A){if("string"==typeof A)try{var t=JSON.parse(A);return!("object"!==(void 0===t?"undefined":e(t))||!t)}catch(e){return!1}}(s.responseText)){var A=JSON.parse(s.responseText);a(A)}else a(s.responseText)},s.open(t,o,!0);var g=new FormData;for(var l in i)g.append(l,i[l]);if(n&&"object"===(void 0===n?"undefined":e(n)))for(var l in n)s.setRequestHeader(l,n[l]);s.send(g)},d=function(){return!!window&&navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone|Opera Mini)/i)},I=function(){function e(e,t){var i=this;A("https://open.ys7.com/assets/ezuikit_v3.4/js/hls.js",(function(){window.Hls.isSupported()&&i.initHLS(e,t)}),(function(){return!!window.Hls}))}var t=e.prototype;return t.toString=function(){return"hls "+this.coreX+"-"+this.coreY},t.initHLS=function(e,A){var t=l(A);t.deviceSerial,t.channelNo,t.hd;var i=document.getElementById(e),n=new window.Hls({defaultAudioCodec:"mp4a.40.2"});n.loadSource(A),n.attachMedia(i),n.on(window.Hls.Events.MANIFEST_PARSED,(function(){i.play()})),n.on(window.Hls.Events.ERROR,(function(e,A){if(A.fatal)switch(A.type){case window.Hls.ErrorTypes.NETWORK_ERROR:n.startLoad();break;case window.Hls.ErrorTypes.MEDIA_ERROR:n.recoverMediaError();break;default:n.destroy()}})),this.hls=n,this.video=i,this.hlsUrl=A},t.play=function(){this.hls.startLoad(),this.video.play()},t.stop=function(){this.video.pause(),this.hls.stopLoad()},e}(),C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,B={exports:{}};var f=(u||(u=1,function(e,A){function t(e,A){return null!=A&&"undefined"!=typeof Symbol&&A[Symbol.hasInstance]?!!A[Symbol.hasInstance](e):e instanceof A}function i(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}!function(t,n){"object"==i(A)&&"object"==i(e)?e.exports=n():"object"==i(A)?A.flvjs=n():t.flvjs=n()}(globalThis,(function(){return function(){var e={343:function(e){var A=function(){},t=function(e,A,t){this.fn=e,this.context=A,this.once=t||!1},i=function(e,A,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var r=new t(i,n||e,a),s=o?o+A:A;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],r]:e._events[s].push(r):(e._events[s]=r,e._eventsCount++),e},n=function(e,t){0==--e._eventsCount?e._events=new A:delete e._events[t]},a=function(){this._events=new A,this._eventsCount=0},r=Object.prototype.hasOwnProperty,o="~";Object.create&&(A.prototype=Object.create(null),(new A).__proto__||(o=!1)),a.prototype.eventNames=function(){var e,A,t=[];if(0===this._eventsCount)return t;for(A in e=this._events)r.call(e,A)&&t.push(o?A.slice(1):A);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t},a.prototype.listeners=function(e){var A=o?o+e:e,t=this._events[A];if(!t)return[];if(t.fn)return[t.fn];for(var i=0,n=t.length,a=new Array(n);i=e[n]&&A0&&e[0].originalDts=A[n].dts&&e((null===(A=t[n].lastSample)||void 0===A?void 0:A.originalDts)||0)&&e=((null===(t=null===(A=i[a])||void 0===A?void 0:A.lastSample)||void 0===t?void 0:t.originalDts)||0)&&(a===i.length-1||a0&&(r=this._searchNearestSegmentBefore(n.originalBeginDts)+1),this._lastAppendLocation=r,this._list.splice(r,0,n)},e.prototype.getLastSegmentBefore=function(e){var A=this._searchNearestSegmentBefore(e);return A>=0?this._list[A]:null},e.prototype.getLastSampleBefore=function(e){var A=this.getLastSegmentBefore(e);return null!=A?A.lastSample:null},e.prototype.getLastSyncPointBefore=function(e){for(var A=this._searchNearestSegmentBefore(e),t=this._list[A].syncPoints;0===t.length&&A>0;)A--,t=this._list[A].syncPoints;return t.length>0?t[t.length-1]:null},e}()},976:function(e,A,n){var a=function(e,A,t){var i=e;if(A+t=128){A.push(String.fromCharCode(65535&r)),i+=2;continue}}else if(t[i]<240){if(a(t,i,2)&&(r=(15&t[i])<<12|(63&t[i+1])<<6|63&t[i+2])>=2048&&55296!=(63488&r)){A.push(String.fromCharCode(65535&r)),i+=3;continue}}else if(t[i]<248){var r;if(a(t,i,3)&&(r=(7&t[i])<<18|(63&t[i+1])<<12|(63&t[i+2])<<6|63&t[i+3])>65536&&r<1114112){r-=65536,A.push(String.fromCharCode(r>>>10|55296)),A.push(String.fromCharCode(1023&r|56320)),i+=4;continue}}A.push(String.fromCharCode(65533)),++i}return A.join("")},u=n(713),B=(g=new ArrayBuffer(2),new DataView(g).setInt16(0,256,!0),256===new Int16Array(g)[0]),f=function(){function e(){}return e.parseScriptData=function(A,t,i){var n={};try{var a=e.parseValue(A,t,i),r=e.parseValue(A,t+a.size,i-a.size);n[a.data]=r.data}catch(e){d.A.e("AMF",e.toString())}return n},e.parseObject=function(A,t,i){if(i<3)throw new u.j4("Data not enough when parse ScriptDataObject");var n=e.parseString(A,t,i),a=e.parseValue(A,t+n.size,i-n.size),r=a.objectEnd;return{data:{name:n.data,value:a.data},size:n.size+a.size,objectEnd:r}},e.parseVariable=function(A,t,i){return e.parseObject(A,t,i)},e.parseString=function(e,A,t){if(t<2)throw new u.j4("Data not enough when parse String");var i=new DataView(e,A,t).getUint16(0,!B);return{data:i>0?h(new Uint8Array(e,A+2,i)):"",size:2+i}},e.parseLongString=function(e,A,t){if(t<4)throw new u.j4("Data not enough when parse LongString");var i=new DataView(e,A,t).getUint32(0,!B);return{data:i>0?h(new Uint8Array(e,A+4,i)):"",size:4+i}},e.parseDate=function(e,A,t){if(t<10)throw new u.j4("Data size invalid when parse Date");var i=new DataView(e,A,t),n=i.getFloat64(0,!B),a=i.getInt16(8,!B);return{data:new Date(n+=60*a*1e3),size:10}},e.parseValue=function(A,t,i){if(i<1)throw new u.j4("Data not enough when parse Value");var n,a=new DataView(A,t,i),r=1,o=a.getUint8(0),s=!1;try{switch(o){case 0:n=a.getFloat64(1,!B),r+=8;break;case 1:n=!!a.getUint8(1),r+=1;break;case 2:var g=e.parseString(A,t+1,i-1);n=g.data,r+=g.size;break;case 3:n={};var l=0;for(9==(16777215&a.getUint32(i-4,!B))&&(l=3);r32)throw new u.Qn("ExpGolomb: readBits() bits exceeded max 32bits!");if(e<=this._current_word_bits_left){var A=this._current_word>>>32-e;return this._current_word<<=e,this._current_word_bits_left-=e,A}var t=this._current_word_bits_left?this._current_word:0;t>>>=32-this._current_word_bits_left;var i=e-this._current_word_bits_left;this._fillCurrentWord();var n=Math.min(i,this._current_word_bits_left),a=this._current_word>>>32-n;return this._current_word<<=n,this._current_word_bits_left-=n,t<>>e)return this._current_word<<=e,this._current_word_bits_left-=e,e;return this._fillCurrentWord(),e+this._skipLeadingZero()},e.prototype.readUEG=function(){var e=this._skipLeadingZero();return this.readBits(e+1)-1},e.prototype.readSEG=function(){var e=this.readUEG();return 1&e?e+1>>>1:-1*(e>>>1)},e}(),x=function(){function e(){}return e._ebsp2rbsp=function(e){for(var A=e,t=A.byteLength,i=new Uint8Array(t),n=0,a=0;a=2&&3===A[a]&&0===A[a-1]&&0===A[a-2]||(i[n]=A[a],n++);return new Uint8Array(i.buffer,0,n)},e.parseSPS=function(A){for(var t=A.subarray(1,4),i="avc1.",n=0;n<3;n++){var a=t[n].toString(16);a.length<2&&(a="0"+a),i+=a}var r=e._ebsp2rbsp(A),o=new E(r);o.readByte();var s=o.readByte();o.readByte();var g=o.readByte();o.readUEG();var l=e.getProfileString(s),c=e.getLevelString(g),d=1,I=420,C=8,h=8;if((100===s||110===s||122===s||244===s||44===s||83===s||86===s||118===s||128===s||138===s||144===s)&&(3===(d=o.readUEG())&&o.readBits(1),d<=3&&(I=[0,420,422,444][d]),C=o.readUEG()+8,h=o.readUEG()+8,o.readBits(1),o.readBool()))for(var u=3!==d?8:12,B=0;B0&&T<16?(w=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][T-1],b=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][T-1]):255===T&&(w=o.readByte()<<8|o.readByte(),b=o.readByte()<<8|o.readByte())}if(o.readBool()&&o.readBool(),o.readBool()&&(o.readBits(4),o.readBool()&&o.readBits(24)),o.readBool()&&(o.readUEG(),o.readUEG()),o.readBool()){var N=o.readBits(32),M=o.readBits(32);R=o.readBool(),F=(k=M)/(P=2*N)}}var L=1;1===w&&1===b||(L=w/b);var G=0,Y=0;0===d?(G=1,Y=2-y):(G=3===d?1:2,Y=(1===d?2:1)*(2-y));var U=16*(p+1),J=16*(m+1)*(2-y);U-=(_+S)*G,J-=(v+D)*Y;var H=Math.ceil(U*L);return o.destroy(),o=null,{codec_mimetype:i,profile_idc:s,level_idc:g,profile_string:l,level_string:c,chroma_format_idc:d,bit_depth:C,bit_depth_luma:C,bit_depth_chroma:h,ref_frames:Q,chroma_format:I,chroma_format_string:e.getChromaFormatString(I),frame_rate:{fixed:R,fps:F,fps_den:P,fps_num:k},sar_ratio:{width:w,height:b},codec_size:{width:U,height:J},present_size:{width:H,height:J}}},e._skipScalingList=function(e,A){for(var t=8,i=8,n=0;n=2&&3===A[a]&&0===A[a-1]&&0===A[a-2]||(i[n]=A[a],n++);return new Uint8Array(i.buffer,0,n)},e.parseVPS=function(A){var t=e._ebsp2rbsp(A),i=new E(t);return i.readByte(),i.readByte(),i.readBits(4),i.readBits(2),i.readBits(6),{num_temporal_layers:i.readBits(3)+1,temporal_id_nested:i.readBool()}},e.parseSPS=function(A){var t=e._ebsp2rbsp(A),i=new E(t);i.readByte(),i.readByte();for(var n=0,a=0,r=0,o=0,s=(i.readBits(4),i.readBits(3)),g=(i.readBool(),i.readBits(2)),l=i.readBool(),c=i.readBits(5),d=i.readByte(),I=i.readByte(),C=i.readByte(),h=i.readByte(),u=i.readByte(),B=i.readByte(),f=i.readByte(),x=i.readByte(),Q=i.readByte(),p=i.readByte(),m=i.readByte(),y=[],_=[],S=0;S0)for(S=s;S<8;S++)i.readBits(2);for(S=0;S1&&i.readSEG(),S=0;S0&&z<=16?(j=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][z-1],W=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][z-1]):255===z&&(j=i.readBits(16),W=i.readBits(16))}if(i.readBool()&&i.readBool(),i.readBool()&&(i.readBits(3),i.readBool(),i.readBool()&&(i.readByte(),i.readByte(),i.readByte())),i.readBool()&&(i.readUEG(),i.readUEG()),i.readBool(),i.readBool(),i.readBool(),i.readBool()&&(i.readUEG(),i.readUEG(),i.readUEG(),i.readUEG()),i.readBool()&&(X=i.readBits(32),q=i.readBits(32),i.readBool()&&i.readUEG(),i.readBool())){var $,ee,Ae=!1;for($=i.readBool(),ee=i.readBool(),($||ee)&&((Ae=i.readBool())&&(i.readByte(),i.readBits(5),i.readBool(),i.readBits(5)),i.readBits(4),i.readBits(4),Ae&&i.readBits(4),i.readBits(5),i.readBits(5),i.readBits(5)),S=0;S<=s;S++){var te=i.readBool();Z=te;var ie=!1,ne=1;te||(ie=i.readBool());var ae=!1;if(ie?i.readSEG():ae=i.readBool(),ae||(ne=i.readUEG()+1),$)for(Y=0;Y>3,a=!!(4&A[i]),r=!!(2&A[i]);A[i],i+=1,a&&(i+=1);var o=Number.POSITIVE_INFINITY;if(r){o=0;for(var s=0;o|=(127&A[i])<<7*s,128&A[i+=1];s++);}1===n&&(t=e.parseSeuqneceHeader(A.subarray(i,i+o))),i+=o}return t},e.parseSeuqneceHeader=function(A){var t=new E(A),i=t.readBits(3),n=(t.readBool(),t.readBool()),a=!0,r=0,o=0,s=[];if(n)s.push({operating_point_idc:0,level:t.readBits(5),tier:0});else{if(t.readBool()){var g=t.readBits(32),l=t.readBits(32),c=t.readBool();if(c){for(var d=0;0===t.readBits(1);)d+=1;d>=32||t.readBits(d)}r=l,o=g,a=c,t.readBool()&&(t.readBits(5),t.readBits(32),t.readBits(5),t.readBits(5))}for(var I=t.readBool(),C=t.readBits(5),h=0;h<=C;h++){var u=t.readBits(12),B=t.readBits(5),f=B>7?t.readBits(1):0;s.push({operating_point_idc:u,level:B,tier:f}),I&&t.readBool()&&t.readBits(4)}}var x=s[0],Q=x.level,p=x.tier,m=t.readBits(4),y=t.readBits(4),_=t.readBits(m+1)+1,S=t.readBits(y+1)+1,v=!1;n||(v=t.readBool()),v&&(t.readBits(4),t.readBits(4)),t.readBool(),t.readBool(),t.readBool();var D=!1;n||(t.readBool(),t.readBool(),t.readBool(),t.readBool(),(D=t.readBool())&&(t.readBool(),t.readBool()),(t.readBool()||t.readBits(1))&&(t.readBool()||t.readBits(1)),D&&t.readBits(3)),t.readBool(),t.readBool(),t.readBool();var w=t.readBool(),b=8;b=2===i&&w?t.readBool()?12:10:w?10:8;var F=!1;1!==i&&(F=t.readBool()),t.readBool()&&(t.readBits(8),t.readBits(8),t.readBits(8));var R=1,k=1;return F?(t.readBits(1),R=1,k=1):(t.readBits(1),0===i?(R=1,k=1):1===i?(R=0,k=0):12===b?t.readBits(1)&&t.readBits(1):(R=1,k=0),R&&k&&t.readBits(2),t.readBits(1)),t.readBool(),t.destroy(),t=null,{codec_mimetype:"av01.".concat(i,".").concat(e.getLevelString(Q,p),".").concat(b.toString(10).padStart(2,"0")),level:Q,tier:p,level_string:e.getLevelString(Q,p),profile_idc:i,profile_string:"".concat(i),bit_depth:b,ref_frames:1,chroma_format:e.getChromaFormat(F,R,k),chroma_format_string:e.getChromaFormatString(F,R,k),frame_rate:{fixed:a,fps:r/o,fps_den:o,fps_num:r},sar_ratio:{width:1,height:1},codec_size:{width:_,height:S},present_size:{width:1*_,height:S}}},e.getLevelString=function(e,A){return"".concat(e.toString(10).padStart(2,"0")).concat(0===A?"M":"H")},e.getChromaFormat=function(e,A,t){return e?0:0===A&&0===t?3:1===A&&0===t?2:1===A&&1===t?1:Number.NaN},e.getChromaFormatString=function(e,A,t){return e?"4:0:0":0===A&&0===t?"4:4:4":1===A&&0===t?"4:2:2":1===A&&1===t?"4:2:0":"Unknown"},e}(),_=function(){function e(e,A){var t;this.TAG="FLVDemuxer",this._config=A,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=e.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=e.hasAudioTrack,this._hasVideo=e.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new C.A,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=(t=new ArrayBuffer(2),new DataView(t).setInt16(0,256,!0),256===new Int16Array(t)[0])}return e.prototype.destroy=function(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null},e.probe=function(e){var A=new Uint8Array(e);if(A.byteLength<9)return{needMoreData:!0};var t={match:!1};if(70!==A[0]||76!==A[1]||86!==A[2]||1!==A[3])return t;var i,n=(4&A[4])>>>2!=0,a=!!(1&A[4]),r=(i=A)[5]<<24|i[6]<<16|i[7]<<8|i[8];return r<9?t:{match:!0,consumed:r,dataOffset:r,hasAudioTrack:n,hasVideoTrack:a}},e.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},Object.defineProperty(e.prototype,"onTrackMetadata",{get:function(){return this._onTrackMetadata},set:function(e){this._onTrackMetadata=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaInfo",{get:function(){return this._onMediaInfo},set:function(e){this._onMediaInfo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMetaDataArrived",{get:function(){return this._onMetaDataArrived},set:function(e){this._onMetaDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onScriptDataArrived",{get:function(){return this._onScriptDataArrived},set:function(e){this._onScriptDataArrived=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataAvailable",{get:function(){return this._onDataAvailable},set:function(e){this._onDataAvailable=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"timestampBase",{get:function(){return this._timestampBase},set:function(e){this._timestampBase=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedDuration",{get:function(){return this._duration},set:function(e){this._durationOverrided=!0,this._duration=e,this._mediaInfo&&(this._mediaInfo.duration=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasAudio",{set:function(e){this._hasAudioFlagOverrided=!0,this._hasAudio=e,this._mediaInfo&&(this._mediaInfo.hasAudio=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"overridedHasVideo",{set:function(e){this._hasVideoFlagOverrided=!0,this._hasVideo=e,this._mediaInfo&&(this._mediaInfo.hasVideo=e)},enumerable:!1,configurable:!0}),e.prototype.resetMediaInfo=function(){this._mediaInfo=new C.A},e.prototype._isInitialMetadataDispatched=function(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!(this._hasAudio||!this._hasVideo)&&this._videoInitialMetadataDispatched},e.prototype.parseChunks=function(A,t){var i,n;if(!(this._onError&&this._onMediaInfo&&this._onTrackMetadata&&this._onDataAvailable))throw new u.j4("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var a=0,r=this._littleEndian;if(0===t){if(!(A.byteLength>13))return 0;var o=e.probe(A);a=(null==o?void 0:o.dataOffset)||0}for(this._firstParse&&(this._firstParse=!1,t+a!==this._dataOffset&&d.A.w(this.TAG,"First time parsing but chunk byteStart invalid!"),0!==(s=new DataView(A,a)).getUint32(0,!r)&&d.A.w(this.TAG,"PrevTagSize0 !== 0 !!!"),a+=4);aA.byteLength)break;var g=s.getUint8(0),l=16777215&s.getUint32(0,!r);if(a+11+l+4>A.byteLength)break;if(8===g||9===g||18===g){var c=s.getUint8(4),I=s.getUint8(5),C=s.getUint8(6)|I<<8|c<<16|s.getUint8(7)<<24;16777215&s.getUint32(7,!r)&&d.A.w(this.TAG,"Meet tag which has StreamID != 0!");var h=a+11;switch(g){case 8:this._parseAudioData(A,h,l,C);break;case 9:this._parseVideoData(A,h,l,C,t+a);break;case 18:this._parseScriptData(A,h,l)}var B=s.getUint32(11+l,!r);B!==11+l&&d.A.w(this.TAG,"Invalid PrevTagSize ".concat(B)),a+=11+l+4}else d.A.w(this.TAG,"Unsupported tag type ".concat(g,", skipped")),a+=11+l+4}return this._isInitialMetadataDispatched()&&this._dispatch&&((null===(i=this._audioTrack)||void 0===i?void 0:i.length)||(null===(n=this._videoTrack)||void 0===n?void 0:n.length))&&this._onDataAvailable(this._audioTrack,this._videoTrack),a},e.prototype._parseScriptData=function(e,A,t){var n,a,r,o=f.parseScriptData(e,A,t);if(o.hasOwnProperty("onMetaData")){if(null==o.onMetaData||"object"!=i(o.onMetaData))return void d.A.w(this.TAG,"Invalid onMetaData structure!");this._metadata&&d.A.w(this.TAG,"Found another onMetaData tag!"),this._metadata=o;var s=null===(n=this._metadata)||void 0===n?void 0:n.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},s)),"boolean"==typeof(null==s?void 0:s.hasAudio)&&(this._hasAudioFlagOverrided||(this._hasAudio=s.hasAudio,this._mediaInfo&&(this._mediaInfo.hasAudio=this._hasAudio))),"boolean"==typeof(null==s?void 0:s.hasVideo)&&(this._hasVideoFlagOverrided||(this._hasVideo=s.hasVideo,this._mediaInfo&&(this._mediaInfo.hasVideo=this._hasVideo))),"number"==typeof(null==s?void 0:s.audiodatarate)&&this._mediaInfo&&(this._mediaInfo.audioDataRate=s.audiodatarate),"number"==typeof(null==s?void 0:s.videodatarate)&&this._mediaInfo&&(this._mediaInfo.videoDataRate=s.videodatarate),"number"==typeof(null==s?void 0:s.width)&&this._mediaInfo&&(this._mediaInfo.width=s.width),"number"==typeof(null==s?void 0:s.height)&&this._mediaInfo&&(this._mediaInfo.height=s.height),"number"==typeof(null==s?void 0:s.duration)){if(!this._durationOverrided){var g=Math.floor(s.duration*this._timescale);this._duration=g,this._mediaInfo&&(this._mediaInfo.duration=g)}}else this._mediaInfo&&(this._mediaInfo.duration=0);if("number"==typeof(null==s?void 0:s.framerate)){var l=Math.floor(1e3*s.framerate);if(l>0){var c=l/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=c,this._referenceFrameRate.fps_num=l,this._referenceFrameRate.fps_den=1e3,this._mediaInfo&&(this._mediaInfo.fps=c)}}if("object"==i(null==s?void 0:s.keyframes)){this._mediaInfo&&(this._mediaInfo.hasKeyframesIndex=!0);var I=s.keyframes;this._mediaInfo&&(this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(I)),s.keyframes=null}else this._mediaInfo&&(this._mediaInfo.hasKeyframesIndex=!1);this._dispatch=!1,this._mediaInfo&&(this._mediaInfo.metadata=s),d.A.v(this.TAG,"Parsed onMetaData"),(null===(a=this._mediaInfo)||void 0===a?void 0:a.isComplete())&&(null===(r=this._onMediaInfo)||void 0===r||r.call(this,this._mediaInfo))}Object.keys(o).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},o))},e.prototype._parseKeyframesIndex=function(e){for(var A=[],t=[],i=1;i>>4;if(2===u||10===u){var B=0,f=(12&h)>>>2;if(f>=0&&f<=4){B=this._flvSoundRateTable[f];var E=1&h,x=this._audioMetadata,p=this._audioTrack;if(x||(!1!==this._hasAudio||this._hasAudioFlagOverrided||(this._hasAudio=!0,this._mediaInfo&&(this._mediaInfo.hasAudio=!0)),(x=this._audioMetadata={}).type="audio",x.id=null==p?void 0:p.id,x.timescale=this._timescale,x.duration=this._duration,x.audioSampleRate=B,x.channelCount=0===E?1:2),10===u){var y=this._parseAACAudioData(e,A+1,t-1);if(void 0===y)return;if(0===(null==y?void 0:y.packetType)){if(null==x?void 0:x.config){if(m(y.data.config,null==x?void 0:x.config))return;d.A.w(this.TAG,"AudioSpecificConfig has been changed, re-generate initialization segment")}var _=y.data;x.audioSampleRate=null==_?void 0:_.samplingRate,x.channelCount=null==_?void 0:_.channelCount,x.codec=null==_?void 0:_.codec,x.originalCodec=null==_?void 0:_.originalCodec,x.config=null==_?void 0:_.config,x.refSampleDuration=1024/x.audioSampleRate*x.timescale,d.A.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&((null===(r=this._audioTrack)||void 0===r?void 0:r.length)||(null===(o=this._videoTrack)||void 0===o?void 0:o.length))&&(null===(s=this._onDataAvailable)||void 0===s||s.call(this,this._audioTrack,this._videoTrack)):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,null===(g=this._onTrackMetadata)||void 0===g||g.call(this,"audio",x),(D=this._mediaInfo).audioCodec=x.originalCodec||"",D.audioSampleRate=x.audioSampleRate,D.audioChannelCount=x.channelCount,D.hasVideo?null!=D.videoCodec&&(D.mimeType='video/x-flv; codecs="'+D.videoCodec+","+D.audioCodec+'"'):D.mimeType='video/x-flv; codecs="'+D.audioCodec+'"',(null==D?void 0:D.isComplete())&&(null===(l=this._onMediaInfo)||void 0===l||l.call(this,D))}else if(1===y.packetType){var S=this._timestampBase+i,v={unit:y.data,length:y.data.byteLength,dts:S,pts:S};p&&(null==p||p.samples.push(v),p.length+=(null===(c=null==y?void 0:y.data)||void 0===c?void 0:c.length)||0)}else d.A.e(this.TAG,"Flv: Unsupported AAC data type ".concat(y.packetType))}else if(2===u){if(!x.codec){var D;if(void 0===(_=this._parseMP3AudioData(e,A+1,t-1,!0)))return;x.audioSampleRate=_.samplingRate,x.channelCount=_.channelCount,x.codec=_.codec,x.originalCodec=_.originalCodec,x.refSampleDuration=1152/x.audioSampleRate*x.timescale,d.A.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,null===(I=this._onTrackMetadata)||void 0===I||I.call(this,"audio",x),(D=this._mediaInfo).audioCodec=x.codec,D.audioSampleRate=x.audioSampleRate,D.audioChannelCount=x.channelCount,D.audioDataRate=_.bitRate,(null==D?void 0:D.hasVideo)?null!=D.videoCodec&&(D.mimeType='video/x-flv; codecs="'+D.videoCodec+","+D.audioCodec+'"'):D.mimeType='video/x-flv; codecs="'+D.audioCodec+'"',D.isComplete()&&(null===(C=this._onMediaInfo)||void 0===C||C.call(this,D))}var w=this._parseMP3AudioData(e,A+1,t-1,!1);if(void 0===w)return;S=this._timestampBase+i;var b={unit:w,length:w.byteLength,dts:S,pts:S};null==p||p.samples.push(b),p&&(p.length+=w.length)}}else null===(a=this._onError)||void 0===a||a.call(this,Q.A.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+f)}else null===(n=this._onError)||void 0===n||n.call(this,Q.A.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+u)}},e.prototype._parseAACAudioData=function(e,A,t){if(!(t<=1)){var i={},n=new Uint8Array(e,A,t);return i.packetType=n[0],0===n[0]?i.data=this._parseAACAudioSpecificConfig(e,A+1,t-1):i.data=n.subarray(1),i}d.A.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!")},e.prototype._parseAACAudioSpecificConfig=function(e,A,t){var i,n,a,r,o=new Uint8Array(e,A,t),s=null,g=0,l=null;if(g=a=o[0]>>>3,(r=(7&o[0])<<1|o[1]>>>7)<0||r>=this._mpegSamplingRates.length)null===(i=this._onError)||void 0===i||i.call(this,Q.A.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");else{var c=this._mpegSamplingRates[r],d=(120&o[1])>>>3;if(!(d<0||d>=8)){5===g&&(l=(7&o[1])<<1|o[2]>>>7,o[2]);var I=self.navigator.userAgent.toLowerCase();return I.includes("firefox")?r>=6?(g=5,s=new Array(4),l=r-3):(g=2,s=new Array(2),l=r):I.includes("android")?(g=2,s=new Array(2),l=r):(g=5,l=r,s=new Array(4),r>=6?l=r-3:1===d&&(g=2,s=new Array(2),l=r)),s[0]=g<<3,s[0]|=(15&r)>>>1,s[1]=(15&r)<<7,s[1]|=(15&d)<<3,5===g&&(s[1]|=(15&l)>>>1,s[2]=(1&l)<<7,s[2]|=8,s[3]=0),{config:s,samplingRate:c,channelCount:d,codec:"mp4a.40."+g,originalCodec:"mp4a.40."+a}}null===(n=this._onError)||void 0===n||n.call(this,Q.A.FORMAT_ERROR,"Flv: AAC invalid channel configuration")}},e.prototype._parseMP3AudioData=function(e,A,t,i){if(!(t<4)){this._littleEndian;var n,a=new Uint8Array(e,A,t);if(i){if(255!==a[0])return;var r=a[1]>>>3&3,o=(6&a[1])>>1,s=(240&a[2])>>>4,g=(12&a[2])>>>2,l=3&~(a[3]>>>6)?2:1,c=0,I=0;switch(r){case 0:c=this._mpegAudioV25SampleRateTable[g];break;case 2:c=this._mpegAudioV20SampleRateTable[g];break;case 3:c=this._mpegAudioV10SampleRateTable[g]}switch(o){case 1:s>>4;if(128&o){var g=15&o,l=String.fromCharCode.apply(String,function(e,A,t){if(2===arguments.length)for(var i,n=0,a=A.length;n0)&&!(i=a.next()).done;)r.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}return r}(new Uint8Array(e,A,t).slice(1,5)),!1));"hvc1"===l?this._parseEnhancedHEVCVideoPacket(e,A+5,t-5,i,n,s,g):"av01"===l?this._parseEnhancedAV1VideoPacket(e,A+5,t-5,i,n,s,g):null===(r=this._onError)||void 0===r||r.call(this,Q.A.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: ".concat(l))}else{var c=15&o;7===c?this._parseAVCVideoPacket(e,A+1,t-1,i,n,s):12===c?this._parseHEVCVideoPacket(e,A+1,t-1,i,n,s):null===(a=this._onError)||void 0===a||a.call(this,Q.A.CODEC_UNSUPPORTED,"Flv: Unsupported codec in video frame: ".concat(c))}}},e.prototype._parseAVCVideoPacket=function(e,A,t,i,n,a){var r;if(t<4)d.A.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");else{var o=this._littleEndian,s=new DataView(e,A,t),g=s.getUint8(0),l=(16777215&s.getUint32(0,!o))<<8>>8;0===g?this._parseAVCDecoderConfigurationRecord(e,A+4,t-4):1===g?this._parseAVCVideoData(e,A+4,t-4,i,n,a,l):2===g||null===(r=this._onError)||void 0===r||r.call(this,Q.A.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(g))}},e.prototype._parseHEVCVideoPacket=function(e,A,t,i,n,a){var r;if(t<4)d.A.w(this.TAG,"Flv: Invalid HEVC packet, missing HEVCPacketType or/and CompositionTime");else{var o=this._littleEndian,s=new DataView(e,A,t),g=s.getUint8(0),l=(16777215&s.getUint32(0,!o))<<8>>8;0===g?this._parseHEVCDecoderConfigurationRecord(e,A+4,t-4):1===g?this._parseHEVCVideoData(e,A+4,t-4,i,n,a,l):2===g||null===(r=this._onError)||void 0===r||r.call(this,Q.A.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(g))}},e.prototype._parseEnhancedHEVCVideoPacket=function(e,A,t,i,n,a,r){var o,s=this._littleEndian,g=new DataView(e,A,t);if(0===r)this._parseHEVCDecoderConfigurationRecord(e,A,t);else if(1===r){var l=(4294967040&g.getUint32(0,!s))>>8;this._parseHEVCVideoData(e,A+3,t-3,i,n,a,l)}else 3===r?this._parseHEVCVideoData(e,A,t,i,n,a,0):2===r||null===(o=this._onError)||void 0===o||o.call(this,Q.A.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(r))},e.prototype._parseEnhancedAV1VideoPacket=function(e,A,t,i,n,a,r){var o,s;this._littleEndian,0===r?this._parseAV1CodecConfigurationRecord(e,A,t):1===r?this._parseAV1VideoData(e,A,t,i,n,a,0):5===r?null===(o=this._onError)||void 0===o||o.call(this,Q.A.FORMAT_ERROR,"Flv: Not Suported MP2T AV1 video packet type ".concat(r)):2===r||null===(s=this._onError)||void 0===s||s.call(this,Q.A.FORMAT_ERROR,"Flv: Invalid video packet type ".concat(r))},e.prototype._parseAVCDecoderConfigurationRecord=function(e,A,t){var i,n,a,r,o,s,g,l,c,I,C;if(t<7)d.A.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");else{var h=this._videoMetadata,u=this._videoTrack,B=this._littleEndian,f=new DataView(e,A,t);if(h){if(void 0!==h.avcc){var E=new Uint8Array(e,A,t);if(m(E,h.avcc))return;d.A.w(this.TAG,"AVCDecoderConfigurationRecord has been changed, re-generate initialization segment")}}else!1!==this._hasVideo||this._hasVideoFlagOverrided||(this._hasVideo=!0,this._mediaInfo&&(this._mediaInfo.hasVideo=!0)),(h=this._videoMetadata={}).type="video",h.id=null==u?void 0:u.id,h.timescale=this._timescale,h.duration=this._duration;var p=f.getUint8(0),y=f.getUint8(1);if(f.getUint8(2),f.getUint8(3),1===p&&0!==y)if(this._naluLengthSize=1+(3&f.getUint8(4)),3===this._naluLengthSize||4===this._naluLengthSize){var _=31&f.getUint8(5);if(0!==_){_>1&&d.A.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ".concat(_));for(var S=6,v=0;v<_;v++){var D=f.getUint16(S,!B);if(S+=2,0!==D){var w=new Uint8Array(e,A+S,D);S+=D;var b=x.parseSPS(w);if(0===v){h.codecWidth=b.codec_size.width,h.codecHeight=b.codec_size.height,h.presentWidth=b.present_size.width,h.presentHeight=b.present_size.height,h.profile=b.profile_string,h.level=b.level_string,h.bitDepth=b.bit_depth,h.chromaFormat=b.chroma_format,h.sarRatio=b.sar_ratio,h.frameRate=b.frame_rate,b.frame_rate.fixed&&0!==b.frame_rate.fps_num&&0!==b.frame_rate.fps_den||(h.frameRate=this._referenceFrameRate);var F=null===(r=h.frameRate)||void 0===r?void 0:r.fps_den,R=null===(o=h.frameRate)||void 0===o?void 0:o.fps_num;h.refSampleDuration=h.timescale*(F/R);for(var k=w.subarray(1,4),P="avc1.",T=0;T<3;T++){var N=k[T].toString(16);N.length<2&&(N="0"+N),P+=N}h.codec=P;var M=this._mediaInfo;M.width=h.codecWidth,M.height=h.codecHeight,M.fps=h.frameRate.fps,M.profile=h.profile,M.level=h.level,M.refFrames=b.ref_frames,M.chromaFormat=b.chroma_format_string,M.sarNum=h.sarRatio.width,M.sarDen=h.sarRatio.height,M.videoCodec=P,M.hasAudio?null!=M.audioCodec&&(M.mimeType='video/x-flv; codecs="'+M.videoCodec+","+M.audioCodec+'"'):M.mimeType='video/x-flv; codecs="'+M.videoCodec+'"',M.isComplete()&&(null===(s=this._onMediaInfo)||void 0===s||s.call(this,M))}}}var L=f.getUint8(S);if(0!==L){for(L>1&&d.A.w(this.TAG,"Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ".concat(L)),S++,v=0;v=t){d.A.w(this.TAG,"Malformed Nalu near timestamp ".concat(C,", offset = ").concat(c,", dataSize = ").concat(t));break}var u=s.getUint32(c,!o);if(3===I&&(u>>>=8),u>t-I)return void d.A.w(this.TAG,"Malformed Nalus near timestamp ".concat(C,", NaluSize > DataSize!"));var B=31&s.getUint8(c+I);5===B&&(h=!0);var f=new Uint8Array(e,A+c,I+u),E={type:B,data:f};g.push(E),l+=f.byteLength,c+=I+u}if(g.length){var x=this._videoTrack,Q={units:g,length:l,isKeyframe:h,dts:C,cts:r,pts:C+r};h&&(Q.fileposition=n),x&&(x.samples.push(Q),x.length+=l)}},e.prototype._parseHEVCVideoData=function(e,A,t,i,n,a,r){for(var o=this._littleEndian,s=new DataView(e,A,t),g=[],l=0,c=0,I=this._naluLengthSize,C=this._timestampBase+i,h=1===a;c=t){d.A.w(this.TAG,"Malformed Nalu near timestamp ".concat(C,", offset = ").concat(c,", dataSize = ").concat(t));break}var u=s.getUint32(c,!o);if(3===I&&(u>>>=8),u>t-I)return void d.A.w(this.TAG,"Malformed Nalus near timestamp ".concat(C,", NaluSize > DataSize!"));var B=31&s.getUint8(c+I);19!==B&&20!==B||(h=!0);var f=new Uint8Array(e,A+c,I+u),E={type:B,data:f};g.push(E),l+=f.byteLength,c+=I+u}if(g.length){var x=this._videoTrack,Q={units:g,length:l,isKeyframe:h,dts:C,cts:r,pts:C+r};h&&(Q.fileposition=n),x&&(null==x||x.samples.push(Q),x.length+=l)}},e.prototype._parseAV1VideoData=function(e,A,t,i,n,a,r){this._littleEndian;var o,s=[],g=this._timestampBase+i,l=1===a;if(o=t,s.push({unitType:0,data:new Uint8Array(e,A+0,t)}),s.length){var c=this._videoTrack,d={units:s,length:o,isKeyframe:l,dts:g,cts:r,pts:g+r};l&&(d.fileposition=n),c&&(null==c||c.samples.push(d),c.length+=o)}},e}(),S=_,v=function(){function e(){}return e.prototype.destroy=function(){this.onError=null,this.onMediaInfo=null,this.onMetaDataArrived=null,this.onTrackMetadata=null,this.onDataAvailable=null,this.onTimedID3Metadata=null,this.onSMPTE2038Metadata=null,this.onSCTE35Metadata=null,this.onPESPrivateData=null,this.onPESPrivateDataDescriptor=null},e}(),D=function(){this.program_pmt_pid={}};!function(e){e[e.kMPEG1Audio=3]="kMPEG1Audio",e[e.kMPEG2Audio=4]="kMPEG2Audio",e[e.kPESPrivateData=6]="kPESPrivateData",e[e.kADTSAAC=15]="kADTSAAC",e[e.kLOASAAC=17]="kLOASAAC",e[e.kAC3=129]="kAC3",e[e.kEAC3=135]="kEAC3",e[e.kID3=21]="kID3",e[e.kSCTE35=134]="kSCTE35",e[e.kH264=27]="kH264",e[e.kH265=36]="kH265"}(l||(l={}));var w,b=function(){this.pid_stream_type={},this.common_pids={h264:void 0,h265:void 0,adts_aac:void 0,loas_aac:void 0,opus:void 0,ac3:void 0,eac3:void 0,mp3:void 0},this.pes_private_data_pids={},this.timed_id3_pids={},this.scte_35_pids={},this.smpte2038_pids={}},F=function(){},R=function(){},k=function(){this.slices=[],this.total_length=0,this.expected_length=0,this.file_position=0,this.random_access_indicator=0};!function(e){e[e.kUnspecified=0]="kUnspecified",e[e.kSliceNonIDR=1]="kSliceNonIDR",e[e.kSliceDPA=2]="kSliceDPA",e[e.kSliceDPB=3]="kSliceDPB",e[e.kSliceDPC=4]="kSliceDPC",e[e.kSliceIDR=5]="kSliceIDR",e[e.kSliceSEI=6]="kSliceSEI",e[e.kSliceSPS=7]="kSliceSPS",e[e.kSlicePPS=8]="kSlicePPS",e[e.kSliceAUD=9]="kSliceAUD",e[e.kEndOfSequence=10]="kEndOfSequence",e[e.kEndOfStream=11]="kEndOfStream",e[e.kFiller=12]="kFiller",e[e.kSPSExt=13]="kSPSExt",e[e.kReserved0=14]="kReserved0"}(w||(w={}));var P,T,N=function(){},M=function(e){var A=e.data.byteLength;this.type=e.type,this.data=new Uint8Array(4+A),new DataView(this.data.buffer).setUint32(0,A),this.data.set(e.data,4)},L=function(){function e(e){this.TAG="H264AnnexBParser",this.current_startcode_offset_=0,this.eof_flag_=!1,this.data_=e,this.current_startcode_offset_=this.findNextStartCodeOffset(0),this.eof_flag_&&d.A.e(this.TAG,"Could not find H264 startcode until payload end!")}return e.prototype.findNextStartCodeOffset=function(e){for(var A=e,t=this.data_;;){if(A+3>=t.byteLength)return this.eof_flag_=!0,t.byteLength;var i=t[A+0]<<24|t[A+1]<<16|t[A+2]<<8|t[A+3],n=t[A+0]<<16|t[A+1]<<8|t[A+2];if(1===i||1===n)return A;A++}},e.prototype.readNextNaluPayload=function(){for(var e=this.data_,A=null;null==A&&!this.eof_flag_;){var t=this.current_startcode_offset_,i=31&e[t+=1==(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])?4:3],n=(128&e[t])>>>7,a=this.findNextStartCodeOffset(t);if(this.current_startcode_offset_=a,!(i>=w.kReserved0)&&0===n){var r=e.subarray(t,a);(A=new N).type=i,A.data=r}}return A},e}(),G=function(){function e(e,A,t){var i=8+e.byteLength+1+2+A.byteLength,n=!1;66!==e[3]&&77!==e[3]&&88!==e[3]&&(n=!0,i+=4);var a=this.data=new Uint8Array(i);a[0]=1,a[1]=e[1],a[2]=e[2],a[3]=e[3],a[4]=255,a[5]=225;var r=e.byteLength;a[6]=r>>>8,a[7]=255&r;var o=8;a.set(e,8),a[o+=r]=1;var s=A.byteLength;a[o+1]=s>>>8,a[o+2]=255&s,a.set(A,o+3),o+=3+s,n&&(a[o]=252|t.chroma_format_idc,a[o+1]=248|t.bit_depth_luma-8,a[o+2]=248|t.bit_depth_chroma-8,a[o+3]=0,o+=4)}return e.prototype.getData=function(){return this.data},e}();!function(e){e[e.kNull=0]="kNull",e[e.kAACMain=1]="kAACMain",e[e.kAAC_LC=2]="kAAC_LC",e[e.kAAC_SSR=3]="kAAC_SSR",e[e.kAAC_LTP=4]="kAAC_LTP",e[e.kAAC_SBR=5]="kAAC_SBR",e[e.kAAC_Scalable=6]="kAAC_Scalable",e[e.kLayer1=32]="kLayer1",e[e.kLayer2=33]="kLayer2",e[e.kLayer3=34]="kLayer3"}(P||(P={})),function(e){e[e.k96000Hz=0]="k96000Hz",e[e.k88200Hz=1]="k88200Hz",e[e.k64000Hz=2]="k64000Hz",e[e.k48000Hz=3]="k48000Hz",e[e.k44100Hz=4]="k44100Hz",e[e.k32000Hz=5]="k32000Hz",e[e.k24000Hz=6]="k24000Hz",e[e.k22050Hz=7]="k22050Hz",e[e.k16000Hz=8]="k16000Hz",e[e.k12000Hz=9]="k12000Hz",e[e.k11025Hz=10]="k11025Hz",e[e.k8000Hz=11]="k8000Hz",e[e.k7350Hz=12]="k7350Hz"}(T||(T={}));var Y,U,J=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],H=(Y=function(e,A){return Y=Object.setPrototypeOf||t({__proto__:[]},Array)&&function(e,A){e.__proto__=A}||function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])},Y(e,A)},function(e,A){if("function"!=typeof A&&null!==A)throw new TypeError("Class extends value "+String(A)+" is not a constructor or null");function t(){this.constructor=e}Y(e,A),e.prototype=null===A?Object.create(A):(t.prototype=A.prototype,new t)}),K=function(){},O=function(e){function A(){return null!==e&&e.apply(this,arguments)||this}return H(A,e),A}(K),V=function(){function e(e){this.TAG="AACADTSParser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&d.A.e(this.TAG,"Could not found ADTS syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var A=e,t=this.data_;;){if(A+7>=t.byteLength)return this.eof_flag_=!0,t.byteLength;if(4095==(t[A+0]<<8|t[A+1])>>>4)return A;A++}},e.prototype.readNextAACFrame=function(){for(var e=this.data_,A=null;null==A&&!this.eof_flag_;){var t=this.current_syncword_offset_,i=(8&e[t+1])>>>3,n=(6&e[t+1])>>>1,a=1&e[t+1],r=(192&e[t+2])>>>6,o=(60&e[t+2])>>>2,s=(1&e[t+2])<<2|(192&e[t+3])>>>6,g=(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5;if(e[t+6],t+g>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var l=1===a?7:9,c=g-l;t+=l;var d=this.findNextSyncwordOffset(t+c);if(this.current_syncword_offset_=d,(0===i||1===i)&&0===n){var I=e.subarray(t,t+c);(A=new K).audio_object_type=r+1,A.sampling_freq_index=o,A.sampling_frequency=J[o],A.channel_config=s,A.data=I}}return A},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),j=function(){function e(e){this.TAG="AACLOASParser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&d.A.e(this.TAG,"Could not found LOAS syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var A=e,t=this.data_;;){if(A+1>=t.byteLength)return this.eof_flag_=!0,t.byteLength;if(695==(t[A+0]<<3|t[A+1]>>>5))return A;A++}},e.prototype.getLATMValue=function(e){for(var A=e.readBits(2),t=0,i=0;i<=A;i++)t<<=8,t|=e.readByte();return t},e.prototype.readNextAACFrame=function(e){for(var A=this.data_,t=null;null==t&&!this.eof_flag_;){var i=this.current_syncword_offset_,n=(31&A[i+1])<<8|A[i+2];if(i+3+n>=this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var a=new E(A.subarray(i+3,i+3+n)),r=null;if(a.readBool()){if(null==e){d.A.w(this.TAG,"StreamMuxConfig Missing"),this.current_syncword_offset_=this.findNextSyncwordOffset(i+3+n),a.destroy();continue}r=e}else{var o=a.readBool();if(o&&a.readBool()){d.A.e(this.TAG,"audioMuxVersionA is Not Supported"),a.destroy();break}if(o&&this.getLATMValue(a),!a.readBool()){d.A.e(this.TAG,"allStreamsSameTimeFraming zero is Not Supported"),a.destroy();break}if(0!==a.readBits(6)){d.A.e(this.TAG,"more than 2 numSubFrames Not Supported"),a.destroy();break}if(0!==a.readBits(4)){d.A.e(this.TAG,"more than 2 numProgram Not Supported"),a.destroy();break}if(0!==a.readBits(3)){d.A.e(this.TAG,"more than 2 numLayer Not Supported"),a.destroy();break}var s=o?this.getLATMValue(a):0,g=a.readBits(5);s-=5;var l=a.readBits(4);s-=4;var c=a.readBits(4);s-=4,a.readBits(3),(s-=3)>0&&a.readBits(s);var I=a.readBits(3);if(0!==I){d.A.e(this.TAG,"frameLengthType = ".concat(I,". Only frameLengthType = 0 Supported")),a.destroy();break}a.readByte();var C=a.readBool();if(C)if(o)this.getLATMValue(a);else for(;;){var h=a.readBool();if(a.readByte(),!h)break}a.readBool()&&a.readByte(),(r=new O).audio_object_type=g,r.sampling_freq_index=l,r.sampling_frequency=J[r.sampling_freq_index],r.channel_config=c,r.other_data_present=C}for(var u=0;;){var B=a.readByte();if(u+=B,255!==B)break}for(var f=new Uint8Array(u),x=0;x=6?(i=5,A=new Array(4),r=n-3):(i=2,A=new Array(2),r=n):o.includes("android")?(i=2,A=new Array(2),r=n):(i=5,r=n,A=new Array(4),n>=6?r=n-3:1===a&&(i=2,A=new Array(2),r=n)),A[0]=i<<3,A[0]|=(15&n)>>>1,A[1]=(15&n)<<7,A[1]|=(15&a)<<3,5===i&&(A[1]|=(15&r)>>>1,A[2]=(1&r)<<7,A[2]|=8,A[3]=0),this.config=A,this.sampling_rate=J[n],this.channel_count=a,this.codec_mimetype="mp4a.40."+i.toString(),this.original_codec_mimetype="mp4a.40."+t.toString()},Z=function(){},X=function(){};!function(e){e[e.kSpliceNull=0]="kSpliceNull",e[e.kSpliceSchedule=4]="kSpliceSchedule",e[e.kSpliceInsert=5]="kSpliceInsert",e[e.kTimeSignal=6]="kTimeSignal",e[e.kBandwidthReservation=7]="kBandwidthReservation",e[e.kPrivateCommand=255]="kPrivateCommand"}(U||(U={}));var q,z=function(e){var A=e.readBool();return A?(e.readBits(6),{time_specified_flag:A,pts_time:4*e.readBits(31)+e.readBits(2)}):(e.readBits(7),{time_specified_flag:A})},$=function(e){var A=e.readBool();return e.readBits(6),{auto_return:A,duration:4*e.readBits(31)+e.readBits(2)}},ee=function(e,A){var t=A.readBits(8);return e?{component_tag:t}:{component_tag:t,splice_time:z(A)}},Ae=function(e){return{component_tag:e.readBits(8),utc_splice_time:e.readBits(32)}},te=function(e){var A=e.readBits(32),t=e.readBool();e.readBits(7);var i={splice_event_id:A,splice_event_cancel_indicator:t};if(t)return i;if(i.out_of_network_indicator=e.readBool(),i.program_splice_flag=e.readBool(),i.duration_flag=e.readBool(),e.readBits(5),i.program_splice_flag)i.utc_splice_time=e.readBits(32);else{i.component_count=e.readBits(8),i.components=[];for(var n=0;n=t.byteLength)return this.eof_flag_=!0,t.byteLength;var i=t[A+0]<<24|t[A+1]<<16|t[A+2]<<8|t[A+3],n=t[A+0]<<16|t[A+1]<<8|t[A+2];if(1===i||1===n)return A;A++}},e.prototype.readNextNaluPayload=function(){for(var e=this.data_,A=null;null==A&&!this.eof_flag_;){var t=this.current_startcode_offset_,i=e[t+=1==(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])?4:3]>>1&63,n=(128&e[t])>>>7,a=this.findNextStartCodeOffset(t);if(this.current_startcode_offset_=a,0===n){var r=e.subarray(t,a);(A=new le).type=i,A.data=r}}return A},e}(),Ie=function(){function e(e,A,t,i){var n=23+(5+e.byteLength)+(5+A.byteLength)+(5+t.byteLength),a=this.data=new Uint8Array(n);a[0]=1,a[1]=(3&i.general_profile_space)<<6|(i.general_tier_flag?1:0)<<5|31&i.general_profile_idc,a[2]=i.general_profile_compatibility_flags_1,a[3]=i.general_profile_compatibility_flags_2,a[4]=i.general_profile_compatibility_flags_3,a[5]=i.general_profile_compatibility_flags_4,a[6]=i.general_constraint_indicator_flags_1,a[7]=i.general_constraint_indicator_flags_2,a[8]=i.general_constraint_indicator_flags_3,a[9]=i.general_constraint_indicator_flags_4,a[10]=i.general_constraint_indicator_flags_5,a[11]=i.general_constraint_indicator_flags_6,a[12]=i.general_level_idc,a[13]=240|(3840&i.min_spatial_segmentation_idc)>>8,a[14]=255&i.min_spatial_segmentation_idc,a[15]=252|3&i.parallelismType,a[16]=252|3&i.chroma_format_idc,a[17]=248|7&i.bit_depth_luma_minus8,a[18]=248|7&i.bit_depth_chroma_minus8,a[19]=0,a[20]=0,a[21]=(3&i.constant_frame_rate)<<6|(7&i.num_temporal_layers)<<3|(i.temporal_id_nested?1:0)<<2|3,a[22]=3,a[23]=128|q.kSliceVPS,a[24]=0,a[25]=1,a[26]=(65280&e.byteLength)>>8,a[27]=255&e.byteLength,a.set(e,28),a[23+(5+e.byteLength)+0]=128|q.kSliceSPS,a[23+(5+e.byteLength)+1]=0,a[23+(5+e.byteLength)+2]=1,a[23+(5+e.byteLength)+3]=(65280&A.byteLength)>>8,a[23+(5+e.byteLength)+4]=255&A.byteLength,a.set(A,23+(5+e.byteLength)+5),a[23+(5+e.byteLength+5+A.byteLength)+0]=128|q.kSlicePPS,a[23+(5+e.byteLength+5+A.byteLength)+1]=0,a[23+(5+e.byteLength+5+A.byteLength)+2]=1,a[23+(5+e.byteLength+5+A.byteLength)+3]=(65280&t.byteLength)>>8,a[23+(5+e.byteLength+5+A.byteLength)+4]=255&t.byteLength,a.set(t,23+(5+e.byteLength+5+A.byteLength)+5)}return e.prototype.getData=function(){return this.data},e}(),Ce=function(){},he=function(){},ue=function(){},Be=[[64,64,80,80,96,96,112,112,128,128,160,160,192,192,224,224,256,256,320,320,384,384,448,448,512,512,640,640,768,768,896,896,1024,1024,1152,1152,1280,1280],[69,70,87,88,104,105,121,122,139,140,174,175,208,209,243,244,278,279,348,349,417,418,487,488,557,558,696,697,835,836,975,976,1114,1115,1253,1254,1393,1394],[96,96,120,120,144,144,168,168,192,192,240,240,288,288,336,336,384,384,480,480,576,576,672,672,768,768,960,960,1152,1152,1344,1344,1536,1536,1728,1728,1920,1920]],fe=function(){function e(e){this.TAG="AC3Parser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&d.A.e(this.TAG,"Could not found AC3 syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var A=e,t=this.data_;;){if(A+7>=t.byteLength)return this.eof_flag_=!0,t.byteLength;if(2935==(t[A+0]<<8|t[A+1]))return A;A++}},e.prototype.readNextAC3Frame=function(){for(var e=this.data_,A=null;null==A&&!this.eof_flag_;){var t=this.current_syncword_offset_,i=e[t+4]>>6,n=[48e3,44200,33e3][i],a=63&e[t+4],r=2*Be[i][a];if(t+r>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var o=this.findNextSyncwordOffset(t+r);this.current_syncword_offset_=o;var s=e[t+5]>>3,g=7&e[t+5],l=e[t+6]>>5,c=0;1&l&&1!==l&&(c+=2),4&l&&(c+=2),2===l&&(c+=2);var d=(e[t+6]<<8|e[t+7])>>12-c&1,I=[2,1,2,3,3,4,4,5][l]+d;(A=new ue).sampling_frequency=n,A.channel_count=I,A.channel_mode=l,A.bit_stream_identification=s,A.low_frequency_effects_channel_on=d,A.bit_stream_mode=g,A.frame_size_code=a,A.data=e.subarray(t,t+r)}return A},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),Ee=function(e){var A;A=[e.sampling_rate_code<<6|e.bit_stream_identification<<1|e.bit_stream_mode>>2,(3&e.bit_stream_mode)<<6|e.channel_mode<<3|e.low_frequency_effects_channel_on<<2|e.frame_size_code>>4,e.frame_size_code<<4&224],this.config=A,this.sampling_rate=e.sampling_frequency,this.bit_stream_identification=e.bit_stream_identification,this.bit_stream_mode=e.bit_stream_mode,this.low_frequency_effects_channel_on=e.low_frequency_effects_channel_on,this.channel_count=e.channel_count,this.channel_mode=e.channel_mode,this.codec_mimetype="ac-3",this.original_codec_mimetype="ac-3"},xe=function(){},Qe=function(){function e(e){this.TAG="EAC3Parser",this.data_=e,this.current_syncword_offset_=this.findNextSyncwordOffset(0),this.eof_flag_&&d.A.e(this.TAG,"Could not found AC3 syncword until payload end")}return e.prototype.findNextSyncwordOffset=function(e){for(var A=e,t=this.data_;;){if(A+7>=t.byteLength)return this.eof_flag_=!0,t.byteLength;if(2935==(t[A+0]<<8|t[A+1]))return A;A++}},e.prototype.readNextEAC3Frame=function(){for(var e=this.data_,A=null;null==A&&!this.eof_flag_;){var t=this.current_syncword_offset_,i=new E(e.subarray(t+2)),n=(i.readBits(2),i.readBits(3),i.readBits(11)+1<<1),a=i.readBits(2),r=null,o=null;3===a?(r=[24e3,22060,16e3][a=i.readBits(2)],o=3):(r=[48e3,44100,32e3][a],o=i.readBits(2));var s=i.readBits(3),g=i.readBits(1),l=i.readBits(5);if(t+n>this.data_.byteLength){this.eof_flag_=!0,this.has_last_incomplete_data=!0;break}var c=this.findNextSyncwordOffset(t+n);this.current_syncword_offset_=c;var d=[2,1,2,3,3,4,4,5][s]+g;i.destroy(),(A=new xe).sampling_frequency=r,A.channel_count=d,A.channel_mode=s,A.bit_stream_identification=l,A.low_frequency_effects_channel_on=g,A.frame_size=n,A.num_blks=[1,2,3,6][o],A.data=e.subarray(t,t+n)}return A},e.prototype.hasIncompleteData=function(){return this.has_last_incomplete_data},e.prototype.getIncompleteData=function(){return this.has_last_incomplete_data?this.data_.subarray(this.current_syncword_offset_):null},e}(),pe=function(e){var A,t=Math.floor(e.frame_size*e.sampling_frequency/(16*e.num_blks));A=[255&t,248&t,e.sampling_rate_code<<6|e.bit_stream_identification<<1,e.channel_mode<<1|e.low_frequency_effects_channel_on,0],this.config=A,this.sampling_rate=e.sampling_frequency,this.bit_stream_identification=e.bit_stream_identification,this.num_blks=e.num_blks,this.low_frequency_effects_channel_on=e.low_frequency_effects_channel_on,this.channel_count=e.channel_count,this.channel_mode=e.channel_mode,this.codec_mimetype="ec-3",this.original_codec_mimetype="ec-3"},me=function(){var e=function(A,i){return e=Object.setPrototypeOf||t({__proto__:[]},Array)&&function(e,A){e.__proto__=A}||function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])},e(A,i)};return function(A,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=A}e(A,t),A.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}}(),ye=function(){return ye=Object.assign||function(e){for(var A,t=1,i=arguments.length;t0)&&!(i=a.next()).done;)r.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}return r},Se=function(e,A,t){if(2===arguments.length)for(var i,n=0,a=A.length;n=4?(d.A.v("TSDemuxer","ts_packet_size = 192, m2ts mode"),t-=4):204===i&&d.A.v("TSDemuxer","ts_packet_size = 204, RS encoded MPEG2-TS stream"),{match:!0,consumed:0,ts_packet_size:i,sync_offset:t})},A.prototype.bindDataSource=function(e){return e.onDataArrival=this.parseChunks.bind(this),this},A.prototype.resetMediaInfo=function(){this.media_info_=new C.A},A.prototype.parseChunks=function(e,A){var t;if(!(this.onError&&this.onMediaInfo&&this.onTrackMetadata&&this.onDataAvailable))throw new u.j4("onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");var i=0;for(this.first_parse_&&(this.first_parse_=!1,i=this.sync_offset_);i+this.ts_packet_size_<=e.byteLength;){var n=A+i;192===this.ts_packet_size_&&(i+=4);var a=new Uint8Array(e,i,188),r=a[0];if(71!==r){d.A.e(this.TAG,"sync_byte = ".concat(r,", not 0x47"));break}var o=(64&a[1])>>>6,s=(a[1],(31&a[1])<<8|a[2]),g=(48&a[3])>>>4,c=15&a[3],I={},C=4;if(2===g||3===g){var h=a[4];if(5+h===188){i+=188,204===this.ts_packet_size_&&(i+=16);continue}h>0&&(I=this.parseAdaptationField(e,i+4,1+h)),C=5+h}if(1===g||3===g)if(0===s||s===this.current_pmt_pid_||void 0!==this.pmt_&&this.pmt_.pid_stream_type[s]===l.kSCTE35){var B=188-C;this.handleSectionSlice(e,i+C,B,{pid:s,file_position:n,payload_unit_start_indicator:o,continuity_conunter:c,random_access_indicator:I.random_access_indicator})}else if(void 0!==(null===(t=this.pmt_)||void 0===t?void 0:t.pid_stream_type[s])){B=188-C;var f=this.pmt_.pid_stream_type[s];(s===this.pmt_.common_pids.h264||s===this.pmt_.common_pids.h265||s===this.pmt_.common_pids.adts_aac||s===this.pmt_.common_pids.loas_aac||s===this.pmt_.common_pids.ac3||s===this.pmt_.common_pids.eac3||s===this.pmt_.common_pids.opus||s===this.pmt_.common_pids.mp3||this.pmt_.pes_private_data_pids[s]||this.pmt_.timed_id3_pids[s])&&this.handlePESSlice(e,i+C,B,{pid:s,stream_type:f,file_position:n,payload_unit_start_indicator:o,continuity_conunter:c,random_access_indicator:I.random_access_indicator})}i+=188,204===this.ts_packet_size_&&(i+=16)}return this.dispatchAudioVideoMediaSegment(),i},A.prototype.parseAdaptationField=function(e,A,t){var i=new Uint8Array(e,A,t),n=i[0];return n>0?n>183?(d.A.w(this.TAG,"Illegal adaptation_field_length: ".concat(n)),{}):{discontinuity_indicator:(128&i[1])>>>7,random_access_indicator:(64&i[1])>>>6,elementary_stream_priority_indicator:(32&i[1])>>>5}:{}},A.prototype.handleSectionSlice=function(e,A,t,i){var n=new Uint8Array(e,A,t),a=this.section_slice_queues_?this.section_slice_queues_[i.pid]:{};if(i.payload_unit_start_indicator){var r=n[0];if(void 0!==a&&0!==(null==a?void 0:a.total_length)){var o=new Uint8Array(e,A+1,Math.min(t,r));a.slices.push(o),a.total_length+=o.byteLength,a.total_length===a.expected_length?this.emitSectionSlices(a,i):this.clearSlices(a,i)}for(var s=1+r;s=a.expected_length&&this.clearSlices(a,i),s+=o.byteLength}}else void 0!==a&&0!==a.total_length&&(o=new Uint8Array(e,A,Math.min(t,a.expected_length-a.total_length)),a.slices.push(o),a.total_length+=o.byteLength,a.total_length===a.expected_length?this.emitSectionSlices(a,i):a.total_length>=a.expected_length&&this.clearSlices(a,i))},A.prototype.handlePESSlice=function(e,A,t,i){var n=new Uint8Array(e,A,t),a=n[0]<<16|n[1]<<8|n[2],r=(n[3],n[4]<<8|n[5]);if(i.payload_unit_start_indicator){if(1!==a)return void d.A.e(this.TAG,"handlePESSlice: packet_start_code_prefix should be 1 but with value ".concat(a));var o=this.pes_slice_queues_[i.pid];o&&(0===o.expected_length||o.expected_length===o.total_length?this.emitPESSlices(o,i):this.clearSlices(o,i)),this.pes_slice_queues_&&(this.pes_slice_queues_[i.pid]=new k,this.pes_slice_queues_[i.pid].file_position=i.file_position,this.pes_slice_queues_[i.pid].random_access_indicator=i.random_access_indicator)}if(void 0!==this.pes_slice_queues_[i.pid]){var s=this.pes_slice_queues_[i.pid];s.slices.push(n),i.payload_unit_start_indicator&&(s.expected_length=0===r?0:r+6),s.total_length+=n.byteLength,s.expected_length>0&&s.expected_length===s.total_length?this.emitPESSlices(s,i):s.expected_length>0&&s.expected_length>>6,r=A[8],o=void 0,s=void 0;2!==a&&3!==a||(o=536870912*(14&A[9])+4194304*(255&A[10])+16384*(254&A[11])+128*(255&A[12])+(254&A[13])/2,s=3===a?536870912*(14&A[14])+4194304*(255&A[15])+16384*(254&A[16])+128*(255&A[17])+(254&A[18])/2:o);var g=9+r,c=void 0;if(0!==n){if(n<3+r)return void d.A.v(this.TAG,"Malformed PES: PES_packet_length < 3 + PES_header_data_length");c=n-3-r}else c=A.byteLength-g;var I=A.subarray(g,g+c);switch(e.stream_type){case l.kMPEG1Audio:case l.kMPEG2Audio:this.parseMP3Payload(I,o);break;case l.kPESPrivateData:this.pmt_.common_pids.opus===e.pid?this.parseOpusPayload(I,o):this.pmt_.common_pids.ac3===e.pid?this.parseAC3Payload(I,o):this.pmt_.common_pids.eac3===e.pid?this.parseEAC3Payload(I,o):this.pmt_.smpte2038_pids[e.pid]?this.parseSMPTE2038MetadataPayload(I,o,s,e.pid,i):this.parsePESPrivateDataPayload(I,o,s,e.pid,i);break;case l.kADTSAAC:this.parseADTSAACPayload(I,o);break;case l.kLOASAAC:this.parseLOASAACPayload(I,o);break;case l.kAC3:this.parseAC3Payload(I,o);break;case l.kEAC3:this.parseEAC3Payload(I,o);break;case l.kID3:this.parseTimedID3MetadataPayload(I,o,s,e.pid,i);break;case l.kH264:this.parseH264Payload(I,o,s,e.file_position,e.random_access_indicator);break;case l.kH265:this.parseH265Payload(I,o,s,e.file_position,e.random_access_indicator)}}else 188!==i&&191!==i&&240!==i&&241!==i&&255!==i&&242!==i&&248!==i||e.stream_type!==l.kPESPrivateData||(g=6,c=void 0,c=0!==n?n:A.byteLength-g,I=A.subarray(g,g+c),this.parsePESPrivateDataPayload(I,void 0,void 0,e.pid,i));else d.A.e(this.TAG,"parsePES: packet_start_code_prefix should be 1 but with value ".concat(t))},A.prototype.parsePAT=function(e){var A=e[0];if(0===A){var t=(15&e[1])<<8|e[2],i=(e[3],e[4],(62&e[5])>>>1),n=1&e[5],a=e[6],r=(e[7],null);if(1===n&&0===a)(r=new D).version_number=i;else if(null==(r=this.pat_))return;for(var o=t-5-4,s=-1,g=-1,l=8;l<8+o;l+=4){var c=e[l]<<8|e[l+1],I=(31&e[l+2])<<8|e[l+3];0===c?r.network_pid=I:(r.program_pmt_pid[c]=I,-1===s&&(s=c),-1===g&&(g=I))}1===n&&0===a&&(void 0===this.pat_&&d.A.v(this.TAG,"Parsed first PAT: ".concat(JSON.stringify(r))),this.pat_=r,this.current_program_=s,this.current_pmt_pid_=g)}else d.A.e(this.TAG,"parsePAT: table_id ".concat(A," is not corresponded to PAT!"))},A.prototype.parsePMT=function(e){var A=e[0];if(2===A){var t=(15&e[1])<<8|e[2],i=e[3]<<8|e[4],n=(62&e[5])>>>1,a=1&e[5],r=e[6],o=(e[7],null);if(1===a&&0===r)(o=new b).program_number=i,o.version_number=n,this.program_pmt_map_[i]=o;else if(null==(o=this.program_pmt_map_[i]))return;e[8],e[9];for(var s=(15&e[10])<<8|e[11],g=12+s,c=t-9-s-4,I=g;I0){for(var E=I+5;E1&&(d.A.w(this.TAG,"AAC: Detected pts overlapped, "+"expected: ".concat(s,"ms, PES pts: ").concat(o,"ms")),o=s)}}for(var g=new V(e),l=null,c=o,I=0;null!=(l=g.readNextAACFrame());){r=1024/l.sampling_frequency*1e3;var C={codec:"aac",data:l};this.audio_init_segment_dispatched_?this.detectAudioMetadataChange(C)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(C)):(this.audio_metadata_={codec:"aac",audio_object_type:l.audio_object_type,sampling_freq_index:l.sampling_freq_index,sampling_frequency:l.sampling_frequency,channel_config:l.channel_config},this.dispatchAudioInitSegment(C)),I=c;var h=Math.floor(c),u={unit:l.data,length:l.data.byteLength,pts:h,dts:h};this.audio_track_&&(null===(n=this.audio_track_)||void 0===n||n.samples.push(u),this.audio_track_.length+=l.data.byteLength),c+=r}g.hasIncompleteData()&&(this.aac_last_incomplete_data_=g.getIncompleteData()),I&&(this.aac_last_sample_pts_=I)}},A.prototype.parseLOASAACPayload=function(e,A){var t,i,n;if(!this.has_video_||this.video_init_segment_dispatched_){if(this.aac_last_incomplete_data_){var a=new Uint8Array(e.byteLength+this.aac_last_incomplete_data_.byteLength);a.set(this.aac_last_incomplete_data_,0),a.set(e,this.aac_last_incomplete_data_.byteLength),e=a}var r,o=0;if(void 0!==A&&(o=A/this.timescale_),"aac"===(null===(t=this.audio_metadata_)||void 0===t?void 0:t.codec)){if(void 0===A&&void 0!==this.aac_last_sample_pts_)r=1024/this.audio_metadata_.sampling_frequency*1e3,o=this.aac_last_sample_pts_+r;else if(void 0===A)return void d.A.w(this.TAG,"AAC: Unknown pts");if(this.aac_last_incomplete_data_&&this.aac_last_sample_pts_){r=1024/this.audio_metadata_.sampling_frequency*1e3;var s=this.aac_last_sample_pts_+r;Math.abs(s-o)>1&&(d.A.w(this.TAG,"AAC: Detected pts overlapped, "+"expected: ".concat(s,"ms, PES pts: ").concat(o,"ms")),o=s)}}for(var g=new j(e),l=null,c=o,I=0;null!=(l=g.readNextAACFrame(null!==(i=this.loas_previous_frame)&&void 0!==i?i:void 0));){this.loas_previous_frame=l,r=1024/l.sampling_frequency*1e3;var C={codec:"aac",data:l};this.audio_init_segment_dispatched_?this.detectAudioMetadataChange(C)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(C)):(this.audio_metadata_={codec:"aac",audio_object_type:l.audio_object_type,sampling_freq_index:l.sampling_freq_index,sampling_frequency:l.sampling_frequency,channel_config:l.channel_config},this.dispatchAudioInitSegment(C)),I=c;var h=Math.floor(c),u={unit:l.data,length:l.data.byteLength,pts:h,dts:h};this.audio_track_&&(null===(n=this.audio_track_)||void 0===n||n.samples.push(u),this.audio_track_.length+=l.data.byteLength),c+=r}g.hasIncompleteData()&&(this.aac_last_incomplete_data_=g.getIncompleteData()),I&&(this.aac_last_sample_pts_=I)}},A.prototype.parseAC3Payload=function(e,A){var t,i;if(!this.has_video_||this.video_init_segment_dispatched_){var n,a=0;if(void 0!==A&&(a=A/this.timescale_),"ac-3"===(null===(t=this.audio_metadata_)||void 0===t?void 0:t.codec))if(void 0===A&&void 0!==this.aac_last_sample_pts_)n=1536/this.audio_metadata_.sampling_frequency*1e3,a=this.aac_last_sample_pts_+n;else if(void 0===A)return void d.A.w(this.TAG,"AC3: Unknown pts");for(var r=new fe(e),o=null,s=a,g=0;null!=(o=r.readNextAC3Frame());){n=1536/o.sampling_frequency*1e3;var l={codec:"ac-3",data:o};this.audio_init_segment_dispatched_?this.detectAudioMetadataChange(l)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(l)):(this.audio_metadata_={codec:"ac-3",sampling_frequency:o.sampling_frequency,bit_stream_identification:o.bit_stream_identification,bit_stream_mode:o.bit_stream_mode,low_frequency_effects_channel_on:o.low_frequency_effects_channel_on,channel_mode:o.channel_mode},this.dispatchAudioInitSegment(l)),g=s;var c=Math.floor(s),I={unit:o.data,length:o.data.byteLength,pts:c,dts:c};this.audio_track_&&(null===(i=this.audio_track_)||void 0===i||i.samples.push(I),this.audio_track_.length+=o.data.byteLength),s+=n}g&&(this.aac_last_sample_pts_=g)}},A.prototype.parseEAC3Payload=function(e,A){var t,i;if(!this.has_video_||this.video_init_segment_dispatched_){var n,a=0;if(void 0!==A&&(a=A/this.timescale_),"ec-3"===(null===(t=this.audio_metadata_)||void 0===t?void 0:t.codec))if(void 0===A&&void 0!==this.aac_last_sample_pts_)n=256*(this.audio_metadata_.num_blks||0)/(this.audio_metadata_.sampling_frequency||0)*1e3,a=this.aac_last_sample_pts_+n;else if(void 0===A)return void d.A.w(this.TAG,"EAC3: Unknown pts");for(var r=new Qe(e),o=null,s=a,g=0;null!=(o=r.readNextEAC3Frame());){n=1536/o.sampling_frequency*1e3;var l={codec:"ec-3",data:o};this.audio_init_segment_dispatched_?this.detectAudioMetadataChange(l)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(l)):(this.audio_metadata_={codec:"ec-3",sampling_frequency:o.sampling_frequency,bit_stream_identification:o.bit_stream_identification,low_frequency_effects_channel_on:o.low_frequency_effects_channel_on,num_blks:o.num_blks,channel_mode:o.channel_mode},this.dispatchAudioInitSegment(l)),g=s;var c=Math.floor(s),I={unit:o.data,length:o.data.byteLength,pts:c,dts:c};this.audio_track_&&(null===(i=this.audio_track_)||void 0===i||i.samples.push(I),this.audio_track_.length+=o.data.byteLength),s+=n}g&&(this.aac_last_sample_pts_=g)}},A.prototype.parseOpusPayload=function(e,A){var t,i;if(!this.has_video_||this.video_init_segment_dispatched_){var n,a=0;if(void 0!==A&&(a=A/this.timescale_),"opus"===(null===(t=this.audio_metadata_)||void 0===t?void 0:t.codec))if(void 0===A&&void 0!==this.aac_last_sample_pts_)n=20,a=this.aac_last_sample_pts_+n;else if(void 0===A)return void d.A.w(this.TAG,"Opus: Unknown pts");for(var r=a,o=0,s=0;s>>3&3,n=(6&e[1])>>1,a=(e[2],(12&e[2])>>>2),r=3&~(e[3]>>>6)?2:1,o=0,s=34;switch(i){case 0:o=[11025,12e3,8e3,0][a];break;case 2:o=[22050,24e3,16e3,0][a];break;case 3:o=[44100,48e3,32e3,0][a]}switch(n){case 1:s=34;break;case 2:s=33;break;case 3:s=32}var g=new he;g.object_type=s,g.sample_rate=o,g.channel_count=r,g.data=e;var l={codec:"mp3",data:g};this.audio_init_segment_dispatched_?this.detectAudioMetadataChange(l)&&(this.dispatchAudioMediaSegment(),this.dispatchAudioInitSegment(l)):(this.audio_metadata_={codec:"mp3",object_type:s,sample_rate:o,channel_count:r},this.dispatchAudioInitSegment(l));var c={unit:e,length:e.byteLength,pts:A/this.timescale_,dts:A/this.timescale_};this.audio_track_&&(null===(t=this.audio_track_)||void 0===t||t.samples.push(c),this.audio_track_.length+=e.byteLength)}},A.prototype.detectAudioMetadataChange=function(e){var A,t,i,n;if(e.codec!==(null===(A=this.audio_metadata_)||void 0===A?void 0:A.codec))return d.A.v(this.TAG,"Audio: Audio Codecs changed from "+"".concat(null===(t=this.audio_metadata_)||void 0===t?void 0:t.codec," to ").concat(e.codec)),!0;if("aac"===e.codec&&"aac"===this.audio_metadata_.codec){if((a=e.data).audio_object_type!==this.audio_metadata_.audio_object_type)return d.A.v(this.TAG,"AAC: AudioObjectType changed from "+"".concat(this.audio_metadata_.audio_object_type," to ").concat(a.audio_object_type)),!0;if(a.sampling_freq_index!==this.audio_metadata_.sampling_freq_index)return d.A.v(this.TAG,"AAC: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sampling_freq_index," to ").concat(a.sampling_freq_index)),!0;if(a.channel_config!==this.audio_metadata_.channel_config)return d.A.v(this.TAG,"AAC: Channel configuration changed from "+"".concat(null===(i=this.audio_metadata_)||void 0===i?void 0:i.channel_config," to ").concat(a.channel_config)),!0}else if("ac-3"===e.codec&&"ac-3"===this.audio_metadata_.codec){var a;if((a=e.data).sampling_frequency!==this.audio_metadata_.sampling_frequency)return d.A.v(this.TAG,"AC3: Sampling Frequency changed from "+"".concat(null===(n=this.audio_metadata_)||void 0===n?void 0:n.sampling_frequency," to ").concat(a.sampling_frequency)),!0;if(a.bit_stream_identification!==this.audio_metadata_.bit_stream_identification)return d.A.v(this.TAG,"AC3: Bit Stream Identification changed from "+"".concat(this.audio_metadata_.bit_stream_identification," to ").concat(a.bit_stream_identification)),!0;if(a.bit_stream_mode!==this.audio_metadata_.bit_stream_mode)return d.A.v(this.TAG,"AC3: BitStream Mode changed from "+"".concat(this.audio_metadata_.bit_stream_mode," to ").concat(a.bit_stream_mode)),!0;if(a.channel_mode!==this.audio_metadata_.channel_mode)return d.A.v(this.TAG,"AC3: Channel Mode changed from "+"".concat(this.audio_metadata_.channel_mode," to ").concat(a.channel_mode)),!0;if(a.low_frequency_effects_channel_on!==this.audio_metadata_.low_frequency_effects_channel_on)return d.A.v(this.TAG,"AC3: Low Frequency Effects Channel On changed from "+"".concat(this.audio_metadata_.low_frequency_effects_channel_on," to ").concat(a.low_frequency_effects_channel_on)),!0}else if("opus"===e.codec&&"opus"===this.audio_metadata_.codec){if((r=e.meta).sample_rate!==this.audio_metadata_.sample_rate)return d.A.v(this.TAG,"Opus: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sample_rate," to ").concat(r.sample_rate)),!0;if(r.channel_count!==this.audio_metadata_.channel_count)return d.A.v(this.TAG,"Opus: Channel count changed from "+"".concat(this.audio_metadata_.channel_count," to ").concat(r.channel_count)),!0}else if("mp3"===e.codec&&"mp3"===this.audio_metadata_.codec){var r;if((r=e.data).object_type!==this.audio_metadata_.object_type)return d.A.v(this.TAG,"MP3: AudioObjectType changed from "+"".concat(this.audio_metadata_.object_type," to ").concat(r.object_type)),!0;if(r.sample_rate!==this.audio_metadata_.sample_rate)return d.A.v(this.TAG,"MP3: SamplingFrequencyIndex changed from "+"".concat(this.audio_metadata_.sample_rate," to ").concat(r.sample_rate)),!0;if(r.channel_count!==this.audio_metadata_.channel_count)return d.A.v(this.TAG,"MP3: Channel count changed from "+"".concat(this.audio_metadata_.channel_count," to ").concat(r.channel_count)),!0}return!1},A.prototype.dispatchAudioInitSegment=function(e){var A,t,i,n,a,r,o={type:"audio"};if(o.id=null===(A=this.audio_track_)||void 0===A?void 0:A.id,o.timescale=1e3,o.duration=this.duration_,"aac"===(null===(t=this.audio_metadata_)||void 0===t?void 0:t.codec)){var s="aac"===e.codec?e.data:null,g=new W(s);o.audioSampleRate=g.sampling_rate,o.channelCount=g.channel_count,o.codec=g.codec_mimetype,o.originalCodec=g.original_codec_mimetype,o.config=g.config,o.refSampleDuration=1024/o.audioSampleRate*o.timescale}else if("ac-3"===(null===(i=this.audio_metadata_)||void 0===i?void 0:i.codec)){var l="ac-3"===e.codec?e.data:null,c=new Ee(l);o.audioSampleRate=c.sampling_rate,o.channelCount=c.channel_count,o.codec=c.codec_mimetype,o.originalCodec=c.original_codec_mimetype,o.config=c.config,o.refSampleDuration=1536/o.audioSampleRate*o.timescale}else if("ec-3"===(null===(n=this.audio_metadata_)||void 0===n?void 0:n.codec)){var I="ec-3"===e.codec?e.data:null,C=new pe(I);o.audioSampleRate=C.sampling_rate,o.channelCount=C.channel_count,o.codec=C.codec_mimetype,o.originalCodec=C.original_codec_mimetype,o.config=C.config,o.refSampleDuration=256*C.num_blks/o.audioSampleRate*o.timescale}else"opus"===(null===(a=this.audio_metadata_)||void 0===a?void 0:a.codec)?(o.audioSampleRate=this.audio_metadata_.sample_rate,o.channelCount=this.audio_metadata_.channel_count,o.channelConfigCode=this.audio_metadata_.channel_config_code,o.codec="opus",o.originalCodec="opus",o.config=void 0,o.refSampleDuration=20):"mp3"===(null===(r=this.audio_metadata_)||void 0===r?void 0:r.codec)&&(o.audioSampleRate=this.audio_metadata_.sample_rate,o.channelCount=this.audio_metadata_.channel_count,o.codec="mp3",o.originalCodec="mp3",o.config=void 0);this.audio_init_segment_dispatched_||d.A.v(this.TAG,"Generated first AudioSpecificConfig for mimeType: ".concat(o.codec)),this.onTrackMetadata&&this.onTrackMetadata("audio",o),this.audio_init_segment_dispatched_=!0,this.video_metadata_changed_=!1;var h=this.media_info_;h.hasAudio=!0,h.audioCodec=o.originalCodec,h.audioSampleRate=o.audioSampleRate,h.audioChannelCount=o.channelCount,h.hasVideo&&h.videoCodec?h.mimeType='video/mp2t; codecs="'.concat(h.videoCodec,",").concat(h.audioCodec,'"'):h.mimeType='video/mp2t; codecs="'.concat(h.audioCodec,'"'),h.isComplete()&&this.onMediaInfo&&this.onMediaInfo(h)},A.prototype.dispatchPESPrivateDataDescriptor=function(e,A,t){var i=new X;i.pid=e,i.stream_type=A,i.descriptor=t,this.onPESPrivateDataDescriptor&&this.onPESPrivateDataDescriptor(i)},A.prototype.parsePESPrivateDataPayload=function(e,A,t,i,n){var a=new Z;if(a.pid=i,a.stream_id=n,a.len=e.byteLength,a.data=e,void 0!==A){var r=Math.floor(A/this.timescale_);a.pts=r}else a.nearest_pts=this.aac_last_sample_pts_;if(void 0!==t){var o=Math.floor(t/this.timescale_);a.dts=o}this.onPESPrivateData&&this.onPESPrivateData(a)},A.prototype.parseTimedID3MetadataPayload=function(e,A,t,i,n){var a=new Z;if(a.pid=i,a.stream_id=n,a.len=e.byteLength,a.data=e,void 0!==A){var r=Math.floor(A/this.timescale_);a.pts=r}if(void 0!==t){var o=Math.floor(t/this.timescale_);a.dts=o}this.onTimedID3Metadata&&this.onTimedID3Metadata(a)},A.prototype.parseSMPTE2038MetadataPayload=function(e,A,t,i,n){var a=new Ce;if(a.pid=i,a.stream_id=n,a.len=e.byteLength,a.data=e,void 0!==A){var r=Math.floor(A/this.timescale_);a.pts=r}if(a.nearest_pts=this.aac_last_sample_pts_,void 0!==t){var o=Math.floor(t/this.timescale_);a.dts=o}a.ancillaries=function(e){for(var A=new E(e),t=0,i=[];t+=6,0===A.readBits(6);){var n=A.readBool();t+=1;var a=A.readBits(11);t+=11;var r=A.readBits(12);t+=12;var o=255&A.readBits(10);t+=10;var s=255&A.readBits(10);t+=10;var g=255&A.readBits(10);t+=10;for(var l=new Uint8Array(g),c=0;c>>24&255,n[1]=i>>>16&255,n[2]=i>>>8&255,n[3]=255&i,n.set(e,4);var s=8;for(o=0;o>>24&255,A>>>16&255,A>>>8&255,255&A,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))},e.trak=function(A){return e.box(e.types.trak,e.tkhd(A),e.mdia(A))},e.tkhd=function(A){var t=A.id,i=A.duration,n=A.presentWidth,a=A.presentHeight;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>>8&255,255&n,0,0,a>>>8&255,255&a,0,0]))},e.mdia=function(A){return e.box(e.types.mdia,e.mdhd(A),e.hdlr(A),e.minf(A))},e.mdhd=function(A){var t=A.timescale,i=A.duration;return e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i,85,196,0,0]))},e.hdlr=function(A){var t;return t="audio"===A.type?e.constants.HDLR_AUDIO:e.constants.HDLR_VIDEO,e.box(e.types.hdlr,t)},e.minf=function(A){var t;return t="audio"===A.type?e.box(e.types.smhd,e.constants.SMHD):e.box(e.types.vmhd,e.constants.VMHD),e.box(e.types.minf,t,e.dinf(),e.stbl(A))},e.dinf=function(){return e.box(e.types.dinf,e.box(e.types.dref,e.constants.DREF))},e.stbl=function(A){return e.box(e.types.stbl,e.stsd(A),e.box(e.types.stts,e.constants.STTS),e.box(e.types.stsc,e.constants.STSC),e.box(e.types.stsz,e.constants.STSZ),e.box(e.types.stco,e.constants.STCO))},e.stsd=function(A){return"audio"===A.type?"mp3"===A.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp3(A)):"ac-3"===A.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.ac3(A)):"ec-3"===A.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.ec3(A)):"opus"===A.codec?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.Opus(A)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.mp4a(A)):"video"===A.type&&A.codec.startsWith("hvc1")?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.hvc1(A)):"video"===A.type&&A.codec.startsWith("av01")?e.box(e.types.stsd,e.constants.STSD_PREFIX,e.av01(A)):e.box(e.types.stsd,e.constants.STSD_PREFIX,e.avc1(A))},e.mp3=function(A){var t=A.channelCount,i=A.audioSampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types[".mp3"],n)},e.mp4a=function(A){var t=A.channelCount,i=A.audioSampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types.mp4a,n,e.esds(A))},e.ac3=function(A){var t,i=A.channelCount,n=A.audioSampleRate,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types["ac-3"],a,e.box(e.types.dac3,new Uint8Array(null!==(t=A.config)&&void 0!==t?t:[])))},e.ec3=function(A){var t,i=A.channelCount,n=A.audioSampleRate,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>>8&255,255&n,0,0]);return e.box(e.types["ec-3"],a,e.box(e.types.dec3,new Uint8Array(null!==(t=A.config)&&void 0!==t?t:[])))},e.esds=function(A){var t,i=null!==(t=A.config)&&void 0!==t?t:[],n=i.length,a=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(i).concat([6,1,2]));return e.box(e.types.esds,a)},e.Opus=function(A){var t=A.channelCount,i=A.audioSampleRate,n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,i>>>8&255,255&i,0,0]);return e.box(e.types.Opus,n,e.dOps(A))},e.dOps=function(A){var t=A.channelCount,i=A.channelConfigCode,n=A.audioSampleRate,a=[];switch(i){case 1:case 2:a=[0];break;case 0:a=[255,1,1,0,1];break;case 128:a=[255,2,0,0,1];break;case 3:a=[1,2,1,0,2,1];break;case 4:a=[1,2,2,0,1,2,3];break;case 5:a=[1,3,2,0,4,1,2,3];break;case 6:a=[1,4,2,0,4,1,2,3,5];break;case 7:a=[1,4,2,0,4,1,2,3,5,6];break;case 8:a=[1,5,3,0,6,1,2,3,4,5,7];break;case 130:a=[1,1,2,0,1];break;case 131:a=[1,1,3,0,1,2];break;case 132:a=[1,1,4,0,1,2,3];break;case 133:a=[1,1,5,0,1,2,3,4];break;case 134:a=[1,1,6,0,1,2,3,4,5];break;case 135:a=[1,1,7,0,1,2,3,4,5,6];break;case 136:a=[1,1,8,0,1,2,3,4,5,6,7]}var r=new Uint8Array(function(e,A,t){if(2===arguments.length)for(var i,n=0,a=A.length;n>>24&255,n>>>17&255,n>>>8&255,n>>>0&255,0,0],function(e,A){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var i,n,a=t.call(e),r=[];try{for(;(void 0===A||A-- >0)&&!(i=a.next()).done;)r.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}return r}(a),!1));return e.box(e.types.dOps,r)},e.avc1=function(A){var t=A.avcc,i=A.codecWidth,n=A.codecHeight,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,n>>>8&255,255&n,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.avc1,a,e.box(e.types.avcC,t))},e.hvc1=function(A){var t=A.hvcc,i=A.codecWidth,n=A.codecHeight,a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i>>>8&255,255&i,n>>>8&255,255&n,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.hvc1,a,e.box(e.types.hvcC,t))},e.av01=function(A){var t,i,n=A.av1c,a=null!==(t=A.codecWidth)&&void 0!==t?t:192,r=null!==(i=A.codecHeight)&&void 0!==i?i:108,o=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>>8&255,255&a,r>>>8&255,255&r,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return e.box(e.types.av01,o,e.box(e.types.av1C,n))},e.mvex=function(A){return e.box(e.types.mvex,e.trex(A))},e.trex=function(A){var t=A.id,i=new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.box(e.types.trex,i)},e.moof=function(A,t){return e.box(e.types.moof,e.mfhd(A.sequenceNumber),e.traf(A,t))},e.mfhd=function(A){var t=new Uint8Array([0,0,0,0,A>>>24&255,A>>>16&255,A>>>8&255,255&A]);return e.box(e.types.mfhd,t)},e.traf=function(A,t){var i=A.id,n=e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>>24&255,i>>>16&255,i>>>8&255,255&i])),a=e.box(e.types.tfdt,new Uint8Array([0,0,0,0,t>>>24&255,t>>>16&255,t>>>8&255,255&t])),r=e.sdtp(A),o=e.trun(A,r.byteLength+16+16+8+16+8+8);return e.box(e.types.traf,n,a,o,r)},e.sdtp=function(A){for(var t=A.samples||[],i=t.length,n=new Uint8Array(4+i),a=0;a>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0);for(var o=0;o>>24&255,s>>>16&255,s>>>8&255,255&s,g>>>24&255,g>>>16&255,g>>>8&255,255&g,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.isNonSync,0,0,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*o)}return e.box(e.types.trun,r)},e.mdat=function(A){return e.box(e.types.mdat,A)},e.constants={FTYP:new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),STSD_PREFIX:new Uint8Array([0,0,0,0,0,0,0,1]),STTS:we,STSC:we,STCO:we,STSZ:new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),HDLR_VIDEO:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),HDLR_AUDIO:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),DREF:new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),SMHD:new Uint8Array([0,0,0,0,0,0,0,0]),VMHD:new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])},e}();be.init();var Fe=be,Re=function(){function e(){}return e.getSilentFrame=function(e,A){if("mp4a.40.2"===e){if(1===A)return new Uint8Array([0,200,0,128,35,128]);if(2===A)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===A)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===A)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===A)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===A)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===A)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===A)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===A)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null},e}(),ke=n(453),Pe=function(){function e(e){var A;this.TAG="MP4Remuxer",this._fillSilentAfterSeek=!1,this._config=e,this._isLive=!!e.isLive,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new ke.Sc("audio"),this._videoSegmentInfoList=new ke.Sc("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!(!I.A.chrome||!(I.A.version&&I.A.version.major<50||I.A.version&&50===I.A.version.major&&((null===(A=I.A.version)||void 0===A?void 0:A.build)||0)<2661)),this._fillSilentAfterSeek=!(!I.A.msedge&&!I.A.msie),this._mp3UseMpegAudio=!I.A.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}return e.prototype.destroy=function(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null},e.prototype.bindDataSource=function(e){var A;return e.onDataAvailable=null===(A=this.remux)||void 0===A?void 0:A.bind(this),e.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this},Object.defineProperty(e.prototype,"onInitSegment",{get:function(){return this._onInitSegment},set:function(e){this._onInitSegment=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMediaSegment",{get:function(){return this._onMediaSegment},set:function(e){this._onMediaSegment=e},enumerable:!1,configurable:!0}),e.prototype.insertDiscontinuity=function(){this._audioNextDts=this._videoNextDts=void 0},e.prototype.seek=function(e){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()},e.prototype.remux=function(e,A){if(!this._onMediaSegment)throw new u.j4("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(e,A),A&&this._remuxVideo(A),e&&this._remuxAudio(e)},e.prototype._onTrackMetadataReceived=function(e,A){var t=null,i="mp4",n=A.codec;if("audio"===e)this._audioMeta=A,"mp3"===A.codec&&this._mp3UseMpegAudio?(i="mpeg",n="",t=new Uint8Array):t=Fe.generateInitSegment(A);else{if("video"!==e)return;this._videoMeta=A,t=Fe.generateInitSegment(A)}if(!this._onInitSegment)throw new u.j4("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(e,{type:e,data:t.buffer,codec:n,container:"".concat(e,"/").concat(i),mediaDuration:A.duration})},e.prototype._calculateDtsBase=function(e,A){var t,i;this._dtsBaseInited||((null===(t=null==e?void 0:e.samples)||void 0===t?void 0:t.length)&&(this._audioDtsBase=e.samples[0].dts),(null===(i=null==A?void 0:A.samples)||void 0===i?void 0:i.length)&&(this._videoDtsBase=A.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)},e.prototype.getTimestampBase=function(){if(this._dtsBaseInited)return this._dtsBase},e.prototype.flushStashedSamples=function(){var e=this._videoStashedLastSample,A=this._audioStashedLastSample,t={type:"video",id:1,sequenceNumber:0,samples:[],length:0};null!=e&&(t.samples.push(e),t.length=null==e?void 0:e.length);var i={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};null!=A&&(i.samples.push(A),i.length=null==A?void 0:A.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(t,!0),this._remuxAudio(i,!0)},e.prototype._remuxAudio=function(e,A){var t,i,n,a,r,o,s;if(null!=this._audioMeta){var g,l,c=e,C=c.samples,h=-1,u=this._audioMeta.refSampleDuration,B="mp3"===this._audioMeta.codec&&this._mp3UseMpegAudio,f=this._dtsBaseInited&&void 0===this._audioNextDts,E=!1;if(C&&0!==C.length&&(1!==C.length||A)){var x=0,Q=null,p=0;B?(x=0,p=c.length):(x=8,p=8+c.length);var m=null;if(C.length>1&&(p-=(m=C.pop()).length),null!=this._audioStashedLastSample){var y=this._audioStashedLastSample;this._audioStashedLastSample=null,C.unshift(y),p+=y.length}null!=m&&(this._audioStashedLastSample=m);var _=C[0].dts-this._dtsBase;if(this._audioNextDts)g=_-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())g=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&"mp3"!==this._audioMeta.originalCodec&&(E=!0);else{var S=this._audioSegmentInfoList.getLastSampleBefore(_);if(null!=S){var v=_-(S.originalDts+S.duration);v<=3&&(v=0),g=_-(S.dts+S.duration+v)}else g=0}if(E){var D=_-g,w=this._videoSegmentInfoList.getLastSegmentBefore(_);if(null!=w&&w.beginDts=3*(u||0)&&this._fillAudioTimestampGap&&!I.A.safari){N=!0;var Y,U=Math.floor(g/(u||0));d.A.w(this.TAG,"Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.\n"+"originalDts: ".concat(T," ms, curRefDts: ").concat(G," ms, ")+"dtsCorrection: ".concat(Math.round(g)," ms, generate: ").concat(U," frames")),b=Math.floor(G),L=Math.floor(G+(u||0))-b,null==(Y=Re.getSilentFrame(null===(n=this._audioMeta)||void 0===n?void 0:n.originalCodec,this._audioMeta.channelCount))&&(d.A.w(this.TAG,"Unable to generate silent frame for "+"".concat(null===(a=this._audioMeta)||void 0===a?void 0:a.originalCodec," with ").concat(this._audioMeta.channelCount," channels, repeat last frame")),Y=P),M=[];for(var J=0;J=1?null===(r=R[R.length-1])||void 0===r?void 0:r.duration:Math.floor(u||0),this._audioNextDts=b+L;-1===h&&(h=b),R.push({dts:b,pts:b,cts:0,unit:y.unit,size:null===(o=y.unit)||void 0===o?void 0:o.byteLength,duration:L,originalDts:T,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),N&&R.push.apply(R,M)}}if(0===R.length)return c.samples=[],void(c.length=0);for(B?Q=new Uint8Array(p):((Q=new Uint8Array(p))[0]=p>>>24&255,Q[1]=p>>>16&255,Q[2]=p>>>8&255,Q[3]=255&p,Q.set(Fe.types.mdat,4)),k=0;k1&&(I-=(C=s.pop()).length),null!=this._videoStashedLastSample){var h=this._videoStashedLastSample;this._videoStashedLastSample=null,s.unshift(h),I+=(null==h?void 0:h.length)||0}null!=C&&(this._videoStashedLastSample=C);var u=s[0].dts-this._dtsBase;if(this._videoNextDts)n=u-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())n=0;else{var B=this._videoSegmentInfoList.getLastSampleBefore(u);if(null!=B){var f=u-(B.originalDts+B.duration);f<=3&&(f=0),n=u-(B.dts+B.duration+f)}else n=0}for(var E=new ke.EZ,x=[],Q=0;Q=1?x[x.length-1].duration:Math.floor((null===(t=this._videoMeta)||void 0===t?void 0:t.refSampleDuration)||0),m){var D=new ke.$_(y,S,v,h.dts,!0);D.fileposition=h.fileposition,E.appendSyncPoint(D)}x.push({dts:y,pts:S,cts:_,units:h.units,size:h.length,isKeyframe:m,duration:v,originalDts:p,flags:{isLeading:0,dependsOn:m?2:1,isDependedOn:m?1:0,hasRedundancy:0,isNonSync:m?0:1}})}for((d=new Uint8Array(I))[0]=I>>>24&255,d[1]=I>>>16&255,d[2]=I>>>8&255,d[3]=255&I,d.set(Fe.types.mdat,4),Q=0;Q0)null===(t=this._demuxer)||void 0===t||t.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments?null===(i=this._mediaDataSource.segments[this._currentSegmentIndex])||void 0===i?void 0:i.timestampBase:0,s=(null===(n=this._demuxer)||void 0===n?void 0:n.parseChunks(e,A))||0;else{var g=null;(g=S.probe(e)).match&&(this._setupFLVDemuxerRemuxer(g),s=(null===(a=this._demuxer)||void 0===a?void 0:a.parseChunks(e,A))||0),g.match||(null==g?void 0:g.needMoreData)||(g=De.probe(e)).match&&(this._setupTSDemuxerRemuxer(g),s=(null===(r=this._demuxer)||void 0===r?void 0:r.parseChunks(e,A))||0),g.match||(null==g?void 0:g.needMoreData)||(g=null,d.A.e(this.TAG,"Non MPEG-TS/FLV, Unsupported media type!"),Promise.resolve().then((function(){o._internalAbort()})),this._emitter.emit(Ne.A.DEMUX_ERROR,Q.A.FORMAT_UNSUPPORTED,"Non MPEG-TS/FLV, Unsupported media type!"))}return s},e.prototype._setupFLVDemuxerRemuxer=function(e){var A;this._demuxer=new S(e,this._config),this._remuxer||(this._remuxer=new Pe(this._config));var t=this._mediaDataSource;void 0===t.duration||isNaN(t.duration)||(this._demuxer.overridedDuration=t.duration),"boolean"==typeof t.hasAudio&&(this._demuxer.overridedHasAudio=t.hasAudio),"boolean"==typeof t.hasVideo&&(this._demuxer.overridedHasVideo=t.hasVideo),t.segments&&this._demuxer&&this._remuxer&&(this._demuxer.timestampBase=null===(A=null==t?void 0:t.segments[this._currentSegmentIndex])||void 0===A?void 0:A.timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this))},e.prototype._setupTSDemuxerRemuxer=function(e){var A=this._demuxer=new De(e,this._config);this._remuxer||(this._remuxer=new Pe(this._config)),A.onError=this._onDemuxException.bind(this),A.onMediaInfo=this._onMediaInfo.bind(this),A.onMetaDataArrived=this._onMetaDataArrived.bind(this),A.onTimedID3Metadata=this._onTimedID3Metadata.bind(this),A.onSMPTE2038Metadata=this._onSMPTE2038Metadata.bind(this),A.onSCTE35Metadata=this._onSCTE35Metadata.bind(this),A.onPESPrivateDataDescriptor=this._onPESPrivateDataDescriptor.bind(this),A.onPESPrivateData=this._onPESPrivateData.bind(this),this._remuxer.bindDataSource(this._demuxer),this._demuxer.bindDataSource(this._ioctl),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this)},e.prototype._onMediaInfo=function(e){var A,t,i=this;null==this._mediaInfo&&(this._mediaInfo=Object.assign({},e),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=(null===(t=null===(A=this._mediaDataSource)||void 0===A?void 0:A.segments)||void 0===t?void 0:t.length)||0,Object.setPrototypeOf(this._mediaInfo,C.A.prototype));var n=Object.assign({},e);Object.setPrototypeOf(n,C.A.prototype),this._mediaInfo.segments&&(this._mediaInfo.segments[this._currentSegmentIndex]=n),this._reportSegmentMediaInfo(this._currentSegmentIndex),null!=this._pendingSeekTime&&Promise.resolve().then((function(){var e=i._pendingSeekTime;i._pendingSeekTime=null,i.seek(e)}))},e.prototype._onMetaDataArrived=function(e){this._emitter.emit(Ne.A.METADATA_ARRIVED,e)},e.prototype._onScriptDataArrived=function(e){this._emitter.emit(Ne.A.SCRIPTDATA_ARRIVED,e)},e.prototype._onTimedID3Metadata=function(e){var A,t=null===(A=this._remuxer)||void 0===A?void 0:A.getTimestampBase();void 0!==t&&(void 0!==e.pts&&(e.pts-=t),void 0!==e.dts&&(e.dts-=t),this._emitter.emit(Ne.A.TIMED_ID3_METADATA_ARRIVED,e))},e.prototype._onSMPTE2038Metadata=function(e){var A,t=null===(A=this._remuxer)||void 0===A?void 0:A.getTimestampBase();void 0!==t&&(void 0!==e.pts&&(e.pts-=t),void 0!==e.dts&&(e.dts-=t),void 0!==e.nearest_pts&&(e.nearest_pts-=t),this._emitter.emit(Ne.A.SMPTE2038_METADATA_ARRIVED,e))},e.prototype._onSCTE35Metadata=function(e){var A,t=null===(A=this._remuxer)||void 0===A?void 0:A.getTimestampBase();void 0!==t&&(void 0!==e.pts&&(e.pts-=t),void 0!==e.nearest_pts&&(e.nearest_pts-=t),this._emitter.emit(Ne.A.SCTE35_METADATA_ARRIVED,e))},e.prototype._onPESPrivateDataDescriptor=function(e){this._emitter.emit(Ne.A.PES_PRIVATE_DATA_DESCRIPTOR,e)},e.prototype._onPESPrivateData=function(e){var A,t=null===(A=this._remuxer)||void 0===A?void 0:A.getTimestampBase();void 0!==t&&(void 0!==e.pts&&(e.pts-=t),void 0!==e.nearest_pts&&(e.nearest_pts-=t),void 0!==e.dts&&(e.dts-=t),this._emitter.emit(Ne.A.PES_PRIVATE_DATA_ARRIVED,e))},e.prototype._onIOSeeked=function(){var e;null===(e=this._remuxer)||void 0===e||e.insertDiscontinuity()},e.prototype._onIOComplete=function(e){var A,t,i=e+1;i<((null===(t=null===(A=this._mediaDataSource)||void 0===A?void 0:A.segments)||void 0===t?void 0:t.length)||0)?(this._internalAbort(),this._remuxer&&this._remuxer.flushStashedSamples(),this._loadSegment(i)):(this._remuxer&&this._remuxer.flushStashedSamples(),this._emitter.emit(Ne.A.LOADING_COMPLETE),this._disableStatisticsReporter())},e.prototype._onIORedirect=function(e){var A,t=null===(A=this._ioctl)||void 0===A?void 0:A.extraData;this._mediaDataSource.segments&&(this._mediaDataSource.segments[t].redirectedURL=e)},e.prototype._onIORecoveredEarlyEof=function(){this._emitter.emit(Ne.A.RECOVERED_EARLY_EOF)},e.prototype._onIOException=function(e,A){d.A.e(this.TAG,"IOException: type = ".concat(e,", code = ").concat(A.code,", msg = ").concat(A.msg)),this._emitter.emit(Ne.A.IO_ERROR,e,A),this._disableStatisticsReporter()},e.prototype._onDemuxException=function(e,A){d.A.e(this.TAG,"DemuxException: type = ".concat(e,", info = ").concat(A)),this._emitter.emit(Ne.A.DEMUX_ERROR,e,A)},e.prototype._onRemuxerInitSegmentArrival=function(e,A){this._emitter.emit(Ne.A.INIT_SEGMENT,e,A)},e.prototype._onRemuxerMediaSegmentArrival=function(e,A){if(null==this._pendingSeekTime&&(this._emitter.emit(Ne.A.MEDIA_SEGMENT,e,A),null!=this._pendingResolveSeekPoint&&"video"===e)){var t=A.info.syncPoints,i=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,I.A.safari&&t.length>0&&t[0].originalDts===i&&(i=t[0].pts),this._emitter.emit(Ne.A.RECOMMEND_SEEKPOINT,i)}},e.prototype._enableStatisticsReporter=function(){null==this._statisticsReporter&&this._reportStatisticsInfo&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))},e.prototype._disableStatisticsReporter=function(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype._reportSegmentMediaInfo=function(e){var A,t,i,n,a=(null===(A=this._mediaInfo)||void 0===A?void 0:A.segments)?null===(t=this._mediaInfo)||void 0===t?void 0:t.segments[e]:{},r=Object.assign({},a);r.duration=null===(i=this._mediaInfo)||void 0===i?void 0:i.duration,r.segmentCount=null===(n=this._mediaInfo)||void 0===n?void 0:n.segmentCount,delete r.segments,delete r.keyframesIndex,this._emitter.emit(Ne.A.MEDIA_INFO,r)},e.prototype._reportStatisticsInfo=function(){var e,A,t,i,n,a,r={};r.url=null===(e=this._ioctl)||void 0===e?void 0:e.currentURL,r.hasRedirect=null===(A=this._ioctl)||void 0===A?void 0:A.hasRedirect,r.hasRedirect&&(r.redirectedURL=null===(t=this._ioctl)||void 0===t?void 0:t.currentRedirectedURL),r.speed=null===(i=this._ioctl)||void 0===i?void 0:i.currentSpeed,r.loaderType=null===(n=this._ioctl)||void 0===n?void 0:n.loaderType,r.currentSegmentIndex=this._currentSegmentIndex,r.totalSegmentCount=null===(a=this._mediaDataSource.segments)||void 0===a?void 0:a.length,this._emitter.emit(Ne.A.STATISTICS_INFO,r)},e}()},716:function(e,A,t){t.d(A,{A:function(){return i}});var i={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",TIMED_ID3_METADATA_ARRIVED:"timed_id3_metadata_arrived",SMPTE2038_METADATA_ARRIVED:"smpte2038_metadata_arrived",SCTE35_METADATA_ARRIVED:"scte35_metadata_arrived",PES_PRIVATE_DATA_DESCRIPTOR:"pes_private_data_descriptor",PES_PRIVATE_DATA_ARRIVED:"pes_private_data_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"}},291:function(e,A,t){var i=function(e,A){var t={msg:Q.A.INIT_SEGMENT,data:{type:e,data:A}};self.postMessage(t,[A.data])},n=function(e,A){var t={msg:Q.A.MEDIA_SEGMENT,data:{type:e,data:A}};self.postMessage(t,[A.data])},a=function(){var e={msg:Q.A.LOADING_COMPLETE};self.postMessage(e)},r=function(){var e={msg:Q.A.RECOVERED_EARLY_EOF};self.postMessage(e)},o=function(e){var A={msg:Q.A.MEDIA_INFO,data:e};self.postMessage(A)},s=function(e){var A={msg:Q.A.METADATA_ARRIVED,data:e};self.postMessage(A)},g=function(e){var A={msg:Q.A.SCRIPTDATA_ARRIVED,data:e};self.postMessage(A)},l=function(e){var A={msg:Q.A.TIMED_ID3_METADATA_ARRIVED,data:e};self.postMessage(A)},c=function(e){var A={msg:Q.A.SMPTE2038_METADATA_ARRIVED,data:e};self.postMessage(A)},d=function(e){var A={msg:Q.A.SCTE35_METADATA_ARRIVED,data:e};self.postMessage(A)},I=function(e){var A={msg:Q.A.PES_PRIVATE_DATA_DESCRIPTOR,data:e};self.postMessage(A)},C=function(e){var A={msg:Q.A.PES_PRIVATE_DATA_ARRIVED,data:e};self.postMessage(A)},h=function(e){var A={msg:Q.A.STATISTICS_INFO,data:e};self.postMessage(A)},u=function(e,A){self.postMessage({msg:Q.A.IO_ERROR,data:{type:e,info:A}})},B=function(e,A){self.postMessage({msg:Q.A.DEMUX_ERROR,data:{type:e,info:A}})},f=function(e){self.postMessage({msg:Q.A.RECOMMEND_SEEKPOINT,data:e})},E=t(641),x=t(976),Q=t(716),p=null,m=function(e,A){self.postMessage({msg:"logcat_callback",data:{type:e,logcat:A}})};self.addEventListener("message",(function(e){switch(e.data.cmd){case"init":(p=new x.A(e.data.param[0],e.data.param[1])).on(Q.A.IO_ERROR,u),p.on(Q.A.DEMUX_ERROR,B),p.on(Q.A.INIT_SEGMENT,i),p.on(Q.A.MEDIA_SEGMENT,n),p.on(Q.A.LOADING_COMPLETE,a),p.on(Q.A.RECOVERED_EARLY_EOF,r),p.on(Q.A.MEDIA_INFO,o),p.on(Q.A.METADATA_ARRIVED,s),p.on(Q.A.SCRIPTDATA_ARRIVED,g),p.on(Q.A.TIMED_ID3_METADATA_ARRIVED,l),p.on(Q.A.SMPTE2038_METADATA_ARRIVED,c),p.on(Q.A.SCTE35_METADATA_ARRIVED,d),p.on(Q.A.PES_PRIVATE_DATA_DESCRIPTOR,I),p.on(Q.A.PES_PRIVATE_DATA_ARRIVED,C),p.on(Q.A.STATISTICS_INFO,h),p.on(Q.A.RECOMMEND_SEEKPOINT,f);break;case"destroy":p&&(p.destroy(),p=null),self.postMessage({msg:"destroyed"});break;case"start":null==p||p.start();break;case"stop":null==p||p.stop();break;case"seek":null==p||p.seek(e.data.param);break;case"pause":null==p||p.pause();break;case"resume":null==p||p.resume();break;case"logging_config":var A=e.data.param;E.A.applyConfig(A),!0===A.enableCallback?E.A.addLogListener(m):E.A.removeLogListener(m)}}))},465:function(e,A,t){t.d(A,{A:function(){return i}});var i={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"}},133:function(e,A,n){var a=function(){return Object.assign({},I)},r=function(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")},o=function(e){return!isNaN(1*e)},s=function(e,A,t){var i={};i[t]=[];var a=A.toString(),s=a.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||a.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!s)return i;for(var g,l=s[1],c=new RegExp("(\\\\n|\\W)"+r(l)+m,"g");g=c.exec(a);)"dll-reference"!==g[3]&&i[t].push(g[3]);for(c=new RegExp("\\("+r(l)+'\\("(dll-reference\\s('+p+'))"\\)\\)'+m,"g");g=c.exec(a);)e[g[2]]||(i[t].push(g[1]),e[g[2]]=n(g[1]).m),i[g[2]]=i[g[2]]||[],i[g[2]].push(g[4]);for(var d=Object.keys(i),I=0;I0}),!1)},l=function(e,A,t,i){var n=e[i].map((function(e){return'"'+e+'": '+A[i][e].toString()})).join(","),a=Q.toString().split("ENTRY_MODULE");return a[0]+"{"+n+"}"+a[1]+'"'+t+'"'+a[2]};n.d(A,{default:function(){return O}});var c={h264:1,h265:2,h266:4,vp8:8,vp9:16,av1:32},d=n(302),I={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,liveBufferLatencyChasing:!1,liveBufferLatencyMaxLatency:1.5,liveBufferLatencyMinRemain:.5,lazyLoad:!0,lazyLoadMaxDuration:180,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:180,autoCleanupMinBackwardDuration:120,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0,url:void 0,redirectedURL:void 0,cors:!1},C=function(){function e(){}return e.supportMSEH264Playback=function(){var e;return null===(e=window.MediaSource)||void 0===e?void 0:e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')},e.supportMSEH265Playback=function(){var e;return null===(e=window.MediaSource)||void 0===e?void 0:e.isTypeSupported('video/mp4; codecs="hvc1.1.6.L93.B0"')},e.supportNetworkStreamIO=function(){var e=new d.A({},a()),A=e.loaderType;return e.destroy(),"fetch-stream-loader"===A||"xhr-moz-chunked-loader"===A},e.getNetworkLoaderTypeName=function(){var e=new d.A({},a()),A=e.loaderType;return e.destroy(),A},e.supportNativeMediaPlayback=function(A){void 0===e.videoElement&&(e.videoElement=window.document.createElement("video"));var t=e.videoElement.canPlayType(A);return"probably"===t||"maybe"===t},e.getFeatureList=function(){var A={msePlayback:!1,mseLivePlayback:!1,mseH265Playback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeMP4H265Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return A.msePlayback=e.supportMSEH264Playback(),A.networkStreamIO=e.supportNetworkStreamIO(),A.networkLoaderName=e.getNetworkLoaderTypeName()||"",A.mseLivePlayback=A.msePlayback&&A.networkStreamIO,A.mseH265Playback=e.supportMSEH265Playback(),A.nativeMP4H264Playback=e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),A.nativeMP4H265Playback=e.supportNativeMediaPlayback('video/mp4; codecs="hvc1.1.6.L93.B0"'),A.nativeWebmVP8Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),A.nativeWebmVP9Playback=e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),A},e}(),h=C,u=n(288),B=n(413),f=n(502),E=n(620),x={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",TIMED_ID3_METADATA_ARRIVED:"timed_id3_metadata_arrived",SMPTE2038_METADATA_ARRIVED:"smpte2038_metadata_arrived",SCTE35_METADATA_ARRIVED:"scte35_metadata_arrived",PES_PRIVATE_DATA_DESCRIPTOR:"pes_private_data_descriptor",PES_PRIVATE_DATA_ARRIVED:"pes_private_data_arrived",STATISTICS_INFO:"statistics_info",DESTROYING:"destroying"},Q=function(){var e=ENTRY_MODULE,A={};function t(i){if(A[i])return A[i].exports;var n=A[i]={exports:{}};return e[i](n,n.exports,t),n.exports}t.m=e,t.n=function(e){var A=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(A,{a:A}),A},t.d=function(e,A){for(var i in A)t.o(A,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:A[i]})},t.g=function(){if("[object Object]"===Object.prototype.toString.call(globalThis))return globalThis;try{return this||new Function("return this")()}catch(e){if("[object Object]"===Object.prototype.toString.call(window))return window}}(),t.o=function(e,A){return Object.prototype.hasOwnProperty.call(e,A)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=t(ENTRY_MODULE);return i.default||i};Q.toString();var p="[\\.|\\-|\\+|\\w|/|@]+",m="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+p+").*?\\)",y=n(641),_=n(976),S=n(716),v=n(825),D=function(){function e(e,A){if(this.TAG="Transmuxer",this._workerDestroying=!1,this._controller=null,this._emitter=new B.A,A.enableWorker&&"undefined"!=typeof Worker)try{this._worker=this._worker=function(e,A){A=A||{};var t={main:n.m},i=A.all?{main:Object.keys(t.main)}:function(e,A){for(var t={main:[A]},i={main:[]},n={main:{}};g(t);)for(var a=Object.keys(t),r=0;r0&&(n+=";codecs=".concat(i.codec));var a=!1;if(f.A.v(this.TAG,"Received Initialization Segment, mimeType: "+n),this._lastInitSegments[i.type]=i,n!==this._mimeTypes[i.type]){if(this._mimeTypes[i.type])f.A.v(this.TAG,"Notice: ".concat(i.type," mimeType changed, origin: ").concat(this._mimeTypes[i.type]||"",", target: ").concat(n));else{a=!0;try{var r=this._sourceBuffers[i.type]=this._mediaSource.addSourceBuffer(n);r.addEventListener("error",this.e.onSourceBufferError),r.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(e){return f.A.e(this.TAG,e.message),void this._emitter.emit(b,{code:e.code,msg:e.message})}}this._mimeTypes[i.type]=n}A||this._pendingSegments[i.type].push(i),a||this._sourceBuffers[i.type]&&!(null===(t=this._sourceBuffers[i.type])||void 0===t?void 0:t.updating)&&this._doAppendSegments(),E.A.safari&&"audio/mpeg"===i.container&&i.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=i.mediaDuration/1e3,this._updateMediaSourceDuration())},e.prototype.appendMediaSegment=function(e){var A=e;this._pendingSegments[A.type].push(A),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();var t=this._sourceBuffers[A.type];!t||t.updating||this._hasPendingRemoveRanges()||this._doAppendSegments()},e.prototype.seek=function(e){var A,t;for(var i in this._sourceBuffers)if(this._sourceBuffers[i]){var n=this._sourceBuffers[i];if("open"===(null===(A=this._mediaSource)||void 0===A?void 0:A.readyState))try{null==n||n.abort()}catch(e){f.A.e(this.TAG,e.message)}this._idrList.clear();var a=this._pendingSegments[i];if(a.splice(0,a.length),"closed"!==(null===(t=this._mediaSource)||void 0===t?void 0:t.readyState)){if(n){for(var r=0;r=1&&t-a.start(0)>=((null===(A=this._config)||void 0===A?void 0:A.autoCleanupMaxBackwardDuration)||0))return!0}}return!1},e.prototype._doCleanupSourceBuffer=function(){var e,A,t,i=null===(e=this._mediaElement)||void 0===e?void 0:e.currentTime;for(var n in this._sourceBuffers){var a=this._sourceBuffers[n];if(a){for(var r=a.buffered,o=!1,s=0;s=((null===(A=this._config)||void 0===A?void 0:A.autoCleanupMaxBackwardDuration)||0)){o=!0;var c=i-((null===(t=this._config)||void 0===t?void 0:t.autoCleanupMinBackwardDuration)||0);this._pendingRemoveRanges[n].push({start:g,end:c})}}else l0&&(isNaN(a)||r>a)&&(f.A.v(this.TAG,"Update MediaSource duration from ".concat(a," to ").concat(r)),this._mediaSource.duration=r),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}},e.prototype._doRemoveRanges=function(){var e;for(var A in this._pendingRemoveRanges)if(this._sourceBuffers[A]&&!(null===(e=this._sourceBuffers[A])||void 0===e?void 0:e.updating))for(var t=this._sourceBuffers[A],i=this._pendingRemoveRanges[A];i.length&&!(null==t?void 0:t.updating);){var n=i.shift();null==t||t.remove(n.start,n.end)}},e.prototype._doAppendSegments=function(){var e,A,t,i=this._pendingSegments;for(var n in i)if(this._sourceBuffers[n]&&!(null===(e=this._sourceBuffers[n])||void 0===e?void 0:e.updating)&&i[n].length>0){var a=i[n].shift();if(null==a?void 0:a.timestampOffset){var r=(null===(A=this._sourceBuffers[n])||void 0===A?void 0:A.timestampOffset)||0,o=a.timestampOffset/1e3;Math.abs(r-o)>.1&&(f.A.v(this.TAG,"Update MPEG audio timestampOffset from ".concat(r," to ").concat(o)),this._sourceBuffers[n]&&(this._sourceBuffers[n].timestampOffset=o)),delete a.timestampOffset}if(!a.data||0===a.data.byteLength)continue;try{null===(t=this._sourceBuffers[n])||void 0===t||t.appendBuffer(a.data),this._isBufferFull=!1,"video"===n&&a.hasOwnProperty("info")&&this._idrList.appendArray(a.info.syncPoints)}catch(e){this._pendingSegments[n].unshift(a),22===e.code?(this._isBufferFull||this._emitter.emit(k),this._isBufferFull=!0):(f.A.e(this.TAG,e.message),this._emitter.emit(b,{code:e.code,msg:e.message}))}}},e.prototype._onSourceOpen=function(){var e;if(f.A.v(this.TAG,"MediaSource onSourceOpen"),null===(e=this._mediaSource)||void 0===e||e.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0)for(var A=this._pendingSourceBufferInit;A.length;){var t=A.shift();this.appendInitSegment(t,!0)}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(F)},e.prototype._onSourceEnded=function(){f.A.v(this.TAG,"MediaSource onSourceEnded")},e.prototype._onSourceClose=function(){f.A.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&null!=this.e&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))},e.prototype._hasPendingSegments=function(){var e=this._pendingSegments;return e.video.length>0||e.audio.length>0},e.prototype._hasPendingRemoveRanges=function(){var e=this._pendingRemoveRanges;return e.video.length>0||e.audio.length>0},e.prototype._onSourceBufferUpdateEnd=function(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(R)},e.prototype._onSourceBufferError=function(e){f.A.e(this.TAG,"SourceBuffer Error: ".concat(e))},e}(),M=N,L=n(465),G={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},Y={NETWORK_EXCEPTION:u.Xv.EXCEPTION,NETWORK_STATUS_CODE_INVALID:u.Xv.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:u.Xv.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:u.Xv.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:L.A.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:L.A.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:L.A.CODEC_UNSUPPORTED},U=function(){function e(e,A){var t,n,r;this.TAG="MSEPlayer",this._type="MSEPlayer",this._emitter=new B.A,this._config=a(),"object"==(void 0===A?"undefined":i(A))&&Object.assign(this._config,A);var o=e.type.toLowerCase();if("mse"!==o&&"mpegts"!==o&&"m2ts"!==o&&"flv"!==o)throw new T.Qn("MSEPlayer requires an mpegts/m2ts/flv MediaDataSource input!");e.isLive&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=e,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;var s=E.A.chrome&&(E.A.version&&(null===(t=E.A.version)||void 0===t?void 0:t.major)<50||E.A.version&&50===(null===(n=null===E.A||void 0===E.A?void 0:E.A.version)||void 0===n?void 0:n.major)&&((null===(r=null===E.A||void 0===E.A?void 0:E.A.version)||void 0===r?void 0:r.build)||-1)<2661);this._alwaysSeekKeyframe=!!(s||E.A.msedge||E.A.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}return e.prototype.destroy=function(){this._emitter.emit(x.DESTROYING),null!=this._progressChecker&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null},e.prototype.on=function(e,A){var t=this;e===x.MEDIA_INFO?null!=this._mediaInfo&&Promise.resolve().then((function(){t._emitter.emit(x.MEDIA_INFO,t.mediaInfo)})):e===x.STATISTICS_INFO&&null!=this._statisticsInfo&&Promise.resolve().then((function(){t._emitter.emit(x.STATISTICS_INFO,t.statisticsInfo)})),this._emitter.addListener(e,A)},e.prototype.off=function(e,A){this._emitter.removeListener(e,A)},e.prototype.attachMediaElement=function(e){var A,t,i,n,a,r=this;if(this._mediaElement=e,e.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),e.addEventListener("seeking",this.e.onvSeeking),e.addEventListener("canplay",this.e.onvCanPlay),e.addEventListener("stalled",this.e.onvStalled),e.addEventListener("progress",this.e.onvProgress),this._msectl=new M(this._config),null===(A=this._msectl)||void 0===A||A.on(R,this._onmseUpdateEnd.bind(this)),null===(t=this._msectl)||void 0===t||t.on(k,this._onmseBufferFull.bind(this)),null===(i=this._msectl)||void 0===i||i.on(F,(function(){r._mseSourceOpened=!0,r._hasPendingLoad&&(r._hasPendingLoad=!1,r.load())})),null===(n=this._msectl)||void 0===n||n.on(b,(function(e){r._emitter.emit(x.ERROR,G.MEDIA_ERROR,Y.MEDIA_MSE_ERROR,e)})),null===(a=this._msectl)||void 0===a||a.attachMediaElement(e),null!=this._pendingSeekTime)try{e.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(e){}},e.prototype.detachMediaElement=function(){var e;this._mediaElement&&(null===(e=this._msectl)||void 0===e||e.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)},e.prototype.load=function(){var e=this;if(!this._mediaElement)throw new T.j4("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new T.j4("MSEPlayer.load() has been called, please call unload() first!");this._hasPendingLoad||(!this._config.deferLoadAfterSourceOpen||this._mseSourceOpened?(this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new w(this._mediaDataSource,this._config),this._transmuxer.on(S.A.INIT_SEGMENT,(function(A,t){var i;null===(i=e._msectl)||void 0===i||i.appendInitSegment(t)})),this._transmuxer.on(S.A.MEDIA_SEGMENT,(function(A,t){var i,n,a;if(null===(i=e._msectl)||void 0===i||i.appendMediaSegment(t),e._config.lazyLoad&&!e._config.isLive){var r=null===(n=e._mediaElement)||void 0===n?void 0:n.currentTime;t.info.endDts>=1e3*(r+((null===(a=e._config)||void 0===a?void 0:a.lazyLoadMaxDuration)||0))&&null==e._progressChecker&&(f.A.v(e.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),e._suspendTransmuxer())}})),this._transmuxer.on(S.A.LOADING_COMPLETE,(function(){var A;null===(A=e._msectl)||void 0===A||A.endOfStream(),e._emitter.emit(x.LOADING_COMPLETE)})),this._transmuxer.on(S.A.RECOVERED_EARLY_EOF,(function(){e._emitter.emit(x.RECOVERED_EARLY_EOF)})),this._transmuxer.on(S.A.IO_ERROR,(function(A,t){e._emitter.emit(x.ERROR,G.NETWORK_ERROR,A,t)})),this._transmuxer.on(S.A.DEMUX_ERROR,(function(A,t){e._emitter.emit(x.ERROR,G.MEDIA_ERROR,A,{code:-1,msg:t})})),this._transmuxer.on(S.A.MEDIA_INFO,(function(A){e._mediaInfo=A,e._emitter.emit(x.MEDIA_INFO,Object.assign({},A))})),this._transmuxer.on(S.A.METADATA_ARRIVED,(function(A){e._emitter.emit(x.METADATA_ARRIVED,A)})),this._transmuxer.on(S.A.SCRIPTDATA_ARRIVED,(function(A){e._emitter.emit(x.SCRIPTDATA_ARRIVED,A)})),this._transmuxer.on(S.A.TIMED_ID3_METADATA_ARRIVED,(function(A){e._emitter.emit(x.TIMED_ID3_METADATA_ARRIVED,A)})),this._transmuxer.on(S.A.SMPTE2038_METADATA_ARRIVED,(function(A){e._emitter.emit(x.SMPTE2038_METADATA_ARRIVED,A)})),this._transmuxer.on(S.A.SCTE35_METADATA_ARRIVED,(function(A){e._emitter.emit(x.SCTE35_METADATA_ARRIVED,A)})),this._transmuxer.on(S.A.PES_PRIVATE_DATA_DESCRIPTOR,(function(A){e._emitter.emit(x.PES_PRIVATE_DATA_DESCRIPTOR,A)})),this._transmuxer.on(S.A.PES_PRIVATE_DATA_ARRIVED,(function(A){e._emitter.emit(x.PES_PRIVATE_DATA_ARRIVED,A)})),this._transmuxer.on(S.A.STATISTICS_INFO,(function(A){e._statisticsInfo=e._fillStatisticsInfo(A),e._emitter.emit(x.STATISTICS_INFO,Object.assign({},e._statisticsInfo))})),this._transmuxer.on(S.A.RECOMMEND_SEEKPOINT,(function(A){e._mediaElement&&!e._config.accurateSeek&&(e._requestSetTime=!0,e._mediaElement.currentTime=A/1e3)})),this._transmuxer.open()):this._hasPendingLoad=!0)},e.prototype.unload=function(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)},e.prototype.play=function(){var e;return function(e,A,i,n){return new(i||(i=Promise))((function(A,a){function r(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var n;e.done?A(e.value):(n=e.value,t(n,i)?n:new i((function(e){e(n)}))).then(r,o)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function(){return function(e,A){var t,i,n,a,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(r=0)),r;)try{if(t=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,i=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!((n=(n=r.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]0&&!(null===(t=this._mediaElement)||void 0===t?void 0:t.paused)){var r=n.end(n.length-1);if(r>((null===(i=this._config)||void 0===i?void 0:i.liveBufferLatencyMaxLatency)||0)&&r-a>(this._config.liveBufferLatencyMaxLatency||0)){var o=r-(this._config.liveBufferLatencyMinRemain||0);this.currentTime=o}}if(this._config.lazyLoad&&!this._config.isLive){for(var s=0,g=0;g=a+(this._config.lazyLoadMaxDuration||0)&&null==this._progressChecker&&(f.A.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}},e.prototype._onmseBufferFull=function(){f.A.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),null==this._progressChecker&&this._suspendTransmuxer()},e.prototype._suspendTransmuxer=function(){this._transmuxer&&(this._transmuxer.pause(),null==this._progressChecker&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))},e.prototype._checkProgressAndResume=function(){for(var e,A,t,i=(null===(e=this._mediaElement)||void 0===e?void 0:e.currentTime)||0,n=null===(A=this._mediaElement)||void 0===A?void 0:A.buffered,a=!1,r=0;r=o&&i=s-(this._config.lazyLoadRecoverDuration||0)&&(a=!0);break}}a&&(window.clearInterval(this._progressChecker),this._progressChecker=null,a&&(f.A.v(this.TAG,"Continue loading from paused position"),null===(t=this._transmuxer)||void 0===t||t.resume()))},e.prototype._isTimepointBuffered=function(e){for(var A,t=null===(A=this._mediaElement)||void 0===A?void 0:A.buffered,i=0;i=n&&e0){var g=(null===(t=this._mediaElement)||void 0===t?void 0:t.buffered).start(0);(g<1&&e0&&A.currentTime0){var r=a.start(0);if(r<1&&n0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)},e.prototype.unload=function(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),null!=this._statisticsReporter&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)},e.prototype.play=function(){var e;return function(e,A,i,n){return new(i||(i=Promise))((function(A,a){function r(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var n;e.done?A(e.value):(n=e.value,t(n,i)?n:new i((function(e){e(n)}))).then(r,o)}s((n=n.apply(e,[])).next())}))}(this,0,void 0,(function(){return function(e,A){var t,i,n,a,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(r=0)),r;)try{if(t=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,i=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!((n=(n=r.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]=500?this.currentKBps:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageKBps",{get:function(){var e=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/e/1024},enumerable:!1,configurable:!0}),e}(),s=n(288),g=n(620),l=n(713),c=(a=function(e,A){return a=Object.setPrototypeOf||t({__proto__:[]},Array)&&function(e,A){e.__proto__=A}||function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])},a(e,A)},function(e,A){if("function"!=typeof A&&null!==A)throw new TypeError("Class extends value "+String(A)+" is not a constructor or null");function t(){this.constructor=e}a(e,A),e.prototype=null===A?Object.create(A):(t.prototype=A.prototype,new t)}),d=function(e){function A(A,t){var i=e.call(this,"fetch-stream-loader")||this;return i.TAG="FetchStreamLoader",i._seekHandler=A,i._config=t,i._needStash=!0,i._requestAbort=!1,i._abortController=null,i._contentLength=null,i._receivedLength=0,i}return c(A,e),A.isSupported=function(){var e;try{var A=g.A.msedge&&((null===(e=null===g.A||void 0===g.A?void 0:g.A.version)||void 0===e?void 0:e.minor)||0)>=15048&&!g.A.webkit,t=!g.A.msedge||A;return self.fetch&&self.ReadableStream&&t}catch(e){return!1}},A.prototype.destroy=function(){this.isWorking()&&this.abort(),e.prototype.destroy.call(this)},A.prototype.open=function(e,A){var t=this;this._dataSource=e,this._range=A;var n=e.url;this._config.reuseRedirectedURL&&void 0!==e.redirectedURL&&(n=e.redirectedURL);var a=this._seekHandler.getConfig(n,A),r=new self.Headers;if("object"==i(a.headers)){var o=a.headers;for(var g in o)o.hasOwnProperty(g)&&r.append(g,o[g])}var c={method:"GET",headers:r,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if("object"==i(this._config.headers))for(var g in this._config.headers)r.append(g,this._config.headers[g]);e.cors||(c.mode="same-origin"),e.withCredentials&&(c.credentials="include"),(null==e?void 0:e.referrerPolicy)&&(c.referrerPolicy=e.referrerPolicy),self.AbortController&&(this._abortController=new self.AbortController,this._abortController&&(c.signal=this._abortController.signal)),this._status=s.eO.kConnecting,self.fetch(a.url,c).then((function(e){var A,i;if(t._requestAbort)return t._status=s.eO.kIdle,void(null===(A=e.body)||void 0===A||A.cancel());if(e.ok&&e.status>=200&&e.status<=299){if(e.url!==a.url&&t._onURLRedirect){var n=t._seekHandler.removeURLParameters(e.url);t._onURLRedirect(n)}var r=e.headers.get("Content-Length");return null!=r&&(t._contentLength=parseInt(r),0!==t._contentLength&&t._onContentLengthKnown&&t._onContentLengthKnown(t._contentLength)),t._pump.call(t,null===(i=e.body)||void 0===i?void 0:i.getReader())}if(t._status=s.eO.kError,!t._onError)throw new l.Al("FetchStreamLoader: Http code invalid, "+e.status+" "+e.statusText);t._onError(s.Xv.HTTP_STATUS_CODE_INVALID,{code:e.status,msg:e.statusText})})).catch((function(e){var A;if(!(null===(A=t._abortController)||void 0===A?void 0:A.signal.aborted)){if(t._status=s.eO.kError,!t._onError)throw e;t._onError(s.Xv.EXCEPTION,{code:-1,msg:e.message})}}))},A.prototype.abort=function(){var e;if(this._requestAbort=!0,(this._status!==s.eO.kBuffering||!g.A.chrome)&&this._abortController)try{null===(e=this._abortController)||void 0===e||e.abort()}catch(e){}},A.prototype._pump=function(e){var A=this;return e.read().then((function(t){var i,n,a,r;if(t.done)if(null!==A._contentLength&&A._receivedLength299)){if(this._status=s.eO.kError,!this._onError)throw new l.Al("MozChunkedLoader: Http code invalid, "+A.status+" "+A.statusText);this._onError(s.Xv.HTTP_STATUS_CODE_INVALID,{code:A.status,msg:A.statusText})}else this._status=s.eO.kBuffering}},A.prototype._onProgress=function(e){var A;if(this._status!==s.eO.kError){null===this._contentLength&&null!==e.total&&0!==e.total&&(this._contentLength=e.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));var t=e.target.response,i=((null===(A=this._range)||void 0===A?void 0:A.from)||0)+this._receivedLength;this._receivedLength+=t.byteLength,this._onDataArrival&&this._onDataArrival(t,i,this._receivedLength)}},A.prototype._onLoadEnd=function(e){this._requestAbort?this._requestAbort=!1:this._status!==s.eO.kError&&(this._status=s.eO.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))},A.prototype._onXhrError=function(e){this._status=s.eO.kError;var A=0,t=null;if(this._contentLength&&e.loaded=this._contentLength&&(n=((null===(A=this._range)||void 0===A?void 0:A.from)||0)+this._contentLength-1),this._currentRequestRange={from:i,to:n},this._internalOpen(this._dataSource,this._currentRequestRange)},A.prototype._internalOpen=function(e,A){this._lastTimeLoaded=0;var t=e.url;this._config.reuseRedirectedURL&&(null!=this._currentRedirectedURL?t=this._currentRedirectedURL:null!=e.redirectedURL&&(t=e.redirectedURL));var n=this._seekHandler.getConfig(t,A);this._currentRequestURL=n.url;var a=this._xhr=new XMLHttpRequest;if(a.open("GET",n.url,!0),a.responseType="arraybuffer",a.onreadystatechange=this._onReadyStateChange.bind(this),a.onprogress=this._onProgress.bind(this),a.onload=this._onLoad.bind(this),a.onerror=this._onXhrError.bind(this),e.withCredentials&&(a.withCredentials=!0),"object"==i(n.headers)){var r=n.headers;for(var o in r)r.hasOwnProperty(o)&&a.setRequestHeader(o,r[o])}if("object"==i(this._config.headers))for(var o in r=this._config.headers)r.hasOwnProperty(o)&&a.setRequestHeader(o,r[o]);a.send()},A.prototype.abort=function(){this._requestAbort=!0,this._internalAbort(),this._status=s.eO.kComplete},A.prototype._internalAbort=function(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)},A.prototype._onReadyStateChange=function(e){var A=e.target;if(2===A.readyState){if(null!=A.responseURL){var t=this._seekHandler.removeURLParameters(A.responseURL);A.responseURL!==this._currentRequestURL&&t!==this._currentRedirectedURL&&(this._currentRedirectedURL=t,this._onURLRedirect&&this._onURLRedirect(t))}if(A.status>=200&&A.status<=299){if(this._waitForTotalLength)return;this._status=s.eO.kBuffering}else{if(this._status=s.eO.kError,!this._onError)throw new l.Al("RangeLoader: Http code invalid, "+A.status+" "+A.statusText);this._onError(s.Xv.HTTP_STATUS_CODE_INVALID,{code:A.status,msg:A.statusText})}}},A.prototype._onProgress=function(e){if(this._status!==s.eO.kError){if(null===this._contentLength){var A=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,A=!0;var t=e.total;this._internalAbort(),null!=t&&0!==t&&(this._totalLength=t)}if(-1===this._range.to?this._contentLength=(this._totalLength||0)-this._range.from:this._contentLength=this._range.to-this._range.from+1,A)return void this._openSubRange();this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}var i=e.loaded-this._lastTimeLoaded;this._lastTimeLoaded=e.loaded,this._speedSampler.addBytes(i)}},A.prototype._normalizeSpeed=function(e){var A=this._chunkSizeKBList,t=A.length-1,i=0,n=0,a=t;if(e=A[i]&&e=3&&(A=this._speedSampler.currentKBps)),0!==A){var t=this._normalizeSpeed(A);this._currentSpeedNormalized!==t&&(this._currentSpeedNormalized=t,this._currentChunkSizeKB=t)}var i=e.target.response,n=this._range.from+this._receivedLength;this._receivedLength+=i.byteLength;var a=!1;null!=this._contentLength&&this._receivedLength0&&this._receivedLength0)for(var a=A.split("&"),r=0;r0;o[0]!==this._startName&&o[0]!==this._endName&&(s&&(n+="&"),n+=a[r])}return 0===n.length?t:t+"?"+n},e}(),Q=function(){function e(e,A,t){this.TAG="IOController",this._config=A,this._extraData=t,this._stashInitialSize=65536,void 0!==A.stashInitialSize&&A.stashInitialSize>0&&(this._stashInitialSize=A.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=3145728,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,A.enableStashBuffer||(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=e,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(e.url||""),this._refTotalLength=e.filesize?e.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new o,this._speedNormalizeList=[32,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}return e.prototype.destroy=function(){var e,A,t;(null===(e=this._loader)||void 0===e?void 0:e.isWorking())&&(null===(A=this._loader)||void 0===A||A.abort()),null===(t=this._loader)||void 0===t||t.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null},e.prototype.isWorking=function(){var e;return(null===(e=this._loader)||void 0===e?void 0:e.isWorking())&&!this._paused},e.prototype.isPaused=function(){return this._paused},Object.defineProperty(e.prototype,"status",{get:function(){var e;return null===(e=this._loader)||void 0===e?void 0:e.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extraData",{get:function(){return this._extraData},set:function(e){this._extraData=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSeeked",{get:function(){return this._onSeeked},set:function(e){this._onSeeked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:function(){return this._onComplete},set:function(e){this._onComplete=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRedirect",{get:function(){return this._onRedirect},set:function(e){this._onRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onRecoveredEarlyEof",{get:function(){return this._onRecoveredEarlyEof},set:function(e){this._onRecoveredEarlyEof=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentURL",{get:function(){var e;return null===(e=this._dataSource)||void 0===e?void 0:e.url},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRedirect",{get:function(){var e;return null!=this._redirectedURL||void 0!==(null===(e=this._dataSource)||void 0===e?void 0:e.redirectedURL)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentRedirectedURL",{get:function(){var e;return this._redirectedURL||(null===(e=this._dataSource)||void 0===e?void 0:e.redirectedURL)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentSpeed",{get:function(){var e,A;return this._loaderClass===u?null===(e=this._loader)||void 0===e?void 0:e.currentSpeed:null===(A=this._speedSampler)||void 0===A?void 0:A.lastSecondKBps},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loaderType",{get:function(){var e;return null===(e=this._loader)||void 0===e?void 0:e.type},enumerable:!1,configurable:!0}),e.prototype._selectSeekHandler=function(){var e=this._config;if("range"===e.seekType)this._seekHandler=new E(!!this._config.rangeLoadZeroStart);else if("param"===e.seekType){var A=e.seekParamStart||"bstart",t=e.seekParamEnd||"bend";this._seekHandler=new x(A,t)}else{if("custom"!==e.seekType)throw new l.Qn("Invalid seekType in config: ".concat((null==e?void 0:e.seekType)||""));if("function"!=typeof e.customSeekHandler)throw new l.Qn("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new e.customSeekHandler}},e.prototype._selectLoader=function(){var e;if(null!=this._config.customLoader)this._loaderClass=(null===(e=this._config)||void 0===e?void 0:e.customLoader)||null;else if(this._isWebSocketURL)this._loaderClass=f;else if(d.isSupported())this._loaderClass=d;else if(C.isSupported())this._loaderClass=C;else{if(!u.isSupported())throw new l.Al("Your browser doesn't support xhr with arraybuffer responseType!");this._loaderClass=u}},e.prototype._createLoader=function(){var e;this._loaderClass&&(this._loader=new this._loaderClass(this._seekHandler,this._config),(null===(e=this._loader)||void 0===e?void 0:e.needStashBuffer)||(this._enableStash=!1),this._loader&&(this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)))},e.prototype.open=function(e){var A,t;this._currentRange={from:0,to:-1},e&&(this._currentRange.from=e),null===(A=this._speedSampler)||void 0===A||A.reset(),e||(this._fullRequestFlag=!0),null===(t=this._loader)||void 0===t||t.open(this._dataSource,Object.assign({},this._currentRange))},e.prototype.abort=function(){var e;null===(e=this._loader)||void 0===e||e.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)},e.prototype.pause=function(){var e,A;this.isWorking()&&(null===(e=this._loader)||void 0===e||e.abort(),0!==this._stashUsed?(this._resumeFrom=this._stashByteStart,this._currentRange&&(this._currentRange.to=this._stashByteStart-1)):this._resumeFrom=((null===(A=this._currentRange)||void 0===A?void 0:A.to)||0)+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)},e.prototype.resume=function(){if(this._paused){this._paused=!1;var e=this._resumeFrom;this._resumeFrom=0,this._internalSeek(e,!0)}},e.prototype.seek=function(e){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(e,!0)},e.prototype._internalSeek=function(e,A){var t,i,n,a;(null===(t=this._loader)||void 0===t?void 0:t.isWorking())&&(null===(i=this._loader)||void 0===i||i.abort()),this._flushStashBuffer(A),null===(n=this._loader)||void 0===n||n.destroy(),this._loader=null;var r={from:e,to:-1};this._currentRange={from:r.from,to:-1},null===(a=this._speedSampler)||void 0===a||a.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,r),this._onSeeked&&this._onSeeked()},e.prototype.updateUrl=function(e){if(!e||"string"!=typeof e||0===e.length)throw new l.Qn("Url must be a non-empty string!");this._dataSource.url=e},e.prototype._expandBuffer=function(e){for(var A=this._stashSize;A+10485760){var i=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(t,0,A).set(i,0)}this._stashBuffer=t,this._bufferSize=A}},e.prototype._normalizeSpeed=function(e){var A=this._speedNormalizeList,t=A.length-1,i=0,n=0,a=t;if(e=A[i]&&e=512&&e<=1024?Math.floor(1.5*e):2*e)>8192&&(A=8192);var t=1024*A+1048576;this._bufferSize0){var o=this._stashBuffer.slice(0,this._stashUsed);(c=this._dispatchChunks(o,this._stashByteStart))0&&(d=new Uint8Array(o,c),g.set(d,0),this._stashUsed=d.byteLength,this._stashByteStart+=c):(this._stashUsed=0,this._stashByteStart+=c),this._stashUsed+e.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+e.byteLength),g=new Uint8Array(this._stashBuffer,0,this._bufferSize)),g.set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength}else(c=this._dispatchChunks(e,A))this._bufferSize&&(this._expandBuffer(s),g=new Uint8Array(this._stashBuffer,0,this._bufferSize)),g.set(new Uint8Array(e,c),0),this._stashUsed+=s,this._stashByteStart=A+c);else if(0===this._stashUsed){var s;(c=this._dispatchChunks(e,A))this._bufferSize&&this._expandBuffer(s),(g=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e,c),0),this._stashUsed+=s,this._stashByteStart=A+c)}else{var g,c;if(this._stashUsed+e.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+e.byteLength),(g=new Uint8Array(this._stashBuffer,0,this._bufferSize)).set(new Uint8Array(e),this._stashUsed),this._stashUsed+=e.byteLength,(c=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart))0){var d=new Uint8Array(this._stashBuffer,c);g.set(d,0)}this._stashUsed-=c,this._stashByteStart+=c}}},e.prototype._flushStashBuffer=function(e){if(this._stashUsed>0){var A=this._stashBuffer.slice(0,this._stashUsed),t=this._dispatchChunks(A,this._stashByteStart),i=A.byteLength-t;if(t0){var n=new Uint8Array(this._stashBuffer,0,this._bufferSize),a=new Uint8Array(A,t);n.set(a,0),this._stashUsed=a.byteLength,this._stashByteStart+=t}return 0}r.A.w(this.TAG,"".concat(i," bytes unconsumed data remain when flush buffer, dropped"))}return this._stashUsed=0,this._stashByteStart=0,i}return 0},e.prototype._onLoaderComplete=function(e,A){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)},e.prototype._onLoaderError=function(e,A){var t;switch(r.A.e(this.TAG,"Loader error, code = ".concat(A.code,", msg = ").concat(A.msg)),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,e=s.Xv.UNRECOVERABLE_EARLY_EOF),e){case s.Xv.EARLY_EOF:if(!this._config.isLive&&this._totalLength){var i=((null===(t=this._currentRange)||void 0===t?void 0:t.to)||0)+1;return void(i1&&(a.version.minor=parseInt(r[1],10)),r.length>2&&(a.version.build=parseInt(r[2],10))}if(n.platform&&(a[n.platform]=!0),(a.chrome||a.opr||a.safari)&&(a.webkit=!0),a.rv||a.iemobile){a.rv&&delete a.rv;var o="msie";n.browser=o,a[o]=!0}if(a.edge){delete a.edge;var s="msedge";n.browser=s,a[s]=!0}if(a.opr){var g="opera";n.browser=g,a[g]=!0}if(a.safari&&a.android){var l="android";n.browser=l,a[l]=!0}for(var c in a.name=n.browser,a.platform=n.platform,i)Object.prototype.hasOwnProperty.call(i,c)&&delete i[c];Object.assign(i,a)}();var n=i},713:function(e,A,i){i.d(A,{Al:function(){return r},Qn:function(){return s},Xu:function(){return g},j4:function(){return o}});var n,a=(n=function(e,A){return n=Object.setPrototypeOf||t({__proto__:[]},Array)&&function(e,A){e.__proto__=A}||function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])},n(e,A)},function(e,A){if("function"!=typeof A&&null!==A)throw new TypeError("Class extends value "+String(A)+" is not a constructor or null");function t(){this.constructor=e}n(e,A),e.prototype=null===A?Object.create(A):(t.prototype=A.prototype,new t)}),r=function(){function e(e){this.name="RuntimeException",this._message=e}return Object.defineProperty(e.prototype,"message",{get:function(){return this._message},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.name+": "+this.message},e}(),o=function(e){function A(A){var t=e.call(this,A)||this;return t.name="IllegalStateException",t}return a(A,e),A}(r),s=function(e){function A(A){var t=e.call(this,A)||this;return t.name="InvalidArgumentException",t}return a(A,e),A}(r),g=function(e){function A(A){var t=e.call(this,A)||this;return t.name="NotImplementedException",t}return a(A,e),A}(r)},502:function(e,A,t){t.d(A,{A:function(){return n}});var i=t(413),n=function(){function e(){}return e.e=function(A,t){var i;A&&!e.FORCE_GLOBAL_TAG||(A=e.GLOBAL_TAG);var n="[".concat(A,"] > ").concat(t);e.ENABLE_CALLBACK&&(null===(i=e.emitter)||void 0===i||i.emit("log","error",n)),e.ENABLE_ERROR&&(console.error||console.warn)},e.i=function(A,t){A&&!e.FORCE_GLOBAL_TAG||(A=e.GLOBAL_TAG);var i="[".concat(A,"] > ").concat(t);e.ENABLE_CALLBACK&&e.emitter.emit("log","info",i),e.ENABLE_INFO&&console.info},e.w=function(A,t){A&&!e.FORCE_GLOBAL_TAG||(A=e.GLOBAL_TAG);var i="[".concat(A,"] > ").concat(t);e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",i),e.ENABLE_WARN&&console.warn},e.d=function(A,t){var i;A&&!e.FORCE_GLOBAL_TAG||(A=e.GLOBAL_TAG);var n="[".concat(A,"] > ").concat(t);e.ENABLE_CALLBACK&&(null===(i=e.emitter)||void 0===i||i.emit("log","debug",n)),e.ENABLE_DEBUG&&console.debug},e.v=function(A,t){var i;A&&!e.FORCE_GLOBAL_TAG||(A=e.GLOBAL_TAG);var n="[".concat(A,"] > ").concat(t);e.ENABLE_CALLBACK&&(null===(i=e.emitter)||void 0===i||i.emit("log","verbose",n)),e.ENABLE_VERBOSE},e.FORCE_GLOBAL_TAG=!1,e.GLOBAL_TAG="ezuikit-flv",e.ENABLE_CALLBACK=!1,e.emitter=new i.A,e.ENABLE_ERROR=!0,e.ENABLE_INFO=!0,e.ENABLE_WARN=!0,e.ENABLE_DEBUG=!0,e.ENABLE_VERBOSE=!0,e}()},641:function(e,A,t){t.d(A,{A:function(){return a}});var i=t(413),n=t(502),a=function(){function e(){}return Object.defineProperty(e,"forceGlobalTag",{get:function(){return n.A.FORCE_GLOBAL_TAG},set:function(A){n.A.FORCE_GLOBAL_TAG=A,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"globalTag",{get:function(){return n.A.GLOBAL_TAG},set:function(A){n.A.GLOBAL_TAG=A,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableAll",{get:function(){return n.A.ENABLE_VERBOSE&&n.A.ENABLE_DEBUG&&n.A.ENABLE_INFO&&n.A.ENABLE_WARN&&n.A.ENABLE_ERROR},set:function(A){n.A.ENABLE_VERBOSE=A,n.A.ENABLE_DEBUG=A,n.A.ENABLE_INFO=A,n.A.ENABLE_WARN=A,n.A.ENABLE_ERROR=A,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableDebug",{get:function(){return n.A.ENABLE_DEBUG},set:function(A){n.A.ENABLE_DEBUG=A,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableVerbose",{get:function(){return n.A.ENABLE_VERBOSE},set:function(A){n.A.ENABLE_VERBOSE=A,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableInfo",{get:function(){return n.A.ENABLE_INFO},set:function(A){n.A.ENABLE_INFO=A,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableWarn",{get:function(){return n.A.ENABLE_WARN},set:function(A){n.A.ENABLE_WARN=A,e._notifyChange()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"enableError",{get:function(){return n.A.ENABLE_ERROR},set:function(A){n.A.ENABLE_ERROR=A,e._notifyChange()},enumerable:!1,configurable:!0}),e.getConfig=function(){return{globalTag:n.A.GLOBAL_TAG,forceGlobalTag:n.A.FORCE_GLOBAL_TAG,enableVerbose:n.A.ENABLE_VERBOSE,enableDebug:n.A.ENABLE_DEBUG,enableInfo:n.A.ENABLE_INFO,enableWarn:n.A.ENABLE_WARN,enableError:n.A.ENABLE_ERROR,enableCallback:n.A.ENABLE_CALLBACK}},e.applyConfig=function(e){n.A.GLOBAL_TAG=e.globalTag,n.A.FORCE_GLOBAL_TAG=e.forceGlobalTag,n.A.ENABLE_VERBOSE=e.enableVerbose,n.A.ENABLE_DEBUG=e.enableDebug,n.A.ENABLE_INFO=e.enableInfo,n.A.ENABLE_WARN=e.enableWarn,n.A.ENABLE_ERROR=e.enableError,n.A.ENABLE_CALLBACK=!!e.enableCallback},e._notifyChange=function(){var A=e.emitter;if(A.listenerCount("change")>0){var t=e.getConfig();A.emit("change",t)}},e.registerListener=function(A){e.emitter.addListener("change",A)},e.removeListener=function(A){e.emitter.removeListener("change",A)},e.addLogListener=function(A){n.A.emitter.addListener("log",A),n.A.emitter.listenerCount("log")>0&&(n.A.ENABLE_CALLBACK=!0,e._notifyChange())},e.removeLogListener=function(A){n.A.emitter.removeListener("log",A),0===n.A.emitter.listenerCount("log")&&(n.A.ENABLE_CALLBACK=!1,e._notifyChange())},e.emitter=new i.A,e}()},413:function(e,A,t){t.d(A,{A:function(){return i}});var i=t(343)}},A={};function n(t){var i=A[t];if(void 0!==i)return i.exports;var a=A[t]={exports:{}};return e[t](a,a.exports,n),a.exports}return n.m=e,n.d=function(e,A){for(var t in A)n.o(A,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:A[t]})},n.o=function(e,A){return Object.prototype.hasOwnProperty.call(e,A)},n(446)}()}))}(B,B.exports)),B.exports),E=h(f);window.flvjs=E;var x,Q=function(){function e(e,A){window.flvjs.isSupported()&&this.initFLV(e,A)}var A=e.prototype;return A.toString=function(){return"Flv "+this.coreX+"-"+this.coreY},A.initFLV=function(e,A){var t=l(A);t.deviceSerial,t.channelNo,t.hd,t.type;var i=document.getElementById(e);i.getAttribute("controls")||i.setAttribute("controls",!0);var n=window.flvjs.createPlayer({type:"flv",url:A,isLive:!0},{enableStashBuffer:!0,stashInitialSize:128,enableWorker:!0});n.attachMediaElement(i),n.load(),n.play(),this.flvUrl=A,this.flv=n,this.video=i,this.video.addEventListener("oncanplaythrough",(function(){}),!1),this.video.addEventListener("onerror",(function(){}),!1)},A.play=function(){this.video.play()},A.stop=function(){this.video.pause(),this.flv.unload()},A.destroy=function(){void 0!==this.flv&&null!==this.flv&&(this.flv.pause(),this.flv.unload(),this.flv.detachMediaElement(),this.flv.destroy(),this.flv=null)},e}();x||(x=1,function(){function e(e,A){(null==A||A>e.length)&&(A=e.length);for(var t=0,i=Array(A);t=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,r=!0,o=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return r=e.done,e},e:function(e){o=!0,a=e},f:function(){try{r||null==t.return||t.return()}finally{if(o)throw a}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,A,t){var i=I(e,A);if(i){var n=Object.getOwnPropertyDescriptor(i,A);return n.get?n.get.call(arguments.length<3?e:t):n.value}},o.apply(null,arguments)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function g(e,A){if("function"!=typeof A&&null!==A)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(A&&A.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),A&&d(e,A)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return A(e)}function d(e,A){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,A){return e.__proto__=A,e},d(e,A)}function I(e,A){for(;!{}.hasOwnProperty.call(e,A)&&null!==(e=s(e)););return e}function h(e,A,t,i){var n=o(s(e.prototype),A,t);return"function"==typeof n?function(e){return n.apply(t,e)}:n}function u(e,A){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,A);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function B(e){var A=u(e,"string");return"symbol"==typeof A?A:A+""}function f(A,t){if(A){if("string"==typeof A)return e(A,t);var i={}.toString.call(A).slice(8,-1);return"Object"===i&&A.constructor&&(i=A.constructor.name),"Map"===i||"Set"===i?Array.from(A):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(A,t):void 0}}function E(e){var A;try{A=new Event("abort")}catch(e){"undefined"!=typeof document?document.createEvent?(A=document.createEvent("Event")).initEvent("abort",!1,!1):(A=document.createEventObject()).type="abort":A={type:"abort",bubbles:!1,cancelable:!1}}return A.reason=e,A}function x(e){if(void 0===e)if("undefined"==typeof document)(e=new Error("This operation was aborted")).name="AbortError";else try{e=new DOMException("signal is aborted without reason"),Object.defineProperty(e,"name",{value:"AbortError"})}catch(A){(e=new Error("This operation was aborted")).name="AbortError"}return e}!function(e){e.AbortSignal,e.AbortController}("undefined"!=typeof self?self:C);var Q=function(){function e(){i(this,e),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return a(e,[{key:"addEventListener",value:function(e,A,t){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:A,options:t})}},{key:"removeEventListener",value:function(e,A){if(e in this.listeners)for(var t=this.listeners[e],i=0,n=t.length;i>>0)+"_",n=0;return function e(i){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new A(t+(i||"")+"_"+n++,i)}})),a("Symbol.iterator",(function(e){if(e)return e;e=Symbol("Symbol.iterator");for(var t="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),a=0;a2?a[1]:"sd"),"rec"===A.type&&n[2]&&(A.recType=n[2].includes(".cloud.")?"cloud":""),A.searchParams=function(e){var A=e.split("?")[1],t={};if(A)for(var i=A.split("&"),n=0;n0&&void 0!==arguments[0]?arguments[0]:{}).window,A=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},t=i.log,g=i.detectBrowser(e),l={browserDetails:g,commonShim:s,extractVersion:i.extractVersion,disableLog:i.disableLog,disableWarnings:i.disableWarnings};switch(g.browser){case"chrome":if(!n||!n.shimPeerConnection||!A.shimChrome)return t("Chrome shim is not included in this adapter release."),l;t("adapter.js shimming chrome."),l.browserShim=n,n.shimGetUserMedia(e),n.shimMediaStream(e),n.shimPeerConnection(e),n.shimOnTrack(e),n.shimAddTrackRemoveTrack(e),n.shimGetSendersWithDtmf(e),n.shimGetStats(e),n.shimSenderReceiverGetStats(e),n.fixNegotiationNeeded(e),s.shimRTCIceCandidate(e),s.shimConnectionState(e),s.shimMaxMessageSize(e),s.shimSendThrowTypeError(e),s.removeAllowExtmapMixed(e);break;case"firefox":if(!r||!r.shimPeerConnection||!A.shimFirefox)return t("Firefox shim is not included in this adapter release."),l;t("adapter.js shimming firefox."),l.browserShim=r,r.shimGetUserMedia(e),r.shimPeerConnection(e),r.shimOnTrack(e),r.shimRemoveStream(e),r.shimSenderGetStats(e),r.shimReceiverGetStats(e),r.shimRTCDataChannel(e),r.shimAddTransceiver(e),r.shimCreateOffer(e),r.shimCreateAnswer(e),s.shimRTCIceCandidate(e),s.shimConnectionState(e),s.shimMaxMessageSize(e),s.shimSendThrowTypeError(e);break;case"edge":if(!a||!a.shimPeerConnection||!A.shimEdge)return t("MS edge shim is not included in this adapter release."),l;t("adapter.js shimming edge."),l.browserShim=a,a.shimGetUserMedia(e),a.shimGetDisplayMedia(e),a.shimPeerConnection(e),a.shimReplaceTrack(e),s.shimMaxMessageSize(e),s.shimSendThrowTypeError(e);break;case"safari":if(!o||!A.shimSafari)return t("Safari shim is not included in this adapter release."),l;t("adapter.js shimming safari."),l.browserShim=o,o.shimRTCIceServerUrls(e),o.shimCreateOfferLegacy(e),o.shimCallbacksAPI(e),o.shimLocalStreamsAPI(e),o.shimRemoteStreamsAPI(e),o.shimTrackEventTransceiver(e),o.shimGetUserMedia(e),s.shimRTCIceCandidate(e),s.shimMaxMessageSize(e),s.shimSendThrowTypeError(e),s.removeAllowExtmapMixed(e);break;default:t("Unsupported browser!")}return l};var i=g(e("./utils")),n=g(e("./chrome/chrome_shim")),a=g(e("./edge/edge_shim")),r=g(e("./firefox/firefox_shim")),o=g(e("./safari/safari_shim")),s=g(e("./common_shim"));function g(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":7,"./firefox/firefox_shim":11,"./safari/safari_shim":14,"./utils":15}],3:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shimGetDisplayMedia=t.shimGetUserMedia=void 0;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=e("./getusermedia");Object.defineProperty(t,"shimGetUserMedia",{enumerable:!0,get:function(){return n.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(t,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),t.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},t.shimOnTrack=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var A=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var t=this;return this._ontrackpoly||(this._ontrackpoly=function(A){A.stream.addEventListener("addtrack",(function(i){var n;n=e.RTCPeerConnection.prototype.getReceivers?t.getReceivers().find((function(e){return e.track&&e.track.id===i.track.id})):{track:i.track};var a=new Event("track");a.track=i.track,a.receiver=n,a.transceiver={receiver:n},a.streams=[A.stream],t.dispatchEvent(a)})),A.stream.getTracks().forEach((function(i){var n;n=e.RTCPeerConnection.prototype.getReceivers?t.getReceivers().find((function(e){return e.track&&e.track.id===i.id})):{track:i};var a=new Event("track");a.track=i,a.receiver=n,a.transceiver={receiver:n},a.streams=[A.stream],t.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),A.apply(this,arguments)}}else r.wrapPeerConnectionEvent(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))},t.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var A=function(e,A){return{track:A,get dtmf(){return void 0===this._dtmf&&("audio"===A.kind?this._dtmf=e.createDTMFSender(A):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){var n=t.apply(this,arguments);return n||(n=A(this,e),this._senders.push(n)),n};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);var A=this._senders.indexOf(e);-1!==A&&this._senders.splice(A,1)}}var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach((function(e){t._senders.push(A(t,e))}))};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var A=this;this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((function(e){var t=A._senders.find((function(A){return A.track===e}));t&&A._senders.splice(A._senders.indexOf(t),1)}))}}else if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var o=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,A=o.apply(this,[]);return A.forEach((function(A){return A._pc=e})),A},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},t.shimGetStats=function(e){if(e.RTCPeerConnection){var A=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,t=Array.prototype.slice.call(arguments),i=t[0],n=t[1],a=t[2];if(arguments.length>0&&"function"==typeof i)return A.apply(this,arguments);if(0===A.length&&(0===arguments.length||"function"!=typeof i))return A.apply(this,[]);var r=function(e){var A={};return e.result().forEach((function(e){var t={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(A){t[A]=e.stat(A)})),A[t.id]=t})),A},o=function(e){return new Map(Object.keys(e).map((function(A){return[A,e[A]]})))};if(arguments.length>=2){return A.apply(this,[function(e){n(o(r(e)))},i])}return new Promise((function(t,i){A.apply(e,[function(e){t(o(r(e)))},i])})).then(n,a)}}},t.shimSenderReceiverGetStats=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var A=e.RTCPeerConnection.prototype.getSenders;A&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=A.apply(this,[]);return t.forEach((function(A){return A._pc=e})),t});var t=e.RTCPeerConnection.prototype.addTrack;t&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=t.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(A){return r.filterStats(A,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,A=n.apply(this,[]);return A.forEach((function(A){return A._pc=e})),A}),r.wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(A){return r.filterStats(A,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var A=arguments[0],t=void 0,i=void 0,n=void 0;return this.getSenders().forEach((function(e){e.track===A&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===A&&(i?n=!0:i=e),e.track===A})),n||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}}}},t.shimAddTrackRemoveTrackWithNative=s,t.shimAddTrackRemoveTrack=function(e){if(e.RTCPeerConnection){var A=r.detectBrowser(e);if(e.RTCPeerConnection.prototype.addTrack&&A.version>=65)return s(e);var t=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,A=t.apply(this);return this._reverseStreams=this._reverseStreams||{},A.map((function(A){return e._reverseStreams[A.id]}))};var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(A){var t=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},A.getTracks().forEach((function(e){if(t.getSenders().find((function(A){return A.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[A.id]){var n=new e.MediaStream(A.getTracks());this._streams[A.id]=n,this._reverseStreams[n.id]=A,A=n}i.apply(this,[A])};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(A,t){var i=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((function(e){return e===A})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((function(e){return e.track===A})))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[t.id];if(a)a.addTrack(A),Promise.resolve().then((function(){i.dispatchEvent(new Event("negotiationneeded"))}));else{var r=new e.MediaStream([A]);this._streams[t.id]=r,this._reverseStreams[r.id]=t,this.addStream(r)}return this.getSenders().find((function(e){return e.track===A}))},["createOffer","createAnswer"].forEach((function(A){var t=e.RTCPeerConnection.prototype[A],i=o({},A,(function(){var e=this,A=arguments;return arguments.length&&"function"==typeof arguments[0]?t.apply(this,[function(t){var i=l(e,t);A[0].apply(null,[i])},function(e){A[1]&&A[1].apply(null,e)},arguments[2]]):t.apply(this,arguments).then((function(A){return l(e,A)}))}));e.RTCPeerConnection.prototype[A]=i[A]}));var a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,A){var t=A.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(A){var i=e._reverseStreams[A],n=e._streams[i.id];t=t.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:A.type,sdp:t})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};var g=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=g.get.apply(this);return""===e.type?e:l(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var A=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var t=void 0;Object.keys(this._streams).forEach((function(i){A._streams[i].getTracks().find((function(A){return e.track===A}))&&(t=A._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function l(e,A){var t=A.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(A){var i=e._reverseStreams[A],n=e._streams[i.id];t=t.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:A.type,sdp:t})}},t.shimPeerConnection=function(e){var A=r.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection){A.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(A){var t=e.RTCPeerConnection.prototype[A],i=o({},A,(function(){return arguments[0]=new("addIceCandidate"===A?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}));e.RTCPeerConnection.prototype[A]=i[A]}));var t=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?A.version<78&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}},t.fixNegotiationNeeded=function(e){r.wrapPeerConnectionEvent(e,"negotiationneeded",(function(e){if("stable"===e.target.signalingState)return e}))};var r=function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}(e("../utils.js"));function o(e,A,t){return A in e?Object.defineProperty(e,A,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[A]=t,e}function s(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(A){return e._shimmedLocalStreams[A][0]}))};var A=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,t){if(!t)return A.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=A.apply(this,arguments);return this._shimmedLocalStreams[t.id]?-1===this._shimmedLocalStreams[t.id].indexOf(i)&&this._shimmedLocalStreams[t.id].push(i):this._shimmedLocalStreams[t.id]=[t,i],i};var t=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var A=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(A.getSenders().find((function(A){return A.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var i=this.getSenders();t.apply(this,arguments);var n=this.getSenders().filter((function(e){return-1===i.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(n)};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],i.apply(this,arguments)};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var A=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(t){var i=A._shimmedLocalStreams[t].indexOf(e);-1!==i&&A._shimmedLocalStreams[t].splice(i,1),1===A._shimmedLocalStreams[t].length&&delete A._shimmedLocalStreams[t]})),n.apply(this,arguments)}}},{"../utils.js":15,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shimGetDisplayMedia=function(e,A){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&"function"==typeof A&&(e.navigator.mediaDevices.getDisplayMedia=function(t){return A(t).then((function(A){var i=t.video&&t.video.width,n=t.video&&t.video.height,a=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:A,maxFrameRate:a||3}},i&&(t.video.mandatory.maxWidth=i),n&&(t.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(t)}))})}},{}],5:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.shimGetUserMedia=function(e){var A=e&&e.navigator;if(A.mediaDevices){var t=n.detectBrowser(e),r=function(e){if("object"!==(void 0===e?"undefined":i(e))||e.mandatory||e.optional)return e;var A={};return Object.keys(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===i(e[t])?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var a=function(e,A){return e?e+A.charAt(0).toUpperCase()+A.slice(1):"deviceId"===A?"sourceId":A};if(void 0!==n.ideal){A.optional=A.optional||[];var r={};"number"==typeof n.ideal?(r[a("min",t)]=n.ideal,A.optional.push(r),(r={})[a("max",t)]=n.ideal,A.optional.push(r)):(r[a("",t)]=n.ideal,A.optional.push(r))}void 0!==n.exact&&"number"!=typeof n.exact?(A.mandatory=A.mandatory||{},A.mandatory[a("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(A.mandatory=A.mandatory||{},A.mandatory[a(e,t)]=n[e])}))}})),e.advanced&&(A.optional=(A.optional||[]).concat(e.advanced)),A},o=function(e,n){if(t.version>=61)return n(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===i(e.audio)){var o=function(e,A,t){A in e&&!(t in e)&&(e[t]=e[A],delete e[A])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"===i(e.video)){var s=e.video.facingMode;s=s&&("object"===(void 0===s?"undefined":i(s))?s:{ideal:s});var g=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!A.mediaDevices.getSupportedConstraints||!A.mediaDevices.getSupportedConstraints().facingMode||g)){delete e.video.facingMode;var l=void 0;if("environment"===s.exact||"environment"===s.ideal?l=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(l=["front"]),l)return A.mediaDevices.enumerateDevices().then((function(A){var t=(A=A.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return l.some((function(A){return e.label.toLowerCase().includes(A)}))}));return!t&&A.length&&l.includes("back")&&(t=A[A.length-1]),t&&(e.video.deviceId=s.exact?{exact:t.deviceId}:{ideal:t.deviceId}),e.video=r(e.video),a("chrome: "+JSON.stringify(e)),n(e)}))}e.video=r(e.video)}return a("chrome: "+JSON.stringify(e)),n(e)},s=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(A.getUserMedia=function(e,t,i){o(e,(function(e){A.webkitGetUserMedia(e,t,(function(e){i&&i(s(e))}))}))}.bind(A),A.mediaDevices.getUserMedia){var g=A.mediaDevices.getUserMedia.bind(A.mediaDevices);A.mediaDevices.getUserMedia=function(e){return o(e,(function(e){return g(e).then((function(A){if(e.audio&&!A.getAudioTracks().length||e.video&&!A.getVideoTracks().length)throw A.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return A}),(function(e){return Promise.reject(s(e))}))}))}}}};var n=function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}(e("../utils.js"));var a=n.log},{"../utils.js":15}],6:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.shimRTCIceCandidate=function(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var A=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var t=new A(e),a=n.default.parseCandidate(e.candidate),r=Object.assign(t,a);return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new A(e)},e.RTCIceCandidate.prototype=A.prototype,a.wrapPeerConnectionEvent(e,"icecandidate",(function(A){return A.candidate&&Object.defineProperty(A,"candidate",{value:new e.RTCIceCandidate(A.candidate),writable:"false"}),A}))}},t.shimMaxMessageSize=function(e){if(e.RTCPeerConnection){var A=a.detectBrowser(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var t=function(e){if(!e||!e.sdp)return!1;var A=n.default.splitSections(e.sdp);return A.shift(),A.some((function(e){var A=n.default.parseMLine(e);return A&&"application"===A.kind&&-1!==A.protocol.indexOf("SCTP")}))},i=function(e,t){var i=65536;"firefox"===A.browser&&57===A.version&&(i=65535);var a=n.default.matchPrefix(e.sdp,"a=max-message-size:");return a.length>0?i=parseInt(a[0].substr(19),10):"firefox"===A.browser&&-1!==t&&(i=2147483637),i},r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===A.browser&&A.version>=76&&"plan-b"===this.getConfiguration().sdpSemantics&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0}),t(arguments[0])){var e,n=function(e){var A=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===A||A.length<2)return-1;var t=parseInt(A[1],10);return t!=t?-1:t}(arguments[0]),a=function(e){var t=65536;return"firefox"===A.browser&&(t=A.version<57?-1===e?16384:2147483637:A.version<60?57===A.version?65535:65536:2147483637),t}(n),o=i(arguments[0],n);e=0===a&&0===o?Number.POSITIVE_INFINITY:0===a||0===o?Math.max(a,o):Math.min(a,o);var s={};Object.defineProperty(s,"maxMessageSize",{get:function(){return e}}),this._sctp=s}return r.apply(this,arguments)}}},t.shimSendThrowTypeError=function(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var A=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=A.apply(this,arguments);return t(e,this),e},a.wrapPeerConnectionEvent(e,"datachannel",(function(e){return t(e.channel,e.target),e}))}function t(e,A){var t=e.send;e.send=function(){var i=arguments[0],n=i.length||i.size||i.byteLength;if("open"===e.readyState&&A.sctp&&n>A.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+A.sctp.maxMessageSize+" bytes)");return t.apply(e,arguments)}}},t.shimConnectionState=function(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var A=e.RTCPeerConnection.prototype;Object.defineProperty(A,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(A,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var t=A[e];A[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var A=e.target;if(A._lastConnectionState!==A.connectionState){A._lastConnectionState=A.connectionState;var t=new Event("connectionstatechange",e);A.dispatchEvent(t)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),t.apply(this,arguments)}}))}},t.removeAllowExtmapMixed=function(e){if(e.RTCPeerConnection){var A=a.detectBrowser(e);if(!("chrome"===A.browser&&A.version>=71)){var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){return e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter((function(e){return"a=extmap-allow-mixed"!==e.trim()})).join("\n")),t.apply(this,arguments)}}}};var n=function(e){return e&&e.__esModule?e:{default:e}}(e("sdp")),a=function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}(e("./utils"))},{"./utils":15,sdp:17}],7:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shimGetDisplayMedia=t.shimGetUserMedia=void 0;var i=e("./getusermedia");Object.defineProperty(t,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var n=e("./getdisplaymedia");Object.defineProperty(t,"shimGetDisplayMedia",{enumerable:!0,get:function(){return n.shimGetDisplayMedia}}),t.shimPeerConnection=function(e){var A=a.detectBrowser(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),A.version<15025)){var t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){t.set.call(this,e);var A=new Event("enabled");A.enabled=e,this.dispatchEvent(A)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);var i=(0,o.default)(e,A.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=(0,r.filterIceServers)(e.iceServers,A.version),a.log("ICE servers after filtering:",e.iceServers)),new i(e)},e.RTCPeerConnection.prototype=i.prototype},t.shimReplaceTrack=function(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)};var a=function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}(e("../utils")),r=e("./filtericeservers"),o=function(e){return e&&e.__esModule?e:{default:e}}(e("rtcpeerconnection-shim"))},{"../utils":15,"./filtericeservers":8,"./getdisplaymedia":9,"./getusermedia":10,"rtcpeerconnection-shim":16}],8:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.filterIceServers=function(e,A){var t=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var A=e.urls||e.url;e.url&&!e.urls&&i.deprecated("RTCIceServer.url","RTCIceServer.urls");var n="string"==typeof A;return n&&(A=[A]),A=A.filter((function(e){if(0===e.indexOf("stun:"))return!1;var A=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return A&&!t?(t=!0,!0):A&&!t})),delete e.url,e.urls=n?A[0]:A,!!A.length}}))};var i=function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}(e("../utils"))},{"../utils":15}],9:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shimGetDisplayMedia=function(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}},{}],10:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shimGetUserMedia=function(e){var A=e&&e.navigator,t=A.mediaDevices.getUserMedia.bind(A.mediaDevices);A.mediaDevices.getUserMedia=function(e){return t(e).catch((function(e){return Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}}(e))}))}}},{}],11:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shimGetDisplayMedia=t.shimGetUserMedia=void 0;var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=e("./getusermedia");Object.defineProperty(t,"shimGetUserMedia",{enumerable:!0,get:function(){return n.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(t,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),t.shimOnTrack=function(e){"object"===(void 0===e?"undefined":i(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},t.shimPeerConnection=function(e){var A=r.detectBrowser(e);if("object"===(void 0===e?"undefined":i(e))&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){if(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),A.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(A){var t=e.RTCPeerConnection.prototype[A],i=function(e,A,t){return A in e?Object.defineProperty(e,A,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[A]=t,e}({},A,(function(){return arguments[0]=new("addIceCandidate"===A?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}));e.RTCPeerConnection.prototype[A]=i[A]})),A.version<68){var t=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}var n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),t=e[0],i=e[1],r=e[2];return a.apply(this,[t||null]).then((function(e){if(A.version<53&&!i)try{e.forEach((function(e){e.type=n[e.type]||e.type}))}catch(A){if("TypeError"!==A.name)throw A;e.forEach((function(A,t){e.set(t,Object.assign({},A,{type:n[A.type]||A.type}))}))}return e})).then(i,r)}}},t.shimSenderGetStats=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var A=e.RTCPeerConnection.prototype.getSenders;A&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=A.apply(this,[]);return t.forEach((function(A){return A._pc=e})),t});var t=e.RTCPeerConnection.prototype.addTrack;t&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=t.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}},t.shimReceiverGetStats=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var A=e.RTCPeerConnection.prototype.getReceivers;A&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=A.apply(this,[]);return t.forEach((function(A){return A._pc=e})),t}),r.wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}},t.shimRemoveStream=function(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var A=this;r.deprecated("removeStream","removeTrack"),this.getSenders().forEach((function(t){t.track&&e.getTracks().includes(t.track)&&A.removeTrack(t)}))})},t.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},t.shimAddTransceiver=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection){var A=e.RTCPeerConnection.prototype.addTransceiver;A&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],t=e&&"sendEncodings"in e;t&&e.sendEncodings.forEach((function(e){if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var i=A.apply(this,arguments);if(t){var n=i.sender,a=n.getParameters();"encodings"in a||(a.encodings=e.sendEncodings,this.setParametersPromises.push(n.setParameters(a).catch((function(){}))))}return i})}},t.shimCreateOffer=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection){var A=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,t=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return A.apply(e,t)})).finally((function(){e.setParametersPromises=[]})):A.apply(this,arguments)}}},t.shimCreateAnswer=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection){var A=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,t=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return A.apply(e,t)})).finally((function(){e.setParametersPromises=[]})):A.apply(this,arguments)}}};var r=function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}(e("../utils"))},{"../utils":15,"./getdisplaymedia":12,"./getusermedia":13}],12:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shimGetDisplayMedia=function(e,A){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(t){if(!t||!t.video){var i=new DOMException("getDisplayMedia without video constraints is undefined");return i.name="NotFoundError",i.code=8,Promise.reject(i)}return!0===t.video?t.video={mediaSource:A}:t.video.mediaSource=A,e.navigator.mediaDevices.getUserMedia(t)})}},{}],13:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.shimGetUserMedia=function(e){var A=n.detectBrowser(e),t=e&&e.navigator,a=e&&e.MediaStreamTrack;if(t.getUserMedia=function(e,A,i){n.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(e).then(A,i)},!(A.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){var r=function(e,A,t){A in e&&!(t in e)&&(e[t]=e[A],delete e[A])},o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(t.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":i(e))&&"object"===i(e.audio)&&(e=JSON.parse(JSON.stringify(e)),r(e.audio,"autoGainControl","mozAutoGainControl"),r(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},a&&a.prototype.getSettings){var s=a.prototype.getSettings;a.prototype.getSettings=function(){var e=s.apply(this,arguments);return r(e,"mozAutoGainControl","autoGainControl"),r(e,"mozNoiseSuppression","noiseSuppression"),e}}if(a&&a.prototype.applyConstraints){var g=a.prototype.applyConstraints;a.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":i(e))&&(e=JSON.parse(JSON.stringify(e)),r(e,"autoGainControl","mozAutoGainControl"),r(e,"noiseSuppression","mozNoiseSuppression")),g.apply(this,[e])}}}};var n=function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t]);return A.default=e,A}(e("../utils"))},{"../utils":15}],14:[function(e,A,t){Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.shimLocalStreamsAPI=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var A=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(i){return A.call(t,i,e)})),e.getVideoTracks().forEach((function(i){return A.call(t,i,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){var t=arguments[1];return t&&(this._localStreams?this._localStreams.includes(t)||this._localStreams.push(t):this._localStreams=[t]),A.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var A=this;this._localStreams||(this._localStreams=[]);var t=this._localStreams.indexOf(e);if(-1!==t){this._localStreams.splice(t,1);var i=e.getTracks();this.getSenders().forEach((function(e){i.includes(e.track)&&A.removeTrack(e)}))}})}},t.shimRemoteStreamsAPI=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var A=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){if(A._remoteStreams||(A._remoteStreams=[]),!A._remoteStreams.includes(e)){A._remoteStreams.push(e);var t=new Event("addstream");t.stream=e,A.dispatchEvent(t)}}))})}});var A=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(A){A.streams.forEach((function(A){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(A)>=0)){e._remoteStreams.push(A);var t=new Event("addstream");t.stream=A,e.dispatchEvent(t)}}))}),A.apply(e,arguments)}}},t.shimCallbacksAPI=function(e){if("object"===(void 0===e?"undefined":i(e))&&e.RTCPeerConnection){var A=e.RTCPeerConnection.prototype,t=A.createOffer,n=A.createAnswer,a=A.setLocalDescription,r=A.setRemoteDescription,o=A.addIceCandidate;A.createOffer=function(e,A){var i=arguments.length>=2?arguments[2]:arguments[0],n=t.apply(this,[i]);return A?(n.then(e,A),Promise.resolve()):n},A.createAnswer=function(e,A){var t=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[t]);return A?(i.then(e,A),Promise.resolve()):i};var s=function(e,A,t){var i=a.apply(this,[e]);return t?(i.then(A,t),Promise.resolve()):i};A.setLocalDescription=s,s=function(e,A,t){var i=r.apply(this,[e]);return t?(i.then(A,t),Promise.resolve()):i},A.setRemoteDescription=s,s=function(e,A,t){var i=o.apply(this,[e]);return t?(i.then(A,t),Promise.resolve()):i},A.addIceCandidate=s}},t.shimGetUserMedia=function(e){var A=e&&e.navigator;if(A.mediaDevices&&A.mediaDevices.getUserMedia){var t=A.mediaDevices,i=t.getUserMedia.bind(t);A.mediaDevices.getUserMedia=function(e){return i(a(e))}}!A.getUserMedia&&A.mediaDevices&&A.mediaDevices.getUserMedia&&(A.getUserMedia=function(e,t,i){A.mediaDevices.getUserMedia(e).then(t,i)}.bind(A))},t.shimConstraints=a,t.shimRTCIceServerUrls=function(e){var A=e.RTCPeerConnection;e.RTCPeerConnection=function(e,t){if(e&&e.iceServers){for(var i=[],a=0;a=t&&parseInt(i[t],10)}function r(e){return"[object Object]"===Object.prototype.toString.call(e)}function o(e,A,t){A&&!t.has(A.id)&&(t.set(A.id,A),Object.keys(A).forEach((function(i){i.endsWith("Id")?o(e,e.get(A[i]),t):i.endsWith("Ids")&&A[i].forEach((function(A){o(e,e.get(A),t)}))})))}},{}],16:[function(e,A,t){var i=e("sdp");function n(e,A,t,n,a){var r=i.writeRtpDescription(e.kind,A);if(r+=i.writeIceParameters(e.iceGatherer.getLocalParameters()),r+=i.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===t?"actpass":a||"active"),r+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?r+="a=sendrecv\r\n":e.rtpSender?r+="a=sendonly\r\n":e.rtpReceiver?r+="a=recvonly\r\n":r+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var s="msid:"+(n?n.id:"-")+" "+o+"\r\n";r+="a="+s,r+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(r+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,r+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return r+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+i.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(r+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+i.localCName+"\r\n"),r}function a(e,A){var t={codecs:[],headerExtensions:[],fecMechanisms:[]},i=function(e,A){e=parseInt(e,10);for(var t=0;t=14393&&-1===e.indexOf("?transport=udp"):(t=!0,!0)})),delete e.url,e.urls=n?i[0]:i,!!i.length}}))}(t.iceServers||[],A),this._iceGatherers=[],t.iceCandidatePoolSize)for(var r=t.iceCandidatePoolSize;r>0;r--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:t.iceServers,gatherPolicy:t.iceTransportPolicy}));else t.iceCandidatePoolSize=0;this._config=t,this.transceivers=[],this._sdpSessionId=i.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(c.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(c.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),c.prototype.onicecandidate=null,c.prototype.onaddstream=null,c.prototype.ontrack=null,c.prototype.onremovestream=null,c.prototype.onsignalingstatechange=null,c.prototype.oniceconnectionstatechange=null,c.prototype.onconnectionstatechange=null,c.prototype.onicegatheringstatechange=null,c.prototype.onnegotiationneeded=null,c.prototype.ondatachannel=null,c.prototype._dispatchEvent=function(e,A){this._isClosed||(this.dispatchEvent(A),"function"==typeof this["on"+e]&&this["on"+e](A))},c.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},c.prototype.getConfiguration=function(){return this._config},c.prototype.getLocalStreams=function(){return this.localStreams},c.prototype.getRemoteStreams=function(){return this.remoteStreams},c.prototype._createTransceiver=function(e,A){var t=this.transceivers.length>0,i={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&t)i.iceTransport=this.transceivers[0].iceTransport,i.dtlsTransport=this.transceivers[0].dtlsTransport;else{var n=this._createIceAndDtlsTransports();i.iceTransport=n.iceTransport,i.dtlsTransport=n.dtlsTransport}return A||this.transceivers.push(i),i},c.prototype.addTrack=function(A,t){if(this._isClosed)throw s("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var i;if(this.transceivers.find((function(e){return e.track===A})))throw s("InvalidAccessError","Track already exists.");for(var n=0;n=15025)e.getTracks().forEach((function(A){t.addTrack(A,e)}));else{var i=e.clone();e.getTracks().forEach((function(e,A){var t=i.getTracks()[A];e.addEventListener("enabled",(function(e){t.enabled=e.enabled}))})),i.getTracks().forEach((function(e){t.addTrack(e,i)}))}},c.prototype.removeTrack=function(A){if(this._isClosed)throw s("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(A instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var t=this.transceivers.find((function(e){return e.rtpSender===A}));if(!t)throw s("InvalidAccessError","Sender was not created by this connection.");var i=t.stream;t.rtpSender.stop(),t.rtpSender=null,t.track=null,t.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(i)&&this.localStreams.indexOf(i)>-1&&this.localStreams.splice(this.localStreams.indexOf(i),1),this._maybeFireNegotiationNeeded()},c.prototype.removeStream=function(e){var A=this;e.getTracks().forEach((function(e){var t=A.getSenders().find((function(A){return A.track===e}));t&&A.removeTrack(t)}))},c.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},c.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},c.prototype._createIceGatherer=function(A,t){var i=this;if(t&&A>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var n=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(n,"state",{value:"new",writable:!0}),this.transceivers[A].bufferedCandidateEvents=[],this.transceivers[A].bufferCandidates=function(e){var t=!e.candidate||0===Object.keys(e.candidate).length;n.state=t?"completed":"gathering",null!==i.transceivers[A].bufferedCandidateEvents&&i.transceivers[A].bufferedCandidateEvents.push(e)},n.addEventListener("localcandidate",this.transceivers[A].bufferCandidates),n},c.prototype._gather=function(A,t){var n=this,a=this.transceivers[t].iceGatherer;if(!a.onlocalcandidate){var r=this.transceivers[t].bufferedCandidateEvents;this.transceivers[t].bufferedCandidateEvents=null,a.removeEventListener("localcandidate",this.transceivers[t].bufferCandidates),a.onlocalcandidate=function(e){if(!(n.usingBundle&&t>0)){var r=new Event("icecandidate");r.candidate={sdpMid:A,sdpMLineIndex:t};var o=e.candidate,s=!o||0===Object.keys(o).length;if(s)"new"!==a.state&&"gathering"!==a.state||(a.state="completed");else{"new"===a.state&&(a.state="gathering"),o.component=1,o.ufrag=a.getLocalParameters().usernameFragment;var g=i.writeCandidate(o);r.candidate=Object.assign(r.candidate,i.parseCandidate(g)),r.candidate.candidate=g,r.candidate.toJSON=function(){return{candidate:r.candidate.candidate,sdpMid:r.candidate.sdpMid,sdpMLineIndex:r.candidate.sdpMLineIndex,usernameFragment:r.candidate.usernameFragment}}}var l=i.getMediaSections(n._localDescription.sdp);l[r.candidate.sdpMLineIndex]+=s?"a=end-of-candidates\r\n":"a="+r.candidate.candidate+"\r\n",n._localDescription.sdp=i.getDescription(n._localDescription.sdp)+l.join("");var c=n.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==n.iceGatheringState&&(n.iceGatheringState="gathering",n._emitGatheringStateChange()),s||n._dispatchEvent("icecandidate",r),c&&(n._dispatchEvent("icecandidate",new Event("icecandidate")),n.iceGatheringState="complete",n._emitGatheringStateChange())}},e.setTimeout((function(){r.forEach((function(e){a.onlocalcandidate(e)}))}),0)}},c.prototype._createIceAndDtlsTransports=function(){var A=this,t=new e.RTCIceTransport(null);t.onicestatechange=function(){A._updateIceConnectionState(),A._updateConnectionState()};var i=new e.RTCDtlsTransport(t);return i.ondtlsstatechange=function(){A._updateConnectionState()},i.onerror=function(){Object.defineProperty(i,"state",{value:"failed",writable:!0}),A._updateConnectionState()},{iceTransport:t,dtlsTransport:i}},c.prototype._disposeIceAndDtlsTransports=function(e){var A=this.transceivers[e].iceGatherer;A&&(delete A.onlocalcandidate,delete this.transceivers[e].iceGatherer);var t=this.transceivers[e].iceTransport;t&&(delete t.onicestatechange,delete this.transceivers[e].iceTransport);var i=this.transceivers[e].dtlsTransport;i&&(delete i.ondtlsstatechange,delete i.onerror,delete this.transceivers[e].dtlsTransport)},c.prototype._transceive=function(e,t,n){var r=a(e.localCapabilities,e.remoteCapabilities);t&&e.rtpSender&&(r.encodings=e.sendEncodingParameters,r.rtcp={cname:i.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(r.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(r)),n&&e.rtpReceiver&&r.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&A<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?r.encodings=e.recvEncodingParameters:r.encodings=[{}],r.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(r.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(r.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(r))},c.prototype.setLocalDescription=function(e){var A,t,n=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(s("TypeError",'Unsupported type "'+e.type+'"'));if(!r("setLocalDescription",e.type,n.signalingState)||n._isClosed)return Promise.reject(s("InvalidStateError","Can not set local "+e.type+" in state "+n.signalingState));if("offer"===e.type)A=i.splitSections(e.sdp),t=A.shift(),A.forEach((function(e,A){var t=i.parseRtpParameters(e);n.transceivers[A].localCapabilities=t})),n.transceivers.forEach((function(e,A){n._gather(e.mid,A)}));else if("answer"===e.type){A=i.splitSections(n._remoteDescription.sdp),t=A.shift();var o=i.matchPrefix(t,"a=ice-lite").length>0;A.forEach((function(e,A){var r=n.transceivers[A],s=r.iceGatherer,g=r.iceTransport,l=r.dtlsTransport,c=r.localCapabilities,d=r.remoteCapabilities;if(!(i.isRejected(e)&&0===i.matchPrefix(e,"a=bundle-only").length||r.rejected)){var I=i.getIceParameters(e,t),C=i.getDtlsParameters(e,t);o&&(C.role="server"),n.usingBundle&&0!==A||(n._gather(r.mid,A),"new"===g.state&&g.start(s,I,o?"controlling":"controlled"),"new"===l.state&&l.start(C));var h=a(c,d);n._transceive(r,h.codecs.length>0,!1)}}))}return n._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?n._updateSignalingState("have-local-offer"):n._updateSignalingState("stable"),Promise.resolve()},c.prototype.setRemoteDescription=function(n){var c=this;if(-1===["offer","answer"].indexOf(n.type))return Promise.reject(s("TypeError",'Unsupported type "'+n.type+'"'));if(!r("setRemoteDescription",n.type,c.signalingState)||c._isClosed)return Promise.reject(s("InvalidStateError","Can not set remote "+n.type+" in state "+c.signalingState));var d={};c.remoteStreams.forEach((function(e){d[e.id]=e}));var I=[],C=i.splitSections(n.sdp),h=C.shift(),u=i.matchPrefix(h,"a=ice-lite").length>0,B=i.matchPrefix(h,"a=group:BUNDLE ").length>0;c.usingBundle=B;var f=i.matchPrefix(h,"a=ice-options:")[0];return c.canTrickleIceCandidates=!!f&&f.substr(14).split(" ").indexOf("trickle")>=0,C.forEach((function(r,s){var l=i.splitLines(r),C=i.getKind(r),f=i.isRejected(r)&&0===i.matchPrefix(r,"a=bundle-only").length,E=l[0].substr(2).split(" ")[2],x=i.getDirection(r,h),Q=i.parseMsid(r),p=i.getMid(r)||i.generateIdentifier();if(f||"application"===C&&("DTLS/SCTP"===E||"UDP/DTLS/SCTP"===E))c.transceivers[s]={mid:p,kind:C,protocol:E,rejected:!0};else{var m,y,_,S,v,D,w,b,F;!f&&c.transceivers[s]&&c.transceivers[s].rejected&&(c.transceivers[s]=c._createTransceiver(C,!0));var R,k,P=i.parseRtpParameters(r);f||(R=i.getIceParameters(r,h),(k=i.getDtlsParameters(r,h)).role="client"),w=i.parseRtpEncodingParameters(r);var T=i.parseRtcpParameters(r),N=i.matchPrefix(r,"a=end-of-candidates",h).length>0,M=i.matchPrefix(r,"a=candidate:").map((function(e){return i.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===n.type||"answer"===n.type)&&!f&&B&&s>0&&c.transceivers[s]&&(c._disposeIceAndDtlsTransports(s),c.transceivers[s].iceGatherer=c.transceivers[0].iceGatherer,c.transceivers[s].iceTransport=c.transceivers[0].iceTransport,c.transceivers[s].dtlsTransport=c.transceivers[0].dtlsTransport,c.transceivers[s].rtpSender&&c.transceivers[s].rtpSender.setTransport(c.transceivers[0].dtlsTransport),c.transceivers[s].rtpReceiver&&c.transceivers[s].rtpReceiver.setTransport(c.transceivers[0].dtlsTransport)),"offer"!==n.type||f)"answer"!==n.type||f||(y=(m=c.transceivers[s]).iceGatherer,_=m.iceTransport,S=m.dtlsTransport,v=m.rtpReceiver,D=m.sendEncodingParameters,b=m.localCapabilities,c.transceivers[s].recvEncodingParameters=w,c.transceivers[s].remoteCapabilities=P,c.transceivers[s].rtcpParameters=T,M.length&&"new"===_.state&&(!u&&!N||B&&0!==s?M.forEach((function(e){o(m.iceTransport,e)})):_.setRemoteCandidates(M)),B&&0!==s||("new"===_.state&&_.start(y,R,"controlling"),"new"===S.state&&S.start(k)),!a(m.localCapabilities,m.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&m.sendEncodingParameters[0].rtx&&delete m.sendEncodingParameters[0].rtx,c._transceive(m,"sendrecv"===x||"recvonly"===x,"sendrecv"===x||"sendonly"===x),!v||"sendrecv"!==x&&"sendonly"!==x?delete m.rtpReceiver:(F=v.track,Q?(d[Q.stream]||(d[Q.stream]=new e.MediaStream),t(F,d[Q.stream]),I.push([F,v,d[Q.stream]])):(d.default||(d.default=new e.MediaStream),t(F,d.default),I.push([F,v,d.default]))));else{(m=c.transceivers[s]||c._createTransceiver(C)).mid=p,m.iceGatherer||(m.iceGatherer=c._createIceGatherer(s,B)),M.length&&"new"===m.iceTransport.state&&(!N||B&&0!==s?M.forEach((function(e){o(m.iceTransport,e)})):m.iceTransport.setRemoteCandidates(M)),b=e.RTCRtpReceiver.getCapabilities(C),A<15019&&(b.codecs=b.codecs.filter((function(e){return"rtx"!==e.name}))),D=m.sendEncodingParameters||[{ssrc:1001*(2*s+2)}];var L,G=!1;"sendrecv"===x||"sendonly"===x?(G=!m.rtpReceiver,v=m.rtpReceiver||new e.RTCRtpReceiver(m.dtlsTransport,C),G&&(F=v.track,Q&&"-"===Q.stream||(Q?(d[Q.stream]||(d[Q.stream]=new e.MediaStream,Object.defineProperty(d[Q.stream],"id",{get:function(){return Q.stream}})),Object.defineProperty(F,"id",{get:function(){return Q.track}}),L=d[Q.stream]):(d.default||(d.default=new e.MediaStream),L=d.default)),L&&(t(F,L),m.associatedRemoteMediaStreams.push(L)),I.push([F,v,L]))):m.rtpReceiver&&m.rtpReceiver.track&&(m.associatedRemoteMediaStreams.forEach((function(e){var A=e.getTracks().find((function(e){return e.id===m.rtpReceiver.track.id}));A&&g(A,e)})),m.associatedRemoteMediaStreams=[]),m.localCapabilities=b,m.remoteCapabilities=P,m.rtpReceiver=v,m.rtcpParameters=T,m.sendEncodingParameters=D,m.recvEncodingParameters=w,c._transceive(c.transceivers[s],!1,G)}}})),void 0===c._dtlsRole&&(c._dtlsRole="offer"===n.type?"active":"passive"),c._remoteDescription={type:n.type,sdp:n.sdp},"offer"===n.type?c._updateSignalingState("have-remote-offer"):c._updateSignalingState("stable"),Object.keys(d).forEach((function(A){var t=d[A];if(t.getTracks().length){if(-1===c.remoteStreams.indexOf(t)){c.remoteStreams.push(t);var i=new Event("addstream");i.stream=t,e.setTimeout((function(){c._dispatchEvent("addstream",i)}))}I.forEach((function(e){var A=e[0],i=e[1];t.id===e[2].id&&l(c,A,i,[t])}))}})),I.forEach((function(e){e[2]||l(c,e[0],e[1],[])})),e.setTimeout((function(){c&&c.transceivers&&c.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&e.iceTransport.addRemoteCandidate({})}))}),4e3),Promise.resolve()},c.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},c.prototype._updateSignalingState=function(e){this.signalingState=e;var A=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",A)},c.prototype._maybeFireNegotiationNeeded=function(){var A=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(A.needNegotiation){A.needNegotiation=!1;var e=new Event("negotiationneeded");A._dispatchEvent("negotiationneeded",e)}}),0))},c.prototype._updateIceConnectionState=function(){var e,A={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&A[e.iceTransport.state]++})),e="new",A.failed>0?e="failed":A.checking>0?e="checking":A.disconnected>0?e="disconnected":A.new>0?e="new":A.connected>0?e="connected":A.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var t=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",t)}},c.prototype._updateConnectionState=function(){var e,A={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(A[e.iceTransport.state]++,A[e.dtlsTransport.state]++)})),A.connected+=A.completed,e="new",A.failed>0?e="failed":A.connecting>0?e="connecting":A.disconnected>0?e="disconnected":A.new>0?e="new":A.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var t=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",t)}},c.prototype.createOffer=function(){var t=this;if(t._isClosed)return Promise.reject(s("InvalidStateError","Can not call createOffer after close"));var a=t.transceivers.filter((function(e){return"audio"===e.kind})).length,r=t.transceivers.filter((function(e){return"video"===e.kind})).length,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(a=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(r=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.offerToReceiveVideo)}for(t.transceivers.forEach((function(e){"audio"===e.kind?--a<0&&(e.wantReceive=!1):"video"===e.kind&&--r<0&&(e.wantReceive=!1)}));a>0||r>0;)a>0&&(t._createTransceiver("audio"),a--),r>0&&(t._createTransceiver("video"),r--);var g=i.writeSessionBoilerplate(t._sdpSessionId,t._sdpSessionVersion++);t.transceivers.forEach((function(n,a){var r=n.track,o=n.kind,s=n.mid||i.generateIdentifier();n.mid=s,n.iceGatherer||(n.iceGatherer=t._createIceGatherer(a,t.usingBundle));var g=e.RTCRtpSender.getCapabilities(o);A<15019&&(g.codecs=g.codecs.filter((function(e){return"rtx"!==e.name}))),g.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),n.remoteCapabilities&&n.remoteCapabilities.codecs&&n.remoteCapabilities.codecs.forEach((function(A){e.name.toLowerCase()===A.name.toLowerCase()&&e.clockRate===A.clockRate&&(e.preferredPayloadType=A.payloadType)}))})),g.headerExtensions.forEach((function(e){(n.remoteCapabilities&&n.remoteCapabilities.headerExtensions||[]).forEach((function(A){e.uri===A.uri&&(e.id=A.id)}))}));var l=n.sendEncodingParameters||[{ssrc:1001*(2*a+1)}];r&&A>=15019&&"video"===o&&!l[0].rtx&&(l[0].rtx={ssrc:l[0].ssrc+1}),n.wantReceive&&(n.rtpReceiver=new e.RTCRtpReceiver(n.dtlsTransport,o)),n.localCapabilities=g,n.sendEncodingParameters=l})),"max-compat"!==t._config.bundlePolicy&&(g+="a=group:BUNDLE "+t.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),g+="a=ice-options:trickle\r\n",t.transceivers.forEach((function(e,A){g+=n(e,e.localCapabilities,"offer",e.stream,t._dtlsRole),g+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===t.iceGatheringState||0!==A&&t.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,g+="a="+i.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(g+="a=end-of-candidates\r\n"))}));var l=new e.RTCSessionDescription({type:"offer",sdp:g});return Promise.resolve(l)},c.prototype.createAnswer=function(){var t=this;if(t._isClosed)return Promise.reject(s("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==t.signalingState&&"have-local-pranswer"!==t.signalingState)return Promise.reject(s("InvalidStateError","Can not call createAnswer in signalingState "+t.signalingState));var r=i.writeSessionBoilerplate(t._sdpSessionId,t._sdpSessionVersion++);t.usingBundle&&(r+="a=group:BUNDLE "+t.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),r+="a=ice-options:trickle\r\n";var o=i.getMediaSections(t._remoteDescription.sdp).length;t.transceivers.forEach((function(e,i){if(!(i+1>o)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?r+="m=application 0 DTLS/SCTP 5000\r\n":r+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?r+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(r+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(r+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var s;e.stream&&("audio"===e.kind?s=e.stream.getAudioTracks()[0]:"video"===e.kind&&(s=e.stream.getVideoTracks()[0]),s&&A>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}));var g=a(e.localCapabilities,e.remoteCapabilities);!g.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,r+=n(e,g,"answer",e.stream,t._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(r+="a=rtcp-rsize\r\n")}}));var g=new e.RTCSessionDescription({type:"answer",sdp:r});return Promise.resolve(g)},c.prototype.addIceCandidate=function(e){var A,t=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(n,a){if(!t._remoteDescription)return a(s("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var r=e.sdpMLineIndex;if(e.sdpMid)for(var g=0;g0?i.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return n();if(c.component&&1!==c.component)return n();if((0===r||r>0&&l.iceTransport!==t.transceivers[0].iceTransport)&&!o(l.iceTransport,c))return a(s("OperationError","Can not add ICE candidate"));var d=e.candidate.trim();0===d.indexOf("a=")&&(d=d.substr(2)),(A=i.getMediaSections(t._remoteDescription.sdp))[r]+="a="+(c.type?d:"end-of-candidates")+"\r\n",t._remoteDescription.sdp=i.getDescription(t._remoteDescription.sdp)+A.join("")}else for(var I=0;I0?A[0].split("/")[1]:"sendrecv",uri:A[1]}},i.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},i.parseFmtp=function(e){for(var A,t={},i=e.substr(e.indexOf(" ")+1).split(";"),n=0;n-1?(t.attribute=e.substr(A+1,i-A-1),t.value=e.substr(i+1)):t.attribute=e.substr(A+1),t},i.parseSsrcGroup=function(e){var A=e.substr(13).split(" ");return{semantics:A.shift(),ssrcs:A.map((function(e){return parseInt(e,10)}))}},i.getMid=function(e){var A=i.matchPrefix(e,"a=mid:")[0];if(A)return A.substr(6)},i.parseFingerprint=function(e){var A=e.substr(14).split(" ");return{algorithm:A[0].toLowerCase(),value:A[1]}},i.getDtlsParameters=function(e,A){return{role:"auto",fingerprints:i.matchPrefix(e+A,"a=fingerprint:").map(i.parseFingerprint)}},i.writeDtlsParameters=function(e,A){var t="a=setup:"+A+"\r\n";return e.fingerprints.forEach((function(e){t+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),t},i.getIceParameters=function(e,A){var t=i.splitLines(e);return{usernameFragment:(t=t.concat(i.splitLines(A))).filter((function(e){return 0===e.indexOf("a=ice-ufrag:")}))[0].substr(12),password:t.filter((function(e){return 0===e.indexOf("a=ice-pwd:")}))[0].substr(10)}},i.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},i.parseRtpParameters=function(e){for(var A={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},t=i.splitLines(e)[0].split(" "),n=3;n0?"9":"0",t+=" UDP/TLS/RTP/SAVPF ",t+=A.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",t+="c=IN IP4 0.0.0.0\r\n",t+="a=rtcp:9 IN IP4 0.0.0.0\r\n",A.codecs.forEach((function(e){t+=i.writeRtpMap(e),t+=i.writeFmtp(e),t+=i.writeRtcpFb(e)}));var n=0;return A.codecs.forEach((function(e){e.maxptime>n&&(n=e.maxptime)})),n>0&&(t+="a=maxptime:"+n+"\r\n"),t+="a=rtcp-mux\r\n",A.headerExtensions&&A.headerExtensions.forEach((function(e){t+=i.writeExtmap(e)})),t},i.parseRtpEncodingParameters=function(e){var A,t=[],n=i.parseRtpParameters(e),a=-1!==n.fecMechanisms.indexOf("RED"),r=-1!==n.fecMechanisms.indexOf("ULPFEC"),o=i.matchPrefix(e,"a=ssrc:").map((function(e){return i.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),s=o.length>0&&o[0].ssrc,g=i.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));g.length>0&&g[0].length>1&&g[0][0]===s&&(A=g[0][1]),n.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var i={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&A&&(i.rtx={ssrc:A}),t.push(i),a&&((i=JSON.parse(JSON.stringify(i))).fec={ssrc:s,mechanism:r?"red+ulpfec":"red"},t.push(i))}})),0===t.length&&s&&t.push({ssrc:s});var l=i.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substr(5),10)*.95-16e3:void 0,t.forEach((function(e){e.maxBitrate=l}))),t},i.parseRtcpParameters=function(e){var A={},t=i.matchPrefix(e,"a=ssrc:").map((function(e){return i.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];t&&(A.cname=t.value,A.ssrc=t.ssrc);var n=i.matchPrefix(e,"a=rtcp-rsize");A.reducedSize=n.length>0,A.compound=0===n.length;var a=i.matchPrefix(e,"a=rtcp-mux");return A.mux=a.length>0,A},i.parseMsid=function(e){var A,t=i.matchPrefix(e,"a=msid:");if(1===t.length)return{stream:(A=t[0].substr(7).split(" "))[0],track:A[1]};var n=i.matchPrefix(e,"a=ssrc:").map((function(e){return i.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return n.length>0?{stream:(A=n[0].value.split(" "))[0],track:A[1]}:void 0},i.parseSctpDescription=function(e){var A,t=i.parseMLine(e),n=i.matchPrefix(e,"a=max-message-size:");n.length>0&&(A=parseInt(n[0].substr(19),10)),isNaN(A)&&(A=65536);var a=i.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:t.fmt,maxMessageSize:A};if(i.matchPrefix(e,"a=sctpmap:").length>0){var r=i.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(r[0],10),protocol:r[1],maxMessageSize:A}}},i.writeSctpDescription=function(e,A){var t=[];return t="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+A.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+A.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+A.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+A.port+" "+A.protocol+" 65535\r\n"],void 0!==A.maxMessageSize&&t.push("a=max-message-size:"+A.maxMessageSize+"\r\n"),t.join("")},i.generateSessionId=function(){return Math.random().toString().substr(2,21)},i.writeSessionBoilerplate=function(e,A,t){var n=void 0!==A?A:2;return"v=0\r\no="+(t||"thisisadapterortc")+" "+(e||i.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},i.writeMediaSection=function(e,A,t,n){var a=i.writeRtpDescription(e.kind,A);if(a+=i.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=i.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===t?"actpass":"active"),a+="a=mid:"+e.mid+"\r\n",e.direction?a+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var r="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+r,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+r,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+r,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+i.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+i.localCName+"\r\n"),a},i.getDirection=function(e,A){for(var t=i.splitLines(e),n=0;n=26&&e<=A||oC.extension.isInstalled()}return!0};var rC={extensionId:"hapfgfdkleiggjjpfpenajgdnfckjpaj",isInstalled:function(){return null!==document.querySelector("#janus-extension-installed")},getScreen:function(e){var A=window.setTimeout((function(){var A=new Error("NavigatorUserMediaError");return A.name='The required Chrome extension is not installed: click here to install it. (NOTE: this will need you to refresh the page)',e(A)}),1e3);this.cache[A]=e,window.postMessage({type:"janusGetScreen",id:A},"*")},init:function(){var e={};this.cache=e,window.addEventListener("message",(function(A){if(A.origin==window.location.origin)if("janusGotScreen"==A.data.type&&e[A.data.id]){var t=e[A.data.id];if(delete e[A.data.id],""===A.data.sourceId){var i=new Error("NavigatorUserMediaError");i.name="You cancelled the request for permission, giving up...",t(i)}else t(null,A.data.sourceId)}else"janusGetScreenPending"==A.data.type&&window.clearTimeout(A.data.id)}))}};function oC(e,A){if(void 0===oC.initDone)return e.error("Library not initialized"),{};if(!oC.isWebrtcSupported())return e.error("WebRTC not supported by this browser"),{};if(oC.log("Library initialized: "+oC.initDone),(e=e||{}).success="function"==typeof e.success?e.success:oC.noop,e.error="function"==typeof e.error?e.error:oC.noop,e.destroyed="function"==typeof e.destroyed?e.destroyed:oC.noop,null===e.server||void 0===e.server)return e.error("Invalid server url"),{};var t=!1,i=null,n={},a=null,r=null,o=0,s=e.server;oC.isArray(s)?(oC.log("Multiple servers provided ("+s.length+"), will use the first that works"),s=null,r=e.server,oC.debug(r)):0===s.indexOf("ws")?(t=!0,oC.log("Using WebSockets to contact Janus: "+s)):(t=!1,oC.log("Using REST API to contact Janus: "+s));var g=e.iceServers;null==g&&(g=[{urls:"stun:stun.l.google.com:19302"}]);var l=e.iceTransportPolicy,c=e.bundlePolicy,d=e.ipv6;null==d&&(d=!1);var I=!1;void 0!==e.withCredentials&&null!==e.withCredentials&&(I=!0===e.withCredentials);var C=10;void 0!==e.max_poll_events&&null!==e.max_poll_events&&(C=e.max_poll_events),C<1&&(C=1);var h=null;void 0!==e.token&&null!==e.token&&(h=e.token);var u=null;void 0!==e.apisecret&&null!==e.apisecret&&(u=e.apisecret),this.destroyOnUnload=!0,void 0!==e.destroyOnUnload&&null!==e.destroyOnUnload&&(this.destroyOnUnload=!0===e.destroyOnUnload);var B=25e3;void 0!==e.keepAlivePeriod&&null!==e.keepAlivePeriod&&(B=e.keepAlivePeriod),isNaN(B)&&(B=25e3);var f=6e4;function E(e){var A={high:9e5,medium:3e5,low:1e5};return null!=e&&(e.high&&(A.high=e.high),e.medium&&(A.medium=e.medium),e.low&&(A.low=e.low)),A}void 0!==e.longPollTimeout&&null!==e.longPollTimeout&&(f=e.longPollTimeout),isNaN(f)&&(f=6e4);var x=!1,Q=null,p={},m=this,y=0,_={};function S(){if(null!=Q)if(oC.debug("Long poll..."),x){var A=s+"/"+Q+"?rid="+(new Date).getTime();null!=C&&(A=A+"&maxev="+C),null!=h&&(A=A+"&token="+encodeURIComponent(h)),null!=u&&(A=A+"&apisecret="+encodeURIComponent(u)),oC.httpAPICall(A,{verb:"GET",withCredentials:I,success:v,timeout:f,error:function(A,t){if(oC.error(A+":",t),++y>3)return x=!1,void e.error("Lost connection to the server (is it down?)");S()}})}else oC.warn("Is the server down? (connected=false)")}function v(e,A){if(y=0,t||null==Q||!0===A||S(),t||!oC.isArray(e))if("keepalive"!==e.rtcgw)if("ack"!==e.rtcgw)if("success"!==e.rtcgw)if("trickle"===e.rtcgw){if(null==(s=e.sender))return void oC.warn("Missing sender...");if(null==(l=p[s]))return void oC.debug("This handle is not attached to this session");var n=e.candidate;oC.debug("Got a trickled candidate on session "+Q),oC.debug(n);var a=l.webrtcStuff;a.pc&&a.remoteSdp?(oC.debug("Adding remote candidate:",n),n&&!0!==n.completed?a.pc.addIceCandidate(n):a.pc.addIceCandidate(oC.endOfCandidates)):(oC.debug("We didn't do setRemoteDescription (trickle got here before the offer?), caching candidate"),a.candidates||(a.candidates=[]),a.candidates.push(n),oC.debug(a.candidates))}else{if("webrtcup"===e.rtcgw)return oC.debug("Got a webrtcup event on session "+Q),oC.debug(e),null==(s=e.sender)?void oC.warn("Missing sender..."):null==(l=p[s])?void oC.debug("This handle is not attached to this session"):void l.webrtcState(!0);if("hangup"===e.rtcgw){if(oC.debug("Got a hangup event on session "+Q),oC.debug(e),null==(s=e.sender))return void oC.warn("Missing sender...");if(null==(l=p[s]))return void oC.debug("This handle is not attached to this session");l.webrtcState(!1,e.reason),l.hangup()}else if("detached"===e.rtcgw){if(oC.debug("Got a detached event on session "+Q),oC.debug(e),null==(s=e.sender))return void oC.warn("Missing sender...");if(null==(l=p[s]))return;l.detached=!0,l.ondetached(),l.detach()}else if("media"===e.rtcgw){if(oC.debug("Got a media event on session "+Q),oC.debug(e),null==(s=e.sender))return void oC.warn("Missing sender...");if(null==(l=p[s]))return void oC.debug("This handle is not attached to this session");l.mediaState(e.type,e.receiving)}else if("slowlink"===e.rtcgw){if(oC.debug("Got a slowlink event on session "+Q),oC.debug(e),null==(s=e.sender))return void oC.warn("Missing sender...");if(null==(l=p[s]))return void oC.debug("This handle is not attached to this session");l.slowLink(e.uplink,e.lost)}else{var r,o;if("error"===e.rtcgw)return oC.error("Ooops: "+e.error.code+" "+e.error.reason),oC.debug(e),void(null!=(r=e.transaction)&&(null!=(o=_[r])&&o(e),delete _[r]));if("event"===e.rtcgw){var s;if(oC.debug("Got a plugin event on session "+Q),oC.debug(e),null==(s=e.sender))return void oC.warn("Missing sender...");var g=e.plugindata;if(null==g)return void oC.warn("Missing plugindata...");oC.debug(" -- Event is coming from "+s+" ("+g.plugin+")");var l,c=g.data;if(oC.debug(c),null==(l=p[s]))return void oC.warn("This handle is not attached to this session");var d=e.jsep;null!=d&&(oC.debug("Handling SDP as well..."),oC.debug(d));var I=l.onmessage;null!=I?(oC.debug("Notifying application..."),I(c,d)):oC.debug("No provided notification callback")}else{if("timeout"===e.rtcgw)return oC.error("Timeout on session "+Q),oC.debug(e),void(t&&i.close(3504,"Gateway timeout"));oC.warn("Unknown message/event '"+e.rtcgw+"' on session "+Q),oC.debug(e)}}}else oC.debug("Got a success on session "+Q),null!=(r=e.transaction)&&(null!=(o=_[r])&&o(e),delete _[r]);else null!=(r=e.transaction)&&(null!=(o=_[r])&&o(e),delete _[r]);else oC.vdebug("Got a keepalive on session "+Q);else for(var C=0;C data channel: "+t),"open"===t){if(a.dataChannel[A].pending&&a.dataChannel[A].pending.length>0){for(var i in oC.log("Sending pending messages on <"+A+">:",a.dataChannel[A].pending.length),a.dataChannel[A].pending){var r=a.dataChannel[A].pending[i];oC.log("Sending string on data channel <"+A+">: "+r),a.dataChannel[A].send(r)}a.dataChannel[A].pending=[]}n.ondataopen(A)}};a.dataChannel[A]=t||a.pc.createDataChannel(A,{ordered:!1}),a.dataChannel[A].onmessage=function(e){oC.log("Received message on data channel:",e);var A=e.target.label;n.ondata(e.data,A)},a.dataChannel[A].onopen=r,a.dataChannel[A].onclose=r,a.dataChannel[A].onerror=function(e){oC.error("Got error on data channel:",e)},a.dataChannel[A].pending=[],i&&a.dataChannel[A].pending.push(i)}else oC.warn("Invalid handle")}function k(e,A){(A=A||{}).success="function"==typeof A.success?A.success:oC.noop,A.error="function"==typeof A.error?A.error:oC.noop;var t=p[e];if(null==t||null===t.webrtcStuff||void 0===t.webrtcStuff)return oC.warn("Invalid handle"),void A.error("Invalid handle");var i=t.webrtcStuff,n=A.text;if(null==n)return oC.warn("Invalid text"),void A.error("Invalid text");var a=A.label?A.label:oC.dataChanDefaultLabel;return i.dataChannel[a]?"open"!==i.dataChannel[a].readyState?(i.dataChannel[a].pending.push(n),void A.success()):(oC.log("Sending string on data channel <"+a+">: "+n),i.dataChannel[a].send(n),void A.success()):(R(e,a,!1,n),void A.success())}function P(e,A){(A=A||{}).success="function"==typeof A.success?A.success:oC.noop,A.error="function"==typeof A.error?A.error:oC.noop;var t=p[e];if(null==t||null===t.webrtcStuff||void 0===t.webrtcStuff)return oC.warn("Invalid handle"),void A.error("Invalid handle");var i=t.webrtcStuff;if(null===i.dtmfSender||void 0===i.dtmfSender){if(void 0!==i.pc&&null!==i.pc){var n=i.pc.getSenders().find((function(e){return e.track&&"audio"===e.track.kind}));if(!n)return oC.warn("Invalid DTMF configuration (no audio track)"),void A.error("Invalid DTMF configuration (no audio track)");i.dtmfSender=n.dtmf,i.dtmfSender&&(oC.log("Created DTMF Sender"),i.dtmfSender.ontonechange=function(e){oC.debug("Sent DTMF tone: "+e.tone)})}if(null===i.dtmfSender||void 0===i.dtmfSender)return oC.warn("Invalid DTMF configuration"),void A.error("Invalid DTMF configuration")}var a=A.dtmf;if(null==a)return oC.warn("Invalid DTMF parameters"),void A.error("Invalid DTMF parameters");var r=a.tones;if(null==r)return oC.warn("Invalid DTMF string"),void A.error("Invalid DTMF string");var o=a.duration;null==o&&(o=500);var s=a.gap;null==s&&(s=50),oC.debug("Sending DTMF string "+r+" (duration "+o+"ms, gap "+s+"ms)"),i.dtmfSender.insertDTMF(r,o,s),A.success()}function T(e,A){(A=A||{}).success="function"==typeof A.success?A.success:oC.noop,A.error="function"==typeof A.error?A.error:oC.noop;var n=!0;void 0!==A.asyncRequest&&null!==A.asyncRequest&&(n=!0===A.asyncRequest);var a=!0;void 0!==A.noRequest&&null!==A.noRequest&&(a=!0===A.noRequest),oC.log("Destroying handle "+e+" (async="+n+")"),K(e);var r=p[e];if(null==r||r.detached)return delete p[e],void A.success();if(a)return delete p[e],void A.success();if(!x)return oC.warn("Is the server down? (connected=false)"),void A.error("Is the server down? (connected=false)");var o={rtcgw:"detach",transaction:oC.randomString(12)};if(null!==r.token&&void 0!==r.token&&(o.token=r.token),null!=u&&(o.apisecret=u),t)return o.session_id=Q,o.handle_id=e,i.send(JSON.stringify(o)),delete p[e],void A.success();oC.httpAPICall(s+"/"+Q+"/"+e,{verb:"POST",async:n,withCredentials:I,body:o,success:function(t){oC.log("Destroyed handle:"),oC.debug(t),"success"!==t.rtcgw&&oC.error("Ooops: "+t.error.code+" "+t.error.reason),delete p[e],A.success()},error:function(t,i){oC.error(t+":",i),delete p[e],A.success()}})}async function N(e,A,t,i,n){var a=p[e];if(null==a||null===a.webrtcStuff||void 0===a.webrtcStuff)return oC.warn("Invalid handle"),void i.error("Invalid handle");var r=a.webrtcStuff;oC.debug("streamsDone:",n),n&&(oC.debug(" -- Audio tracks:",n.getAudioTracks()),oC.debug(" -- Video tracks:",n.getVideoTracks()));var o=!1;if(r.myStream&&t.update&&!r.streamExternal){if((!t.update&&O(t)||t.update&&(t.addAudio||t.replaceAudio))&&n.getAudioTracks()&&n.getAudioTracks().length)if(r.myStream.addTrack(n.getAudioTracks()[0]),oC.unifiedPlan){oC.log((t.replaceAudio?"Replacing":"Adding")+" audio track:",n.getAudioTracks()[0]);var s=null;if((f=r.pc.getTransceivers())&&f.length>0)for(var I in f)if((Q=f[I]).sender&&Q.sender.track&&"audio"===Q.sender.track.kind||Q.receiver&&Q.receiver.track&&"audio"===Q.receiver.track.kind){s=Q;break}let A=null;try{A=await i.customizeStream(n)}catch(e){i.error(e)}var C,h,u,B;s&&s.sender?s.sender.replaceTrack((null===(C=A)||void 0===C||null===(h=C.getAudioTracks)||void 0===h||null===(h=h.call(C))||void 0===h?void 0:h[0])||n.getAudioTracks()[0]):r.pc.addTrack((null===(u=A)||void 0===u||null===(B=u.getAudioTracks)||void 0===B||null===(B=B.call(u))||void 0===B?void 0:B[0])||n.getAudioTracks()[0],A||n)}else oC.log((t.replaceAudio?"Replacing":"Adding")+" audio track:",n.getAudioTracks()[0]),r.pc.addTrack(n.getAudioTracks()[0],n);if((!t.update&&j(t)||t.update&&(t.addVideo||t.replaceVideo))&&n.getVideoTracks()&&n.getVideoTracks().length)if(r.myStream.addTrack(n.getVideoTracks()[0]),oC.unifiedPlan){oC.log((t.replaceVideo?"Replacing":"Adding")+" video track:",n.getVideoTracks()[0]);var f,x=null;if((f=r.pc.getTransceivers())&&f.length>0)for(var I in f){var Q;if((Q=f[I]).sender&&Q.sender.track&&"video"===Q.sender.track.kind||Q.receiver&&Q.receiver.track&&"video"===Q.receiver.track.kind){x=Q;break}}x&&x.sender?x.sender.replaceTrack(n.getVideoTracks()[0]):r.pc.addTrack(n.getVideoTracks()[0],n)}else oC.log((t.replaceVideo?"Replacing":"Adding")+" video track:",n.getVideoTracks()[0]),r.pc.addTrack(n.getVideoTracks()[0],n)}else r.myStream=n,o=!0;if(!r.pc){var m={iceServers:g,iceTransportPolicy:l,bundlePolicy:c};"chrome"===oC.webRTCAdapter.browserDetails.browser&&(m.sdpSemantics=oC.webRTCAdapter.browserDetails.version<72?"plan-b":"unified-plan");var y={optional:[{DtlsSrtpKeyAgreement:!0}]};if(!0===d&&y.optional.push({googIPv6:!0}),i.rtcConstraints&&"object"==typeof i.rtcConstraints)for(var I in oC.debug("Adding custom PeerConnection constraints:",i.rtcConstraints),i.rtcConstraints)y.optional.push(i.rtcConstraints[I]);"edge"===oC.webRTCAdapter.browserDetails.browser&&(m.bundlePolicy="max-bundle"),oC.log("Creating PeerConnection"),oC.debug(y),r.pc=new RTCPeerConnection(m,y),oC.debug(r.pc),r.pc.getStats&&(r.volume={},r.bitrate.value="0 kbits/sec"),oC.log("Preparing local SDP and gathering candidates (trickle="+r.trickle+")"),r.pc.oniceconnectionstatechange=function(e){r.pc&&a.iceState(r.pc.iceConnectionState)},r.pc.onicecandidate=function(A){if(null==A.candidate||"edge"===oC.webRTCAdapter.browserDetails.browser&&A.candidate.candidate.indexOf("endOfCandidates")>0)oC.log("End of candidates."),r.iceDone=!0,!0===r.trickle?F(e,{completed:!0}):function(e,A){(A=A||{}).success="function"==typeof A.success?A.success:oC.noop,A.error="function"==typeof A.error?A.error:oC.noop;var t=p[e];if(null!=t&&null!==t.webrtcStuff&&void 0!==t.webrtcStuff){var i=t.webrtcStuff;oC.log("Sending offer/answer SDP..."),null!==i.mySdp&&void 0!==i.mySdp?(i.mySdp={type:i.pc.localDescription.type,sdp:i.pc.localDescription.sdp},!1===i.trickle&&(i.mySdp.trickle=!1),oC.debug(A),i.sdpSent=!0,A.success(i.mySdp)):oC.warn("Local SDP instance is invalid, not sending anything...")}else oC.warn("Invalid handle, not sending anything")}(e,i);else{var t={candidate:A.candidate.candidate,sdpMid:A.candidate.sdpMid,sdpMLineIndex:A.candidate.sdpMLineIndex};!0===r.trickle&&F(e,t)}},r.pc.ontrack=function(e){oC.log("Handling Remote Track"),oC.debug(e),e.streams&&(r.remoteStream=e.streams[0],a.onremotestream(r.remoteStream),e.track.onended||(oC.log("Adding onended callback to track:",e.track),e.track.onended=function(e){oC.log("Remote track muted/removed:",e),r.remoteStream&&(r.remoteStream.removeTrack(e.target),a.onremotestream(r.remoteStream))},e.track.onmute=e.track.onended,e.track.onunmute=function(e){try{r.remoteStream.addTrack(e.target),a.onremotestream(r.remoteStream)}catch(e){oC.error(e)}}))}}if(o&&null!=n){oC.log("Adding local stream");var _=!0===i.simulcast2,S=n.getTracks();for(let A=0;A0)for(var l in g){var c=g[l];c.sender&&c.sender.track&&"audio"===c.sender.track.kind||c.receiver&&c.receiver.track&&"audio"===c.receiver.track.kind?o||(o=c):(c.sender&&c.sender.track&&"video"===c.sender.track.kind||c.receiver&&c.receiver.track&&"video"===c.receiver.track.kind)&&(s||(s=c))}var d=O(A),I=V(A);d||I?d&&I?o&&(o.setDirection?o.setDirection("sendrecv"):o.direction="sendrecv",oC.log("Setting audio transceiver to sendrecv:",o)):d&&!I?o&&(o.setDirection?o.setDirection("sendonly"):o.direction="sendonly",oC.log("Setting audio transceiver to sendonly:",o)):!d&&I&&(o?(o.setDirection?o.setDirection("recvonly"):o.direction="recvonly",oC.log("Setting audio transceiver to recvonly:",o)):(o=n.pc.addTransceiver("audio",{direction:"recvonly"}),oC.log("Adding recvonly audio transceiver:",o))):A.removeAudio&&o&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive",oC.log("Setting audio transceiver to inactive:",o));var C=j(A),h=W(A);C||h?C&&h?s&&(s.setDirection?s.setDirection("sendrecv"):s.direction="sendrecv",oC.log("Setting video transceiver to sendrecv:",s)):C&&!h?s&&(s.setDirection?s.setDirection("sendonly"):s.direction="sendonly",oC.log("Setting video transceiver to sendonly:",s)):!C&&h&&(s?(s.setDirection?s.setDirection("recvonly"):s.direction="recvonly",oC.log("Setting video transceiver to recvonly:",s)):(s=n.pc.addTransceiver("video",{direction:"recvonly"}),oC.log("Adding recvonly video transceiver:",s))):A.removeVideo&&s&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive",oC.log("Setting video transceiver to inactive:",s))}else r.offerToReceiveAudio=V(A),r.offerToReceiveVideo=W(A);!0===t.iceRestart&&(r.iceRestart=!0),oC.debug(r);var u=j(A);if(u&&a&&"firefox"===oC.webRTCAdapter.browserDetails.browser){var B=n.pc.getSenders().find((function(e){return"video"==e.track.kind}));if(B){var f=B.getParameters();f||(f={});const e=E(t.simulcastMaxBitrates);f.encodings=[{rid:"h",active:!0,maxBitrate:e.high},{rid:"m",active:!0,maxBitrate:e.medium,scaleResolutionDownBy:2},{rid:"l",active:!0,maxBitrate:e.low,scaleResolutionDownBy:4}],B.setParameters(f)}}n.pc.createOffer(r).then((function(e){var A={type:e.type,sdp:e.sdp};t.customizeSdp(A),e.sdp=A.sdp,oC.log("Setting local description"),u&&a&&("chrome"===oC.webRTCAdapter.browserDetails.browser||"safari"===oC.webRTCAdapter.browserDetails.browser?(oC.log("Enabling Simulcasting for Chrome (SDP munging)"),e.sdp=function(e){for(var A=e.split("\r\n"),t=!1,i=[-1],n=[-1],a=null,r=null,o=null,s=null,g=-1,l=0;l-1){g=l;break}}else if(t){var c=A[l].match(/a=ssrc-group:FID (\d+) (\d+)/);if(c)i[0]=c[1],n[0]=c[2],A.splice(l,1),l--;else{if(i[0]){if((C=A[l].match("a=ssrc:"+i[0]+" cname:(.+)"))&&(a=C[1]),(C=A[l].match("a=ssrc:"+i[0]+" msid:(.+)"))&&(r=C[1]),(C=A[l].match("a=ssrc:"+i[0]+" mslabel:(.+)"))&&(o=C[1]),(C=A[l].match("a=ssrc:"+i[0]+" label:(.+)"))&&(s=C[1]),0===A[l].indexOf("a=ssrc:"+n[0])){A.splice(l,1),l--;continue}if(0===A[l].indexOf("a=ssrc:"+i[0])){A.splice(l,1),l--;continue}}0!=A[l].length||(A.splice(l,1),l--)}}if(i[0]<0)for(g=-1,t=!1,l=0;l-1){g=l;break}}else if(t){if(i[0]<0){var I=A[l].match(/a=ssrc:(\d+)/);if(I){i[0]=I[1],A.splice(l,1),l--;continue}}else{var C;if((C=A[l].match("a=ssrc:"+i[0]+" cname:(.+)"))&&(a=C[1]),(C=A[l].match("a=ssrc:"+i[0]+" msid:(.+)"))&&(r=C[1]),(C=A[l].match("a=ssrc:"+i[0]+" mslabel:(.+)"))&&(o=C[1]),(C=A[l].match("a=ssrc:"+i[0]+" label:(.+)"))&&(s=C[1]),0===A[l].indexOf("a=ssrc:"+n[0])){A.splice(l,1),l--;continue}if(0===A[l].indexOf("a=ssrc:"+i[0])){A.splice(l,1),l--;continue}}0!=A[l].length||(A.splice(l,1),l--)}}if(i[0]<0)return oC.warn("Couldn't find the video SSRC, simulcasting NOT enabled"),e;for(g<0&&(g=A.length),i[1]=Math.floor(4294967295*Math.random()),i[2]=Math.floor(4294967295*Math.random()),n[1]=Math.floor(4294967295*Math.random()),n[2]=Math.floor(4294967295*Math.random()),l=0;l0){for(var n=0;n0)for(var l in g){var c=g[l];c.sender&&c.sender.track&&"audio"===c.sender.track.kind||c.receiver&&c.receiver.track&&"audio"===c.receiver.track.kind?o||(o=c):(c.sender&&c.sender.track&&"video"===c.sender.track.kind||c.receiver&&c.receiver.track&&"video"===c.receiver.track.kind)&&(s||(s=c))}var d=O(A),I=V(A);if(d||I){if(d&&I){if(o)try{o.setDirection?o.setDirection("sendrecv"):o.direction="sendrecv",oC.log("Setting audio transceiver to sendrecv:",o)}catch(e){oC.error(e)}}else if(d&&!I)try{o&&(o.setDirection?o.setDirection("sendonly"):o.direction="sendonly",oC.log("Setting audio transceiver to sendonly:",o))}catch(e){oC.error(e)}else if(!d&&I)if(o)try{o.setDirection?o.setDirection("recvonly"):o.direction="recvonly",oC.log("Setting audio transceiver to recvonly:",o)}catch(e){oC.error(e)}else o=n.pc.addTransceiver("audio",{direction:"recvonly"}),oC.log("Adding recvonly audio transceiver:",o)}else if(A.removeAudio&&o)try{o.setDirection?o.setDirection("inactive"):o.direction="inactive",oC.log("Setting audio transceiver to inactive:",o)}catch(e){oC.error(e)}var C=j(A),h=W(A);if(C||h){if(C&&h){if(s)try{s.setDirection?s.setDirection("sendrecv"):s.direction="sendrecv",oC.log("Setting video transceiver to sendrecv:",s)}catch(e){oC.error(e)}}else if(C&&!h){if(s)try{s.setDirection?s.setDirection("sendonly"):s.direction="sendonly",oC.log("Setting video transceiver to sendonly:",s)}catch(e){oC.error(e)}}else if(!C&&h)if(s)try{s.setDirection?s.setDirection("recvonly"):s.direction="recvonly",oC.log("Setting video transceiver to recvonly:",s)}catch(e){oC.error(e)}else s=n.pc.addTransceiver("video",{direction:"recvonly"}),oC.log("Adding recvonly video transceiver:",s)}else if(A.removeVideo&&s)try{s.setDirection?s.setDirection("inactive"):s.direction="inactive",oC.log("Setting video transceiver to inactive:",s)}catch(e){oC.error(e)}}else r="firefox"==oC.webRTCAdapter.browserDetails.browser||"edge"==oC.webRTCAdapter.browserDetails.browser?{offerToReceiveAudio:V(A),offerToReceiveVideo:W(A)}:{mandatory:{OfferToReceiveAudio:V(A),OfferToReceiveVideo:W(A)}};oC.debug(r);var u=j(A);if(u&&a&&"firefox"===oC.webRTCAdapter.browserDetails.browser){oC.log("Enabling Simulcasting for Firefox (RID)");var B=n.pc.getSenders()[1];oC.log(B);var f=B.getParameters();oC.log(f);const e=E(t.simulcastMaxBitrates);B.setParameters({encodings:[{rid:"high",active:!0,priority:"high",maxBitrate:e.high},{rid:"medium",active:!0,priority:"medium",maxBitrate:e.medium},{rid:"low",active:!0,priority:"low",maxBitrate:e.low}]})}n.pc.createAnswer(r).then((function(e){oC.debug(e);var A={type:e.type,sdp:e.sdp};t.customizeSdp(A),e.sdp=A.sdp,oC.log("Setting local description"),u&&a&&("chrome"===oC.webRTCAdapter.browserDetails.browser?oC.warn("simulcast=true, but this is an answer, and video breaks in Chrome if we enable it"):"firefox"!==oC.webRTCAdapter.browserDetails.browser&&oC.warn("simulcast=true, but this is not Chrome nor Firefox, ignoring")),n.mySdp=e.sdp,n.pc.setLocalDescription(e).catch(t.error),n.mediaConstraints=r,n.iceDone||n.trickle?t.success(e):oC.log("Waiting for all candidates...")}),t.error)}(e,t,i)}),i.error)}function M(e,A,t){(t=t||{}).success="function"==typeof t.success?t.success:oC.noop,t.error="function"==typeof t.error?t.error:H,t.customizeStream="function"==typeof t.customizeStream?t.customizeStream:oC.noop;var i=t.jsep;if(A&&i)return oC.error("Provided a JSEP to a createOffer"),void t.error("Provided a JSEP to a createOffer");if(!(A||i&&i.type&&i.sdp))return oC.error("A valid JSEP is required for createAnswer"),void t.error("A valid JSEP is required for createAnswer");t.media=t.media||{audio:!0,video:!0};var n=t.media,a=p[e];if(null==a||null===a.webrtcStuff||void 0===a.webrtcStuff)return oC.warn("Invalid handle"),void t.error("Invalid handle");var r,o=a.webrtcStuff;if(o.trickle=null==(r=t.trickle)||!0===r,void 0===o.pc||null===o.pc)n.update=!1,n.keepAudio=!1,n.keepVideo=!1;else if(void 0!==o.pc&&null!==o.pc){if(oC.log("Updating existing media session"),n.update=!0,null!==t.stream&&void 0!==t.stream)t.stream!==o.myStream&&oC.log("Renegotiation involves a new external stream");else{if(n.addAudio){if(n.keepAudio=!1,n.replaceAudio=!1,n.removeAudio=!1,n.audioSend=!0,o.myStream&&o.myStream.getAudioTracks()&&o.myStream.getAudioTracks().length)return oC.error("Can't add audio stream, there already is one"),void t.error("Can't add audio stream, there already is one")}else n.removeAudio?(n.keepAudio=!1,n.replaceAudio=!1,n.addAudio=!1,n.audioSend=!1):n.replaceAudio&&(n.keepAudio=!1,n.addAudio=!1,n.removeAudio=!1,n.audioSend=!0);if(null===o.myStream||void 0===o.myStream?(n.replaceAudio&&(n.keepAudio=!1,n.replaceAudio=!1,n.addAudio=!0,n.audioSend=!0),O(n)&&(n.keepAudio=!1,n.addAudio=!0)):null===o.myStream.getAudioTracks()||void 0===o.myStream.getAudioTracks()||0===o.myStream.getAudioTracks().length?(n.replaceAudio&&(n.keepAudio=!1,n.replaceAudio=!1,n.addAudio=!0,n.audioSend=!0),O(n)&&(n.keepVideo=!1,n.addAudio=!0)):!O(n)||n.removeAudio||n.replaceAudio||(n.keepAudio=!0),n.addVideo){if(n.keepVideo=!1,n.replaceVideo=!1,n.removeVideo=!1,n.videoSend=!0,o.myStream&&o.myStream.getVideoTracks()&&o.myStream.getVideoTracks().length)return oC.error("Can't add video stream, there already is one"),void t.error("Can't add video stream, there already is one")}else n.removeVideo?(n.keepVideo=!1,n.replaceVideo=!1,n.addVideo=!1,n.videoSend=!1):n.replaceVideo&&(n.keepVideo=!1,n.addVideo=!1,n.removeVideo=!1,n.videoSend=!0);null===o.myStream||void 0===o.myStream||null===o.myStream.getVideoTracks()||void 0===o.myStream.getVideoTracks()||0===o.myStream.getVideoTracks().length?(n.replaceVideo&&(n.keepVideo=!1,n.replaceVideo=!1,n.addVideo=!0,n.videoSend=!0),j(n)&&(n.keepVideo=!1,n.addVideo=!0)):!j(n)||n.removeVideo||n.replaceVideo||(n.keepVideo=!0),n.addData&&(n.data=!0)}if(O(n)&&n.keepAudio&&j(n)&&n.keepVideo)return a.consentDialog(!1),void N(e,i,n,t,o.myStream)}if(n.update&&!o.streamExternal){if(n.removeAudio||n.replaceAudio){if(o.myStream&&o.myStream.getAudioTracks()&&o.myStream.getAudioTracks().length){var s=o.myStream.getAudioTracks()[0];oC.log("Removing audio track:",s),o.myStream.removeTrack(s);try{s.stop()}catch(v){}}if(o.pc.getSenders()&&o.pc.getSenders().length){var g=!0;if(n.replaceAudio&&oC.unifiedPlan&&(g=!1),g)for(var l in o.pc.getSenders())(s=o.pc.getSenders()[l])&&s.track&&"audio"===s.track.kind&&(oC.log("Removing audio sender:",s),o.pc.removeTrack(s))}}if(n.removeVideo||n.replaceVideo){if(o.myStream&&o.myStream.getVideoTracks()&&o.myStream.getVideoTracks().length){s=o.myStream.getVideoTracks()[0],oC.log("Removing video track:",s),o.myStream.removeTrack(s);try{s.stop()}catch(D){}}if(o.pc.getSenders()&&o.pc.getSenders().length){var c=!0;if(n.replaceVideo&&oC.unifiedPlan&&(c=!1),c)for(var l in o.pc.getSenders())(s=o.pc.getSenders()[l])&&s.track&&"video"===s.track.kind&&(oC.log("Removing video sender:",s),o.pc.removeTrack(s))}}}if(null!==t.stream&&void 0!==t.stream){var d=t.stream;if(oC.log("MediaStream provided by the application"),oC.debug(d),n.update&&o.myStream&&o.myStream!==t.stream&&!o.streamExternal){try{var I=o.myStream.getTracks();for(var C in I){var h=I[C];oC.log(h),null!=h&&h.stop()}}catch(w){}o.myStream=null}return o.streamExternal=!0,a.consentDialog(!1),void N(e,i,n,t,d)}if(O(n)||j(n)){if(!oC.isGetUserMediaAvailable())return void t.error("getUserMedia not available");var u={mandatory:{},optional:[]};a.consentDialog(!0);var B=O(n);!0===B&&null!=n&&null!=n&&"object"==typeof n.audio&&(B=n.audio);var f=j(n);if(!0===f&&null!=n&&null!=n){var E=!0===t.simulcast,x=!0===t.simulcast2;if(!E&&!x||i||void 0!==n.video&&!1!==n.video||(n.video="hires"),n.video&&"screen"!=n.video&&"window"!=n.video)if("object"==typeof n.video)f=n.video;else{var Q=0,m=0;"lowres"===n.video?(m=240,Q=320):"lowres-16:9"===n.video?(m=180,Q=320):"hires"===n.video||"hires-16:9"===n.video||"hdres"===n.video?(m=720,Q=1280):"fhdres"===n.video?(m=1080,Q=1920):"4kres"===n.video?(m=2160,Q=3840):"stdres"===n.video?(m=480,Q=640):"stdres-16:9"===n.video?(m=360,Q=640):(oC.log("Default video setting is stdres 4:3"),m=480,Q=640),oC.log("Adding media constraint:",n.video),f={height:{ideal:m},width:{ideal:Q}},oC.log("Adding video constraint:",f)}else if("screen"===n.video||"window"===n.video){if(n.screenshareFrameRate||(n.screenshareFrameRate=3),navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)return void navigator.mediaDevices.getDisplayMedia({video:!0}).then((function(A){a.consentDialog(!1),O(n)&&!n.keepAudio?navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((function(a){A.addTrack(a.getAudioTracks()[0]),N(e,i,n,t,A)})):N(e,i,n,t,A)}),(function(e){a.consentDialog(!1),t.error(e)}));function b(A,r){a.consentDialog(!1),A?t.error(A):N(e,i,n,t,r)}function F(e,A,t){oC.log("Adding media constraint (screen capture)"),oC.debug(e),navigator.mediaDevices.getUserMedia(e).then((function(e){t?navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then((function(t){e.addTrack(t.getAudioTracks()[0]),A(null,e)})):A(null,e)})).catch((function(e){a.consentDialog(!1),A(e)}))}if("chrome"===oC.webRTCAdapter.browserDetails.browser){var y=oC.webRTCAdapter.browserDetails.version,_=33;window.navigator.userAgent.match("Linux")&&(_=35),y>=26&&y<=_?F(u={video:{mandatory:{googLeakyBucket:!0,maxWidth:window.screen.width,maxHeight:window.screen.height,minFrameRate:n.screenshareFrameRate,maxFrameRate:n.screenshareFrameRate,chromeMediaSource:"screen"}},audio:O(n)&&!n.keepAudio},b):oC.extension.getScreen((function(e,A){if(e)return a.consentDialog(!1),t.error(e);(u={audio:!1,video:{mandatory:{chromeMediaSource:"desktop",maxWidth:window.screen.width,maxHeight:window.screen.height,minFrameRate:n.screenshareFrameRate,maxFrameRate:n.screenshareFrameRate},optional:[{googLeakyBucket:!0},{googTemporalLayeredScreencast:!0}]}}).video.mandatory.chromeMediaSourceId=A,F(u,b,O(n)&&!n.keepAudio)}))}else if("firefox"===oC.webRTCAdapter.browserDetails.browser){if(!(oC.webRTCAdapter.browserDetails.version>=33)){var S=new Error("NavigatorUserMediaError");return S.name="Your version of Firefox does not support screen sharing, please install Firefox 33 (or more recent versions)",a.consentDialog(!1),void t.error(S)}F(u={video:{mozMediaSource:n.video,mediaSource:n.video},audio:O(n)&&!n.keepAudio},(function(e,A){if(b(e,A),!e)var t=A.currentTime,i=window.setInterval((function(){A||window.clearInterval(i),A.currentTime==t&&(window.clearInterval(i),A.onended&&A.onended()),t=A.currentTime}),500)}))}return}}null!=n&&"screen"===n.video||navigator.mediaDevices.enumerateDevices().then((function(A){var r=A.some((function(e){return"audioinput"===e.kind})),o=function(e){if(null==e)return!1;if("object"!=typeof e.video||"object"!=typeof e.video.mandatory)return!1;var A=e.video.mandatory;return A.chromeMediaSource?"desktop"===A.chromeMediaSource||"screen"===A.chromeMediaSource:A.mozMediaSource?"window"===A.mozMediaSource||"screen"===A.mozMediaSource:!!A.mediaSource&&("window"===A.mediaSource||"screen"===A.mediaSource)}(n)||A.some((function(e){return"videoinput"===e.kind})),s=O(n),g=j(n),l=function(e){return null!=e&&!1!==e.audio&&!1!==e.audioSend&&void 0!==e.failIfNoAudio&&null!==e.failIfNoAudio&&!0===e.failIfNoAudio}(n),c=function(e){return null!=e&&!1!==e.video&&!1!==e.videoSend&&void 0!==e.failIfNoVideo&&null!==e.failIfNoVideo&&!0===e.failIfNoVideo}(n);if(s||g||l||c){var I=!!s&&r,C=!!g&&o;if(!I&&!C)return a.consentDialog(!1),t.error("No capture device found"),!1;if(!I&&l)return a.consentDialog(!1),t.error("Audio capture is required, but no capture device found"),!1;if(!C&&c)return a.consentDialog(!1),t.error("Video capture is required, but no capture device found"),!1}var h={audio:!(!r||n.keepAudio)&&B,video:!(!o||n.keepVideo)&&f};oC.debug("getUserMedia constraints",h),h.audio||h.video?navigator.mediaDevices.getUserMedia(h).then((function(A){a.consentDialog(!1),N(e,i,n,t,A)})).catch((function(e){a.consentDialog(!1),t.error({code:e.code,name:e.name,message:e.message})})):(a.consentDialog(!1),N(e,i,n,t,d))})).catch((function(e){a.consentDialog(!1),t.error("enumerateDevices error",e)}))}else N(e,i,n,t)}function L(e,A){(A=A||{}).success="function"==typeof A.success?A.success:oC.noop,A.error="function"==typeof A.error?A.error:H;var t=A.jsep,i=p[e];if(null==i||null===i.webrtcStuff||void 0===i.webrtcStuff)return oC.warn("Invalid handle"),void A.error("Invalid handle");var n=i.webrtcStuff;if(null!=t){if(null===n.pc)return oC.warn("Wait, no PeerConnection?? if this is an answer, use createAnswer and not handleRemoteJsep"),void A.error("No PeerConnection: if this is an answer, use createAnswer and not handleRemoteJsep");n.pc.setRemoteDescription(t).then((function(){if(oC.log("Remote description accepted!"),n.remoteSdp=t.sdp,n.candidates&&n.candidates.length>0){for(var e=0;e-1)&&"inbound-rtp"===e.type&&e.id.indexOf("rtcp")<0?A=!0:"ssrc"!=e.type||!e.bytesReceived||"VP8"!==e.googCodecName&&""!==e.googCodecName||(A=!0),A)if(t.bitrate.bsnow=e.bytesReceived,t.bitrate.tsnow=e.timestamp,null===t.bitrate.bsbefore||null===t.bitrate.tsbefore)t.bitrate.bsbefore=t.bitrate.bsnow,t.bitrate.tsbefore=t.bitrate.tsnow;else{var i=t.bitrate.tsnow-t.bitrate.tsbefore;"safari"==oC.webRTCAdapter.browserDetails.browser&&(i/=1e3);var n=Math.round(8*(t.bitrate.bsnow-t.bitrate.bsbefore)/i);"safari"===oC.webRTCAdapter.browserDetails.browser&&(n=parseInt(n/1e3)),t.bitrate.value=n+" kbits/sec",t.bitrate.bsbefore=t.bitrate.bsnow,t.bitrate.tsbefore=t.bitrate.tsnow}}}))}))}),1e3),"0 kbits/sec"):t.bitrate.value:(oC.warn("Getting the video bitrate unsupported by browser"),"Feature unsupported by browser")}function H(e){oC.error("WebRTC error:",e)}function K(e,A){oC.log("Cleaning WebRTC stuff");var n=p[e];if(null!=n){var a=n.webrtcStuff;if(null!=a){if(!0===A){var r={rtcgw:"hangup",transaction:oC.randomString(12)};null!==n.token&&void 0!==n.token&&(r.token=n.token),null!=u&&(r.apisecret=u),oC.debug("Sending hangup request (handle="+e+"):",r),t?(r.session_id=Q,r.handle_id=e,i.send(JSON.stringify(r))):oC.httpAPICall(s+"/"+Q+"/"+e,{verb:"POST",withCredentials:I,body:r})}a.remoteStream=null,a.volume&&(a.volume.local&&a.volume.local.timer&&clearInterval(a.volume.local.timer),a.volume.remote&&a.volume.remote.timer&&clearInterval(a.volume.remote.timer)),a.volume={},a.bitrate.timer&&clearInterval(a.bitrate.timer),a.bitrate.timer=null,a.bitrate.bsnow=null,a.bitrate.bsbefore=null,a.bitrate.tsnow=null,a.bitrate.tsbefore=null,a.bitrate.value=null;try{if(!a.streamExternal&&null!==a.myStream&&void 0!==a.myStream){oC.log("Stopping local stream tracks");var o=a.myStream.getTracks();for(var g in o){var l=o[g];oC.log(l),null!=l&&l.stop()}}}catch(e){}a.streamExternal=!1,a.myStream=null;try{a.pc.close()}catch(e){}a.pc=null,a.candidates=null,a.mySdp=null,a.remoteSdp=null,a.iceDone=!1,a.dataChannel={},a.dtmfSender=null}n.oncleanup()}}function O(e){return null==e||!1!==e.audio&&(void 0===e.audioSend||null===e.audioSend||!0===e.audioSend)}function V(e){return null==e||!1!==e.audio&&(void 0===e.audioRecv||null===e.audioRecv||!0===e.audioRecv)}function j(e){return null==e||!1!==e.video&&(void 0===e.videoSend||null===e.videoSend||!0===e.videoSend)}function W(e){return null==e||!1!==e.video&&(void 0===e.videoRecv||null===e.videoRecv||!0===e.videoRecv)}w(e),this.getServer=function(){return s},this.isConnected=function(){return x},this.reconnect=function(e){(e=e||{}).success="function"==typeof e.success?e.success:oC.noop,e.error="function"==typeof e.error?e.error:oC.noop,e.reconnect=!0,w(e)},this.getSessionId=function(){return Q},this.destroy=function(A){!function(A){(A=A||{}).success="function"==typeof A.success?A.success:oC.noop;var r=!0;void 0!==A.asyncRequest&&null!==A.asyncRequest&&(r=!0===A.asyncRequest);var o=!0;void 0!==A.notifyDestroyed&&null!==A.notifyDestroyed&&(o=!0===A.notifyDestroyed);var g=!1;if(void 0!==A.cleanupHandles&&null!==A.cleanupHandles&&(g=!0===A.cleanupHandles),oC.log("Destroying session "+Q+" (async="+r+")"),!x)return oC.warn("Is the server down? (connected=false)"),void A.success();if(null==Q)return oC.warn("No session to destroy"),A.success(),void(o&&e.destroyed());if(g)for(var l in p)T(l,{noRequest:!0});var c={rtcgw:"destroy",transaction:oC.randomString(12)};if(null!=h&&(c.token=h),null!=u&&(c.apisecret=u),t){c.session_id=Q;var d=function(){for(var e in n)i.removeEventListener(e,n[e]);i.removeEventListener("message",C),i.removeEventListener("error",B),a&&clearTimeout(a),i.close()},C=function(t){var i=JSON.parse(t.data);i.session_id==c.session_id&&i.transaction==c.transaction&&(d(),A.success(),o&&e.destroyed())},B=function(t){d(),A.error("Failed to destroy the server: Is the server down?"),o&&e.destroyed()};return i.addEventListener("message",C),i.addEventListener("error",B),void i.send(JSON.stringify(c))}oC.httpAPICall(s+"/"+Q,{verb:"POST",async:r,withCredentials:I,body:c,success:function(t){oC.log("Destroyed session:"),oC.debug(t),Q=null,x=!1,"success"!==t.rtcgw&&oC.error("Ooops: "+t.error.code+" "+t.error.reason),A.success(),o&&e.destroyed()},error:function(t,i){oC.error(t+":",i),Q=null,x=!1,A.success(),o&&e.destroyed()}})}(A)},this.attach=function(e){!function(e){if((e=e||{}).success="function"==typeof e.success?e.success:oC.noop,e.error="function"==typeof e.error?e.error:oC.noop,e.consentDialog="function"==typeof e.consentDialog?e.consentDialog:oC.noop,e.iceState="function"==typeof e.iceState?e.iceState:oC.noop,e.mediaState="function"==typeof e.mediaState?e.mediaState:oC.noop,e.webrtcState="function"==typeof e.webrtcState?e.webrtcState:oC.noop,e.slowLink="function"==typeof e.slowLink?e.slowLink:oC.noop,e.onmessage="function"==typeof e.onmessage?e.onmessage:oC.noop,e.onlocalstream="function"==typeof e.onlocalstream?e.onlocalstream:oC.noop,e.onremotestream="function"==typeof e.onremotestream?e.onremotestream:oC.noop,e.ondata="function"==typeof e.ondata?e.ondata:oC.noop,e.ondataopen="function"==typeof e.ondataopen?e.ondataopen:oC.noop,e.oncleanup="function"==typeof e.oncleanup?e.oncleanup:oC.noop,e.ondetached="function"==typeof e.ondetached?e.ondetached:oC.noop,!x)return oC.warn("Is the server down? (connected=false)"),void e.error("Is the server down? (connected=false)");var A=e.plugin;if(null==A)return oC.error("Invalid plugin"),void e.error("Invalid plugin");var n=e.opaqueId,a=e.token?e.token:h,r=oC.randomString(12),o={rtcgw:"attach",plugin:A,opaque_id:n,transaction:r};if(null!=a&&(o.token=a),null!=u&&(o.apisecret=u),t)return _[r]=function(t){if("success"!==t.rtcgw)return oC.error("Ooops: "+t.error.code+" "+t.error.reason),void e.error("Ooops: "+t.error.code+" "+t.error.reason);var i=t.data.id;oC.log("Created handle: "+i);var n={session:m,plugin:A,id:i,token:a,detached:!1,webrtcStuff:{started:!1,myStream:null,streamExternal:!1,remoteStream:null,mySdp:null,mediaConstraints:null,pc:null,dataChannel:{},dtmfSender:null,trickle:!0,iceDone:!1,volume:{value:null,timer:null},bitrate:{value:null,bsnow:null,bsbefore:null,tsnow:null,tsbefore:null,timer:null}},getId:function(){return i},getPlugin:function(){return A},getVolume:function(){return G(i,!0)},getRemoteVolume:function(){return G(i,!0)},getLocalVolume:function(){return G(i,!1)},isAudioMuted:function(){return Y(i,!1)},muteAudio:function(){return U(i,!1,!0)},unmuteAudio:function(){return U(i,!1,!1)},isVideoMuted:function(){return Y(i,!0)},muteVideo:function(){return U(i,!0,!0)},unmuteVideo:function(){return U(i,!0,!1)},getBitrate:function(){return J(i)},send:function(e){b(i,e)},data:function(e){k(i,e)},dtmf:function(e){P(i,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){M(i,!0,e)},createAnswer:function(e){M(i,!1,e)},handleRemoteJsep:function(e){L(i,e)},onlocalstream:e.onlocalstream,onremotestream:e.onremotestream,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){K(i,!0===e)},detach:function(e){T(i,e)}};p[i]=n,e.success(n)},o.session_id=Q,void i.send(JSON.stringify(o));oC.httpAPICall(s+"/"+Q,{verb:"POST",withCredentials:I,body:o,success:function(t){if(oC.debug(t),"success"!==t.rtcgw)return oC.error("Ooops: "+t.error.code+" "+t.error.reason),void e.error("Ooops: "+t.error.code+" "+t.error.reason);var i=t.data.id;oC.log("Created handle: "+i);var n={session:m,plugin:A,id:i,token:a,detached:!1,webrtcStuff:{started:!1,myStream:null,streamExternal:!1,remoteStream:null,mySdp:null,mediaConstraints:null,pc:null,dataChannel:{},dtmfSender:null,trickle:!0,iceDone:!1,volume:{value:null,timer:null},bitrate:{value:null,bsnow:null,bsbefore:null,tsnow:null,tsbefore:null,timer:null}},getId:function(){return i},getPlugin:function(){return A},getVolume:function(){return G(i,!0)},getRemoteVolume:function(){return G(i,!0)},getLocalVolume:function(){return G(i,!1)},isAudioMuted:function(){return Y(i,!1)},muteAudio:function(){return U(i,!1,!0)},unmuteAudio:function(){return U(i,!1,!1)},isVideoMuted:function(){return Y(i,!0)},muteVideo:function(){return U(i,!0,!0)},unmuteVideo:function(){return U(i,!0,!1)},getBitrate:function(){return J(i)},send:function(e){b(i,e)},data:function(e){k(i,e)},dtmf:function(e){P(i,e)},consentDialog:e.consentDialog,iceState:e.iceState,mediaState:e.mediaState,webrtcState:e.webrtcState,slowLink:e.slowLink,onmessage:e.onmessage,createOffer:function(e){M(i,!0,e)},createAnswer:function(e){M(i,!1,e)},handleRemoteJsep:function(e){L(i,e)},onlocalstream:e.onlocalstream,onremotestream:e.onremotestream,ondata:e.ondata,ondataopen:e.ondataopen,oncleanup:e.oncleanup,ondetached:e.ondetached,hangup:function(e){K(i,!0===e)},detach:function(e){T(i,e)}};p[i]=n,e.success(n)},error:function(e,A){oC.error(e+":",A)}})}(e)}}oC.useDefaultDependencies=function(e){var A=e&&e.fetch||fetch,t=e&&e.Promise||Promise,i=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,A){return new i(e,A)},extension:e&&e.extension||rC,isArray:function(e){return Array.isArray(e)},webRTCAdapter:e&&e.adapter||window.adapter,httpAPICall:function(e,i){var n={method:i.verb,headers:{Accept:"application/json, text/plain, */*"},cache:"no-cache"};"POST"===i.verb&&(n.headers["Content-Type"]="application/json"),void 0!==i.withCredentials&&(n.credentials=!0===i.withCredentials?"include":i.withCredentials?i.withCredentials:"omit"),void 0!==i.body&&(n.body=JSON.stringify(i.body));var a=A(e,n).catch((function(e){return t.reject({message:"Probably a network error, is the server down?",error:e})}));if(void 0!==i.timeout){var r=new t((function(e,A){var t=setTimeout((function(){return clearTimeout(t),A({message:"Request timed out",timeout:i.timeout})}),i.timeout)}));a=t.race([a,r])}return a.then((function(e){return e.ok?typeof i.success==typeof oC.noop?e.json().then((function(e){i.success(e)})).catch((function(A){return t.reject({message:"Failed to parse response body",error:A,response:e})})):void 0:t.reject({message:"API call failed",response:e})})).catch((function(e){typeof i.error==typeof oC.noop&&i.error(e.message||"<< internal error >>",e)})),a}}},oC.useOldDependencies=function(e){var A=e&&e.jQuery||jQuery,t=e&&e.WebSocket||WebSocket;return{newWebSocket:function(e,A){return new t(e,A)},isArray:function(e){return A.isArray(e)},extension:e&&e.extension||rC,webRTCAdapter:e&&e.adapter||adapter,httpAPICall:function(e,t){var i=void 0!==t.body?{contentType:"application/json",data:JSON.stringify(t.body)}:{},n=void 0!==t.withCredentials?{xhrFields:{withCredentials:t.withCredentials}}:{};return A.ajax(A.extend(i,n,{url:e,type:t.verb,cache:!1,dataType:"json",async:t.async,timeout:t.timeout,success:function(e){typeof t.success==typeof oC.noop&&t.success(e)},error:function(e,A,i){typeof t.error==typeof oC.noop&&t.error(A,i)}}))}}},oC.noop=function(){},oC.dataChanDefaultLabel="JanusDataChannel",oC.endOfCandidates=null,oC.init=function(e){if((e=e||{}).callback="function"==typeof e.callback?e.callback:oC.noop,!0===oC.initDone)e.callback();else{if("undefined"!=typeof console&&void 0!==console.log||(console={log:function(){}}),oC.trace=oC.noop,oC.debug=oC.noop,oC.vdebug=oC.noop,oC.log=oC.noop,oC.warn=oC.noop,oC.error=oC.noop,!0===e.debug||"all"===e.debug)oC.trace=console.trace.bind(console)||oC.noop,oC.debug=console.debug.bind(console)||oC.noop,oC.vdebug=console.debug.bind(console)||oC.noop,oC.log=console.log.bind(console)||oC.noop,oC.warn=console.warn.bind(console)||oC.noop,oC.error=console.error.bind(console)||oC.noop;else if(Array.isArray(e.debug))for(var A in e.debug)switch(e.debug[A]){case"trace":oC.trace=console.trace.bind(console)||oC.noop;break;case"debug":oC.debug=console.debug.bind(console)||oC.noop;break;case"vdebug":oC.vdebug=console.debug.bind(console)||oC.noop;break;case"log":oC.log=console.log.bind(console)||oC.noop;break;case"warn":oC.warn=console.warn.bind(console)||oC.noop;break;case"error":oC.error=console.error.bind(console)||oC.noop}var t=e.dependencies||oC.useDefaultDependencies();oC.isArray=t.isArray,oC.webRTCAdapter=t.webRTCAdapter,oC.httpAPICall=t.httpAPICall,oC.newWebSocket=t.newWebSocket,oC.extension=t.extension,oC.extension.init(),oC.listDevices=function(e,A){e="function"==typeof e?e:oC.noop,null==A&&(A={audio:!0,video:!0}),oC.isGetUserMediaAvailable()?navigator.mediaDevices.getUserMedia(A).then((function(A){navigator.mediaDevices.enumerateDevices().then((function(t){oC.debug(t),e(t);try{var i=A.getTracks();for(var n in i){var a=i[n];null!=a&&a.stop()}}catch(e){}}))})).catch((function(A){oC.error(A),e([])})):(oC.warn("navigator.mediaDevices unavailable"),e([]))},oC.attachMediaStream=function(e,A){"chrome"===oC.webRTCAdapter.browserDetails.browser?oC.webRTCAdapter.browserDetails.version>=52?e.srcObject=A:oC.error("Error attaching stream to element"):e.srcObject=A},oC.reattachMediaStream=function(e,A){"chrome"===oC.webRTCAdapter.browserDetails.browser?oC.webRTCAdapter.browserDetails.version>=52?e.srcObject=A.srcObject:void 0!==e.src?e.src=A.src:oC.error("Error reattaching stream to element"):e.srcObject=A.srcObject};var i=["iPad","iPhone","iPod"].indexOf(navigator.platform)>=0?"pagehide":"beforeunload",n=window["on"+i];if(window.addEventListener(i,(function(e){for(var A in oC.log("Closing window"),oC.sessions)null!==oC.sessions[A]&&void 0!==oC.sessions[A]&&oC.sessions[A].destroyOnUnload&&(oC.log("Destroying session "+A),oC.sessions[A].destroy({asyncRequest:!1,notifyDestroyed:!1}));n&&"function"==typeof n&&n()})),oC.safariVp8=!1,"safari"===oC.webRTCAdapter.browserDetails.browser&&oC.webRTCAdapter.browserDetails.version>=605)if(RTCRtpSender&&RTCRtpSender.getCapabilities&&RTCRtpSender.getCapabilities("video")&&RTCRtpSender.getCapabilities("video").codecs&&RTCRtpSender.getCapabilities("video").codecs.length){for(var A in RTCRtpSender.getCapabilities("video").codecs){var a=RTCRtpSender.getCapabilities("video").codecs[A];if(a&&a.mimeType&&"video/vp8"===a.mimeType.toLowerCase()){oC.safariVp8=!0;break}}oC.safariVp8?oC.log("This version of Safari supports VP8"):oC.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu")}else{var r=new RTCPeerConnection({},{});r.createOffer({offerToReceiveVideo:!0}).then((function(e){oC.safariVp8=-1!==e.sdp.indexOf("VP8"),oC.safariVp8?oC.log("This version of Safari supports VP8"):oC.warn("This version of Safari does NOT support VP8: if you're using a Technology Preview, try enabling the 'WebRTC VP8 codec' setting in the 'Experimental Features' Develop menu"),r.close(),r=null}))}if(oC.unifiedPlan=!1,"firefox"===oC.webRTCAdapter.browserDetails.browser&&oC.webRTCAdapter.browserDetails.version>=59)oC.unifiedPlan=!0;else if("chrome"===oC.webRTCAdapter.browserDetails.browser&&oC.webRTCAdapter.browserDetails.version<72)oC.unifiedPlan=!1;else if("undefined"==typeof RTCRtpTransceiver||"currentDirection"in RTCRtpTransceiver.prototype){const A=new RTCPeerConnection;try{A.addTransceiver("audio"),oC.unifiedPlan=!0}catch(e){}A.close()}else oC.unifiedPlan=!1;oC.initDone=!0,e.callback()}},oC.isWebrtcSupported=function(){return void 0!==window.RTCPeerConnection&&null!==window.RTCPeerConnection},oC.isGetUserMediaAvailable=function(){return void 0!==navigator.mediaDevices&&null!==navigator.mediaDevices&&void 0!==navigator.mediaDevices.getUserMedia&&null!==navigator.mediaDevices.getUserMedia},oC.randomString=function(e){for(var A="",t=0;t{const t=this;if("function"==typeof A&&!A())return void t.eventEmitter.emit("handleTalkError",{code:-1,msg:"startTalk terminate"});const{customizeStream:i,audio:n}=e;oC.isWebrtcSupported()&&(this.janus=new oC({server:e.rtcUrl,success:function(){t.janus&&t.janus.attach({plugin:"rtcgw.plugin.tts",opaqueId:t.opaqueId,success:function(A){t.tts=window.tts=A;let a={request:"start",url:e.talkLink,codec:"opus",dir:"sendrecv",audio_debug:1,url_version:"1"};"gb28181"===e.talkType&&(a.devProto="gb28181"),t.tts.createOffer({media:{audio:n||!0,video:!1,data:!1},simulcast:!1,simulcast2:!1,customizeStream:i,success:function(e){t.tts.send({message:a,jsep:e}),t.eventEmitter.emit("handleTalkSuccess",{message:a,jsep:e})},error:function(e){t.eventEmitter.emit("handleTalkError",e),t.tts.destroy()}})},error:function(e){t.eventEmitter.emit("handleTalkError",e)},consentDialog:function(e){},iceState:function(e){},mediaState:function(e,A){},webrtcState:function(e){},slowLink:function(e,A){},onmessage:function(e,A){null!=A&&t.tts.handleRemoteJsep({jsep:A});let i=e.result;if(null!=i){if("done"===i)return null!==t.spinner&&void 0!==t.spinner&&t.spinner.stop(),void(t.spinner=null);"msg"===i&&t.eventEmitter.emit("handleTalkMessage",e),i.status}},onlocalstream:function(e){const A=document.getElementById("myaudio");A&&oC.attachMediaStream(A,e),"completed"!==t.tts.webrtcStuff.pc.iceConnectionState&&"connected"!==t.tts.webrtcStuff.pc.iceConnectionState&&(null==t.spinner?document.getElementById("audioright"):t.spinner.spin()),e.getAudioTracks()},onremotestream:function(e){const A=document.getElementById("peeraudio");A&&oC.attachMediaStream(A,e);let t=e.getAudioTracks();if(null==t||0===t.length);else{const e=document.getElementById("peeraudio");e&&e.play()}},ondataopen:function(e){},ondata:function(e){},oncleanup:function(){null!==t.spinner&&void 0!==t.spinner&&t.spinner.stop(),t.spinner=null}})},error:function(e){t.eventEmitter.emit("handleTalkError",e)}},{stream:e.stream,deviceSerial:e.deviceSerial,channel:e.channelNo}))},this.stopTalk=e=>{if("function"!=typeof e||e())if(this.janus){try{this.janus.destroy({success:()=>{this.eventEmitter.emit("handleStopTalkSuccess",this.janus)},error:e=>{this.eventEmitter.emit("handleStopTalkError",e)}})}catch(e){this.eventEmitter.emit("handleStopTalkError",e)}this.janus=void 0,this.tts=null}else this.eventEmitter.emit("handleStopTalkError",{code:-1,msg:"stopTalk terminate"});else this.eventEmitter.emit("handleStopTalkError",{code:-1,msg:"stopTalk terminate"})},this.destroy=()=>{},this.tts=null,this.opaqueId="tts-"+oC.randomString(12),this.spinner=null,this.options=Object.assign({},sC,e||{}),this.eventEmitter=e.eventEmitter,oC.init({debug:"all"})}};const lC="stopTalk",cC="volumeChange",dC={deviceSerial:"",channelNo:"0",accessToken:"",env:{domain:"https://open.ys7.com"},capacity:{support_talk:null,support_switch_talkmode:null}};let IC=class{constructor(e){this.destroy=()=>{this.stopTalk(),document.body.removeChild(this.audioLeft),document.body.removeChild(this.audioRight)},this.startTalk=e=>{this.eventEmitter.emit("beforeTalk",{});const A=this;new Promise(((e,A)=>{this.options.capacity&&this.options.capacity.support_switch_talkmode&&"1"==this.options.capacity.support_switch_talkmode?fetch(this.options.env.domain+"/api/service/device/talkMode"+`?deviceSerial=${this.options.deviceSerial}`,{method:"GET",headers:{accessToken:this.options.accessToken}}).then((e=>e.json())).then((A=>{A.meta&&200==A.meta.code?A.data&&A.data.valueInfo&&0==A.data.valueInfo.mode?fetch(this.options.env.domain+"/api/v3/device/talkMode"+`?deviceSerial=${this.options.deviceSerial}&channelNo=${this.options.channelNo}&mode=1`,{method:"PUT",headers:{accessToken:this.options.accessToken}}).then((e=>e.json())).then((A=>{A.meta&&200==A.meta.code?e({}):e({code:-1,msg:"对讲模式切换失败",res:A})})).catch((A=>{e({code:-1,msg:"对讲模式切换失败",res:A})})):e({}):e({code:-1,msg:"获取当前对讲模式失败",res:A})})).catch((A=>{e({code:-1,msg:"获取当前对讲模式失败",res:A})})):e({code:-1,msg:"当前设备不支持对讲模式切换"})})).then((t=>{if(this.options.capacity&&this.options.capacity.support_talk&&(!this.options.capacity||"3"!==this.options.capacity.support_talk&&"1"!==this.options.capacity.support_talk))return!1;let i=new FormData;i.append("accessToken",this.options.accessToken),i.append("deviceSerial",this.options.deviceSerial),i.append("channelNo",this.options.channelNo),fetch(this.options.env.domain+"/api/lapp/live/talk/url",{method:"POST",body:i}).then((e=>e.json())).then((t=>{if(200==t.code){let i=t.data;if(i){let t=i.rtcUrl;-1===t.indexOf("ws")&&(t=t.replace("https","wss").replace("rtcgw","rtcgw-ws")),this.talkOptions.rtcUrl=t,this.talkOptions.ttsUrl="tts://"+i.ttsUrl,this.talkOptions.deviceSerial=this.options.deviceSerial,this.talkOptions.channelNo=this.options.channelNo,this.talkOptions.talkLink=this.talkOptions.ttsUrl.split("?")[0]+"/talk?dev="+this.talkOptions.deviceSerial+"&chann="+this.talkOptions.channelNo+"&encodetype=2",i.ttsUrl.indexOf("gb28181")>-1&&(this.talkOptions.talkType="gb28181"),e&&e(i.ttsUrl.indexOf("gb28181")>-1||-1!==this.talkOptions.deviceSerial.indexOf(":")),this.talkOptions.stream=i.stream?i.stream:this.options.accessToken,this.ttsTalk.startTalk(Object.assign(Object.assign({},this.talkOptions),{customizeStream:A._customizeStream.bind(A),audio:!this.microphoneId||{deviceId:this.microphoneId}})),this.isTalking=!0,this.observeVolumeChange({interval:100}),this.eventEmitter&&this.eventEmitter.emit("startTalk",{eventType:"startTalk",code:0,target:this,msg:"开启对讲"})}}else this.eventEmitter&&this.eventEmitter.emit("startTalk",{eventType:"startTalk",code:-1,target:this,msg:t.msg})})).catch((e=>{}))})).catch((e=>{}))},this.stopTalk=()=>{var e,A;try{this.ttsTalk.stopTalk(),this.isTalking=!1}catch(A){null===(e=this.eventEmitter)||void 0===e||e.emit(lC,{eventType:lC,code:-1,msg:"结束对讲"})}this.gainNode=null,this.volumeChangeInterval&&(clearInterval(this.volumeChangeInterval),this.volumeChangeInterval=null),this.eventEmitter&&setTimeout((()=>{var e;null===(e=this.eventEmitter)||void 0===e||e.emit(cC,{eventType:cC,code:0,target:this,data:0,msg:"音量变化"})}),200);const t=document.getElementById("myaudio").srcObject;t&&t.getTracks()[0].stop(),null===(A=this.eventEmitter)||void 0===A||A.emit(lC,{eventType:lC,code:0,target:this,msg:"结束对讲"})},this.changeTalkChannelNo=e=>{this.talkOptions.channelNo=e},this._customizeStream=e=>new Promise(((A,t)=>{var i;const n=new window.AudioContext;this.gainNode=n.createGain();const a=n.createMediaStreamSource(e);this.gainNode.gain.value=null!==(i=this.volumeGain)&&void 0!==i?i:1;const r=n.createMediaStreamDestination();a.connect(this.gainNode),this.gainNode.connect(r),A(r.stream)})),this.setVolumeGain=e=>{const A=e;return"number"==typeof A&&A>=0?(this.volumeGain=Math.min(A,10),this.gainNode&&(this.gainNode.gain.value=this.volumeGain),{code:0,msg:"成功",res:null}):{code:-1,msg:"参数格式有误",res:null}},this.observeVolumeChange=e=>{const{interval:A}=e;this.volumeChangeInterval&&(clearInterval(this.volumeChangeInterval),this.volumeChangeInterval=null),this.volumeChangeInterval=setInterval((()=>{var e,A,t,i,n;null===(n=null===(i=null===(t=null===(A=null===(e=window.tts)||void 0===e?void 0:e.webrtcStuff)||void 0===A?void 0:A.pc)||void 0===t?void 0:t.getStats)||void 0===i?void 0:i.call(t))||void 0===n||n.then((e=>{e.forEach((e=>{var A;"media-source"===e.type&&(null===(A=this.eventEmitter)||void 0===A||A.emit("volumeChange",{eventType:"volumeChange",code:0,target:this,data:e.audioLevel,msg:"音量变化"}))}))}))}),A)},this.getMicrophonePermission=()=>new Promise(((e,A)=>{navigator.mediaDevices.getUserMedia({audio:!0}).then((A=>{A.getTracks().forEach((e=>{e.stop()})),e({code:0,msg:"成功",res:null})})).catch((A=>{e({code:-1,msg:"获取麦克风权限失败",res:A})}))})),this.getMicrophonesList=()=>new Promise(((e,A)=>{navigator.mediaDevices?navigator.mediaDevices.enumerateDevices().then((A=>{let t=[];A.map((e=>{"audioinput"==e.kind&&t.push(e)})),e({code:0,msg:"成功",res:t})})):e({code:-1,msg:"未查询到相关设备",res:null})})),this.setProfile=e=>{const{microphoneId:A}=e;A!==this.microphoneId&&(this.microphoneId=A,this.isTalking&&(this.stopTalk(),setTimeout((()=>{this.ttsTalk.startTalk(Object.assign(Object.assign({},this.talkOptions),{customizeStream:this._customizeStream.bind(this),audio:!this.microphoneId||{deviceId:this.microphoneId}})),this.isTalking=!0}),300)))},this.options=Object.assign({},dC,e||{}),this.gainNode=null,this.volumeGain=null,this.volumeChangeInterval=null,this.microphoneId=null,this.eventEmitter=new iC,this.ttsTalk=new gC({eventEmitter:this.eventEmitter}),this.isTalking=!1;const A=document.createElement("div");A.id="audioleft";const t=document.createElement("audio");t.id="myaudio",t.muted=!0,t.setAttribute("autoplay","true"),t.setAttribute("controls","true"),A.appendChild(t),A.style.display="none";const i=document.createElement("div");i.id="audioright",i.style.display="none";const n=document.createElement("audio");n.id="peeraudio",n.setAttribute("autoplay","true"),n.setAttribute("controls","true"),i.appendChild(n),this.talkOptions={rtcUrl:"",talkLink:"",ttsUrl:"",stream:"",deviceSerial:this.options.deviceSerial,channelNo:this.options.channelNo},this.audioLeft=A,this.audioRight=i,document.body.appendChild(A),document.body.appendChild(i)}};var CC=function(){function e(){this.events={}}var A=e.prototype;return A.on=function(e,A){e&&A&&(this.events[e]=this.events[e]||[],this.events[e].push(A))},A.emit=function(e,A){e&&this.events[e]&&this.events[e].forEach((function(e){return e(A)}))},A.off=function(e,A){e&&A&&this.events[e]&&this.events[e].splice(this.events[e].indexOf(A),1)},A.once=function(e,A){var t=this;this.on(e,(function i(){var n=Array.prototype.slice.call(arguments);A.apply(null,n),t.off(e,i)}))},A.removeAllListener=function(){this.events={}},e}(),hC=function(e,A){if(void 0===e)return A.themeData?{templateType:"themeData",templateId:"themeData"}:{templateType:"local",templateId:""};if("string"==typeof e){if(32===e.length)return{templateType:"remote",templateId:e};if(-1!==["theme","standard"].indexOf(e))return"simple"===e&&void 0===A.header&&void 0===A.footer?{templateType:"local",templateId:""}:{templateType:"iframe",templateId:e};if(-1!==["pcLive","pcRec","mobileLive","mobileRec","noData","security","voice","simple","mobileCall","miniRec"].indexOf(e))return-1!=A.url.indexOf("rec")&&"simple"!=A.template&&"miniRec"!=A.id?{templateType:"local",templateId:d()?"mobileRec":"pcRec"}:{templateType:"local",templateId:e};if(A&&A.isCall)return{templateType:"invalid",templateId:e}}},uC=function(){var e=window.navigator.userAgent.toLowerCase(),A=(/version.*safari/.test(e),/chrome/.test(e));/gecko/.test(e)&&/webkit/.test(e);if(d())return!1;if(A){return function(){for(var e=window.navigator.userAgent.split(" "),A="",t=0;t91&&!!window.SharedArrayBuffer}return!1},BC=function(e){return e&&e.retcode?String(e.retcode):e&&e.code?"1"+String(e.code).padStart(5,"0"):e&&e.errorCode?"39"+String(e.errorCode).padStart(4,"0"):"400001"};function fC(){var e,A={},t=navigator.userAgent.toLowerCase();if((e=t.match(/rv:([\d.]+)\) like gecko/))||(e=t.match(/msie ([\d\.]+)/))?A.ie=e[1]:(e=t.match(/edge\/([\d\.]+)/))?A.edge=e[1]:(e=t.match(/firefox\/([\d\.]+)/))?A.firefox=e[1]:(e=t.match(/(?:opera|opr).([\d\.]+)/))?A.opera=e[1]:(e=t.match(/chrome\/([\d\.]+)/))?A.chrome=e[1]:(e=t.match(/version\/([\d\.]+).*safari/))&&(A.safari=e[1]),A.chrome){var i=A.chrome,n=i.indexOf(".");return Number(i.substring(0,n))}return-1}function EC(e){return fC()>=94}function xC(e){if(fC()>=107){window.VideoDecoder&&VideoDecoder.isConfigSupported({codec:"hvc1.1.6.L123.00",hardwareAcceleration:"prefer-hardware"}).then((function(e){e.supported}))}}function QC(e,A,t,i,n,a,r){try{var o=e[a](r),s=o.value}catch(e){return void t(e)}o.done?A(s):Promise.resolve(s).then(i,n)}function pC(e){return function(){var A=this,t=arguments;return new Promise((function(i,n){var a=e.apply(A,t);function r(e){QC(a,i,n,r,o,"next",e)}function o(e){QC(a,i,n,r,o,"throw",e)}r(void 0)}))}}function mC(){return mC=Object.assign||function(e){for(var A=1;A0&&n[n.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]A.domain?1:-1})),i=[].concat(A).sort((function(e,A){return e.domain>A.domain?1:-1})),n=0;n-1||t.data.indexOf("cloud")>-1?"live":"rec"];if(t.ext&&t.ext.token)r+=t.data,o=A._options.accessToken?t.ext.token:s;else if(t.data){var g;if("string"==typeof t.data&&s)r+=t.data,o=s;else r+=(null==(g=t.data)?void 0:g.url)||"",o=A._options.accessToken?t.data.token:s}if(r="live"===(-1!==e.indexOf("live")?"live":"playback")?r+"&ssn="+(o||"")+"&auth=1&biz=4&cln=100":r+"&ssn="+(o||"")+"&auth=1&cln=100",A._options.wsParams&&"[object Object]"===Object.prototype.toString.call(A._options.wsParams))for(var l in A._options.wsParams)r+="&"+l+"="+A._options.wsParams[l]||"";return r.replace(/&&/gi,"&")}return t})).catch((function(){return""}))]}))}))()},A.getCloudRecordTimes=function(e){var A=this;return pC((function(){var t,i;return yC(this,(function(n){return t={startTime:e.begin?gd.formate(e.begin,"YYYY-MM-DD hh:mm:ss"):void 0,endTime:e.end?gd.formate(e.end,"YYYY-MM-DD hh:mm:ss"):void 0,spaceId:e.spaceId},i=Object.keys(t).reduce((function(e,A){return null==t[A]?e:e+="&"+A+"="+encodeURIComponent(t[A])}),"").replace("&",""),[2,A.get(TC+"?"+i).then((function(e){return e.json()})).then((function(e){var A;return 200==+(null==e||null==(A=e.meta)?void 0:A.code)?Bd((e.data||[]).map((function(e){return e.endTime=parseInt(gd.strToDate(e.stopTime).getTime()/1e3+"",10),e.startTime=parseInt(gd.strToDate(e.startTime).getTime()/1e3+"",10),e.busType=7,e.iStorageVersion=e.istorageVersion,e}))):[]})).catch((function(){return[]}))]}))}))()},A.getCloudTimes=function(e){var A=this;return pC((function(){var t,i,n,a,r;return yC(this,(function(o){switch(o.label){case 0:return(n=new FormData).append("recType","1"),n.append("version","2.0"),n.append("deviceSerial",A._options.deviceSerial),n.append("channelNo",A._options.channelNo+""),n.append("accessToken",A._options.accessToken||(null==(i=A._options.token)||null==(t=i.deviceToken)?void 0:t.video)||""),e.begin&&n.append("startTime",gd.strToDate(e.begin+"").getTime()+""),e.end&&n.append("endTime",gd.strToDate(e.end+"").getTime()+""),a=[],r=pC((function(e){return yC(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,A.post(""+NC,{headers:null,body:e}).then((function(e){return e.json()})).then(pC((function(A){var t,i,n,o,s,g,l;return yC(this,(function(c){switch(c.label){case 0:return 200==+A.code&&A.data?(g=[],Array.isArray(A.data)?g=A.data:(null==(t=A.data)?void 0:t.files)&&(null==(n=A.data)||null==(i=n.files)?void 0:i.length)>0&&(g=(null==(l=A.data)?void 0:l.files)||[]),a=a.concat(g),(null==(o=A.data)?void 0:o.isAll)||!(null==(s=A.data)?void 0:s.nextFileTime)?[3,2]:(e.append("startTime",A.data.nextFileTime),[4,r(e)])):[3,2];case 1:return[2,c.sent()];case 2:return[2]}}))})))];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))})),[4,r(n)];case 1:return o.sent(),[2,Bd(a=a.map((function(e){return mC({},e,{endTime:parseInt(e.endTime/1e3+"",10),startTime:parseInt(e.startTime/1e3+"",10)})})),A._options.timeZone||0)]}}))}))()},A.getLocalRecTimes=function(e){var A=this;return pC((function(){var t,i,n;return yC(this,(function(a){switch(a.label){case 0:return t=parseInt(gd.strToDate(e.begin+"").getTime()/1e3+"",10),i=parseInt(gd.strToDate(e.end+"").getTime()/1e3+"",10),n=pC((function(e){var t,i,a,r,o,s,g,l,c,d;return yC(this,(function(I){switch(I.label){case 0:t=[],I.label=1;case 1:return I.trys.push([1,5,,6]),[4,A.get(MC+"?startTime="+e.startTime+"&endTime="+e.endTime+"&pageSize="+(e.pageSize||200),{headers:{accessToken:A._options.accessToken||(null==(a=A._options.token)||null==(i=a.deviceToken)?void 0:i.video)}}).then((function(e){return e.json()}))];case 2:return 200!=+(null==(l=I.sent())||null==(r=l.meta)?void 0:r.code)?[2,t]:((null==l||null==(s=l.data)||null==(o=s.records)?void 0:o.length)&&(t=t.concat(l.data.records||[])),(null==l||null==(g=l.data)?void 0:g.hasMore)?(d=t.concat,[4,n(mC({},e,{startTime:null==l||null==(c=l.data)?void 0:c.nextFileTime}))]):[3,4]);case 3:t=d.apply(t,[I.sent()]),I.label=4;case 4:return[3,6];case 5:return I.sent(),[3,6];case 6:return[2,t]}}))})),[4,n({startTime:t,endTime:i})];case 1:return[2,Bd(a.sent()||[]||[],A._options.timeZone||0)]}}))}))()},A.postDevicePtzMirror=function(e){var A=this;return pC((function(){var t,i,n;return yC(this,(function(a){return(n=new FormData).append("command",e+""),n.append("accessToken",A._options.accessToken||(null==(i=A._options.token)||null==(t=i.deviceToken)?void 0:t.video)||""),n.append("deviceSerial",A._options.deviceSerial),n.append("channelNo",A._options.channelNo+""),A.post(LC,{body:n}),[2]}))}))()},e}(),UC=(_C="undefined"!=typeof self?self:window,SC={navigator:void 0!==_C.navigator?_C.navigator:{userAgent:""},infoMap:{engine:["WebKit","Trident","Gecko","Presto"],browser:["Safari","Chrome","Edge","IE","Firefox","Firefox Focus","Chromium","Opera","Vivaldi","Yandex","Arora","Lunascape","QupZilla","Coc Coc","Kindle","Iceweasel","Konqueror","Iceape","SeaMonkey","Epiphany","360","360SE","360EE","UC","QQBrowser","QQ","Baidu","Maxthon","Sogou","LBBROWSER","2345Explorer","TheWorld","XiaoMi","Quark","Qiyu","Wechat","Taobao","Alipay","Weibo","Douban","Suning","iQiYi"],os:["Windows","Linux","Mac OS","Android","Ubuntu","FreeBSD","Debian","iOS","Windows Phone","BlackBerry","MeeGo","Symbian","Chrome OS","WebOS"],device:["Mobile","Tablet","iPad"]}},vC={getMatchMap:function(e){return{Trident:e.indexOf("Trident")>-1||e.indexOf("NET CLR")>-1,Presto:e.indexOf("Presto")>-1,WebKit:e.indexOf("AppleWebKit")>-1,Gecko:e.indexOf("Gecko/")>-1,Safari:e.indexOf("Safari")>-1,Chrome:e.indexOf("Chrome")>-1||e.indexOf("CriOS")>-1,IE:e.indexOf("MSIE")>-1||e.indexOf("Trident")>-1,Edge:e.indexOf("Edge")>-1,Firefox:e.indexOf("Firefox")>-1||e.indexOf("FxiOS")>-1,"Firefox Focus":e.indexOf("Focus")>-1,Chromium:e.indexOf("Chromium")>-1,Opera:e.indexOf("Opera")>-1||e.indexOf("OPR")>-1,Vivaldi:e.indexOf("Vivaldi")>-1,Yandex:e.indexOf("YaBrowser")>-1,Arora:e.indexOf("Arora")>-1,Lunascape:e.indexOf("Lunascape")>-1,QupZilla:e.indexOf("QupZilla")>-1,"Coc Coc":e.indexOf("coc_coc_browser")>-1,Kindle:e.indexOf("Kindle")>-1||e.indexOf("Silk/")>-1,Iceweasel:e.indexOf("Iceweasel")>-1,Konqueror:e.indexOf("Konqueror")>-1,Iceape:e.indexOf("Iceape")>-1,SeaMonkey:e.indexOf("SeaMonkey")>-1,Epiphany:e.indexOf("Epiphany")>-1,360:e.indexOf("QihooBrowser")>-1||e.indexOf("QHBrowser")>-1,"360EE":e.indexOf("360EE")>-1,"360SE":e.indexOf("360SE")>-1,UC:e.indexOf("UC")>-1||e.indexOf(" UBrowser")>-1,QQBrowser:e.indexOf("QQBrowser")>-1,QQ:e.indexOf("QQ/")>-1,Baidu:e.indexOf("Baidu")>-1||e.indexOf("BIDUBrowser")>-1,Maxthon:e.indexOf("Maxthon")>-1,Sogou:e.indexOf("MetaSr")>-1||e.indexOf("Sogou")>-1,LBBROWSER:e.indexOf("LBBROWSER")>-1,"2345Explorer":e.indexOf("2345Explorer")>-1,TheWorld:e.indexOf("TheWorld")>-1,XiaoMi:e.indexOf("MiuiBrowser")>-1,Quark:e.indexOf("Quark")>-1,Qiyu:e.indexOf("Qiyu")>-1,Wechat:e.indexOf("MicroMessenger")>-1,Taobao:e.indexOf("AliApp(TB")>-1,Alipay:e.indexOf("AliApp(AP")>-1,Weibo:e.indexOf("Weibo")>-1,Douban:e.indexOf("com.douban.frodo")>-1,Suning:e.indexOf("SNEBUY-APP")>-1,iQiYi:e.indexOf("IqiyiApp")>-1,Windows:e.indexOf("Windows")>-1,Linux:e.indexOf("Linux")>-1||e.indexOf("X11")>-1,"Mac OS":e.indexOf("Macintosh")>-1,Android:e.indexOf("Android")>-1||e.indexOf("Adr")>-1,Ubuntu:e.indexOf("Ubuntu")>-1,FreeBSD:e.indexOf("FreeBSD")>-1,Debian:e.indexOf("Debian")>-1,"Windows Phone":e.indexOf("IEMobile")>-1||e.indexOf("Windows Phone")>-1,BlackBerry:e.indexOf("BlackBerry")>-1||e.indexOf("RIM")>-1,MeeGo:e.indexOf("MeeGo")>-1,Symbian:e.indexOf("Symbian")>-1,iOS:e.indexOf("like Mac OS X")>-1,"Chrome OS":e.indexOf("CrOS")>-1,WebOS:e.indexOf("hpwOS")>-1,Mobile:e.indexOf("Mobi")>-1||e.indexOf("iPh")>-1||e.indexOf("480")>-1,Tablet:e.indexOf("Tablet")>-1||e.indexOf("Nexus 7")>-1,iPad:e.indexOf("iPad")>-1}},matchInfoMap:function(e){var A,t=(null==(A=SC.navigator)?void 0:A.userAgent)||"",i=vC.getMatchMap(t);for(var n in SC.infoMap)for(var a=0;a36&&_C.showModalDialog?n=!0:+a>45&&(n=t("type","application/vnd.chromium.remoting-viewer"))}if(i.Baidu&&i.Opera&&(i.Baidu=!1),i.Mobile&&(i.Mobile=!A.includes("iPad")),n&&(t("type","application/gameplugin")||SC.navigator&&void 0===SC.navigator.connection.saveData?i["360SE"]=!0:i["360EE"]=!0),i.IE||i.Edge)switch(window.screenTop-window.screenY){case 71:case 74:case 99:case 75:case 105:break;case 102:i["360EE"]=!0;break;case 104:i["360SE"]=!0}var r={Safari:function(){return A.replace(/^.*Version\/([\d.]+).*$/,"$1")},Chrome:function(){return A.replace(/^.*Chrome\/([\d.]+).*$/,"$1").replace(/^.*CriOS\/([\d.]+).*$/,"$1")},IE:function(){return A.replace(/^.*MSIE ([\d.]+).*$/,"$1").replace(/^.*rv:([\d.]+).*$/,"$1")},Edge:function(){return A.replace(/^.*Edge\/([\d.]+).*$/,"$1")},Firefox:function(){return A.replace(/^.*Firefox\/([\d.]+).*$/,"$1").replace(/^.*FxiOS\/([\d.]+).*$/,"$1")},"Firefox Focus":function(){return A.replace(/^.*Focus\/([\d.]+).*$/,"$1")},Chromium:function(){return A.replace(/^.*Chromium\/([\d.]+).*$/,"$1")},Opera:function(){return A.replace(/^.*Opera\/([\d.]+).*$/,"$1").replace(/^.*OPR\/([\d.]+).*$/,"$1")},Vivaldi:function(){return A.replace(/^.*Vivaldi\/([\d.]+).*$/,"$1")},Yandex:function(){return A.replace(/^.*YaBrowser\/([\d.]+).*$/,"$1")},Arora:function(){return A.replace(/^.*Arora\/([\d.]+).*$/,"$1")},Lunascape:function(){return A.replace(/^.*Lunascape[\/\s]([\d.]+).*$/,"$1")},QupZilla:function(){return A.replace(/^.*QupZilla[\/\s]([\d.]+).*$/,"$1")},"Coc Coc":function(){return A.replace(/^.*coc_coc_browser\/([\d.]+).*$/,"$1")},Kindle:function(){return A.replace(/^.*Version\/([\d.]+).*$/,"$1")},Iceweasel:function(){return A.replace(/^.*Iceweasel\/([\d.]+).*$/,"$1")},Konqueror:function(){return A.replace(/^.*Konqueror\/([\d.]+).*$/,"$1")},Iceape:function(){return A.replace(/^.*Iceape\/([\d.]+).*$/,"$1")},SeaMonkey:function(){return A.replace(/^.*SeaMonkey\/([\d.]+).*$/,"$1")},Epiphany:function(){return A.replace(/^.*Epiphany\/([\d.]+).*$/,"$1")},360:function(){return A.replace(/^.*QihooBrowser\/([\d.]+).*$/,"$1")},"360SE":function(){return{63:"10.0",55:"9.1",45:"8.1",42:"8.0",31:"7.0",21:"6.3"}[+A.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"360EE":function(){return{69:"11.0",63:"9.5",55:"9.0",50:"8.7",30:"7.5"}[+A.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},Maxthon:function(){return A.replace(/^.*Maxthon\/([\d.]+).*$/,"$1")},QQBrowser:function(){return A.replace(/^.*QQBrowser\/([\d.]+).*$/,"$1")},QQ:function(){return A.replace(/^.*QQ\/([\d.]+).*$/,"$1")},Baidu:function(){return A.replace(/^.*BIDUBrowser[\s\/]([\d.]+).*$/,"$1")},UC:function(){return A.replace(/^.*UC?Browser\/([\d.]+).*$/,"$1")},Sogou:function(){return A.replace(/^.*SE ([\d.X]+).*$/,"$1").replace(/^.*SogouMobileBrowser\/([\d.]+).*$/,"$1")},LBBROWSER:function(){return{57:"6.5",49:"6.0",46:"5.9",42:"5.3",39:"5.2",34:"5.0",29:"4.5",21:"4.0"}[+navigator.userAgent.replace(/^.*Chrome\/([\d]+).*$/,"$1")]||""},"2345Explorer":function(){return A.replace(/^.*2345Explorer\/([\d.]+).*$/,"$1")},TheWorld:function(){return A.replace(/^.*TheWorld ([\d.]+).*$/,"$1")},XiaoMi:function(){return A.replace(/^.*MiuiBrowser\/([\d.]+).*$/,"$1")},Quark:function(){return A.replace(/^.*Quark\/([\d.]+).*$/,"$1")},Qiyu:function(){return A.replace(/^.*Qiyu\/([\d.]+).*$/,"$1")},Wechat:function(){return A.replace(/^.*MicroMessenger\/([\d.]+).*$/,"$1")},Taobao:function(){return A.replace(/^.*AliApp\(TB\/([\d.]+).*$/,"$1")},Alipay:function(){return A.replace(/^.*AliApp\(AP\/([\d.]+).*$/,"$1")},Weibo:function(){return A.replace(/^.*weibo__([\d.]+).*$/,"$1")},Douban:function(){return A.replace(/^.*com.douban.frodo\/([\d.]+).*$/,"$1")},Suning:function(){return A.replace(/^.*SNEBUY-APP([\d.]+).*$/,"$1")},iQiYi:function(){return A.replace(/^.*IqiyiVersion\/([\d.]+).*$/,"$1")}};return e.browserVersion="",r[e.browser]&&(e.browserVersion=r[e.browser](),e.browserVersion==A&&(e.browserVersion="")),"Edge"==e.browser&&(e.engine="EdgeHTML"),"Chrome"==e.browser&&parseInt(e.browserVersion)>27&&(e.engine="Blink"),"Opera"==e.browser&&parseInt(e.browserVersion)>12&&(e.engine="Blink"),"Yandex"==e.browser&&(e.engine="Blink"),e.browser+" (version: "+e.browserVersion+"; kernel: "+e.engine+")"}},DC={DeviceInfoObj:function(e){var A,t=function(A){var t;null==(t=e.info)||t.forEach((function(e){e.toLowerCase()===A.toLowerCase()&&(n[A]=i[A])}))};e=e||{domain:""};var i={deviceType:vC.getDeviceType(),OS:vC.getOS(),OSVersion:vC.getOSVersion(),sh:_C.screen.height,sw:_C.screen.width,lang:vC.getLanguage(),netWork:vC.getNetwork(),orientation:vC.getOrientationStatu(),browserInfo:vC.getBrowserInfo(),fingerprint:vC.createFingerprint(e.domain),userAgent:null==(A=SC.navigator)?void 0:A.userAgent};if(!e.info||0===e.info.length)return i;var n={};for(var a in i)t(a);return n}},{getDeviceInfo:function(e){return DC.DeviceInfoObj(e)}}),JC=function(){function e(){}return e.add=function(A,t){e.queues.push({url:A,data:t})},e.fire=function(){if(e.queues&&0!==e.queues.length){e.isStop=!1;var A=e.queues[0];A.url&&e.api.report(A.data),e.queues.splice(0,1),e.fire()}else e.isStop=!0},e}();function HC(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}JC.isStop=!0,JC.queues=[];var KC=function(){function e(e){this.url=e}var A=e.prototype;return A.report=function(e){this.checkUrl(this.url)&&this.sendInfo(e)},A.sendInfo=function(e){navigator.sendBeacon?this.sendBeacon(this.url,e):this.sendImage(this.url,e)},A.sendImage=function(e,A){var t=this.changeJSON2Query(A),i=new Image;i.onload=i.onerror=function(){i=null},i.src=e+"?"+t+"&random="+Math.random()},A.sendBeacon=function(e,A){try{navigator.sendBeacon(e,this.formatParamsByURLSearchParams(A))}catch(e){}},A.formatParamsByURLSearchParams=function(e){var A=new URLSearchParams;for(var t in e)"object"===HC(e[t])&&(e[t]=JSON.stringify(e[t])),A.append(t,e[t]);return A},A.changeJSON2Query=function(e){var A="";for(var t in e){""!=A&&(A+="&");var i=e[t];A+=t+"="+encodeURIComponent("object"===(void 0===i?"undefined":HC(i))?JSON.stringify(i):i)}return A},A.checkUrl=function(e){return!!e&&/^[hH][tT][tT][pP]([sS]?):\/\//.test(e)},e}();function OC(){return OC=Object.assign||function(e){for(var A=1;A-1?WC[A].logHost:""},A.report=function(e,A){var t;this.monitorReport&&(null==(t=this.collect)||t.send(jC({action:e,appKey:this.appKey},A,{logInfo:jC({pluginVersion:this.pluginVersion},A.logInfo||{})})))},A.updateParams=function(e){var A;null==(A=this.collect)||A.updateExtendsInfo(e)},A.updateAppKey=function(e){this.appKey=e},A.setForbidden=function(e){var A;null==(A=this.collect)||A.setForbidden(e)},e}();function XC(e){document.getElementById(e+"-player")&&document.getElementById(e+"-container-0").removeChild(document.getElementById(e+"-player"))}function qC(){return qC=Object.assign||function(e){for(var A=1;A=a&&e.endTime<=r||(e.startTimea||(e.startTimer||void 0))}))).length>0&&(e[0].startTime=a,e[e.length-1].endTime=r),e.reduce((function(e,A,t){return 0===t?(e.push(n(A)),e):(e[e.length-1].downloadPath===A.downloadPath?e[e.length-1].endTime=A.endTime:e.push(n(A)),e)}),[])}function $C(e,A,t,i,n,a,r){try{var o=e[a](r),s=o.value}catch(e){return void t(e)}o.done?A(s):Promise.resolve(s).then(i,n)}function eh(){return eh=Object.assign||function(e){for(var A=1;A0&&n[n.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]=24||t<=-24||isNaN(t))&&(t=0),7==+i?{begin:e,end:A,timeZone:t,originBegin:n,originEnd:a}:{begin:e=gd.formate(gd.strToDate(e).getTime()+60*t*60*1e3,"YYYYMMDDhhmmss"),end:A=gd.formate(gd.strToDate(A).getTime()+60*t*60*1e3,"YYYYMMDDhhmmss"),timeZone:t,originBegin:n,originEnd:a}}(e.urlInfo.searchParams.begin,e.urlInfo.searchParams.end,null==(i=e.urlInfo.searchParams)?void 0:i.timeZone,e.urlInfo.searchParams.busType),e.timeZone=A.timeZone,t="&begin="+gd.formate(A.originBegin,"YYYYMMDDThhmmssZ")+"&end="+gd.formate(A.originEnd,"YYYYMMDDThhmmssZ")+"&timeZone="+A.timeZone),e._isCloudRecord&&-1!==e.url.indexOf(".cloud")&&"7"===e.urlInfo.searchParams.busType?[4,e._services.getCloudRecordTimes({begin:A.begin,end:A.end,spaceId:e.urlInfo.searchParams.spaceId}).then((function(i){var n,a,r;if(e.cloudRecordRecList=i||[],null==(n=e.eventEmitter)||n.emit(id.http.getCloudRecordTimes,i||[]),null==(a=e.eventEmitter)||a.emit(id.setAllDayRecTimes,{type:"cloudRecordTimes",list:i||[]}),i.length){var o,s=zC(i,["downloadPath","ownerId","iStorageVersion","spaceId","startTime","endTime","videoType","busType"],A.originBegin,A.originEnd);if(null==(o=e.eventEmitter)||o.emit(id.setRecTimes,i),0===s.length)return"";var g=JSON.stringify(s).replace("\\","");return t+"&recSlice="+g.replace("\\","")+"&r="+Math.random()}return null==(r=e.eventEmitter)||r.emit(id.setRecTimes,[]),""}))]:[3,2];case 1:return[2,n.sent()];case 2:return-1===e.url.indexOf(".cloud")||"7"===e.urlInfo.searchParams.busType?[3,4]:[4,e._services.getCloudTimes({begin:A.begin,end:A.end}).then((function(i){var n,a,r;if(e.cloudRecList=i||[],null==(n=e.eventEmitter)||n.emit(id.http.getCloudRecTimes,i||[]),null==(a=e.eventEmitter)||a.emit(id.setAllDayRecTimes,{type:"cloudRecTimes",list:i||[]}),i.length){var o,s=zC(i,["downloadPath","ownerId","iStorageVersion","startTime","endTime","videoType"],A.originBegin,A.originEnd);if(null==(o=e.eventEmitter)||o.emit(id.setRecTimes,s),0===s.length)return"";var g=JSON.stringify(s.map((function(A){var t,i;return eh({},A,{startTime:A.startTime+3600*((null==(t=e.urlInfo.searchParams)?void 0:t.timeZone)||0)*1e3,endTime:A.endTime+3600*((null==(i=e.urlInfo.searchParams)?void 0:i.timeZone)||0)*1e3})}))).replace("\\","");return t+"&recSlice="+g.replace("\\","")+"&r="+Math.random()}return null==(r=e.eventEmitter)||r.emit(id.setRecTimes,[]),""}))];case 3:return[2,n.sent()];case 4:if(-1!==e.url.indexOf(".rec"))return e._services.getLocalRecTimes({begin:A.begin,end:A.end}).then((function(A){var t,i,n;e.localRecList=A,null==(t=e.eventEmitter)||t.emit(id.http.getLocalRecTimes,A||[]),null==(i=e.eventEmitter)||i.emit(id.setAllDayRecTimes,{type:"localTimes",list:A||[]}),null==(n=e.eventEmitter)||n.emit(id.setRecTimes,[])})),[2,t];n.label=5;case 5:return[2]}}))})),ih.apply(this,arguments)}function nh(e){var A,t;return e.url.indexOf(".live")>-1?(null==(t=e.logger)||null==(A=t.log)||A.call(t,"[https request] _getDeviceSupportQualityServicesAndGetDeviceListServices()"),new Promise((function(A){var t=e.params.videoLevelList?Promise.resolve(e.params.videoLevelList):function(e){var A,t;return null==(t=e.logger)||null==(A=t.log)||A.call(t,"[https request] getDeviceSupportQuality()"),e._services.getDeviceSupportQuality().then((function(A){var t;return e.videoLevelList=A,null==(t=e.eventEmitter)||t.emit(id.http.getDeviceSupportQuality,A),A}))}(e);Promise.all([t,e._services.getDeviceList()]).then((function(t){var i,n,a,r,o,s,g,l;null==(n=e.logger)||null==(i=n.log)||i.call(n,"[https request] getDeviceList()"),null==(r=e.eventEmitter)||null==(a=r.emit)||a.call(r,id.http.getDeviceList,t[1]||[]);var c=t[1].find((function(A){return A.channelNo===+e.urlInfo.channelNo}));c||A([[],[]]),e.videoLevelList=t[0],null==(s=e.eventEmitter)||null==(o=s.emit)||o.call(s,id.setVideoLevelList,t[0]||[]);var d={};(d="compatible"===(null==(g=e.videoLevelList[0])?void 0:g.type)?e.url.indexOf(".hd.live")>0?e.videoLevelList[1]:e.videoLevelList[0]:e.videoLevelList.find((function(e){return e.level==(null==c?void 0:c.videoLevel)}))||{})?(e.videoLevel=d.level,e.streamTypeIn=d.streamTypeIn):e.logger.warn("the current video quality("+(null==c?void 0:c.videoLevel)+") is not in the list!"),null==(l=e.eventEmitter)||l.emit(id.currentVideoLevel,d),A(t)}))}))):Promise.resolve([[],[]])}function ah(e){var A;return null==(A=e.logger)||A.log("[https request] getStreamAddressList()"),e._services.getStreamAddressList().then((function(A){var t;e.maxReloadTime=A[0],null==(t=e.eventEmitter)||t.emit(id.http.getStreamAddressList,A[1])}))}function rh(){return rh=Object.assign||function(e){for(var A=1;Ae.length)&&(A=e.length);for(var t=0,i=new Array(A);t=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ih(e,A){var t,i,n,a=-1;if(A===e.speed)return null==(t=e.logger)||t.warn("the speed value has not changed!"),0;A&&(ed.includes(A)?(e.jSPlugin.JS_Speed(A),a=1,e.speed=A,e.Theme?(e.Theme.changeRecSpeed(A),e.Theme.nextRate=A):null==(i=e.eventEmitter)||i.emit(id.speedChange,e.speed)):null==(n=e.logger)||n.warn("current speed is not supported!"));return a}function Ch(e,A,t,i,n,a,r){try{var o=e[a](r),s=o.value}catch(e){return void t(e)}o.done?A(s):Promise.resolve(s).then(i,n)}function hh(e){return function(){var A=this,t=arguments;return new Promise((function(i,n){var a=e.apply(A,t);function r(e){Ch(a,i,n,r,o,"next",e)}function o(e){Ch(a,i,n,r,o,"throw",e)}r(void 0)}))}}function uh(e,A){var t,i,n,a,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(n=r.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]=0?i=i.replace(".hd.live",".live"):i.indexOf(".live")>=0&&(i=i.replace(".live",".hd.live")),[3,4]);case 1:return d.trys.push([1,3,,4]),null==(r=e.logger)||null==(n=r.log)||n.call(r,"[https request] setVideoLevel()","videoLevel",JSON.stringify(A)),[4,null==(o=e._services)?void 0:o.setVideoLevel(e.videoLevel)];case 2:return l=d.sent(),null==e||null==(g=e.eventEmitter)||null==(s=g.emit)||s.call(g,id.http.setVideoLevel,l),[3,4];case 3:return d.sent(),[3,4];case 4:return document.getElementById(e.id+"-videoLevel-icon")&&(c=e.videoLevelList.find((function(A){return A.level===e.videoLevel})),document.getElementById(e.id+"-videoLevel-icon").innerHTML=function(e,A){return Object.values(td).includes(A.name)?e.i18n.t(td[A.level]):A.name}(e,c),document.getElementById(e.id+"-videoLevel-icon").dataset.type=e.videoLevel),e.changePlayUrl({url:e.url},(function(){}),!1).then((function(i){var n;null==(n=e.eventEmitter)||n.emit(id.changeVideoLevel,{eventType:id.changeVideoLevel,code:0,data:A,msg:e.i18n.t("CHANGE_VIDEO_LEVEL")}),t({code:0,data:A,msg:e.i18n.t("CHANGE_VIDEO_LEVEL")})})).catch((function(){var i;null==(i=e.eventEmitter)||i.emit(id.changeVideoLevel,{eventType:id.changeVideoLevel,code:-1,data:A,msg:e.i18n.t("CHANGE_VIDEO_LEVEL_FAIL")}),t({code:-1,data:A,msg:e.i18n.t("CHANGE_VIDEO_LEVEL_FAIL")})})),[2]}}))})))):(null==(i=e.eventEmitter)||i.emit(id.changeVideoLevel,{eventType:id.changeVideoLevel,code:-2,data:A,msg:e.i18n.t("VIDEO_LEVEL_NOT_SUPPORT")+":"+JSON.stringify(A)}),null==(n=e.logger)||n.warn("video level does not exist!"),Promise.resolve({code:-2,data:A}))}function fh(){return fh=Object.assign||function(e){for(var A=1;At&&ai?0:-1:n>t&&a>i?1:n-1)try{var a=function(e,A,t,i){void 0===i&&(i=5);if(!(e&&A&&t&&t.startPos&&t.endPos))return-1;var n=t.startPos[0],a=t.startPos[1],r=t.endPos[0],o=t.endPos[1],s=Math.abs(r-n),g=Math.abs(o-a),l=parseInt((n+r)/2+""),c=parseInt((a+o)/2+""),d=Math.round(e*A/(s*g));return{startPointX:parseInt(n/e*256+""),startPointY:parseInt(a/A*256+""),endPointX:parseInt(r/e*256+""),endPointY:parseInt(o/A*256+""),zoomRate:d>i?i:d,targetCenterX:l,targetCenterY:c,targetWidth:s,targetHeight:g}}(t,i,A,e.capacity&&e.capacity.support_zoomOut_maxTime?e.capacity.support_zoomOut_maxTime:5);if(-1===a)return;var r=e.env.domain+"/api/v3/das/device/3d/zoom?accessToken="+(e.accessToken||e.token.deviceToken.video)+"&deviceSerial="+e.urlInfo.deviceSerial+"&channelNo="+e.urlInfo.channelNo+"&command="+(0==n?9:8)+"&zoomTimes="+a.zoomRate+"&startPointX="+a.startPointX+"&startPointY="+a.startPointY+"&endPointX="+a.endPointX+"&endPointY="+a.endPointY+"&length="+parseInt(i)+"&width="+parseInt(t)+"&midPointX="+a.targetCenterX+"&midPointY="+a.targetCenterY+"&lengthX="+a.targetWidth+"&lengthY="+a.targetHeight;fetch(r,{method:"POST"}).then((function(e){return e.json()})).then((function(A){var t;200!=A.code&&(null==(t=e.pluginStatus)||t.loadingSetText({text:A.msg,color:"red",delayClear:2e3}))})).catch((function(A){var t;null==(t=e.pluginStatus)||t.loadingSetText({text:e.i18n.t("3D_ZOOM_FAILED"),color:"red",delayClear:2e3})}))}catch(A){var o;e.pluginStatus.loadingSetText({text:null==(o=e.i18n)?void 0:o.t("3D_ZOOM_FAILED"),color:"red",delayClear:2e3})}}));return null==(g=e.eventEmitter)||g.emit(id.enable3DZoom,{eventType:id.enable3DZoom,code:l,msg:null==(s=e.i18n)?void 0:s.t("START_3D_ZOOM")}),0===l?Promise.resolve({code:-1}):Promise.resolve({code:0})}return e.is3DZooming=!1,a&&(a.title=null==(n=e.i18n)?void 0:n.t("ZOOM")),new Promise((function(A){e.eventEmitter&&e.eventEmitter.emit(id.enable3DZoom,{eventType:id.enable3DZoom,code:-1,msg:e.i18n.t("DEVICE_NOT_SUPPORT_3D_ZOOM")}),A({code:-1,msg:e.i18n.t("DEVICE_NOT_SUPPORT_3D_ZOOM")})}))}function ph(e,A){var t,i,n,a,r,o,s,g,l;return!e._FECCorrectType||((null==(t=e.jSPlugin)?void 0:t.isHardH264)||(null==(i=e.jSPlugin)?void 0:i.isHardH265))&&(null==(n=e.jSPlugin)?void 0:n.useHardDev)?(e.eventEmitter.emit(id.getFEC3DViewParam,{eventType:id.getFEC3DViewParam,code:-1,msg:e.i18n.t("FEC.GET_FEC_PARAMS_SUPPORT_VERSION")}),Promise.resolve({code:-1,msg:e.i18n.t("FEC.GET_FEC_PARAMS_SUPPORT_VERSION")})):(null==(a=e.jSPlugin)?void 0:a.FEC_Set3DViewParam)&&e._FECCorrectType&&(3===(null==(r=e._FECCorrectType)?void 0:r.place)&&1536===(null==(o=e._FECCorrectType)?void 0:o.correctType)||1===(null==(s=e._FECCorrectType)?void 0:s.place)&&2304===(null==(g=e._FECCorrectType)?void 0:g.correctType))?null==(l=e.jSPlugin)?void 0:l.FEC_Get3DViewParam(A).then((function(A){return e.eventEmitter.emit(id.getFEC3DViewParam,{eventType:id.getFEC3DViewParam,code:0,data:A,msg:e.i18n.t("FEC.SET_FEC_PARAMS")}),{code:0,data:A}})).catch((function(){return e.eventEmitter.emit(id.getFEC3DViewParam,{eventType:id.getFEC3DViewParam,code:-1}),{code:-1}})):(e.eventEmitter.emit(id.getFEC3DViewParam,{eventType:id.getFEC3DViewParam,code:-1,msg:e.i18n.t("FEC.SET_FEC_PARAMS_FAILED")}),Promise.resolve({code:-1,msg:e.i18n.t("FEC.SET_FEC_PARAMS_FAILED")}))}function mh(e,A,t,i,n,a,r){try{var o=e[a](r),s=o.value}catch(e){return void t(e)}o.done?A(s):Promise.resolve(s).then(i,n)}function yh(e,A){var t,i,n,a,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!(n=r.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]0&&A-1 in e)}function y(e,A){return e.nodeName&&e.nodeName.toLowerCase()===A.toLowerCase()}p.fn=p.prototype={jquery:x,constructor:p,length:0,toArray:function(){return n.call(this)},get:function(e){return null==e?n.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var A=p.merge(this.constructor(),e);return A.prevObject=this,A},each:function(e){return p.each(this,e)},map:function(e){return this.pushStack(p.map(this,(function(A,t){return e.call(A,t,A)})))},slice:function(){return this.pushStack(n.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(p.grep(this,(function(e,A){return(A+1)%2})))},odd:function(){return this.pushStack(p.grep(this,(function(e,A){return A%2})))},eq:function(e){var A=this.length,t=+e+(e<0?A:0);return this.pushStack(t>=0&&t+~]|"+D+")"+D+"*"),U=new RegExp(D+"|>"),J=new RegExp(M),H=new RegExp("^"+T+"$"),K={ID:new RegExp("^#("+T+")"),CLASS:new RegExp("^\\.("+T+")"),TAG:new RegExp("^("+T+"|[*])"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+M),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+D+"*(even|odd|(([+-]|)(\\d*)n|)"+D+"*(?:([+-]|)"+D+"*(\\d+)|))"+D+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+D+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+D+"*((?:-\\d)?\\d*)"+D+"*\\)|)(?=[^-]|$)","i")},O=/^(?:input|select|textarea|button)$/i,V=/^h\d$/i,j=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,W=/[+~]/,Z=new RegExp("\\\\[\\da-fA-F]{1,6}"+D+"?|\\\\([^\\r\\n\\f])","g"),X=function(e,A){var t="0x"+e.slice(1)-65536;return A||(t<0?String.fromCharCode(t+65536):String.fromCharCode(t>>10|55296,1023&t|56320))},q=function(){se()},z=de((function(e){return!0===e.disabled&&y(e,"fieldset")}),{dir:"parentNode",next:"legend"});try{u.apply(t=n.call(R.childNodes),R.childNodes),t[R.childNodes.length].nodeType}catch(e){u={apply:function(e,A){k.apply(e,n.call(A))},call:function(e){k.apply(e,n.call(arguments,1))}}}function $(e,A,t,i){var n,a,r,o,s,l,c,h=A&&A.ownerDocument,f=A?A.nodeType:9;if(t=t||[],"string"!=typeof e||!e||1!==f&&9!==f&&11!==f)return t;if(!i&&(se(A),A=A||g,d)){if(11!==f&&(s=j.exec(e)))if(n=s[1]){if(9===f){if(!(r=A.getElementById(n)))return t;if(r.id===n)return u.call(t,r),t}else if(h&&(r=h.getElementById(n))&&$.contains(A,r)&&r.id===n)return u.call(t,r),t}else{if(s[2])return u.apply(t,A.getElementsByTagName(e)),t;if((n=s[3])&&A.getElementsByClassName)return u.apply(t,A.getElementsByClassName(n)),t}if(!(b[e+" "]||C&&C.test(e))){if(c=e,h=A,1===f&&(U.test(e)||Y.test(e))){for((h=W.test(e)&&oe(A.parentNode)||A)==A&&I.scope||((o=A.getAttribute("id"))?o=p.escapeSelector(o):A.setAttribute("id",o=B)),a=(l=le(e)).length;a--;)l[a]=(o?"#"+o:":scope")+" "+ce(l[a]);c=l.join(",")}try{return u.apply(t,h.querySelectorAll(c)),t}catch(A){b(e,!0)}finally{o===B&&A.removeAttribute("id")}}}return fe(e.replace(w,"$1"),A,t,i)}function ee(){var e=[];return function A(t,n){return e.push(t+" ")>i.cacheLength&&delete A[e.shift()],A[t+" "]=n}}function Ae(e){return e[B]=!0,e}function te(e){var A=g.createElement("fieldset");try{return!!e(A)}catch(e){return!1}finally{A.parentNode&&A.parentNode.removeChild(A),A=null}}function ie(e){return function(A){return y(A,"input")&&A.type===e}}function ne(e){return function(A){return(y(A,"input")||y(A,"button"))&&A.type===e}}function ae(e){return function(A){return"form"in A?A.parentNode&&!1===A.disabled?"label"in A?"label"in A.parentNode?A.parentNode.disabled===e:A.disabled===e:A.isDisabled===e||A.isDisabled!==!e&&z(A)===e:A.disabled===e:"label"in A&&A.disabled===e}}function re(e){return Ae((function(A){return A=+A,Ae((function(t,i){for(var n,a=e([],t.length,A),r=a.length;r--;)t[n=a[r]]&&(t[n]=!(i[n]=t[n]))}))}))}function oe(e){return e&&void 0!==e.getElementsByTagName&&e}function se(e){var A,t=e?e.ownerDocument||e:R;return t!=g&&9===t.nodeType&&t.documentElement?(c=(g=t).documentElement,d=!p.isXMLDoc(g),h=c.matches||c.webkitMatchesSelector||c.msMatchesSelector,c.msMatchesSelector&&R!=g&&(A=g.defaultView)&&A.top!==A&&A.addEventListener("unload",q),I.getById=te((function(e){return c.appendChild(e).id=p.expando,!g.getElementsByName||!g.getElementsByName(p.expando).length})),I.disconnectedMatch=te((function(e){return h.call(e,"*")})),I.scope=te((function(){return g.querySelectorAll(":scope")})),I.cssHas=te((function(){try{return g.querySelector(":has(*,:jqfake)"),!1}catch(e){return!0}})),I.getById?(i.filter.ID=function(e){var A=e.replace(Z,X);return function(e){return e.getAttribute("id")===A}},i.find.ID=function(e,A){if(void 0!==A.getElementById&&d){var t=A.getElementById(e);return t?[t]:[]}}):(i.filter.ID=function(e){var A=e.replace(Z,X);return function(e){var t=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===A}},i.find.ID=function(e,A){if(void 0!==A.getElementById&&d){var t,i,n,a=A.getElementById(e);if(a){if((t=a.getAttributeNode("id"))&&t.value===e)return[a];for(n=A.getElementsByName(e),i=0;a=n[i++];)if((t=a.getAttributeNode("id"))&&t.value===e)return[a]}return[]}}),i.find.TAG=function(e,A){return void 0!==A.getElementsByTagName?A.getElementsByTagName(e):A.querySelectorAll(e)},i.find.CLASS=function(e,A){if(void 0!==A.getElementsByClassName&&d)return A.getElementsByClassName(e)},C=[],te((function(e){var A;c.appendChild(e).innerHTML="",e.querySelectorAll("[selected]").length||C.push("\\["+D+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+B+"-]").length||C.push("~="),e.querySelectorAll("a#"+B+"+*").length||C.push(".#.+[+~]"),e.querySelectorAll(":checked").length||C.push(":checked"),(A=g.createElement("input")).setAttribute("type","hidden"),e.appendChild(A).setAttribute("name","D"),c.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&C.push(":enabled",":disabled"),(A=g.createElement("input")).setAttribute("name",""),e.appendChild(A),e.querySelectorAll("[name='']").length||C.push("\\["+D+"*name"+D+"*="+D+"*(?:''|\"\")")})),I.cssHas||C.push(":has"),C=C.length&&new RegExp(C.join("|")),F=function(e,A){if(e===A)return s=!0,0;var t=!e.compareDocumentPosition-!A.compareDocumentPosition;return t||(1&(t=(e.ownerDocument||e)==(A.ownerDocument||A)?e.compareDocumentPosition(A):1)||!I.sortDetached&&A.compareDocumentPosition(e)===t?e===g||e.ownerDocument==R&&$.contains(R,e)?-1:A===g||A.ownerDocument==R&&$.contains(R,A)?1:r?o.call(r,e)-o.call(r,A):0:4&t?-1:1)},g):g}for(A in $.matches=function(e,A){return $(e,null,null,A)},$.matchesSelector=function(e,A){if(se(e),d&&!b[A+" "]&&(!C||!C.test(A)))try{var t=h.call(e,A);if(t||I.disconnectedMatch||e.document&&11!==e.document.nodeType)return t}catch(e){b(A,!0)}return $(A,g,null,[e]).length>0},$.contains=function(e,A){return(e.ownerDocument||e)!=g&&se(e),p.contains(e,A)},$.attr=function(e,A){(e.ownerDocument||e)!=g&&se(e);var t=i.attrHandle[A.toLowerCase()],n=t&&l.call(i.attrHandle,A.toLowerCase())?t(e,A,!d):void 0;return void 0!==n?n:e.getAttribute(A)},$.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},p.uniqueSort=function(e){var A,t=[],i=0,a=0;if(s=!I.sortStable,r=!I.sortStable&&n.call(e,0),S.call(e,F),s){for(;A=e[a++];)A===e[a]&&(i=t.push(a));for(;i--;)v.call(e,t[i],1)}return r=null,e},p.fn.uniqueSort=function(){return this.pushStack(p.uniqueSort(n.apply(this)))},i=p.expr={cacheLength:50,createPseudo:Ae,match:K,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,X),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,X),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||$.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&$.error(e[0]),e},PSEUDO:function(e){var A,t=!e[6]&&e[2];return K.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":t&&J.test(t)&&(A=le(t,!0))&&(A=t.indexOf(")",t.length-A)-t.length)&&(e[0]=e[0].slice(0,A),e[2]=t.slice(0,A)),e.slice(0,3))}},filter:{TAG:function(e){var A=e.replace(Z,X).toLowerCase();return"*"===e?function(){return!0}:function(e){return y(e,A)}},CLASS:function(e){var A=x[e+" "];return A||(A=new RegExp("(^|"+D+")"+e+"("+D+"|$)"))&&x(e,(function(e){return A.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")}))},ATTR:function(e,A,t){return function(i){var n=$.attr(i,e);return null==n?"!="===A:!A||(n+="","="===A?n===t:"!="===A?n!==t:"^="===A?t&&0===n.indexOf(t):"*="===A?t&&n.indexOf(t)>-1:"$="===A?t&&n.slice(-t.length)===t:"~="===A?(" "+n.replace(L," ")+" ").indexOf(t)>-1:"|="===A&&(n===t||n.slice(0,t.length+1)===t+"-"))}},CHILD:function(e,A,t,i,n){var a="nth"!==e.slice(0,3),r="last"!==e.slice(-4),o="of-type"===A;return 1===i&&0===n?function(e){return!!e.parentNode}:function(A,t,s){var g,l,c,d,I,C=a!==r?"nextSibling":"previousSibling",h=A.parentNode,u=o&&A.nodeName.toLowerCase(),E=!s&&!o,x=!1;if(h){if(a){for(;C;){for(c=A;c=c[C];)if(o?y(c,u):1===c.nodeType)return!1;I=C="only"===e&&!I&&"nextSibling"}return!0}if(I=[r?h.firstChild:h.lastChild],r&&E){for(x=(d=(g=(l=h[B]||(h[B]={}))[e]||[])[0]===f&&g[1])&&g[2],c=d&&h.childNodes[d];c=++d&&c&&c[C]||(x=d=0)||I.pop();)if(1===c.nodeType&&++x&&c===A){l[e]=[f,d,x];break}}else if(E&&(x=d=(g=(l=A[B]||(A[B]={}))[e]||[])[0]===f&&g[1]),!1===x)for(;(c=++d&&c&&c[C]||(x=d=0)||I.pop())&&(!(o?y(c,u):1===c.nodeType)||!++x||(E&&((l=c[B]||(c[B]={}))[e]=[f,x]),c!==A)););return(x-=n)===i||x%i==0&&x/i>=0}}},PSEUDO:function(e,A){var t,n=i.pseudos[e]||i.setFilters[e.toLowerCase()]||$.error("unsupported pseudo: "+e);return n[B]?n(A):n.length>1?(t=[e,e,"",A],i.setFilters.hasOwnProperty(e.toLowerCase())?Ae((function(e,t){for(var i,a=n(e,A),r=a.length;r--;)e[i=o.call(e,a[r])]=!(t[i]=a[r])})):function(e){return n(e,0,t)}):n}},pseudos:{not:Ae((function(e){var A=[],t=[],i=Be(e.replace(w,"$1"));return i[B]?Ae((function(e,A,t,n){for(var a,r=i(e,null,n,[]),o=e.length;o--;)(a=r[o])&&(e[o]=!(A[o]=a))})):function(e,n,a){return A[0]=e,i(A,null,a,t),A[0]=null,!t.pop()}})),has:Ae((function(e){return function(A){return $(e,A).length>0}})),contains:Ae((function(e){return e=e.replace(Z,X),function(A){return(A.textContent||p.text(A)).indexOf(e)>-1}})),lang:Ae((function(e){return H.test(e||"")||$.error("unsupported lang: "+e),e=e.replace(Z,X).toLowerCase(),function(A){var t;do{if(t=d?A.lang:A.getAttribute("xml:lang")||A.getAttribute("lang"))return(t=t.toLowerCase())===e||0===t.indexOf(e+"-")}while((A=A.parentNode)&&1===A.nodeType);return!1}})),target:function(A){var t=e.location&&e.location.hash;return t&&t.slice(1)===A.id},root:function(e){return e===c},focus:function(e){return e===function(){try{return g.activeElement}catch(e){}}()&&g.hasFocus()&&!!(e.type||e.href||~e.tabIndex)},enabled:ae(!1),disabled:ae(!0),checked:function(e){return y(e,"input")&&!!e.checked||y(e,"option")&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return V.test(e.nodeName)},input:function(e){return O.test(e.nodeName)},button:function(e){return y(e,"input")&&"button"===e.type||y(e,"button")},text:function(e){var A;return y(e,"input")&&"text"===e.type&&(null==(A=e.getAttribute("type"))||"text"===A.toLowerCase())},first:re((function(){return[0]})),last:re((function(e,A){return[A-1]})),eq:re((function(e,A,t){return[t<0?t+A:t]})),even:re((function(e,A){for(var t=0;tA?A:t;--i>=0;)e.push(i);return e})),gt:re((function(e,A,t){for(var i=t<0?t+A:t;++i1?function(A,t,i){for(var n=e.length;n--;)if(!e[n](A,t,i))return!1;return!0}:e[0]}function Ce(e,A,t,i,n){for(var a,r=[],o=0,s=e.length,g=null!=A;o-1&&(a[l]=!(r[l]=d))}}else I=Ce(I===r?I.splice(B,I.length):I),n?n(null,r,I,g):u.apply(r,I)}))}function ue(e){for(var A,t,n,r=e.length,s=i.relative[e[0].type],g=s||i.relative[" "],l=s?1:0,c=de((function(e){return e===A}),g,!0),d=de((function(e){return o.call(A,e)>-1}),g,!0),I=[function(e,t,i){var n=!s&&(i||t!=a)||((A=t).nodeType?c(e,t,i):d(e,t,i));return A=null,n}];l1&&Ie(I),l>1&&ce(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(w,"$1"),t,l0,n=e.length>0,r=function(r,o,s,l,c){var I,C,h,B=0,E="0",x=r&&[],Q=[],m=a,y=r||n&&i.find.TAG("*",c),S=f+=null==m?1:Math.random()||.1,v=y.length;for(c&&(a=o==g||o||c);E!==v&&null!=(I=y[E]);E++){if(n&&I){for(C=0,o||I.ownerDocument==g||(se(I),s=!d);h=e[C++];)if(h(I,o||g,s)){u.call(l,I);break}c&&(f=S)}t&&((I=!h&&I)&&B--,r&&x.push(I))}if(B+=E,t&&E!==B){for(C=0;h=A[C++];)h(x,Q,o,s);if(r){if(B>0)for(;E--;)x[E]||Q[E]||(Q[E]=_.call(l));Q=Ce(Q)}u.apply(l,Q),c&&!r&&Q.length>0&&B+A.length>1&&p.uniqueSort(l)}return c&&(f=S,a=m),x};return t?Ae(r):r}(r,n)),o.selector=e}return o}function fe(e,A,t,n){var a,r,o,s,g,l="function"==typeof e&&e,c=!n&&le(e=l.selector||e);if(t=t||[],1===c.length){if((r=c[0]=c[0].slice(0)).length>2&&"ID"===(o=r[0]).type&&9===A.nodeType&&d&&i.relative[r[1].type]){if(!(A=(i.find.ID(o.matches[0].replace(Z,X),A)||[])[0]))return t;l&&(A=A.parentNode),e=e.slice(r.shift().value.length)}for(a=K.needsContext.test(e)?0:r.length;a--&&(o=r[a],!i.relative[s=o.type]);)if((g=i.find[s])&&(n=g(o.matches[0].replace(Z,X),W.test(r[0].type)&&oe(A.parentNode)||A))){if(r.splice(a,1),!(e=n.length&&ce(r)))return u.apply(t,n),t;break}}return(l||Be(e,c))(n,A,!d,t,!A||W.test(e)&&oe(A.parentNode)||A),t}ge.prototype=i.filters=i.pseudos,i.setFilters=new ge,I.sortStable=B.split("").sort(F).join("")===B,se(),I.sortDetached=te((function(e){return 1&e.compareDocumentPosition(g.createElement("fieldset"))})),p.find=$,p.expr[":"]=p.expr.pseudos,p.unique=p.uniqueSort,$.compile=Be,$.select=fe,$.setDocument=se,$.tokenize=le,$.escape=p.escapeSelector,$.getText=p.text,$.isXML=p.isXMLDoc,$.selectors=p.expr,$.support=p.support,$.uniqueSort=p.uniqueSort}();var P=function(e,A,t){for(var i=[],n=void 0!==t;(e=e[A])&&9!==e.nodeType;)if(1===e.nodeType){if(n&&p(e).is(t))break;i.push(e)}return i},T=function(e,A){for(var t=[];e;e=e.nextSibling)1===e.nodeType&&e!==A&&t.push(e);return t},N=p.expr.match.needsContext,M=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function L(e,A,t){return C(A)?p.grep(e,(function(e,i){return!!A.call(e,i,e)!==t})):A.nodeType?p.grep(e,(function(e){return e===A!==t})):"string"!=typeof A?p.grep(e,(function(e){return o.call(A,e)>-1!==t})):p.filter(A,e,t)}p.filter=function(e,A,t){var i=A[0];return t&&(e=":not("+e+")"),1===A.length&&1===i.nodeType?p.find.matchesSelector(i,e)?[i]:[]:p.find.matches(e,p.grep(A,(function(e){return 1===e.nodeType})))},p.fn.extend({find:function(e){var A,t,i=this.length,n=this;if("string"!=typeof e)return this.pushStack(p(e).filter((function(){for(A=0;A1?p.uniqueSort(t):t},filter:function(e){return this.pushStack(L(this,e||[],!1))},not:function(e){return this.pushStack(L(this,e||[],!0))},is:function(e){return!!L(this,"string"==typeof e&&N.test(e)?p(e):e||[],!1).length}});var G,Y=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,U=p.fn.init=function(e,A,t){var i,n;if(!e)return this;if(t=t||G,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:Y.exec(e))||!i[1]&&A)return!A||A.jquery?(A||t).find(e):this.constructor(A).find(e);if(i[1]){if(A=A instanceof p?A[0]:A,p.merge(this,p.parseHTML(i[1],A&&A.nodeType?A.ownerDocument||A:u,!0)),M.test(i[1])&&p.isPlainObject(A))for(i in A)C(this[i])?this[i](A[i]):this.attr(i,A[i]);return this}return(n=u.getElementById(i[2]))&&(this[0]=n,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):C(e)?void 0!==t.ready?t.ready(e):e(p):p.makeArray(e,this)};U.prototype=p.fn,G=p(u);var J=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function K(e,A){for(;(e=e[A])&&1!==e.nodeType;);return e}p.fn.extend({has:function(e){var A=p(e,this),t=A.length;return this.filter((function(){for(var e=0;e-1:1===t.nodeType&&p.find.matchesSelector(t,e))){a.push(t);break}return this.pushStack(a.length>1?p.uniqueSort(a):a)},index:function(e){return e?"string"==typeof e?o.call(p(e),this[0]):o.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,A){return this.pushStack(p.uniqueSort(p.merge(this.get(),p(e,A))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),p.each({parent:function(e){var A=e.parentNode;return A&&11!==A.nodeType?A:null},parents:function(e){return P(e,"parentNode")},parentsUntil:function(e,A,t){return P(e,"parentNode",t)},next:function(e){return K(e,"nextSibling")},prev:function(e){return K(e,"previousSibling")},nextAll:function(e){return P(e,"nextSibling")},prevAll:function(e){return P(e,"previousSibling")},nextUntil:function(e,A,t){return P(e,"nextSibling",t)},prevUntil:function(e,A,t){return P(e,"previousSibling",t)},siblings:function(e){return T((e.parentNode||{}).firstChild,e)},children:function(e){return T(e.firstChild)},contents:function(e){return null!=e.contentDocument&&i(e.contentDocument)?e.contentDocument:(y(e,"template")&&(e=e.content||e),p.merge([],e.childNodes))}},(function(e,A){p.fn[e]=function(t,i){var n=p.map(this,A,t);return"Until"!==e.slice(-5)&&(i=t),i&&"string"==typeof i&&(n=p.filter(i,n)),this.length>1&&(H[e]||p.uniqueSort(n),J.test(e)&&n.reverse()),this.pushStack(n)}}));var O=/[^\x20\t\r\n\f]+/g;function V(e){return e}function j(e){throw e}function W(e,A,t,i){var n;try{e&&C(n=e.promise)?n.call(e).done(A).fail(t):e&&C(n=e.then)?n.call(e,A,t):A.apply(void 0,[e].slice(i))}catch(e){t.apply(void 0,[e])}}p.Callbacks=function(e){e="string"==typeof e?function(e){var A={};return p.each(e.match(O)||[],(function(e,t){A[t]=!0})),A}(e):p.extend({},e);var A,t,i,n,a=[],r=[],o=-1,s=function(){for(n=n||e.once,i=A=!0;r.length;o=-1)for(t=r.shift();++o-1;)a.splice(t,1),t<=o&&o--})),this},has:function(e){return e?p.inArray(e,a)>-1:a.length>0},empty:function(){return a&&(a=[]),this},disable:function(){return n=r=[],a=t="",this},disabled:function(){return!a},lock:function(){return n=r=[],t||A||(a=t=""),this},locked:function(){return!!n},fireWith:function(e,t){return n||(t=[e,(t=t||[]).slice?t.slice():t],r.push(t),A||s()),this},fire:function(){return g.fireWith(this,arguments),this},fired:function(){return!!i}};return g},p.extend({Deferred:function(A){var t=[["notify","progress",p.Callbacks("memory"),p.Callbacks("memory"),2],["resolve","done",p.Callbacks("once memory"),p.Callbacks("once memory"),0,"resolved"],["reject","fail",p.Callbacks("once memory"),p.Callbacks("once memory"),1,"rejected"]],i="pending",n={state:function(){return i},always:function(){return a.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return p.Deferred((function(A){p.each(t,(function(t,i){var n=C(e[i[4]])&&e[i[4]];a[i[1]]((function(){var e=n&&n.apply(this,arguments);e&&C(e.promise)?e.promise().progress(A.notify).done(A.resolve).fail(A.reject):A[i[0]+"With"](this,n?[e]:arguments)}))})),e=null})).promise()},then:function(A,i,n){var a=0;function r(A,t,i,n){return function(){var o=this,s=arguments,g=function(){var e,g;if(!(A=a&&(i!==j&&(o=void 0,s=[e]),t.rejectWith(o,s))}};A?l():(p.Deferred.getErrorHook?l.error=p.Deferred.getErrorHook():p.Deferred.getStackHook&&(l.error=p.Deferred.getStackHook()),e.setTimeout(l))}}return p.Deferred((function(e){t[0][3].add(r(0,e,C(n)?n:V,e.notifyWith)),t[1][3].add(r(0,e,C(A)?A:V)),t[2][3].add(r(0,e,C(i)?i:j))})).promise()},promise:function(e){return null!=e?p.extend(e,n):n}},a={};return p.each(t,(function(e,A){var r=A[2],o=A[5];n[A[1]]=r.add,o&&r.add((function(){i=o}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),r.add(A[3].fire),a[A[0]]=function(){return a[A[0]+"With"](this===a?void 0:this,arguments),this},a[A[0]+"With"]=r.fireWith})),n.promise(a),A&&A.call(a,a),a},when:function(e){var A=arguments.length,t=A,i=Array(t),a=n.call(arguments),r=p.Deferred(),o=function(e){return function(t){i[e]=this,a[e]=arguments.length>1?n.call(arguments):t,--A||r.resolveWith(i,a)}};if(A<=1&&(W(e,r.done(o(t)).resolve,r.reject,!A),"pending"===r.state()||C(a[t]&&a[t].then)))return r.then();for(;t--;)W(a[t],o(t),r.reject);return r.promise()}});var Z=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;p.Deferred.exceptionHook=function(A,t){e.console&&e.console.warn&&A&&Z.test(A.name)&&e.console.warn("jQuery.Deferred exception: "+A.message,A.stack,t)},p.readyException=function(A){e.setTimeout((function(){throw A}))};var X=p.Deferred();function q(){u.removeEventListener("DOMContentLoaded",q),e.removeEventListener("load",q),p.ready()}p.fn.ready=function(e){return X.then(e).catch((function(e){p.readyException(e)})),this},p.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--p.readyWait:p.isReady)||(p.isReady=!0,!0!==e&&--p.readyWait>0||X.resolveWith(u,[p]))}}),p.ready.then=X.then,"complete"===u.readyState||"loading"!==u.readyState&&!u.documentElement.doScroll?e.setTimeout(p.ready):(u.addEventListener("DOMContentLoaded",q),e.addEventListener("load",q));var z=function(e,A,t,i,n,a,r){var o=0,s=e.length,g=null==t;if("object"===E(t))for(o in n=!0,t)z(e,A,o,t[o],!0,a,r);else if(void 0!==i&&(n=!0,C(i)||(r=!0),g&&(r?(A.call(e,i),A=null):(g=A,A=function(e,A,t){return g.call(p(e),t)})),A))for(;o1,null,!0)},removeData:function(e){return this.each((function(){re.remove(this,e)}))}}),p.extend({queue:function(e,A,t){var i;if(e)return A=(A||"fx")+"queue",i=ae.get(e,A),t&&(!i||Array.isArray(t)?i=ae.access(e,A,p.makeArray(t)):i.push(t)),i||[]},dequeue:function(e,A){A=A||"fx";var t=p.queue(e,A),i=t.length,n=t.shift(),a=p._queueHooks(e,A);"inprogress"===n&&(n=t.shift(),i--),n&&("fx"===A&&t.unshift("inprogress"),delete a.stop,n.call(e,(function(){p.dequeue(e,A)}),a)),!i&&a&&a.empty.fire()},_queueHooks:function(e,A){var t=A+"queueHooks";return ae.get(e,t)||ae.access(e,t,{empty:p.Callbacks("once memory").add((function(){ae.remove(e,[A+"queue",t])}))})}}),p.fn.extend({queue:function(e,A){var t=2;return"string"!=typeof e&&(A=e,e="fx",t--),arguments.length\x20\t\r\n\f]*)/i,_e=/^$|^module$|\/(?:java|ecma)script/i;Qe=u.createDocumentFragment().appendChild(u.createElement("div")),(pe=u.createElement("input")).setAttribute("type","radio"),pe.setAttribute("checked","checked"),pe.setAttribute("name","t"),Qe.appendChild(pe),I.checkClone=Qe.cloneNode(!0).cloneNode(!0).lastChild.checked,Qe.innerHTML="",I.noCloneChecked=!!Qe.cloneNode(!0).lastChild.defaultValue,Qe.innerHTML="",I.option=!!Qe.lastChild;var Se={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,A){var t;return t=void 0!==e.getElementsByTagName?e.getElementsByTagName(A||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(A||"*"):[],void 0===A||A&&y(e,A)?p.merge([e],t):t}function De(e,A){for(var t=0,i=e.length;t",""]);var we=/<|&#?\w+;/;function be(e,A,t,i,n){for(var a,r,o,s,g,l,c=A.createDocumentFragment(),d=[],I=0,C=e.length;I-1)n&&n.push(a);else if(g=Ce(a),r=ve(c.appendChild(a),"script"),g&&De(r),t)for(l=0;a=r[l++];)_e.test(a.type||"")&&t.push(a);return c}var Fe=/^([^.]*)(?:\.(.+)|)/;function Re(){return!0}function ke(){return!1}function Pe(e,A,t,i,n,a){var r,o;if("object"==typeof A){for(o in"string"!=typeof t&&(i=i||t,t=void 0),A)Pe(e,o,t,i,A[o],a);return e}if(null==i&&null==n?(n=t,i=t=void 0):null==n&&("string"==typeof t?(n=i,i=void 0):(n=i,i=t,t=void 0)),!1===n)n=ke;else if(!n)return e;return 1===a&&(r=n,n=function(e){return p().off(e),r.apply(this,arguments)},n.guid=r.guid||(r.guid=p.guid++)),e.each((function(){p.event.add(this,A,n,i,t)}))}function Te(e,A,t){t?(ae.set(e,A,!1),p.event.add(e,A,{namespace:!1,handler:function(e){var t,i=ae.get(this,A);if(1&e.isTrigger&&this[A]){if(i)(p.event.special[A]||{}).delegateType&&e.stopPropagation();else if(i=n.call(arguments),ae.set(this,A,i),this[A](),t=ae.get(this,A),ae.set(this,A,!1),i!==t)return e.stopImmediatePropagation(),e.preventDefault(),t}else i&&(ae.set(this,A,p.event.trigger(i[0],i.slice(1),this)),e.stopPropagation(),e.isImmediatePropagationStopped=Re)}})):void 0===ae.get(e,A)&&p.event.add(e,A,Re)}p.event={global:{},add:function(e,A,t,i,n){var a,r,o,s,g,l,c,d,I,C,h,u=ae.get(e);if(ie(e))for(t.handler&&(t=(a=t).handler,n=a.selector),n&&p.find.matchesSelector(Ie,n),t.guid||(t.guid=p.guid++),(s=u.events)||(s=u.events=Object.create(null)),(r=u.handle)||(r=u.handle=function(A){return void 0!==p&&p.event.triggered!==A.type?p.event.dispatch.apply(e,arguments):void 0}),g=(A=(A||"").match(O)||[""]).length;g--;)I=h=(o=Fe.exec(A[g])||[])[1],C=(o[2]||"").split(".").sort(),I&&(c=p.event.special[I]||{},I=(n?c.delegateType:c.bindType)||I,c=p.event.special[I]||{},l=p.extend({type:I,origType:h,data:i,handler:t,guid:t.guid,selector:n,needsContext:n&&p.expr.match.needsContext.test(n),namespace:C.join(".")},a),(d=s[I])||((d=s[I]=[]).delegateCount=0,c.setup&&!1!==c.setup.call(e,i,C,r)||e.addEventListener&&e.addEventListener(I,r)),c.add&&(c.add.call(e,l),l.handler.guid||(l.handler.guid=t.guid)),n?d.splice(d.delegateCount++,0,l):d.push(l),p.event.global[I]=!0)},remove:function(e,A,t,i,n){var a,r,o,s,g,l,c,d,I,C,h,u=ae.hasData(e)&&ae.get(e);if(u&&(s=u.events)){for(g=(A=(A||"").match(O)||[""]).length;g--;)if(I=h=(o=Fe.exec(A[g])||[])[1],C=(o[2]||"").split(".").sort(),I){for(c=p.event.special[I]||{},d=s[I=(i?c.delegateType:c.bindType)||I]||[],o=o[2]&&new RegExp("(^|\\.)"+C.join("\\.(?:.*\\.|)")+"(\\.|$)"),r=a=d.length;a--;)l=d[a],!n&&h!==l.origType||t&&t.guid!==l.guid||o&&!o.test(l.namespace)||i&&i!==l.selector&&("**"!==i||!l.selector)||(d.splice(a,1),l.selector&&d.delegateCount--,c.remove&&c.remove.call(e,l));r&&!d.length&&(c.teardown&&!1!==c.teardown.call(e,C,u.handle)||p.removeEvent(e,I,u.handle),delete s[I])}else for(I in s)p.event.remove(e,I+A[g],t,i,!0);p.isEmptyObject(s)&&ae.remove(e,"handle events")}},dispatch:function(e){var A,t,i,n,a,r,o=new Array(arguments.length),s=p.event.fix(e),g=(ae.get(this,"events")||Object.create(null))[s.type]||[],l=p.event.special[s.type]||{};for(o[0]=s,A=1;A=1))for(;g!==this;g=g.parentNode||this)if(1===g.nodeType&&("click"!==e.type||!0!==g.disabled)){for(a=[],r={},t=0;t-1:p.find(n,this,null,[g]).length),r[n]&&a.push(i);a.length&&o.push({elem:g,handlers:a})}return g=this,s\s*$/g;function Ge(e,A){return y(e,"table")&&y(11!==A.nodeType?A:A.firstChild,"tr")&&p(e).children("tbody")[0]||e}function Ye(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Ue(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Je(e,A){var t,i,n,a,r,o;if(1===A.nodeType){if(ae.hasData(e)&&(o=ae.get(e).events))for(n in ae.remove(A,"handle events"),o)for(t=0,i=o[n].length;t1&&"string"==typeof u&&!I.checkClone&&Me.test(u))return e.each((function(n){var a=e.eq(n);B&&(A[0]=u.call(this,n,a.html())),Ke(a,A,t,i)}));if(d&&(r=(n=be(A,e[0].ownerDocument,!1,e,i)).firstChild,1===n.childNodes.length&&(n=r),r||i)){for(s=(o=p.map(ve(n,"script"),Ye)).length;c0&&De(r,!s&&ve(e,"script")),o},cleanData:function(e){for(var A,t,i,n=p.event.special,a=0;void 0!==(t=e[a]);a++)if(ie(t)){if(A=t[ae.expando]){if(A.events)for(i in A.events)n[i]?p.event.remove(t,i):p.removeEvent(t,i,A.handle);t[ae.expando]=void 0}t[re.expando]&&(t[re.expando]=void 0)}}}),p.fn.extend({detach:function(e){return Oe(this,e,!0)},remove:function(e){return Oe(this,e)},text:function(e){return z(this,(function(e){return void 0===e?p.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Ke(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Ge(this,e).appendChild(e)}))},prepend:function(){return Ke(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var A=Ge(this,e);A.insertBefore(e,A.firstChild)}}))},before:function(){return Ke(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Ke(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,A=0;null!=(e=this[A]);A++)1===e.nodeType&&(p.cleanData(ve(e,!1)),e.textContent="");return this},clone:function(e,A){return e=null!=e&&e,A=null==A?e:A,this.map((function(){return p.clone(this,e,A)}))},html:function(e){return z(this,(function(e){var A=this[0]||{},t=0,i=this.length;if(void 0===e&&1===A.nodeType)return A.innerHTML;if("string"==typeof e&&!Ne.test(e)&&!Se[(ye.exec(e)||["",""])[1].toLowerCase()]){e=p.htmlPrefilter(e);try{for(;t=0&&(s+=Math.max(0,Math.ceil(e["offset"+A[0].toUpperCase()+A.slice(1)]-a-s-o-.5))||0),s+g}function sA(e,A,t){var i=We(e),n=(!I.boxSizingReliable()||t)&&"border-box"===p.css(e,"boxSizing",!1,i),a=n,r=qe(e,A,i),o="offset"+A[0].toUpperCase()+A.slice(1);if(Ve.test(r)){if(!t)return r;r="auto"}return(!I.boxSizingReliable()&&n||!I.reliableTrDimensions()&&y(e,"tr")||"auto"===r||!parseFloat(r)&&"inline"===p.css(e,"display",!1,i))&&e.getClientRects().length&&(n="border-box"===p.css(e,"boxSizing",!1,i),(a=o in e)&&(r=e[o])),(r=parseFloat(r)||0)+oA(e,A,t||(n?"border":"content"),a,i,r)+"px"}function gA(e,A,t,i,n){return new gA.prototype.init(e,A,t,i,n)}p.extend({cssHooks:{opacity:{get:function(e,A){if(A){var t=qe(e,"opacity");return""===t?"1":t}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(e,A,t,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var n,a,r,o=te(A),s=je.test(A),g=e.style;if(s||(A=tA(o)),r=p.cssHooks[A]||p.cssHooks[o],void 0===t)return r&&"get"in r&&void 0!==(n=r.get(e,!1,i))?n:g[A];"string"==(a=typeof t)&&(n=ce.exec(t))&&n[1]&&(t=Be(e,A,n),a="number"),null!=t&&t==t&&("number"!==a||s||(t+=n&&n[3]||(p.cssNumber[o]?"":"px")),I.clearCloneStyle||""!==t||0!==A.indexOf("background")||(g[A]="inherit"),r&&"set"in r&&void 0===(t=r.set(e,t,i))||(s?g.setProperty(A,t):g[A]=t))}},css:function(e,A,t,i){var n,a,r,o=te(A);return je.test(A)||(A=tA(o)),(r=p.cssHooks[A]||p.cssHooks[o])&&"get"in r&&(n=r.get(e,!0,t)),void 0===n&&(n=qe(e,A,i)),"normal"===n&&A in aA&&(n=aA[A]),""===t||t?(a=parseFloat(n),!0===t||isFinite(a)?a||0:n):n}}),p.each(["height","width"],(function(e,A){p.cssHooks[A]={get:function(e,t,i){if(t)return!iA.test(p.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?sA(e,A,i):Ze(e,nA,(function(){return sA(e,A,i)}))},set:function(e,t,i){var n,a=We(e),r=!I.scrollboxSize()&&"absolute"===a.position,o=(r||i)&&"border-box"===p.css(e,"boxSizing",!1,a),s=i?oA(e,A,i,o,a):0;return o&&r&&(s-=Math.ceil(e["offset"+A[0].toUpperCase()+A.slice(1)]-parseFloat(a[A])-oA(e,A,"border",!1,a)-.5)),s&&(n=ce.exec(t))&&"px"!==(n[3]||"px")&&(e.style[A]=t,t=p.css(e,A)),rA(0,t,s)}}})),p.cssHooks.marginLeft=ze(I.reliableMarginLeft,(function(e,A){if(A)return(parseFloat(qe(e,"marginLeft"))||e.getBoundingClientRect().left-Ze(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+"px"})),p.each({margin:"",padding:"",border:"Width"},(function(e,A){p.cssHooks[e+A]={expand:function(t){for(var i=0,n={},a="string"==typeof t?t.split(" "):[t];i<4;i++)n[e+de[i]+A]=a[i]||a[i-2]||a[0];return n}},"margin"!==e&&(p.cssHooks[e+A].set=rA)})),p.fn.extend({css:function(e,A){return z(this,(function(e,A,t){var i,n,a={},r=0;if(Array.isArray(A)){for(i=We(e),n=A.length;r1)}}),p.Tween=gA,gA.prototype={constructor:gA,init:function(e,A,t,i,n,a){this.elem=e,this.prop=t,this.easing=n||p.easing._default,this.options=A,this.start=this.now=this.cur(),this.end=i,this.unit=a||(p.cssNumber[t]?"":"px")},cur:function(){var e=gA.propHooks[this.prop];return e&&e.get?e.get(this):gA.propHooks._default.get(this)},run:function(e){var A,t=gA.propHooks[this.prop];return this.options.duration?this.pos=A=p.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=A=e,this.now=(this.end-this.start)*A+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),t&&t.set?t.set(this):gA.propHooks._default.set(this),this}},gA.prototype.init.prototype=gA.prototype,gA.propHooks={_default:{get:function(e){var A;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(A=p.css(e.elem,e.prop,""))&&"auto"!==A?A:0},set:function(e){p.fx.step[e.prop]?p.fx.step[e.prop](e):1!==e.elem.nodeType||!p.cssHooks[e.prop]&&null==e.elem.style[tA(e.prop)]?e.elem[e.prop]=e.now:p.style(e.elem,e.prop,e.now+e.unit)}}},gA.propHooks.scrollTop=gA.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},p.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},p.fx=gA.prototype.init,p.fx.step={};var lA,cA,dA=/^(?:toggle|show|hide)$/,IA=/queueHooks$/;function CA(){cA&&(!1===u.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(CA):e.setTimeout(CA,p.fx.interval),p.fx.tick())}function hA(){return e.setTimeout((function(){lA=void 0})),lA=Date.now()}function uA(e,A){var t,i=0,n={height:e};for(A=A?1:0;i<4;i+=2-A)n["margin"+(t=de[i])]=n["padding"+t]=e;return A&&(n.opacity=n.width=e),n}function BA(e,A,t){for(var i,n=(fA.tweeners[A]||[]).concat(fA.tweeners["*"]),a=0,r=n.length;a1)},removeAttr:function(e){return this.each((function(){p.removeAttr(this,e)}))}}),p.extend({attr:function(e,A,t){var i,n,a=e.nodeType;if(3!==a&&8!==a&&2!==a)return void 0===e.getAttribute?p.prop(e,A,t):(1===a&&p.isXMLDoc(e)||(n=p.attrHooks[A.toLowerCase()]||(p.expr.match.bool.test(A)?EA:void 0)),void 0!==t?null===t?void p.removeAttr(e,A):n&&"set"in n&&void 0!==(i=n.set(e,t,A))?i:(e.setAttribute(A,t+""),t):n&&"get"in n&&null!==(i=n.get(e,A))?i:null==(i=p.find.attr(e,A))?void 0:i)},attrHooks:{type:{set:function(e,A){if(!I.radioValue&&"radio"===A&&y(e,"input")){var t=e.value;return e.setAttribute("type",A),t&&(e.value=t),A}}}},removeAttr:function(e,A){var t,i=0,n=A&&A.match(O);if(n&&1===e.nodeType)for(;t=n[i++];)e.removeAttribute(t)}}),EA={set:function(e,A,t){return!1===A?p.removeAttr(e,t):e.setAttribute(t,t),t}},p.each(p.expr.match.bool.source.match(/\w+/g),(function(e,A){var t=xA[A]||p.find.attr;xA[A]=function(e,A,i){var n,a,r=A.toLowerCase();return i||(a=xA[r],xA[r]=n,n=null!=t(e,A,i)?r:null,xA[r]=a),n}}));var QA=/^(?:input|select|textarea|button)$/i,pA=/^(?:a|area)$/i;function mA(e){return(e.match(O)||[]).join(" ")}function yA(e){return e.getAttribute&&e.getAttribute("class")||""}function _A(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(O)||[]}p.fn.extend({prop:function(e,A){return z(this,p.prop,e,A,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[p.propFix[e]||e]}))}}),p.extend({prop:function(e,A,t){var i,n,a=e.nodeType;if(3!==a&&8!==a&&2!==a)return 1===a&&p.isXMLDoc(e)||(A=p.propFix[A]||A,n=p.propHooks[A]),void 0!==t?n&&"set"in n&&void 0!==(i=n.set(e,t,A))?i:e[A]=t:n&&"get"in n&&null!==(i=n.get(e,A))?i:e[A]},propHooks:{tabIndex:{get:function(e){var A=p.find.attr(e,"tabindex");return A?parseInt(A,10):QA.test(e.nodeName)||pA.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),I.optSelected||(p.propHooks.selected={get:function(e){var A=e.parentNode;return A&&A.parentNode&&A.parentNode.selectedIndex,null},set:function(e){var A=e.parentNode;A&&(A.selectedIndex,A.parentNode&&A.parentNode.selectedIndex)}}),p.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){p.propFix[this.toLowerCase()]=this})),p.fn.extend({addClass:function(e){var A,t,i,n,a,r;return C(e)?this.each((function(A){p(this).addClass(e.call(this,A,yA(this)))})):(A=_A(e)).length?this.each((function(){if(i=yA(this),t=1===this.nodeType&&" "+mA(i)+" "){for(a=0;a-1;)t=t.replace(" "+n+" "," ");r=mA(t),i!==r&&this.setAttribute("class",r)}})):this:this.attr("class","")},toggleClass:function(e,A){var t,i,n,a,r=typeof e,o="string"===r||Array.isArray(e);return C(e)?this.each((function(t){p(this).toggleClass(e.call(this,t,yA(this),A),A)})):"boolean"==typeof A&&o?A?this.addClass(e):this.removeClass(e):(t=_A(e),this.each((function(){if(o)for(a=p(this),n=0;n-1)return!0;return!1}});var SA=/\r/g;p.fn.extend({val:function(e){var A,t,i,n=this[0];return arguments.length?(i=C(e),this.each((function(t){var n;1===this.nodeType&&(null==(n=i?e.call(this,t,p(this).val()):e)?n="":"number"==typeof n?n+="":Array.isArray(n)&&(n=p.map(n,(function(e){return null==e?"":e+""}))),(A=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()])&&"set"in A&&void 0!==A.set(this,n,"value")||(this.value=n))}))):n?(A=p.valHooks[n.type]||p.valHooks[n.nodeName.toLowerCase()])&&"get"in A&&void 0!==(t=A.get(n,"value"))?t:"string"==typeof(t=n.value)?t.replace(SA,""):null==t?"":t:void 0}}),p.extend({valHooks:{option:{get:function(e){var A=p.find.attr(e,"value");return null!=A?A:mA(p.text(e))}},select:{get:function(e){var A,t,i,n=e.options,a=e.selectedIndex,r="select-one"===e.type,o=r?null:[],s=r?a+1:n.length;for(i=a<0?s:r?a:0;i-1)&&(t=!0);return t||(e.selectedIndex=-1),a}}}}),p.each(["radio","checkbox"],(function(){p.valHooks[this]={set:function(e,A){if(Array.isArray(A))return e.checked=p.inArray(p(e).val(),A)>-1}},I.checkOn||(p.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}));var vA=e.location,DA={guid:Date.now()},wA=/\?/;p.parseXML=function(A){var t,i;if(!A||"string"!=typeof A)return null;try{t=(new e.DOMParser).parseFromString(A,"text/xml")}catch(e){}return i=t&&t.getElementsByTagName("parsererror")[0],t&&!i||p.error("Invalid XML: "+(i?p.map(i.childNodes,(function(e){return e.textContent})).join("\n"):A)),t};var bA=/^(?:focusinfocus|focusoutblur)$/,FA=function(e){e.stopPropagation()};p.extend(p.event,{trigger:function(A,t,i,n){var a,r,o,s,g,c,d,I,B=[i||u],f=l.call(A,"type")?A.type:A,E=l.call(A,"namespace")?A.namespace.split("."):[];if(r=I=o=i=i||u,3!==i.nodeType&&8!==i.nodeType&&!bA.test(f+p.event.triggered)&&(f.indexOf(".")>-1&&(E=f.split("."),f=E.shift(),E.sort()),g=f.indexOf(":")<0&&"on"+f,(A=A[p.expando]?A:new p.Event(f,"object"==typeof A&&A)).isTrigger=n?2:3,A.namespace=E.join("."),A.rnamespace=A.namespace?new RegExp("(^|\\.)"+E.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,A.result=void 0,A.target||(A.target=i),t=null==t?[A]:p.makeArray(t,[A]),d=p.event.special[f]||{},n||!d.trigger||!1!==d.trigger.apply(i,t))){if(!n&&!d.noBubble&&!h(i)){for(s=d.delegateType||f,bA.test(s+f)||(r=r.parentNode);r;r=r.parentNode)B.push(r),o=r;o===(i.ownerDocument||u)&&B.push(o.defaultView||o.parentWindow||e)}for(a=0;(r=B[a++])&&!A.isPropagationStopped();)I=r,A.type=a>1?s:d.bindType||f,(c=(ae.get(r,"events")||Object.create(null))[A.type]&&ae.get(r,"handle"))&&c.apply(r,t),(c=g&&r[g])&&c.apply&&ie(r)&&(A.result=c.apply(r,t),!1===A.result&&A.preventDefault());return A.type=f,n||A.isDefaultPrevented()||d._default&&!1!==d._default.apply(B.pop(),t)||!ie(i)||g&&C(i[f])&&!h(i)&&((o=i[g])&&(i[g]=null),p.event.triggered=f,A.isPropagationStopped()&&I.addEventListener(f,FA),i[f](),A.isPropagationStopped()&&I.removeEventListener(f,FA),p.event.triggered=void 0,o&&(i[g]=o)),A.result}},simulate:function(e,A,t){var i=p.extend(new p.Event,t,{type:e,isSimulated:!0});p.event.trigger(i,null,A)}}),p.fn.extend({trigger:function(e,A){return this.each((function(){p.event.trigger(e,A,this)}))},triggerHandler:function(e,A){var t=this[0];if(t)return p.event.trigger(e,A,t,!0)}});var RA=/\[\]$/,kA=/\r?\n/g,PA=/^(?:submit|button|image|reset|file)$/i,TA=/^(?:input|select|textarea|keygen)/i;function NA(e,A,t,i){var n;if(Array.isArray(A))p.each(A,(function(A,n){t||RA.test(e)?i(e,n):NA(e+"["+("object"==typeof n&&null!=n?A:"")+"]",n,t,i)}));else if(t||"object"!==E(A))i(e,A);else for(n in A)NA(e+"["+n+"]",A[n],t,i)}p.param=function(e,A){var t,i=[],n=function(e,A){var t=C(A)?A():A;i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==t?"":t)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!p.isPlainObject(e))p.each(e,(function(){n(this.name,this.value)}));else for(t in e)NA(t,e[t],A,n);return i.join("&")},p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=p.prop(this,"elements");return e?p.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!p(this).is(":disabled")&&TA.test(this.nodeName)&&!PA.test(e)&&(this.checked||!me.test(e))})).map((function(e,A){var t=p(this).val();return null==t?null:Array.isArray(t)?p.map(t,(function(e){return{name:A.name,value:e.replace(kA,"\r\n")}})):{name:A.name,value:t.replace(kA,"\r\n")}})).get()}});var MA=/%20/g,LA=/#.*$/,GA=/([?&])_=[^&]*/,YA=/^(.*?):[ \t]*([^\r\n]*)$/gm,UA=/^(?:GET|HEAD)$/,JA=/^\/\//,HA={},KA={},OA="*/".concat("*"),VA=u.createElement("a");function jA(e){return function(A,t){"string"!=typeof A&&(t=A,A="*");var i,n=0,a=A.toLowerCase().match(O)||[];if(C(t))for(;i=a[n++];)"+"===i[0]?(i=i.slice(1)||"*",(e[i]=e[i]||[]).unshift(t)):(e[i]=e[i]||[]).push(t)}}function WA(e,A,t,i){var n={},a=e===KA;function r(o){var s;return n[o]=!0,p.each(e[o]||[],(function(e,o){var g=o(A,t,i);return"string"!=typeof g||a||n[g]?a?!(s=g):void 0:(A.dataTypes.unshift(g),r(g),!1)})),s}return r(A.dataTypes[0])||!n["*"]&&r("*")}function ZA(e,A){var t,i,n=p.ajaxSettings.flatOptions||{};for(t in A)void 0!==A[t]&&((n[t]?e:i||(i={}))[t]=A[t]);return i&&p.extend(!0,e,i),e}VA.href=vA.href,p.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:vA.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(vA.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":OA,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":p.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,A){return A?ZA(ZA(e,p.ajaxSettings),A):ZA(p.ajaxSettings,e)},ajaxPrefilter:jA(HA),ajaxTransport:jA(KA),ajax:function(A,t){"object"==typeof A&&(t=A,A=void 0),t=t||{};var i,n,a,r,o,s,g,l,c,d,I=p.ajaxSetup({},t),C=I.context||I,h=I.context&&(C.nodeType||C.jquery)?p(C):p.event,B=p.Deferred(),f=p.Callbacks("once memory"),E=I.statusCode||{},x={},Q={},m="canceled",y={readyState:0,getResponseHeader:function(e){var A;if(g){if(!r)for(r={};A=YA.exec(a);)r[A[1].toLowerCase()+" "]=(r[A[1].toLowerCase()+" "]||[]).concat(A[2]);A=r[e.toLowerCase()+" "]}return null==A?null:A.join(", ")},getAllResponseHeaders:function(){return g?a:null},setRequestHeader:function(e,A){return null==g&&(e=Q[e.toLowerCase()]=Q[e.toLowerCase()]||e,x[e]=A),this},overrideMimeType:function(e){return null==g&&(I.mimeType=e),this},statusCode:function(e){var A;if(e)if(g)y.always(e[y.status]);else for(A in e)E[A]=[E[A],e[A]];return this},abort:function(e){var A=e||m;return i&&i.abort(A),_(0,A),this}};if(B.promise(y),I.url=((A||I.url||vA.href)+"").replace(JA,vA.protocol+"//"),I.type=t.method||t.type||I.method||I.type,I.dataTypes=(I.dataType||"*").toLowerCase().match(O)||[""],null==I.crossDomain){s=u.createElement("a");try{s.href=I.url,s.href=s.href,I.crossDomain=VA.protocol+"//"+VA.host!=s.protocol+"//"+s.host}catch(e){I.crossDomain=!0}}if(I.data&&I.processData&&"string"!=typeof I.data&&(I.data=p.param(I.data,I.traditional)),WA(HA,I,t,y),g)return y;for(c in(l=p.event&&I.global)&&0==p.active++&&p.event.trigger("ajaxStart"),I.type=I.type.toUpperCase(),I.hasContent=!UA.test(I.type),n=I.url.replace(LA,""),I.hasContent?I.data&&I.processData&&0===(I.contentType||"").indexOf("application/x-www-form-urlencoded")&&(I.data=I.data.replace(MA,"+")):(d=I.url.slice(n.length),I.data&&(I.processData||"string"==typeof I.data)&&(n+=(wA.test(n)?"&":"?")+I.data,delete I.data),!1===I.cache&&(n=n.replace(GA,"$1"),d=(wA.test(n)?"&":"?")+"_="+DA.guid+++d),I.url=n+d),I.ifModified&&(p.lastModified[n]&&y.setRequestHeader("If-Modified-Since",p.lastModified[n]),p.etag[n]&&y.setRequestHeader("If-None-Match",p.etag[n])),(I.data&&I.hasContent&&!1!==I.contentType||t.contentType)&&y.setRequestHeader("Content-Type",I.contentType),y.setRequestHeader("Accept",I.dataTypes[0]&&I.accepts[I.dataTypes[0]]?I.accepts[I.dataTypes[0]]+("*"!==I.dataTypes[0]?", "+OA+"; q=0.01":""):I.accepts["*"]),I.headers)y.setRequestHeader(c,I.headers[c]);if(I.beforeSend&&(!1===I.beforeSend.call(C,y,I)||g))return y.abort();if(m="abort",f.add(I.complete),y.done(I.success),y.fail(I.error),i=WA(KA,I,t,y)){if(y.readyState=1,l&&h.trigger("ajaxSend",[y,I]),g)return y;I.async&&I.timeout>0&&(o=e.setTimeout((function(){y.abort("timeout")}),I.timeout));try{g=!1,i.send(x,_)}catch(e){if(g)throw e;_(-1,e)}}else _(-1,"No Transport");function _(A,t,r,s){var c,d,u,x,Q,m=t;g||(g=!0,o&&e.clearTimeout(o),i=void 0,a=s||"",y.readyState=A>0?4:0,c=A>=200&&A<300||304===A,r&&(x=function(e,A,t){for(var i,n,a,r,o=e.contents,s=e.dataTypes;"*"===s[0];)s.shift(),void 0===i&&(i=e.mimeType||A.getResponseHeader("Content-Type"));if(i)for(n in o)if(o[n]&&o[n].test(i)){s.unshift(n);break}if(s[0]in t)a=s[0];else{for(n in t){if(!s[0]||e.converters[n+" "+s[0]]){a=n;break}r||(r=n)}a=a||r}if(a)return a!==s[0]&&s.unshift(a),t[a]}(I,y,r)),!c&&p.inArray("script",I.dataTypes)>-1&&p.inArray("json",I.dataTypes)<0&&(I.converters["text script"]=function(){}),x=function(e,A,t,i){var n,a,r,o,s,g={},l=e.dataTypes.slice();if(l[1])for(r in e.converters)g[r.toLowerCase()]=e.converters[r];for(a=l.shift();a;)if(e.responseFields[a]&&(t[e.responseFields[a]]=A),!s&&i&&e.dataFilter&&(A=e.dataFilter(A,e.dataType)),s=a,a=l.shift())if("*"===a)a=s;else if("*"!==s&&s!==a){if(!(r=g[s+" "+a]||g["* "+a]))for(n in g)if((o=n.split(" "))[1]===a&&(r=g[s+" "+o[0]]||g["* "+o[0]])){!0===r?r=g[n]:!0!==g[n]&&(a=o[0],l.unshift(o[1]));break}if(!0!==r)if(r&&e.throws)A=r(A);else try{A=r(A)}catch(e){return{state:"parsererror",error:r?e:"No conversion from "+s+" to "+a}}}return{state:"success",data:A}}(I,x,y,c),c?(I.ifModified&&((Q=y.getResponseHeader("Last-Modified"))&&(p.lastModified[n]=Q),(Q=y.getResponseHeader("etag"))&&(p.etag[n]=Q)),204===A||"HEAD"===I.type?m="nocontent":304===A?m="notmodified":(m=x.state,d=x.data,c=!(u=x.error))):(u=m,!A&&m||(m="error",A<0&&(A=0))),y.status=A,y.statusText=(t||m)+"",c?B.resolveWith(C,[d,m,y]):B.rejectWith(C,[y,m,u]),y.statusCode(E),E=void 0,l&&h.trigger(c?"ajaxSuccess":"ajaxError",[y,I,c?d:u]),f.fireWith(C,[y,m]),l&&(h.trigger("ajaxComplete",[y,I]),--p.active||p.event.trigger("ajaxStop")))}return y},getJSON:function(e,A,t){return p.get(e,A,t,"json")},getScript:function(e,A){return p.get(e,void 0,A,"script")}}),p.each(["get","post"],(function(e,A){p[A]=function(e,t,i,n){return C(t)&&(n=n||i,i=t,t=void 0),p.ajax(p.extend({url:e,type:A,dataType:n,data:t,success:i},p.isPlainObject(e)&&e))}})),p.ajaxPrefilter((function(e){var A;for(A in e.headers)"content-type"===A.toLowerCase()&&(e.contentType=e.headers[A]||"")})),p._evalUrl=function(e,A,t){return p.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){p.globalEval(e,A,t)}})},p.fn.extend({wrapAll:function(e){var A;return this[0]&&(C(e)&&(e=e.call(this[0])),A=p(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&A.insertBefore(this[0]),A.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return C(e)?this.each((function(A){p(this).wrapInner(e.call(this,A))})):this.each((function(){var A=p(this),t=A.contents();t.length?t.wrapAll(e):A.append(e)}))},wrap:function(e){var A=C(e);return this.each((function(t){p(this).wrapAll(A?e.call(this,t):e)}))},unwrap:function(e){return this.parent(e).not("body").each((function(){p(this).replaceWith(this.childNodes)})),this}}),p.expr.pseudos.hidden=function(e){return!p.expr.pseudos.visible(e)},p.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},p.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var XA={0:200,1223:204},qA=p.ajaxSettings.xhr();I.cors=!!qA&&"withCredentials"in qA,I.ajax=qA=!!qA,p.ajaxTransport((function(A){var t,i;if(I.cors||qA&&!A.crossDomain)return{send:function(n,a){var r,o=A.xhr();if(o.open(A.type,A.url,A.async,A.username,A.password),A.xhrFields)for(r in A.xhrFields)o[r]=A.xhrFields[r];for(r in A.mimeType&&o.overrideMimeType&&o.overrideMimeType(A.mimeType),A.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest"),n)o.setRequestHeader(r,n[r]);t=function(e){return function(){t&&(t=i=o.onload=o.onerror=o.onabort=o.ontimeout=o.onreadystatechange=null,"abort"===e?o.abort():"error"===e?"number"!=typeof o.status?a(0,"error"):a(o.status,o.statusText):a(XA[o.status]||o.status,o.statusText,"text"!==(o.responseType||"text")||"string"!=typeof o.responseText?{binary:o.response}:{text:o.responseText},o.getAllResponseHeaders()))}},o.onload=t(),i=o.onerror=o.ontimeout=t("error"),void 0!==o.onabort?o.onabort=i:o.onreadystatechange=function(){4===o.readyState&&e.setTimeout((function(){t&&i()}))},t=t("abort");try{o.send(A.hasContent&&A.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}})),p.ajaxPrefilter((function(e){e.crossDomain&&(e.contents.script=!1)})),p.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return p.globalEval(e),e}}}),p.ajaxPrefilter("script",(function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")})),p.ajaxTransport("script",(function(e){var A,t;if(e.crossDomain||e.scriptAttrs)return{send:function(i,n){A=p("