From ba3ec158eac26d4dd87d120fe2ae2231a3dfd326 Mon Sep 17 00:00:00 2001 From: jiaxu <> Date: Fri, 4 Nov 2022 17:38:18 +0800 Subject: [PATCH] release v4.1.9 --- API-Examples-Web/assets/qnweb-rtc.js | 2 +- Demo/package.json | 4 ++-- Release/qnweb-rtc.js | 2 +- ReleaseNotes/release-note-4.1.9.md | 13 +++++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 ReleaseNotes/release-note-4.1.9.md diff --git a/API-Examples-Web/assets/qnweb-rtc.js b/API-Examples-Web/assets/qnweb-rtc.js index f53faaf..c597972 100644 --- a/API-Examples-Web/assets/qnweb-rtc.js +++ b/API-Examples-Web/assets/qnweb-rtc.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).QNRTC=t()}(this,function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};var t=function(t){for(var r=1;r)?=?)";var _=s++;o[_]=o[d]+"|x|X|\\*";var w=s++;o[w]=o[c]+"|x|X|\\*";var E=s++;o[E]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var C=s++;o[C]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var I=s++;o[I]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var R=s++;o[R]="(?:~>?)";var D=s++;o[D]="(\\s*)"+o[R]+"\\s+",a[D]=new RegExp(o[D],"g");var O=s++;o[O]="^"+o[R]+o[E]+"$";var x=s++;o[x]="^"+o[R]+o[C]+"$";var B=s++;o[B]="(?:\\^)";var L=s++;o[L]="(\\s*)"+o[B]+"\\s+",a[L]=new RegExp(o[L],"g");var G=s++;o[G]="^"+o[B]+o[E]+"$";var N=s++;o[N]="^"+o[B]+o[C]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var F=s++;o[F]="^"+o[k]+"\\s*("+b+")$|^$";var j=s++;o[j]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[E]+")",a[j]=new RegExp(o[j],"g");var V=s++;o[V]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="(<|>)?=?\\s*\\*";for(var W=0;W<35;W++)r(W,o[W]),a[W]||(a[W]=new RegExp(o[W]));function z(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X)return e;if("string"!=typeof e)return null;if(e.length>n)return null;if(!(t.loose?a[y]:a[T]).test(e))return null;try{return new X(e,t)}catch(e){return null}}function X(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>n)throw new TypeError("version is longer than "+n+" characters");if(!(this instanceof X))return new X(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var o=e.trim().match(t.loose?a[y]:a[T]);if(!o)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+o[1],this.minor=+o[2],this.patch=+o[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");o[4]?this.prerelease=o[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new X(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(Y(e,t))return null;var r=z(e),n=z(t);if(r.prerelease.length||n.prerelease.length){for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return"pre"+i;return"prerelease"}for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return i},t.compareIdentifiers=Q;var K=/^[0-9]+$/;function Q(e,t){var r=K.test(e),n=K.test(t);return r&&n&&(e=+e,t=+t),r&&!n?-1:n&&!r?1:et?1:0}function J(e,t,r){return new X(e,r).compare(new X(t,r))}function Z(e,t,r){return J(e,t,r)>0}function $(e,t,r){return J(e,t,r)<0}function Y(e,t,r){return 0===J(e,t,r)}function ee(e,t,r){return 0!==J(e,t,r)}function te(e,t,r){return J(e,t,r)>=0}function re(e,t,r){return J(e,t,r)<=0}function ne(e,t,r,n){var i;switch(t){case"===":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e===r;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e!==r;break;case"":case"=":case"==":i=Y(e,r,n);break;case"!=":i=ee(e,r,n);break;case">":i=Z(e,r,n);break;case">=":i=te(e,r,n);break;case"<":i=$(e,r,n);break;case"<=":i=re(e,r,n);break;default:throw new TypeError("Invalid operator: "+t)}return i}function ie(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ie){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ie))return new ie(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ae?this.value="":this.value=this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){return Q(t,e)},t.major=function(e,t){return new X(e,t).major},t.minor=function(e,t){return new X(e,t).minor},t.patch=function(e,t){return new X(e,t).patch},t.compare=J,t.compareLoose=function(e,t){return J(e,t,!0)},t.rcompare=function(e,t,r){return J(t,e,r)},t.sort=function(e,r){return e.sort(function(e,n){return t.compare(e,n,r)})},t.rsort=function(e,r){return e.sort(function(e,n){return t.rcompare(e,n,r)})},t.gt=Z,t.lt=$,t.eq=Y,t.neq=ee,t.gte=te,t.lte=re,t.cmp=ne,t.Comparator=ie;var ae={};function oe(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof oe)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new oe(e.raw,t);if(e instanceof ie)return new oe(e.value,t);if(!(this instanceof oe))return new oe(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function se(e){return!e||"x"===e.toLowerCase()||"*"===e}function ce(e,t,r,n,i,a,o,s,c,d,u,l,A){return((t=se(r)?"":se(n)?">="+r+".0.0":se(i)?">="+r+"."+n+".0":">="+t)+" "+(s=se(c)?"":se(d)?"<"+(+c+1)+".0.0":se(u)?"<"+c+"."+(+d+1)+".0":l?"<="+c+"."+d+"."+u+"-"+l:"<="+s)).trim()}function de(e,t,n){for(var i=0;i0){var a=e[i].semver;if(a.major===t.major&&a.minor===t.minor&&a.patch===t.patch)return!0}return!1}return!0}function ue(e,t,r){try{t=new oe(t,r)}catch(e){return!1}return t.test(e)}function le(e,t,r,n){var i,a,o,s,c;switch(e=new X(e,n),t=new oe(t,n),r){case">":i=Z,a=re,o=$,s=">",c=">=";break;case"<":i=$,a=te,o=Z,s="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ue(e,t,n))return!1;for(var d=0;d=0.0.0")),l=l||e,A=A||e,i(e.semver,l.semver,n)?l=e:o(e.semver,A.semver,n)&&(A=e)}),l.operator===s||l.operator===c)return!1;if((!A.operator||A.operator===s)&&a(e,A.semver))return!1;if(A.operator===c&&o(e,A.semver))return!1}return!0}ie.prototype.parse=function(e){var t=this.options.loose?a[H]:a[F],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new X(r[2],this.options.loose):this.semver=ae},ie.prototype.toString=function(){return this.value},ie.prototype.test=function(e){return r("Comparator.test",e,this.options.loose),this.semver===ae||("string"==typeof e&&(e=new X(e,this.options)),ne(e,this.operator,this.semver,this.options))},ie.prototype.intersects=function(e,t){if(!(e instanceof ie))throw new TypeError("a Comparator is required");var r;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return r=new oe(e.value,t),ue(this.value,r,t);if(""===e.operator)return r=new oe(this.value,t),ue(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),a=this.semver.version===e.semver.version,o=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),s=ne(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),c=ne(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||a&&o||s||c},t.Range=oe,oe.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},oe.prototype.toString=function(){return this.range},oe.prototype.parseRange=function(e){var t=this.options.loose;e=e.trim();var n=t?a[U]:a[V];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[j],"$1$2$3"),r("comparator trim",e,a[j]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[F],o=e.split(" ").map(function(e){return function(e,t){return r("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){r("caret",e,t),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[N]:a[G];return e.replace(n,function(t,n,i,a,o){var s;return r("caret",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s="0"===n?">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":">="+n+"."+i+".0 <"+(+n+1)+".0.0":o?(r("replaceCaret pr",o),"-"!==o.charAt(0)&&(o="-"+o),s="0"===n?"0"===i?">="+n+"."+i+"."+a+o+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+o+" <"+(+n+1)+".0.0"):(r("no pr"),s="0"===n?"0"===i?">="+n+"."+i+"."+a+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+" <"+(+n+1)+".0.0"),r("caret return",s),s})}(e,t)}).join(" ")}(e,t),r("caret",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[x]:a[O];return e.replace(n,function(t,n,i,a,o){var s;return r("tilde",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":o?(r("replaceTilde pr",o),"-"!==o.charAt(0)&&(o="-"+o),s=">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0"):s=">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0",r("tilde return",s),s})}(e,t)}).join(" ")}(e,t),r("tildes",e),e=function(e,t){return r("replaceXRanges",e,t),e.split(/\s+/).map(function(e){return function(e,t){e=e.trim(),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[P]:a[M];return e.replace(n,function(t,n,i,a,o,s){r("xRange",e,t,n,i,a,o,s);var c=se(i),d=c||se(a),u=d||se(o),l=u;return"="===n&&l&&(n=""),c?t=">"===n||"<"===n?"<0.0.0":"*":n&&l?(d&&(a=0),u&&(o=0),">"===n?(n=">=",d?(i=+i+1,a=0,o=0):u&&(a=+a+1,o=0)):"<="===n&&(n="<",d?i=+i+1:a=+a+1),t=n+i+"."+a+"."+o):d?t=">="+i+".0.0 <"+(+i+1)+".0.0":u&&(t=">="+i+"."+a+".0 <"+i+"."+(+a+1)+".0"),r("xRange return",t),t})}(e,t)}).join(" ")}(e,t),r("xrange",e),e=function(e,t){return r("replaceStars",e,t),e.trim().replace(a[q],"")}(e,t),r("stars",e),e}(e,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(o=o.filter(function(e){return!!e.match(i)})),o=o.map(function(e){return new ie(e,this.options)},this)},oe.prototype.intersects=function(e,t){if(!(e instanceof oe))throw new TypeError("a Range is required");return this.set.some(function(r){return r.every(function(r){return e.set.some(function(e){return e.every(function(e){return r.intersects(e,t)})})})})},t.toComparators=function(e,t){return new oe(e,t).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},oe.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new X(e,this.options));for(var t=0;t",r)},t.outside=le,t.prerelease=function(e,t){var r=z(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new oe(e,r),t=new oe(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof X)return e;if("string"!=typeof e)return null;var t=e.match(a[I]);return null==t?null:z((t[1]||"0")+"."+(t[2]||"0")+"."+(t[3]||"0"))}}),A=(l.SEMVER_SPEC_VERSION,l.re,l.src,l.parse,l.valid,l.clean,l.SemVer,l.inc,l.diff,l.compareIdentifiers,l.rcompareIdentifiers,l.major,l.minor,l.patch,l.compare,l.compareLoose,l.rcompare,l.sort,l.rsort,l.gt),h=l.lt,f=(l.eq,l.neq,l.gte),p=l.lte,m=(l.cmp,l.Comparator,l.Range,l.toComparators,l.satisfies,l.maxSatisfying,l.minSatisfying,l.validRange,l.ltr,l.gtr,l.outside,l.prerelease,l.intersects,l.coerce,u(function(e){(function(t){if(e.exports)return function(t){e.exports=t()};if("undefined"!=typeof window)return function(e){window.MobileDetect=e()};throw new Error("unknown environment")})()(function(){var e,t={mobileDetectRules:{phones:{iPhone:"\\biPhone\\b|\\biPod\\b",BlackBerry:"BlackBerry|\\bBB10\\b|rim[0-9]+|\\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\\b-[0-9]+",Pixel:"; \\bPixel\\b",HTC:"HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel",Nexus:"Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 5X|Nexus 6",Dell:"Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b",Motorola:"Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b|XT1068|XT1092|XT1052",Samsung:"\\bSamsung\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F|SM-G610F|SM-G981B|SM-G892A|SM-A530F",LG:"\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710",Sony:"SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533|SOV34|601SO|F8332",Asus:"Asus.*Galaxy|PadFone.*Mobile",Xiaomi:"^(?!.*\\bx11\\b).*xiaomi.*$|POCOPHONE F1|MI 8|Redmi Note 9S|Redmi Note 5A Prime|N2G47H|M2001J2G|M2001J2I|M1805E10A|M2004J11G|M1902F1G|M2002J9G|M2004J19G|M2003J6A1G",NokiaLumia:"Lumia [0-9]{3,4}",Micromax:"Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b",Palm:"PalmSource|Palm",Vertu:"Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature",Pantech:"PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790",Fly:"IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250",Wiko:"KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM",iMobile:"i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)",SimValley:"\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b",Wolfgang:"AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q",Alcatel:"Alcatel",Nintendo:"Nintendo (3DS|Switch)",Amoi:"Amoi",INQ:"INQ",OnePlus:"ONEPLUS",GenericPhone:"Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser"},tablets:{iPad:"iPad|iPad.*Mobile",NexusTablet:"Android.*Nexus[\\s]+(7|9|10)",GoogleTablet:"Android.*Pixel C",SamsungTablet:"SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V|SM-P610|SM-T290|SM-T515|SM-T590|SM-T595|SM-T725|SM-T817P|SM-P585N0|SM-T395|SM-T295|SM-T865|SM-P610N|SM-P615|SM-T970|SM-T380|SM-T5950|SM-T905|SM-T231|SM-T500|SM-T860",Kindle:"Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)",SurfaceTablet:"Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)",HPTablet:"HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10",AsusTablet:"^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\bP027\\b|\\bP024\\b|\\bP00C\\b",BlackBerryTablet:"PlayBook|RIM Tablet",HTCtablet:"HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410",MotorolaTablet:"xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617",NookTablet:"Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2",AcerTablet:"Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20\\b|\\bA3-A30|A3-A40",ToshibaTablet:"Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO",LGTablet:"\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b",FujitsuTablet:"Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b",PrestigioTablet:"PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002",LenovoTablet:"Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X|TB-X704F|TB-X104F|TB3-X70F|TB-X705F|TB-8504F|TB3-X70L|TB3-710F|TB-X704L",DellTablet:"Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7",YarvikTablet:"Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b",MedionTablet:"Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB",ArnovaTablet:"97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2",IntensoTablet:"INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004",IRUTablet:"M702pro",MegafonTablet:"MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b",EbodaTablet:"E-Boda (Supreme|Impresspeed|Izzycomm|Essential)",AllViewTablet:"Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)",ArchosTablet:"\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b",AinolTablet:"NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark",NokiaLumiaTablet:"Lumia 2520",SonyTablet:"Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712",PhilipsTablet:"\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b",CubeTablet:"Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT",CobyTablet:"MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010",MIDTablet:"M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10",MSITablet:"MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b",SMiTTablet:"Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)",RockChipTablet:"Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A",FlyTablet:"IQ310|Fly Vision",bqTablet:"Android.*(bq)?.*\\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\\b|Maxwell.*Lite|Maxwell.*Plus",HuaweiTablet:"MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19",NecTablet:"\\bN-06D|\\bN-08D",PantechTablet:"Pantech.*P4100",BronchoTablet:"Broncho.*(N701|N708|N802|a710)",VersusTablet:"TOUCHPAD.*[78910]|\\bTOUCHTAB\\b",ZyncTablet:"z1000|Z99 2G|z930|z990|z909|Z919|z900",PositivoTablet:"TB07STA|TB10STA|TB07FTA|TB10FTA",NabiTablet:"Android.*\\bNabi",KoboTablet:"Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build",DanewTablet:"DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b",TexetTablet:"NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE",PlaystationTablet:"Playstation.*(Portable|Vita)",TrekstorTablet:"ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab",PyleAudioTablet:"\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b",AdvanTablet:"Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ",DanyTechTablet:"Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1",GalapadTablet:"Android [0-9.]+; [a-z-]+; \\bG1\\b",MicromaxTablet:"Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b",KarbonnTablet:"Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b",AllFineTablet:"Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide",PROSCANTablet:"\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b",YONESTablet:"BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026",ChangJiaTablet:"TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503",GUTablet:"TX-A1301|TX-M9002|Q702|kf026",PointOfViewTablet:"TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10",OvermaxTablet:"OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027",HCLTablet:"HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync",DPSTablet:"DPS Dream 9|DPS Dual 7",VistureTablet:"V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10",CrestaTablet:"CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989",MediatekTablet:"\\bMT8125|MT8389|MT8135|MT8377\\b",ConcordeTablet:"Concorde([ ]+)?Tab|ConCorde ReadMan",GoCleverTablet:"GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042",ModecomTablet:"FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003",VoninoTablet:"\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b",ECSTablet:"V07OT2|TM105A|S10OT1|TR10CS1",StorexTablet:"eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab",VodafoneTablet:"SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400",EssentielBTablet:"Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2",RossMoorTablet:"RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711",iMobileTablet:"i-mobile i-note",TolinoTablet:"tolino tab [0-9.]+|tolino shine",AudioSonicTablet:"\\bC-22Q|T7-QC|T-17B|T-17P\\b",AMPETablet:"Android.* A78 ",SkkTablet:"Android.* (SKYPAD|PHOENIX|CYCLOPS)",TecnoTablet:"TECNO P9|TECNO DP8D",JXDTablet:"Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b",iJoyTablet:"Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)",FX2Tablet:"FX2 PAD7|FX2 PAD10",XoroTablet:"KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151",ViewsonicTablet:"ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a",VerizonTablet:"QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1",OdysTablet:"LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10",CaptivaTablet:"CAPTIVA PAD",IconbitTablet:"NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S",TeclastTablet:"T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi",OndaTablet:"\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+|V10 \\b4G\\b",JaytechTablet:"TPC-PA762",BlaupunktTablet:"Endeavour 800NG|Endeavour 1010",DigmaTablet:"\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b",EvolioTablet:"ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b",LavaTablet:"QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b",AocTablet:"MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712",MpmanTablet:"MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010",CelkonTablet:"CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b",WolderTablet:"miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b",MediacomTablet:"M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA",MiTablet:"\\bMI PAD\\b|\\bHM NOTE 1W\\b",NibiruTablet:"Nibiru M1|Nibiru Jupiter One",NexoTablet:"NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI",LeaderTablet:"TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100",UbislateTablet:"UbiSlate[\\s]?7C",PocketBookTablet:"Pocketbook",KocasoTablet:"\\b(TB-1207)\\b",HisenseTablet:"\\b(F5281|E2371)\\b",Hudl:"Hudl HT7S3|Hudl 2",TelstraTablet:"T-Hub2",GenericTablet:"Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bTP750\\b|\\bQTAQZ3\\b|WVT101|TM1088|KT107"},oss:{AndroidOS:"Android",BlackBerryOS:"blackberry|\\bBB10\\b|rim tablet os",PalmOS:"PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino",SymbianOS:"Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b",WindowsMobileOS:"Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;",WindowsPhoneOS:"Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;",iOS:"\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia",iPadOS:"CPU OS 13",SailfishOS:"Sailfish",MeeGoOS:"MeeGo",MaemoOS:"Maemo",JavaOS:"J2ME/|\\bMIDP\\b|\\bCLDC\\b",webOS:"webOS|hpwOS",badaOS:"\\bBada\\b",BREWOS:"BREW"},uas:{Chrome:"\\bCrMo\\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?",Dolfin:"\\bDolfin\\b",Opera:"Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+$|Coast/[0-9.]+",Skyfire:"Skyfire",Edge:"\\bEdgiOS\\b|Mobile Safari/[.0-9]* Edge",IE:"IEMobile|MSIEMobile",Firefox:"fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS",Bolt:"bolt",TeaShark:"teashark",Blazer:"Blazer",Safari:"Version((?!\\bEdgiOS\\b).)*Mobile.*Safari|Safari.*Mobile|MobileSafari",WeChat:"\\bMicroMessenger\\b",UCBrowser:"UC.*Browser|UCWEB",baiduboxapp:"baiduboxapp",baidubrowser:"baidubrowser",DiigoBrowser:"DiigoBrowser",Mercury:"\\bMercury\\b",ObigoBrowser:"Obigo",NetFront:"NF-Browser",GenericBrowser:"NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger",PaleMoon:"Android.*PaleMoon|Mobile.*PaleMoon"},props:{Mobile:"Mobile/[VER]",Build:"Build/[VER]",Version:"Version/[VER]",VendorID:"VendorID/[VER]",iPad:"iPad.*CPU[a-z ]+[VER]",iPhone:"iPhone.*CPU[a-z ]+[VER]",iPod:"iPod.*CPU[a-z ]+[VER]",Kindle:"Kindle/[VER]",Chrome:["Chrome/[VER]","CriOS/[VER]","CrMo/[VER]"],Coast:["Coast/[VER]"],Dolfin:"Dolfin/[VER]",Firefox:["Firefox/[VER]","FxiOS/[VER]"],Fennec:"Fennec/[VER]",Edge:"Edge/[VER]",IE:["IEMobile/[VER];","IEMobile [VER]","MSIE [VER];","Trident/[0-9.]+;.*rv:[VER]"],NetFront:"NetFront/[VER]",NokiaBrowser:"NokiaBrowser/[VER]",Opera:[" OPR/[VER]","Opera Mini/[VER]","Version/[VER]"],"Opera Mini":"Opera Mini/[VER]","Opera Mobi":"Version/[VER]",UCBrowser:["UCWEB[VER]","UC.*Browser/[VER]"],MQQBrowser:"MQQBrowser/[VER]",MicroMessenger:"MicroMessenger/[VER]",baiduboxapp:"baiduboxapp/[VER]",baidubrowser:"baidubrowser/[VER]",SamsungBrowser:"SamsungBrowser/[VER]",Iron:"Iron/[VER]",Safari:["Version/[VER]","Safari/[VER]"],Skyfire:"Skyfire/[VER]",Tizen:"Tizen/[VER]",Webkit:"webkit[ /][VER]",PaleMoon:"PaleMoon/[VER]",SailfishBrowser:"SailfishBrowser/[VER]",Gecko:"Gecko/[VER]",Trident:"Trident/[VER]",Presto:"Presto/[VER]",Goanna:"Goanna/[VER]",iOS:" \\bi?OS\\b [VER][ ;]{1}",Android:"Android [VER]",Sailfish:"Sailfish [VER]",BlackBerry:["BlackBerry[\\w]+/[VER]","BlackBerry.*Version/[VER]","Version/[VER]"],BREW:"BREW [VER]",Java:"Java/[VER]","Windows Phone OS":["Windows Phone OS [VER]","Windows Phone [VER]"],"Windows Phone":"Windows Phone [VER]","Windows CE":"Windows CE/[VER]","Windows NT":"Windows NT [VER]",Symbian:["SymbianOS/[VER]","Symbian/[VER]"],webOS:["webOS/[VER]","hpwOS/[VER];"]},utils:{Bot:"Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp|AspiegelBot",MobileBot:"Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2",DesktopMode:"WPDesktop",TV:"SonyDTV|HbbTV",WebKit:"(webkit)[ /]([\\w.]+)",Console:"\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\\b",Watch:"SM-V700"}},detectMobileBrowsers:{fullPattern:/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i,shortPattern:/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,tabletPattern:/android|ipad|playbook|silk/i}},r=Object.prototype.hasOwnProperty;function n(e,t){return null!=e&&null!=t&&e.toLowerCase()===t.toLowerCase()}function i(e,t){var r,n,i=e.length;if(!i||!t)return!1;for(r=t.toLowerCase(),n=0;n=0&&(o=o.substring(0,d)+"([\\w._\\+]+)"+o.substring(d+5)),i[s]=new RegExp(o,"i");u.props[n]=i}a(u.oss),a(u.phones),a(u.tablets),a(u.uas),a(u.utils),u.oss0={WindowsPhoneOS:u.oss.WindowsPhoneOS,WindowsMobileOS:u.oss.WindowsMobileOS}}(),t.findMatch=function(e,t){for(var n in e)if(r.call(e,n)&&e[n].test(t))return n;return null},t.findMatches=function(e,t){var n=[];for(var i in e)r.call(e,i)&&e[i].test(t)&&n.push(i);return n},t.getVersionStr=function(e,n){var i,a,o,s,c=t.mobileDetectRules.props;if(r.call(c,e))for(o=(i=c[e]).length,a=0;a1&&(e=t[0]+".",t.shift(),e+=t.join("")),Number(e)},t.isMobileFallback=function(e){return t.detectMobileBrowsers.fullPattern.test(e)||t.detectMobileBrowsers.shortPattern.test(e.substr(0,4))},t.isTabletFallback=function(e){return t.detectMobileBrowsers.tabletPattern.test(e)},t.prepareDetectionCache=function(e,r,n){if(void 0===e.mobile){var i,a,s;if(a=t.findMatch(t.mobileDetectRules.tablets,r))return e.mobile=e.tablet=a,void(e.phone=null);if(i=t.findMatch(t.mobileDetectRules.phones,r))return e.mobile=e.phone=i,void(e.tablet=null);t.isMobileFallback(r)?void 0===(s=o.isPhoneSized(n))?(e.mobile=t.FALLBACK_MOBILE,e.tablet=e.phone=null):s?(e.mobile=e.phone=t.FALLBACK_PHONE,e.tablet=null):(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):t.isTabletFallback(r)?(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):e.mobile=e.tablet=e.phone=null}},t.mobileGrade=function(e){var t=null!==e.mobile();return e.os("iOS")&&e.version("iPad")>=4.3||e.os("iOS")&&e.version("iPhone")>=3.1||e.os("iOS")&&e.version("iPod")>=3.1||e.version("Android")>2.1&&e.is("Webkit")||e.version("Windows Phone OS")>=7||e.is("BlackBerry")&&e.version("BlackBerry")>=6||e.match("Playbook.*Tablet")||e.version("webOS")>=1.4&&e.match("Palm|Pre|Pixi")||e.match("hp.*TouchPad")||e.is("Firefox")&&e.version("Firefox")>=12||e.is("Chrome")&&e.is("AndroidOS")&&e.version("Android")>=4||e.is("Skyfire")&&e.version("Skyfire")>=4.1&&e.is("AndroidOS")&&e.version("Android")>=2.3||e.is("Opera")&&e.version("Opera Mobi")>11&&e.is("AndroidOS")||e.is("MeeGoOS")||e.is("Tizen")||e.is("Dolfin")&&e.version("Bada")>=2||(e.is("UC Browser")||e.is("Dolfin"))&&e.version("Android")>=2.3||e.match("Kindle Fire")||e.is("Kindle")&&e.version("Kindle")>=3||e.is("AndroidOS")&&e.is("NookTablet")||e.version("Chrome")>=11&&!t||e.version("Safari")>=5&&!t||e.version("Firefox")>=4&&!t||e.version("MSIE")>=7&&!t||e.version("Opera")>=10&&!t?"A":e.os("iOS")&&e.version("iPad")<4.3||e.os("iOS")&&e.version("iPhone")<3.1||e.os("iOS")&&e.version("iPod")<3.1||e.is("Blackberry")&&e.version("BlackBerry")>=5&&e.version("BlackBerry")<6||e.version("Opera Mini")>=5&&e.version("Opera Mini")<=6.5&&(e.version("Android")>=2.3||e.is("iOS"))||e.match("NokiaN8|NokiaC7|N97.*Series60|Symbian/3")||e.version("Opera Mobi")>=11&&e.is("SymbianOS")?"B":(e.version("BlackBerry")<5||e.match("MSIEMobile|Windows CE.*Mobile")||e.version("Windows Mobile"),"C")},t.detectOS=function(e){return t.findMatch(t.mobileDetectRules.oss0,e)||t.findMatch(t.mobileDetectRules.oss,e)},t.getDeviceSmallerSide=function(){return window.screen.width-1,v=!!window.chrome,T=navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i),b=function(){const e=s();if(!navigator||!navigator.appVersion||!e)return e;const r=/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/.exec(window.navigator.appVersion);return r&&r[1]?t({},e,{chromeVersion:r[1]}):e}()||{},S=!!new m(navigator.userAgent).mobile(),y=navigator.userAgent.toLowerCase().indexOf("electron")>-1;function k(){try{return!!window&&("RTCPeerConnection"in window&&("WebSocket"in window&&(!!navigator&&(!!navigator.mediaDevices&&!!navigator.mediaDevices.getUserMedia))))}catch(e){return!1}}function _(){const e=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia,t=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getSupportedConstraints&&navigator.mediaDevices.getSupportedConstraints().displaySurface;return g?!!e&&!!t:!!e}function w(){return"createMediaStreamDestination"in(window.AudioContext||window.webkitAudioContext||window.Object).prototype}const E=function(){if(!b)return{support:k(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0};switch(b.name){case"chrome":return{support:k(),mediaStreamDest:f(b.version,"55.0.0"),replaceTrack:f(b.version,"65.0.0"),screenSharing:f(b.version,"55.0.0"),connectionState:f(b.version,"72.0.0"),stats:f(b.version,"67.0.0"),ondevicechange:f(b.version,"57.0.0"),minMaxWithIdeal:f(b.version,"56.0.0"),supportTransceivers:f(b.version,"69.0.0"),unifiedPlan:f(b.version,"72.0.0"),supportRestartICE:!0,getReceivers:f(b.version,"59.0.0"),needH264FmtpLine:p(b.version,"51.0.0"),audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!0,setPlaybackDevice:!0};case"ios":case"safari":return{support:k(),replaceTrack:f(b.version,"11.0.0"),stats:!1,ondevicechange:!1,connectionState:!0,mediaStreamDest:f(b.version,"12.0.0"),screenSharing:f(b.version,"13.0.0"),unifiedPlan:f(b.version,"12.1.0"),supportTransceivers:!0,minMaxWithIdeal:!1,supportRestartICE:!0,getReceivers:!0,audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!1};case"firefox":return{support:k(),replaceTrack:!0,stats:!0,ondevicechange:f(b.version,"52.0.0"),connectionState:!0,mediaStreamDest:!0,screenSharing:!0,minMaxWithIdeal:!0,unifiedPlan:!0,supportTransceivers:f(b.version,"59.0.0"),supportRestartICE:!1,getReceivers:!0,audioContextOptions:f(b.version,"55.0.0"),getDisplayMedia:_(),disconnectAudioNode:!0};case"crios":case"ios-webview":return{support:k(),getDisplayMedia:_(),mediaStreamDest:w(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),mediaStreamDest:w(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0}}}();"chrome"===b.name&&function(){const e=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),(e={})[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(e){return new Promise((t,r)=>{navigator.getUserMedia(e,t,r)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:t,enumerateDevices:()=>new Promise(e=>{const t={audio:"audioinput",video:"videoinput"};return window.MediaStreamTrack.getSources(r=>{e(r.map(e=>({label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""})))})})}),navigator.mediaDevices.getSupportedConstraints||(navigator.mediaDevices.getSupportedConstraints=(()=>({deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}))),navigator.mediaDevices.getUserMedia){const t=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(r){return function(t,r){if(A(b.version,"61.0.0"))return r(t);if((t=JSON.parse(JSON.stringify(t)))&&"object"==typeof t.audio){const r=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};r((t=JSON.parse(JSON.stringify(t))).audio,"autoGainControl","googAutoGainControl"),r(t.audio,"noiseSuppression","googNoiseSuppression"),t.audio=e(t.audio)}if(t&&"object"==typeof t.video){let n=t.video.facingMode;n=n&&("object"==typeof n?n:{ideal:n});const i=h(b.version,"66.0.0");if(n&&("user"===n.exact||"environment"===n.exact||"user"===n.ideal||"environment"===n.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode||i)){delete t.video.facingMode;let i=void 0;if("environment"===n.exact||"environment"===n.ideal?i=["back","rear"]:"user"!==n.exact&&"user"!==n.ideal||(i=["front"]),i)return navigator.mediaDevices.enumerateDevices().then(a=>{let o=(a=a.filter(e=>"videoinput"===e.kind)).find(e=>i.some(t=>e.label.toLowerCase().includes(t)));return!o&&a.length&&i.includes("back")&&(o=a[a.length-1]),o&&(t.video.deviceId=n.exact?{exact:o.deviceId}:{ideal:o.deviceId}),t.video=e(t.video),r(t)})}t.video=e(t.video)}return r(t)}(r,e=>t(e).then(t=>{if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return t},e=>Promise.reject(e)))}}else navigator.mediaDevices.getUserMedia=function(e){return t(e)}}(),"firefox"===b.name&&function(){const e=function(e){return new Promise((t,r)=>{!function(e,t,r){e=JSON.parse(JSON.stringify(e)),navigator.mozGetUserMedia(e,t,e=>{r(e)})}(e,t,r)})};navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:e,addEventListener(){},removeEventListener(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise(e=>{e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})}}();var C=u(function(e){!function(t){function r(){}var n=r.prototype,i=t.EventEmitter;function a(e,t){for(var r=e.length;r--;)if(e[r].listener===t)return r;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}n.getListeners=function(e){var t,r,n=this._getEvents();if(e instanceof RegExp)for(r in t={},n)n.hasOwnProperty(r)&&e.test(r)&&(t[r]=n[r]);else t=n[e]||(n[e]=[]);return t},n.flattenListeners=function(e){var t,r=[];for(t=0;td))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ee:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Pe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},we.prototype.clear=function(){this.__data__={hash:new ke,map:new(ue||_e),string:new ke}},we.prototype.delete=function(e){return Ne(this,e).delete(e)},we.prototype.get=function(e){return Ne(this,e).get(e)},we.prototype.has=function(e){return Ne(this,e).has(e)},we.prototype.set=function(e,t){return Ne(this,e).set(e,t),this},Ee.prototype.add=Ee.prototype.push=function(e){return this.__data__.set(e,i),this},Ee.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.clear=function(){this.__data__=new _e},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var n=this.__data__;if(n instanceof _e){var i=n.__data__;if(!ue||i.length-1&&e%1==0&&ei?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var a=Array(i);++n-1&&e%1==0&&e<=d}function nt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function it(e){return!!e&&"object"==typeof e}function at(e){return"symbol"==typeof e||it(e)&&re.call(e)==k}var ot=j?function(e){return function(t){return e(t)}}(j):function(e){return it(e)&&rt(e.length)&&!!O[re.call(e)]};function st(e){return et(e)?Me(e):Be(e)}function ct(e){return e}e.exports=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],a=e.length;for(t=xe(t);++n!!e&&!!e.audio&&e.audio.enabled,I=e=>!!e&&!!e.video&&e.video.enabled,R=e=>!!e&&!!e.screen&&e.screen.enabled;var D,O,x,B,L;function G(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(D||(D={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(O||(O={})),function(e){e[e.INVALID=-1]="INVALID",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.FAIR=3]="FAIR",e[e.POOR=4]="POOR"}(x||(x={})),function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connect=2]="Connect"}(B||(B={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(L||(L={}));const N={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var H;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.STOP="stop",e.END="end"}(H||(H={}));const F={Init:1,UnInit:2,JoinRoom:3,MCSAuth:4,SignalAuth:5,LeaveRoom:6,PublisherPC:7,PublishTracks:8,UnPublishTracks:9,SubscriberPC:10,SubscribeTracks:11,UnSubscribeTracks:13,MuteTracks:14,ICEConnectionState:15,CallbackStatistics:16,KickoutUser:17,RoomStateChanged:18,AudioDeviceInOut:19,VideoDeviceInOut:20,SDKError:21,ApplicationState:22,CreateMergeJob:24,UpdateMergeTracks:25,StopMerge:26,AuthorizationStatus:27,DeviceChanged:28,DefaultSetting:29,MediaStatistics:30,AbnormalDisconnect:31,CreateForwardJob:36,StopForwardJob:37,WebsocketConnect:40,NetworkChange:46,SystemRequirementsTest:47,AutoplayFail:49,TrackEnded:50,WebSDKException:51,VideoPlayQuality:53,AudioPlayQuality:54,JoinRoomResult:55,SetClientRole:56,StartMediaRelay:57,UpdateMediaRelay:58,StopMediaRelay:59,MCURelayAuth:60};var j=u(function(e){var t,r;t=c,r=function(){var e=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},t=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},r=function(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])},n=function(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=t(e,[4283543511,3981806797]),e=i(e,[0,e[0]>>>1]),e=t(e,[3301882366,444984403]),e=i(e,[0,e[0]>>>1])},o=function(o,s){s=s||0;for(var c=(o=o||"").length%16,d=o.length-c,u=[0,s],l=[0,s],A=[0,0],h=[0,0],f=[2277735313,289559509],p=[1291169091,658871167],m=0;m>>0).toString(16)).slice(-8)+("00000000"+(u[1]>>>0).toString(16)).slice(-8)+("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)},s={preprocessor:null,audio:{timeout:1e3,excludeIOS11:!0},fonts:{swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",userDefinedFonts:[],extendedJsFonts:!1},screen:{detectScreenOrientation:!0},plugins:{sortPluginsFor:[/palemoon/i],excludeIE:!1},extraComponents:[],excludes:{enumerateDevices:!0,pixelRatio:!0,doNotTrack:!0,fontsFlash:!0},NOT_AVAILABLE:"not available",ERROR:"error",EXCLUDED:"excluded"},c=function(e,t){if(Array.prototype.forEach&&e.forEach===Array.prototype.forEach)e.forEach(t);else if(e.length===+e.length)for(var r=0,n=e.length;rt.name?1:e.name=0?"Windows Phone":t.indexOf("win")>=0?"Windows":t.indexOf("android")>=0?"Android":t.indexOf("linux")>=0?"Linux":t.indexOf("iphone")>=0||t.indexOf("ipad")>=0?"iOS":t.indexOf("mac")>=0?"Mac":"Other",("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)&&"Windows Phone"!==e&&"Android"!==e&&"iOS"!==e&&"Other"!==e)return!0;if(void 0!==r){if((r=r.toLowerCase()).indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e)return!0;if(r.indexOf("linux")>=0&&"Linux"!==e&&"Android"!==e)return!0;if(r.indexOf("mac")>=0&&"Mac"!==e&&"iOS"!==e)return!0;if((-1===r.indexOf("win")&&-1===r.indexOf("linux")&&-1===r.indexOf("mac"))!=("Other"===e))return!0}return n.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e||((n.indexOf("linux")>=0||n.indexOf("android")>=0||n.indexOf("pike")>=0)&&"Linux"!==e&&"Android"!==e||((n.indexOf("mac")>=0||n.indexOf("ipad")>=0||n.indexOf("ipod")>=0||n.indexOf("iphone")>=0)&&"Mac"!==e&&"iOS"!==e||((-1===n.indexOf("win")&&-1===n.indexOf("linux")&&-1===n.indexOf("mac"))!=("Other"===e)||void 0===navigator.plugins&&"Windows"!==e&&"Windows Phone"!==e)))},R=function(){var e,t=navigator.userAgent.toLowerCase(),r=navigator.productSub;if(("Chrome"===(e=t.indexOf("firefox")>=0?"Firefox":t.indexOf("opera")>=0||t.indexOf("opr")>=0?"Opera":t.indexOf("chrome")>=0?"Chrome":t.indexOf("safari")>=0?"Safari":t.indexOf("trident")>=0?"Internet Explorer":"Other")||"Safari"===e||"Opera"===e)&&"20030107"!==r)return!0;var n,i=eval.toString().length;if(37===i&&"Safari"!==e&&"Firefox"!==e&&"Other"!==e)return!0;if(39===i&&"Internet Explorer"!==e&&"Other"!==e)return!0;if(33===i&&"Chrome"!==e&&"Opera"!==e&&"Other"!==e)return!0;try{throw"a"}catch(e){try{e.toSource(),n=!0}catch(e){n=!1}}return n&&"Firefox"!==e&&"Other"!==e},D=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},O=function(){if(!D())return!1;var e=N();return!!window.WebGLRenderingContext&&!!e},x=function(){return"Microsoft Internet Explorer"===navigator.appName||!("Netscape"!==navigator.appName||!/Trident/.test(navigator.userAgent))},B=function(){return void 0!==window.swfobject},L=function(){return window.swfobject.hasFlashPlayerVersion("9.0.0")},G=function(e,t){window.___fp_swf_loaded=function(t){e(t)};var r=t.fonts.swfContainerId;!function(e){var t=document.createElement("div");t.setAttribute("id",e.fonts.swfContainerId),document.body.appendChild(t)}();var n={onReady:"___fp_swf_loaded"};window.swfobject.embedSWF(t.fonts.swfPath,r,"1","1","9.0.0",!1,n,{allowScriptAccess:"always",menu:"false"},{})},N=function(){var e=document.createElement("canvas"),t=null;try{t=e.getContext("webgl")||e.getContext("experimental-webgl")}catch(e){}return t||(t=null),t},H=[{key:"userAgent",getData:function(e){e(navigator.userAgent)}},{key:"language",getData:function(e,t){e(navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||t.NOT_AVAILABLE)}},{key:"colorDepth",getData:function(e,t){e(window.screen.colorDepth||t.NOT_AVAILABLE)}},{key:"deviceMemory",getData:function(e,t){e(navigator.deviceMemory||t.NOT_AVAILABLE)}},{key:"pixelRatio",getData:function(e,t){e(window.devicePixelRatio||t.NOT_AVAILABLE)}},{key:"hardwareConcurrency",getData:function(e,t){e(T(t))}},{key:"screenResolution",getData:function(e,t){e(l(t))}},{key:"availableScreenResolution",getData:function(e,t){e(A(t))}},{key:"timezoneOffset",getData:function(e){e((new Date).getTimezoneOffset())}},{key:"timezone",getData:function(e,t){window.Intl&&window.Intl.DateTimeFormat?e((new window.Intl.DateTimeFormat).resolvedOptions().timeZone):e(t.NOT_AVAILABLE)}},{key:"sessionStorage",getData:function(e,t){e(m(t))}},{key:"localStorage",getData:function(e,t){e(g(t))}},{key:"indexedDb",getData:function(e,t){e(v(t))}},{key:"addBehavior",getData:function(e){e(!(!document.body||!document.body.addBehavior))}},{key:"openDatabase",getData:function(e){e(!!window.openDatabase)}},{key:"cpuClass",getData:function(e,t){e(b(t))}},{key:"platform",getData:function(e,t){e(S(t))}},{key:"doNotTrack",getData:function(e,t){e(y(t))}},{key:"plugins",getData:function(e,t){x()?t.plugins.excludeIE?e(t.EXCLUDED):e(f(t)):e(h(t))}},{key:"canvas",getData:function(e,t){D()?e(_(t)):e(t.NOT_AVAILABLE)}},{key:"webgl",getData:function(e,t){O()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){O()?e(E()):e()}},{key:"adBlock",getData:function(e){e(C())}},{key:"hasLiedLanguages",getData:function(e){e(M())}},{key:"hasLiedResolution",getData:function(e){e(P())}},{key:"hasLiedOs",getData:function(e){e(I())}},{key:"hasLiedBrowser",getData:function(e){e(R())}},{key:"touchSupport",getData:function(e){e(k())}},{key:"fonts",getData:function(e,t){var r=["monospace","sans-serif","serif"],n=["Andale Mono","Arial","Arial Black","Arial Hebrew","Arial MT","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Bitstream Vera Sans Mono","Book Antiqua","Bookman Old Style","Calibri","Cambria","Cambria Math","Century","Century Gothic","Century Schoolbook","Comic Sans","Comic Sans MS","Consolas","Courier","Courier New","Geneva","Georgia","Helvetica","Helvetica Neue","Impact","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","LUCIDA GRANDE","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Microsoft Sans Serif","Monaco","Monotype Corsiva","MS Gothic","MS Outlook","MS PGothic","MS Reference Sans Serif","MS Sans Serif","MS Serif","MYRIAD","MYRIAD PRO","Palatino","Palatino Linotype","Segoe Print","Segoe Script","Segoe UI","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tahoma","Times","Times New Roman","Times New Roman PS","Trebuchet MS","Verdana","Wingdings","Wingdings 2","Wingdings 3"];t.fonts.extendedJsFonts&&(n=n.concat(["Abadi MT Condensed Light","Academy Engraved LET","ADOBE CASLON PRO","Adobe Garamond","ADOBE GARAMOND PRO","Agency FB","Aharoni","Albertus Extra Bold","Albertus Medium","Algerian","Amazone BT","American Typewriter","American Typewriter Condensed","AmerType Md BT","Andalus","Angsana New","AngsanaUPC","Antique Olive","Aparajita","Apple Chancery","Apple Color Emoji","Apple SD Gothic Neo","Arabic Typesetting","ARCHER","ARNO PRO","Arrus BT","Aurora Cn BT","AvantGarde Bk BT","AvantGarde Md BT","AVENIR","Ayuthaya","Bandy","Bangla Sangam MN","Bank Gothic","BankGothic Md BT","Baskerville","Baskerville Old Face","Batang","BatangChe","Bauer Bodoni","Bauhaus 93","Bazooka","Bell MT","Bembo","Benguiat Bk BT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","BernhardFashion BT","BernhardMod BT","Big Caslon","BinnerD","Blackadder ITC","BlairMdITC TT","Bodoni 72","Bodoni 72 Oldstyle","Bodoni 72 Smallcaps","Bodoni MT","Bodoni MT Black","Bodoni MT Condensed","Bodoni MT Poster Compressed","Bookshelf Symbol 7","Boulder","Bradley Hand","Bradley Hand ITC","Bremen Bd BT","Britannic Bold","Broadway","Browallia New","BrowalliaUPC","Brush Script MT","Californian FB","Calisto MT","Calligrapher","Candara","CaslonOpnface BT","Castellar","Centaur","Cezanne","CG Omega","CG Times","Chalkboard","Chalkboard SE","Chalkduster","Charlesworth","Charter Bd BT","Charter BT","Chaucer","ChelthmITC Bk BT","Chiller","Clarendon","Clarendon Condensed","CloisterBlack BT","Cochin","Colonna MT","Constantia","Cooper Black","Copperplate","Copperplate Gothic","Copperplate Gothic Bold","Copperplate Gothic Light","CopperplGoth Bd BT","Corbel","Cordia New","CordiaUPC","Cornerstone","Coronet","Cuckoo","Curlz MT","DaunPenh","Dauphin","David","DB LCD Temp","DELICIOUS","Denmark","DFKai-SB","Didot","DilleniaUPC","DIN","DokChampa","Dotum","DotumChe","Ebrima","Edwardian Script ITC","Elephant","English 111 Vivace BT","Engravers MT","EngraversGothic BT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC","EucrosiaUPC","Euphemia","Euphemia UCAS","EUROSTILE","Exotc350 Bd BT","FangSong","Felix Titling","Fixedsys","FONTIN","Footlight MT Light","Forte","FrankRuehl","Fransiscan","Freefrm721 Blk BT","FreesiaUPC","Freestyle Script","French Script MT","FrnkGothITC Bk BT","Fruitger","FRUTIGER","Futura","Futura Bk BT","Futura Lt BT","Futura Md BT","Futura ZBlk BT","FuturaBlack BT","Gabriola","Galliard BT","Gautami","Geeza Pro","Geometr231 BT","Geometr231 Hv BT","Geometr231 Lt BT","GeoSlab 703 Lt BT","GeoSlab 703 XBd BT","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Gisha","Gloucester MT Extra Condensed","GOTHAM","GOTHAM BOLD","Goudy Old Style","Goudy Stout","GoudyHandtooled BT","GoudyOLSt BT","Gujarati Sangam MN","Gulim","GulimChe","Gungsuh","GungsuhChe","Gurmukhi MN","Haettenschweiler","Harlow Solid Italic","Harrington","Heather","Heiti SC","Heiti TC","HELV","Herald","High Tower Text","Hiragino Kaku Gothic ProN","Hiragino Mincho ProN","Hoefler Text","Humanst 521 Cn BT","Humanst521 BT","Humanst521 Lt BT","Imprint MT Shadow","Incised901 Bd BT","Incised901 BT","Incised901 Lt BT","INCONSOLATA","Informal Roman","Informal011 BT","INTERSTATE","IrisUPC","Iskoola Pota","JasmineUPC","Jazz LET","Jenson","Jester","Jokerman","Juice ITC","Kabel Bk BT","Kabel Ult BT","Kailasa","KaiTi","Kalinga","Kannada Sangam MN","Kartika","Kaufmann Bd BT","Kaufmann BT","Khmer UI","KodchiangUPC","Kokila","Korinna BT","Kristen ITC","Krungthep","Kunstler Script","Lao UI","Latha","Leelawadee","Letter Gothic","Levenim MT","LilyUPC","Lithograph","Lithograph Light","Long Island","Lydian BT","Magneto","Maiandra GD","Malayalam Sangam MN","Malgun Gothic","Mangal","Marigold","Marion","Marker Felt","Market","Marlett","Matisse ITC","Matura MT Script Capitals","Meiryo","Meiryo UI","Microsoft Himalaya","Microsoft JhengHei","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Tai Le","Microsoft Uighur","Microsoft YaHei","Microsoft Yi Baiti","MingLiU","MingLiU_HKSCS","MingLiU_HKSCS-ExtB","MingLiU-ExtB","Minion","Minion Pro","Miriam","Miriam Fixed","Mistral","Modern","Modern No. 20","Mona Lisa Solid ITC TT","Mongolian Baiti","MONO","MoolBoran","Mrs Eaves","MS LineDraw","MS Mincho","MS PMincho","MS Reference Specialty","MS UI Gothic","MT Extra","MUSEO","MV Boli","Nadeem","Narkisim","NEVIS","News Gothic","News GothicMT","NewsGoth BT","Niagara Engraved","Niagara Solid","Noteworthy","NSimSun","Nyala","OCR A Extended","Old Century","Old English Text MT","Onyx","Onyx BT","OPTIMA","Oriya Sangam MN","OSAKA","OzHandicraft BT","Palace Script MT","Papyrus","Parchment","Party LET","Pegasus","Perpetua","Perpetua Titling MT","PetitaBold","Pickwick","Plantagenet Cherokee","Playbill","PMingLiU","PMingLiU-ExtB","Poor Richard","Poster","PosterBodoni BT","PRINCETOWN LET","Pristina","PTBarnum BT","Pythagoras","Raavi","Rage Italic","Ravie","Ribbon131 Bd BT","Rockwell","Rockwell Condensed","Rockwell Extra Bold","Rod","Roman","Sakkal Majalla","Santa Fe LET","Savoye LET","Sceptre","Script","Script MT Bold","SCRIPTINA","Serifa","Serifa BT","Serifa Th BT","ShelleyVolante BT","Sherwood","Shonar Bangla","Showcard Gothic","Shruti","Signboard","SILKSCREEN","SimHei","Simplified Arabic","Simplified Arabic Fixed","SimSun","SimSun-ExtB","Sinhala Sangam MN","Sketch Rockwell","Skia","Small Fonts","Snap ITC","Snell Roundhand","Socket","Souvenir Lt BT","Staccato222 BT","Steamer","Stencil","Storybook","Styllo","Subway","Swis721 BlkEx BT","Swiss911 XCm BT","Sylfaen","Synchro LET","System","Tamil Sangam MN","Technical","Teletype","Telugu Sangam MN","Tempus Sans ITC","Terminal","Thonburi","Traditional Arabic","Trajan","TRAJAN PRO","Tristan","Tubular","Tunga","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold","TypoUpright BT","Unicorn","Univers","Univers CE 55 Medium","Univers Condensed","Utsaah","Vagabond","Vani","Vijaya","Viner Hand ITC","VisualUI","Vivaldi","Vladimir Script","Vrinda","Westminster","WHITNEY","Wide Latin","ZapfEllipt BT","ZapfHumnst BT","ZapfHumnst Dm BT","Zapfino","Zurich BlkEx BT","Zurich Ex BT","ZWAdobeF"]));n=(n=n.concat(t.fonts.userDefinedFonts)).filter(function(e,t){return n.indexOf(e)===t});var i=document.getElementsByTagName("body")[0],a=document.createElement("div"),o=document.createElement("div"),s={},c={},d=function(){var e=document.createElement("span");return e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="72px",e.style.fontStyle="normal",e.style.fontWeight="normal",e.style.letterSpacing="normal",e.style.lineBreak="auto",e.style.lineHeight="normal",e.style.textTransform="none",e.style.textAlign="left",e.style.textDecoration="none",e.style.textShadow="none",e.style.whiteSpace="normal",e.style.wordBreak="normal",e.style.wordSpacing="normal",e.innerHTML="mmmmmmmmmmlli",e},u=function(e,t){var r=d();return r.style.fontFamily="'"+e+"',"+t,r},l=function(e){for(var t=!1,n=0;n=e.components.length)t(r.data);else{var o=e.components[n];if(e.excludes[o.key])i(!1);else{if(!a&&o.pauseBefore)return n-=1,void setTimeout(function(){i(!0)},1);try{o.getData(function(e){r.addPreprocessedComponent(o.key,e),i(!1)},e)}catch(e){r.addPreprocessedComponent(o.key,String(e)),i(!1)}}}};i(!1)},F.getPromise=function(e){return new Promise(function(t,r){F.get(e,t)})},F.getV18=function(e,t){return null==t&&(t=e,e={}),F.get(e,function(r){for(var n=[],i=0;i=43)}}).catch(function(){return!1})}(e).then(function(e){return A=e})}function v(e){var t=h[e.name],r={};r.promise=new o(function(e,t){r.resolve=e,r.reject=t}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function T(e){var t=h[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function b(e,t){var r=h[e.name],n=r.deferredOperations.pop();if(n)return n.reject(t),n.promise}function S(e,t){return new o(function(r,n){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);v(e),e.db.close()}var a=[e.name];t&&a.push(e.version);var o=i.open.apply(i,a);t&&(o.onupgradeneeded=function(t){var r=o.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(l)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),n(o.error)},o.onsuccess=function(){r(o.result),T(e)}})}function y(e){return S(e,!1)}function k(e){return S(e,!0)}function _(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function w(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return o.resolve().then(function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),k(e)}).then(function(){return function(e){v(e);for(var t=h[e.name],r=t.forages,n=0;n>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&a;return d}function Q(e){var t,r=new Uint8Array(e),n="";for(t=0;t>2],n+=I[(3&r[t])<<4|r[t+1]>>4],n+=I[(15&r[t+1])<<2|r[t+2]>>6],n+=I[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var J={serialize:function(e,t){var r="";if(e&&(r=X.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===X.call(e.buffer))){var n,i=O;e instanceof ArrayBuffer?(n=e,i+=B):(n=e.buffer,"[object Int8Array]"===r?i+=G:"[object Uint8Array]"===r?i+=N:"[object Uint8ClampedArray]"===r?i+=H:"[object Int16Array]"===r?i+=F:"[object Uint16Array]"===r?i+=V:"[object Int32Array]"===r?i+=j:"[object Uint32Array]"===r?i+=U:"[object Float32Array]"===r?i+=q:"[object Float64Array]"===r?i+=W:t(new Error("Failed to get type for BinaryArray"))),t(i+Q(n))}else if("[object Blob]"===r){var a=new FileReader;a.onload=function(){var r=R+e.type+"~"+Q(this.result);t(O+L+r)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,x)!==O)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(x,z);if(n===L&&D.test(r)){var i=r.match(D);t=i[1],r=r.substring(i[0].length)}var o=K(r);switch(n){case B:return o;case L:return a([o],{type:t});case G:return new Int8Array(o);case N:return new Uint8Array(o);case H:return new Uint8ClampedArray(o);case F:return new Int16Array(o);case V:return new Uint16Array(o);case j:return new Int32Array(o);case U:return new Uint32Array(o);case q:return new Float32Array(o);case W:return new Float64Array(o);default:throw new Error("Unkown type: "+n)}},stringToBuffer:K,bufferToString:Q};function Z(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function $(e,t,r,n,i,a){e.executeSql(r,n,i,function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(e,s){s.rows.length?a(e,o):Z(e,t,function(){e.executeSql(r,n,i,a)},a)},a):a(e,o)},a)}var Y={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new o(function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction(function(i){Z(i,r,function(){t._dbInfo=r,e()},function(e,t){n(t)})},n)});return r.serializer=J,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT * FROM "+i.storeName,[],function(r,n){for(var a=n.rows,o=a.length,s=0;s0)return void o(e.apply(a,[t,c,n,i-1]));s(r)}})})}).catch(s)});return s(c,n),c}.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=d(e);var n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},clear:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"DELETE FROM "+n.storeName,[],function(){e()},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},length:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(t,r){var n=r.rows.item(0).c;e(n)},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},key:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},keys:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT key FROM "+n.storeName,[],function(t,r){for(var n=[],i=0;i '__WebKitDatabaseInfoTable__'",[],function(r,n){for(var i=[],a=0;a0}var re={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=J,o.resolve()):o.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then(function(){for(var t=r._dbInfo,n=t.keyPrefix,i=n.length,a=localStorage.length,o=1,s=0;s=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}});return s(r,e),r},length:function(e){var t=this.keys().then(function(e){return e.length});return s(t,e),t},key:function(e,t){var r=this,n=r.ready().then(function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t});return s(n,t),n},keys:function(e){var t=this,r=t.ready().then(function(){for(var e=t._dbInfo,r=localStorage.length,n=[],i=0;i=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}}):o.reject("Invalid arguments"),t),n}},ne=function(e,t){for(var r=e.length,n=0;n=0;)e[t]=0}const q=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),W=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),z=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),X=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K=new Array(576);U(K);const Q=new Array(60);U(Q);const J=new Array(512);U(J);const Z=new Array(256);U(Z);const $=new Array(29);U($);const Y=new Array(30);function ee(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let te,re,ne;function ie(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U(Y);const ae=e=>e<256?J[e]:J[256+(e>>>7)],oe=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},se=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<{se(e,r[2*t],r[2*t+1])},de=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},ue=(e,t,r)=>{const n=new Array(16);let i,a,o=0;for(i=1;i<=15;i++)n[i]=o=o+r[i-1]<<1;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=de(n[t]++,t))}},le=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},Ae=e=>{e.bi_valid>8?oe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},he=(e,t,r,n)=>{const i=2*t,a=2*r;return e[i]{const n=e.heap[r];let i=r<<1;for(;i<=e.heap_len&&(i{let n,i,a,o,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?ce(e,i,t):(a=Z[i],ce(e,a+256+1,t),0!==(o=q[a])&&(i-=$[a],se(e,i,o)),a=ae(--n),ce(e,a,r),0!==(o=W[a])&&(n-=Y[a],se(e,n,o)))}while(s{const r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems;let o,s,c,d=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)fe(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],fe(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[2*c]=r[2*o]+r[2*s],e.depth[c]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[2*o+1]=r[2*s+1]=c,e.heap[1]=c++,fe(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let d,u,l,A,h,f,p=0;for(A=0;A<=15;A++)e.bl_count[A]=0;for(r[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)(A=r[2*r[2*(u=e.heap[d])+1]+1]+1)>c&&(A=c,p++),r[2*u+1]=A,u>n||(e.bl_count[A]++,h=0,u>=s&&(h=o[u-s]),f=r[2*u],e.opt_len+=f*(A+h),a&&(e.static_len+=f*(i[2*u+1]+h)));if(0!==p){do{for(A=c-1;0===e.bl_count[A];)A--;e.bl_count[A]--,e.bl_count[A+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(A=c;0!==A;A--)for(u=e.bl_count[A];0!==u;)(l=e.heap[--d])>n||(r[2*l+1]!==A&&(e.opt_len+=(A-r[2*l+1])*r[2*l],r[2*l+1]=A),u--)}})(e,t),ue(r,d,e.bl_count)},ge=(e,t,r)=>{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=t[2*(n+1)+1],++s{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),n=0;n<=r;n++)if(i=o,o=t[2*(n+1)+1],!(++s{se(e,0+(n?1:0),3),((e,t,r,n)=>{Ae(e),n&&(oe(e,r),oe(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var Se={_tr_init:e=>{Te||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for($[n]=r,e=0;e<1<>=7;n<30;n++)for(Y[n]=i<<7,e=0;e<1<{let i,a,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),me(e,e.l_desc),me(e,e.d_desc),o=(e=>{let t;for(ge(e,e.dyn_ltree,e.l_desc.max_code),ge(e,e.dyn_dtree,e.d_desc.max_code),me(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*X[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?be(e,t,r,n):4===e.strategy||a===i?(se(e,2+(n?1:0),3),pe(e,K,Q)):(se(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(se(e,t-257,5),se(e,r-1,5),se(e,n-4,4),i=0;i(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Z[r]+256+1)]++,e.dyn_dtree[2*ae(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{se(e,2,3),ce(e,256,K),(e=>{16===e.bi_valid?(oe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var ye=(e,t,r,n)=>{let i=65535&e|0,a=e>>>16&65535|0,o=0;for(;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0};const ke=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var _e=(e,t,r,n)=>{const i=ke,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},we={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ee={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ce,_tr_stored_block:Me,_tr_flush_block:Pe,_tr_tally:Ie,_tr_align:Re}=Se,{Z_NO_FLUSH:De,Z_PARTIAL_FLUSH:Oe,Z_FULL_FLUSH:xe,Z_FINISH:Be,Z_BLOCK:Le,Z_OK:Ge,Z_STREAM_END:Ne,Z_STREAM_ERROR:He,Z_DATA_ERROR:Fe,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Ve,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:We,Z_FIXED:ze,Z_DEFAULT_STRATEGY:Xe,Z_UNKNOWN:Ke,Z_DEFLATED:Qe}=Ee,Je=286,Ze=30,$e=19,Ye=2*Je+1,et=15,tt=(e,t)=>(e.msg=we[t],t),rt=e=>(e<<1)-(e>4?9:0),nt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let it=(e,t,r)=>(t<{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ot=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,at(e.strm)},st=(e,t)=>{e.pending_buf[e.pending++]=t},ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},dt=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=ye(e.adler,t,i,r):2===e.state.wrap&&(e.adler=_e(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ut=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,u=e.w_mask,l=e.prev,A=e.strstart+258;let h=d[a+o-1],f=d[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(d[(r=t)+o]===f&&d[r+o-1]===h&&d[r]===d[a]&&d[++r]===d[a+1]){a+=2,r++;do{}while(d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&ao){if(e.match_start=t,o=n,n>=s)break;h=d[a+o-1],f=d[a+o]}}}while((t=l[t&u])>c&&0!=--i);return o<=e.lookahead?o:e.lookahead},lt=e=>{const t=e.w_size;let r,n,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-262)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=n=e.hash_size;do{i=e.head[--r],e.head[r]=i>=t?i-t:0}while(--n);r=n=t;do{i=e.prev[--r],e.prev[r]=i>=t?i-t:0}while(--n);a+=t}if(0===e.strm.avail_in)break;if(n=dt(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=it(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=it(e,e.ins_h,e.window[o+3-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},At=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ut(e,r)),e.match_length>=3)if(n=Ie(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=it(e,e.ins_h,e.window[e.strstart+1]);else n=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2},ht=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Ie(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(ot(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Ie(e,0,e.window[e.strstart-1]))&&ot(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ie(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2};function ft(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}const pt=[new ft(0,0,0,0,(e,t)=>{let r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(lt(e),0===e.lookahead&&t===De)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,ot(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(ot(e,!1),e.strm.avail_out),1)}),new ft(4,4,8,4,At),new ft(4,5,16,8,At),new ft(4,6,32,32,At),new ft(4,4,16,16,ht),new ft(8,16,32,32,ht),new ft(8,16,128,128,ht),new ft(8,32,128,256,ht),new ft(32,128,258,1024,ht),new ft(32,258,258,4096,ht)];function mt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qe,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*Ye),this.dyn_dtree=new Uint16Array(2*(2*Ze+1)),this.bl_tree=new Uint16Array(2*(2*$e+1)),nt(this.dyn_ltree),nt(this.dyn_dtree),nt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(et+1),this.heap=new Uint16Array(2*Je+1),nt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Je+1),nt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const gt=e=>{if(!e||!e.state)return tt(e,He);e.total_in=e.total_out=0,e.data_type=Ke;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=De,Ce(t),Ge},vt=e=>{const t=gt(e);return t===Ge&&(e=>{e.window_size=2*e.w_size,nt(e.head),e.max_lazy_match=pt[e.level].max_lazy,e.good_match=pt[e.level].good_length,e.nice_match=pt[e.level].nice_length,e.max_chain_length=pt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0})(e.state),t},Tt=(e,t,r,n,i,a)=>{if(!e)return He;let o=1;if(t===Ve&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Qe||n<8||n>15||t<0||t>9||a<0||a>ze)return tt(e,He);8===n&&(n=9);const s=new mt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<Tt(e,t,Qe,15,8,Xe),deflateInit2:Tt,deflateReset:vt,deflateResetKeep:gt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?He:(e.state.gzhead=t,Ge):He,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Le||t<0)return e?tt(e,He):He;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Be)return tt(e,0===e.avail_out?je:He);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,st(i,31),st(i,139),st(i,8),i.gzhead?(st(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),st(i,255&i.gzhead.time),st(i,i.gzhead.time>>8&255),st(i,i.gzhead.time>>16&255),st(i,i.gzhead.time>>24&255),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(st(i,255&i.gzhead.extra.length),st(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=_e(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(st(i,0),st(i,0),st(i,0),st(i,0),st(i,0),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,3),i.status=113);else{let t=Qe+(i.w_bits-8<<4)<<8,r=-1;t|=(r=i.strategy>=qe||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,ct(i,t),0!==i.strstart&&(ct(i,e.adler>>>16),ct(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending!==i.pending_buf_size));)st(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&at(e),i.pending+2<=i.pending_buf_size&&(st(i,255&e.adler),st(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(at(e),0===e.avail_out)return i.last_flush=-1,Ge}else if(0===e.avail_in&&rt(t)<=rt(a)&&t!==Be)return tt(e,je);if(666===i.status&&0!==e.avail_in)return tt(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==De&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(lt(e),0===e.lookahead)){if(t===De)return 1;break}if(e.match_length=0,r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===We?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(lt(e),e.lookahead<=258&&t===De)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=o[i=e.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){a=e.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Ie(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):pt[i.level].func(i,t);if(3!==r&&4!==r||(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),Ge;if(2===r&&(t===Oe?Re(i):t!==Le&&(Me(i,0,0,!1),t===xe&&(nt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),at(e),0===e.avail_out))return i.last_flush=-1,Ge}return t!==Be?Ge:i.wrap<=0?Ne:(2===i.wrap?(st(i,255&e.adler),st(i,e.adler>>8&255),st(i,e.adler>>16&255),st(i,e.adler>>24&255),st(i,255&e.total_in),st(i,e.total_in>>8&255),st(i,e.total_in>>16&255),st(i,e.total_in>>24&255)):(ct(i,e.adler>>>16),ct(i,65535&e.adler)),at(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Ge:Ne)},deflateEnd:e=>{if(!e||!e.state)return He;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?tt(e,He):(e.state=null,113===t?tt(e,Fe):Ge)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return He;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return He;if(1===i&&(e.adler=ye(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(nt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}const a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,lt(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=it(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,lt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,n.wrap=i,Ge},deflateInfo:"pako deflate (from Nodeca project)"};const St=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var yt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)St(r,t)&&(e[t]=r[t])}}return e},flattenChunks:e=>{let t=0;for(let r=0,n=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;_t[254]=_t[254]=1;var wt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,n,i,a,o=e.length,s=0;for(i=0;i>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},buf2string:(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const a=new Array(2*r);for(i=0,n=0;n4)a[i++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?a[i++]=65533:t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&kt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+_t[e[r]]>t?r:t}};var Et=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ct=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:It,Z_FINISH:Rt,Z_OK:Dt,Z_STREAM_END:Ot,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Bt,Z_DEFLATED:Lt}=Ee;function Gt(e){this.options=yt.assign({level:xt,method:Lt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Bt},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=bt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Dt)throw new Error(we[r]);if(t.header&&bt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?wt.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=bt.deflateSetDictionary(this.strm,e))!==Dt)throw new Error(we[r]);this._dict_set=!0}}function Nt(e,t){const r=new Gt(t);if(r.push(e,!0),r.err)throw r.msg||we[r.err];return r.result}Gt.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize;let i,a;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Rt:Mt,"string"==typeof e?r.input=wt.string2buf(e):"[object ArrayBuffer]"===Ct.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a===Pt||a===It)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=bt.deflate(r,a))===Ot)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=bt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Dt;if(0!==r.avail_out){if(a>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Gt.prototype.onData=function(e){this.chunks.push(e)},Gt.prototype.onEnd=function(e){e===Dt&&(this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ht={Deflate:Gt,deflate:Nt,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Nt(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Nt(e,t)},constants:Ee};var Ft=function(e,t){let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_,w;const E=e.state;r=e.next_in,_=e.input,n=r+(e.avail_in-5),i=e.next_out,w=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,d=E.whave,u=E.wnext,l=E.window,A=E.hold,h=E.bits,f=E.lencode,p=E.distcode,m=(1<>>=T=v>>>24,h-=T,0===(T=v>>>16&255))w[i++]=65535&v;else{if(!(16&T)){if(0==(64&T)){v=f[(65535&v)+(A&(1<>>=T,h-=T),h<15&&(A+=_[r++]<>>=T=v>>>24,h-=T,!(16&(T=v>>>16&255))){if(0==(64&T)){v=p[(65535&v)+(A&(1<s){e.msg="invalid distance too far back",E.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&E.sane){e.msg="invalid distance too far back",E.mode=30;break e}if(y=0,k=l,0===u){if(y+=c-T,T2;)w[i++]=k[y++],w[i++]=k[y++],w[i++]=k[y++],b-=3;b&&(w[i++]=k[y++],b>1&&(w[i++]=k[y++]))}else{y=i-S;do{w[i++]=w[y++],w[i++]=w[y++],w[i++]=w[y++],b-=3}while(b>2);b&&(w[i++]=w[y++],b>1&&(w[i++]=w[y++]))}break}}break}}while(r>3,A&=(1<<(h-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r{const c=s.bits;let d,u,l,A,h,f,p=0,m=0,g=0,v=0,T=0,b=0,S=0,y=0,k=0,_=0,w=null,E=0;const C=new Uint16Array(16),M=new Uint16Array(16);let P,I,R,D=null,O=0;for(p=0;p<=15;p++)C[p]=0;for(m=0;m=1&&0===C[v];v--);if(T>v&&(T=v),0===v)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(M[1]=0,p=1;p<15;p++)M[p+1]=M[p]+C[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){P=p-S,o[m]f?(I=D[O+o[m]],R=w[E+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=P<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--C[p]){if(p===v)break;p=t[r+o[m]]}if(p>T&&(_&A)!==l){for(0===S&&(S=T),h+=g,y=1<<(b=p-S);b+S852||2===e&&k>592)return 1;i[l=_&A]=T<<24|b<<16|h-a|0}}return 0!==_&&(i[h+_]=p-S<<24|64<<16|0),s.bits=T,0};const{Z_FINISH:zt,Z_BLOCK:Xt,Z_TREES:Kt,Z_OK:Qt,Z_STREAM_END:Jt,Z_NEED_DICT:Zt,Z_STREAM_ERROR:$t,Z_DATA_ERROR:Yt,Z_MEM_ERROR:er,Z_BUF_ERROR:tr,Z_DEFLATED:rr}=Ee,nr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ir(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ar=e=>{if(!e||!e.state)return $t;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Qt},or=e=>{if(!e||!e.state)return $t;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ar(e)},sr=(e,t)=>{let r;if(!e||!e.state)return $t;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?$t:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,or(e))},cr=(e,t)=>{if(!e)return $t;const r=new ir;e.state=r,r.window=null;const n=sr(e,t);return n!==Qt&&(e.state=null),n};let dr,ur,lr=!0;const Ar=e=>{if(lr){dr=new Int32Array(512),ur=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Wt(1,e.lens,0,288,dr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Wt(2,e.lens,0,32,ur,0,e.work,{bits:5}),lr=!1}e.lencode=dr,e.lenbits=9,e.distcode=ur,e.distbits=5},hr=(e,t,r,n)=>{let i;const a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whavecr(e,15),inflateInit2:cr,inflate:(e,t)=>{let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_=0;const w=new Uint8Array(4);let E,C;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return $t;12===(r=e.state).mode&&(r.mode=13),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,l=s,A=c,k=Qt;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0),d=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&d)!==rr){e.msg="unknown compression method",r.mode=30;break}if(u-=4,y=8+(15&(d>>>=4)),0===r.wbits)r.wbits=y;else if(y>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>8&255,w[2]=d>>>16&255,w[3]=d>>>24&255,r.check=_e(r.check,w,4,0)),d=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>8),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>s&&(h=s),h&&(r.head&&(y=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),y)),512&r.flags&&(r.check=_e(r.check,n,h,a)),s-=h,a+=h,r.length-=h),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;h=0;do{y=n[a+h++],r.head&&y&&r.length<65536&&(r.head.name+=String.fromCharCode(y))}while(y&&h>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===s)break e;s--,d+=n[a++]<>>=1)){case 0:r.mode=14;break;case 1:if(Ar(r),r.mode=20,t===Kt){d>>>=2,u-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}d>>>=2,u-=2;break;case 14:for(d>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,d+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&d,d=0,u=0,r.mode=15,t===Kt)break e;case 15:r.mode=16;case 16:if(h=r.length){if(h>s&&(h=s),h>c&&(h=c),0===h)break e;i.set(n.subarray(a,a+h),o),s-=h,a+=h,c-=h,o+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===s)break e;s--,d+=n[a++]<>>=5,u-=5,r.ndist=1+(31&d),d>>>=5,u-=5,r.ncode=4+(15&d),d>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,E={bits:r.lenbits},k=Wt(0,r.lens,0,19,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=m,u-=m,r.lens[r.have++]=v;else{if(16===v){for(C=m+2;u>>=m,u-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}y=r.lens[r.have-1],h=3+(3&d),d>>>=2,u-=2}else if(17===v){for(C=m+3;u>>=m)),d>>>=3,u-=3}else{for(C=m+7;u>>=m)),d>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=y}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,E={bits:r.lenbits},k=Wt(1,r.lens,0,r.nlen,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,E={bits:r.distbits},k=Wt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,E),r.distbits=E.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Kt)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=d,r.bits=u,Ft(e,A),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(_=r.lencode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,r.length=v,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(_=r.distcode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=v,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===c)break e;if(h=A-c,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,f=r.wsize-h):f=r.wnext-h,h>r.length&&(h=r.length),p=r.window}else p=i,f=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do{i[o++]=p[f++]}while(--h);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[o++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===s)break e;s--,d|=n[a++]<{if(!e||!e.state)return $t;let t=e.state;return t.window&&(t.window=null),e.state=null,Qt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return $t;const r=e.state;return 0==(2&r.wrap)?$t:(r.head=t,t.done=!1,Qt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?$t:11===n.mode&&(i=ye(i=1,t,r,0))!==n.check?Yt:(a=hr(e,t,r,r))?(n.mode=31,er):(n.havedict=1,Qt):$t},inflateInfo:"pako inflate (from Nodeca project)"};var pr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const mr=Object.prototype.toString,{Z_NO_FLUSH:gr,Z_FINISH:vr,Z_OK:Tr,Z_STREAM_END:br,Z_NEED_DICT:Sr,Z_STREAM_ERROR:yr,Z_DATA_ERROR:kr,Z_MEM_ERROR:_r}=Ee;function wr(e){this.options=yt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=fr.inflateInit2(this.strm,t.windowBits);if(r!==Tr)throw new Error(we[r]);if(this.header=new pr,fr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wt.string2buf(t.dictionary):"[object ArrayBuffer]"===mr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=fr.inflateSetDictionary(this.strm,t.dictionary))!==Tr))throw new Error(we[r])}function Er(e,t){const r=new wr(t);if(r.push(e),r.err)throw r.msg||we[r.err];return r.result}wr.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let a,o,s;if(this.ended)return!1;for(o=t===~~t?t:!0===t?vr:gr,"[object ArrayBuffer]"===mr.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a=fr.inflate(r,o))===Sr&&i&&((a=fr.inflateSetDictionary(r,i))===Tr?a=fr.inflate(r,o):a===kr&&(a=Sr));r.avail_in>0&&a===br&&r.state.wrap>0&&0!==e[r.next_in];)fr.inflateReset(r),a=fr.inflate(r,o);switch(a){case yr:case kr:case Sr:case _r:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===br))if("string"===this.options.to){let e=wt.utf8border(r.output,r.next_out),t=r.next_out-e,i=wt.buf2string(r.output,e);r.next_out=t,r.avail_out=n-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(a!==Tr||0!==s){if(a===br)return a=fr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},wr.prototype.onData=function(e){this.chunks.push(e)},wr.prototype.onEnd=function(e){e===Tr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:wr,inflate:Er,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Er(e,t)},ungzip:Er,constants:Ee};const{Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr}=Ht,{Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br}=Cr;var Lr={Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr,Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br,constants:Ee},Gr=u(function(e){!function(t){function r(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function n(e,t,n,i,a,o){return r((s=r(r(t,e),r(i,o)))<<(c=a)|s>>>32-c,n);var s,c}function i(e,t,r,i,a,o,s){return n(t&r|~t&i,e,t,a,o,s)}function a(e,t,r,i,a,o,s){return n(t&i|r&~i,e,t,a,o,s)}function o(e,t,r,i,a,o,s){return n(t^r^i,e,t,a,o,s)}function s(e,t,r,i,a,o,s){return n(r^(t|~i),e,t,a,o,s)}function c(e,t){var n,c,d,u,l;e[t>>5]|=128<>>9<<4)]=t;var A=1732584193,h=-271733879,f=-1732584194,p=271733878;for(n=0;n>5]>>>t%32&255);return r}function u(e){var t,r=[];for(r[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+"0123456789abcdef".charAt(15&t);return n}function A(e){return unescape(encodeURIComponent(e))}function h(e){return function(e){return d(c(u(e),8*e.length))}(A(e))}function f(e,t){return function(e,t){var r,n,i=u(e),a=[],o=[];for(a[15]=o[15]=void 0,i.length>16&&(i=c(i,8*e.length)),r=0;r<16;r+=1)a[r]=909522486^i[r],o[r]=1549556828^i[r];return n=c(a.concat(u(t)),512+8*t.length),d(c(o.concat(n),640))}(A(e),A(t))}function p(e,t,r){return t?r?f(t,e):l(f(t,e)):r?h(e):l(h(e))}e.exports?e.exports=p:t.md5=p}(c)}),Nr=u(function(e,t){var r=200,n="Expected a function",i="__lodash_hash_undefined__",a=1,o=2,s=1/0,d=9007199254740991,u="[object Arguments]",l="[object Array]",A="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Function]",m="[object GeneratorFunction]",g="[object Map]",v="[object Number]",T="[object Object]",b="[object RegExp]",S="[object Set]",y="[object String]",k="[object Symbol]",_="[object ArrayBuffer]",w="[object DataView]",E=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,C=/^\w*$/,M=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,O={};O["[object Float32Array]"]=O["[object Float64Array]"]=O["[object Int8Array]"]=O["[object Int16Array]"]=O["[object Int32Array]"]=O["[object Uint8Array]"]=O["[object Uint8ClampedArray]"]=O["[object Uint16Array]"]=O["[object Uint32Array]"]=!0,O[u]=O[l]=O[_]=O[A]=O[w]=O[h]=O[f]=O[p]=O[g]=O[v]=O[T]=O[b]=O[S]=O[y]=O["[object WeakMap]"]=!1;var x="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=x||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&x.process,F=function(){try{return H&&H.binding("util")}catch(e){}}(),j=F&&F.isTypedArray;function V(e,t,r,n){for(var i=-1,a=e?e.length:0;++i-1},we.prototype.set=function(e,t){var r=this.__data__,n=Ie(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ee.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ee.prototype.delete=function(e){return qe(this,e).delete(e)},Ee.prototype.get=function(e){return qe(this,e).get(e)},Ee.prototype.has=function(e){return qe(this,e).has(e)},Ee.prototype.set=function(e,t){return qe(this,e).set(e,t),this},Ce.prototype.add=Ce.prototype.push=function(e){return this.__data__.set(e,i),this},Ce.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.clear=function(){this.__data__=new we},Me.prototype.delete=function(e){return this.__data__.delete(e)},Me.prototype.get=function(e){return this.__data__.get(e)},Me.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.set=function(e,t){var n=this.__data__;if(n instanceof we){var i=n.__data__;if(!le||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ut(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function lt(e){return!!e&&"object"==typeof e}function At(e){return"symbol"==typeof e||lt(e)&&ne.call(e)==k}var ht=j?function(e){return function(t){return e(t)}}(j):function(e){return lt(e)&&dt(e.length)&&!!O[ne.call(e)]};function ft(e){return st(e)?Pe(e):je(e)}function pt(e){return e}e.exports=rt});const Hr="4.1.8";function Fr(){const e=new Date;function t(e){const t=e.toString();return t.length<2?"0"+t:t}return`[${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${e.getMilliseconds()}]`}const jr=new class{constructor(e){this.level=e}setLevel(e){this.level=e}log(...e){if("log"!==this.level)return;const t=`${Fr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Fr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Fr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Vr extends C{constructor(e,t=!0){super(),this._closed=!1,this._busy=!1,this._queue=[],this.name=e||"TaskQueue",this.isDebug=t}close(){this._closed=!0}push(e,t){return this.isDebug&&jr.debug(`${this.name} push()`,e,t),new Promise((r,n)=>{this._queue.push({method:e,data:t,resolve:r,reject:n}),this._handlePendingCommands()})}_handlePendingCommands(){if(this._busy)return;const e=this._queue,t=e[0];t&&(this._busy=!0,this._handleCommand(t).then(()=>{this._busy=!1,e.shift(),this._handlePendingCommands()}))}_handleCommand(e){if(this.isDebug&&jr.debug(`${this.name} _handleCommand() `,e.method,e.data),this._closed)return e.reject(new $n("closed")),Promise.resolve();const t={promise:null};return this.emit("exec",e,t),Promise.resolve().then(()=>t.promise).then(t=>{this.isDebug&&jr.debug(`${this.name} _handleCommand() | command succeeded`,e.method),this._closed?e.reject(new $n("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}var Ur,qr;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}(Ur||(Ur={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}(qr||(qr={}));const Wr={"360p":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:30,bitrate:1130},"1080p":{width:1920,height:1080,frameRate:30,bitrate:2080},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4850},"4k":{width:3840,height:2160,frameRate:30,bitrate:8910}},zr=Wr["480p"],Xr={LOW:{sampleRate:16e3,stereo:!1,bitrate:24,sampleSize:16},STANDARD:{sampleRate:48e3,stereo:!1,bitrate:64,sampleSize:16},STANDARD_STEREO:{sampleRate:48e3,stereo:!0,bitrate:80,sampleSize:16},HIGH:{sampleRate:48e3,stereo:!1,bitrate:96,sampleSize:16},HIGH_STEREO:{sampleRate:48e3,stereo:!0,bitrate:128,sampleSize:16}},Kr=Xr.STANDARD,Qr={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},Jr=Qr["720p"];var Zr,$r,Yr,en,tn,rn,nn,an,on,sn,cn,dn,un,ln,An,hn;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(Zr||(Zr={})),function(e){e.IDLE="IDLE",e.PlAYING="PlAYING",e.MIXING="MIXING",e.PAUSED="PAUSED",e.STOPPED="STOPPED",e.COMPLETED="COMPLETED"}($r||($r={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(Yr||(Yr={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(en||(en={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(tn||(tn={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(rn||(rn={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(nn||(nn={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(an||(an={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(on||(on={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(sn||(sn={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(cn||(cn={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(dn||(dn={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(un||(un={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.STOPPED=1]="STOPPED",e[e.INVALID_TOKEN=2]="INVALID_TOKEN",e[e.NO_ROOM=3]="NO_ROOM",e[e.ROOM_CLOSED=4]="ROOM_CLOSED",e[e.PLAYER_EXISTED=5]="PLAYER_EXISTED"}(ln||(ln={})),function(e){e.NORMAL="NORMAL",e.GENERAL="GENERAL",e.SERVERE="SERVERE"}(An||(An={})),function(e){e.CORE="Core",e.API="API",e.AUDIO="Audio",e.VIDEO="Video",e.SIGNAL="Signal"}(hn||(hn={}));const fn="qnrtcqosevents";function pn(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Gr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Gr(JSON.stringify(t));e(r)})},500)})}function mn(e){const t=[];for(let r=0;r>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return new Uint8Array(t)}const gn=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Vr("qossubmit",!1),pn().then(e=>{this.deviceId=e,this.base.device_id=this.deviceId}).catch(()=>{this.deviceId="unknow",this.base.device_id=this.deviceId}),this.base={qos_version:"2.0",device_id:"",bundle_id:"",url:window.location.href,app_version:"",sdk_version:Hr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(ni)}setSessionId(e){for(let t=this.events.length-1;t>=0;t-=1){const r=this.events[t];if(r.session_id)break;r.session_id=e}this.sessionId=e}setUserBase(e,t,r){this.userBase={user_id:e,room_name:t,app_id:r};for(let e=this.events.length-1;e>=0;e-=1){const t=this.events[e];if(t.user_base)break;t.user_base=this.userBase}}addEvent(e,r,n){const i=t({timestamp:Date.now(),event_id:F[e],event_name:e},r);this.submitQueue.push("add",i).catch(ni),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(ni)}initSubmitQueue(){this.submitQueue.on("exec",(e,t)=>{switch(e.method){case"submit":return void(t.promise=this._submit(e.data));case"add":return void(t.promise=this._addEvent(e.data));case"resume":return void(t.promise=this._recoverStoredEvents())}})}async _recoverStoredEvents(){const e=await V.getItem(fn);jr.log("get item",e),await V.removeItem(fn),e&&(this.events=JSON.parse(window.atob(decodeURIComponent(e))),this.events=this.events.filter(e=>!!e.session_id&&!!e.user_base).sort((e,t)=>e.event.timestamp-t.event.timestamp))}_addEvent(e){return this.events.push({user_base:this.userBase,event:e,session_id:this.sessionId}),this.submit(),Promise.resolve()}saveEvents(){const e=encodeURIComponent(window.btoa(JSON.stringify(this.events)));V.setItem(fn,e).catch(ni)}submitCheck(){return!!(this.sessionId&&this.deviceId&&this.userBase)&&(Date.now()-this.lastSubmitTime>3e5||this.events.length>=30)}async _submit(e=!1){if(e||this.submitCheck())try{const e=this.encodeQosSubmitData();for(const t of e)if(!(await fetch("https://pili-rtc-qos.qiniuapi.com/v1/rtcevent",{method:"POST",headers:{"Content-Type":"application/x-gzip"},body:t.buffer})).ok)throw kn("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await V.removeItem(fn)}catch(e){jr.log(e)}else this.saveEvents()}encodeQosSubmitData(){const e=Nr(this.events,e=>e.session_id||""+JSON.stringify(e.user_base)),t=[];for(const r in e){const n=e[r];if(0===n.length)continue;const i={session_id:n[0].session_id,user_base:n[0].user_base,base:this.base,items:n.map(e=>e.event)};jr.log("encode",i);const a=new Uint8Array(Lr.gzip(mn(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function vn(e,t){let r;switch(e){case"prompt":r=O.prompt;break;case"granted":r=O.granted;break;case"denied":r=O.denied;break;default:return}let n=An.NORMAL;(r===O.prompt||O.denied)&&(n=An.SERVERE),gn.addEvent("AuthorizationStatus",{type:t,status:r,event_grade:n,event_category:hn.CORE})}function Tn(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{vn(e.state,D[t]),e.onchange=(()=>{vn(e.state,D[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Tn("camera"),Tn("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{gn.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2,event_grade:An.GENERAL,event_category:hn.CORE})});const bn=(()=>{let e=x.INVALID,t="unknow";const r=e=>{let t;switch(e){case"cellular":t=0;break;case"wifi":t=1;break;case"ethernet":t=2;break;default:t=-1}return t},n=()=>{gn.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e,event_grade:An.GENERAL,event_category:hn.CORE})},i=navigator,a=i.connection||i.mozConnection||i.webkitConnection;return a&&a.type&&(t=a.type,a.onchange=(()=>{t!==a.type&&(t=a.type,n())})),n(),t=>{t!==e&&(e=t,n())}})();class Sn extends Error{constructor(e,t){super(t),this.code=e,this.error=t,gn.addEvent("SDKError",{error_code:e,error_msg:t})}}const yn=e=>new Sn(10053,`invalid parameters: ${e}`),kn=e=>new Sn(21005,`piliRTC: unexpected error ${e}`),_n=e=>new Sn(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),wn=e=>new Sn(21006,`not support! ${e}`),En=e=>new Sn(21007,`track play is not allowed: ${e}`),Cn=e=>new Sn(23003,`plugin not avaliable! ${e}`),Mn=e=>new Sn(23004,`NotAllowedError: no permission to access media device. ${e}`),Pn=e=>new Sn(22011,`can not decode audio data, ${e.toString()}`),In=()=>new Sn(23005,"no audio track when createScreenVideoTrack withAudio enable"),Rn=e=>new Sn(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),Dn=e=>new Sn(24e3,`relay error, can not get relayToken. Error: ${e}`),On=e=>new Sn(24001,`invalid client mode, ${e}`),xn=e=>new Sn(24002,`invalid client role, ${e}`),Bn=()=>kn("websocket abort"),Ln=e=>yn(`can not set merge layout stream, no merge job id ${e}`),Gn=()=>Mn("can not sharing screen/window on chrome"),Nn=()=>kn("subscribe/publish operation is aborted"),Hn=()=>yn("cannot found preset"),Fn=()=>new Sn(22003,"mix source error"),jn=()=>new Sn(22002,"mixed source does not find a valid track"),Vn=()=>new Sn(22001,"effectID already exists, cannot create QNAudioEffect"),Un=()=>new Sn(22004,"effectID is not exists, pleast createAudioEffect firstt"),qn=(e,t)=>new Sn(e,`publish error, signaling code: ${e}, msg: ${t}`),Wn=(e,t)=>new Sn(e,`create merge job error, signaling code: ${e}, msg: ${t}`),zn=(e,t)=>new Sn(e,`create forward job error, signaling code: ${e}, msg: ${t}`),Xn=(e,t)=>new Sn(e,`media format not support, ${t}`),Kn=(e,t)=>new Sn(e,`subscribe error, signaling code: ${e}, msg: ${t}`),Qn=(e,t)=>new Sn(e,`send control error, code: ${e}, msg: ${t}`),Jn=(e,t)=>new Sn(e,t),Zn=()=>new Sn(10052,"server unavailable");class $n extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,$n):this.stack=new Error(e).stack}}var Yn=Object.freeze({QNRTCError:Sn,ERROR_INVALID_PARAMETER:yn,ERROR_FATAL:kn,ERROR_AUTH_FAILED:_n,ERROR_RECONNECT_FAILED:e=>new Sn(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:wn,ERROR_PLAY_NOT_ALLOWED:En,ERROR_PLUGIN_NOT_AVAILABLE:Cn,ERROR_DEVICE_NOT_ALLOWED:Mn,ERROR_AUDIO_DECODE_ERROR:Pn,CREATE_SCREEN_AUDIO_ERROR:In,ERROR_ELECTRON_REQUIRE_ERROR:Rn,ERROR_RELAY_TOKEN:Dn,ERROR_INVALID_CLIENT_MODE:On,ERROR_INVALID_CLIENT_ROLE:xn,WS_ABORT:Bn,NO_MERGE_JOB:Ln,SCREEN_PERMISSION_DENIED:Gn,SUB_PUB_ABORT:Nn,PRESET_NOT_FOUND:Hn,ERROR_AUDIO_MIXING_IO_EXCEPTION:Fn,ERROR_AUDIO_MIXING_AUDIO_NOT_FOUND:jn,ERROR_EFFECT_ID_IS_EXIST:Vn,ERROR_EFFECT_ID_IS_NOT_EXIST:Un,PUBLISH_ERROR:qn,CREATE_MERGE_JOB_ERROR:Wn,CREATE_FORWARD_JOB_ERROR:zn,UNSUPPORT_FMT:Xn,JOIN_ROOM_ERROR:(e,t)=>new Sn(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Kn,UNPUBLISH_ERROR:(e,t)=>new Sn(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Sn(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:Qn,SERVER_ERROR:Jn,SERVER_UNAVAILABLE:Zn,InvalidStateError:$n});function ei(e){const t=e.split(".")[1];if(!t)throw new Error("parse jwt error, can not find payload string.");const r=atob(t);return JSON.parse(r)}function ti(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw kn(`can not parse roomToken, ${e}`)}}function ri(e,t,r){if(!r)return null;for(let n=0;n=4)return e;for(const r in e)void 0===e[r]&&delete e[r],e[r]instanceof File||e[r]instanceof ArrayBuffer||"object"==typeof e[r]&&(e[r]=ii(e[r],t+1));return e}function ai(e){Promise.resolve().then(e)}function oi(e){return("0"+e.toString(16)).substr(-2)}function si(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,oi).join("")}function ci(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const di={};function ui(e,t){if(!di[t])return di[t]=!0,e()}function li(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Ai(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>{r.abort(),n({networkCode:-1,message:"请求超时"})},t),i=fetch(e,{signal:r.signal})}else i=fetch(e);i.then(e=>(function(e,t,r){e>=400&&r({retry:!1,message:t}),200!==e&&r({retry:!0,message:t})}(e.status,e.statusText,n),e.json())).then(r).catch(n)})}async function hi(e){const t=e.match(/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/);if(e.match(/^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$/)||t)return e;try{const t=await fetch(`https://${e}/ip`);return(await t.json()).ip}catch(t){return jr.warning("resolve ice failed, retry",t),await ci(1e3),await hi(e)}}var fi,pi=u(function(e){!function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){if(!s&&d)return d();if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a=d,o=0;o0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},r=n.log,d=n.detectBrowser(e),u={browserDetails:d,commonShim:c,extractVersion:n.extractVersion,disableLog:n.disableLog,disableWarnings:n.disableWarnings};switch(d.browser){case"chrome":if(!i||!i.shimPeerConnection||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;if(null===d.version)return r("Chrome shim can not determine version, not shimming."),u;r("adapter.js shimming chrome."),u.browserShim=i,c.shimAddIceCandidateNullOrEmpty(e,d),i.shimGetUserMedia(e,d),i.shimMediaStream(e,d),i.shimPeerConnection(e,d),i.shimOnTrack(e,d),i.shimAddTrackRemoveTrack(e,d),i.shimGetSendersWithDtmf(e,d),i.shimGetStats(e,d),i.shimSenderReceiverGetStats(e,d),i.fixNegotiationNeeded(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;case"firefox":if(!o||!o.shimPeerConnection||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=o,c.shimAddIceCandidateNullOrEmpty(e,d),o.shimGetUserMedia(e,d),o.shimPeerConnection(e,d),o.shimOnTrack(e,d),o.shimRemoveStream(e,d),o.shimSenderGetStats(e,d),o.shimReceiverGetStats(e,d),o.shimRTCDataChannel(e,d),o.shimAddTransceiver(e,d),o.shimGetParameters(e,d),o.shimCreateOffer(e,d),o.shimCreateAnswer(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"edge":if(!a||!a.shimPeerConnection||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=a,a.shimGetUserMedia(e,d),a.shimGetDisplayMedia(e,d),a.shimPeerConnection(e,d),a.shimReplaceTrack(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"safari":if(!s||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=s,c.shimAddIceCandidateNullOrEmpty(e,d),s.shimRTCIceServerUrls(e,d),s.shimCreateOfferLegacy(e,d),s.shimCallbacksAPI(e,d),s.shimLocalStreamsAPI(e,d),s.shimRemoteStreamsAPI(e,d),s.shimTrackEventTransceiver(e,d),s.shimGetUserMedia(e,d),s.shimAudioContext(e,d),c.shimRTCIceCandidate(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;default:r("Unsupported browser!")}return u};var n=d(e("./utils")),i=d(e("./chrome/chrome_shim")),a=d(e("./edge/edge_shim")),o=d(e("./firefox/firefox_shim")),s=d(e("./safari/safari_shim")),c=d(e("./common_shim"));function d(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":12,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11}],3:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},r.shimOnTrack=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)o.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e});else{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 t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.track.id}):{track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}),t.stream.getTracks().forEach(function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.id}):{track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}},r.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):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 r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach(function(e){r._senders.push(t(r,e))})};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach(function(e){var r=t._senders.find(function(t){return t.track===e});r&&t._senders.splice(t._senders.indexOf(r),1)})}}else if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t},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}})}},r.shimGetStats=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],a=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var o=function(e){var t={},r=e.result();return r.forEach(function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){r[t]=e.stat(t)}),t[r.id]=r}),t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return t.apply(this,[function(e){i(s(o(e)))},n])}return new Promise(function(r,n){t.apply(e,[function(e){r(s(o(e)))},n])}).then(i,a)}},r.shimSenderReceiverGetStats=function(e){if(!("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return o.filterStats(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t}),o.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(t){return o.filterStats(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],r=void 0,n=void 0,i=void 0;return this.getSenders().forEach(function(e){e.track===t&&(r?i=!0:r=e)}),this.getReceivers().forEach(function(e){return e.track===t&&(n?i=!0:n=e),e.track===t}),i||r&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}},r.shimAddTrackRemoveTrackWithNative=c,r.shimAddTrackRemoveTrack=function(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return c(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(function(e){var t=r.getSenders().find(function(t){return t.track===e});if(t)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;function a(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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(t,r){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var a=this.getSenders().find(function(e){return e.track===t});if(a)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var o=this._streams[r.id];if(o)o.addTrack(t),Promise.resolve().then(function(){n.dispatchEvent(new Event("negotiationneeded"))});else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=a(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then(function(t){return a(e,t)})});e.RTCPeerConnection.prototype[t]=n[t]});var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=(e=this,t=arguments[0],r=t.sdp,Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:r})),o.apply(this,arguments)):o.apply(this,arguments);var e,t,r};var d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=d.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=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");var r=e._pc===this;if(!r)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var n=void 0;Object.keys(this._streams).forEach(function(r){var i=t._streams[r].getTracks().find(function(t){return e.track===t});i&&(n=t._streams[r])}),n&&(1===n.getTracks().length?this.removeStream(this._reverseStreams[n.id]):n.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}},r.shimPeerConnection=function(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection);if(!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})},r.fixNegotiationNeeded=function(e,t){o.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js"));function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter(function(e){return-1===n.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]}),i.apply(this,arguments)}}},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;if("function"!=typeof t)return void console.error("shimGetDisplayMedia: getSourceId argument is not a function");e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,a=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)})}}},{}],5:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator;if(!r.mediaDevices)return;var a=function(e){if("object"!==(void 0===e?"undefined":n(e))||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var i="object"===n(e[r])?e[r]:{ideal:e[r]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);var a=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];var o={};"number"==typeof i.ideal?(o[a("min",r)]=i.ideal,t.optional.push(o),(o={})[a("max",r)]=i.ideal,t.optional.push(o)):(o[a("",r)]=i.ideal,t.optional.push(o))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[a("",r)]=i.exact):["min","max"].forEach(function(e){void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[a(e,r)]=i[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,o){if(t.version>=61)return o(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===n(e.audio)){var s=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),s(e.audio,"autoGainControl","googAutoGainControl"),s(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=a(e.audio)}if(e&&"object"===n(e.video)){var c=e.video.facingMode;c=c&&("object"===(void 0===c?"undefined":n(c))?c:{ideal:c});var d=t.version<66;if(c&&("user"===c.exact||"environment"===c.exact||"user"===c.ideal||"environment"===c.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||d)){delete e.video.facingMode;var u=void 0;if("environment"===c.exact||"environment"===c.ideal?u=["back","rear"]:"user"!==c.exact&&"user"!==c.ideal||(u=["front"]),u)return r.mediaDevices.enumerateDevices().then(function(t){var r=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return e.label.toLowerCase().includes(t)})});return!r&&t.length&&u.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=c.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=a(e.video),i("chrome: "+JSON.stringify(e)),o(e)})}e.video=a(e.video)}return i("chrome: "+JSON.stringify(e)),o(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(r.getUserMedia=function(e,t,n){o(e,function(e){r.webkitGetUserMedia(e,t,function(e){n&&n(s(e))})})}.bind(r),r.mediaDevices.getUserMedia){var c=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return o(e,function(e){return c(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(s(e))})})}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js")).log},{"../utils.js":11}],6:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimRTCIceCandidate=function(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":n(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 r=new t(e),i=o.default.parseCandidate(e.candidate),a=Object.assign(r,i);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,s.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})},r.shimMaxMessageSize=function(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),n=e.sdpSemantics;"plan-b"===n&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;var t=o.default.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=o.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){var i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),a=function(e){var r=65536;"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637);return r}(i),s=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=o.default.matchPrefix(e.sdp,"a=max-message-size:");i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637);return n}(arguments[0],i),c=void 0;c=0===a&&0===s?Number.POSITIVE_INFINITY:0===a||0===s?Math.max(a,s):Math.min(a,s);var d={};Object.defineProperty(d,"maxMessageSize",{get:function(){return c}}),this._sctp=d}return r.apply(this,arguments)}},r.shimSendThrowTypeError=function(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=r.apply(this,arguments);return t(e,this),e},s.wrapPeerConnectionEvent(e,"datachannel",function(e){return t(e.channel,e.target),e})},r.shimConnectionState=function(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"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 r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})},r.removeExtmapAllowMixed=function(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return r.apply(this,arguments)}},r.shimAddIceCandidateNullOrEmpty=function(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;var r=e.RTCPeerConnection.prototype.addIceCandidate;if(!r||0===r.length)return;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}};var i,a=e("sdp"),o=(i=a)&&i.__esModule?i:{default:i},s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("./utils"))},{"./utils":11,sdp:13}],7:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimOnTrack=function(e){"object"===(void 0===e?"undefined":n(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}}})},r.shimPeerConnection=function(e,t){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection);t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r;return e}({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]});var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),n=e[0],a=e[1],o=e[2];return i.apply(this,[n||null]).then(function(e){if(t.version<53&&!a)try{e.forEach(function(e){e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(a,o)}},r.shimSenderGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.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)}},r.shimReceiverGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});o.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}},r.shimRemoveStream=function(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype)return;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)})}},r.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},r.shimAddTransceiver=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(function(e){if("rid"in e){if(!/^[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 n=t.apply(this,arguments);if(r){var i=n.sender,a=i.getParameters();"encodings"in a&&(1!==a.encodings.length||0!==Object.keys(a.encodings[0]).length)||(a.encodings=e.sendEncodings,i.sendEncodings=e.sendEncodings,this.setParametersPromises.push(i.setParameters(a).then(function(){delete i.sendEncodings}).catch(function(){delete i.sendEncodings})))}return n})},r.shimGetParameters=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCRtpSender)return;var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})},r.shimCreateOffer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}},r.shimCreateAnswer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)}}},{}],9:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator,a=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){i.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":n(e))&&"object"===n(e.audio)&&(e=JSON.parse(JSON.stringify(e)),o(e.audio,"autoGainControl","mozAutoGainControl"),o(e.audio,"noiseSuppression","mozNoiseSuppression")),s(e)},a&&a.prototype.getSettings){var c=a.prototype.getSettings;a.prototype.getSettings=function(){var e=c.apply(this,arguments);return o(e,"mozAutoGainControl","autoGainControl"),o(e,"mozNoiseSuppression","noiseSuppression"),e}}if(a&&a.prototype.applyConstraints){var d=a.prototype.applyConstraints;a.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":n(e))&&(e=JSON.parse(JSON.stringify(e)),o(e,"autoGainControl","mozAutoGainControl"),o(e,"noiseSuppression","mozNoiseSuppression")),d.apply(this,[e])}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11}],10:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimLocalStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;"getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams});if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(function(n){return t.call(r,n,e)}),e.getVideoTracks().forEach(function(n){return t.call(r,n,e)})},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=Array(n>1?n-1:0),a=1;a=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}})}),t.apply(e,arguments)}}},r.shimCallbacksAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype,r=t.createOffer,i=t.createAnswer,a=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n};var c=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=c,c=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=c,c=function(e,t,r){var n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=c},r.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(a(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))},r.shimConstraints=a,r.shimRTCIceServerUrls=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],a=0;a=r&&parseInt(n[r],10)}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function c(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach(function(n){n.endsWith("Id")?c(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach(function(t){c(e,e.get(t),r)})}))}},{}],12:[function(e,t,r){},{}],13:[function(e,t,r){var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},n.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},n.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),r},n.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},n.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},n.getCryptoParameters=function(e,t){return n.matchPrefix(e+t,"a=crypto:").map(n.parseCryptoLine)},n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0],i=n.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){r+=n.writeExtmap(e)}),r},n.parseRtpEncodingParameters=function(e){var t,r=[],i=n.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,d=n.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});d.length>0&&d[0].length>1&&d[0][0]===c&&(t=d[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),a&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},r.push(n))}}),0===r.length&&c&&r.push({ssrc:c});var u=n.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,r.forEach(function(e){e.maxBitrate=u})),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var a=n.matchPrefix(e,"a=rtcp-mux");return t.mux=a.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var i=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),i=n.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var a=n.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var o=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var i=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,i){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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 o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,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:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a},n.getDirection=function(e,t){for(var r=n.splitLines(e),i=0;i-1}function U(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Me.prototype.set=function(e,t){var r=this.__data__,n=Oe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new Ce,map:new(fe||Me),string:new Ce}},Pe.prototype.delete=function(e){return Ue(this,e).delete(e)},Pe.prototype.get=function(e){return Ue(this,e).get(e)},Pe.prototype.has=function(e){return Ue(this,e).has(e)},Pe.prototype.set=function(e,t){return Ue(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,i),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.clear=function(){this.__data__=new Me},Re.prototype.delete=function(e){return this.__data__.delete(e)},Re.prototype.get=function(e){return this.__data__.get(e)},Re.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Me){var i=n.__data__;if(!fe||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ie:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ot(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function st(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||st(e)&&oe.call(e)==k}var dt=j?function(e){return function(t){return e(t)}}(j):function(e){return st(e)&&at(e.length)&&!!O[oe.call(e)]};function ut(e){return nt(e)?De(e):He(e)}function lt(e){return e}e.exports=function(e,t){return e&&e.length?function(e,t,n){var i=-1,a=V,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=U;else if(o>=r){var u=t?null:je(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}var Si;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(Si||(Si={}));const{JOIN_ROOM_ERROR:yi,ERROR_RECONNECT_FAILED:ki}=Yn;class _i extends bi{constructor(e,t,r,n,i,a=["subscribe","publish"]){super(),this.privileges=[],this.rpcid=si(16),this.startInitTime=-1,this.startAuthTime=0,this.initWs=((e=!1,t,r)=>new Promise((n,i)=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.close(),this.ws.onclose=null),e)this.ws=t,this.setUrl(r);else{this.startInitTime=Date.now();try{this.wsConnectTimeoutID=setTimeout(()=>{this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close());const t=this.wsConnectTimeout/1e3+"s timeout";gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,socket_connect_error_message:t,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=Si.CONNECTING}catch(e){throw kn(`init signaling websocket faild!\nError: ${e}`)}}this.ws.onerror=this.onWsError,this.ws.onclose=this.onWsClose.bind(this,n,i);const a=()=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.emit("ws:onopen"),jr.log("signaling: websocket open",this.url),e||(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!0,event_grade:An.NORMAL,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Hr,capsdp:this.capsdp,msgsn:this.customMsgNumber,supportdomain:!0,privileges:this.privileges};this.playerdata&&(t.playerdata=this.playerdata),this.startAuthTime=Date.now(),this.request("auth",t).then(t=>{switch(0!==t.code&&(gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:t.code,auth_error_message:t.error,auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.SERVERE,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.startAuthTime=0),t.code){case 0:this.ws.onclose=this.onWsClose.bind(this,null,null),this.reconnectToken=t.reconntoken,jr.log("signaling: websocket authed"),this._state=Si.OPEN,gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:0,auth_error_message:"",auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.emit("@signalingauth",t),this.startAuthTime=0,n(t);break;case 10001:case 10002:case 10011:case 10022:case 10012:case 10004:this.emit("@error",t),i(ki(t.error));break;case 10005:this.emit("@error",t),i(ki(t.error));case 10052:if(jr.debug("10052 auth, retry",e),this.reconnectToken=void 0,e){i(yi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(Xn(10054,t.error));break;default:i(kn(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=Si.CLOSED,this.release())})};this.ws.onopen=(()=>{a()}),e&&a()})),this.onWsMsg=(e=>{const t=e.data;this.emit("ws:onmessage",t);const r=t.indexOf("=");if(!(r>0))throw kn(`signaling model can not parse message: ${t}`);{const e=t.substring(0,r),n=JSON.parse(t.substring(r+1));this.receiveWsMsg(e,n)}}),this.onWsError=(e=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),jr.warning("signaling: websocket error",e),this.emit("@ws:error",e),-1!==this.startInitTime&&(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:""}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw Bn();const r=JSON.stringify(t);try{this.ws.send(`${e}=${r}`),this.emit("send",e,t)}catch(e){throw jr.warning("signaling: websocket send error",e),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)}),Bn()}}),this.handlePing=(()=>{this.sendWsMsg("pong",{}),this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.reconnectTimeoutID=setTimeout(()=>{jr.debug("signaling: websocket heartbeat timeout"),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)})},9e3)}),this.receiveWsMsg=((e,t)=>{switch(this.emit("receive",e,t),e){case"ping":this.handlePing();break;case"auth-res":this.emit("@auth-res",t);case"pubpc-res":case"subpc-res":case"pub-tracks":case"webrtc-candidate":case"on-player-in":case"on-player-out":case"disconnect":case"mute-tracks":case"on-add-tracks":case"on-remove-tracks":case"on-player-reconnect":case"on-player-reconnect-in":this.emit(e,t);break;case"sub-res":case"unsub-res":this.emit(e,t),this.emit(`${e}-${t.streamid}`,t);break;case"control-res":this.emit(e,t),this.emit(`${e}-${t.command}-${t.playerid}`,t);break;case"on-pubpc-connected":case"on-pubpc-disconnected":this.emit("on-pubpc-state",{pcid:t.pcid,connected:"on-pubpc-connected"===e}),this.emit(`${e}-${t.pcid}`,t);break;case"on-subpc-disconnected":case"on-subpc-connected":this.emit("on-subpc-state",{pcid:t.pcid,connected:"on-subpc-connected"===e}),this.emit(e,t);break;case"pub-tracks-res":this.emit(e,t);break;case"on-messages":case"on-qos-messages":t.messages=t.messages.sort((e,t)=>e.msgsn-t.msgsn),this.customMsgNumber=t.messages[t.messages.length-1].msgsn,this.emit(e,t);break;case"unpub-tracks-res":case"sub-tracks-res":case"unsub-tracks-res":case"on-pubpc-restart-notify":case"on-subpc-restart-notify":case"set-sub-profile-res":case"on-sub-profile-changed":case"pubpc-restart-res":case"subpc-restart-res":case"create-merge-job-res":case"create-forward-job-res":case"stop-forward-res":case"on-job-connected":case"on-job-disconnected":case"on-merge-job-connected":case"on-merge-job-disconnected":case"update-merge-tracks-res":case"set-privileges-res":case"start-media-relay-res":case"update-media-relay-res":case"stop-media-relay-res":case"on-media-relay-state":this.emit(e,t)}}),this.accessToken=e,this.capsdp=t,this.reconnectTimes=r,this.wsConnectTimeout=n,this.playerdata=i,this.privileges=a,this._state=Si.CONNECTING}set _state(e){this.emit("@ws-state-change",this.__state,e),this.__state=e}get state(){return this.__state}set reconnectTimes(e){this._reconnectTimes=e,this.currentLeftReconnectTimes=e}get reconnectTimes(){return this._reconnectTimes}setUrl(e){this.url=e+`?rpcid=${this.rpcid}`}onWsClose(e,t,r){this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this._state=Si.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:r.code,auth_error_message:r.toString(),auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:this.url,auth_reason:"connect"});let n=this.reconnectPromise;switch(r.code){case 1e3:this.emit("@closed");break;case 1001:case 1005:case 1006:n=this.reconnect();break;case 1007:case 1008:case 1009:case 1010:break;case 1011:n=this.reconnect();break;case 1012:n=this.reconnect(5e3);break;case 1013:n=this.reconnect();break;case 1014:n=this.reconnect(5e3)}e&&t&&(n?n.then(e).catch(e=>{jr.warning("signaling: reconnect error",e)}):t(r))}sendDisconnect(){if(this.state===Si.OPEN)try{this.sendWsMsg("disconnect",{})}catch(e){}}reconnect(e=1e3){return this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.reconnectPromise&&this._state===Si.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=Si.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=ci(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=Si.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=si(8);return t.rpcid=r,jr.log("ws request",r,e,t),this.sendWsMsg(e,t),new Promise(t=>{const n=i=>{i.rpcid===r&&(jr.log("ws response",r,e,i),this.off(`${e}-res`,n),t(i))};this.on(`${e}-res`,n)})}release(){this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.removeEvent(),this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close())}}class wi{}class Ei{constructor(e,t,r,n){this.videoTrackInfo=[],this.audioTrackInfo=[],this.layoutLevel=0,this.width=e,this.height=t,this.jobID=n,this.controller=r,this.controller.getCurrentTracks().forEach(e=>{"audio"===e.kind?this.audioTrackInfo.push(e):this.videoTrackInfo.push(e)}),this.controller.addMergeTrack(this.audioTrackInfo.map(e=>({trackID:e.trackID})),this.jobID),this.initLayout(),this.controller.onAddTracks=(e=>{const t=e.filter(e=>"audio"===e.kind),r=e.filter(e=>"video"===e.kind);this.controller.addMergeTrack(t.map(e=>({trackID:e.trackID})),this.jobID),r.forEach(this.handleAddVideoTrack.bind(this))}),this.controller.onRemoveTracks=(e=>{e.filter(e=>"video"===e.kind).forEach(this.handleRemoveVideoTrack.bind(this))}),jr.log("init default merger, init layout: ",this.layout)}initLayout(){const e=this.videoTrackInfo.length;this.layoutLevel=0,this.layout={"level-0":{items:{"item-0":{x:0,y:0,isExpand:!1,isExpanded:!1,index:0}},itemWidth:this.width,itemHeight:this.height,maxItems:1,currentItems:0,splitWidthFlag:this.width=this.height;if(0!==e){for(;Math.pow(2,this.layoutLevel)=this.height?a:0,y:this.width{const n=this.layout[`level-${this.layoutLevel-1}`].items[r],i=2*n.index;t[`item-${i}`]={x:n.x,y:n.y,isExpand:!1,isExpanded:!1,index:i},t[`item-${i+1}`]=e?{x:n.x+a,y:n.y,isExpand:!1,isExpanded:!1,index:i+1}:{x:n.x,y:n.y+o,isExpand:!1,isExpanded:!1,index:i+1}})}jr.log(`merger: increase layout level, current level: ${this.layoutLevel}`,this.layout)}setLevelLayoutStream(){const e=this.videoTrackInfo.length,t=this.layout[`level-${this.layoutLevel}`];let r=t.maxItems-e,n=0;for(let e=0;e0?e%2==0?(t.items[`item-${e}`].isExpand=!0,t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1):(t.items[`item-${e}`].isExpanded=!0,r-=1):(t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1);t.currentItems=e}sendMergeOpt(e,t){const r=this.layout[`level-${e}`],n=r.items[`item-${t}`];if(!n.trackID||n.isExpanded)return;let i=r.itemWidth,a=r.itemHeight;n.isExpand&&(r.splitWidthFlag?i*=2:a*=2);const o={x:n.x,y:n.y,w:i,h:a,z:0,trackID:n.trackID};this.controller.addMergeTrack([o],this.jobID)}handleRemoveVideoTrack(e){M(this.videoTrackInfo,t=>t.trackID===e.trackID);const t=this.layout[`level-${this.layoutLevel}`];if(this.layoutLevel>0&&this.videoTrackInfo.length<=this.layout[`level-${this.layoutLevel-1}`].maxItems)this.layoutLevel-=1,jr.log(`merger: reduce layout level, current level: ${this.layoutLevel}`,this.layout),this.setLevelLayoutStream();else for(const r in t.items){const n=t.items[r];if(n.trackID===e.trackID){n.index%2==0?(t.items[`item-${n.index+1}`]?(n.isExpand=!0,n.trackID=t.items[`item-${n.index+1}`].trackID,t.items[`item-${n.index+1}`].isExpanded=!0,t.items[`item-${n.index+1}`].trackID=void 0):n.trackID=void 0,this.sendMergeOpt(this.layoutLevel,n.index)):(n.isExpanded=!0,n.trackID=void 0,t.items[`item-${n.index-1}`].isExpand=!0,this.sendMergeOpt(this.layoutLevel,n.index-1));break}}}handleAddVideoTrack(e){const t=this.videoTrackInfo.length;if(this.videoTrackInfo.push(e),this.videoTrackInfo=mi(this.videoTrackInfo,"trackID"),this.videoTrackInfo.length===t)return void jr.log("handle add video track ignore",e);const r=this.layout[`level-${this.layoutLevel}`];if(this.videoTrackInfo.length<=r.maxItems){for(const t in r.items){const n=r.items[t];if(!n.trackID){n.trackID=e.trackID,n.isExpanded&&(n.isExpanded=!1,r.items[`item-${n.index-1}`].isExpand=!1,this.sendMergeOpt(this.layoutLevel,n.index-1)),this.sendMergeOpt(this.layoutLevel,n.index);break}}r.currentItems=this.videoTrackInfo.length}else this.updateLayoutLevel(!r.splitWidthFlag),this.setLevelLayoutStream()}release(){this.controller.release()}}function Ci(e){const t=document.createElement("audio"),r=new MediaStream([e]);return t.style.visibility="hidden",t.className="qnrtc-audio-player qnrtc-stream-player",t.dataset.localid=e.id,t.srcObject=r,t.autoplay=!0,t}function Mi(e){const t=document.createElement("video"),r=new MediaStream([e]);return t.style.width="100%",t.style.height="100%",t.style.objectFit="contain",t.muted=!0,t.className="qnrtc-video-player qnrtc-stream-player",t.dataset.localid=e.id,t.setAttribute("playsinline",!0),t.autoplay=!0,t.srcObject=r,T&&(t.setAttribute("controls",!0),ai(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),t}class Pi extends bi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=L.NORMAL,this.onended=(async e=>{"local"===this.direction?(jr.warning("track ended",this.mediaTrack,this.info.trackID),this.info.trackID&&this._selfEndedCallback&&await this._selfEndedCallback([this.info.trackID]),this.emit("ended",e),gn.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label,event_grade:An.SERVERE}),this.release()):this.emit("@ended",e)}),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.userID=t,r&&(this.direction=r),this.info={kind:e.kind,muted:!e.enabled,userID:this.userID,versionid:0,profiles:n||[]},this.handleMediaPause=this.handleMediaPause.bind(this)}async setPlaybackDevice(e){if(E.setPlaybackDevice||wn("setPlaybackDevice api not support"),this.playbackDevice=e,this.mediaElement)return this.mediaElement.setSinkId(e)}play(e,t,r={mirror:!1}){return new Promise((n,i)=>{this.removeMediaElement();const a="video"===this.info.kind?Mi:Ci;this.mediaElement=a(this.mediaTrack),"audio"===this.info.kind&&void 0!==t&&(this.mediaElement.muted=t),r.mirror?this.mediaElement.style.transform="rotateY(180deg)":this.mediaElement.style.transform="",this.mediaElement.setAttribute("controls",!0),e.appendChild(this.mediaElement),this.mediaElement.onplaying=(()=>{this.mediaElement.onplaying=null,n()}),Promise.resolve().then(()=>{if(this.mediaElement.removeAttribute("controls"),this.playbackDevice)return this.setPlaybackDevice(this.playbackDevice)}).then(()=>{(function(e,t=3e3){const r=async()=>{if(e.paused)return e.play()};return new Promise((n,i)=>{const a=setTimeout(()=>{r().then(n).catch(i)},t);e.onloadedmetadata=(()=>{clearTimeout(a),r().then(n).catch(i)}),"WeixinJSBridge"in window?window.WeixinJSBridge.invoke("getNetworkType",{},()=>{r().then(n).catch(ni)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(ni)},!1)})})(this.mediaElement).then(n).catch(e=>{const t=e instanceof Error?e.name+", "+e.message:"play failed"+String(e);"NotAllowedError"===e.name?(i(En(t)),gn.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t,event_grade:An.SERVERE})):i(kn(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(li),900)}switchPlayingTrack(){if(this.mediaElement){if(this.isReplacedByImageTrack&&this.imageStreamTrack)this.mediaElement.srcObject=new MediaStream([this.imageStreamTrack.mediaTrack]);else{if(this.isReplacedByImageTrack||!this.mediaTrack)return;this.mediaElement.srcObject=new MediaStream([this.mediaTrack])}this.mediaElement.paused||this.mediaElement.play().catch(li)}}resume(e){if(this.mediaTrack.removeEventListener("ended",this.onended),this.mediaTrack.stop(),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.mediaElement){const t=new MediaStream([e]);this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t}this.removeEvent("@get-stats"),this.resetStats()}getStats(){return this.statsInterval||this.startGetStatsInterval(),this.stats}getCurrentFrameDataURL(){return this.mediaElement&&this.mediaElement instanceof HTMLVideoElement?function(e){const t=document.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;const r=t.getContext("2d");return r?(r.drawImage(e,0,0,e.videoWidth,e.videoHeight),t.toDataURL()):"data:,"}(this.mediaElement):"data:,"}setMaster(e){this.master=e}setMute(e){this.info.muted=e,this.mediaTrack.enabled=!e,this.emit("mute",e)}setKbps(e){this.info.kbps=e}setInfo(e){this.info=t({},this.info,e)}removeMediaElement(){this.mediaElement&&(this.mediaElement.removeEventListener("pause",this.handleMediaPause),this.mediaElement.remove(),this.mediaElement=void 0)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),"local"!==this.direction&&E.unifiedPlan||this.mediaTrack.stop(),this.removeMediaElement(),this.imageStreamTrack&&(this.imageStreamTrack.release(),this.imageStreamTrack=void 0)}reset(){this.info.trackID=void 0,this.info.userID=void 0,this.info.versionid=0,this.userID=void 0,this.resetStats()}resetStats(){this.stats=[],this.lastStats=[]}async startGetStatsInterval(){this.statsInterval=window.setInterval(async()=>{const e=this.getListeners("@get-stats");if(!e||0===e.length)return[];this.stats=await this.safeEmitAsPromise("@get-stats",this.lastStats),this.lastStats=[...this.stats]},1e3)}set selfEndedCallback(e){this._selfEndedCallback=e}setVolume(e){jr.warning("not implement")}getCurrentTimeDomainData(){return jr.warning("not implement"),new Uint8Array}getCurrentFrequencyData(){return jr.warning("not implement"),new Uint8Array}getVolume(){return jr.warning("not implement"),0}getCurrentVolumeLevel(){return jr.warning("not implement"),0}setLoop(e){jr.warning("not implement")}startAudioSource(){jr.warning("not implement")}pauseAudioSource(){jr.warning("not implement")}resumeAudioSource(){jr.warning("not implement")}stopAudioSource(){jr.warning("not implement")}getCurrentTime(){return jr.warning("not implement"),0}setCurrentTime(e){jr.warning("not implement")}getDuration(){return jr.warning("not implement"),0}}class Ii{static loadImage(e){if(e instanceof File)return Ii.loadImageFromFile(e);if(e instanceof ArrayBuffer)return Ii.loadImageFromArrayBuffer(e);if("string"==typeof e)return Ii.loadImageFromUrl(e);throw wn("unsupported image source")}static loadImageFromUrl(e){return new Promise((t,r)=>{var n=new Image;n.crossOrigin="Anonymous",n.src=e,n.onload=function(){t(n)},n.onerror=function(e){r(e)}})}static loadImageFromFile(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=(e=>{n.result&&t(Ii.loadImageFromUrl(n.result))}),n.onerror=(e=>{r(e)}),n.readAsDataURL(e)})}static loadImageFromArrayBuffer(e){return new Promise((t,r)=>{const n=new Blob([e]),i=URL.createObjectURL(n);t(Ii.loadImageFromUrl(i))})}}class Ri{constructor(){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}async setSource(e){e!==this.source&&(this.source=e,await this.createImageStreamTrack(e))}get id(){if(this.mediaTrack)return this.mediaTrack.id}async createImageStreamTrack(e){let t;t=e instanceof File?await Ii.loadImageFromFile(e):e instanceof ArrayBuffer?await Ii.loadImageFromArrayBuffer(e):await Ii.loadImageFromUrl(e),this.canvas.width=t.width,this.canvas.height=t.height,this.drawIntervalId&&clearInterval(this.drawIntervalId),this.drawIntervalId=setInterval(()=>{this.ctx.drawImage(t,0,0)},900);const r=this.canvas.captureStream(1);this.mediaTrack=r.getTracks()[0]}release(){this.drawIntervalId&&clearInterval(this.drawIntervalId)}}class Di{constructor(){this.recordedChunks=[]}releaseMediaElement(){jr.log("Recorder release Media Element",this.mediaElement),this.mediaElement&&this.mediaElement.parentElement&&this.mediaElement.parentElement.removeChild(this.mediaElement)}release(){this.recorder&&"inactive"!==this.recorder.state&&this.recorder.stop(),this.recorder=void 0,this.recordedChunks=[],this.recordedBlob=void 0,this.recordedUrl&&(window.URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=void 0),this.releaseMediaElement()}setMimeType(e){if(jr.log("Recorder setMimeType, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");return!!window.MediaRecorder.isTypeSupported(e)&&(this.mimeType=e,!0)}start(e){if(jr.log("Recorder start, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw kn("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw kn("MediaRecorder is active, cannot start again.");if(e.reduce((e,t)=>("video"===t.mediaTrack.kind&&(e[0]+=1),"audio"===t.mediaTrack.kind&&(e[1]+=1),e),[0,0]).some(e=>e>1))throw kn("Invalid parameters.");this.release();try{const t=new MediaStream(e.map(e=>e.mediaTrack)),r=window;if(this.mimeType){const e={mimeType:this.mimeType};this.recorder=new r.MediaRecorder(t,e)}else this.recorder=new r.MediaRecorder(t);this.recorder.ondataavailable=(e=>{jr.debug("Recorder data, ",e.data),this.recordedChunks.push(e.data)}),this.recorder.start(Di.recorderTimeslice)}catch(e){throw kn("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw kn("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw kn("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw kn("MediaRecorder is in inactive state, cannot do stop.");try{if(this.recorder.stop(),this.mimeType){const e={type:this.mimeType};this.recordedBlob=new Blob(this.recordedChunks,e)}else this.recordedBlob=new Blob(this.recordedChunks);return this.recordedUrl=window.URL.createObjectURL(this.recordedBlob),this.recordedBlob}catch(e){throw kn("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw kn("No recorded data, please start record first.");this.releaseMediaElement();const r=document.createElement("video");return r.style.width="100%",r.style.height="100%",r.style.objectFit="contain",r.controls=!0,r.muted=t,r.className="qnrtc-recorder-video-player",r.setAttribute("playsinline",!0),r.autoplay=!0,r.src=this.recordedUrl,e.appendChild(r),this.mediaElement=r,new Promise((e,t)=>{let n;try{n=r.play()}catch(e){t(e)}n?n.then(e).catch(e=>{t(e);try{throw kn("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw kn("No recorded data, please start record first.");const t=document.createElement("a");t.style.display="none",t.href=this.recordedUrl,t.download=e,document.body.appendChild(t),t.click(),setTimeout(()=>{document.body.removeChild(t)},100)}}Di.recorderTimeslice=1e3;class Oi{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class xi{constructor(e,t,r,n,i){this._connectStatus=B.Idle,this.track=r,this.trackID=n,this.mid=i,this.transport=e,this.direction=t}get connectStatus(){return this._connectStatus}set connectStatus(e){if(e!==this._connectStatus){const t=this._connectStatus;this._connectStatus=e,ai(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=B.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===B.Connect&&e(),n===B.Idle&&t()})})}appendConsumner(e,t){this.consumer=new Oi(this.trackID,this.mid,t,e),this.transport.appendConsumer(this.consumer)}setMute(e){this.track&&this.track.setMute(e)}addTrackId(e){this.track&&(this.trackID=e,this.track.setInfo({trackID:e}))}release(){this.consumer&&this.transport?(this.transport.recvHandler.isPcReady&&this.transport.removeConsumers([this.consumer]),this.track&&this.track.release()):this.track&&this.track.reset()}}const Bi=window.AudioContext||window.webkitAudioContext||window.Object,Li=E.audioContextOptions?new Bi({latencyHint:"interactive"}):new Bi;if(window.audioContext=Li,window.Promise){const e=()=>{(function(e){return new Promise((t,r)=>{if("suspended"===e.state){jr.log("audio context state is suspended");const n=()=>{e.resume().then(()=>{document.body.removeEventListener("touchstart",n),document.body.removeEventListener("touchend",n),document.body.removeEventListener("mousedown",n),document.body.removeEventListener("mouseup",n),t(!0)}).catch(r)};document.body.addEventListener("touchstart",n,!0),document.body.addEventListener("touchend",n,!0),document.body.addEventListener("mousedown",n,!0),document.body.addEventListener("mouseup",n,!0),n()}else t(!1)})})(Li).then(e=>{jr.debug("web audio context unlocked",e)}).catch(e=>{jr.warning("can not unlock web audio context",e)}),window.removeEventListener("load",e)};document.body?e():window.addEventListener("load",e),Li.onstatechange=(()=>{e()})}const Gi=2048,Ni=4096,Hi=["play","playing","pause","ended","waiting","seeking"];class Fi extends bi{constructor(){super(),this.audioSource=null,this._audioSourceState=H.IDLE,this.bufferSourceDuration={startTime:0,pauseTime:0,lastPauseTime:0,offsetTime:0,stopTime:0},this.handleMediaElementEvents=(e=>{switch(e.type){case"playing":case"play":this.audioSourceState=H.PLAY;break;case"waiting":case"seeking":this.audioSourceState=H.LOADING;break;case"ended":this.audioSourceElement&&(this.audioSourceElement.currentTime=0),this.audioSourceState=H.END}})}get audioSourceState(){return this._audioSourceState}set audioSourceState(e){e!==this._audioSourceState&&(this.emit("@audio-source-state-change",e,this._audioSourceState),this._audioSourceState=e)}initAudioContext(){jr.log("init audio context",Li.state),"suspended"===Li.state&&(jr.log("audio context suspended"),Li.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",Li.state),this.analyserNode=Li.createAnalyser(),this.analyserNode.fftSize=Gi,this.gainNode=Li.createGain(),function(e){if(E.disconnectAudioNode)return;const t=e.connect,r=e.disconnect;e.connect=((r,n,i)=>(e._inputNodes||(e._inputNodes=[]),r instanceof AudioNode?(e._inputNodes.push(r),e._inputNodes=mi(e._inputNodes,e=>e),t.call(e,r,n,i)):t.call(e,r,n),e)),e.disconnect=((t,n,i)=>{if(!t)return r.call(e),void(e._inputNodes=[]);r.call(e,t,n,i),M(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),E.mediaStreamDest&&(this.audioStream=Li.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=Li.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=Li.createBufferSource(),this.audioSource.onended=(()=>{this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Li.currentTime,this.audioSourceState=H.END}),this.connect()}setMediaElementSource(e){this.audioSource=Li.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Hi)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.isAudioSource()?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.isAudioSource()&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.isAudioSource()){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Li.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(li)):null===this.audioSource&&this.audioSourceBuffer&&(this.resetBufferSourceDuration(),this.setAudioBufferSource(),this.setAudioBuffer(this.audioSourceBuffer),this.setAudioSourceLoop(!!this.audioSourceLoop),this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Li.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY)}resumeAudioSource(){if(this.isAudioSource()){if(this.audioSourceState!==H.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=Li.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=H.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(li)}pauseAudioSource(){this.isAudioSource()?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=Li.currentTime),this.audioSourceState=H.PAUSE):this.audioSourceElement&&(this.audioSourceElement.pause(),this.audioSourceState!==H.END&&(this.audioSourceState=H.PAUSE))}stopAudioSource(e=!1,t=!1){this.isAudioSource()?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Li.currentTime,e||!1!==t||(this.audioSourceState=H.STOP)):this.audioSourceElement&&(!1===t&&(this.audioSourceState=H.STOP),this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.isAudioSource()){let e=Li.currentTime;const t=this.getAudioSourceDuration();this.bufferSourceDuration.lastPauseTime&&(e=this.bufferSourceDuration.lastPauseTime),this.bufferSourceDuration.stopTime&&(e=this.bufferSourceDuration.stopTime);const r=this.bufferSourceDuration.offsetTime+e-this.bufferSourceDuration.startTime-this.bufferSourceDuration.pauseTime;return Math.max(0,r%t)}return 0}setAudioSourceCurrentTime(e){this.audioSourceElement?this.audioSourceElement.currentTime=e:this.isAudioSource()&&(this.stopAudioSource(!0),this.playAudioSource(e))}getAudioSourceDuration(){return this.audioSourceElement?this.audioSourceElement.duration:this.audioSourceBuffer?this.audioSourceBuffer.duration:0}release(){if(this.audioSource instanceof MediaStreamAudioSourceNode&&this.audioSource.mediaStream&&this.audioSource.mediaStream.getTracks().map(e=>e.stop()),this.audioSource&&this.audioSource.disconnect(),this.gainNode.disconnect(),this.audioSourceElement){for(const e of Hi)this.audioSourceElement.removeEventListener(e,this.handleMediaElementEvents);this.audioSourceElement.src="",this.audioSourceElement.load(),this.audioSourceElement.remove(),this.audioSourceElement=void 0}this.scriptNode&&this.scriptNode.disconnect()}connect(){this.audioSource?(this.audioSource.connect(this.analyserNode),this.audioSource.connect(this.gainNode),this.audioStream&&(this.gainNode.connect(this.audioStream),this.onAudioBuffer())):jr.warning("no audio source, can not connect")}handleAudioBuffer(e){const t=e.inputBuffer;this.emit("audioBuffer",t),this.audioBufferCallback&&this.audioBufferCallback(t)}onAudioBuffer(e,t=Ni){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=Li.createScriptProcessor(t),this.audioSource.connect(this.scriptNode),this.scriptNode.connect(this.audioStream),this.scriptNode.onaudioprocess=this.handleAudioBuffer.bind(this)))}resetBufferSourceDuration(){this.bufferSourceDuration={offsetTime:0,startTime:0,lastPauseTime:0,pauseTime:0,stopTime:0}}isAudioSource(){const{audioSource:e}=this;return e instanceof AudioBufferSourceNode||e instanceof AudioScheduledSourceNode}}const ji=0;class Vi extends Pi{constructor(e,t,r){if("audio"!==e.kind)throw new Error("audio track only!");super(e,t,r),this.mediaStream=new MediaStream,this.mediaStream.addTrack(e)}resume(e){this.mediaTrack=e,this.removeEvent("@get-stats"),this.resetStats();const t=new MediaStream([e]);this.mediaStream=t,this.mediaElement&&(this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t),this.audioManager&&(this.audioManager.release(),this.initAudioManager())}initAudioManager(e){this.audioManager=new Fi,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&E.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){this.audioManager.gainNode.gain.setValueAtTime(e,Li.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Gi);return this.audioManager.analyserNode.getByteTimeDomainData(e),e}getCurrentFrequencyData(){const e=new Uint8Array(this.audioManager.analyserNode.frequencyBinCount);return this.audioManager.analyserNode.getByteFrequencyData(e),e}getVolume(){return this.audioManager.gainNode.gain.value}getCurrentVolumeLevel(){const e=this.getCurrentFrequencyData();let t=0,r=e.length;return e.forEach((n,i)=>{const a=i*(Li.sampleRate||44100)/e.length;if(a>22050)return void(r-=1);const o=function(e){const t=e*e;return 1.2588966*14884e4*t*t/((t+424.36)*Math.sqrt((t+11599.29)*(t+544496.41))*(t+14884e4))}(a)*n/255;o<=ji?r-=1:t+=o*o}),0===r?0:Math.sqrt(t/r)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),this.audioManager&&this.audioManager.release(),this.removeMediaElement(),this.mediaTrack.stop()}}var Ui=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i};var qi=function(e,t){if(null==e)return{};var r,n,i=Ui(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i};const Wi="\n";var zi=u(function(e){var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach(function(e){t[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})}),Xi=(zi.v,zi.o,zi.s,zi.i,zi.u,zi.e,zi.p,zi.z,zi.r,zi.t,zi.c,zi.b,zi.m,zi.a,u(function(e,t){var r=function(e){return String(Number(e))===e?Number(e):e},n=function(e,t,n){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var a=e.push?{}:i?t[e.name]:t;!function(e,t,n,i){if(i&&!n)t[i]=r(e[1]);else for(var a=0;a1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),i=0;i=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})}.apply(null,n)},Ji=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Zi=["i","c","b","a"],$i={write:function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var r=t.outerOrder||Ji,n=t.innerOrder||Zi,i=[];return r.forEach(function(t){zi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Qi(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Qi(t,r,e))})})}),e.media.forEach(function(e){i.push(Qi("m",zi.m[0],e)),n.forEach(function(t){zi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Qi(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Qi(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Xi.parse,parseParams:Xi.parseParams,parseFmtpConfig:Xi.parseFmtpConfig,parsePayloads:Xi.parsePayloads,parseRemoteCandidates:Xi.parseRemoteCandidates,parseImageAttributes:Xi.parseImageAttributes,parseSimulcastStreamList:Xi.parseSimulcastStreamList};const Yi="qiniu-rtc-client";function ea(e){return e.map(e=>{const t={component:1,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,transport:e.protocol,type:e.type};return e.tcpType&&(t.tcptype=e.tcpType),t})}class ta{constructor(e,t){this.lastSubMids=[],this.sessionVersion=0,this.direction=e,this.extendedRtpCapabilities=t}get transportRemoteParameters(){return this._transportRemoteParameters}async setTransportRemoteParameters(e){for(const t of e.iceCandidates)t.ip=await hi(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");return E.unifiedPlan?function(e,t,r,n,i){const a=$i.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Yi},o.name="-",o.timing={start:0,stop:0},o.icelite=t.iceParameters.iceLite?"ice-lite":void 0,o.msidSemantic={semantic:"WMS",token:"*"},o.media=[],o.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};for(const r of a.media){const a="inactive"===r.direction,s=r.type,c="audio"===s?e.codecs[0]:e.codecs[1],d=e.headerExtensions.filter(e=>e.kind===s),u={type:r.type,port:i&&i.has(String(r.mid))?0:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:r.mid,iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ea(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"sendonly"===r.direction||"sendrecv"===r.direction?"recvonly":"inactive",rtp:[{payload:c.sendPayloadType,codec:c.name,rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}],rtcpFb:[],fmtp:[{payload:c.sendPayloadType,config:Object.keys(c.parameters).map(e=>`${e}=${c.parameters[e]};`).join("")}],payloads:c.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:d.map(e=>({uri:e.uri,value:e.sendId}))};c.rtcpFeedback&&c.rtcpFeedback.length>0&&c.rtcpFeedback.forEach(e=>{u.rtcpFb.push({payload:c.sendPayloadType,type:e.type,subtype:e.parameter})}),c.sendRtxPayloadType&&(u.rtp.push({payload:c.sendRtxPayloadType,codec:"rtx",rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}),u.fmtp.push({payload:c.sendRtxPayloadType,config:`apt=${c.sendPayloadType};`}),u.payloads=`${c.sendPayloadType} ${c.sendRtxPayloadType}`),na(s,u,e,c);const l=n[u.mid];"video"===u.type&&l&&!a&&(u.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],u.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(u)}const s=(a.media||[]).filter(e=>e.hasOwnProperty("mid")&&0!==e.port).map(e=>String(e.mid));s.length>0&&(o.groups=[{type:"BUNDLE",mids:s.join(" ")}]);return $i.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=$i.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Yi},n.name="-",n.timing={start:0,stop:0},n.icelite=t.iceParameters.iceLite?"ice-lite":void 0,n.msidSemantic={semantic:"WMS",token:"*"},n.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};const i=[];for(const r of n.media){const n=r.type,a=e.codecs.find(e=>e.kind===n),o=(e.headerExtensions||[]).filter(e=>e.kind===n);if(!a)throw kn("can not find codec"+n);const s={type:n,mid:n,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ea(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"recvonly",rtp:[{payload:a.sendPayloadType,codec:a.name,rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}],rtcpFb:[],fmtp:[{payload:a.sendPayloadType,config:Object.keys(a.parameters).map(e=>`${e}=${a.parameters[e]};`).join("")}],payloads:a.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:o.map(e=>({uri:e.uri,value:e.sendId}))};a.rtcpFeedback&&a.rtcpFeedback.length>0&&a.rtcpFeedback.forEach(e=>{s.rtcpFb.push({payload:a.sendPayloadType,type:e.type,subtype:e.parameter})}),a.sendRtxPayloadType&&(s.rtp.push({payload:a.sendRtxPayloadType,codec:"rtx",rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}),s.fmtp.push({payload:a.sendRtxPayloadType,config:`apt=${a.sendPayloadType};`}),s.payloads=`${a.sendPayloadType} ${a.sendRtxPayloadType}`),i.push(s)}return n.media=i,$i.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");if(E.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=M(e,e=>e.mid===n)[0];t&&r.push(t)}return r=r.concat(e),t=r.map(e=>e.mid),r}(e,this.lastSubMids);return this.lastSubMids=t.map(e=>e.mid),this.sessionVersion+=1,function(e,t,r,n){jr.debug("consumerInfos",e);const i={},a=e.map(e=>e.mid);i.version=0,i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:n,username:Yi},i.name="-",i.timing={start:0,stop:0},i.icelite=r.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},a.length>0&&(i.groups=[{type:"BUNDLE",mids:a.join(" ")}]);i.media=[],i.fingerprint={type:r.dtlsParameters.fingerprints[0].algorithm,hash:r.dtlsParameters.fingerprints[0].value};for(const n of e){const e="audio"===n.kind?t.codecs[0]:t.codecs[1],a=t.headerExtensions.filter(e=>e.kind===n.kind),o={type:n.kind,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:n.mid,msid:`${n.streamId} ${n.trackID}`,iceUfrag:r.iceParameters.usernameFragment,icePwd:r.iceParameters.password,candidates:ea(r.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===r.dtlsParameters.role?"actpass":"active",direction:n.closed?"inactive":"sendonly",rtp:[{payload:e.recvPayloadType,codec:e.name,rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}],rtcpFb:[],fmtp:[{payload:e.recvPayloadType,config:Object.keys(e.parameters).map(t=>`${t}=${e.parameters[t]};`).join("")}],payloads:e.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:n.closed?[]:a.map(e=>({uri:e.uri,value:e.recvId})),ssrcs:!n.closed&&n.ssrc?[{id:n.ssrc,attribute:"cname",value:n.cname}]:[],ssrcGroups:[]};e.rtcpFeedback&&e.rtcpFeedback.length>0&&e.rtcpFeedback.forEach(t=>{o.rtcpFb.push({payload:e.recvPayloadType,type:t.type,subtype:t.parameter})}),e.recvRtxPayloadType&&(o.rtp.push({payload:e.recvRtxPayloadType,codec:"rtx",rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}),o.fmtp.push({payload:e.recvRtxPayloadType,config:`apt=${e.recvPayloadType};`}),o.payloads=`${e.recvPayloadType} ${e.recvRtxPayloadType}`),na(n.kind,o,t,e,!0),n.rtxSsrc&&!n.closed&&(o.ssrcs=o.ssrcs.concat([{id:n.rtxSsrc,attribute:"cname",value:n.cname}]),o.ssrcGroups.push({semantics:"FID",ssrcs:`${n.ssrc} ${n.rtxSsrc}`})),i.media.push(o)}return $i.write(i)}(t,this.extendedRtpCapabilities,this.transportRemoteParameters,this.sessionVersion)}{const t=new Set;return e.forEach(e=>t.add(e.kind)),0===e.length&&(t.add("audio"),t.add("video")),function(e,t,r,n){e=["audio","video"];const i={version:0};i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:2,username:Yi},i.name="-",i.timing={start:0,stop:0},i.icelite=n.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},i.groups=[{type:"BUNDLE",mids:e.join(" ")}],i.media=[],i.fingerprint={type:n.dtlsParameters.fingerprints[0].algorithm,hash:n.dtlsParameters.fingerprints[0].value};for(const a of e){const e=t.filter(e=>e.kind===a),o=r.codecs.find(e=>e.kind===a),s=(r.headerExtensions||[]).filter(e=>e.kind===a);if(!o)throw kn("no codec"+a);const c={type:a,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:a,iceUfrag:n.iceParameters.usernameFragment,icePwd:n.iceParameters.password,candidates:ea(n.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===n.dtlsParameters.role?"actpass":"active",direction:"sendonly",rtp:[{payload:o.recvPayloadType,codec:o.name,rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}],rtcpFb:[],fmtp:[{payload:o.recvPayloadType,config:Object.keys(o.parameters).map(e=>`${e}=${o.parameters[e]};`).join("")}],payloads:o.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ssrcs:[],ssrcGroups:[],ext:s.map(e=>({uri:e.uri,value:e.recvId}))};o.rtcpFeedback&&o.rtcpFeedback.length>0&&o.rtcpFeedback.forEach(e=>{c.rtcpFb.push({payload:o.recvPayloadType,type:e.type,subtype:e.parameter})}),o.recvRtxPayloadType&&(c.rtp.push({payload:o.recvRtxPayloadType,codec:"rtx",rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}),c.fmtp.push({payload:o.recvRtxPayloadType,config:`apt=${o.recvPayloadType};`}),c.payloads=`${o.recvPayloadType} ${o.recvRtxPayloadType}`);for(const t of e)c.ssrcs.push({id:t.ssrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.ssrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"cname",value:`${t.cname}`}),t.rtxSsrc&&(c.ssrcGroups.push({semantics:"FID",ssrcs:`${t.ssrc} ${t.rtxSsrc}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"cname",value:`${t.cname}`}));i.media.push(c)}return $i.write(i)}(Array.from(t),e,this.extendedRtpCapabilities,this.transportRemoteParameters)}}async updateICEData(e,t){if(this.transportRemoteParameters){for(const e of t)e.ip=await hi(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function ra(e){const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});return t.sdp?{isH264:-1!==t.sdp.toLowerCase().indexOf("h264"),sdp:t.sdp}:{isH264:!1,sdp:""}}function na(e,t,r,n,i=!1){const a=r.codecs.filter(t=>t.kind===e&&t.name!==n.name);if(a.length>0){let e=i?n.recvPayloadType:n.sendPayloadType;const r=[];a.forEach(n=>{const a=i?n.recvPayloadType:n.sendPayloadType;r.push(a),t.rtp.push({payload:a,codec:n.name,rate:n.clockRate,encoding:n.channels>1?n.channels:void 0}),t.fmtp.push({payload:a,config:`${e}/${e}`})}),t.payloads=`${t.payloads} ${r.join(" ")}`}}function ia(e){const t=$i.parse(e);if(!("media"in t))return $i.write(t);if(!Array.isArray(t.media))return $i.write(t);for(const e of t.media)"ext"in e&&Array.isArray(e.ext)&&"video"===e.type&&(e.ext=e.ext.filter(e=>"urn:3gpp:video-orientation"!==e.uri));return $i.write(t)}class aa extends bi{constructor(e,t,r){super(),this._isRestartingICE=!1,this.isPcReady=!1,this.midRidEncoding={},this.removeMids=new Set,this.lastMediaStatistics=[],this.intervalId=-1,this.playQualityIntervalId=-1,this.qualityStats=new Map,this._direction=e,this._pc=lo(),this._extendedRtpCapabilities=t,this._remoteSdp=new ta(e,t),this._simulcast=!!r&&r.simulcast,this.coreInstance=r&&r.core,this._pc.addEventListener("iceconnectionstatechange",()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected"),this.registerMediaStatisticStatsReport(),this.registerPlayQualityReport();break;case"failed":this.emit("@connectionstatechange","failed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"disconnected":this.emit("@connectionstatechange","disconnected"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"closed":this.emit("@connectionstatechange","closed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport()}})}async getStats(e,r){return await async function(e,r,n,i){if(E.stats){const a=await async function(e,t,r){let n;try{n=await e.getStats(t)}catch(e){return jr.debug("get stats error, fallback to default",e),[]}if(!n)return jr.debug("get null stats, fallback to default"),[];const i=[];for(const e of n.values())if("send"===r&&"outbound-rtp"===e.type&&!e.isRemote||"recv"===r&&"inbound-rtp"===e.type&&!e.isRemote){const t=$a(),a=n.get(e.remoteId);t.packetLoss=co(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=so(e)||so(a)||0,t.id=e.id,t.kind=e.kind,e.frameWidth&&(t.width=e.frameWidth),e.frameHeight&&(t.height=e.frameHeight),e.framesPerSecond&&(t.frameRate=e.framesPerSecond),e.framerateMean&&(t.frameRate=Math.ceil(e.framerateMean)),i.push(t)}return i}(e,r,n);return function(e,r){if(!r||0===r.length)return e;if(r.length!==e.length)return e;const n=Object.values(Nr([...e,...r],"id"));if(!n.every(e=>2===e.length))return e;return n.map(([e,r])=>{const n=(e.timestamp-r.timestamp)/1e3;if(n<=0)return e;const i=t({},e),a=uo(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=Ya(a,i.rtt);const o=Ja(e.id,e.kind);return o.Apply(a),i.packetLossRate=o.Filtered()<0?0:o.Filtered(),i.bitrate=8*(e.bytes-r.bytes)/n,i.bitrate<0?r:i})}(a,i)}return ui(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}(this._pc,e,this._direction,r)}registerPlayQualityReport(){"send"!==this._direction&&(this.unregisterPlayQualityReport(),this.playQualityIntervalId=window.setInterval(async()=>{const e=await async function(e,t){let r;try{r=await e.getStats()}catch(e){return ui(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return ui(()=>{jr.debug("get null media statistic stats, fallback to default")},"getStats error"),[];const n=[...r.values()];return t.subscribedTracks.map(e=>{const t=e.mediaTrack,r=n.find(e=>e.type===io.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===io.InBoundRtp&&e.trackId===r.id);return i?{time:Date.now(),trackID:e.info.trackID,kind:"video"===i.kind?"video":"audio",framesDecoded:i.framesDecoded||-1,totalSamplesReceived:i.totalSamplesReceived||-1}:void 0}).filter(G)}(this._pc,this.coreInstance);for(const t of e){const e=this.qualityStats.get(t.trackID);e?e.push(t):this.qualityStats.set(t.trackID,[t])}this.addQualityStats()},2e3))}unregisterPlayQualityReport(){"send"!==this._direction&&-1!==this.playQualityIntervalId&&(window.clearInterval(this.playQualityIntervalId),this.addQualityStats(!0),this.playQualityIntervalId=-1)}addQualityStats(e=!1){const t=[...this.qualityStats.values()];if(t.some(e=>e.length>=30)||e){jr.log("quality stats",this.qualityStats);for(const e of t){if(0===e.length)continue;const t=e[0].trackID,r=2*e.length*1e3;if("video"===e[0].kind){const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].framesDecoded===e[n-1].framesDecoded?t+2:t,0);gn.addEvent("VideoPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}else{const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].totalSamplesReceived===e[n-1].totalSamplesReceived?t+2:t,0);gn.addEvent("AudioPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}}this.qualityStats=new Map}}registerMediaStatisticStatsReport(){this.unregisterMediaStatisticStatsReport(),this.intervalId=window.setInterval(async()=>{const e=await async function(e,r){let n;try{n=await e.getStats()}catch(e){return jr.debug("get media statistic stats error, fallback to default",e),[]}if(!n)return jr.debug("get null media statistic stats, fallback to default"),[];const i=[...n.values()];return i.filter(e=>(e.type===io.InBoundRtp||e.type===io.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[io.MediaSource]:r.filter(e=>e.type===io.MediaSource).find(t=>t.id===e.mediaSourceId),[io.Track]:r.filter(e=>e.type===io.Track).find(t=>t.id===e.trackId),[io.RemoteInBound]:r.filter(e=>e.type===io.RemoteInBound).find(t=>t.id===e.remoteId)};let a=function(e,r,n){const i={id:e,track_id:r,kind:"audio",kbps:0,framerate:0,packet_lost_rate:0,rtt:0,extra_stats:null,calculation_stats:t({},ro)};n===no.Audio?i.extra_stats=t({},eo):i.extra_stats=t({},to);return i}(e.id,e.trackID,e.mediaType);a.rtt=so(i[io.RemoteInBound])||so(e)||0,a.calculation_stats.packets_lost=co(e,i[io.RemoteInBound])||0,e.mediaType===no.Video?(a=function(e,t){return t.kind=e.kind,t.extra_stats.nack_count=e.nackCount,t.extra_stats.fir_count=e.firCount,t.extra_stats.pli_count=e.pliCount,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.frame_encoded=e.framesEncoded||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.frame_decoded=e.framesDecoded||0,t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[io.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[io.MediaSource],a)),i[io.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.width=e.frameWidth,t.extra_stats.height=e.frameHeight,t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[io.Track],a,n))):(a=function(e,t){return t.kind=e.kind,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.track_audio_volume=oo(e.audioLevel,e.type),t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[io.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=oo(e.audioLevel,e.type),t}(i[io.MediaSource],a)),i[io.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[io.Track],a,n)));return a})(e,i,r))}(this._pc,this.coreInstance);e&&e.length>0&&(this.addMediaStatistics(e,this.lastMediaStatistics),this.lastMediaStatistics=e)},3e3)}unregisterMediaStatisticStatsReport(){-1!==this.intervalId&&(window.clearInterval(this.intervalId),this.lastMediaStatistics=[],this.intervalId=-1)}addMediaStatistics(e,r){const n=e.map(e=>{const n=Za(e.id,e.kind),i=r.find(t=>t.id===e.id);if(!i)return e;const a=i.calculation_stats,{calculation_stats:o}=e,s=qi(e,["calculation_stats"]);return t({},s,function(e,t,r){if(!e||!t)return{framerate:0,kbps:0,packet_lost_rate:0};const n=(e.timestamp-t.timestamp)/1e3,i=0===n?0:(e.frames_sent-t.frames_sent+(e.frames_received-t.frames_received))/n,a=0===n?0:(e.bytes_sent-t.bytes_sent+(e.bytes_received-t.bytes_received))/(1024*n/8),o=uo(t.packets_lost,e.packets_lost,t.packets_received+t.packets_sent,e.packets_received+e.packets_sent);r.Apply(o);const s=r.Filtered()<0?0:100*r.Filtered();return{framerate:Math.ceil(i),kbps:Math.ceil(a),packet_lost_rate:Math.ceil(s)}}(o,a,n))});jr.log("media statistics",n),gn.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=Ya(n.sort((e,t)=>t.packet_lost_rate-e.packet_lost_rate)[0].packet_lost_rate,n.sort((e,t)=>t.rtt-e.rtt)[0].rtt);bn(i);const a=n.map(e=>({kind:e.kind,lostRate:e.packet_lost_rate,rtt:e.rtt,track:e.track_id}));this.emit("@send-qos-message",{qos:JSON.stringify({networkGrade:i,tracks_qos:a})})}getCurrentIceConnectionState(){return this._pc.iceConnectionState}close(){jr.log("handle",this._direction,"close"),this.removeEvent(),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport(),this._pc.close(),this.isPcReady=!1}}class oa extends aa{constructor(e,t,r){super("send",e,r),jr.log("init send handler"),this._transportReady=!1,this._stream=new MediaStream,this._signaling=t,t.on("on-pubpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))})}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-pubpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-pubpc-state",n)})}addProducerTracks(e){jr.debug("add producer",e);const t=e.filter(e=>!this._stream.getTrackById(e.mediaTrack.id));if(0===t.length)return Promise.reject(new Error("track already added"));let r;const n=[];let i,a=!0;return Promise.resolve().then(async()=>{for(const e of t)this._stream.addTrack(e.mediaTrack);if(E.unifiedPlan&&E.supportTransceivers)for(const e of t){const t=await Ao(e.mediaTrack,this._pc,e.lowStreamConfig,e.info.kbps);jr.debug("add transceiver",t,t.mid),n.push(t)}else jr.debug("add tracks",t),r=t.map(e=>this._pc.addTrack(e.mediaTrack,this._stream));return ca(this._pc,this._simulcast)}).then(e=>{let t;return E.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Wi}`),t={type:"offer",sdp:e.sdp},i=t.sdp,jr.log("publish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{for(const t of n){if(!t.sender.track)continue;const r=e.find(e=>e.mediaTrack===t.sender.track);if(!r||!t.mid)throw kn("can not get transceiver mid!");r.setInfo({mid:t.mid}),this.midRidEncoding[t.mid]=r.lowStreamConfig}if(!this._transportReady)return a=!1,this._setupTransport(e)}).then(()=>this._remoteSdp.createRemoteAnswer(i,this.midRidEncoding,this.removeMids)).then(e=>{const t={type:"answer",sdp:e};return jr.debug("addProducer answer",t),this._pc.setRemoteDescription(t)}).then(()=>this._pcReady).then(()=>a?this.safeEmitAsPromise("@needpubtracks",e,i):Promise.resolve(this._remoteSdp.transportRemoteParameters)).catch(e=>{jr.log("add producer error",e);try{for(const e of r)this._pc.removeTrack(e);for(const e of n)e.direction="inactive"}catch(e){}for(const e of t)this._stream.removeTrack(e.mediaTrack);throw e instanceof Sn?e:kn(e)})}removeProducerTracks(e){jr.debug("removeProducerTracks",e);const t=e.filter(e=>void 0!==e.track&&!!this._stream.getTrackById(e.track.mediaTrack.id)).map(e=>e.track.isReplacedByImageTrack?e.track.imageStreamTrack.mediaTrack:e.track.mediaTrack);let r;return Promise.resolve().then(()=>{E.unifiedPlan&&E.supportTransceivers&&this._pc.getTransceivers().forEach(e=>{e.sender.track&&e.mid&&t.includes(e.sender.track)&&this.removeMids.add(e.mid)});const e=this._pc.getSenders().filter(e=>e.track&&t.includes(e.track));if(0===e.length)return jr.warning("removeProducerTracks [nothing to remove]"),Promise.reject("removeProducerTracks: nothing to remote");for(const t of e)this._pc.removeTrack(t);for(const e of t)this._stream.removeTrack(e);return ca(this._pc,this._simulcast)}).then(e=>{const t=new RTCSessionDescription(e);return r=t.sdp,jr.log("unpublish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(r,this.midRidEncoding,this.removeMids)};return jr.log("unpublish: set remote answer",e),this._pc.setRemoteDescription(e)}).catch(e=>{if(0!==this._stream.getTracks().length)throw e instanceof Sn?e:kn(e);jr.debug("removeProducer() | ignoring expected error due no sending tracks: %s",e.toString())}).then(()=>{this.safeEmitAsPromise("@needunpubtracks",e)})}async replaceTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");e.track&&(e.track.mediaTrack=t,e.track.removeMediaElement());const n=r.track;await r.replaceTrack(t),this._stream.removeTrack(n),this._stream.addTrack(t)}async replaceProducerTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");"image"===t?(jr.debug("replaceTrack",e.track.imageStreamTrack.mediaTrack),await r.replaceTrack(e.track.imageStreamTrack.mediaTrack)):"video"===t&&(jr.debug("replaceTrack",e.track.mediaTrack),await r.replaceTrack(e.track.mediaTrack))}restartICE(e,t){return jr.log("restart send ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>ca(this._pc,this._simulcast,{iceRestart:!0})).then(e=>this._pc.setLocalDescription(e)).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(this._pc.localDescription.sdp,this.midRidEncoding,this.removeMids)};return this._pc.setRemoteDescription(e)})}_setupTransport(e){const t=Date.now();return Promise.resolve().then(()=>this._pc.localDescription?this._pc.localDescription:ca(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(gn.addEvent("PublisherPC",{signal_take_time:Date.now()-t,result_code:r.code,up_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),this.pcid=r.pcid,this._transportReady=!0,this._pcReady=this.getReady(r),this._remoteSdp.setTransportRemoteParameters(r)))}}class sa extends aa{constructor(e,t,r){super("recv",e,r),this._transportCreated=!1,this._consumerInfos=new Map,this._signaling=t,t.on("on-subpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))}),jr.log("init recvhandler",this)}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-subpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-subpc-state",n)})}async addConsumerTracks(e){if(E.unifiedPlan&&g){const t=[];for(const r of e){const e=await this.addConsumerTrack(r);t.push(e)}return t}jr.log("add consumers",e);const t=[],r=Array.from(this._consumerInfos.values());for(const n of e){const e=r.find(e=>e.consumerId===n.id);if(e&&!e.closed)t.push(e);else{const e=this.genNewConsumerInfo(n);if(E.unifiedPlan){const t=n.mid;e.mid=t,this._consumerInfos.set(t,e)}else this._consumerInfos.set(n.id,e);t.push(e)}}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>(E.unifiedPlan,this._pc.createAnswer())).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{for(let r=0;r!!e.receiver.track&&(e.receiver.track.id===n.trackID||e.mid===n.mid));e&&(i.track=e.receiver.track)}else if(E.getReceivers){const e=this._pc.getReceivers().find(e=>{const{track:t}=e;return!!t&&n.trackID===t.id});e&&(i.track=e.track)}else{const e=this._pc.getRemoteStreams().find(e=>e.id===n.streamId);e&&(i.track=e.getTrackById(n.trackID))}if(!i.track)throw kn("remote track not found");jr.log("subscribe: get new track",i.track)}}return e.map(e=>e.track)})}genNewConsumerInfo(e){const t=e.rtpParameters.encodings[0],r=e.rtpParameters.rtcp.cname,n=e.mid;return{kind:e.kind,streamId:E.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:E.unifiedPlan?`consumer-${e.kind}-${n}`:`consumer-${e.kind}-${t.ssrc}`,ssrc:t.ssrc,rtxSsrc:t.rtx?t.rtx.ssrc:void 0,cname:r,consumerId:e.id,closed:!1}}async addConsumerTrack(e){jr.log("add consumer",e);let t=null;const r=Array.from(this._consumerInfos.values()).find(t=>t.consumerId===e.id);if(r&&!r.closed)t=r;else{const r=this.genNewConsumerInfo(e);if(E.unifiedPlan){const t=e.mid;r.mid=t,this._consumerInfos.set(t,r)}else this._consumerInfos.set(e.id,r);t=r}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("set ontrack"),this._pc.ontrack=(e=>{jr.log("ontrack",e.receiver.track)}),jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{let r=null;if(E.unifiedPlan&&E.supportTransceivers&&e&&t){const n=this._pc.getTransceivers().find(r=>!!r.receiver.track&&((r.receiver.track.id===t.trackID||r.mid===t.mid)&&(e.track=r.receiver.track,!0)));n&&(r=n.receiver.track)}else if(e&&t){const n=this._pc.getReceivers().find(r=>{const{track:n}=r;return!!n&&(t.trackID===n.id&&(e.track=n,!0))});n&&(r=n.track)}if(!r&&e)throw kn("remote track not found");return jr.log("subscribe: get new track",r,r.readyState),r})}removeConsumerTracks(e){jr.log("remove consumer",e);let t=!1;for(const r of e){const e=Array.from(this._consumerInfos.values()).find(e=>e.consumerId===r.id&&!e.closed);e?(t=!0,E.unifiedPlan?(r.track=null,e.closed=!0):this._consumerInfos.delete(r.id)):jr.log("can not find unpublish track target, ignore")}return t?Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("unsubscribe set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.log("unsubscribe set local answer",e),this._pc.setLocalDescription(e))):Promise.resolve()}restartICE(e,t){return jr.log("recv restart ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>{this._pc.setLocalDescription(e)})}async setupTransport(e){if(this._transportCreated)return await this._pcReady;const t=Date.now(),r=await this.safeEmitAsPromise("@needsubpc",e);return gn.addEvent("SubscriberPC",{signal_take_time:Date.now()-t,result_code:r.code,down_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(e=>({track_id:e.trackid,status:e.status}))}),this.pcid=r.pcid,this._transportCreated=!0,this._pcReady=this.getReady(r),jr.log("init subscribe, get transport remote",r),await this._remoteSdp.setTransportRemoteParameters(r),r}}function ca(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=ia(n),"chrome"===b.name&&t&&(n=function(e,t){const r=$i.parse(e);t&&"chrome"===b.name&&(r.media=r.media.map(e=>{if(!e.ssrcGroups||0===e.ssrcGroups.length||!e.ssrcs||0===e.ssrcs.length)return e;const r=e.ssrcGroups.find(e=>"FID"===e.semantics);if(!r)return e;const[n,i]=r.ssrcs.split(" ").map(e=>parseInt(e,10));let a,o;e.ssrcs.forEach(e=>{"cname"===e.attribute&&(a=e.value),"msid"===e.attribute&&(o=e.value)});const s=[];if(s.push(n),t>=2){const t=n+1,r=i+1;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}if(t>=3){const t=n+2,r=i+2;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}return e.ssrcGroups.push({semantics:"SIM",ssrcs:s.join(" ")}),e}));const n=$i.write(r).split("\r\n");let i=n.findIndex(e=>0===e.indexOf("a=ssrc-group:FID"));for(;-1!==i&&0===n[i].indexOf("a=ssrc-group:FID");){const e=n[i].split(" ")[2];for(let t=i-1;t>=0;t--)if(n[t].indexOf(e)>0){n.splice(t+1,0,n[i]),n.splice(i+1,1);break}i++}return n.join("\r\n")}(n,3)),{type:r,sdp:n}):e})}function da(e,t,r,n){switch(e){case"send":return new oa(t,r,n);case"recv":return new sa(t,r,n)}}var ua;!function(e){e.SEND_TRACKS="@transport:send-tracks",e.RESTART_SEND_ICE="@transport:send-restart-ice",e.REMOVE_TRACKS="@transport:remove-tracks",e.INIT_RECV="@transport:init-recv",e.RESTART_RECV_ICE="@transport:recv-restart-ice",e.ADD_CONUMERS="@transport:add-consumers",e.REMOVE_CONSUMERS="@transport:remove-consumers"}(ua||(ua={}));class la extends bi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Vr("SendQueue"),this.recvCommandQueue=new Vr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=da("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=da("recv",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),this.handleRecvHandler(),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this)),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this)),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e})}get publishTracks(){return Array.from(this._publishTracks.values())}resolveInitSubPcPromise(){this.initSubPcPromiseResolve&&(this.initSubPcPromiseResolve(),this.initSubPcPromiseResolve=void 0)}handleSendHandler(){this.sendHandler.on("@needpubpc",(e,t,r,n)=>{this.safeEmitAsPromise("@needpubpc",e,t).then(r).catch(n)}).on("@connectionstatechange",e=>{switch(jr.log("pubpc connectionstatechange",e),gn.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartSendICE(this.sendHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.sendHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartSendICE(this.sendHandler.pcid))})}}).on("@needpubtracks",(e,t,r,n)=>{const i=e.map(yo),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(gn.addEvent("PublishTracks",{signal_take_time:Date.now()-a,result_code:t.code,tracks:t.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),t.code){case 0:break;case 10052:return n(Zn());case 10061:return this.reconnectProducer(),n(qn(10061,t.error));default:return n(qn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(qn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{gn.addEvent("UnPublishTracks",{tracks:e.map(e=>({track_id:e.trackID}))}),this.signaling.request("unpub-tracks",{tracks:e.map(e=>({trackid:e.trackID}))}).then(e=>{t(e)})}).on("@send-qos-message",e=>{this.signaling.request("send-qos-message",e)})}async sendTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(ua.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(ua.REMOVE_TRACKS,e)}async restartSendICE(e){return E.supportRestartICE?this.sendCommandQueue.push(ua.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case ua.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case ua.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case ua.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new xi(this,"send",e));for(const e of t)this._publishTracks.set(e.track.mediaTrack.id,e);return t}removeTrackFromPublishTracks(e){for(const t of e)this._publishTracks.delete(t.mediaTrack.id)}async _execAddProducerTracks(e){const t=await this.sendHandler.addProducerTracks(e.map(e=>e.track));for(const r of e){const e=ri(t.tracks,"localid",r.track.mediaTrack.id);e&&(r.addTrackId(e.trackid),r.track.setInfo({versionid:e.versionid}),r.track.resetStats())}return e.map(e=>e.connectStatus=B.Connect),t}_execRemoveTracks(e){return this.removeTrackFromPublishTracks(e.map(e=>e.track)),e.map(e=>e.release()),this.sendHandler.removeProducerTracks(e)}async _execRestartSendICE(e){this.sendHandler._isRestartingICE=!0;const t=await this.signaling.request("pubpc-restart",{pcid:e});if(0!==t.code)return this.sendHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.reconnectProducer();try{await this.sendHandler.restartICE(t.iceParameters,t.iceCandidates),this.sendHandler._isRestartingICE=!1}catch(e){jr.debug("restart ice faild",t.code,t.error),this.sendHandler._isRestartingICE=!1,this.reconnectProducer()}}reconnectProducer(){this.resetSendCommandQueue(),this.sendHandler.close();const e=this.publishTracks;this.sendHandler=da("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=B.Connecting}),this.emit("@needrepub",e)}handleRecvHandler(){this.recvHandler.on("@needsubpc",(e,t,r)=>{this.safeEmitAsPromise("@needsubpc",e).then(t,r)}).on("@connectionstatechange",e=>{switch(jr.log("sub pc connection state change",e),gn.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartRecvICE(this.recvHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.recvHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartRecvICE(this.recvHandler.pcid))})}})}appendConsumer(e){this.consumerQueue.push(e)}async addConsumers(){const e=this.consumerQueue;return this.consumerQueue=[],this.recvCommandQueue.push(ua.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(ua.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(ua.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return E.supportRestartICE?this.recvCommandQueue.push(ua.RESTART_RECV_ICE,e):this.resetRecvHandler()}async _removeConsumers(e){await this.recvHandler.removeConsumerTracks(e)}async _initRecvHandler(e){return this.recvHandler.isPcReady?(await this.initSubPcPromise,null):await this.recvHandler.setupTransport(e)}async _addConsumers(e){if(0===e.length)return Promise.resolve([]);return await this.recvHandler.addConsumerTracks(e)}async _execRestartRecvICE(e){this.recvHandler._isRestartingICE=!0;const t=await this.signaling.request("subpc-restart",{pcid:e});if(0!==t.code)return this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.resetRecvHandler();try{await this.recvHandler.restartICE(t.iceParameters,t.iceCandidates),this.recvHandler._isRestartingICE=!1}catch(e){this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),this.resetRecvHandler()}}handleRecvCommandTask(e,t){switch(e.method){case ua.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case ua.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case ua.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case ua.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Vr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Vr("RecvQueue"),this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this))}resetRecvHandler(){this.resetRecvCommandQueue(),this.emit("@needresetrecv"),this.recvHandler.close(),this.recvHandler=da("recv",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e}),this.handleRecvHandler(),this.emit("@needresub")}release(){this.recvHandler.close(),this.sendHandler.close(),this.publishTracks.forEach(e=>e.release())}}const Aa=new bi;function ha(e,t){return new Promise(r=>{let n;const i=Date.now(),a=new WebSocket(e);a.onopen=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!0,reason:"ok",connectTime:t})}),a.onerror=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"onerror",connectTime:t})}),n=setTimeout(()=>{const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"timeout",connectTime:t}),a.close()},t)})}var fa;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(fa||(fa={}));const pa={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class ma extends C{constructor(e=pa){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new Di,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=fa.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==fa.Connected)return void n(kn("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===dn.LIVE&&this._role===un.AUDIENCE)return void n(kn("no permission. Audience in Live mode has no permission to publish."));e.forEach(e=>e.userID=this.userID),e.forEach(e=>e.selfEndedCallback=this.unpublish.bind(this));const i=this.connectionTransport,a=this.signaling;let o;if(t){const t=e.map(e=>e.mediaTrack.id);o=i.publishTracks.filter(e=>-1!==t.indexOf(e.track.mediaTrack.id))}else{const t=i.publishTracks.map(e=>e.track.mediaTrack.id);if(e.filter(e=>-1===t.indexOf(e.mediaTrack.id)).length!==e.length)return void n(kn("there are already published tracks in the provided tracks"));o=i.addTrackToPublishTracks(e)}if(jr.debug("start publish",o,t),!t){const e=o.map(e=>e.startConnect());Promise.all(e).then(()=>r()).catch(()=>{n(Nn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=ri(this.users,"userID",this.userID);t&&(t.addTracks(o.map(e=>e.track)),t.addPublishedTrackInfo(o.map(e=>({trackID:e.trackID,muted:!!e.track.info.muted,kind:e.track.info.kind,tag:e.track.info.tag,userID:this.userID,versionid:e.track.info.versionid,profiles:e.track.info.profiles})))),e.forEach(e=>{e.on("@get-stats",(t,r,n)=>{if(!this.connectionTransport)return r([]);const i=e.isReplacedByImageTrack?e.imageStreamTrack.mediaTrack:e.mediaTrack;this.connectionTransport.sendHandler.getStats(i,t).then(r,n)})}),this.getAllMerger().forEach(t=>t.controller.onAddTracks(e.map(e=>e.info)))}catch(t){if(t instanceof Sn)switch(t.code){case 10061:case 30001:return;case 10052:return jr.warning(t,"republish"),void setTimeout(()=>this._publish(e,!0),1e3);default:i.removeTrackFromPublishTracks(e),n(t)}else jr.warning(t,"republish"),setTimeout(()=>this._publish(e,!0),1e3)}})),this._subscribe=((e,t,r=!1,n)=>new Promise(async(i,a)=>{if(this.roomState!==fa.Connected)return void a(kn("can not connected to the room, please joinRoom first"));if(0===e.length)return void i([]);jr.debug("subscribe",e,t);const o=this._trackInfo.filter(t=>e.includes(t.trackid));if(o.length!==e.length)return void a(Kn(10041,`can not find track in room ${e}`));let s;const c=this.connectionTransport,d=this.signaling;if(t)s=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));else{const e=this.subscribeTracks.map(e=>e.trackID),t=o.filter(t=>!e.includes(t.trackid));s=t.map(e=>new xi(c,"recv",void 0,e.trackid,e.mid)),this.subscribeTracks=this.subscribeTracks.concat(s)}n&&Object.entries(n).forEach(([e,t])=>{this.profiles.set(e,t)}),jr.log("sub tracks",s,n);try{if(!t){const e=s.map(e=>e.startConnect());Promise.all(e).then(()=>i(s.map(e=>e.track))).catch(()=>{a(Nn())})}let n=await c.initRecvHandler(s.map(e=>e.trackID));if(!n){const e=Date.now();n=await d.request("sub-tracks",{tracks:s.map(e=>{const t=e.trackID;return this.profiles.get(t)?{trackid:t,profile:this.profiles.get(t)}:{trackid:t}})}),gn.addEvent("SubscribeTracks",{result_code:n.code,signal_take_time:Date.now()-e,tracks:n.tracks.map(e=>({track_id:e.trackid,status:e.status}))})}switch(jr.log("get sub res data",n),n.code){case 0:break;case 10052:throw Zn();case 10062:throw c.resetRecvHandler(),Kn(10062,n.error);default:throw Kn(n.code,n.error)}const u=n.tracks.filter(e=>!!e.status),l=n.tracks.filter(e=>!e.status).map(e=>e.trackid);if(u.length-1!==l.indexOf(e.trackID));M(this.subscribeTracks,e=>-1!==l.indexOf(e.trackID)),e.map(e=>e.release())}n.tracks=u;for(const e of n.tracks||[]){const t=s.find(t=>t.trackID===e.trackid),r=o.find(t=>t.trackid===e.trackid);if(!t||!r)continue;const n=e.rtpparams;t.appendConsumner(n,r.kind)}await c.addConsumers(),c.resolveInitSubPcPromise();for(const e of s){const{consumer:t}=e;if(!t||!t.track)continue;const r=t.track;let n=e.track;const i=o.find(e=>e.trackid===t.id);if(!i)continue;n?n.resume(r):"audio"===r.kind?(n=new Vi(r,i.playerid,"remote")).initAudioManager():n=new Pi(r,i.playerid,"remote",i.profiles||[]),n.setInfo({trackID:i.trackid,userID:i.playerid,tag:i.tag,kind:i.kind,muted:i.muted,versionid:i.versionid}),n.setMaster(i.master),n.removeAllListeners("@get-stats"),n.removeAllListeners("@ended"),n.on("@get-stats",(e,t,r)=>{if(!this.connectionTransport)return t([]);this.connectionTransport.recvHandler.getStats(n.mediaTrack,e).then(t,r)}),n.once("@ended",async()=>{if(n&&n.info.trackID){jr.warning("remote track ended, try to resubscribe");try{await this._unsubscribe([n.info.trackID],!0)}catch(e){}await this._subscribe([n.info.trackID],!0)}}),e.track=n;const a=this.users.find(e=>e.userID===i.playerid);a&&a.addTracks([n])}s.forEach(e=>e.connectStatus=B.Connect);let A=n.tracks.map(e=>{if(void 0===e.muted)for(let t=0;t{e.consumer&&r.push(e.consumer)}),await c.removeConsumers(r),!(t instanceof Sn))return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);switch(t.code){case 10062:case 30001:return;case 10052:return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);default:M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},pa,e),this.config=e,jr.log("config",e),jr.log("version",Hr),jr.log("browser report",E,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(bo)}get roomState(){return this._roomState}set roomState(e){this._roomState!==e&&(this._roomState=e,jr.debug("roomState change",this._roomState),this.emit("room-state-change",this._roomState),gn.addEvent("RoomStateChanged",{room_state:e,event_grade:this._roomState===fa.Reconnecting?An.SERVERE:An.NORMAL,event_category:hn.CORE}))}_setReconnectTimes(e){this.config.reconnectTimes=e,this.signaling&&(this.signaling.reconnectTimes=e)}set simulcast(e){this.config.simulcast=e,this.connectionTransport&&(this.connectionTransport.simulcast=e,this.connectionTransport.sendHandler._simulcast=e,this.connectionTransport.recvHandler._simulcast=e)}_getReconnectTimes(){return this.config.reconnectTimes||pa.reconnectTimes}setRequestTimeout(e){this.config.requestTimeout=e}_setProfile(e,t){if(this.profile=t,this.profiles.set(e,t),!this.subscribeTracks.some(t=>t.trackID===e))return;this.signaling.sendWsMsg("set-sub-profile",{tracks:[{trackid:e,profile:this.profile}]})}getForwardJobTracks(){return this.forwardJobTracks}get publishedTracks(){return this.connectionTransport?this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==fa.Idle)throw kn("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===dn.RTC||this._mode===dn.LIVE&&this._role===un.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===dn.RTC)throw kn("client role can only be set in client mode LIVE.");if(e===un.AUDIENCE&&this.publishedTracks.length>0&&e===un.AUDIENCE)throw kn("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==fa.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(gn.addEvent("SetClientRole",{result_code:t.code,user_role:e===un.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Jn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();let n=0;this._mode===dn.LIVE&&(n=1);const i=this._role===un.BROADCASTER?0:1;if(gn.addEvent("JoinRoom",{room_token:e,user_data:t,room_type:n,user_role:i,audience_latency_level:0}),this.roomState!==fa.Idle)throw kn("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=fa.Connecting;try{this.roomToken=e,this.userData=t;const n=ti(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,gn.setUserBase(this.userID,this.roomName,this.appId),jr.log("join room, token:",e),jr.debug(`join room, roomName: ${this.roomName}, userID: ${this.userID}`),!this.roomName.match(/^[a-zA-Z0-9_-]{1,64}$/))throw this.roomState=fa.Idle,kn("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{1,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{1,50}$/))throw this.roomState=fa.Idle,kn("invalid userID. userID must match /^[a-zA-Z0-9_-]{1,50}$/");try{const t=await vi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,gn.setSessionId(t.sessionId),gn.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:0,join_node_info:this.signaling.url,join_error_message:"",event_grade:An.NORMAL,event_category:hn.CORE}),this._mode===dn.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=fa.Idle,jr.debug("joinRoomWithToken fail: "+t.message),gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:t.code?t.code:-1,join_node_info:this.signaling?this.signaling.url:"",join_error_message:t.message||t.error||"",event_grade:An.SERVERE,event_category:hn.CORE}),t}}async joinRoomWithAccess(e){const t=ei(e),{capsdp:r}=await async function(){let e=lo(),{isH264:t,sdp:r}=await ra(e),n=5;for(;!t&&n>0;)e.close(),e=lo(),({isH264:t,sdp:r}=await ra(e)),n--;E.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Wi}`);const i={capsdp:r=ia(r),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===fa.Idle)throw kn("roomState is idle, maybe because you left the room.");const n=new _i(e,r,this._getReconnectTimes(),this.config.requestTimeout,this.userData,this._privileges);n.on("@error",this.handleDisconnect.bind(this)).on("@ws-state-change",(e,t)=>{switch(t){case Si.CONNECTING:this.roomState===fa.Connected?this.roomState=fa.Reconnecting:this.roomState!==fa.Reconnecting&&(this.roomState=fa.Connecting)}}).on("@needupdateaccesstoken",(e,t)=>{this.updateAccessToken().then(e).catch(t)}).on("on-player-in",this.handlePlayerIn.bind(this)).on("on-player-out",this.handlePlayerOut.bind(this)).on("on-add-tracks",e=>{this.filterSignalTracks(e),this.handleAddTracks(e)}).on("on-remove-tracks",e=>{this.filterSignalTracks(e),this.handleRemoveTracks(e)}).on("mute-tracks",e=>{this.filterSignalTracks(e),this.handleMute(e)}).on("on-messages",this.handleCustomMessages.bind(this)).on("on-qos-messages",this.handleQosMessages.bind(this)).on("on-pubpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartRecvICE(e.pcid).catch(jr.debug)}).on("on-sub-profile-changed",e=>{this.emit("on-sub-profile-changed",e)}).on("on-job-connected",e=>{this.emit("forward-job-connected",{jobId:e.id})}).on("on-job-disconnected",e=>{this.emit("forward-job-disconnected",{jobId:e.id})}).on("on-merge-job-connected",e=>{this.emit("merge-job-connected",{jobId:e.id})}).on("on-merge-job-disconnected",e=>{this.emit("merge-job-disconnected",{jobId:e.id})}).on("on-media-relay-state",e=>{const t=e.roomid.slice(e.roomid.indexOf(":")+1);this.emit("media-relay-state-changed",t,e.state)}).on("disconnect",this.handleDisconnect.bind(this)).on("on-player-reconnect",this.handleRemoteUserReconnecting.bind(this)).on("on-player-reconnect-in",this.handleRemoteUserReconnected.bind(this)),jr.log("init signaling websocket"),this.signaling=n;try{let e;e=t.roomServers&&t.roomServers.length>0?t.roomServers.sort((e,t)=>t.score-e.score).map(e=>e.url):[t.signalingurl2];const{ws:r,url:i}=await function(e,t){let r=[],n=!1;return new Promise((i,a)=>{for(const o of e)ha(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:t.url,socket_connect_time:t.connectTime,socket_connect_success:t.status,socket_connect_error_message:t.reason,event_grade:n?An.NORMAL:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:"connect"}),r.length!==e.length||n||a(_n("websocket connect failed."))})})}(e,this.config.requestTimeout),a=await n.initWs(!0,r,i);n.on("@signalingauth",this.handleAuth.bind(this)),await this.handleAuth(a)}catch(e){if(this.signaling&&(this.signaling.release(),this.signaling=void 0),10052===e.code)return await ci(1e3),this.joinRoomWithToken(this.roomToken,this.userData);throw e}for(let e of this.users)e.userID!==this.userID&&this.emit("user-join",e);return this.trackInfoList.length>0&&this.emit("track-add",this.trackInfoList),this.users}async _unpublish(e){if(this.roomState!==fa.Connected)throw kn("not connected to the room");if(0===e.length)return;jr.debug("unpublish",e);const t=this.connectionTransport,r=t.publishTracks.filter(t=>-1!==e.indexOf(t.trackID));if(r.length!==e.length)throw kn("can not find target trackid to unpublish");await t.removeTracks(r),this.getAllMerger().forEach(e=>e.controller.onRemoveTracks(r.map(e=>e.track.info)));const n=ri(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==fa.Connected)throw kn("can not createMergeJob, room state is not connected");const n=t({},N,r,{id:e});jr.debug("send create merge job",n,e);const i=Date.now(),a=await this.signaling.request("create-merge-job",n);if(gn.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw Wn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==fa.Connected)throw kn("can not createForwardJob, room state is not connected");const t=!!e.audioTrackId&&!e.videoTrackId,r=[e.audioTrackId,e.videoTrackId].filter(Boolean).map(e=>({trackid:e})),n={id:e.jobId,publishUrl:e.publishUrl,audioOnly:t,tracks:r};if(e&&e.userConfigExtraInfo){if(i=e.userConfigExtraInfo,!(new Blob([i]).size<=1e3))throw kn("userConfigExtraInfo Up to 1000 Bytes");n.seiTemplate={value:e.userConfigExtraInfo}}var i;const a=Date.now(),o=await this.signaling.request("create-forward-job",n);if(gn.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw zn(o.code,o.error);this.forwardJobTracks[e.jobId]?jr.warning("forward job id already exist",e.jobId):(this.forwardJobTracks[e.jobId]=[],e.audioTrackId&&this.forwardJobTracks[e.jobId].push(e.audioTrackId),e.videoTrackId&&this.forwardJobTracks[e.jobId].push(e.videoTrackId))}async stopForwardJob(e){if(this.roomState!==fa.Connected)throw kn("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw kn(`no forward job id ${e}`);gn.addEvent("StopForwardJob",{id:e||""}),await this.signaling.request("stop-forward",{id:e,delayMillisecond:0}),delete this.forwardJobTracks[e]}setDefaultMergeStream(e,t,r){if(r&&!this.mergeJobTracks[r])throw Ln(r);this.merger&&!r&&(this.merger.release(),this.merger=void 0),r&&this.mergeJobMerger[r]&&(this.mergeJobMerger[r].release(),delete this.mergeJobMerger[r]);const n=this.CreateMergerSessionController();r?this.mergeJobMerger[r]=new Ei(e,t,n,r):this.merger=new Ei(e,t,n,r)}_stopMerge(e){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw Ln(e);gn.addEvent("StopMerge",{id:e||""}),this.signaling.sendWsMsg("stop-merge",{id:e}),e?(delete this.mergeJobTracks[e],this.mergeJobMerger[e]&&(this.mergeJobMerger[e].release(),delete this.mergeJobMerger[e])):(this.defaultMergeJobTracks=[],this.merger&&(this.merger.release(),this.merger=void 0))}async _addMergeTracks(e,t){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,add:r};jr.debug("addMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(gn.addEvent("UpdateMergeTracks",{id:t||"",add:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""})),result_code:i.code}),0!==i.code)throw Jn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r={id:t,remove:e.map(e=>({trackid:e}))};jr.debug("removeMergeTracks",r),M(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(gn.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Jn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,all:r,mode:1};jr.debug("updateMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e)),gn.addEvent("UpdateMergeTracks",{id:t||"",all:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""}))}),await this.signaling.request("update-merge-tracks",n)}async _unsubscribe(e,t){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));if(jr.debug("unsubscribe",r),0===r.length)return;const n=Date.now(),i=await this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))});gn.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e})),result_code:i.code,signal_take_time:Date.now()-n}),t||(r.forEach(e=>e.release()),M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer))}_muteTracks(e){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const t=this.connectionTransport,r={};e.forEach(e=>{r[e.trackID]=e.muted});const n=t.publishTracks.filter(e=>void 0!==r[e.trackID]);n.forEach(e=>{e.setMute(r[e.trackID])}),gn.addEvent("MuteTracks",{tracks:n.map(e=>({track_id:e.trackID,muted:e.track.info.muted,kind:e.track.info.kind}))}),this.signaling.sendWsMsg("mute-tracks",{tracks:e.map(e=>({trackid:e.trackID,muted:e.muted}))})}async kickoutUser(e){jr.log("kickoutUser",e),await this.control("kickplayer",e)}sendCustomMessage(e,t,r){if(this.roomState!==fa.Connected)throw kn("room state is not connected, can not send message");const n=r||si(8),i=t&&0!==t.length?t:void 0;this.signaling.sendWsMsg("send-message",{msgid:n,target:i,type:"normal",text:e}),jr.debug("send custom message",e,i,n)}async replaceTrack(e,t){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("replaceTrack",e,t);const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("pushCameraTrackWithImage",{trackID:e,source:t});const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw kn(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new Ri),void 0===t&&r.track.isReplacedByImageTrack?(await this.connectionTransport.sendHandler.replaceProducerTrack(r,"video"),r.track.isReplacedByImageTrack=!1,void r.track.switchPlayingTrack()):void 0!==t&&r.track&&!r.track.isReplacedByImageTrack?(await r.track.imageStreamTrack.setSource(t),await this.connectionTransport.sendHandler.replaceProducerTrack(r,"image"),r.track.isReplacedByImageTrack=!0,void r.track.switchPlayingTrack()):void 0}leaveRoom(){this.roomState!==fa.Idle?(jr.log("leave room"),gn.addEvent("LeaveRoom",{leave_reason_code:0}),this.signaling&&(Object.keys(this.forwardJobTracks).forEach(e=>this.stopForwardJob(e)),this.signaling.sendDisconnect()),this.releaseRoom()):jr.log("can not leave room, please join room first")}_releasePublishTracks(){}async control(e,t){if(this.roomState!==fa.Connected)throw kn("can not connected to the room, please run joinRoom first");const r=await this.signaling.request("control",{command:e,playerid:t});if(r.error)throw Qn(r.code,r.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),M(this._trackInfo,t=>t.playerid===e.playerid),M(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),ai(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=ko(e);this._users.set(t.userID,t),ai(()=>{jr.debug("user-join",t),this.emit("user-join",t)})}handleAddTracks({tracks:e}){jr.log("receive track-add",e,t({},this._trackInfo));const r=new Set;for(const t of e){const e=ri(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>So(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([bo(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))ai(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});ai(()=>{jr.debug("track-add",e.map(bo)),this.emit("track-add",e.map(bo))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=M(this._trackInfo,t=>e.map(e=>e.trackid).includes(t.trackid)),n=new Set;for(const e of r){const t=this._users.get(e.playerid);if(!t)continue;t.removePublishedTrackInfo([e.trackid]),t.removeTracksByTrackId([e.trackid]),n.add(t.userID);const r=M(this.subscribeTracks,t=>t.trackID===e.trackid)[0];r&&r.release()}if(this.cleanTrackIdsFromMergeJobs(e.map(e=>e.trackid)),"stream"===this.sessionMode)for(const e of Array.from(n)){const t=this._users.get(e);if(t.published){const e=t.publishedTrackInfo.map(e=>So(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else ai(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}ai(()=>{jr.debug("track-remove",r.map(bo)),this.emit("track-remove",r.map(bo))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=ri(this._trackInfo,"trackid",e);if(!n)return;const i=this._users.get(n.playerid);if(!i)return;const a=i.publishedTrackInfo.find(t=>t.trackID===e);a&&(a.muted=r);const o=i.tracks.find(t=>t.info.trackID===e);o&&(o.info.muted=r,o.setMute(r)),n.muted=r;const s=this.subscribeTracks.filter(t=>t.trackID===e)[0];s&&s.setMute(r);let c=void 0;for(let e=0;e{jr.log("user-mute",d),this.emit("user-mute",d)})}ai(()=>{jr.log("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted}))),this.emit("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted})))})}handleCustomMessages({messages:e}){this.emit("messages-received",e.map(To))}handleQosMessages({messages:e}){const t=[];e.forEach(e=>{try{const r=JSON.parse(e.qos);r.tracks_qos.forEach(n=>{t.push({userID:e.playerid,networkGrade:r.networkGrade,kind:n.kind,trackID:n.track,packetLossRate:n.lostRate,rtt:n.rtt})})}catch(e){jr.warning("parse SignalingQosMessage error: ",e)}}),Aa.emit("remote-track-stats",t),this.emit("remote-track-stats",t)}handleDisconnect(e){if(jr.log("handle disconnect",e.code,e),-1===[0,10005,10006].indexOf(e.code)&&gn.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:-1,socket_node_info:this.signaling.url}),gn.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=fa.Reconnecting,void setTimeout(()=>this.signaling.initWs(),1e3);switch(e.code){case 10006:this.emit("disconnect",{code:e.code,data:{userID:e.kickedid}});break;default:this.emit("disconnect",{code:e.code})}this.releaseRoom()}handleRemoteUserReconnecting(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnecting",t),this.emit("remote-user-reconnecting",t))}handleRemoteUserReconnected(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnected",t),this.emit("remote-user-reconnected",t))}async updateAccessToken(){const e=ti(this.roomToken),t=await vi(e,this.roomToken,this.config.requestTimeout);gn.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=ei(t.accessToken);if(!this.signaling)throw kn("room state is idle when updateAccessToken");this.signaling.accessToken=this.accessToken,this.signaling.setUrl(r.signalingurl2)}async handleAuth(e){if(this.filterSignalTracks(e),jr.debug("handleAuth",e),e.error)return void await this.joinRoomWithToken(this.roomToken,this.userData);e.tracks=e.tracks||[],e.tracks=e.tracks.filter(e=>e.playerid!==this.userID),e.players=e.players||[];const t=this.roomState===fa.Reconnecting;let r={join:[],leave:[],add:[],remove:[],mute:[]};const n=Array.from(this._users.keys()),i=e.players.map(e=>e.playerid);if(r=function(e,t,r,n,i){const a={join:[],leave:[],add:[],remove:[],mute:[]},o=t.map(e=>e.trackid),s=r.map(e=>e.trackid);return o.forEach((n,i)=>{if(t[i].playerid!==e)if(-1===s.indexOf(n))a.remove.push(t[i]);else{const e=r.find(e=>e.trackid===n),o=t[i];e.versionid!==o.versionid&&(a.remove.push(o),a.add.push(e))}}),s.forEach((n,i)=>{if(r[i].playerid===e)return;const s=o.indexOf(n);-1===s?(a.add.push(r[i]),a.mute.push({trackid:n,muted:r[i].muted})):r[i].muted!==t[s].muted&&a.mute.push({trackid:n,muted:r[i].muted})}),n.forEach(t=>{t!==e&&-1===i.indexOf(t)&&a.leave.push({playerid:t})}),i.forEach(t=>{t!==e&&-1===n.indexOf(t)&&a.join.push({playerid:t})}),a}(this.userID,this._trackInfo,e.tracks,n,i),this.roomState=fa.Connected,t)jr.debug("get missing events",r),r.remove.length>0&&this.handleRemoveTracks({tracks:r.remove}),r.leave.length>0&&r.leave.forEach(this.handlePlayerOut.bind(this)),r.join.length>0&&r.join.forEach(this.handlePlayerIn.bind(this)),r.add.length>0&&this.handleAddTracks({tracks:r.add}),r.mute.length>0&&this.handleMute({tracks:r.mute});else{this._trackInfo=e.tracks,this._users.clear();for(const t of e.players||[]){const e=ko(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(bo)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===B.Connecting);this.connectionTransport.extendedRtpCapabilities=e.rtpcaps,(!this.connectionTransport.sendHandler.isPcReady||this.connectionTransport.sendHandler._isRestartingICE||t.length>0)&&this.connectionTransport.reconnectProducer(),(!this.connectionTransport.recvHandler.isPcReady||this.connectionTransport.recvHandler._isRestartingICE||r.length>0)&&this.connectionTransport.resetRecvHandler()}else this.connectionTransport=this.createConnectionTransport(e.rtpcaps)}createConnectionTransport(e){const t=this.signaling,r=new la(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(yo),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(i)}),r.on("@needsubpc",(e,r,n)=>{t.request("subpc",{tracks:e.map(e=>this.profiles.get(e)?{trackid:e,profile:this.profiles.get(e)}:{trackid:e}),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void r(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=B.Connecting),this._subscribe(e,!0)}).on("@needrepub",e=>{this._publish(e.map(e=>e.track),!0)}).on("@needresetrecv",()=>{this.subscribeTracks.filter(e=>!!e.track).forEach(e=>{e.track.removeAllListeners("@ended")})}),r}cleanTrackIdsFromMergeJobs(e){M(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)M(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new wi,t=t=>{e.onAddTracks(t)},r=t=>{e.onRemoveTracks(t)};return this.on("track-add",t),this.on("track-remove",r),e.getCurrentTracks=(()=>{if(!this.connectionTransport)return[];const e=this._trackInfo.map(bo),t=this.connectionTransport.publishTracks.map(e=>e.track.info);return e.concat(t)}),e.addMergeTrack=((e,t)=>{this._addMergeTracks(e,t)}),e.release=(()=>{this.off("track-add",t),this.off("track-remove",r)}),e}getAllMerger(){const e=[];this.merger&&e.push(this.merger);for(const t in this.mergeJobMerger)e.push(this.mergeJobMerger[t]);return e}releaseRoom(){this.releaseSession(),this.signaling&&(this.signaling.release(),this.signaling=void 0),gn.addEvent("UnInit",{id:`${this.sessionMode}_${Date.now()}`},!0),this.connectionTransport&&(this.connectionTransport.release(),this.connectionTransport=void 0),this.getAllMerger().map(e=>{e.release()}),this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this.merger=void 0,this.mergeJobMerger={},this.roomState=fa.Idle,this._trackInfo=[],this._users.clear(),this.userID=void 0,this.subscribeTracks.forEach(e=>{e.release()}),this.subscribeTracks=[],this.profile=void 0,this.profiles.clear(),clearInterval(this.volumeIndicatorTimer),this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"]}registerVolumeIndicatorEvent(){clearInterval(this.volumeIndicatorTimer),this.volumeIndicatorTimer=setInterval(()=>{if(!this.connectionTransport)return!1;const e=[...this.subscribedTracks,...this.publishedTracks].filter(e=>"audio"===e.info.kind&&!e.info.muted).map(e=>({trackID:e.info.trackID,userID:e.userID,level:e.getCurrentVolumeLevel()||0,muted:e.info.muted}));if(0===this.volumeIndicatorHistory.length)this.volumeIndicatorHistory.push(e.filter(e=>e.level>=.1));else{const r=this.volumeIndicatorHistory[this.volumeIndicatorHistory.length-1],n={};r.forEach(e=>n[e.trackID]=e.level);const i=[];for(let r of e)r.level>=.1?n[r.trackID]?r.level>n[r.trackID]?i.push(r):i.push(t({},r,{level:n[r.trackID]})):i.push(r):n[r.trackID]&&i.push(t({},r,{level:n[r.trackID]}));this.volumeIndicatorHistory.push(i),4===this.volumeIndicatorHistory.length&&(this.emit("volume-indicator",i.filter(e=>!e.muted).map(e=>({trackID:e.trackID,userID:e.userID,level:e.level}))),this.volumeIndicatorHistory=[])}},500)}async startMediaRelay(e){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("start-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("StartMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("update-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("UpdateMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(gn.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Jn(e.code,e.error);const r=e.status;return Object.keys(r).reduce((e,n)=>t({},e,{[n]:r[n].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}}class ga extends ma{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",gn.addEvent("Init",{id:`${this.sessionMode}_${Date.now()}`})}get mergeStreamTracks(){return this.defaultMergeJobTracks}get mergeStreamJobTracks(){return this.mergeJobTracks}async join(e,t){return await this.joinRoomWithToken(e,t)}leave(){this.leaveRoom(),this.isAudioMastered=!1,this.isVideoMastered=!1}async publish(e){const t=this.isAudioMastered,r=this.isVideoMastered;for(const t of e)"audio"===t.info.kind&&(this.isAudioMastered?t.setMaster(!1):(t.setMaster(!0),this.isAudioMastered=!0)),"video"===t.info.kind&&(this.isVideoMastered?t.setMaster(!1):(t.setMaster(!0),this.isVideoMastered=!0));try{return await this._publish(e)}catch(e){throw this.isAudioMastered=t,this.isVideoMastered=r,e}}async unpublish(e){const t=await this._unpublish(e);return this.isAudioMastered=this.publishedTracks.some(e=>!("audio"!==e.info.kind||!e.master)),this.isVideoMastered=this.publishedTracks.some(e=>!("video"!==e.info.kind||!e.master)),t}async subscribe(e,t=!1,r){return await this._subscribe(e,!1,t,r)}async unsubscribe(e){return await this._unsubscribe(e)}setProfile(e,t){this._setProfile(e,t)}setReconnectTimes(e){this._setReconnectTimes(e)}getReconnectTimes(){return this._getReconnectTimes()}muteTracks(e){this._muteTracks(e)}async addMergeStreamTracks(e,t){await this._addMergeTracks(e,t)}async removeMergeStreamTracks(e,t){await this._removeMergeTracks(e,t)}stopMergeStream(e){this._stopMerge(e)}filterSignalTracks(){}releaseSession(){}}class va{constructor(e,t){this.networkQuality=tn.UNKNOWN,this._client=e,this._user=t,this.userID=t.userID,this.userData=t.userData}getVideoTracks(){let e=[];for(let t of this._client._remoteTracks)t.isVideo()&&t.userID===this.userID&&e.push(t);return e}getAudioTracks(){let e=[];for(let t of this._client._remoteTracks)t.isAudio()&&t.userID===this.userID&&e.push(t);return e}}class Ta extends C{constructor(){super(...arguments),this._isMuted=!1}get mediaElement(){return this._track&&this._track.mediaElement}get track(){return this._track}set track(e){e&&(this._track=e,this._track.on("ended",()=>{Aa.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{Aa.emit("audioBuffer",t,e.mediaTrack.id)}),this.trackID=this._track.info.trackID,this.userID=this._track.info.userID,this.tag=this._track.info.tag,this._kind=this._track.info.kind,this._isMuted=!!this._track.info.muted)}play(e,t={}){return this._track?"boolean"==typeof t?this._track.play(e,t,{}):this._track.play(e,void 0,t):Promise.reject()}isAudio(){return"audio"===this._kind}isVideo(){return"video"===this._kind}isMuted(){return this._isMuted}getMediaStreamTrack(){return this.track?this.track.mediaTrack:void 0}}class ba extends Ta{constructor(e){super(),this._isSubScribed=!1,this.uplinkStats={uplinkRTT:0,uplinkLostRate:0},this._kind=e.kind,this.trackID=e.trackID,this.userID=e.userID,this.tag=e.tag,Aa.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),Aa.on("mute-tracks",e=>{for(const t of e)t.trackID===this.trackID&&(this._isMuted=t.muted,this.emit("mute-state-changed",t.muted))})}isSubscribed(){return this._isSubScribed}}class Sa extends ba{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=rn.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),Aa.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=rn.HIGH,this.emit("profile-changed",rn.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=rn.MEDIUM,this.emit("profile-changed",rn.MEDIUM);break;case"low":this.profile=rn.LOW,this.emit("profile-changed",rn.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){Aa.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw kn("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?rn.LOW:rn.HIGH;Aa.emit("set-profile",this.trackID,t)}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){const e={downlinkFrameRate:0,downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkFrameRate=t[0].frameRate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,this.isMultiProfileEnabled&&(e.profile=this.profile),e)}}class ya extends ba{constructor(e){super(e),Aa.on("audioBuffer",(e,t)=>{this._track&&t===this._track.mediaTrack.id&&this.emit("audioFrame",e)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,e)}}class ka extends C{constructor(e){super(),this.connectionState=Ur.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new ga({transportPolicy:e}),this.session.on("user-join",e=>{const t=new va(this,e);this.remoteUsers.push(t),this.emit("user-joined",e.userID,e.userData)}),this.session.on("user-leave",e=>{this.remoteUsers=this.remoteUsers.filter(t=>t.userID!==e.userID),this.emit("user-left",e.userID)}),this.session.on("track-add",e=>{if(0===e.length)return;const t=e.map(e=>"audio"===e.kind?new ya(e):new Sa(e));this._remoteTracks.push(...t);const r=Nr(t,e=>e.userID);Object.entries(r).forEach(([e,t])=>{this.emit("user-published",e,t)})}),this.session.on("track-remove",e=>{if(0===e.length)return;const t=e[0].userID,r=new Set;for(const t of e)r.add(t.trackID);let n=[],i=[];for(const e of this._remoteTracks)r.has(e.trackID)?n.push(e):i.push(e);this._remoteTracks=i,this.emit("user-unpublished",t,n)}),this.session.on("mute-tracks",e=>{0!==e.length&&Aa.emit("mute-tracks",e)}),Aa.on("set-mute-tracks",(e,t,r)=>{if(r===this.getClientKey())this.session.muteTracks([{trackID:e,muted:t}]);else if(""===r)throw kn("can not setMuted,please publish track first")}),this.session.on("room-state-change",e=>{switch(e){case fa.Idle:this.connectionState=Ur.DISCONNECTED;break;case fa.Connecting:this.connectionState=Ur.CONNECTING;break;case fa.Reconnecting:this.connectionState=Ur.RECONNECTING;break;case fa.Connected:this.connectionState=this.connectionState===Ur.CONNECTING?Ur.CONNECTED:Ur.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===Ur.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=nn.LEAVE;break;case 10006:e=nn.KICKED_OUT;break;default:e=nn.ERROR}let t={reason:e};if(e===nn.ERROR)switch(t.errorCode=this._disconnectedInfo.code,t.errorCode){case 10001:t.errorMessage="token 错误";break;case 10002:t.errorMessage="token 过期";break;case 10004:t.errorMessage="reconnect token 过期";break;case 10007:t.errorMessage="断线重连失败";break;case 10022:t.errorMessage="该用户在其他页面或终端登录";break;case 10011:t.errorMessage="房间人数已满";break;case 10012:t.errorMessage="房间已关闭";break;default:t.errorMessage="unexpected error"}this.release(),this.emit("connection-state-changed",this.connectionState,t)}else this.emit("connection-state-changed",this.connectionState)}),this.session.on("messages-received",e=>{for(let t of e){const e={ID:t.msgid,userID:t.userID,content:t.data,timestamp:t.timestamp};this.emit("message-received",e)}}),this.session.on("media-relay-state-changed",(e,t)=>{this.emit("media-relay-state-changed",e,t)}),this.session.on("remote-user-reconnecting",e=>{this.emit("user-reconnecting",e.userID)}),this.session.on("remote-user-reconnected",e=>{this.emit("user-reconnected",e.userID)}),this.session.on("forward-job-connected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{Aa.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),Aa.on("remote-track-stats",e=>{for(let t of e){const e=this.remoteUsers.filter(e=>e.userID===t.userID)[0];if(!e)return;switch(t.networkGrade){case x.INVALID:e.networkQuality=tn.UNKNOWN;break;case x.POOR:e.networkQuality=tn.POOR;break;case x.FAIR:e.networkQuality=tn.FAIR;break;case x.GOOD:e.networkQuality=tn.GOOD;break;case x.EXCELLENT:e.networkQuality=tn.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),Aa.on("set-profile",(e,t)=>{switch(t){case rn.HIGH:this.session.setProfile(e,"high");break;case rn.MEDIUM:this.session.setProfile(e,"medium");break;case rn.LOW:this.session.setProfile(e,"low")}}),Aa.on("setMediaStreamTrack",(e,t,r,n,i)=>{if(r===this.getClientKey())this.session.replaceTrack(e,t).then(n).catch(i);else if(""===r)throw kn("can not setMediaStreamTrack,please publish track first")})}setTransportPolicy(e){this.session.config.transportPolicy=e}get userID(){return this.session.userID}get userData(){return this.session.userData}get roomName(){return this.session.roomName}getRemoteUser(e){return this.remoteUsers.find(t=>t.userID===e)}async setClientMode(e){this.session.setClientMode(e)}async setClientRole(e){await this.session.setClientRole(e)}async join(e,t){await this.session.joinRoomWithToken(e,t)}async leave(){await Promise.resolve().then(()=>this.session.leave()),this.release()}release(){this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[]}async publish(e){if(Array.isArray(e)){e.find(e=>e.isVideo())&&(this.session.simulcast=!!e.filter(e=>e.isVideo()).find(e=>e.isMultiProfileEnabled)),await this.session.publish(e.map(e=>e.track));for(const t of e)t.trackID=t.track.info.trackID,t.userID=this.session.userID,t.client=this.getClientKey();this._localTracks.push(...e)}else e.isVideo()&&e.isMultiProfileEnabled&&(this.session.config.simulcast=!0),await this.session.publish([e.track]),e.trackID=e.track.info.trackID,e.userID=this.session.userID,e.client=this.getClientKey(),this._localTracks.push(e)}getClientKey(){return Gr(`${this.roomName?this.roomName:""}${this.userID?this.userID:""}${this.session.appId?this.session.appId:""}`)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw kn("target tracks has not published");await this.session.unpublish(e.map(e=>e.trackID)),this._localTracks=this._localTracks.filter(t=>!e.includes(t))}else{if(!this._localTracks.includes(e))throw kn("target tracks has not published");await this.session.unpublish([e.trackID]),this._localTracks=this._localTracks.filter(t=>t!==e)}}async subscribe(e){let t;if(Array.isArray(e)){t=await this.session.subscribe(e.map(e=>e.trackID));let r=[],n=[];for(let i of t){const t=e.filter(e=>e.trackID===i.info.trackID);if(0===t.length)continue;const a=t[0];a.track=i,a._isSubScribed=!0,"audio"===i.info.kind?n.push(a):r.push(a)}return{audioTracks:n,videoTracks:r}}if((t=await this.session.subscribe([e.trackID])).length>0){const r=t[0];return e.track=r,e._isSubScribed=!0,"audio"===r.info.kind?{videoTracks:[],audioTracks:[e]}:{audioTracks:[],videoTracks:[e]}}return{audioTracks:[],videoTracks:[]}}async unsubscribe(e){Array.isArray(e)?(await this.session.unsubscribe(e.map(e=>e.trackID)),e.forEach(e=>{e._isSubScribed=!1})):(await this.session.unsubscribe([e.trackID]),e._isSubScribed=!1)}async sendMessage(e,t,r){Array.isArray(r)?await Promise.resolve().then(()=>this.session.sendCustomMessage(t,r.map(e=>e.userID),e)):await Promise.resolve().then(()=>this.session.sendCustomMessage(t,[],e))}async startDirectLiveStreaming(e){await this.session.createForwardJob(ii({userConfigExtraInfo:e.userConfigExtraInfo,jobId:e.streamID,publishUrl:e.url,audioTrackId:e.audioTrack&&e.audioTrack.trackID,videoTrackId:e.videoTrack&&e.videoTrack.trackID}))}async stopDirectLiveStreaming(e){await this.session.stopForwardJob(e)}async startTranscodingLiveStreaming(e){await this.session.createMergeJob(e.streamID,ii({publishUrl:e.url,height:e.height,width:e.width,fps:e.videoFrameRate,kbps:e.bitrate,stretchMode:e.renderMode,watermarks:e.watermarks&&e.watermarks.map(e=>({x:e.x,y:e.y,w:e.width,h:e.height,url:e.url})),background:e.background&&{x:e.background.x,y:e.background.y,w:e.background.width,h:e.background.height,url:e.background.url},maxRate:e.maxBitrate,minRate:e.minBitrate,holdLastFrame:e.holdLastFrame})),e.transcodingTracks&&await this.setTranscodingLiveStreamingTracks(e.streamID,e.transcodingTracks)}async stopTranscodingLiveStreaming(e){await this.session.stopMergeStream(e)}async setTranscodingLiveStreamingTracks(e,t){const r=t.map(e=>ii({trackID:e.trackID,x:e.x,y:e.y,w:e.width,h:e.height,z:e.zOrder,stretchMode:e.renderMode}));e?await this.session.addMergeStreamTracks(r,e):await this.session.addMergeStreamTracks(r)}async removeTranscodingLiveStreamingTracks(e,t){e?await this.session.removeMergeStreamTracks(t.map(e=>e.trackID),e):await this.session.removeMergeStreamTracks(t.map(e=>e.trackID))}getNetworkQuality(){let e=tn.UNKNOWN;const t=this._localTracks.reduce((e,t)=>t.track?[...e,...t.track.getStats().map(e=>e.networkGrade)]:[...e],[]);return t.includes(x.POOR)?e=tn.POOR:t.includes(x.FAIR)?e=tn.FAIR:t.includes(x.GOOD)?e=tn.GOOD:t.includes(x.EXCELLENT)?e=tn.EXCELLENT:e}getUserNetworkQuality(e){let t=tn.UNKNOWN;const r=this.remoteUsers.filter(t=>t.userID===e)[0];return r?t=r.networkQuality:(jr.warning("cannot find userID: ",e),t)}enableAudioVolumeIndicator(){this.session.registerVolumeIndicatorEvent()}async kickOutUser(e){this.remoteUsers.find(t=>t.userID===e)?await this.session.kickoutUser(e):jr.warning("cannot find userID: ",e)}async startMediaRelay(e){return this.session.startMediaRelay(e)}async updateMediaRelay(e){return this.session.updateMediaRelay(e)}async stopMediaRelay(){return this.session.stopMediaRelay()}}class _a extends Ta{constructor(e){super(),this.track=e,this.client="",Aa.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,Aa.emit("set-mute-tracks",this.trackID,e,this.client)}destroy(){this.track&&this.track.release()}}class wa extends _a{constructor(e){super(e),Aa.on("audioBuffer",(t,r)=>{r===e.mediaTrack.id&&this.emit("audioFrame",t)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={uplinkBitrate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.uplinkBitrate=t[0].bitrate,e.uplinkRTT=t[0].rtt,e.uplinkLostRate=t[0].packetLossRate,e)}}class Ea extends _a{constructor(e){super(e),this.isMultiProfileEnabled=!1}getLowStreamConfig(){if(this._track)return this._track.lowStreamConfig}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){if(!this._track)return[];let e=this._track.getStats();if(0===e.length)return[];if(1===e.length){return e.map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}))}{const t=(e=e.filter(e=>0!==e.bitrate).sort((e,t)=>e.bitrate-t.bitrate)).map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}));return t[0]&&(t[0].profile=rn.LOW),t[1]&&(t[1].profile=rn.MEDIUM),t[2]&&(t[2].profile=rn.HIGH),2==t.length&&t[1].profile===rn.MEDIUM&&(t[1].profile=rn.HIGH),t}}setOptimizationMode(e){if(!this._track)return!1;const t=this._track.mediaTrack;return"contentHint"in t&&(t.contentHint=e,t.contentHint===e)}}class Ca extends Ea{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class Ma extends Vi{constructor(e){const t=Li.createMediaStreamDestination();super(t.stream.getAudioTracks()[0],e,"local"),this.sourceType=L.MIXING,this.initAudioManager(!0),this.destination=t,this.inputList=[]}appendAudioSource(e){this.inputList.find(t=>t.track===e)?jr.warning("track is already in the track list"):(this.inputList.push({track:e}),e.on("ended",()=>{this.emit("ended")}),e.audioManager.gainNode.connect(this.destination))}removeAudioSource(e){const t=this.inputList.find(t=>t.track===e);if(t){try{t.track.audioManager.gainNode.disconnect(this.destination)}catch(e){}M(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class Pa{constructor(e,t){this.effectSourceMap=new Map,this.playback=!0,this.output=e,this.playbackEngine=t}get effectList(){return Array.from(this.effectSourceMap.keys())}getEffectTrack(e){return this.effectSourceMap.get(e)}playEffect(e,t){const r=this.effectSourceMap.get(e);r?(t&&r.setVolume(t),this.playback&&r.audioManager.audioSource&&this.playbackEngine.addAudioNode(r.audioManager.gainNode),r.startAudioSource()):jr.warning("can not find target effect",e)}async addEffectSource(e,t){if(this.effectSourceMap.has(t))return void jr.warning("duplicate effect key!",t);const r=await Oa.createAudioTrackFromSource(e);this.effectSourceMap.set(t,r),this.output.appendAudioSource(r)}removeEffectSource(e){let t=[];t=e?[e]:Array.from(this.effectSourceMap.keys());for(const e of t){const t=this.effectSourceMap.get(e);if(!t)return;this.output.removeAudioSource(t),t.release(),this.effectSourceMap.delete(e)}}}class Ia{constructor(){this.gainNode=Li.createGain(),this.gainNode.connect(Li.destination)}setPlayingVolume(e){this.gainNode.gain.setValueAtTime(e,Li.currentTime)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class Ra{constructor(e){if(this.playbackEngine=new Ia,this.sourcePlayebackState=!1,!(e instanceof Vi))throw kn("audio mixing manager: origin track is not audio track");this.outputTrack=new Ma,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new Pa(this.outputTrack,this.playbackEngine),this.musicManager=new xa(this.outputTrack,this.playbackEngine)}getMusicPlaybackState(){return this.musicManager.playback}setMusicPlaybackState(e){this.musicManager.playback!==e&&(this.musicManager.playback=e,this.musicManager.audioNode&&(e?this.playbackEngine.addAudioNode(this.musicManager.audioNode):this.playbackEngine.removeAudioNode(this.musicManager.audioNode)))}getSourcePlaybackState(){return this.sourcePlayebackState}setSourcePlaybackState(e){this.sourcePlayebackState!==e&&(this.sourcePlayebackState=e,this.source.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(this.source.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.source.audioManager.gainNode)))}getEffectPlaybackState(){return this.effectManager.playback}setEffectPlaybackState(e){this.effectManager.playback!==e&&(this.effectManager.playback=e,this.effectManager.effectSourceMap.forEach((t,r)=>{t.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(t.audioManager.gainNode):this.playbackEngine.removeAudioNode(t.audioManager.gainNode))}))}setBitrate(e){this.outputTrack.setInfo({kbps:e})}setTag(e){this.outputTrack.setInfo({tag:e})}release(){this.effectManager.removeEffectSource(),this.musicManager.stopMusicMixing(),this.outputTrack.removeAudioSource(this.source),this.outputTrack.release(),this.playbackEngine.release()}}class Da extends Ra{constructor(e){if(!e._audioTrack)throw kn("input stream do not have audio track");super(e._audioTrack),this.input=e;const t=[this.outputTrack];this.input._videoTrack&&t.push(this.input._videoTrack),this.outputStream=new xo(t,"send",this.input.userID)}setBitrate(e,t){e&&this.outputStream._audioTrack&&this.outputStream._audioTrack.setKbps(e),t&&this.outputStream._videoTrack&&this.outputStream._videoTrack.setKbps(t)}}var Oa;!function(e){async function t(e,t="anonymous",r,n){return new Promise((i,a)=>{const o=document.createElement("audio");o.preload="auto",o.src=e,o.crossOrigin=t,o.addEventListener("error",()=>{a(Fn())});const s=()=>{o.removeEventListener("canplay",s);const e=new Oo(o);n&&e.setKbps(n),e.setInfo({tag:r}),i(e)};o.addEventListener("canplay",s)})}function r(e,t,r){return new Promise((n,a)=>{const o=new FileReader;o.onload=(e=>{i(e.target.result).then(e=>{const i=new Oo(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(()=>{a(Fn())})}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new Oo(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===Li.state&&await Li.resume();return await(()=>new Promise((t,r)=>{Li.decodeAudioData(e,e=>{t(e)},e=>{r(Pn(e))})}))()}e.createAudioTrackFromURL=t,e.createAudioTrackFromFile=r,e.createAudioTrackFromBuffer=n,e.createAudioTrackFromSource=async function(e,i,a){return e instanceof File?await r(e,i,a):e instanceof AudioBuffer?n(e,i,a):"string"==typeof e?await t(e,"anonymous",i,a):Promise.reject(Fn())},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new Ra(e)},e.createAudioMixingManagerFromStream=function(e){return new Da(e)}}(Oa||(Oa={}));class xa extends C{constructor(e,t){super(),this.musicOption={loop:!1,volume:1},this.playback=!0,this.output=e,this.playbackEngine=t}get audioNode(){return this.musicTrack?this.musicTrack.audioManager.gainNode:null}setMusicOption(e){this.musicOption=Object.assign(this.musicOption,e),this.musicTrack&&(this.musicTrack.setVolume(this.musicOption.volume),this.musicTrack.setLoop(this.musicOption.loop))}async startMusicMixing(e,t=!1){if(this.musicTrack)return this.stopMusicMixing(t),await this.startMusicMixing(e);try{if(this.musicTrack=await Oa.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw kn("can not find audio source");this.playback&&this.audioNode&&this.playbackEngine.addAudioNode(this.audioNode),this.musicTrack.on("audio-state-change",(e,t)=>{this.emit("music-state-change",e,t)}),this.musicTrack.startAudioSource()}catch(e){e instanceof Sn&&this.emit("error",e)}}pauseMusicMixing(){this.musicTrack?this.musicTrack.pauseAudioSource():jr.warning("can not find target music, please run startAudioMixing")}resumeMusicMixing(){this.musicTrack?this.musicTrack.resumeAudioSource():jr.warning("can not find target music, please run startAudioMixing")}stopMusicMixing(e=!1){this.musicTrack&&(this.musicTrack.stopAudioSource(e),this.output.removeAudioSource(this.musicTrack),this.musicTrack.release(),this.musicTrack=void 0)}getMusicDuration(){return this.musicTrack?this.musicTrack.getDuration():0}getMusicCurrentTime(){return this.musicTrack?this.musicTrack.getCurrentTime():0}setMusicCurrentTime(e){if(this.musicTrack&&(this.musicTrack.setCurrentTime(e),!this.musicTrack.audioManager.audioSource))throw kn("can not find audio source")}}class Ba extends C{constructor(e,t,r){super(),this.mixingTrack=e,this.source=t,this.playbackEngine=r,this.musicVolume=1,this.audioMusicManger=new xa(this.mixingTrack,this.playbackEngine),this.handleAudioMusicManger()}handleAudioMusicManger(){this.audioMusicManger.on("error",e=>{throw this.emit(Ba.ERROR,e.code,e.message),e}),this.audioMusicManger.on("music-state-change",e=>{switch(e){case H.IDLE:this.emit(Ba.STATE_CHANGED,$r.IDLE);break;case H.LOADING:break;case H.PLAY:this.emit(Ba.STATE_CHANGED,$r.MIXING);break;case H.PAUSE:this.emit(Ba.STATE_CHANGED,$r.PAUSED);break;case H.END:this.loopCount>1?(--this.loopCount,this._start(this.loopCount,!0)):this.emit(Ba.STATE_CHANGED,$r.COMPLETED);break;case H.STOP:this.emit(Ba.STATE_CHANGED,$r.STOPPED)}})}async start(e=1){this._start(e)}stop(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}resume(){this.audioMusicManger.resumeMusicMixing()}pause(){this.audioMusicManger.pauseMusicMixing()}getDuration(){return this.audioMusicManger.getMusicDuration()}getCurrentPosition(){return this.audioMusicManger.getMusicCurrentTime()}seekTo(e){this.audioMusicManger.setMusicCurrentTime(e)}getMixingVolume(){return this.musicVolume}setMixingVolume(e){let t=Number(e);t=isNaN(t)?0:t,this.musicVolume=t,this.audioMusicManger.setMusicOption({volume:this.musicVolume})}release(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}async _start(e=1,t=!1){this.loopCount=Math.max(-1,Number(e)),this.audioMusicManger.setMusicOption({loop:-1===this.loopCount,volume:this.musicVolume}),0!==this.loopCount&&await this.audioMusicManger.startMusicMixing(this.source,t)}}Ba.STATE_CHANGED="state-changed",Ba.ERROR="error";class La extends C{constructor(e,t,r){super(),this.outputTrack=e,this.playbackEngine=t,this.effectID=r,this.playback=!0,this.loopCount=1}getDuration(){return this.getValidateAudioTrack().getDuration()}getID(){return this.effectID}getFilePath(){return this._filePath}setLoopCount(e){this.loopCount=-1===e?Number.MAX_SAFE_INTEGER:Math.max(0,Number(e)),0===this.loopCount&&this.stopEffect()}getLoopCount(){return this.loopCount===Number.MAX_SAFE_INTEGER?-1:this.loopCount}playEffect(e){if(this.loopCount>0){const t=this.getValidateAudioTrack();e&&t.setVolume(e),this.playback&&t.audioManager.audioSource&&this.playbackEngine.addAudioNode(t.audioManager.gainNode),t.startAudioSource()}}stopEffect(){const e=this.getValidateAudioTrack();this.loopCount=1,e.stopAudioSource()}resumeEffect(){this.getValidateAudioTrack().resumeAudioSource()}pauseEffect(){this.getValidateAudioTrack().pauseAudioSource()}getCurrentPosition(){return this.getValidateAudioTrack().getCurrentTime()}async addEffectSource(e){try{this.audioTrack=await Oa.createAudioTrackFromSource(e),this._filePath="string"==typeof e?e:URL.createObjectURL(e),this.handleAudioTrack(),this.outputTrack.appendAudioSource(this.audioTrack)}catch(e){e instanceof Sn&&this.emit(La.ERROR,e)}}removeEffectSource(){void 0!==this.audioTrack&&(this.outputTrack.removeAudioSource(this.audioTrack),this.audioTrack.release(),this.audioTrack=void 0)}getValidateAudioTrack(){if(void 0===this.audioTrack){const e=jn();throw this.emit(La.ERROR,e),e}return this.audioTrack}handleAudioTrack(){this.audioTrack&&this.audioTrack.on("audio-state-change",e=>{switch(e){case H.END:this.loopCount>1?(this.loopCount=this.loopCount===Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:this.loopCount-1,this.playEffect(this.loopCount)):this.emit(La.FINISHED)}})}}La.FINISHED="finished",La.ERROR="error";class Ga extends C{constructor(e,t){super(),this.mixingTrack=e,this.playbackEngine=t,this.audioEffectMap=new Map,this.startedList=new Map}addListener(e,t){return super.addListener(e,t)}async createAudioEffect(e,t){if(this.audioEffectMap.has(e)){const e=Vn();throw this.emit(Ga.ERROR,e.code,e.message),e}{const r=new La(this.mixingTrack,this.playbackEngine,e);return this.handleAudioEffect(e,r),await r.addEffectSource(t),this.audioEffectMap.set(e,r),r}}start(e){this.getValidateAudioEffect(e).playEffect(1),this.startedList.set(e,!0)}stop(e){this.getValidateAudioEffect(e).stopEffect()}pause(e){this.getValidateAudioEffect(e).pauseEffect()}resume(e){this.getValidateAudioEffect(e).resumeEffect()}stopAll(){this.audioEffectMap.forEach(e=>{e.stopEffect()})}pauseAll(){this.audioEffectMap.forEach(e=>{e.pauseEffect()})}resumeAll(){this.audioEffectMap.forEach(e=>{e.resumeEffect()})}getCurrentPosition(e){const t=this.getValidateAudioEffect(e);return this.startedList.get(e)?Math.floor(1e3*t.getCurrentPosition()):0}setVolume(e,t){this.getValidateAudioEffect(e).getValidateAudioTrack().setVolume(t)}getVolume(e){return this.getValidateAudioEffect(e).getValidateAudioTrack().getVolume()}setAllEffectsVolume(e){this.audioEffectMap.forEach(t=>{t.getValidateAudioTrack().setVolume(e)})}release(){this.audioEffectMap.forEach(e=>{e.removeEffectSource()}),this.audioEffectMap.clear()}getValidateAudioEffect(e){const t=this.audioEffectMap.get(e);if(void 0===t){const e=Un();throw this.emit(Ga.ERROR,e),e}return t}handleAudioEffect(e,t){t.on(La.FINISHED,()=>{this.emit(Ga.FINISHED,e)}),t.on(La.ERROR,e=>{throw this.emit(Ga.ERROR,e.code,e.message),e})}}Ga.FINISHED="finished",Ga.ERROR="error";class Na extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:case H.STOP:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){this._mixingManager.musicManager.setMusicOption({loop:e}),await this._mixingManager.musicManager.startMusicMixing(this.source)}stop(){this._mixingManager.musicManager.stopMusicMixing()}resume(){this._mixingManager.musicManager.resumeMusicMixing()}pause(){this._mixingManager.musicManager.pauseMusicMixing()}getDuration(){return this._mixingManager.musicManager.getMusicDuration()}getCurrentPosition(){return this._mixingManager.musicManager.getMusicCurrentTime()}seekTo(e){this._mixingManager.musicManager.setMusicCurrentTime(e)}setPlayingVolume(e){this._mixingManager.playbackEngine.setPlayingVolume(e)}setMixingVolume(e,t){this._mixingManager.source.setVolume(e),this._mixingManager.musicManager.setMusicOption({volume:t})}}class Ha extends wa{constructor(e){const t=new Ra(e);super(t.outputTrack),this.sourceTrack=e,this.outputTrack=t.outputTrack,this.mixingManager=t,this.playbackEngine=new Ia,this.earMonitorEnable=!1}createAudioMusicMixer(e){return this.audioMusicMixer&&this.audioMusicMixer.release(),this.audioMusicMixer=new Ba(this.outputTrack,e,this.playbackEngine),this.audioMusicMixer}createAudioEffectMixer(){return this.audioEffectMixer?this.audioEffectMixer:(this.audioEffectMixer=new Ga(this.outputTrack,this.playbackEngine),this.audioEffectMixer)}isEarMonitorEnabled(){return this.earMonitorEnable}setEarMonitorEnabled(e){this.earMonitorEnable=e,this.earMonitorEnable?this.playbackEngine.addAudioNode(this.sourceTrack.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.sourceTrack.audioManager.gainNode)}setPlayingVolume(e){let t=Number(e);t=isNaN(t)?0:t>1?1:t<0?0:t,this.playbackEngine.setPlayingVolume(t)}destroy(){this.mixingManager.release(),this.audioEffectMixer&&this.audioEffectMixer.release(),this.audioMusicMixer&&this.audioMusicMixer.release(),this.playbackEngine.release(),this.sourceTrack.release()}createAudioMixer(e){return new Na(this.mixingManager,e)}setVolume(e){this.sourceTrack&&this.sourceTrack.setVolume(e)}}class Fa extends Ea{constructor(e){super(e)}}class ja extends wa{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){e&&this._track.setLoop(e),this._track.startAudioSource()}stop(){this._track.stopAudioSource()}resume(){this._track.resumeAudioSource()}pause(){this._track.pauseAudioSource()}getDuration(){return this._track.getDuration()}getCurrentPosition(){return this._track.getCurrentTime()}seekTo(e){this._track.setCurrentTime(e)}}const Va="data:audio/mpeg;base64,SUQzAwAAAAAfdlRJVDIAAAALAAAB//6wZY+JMpPzl1RQRTEAAAABAAAAVEFMQgAAAAEAAABUWUVSAAAAAQAAAFRDT04AAAABAAAAVFJDSwAAAAEAAABDT01NAAAAHwAAAGVuZwBvbmxpbmUtYXVkaW8tY29udmVydGVyLmNvbQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/7UMAAAAAAAAAAAAAAAAAAAAAAAEluZm8AAAAPAAAAIQAAG8AADg4OFhYWHh4eJSUlLS0tNDQ0PDw8Q0NDS0tLUlJSWlpaYWFhaWlpcHBweHh4f39/h4eHj4+PlpaWnp6epaWlra2ttLS0vLy8w8PDy8vL0tLS2tra4eHh6enp8PDw+Pj4////AAAAAExhdmM1OC4xMwAAAAAAAAAAAAAAACQGkQAAAAAAABvAI9ArKwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+1DEAAPAAAGkAAAAIAAANIAAAAQgUuQ2C0ggHpVv2yykMn99MBkmlkbANsGRtN/9DKn6+WMLYws4Lh4WxkjxRTCyjBeEm3+nZCzjyFLIzIKSqMgLKkIP1kOAiDKPuoPHEJhZAyGA11lGJAQwQrN4Rbybog81Oo5/HL4hDAzMhfDIORCH6sJWPxCHi7OvCHrs+08SyrYcjCunFEIUcF3h+GRk/0ezsbcciMXCMV+nqHuc7pCyQEknfL87AuS5wm9PnAe5Y7Ggvq5YntSi4JZp//tSxF2BAAABpAAAACEAm9fYYKG5sVGC+JNCz/TxyljU6F40ShUKyWObiUFhgEjStZ2CVnUitUbMqIzyCqxoUKH3NoM9MdurRtIOQGCAUMFCSESeQjFxRAgYXbXJF0nVe9uFo28sYY7vaCij0ID9hSkkXuTJaCDJFz8gUSiyxc8sXPLPuoSix9OQOB8P8UEoLx8INHg3fTIDwaLh4YNPIFEl33fQs/pyKfc+yxe8tkLuDJtK//QaH9/82KCiVSikopLdrY0AnUanBzTSVpS9C97/+1LEmwISLPzKLWHhSkMzXxT0objEkfG4QCz4OIieKEYpLmuJkMtc5uJdtmDor6SYLaLLX0raXraxBc+7cAr3hDL0qGSsCBwGZqypjA4ElVUY7GnEmFjhwPID30wHCGbtHoN0Z2QB0OAoDhALxQAnYOxcBA+YMFMbLwgKWUbl2Ifrr24gYTadbLMVv/+Mq24Gp3l3/h86KJLTckkhrKhq26mLTJpLGV7fiEblMVS/XOw9nrQlCwNYepQTYgRNCkqGmA1BWGYwNiGrgoDxJm5IFv/7UsRngFKU9SesMNqKVSCldaex+CXJcyfnSS9gOg3353q5gGIk2prcmlvRauYXkE9NM7dDYEWxIRGycMUtXE9qcRhJr8C1O0lVxpn0Kp/m6zF/wRLtSXM4z1RlXWHEd1DXzWM+UW8Ph44xqf///9YEMAABKDji+CgJAK7SWrtM+kLV3seiQMQh5uzbyxuDKYFdoAcmgOJZwcmBsFRkU1rTIqfKZIOMefJpi0XnywvZJR7aIsFdUXI0PYFFX46ocVsWQNp3kq67hYrZ1+B9jnnr//tSxDCAkd0fJwywccHgHeXxhhlw0cdooYK+gHjEOABLZZgYoYOoha7T6UpF/cNAmHxceFk3G7tDTxQeftfcUR4yLAGNEAABjLIu8PEIvus6sXZI0l/YEcBYAi5TEtDaViW8tUmhow2InK0p77jhdbeL1T/1lDS5pDRoaD1pMZGvVbCaVUagkijWnZZ96+TGDn23cr1MU+dv4fIbSmumc8DLQPKiAURQKMEpsSjzxxZ/7knKQBPNsT9UTwW5ZEgAAAi6EyEFKkWBDVKYCjOtzNz/+1LECwAMaGM7qLzBwYyP57WGGDCVOsqXUqVdqZlalUTFyum6B6yWHxKtfJ102ZWAmRDKgGKm50SkSRURkXbmJQqXCSwIKYJnAmGHJVFP5Rz7zcAIfFk1KXvpt2GxUQOCIwByRMAAFAlSgpAjMNQ8juOgiKhoYJIHB/jdGqTq0yaTTZenn0fTOdih3rwVkZPSk/GucPt+pjheShUIMHrA4BmQ6ecxGPKokxEtyAYL11Oo4YOAIvsHPAVTxpwg482MiPpbRYoCNuRgAEglOCRk4//7UsQFgAu4bT+sMGVBfRZntYSM+HIk6vqeMSCuSkM5F5bEQlk5Ptzp4h0YiQfCQ4LCAJJ66Ay034GEiBh1I8OIcZNrDJ0CtF40XfZPB4TPaTGXgUoPhuzNH7XhK9yydOvhjHxIQ/e0KuNMkAAAAuICRAlnsIdx2ZI+hATsEgUIiAC0abFoVUl4s+KU8Y1KK7EAxKkZHFLy8g0ZoX2HZdiKzaFS7p/jzo4VFLXt1YCQKFLl9KFoSC6AfcK8pQp3ULnCDeovRY8OT+xIBJpKPFQD//tSxAUACtCpQ6YYbIFUj2h1hgw4gD04ikwjCAIbw/nRingHLMRPNKQhE6uZE36qFjtpR42aCmPJUDGvE/BMa9n/9ijarn7LWG7Vbg6MCSCSn2S8UkXut/rOz56xjvQS0rCft+aIbkklAIkPGBmSx3JSwUD8OXEgoGJXMUUHuqmnVxp0WqTG1SmSj6rUNEuDOFqQYVYiPDTnAk2LixIzzwmDyUCKdCYKhEJD4yhWe3HRFaGAC6xVBXdWh0Uk5ZHMBYyEl5SybRFAgQCMIxAtY4f/+1LEDQAKhGlL56RloSqJZzGEmOBohpRiSG2F4Y7OCKCqEH5Z7UjVAZPgJgu0MFD6Xko0XsCIHsOmRuwydoeKKQONTv3OCCSpGAH2FVDlAlZRogBlsDCAQCfCsLoxxm8qVFBGDo8IxS4UIGygImCZNLcvIYCgbEmHAwdMmhdxAcCRsnoKjknVgIkiKLc9GlPo2hquKP/Wis6lAwAQBrN81FlZbkuy0KgqxigfmZl0DCeBofolpYVFMlFI0HJ2SAtf7Y4bQQXbfBhn6Oc/joGPk//7UsQbgApkeTCssGnBUY2pdPSM5BZITGvPiYYSXI7CRsyzKCVjlrVPOFlp9eBRhTcNr/vY3bpFLjPRI1TiGcuWg3BEGTIlJNCwgaBIFTZvolcQhPAShI4USOykeGVnFICwWHg61MSOmQMqQSWYFH0fTowBBNYmIgFL0bVGTRtdbv/f+n6VBUSZJAASRciGgy5liuXZZgbBq4T/QDlEJzRfXkiMwxN01xqHg5g+7BJpjM+v3yescqw+RuInWTjoiKngfCQo0v+zcxQwyX4+ttMy//tSxCWACfBpO6wwxUFLjGgw9Izs+2j1fuDbkrMAVK5HBzgpCdrRIkAdQcSFhcSNBtyo6imj6JdDFDx8SvYEJYXTiAsCEjhoiLkWS5QctQcLA+/kkD1pSKnBZrQIw4+5AZZenuS8URKQCTLdKg4m2y01KKMZZlzCDGoe7IIsASGhUPjxCgbARPv1kbWJTWOnGbfljF9Ti3bCSDlx2h8SOkyu4RKQPPD2Qw6OC2MbL0oJ4iatyRTloqCDhRL6fSCMAAAK4DLBnFrNdlDgUrjgcbD/+1LEMgAKLHNLh6TFsUyU5qWEjPhMbExcgCpAhIGnL2X51kh0iVQRZQQOuowcUaDmbvclmzMn387nP/fhOQfMJUFFp73K2sEZ2OSy+nLpEazQxbVRal+7tFlBALj2M4ghjEoBCYyAqZLbFw+HFeLWA5JzByKCpyUH/g6RyJ9HXpcNWoKaPNM4i/E5E3bxRD3Pe9hFhMJi9IqbmXFlEP5QEyIq8kU+wKkJkoghJNzAVDwXgkA9ciBE4BbZ2QEikHCtQMSk44haxACDjJ5Z0EEjmP/7UsQ9gAoQs0kmGG5xTwan9MSYmE7jpAw0RrGMdUNFLAEBGaxahOJDJxYFcwUlXeLKYLo72/oIKhTz5BdCag4k6ATJSda8IyHYGTovkg+aA0Z0M8OSgog7CQpDTjiTAw8abfl1o59z3iKVZq+6DxUPKWZ24aYlYuVT2UOqHrJzaVEmLWrV3n9AoKs/ohn/aguuaCU0k3AlKYUkJKFEIjxiSduHBqUg9ogMyXuEb3fNyM92e8OEDqqSRSriAmTYBRDcdNH6sQ1b0Rf0sIVxUBxy//tSxEkACihtPUwwwYE5jmjoww2SFcqgWYzRUazFdyXkP10MAAAAAYnBaB4CxiZq1IljkJIwOE5meE9wQSNhGLRMOZYxEgYi+ngx0h2xAQgXDqllDI99JcVujUNCbCbbLxGUaPFkraoagWPipq5XjdK7P8WN1jjZBRaQSoZy+HwzRk8FD1ImZFsBSbJCNJ7b1E0e6+Jc6gKCVFhgtbJsY6iIiC4xpEs1pgacY87QJyb+9abaKg0GSBUms2HuqjX/w5YJ//1KD5UASmvACU7USp//+1LEVwAKKGU3JhhuwUSM6LT2DDx7Y+CxY0AUTmjALRAthrHJHm/aasmceDjn0BHWOxU2zDHD+qkcQbUFQ4JQ6MNAwLuhNTNs2zEzAWHrD0ImyrDGnIIYQKs2f+4GeV1IoyNFPA8BAD3GYjjuIQ6GKosgGLEiET0Op7Cq5Qo5QoHkxZdokyNsjC77QKWXnP5EQxRwgxzCy2TPq7yB9TRKOzX5U0RU8ZCvXWLybyn3pjXBAGSma+pqEO/OPbQwuC45WnIIZvPCtkXXrojyITkkAv/7UsRjgApgezssJGXBSxMo9MSNFKIzdzlgD2gk2svFxytcWsjvlmhKn1eSZn3q8MwoZki5AIrYePhhwjXAzgG+GD+jt7IAIBR2aMkZI0QDF14mkgBY3rlyYPZeI50Jxj6keGaIj7pUBpWdRClqy6/6dsW3++zDROLlF4gIHR4oJ1kgg2+5sUpz4TjxXvb9c26t5rs31QwEAABBLdMNhCpOXUQXM4TOGsP+9DKHFdtg8ifKunQ1iQRNGMBRUN42jZYVbEGzfYIEDwGA8JpAgxwc//tSxG6CCjitMgykbwE9juaZhhh4nRe7ZadDN4KR5vVPgyWqARjOO/53YiIYW+4PU2PJ4uQmu4J3j/P+Tb/+36/6rWr1zqmve437/sLIQAA2k9ySNBNCHihLSTkHRKHM0OhCNiOPRmH7ZCF5eWvLTJuuuMC3FvQFRKkGyEisiDMK1MQKg5UT/rIblCO1IpX+v55fO+/2lMF/fXX1KNKW90n5eX8i/LTsdooMnT3UgutZNX/iZQQAAAxk2cYkSJaEAEngiYh+4SwKR8HuwyJlDnz/+1LEe4AOSHs3TCTQiaEn56mWDLhsSAlNRIaVYyNm6wThPzA8QQiULALDsPwJlspB6L07ymp9G8ndvclRH69p0OilmBW9D8qpXtBikk6XtILNNfT8uJeLNc0t5zu07wut2Htqm1m7v7xBvx7iJe2fe7Nn7HlBIOvNur62iJ+VL3/lUAEEFQ4azSgXqweuhMaUpW6TET7Q4/jcHbAMcwjV2o1dI1TsZSN6+kFCoVdpx5uI1tlo4vpLpCdvRJ3JQg5eaql/X3NfUxslzvnZI7rW5f/7UsRsAZE9KyjNsNLB5B6lqZeZOPsqTqh1523vbVZub7n7/kzCbmh46qxpqMaoiNHNOjQ0uVfeubvtqjanZ5oeQAIALpnZgH5SIyAEP07HlV1HV4rXgCZXSu2eZIzFOmiWZSvw7tO7rcJ6elMDytrkojMjgtLDeOdJTHLWtYX8Y0WUZvPZ03xsfsqHi2Vkb3SYxsjMN+5spPVUqFUVHJK7K6zB+QjlRl/v3GjQ+6DhYrKdGXX/V1QQONm1K/f+/o2oxngAAMZ2QIIQVNFqjRgA//tSxEiAEH2bLOyYtworIOTJpKLIsBQGJ3l0YGaeylxnIUxZyoSwEv04xetvWGwZLazmMPd5sDmNIWDjFMzdnIEk+BVYmk0H5lg3sH1NJUNFlYOJipQWOmmMujEGQPNWhssKjpaZvMTcaNrnZFB/YbK33jTpYmnJu5izzkyguOQAwOpwwLA0vSmHlCx2ZfS+i7ENAKQAAAfNJ0QbCRbhrfSJQgp4agASxIiXhGSAbow8MLRLDpCP4jIkqlJxZAPE4nJio+484qaaoKtOLx4Ia43/+1LEHwAM7JEvLLBpwdEeJamGGXC18RMGDqjRVQ0OIWKB3aNaRAqybOdYGgk2hDudAKFvARw6K3mqcdou8sAiwAAIRLgYY40NbnADxrUcWWtbo3ebYGJoYCUFxfE9MIJ6uMRxRHRNO9D4kE4sBq+PQ41rFmPcmRLwfbvtwhub5jZLrfkItmuz9rTPrUoykMzC1e3748PW8VU329//ESoYDsFS+7OAwKhdZN5Qm1R18CZLSgIfAACKStFFFmg87S1XMlbjDtA+pQ8tAuWBSYHJOf/7UsQPAAy9JTVMMKnBeh8naYSM6NVw2vHy85fsugSHv/WB6J+CcmY7KIolRrqj95fKdEVSEpc7PF2Zlbd0VHpZagOjNVTLkNOf5nm//EDkxYoDs2ZYKNdCJDyb0A92QCm27sF4RJKNkKu5S8GYLnwIE40jEICEw0goijjkSKDOtMYmUBA49fs4eMUnoZEec7ISy4/9L3K1yhllsuq84+fkR//J+9XChEDixZ+tpoTiqBR4GNET7Ou6jZJ1AU+jUAEiacoBKW4WpMjX60dZxp9G//tSxAqACoxpQ6eYbGFHCebplhjgtPQuwsaobCZzorZNuwyvYGJ+fgg0gQOMDBRBRZgk6w2RjhC0awkSdJ6j7jx1ZIWaUpeWCPohsYLuGvUuz2/9QG7iABJJ0GTwX8DgmE224vUwNCGxTXGqHENJ94l2WQplp/nmiHoJdLDjzwy0XcMIui5MeBFiqrpgqxo9De8mMkNEvHAVFjb2I6iQTSRPExROlqoASWRIBKNuagE4aIl1ToqzQYgRBMjFQwMjEimdDxdz/T7m535NK11OAIX/+1LEFQAKcHs9p7BnwVAM57WEmRAIrENipTmOynjrhcTIDIReAws5AlkB6pfdIk7sfUY1q1MLhpKMZc///rAC2kaATablw2AUUlG1t+GkuLEGuuUBIiKhs0TjjhK5lHJybTu7GKuZJzDy5bMzrMQB4GD9yAA8kxKVi6JlhogtjhVtBs1cfPQWrU07/Mo6Pbo0KqoDvuAGk3LhPxJQWEwlzHZct3yoCgnMuQHyY/YXco39WxS2IcqoxqFYQroj1ShRyoC98bXoyUd3OfaDzK7Wh//7UsQfAEtZAzlMJEfBSomncYYYYJKrWzK/AeyWyvyasoM8/2Iepx0MNezzzluPXlBQBSrNIC8TMAjC/TpiSSBSsQSSqMTVw24WASWBbmqKjqvuvHU7HhE24KklMeNB0+WaIqCgUKbBYSBJoooel6Wza0hIVlgTW1j2W6F1CooLO1/fqXUe37e2FWpuXgkBQWGYEEQvfLhyiN2xqOHFkgwhIzGY/yevZAt3LGsQihk41qRnGIsFRgCTSyhJAgZGrjhbfeHzomeMHNGMFy8Wq3UE//tSxCYACqBvR6YYbSFHieb1lhhgzYCVds9VDfsuAMSZQABJKcoxCZoSnEFnwqIg/iUZJUhcfTgIJAZXkiZUkEr/knjQR6bmjZcSQ2KCxM8RFdFkkf6wAqhhnIqYyXFrXxV7PK2ImDKL3Oo70Cun0AXZG0gE425upMoUwVwgiCwaSyZDE7FrCZWZEtmpmbPkeKvK9IgtBBYVtBZgaKBUVD7hUewpYoJRQWFCqQStTZXoC8te5m9j/wbCYAeMde/J+YFLWa6w7td3CnbIpeYitGb/+1LEMIAKsGE9rDBjgWcOKPT2GKShB5iPC5UOxmvCsilY+VHprIOdOKxp9eHAp1VM8ZXOfaqmhftPThYiRPGRUDBEpPHWnwy4QkzmxMEXnGXiccbCYIHRZCqddkr6e7MbDnrqBebrRILkjm67MlxMBdDuCJ9OQUZ6eDQuWKmF0a+q1gRMOlNi9wZ0iNmLppmeecfiZa8jEYyTKB7Roq6J3n6iosRETJhw1QoGjo0YO/NTq81f1u/qBds0cKLjac4hZCyJSCWLsoDSCzbYNExEHf/7UsQ2gAqAk0GnsGVBTZJotPSM5OOkDs0Uh8O9anh4GckBP7c1wiiWeK6sfkX5+cuJ0CZrjIAWwcfGWYHYXRHIExhVQrV60MH39fp9KqnVAGlAAEoqU2QHYpMKzWF5AYXDqXEhuaD33FwwOOHwsEtZFi2JMckTwyzOUWJjBUOg094PhddDoqLvvSPUHzCrnM/KrQGL5oVUzumnspfW+/vUqZv6ASrAALSUvHeAlnCpDiTBqyiQakICQcHyIgJ0CBdNBjcUQZaGTdzAEd2T86mZ//tSxECACohVN0wwxQGEkCfo9IzooUEU4VwQ4gPhhpQIjhoeCwq1JOTEN9VWt8BgS+9h/tJirxjULUNGqsSBDI4TuQTZUcC/xIoRqlQUk0xBJBQlWzRF8pdIx+LWXC0rLFmuLWqmaBSASd9m1cPDUL+ihaYK1iOUjZSUo+RmpPtnMxamMCoaAQsJZ+7en3GxyUlUZhyf//FYmen2cWcKBCR9lINRyXgGyGQGzpVVkLwBSYgKTZUdiSWwLiGMI0mQQ+nOh930zwfJERkhSQJCNgD/+1LEQ4AKpKtDR7Bo0UwKaDWWGGAEYCD6APOvolzoxDFVQmxzwnQ8mQQYap5P+8PnBx+OCPTVAkV5iTZHL7rfxwq5Wbzbrvq89BCLLrRd1J6mZzKobw9GAUIEC9OM5FDnLDFAzKlTSuBJrqMUHVNhzaur0j3Lgnqxc7fcMurjzSCzVP8O///X77wWpX7ev/8+gBNUuSAEhRxNpRJuQAHhLLDGXQBxAHpVoA4+7xfNdZaIMAF0HkicaRAVgHsHKYIxT8EceOkOdr53pDakdomzjP/7UsRNAAtEcU31gYAqYSbmtzTwAelqwkmxLb1Iui+ZtPHcXcUlagUyvNKFnt9K7owP/qM5qtrfv4M+/77pNeW89Fcssj95PBiVvqurZ3/ExBz/aJRieRKODyTX/+P/X3/pibzb3RUPImPEvALKAGAAAgArwFi3Cif+bImX+lmP+BDZooObSf8DSrgBmw5JEcAQ2Bi0AGfOGJMocCw8DAlgMmKBYE6KSfh6QN1gbuHUAaARb/AwoQckVgAUMFkofXqV/AXDBYEPqAuCCyUG2osh//tSxDGAEoFFELmqAAAAADSDgAAESVSqv4ciFkIqIpEG6oNsS8JtC33//8OSGTAQDCxIL7BjoXyC5ocsR0Hza9f//k+XkkxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+1LERYPAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==";class Ua extends Ea{constructor(e,t,r,n){super(e),this.drawImage=(()=>{this.drawImageOnce(),requestAnimationFrame(this.drawImage)}),this.drawImageOnce=(()=>{if(this.ctx)for(const e of this.canvasSources)this.ctx.drawImage(e.source,e.x,e.y,e.width,e.heigth)}),this.canvas=t,this.ctx=r,this.updateSources(n).then(this.drawImage).catch(e=>{jr.warning(e)});const i=new Audio;i.src=Va,i.autoplay=!0,i.loop=!0,i.muted=!0,i.ontimeupdate=(()=>{this.drawImageOnce()}),this.audioElement=i}async updateSources(e){this.sources=e,this.canvasSources=[];const t=await Promise.all(e.map(e=>Ii.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;rthis.mMax&&(this.mFiltered=this.mMax),this.mLastFilteredTimestamp=Date.now(),this.applied=!0}Filtered(){return this.mFiltered}LastFilteredTime(){return this.mLastFilteredTimestamp}UpdateBase(e){this.mAlpha=e}}function Qa(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Ka(r),e[t])}Ka.kValueUndefined=-1,Ka.AlphaForPacketLossFractionSmoother=.9999,Ka.SMOOTH_VIDEO_INTERVAL=1e3,Ka.SMOOTH_AUDIO_INTERVAL=5e3;const Ja=Qa(),Za=Qa(),$a=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function Ya(e,t){let r;r=e>9||t>100?x.POOR:e>5||t>80?x.FAIR:e>1||t>40?x.GOOD:x.EXCELLENT;const n=navigator;return n.connection&&n.connection.effectiveType&&["slow-2g","2g","3g"].includes(n.connection.effectiveType)&&(r=x.POOR),r}const eo={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},to={nack_count:0,fir_count:0,pli_count:0,width:0,height:0,jitter_buffer_delay:0,bytes_sent:0,frame_encoded:0,bytes_received:0,frame_decoded:0},ro={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var no,io,ao;function oo(e,t){let r=e||0;const n={chrome:["86.0.4240","87.0.4280"]};return n[b.name]&&n[b.name].includes(b.version)&&t===io.InBoundRtp?(r=Math.min(e/32767,1),Xa.create({code:za.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&Xa.create({code:za.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function so(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function co(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function uo(e,t,r,n){const i=t-e,a=n-r;if(i<=0||a<=0)return 0;const o=i/a;return o>1?1:o}function lo(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};E.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return E.unifiedPlan&&E.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function Ao(e,t,r,n=600){if(r){const i=[{rid:"hi",active:!0,maxBitrate:1e3*n},{rid:"lo",active:!0,maxBitrate:1e3*r.bitrate,scaleResolutionDownBy:r.scaleResolutionDownBy}];return await t.addTransceiver(e,{direction:"sendonly",sendEncodings:i})}return await t.addTransceiver(e,{direction:"sendonly"})}!function(e){e.Video="video",e.Audio="audio"}(no||(no={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(io||(io={})),function(e){e.In="in",e.Out="out"}(ao||(ao={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(po="PermissionDeniedError",fo)return fo("PermissionDeniedError");throw Gn()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(po="desktop");"rtcmulticonnection-extension-loaded"===e&&jr.warning("your chrome screen sharing plugin is not the latest version, or you have other screen sharing plugins.");e.sourceId&&fo&&fo(ho=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let ho,fo,po="screen";async function mo(){return await(()=>new Promise((e,t)=>{"desktop"!==po?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==po)},2e3)):e(!0)}))()}async function go(e,t){const r=t.source;return await(()=>new Promise((n,i)=>{const a={mozMediaSource:r||"window",mediaSource:r||"window",height:t.height,width:t.width};if(g)return void n(a);const o={mandatory:{chromeMediaSource:po,maxWidth:Co(t.width),maxHeight:Co(t.height)},optional:[]};"desktop"!==po?n(o):e?function(e){if(ho)return e(ho);fo=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(Gn())}):function(e,t=!1,r=!1){fo=e,t?window.postMessage("qnrtc:get-sourceId-screen","*"):r?window.postMessage("qnrtc:get-sourceId-window","*"):window.postMessage("qnrtc:get-sourceId","*")}(function(e){o.mandatory.chromeMediaSourceId=e,"PermissionDeniedError"!==e?n(o):i(Gn())},"screen"===r,"window"===r)}))()}class vo{constructor(e,t){this.tracks=[],this.publishedTrackInfo=[],this.userID=e,this.userData=t}get published(){return this.publishedTrackInfo.length>0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=mi(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{M(this.tracks,t=>t===e)})}removeTracksByTrackId(e){M(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=mi(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){M(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function To(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function bo(e){return{trackID:e.trackid,tag:e.tag,mid:e.mid||void 0,kind:e.kind,userID:e.playerid,muted:e.muted,versionid:e.versionid,profiles:e.profiles||[]}}function So(e,t){return{trackid:e.trackID,mid:e.mid||void 0,kind:e.kind,master:t,muted:!!e.muted,playerid:e.userID,tag:e.tag||"",versionid:e.versionid}}function yo(e){if(!e.info.mid&&E.unifiedPlan)throw kn("can not find track mid!");return{localid:e.mediaTrack.id,localmid:e.info.mid||void 0,master:e.master,kind:e.info.kind,kbps:e.info.kbps,tag:e.info.tag}}function ko(e){return new vo(e.playerid,e.playerdata)}function _o(e,t,r){let n;return"audio"===e.kind?(n=new Vi(e)).initAudioManager(!0):n=new Pi(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function wo(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const Eo=e=>(function(e){0===Object.keys(e.audio).length&&"boolean"!=typeof e.audio&&(e.audio=!0);0===Object.keys(e.video).length&&"boolean"!=typeof e.video&&(e.video=!0);return e})(function(e){if(E.minMaxWithIdeal)return e;return["video","screen"].forEach(t=>{"object"==typeof e[t]&&"object"==typeof e[t].width&&e[t].width.ideal&&delete e[t].width.ideal,"object"==typeof e[t]&&"object"==typeof e[t].height&&e[t].height.ideal&&delete e[t].height.ideal}),e}(ii(e)));function Co(e){if(e)return"number"==typeof e?e:e.exact?e.exact:e.max?e.max:e.ideal?e.ideal:e.min?e.min:void 0}const Mo="fk6fk2rnb",Po="https://api-demo.qnsdk.com",Io="/v1",Ro=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function Do(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new ga,i=new ga,a=await async function(){let e="unknow";try{e=await pn()}catch(e){}return e+"_"+si(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await Go.getLocalTracks({video:{enabled:!0},audio:{enabled:!0}});if(c=f.find(e=>"video"===e.info.kind),s=f.find(e=>"audio"===e.info.kind),void 0===c||void 0===s)throw kn("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Po}${Io}${Ro(e,t,Mo)}`;try{let e;if("AbortController"in window){const t=new AbortController;setTimeout(()=>t.abort(),5e3),e=await fetch(r,{signal:t.signal,headers:{"Content-Type":"application/json"}})}else e=await fetch(r,{headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error(e.statusText);return e.text()}catch(e){throw e}})(a,e).then(e=>t.joinRoomWithToken(e)).then(r).catch(n)});await Promise.all([p("userA",n),p("userB",i)]);const m=e=>new Promise((t,r)=>{e.trackInfoList.length>0?e.subscribe(e.trackInfoList.map(e=>e.trackID)).then(t).catch(r):e.on("track-add",n=>{e.subscribe(n.map(e=>e.trackID)).then(t).catch(r)})});await Promise.all([n.publish([c]),i.publish([s]),m(n),m(i)]);const g=[],v=[],T=[],b=[],S=[],y=30;let k=0;await new Promise(e=>{o=setInterval(()=>{const t=n.publishedTracks[0].getStats(),r=i.publishedTracks[0].getStats();t.length>0&&r.length>0&&s&&(g.push(t[0].rtt),v.push(t[0].packetLossRate),T.push(r[0].bitrate),b.push(t[0].bitrate),S.push(s.getCurrentVolumeLevel())),g.length>15&&(clearInterval(o),e()),k>y&&(jr.warning("abnormal track stats: less than 15 valid stats in 30s"),clearInterval(o),e()),k+=1},1e3)}),jr.log(JSON.stringify({detailTestResult:{rtts:g,packetLossRates:v,audioBitrates:T,videoBitrates:b,volumnLevels:S}})),g.length>0&&(d=Math.ceil(g.reduce((e,t)=>e+t,0)/g.length),u=v.reduce((e,t)=>e+t,0)/v.length,l=T.reduce((e,t)=>e+t,0)/T.length,A=b.reduce((e,t)=>e+t,0)/b.length,h=S.reduce((e,t)=>e+t,0)/S.length),t=!0}catch(e){t=!1,r="string"==typeof e?e:e instanceof Sn?JSON.stringify(e):e.message}finally{return n.roomState===fa.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===fa.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),gn.addEvent("SystemRequirementsTest",{room_name:a,ok:t,reason:r,avg_rtt:d,avg_packet_loss_rate:u,avg_volumn_level:h,avg_audio_bitrate:l,avg_video_bitrate:A,test_take_time:Date.now()-e,event_grade:t?An.NORMAL:An.SERVERE},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class Oo extends Vi{constructor(e,t){if(!E.mediaStreamDest)throw wn("your browser does not support audio buffer input!");const r=new Fi;r.initAudioContext(),e instanceof AudioBuffer?(r.setAudioBufferSource(),r.setAudioBuffer(e)):e instanceof HTMLAudioElement&&r.setMediaElementSource(e),super(r.audioStream.stream.getTracks()[0],t,"local"),this.sourceType=L.EXTERNAL,this.isLoop=!1,this.originSource=e,this.audioManager=r,this.handleAudioManagerEvents()}setLoop(e){this.isLoop=e,this.audioManager.setAudioSourceLoop(e)}startAudioSource(){this.audioManager.playAudioSource()}pauseAudioSource(){this.audioManager.pauseAudioSource()}resumeAudioSource(){this.audioManager.resumeAudioSource()}stopAudioSource(e=!1){this.audioManager.stopAudioSource(!1,e)}getCurrentTime(){return this.audioManager.getAudioSourceCurrentTime()||0}setCurrentTime(e){this.audioManager.setAudioSourceCurrentTime(e)}getDuration(){return this.audioManager.getAudioSourceDuration()||0}handleAudioManagerEvents(){this.audioManager.on("@audio-source-state-change",(e,t)=>{this.emit("audio-state-change",e,t)})}}class xo extends C{constructor(e,t="send",r){super(),this.trackList=[],this.isDestroyed=!1,this.enableAudio=!0,this.enableVideo=!0,this.muteAudio=!1,this.muteVideo=!1,this.onAudioEnded=(e=>{this.emit("audio-ended",e)}),this.onVideoEnded=(e=>{this.emit("video-ended",e)}),this.onAudioSourceStateChange=((e,t)=>{this.emit("audio-source-state-change",e,t)}),this.direction=t,this.userID=r,e.forEach(e=>{e.setMaster(!0),e.on("mute",()=>{this.updateTrackState()}),e.on("release",()=>{M(this.trackList,t=>t===e),this.updateTrackState(),0===this.trackList.length&&this.release()}),this.trackList.push(e)}),this.updateTrackState()}get audioSourceIsLoop(){return this._audioTrack instanceof Oo&&this._audioTrack.isLoop}setVolume(e){this._audioTrack&&this._audioTrack.setVolume(e)}play(e,t){this.trackList.forEach(r=>r.play(e,t)),this._audioTrack&&(this.audio=this._audioTrack.mediaElement),this._videoTrack&&(this.video=this._videoTrack.mediaElement)}getCurrentTimeDomainData(){return this._audioTrack?this._audioTrack.getCurrentTimeDomainData():new Uint8Array(0)}getCurrentFrequencyData(){return this._audioTrack?this._audioTrack.getCurrentFrequencyData():new Uint8Array(0)}getCurrentVolumeLevel(){return this._audioTrack?this._audioTrack.getCurrentVolumeLevel():0}getStats(){let e=$a();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=$a();if(this._videoTrack){const e=this._videoTrack.getStats();e.length>0&&(t=e[0])}return{timestamp:Date.now(),videoBitrate:t.bitrate,audioBitrate:e.bitrate,videoPacketLoss:t.packetLoss,audioPacketLoss:e.packetLoss,videoPackets:t.packets,audioPackets:e.packets,videoPacketLossRate:t.packetLossRate,audioPacketLossRate:e.packetLossRate,videoBytes:t.bytes,audioBytes:e.bytes,pctype:this.direction}}getCurrentFrameDataURL(){return this._videoTrack?this._videoTrack.getCurrentFrameDataURL():"data:,"}setAudioSourceLoop(e){this._audioTrack instanceof Oo&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof Oo?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof Oo?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof Oo)return this._audioTrack.setCurrentTime(e)}setKbps(e,t){e&&this._videoTrack&&this._videoTrack.setKbps(e),t&&this._audioTrack&&this._audioTrack.setKbps(t)}updateTrackState(){this.trackList.forEach(e=>{"audio"===e.info.kind?(this._audioTrack&&(this._audioTrack.off("ended",this.onAudioEnded),this._audioTrack.off("audio-state-change",this.onAudioSourceStateChange)),this.audioTrack=e.mediaTrack,this._audioTrack=e,this._audioTrack.on("ended",this.onAudioEnded),this._audioTrack instanceof Oo&&this._audioTrack.on("audio-state-change",this.onAudioSourceStateChange)):(this._videoTrack&&this._videoTrack.off("ended",this.onVideoEnded),this.videoTrack=e.mediaTrack,this._videoTrack=e,this._videoTrack.on("ended",this.onVideoEnded))}),this.audioTrack?(this.enableAudio=!0,this.muteAudio=!this.audioTrack.enabled):this.enableAudio=!1,this.videoTrack?(this.enableVideo=!0,this.muteVideo=!this.videoTrack.enabled):this.enableVideo=!1}release(){if(!this.isDestroyed){for(let e=0;e"videoinput"===e.kind);case"microphones":return this.deviceInfo.filter(e=>"audioinput"===e.kind);case"playback":return this.deviceInfo.filter(e=>"audiooutput"===e.kind)}}async getElectronScreenSources(e){let t;try{const{ipcRenderer:e}=window.require("electron");t={getSources:t=>e.invoke("QNRTC_DESKTOP_CAPTURER_GET_SOURCES",t)}}catch(e){throw jr.warning(e),Rn(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case cn.ALL:r.types.push("window","screen");break;case cn.SCREEN:r.types.push("screen");break;case cn.WINDOW:r.types.push("window")}try{return(await t.getSources(r)).map(e=>({ID:e.id,name:e.name,url:e.thumbnail.toDataURL()}))}catch(e){throw jr.warning(e),kn(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(!0===e.audio&&(t={audio:{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop"}}}),e.sourceID)t={video:{mandatory:{chromeMediaSourceId:e.sourceID,chromeMediaSource:"desktop"}}};else{const e=await this.getElectronScreenSources();if(0===e.length)return[];t={video:{mandatory:{chromeMediaSourceId:await async function(e){return new Promise((t,r)=>{const n=document.createElement("div");n.setAttribute("style","position: fixed; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);");const i=document.createElement("div");i.setAttribute("style","text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;"),i.innerText="share screen";const a=document.createElement("div");a.setAttribute("style","width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;"),n.appendChild(i),n.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 12%;"),o.innerText="QiNiu Web Screensharing wants to share the contents. Choose what you'd like to share.";const s=document.createElement("div");s.setAttribute("style","width: 100%; height: 80%; background: #FFF; border: solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around; overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");const c=document.createElement("button");c.setAttribute("style","width: 85px;"),c.innerText="cancel",c.onclick=(()=>{document.body.removeChild(n),r(Mn("user cancel selection"))});const d=document.createElement("div");d.setAttribute("style","text-align: right; padding: 16px 0;"),d.appendChild(c),a.appendChild(o),a.appendChild(s),a.appendChild(d);for(const r of e){const e=document.createElement("div");e.setAttribute("style","width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;"),e.onclick=(()=>{document.body.removeChild(n),t(r.ID)});const i=document.createElement("div");i.setAttribute("style","height: 120px; display: table-cell; vertical-align: middle;");const a=document.createElement("img");a.setAttribute("style","width: 100%; background: #333333; box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);"),a.src=r.url,i.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 40px; line-height: 40px; display: inline-block; width: 70%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"),o.innerText=r.name,e.appendChild(i),e.appendChild(o),s.appendChild(e)}document.body.appendChild(n)})}(e),chromeMediaSource:"desktop"}}}}e.width&&(t.video.maxWidth=e.width,t.video.minWidth=e.width),e.height&&(t.video.maxHeight=e.height,t.video.minHeight=e.height);try{jr.log("electron getUserMedia constraints: ",t),r=await navigator.mediaDevices.getUserMedia(t)}catch(e){throw kn(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())"audio"===t.kind?n.push(_o(t,e.audioTag,e.bitrate)):(e.optimizationMode&&Lo(t,e.optimizationMode),n.push(_o(t,e.tag,e.bitrate)));return n}async getLocalTracks(e=Bo){if(jr.debug("get local tracks",e),R(e)&&I(e)){const t={screen:e.screen},r={video:e.video,audio:e.audio},n=await Promise.all([this.getLocalTracks(t),this.getLocalTracks(r)]);return n[0].concat(n[1])}const t=await async function(e){if(!e)return{audio:!0,video:!0};if(R(e)){if(I(e))throw kn("can not get mediaStream with video and screen are all enabled");if(!E.screenSharing)throw wn("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!E.getDisplayMedia)&&!await mo())throw Cn("")}const t=!(!e.audio||!e.audio.enabled||e.audio.source)&&{deviceId:e.audio.deviceId,sampleRate:e.audio.sampleRate,sampleSize:e.audio.sampleSize,channelCount:e.audio.channelCount,autoGainControl:e.audio.autoGainControl,echoCancellation:e.audio.echoCancellation,noiseSuppression:e.audio.noiseSuppression},r=!(!e.video||!e.video.enabled)&&{frameRate:e.video.frameRate,height:e.video.height,width:e.video.width,deviceId:e.video.deviceId,facingMode:e.video.facingMode};if(R(e)&&e.screen){if(E.getDisplayMedia&&!e.screen.forceChromePlugin)return Eo({audio:t,video:{displaySurface:wo(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await go(!1,e.screen);return Eo({audio:t,video:r})}return Eo({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&gn.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId,event_grade:An.GENERAL,event_category:hn.VIDEO}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&gn.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId,event_grade:An.GENERAL,event_category:hn.AUDIO});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?Mn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),R(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),I(e)&&(n=e.video.bitrate,a=e.video.tag);const s=r?r.getTracks():[],c=[];for(const t of s){let r;e.video&&e.video.optimizationMode&&(r=e.video.optimizationMode),e.screen&&e.screen.optimizationMode&&(r=e.screen.optimizationMode),r&&Lo(t,r)}for(const e of s){let t;t="audio"===e.kind?_o(e,o,i):_o(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await Oa.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&R(e)&&I(e))throw kn("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new xo(t,"send")}async getUserMedia(e,r,n=!0){if(jr.debug("request to get user media, config",e),jr.debug("request to get user media, constraints",r),!r.audio&&!r.video)return null;let i;if(R(e))i=await this.getDisplayMedia(r,e);else if(i=await navigator.mediaDevices.getUserMedia(r),!S&&"getSettings"in MediaStreamTrack.prototype&&n){const n=r.video;if(n&&"boolean"!=typeof n){const a=n.width,o=n.height;if("number"==typeof a&&"number"==typeof o){const s=i.getVideoTracks(),c=s&&s[0],{height:d=o,width:u=a}=c.getSettings();if(u&&d){const s=(o-d)*(a-u);if(s*s>10){const s=o/a;return d/ue.stop()),this.getUserMedia(e,t({},r,{video:n}),!1)}}}}}return i}async getDisplayMedia(e,t){let r,n;e.audio&&(r=await navigator.mediaDevices.getUserMedia({audio:e.audio}));const i=t.screen&&t.screen.audio&&!e.audio?{video:e.video,audio:t.screen.audio}:{video:e.video};return n=E.getDisplayMedia&&t.screen&&!t.screen.forceChromePlugin?await navigator.mediaDevices.getDisplayMedia(i):await navigator.mediaDevices.getUserMedia(i),r&&n.addTrack(r.getAudioTracks()[0]),n}async updateDeivceInfo(){this.deviceInfo=await navigator.mediaDevices.enumerateDevices();const e=this.deviceInfo.map(e=>e.deviceId),t=Object.keys(this.deviceMap);let r=!1;t.forEach(t=>{if(-1===e.indexOf(t)&&"@default"!==t){this.emit("device-remove",this.deviceMap[t].device);const e=this.deviceMap[t].device;this.emit("device-changed",{device:e,state:qr.INACTIVE});const n="audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",i="AudioDeviceInOut"===n?hn.AUDIO:hn.VIDEO;gn.addEvent(n,{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label,event_grade:An.GENERAL,event_category:i}),delete this.deviceMap[t],r=!0}else this.deviceMap[t].tick+=1}),e.forEach((e,n)=>{if(-1===t.indexOf(e)&&"@default"!==e){this.deviceMap[e]={device:this.deviceInfo[n],tick:0};const t=this.deviceMap[e].device;this.emit("device-changed",{device:t,state:qr.ACTIVE}),this.emit("device-add",t);const i="audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",a="AudioDeviceInOut"===i?hn.AUDIO:hn.VIDEO;gn.addEvent(i,{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId,event_grade:An.GENERAL,event_category:a}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class No{static get VERSION(){return Hr}static isBrowserSupported(){return E.support}static async checkSystemRequirements(){return await Do()}static setLogLevel(e){switch(e){case an.VERBOSE:jr.setLevel("log");break;case an.INFO:jr.setLevel("debug");break;case an.WARNING:case an.ERROR:jr.setLevel("warning");break;case an.NONE:jr.setLevel("disable")}}static async isChromeExtensionAvailable(){return await mo()}static createClient(){const e=new ka(this._transportPolicy);return No._clients.push(e),e}static async getCameras(e=!1){return Go.getDeviceInfo(e,"cameras")}static async getMicrophones(e=!1){return Go.getDeviceInfo(e,"microphones")}static async getPlaybackDevices(e=!1){return Go.getDeviceInfo(e,"playback")}static async getDevices(e=!1){return Go.getDeviceInfo(e,"all")}static async createCameraVideoTrack(e){let r;if(jr.log("createCameraVideoTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Wr[e.encoderConfig]))throw Hn()}else r=t({},zr,e.encoderConfig);else r=zr;const n=(await Go.getLocalTracks({video:ii({enabled:!0,width:r.width,height:r.height,frameRate:r.frameRate,bitrate:r.bitrate,tag:e&&e.tag,facingMode:e&&e.facingMode,optimizationMode:e&&e.optimizationMode,deviceId:e&&e.cameraId})}))[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(n.lowStreamConfig=e.encoderConfig.lowStreamConfig);const i=new Ca(n);return void 0!==r.isMultiProfileEnabled&&(i.isMultiProfileEnabled=r.isMultiProfileEnabled),jr.log("createCameraVideoTrack end",i),i}static async createMicrophoneAudioTrack(e){let r;if(jr.log("createMicrophoneAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag})}),i=new Ha(n[0]);return jr.log("createMicrophoneAudioTrack end",i),i}static async createScreenVideoTrack(e,r){let n;if(jr.log("createScreenVideoTrack start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Qr[e.encoderConfig]))throw Hn()}else n=t({},Jr,e.encoderConfig);else n=Jr;let i=[];if(y)i=await Go.createElectronScreenTrack(ii({sourceID:e&&e.electronScreenSourceID,screenBitrate:n.bitrate,width:n.width,height:n.height,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag}));else{let a=ii({enabled:!0,width:n.width,height:n.height,bitrate:n.bitrate,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag});if(e&&e.chromeExtensionSourceType)switch(e.chromeExtensionSourceType){case Zr.ALL:a=t({},a,{forceChromePlugin:!0});break;case Zr.SCREEN:case Zr.WINDOW:a=t({},a,{forceChromePlugin:!0,source:e.chromeExtensionSourceType})}i=await Go.getLocalTracks({screen:a})}if(1===i.length&&"video"===i[0].info.kind&&"enable"===r)throw i[0].release(),In();if(1===i.length&&"video"===i[0].info.kind){const t=i[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(t.lowStreamConfig=e.encoderConfig.lowStreamConfig);const r=new Fa(t);return void 0!==n.isMultiProfileEnabled&&(r.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",r),r}{const t=i.filter(e=>"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw kn(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new wa(t),o=new Fa(r);return void 0!==n.isMultiProfileEnabled&&(o.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",[o,a]),[o,a]}}static async createMicrophoneAndCameraTracks(e,r){let n,i;if(jr.log("createMicrophoneAndCameraTracks start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Xr[e.encoderConfig]))throw Hn()}else n=t({},Kr,e.encoderConfig);else n=Kr;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=Wr[r.encoderConfig]))throw Hn()}else i=t({},zr,r.encoderConfig);else i=zr;const a=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:n.bitrate,sampleRate:n.sampleRate,sampleSize:n.sampleSize,channelCount:n.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag}),video:ii({enabled:!0,width:i.width,height:i.height,frameRate:i.frameRate,bitrate:i.bitrate,tag:r&&r.tag,facingMode:r&&r.facingMode,deviceId:r&&r.cameraId})}),o=a.filter(e=>"audio"===e.info.kind)[0],s=a.filter(e=>"video"===e.info.kind)[0];if(!o||!s)throw kn(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new Ha(o),d=new Ca(s);return void 0!==i.isMultiProfileEnabled&&(d.isMultiProfileEnabled=i.isMultiProfileEnabled),jr.log("createMicrophoneAndCameraTracks end",[c,d]),[c,d]}static async createBufferSourceAudioTrack(e){let r;if(jr.log("createBufferSourceAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,source:e.source,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,tag:e&&e.tag})}),i=new ja(n[0],e.source);return jr.log("createBufferSourceAudioTrack end",i),i}static createCanvasVideoTrack(e){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");if(null===r)throw wn("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw wn("capture stream error, canvas track not supported");n=t.mozCaptureStream(15)}const i=n.getTracks()[0];e.optimizationMode&&"contentHint"in i&&(i.contentHint=e.optimizationMode);const a=_o(i,e.tag);return new Ua(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=_o(e.mediaStreamTrack,e.tag,e.bitrate);return new qa(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=_o(e.mediaStreamTrack,e.tag,e.bitrate);return new Wa(t)}static setTransportPolicy(e){e===on.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===on.FORCE_UDP&&(this._transportPolicy="forceUdp"),this._clients.forEach(e=>e.setTransportPolicy(this._transportPolicy))}static async checkAudioTrackIsActive(e,t=5e3){const r=Math.min(200,t);return new Promise((t,n)=>{if(e.isAudio()){const n=.01,i=200;let a=e.getVolumeLevel()||0,o=e.getVolumeLevel()||0,s=o<=n,c=!0;if(e.isMuted())t(!1);else{const d=setInterval(()=>{e.isMuted()?(t(!1),clearInterval(d)):(a=o,(o=e.getVolumeLevel()||0)>n&&(s=!1),o!==a&&(c=!1))},i);setTimeout(()=>setTimeout(()=>{d&&(clearInterval(d),t(!s&&!c))},0),r)}}else n(kn("only support audio track"))})}static async checkVideoTrackIsActive(e,t=5e3){return new Promise((r,n)=>{if(e.isVideo()){const i=e.getMediaStreamTrack();if(e.isMuted()&&r(!1),void 0===i)n(kn("cannot find mediaStreamTrack"));else{const a=document.createElement("video");a.style.width="1px",a.style.height="1px",a.setAttribute("muted",""),a.muted=!0,a.setAttribute("playsinline",""),a.controls=!1,a.style.opacity="0.01",a.style.position="fixed",a.style.left="0",a.style.top="0",document.body.appendChild(a),a.srcObject=new MediaStream([i]),a.play();const o=document.createElement("canvas");o.width=160,o.height=120;const s=o.getContext("2d");if(s){let n=!1,i=null;const c=setInterval(()=>{e.isMuted()&&(c&&(clearInterval(c),r(!1)),a&&a.remove()),s.drawImage(a,0,0,160,120);const t=s.getImageData(0,0,o.width,o.height);var d=Math.floor(t.data.length/3);if(i){for(let e=0;e{setTimeout(()=>{c&&(clearInterval(c),r(n)),a&&a.remove()},0)},t)}else n(kn("can not get canvas 2d context"))}}else n(kn("only support video track"))})}static async getElectronScreenSources(e){return Go.getElectronScreenSources(e)}}return No._clients=[],No._transportPolicy="preferUdp",Go.on("device-changed",e=>{switch(e.device.kind){case"audioinput":No.onMicrophoneChanged&&No.onMicrophoneChanged(e);break;case"audiooutput":No.onPlaybackDeviceChanged&&No.onPlaybackDeviceChanged(e);break;case"videoinput":No.onCameraChanged&&No.onCameraChanged(e)}}),No}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).QNRTC=t()}(this,function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};var t=function(t){for(var r=1;r)?=?)";var _=s++;o[_]=o[d]+"|x|X|\\*";var w=s++;o[w]=o[c]+"|x|X|\\*";var E=s++;o[E]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var C=s++;o[C]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var I=s++;o[I]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var R=s++;o[R]="(?:~>?)";var D=s++;o[D]="(\\s*)"+o[R]+"\\s+",a[D]=new RegExp(o[D],"g");var O=s++;o[O]="^"+o[R]+o[E]+"$";var x=s++;o[x]="^"+o[R]+o[C]+"$";var B=s++;o[B]="(?:\\^)";var L=s++;o[L]="(\\s*)"+o[B]+"\\s+",a[L]=new RegExp(o[L],"g");var N=s++;o[N]="^"+o[B]+o[E]+"$";var G=s++;o[G]="^"+o[B]+o[C]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var F=s++;o[F]="^"+o[k]+"\\s*("+b+")$|^$";var j=s++;o[j]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[E]+")",a[j]=new RegExp(o[j],"g");var V=s++;o[V]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="(<|>)?=?\\s*\\*";for(var W=0;W<35;W++)r(W,o[W]),a[W]||(a[W]=new RegExp(o[W]));function z(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X)return e;if("string"!=typeof e)return null;if(e.length>n)return null;if(!(t.loose?a[y]:a[T]).test(e))return null;try{return new X(e,t)}catch(e){return null}}function X(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>n)throw new TypeError("version is longer than "+n+" characters");if(!(this instanceof X))return new X(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var o=e.trim().match(t.loose?a[y]:a[T]);if(!o)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+o[1],this.minor=+o[2],this.patch=+o[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");o[4]?this.prerelease=o[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new X(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(Y(e,t))return null;var r=z(e),n=z(t);if(r.prerelease.length||n.prerelease.length){for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return"pre"+i;return"prerelease"}for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return i},t.compareIdentifiers=Q;var K=/^[0-9]+$/;function Q(e,t){var r=K.test(e),n=K.test(t);return r&&n&&(e=+e,t=+t),r&&!n?-1:n&&!r?1:et?1:0}function J(e,t,r){return new X(e,r).compare(new X(t,r))}function Z(e,t,r){return J(e,t,r)>0}function $(e,t,r){return J(e,t,r)<0}function Y(e,t,r){return 0===J(e,t,r)}function ee(e,t,r){return 0!==J(e,t,r)}function te(e,t,r){return J(e,t,r)>=0}function re(e,t,r){return J(e,t,r)<=0}function ne(e,t,r,n){var i;switch(t){case"===":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e===r;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e!==r;break;case"":case"=":case"==":i=Y(e,r,n);break;case"!=":i=ee(e,r,n);break;case">":i=Z(e,r,n);break;case">=":i=te(e,r,n);break;case"<":i=$(e,r,n);break;case"<=":i=re(e,r,n);break;default:throw new TypeError("Invalid operator: "+t)}return i}function ie(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ie){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ie))return new ie(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ae?this.value="":this.value=this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){return Q(t,e)},t.major=function(e,t){return new X(e,t).major},t.minor=function(e,t){return new X(e,t).minor},t.patch=function(e,t){return new X(e,t).patch},t.compare=J,t.compareLoose=function(e,t){return J(e,t,!0)},t.rcompare=function(e,t,r){return J(t,e,r)},t.sort=function(e,r){return e.sort(function(e,n){return t.compare(e,n,r)})},t.rsort=function(e,r){return e.sort(function(e,n){return t.rcompare(e,n,r)})},t.gt=Z,t.lt=$,t.eq=Y,t.neq=ee,t.gte=te,t.lte=re,t.cmp=ne,t.Comparator=ie;var ae={};function oe(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof oe)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new oe(e.raw,t);if(e instanceof ie)return new oe(e.value,t);if(!(this instanceof oe))return new oe(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function se(e){return!e||"x"===e.toLowerCase()||"*"===e}function ce(e,t,r,n,i,a,o,s,c,d,u,l,A){return((t=se(r)?"":se(n)?">="+r+".0.0":se(i)?">="+r+"."+n+".0":">="+t)+" "+(s=se(c)?"":se(d)?"<"+(+c+1)+".0.0":se(u)?"<"+c+"."+(+d+1)+".0":l?"<="+c+"."+d+"."+u+"-"+l:"<="+s)).trim()}function de(e,t,n){for(var i=0;i0){var a=e[i].semver;if(a.major===t.major&&a.minor===t.minor&&a.patch===t.patch)return!0}return!1}return!0}function ue(e,t,r){try{t=new oe(t,r)}catch(e){return!1}return t.test(e)}function le(e,t,r,n){var i,a,o,s,c;switch(e=new X(e,n),t=new oe(t,n),r){case">":i=Z,a=re,o=$,s=">",c=">=";break;case"<":i=$,a=te,o=Z,s="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ue(e,t,n))return!1;for(var d=0;d=0.0.0")),l=l||e,A=A||e,i(e.semver,l.semver,n)?l=e:o(e.semver,A.semver,n)&&(A=e)}),l.operator===s||l.operator===c)return!1;if((!A.operator||A.operator===s)&&a(e,A.semver))return!1;if(A.operator===c&&o(e,A.semver))return!1}return!0}ie.prototype.parse=function(e){var t=this.options.loose?a[H]:a[F],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new X(r[2],this.options.loose):this.semver=ae},ie.prototype.toString=function(){return this.value},ie.prototype.test=function(e){return r("Comparator.test",e,this.options.loose),this.semver===ae||("string"==typeof e&&(e=new X(e,this.options)),ne(e,this.operator,this.semver,this.options))},ie.prototype.intersects=function(e,t){if(!(e instanceof ie))throw new TypeError("a Comparator is required");var r;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return r=new oe(e.value,t),ue(this.value,r,t);if(""===e.operator)return r=new oe(this.value,t),ue(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),a=this.semver.version===e.semver.version,o=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),s=ne(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),c=ne(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||a&&o||s||c},t.Range=oe,oe.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},oe.prototype.toString=function(){return this.range},oe.prototype.parseRange=function(e){var t=this.options.loose;e=e.trim();var n=t?a[U]:a[V];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[j],"$1$2$3"),r("comparator trim",e,a[j]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[F],o=e.split(" ").map(function(e){return function(e,t){return r("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){r("caret",e,t),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[G]:a[N];return e.replace(n,function(t,n,i,a,o){var s;return r("caret",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s="0"===n?">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":">="+n+"."+i+".0 <"+(+n+1)+".0.0":o?(r("replaceCaret pr",o),"-"!==o.charAt(0)&&(o="-"+o),s="0"===n?"0"===i?">="+n+"."+i+"."+a+o+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+o+" <"+(+n+1)+".0.0"):(r("no pr"),s="0"===n?"0"===i?">="+n+"."+i+"."+a+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+" <"+(+n+1)+".0.0"),r("caret return",s),s})}(e,t)}).join(" ")}(e,t),r("caret",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[x]:a[O];return e.replace(n,function(t,n,i,a,o){var s;return r("tilde",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":o?(r("replaceTilde pr",o),"-"!==o.charAt(0)&&(o="-"+o),s=">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0"):s=">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0",r("tilde return",s),s})}(e,t)}).join(" ")}(e,t),r("tildes",e),e=function(e,t){return r("replaceXRanges",e,t),e.split(/\s+/).map(function(e){return function(e,t){e=e.trim(),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[P]:a[M];return e.replace(n,function(t,n,i,a,o,s){r("xRange",e,t,n,i,a,o,s);var c=se(i),d=c||se(a),u=d||se(o),l=u;return"="===n&&l&&(n=""),c?t=">"===n||"<"===n?"<0.0.0":"*":n&&l?(d&&(a=0),u&&(o=0),">"===n?(n=">=",d?(i=+i+1,a=0,o=0):u&&(a=+a+1,o=0)):"<="===n&&(n="<",d?i=+i+1:a=+a+1),t=n+i+"."+a+"."+o):d?t=">="+i+".0.0 <"+(+i+1)+".0.0":u&&(t=">="+i+"."+a+".0 <"+i+"."+(+a+1)+".0"),r("xRange return",t),t})}(e,t)}).join(" ")}(e,t),r("xrange",e),e=function(e,t){return r("replaceStars",e,t),e.trim().replace(a[q],"")}(e,t),r("stars",e),e}(e,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(o=o.filter(function(e){return!!e.match(i)})),o=o.map(function(e){return new ie(e,this.options)},this)},oe.prototype.intersects=function(e,t){if(!(e instanceof oe))throw new TypeError("a Range is required");return this.set.some(function(r){return r.every(function(r){return e.set.some(function(e){return e.every(function(e){return r.intersects(e,t)})})})})},t.toComparators=function(e,t){return new oe(e,t).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},oe.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new X(e,this.options));for(var t=0;t",r)},t.outside=le,t.prerelease=function(e,t){var r=z(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new oe(e,r),t=new oe(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof X)return e;if("string"!=typeof e)return null;var t=e.match(a[I]);return null==t?null:z((t[1]||"0")+"."+(t[2]||"0")+"."+(t[3]||"0"))}}),A=(l.SEMVER_SPEC_VERSION,l.re,l.src,l.parse,l.valid,l.clean,l.SemVer,l.inc,l.diff,l.compareIdentifiers,l.rcompareIdentifiers,l.major,l.minor,l.patch,l.compare,l.compareLoose,l.rcompare,l.sort,l.rsort,l.gt),h=l.lt,f=(l.eq,l.neq,l.gte),p=l.lte,m=(l.cmp,l.Comparator,l.Range,l.toComparators,l.satisfies,l.maxSatisfying,l.minSatisfying,l.validRange,l.ltr,l.gtr,l.outside,l.prerelease,l.intersects,l.coerce,u(function(e){(function(t){if(e.exports)return function(t){e.exports=t()};if("undefined"!=typeof window)return function(e){window.MobileDetect=e()};throw new Error("unknown environment")})()(function(){var e,t={mobileDetectRules:{phones:{iPhone:"\\biPhone\\b|\\biPod\\b",BlackBerry:"BlackBerry|\\bBB10\\b|rim[0-9]+|\\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\\b-[0-9]+",Pixel:"; \\bPixel\\b",HTC:"HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel",Nexus:"Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 5X|Nexus 6",Dell:"Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b",Motorola:"Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b|XT1068|XT1092|XT1052",Samsung:"\\bSamsung\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F|SM-G610F|SM-G981B|SM-G892A|SM-A530F",LG:"\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710",Sony:"SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533|SOV34|601SO|F8332",Asus:"Asus.*Galaxy|PadFone.*Mobile",Xiaomi:"^(?!.*\\bx11\\b).*xiaomi.*$|POCOPHONE F1|MI 8|Redmi Note 9S|Redmi Note 5A Prime|N2G47H|M2001J2G|M2001J2I|M1805E10A|M2004J11G|M1902F1G|M2002J9G|M2004J19G|M2003J6A1G",NokiaLumia:"Lumia [0-9]{3,4}",Micromax:"Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b",Palm:"PalmSource|Palm",Vertu:"Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature",Pantech:"PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790",Fly:"IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250",Wiko:"KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM",iMobile:"i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)",SimValley:"\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b",Wolfgang:"AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q",Alcatel:"Alcatel",Nintendo:"Nintendo (3DS|Switch)",Amoi:"Amoi",INQ:"INQ",OnePlus:"ONEPLUS",GenericPhone:"Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser"},tablets:{iPad:"iPad|iPad.*Mobile",NexusTablet:"Android.*Nexus[\\s]+(7|9|10)",GoogleTablet:"Android.*Pixel C",SamsungTablet:"SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V|SM-P610|SM-T290|SM-T515|SM-T590|SM-T595|SM-T725|SM-T817P|SM-P585N0|SM-T395|SM-T295|SM-T865|SM-P610N|SM-P615|SM-T970|SM-T380|SM-T5950|SM-T905|SM-T231|SM-T500|SM-T860",Kindle:"Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)",SurfaceTablet:"Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)",HPTablet:"HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10",AsusTablet:"^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\bP027\\b|\\bP024\\b|\\bP00C\\b",BlackBerryTablet:"PlayBook|RIM Tablet",HTCtablet:"HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410",MotorolaTablet:"xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617",NookTablet:"Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2",AcerTablet:"Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20\\b|\\bA3-A30|A3-A40",ToshibaTablet:"Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO",LGTablet:"\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b",FujitsuTablet:"Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b",PrestigioTablet:"PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002",LenovoTablet:"Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X|TB-X704F|TB-X104F|TB3-X70F|TB-X705F|TB-8504F|TB3-X70L|TB3-710F|TB-X704L",DellTablet:"Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7",YarvikTablet:"Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b",MedionTablet:"Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB",ArnovaTablet:"97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2",IntensoTablet:"INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004",IRUTablet:"M702pro",MegafonTablet:"MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b",EbodaTablet:"E-Boda (Supreme|Impresspeed|Izzycomm|Essential)",AllViewTablet:"Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)",ArchosTablet:"\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b",AinolTablet:"NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark",NokiaLumiaTablet:"Lumia 2520",SonyTablet:"Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712",PhilipsTablet:"\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b",CubeTablet:"Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT",CobyTablet:"MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010",MIDTablet:"M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10",MSITablet:"MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b",SMiTTablet:"Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)",RockChipTablet:"Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A",FlyTablet:"IQ310|Fly Vision",bqTablet:"Android.*(bq)?.*\\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\\b|Maxwell.*Lite|Maxwell.*Plus",HuaweiTablet:"MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19",NecTablet:"\\bN-06D|\\bN-08D",PantechTablet:"Pantech.*P4100",BronchoTablet:"Broncho.*(N701|N708|N802|a710)",VersusTablet:"TOUCHPAD.*[78910]|\\bTOUCHTAB\\b",ZyncTablet:"z1000|Z99 2G|z930|z990|z909|Z919|z900",PositivoTablet:"TB07STA|TB10STA|TB07FTA|TB10FTA",NabiTablet:"Android.*\\bNabi",KoboTablet:"Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build",DanewTablet:"DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b",TexetTablet:"NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE",PlaystationTablet:"Playstation.*(Portable|Vita)",TrekstorTablet:"ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab",PyleAudioTablet:"\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b",AdvanTablet:"Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ",DanyTechTablet:"Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1",GalapadTablet:"Android [0-9.]+; [a-z-]+; \\bG1\\b",MicromaxTablet:"Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b",KarbonnTablet:"Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b",AllFineTablet:"Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide",PROSCANTablet:"\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b",YONESTablet:"BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026",ChangJiaTablet:"TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503",GUTablet:"TX-A1301|TX-M9002|Q702|kf026",PointOfViewTablet:"TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10",OvermaxTablet:"OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027",HCLTablet:"HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync",DPSTablet:"DPS Dream 9|DPS Dual 7",VistureTablet:"V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10",CrestaTablet:"CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989",MediatekTablet:"\\bMT8125|MT8389|MT8135|MT8377\\b",ConcordeTablet:"Concorde([ ]+)?Tab|ConCorde ReadMan",GoCleverTablet:"GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042",ModecomTablet:"FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003",VoninoTablet:"\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b",ECSTablet:"V07OT2|TM105A|S10OT1|TR10CS1",StorexTablet:"eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab",VodafoneTablet:"SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400",EssentielBTablet:"Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2",RossMoorTablet:"RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711",iMobileTablet:"i-mobile i-note",TolinoTablet:"tolino tab [0-9.]+|tolino shine",AudioSonicTablet:"\\bC-22Q|T7-QC|T-17B|T-17P\\b",AMPETablet:"Android.* A78 ",SkkTablet:"Android.* (SKYPAD|PHOENIX|CYCLOPS)",TecnoTablet:"TECNO P9|TECNO DP8D",JXDTablet:"Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b",iJoyTablet:"Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)",FX2Tablet:"FX2 PAD7|FX2 PAD10",XoroTablet:"KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151",ViewsonicTablet:"ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a",VerizonTablet:"QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1",OdysTablet:"LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10",CaptivaTablet:"CAPTIVA PAD",IconbitTablet:"NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S",TeclastTablet:"T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi",OndaTablet:"\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+|V10 \\b4G\\b",JaytechTablet:"TPC-PA762",BlaupunktTablet:"Endeavour 800NG|Endeavour 1010",DigmaTablet:"\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b",EvolioTablet:"ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b",LavaTablet:"QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b",AocTablet:"MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712",MpmanTablet:"MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010",CelkonTablet:"CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b",WolderTablet:"miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b",MediacomTablet:"M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA",MiTablet:"\\bMI PAD\\b|\\bHM NOTE 1W\\b",NibiruTablet:"Nibiru M1|Nibiru Jupiter One",NexoTablet:"NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI",LeaderTablet:"TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100",UbislateTablet:"UbiSlate[\\s]?7C",PocketBookTablet:"Pocketbook",KocasoTablet:"\\b(TB-1207)\\b",HisenseTablet:"\\b(F5281|E2371)\\b",Hudl:"Hudl HT7S3|Hudl 2",TelstraTablet:"T-Hub2",GenericTablet:"Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bTP750\\b|\\bQTAQZ3\\b|WVT101|TM1088|KT107"},oss:{AndroidOS:"Android",BlackBerryOS:"blackberry|\\bBB10\\b|rim tablet os",PalmOS:"PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino",SymbianOS:"Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b",WindowsMobileOS:"Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;",WindowsPhoneOS:"Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;",iOS:"\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia",iPadOS:"CPU OS 13",SailfishOS:"Sailfish",MeeGoOS:"MeeGo",MaemoOS:"Maemo",JavaOS:"J2ME/|\\bMIDP\\b|\\bCLDC\\b",webOS:"webOS|hpwOS",badaOS:"\\bBada\\b",BREWOS:"BREW"},uas:{Chrome:"\\bCrMo\\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?",Dolfin:"\\bDolfin\\b",Opera:"Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+$|Coast/[0-9.]+",Skyfire:"Skyfire",Edge:"\\bEdgiOS\\b|Mobile Safari/[.0-9]* Edge",IE:"IEMobile|MSIEMobile",Firefox:"fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS",Bolt:"bolt",TeaShark:"teashark",Blazer:"Blazer",Safari:"Version((?!\\bEdgiOS\\b).)*Mobile.*Safari|Safari.*Mobile|MobileSafari",WeChat:"\\bMicroMessenger\\b",UCBrowser:"UC.*Browser|UCWEB",baiduboxapp:"baiduboxapp",baidubrowser:"baidubrowser",DiigoBrowser:"DiigoBrowser",Mercury:"\\bMercury\\b",ObigoBrowser:"Obigo",NetFront:"NF-Browser",GenericBrowser:"NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger",PaleMoon:"Android.*PaleMoon|Mobile.*PaleMoon"},props:{Mobile:"Mobile/[VER]",Build:"Build/[VER]",Version:"Version/[VER]",VendorID:"VendorID/[VER]",iPad:"iPad.*CPU[a-z ]+[VER]",iPhone:"iPhone.*CPU[a-z ]+[VER]",iPod:"iPod.*CPU[a-z ]+[VER]",Kindle:"Kindle/[VER]",Chrome:["Chrome/[VER]","CriOS/[VER]","CrMo/[VER]"],Coast:["Coast/[VER]"],Dolfin:"Dolfin/[VER]",Firefox:["Firefox/[VER]","FxiOS/[VER]"],Fennec:"Fennec/[VER]",Edge:"Edge/[VER]",IE:["IEMobile/[VER];","IEMobile [VER]","MSIE [VER];","Trident/[0-9.]+;.*rv:[VER]"],NetFront:"NetFront/[VER]",NokiaBrowser:"NokiaBrowser/[VER]",Opera:[" OPR/[VER]","Opera Mini/[VER]","Version/[VER]"],"Opera Mini":"Opera Mini/[VER]","Opera Mobi":"Version/[VER]",UCBrowser:["UCWEB[VER]","UC.*Browser/[VER]"],MQQBrowser:"MQQBrowser/[VER]",MicroMessenger:"MicroMessenger/[VER]",baiduboxapp:"baiduboxapp/[VER]",baidubrowser:"baidubrowser/[VER]",SamsungBrowser:"SamsungBrowser/[VER]",Iron:"Iron/[VER]",Safari:["Version/[VER]","Safari/[VER]"],Skyfire:"Skyfire/[VER]",Tizen:"Tizen/[VER]",Webkit:"webkit[ /][VER]",PaleMoon:"PaleMoon/[VER]",SailfishBrowser:"SailfishBrowser/[VER]",Gecko:"Gecko/[VER]",Trident:"Trident/[VER]",Presto:"Presto/[VER]",Goanna:"Goanna/[VER]",iOS:" \\bi?OS\\b [VER][ ;]{1}",Android:"Android [VER]",Sailfish:"Sailfish [VER]",BlackBerry:["BlackBerry[\\w]+/[VER]","BlackBerry.*Version/[VER]","Version/[VER]"],BREW:"BREW [VER]",Java:"Java/[VER]","Windows Phone OS":["Windows Phone OS [VER]","Windows Phone [VER]"],"Windows Phone":"Windows Phone [VER]","Windows CE":"Windows CE/[VER]","Windows NT":"Windows NT [VER]",Symbian:["SymbianOS/[VER]","Symbian/[VER]"],webOS:["webOS/[VER]","hpwOS/[VER];"]},utils:{Bot:"Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp|AspiegelBot",MobileBot:"Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2",DesktopMode:"WPDesktop",TV:"SonyDTV|HbbTV",WebKit:"(webkit)[ /]([\\w.]+)",Console:"\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\\b",Watch:"SM-V700"}},detectMobileBrowsers:{fullPattern:/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i,shortPattern:/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,tabletPattern:/android|ipad|playbook|silk/i}},r=Object.prototype.hasOwnProperty;function n(e,t){return null!=e&&null!=t&&e.toLowerCase()===t.toLowerCase()}function i(e,t){var r,n,i=e.length;if(!i||!t)return!1;for(r=t.toLowerCase(),n=0;n=0&&(o=o.substring(0,d)+"([\\w._\\+]+)"+o.substring(d+5)),i[s]=new RegExp(o,"i");u.props[n]=i}a(u.oss),a(u.phones),a(u.tablets),a(u.uas),a(u.utils),u.oss0={WindowsPhoneOS:u.oss.WindowsPhoneOS,WindowsMobileOS:u.oss.WindowsMobileOS}}(),t.findMatch=function(e,t){for(var n in e)if(r.call(e,n)&&e[n].test(t))return n;return null},t.findMatches=function(e,t){var n=[];for(var i in e)r.call(e,i)&&e[i].test(t)&&n.push(i);return n},t.getVersionStr=function(e,n){var i,a,o,s,c=t.mobileDetectRules.props;if(r.call(c,e))for(o=(i=c[e]).length,a=0;a1&&(e=t[0]+".",t.shift(),e+=t.join("")),Number(e)},t.isMobileFallback=function(e){return t.detectMobileBrowsers.fullPattern.test(e)||t.detectMobileBrowsers.shortPattern.test(e.substr(0,4))},t.isTabletFallback=function(e){return t.detectMobileBrowsers.tabletPattern.test(e)},t.prepareDetectionCache=function(e,r,n){if(void 0===e.mobile){var i,a,s;if(a=t.findMatch(t.mobileDetectRules.tablets,r))return e.mobile=e.tablet=a,void(e.phone=null);if(i=t.findMatch(t.mobileDetectRules.phones,r))return e.mobile=e.phone=i,void(e.tablet=null);t.isMobileFallback(r)?void 0===(s=o.isPhoneSized(n))?(e.mobile=t.FALLBACK_MOBILE,e.tablet=e.phone=null):s?(e.mobile=e.phone=t.FALLBACK_PHONE,e.tablet=null):(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):t.isTabletFallback(r)?(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):e.mobile=e.tablet=e.phone=null}},t.mobileGrade=function(e){var t=null!==e.mobile();return e.os("iOS")&&e.version("iPad")>=4.3||e.os("iOS")&&e.version("iPhone")>=3.1||e.os("iOS")&&e.version("iPod")>=3.1||e.version("Android")>2.1&&e.is("Webkit")||e.version("Windows Phone OS")>=7||e.is("BlackBerry")&&e.version("BlackBerry")>=6||e.match("Playbook.*Tablet")||e.version("webOS")>=1.4&&e.match("Palm|Pre|Pixi")||e.match("hp.*TouchPad")||e.is("Firefox")&&e.version("Firefox")>=12||e.is("Chrome")&&e.is("AndroidOS")&&e.version("Android")>=4||e.is("Skyfire")&&e.version("Skyfire")>=4.1&&e.is("AndroidOS")&&e.version("Android")>=2.3||e.is("Opera")&&e.version("Opera Mobi")>11&&e.is("AndroidOS")||e.is("MeeGoOS")||e.is("Tizen")||e.is("Dolfin")&&e.version("Bada")>=2||(e.is("UC Browser")||e.is("Dolfin"))&&e.version("Android")>=2.3||e.match("Kindle Fire")||e.is("Kindle")&&e.version("Kindle")>=3||e.is("AndroidOS")&&e.is("NookTablet")||e.version("Chrome")>=11&&!t||e.version("Safari")>=5&&!t||e.version("Firefox")>=4&&!t||e.version("MSIE")>=7&&!t||e.version("Opera")>=10&&!t?"A":e.os("iOS")&&e.version("iPad")<4.3||e.os("iOS")&&e.version("iPhone")<3.1||e.os("iOS")&&e.version("iPod")<3.1||e.is("Blackberry")&&e.version("BlackBerry")>=5&&e.version("BlackBerry")<6||e.version("Opera Mini")>=5&&e.version("Opera Mini")<=6.5&&(e.version("Android")>=2.3||e.is("iOS"))||e.match("NokiaN8|NokiaC7|N97.*Series60|Symbian/3")||e.version("Opera Mobi")>=11&&e.is("SymbianOS")?"B":(e.version("BlackBerry")<5||e.match("MSIEMobile|Windows CE.*Mobile")||e.version("Windows Mobile"),"C")},t.detectOS=function(e){return t.findMatch(t.mobileDetectRules.oss0,e)||t.findMatch(t.mobileDetectRules.oss,e)},t.getDeviceSmallerSide=function(){return window.screen.width-1,v=!!window.chrome,T=navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i),b=function(){const e=s();if(!navigator||!navigator.appVersion||!e)return e;const r=/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/.exec(window.navigator.appVersion);return r&&r[1]?t({},e,{chromeVersion:r[1]}):e}()||{},S=!!new m(navigator.userAgent).mobile(),y=navigator.userAgent.toLowerCase().indexOf("electron")>-1;function k(){try{return!!window&&("RTCPeerConnection"in window&&("WebSocket"in window&&(!!navigator&&(!!navigator.mediaDevices&&!!navigator.mediaDevices.getUserMedia))))}catch(e){return!1}}function _(){const e=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia,t=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getSupportedConstraints&&navigator.mediaDevices.getSupportedConstraints().displaySurface;return g?!!e&&!!t:!!e}function w(){return"createMediaStreamDestination"in(window.AudioContext||window.webkitAudioContext||window.Object).prototype}const E=function(){if(!b)return{support:k(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0};switch(b.name){case"chrome":return{support:k(),mediaStreamDest:f(b.version,"55.0.0"),replaceTrack:f(b.version,"65.0.0"),screenSharing:f(b.version,"55.0.0"),connectionState:f(b.version,"72.0.0"),stats:f(b.version,"67.0.0"),ondevicechange:f(b.version,"57.0.0"),minMaxWithIdeal:f(b.version,"56.0.0"),supportTransceivers:f(b.version,"69.0.0"),unifiedPlan:f(b.version,"72.0.0"),supportRestartICE:!0,getReceivers:f(b.version,"59.0.0"),needH264FmtpLine:p(b.version,"51.0.0"),audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!0,setPlaybackDevice:!0};case"ios":case"safari":return{support:k(),replaceTrack:f(b.version,"11.0.0"),stats:!1,ondevicechange:!1,connectionState:!0,mediaStreamDest:f(b.version,"12.0.0"),screenSharing:f(b.version,"13.0.0"),unifiedPlan:f(b.version,"12.1.0"),supportTransceivers:!0,minMaxWithIdeal:!1,supportRestartICE:!0,getReceivers:!0,audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!1};case"firefox":return{support:k(),replaceTrack:!0,stats:!0,ondevicechange:f(b.version,"52.0.0"),connectionState:!0,mediaStreamDest:!0,screenSharing:!0,minMaxWithIdeal:!0,unifiedPlan:!0,supportTransceivers:f(b.version,"59.0.0"),supportRestartICE:!1,getReceivers:!0,audioContextOptions:f(b.version,"55.0.0"),getDisplayMedia:_(),disconnectAudioNode:!0};case"crios":case"ios-webview":return{support:k(),getDisplayMedia:_(),mediaStreamDest:w(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),mediaStreamDest:w(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0}}}();"chrome"===b.name&&function(){const e=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),(e={})[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(e){return new Promise((t,r)=>{navigator.getUserMedia(e,t,r)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:t,enumerateDevices:()=>new Promise(e=>{const t={audio:"audioinput",video:"videoinput"};return window.MediaStreamTrack.getSources(r=>{e(r.map(e=>({label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""})))})})}),navigator.mediaDevices.getSupportedConstraints||(navigator.mediaDevices.getSupportedConstraints=(()=>({deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}))),navigator.mediaDevices.getUserMedia){const t=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(r){return function(t,r){if(A(b.version,"61.0.0"))return r(t);if((t=JSON.parse(JSON.stringify(t)))&&"object"==typeof t.audio){const r=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};r((t=JSON.parse(JSON.stringify(t))).audio,"autoGainControl","googAutoGainControl"),r(t.audio,"noiseSuppression","googNoiseSuppression"),t.audio=e(t.audio)}if(t&&"object"==typeof t.video){let n=t.video.facingMode;n=n&&("object"==typeof n?n:{ideal:n});const i=h(b.version,"66.0.0");if(n&&("user"===n.exact||"environment"===n.exact||"user"===n.ideal||"environment"===n.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode||i)){delete t.video.facingMode;let i=void 0;if("environment"===n.exact||"environment"===n.ideal?i=["back","rear"]:"user"!==n.exact&&"user"!==n.ideal||(i=["front"]),i)return navigator.mediaDevices.enumerateDevices().then(a=>{let o=(a=a.filter(e=>"videoinput"===e.kind)).find(e=>i.some(t=>e.label.toLowerCase().includes(t)));return!o&&a.length&&i.includes("back")&&(o=a[a.length-1]),o&&(t.video.deviceId=n.exact?{exact:o.deviceId}:{ideal:o.deviceId}),t.video=e(t.video),r(t)})}t.video=e(t.video)}return r(t)}(r,e=>t(e).then(t=>{if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return t},e=>Promise.reject(e)))}}else navigator.mediaDevices.getUserMedia=function(e){return t(e)}}(),"firefox"===b.name&&function(){const e=function(e){return new Promise((t,r)=>{!function(e,t,r){e=JSON.parse(JSON.stringify(e)),navigator.mozGetUserMedia(e,t,e=>{r(e)})}(e,t,r)})};navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:e,addEventListener(){},removeEventListener(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise(e=>{e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})}}();var C=u(function(e){!function(t){function r(){}var n=r.prototype,i=t.EventEmitter;function a(e,t){for(var r=e.length;r--;)if(e[r].listener===t)return r;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}n.getListeners=function(e){var t,r,n=this._getEvents();if(e instanceof RegExp)for(r in t={},n)n.hasOwnProperty(r)&&e.test(r)&&(t[r]=n[r]);else t=n[e]||(n[e]=[]);return t},n.flattenListeners=function(e){var t,r=[];for(t=0;td))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ee:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Pe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},we.prototype.clear=function(){this.__data__={hash:new ke,map:new(ue||_e),string:new ke}},we.prototype.delete=function(e){return Ge(this,e).delete(e)},we.prototype.get=function(e){return Ge(this,e).get(e)},we.prototype.has=function(e){return Ge(this,e).has(e)},we.prototype.set=function(e,t){return Ge(this,e).set(e,t),this},Ee.prototype.add=Ee.prototype.push=function(e){return this.__data__.set(e,i),this},Ee.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.clear=function(){this.__data__=new _e},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var n=this.__data__;if(n instanceof _e){var i=n.__data__;if(!ue||i.length-1&&e%1==0&&ei?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var a=Array(i);++n-1&&e%1==0&&e<=d}function nt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function it(e){return!!e&&"object"==typeof e}function at(e){return"symbol"==typeof e||it(e)&&re.call(e)==k}var ot=j?function(e){return function(t){return e(t)}}(j):function(e){return it(e)&&rt(e.length)&&!!O[re.call(e)]};function st(e){return et(e)?Me(e):Be(e)}function ct(e){return e}e.exports=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],a=e.length;for(t=xe(t);++n!!e&&!!e.audio&&e.audio.enabled,I=e=>!!e&&!!e.video&&e.video.enabled,R=e=>!!e&&!!e.screen&&e.screen.enabled;var D,O,x,B,L;function N(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(D||(D={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(O||(O={})),function(e){e[e.INVALID=-1]="INVALID",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.FAIR=3]="FAIR",e[e.POOR=4]="POOR"}(x||(x={})),function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connect=2]="Connect"}(B||(B={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(L||(L={}));const G={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var H;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.STOP="stop",e.END="end"}(H||(H={}));const F={Init:1,UnInit:2,JoinRoom:3,MCSAuth:4,SignalAuth:5,LeaveRoom:6,PublisherPC:7,PublishTracks:8,UnPublishTracks:9,SubscriberPC:10,SubscribeTracks:11,UnSubscribeTracks:13,MuteTracks:14,ICEConnectionState:15,CallbackStatistics:16,KickoutUser:17,RoomStateChanged:18,AudioDeviceInOut:19,VideoDeviceInOut:20,SDKError:21,ApplicationState:22,CreateMergeJob:24,UpdateMergeTracks:25,StopMerge:26,AuthorizationStatus:27,DeviceChanged:28,DefaultSetting:29,MediaStatistics:30,AbnormalDisconnect:31,CreateForwardJob:36,StopForwardJob:37,WebsocketConnect:40,NetworkChange:46,SystemRequirementsTest:47,AutoplayFail:49,TrackEnded:50,WebSDKException:51,VideoPlayQuality:53,AudioPlayQuality:54,JoinRoomResult:55,SetClientRole:56,StartMediaRelay:57,UpdateMediaRelay:58,StopMediaRelay:59,MCURelayAuth:60};var j=u(function(e){var t,r;t=c,r=function(){var e=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},t=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},r=function(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])},n=function(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=t(e,[4283543511,3981806797]),e=i(e,[0,e[0]>>>1]),e=t(e,[3301882366,444984403]),e=i(e,[0,e[0]>>>1])},o=function(o,s){s=s||0;for(var c=(o=o||"").length%16,d=o.length-c,u=[0,s],l=[0,s],A=[0,0],h=[0,0],f=[2277735313,289559509],p=[1291169091,658871167],m=0;m>>0).toString(16)).slice(-8)+("00000000"+(u[1]>>>0).toString(16)).slice(-8)+("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)},s={preprocessor:null,audio:{timeout:1e3,excludeIOS11:!0},fonts:{swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",userDefinedFonts:[],extendedJsFonts:!1},screen:{detectScreenOrientation:!0},plugins:{sortPluginsFor:[/palemoon/i],excludeIE:!1},extraComponents:[],excludes:{enumerateDevices:!0,pixelRatio:!0,doNotTrack:!0,fontsFlash:!0},NOT_AVAILABLE:"not available",ERROR:"error",EXCLUDED:"excluded"},c=function(e,t){if(Array.prototype.forEach&&e.forEach===Array.prototype.forEach)e.forEach(t);else if(e.length===+e.length)for(var r=0,n=e.length;rt.name?1:e.name=0?"Windows Phone":t.indexOf("win")>=0?"Windows":t.indexOf("android")>=0?"Android":t.indexOf("linux")>=0?"Linux":t.indexOf("iphone")>=0||t.indexOf("ipad")>=0?"iOS":t.indexOf("mac")>=0?"Mac":"Other",("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)&&"Windows Phone"!==e&&"Android"!==e&&"iOS"!==e&&"Other"!==e)return!0;if(void 0!==r){if((r=r.toLowerCase()).indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e)return!0;if(r.indexOf("linux")>=0&&"Linux"!==e&&"Android"!==e)return!0;if(r.indexOf("mac")>=0&&"Mac"!==e&&"iOS"!==e)return!0;if((-1===r.indexOf("win")&&-1===r.indexOf("linux")&&-1===r.indexOf("mac"))!=("Other"===e))return!0}return n.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e||((n.indexOf("linux")>=0||n.indexOf("android")>=0||n.indexOf("pike")>=0)&&"Linux"!==e&&"Android"!==e||((n.indexOf("mac")>=0||n.indexOf("ipad")>=0||n.indexOf("ipod")>=0||n.indexOf("iphone")>=0)&&"Mac"!==e&&"iOS"!==e||((-1===n.indexOf("win")&&-1===n.indexOf("linux")&&-1===n.indexOf("mac"))!=("Other"===e)||void 0===navigator.plugins&&"Windows"!==e&&"Windows Phone"!==e)))},R=function(){var e,t=navigator.userAgent.toLowerCase(),r=navigator.productSub;if(("Chrome"===(e=t.indexOf("firefox")>=0?"Firefox":t.indexOf("opera")>=0||t.indexOf("opr")>=0?"Opera":t.indexOf("chrome")>=0?"Chrome":t.indexOf("safari")>=0?"Safari":t.indexOf("trident")>=0?"Internet Explorer":"Other")||"Safari"===e||"Opera"===e)&&"20030107"!==r)return!0;var n,i=eval.toString().length;if(37===i&&"Safari"!==e&&"Firefox"!==e&&"Other"!==e)return!0;if(39===i&&"Internet Explorer"!==e&&"Other"!==e)return!0;if(33===i&&"Chrome"!==e&&"Opera"!==e&&"Other"!==e)return!0;try{throw"a"}catch(e){try{e.toSource(),n=!0}catch(e){n=!1}}return n&&"Firefox"!==e&&"Other"!==e},D=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},O=function(){if(!D())return!1;var e=G();return!!window.WebGLRenderingContext&&!!e},x=function(){return"Microsoft Internet Explorer"===navigator.appName||!("Netscape"!==navigator.appName||!/Trident/.test(navigator.userAgent))},B=function(){return void 0!==window.swfobject},L=function(){return window.swfobject.hasFlashPlayerVersion("9.0.0")},N=function(e,t){window.___fp_swf_loaded=function(t){e(t)};var r=t.fonts.swfContainerId;!function(e){var t=document.createElement("div");t.setAttribute("id",e.fonts.swfContainerId),document.body.appendChild(t)}();var n={onReady:"___fp_swf_loaded"};window.swfobject.embedSWF(t.fonts.swfPath,r,"1","1","9.0.0",!1,n,{allowScriptAccess:"always",menu:"false"},{})},G=function(){var e=document.createElement("canvas"),t=null;try{t=e.getContext("webgl")||e.getContext("experimental-webgl")}catch(e){}return t||(t=null),t},H=[{key:"userAgent",getData:function(e){e(navigator.userAgent)}},{key:"language",getData:function(e,t){e(navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||t.NOT_AVAILABLE)}},{key:"colorDepth",getData:function(e,t){e(window.screen.colorDepth||t.NOT_AVAILABLE)}},{key:"deviceMemory",getData:function(e,t){e(navigator.deviceMemory||t.NOT_AVAILABLE)}},{key:"pixelRatio",getData:function(e,t){e(window.devicePixelRatio||t.NOT_AVAILABLE)}},{key:"hardwareConcurrency",getData:function(e,t){e(T(t))}},{key:"screenResolution",getData:function(e,t){e(l(t))}},{key:"availableScreenResolution",getData:function(e,t){e(A(t))}},{key:"timezoneOffset",getData:function(e){e((new Date).getTimezoneOffset())}},{key:"timezone",getData:function(e,t){window.Intl&&window.Intl.DateTimeFormat?e((new window.Intl.DateTimeFormat).resolvedOptions().timeZone):e(t.NOT_AVAILABLE)}},{key:"sessionStorage",getData:function(e,t){e(m(t))}},{key:"localStorage",getData:function(e,t){e(g(t))}},{key:"indexedDb",getData:function(e,t){e(v(t))}},{key:"addBehavior",getData:function(e){e(!(!document.body||!document.body.addBehavior))}},{key:"openDatabase",getData:function(e){e(!!window.openDatabase)}},{key:"cpuClass",getData:function(e,t){e(b(t))}},{key:"platform",getData:function(e,t){e(S(t))}},{key:"doNotTrack",getData:function(e,t){e(y(t))}},{key:"plugins",getData:function(e,t){x()?t.plugins.excludeIE?e(t.EXCLUDED):e(f(t)):e(h(t))}},{key:"canvas",getData:function(e,t){D()?e(_(t)):e(t.NOT_AVAILABLE)}},{key:"webgl",getData:function(e,t){O()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){O()?e(E()):e()}},{key:"adBlock",getData:function(e){e(C())}},{key:"hasLiedLanguages",getData:function(e){e(M())}},{key:"hasLiedResolution",getData:function(e){e(P())}},{key:"hasLiedOs",getData:function(e){e(I())}},{key:"hasLiedBrowser",getData:function(e){e(R())}},{key:"touchSupport",getData:function(e){e(k())}},{key:"fonts",getData:function(e,t){var r=["monospace","sans-serif","serif"],n=["Andale Mono","Arial","Arial Black","Arial Hebrew","Arial MT","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Bitstream Vera Sans Mono","Book Antiqua","Bookman Old Style","Calibri","Cambria","Cambria Math","Century","Century Gothic","Century Schoolbook","Comic Sans","Comic Sans MS","Consolas","Courier","Courier New","Geneva","Georgia","Helvetica","Helvetica Neue","Impact","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","LUCIDA GRANDE","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Microsoft Sans Serif","Monaco","Monotype Corsiva","MS Gothic","MS Outlook","MS PGothic","MS Reference Sans Serif","MS Sans Serif","MS Serif","MYRIAD","MYRIAD PRO","Palatino","Palatino Linotype","Segoe Print","Segoe Script","Segoe UI","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tahoma","Times","Times New Roman","Times New Roman PS","Trebuchet MS","Verdana","Wingdings","Wingdings 2","Wingdings 3"];t.fonts.extendedJsFonts&&(n=n.concat(["Abadi MT Condensed Light","Academy Engraved LET","ADOBE CASLON PRO","Adobe Garamond","ADOBE GARAMOND PRO","Agency FB","Aharoni","Albertus Extra Bold","Albertus Medium","Algerian","Amazone BT","American Typewriter","American Typewriter Condensed","AmerType Md BT","Andalus","Angsana New","AngsanaUPC","Antique Olive","Aparajita","Apple Chancery","Apple Color Emoji","Apple SD Gothic Neo","Arabic Typesetting","ARCHER","ARNO PRO","Arrus BT","Aurora Cn BT","AvantGarde Bk BT","AvantGarde Md BT","AVENIR","Ayuthaya","Bandy","Bangla Sangam MN","Bank Gothic","BankGothic Md BT","Baskerville","Baskerville Old Face","Batang","BatangChe","Bauer Bodoni","Bauhaus 93","Bazooka","Bell MT","Bembo","Benguiat Bk BT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","BernhardFashion BT","BernhardMod BT","Big Caslon","BinnerD","Blackadder ITC","BlairMdITC TT","Bodoni 72","Bodoni 72 Oldstyle","Bodoni 72 Smallcaps","Bodoni MT","Bodoni MT Black","Bodoni MT Condensed","Bodoni MT Poster Compressed","Bookshelf Symbol 7","Boulder","Bradley Hand","Bradley Hand ITC","Bremen Bd BT","Britannic Bold","Broadway","Browallia New","BrowalliaUPC","Brush Script MT","Californian FB","Calisto MT","Calligrapher","Candara","CaslonOpnface BT","Castellar","Centaur","Cezanne","CG Omega","CG Times","Chalkboard","Chalkboard SE","Chalkduster","Charlesworth","Charter Bd BT","Charter BT","Chaucer","ChelthmITC Bk BT","Chiller","Clarendon","Clarendon Condensed","CloisterBlack BT","Cochin","Colonna MT","Constantia","Cooper Black","Copperplate","Copperplate Gothic","Copperplate Gothic Bold","Copperplate Gothic Light","CopperplGoth Bd BT","Corbel","Cordia New","CordiaUPC","Cornerstone","Coronet","Cuckoo","Curlz MT","DaunPenh","Dauphin","David","DB LCD Temp","DELICIOUS","Denmark","DFKai-SB","Didot","DilleniaUPC","DIN","DokChampa","Dotum","DotumChe","Ebrima","Edwardian Script ITC","Elephant","English 111 Vivace BT","Engravers MT","EngraversGothic BT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC","EucrosiaUPC","Euphemia","Euphemia UCAS","EUROSTILE","Exotc350 Bd BT","FangSong","Felix Titling","Fixedsys","FONTIN","Footlight MT Light","Forte","FrankRuehl","Fransiscan","Freefrm721 Blk BT","FreesiaUPC","Freestyle Script","French Script MT","FrnkGothITC Bk BT","Fruitger","FRUTIGER","Futura","Futura Bk BT","Futura Lt BT","Futura Md BT","Futura ZBlk BT","FuturaBlack BT","Gabriola","Galliard BT","Gautami","Geeza Pro","Geometr231 BT","Geometr231 Hv BT","Geometr231 Lt BT","GeoSlab 703 Lt BT","GeoSlab 703 XBd BT","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Gisha","Gloucester MT Extra Condensed","GOTHAM","GOTHAM BOLD","Goudy Old Style","Goudy Stout","GoudyHandtooled BT","GoudyOLSt BT","Gujarati Sangam MN","Gulim","GulimChe","Gungsuh","GungsuhChe","Gurmukhi MN","Haettenschweiler","Harlow Solid Italic","Harrington","Heather","Heiti SC","Heiti TC","HELV","Herald","High Tower Text","Hiragino Kaku Gothic ProN","Hiragino Mincho ProN","Hoefler Text","Humanst 521 Cn BT","Humanst521 BT","Humanst521 Lt BT","Imprint MT Shadow","Incised901 Bd BT","Incised901 BT","Incised901 Lt BT","INCONSOLATA","Informal Roman","Informal011 BT","INTERSTATE","IrisUPC","Iskoola Pota","JasmineUPC","Jazz LET","Jenson","Jester","Jokerman","Juice ITC","Kabel Bk BT","Kabel Ult BT","Kailasa","KaiTi","Kalinga","Kannada Sangam MN","Kartika","Kaufmann Bd BT","Kaufmann BT","Khmer UI","KodchiangUPC","Kokila","Korinna BT","Kristen ITC","Krungthep","Kunstler Script","Lao UI","Latha","Leelawadee","Letter Gothic","Levenim MT","LilyUPC","Lithograph","Lithograph Light","Long Island","Lydian BT","Magneto","Maiandra GD","Malayalam Sangam MN","Malgun Gothic","Mangal","Marigold","Marion","Marker Felt","Market","Marlett","Matisse ITC","Matura MT Script Capitals","Meiryo","Meiryo UI","Microsoft Himalaya","Microsoft JhengHei","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Tai Le","Microsoft Uighur","Microsoft YaHei","Microsoft Yi Baiti","MingLiU","MingLiU_HKSCS","MingLiU_HKSCS-ExtB","MingLiU-ExtB","Minion","Minion Pro","Miriam","Miriam Fixed","Mistral","Modern","Modern No. 20","Mona Lisa Solid ITC TT","Mongolian Baiti","MONO","MoolBoran","Mrs Eaves","MS LineDraw","MS Mincho","MS PMincho","MS Reference Specialty","MS UI Gothic","MT Extra","MUSEO","MV Boli","Nadeem","Narkisim","NEVIS","News Gothic","News GothicMT","NewsGoth BT","Niagara Engraved","Niagara Solid","Noteworthy","NSimSun","Nyala","OCR A Extended","Old Century","Old English Text MT","Onyx","Onyx BT","OPTIMA","Oriya Sangam MN","OSAKA","OzHandicraft BT","Palace Script MT","Papyrus","Parchment","Party LET","Pegasus","Perpetua","Perpetua Titling MT","PetitaBold","Pickwick","Plantagenet Cherokee","Playbill","PMingLiU","PMingLiU-ExtB","Poor Richard","Poster","PosterBodoni BT","PRINCETOWN LET","Pristina","PTBarnum BT","Pythagoras","Raavi","Rage Italic","Ravie","Ribbon131 Bd BT","Rockwell","Rockwell Condensed","Rockwell Extra Bold","Rod","Roman","Sakkal Majalla","Santa Fe LET","Savoye LET","Sceptre","Script","Script MT Bold","SCRIPTINA","Serifa","Serifa BT","Serifa Th BT","ShelleyVolante BT","Sherwood","Shonar Bangla","Showcard Gothic","Shruti","Signboard","SILKSCREEN","SimHei","Simplified Arabic","Simplified Arabic Fixed","SimSun","SimSun-ExtB","Sinhala Sangam MN","Sketch Rockwell","Skia","Small Fonts","Snap ITC","Snell Roundhand","Socket","Souvenir Lt BT","Staccato222 BT","Steamer","Stencil","Storybook","Styllo","Subway","Swis721 BlkEx BT","Swiss911 XCm BT","Sylfaen","Synchro LET","System","Tamil Sangam MN","Technical","Teletype","Telugu Sangam MN","Tempus Sans ITC","Terminal","Thonburi","Traditional Arabic","Trajan","TRAJAN PRO","Tristan","Tubular","Tunga","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold","TypoUpright BT","Unicorn","Univers","Univers CE 55 Medium","Univers Condensed","Utsaah","Vagabond","Vani","Vijaya","Viner Hand ITC","VisualUI","Vivaldi","Vladimir Script","Vrinda","Westminster","WHITNEY","Wide Latin","ZapfEllipt BT","ZapfHumnst BT","ZapfHumnst Dm BT","Zapfino","Zurich BlkEx BT","Zurich Ex BT","ZWAdobeF"]));n=(n=n.concat(t.fonts.userDefinedFonts)).filter(function(e,t){return n.indexOf(e)===t});var i=document.getElementsByTagName("body")[0],a=document.createElement("div"),o=document.createElement("div"),s={},c={},d=function(){var e=document.createElement("span");return e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="72px",e.style.fontStyle="normal",e.style.fontWeight="normal",e.style.letterSpacing="normal",e.style.lineBreak="auto",e.style.lineHeight="normal",e.style.textTransform="none",e.style.textAlign="left",e.style.textDecoration="none",e.style.textShadow="none",e.style.whiteSpace="normal",e.style.wordBreak="normal",e.style.wordSpacing="normal",e.innerHTML="mmmmmmmmmmlli",e},u=function(e,t){var r=d();return r.style.fontFamily="'"+e+"',"+t,r},l=function(e){for(var t=!1,n=0;n=e.components.length)t(r.data);else{var o=e.components[n];if(e.excludes[o.key])i(!1);else{if(!a&&o.pauseBefore)return n-=1,void setTimeout(function(){i(!0)},1);try{o.getData(function(e){r.addPreprocessedComponent(o.key,e),i(!1)},e)}catch(e){r.addPreprocessedComponent(o.key,String(e)),i(!1)}}}};i(!1)},F.getPromise=function(e){return new Promise(function(t,r){F.get(e,t)})},F.getV18=function(e,t){return null==t&&(t=e,e={}),F.get(e,function(r){for(var n=[],i=0;i=43)}}).catch(function(){return!1})}(e).then(function(e){return A=e})}function v(e){var t=h[e.name],r={};r.promise=new o(function(e,t){r.resolve=e,r.reject=t}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function T(e){var t=h[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function b(e,t){var r=h[e.name],n=r.deferredOperations.pop();if(n)return n.reject(t),n.promise}function S(e,t){return new o(function(r,n){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);v(e),e.db.close()}var a=[e.name];t&&a.push(e.version);var o=i.open.apply(i,a);t&&(o.onupgradeneeded=function(t){var r=o.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(l)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),n(o.error)},o.onsuccess=function(){r(o.result),T(e)}})}function y(e){return S(e,!1)}function k(e){return S(e,!0)}function _(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function w(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return o.resolve().then(function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),k(e)}).then(function(){return function(e){v(e);for(var t=h[e.name],r=t.forages,n=0;n>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&a;return d}function Q(e){var t,r=new Uint8Array(e),n="";for(t=0;t>2],n+=I[(3&r[t])<<4|r[t+1]>>4],n+=I[(15&r[t+1])<<2|r[t+2]>>6],n+=I[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var J={serialize:function(e,t){var r="";if(e&&(r=X.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===X.call(e.buffer))){var n,i=O;e instanceof ArrayBuffer?(n=e,i+=B):(n=e.buffer,"[object Int8Array]"===r?i+=N:"[object Uint8Array]"===r?i+=G:"[object Uint8ClampedArray]"===r?i+=H:"[object Int16Array]"===r?i+=F:"[object Uint16Array]"===r?i+=V:"[object Int32Array]"===r?i+=j:"[object Uint32Array]"===r?i+=U:"[object Float32Array]"===r?i+=q:"[object Float64Array]"===r?i+=W:t(new Error("Failed to get type for BinaryArray"))),t(i+Q(n))}else if("[object Blob]"===r){var a=new FileReader;a.onload=function(){var r=R+e.type+"~"+Q(this.result);t(O+L+r)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,x)!==O)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(x,z);if(n===L&&D.test(r)){var i=r.match(D);t=i[1],r=r.substring(i[0].length)}var o=K(r);switch(n){case B:return o;case L:return a([o],{type:t});case N:return new Int8Array(o);case G:return new Uint8Array(o);case H:return new Uint8ClampedArray(o);case F:return new Int16Array(o);case V:return new Uint16Array(o);case j:return new Int32Array(o);case U:return new Uint32Array(o);case q:return new Float32Array(o);case W:return new Float64Array(o);default:throw new Error("Unkown type: "+n)}},stringToBuffer:K,bufferToString:Q};function Z(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function $(e,t,r,n,i,a){e.executeSql(r,n,i,function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(e,s){s.rows.length?a(e,o):Z(e,t,function(){e.executeSql(r,n,i,a)},a)},a):a(e,o)},a)}var Y={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new o(function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction(function(i){Z(i,r,function(){t._dbInfo=r,e()},function(e,t){n(t)})},n)});return r.serializer=J,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT * FROM "+i.storeName,[],function(r,n){for(var a=n.rows,o=a.length,s=0;s0)return void o(e.apply(a,[t,c,n,i-1]));s(r)}})})}).catch(s)});return s(c,n),c}.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=d(e);var n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},clear:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"DELETE FROM "+n.storeName,[],function(){e()},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},length:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(t,r){var n=r.rows.item(0).c;e(n)},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},key:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},keys:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT key FROM "+n.storeName,[],function(t,r){for(var n=[],i=0;i '__WebKitDatabaseInfoTable__'",[],function(r,n){for(var i=[],a=0;a0}var re={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=J,o.resolve()):o.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then(function(){for(var t=r._dbInfo,n=t.keyPrefix,i=n.length,a=localStorage.length,o=1,s=0;s=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}});return s(r,e),r},length:function(e){var t=this.keys().then(function(e){return e.length});return s(t,e),t},key:function(e,t){var r=this,n=r.ready().then(function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t});return s(n,t),n},keys:function(e){var t=this,r=t.ready().then(function(){for(var e=t._dbInfo,r=localStorage.length,n=[],i=0;i=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}}):o.reject("Invalid arguments"),t),n}},ne=function(e,t){for(var r=e.length,n=0;n=0;)e[t]=0}const q=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),W=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),z=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),X=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K=new Array(576);U(K);const Q=new Array(60);U(Q);const J=new Array(512);U(J);const Z=new Array(256);U(Z);const $=new Array(29);U($);const Y=new Array(30);function ee(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let te,re,ne;function ie(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U(Y);const ae=e=>e<256?J[e]:J[256+(e>>>7)],oe=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},se=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<{se(e,r[2*t],r[2*t+1])},de=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},ue=(e,t,r)=>{const n=new Array(16);let i,a,o=0;for(i=1;i<=15;i++)n[i]=o=o+r[i-1]<<1;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=de(n[t]++,t))}},le=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},Ae=e=>{e.bi_valid>8?oe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},he=(e,t,r,n)=>{const i=2*t,a=2*r;return e[i]{const n=e.heap[r];let i=r<<1;for(;i<=e.heap_len&&(i{let n,i,a,o,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?ce(e,i,t):(a=Z[i],ce(e,a+256+1,t),0!==(o=q[a])&&(i-=$[a],se(e,i,o)),a=ae(--n),ce(e,a,r),0!==(o=W[a])&&(n-=Y[a],se(e,n,o)))}while(s{const r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems;let o,s,c,d=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)fe(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],fe(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[2*c]=r[2*o]+r[2*s],e.depth[c]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[2*o+1]=r[2*s+1]=c,e.heap[1]=c++,fe(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let d,u,l,A,h,f,p=0;for(A=0;A<=15;A++)e.bl_count[A]=0;for(r[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)(A=r[2*r[2*(u=e.heap[d])+1]+1]+1)>c&&(A=c,p++),r[2*u+1]=A,u>n||(e.bl_count[A]++,h=0,u>=s&&(h=o[u-s]),f=r[2*u],e.opt_len+=f*(A+h),a&&(e.static_len+=f*(i[2*u+1]+h)));if(0!==p){do{for(A=c-1;0===e.bl_count[A];)A--;e.bl_count[A]--,e.bl_count[A+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(A=c;0!==A;A--)for(u=e.bl_count[A];0!==u;)(l=e.heap[--d])>n||(r[2*l+1]!==A&&(e.opt_len+=(A-r[2*l+1])*r[2*l],r[2*l+1]=A),u--)}})(e,t),ue(r,d,e.bl_count)},ge=(e,t,r)=>{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=t[2*(n+1)+1],++s{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),n=0;n<=r;n++)if(i=o,o=t[2*(n+1)+1],!(++s{se(e,0+(n?1:0),3),((e,t,r,n)=>{Ae(e),n&&(oe(e,r),oe(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var Se={_tr_init:e=>{Te||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for($[n]=r,e=0;e<1<>=7;n<30;n++)for(Y[n]=i<<7,e=0;e<1<{let i,a,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),me(e,e.l_desc),me(e,e.d_desc),o=(e=>{let t;for(ge(e,e.dyn_ltree,e.l_desc.max_code),ge(e,e.dyn_dtree,e.d_desc.max_code),me(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*X[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?be(e,t,r,n):4===e.strategy||a===i?(se(e,2+(n?1:0),3),pe(e,K,Q)):(se(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(se(e,t-257,5),se(e,r-1,5),se(e,n-4,4),i=0;i(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Z[r]+256+1)]++,e.dyn_dtree[2*ae(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{se(e,2,3),ce(e,256,K),(e=>{16===e.bi_valid?(oe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var ye=(e,t,r,n)=>{let i=65535&e|0,a=e>>>16&65535|0,o=0;for(;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0};const ke=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var _e=(e,t,r,n)=>{const i=ke,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},we={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ee={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ce,_tr_stored_block:Me,_tr_flush_block:Pe,_tr_tally:Ie,_tr_align:Re}=Se,{Z_NO_FLUSH:De,Z_PARTIAL_FLUSH:Oe,Z_FULL_FLUSH:xe,Z_FINISH:Be,Z_BLOCK:Le,Z_OK:Ne,Z_STREAM_END:Ge,Z_STREAM_ERROR:He,Z_DATA_ERROR:Fe,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Ve,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:We,Z_FIXED:ze,Z_DEFAULT_STRATEGY:Xe,Z_UNKNOWN:Ke,Z_DEFLATED:Qe}=Ee,Je=286,Ze=30,$e=19,Ye=2*Je+1,et=15,tt=(e,t)=>(e.msg=we[t],t),rt=e=>(e<<1)-(e>4?9:0),nt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let it=(e,t,r)=>(t<{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ot=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,at(e.strm)},st=(e,t)=>{e.pending_buf[e.pending++]=t},ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},dt=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=ye(e.adler,t,i,r):2===e.state.wrap&&(e.adler=_e(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ut=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,u=e.w_mask,l=e.prev,A=e.strstart+258;let h=d[a+o-1],f=d[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(d[(r=t)+o]===f&&d[r+o-1]===h&&d[r]===d[a]&&d[++r]===d[a+1]){a+=2,r++;do{}while(d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&ao){if(e.match_start=t,o=n,n>=s)break;h=d[a+o-1],f=d[a+o]}}}while((t=l[t&u])>c&&0!=--i);return o<=e.lookahead?o:e.lookahead},lt=e=>{const t=e.w_size;let r,n,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-262)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=n=e.hash_size;do{i=e.head[--r],e.head[r]=i>=t?i-t:0}while(--n);r=n=t;do{i=e.prev[--r],e.prev[r]=i>=t?i-t:0}while(--n);a+=t}if(0===e.strm.avail_in)break;if(n=dt(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=it(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=it(e,e.ins_h,e.window[o+3-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},At=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ut(e,r)),e.match_length>=3)if(n=Ie(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=it(e,e.ins_h,e.window[e.strstart+1]);else n=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2},ht=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Ie(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(ot(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Ie(e,0,e.window[e.strstart-1]))&&ot(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ie(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2};function ft(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}const pt=[new ft(0,0,0,0,(e,t)=>{let r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(lt(e),0===e.lookahead&&t===De)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,ot(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(ot(e,!1),e.strm.avail_out),1)}),new ft(4,4,8,4,At),new ft(4,5,16,8,At),new ft(4,6,32,32,At),new ft(4,4,16,16,ht),new ft(8,16,32,32,ht),new ft(8,16,128,128,ht),new ft(8,32,128,256,ht),new ft(32,128,258,1024,ht),new ft(32,258,258,4096,ht)];function mt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qe,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*Ye),this.dyn_dtree=new Uint16Array(2*(2*Ze+1)),this.bl_tree=new Uint16Array(2*(2*$e+1)),nt(this.dyn_ltree),nt(this.dyn_dtree),nt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(et+1),this.heap=new Uint16Array(2*Je+1),nt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Je+1),nt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const gt=e=>{if(!e||!e.state)return tt(e,He);e.total_in=e.total_out=0,e.data_type=Ke;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=De,Ce(t),Ne},vt=e=>{const t=gt(e);return t===Ne&&(e=>{e.window_size=2*e.w_size,nt(e.head),e.max_lazy_match=pt[e.level].max_lazy,e.good_match=pt[e.level].good_length,e.nice_match=pt[e.level].nice_length,e.max_chain_length=pt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0})(e.state),t},Tt=(e,t,r,n,i,a)=>{if(!e)return He;let o=1;if(t===Ve&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Qe||n<8||n>15||t<0||t>9||a<0||a>ze)return tt(e,He);8===n&&(n=9);const s=new mt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<Tt(e,t,Qe,15,8,Xe),deflateInit2:Tt,deflateReset:vt,deflateResetKeep:gt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?He:(e.state.gzhead=t,Ne):He,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Le||t<0)return e?tt(e,He):He;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Be)return tt(e,0===e.avail_out?je:He);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,st(i,31),st(i,139),st(i,8),i.gzhead?(st(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),st(i,255&i.gzhead.time),st(i,i.gzhead.time>>8&255),st(i,i.gzhead.time>>16&255),st(i,i.gzhead.time>>24&255),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(st(i,255&i.gzhead.extra.length),st(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=_e(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(st(i,0),st(i,0),st(i,0),st(i,0),st(i,0),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,3),i.status=113);else{let t=Qe+(i.w_bits-8<<4)<<8,r=-1;t|=(r=i.strategy>=qe||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,ct(i,t),0!==i.strstart&&(ct(i,e.adler>>>16),ct(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending!==i.pending_buf_size));)st(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&at(e),i.pending+2<=i.pending_buf_size&&(st(i,255&e.adler),st(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(at(e),0===e.avail_out)return i.last_flush=-1,Ne}else if(0===e.avail_in&&rt(t)<=rt(a)&&t!==Be)return tt(e,je);if(666===i.status&&0!==e.avail_in)return tt(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==De&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(lt(e),0===e.lookahead)){if(t===De)return 1;break}if(e.match_length=0,r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===We?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(lt(e),e.lookahead<=258&&t===De)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=o[i=e.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){a=e.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Ie(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):pt[i.level].func(i,t);if(3!==r&&4!==r||(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),Ne;if(2===r&&(t===Oe?Re(i):t!==Le&&(Me(i,0,0,!1),t===xe&&(nt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),at(e),0===e.avail_out))return i.last_flush=-1,Ne}return t!==Be?Ne:i.wrap<=0?Ge:(2===i.wrap?(st(i,255&e.adler),st(i,e.adler>>8&255),st(i,e.adler>>16&255),st(i,e.adler>>24&255),st(i,255&e.total_in),st(i,e.total_in>>8&255),st(i,e.total_in>>16&255),st(i,e.total_in>>24&255)):(ct(i,e.adler>>>16),ct(i,65535&e.adler)),at(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Ne:Ge)},deflateEnd:e=>{if(!e||!e.state)return He;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?tt(e,He):(e.state=null,113===t?tt(e,Fe):Ne)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return He;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return He;if(1===i&&(e.adler=ye(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(nt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}const a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,lt(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=it(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,lt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,n.wrap=i,Ne},deflateInfo:"pako deflate (from Nodeca project)"};const St=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var yt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)St(r,t)&&(e[t]=r[t])}}return e},flattenChunks:e=>{let t=0;for(let r=0,n=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;_t[254]=_t[254]=1;var wt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,n,i,a,o=e.length,s=0;for(i=0;i>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},buf2string:(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const a=new Array(2*r);for(i=0,n=0;n4)a[i++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?a[i++]=65533:t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&kt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+_t[e[r]]>t?r:t}};var Et=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ct=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:It,Z_FINISH:Rt,Z_OK:Dt,Z_STREAM_END:Ot,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Bt,Z_DEFLATED:Lt}=Ee;function Nt(e){this.options=yt.assign({level:xt,method:Lt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Bt},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=bt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Dt)throw new Error(we[r]);if(t.header&&bt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?wt.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=bt.deflateSetDictionary(this.strm,e))!==Dt)throw new Error(we[r]);this._dict_set=!0}}function Gt(e,t){const r=new Nt(t);if(r.push(e,!0),r.err)throw r.msg||we[r.err];return r.result}Nt.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize;let i,a;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Rt:Mt,"string"==typeof e?r.input=wt.string2buf(e):"[object ArrayBuffer]"===Ct.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a===Pt||a===It)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=bt.deflate(r,a))===Ot)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=bt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Dt;if(0!==r.avail_out){if(a>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Nt.prototype.onData=function(e){this.chunks.push(e)},Nt.prototype.onEnd=function(e){e===Dt&&(this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ht={Deflate:Nt,deflate:Gt,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Gt(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Gt(e,t)},constants:Ee};var Ft=function(e,t){let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_,w;const E=e.state;r=e.next_in,_=e.input,n=r+(e.avail_in-5),i=e.next_out,w=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,d=E.whave,u=E.wnext,l=E.window,A=E.hold,h=E.bits,f=E.lencode,p=E.distcode,m=(1<>>=T=v>>>24,h-=T,0===(T=v>>>16&255))w[i++]=65535&v;else{if(!(16&T)){if(0==(64&T)){v=f[(65535&v)+(A&(1<>>=T,h-=T),h<15&&(A+=_[r++]<>>=T=v>>>24,h-=T,!(16&(T=v>>>16&255))){if(0==(64&T)){v=p[(65535&v)+(A&(1<s){e.msg="invalid distance too far back",E.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&E.sane){e.msg="invalid distance too far back",E.mode=30;break e}if(y=0,k=l,0===u){if(y+=c-T,T2;)w[i++]=k[y++],w[i++]=k[y++],w[i++]=k[y++],b-=3;b&&(w[i++]=k[y++],b>1&&(w[i++]=k[y++]))}else{y=i-S;do{w[i++]=w[y++],w[i++]=w[y++],w[i++]=w[y++],b-=3}while(b>2);b&&(w[i++]=w[y++],b>1&&(w[i++]=w[y++]))}break}}break}}while(r>3,A&=(1<<(h-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r{const c=s.bits;let d,u,l,A,h,f,p=0,m=0,g=0,v=0,T=0,b=0,S=0,y=0,k=0,_=0,w=null,E=0;const C=new Uint16Array(16),M=new Uint16Array(16);let P,I,R,D=null,O=0;for(p=0;p<=15;p++)C[p]=0;for(m=0;m=1&&0===C[v];v--);if(T>v&&(T=v),0===v)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(M[1]=0,p=1;p<15;p++)M[p+1]=M[p]+C[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){P=p-S,o[m]f?(I=D[O+o[m]],R=w[E+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=P<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--C[p]){if(p===v)break;p=t[r+o[m]]}if(p>T&&(_&A)!==l){for(0===S&&(S=T),h+=g,y=1<<(b=p-S);b+S852||2===e&&k>592)return 1;i[l=_&A]=T<<24|b<<16|h-a|0}}return 0!==_&&(i[h+_]=p-S<<24|64<<16|0),s.bits=T,0};const{Z_FINISH:zt,Z_BLOCK:Xt,Z_TREES:Kt,Z_OK:Qt,Z_STREAM_END:Jt,Z_NEED_DICT:Zt,Z_STREAM_ERROR:$t,Z_DATA_ERROR:Yt,Z_MEM_ERROR:er,Z_BUF_ERROR:tr,Z_DEFLATED:rr}=Ee,nr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ir(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ar=e=>{if(!e||!e.state)return $t;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Qt},or=e=>{if(!e||!e.state)return $t;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ar(e)},sr=(e,t)=>{let r;if(!e||!e.state)return $t;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?$t:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,or(e))},cr=(e,t)=>{if(!e)return $t;const r=new ir;e.state=r,r.window=null;const n=sr(e,t);return n!==Qt&&(e.state=null),n};let dr,ur,lr=!0;const Ar=e=>{if(lr){dr=new Int32Array(512),ur=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Wt(1,e.lens,0,288,dr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Wt(2,e.lens,0,32,ur,0,e.work,{bits:5}),lr=!1}e.lencode=dr,e.lenbits=9,e.distcode=ur,e.distbits=5},hr=(e,t,r,n)=>{let i;const a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whavecr(e,15),inflateInit2:cr,inflate:(e,t)=>{let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_=0;const w=new Uint8Array(4);let E,C;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return $t;12===(r=e.state).mode&&(r.mode=13),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,l=s,A=c,k=Qt;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0),d=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&d)!==rr){e.msg="unknown compression method",r.mode=30;break}if(u-=4,y=8+(15&(d>>>=4)),0===r.wbits)r.wbits=y;else if(y>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>8&255,w[2]=d>>>16&255,w[3]=d>>>24&255,r.check=_e(r.check,w,4,0)),d=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>8),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>s&&(h=s),h&&(r.head&&(y=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),y)),512&r.flags&&(r.check=_e(r.check,n,h,a)),s-=h,a+=h,r.length-=h),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;h=0;do{y=n[a+h++],r.head&&y&&r.length<65536&&(r.head.name+=String.fromCharCode(y))}while(y&&h>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===s)break e;s--,d+=n[a++]<>>=1)){case 0:r.mode=14;break;case 1:if(Ar(r),r.mode=20,t===Kt){d>>>=2,u-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}d>>>=2,u-=2;break;case 14:for(d>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,d+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&d,d=0,u=0,r.mode=15,t===Kt)break e;case 15:r.mode=16;case 16:if(h=r.length){if(h>s&&(h=s),h>c&&(h=c),0===h)break e;i.set(n.subarray(a,a+h),o),s-=h,a+=h,c-=h,o+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===s)break e;s--,d+=n[a++]<>>=5,u-=5,r.ndist=1+(31&d),d>>>=5,u-=5,r.ncode=4+(15&d),d>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,E={bits:r.lenbits},k=Wt(0,r.lens,0,19,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=m,u-=m,r.lens[r.have++]=v;else{if(16===v){for(C=m+2;u>>=m,u-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}y=r.lens[r.have-1],h=3+(3&d),d>>>=2,u-=2}else if(17===v){for(C=m+3;u>>=m)),d>>>=3,u-=3}else{for(C=m+7;u>>=m)),d>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=y}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,E={bits:r.lenbits},k=Wt(1,r.lens,0,r.nlen,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,E={bits:r.distbits},k=Wt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,E),r.distbits=E.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Kt)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=d,r.bits=u,Ft(e,A),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(_=r.lencode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,r.length=v,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(_=r.distcode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=v,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===c)break e;if(h=A-c,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,f=r.wsize-h):f=r.wnext-h,h>r.length&&(h=r.length),p=r.window}else p=i,f=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do{i[o++]=p[f++]}while(--h);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[o++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===s)break e;s--,d|=n[a++]<{if(!e||!e.state)return $t;let t=e.state;return t.window&&(t.window=null),e.state=null,Qt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return $t;const r=e.state;return 0==(2&r.wrap)?$t:(r.head=t,t.done=!1,Qt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?$t:11===n.mode&&(i=ye(i=1,t,r,0))!==n.check?Yt:(a=hr(e,t,r,r))?(n.mode=31,er):(n.havedict=1,Qt):$t},inflateInfo:"pako inflate (from Nodeca project)"};var pr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const mr=Object.prototype.toString,{Z_NO_FLUSH:gr,Z_FINISH:vr,Z_OK:Tr,Z_STREAM_END:br,Z_NEED_DICT:Sr,Z_STREAM_ERROR:yr,Z_DATA_ERROR:kr,Z_MEM_ERROR:_r}=Ee;function wr(e){this.options=yt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=fr.inflateInit2(this.strm,t.windowBits);if(r!==Tr)throw new Error(we[r]);if(this.header=new pr,fr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wt.string2buf(t.dictionary):"[object ArrayBuffer]"===mr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=fr.inflateSetDictionary(this.strm,t.dictionary))!==Tr))throw new Error(we[r])}function Er(e,t){const r=new wr(t);if(r.push(e),r.err)throw r.msg||we[r.err];return r.result}wr.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let a,o,s;if(this.ended)return!1;for(o=t===~~t?t:!0===t?vr:gr,"[object ArrayBuffer]"===mr.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a=fr.inflate(r,o))===Sr&&i&&((a=fr.inflateSetDictionary(r,i))===Tr?a=fr.inflate(r,o):a===kr&&(a=Sr));r.avail_in>0&&a===br&&r.state.wrap>0&&0!==e[r.next_in];)fr.inflateReset(r),a=fr.inflate(r,o);switch(a){case yr:case kr:case Sr:case _r:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===br))if("string"===this.options.to){let e=wt.utf8border(r.output,r.next_out),t=r.next_out-e,i=wt.buf2string(r.output,e);r.next_out=t,r.avail_out=n-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(a!==Tr||0!==s){if(a===br)return a=fr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},wr.prototype.onData=function(e){this.chunks.push(e)},wr.prototype.onEnd=function(e){e===Tr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:wr,inflate:Er,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Er(e,t)},ungzip:Er,constants:Ee};const{Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr}=Ht,{Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br}=Cr;var Lr={Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr,Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br,constants:Ee},Nr=u(function(e){!function(t){function r(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function n(e,t,n,i,a,o){return r((s=r(r(t,e),r(i,o)))<<(c=a)|s>>>32-c,n);var s,c}function i(e,t,r,i,a,o,s){return n(t&r|~t&i,e,t,a,o,s)}function a(e,t,r,i,a,o,s){return n(t&i|r&~i,e,t,a,o,s)}function o(e,t,r,i,a,o,s){return n(t^r^i,e,t,a,o,s)}function s(e,t,r,i,a,o,s){return n(r^(t|~i),e,t,a,o,s)}function c(e,t){var n,c,d,u,l;e[t>>5]|=128<>>9<<4)]=t;var A=1732584193,h=-271733879,f=-1732584194,p=271733878;for(n=0;n>5]>>>t%32&255);return r}function u(e){var t,r=[];for(r[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+"0123456789abcdef".charAt(15&t);return n}function A(e){return unescape(encodeURIComponent(e))}function h(e){return function(e){return d(c(u(e),8*e.length))}(A(e))}function f(e,t){return function(e,t){var r,n,i=u(e),a=[],o=[];for(a[15]=o[15]=void 0,i.length>16&&(i=c(i,8*e.length)),r=0;r<16;r+=1)a[r]=909522486^i[r],o[r]=1549556828^i[r];return n=c(a.concat(u(t)),512+8*t.length),d(c(o.concat(n),640))}(A(e),A(t))}function p(e,t,r){return t?r?f(t,e):l(f(t,e)):r?h(e):l(h(e))}e.exports?e.exports=p:t.md5=p}(c)}),Gr=u(function(e,t){var r=200,n="Expected a function",i="__lodash_hash_undefined__",a=1,o=2,s=1/0,d=9007199254740991,u="[object Arguments]",l="[object Array]",A="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Function]",m="[object GeneratorFunction]",g="[object Map]",v="[object Number]",T="[object Object]",b="[object RegExp]",S="[object Set]",y="[object String]",k="[object Symbol]",_="[object ArrayBuffer]",w="[object DataView]",E=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,C=/^\w*$/,M=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,O={};O["[object Float32Array]"]=O["[object Float64Array]"]=O["[object Int8Array]"]=O["[object Int16Array]"]=O["[object Int32Array]"]=O["[object Uint8Array]"]=O["[object Uint8ClampedArray]"]=O["[object Uint16Array]"]=O["[object Uint32Array]"]=!0,O[u]=O[l]=O[_]=O[A]=O[w]=O[h]=O[f]=O[p]=O[g]=O[v]=O[T]=O[b]=O[S]=O[y]=O["[object WeakMap]"]=!1;var x="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=x||B||Function("return this")(),N=t&&!t.nodeType&&t,G=N&&e&&!e.nodeType&&e,H=G&&G.exports===N&&x.process,F=function(){try{return H&&H.binding("util")}catch(e){}}(),j=F&&F.isTypedArray;function V(e,t,r,n){for(var i=-1,a=e?e.length:0;++i-1},we.prototype.set=function(e,t){var r=this.__data__,n=Ie(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ee.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ee.prototype.delete=function(e){return qe(this,e).delete(e)},Ee.prototype.get=function(e){return qe(this,e).get(e)},Ee.prototype.has=function(e){return qe(this,e).has(e)},Ee.prototype.set=function(e,t){return qe(this,e).set(e,t),this},Ce.prototype.add=Ce.prototype.push=function(e){return this.__data__.set(e,i),this},Ce.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.clear=function(){this.__data__=new we},Me.prototype.delete=function(e){return this.__data__.delete(e)},Me.prototype.get=function(e){return this.__data__.get(e)},Me.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.set=function(e,t){var n=this.__data__;if(n instanceof we){var i=n.__data__;if(!le||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ut(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function lt(e){return!!e&&"object"==typeof e}function At(e){return"symbol"==typeof e||lt(e)&&ne.call(e)==k}var ht=j?function(e){return function(t){return e(t)}}(j):function(e){return lt(e)&&dt(e.length)&&!!O[ne.call(e)]};function ft(e){return st(e)?Pe(e):je(e)}function pt(e){return e}e.exports=rt});const Hr="4.1.9";function Fr(){const e=new Date;function t(e){const t=e.toString();return t.length<2?"0"+t:t}return`[${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${e.getMilliseconds()}]`}const jr=new class{constructor(e){this.level=e}setLevel(e){this.level=e}log(...e){if("log"!==this.level)return;const t=`${Fr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Fr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Fr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Vr extends C{constructor(e,t=!0){super(),this._closed=!1,this._busy=!1,this._queue=[],this.name=e||"TaskQueue",this.isDebug=t}close(){this._closed=!0}push(e,t){return this.isDebug&&jr.debug(`${this.name} push()`,e,t),new Promise((r,n)=>{this._queue.push({method:e,data:t,resolve:r,reject:n}),this._handlePendingCommands()})}_handlePendingCommands(){if(this._busy)return;const e=this._queue,t=e[0];t&&(this._busy=!0,this._handleCommand(t).then(()=>{this._busy=!1,e.shift(),this._handlePendingCommands()}))}_handleCommand(e){if(this.isDebug&&jr.debug(`${this.name} _handleCommand() `,e.method,e.data),this._closed)return e.reject(new $n("closed")),Promise.resolve();const t={promise:null};return this.emit("exec",e,t),Promise.resolve().then(()=>t.promise).then(t=>{this.isDebug&&jr.debug(`${this.name} _handleCommand() | command succeeded`,e.method),this._closed?e.reject(new $n("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}var Ur,qr;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}(Ur||(Ur={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}(qr||(qr={}));const Wr={"360p":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:30,bitrate:1130},"1080p":{width:1920,height:1080,frameRate:30,bitrate:2080},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4850},"4k":{width:3840,height:2160,frameRate:30,bitrate:8910}},zr=Wr["480p"],Xr={LOW:{sampleRate:16e3,stereo:!1,bitrate:24,sampleSize:16},STANDARD:{sampleRate:48e3,stereo:!1,bitrate:64,sampleSize:16},STANDARD_STEREO:{sampleRate:48e3,stereo:!0,bitrate:80,sampleSize:16},HIGH:{sampleRate:48e3,stereo:!1,bitrate:96,sampleSize:16},HIGH_STEREO:{sampleRate:48e3,stereo:!0,bitrate:128,sampleSize:16}},Kr=Xr.STANDARD,Qr={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},Jr=Qr["720p"];var Zr,$r,Yr,en,tn,rn,nn,an,on,sn,cn,dn,un,ln,An,hn;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(Zr||(Zr={})),function(e){e.IDLE="IDLE",e.PlAYING="PlAYING",e.MIXING="MIXING",e.PAUSED="PAUSED",e.STOPPED="STOPPED",e.COMPLETED="COMPLETED"}($r||($r={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(Yr||(Yr={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(en||(en={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(tn||(tn={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(rn||(rn={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(nn||(nn={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(an||(an={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(on||(on={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(sn||(sn={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(cn||(cn={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(dn||(dn={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(un||(un={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.STOPPED=1]="STOPPED",e[e.INVALID_TOKEN=2]="INVALID_TOKEN",e[e.NO_ROOM=3]="NO_ROOM",e[e.ROOM_CLOSED=4]="ROOM_CLOSED",e[e.PLAYER_EXISTED=5]="PLAYER_EXISTED"}(ln||(ln={})),function(e){e.NORMAL="NORMAL",e.GENERAL="GENERAL",e.SERVERE="SERVERE"}(An||(An={})),function(e){e.CORE="Core",e.API="API",e.AUDIO="Audio",e.VIDEO="Video",e.SIGNAL="Signal"}(hn||(hn={}));const fn="qnrtcqosevents";function pn(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Nr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Nr(JSON.stringify(t));e(r)})},500)})}function mn(e){const t=[];for(let r=0;r>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return new Uint8Array(t)}const gn=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Vr("qossubmit",!1),pn().then(e=>{this.deviceId=e,this.base.device_id=this.deviceId}).catch(()=>{this.deviceId="unknow",this.base.device_id=this.deviceId}),this.base={qos_version:"2.0",device_id:"",bundle_id:"",url:window.location.href,app_version:"",sdk_version:Hr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(ni)}setSessionId(e){for(let t=this.events.length-1;t>=0;t-=1){const r=this.events[t];if(r.session_id)break;r.session_id=e}this.sessionId=e}setUserBase(e,t,r){this.userBase={user_id:e,room_name:t,app_id:r};for(let e=this.events.length-1;e>=0;e-=1){const t=this.events[e];if(t.user_base)break;t.user_base=this.userBase}}addEvent(e,r,n){const i=t({timestamp:Date.now(),event_id:F[e],event_name:e},r);this.submitQueue.push("add",i).catch(ni),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(ni)}initSubmitQueue(){this.submitQueue.on("exec",(e,t)=>{switch(e.method){case"submit":return void(t.promise=this._submit(e.data));case"add":return void(t.promise=this._addEvent(e.data));case"resume":return void(t.promise=this._recoverStoredEvents())}})}async _recoverStoredEvents(){const e=await V.getItem(fn);jr.log("get item",e),await V.removeItem(fn),e&&(this.events=JSON.parse(window.atob(decodeURIComponent(e))),this.events=this.events.filter(e=>!!e.session_id&&!!e.user_base).sort((e,t)=>e.event.timestamp-t.event.timestamp))}_addEvent(e){return this.events.push({user_base:this.userBase,event:e,session_id:this.sessionId}),this.submit(),Promise.resolve()}saveEvents(){const e=encodeURIComponent(window.btoa(JSON.stringify(this.events)));V.setItem(fn,e).catch(ni)}submitCheck(){return!!(this.sessionId&&this.deviceId&&this.userBase)&&(Date.now()-this.lastSubmitTime>3e5||this.events.length>=30)}async _submit(e=!1){if(e||this.submitCheck())try{const e=this.encodeQosSubmitData();for(const t of e)if(!(await fetch("https://pili-rtc-qos.qiniuapi.com/v1/rtcevent",{method:"POST",headers:{"Content-Type":"application/x-gzip"},body:t.buffer})).ok)throw kn("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await V.removeItem(fn)}catch(e){jr.log(e)}else this.saveEvents()}encodeQosSubmitData(){const e=Gr(this.events,e=>e.session_id||""+JSON.stringify(e.user_base)),t=[];for(const r in e){const n=e[r];if(0===n.length)continue;const i={session_id:n[0].session_id,user_base:n[0].user_base,base:this.base,items:n.map(e=>e.event)};jr.log("encode",i);const a=new Uint8Array(Lr.gzip(mn(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function vn(e,t){let r;switch(e){case"prompt":r=O.prompt;break;case"granted":r=O.granted;break;case"denied":r=O.denied;break;default:return}let n=An.NORMAL;(r===O.prompt||O.denied)&&(n=An.SERVERE),gn.addEvent("AuthorizationStatus",{type:t,status:r,event_grade:n,event_category:hn.CORE})}function Tn(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{vn(e.state,D[t]),e.onchange=(()=>{vn(e.state,D[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Tn("camera"),Tn("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{gn.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2,event_grade:An.GENERAL,event_category:hn.CORE})});const bn=(()=>{let e=x.INVALID,t="unknow";const r=e=>{let t;switch(e){case"cellular":t=0;break;case"wifi":t=1;break;case"ethernet":t=2;break;default:t=-1}return t},n=()=>{gn.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e,event_grade:An.GENERAL,event_category:hn.CORE})},i=navigator,a=i.connection||i.mozConnection||i.webkitConnection;return a&&a.type&&(t=a.type,a.onchange=(()=>{t!==a.type&&(t=a.type,n())})),n(),t=>{t!==e&&(e=t,n())}})();class Sn extends Error{constructor(e,t){super(t),this.code=e,this.error=t,gn.addEvent("SDKError",{error_code:e,error_msg:t})}}const yn=e=>new Sn(10053,`invalid parameters: ${e}`),kn=e=>new Sn(21005,`piliRTC: unexpected error ${e}`),_n=e=>new Sn(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),wn=e=>new Sn(21006,`not support! ${e}`),En=e=>new Sn(21007,`track play is not allowed: ${e}`),Cn=e=>new Sn(23003,`plugin not avaliable! ${e}`),Mn=e=>new Sn(23004,`NotAllowedError: no permission to access media device. ${e}`),Pn=e=>new Sn(22011,`can not decode audio data, ${e.toString()}`),In=()=>new Sn(23005,"no audio track when createScreenVideoTrack withAudio enable"),Rn=e=>new Sn(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),Dn=e=>new Sn(24e3,`relay error, can not get relayToken. Error: ${e}`),On=e=>new Sn(24001,`invalid client mode, ${e}`),xn=e=>new Sn(24002,`invalid client role, ${e}`),Bn=()=>kn("websocket abort"),Ln=e=>yn(`can not set merge layout stream, no merge job id ${e}`),Nn=()=>Mn("can not sharing screen/window on chrome"),Gn=()=>kn("subscribe/publish operation is aborted"),Hn=()=>yn("cannot found preset"),Fn=()=>new Sn(22003,"mix source error"),jn=()=>new Sn(22002,"mixed source does not find a valid track"),Vn=()=>new Sn(22001,"effectID already exists, cannot create QNAudioEffect"),Un=()=>new Sn(22004,"effectID is not exists, pleast createAudioEffect firstt"),qn=(e,t)=>new Sn(e,`publish error, signaling code: ${e}, msg: ${t}`),Wn=(e,t)=>new Sn(e,`create merge job error, signaling code: ${e}, msg: ${t}`),zn=(e,t)=>new Sn(e,`create forward job error, signaling code: ${e}, msg: ${t}`),Xn=(e,t)=>new Sn(e,`media format not support, ${t}`),Kn=(e,t)=>new Sn(e,`subscribe error, signaling code: ${e}, msg: ${t}`),Qn=(e,t)=>new Sn(e,`send control error, code: ${e}, msg: ${t}`),Jn=(e,t)=>new Sn(e,t),Zn=()=>new Sn(10052,"server unavailable");class $n extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,$n):this.stack=new Error(e).stack}}var Yn=Object.freeze({QNRTCError:Sn,ERROR_INVALID_PARAMETER:yn,ERROR_FATAL:kn,ERROR_AUTH_FAILED:_n,ERROR_RECONNECT_FAILED:e=>new Sn(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:wn,ERROR_PLAY_NOT_ALLOWED:En,ERROR_PLUGIN_NOT_AVAILABLE:Cn,ERROR_DEVICE_NOT_ALLOWED:Mn,ERROR_AUDIO_DECODE_ERROR:Pn,CREATE_SCREEN_AUDIO_ERROR:In,ERROR_ELECTRON_REQUIRE_ERROR:Rn,ERROR_RELAY_TOKEN:Dn,ERROR_INVALID_CLIENT_MODE:On,ERROR_INVALID_CLIENT_ROLE:xn,WS_ABORT:Bn,NO_MERGE_JOB:Ln,SCREEN_PERMISSION_DENIED:Nn,SUB_PUB_ABORT:Gn,PRESET_NOT_FOUND:Hn,ERROR_AUDIO_MIXING_IO_EXCEPTION:Fn,ERROR_AUDIO_MIXING_AUDIO_NOT_FOUND:jn,ERROR_EFFECT_ID_IS_EXIST:Vn,ERROR_EFFECT_ID_IS_NOT_EXIST:Un,PUBLISH_ERROR:qn,CREATE_MERGE_JOB_ERROR:Wn,CREATE_FORWARD_JOB_ERROR:zn,UNSUPPORT_FMT:Xn,JOIN_ROOM_ERROR:(e,t)=>new Sn(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Kn,UNPUBLISH_ERROR:(e,t)=>new Sn(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Sn(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:Qn,SERVER_ERROR:Jn,SERVER_UNAVAILABLE:Zn,InvalidStateError:$n});function ei(e){const t=e.split(".")[1];if(!t)throw new Error("parse jwt error, can not find payload string.");const r=atob(t);return JSON.parse(r)}function ti(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw kn(`can not parse roomToken, ${e}`)}}function ri(e,t,r){if(!r)return null;for(let n=0;n=4)return e;for(const r in e)void 0===e[r]&&delete e[r],e[r]instanceof File||e[r]instanceof ArrayBuffer||"object"==typeof e[r]&&(e[r]=ii(e[r],t+1));return e}function ai(e){Promise.resolve().then(e)}function oi(e){return("0"+e.toString(16)).substr(-2)}function si(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,oi).join("")}function ci(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const di={};function ui(e,t){if(!di[t])return di[t]=!0,e()}function li(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Ai(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>{r.abort(),n({networkCode:-1,message:"请求超时"})},t),i=fetch(e,{signal:r.signal})}else i=fetch(e);i.then(e=>(function(e,t,r){e>=400&&r({retry:!1,message:t}),200!==e&&r({retry:!0,message:t})}(e.status,e.statusText,n),e.json())).then(r).catch(n)})}async function hi(e){const t=e.match(/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/);if(e.match(/^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$/)||t)return e;try{const t=await fetch(`https://${e}/ip`);return(await t.json()).ip}catch(t){return jr.warning("resolve ice failed, retry",t),await ci(1e3),await hi(e)}}var fi,pi=u(function(e){!function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){if(!s&&d)return d();if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a=d,o=0;o0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},r=n.log,d=n.detectBrowser(e),u={browserDetails:d,commonShim:c,extractVersion:n.extractVersion,disableLog:n.disableLog,disableWarnings:n.disableWarnings};switch(d.browser){case"chrome":if(!i||!i.shimPeerConnection||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;if(null===d.version)return r("Chrome shim can not determine version, not shimming."),u;r("adapter.js shimming chrome."),u.browserShim=i,c.shimAddIceCandidateNullOrEmpty(e,d),i.shimGetUserMedia(e,d),i.shimMediaStream(e,d),i.shimPeerConnection(e,d),i.shimOnTrack(e,d),i.shimAddTrackRemoveTrack(e,d),i.shimGetSendersWithDtmf(e,d),i.shimGetStats(e,d),i.shimSenderReceiverGetStats(e,d),i.fixNegotiationNeeded(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;case"firefox":if(!o||!o.shimPeerConnection||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=o,c.shimAddIceCandidateNullOrEmpty(e,d),o.shimGetUserMedia(e,d),o.shimPeerConnection(e,d),o.shimOnTrack(e,d),o.shimRemoveStream(e,d),o.shimSenderGetStats(e,d),o.shimReceiverGetStats(e,d),o.shimRTCDataChannel(e,d),o.shimAddTransceiver(e,d),o.shimGetParameters(e,d),o.shimCreateOffer(e,d),o.shimCreateAnswer(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"edge":if(!a||!a.shimPeerConnection||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=a,a.shimGetUserMedia(e,d),a.shimGetDisplayMedia(e,d),a.shimPeerConnection(e,d),a.shimReplaceTrack(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"safari":if(!s||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=s,c.shimAddIceCandidateNullOrEmpty(e,d),s.shimRTCIceServerUrls(e,d),s.shimCreateOfferLegacy(e,d),s.shimCallbacksAPI(e,d),s.shimLocalStreamsAPI(e,d),s.shimRemoteStreamsAPI(e,d),s.shimTrackEventTransceiver(e,d),s.shimGetUserMedia(e,d),s.shimAudioContext(e,d),c.shimRTCIceCandidate(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;default:r("Unsupported browser!")}return u};var n=d(e("./utils")),i=d(e("./chrome/chrome_shim")),a=d(e("./edge/edge_shim")),o=d(e("./firefox/firefox_shim")),s=d(e("./safari/safari_shim")),c=d(e("./common_shim"));function d(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":12,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11}],3:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},r.shimOnTrack=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)o.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e});else{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 t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.track.id}):{track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}),t.stream.getTracks().forEach(function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.id}):{track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}},r.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):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 r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach(function(e){r._senders.push(t(r,e))})};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach(function(e){var r=t._senders.find(function(t){return t.track===e});r&&t._senders.splice(t._senders.indexOf(r),1)})}}else if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t},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}})}},r.shimGetStats=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],a=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var o=function(e){var t={},r=e.result();return r.forEach(function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){r[t]=e.stat(t)}),t[r.id]=r}),t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return t.apply(this,[function(e){i(s(o(e)))},n])}return new Promise(function(r,n){t.apply(e,[function(e){r(s(o(e)))},n])}).then(i,a)}},r.shimSenderReceiverGetStats=function(e){if(!("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return o.filterStats(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t}),o.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(t){return o.filterStats(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],r=void 0,n=void 0,i=void 0;return this.getSenders().forEach(function(e){e.track===t&&(r?i=!0:r=e)}),this.getReceivers().forEach(function(e){return e.track===t&&(n?i=!0:n=e),e.track===t}),i||r&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}},r.shimAddTrackRemoveTrackWithNative=c,r.shimAddTrackRemoveTrack=function(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return c(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(function(e){var t=r.getSenders().find(function(t){return t.track===e});if(t)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;function a(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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(t,r){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var a=this.getSenders().find(function(e){return e.track===t});if(a)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var o=this._streams[r.id];if(o)o.addTrack(t),Promise.resolve().then(function(){n.dispatchEvent(new Event("negotiationneeded"))});else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=a(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then(function(t){return a(e,t)})});e.RTCPeerConnection.prototype[t]=n[t]});var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=(e=this,t=arguments[0],r=t.sdp,Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:r})),o.apply(this,arguments)):o.apply(this,arguments);var e,t,r};var d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=d.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=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");var r=e._pc===this;if(!r)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var n=void 0;Object.keys(this._streams).forEach(function(r){var i=t._streams[r].getTracks().find(function(t){return e.track===t});i&&(n=t._streams[r])}),n&&(1===n.getTracks().length?this.removeStream(this._reverseStreams[n.id]):n.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}},r.shimPeerConnection=function(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection);if(!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})},r.fixNegotiationNeeded=function(e,t){o.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js"));function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter(function(e){return-1===n.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]}),i.apply(this,arguments)}}},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;if("function"!=typeof t)return void console.error("shimGetDisplayMedia: getSourceId argument is not a function");e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,a=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)})}}},{}],5:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator;if(!r.mediaDevices)return;var a=function(e){if("object"!==(void 0===e?"undefined":n(e))||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var i="object"===n(e[r])?e[r]:{ideal:e[r]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);var a=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];var o={};"number"==typeof i.ideal?(o[a("min",r)]=i.ideal,t.optional.push(o),(o={})[a("max",r)]=i.ideal,t.optional.push(o)):(o[a("",r)]=i.ideal,t.optional.push(o))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[a("",r)]=i.exact):["min","max"].forEach(function(e){void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[a(e,r)]=i[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,o){if(t.version>=61)return o(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===n(e.audio)){var s=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),s(e.audio,"autoGainControl","googAutoGainControl"),s(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=a(e.audio)}if(e&&"object"===n(e.video)){var c=e.video.facingMode;c=c&&("object"===(void 0===c?"undefined":n(c))?c:{ideal:c});var d=t.version<66;if(c&&("user"===c.exact||"environment"===c.exact||"user"===c.ideal||"environment"===c.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||d)){delete e.video.facingMode;var u=void 0;if("environment"===c.exact||"environment"===c.ideal?u=["back","rear"]:"user"!==c.exact&&"user"!==c.ideal||(u=["front"]),u)return r.mediaDevices.enumerateDevices().then(function(t){var r=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return e.label.toLowerCase().includes(t)})});return!r&&t.length&&u.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=c.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=a(e.video),i("chrome: "+JSON.stringify(e)),o(e)})}e.video=a(e.video)}return i("chrome: "+JSON.stringify(e)),o(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(r.getUserMedia=function(e,t,n){o(e,function(e){r.webkitGetUserMedia(e,t,function(e){n&&n(s(e))})})}.bind(r),r.mediaDevices.getUserMedia){var c=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return o(e,function(e){return c(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(s(e))})})}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js")).log},{"../utils.js":11}],6:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimRTCIceCandidate=function(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":n(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 r=new t(e),i=o.default.parseCandidate(e.candidate),a=Object.assign(r,i);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,s.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})},r.shimMaxMessageSize=function(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),n=e.sdpSemantics;"plan-b"===n&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;var t=o.default.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=o.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){var i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),a=function(e){var r=65536;"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637);return r}(i),s=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=o.default.matchPrefix(e.sdp,"a=max-message-size:");i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637);return n}(arguments[0],i),c=void 0;c=0===a&&0===s?Number.POSITIVE_INFINITY:0===a||0===s?Math.max(a,s):Math.min(a,s);var d={};Object.defineProperty(d,"maxMessageSize",{get:function(){return c}}),this._sctp=d}return r.apply(this,arguments)}},r.shimSendThrowTypeError=function(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=r.apply(this,arguments);return t(e,this),e},s.wrapPeerConnectionEvent(e,"datachannel",function(e){return t(e.channel,e.target),e})},r.shimConnectionState=function(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"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 r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})},r.removeExtmapAllowMixed=function(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return r.apply(this,arguments)}},r.shimAddIceCandidateNullOrEmpty=function(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;var r=e.RTCPeerConnection.prototype.addIceCandidate;if(!r||0===r.length)return;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}};var i,a=e("sdp"),o=(i=a)&&i.__esModule?i:{default:i},s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("./utils"))},{"./utils":11,sdp:13}],7:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimOnTrack=function(e){"object"===(void 0===e?"undefined":n(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}}})},r.shimPeerConnection=function(e,t){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection);t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r;return e}({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]});var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),n=e[0],a=e[1],o=e[2];return i.apply(this,[n||null]).then(function(e){if(t.version<53&&!a)try{e.forEach(function(e){e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(a,o)}},r.shimSenderGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.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)}},r.shimReceiverGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});o.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}},r.shimRemoveStream=function(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype)return;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)})}},r.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},r.shimAddTransceiver=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(function(e){if("rid"in e){if(!/^[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 n=t.apply(this,arguments);if(r){var i=n.sender,a=i.getParameters();"encodings"in a&&(1!==a.encodings.length||0!==Object.keys(a.encodings[0]).length)||(a.encodings=e.sendEncodings,i.sendEncodings=e.sendEncodings,this.setParametersPromises.push(i.setParameters(a).then(function(){delete i.sendEncodings}).catch(function(){delete i.sendEncodings})))}return n})},r.shimGetParameters=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCRtpSender)return;var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})},r.shimCreateOffer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}},r.shimCreateAnswer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)}}},{}],9:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator,a=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){i.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":n(e))&&"object"===n(e.audio)&&(e=JSON.parse(JSON.stringify(e)),o(e.audio,"autoGainControl","mozAutoGainControl"),o(e.audio,"noiseSuppression","mozNoiseSuppression")),s(e)},a&&a.prototype.getSettings){var c=a.prototype.getSettings;a.prototype.getSettings=function(){var e=c.apply(this,arguments);return o(e,"mozAutoGainControl","autoGainControl"),o(e,"mozNoiseSuppression","noiseSuppression"),e}}if(a&&a.prototype.applyConstraints){var d=a.prototype.applyConstraints;a.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":n(e))&&(e=JSON.parse(JSON.stringify(e)),o(e,"autoGainControl","mozAutoGainControl"),o(e,"noiseSuppression","mozNoiseSuppression")),d.apply(this,[e])}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11}],10:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimLocalStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;"getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams});if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(function(n){return t.call(r,n,e)}),e.getVideoTracks().forEach(function(n){return t.call(r,n,e)})},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=Array(n>1?n-1:0),a=1;a=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}})}),t.apply(e,arguments)}}},r.shimCallbacksAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype,r=t.createOffer,i=t.createAnswer,a=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n};var c=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=c,c=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=c,c=function(e,t,r){var n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=c},r.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(a(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))},r.shimConstraints=a,r.shimRTCIceServerUrls=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],a=0;a=r&&parseInt(n[r],10)}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function c(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach(function(n){n.endsWith("Id")?c(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach(function(t){c(e,e.get(t),r)})}))}},{}],12:[function(e,t,r){},{}],13:[function(e,t,r){var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},n.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},n.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),r},n.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},n.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},n.getCryptoParameters=function(e,t){return n.matchPrefix(e+t,"a=crypto:").map(n.parseCryptoLine)},n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0],i=n.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){r+=n.writeExtmap(e)}),r},n.parseRtpEncodingParameters=function(e){var t,r=[],i=n.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,d=n.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});d.length>0&&d[0].length>1&&d[0][0]===c&&(t=d[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),a&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},r.push(n))}}),0===r.length&&c&&r.push({ssrc:c});var u=n.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,r.forEach(function(e){e.maxBitrate=u})),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var a=n.matchPrefix(e,"a=rtcp-mux");return t.mux=a.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var i=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),i=n.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var a=n.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var o=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var i=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,i){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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 o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,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:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a},n.getDirection=function(e,t){for(var r=n.splitLines(e),i=0;i-1}function U(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Me.prototype.set=function(e,t){var r=this.__data__,n=Oe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new Ce,map:new(fe||Me),string:new Ce}},Pe.prototype.delete=function(e){return Ue(this,e).delete(e)},Pe.prototype.get=function(e){return Ue(this,e).get(e)},Pe.prototype.has=function(e){return Ue(this,e).has(e)},Pe.prototype.set=function(e,t){return Ue(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,i),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.clear=function(){this.__data__=new Me},Re.prototype.delete=function(e){return this.__data__.delete(e)},Re.prototype.get=function(e){return this.__data__.get(e)},Re.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Me){var i=n.__data__;if(!fe||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ie:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ot(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function st(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||st(e)&&oe.call(e)==k}var dt=j?function(e){return function(t){return e(t)}}(j):function(e){return st(e)&&at(e.length)&&!!O[oe.call(e)]};function ut(e){return nt(e)?De(e):He(e)}function lt(e){return e}e.exports=function(e,t){return e&&e.length?function(e,t,n){var i=-1,a=V,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=U;else if(o>=r){var u=t?null:je(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}var Si;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(Si||(Si={}));const{JOIN_ROOM_ERROR:yi,ERROR_RECONNECT_FAILED:ki}=Yn;class _i extends bi{constructor(e,t,r,n,i,a=["subscribe","publish"]){super(),this.privileges=[],this.rpcid=si(16),this.startInitTime=-1,this.startAuthTime=0,this.initWs=((e=!1,t,r)=>new Promise((n,i)=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.close(),this.ws.onclose=null),e)this.ws=t,this.setUrl(r);else{this.startInitTime=Date.now();try{this.wsConnectTimeoutID=setTimeout(()=>{this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close());const t=this.wsConnectTimeout/1e3+"s timeout";gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,socket_connect_error_message:t,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=Si.CONNECTING}catch(e){throw kn(`init signaling websocket faild!\nError: ${e}`)}}this.ws.onerror=this.onWsError,this.ws.onclose=this.onWsClose.bind(this,n,i);const a=()=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.emit("ws:onopen"),jr.log("signaling: websocket open",this.url),e||(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!0,event_grade:An.NORMAL,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Hr,capsdp:this.capsdp,msgsn:this.customMsgNumber,supportdomain:!0,privileges:this.privileges};this.playerdata&&(t.playerdata=this.playerdata),this.startAuthTime=Date.now(),this.request("auth",t).then(t=>{switch(0!==t.code&&(gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:t.code,auth_error_message:t.error,auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.SERVERE,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.startAuthTime=0),t.code){case 0:this.ws.onclose=this.onWsClose.bind(this,null,null),this.reconnectToken=t.reconntoken,jr.log("signaling: websocket authed"),this._state=Si.OPEN,gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:0,auth_error_message:"",auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.emit("@signalingauth",t),this.startAuthTime=0,n(t);break;case 10001:case 10002:case 10011:case 10022:case 10012:case 10004:this.emit("@error",t),i(ki(t.error));break;case 10005:this.emit("@error",t),i(ki(t.error));case 10052:if(jr.debug("10052 auth, retry",e),this.reconnectToken=void 0,e){i(yi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(Xn(10054,t.error));break;default:i(kn(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=Si.CLOSED,this.release())})};this.ws.onopen=(()=>{a()}),e&&a()})),this.onWsMsg=(e=>{const t=e.data;this.emit("ws:onmessage",t);const r=t.indexOf("=");if(!(r>0))throw kn(`signaling model can not parse message: ${t}`);{const e=t.substring(0,r),n=JSON.parse(t.substring(r+1));this.receiveWsMsg(e,n)}}),this.onWsError=(e=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),jr.warning("signaling: websocket error",e),this.emit("@ws:error",e),-1!==this.startInitTime&&(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:""}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw Bn();const r=JSON.stringify(t);try{this.ws.send(`${e}=${r}`),this.emit("send",e,t)}catch(e){throw jr.warning("signaling: websocket send error",e),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)}),Bn()}}),this.handlePing=(()=>{this.sendWsMsg("pong",{}),this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.reconnectTimeoutID=setTimeout(()=>{jr.debug("signaling: websocket heartbeat timeout"),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)})},9e3)}),this.receiveWsMsg=((e,t)=>{switch(this.emit("receive",e,t),e){case"ping":this.handlePing();break;case"auth-res":this.emit("@auth-res",t);case"pubpc-res":case"subpc-res":case"pub-tracks":case"webrtc-candidate":case"on-player-in":case"on-player-out":case"disconnect":case"mute-tracks":case"on-add-tracks":case"on-remove-tracks":case"on-player-reconnect":case"on-player-reconnect-in":this.emit(e,t);break;case"sub-res":case"unsub-res":this.emit(e,t),this.emit(`${e}-${t.streamid}`,t);break;case"control-res":this.emit(e,t),this.emit(`${e}-${t.command}-${t.playerid}`,t);break;case"on-pubpc-connected":case"on-pubpc-disconnected":this.emit("on-pubpc-state",{pcid:t.pcid,connected:"on-pubpc-connected"===e}),this.emit(`${e}-${t.pcid}`,t);break;case"on-subpc-disconnected":case"on-subpc-connected":this.emit("on-subpc-state",{pcid:t.pcid,connected:"on-subpc-connected"===e}),this.emit(e,t);break;case"pub-tracks-res":this.emit(e,t);break;case"on-messages":case"on-qos-messages":t.messages=t.messages.sort((e,t)=>e.msgsn-t.msgsn),this.customMsgNumber=t.messages[t.messages.length-1].msgsn,this.emit(e,t);break;case"unpub-tracks-res":case"sub-tracks-res":case"unsub-tracks-res":case"on-pubpc-restart-notify":case"on-subpc-restart-notify":case"set-sub-profile-res":case"on-sub-profile-changed":case"pubpc-restart-res":case"subpc-restart-res":case"create-merge-job-res":case"create-forward-job-res":case"stop-forward-res":case"on-job-connected":case"on-job-disconnected":case"on-merge-job-connected":case"on-merge-job-disconnected":case"update-merge-tracks-res":case"set-privileges-res":case"start-media-relay-res":case"update-media-relay-res":case"stop-media-relay-res":case"on-media-relay-state":this.emit(e,t)}}),this.accessToken=e,this.capsdp=t,this.reconnectTimes=r,this.wsConnectTimeout=n,this.playerdata=i,this.privileges=a,this._state=Si.CONNECTING}set _state(e){this.emit("@ws-state-change",this.__state,e),this.__state=e}get state(){return this.__state}set reconnectTimes(e){this._reconnectTimes=e,this.currentLeftReconnectTimes=e}get reconnectTimes(){return this._reconnectTimes}setUrl(e){this.url=e+`?rpcid=${this.rpcid}`}onWsClose(e,t,r){this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this._state=Si.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:r.code,auth_error_message:r.toString(),auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:this.url,auth_reason:"connect"});let n=this.reconnectPromise;switch(r.code){case 1e3:this.emit("@closed");break;case 1001:case 1005:case 1006:n=this.reconnect();break;case 1007:case 1008:case 1009:case 1010:break;case 1011:n=this.reconnect();break;case 1012:n=this.reconnect(5e3);break;case 1013:n=this.reconnect();break;case 1014:n=this.reconnect(5e3)}e&&t&&(n?n.then(e).catch(e=>{jr.warning("signaling: reconnect error",e)}):t(r))}sendDisconnect(){if(this.state===Si.OPEN)try{this.sendWsMsg("disconnect",{})}catch(e){}}reconnect(e=1e3){return this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.reconnectPromise&&this._state===Si.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=Si.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=ci(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=Si.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=si(8);return t.rpcid=r,jr.log("ws request",r,e,t),this.sendWsMsg(e,t),new Promise(t=>{const n=i=>{i.rpcid===r&&(jr.log("ws response",r,e,i),this.off(`${e}-res`,n),t(i))};this.on(`${e}-res`,n)})}release(){this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.removeEvent(),this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close())}}class wi{}class Ei{constructor(e,t,r,n){this.videoTrackInfo=[],this.audioTrackInfo=[],this.layoutLevel=0,this.width=e,this.height=t,this.jobID=n,this.controller=r,this.controller.getCurrentTracks().forEach(e=>{"audio"===e.kind?this.audioTrackInfo.push(e):this.videoTrackInfo.push(e)}),this.controller.addMergeTrack(this.audioTrackInfo.map(e=>({trackID:e.trackID})),this.jobID),this.initLayout(),this.controller.onAddTracks=(e=>{const t=e.filter(e=>"audio"===e.kind),r=e.filter(e=>"video"===e.kind);this.controller.addMergeTrack(t.map(e=>({trackID:e.trackID})),this.jobID),r.forEach(this.handleAddVideoTrack.bind(this))}),this.controller.onRemoveTracks=(e=>{e.filter(e=>"video"===e.kind).forEach(this.handleRemoveVideoTrack.bind(this))}),jr.log("init default merger, init layout: ",this.layout)}initLayout(){const e=this.videoTrackInfo.length;this.layoutLevel=0,this.layout={"level-0":{items:{"item-0":{x:0,y:0,isExpand:!1,isExpanded:!1,index:0}},itemWidth:this.width,itemHeight:this.height,maxItems:1,currentItems:0,splitWidthFlag:this.width=this.height;if(0!==e){for(;Math.pow(2,this.layoutLevel)=this.height?a:0,y:this.width{const n=this.layout[`level-${this.layoutLevel-1}`].items[r],i=2*n.index;t[`item-${i}`]={x:n.x,y:n.y,isExpand:!1,isExpanded:!1,index:i},t[`item-${i+1}`]=e?{x:n.x+a,y:n.y,isExpand:!1,isExpanded:!1,index:i+1}:{x:n.x,y:n.y+o,isExpand:!1,isExpanded:!1,index:i+1}})}jr.log(`merger: increase layout level, current level: ${this.layoutLevel}`,this.layout)}setLevelLayoutStream(){const e=this.videoTrackInfo.length,t=this.layout[`level-${this.layoutLevel}`];let r=t.maxItems-e,n=0;for(let e=0;e0?e%2==0?(t.items[`item-${e}`].isExpand=!0,t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1):(t.items[`item-${e}`].isExpanded=!0,r-=1):(t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1);t.currentItems=e}sendMergeOpt(e,t){const r=this.layout[`level-${e}`],n=r.items[`item-${t}`];if(!n.trackID||n.isExpanded)return;let i=r.itemWidth,a=r.itemHeight;n.isExpand&&(r.splitWidthFlag?i*=2:a*=2);const o={x:n.x,y:n.y,w:i,h:a,z:0,trackID:n.trackID};this.controller.addMergeTrack([o],this.jobID)}handleRemoveVideoTrack(e){M(this.videoTrackInfo,t=>t.trackID===e.trackID);const t=this.layout[`level-${this.layoutLevel}`];if(this.layoutLevel>0&&this.videoTrackInfo.length<=this.layout[`level-${this.layoutLevel-1}`].maxItems)this.layoutLevel-=1,jr.log(`merger: reduce layout level, current level: ${this.layoutLevel}`,this.layout),this.setLevelLayoutStream();else for(const r in t.items){const n=t.items[r];if(n.trackID===e.trackID){n.index%2==0?(t.items[`item-${n.index+1}`]?(n.isExpand=!0,n.trackID=t.items[`item-${n.index+1}`].trackID,t.items[`item-${n.index+1}`].isExpanded=!0,t.items[`item-${n.index+1}`].trackID=void 0):n.trackID=void 0,this.sendMergeOpt(this.layoutLevel,n.index)):(n.isExpanded=!0,n.trackID=void 0,t.items[`item-${n.index-1}`].isExpand=!0,this.sendMergeOpt(this.layoutLevel,n.index-1));break}}}handleAddVideoTrack(e){const t=this.videoTrackInfo.length;if(this.videoTrackInfo.push(e),this.videoTrackInfo=mi(this.videoTrackInfo,"trackID"),this.videoTrackInfo.length===t)return void jr.log("handle add video track ignore",e);const r=this.layout[`level-${this.layoutLevel}`];if(this.videoTrackInfo.length<=r.maxItems){for(const t in r.items){const n=r.items[t];if(!n.trackID){n.trackID=e.trackID,n.isExpanded&&(n.isExpanded=!1,r.items[`item-${n.index-1}`].isExpand=!1,this.sendMergeOpt(this.layoutLevel,n.index-1)),this.sendMergeOpt(this.layoutLevel,n.index);break}}r.currentItems=this.videoTrackInfo.length}else this.updateLayoutLevel(!r.splitWidthFlag),this.setLevelLayoutStream()}release(){this.controller.release()}}function Ci(e){const t=document.createElement("audio"),r=new MediaStream([e]);return t.style.visibility="hidden",t.className="qnrtc-audio-player qnrtc-stream-player",t.dataset.localid=e.id,t.srcObject=r,t.autoplay=!0,{element:t,stream:r}}function Mi(e){const t=document.createElement("video"),r=new MediaStream([e]);return t.style.width="100%",t.style.height="100%",t.style.objectFit="contain",t.muted=!0,t.className="qnrtc-video-player qnrtc-stream-player",t.dataset.localid=e.id,t.setAttribute("playsinline",!0),t.autoplay=!0,t.srcObject=r,T&&(t.setAttribute("controls",!0),ai(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),{element:t,stream:r}}const Pi=window.AudioContext||window.webkitAudioContext||window.Object,Ii=E.audioContextOptions?new Pi({latencyHint:"interactive"}):new Pi;if(window.audioContext=Ii,window.Promise){const e=()=>{(function(e){return new Promise((t,r)=>{if("suspended"===e.state){jr.log("audio context state is suspended");const n=()=>{e.resume().then(()=>{document.body.removeEventListener("touchstart",n),document.body.removeEventListener("touchend",n),document.body.removeEventListener("mousedown",n),document.body.removeEventListener("mouseup",n),t(!0)}).catch(r)};document.body.addEventListener("touchstart",n,!0),document.body.addEventListener("touchend",n,!0),document.body.addEventListener("mousedown",n,!0),document.body.addEventListener("mouseup",n,!0),n()}else t(!1)})})(Ii).then(e=>{jr.debug("web audio context unlocked",e)}).catch(e=>{jr.warning("can not unlock web audio context",e)}),window.removeEventListener("load",e)};document.body?e():window.addEventListener("load",e),Ii.onstatechange=(()=>{e()})}const Ri=2048,Di=4096,Oi=["play","playing","pause","ended","waiting","seeking"];class xi extends bi{constructor(){super(),this.audioSource=null,this._audioSourceState=H.IDLE,this.bufferSourceDuration={startTime:0,pauseTime:0,lastPauseTime:0,offsetTime:0,stopTime:0},this.handleMediaElementEvents=(e=>{switch(e.type){case"playing":case"play":this.audioSourceState=H.PLAY;break;case"waiting":case"seeking":this.audioSourceState=H.LOADING;break;case"ended":this.audioSourceElement&&(this.audioSourceElement.currentTime=0),this.audioSourceState=H.END}})}get audioSourceState(){return this._audioSourceState}set audioSourceState(e){e!==this._audioSourceState&&(this.emit("@audio-source-state-change",e,this._audioSourceState),this._audioSourceState=e)}initAudioContext(){jr.log("init audio context",Ii.state),"suspended"===Ii.state&&(jr.log("audio context suspended"),Ii.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",Ii.state),this.analyserNode=Ii.createAnalyser(),this.analyserNode.fftSize=Ri,this.gainNode=Ii.createGain(),function(e){if(E.disconnectAudioNode)return;const t=e.connect,r=e.disconnect;e.connect=((r,n,i)=>(e._inputNodes||(e._inputNodes=[]),r instanceof AudioNode?(e._inputNodes.push(r),e._inputNodes=mi(e._inputNodes,e=>e),t.call(e,r,n,i)):t.call(e,r,n),e)),e.disconnect=((t,n,i)=>{if(!t)return r.call(e),void(e._inputNodes=[]);r.call(e,t,n,i),M(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),E.mediaStreamDest&&(this.audioStream=Ii.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=Ii.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=Ii.createBufferSource(),this.audioSource.onended=(()=>{this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Ii.currentTime,this.audioSourceState=H.END}),this.connect()}setMediaElementSource(e){this.audioSource=Ii.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Oi)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.isAudioSource()?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.isAudioSource()&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.isAudioSource()){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Ii.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(li)):null===this.audioSource&&this.audioSourceBuffer&&(this.resetBufferSourceDuration(),this.setAudioBufferSource(),this.setAudioBuffer(this.audioSourceBuffer),this.setAudioSourceLoop(!!this.audioSourceLoop),this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Ii.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY)}resumeAudioSource(){if(this.isAudioSource()){if(this.audioSourceState!==H.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=Ii.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=H.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(li)}pauseAudioSource(){this.isAudioSource()?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=Ii.currentTime),this.audioSourceState=H.PAUSE):this.audioSourceElement&&(this.audioSourceElement.pause(),this.audioSourceState!==H.END&&(this.audioSourceState=H.PAUSE))}stopAudioSource(e=!1,t=!1){this.isAudioSource()?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Ii.currentTime,e||!1!==t||(this.audioSourceState=H.STOP)):this.audioSourceElement&&(!1===t&&(this.audioSourceState=H.STOP),this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.isAudioSource()){let e=Ii.currentTime;const t=this.getAudioSourceDuration();this.bufferSourceDuration.lastPauseTime&&(e=this.bufferSourceDuration.lastPauseTime),this.bufferSourceDuration.stopTime&&(e=this.bufferSourceDuration.stopTime);const r=this.bufferSourceDuration.offsetTime+e-this.bufferSourceDuration.startTime-this.bufferSourceDuration.pauseTime;return Math.max(0,r%t)}return 0}setAudioSourceCurrentTime(e){this.audioSourceElement?this.audioSourceElement.currentTime=e:this.isAudioSource()&&(this.stopAudioSource(!0),this.playAudioSource(e))}getAudioSourceDuration(){return this.audioSourceElement?this.audioSourceElement.duration:this.audioSourceBuffer?this.audioSourceBuffer.duration:0}release(){if(this.audioSource&&this.audioSource.disconnect(),this.gainNode.disconnect(),this.audioSourceElement){for(const e of Oi)this.audioSourceElement.removeEventListener(e,this.handleMediaElementEvents);this.audioSourceElement.src="",this.audioSourceElement.load(),this.audioSourceElement.remove(),this.audioSourceElement=void 0}this.scriptNode&&this.scriptNode.disconnect()}connect(){this.audioSource?(this.audioSource.connect(this.analyserNode),this.audioSource.connect(this.gainNode),this.audioStream&&(this.gainNode.connect(this.audioStream),this.onAudioBuffer())):jr.warning("no audio source, can not connect")}handleAudioBuffer(e){const t=e.inputBuffer;this.emit("audioBuffer",t),this.audioBufferCallback&&this.audioBufferCallback(t)}onAudioBuffer(e,t=Di){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=Ii.createScriptProcessor(t),this.audioSource.connect(this.scriptNode),this.scriptNode.connect(this.audioStream),this.scriptNode.onaudioprocess=this.handleAudioBuffer.bind(this)))}resetBufferSourceDuration(){this.bufferSourceDuration={offsetTime:0,startTime:0,lastPauseTime:0,pauseTime:0,stopTime:0}}isAudioSource(){const{audioSource:e}=this;return e instanceof AudioBufferSourceNode||e instanceof AudioScheduledSourceNode}}class Bi{constructor(e,t){this.streamSourceNode=Ii.createMediaStreamSource(e),this.gainNode=Ii.createGain(),this.mediaElement=t,this.mediaElement.volume=0,this.mediaElement.addEventListener("pause",()=>{this.release()}),this.mediaElement.addEventListener("play",()=>{this.connect()}),this.connect()}release(){this.gainNode.disconnect(),this.streamSourceNode.disconnect()}connect(){this.streamSourceNode.connect(this.gainNode).connect(Ii.destination)}setVolume(e){this.gainNode.gain.value=e}}class Li extends bi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=L.NORMAL,this.onended=(async e=>{"local"===this.direction?(jr.warning("track ended",this.mediaTrack,this.info.trackID),this.info.trackID&&this._selfEndedCallback&&await this._selfEndedCallback([this.info.trackID]),this.emit("ended",e),gn.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label,event_grade:An.SERVERE}),this.release()):this.emit("@ended",e)}),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.userID=t,r&&(this.direction=r),this.info={kind:e.kind,muted:!e.enabled,userID:this.userID,versionid:0,profiles:n||[]},this.handleMediaPause=this.handleMediaPause.bind(this)}async setPlaybackDevice(e){if(E.setPlaybackDevice||wn("setPlaybackDevice api not support"),this.playbackDevice=e,this.mediaElement)return this.mediaElement.setSinkId(e)}play(e,t,r={mirror:!1}){return new Promise((n,i)=>{this.removeMediaElement();const a="video"===this.info.kind?Mi:Ci,{element:o,stream:s}=a(this.mediaTrack);this.mediaElement=o,"audio"===this.info.kind&&("remote"===this.direction&&(this.remoteAudioHelper=new Bi(s,o)),void 0!==t&&(this.mediaElement.muted=t)),r.mirror?this.mediaElement.style.transform="rotateY(180deg)":this.mediaElement.style.transform="",this.mediaElement.setAttribute("controls",!0),e.appendChild(this.mediaElement),this.mediaElement.onplaying=(()=>{this.mediaElement.onplaying=null,n()}),Promise.resolve().then(()=>{if(this.mediaElement.removeAttribute("controls"),this.playbackDevice)return this.setPlaybackDevice(this.playbackDevice)}).then(()=>{(function(e,t=3e3){const r=async()=>{if(e.paused)return e.play()};return new Promise((n,i)=>{const a=setTimeout(()=>{r().then(n).catch(i)},t);e.onloadedmetadata=(()=>{clearTimeout(a),r().then(n).catch(i)}),"WeixinJSBridge"in window?window.WeixinJSBridge.invoke("getNetworkType",{},()=>{r().then(n).catch(ni)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(ni)},!1)})})(this.mediaElement).then(n).catch(e=>{const t=e instanceof Error?e.name+", "+e.message:"play failed"+String(e);"NotAllowedError"===e.name?(i(En(t)),gn.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t,event_grade:An.SERVERE})):i(kn(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(li),900)}switchPlayingTrack(){if(this.mediaElement){if(this.isReplacedByImageTrack&&this.imageStreamTrack)this.mediaElement.srcObject=new MediaStream([this.imageStreamTrack.mediaTrack]);else{if(this.isReplacedByImageTrack||!this.mediaTrack)return;this.mediaElement.srcObject=new MediaStream([this.mediaTrack])}this.mediaElement.paused||this.mediaElement.play().catch(li)}}resume(e){if(this.mediaTrack.removeEventListener("ended",this.onended),this.mediaTrack.stop(),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.mediaElement){const t=new MediaStream([e]);this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t}this.removeEvent("@get-stats"),this.resetStats()}getStats(){return this.statsInterval||this.startGetStatsInterval(),this.stats}getCurrentFrameDataURL(){return this.mediaElement&&this.mediaElement instanceof HTMLVideoElement?function(e){const t=document.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;const r=t.getContext("2d");return r?(r.drawImage(e,0,0,e.videoWidth,e.videoHeight),t.toDataURL()):"data:,"}(this.mediaElement):"data:,"}setMaster(e){this.master=e}setMute(e){this.info.muted=e,this.mediaTrack.enabled=!e,this.emit("mute",e)}setKbps(e){this.info.kbps=e}setInfo(e){this.info=t({},this.info,e)}removeMediaElement(){this.mediaElement&&(this.mediaElement.removeEventListener("pause",this.handleMediaPause),this.mediaElement.remove(),this.mediaElement=void 0)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),"local"!==this.direction&&E.unifiedPlan||this.mediaTrack.stop(),this.removeMediaElement(),this.imageStreamTrack&&(this.imageStreamTrack.release(),this.imageStreamTrack=void 0),this.remoteAudioHelper&&(this.remoteAudioHelper.release(),this.remoteAudioHelper=void 0)}reset(){this.info.trackID=void 0,this.info.userID=void 0,this.info.versionid=0,this.userID=void 0,this.resetStats()}resetStats(){this.stats=[],this.lastStats=[]}async startGetStatsInterval(){this.statsInterval=window.setInterval(async()=>{const e=this.getListeners("@get-stats");if(!e||0===e.length)return[];this.stats=await this.safeEmitAsPromise("@get-stats",this.lastStats),this.lastStats=[...this.stats]},1e3)}set selfEndedCallback(e){this._selfEndedCallback=e}setVolume(e){jr.warning("not implement")}getCurrentTimeDomainData(){return jr.warning("not implement"),new Uint8Array}getCurrentFrequencyData(){return jr.warning("not implement"),new Uint8Array}getVolume(){return jr.warning("not implement"),0}getCurrentVolumeLevel(){return jr.warning("not implement"),0}setLoop(e){jr.warning("not implement")}startAudioSource(){jr.warning("not implement")}pauseAudioSource(){jr.warning("not implement")}resumeAudioSource(){jr.warning("not implement")}stopAudioSource(){jr.warning("not implement")}getCurrentTime(){return jr.warning("not implement"),0}setCurrentTime(e){jr.warning("not implement")}getDuration(){return jr.warning("not implement"),0}}class Ni{static loadImage(e){if(e instanceof File)return Ni.loadImageFromFile(e);if(e instanceof ArrayBuffer)return Ni.loadImageFromArrayBuffer(e);if("string"==typeof e)return Ni.loadImageFromUrl(e);throw wn("unsupported image source")}static loadImageFromUrl(e){return new Promise((t,r)=>{var n=new Image;n.crossOrigin="Anonymous",n.src=e,n.onload=function(){t(n)},n.onerror=function(e){r(e)}})}static loadImageFromFile(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=(e=>{n.result&&t(Ni.loadImageFromUrl(n.result))}),n.onerror=(e=>{r(e)}),n.readAsDataURL(e)})}static loadImageFromArrayBuffer(e){return new Promise((t,r)=>{const n=new Blob([e]),i=URL.createObjectURL(n);t(Ni.loadImageFromUrl(i))})}}class Gi{constructor(){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}async setSource(e){e!==this.source&&(this.source=e,await this.createImageStreamTrack(e))}get id(){if(this.mediaTrack)return this.mediaTrack.id}async createImageStreamTrack(e){let t;t=e instanceof File?await Ni.loadImageFromFile(e):e instanceof ArrayBuffer?await Ni.loadImageFromArrayBuffer(e):await Ni.loadImageFromUrl(e),this.canvas.width=t.width,this.canvas.height=t.height,this.drawIntervalId&&clearInterval(this.drawIntervalId),this.drawIntervalId=setInterval(()=>{this.ctx.drawImage(t,0,0)},900);const r=this.canvas.captureStream(1);this.mediaTrack=r.getTracks()[0]}release(){this.drawIntervalId&&clearInterval(this.drawIntervalId)}}class Hi{constructor(){this.recordedChunks=[]}releaseMediaElement(){jr.log("Recorder release Media Element",this.mediaElement),this.mediaElement&&this.mediaElement.parentElement&&this.mediaElement.parentElement.removeChild(this.mediaElement)}release(){this.recorder&&"inactive"!==this.recorder.state&&this.recorder.stop(),this.recorder=void 0,this.recordedChunks=[],this.recordedBlob=void 0,this.recordedUrl&&(window.URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=void 0),this.releaseMediaElement()}setMimeType(e){if(jr.log("Recorder setMimeType, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");return!!window.MediaRecorder.isTypeSupported(e)&&(this.mimeType=e,!0)}start(e){if(jr.log("Recorder start, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw kn("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw kn("MediaRecorder is active, cannot start again.");if(e.reduce((e,t)=>("video"===t.mediaTrack.kind&&(e[0]+=1),"audio"===t.mediaTrack.kind&&(e[1]+=1),e),[0,0]).some(e=>e>1))throw kn("Invalid parameters.");this.release();try{const t=new MediaStream(e.map(e=>e.mediaTrack)),r=window;if(this.mimeType){const e={mimeType:this.mimeType};this.recorder=new r.MediaRecorder(t,e)}else this.recorder=new r.MediaRecorder(t);this.recorder.ondataavailable=(e=>{jr.debug("Recorder data, ",e.data),this.recordedChunks.push(e.data)}),this.recorder.start(Hi.recorderTimeslice)}catch(e){throw kn("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw kn("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw kn("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw kn("MediaRecorder is in inactive state, cannot do stop.");try{if(this.recorder.stop(),this.mimeType){const e={type:this.mimeType};this.recordedBlob=new Blob(this.recordedChunks,e)}else this.recordedBlob=new Blob(this.recordedChunks);return this.recordedUrl=window.URL.createObjectURL(this.recordedBlob),this.recordedBlob}catch(e){throw kn("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw kn("No recorded data, please start record first.");this.releaseMediaElement();const r=document.createElement("video");return r.style.width="100%",r.style.height="100%",r.style.objectFit="contain",r.controls=!0,r.muted=t,r.className="qnrtc-recorder-video-player",r.setAttribute("playsinline",!0),r.autoplay=!0,r.src=this.recordedUrl,e.appendChild(r),this.mediaElement=r,new Promise((e,t)=>{let n;try{n=r.play()}catch(e){t(e)}n?n.then(e).catch(e=>{t(e);try{throw kn("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw kn("No recorded data, please start record first.");const t=document.createElement("a");t.style.display="none",t.href=this.recordedUrl,t.download=e,document.body.appendChild(t),t.click(),setTimeout(()=>{document.body.removeChild(t)},100)}}Hi.recorderTimeslice=1e3;class Fi{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class ji{constructor(e,t,r,n,i){this._connectStatus=B.Idle,this.track=r,this.trackID=n,this.mid=i,this.transport=e,this.direction=t}get connectStatus(){return this._connectStatus}set connectStatus(e){if(e!==this._connectStatus){const t=this._connectStatus;this._connectStatus=e,ai(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=B.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===B.Connect&&e(),n===B.Idle&&t()})})}appendConsumner(e,t){this.consumer=new Fi(this.trackID,this.mid,t,e),this.transport.appendConsumer(this.consumer)}setMute(e){this.track&&this.track.setMute(e)}addTrackId(e){this.track&&(this.trackID=e,this.track.setInfo({trackID:e}))}release(){this.consumer&&this.transport?(this.transport.recvHandler.isPcReady&&this.transport.removeConsumers([this.consumer]),this.track&&this.track.release()):this.track&&this.track.reset()}}const Vi=0;class Ui extends Li{constructor(e,t,r){if("audio"!==e.kind)throw new Error("audio track only!");super(e,t,r),this.mediaStream=new MediaStream,this.mediaStream.addTrack(e)}resume(e){this.mediaTrack=e,this.removeEvent("@get-stats"),this.resetStats();const t=new MediaStream([e]);this.mediaStream=t,this.mediaElement&&(this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t),this.audioManager&&(this.audioManager.release(),this.initAudioManager())}initAudioManager(e){this.audioManager=new xi,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&E.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){e<0||e>100?jr.warning(`available volume value is between 0 to 100 , current ${e} is unavailable`):"local"!=this.direction?this.remoteAudioHelper.setVolume(e):this.audioManager.gainNode.gain.setValueAtTime(e,Ii.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Ri);return this.audioManager.analyserNode.getByteTimeDomainData(e),e}getCurrentFrequencyData(){const e=new Uint8Array(this.audioManager.analyserNode.frequencyBinCount);return this.audioManager.analyserNode.getByteFrequencyData(e),e}getVolume(){return this.audioManager.gainNode.gain.value}getCurrentVolumeLevel(){const e=this.getCurrentFrequencyData();let t=0,r=e.length;return e.forEach((n,i)=>{const a=i*(Ii.sampleRate||44100)/e.length;if(a>22050)return void(r-=1);const o=function(e){const t=e*e;return 1.2588966*14884e4*t*t/((t+424.36)*Math.sqrt((t+11599.29)*(t+544496.41))*(t+14884e4))}(a)*n/255;o<=Vi?r-=1:t+=o*o}),0===r?0:Math.sqrt(t/r)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),this.audioManager&&this.audioManager.release(),this.removeMediaElement()}}var qi=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i};var Wi=function(e,t){if(null==e)return{};var r,n,i=qi(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i};const zi="\n";var Xi=u(function(e){var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach(function(e){t[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})}),Ki=(Xi.v,Xi.o,Xi.s,Xi.i,Xi.u,Xi.e,Xi.p,Xi.z,Xi.r,Xi.t,Xi.c,Xi.b,Xi.m,Xi.a,u(function(e,t){var r=function(e){return String(Number(e))===e?Number(e):e},n=function(e,t,n){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var a=e.push?{}:i?t[e.name]:t;!function(e,t,n,i){if(i&&!n)t[i]=r(e[1]);else for(var a=0;a1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),i=0;i=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})}.apply(null,n)},Zi=["v","o","s","i","u","e","p","c","b","t","r","z","a"],$i=["i","c","b","a"],Yi={write:function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var r=t.outerOrder||Zi,n=t.innerOrder||$i,i=[];return r.forEach(function(t){Xi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ji(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ji(t,r,e))})})}),e.media.forEach(function(e){i.push(Ji("m",Xi.m[0],e)),n.forEach(function(t){Xi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ji(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ji(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Ki.parse,parseParams:Ki.parseParams,parseFmtpConfig:Ki.parseFmtpConfig,parsePayloads:Ki.parsePayloads,parseRemoteCandidates:Ki.parseRemoteCandidates,parseImageAttributes:Ki.parseImageAttributes,parseSimulcastStreamList:Ki.parseSimulcastStreamList};const ea="qiniu-rtc-client";function ta(e){return e.map(e=>{const t={component:1,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,transport:e.protocol,type:e.type};return e.tcpType&&(t.tcptype=e.tcpType),t})}class ra{constructor(e,t){this.lastSubMids=[],this.sessionVersion=0,this.direction=e,this.extendedRtpCapabilities=t}get transportRemoteParameters(){return this._transportRemoteParameters}async setTransportRemoteParameters(e){for(const t of e.iceCandidates)t.ip=await hi(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");return E.unifiedPlan?function(e,t,r,n,i){const a=Yi.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:ea},o.name="-",o.timing={start:0,stop:0},o.icelite=t.iceParameters.iceLite?"ice-lite":void 0,o.msidSemantic={semantic:"WMS",token:"*"},o.media=[],o.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};for(const r of a.media){const a="inactive"===r.direction,s=r.type,c="audio"===s?e.codecs[0]:e.codecs[1],d=e.headerExtensions.filter(e=>e.kind===s),u={type:r.type,port:i&&i.has(String(r.mid))?0:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:r.mid,iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ta(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"sendonly"===r.direction||"sendrecv"===r.direction?"recvonly":"inactive",rtp:[{payload:c.sendPayloadType,codec:c.name,rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}],rtcpFb:[],fmtp:[{payload:c.sendPayloadType,config:Object.keys(c.parameters).map(e=>`${e}=${c.parameters[e]};`).join("")}],payloads:c.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:d.map(e=>({uri:e.uri,value:e.sendId}))};c.rtcpFeedback&&c.rtcpFeedback.length>0&&c.rtcpFeedback.forEach(e=>{u.rtcpFb.push({payload:c.sendPayloadType,type:e.type,subtype:e.parameter})}),c.sendRtxPayloadType&&(u.rtp.push({payload:c.sendRtxPayloadType,codec:"rtx",rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}),u.fmtp.push({payload:c.sendRtxPayloadType,config:`apt=${c.sendPayloadType};`}),u.payloads=`${c.sendPayloadType} ${c.sendRtxPayloadType}`),ia(s,u,e,c);const l=n[u.mid];"video"===u.type&&l&&!a&&(u.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],u.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(u)}const s=(a.media||[]).filter(e=>e.hasOwnProperty("mid")&&0!==e.port).map(e=>String(e.mid));s.length>0&&(o.groups=[{type:"BUNDLE",mids:s.join(" ")}]);return Yi.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=Yi.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:ea},n.name="-",n.timing={start:0,stop:0},n.icelite=t.iceParameters.iceLite?"ice-lite":void 0,n.msidSemantic={semantic:"WMS",token:"*"},n.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};const i=[];for(const r of n.media){const n=r.type,a=e.codecs.find(e=>e.kind===n),o=(e.headerExtensions||[]).filter(e=>e.kind===n);if(!a)throw kn("can not find codec"+n);const s={type:n,mid:n,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ta(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"recvonly",rtp:[{payload:a.sendPayloadType,codec:a.name,rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}],rtcpFb:[],fmtp:[{payload:a.sendPayloadType,config:Object.keys(a.parameters).map(e=>`${e}=${a.parameters[e]};`).join("")}],payloads:a.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:o.map(e=>({uri:e.uri,value:e.sendId}))};a.rtcpFeedback&&a.rtcpFeedback.length>0&&a.rtcpFeedback.forEach(e=>{s.rtcpFb.push({payload:a.sendPayloadType,type:e.type,subtype:e.parameter})}),a.sendRtxPayloadType&&(s.rtp.push({payload:a.sendRtxPayloadType,codec:"rtx",rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}),s.fmtp.push({payload:a.sendRtxPayloadType,config:`apt=${a.sendPayloadType};`}),s.payloads=`${a.sendPayloadType} ${a.sendRtxPayloadType}`),i.push(s)}return n.media=i,Yi.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");if(E.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=M(e,e=>e.mid===n)[0];t&&r.push(t)}return r=r.concat(e),t=r.map(e=>e.mid),r}(e,this.lastSubMids);return this.lastSubMids=t.map(e=>e.mid),this.sessionVersion+=1,function(e,t,r,n){jr.debug("consumerInfos",e);const i={},a=e.map(e=>e.mid);i.version=0,i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:n,username:ea},i.name="-",i.timing={start:0,stop:0},i.icelite=r.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},a.length>0&&(i.groups=[{type:"BUNDLE",mids:a.join(" ")}]);i.media=[],i.fingerprint={type:r.dtlsParameters.fingerprints[0].algorithm,hash:r.dtlsParameters.fingerprints[0].value};for(const n of e){const e="audio"===n.kind?t.codecs[0]:t.codecs[1],a=t.headerExtensions.filter(e=>e.kind===n.kind),o={type:n.kind,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:n.mid,msid:`${n.streamId} ${n.trackID}`,iceUfrag:r.iceParameters.usernameFragment,icePwd:r.iceParameters.password,candidates:ta(r.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===r.dtlsParameters.role?"actpass":"active",direction:n.closed?"inactive":"sendonly",rtp:[{payload:e.recvPayloadType,codec:e.name,rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}],rtcpFb:[],fmtp:[{payload:e.recvPayloadType,config:Object.keys(e.parameters).map(t=>`${t}=${e.parameters[t]};`).join("")}],payloads:e.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:n.closed?[]:a.map(e=>({uri:e.uri,value:e.recvId})),ssrcs:!n.closed&&n.ssrc?[{id:n.ssrc,attribute:"cname",value:n.cname}]:[],ssrcGroups:[]};e.rtcpFeedback&&e.rtcpFeedback.length>0&&e.rtcpFeedback.forEach(t=>{o.rtcpFb.push({payload:e.recvPayloadType,type:t.type,subtype:t.parameter})}),e.recvRtxPayloadType&&(o.rtp.push({payload:e.recvRtxPayloadType,codec:"rtx",rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}),o.fmtp.push({payload:e.recvRtxPayloadType,config:`apt=${e.recvPayloadType};`}),o.payloads=`${e.recvPayloadType} ${e.recvRtxPayloadType}`),ia(n.kind,o,t,e,!0),n.rtxSsrc&&!n.closed&&(o.ssrcs=o.ssrcs.concat([{id:n.rtxSsrc,attribute:"cname",value:n.cname}]),o.ssrcGroups.push({semantics:"FID",ssrcs:`${n.ssrc} ${n.rtxSsrc}`})),i.media.push(o)}return Yi.write(i)}(t,this.extendedRtpCapabilities,this.transportRemoteParameters,this.sessionVersion)}{const t=new Set;return e.forEach(e=>t.add(e.kind)),0===e.length&&(t.add("audio"),t.add("video")),function(e,t,r,n){e=["audio","video"];const i={version:0};i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:2,username:ea},i.name="-",i.timing={start:0,stop:0},i.icelite=n.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},i.groups=[{type:"BUNDLE",mids:e.join(" ")}],i.media=[],i.fingerprint={type:n.dtlsParameters.fingerprints[0].algorithm,hash:n.dtlsParameters.fingerprints[0].value};for(const a of e){const e=t.filter(e=>e.kind===a),o=r.codecs.find(e=>e.kind===a),s=(r.headerExtensions||[]).filter(e=>e.kind===a);if(!o)throw kn("no codec"+a);const c={type:a,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:a,iceUfrag:n.iceParameters.usernameFragment,icePwd:n.iceParameters.password,candidates:ta(n.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===n.dtlsParameters.role?"actpass":"active",direction:"sendonly",rtp:[{payload:o.recvPayloadType,codec:o.name,rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}],rtcpFb:[],fmtp:[{payload:o.recvPayloadType,config:Object.keys(o.parameters).map(e=>`${e}=${o.parameters[e]};`).join("")}],payloads:o.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ssrcs:[],ssrcGroups:[],ext:s.map(e=>({uri:e.uri,value:e.recvId}))};o.rtcpFeedback&&o.rtcpFeedback.length>0&&o.rtcpFeedback.forEach(e=>{c.rtcpFb.push({payload:o.recvPayloadType,type:e.type,subtype:e.parameter})}),o.recvRtxPayloadType&&(c.rtp.push({payload:o.recvRtxPayloadType,codec:"rtx",rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}),c.fmtp.push({payload:o.recvRtxPayloadType,config:`apt=${o.recvPayloadType};`}),c.payloads=`${o.recvPayloadType} ${o.recvRtxPayloadType}`);for(const t of e)c.ssrcs.push({id:t.ssrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.ssrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"cname",value:`${t.cname}`}),t.rtxSsrc&&(c.ssrcGroups.push({semantics:"FID",ssrcs:`${t.ssrc} ${t.rtxSsrc}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"cname",value:`${t.cname}`}));i.media.push(c)}return Yi.write(i)}(Array.from(t),e,this.extendedRtpCapabilities,this.transportRemoteParameters)}}async updateICEData(e,t){if(this.transportRemoteParameters){for(const e of t)e.ip=await hi(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function na(e){const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});return t.sdp?{isH264:-1!==t.sdp.toLowerCase().indexOf("h264"),sdp:t.sdp}:{isH264:!1,sdp:""}}function ia(e,t,r,n,i=!1){const a=r.codecs.filter(t=>t.kind===e&&t.name!==n.name);if(a.length>0){let e=i?n.recvPayloadType:n.sendPayloadType;const r=[];a.forEach(n=>{const a=i?n.recvPayloadType:n.sendPayloadType;r.push(a),t.rtp.push({payload:a,codec:n.name,rate:n.clockRate,encoding:n.channels>1?n.channels:void 0}),t.fmtp.push({payload:a,config:`${e}/${e}`})}),t.payloads=`${t.payloads} ${r.join(" ")}`}}function aa(e){const t=Yi.parse(e);if(!("media"in t))return Yi.write(t);if(!Array.isArray(t.media))return Yi.write(t);for(const e of t.media)"ext"in e&&Array.isArray(e.ext)&&"video"===e.type&&(e.ext=e.ext.filter(e=>"urn:3gpp:video-orientation"!==e.uri));return Yi.write(t)}class oa extends bi{constructor(e,t,r){super(),this._isRestartingICE=!1,this.isPcReady=!1,this.midRidEncoding={},this.removeMids=new Set,this.lastMediaStatistics=[],this.intervalId=-1,this.playQualityIntervalId=-1,this.qualityStats=new Map,this._direction=e,this._pc=Ao(),this._extendedRtpCapabilities=t,this._remoteSdp=new ra(e,t),this._simulcast=!!r&&r.simulcast,this.coreInstance=r&&r.core,this._pc.addEventListener("iceconnectionstatechange",()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected"),this.registerMediaStatisticStatsReport(),this.registerPlayQualityReport();break;case"failed":this.emit("@connectionstatechange","failed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"disconnected":this.emit("@connectionstatechange","disconnected"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"closed":this.emit("@connectionstatechange","closed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport()}})}async getStats(e,r){return await async function(e,r,n,i){if(E.stats){const a=await async function(e,t,r){let n;try{n=await e.getStats(t)}catch(e){return jr.debug("get stats error, fallback to default",e),[]}if(!n)return jr.debug("get null stats, fallback to default"),[];const i=[];for(const e of n.values())if("send"===r&&"outbound-rtp"===e.type&&!e.isRemote||"recv"===r&&"inbound-rtp"===e.type&&!e.isRemote){const t=Ya(),a=n.get(e.remoteId);t.packetLoss=uo(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=co(e)||co(a)||0,t.id=e.id,t.kind=e.kind,e.frameWidth&&(t.width=e.frameWidth),e.frameHeight&&(t.height=e.frameHeight),e.framesPerSecond&&(t.frameRate=e.framesPerSecond),e.framerateMean&&(t.frameRate=Math.ceil(e.framerateMean)),i.push(t)}return i}(e,r,n);return function(e,r){if(!r||0===r.length)return e;if(r.length!==e.length)return e;const n=Object.values(Gr([...e,...r],"id"));if(!n.every(e=>2===e.length))return e;return n.map(([e,r])=>{const n=(e.timestamp-r.timestamp)/1e3;if(n<=0)return e;const i=t({},e),a=lo(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=eo(a,i.rtt);const o=Za(e.id,e.kind);return o.Apply(a),i.packetLossRate=o.Filtered()<0?0:o.Filtered(),i.bitrate=8*(e.bytes-r.bytes)/n,i.bitrate<0?r:i})}(a,i)}return ui(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}(this._pc,e,this._direction,r)}registerPlayQualityReport(){"send"!==this._direction&&(this.unregisterPlayQualityReport(),this.playQualityIntervalId=window.setInterval(async()=>{const e=await async function(e,t){let r;try{r=await e.getStats()}catch(e){return ui(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return ui(()=>{jr.debug("get null media statistic stats, fallback to default")},"getStats error"),[];const n=[...r.values()];return t.subscribedTracks.map(e=>{const t=e.mediaTrack,r=n.find(e=>e.type===ao.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===ao.InBoundRtp&&e.trackId===r.id);return i?{time:Date.now(),trackID:e.info.trackID,kind:"video"===i.kind?"video":"audio",framesDecoded:i.framesDecoded||-1,totalSamplesReceived:i.totalSamplesReceived||-1}:void 0}).filter(N)}(this._pc,this.coreInstance);for(const t of e){const e=this.qualityStats.get(t.trackID);e?e.push(t):this.qualityStats.set(t.trackID,[t])}this.addQualityStats()},2e3))}unregisterPlayQualityReport(){"send"!==this._direction&&-1!==this.playQualityIntervalId&&(window.clearInterval(this.playQualityIntervalId),this.addQualityStats(!0),this.playQualityIntervalId=-1)}addQualityStats(e=!1){const t=[...this.qualityStats.values()];if(t.some(e=>e.length>=30)||e){jr.log("quality stats",this.qualityStats);for(const e of t){if(0===e.length)continue;const t=e[0].trackID,r=2*e.length*1e3;if("video"===e[0].kind){const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].framesDecoded===e[n-1].framesDecoded?t+2:t,0);gn.addEvent("VideoPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}else{const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].totalSamplesReceived===e[n-1].totalSamplesReceived?t+2:t,0);gn.addEvent("AudioPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}}this.qualityStats=new Map}}registerMediaStatisticStatsReport(){this.unregisterMediaStatisticStatsReport(),this.intervalId=window.setInterval(async()=>{const e=await async function(e,r){let n;try{n=await e.getStats()}catch(e){return jr.debug("get media statistic stats error, fallback to default",e),[]}if(!n)return jr.debug("get null media statistic stats, fallback to default"),[];const i=[...n.values()];return i.filter(e=>(e.type===ao.InBoundRtp||e.type===ao.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[ao.MediaSource]:r.filter(e=>e.type===ao.MediaSource).find(t=>t.id===e.mediaSourceId),[ao.Track]:r.filter(e=>e.type===ao.Track).find(t=>t.id===e.trackId),[ao.RemoteInBound]:r.filter(e=>e.type===ao.RemoteInBound).find(t=>t.id===e.remoteId)};let a=function(e,r,n){const i={id:e,track_id:r,kind:"audio",kbps:0,framerate:0,packet_lost_rate:0,rtt:0,extra_stats:null,calculation_stats:t({},no)};n===io.Audio?i.extra_stats=t({},to):i.extra_stats=t({},ro);return i}(e.id,e.trackID,e.mediaType);a.rtt=co(i[ao.RemoteInBound])||co(e)||0,a.calculation_stats.packets_lost=uo(e,i[ao.RemoteInBound])||0,e.mediaType===io.Video?(a=function(e,t){return t.kind=e.kind,t.extra_stats.nack_count=e.nackCount,t.extra_stats.fir_count=e.firCount,t.extra_stats.pli_count=e.pliCount,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.frame_encoded=e.framesEncoded||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.frame_decoded=e.framesDecoded||0,t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[ao.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[ao.MediaSource],a)),i[ao.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.width=e.frameWidth,t.extra_stats.height=e.frameHeight,t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[ao.Track],a,n))):(a=function(e,t){return t.kind=e.kind,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.track_audio_volume=so(e.audioLevel,e.type),t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[ao.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=so(e.audioLevel,e.type),t}(i[ao.MediaSource],a)),i[ao.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[ao.Track],a,n)));return a})(e,i,r))}(this._pc,this.coreInstance);e&&e.length>0&&(this.addMediaStatistics(e,this.lastMediaStatistics),this.lastMediaStatistics=e)},3e3)}unregisterMediaStatisticStatsReport(){-1!==this.intervalId&&(window.clearInterval(this.intervalId),this.lastMediaStatistics=[],this.intervalId=-1)}addMediaStatistics(e,r){const n=e.map(e=>{const n=$a(e.id,e.kind),i=r.find(t=>t.id===e.id);if(!i)return e;const a=i.calculation_stats,{calculation_stats:o}=e,s=Wi(e,["calculation_stats"]);return t({},s,function(e,t,r){if(!e||!t)return{framerate:0,kbps:0,packet_lost_rate:0};const n=(e.timestamp-t.timestamp)/1e3,i=0===n?0:(e.frames_sent-t.frames_sent+(e.frames_received-t.frames_received))/n,a=0===n?0:(e.bytes_sent-t.bytes_sent+(e.bytes_received-t.bytes_received))/(1024*n/8),o=lo(t.packets_lost,e.packets_lost,t.packets_received+t.packets_sent,e.packets_received+e.packets_sent);r.Apply(o);const s=r.Filtered()<0?0:100*r.Filtered();return{framerate:Math.ceil(i),kbps:Math.ceil(a),packet_lost_rate:Math.ceil(s)}}(o,a,n))});jr.log("media statistics",n),gn.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=eo(n.sort((e,t)=>t.packet_lost_rate-e.packet_lost_rate)[0].packet_lost_rate,n.sort((e,t)=>t.rtt-e.rtt)[0].rtt);bn(i);const a=n.map(e=>({kind:e.kind,lostRate:e.packet_lost_rate,rtt:e.rtt,track:e.track_id}));this.emit("@send-qos-message",{qos:JSON.stringify({networkGrade:i,tracks_qos:a})})}getCurrentIceConnectionState(){return this._pc.iceConnectionState}close(){jr.log("handle",this._direction,"close"),this.removeEvent(),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport(),this._pc.close(),this.isPcReady=!1}}class sa extends oa{constructor(e,t,r){super("send",e,r),jr.log("init send handler"),this._transportReady=!1,this._stream=new MediaStream,this._signaling=t,t.on("on-pubpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))})}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-pubpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-pubpc-state",n)})}addProducerTracks(e){jr.debug("add producer",e);const t=e.filter(e=>!this._stream.getTrackById(e.mediaTrack.id));if(0===t.length)return Promise.reject(new Error("track already added"));let r;const n=[];let i,a=!0;return Promise.resolve().then(async()=>{for(const e of t)this._stream.addTrack(e.mediaTrack);if(E.unifiedPlan&&E.supportTransceivers)for(const e of t){const t=await ho(e.mediaTrack,this._pc,e.lowStreamConfig,e.info.kbps);jr.debug("add transceiver",t,t.mid),n.push(t)}else jr.debug("add tracks",t),r=t.map(e=>this._pc.addTrack(e.mediaTrack,this._stream));return da(this._pc,this._simulcast)}).then(e=>{let t;return E.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${zi}`),t={type:"offer",sdp:e.sdp},i=t.sdp,jr.log("publish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{for(const t of n){if(!t.sender.track)continue;const r=e.find(e=>e.mediaTrack===t.sender.track);if(!r||!t.mid)throw kn("can not get transceiver mid!");r.setInfo({mid:t.mid}),this.midRidEncoding[t.mid]=r.lowStreamConfig}if(!this._transportReady)return a=!1,this._setupTransport(e)}).then(()=>this._remoteSdp.createRemoteAnswer(i,this.midRidEncoding,this.removeMids)).then(e=>{const t={type:"answer",sdp:e};return jr.debug("addProducer answer",t),this._pc.setRemoteDescription(t)}).then(()=>this._pcReady).then(()=>a?this.safeEmitAsPromise("@needpubtracks",e,i):Promise.resolve(this._remoteSdp.transportRemoteParameters)).catch(e=>{jr.log("add producer error",e);try{for(const e of r)this._pc.removeTrack(e);for(const e of n)e.direction="inactive"}catch(e){}for(const e of t)this._stream.removeTrack(e.mediaTrack);throw e instanceof Sn?e:kn(e)})}removeProducerTracks(e){jr.debug("removeProducerTracks",e);const t=e.filter(e=>void 0!==e.track&&!!this._stream.getTrackById(e.track.mediaTrack.id)).map(e=>e.track.isReplacedByImageTrack?e.track.imageStreamTrack.mediaTrack:e.track.mediaTrack);let r;return Promise.resolve().then(()=>{E.unifiedPlan&&E.supportTransceivers&&this._pc.getTransceivers().forEach(e=>{e.sender.track&&e.mid&&t.includes(e.sender.track)&&this.removeMids.add(e.mid)});const e=this._pc.getSenders().filter(e=>e.track&&t.includes(e.track));if(0===e.length)return jr.warning("removeProducerTracks [nothing to remove]"),Promise.reject("removeProducerTracks: nothing to remote");for(const t of e)this._pc.removeTrack(t);for(const e of t)this._stream.removeTrack(e);return da(this._pc,this._simulcast)}).then(e=>{const t=new RTCSessionDescription(e);return r=t.sdp,jr.log("unpublish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(r,this.midRidEncoding,this.removeMids)};return jr.log("unpublish: set remote answer",e),this._pc.setRemoteDescription(e)}).catch(e=>{if(0!==this._stream.getTracks().length)throw e instanceof Sn?e:kn(e);jr.debug("removeProducer() | ignoring expected error due no sending tracks: %s",e.toString())}).then(()=>{this.safeEmitAsPromise("@needunpubtracks",e)})}async replaceTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");e.track&&(e.track.mediaTrack=t,e.track.removeMediaElement());const n=r.track;await r.replaceTrack(t),this._stream.removeTrack(n),this._stream.addTrack(t)}async replaceProducerTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");"image"===t?(jr.debug("replaceTrack",e.track.imageStreamTrack.mediaTrack),await r.replaceTrack(e.track.imageStreamTrack.mediaTrack)):"video"===t&&(jr.debug("replaceTrack",e.track.mediaTrack),await r.replaceTrack(e.track.mediaTrack))}restartICE(e,t){return jr.log("restart send ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>da(this._pc,this._simulcast,{iceRestart:!0})).then(e=>this._pc.setLocalDescription(e)).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(this._pc.localDescription.sdp,this.midRidEncoding,this.removeMids)};return this._pc.setRemoteDescription(e)})}_setupTransport(e){const t=Date.now();return Promise.resolve().then(()=>this._pc.localDescription?this._pc.localDescription:da(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(gn.addEvent("PublisherPC",{signal_take_time:Date.now()-t,result_code:r.code,up_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),this.pcid=r.pcid,this._transportReady=!0,this._pcReady=this.getReady(r),this._remoteSdp.setTransportRemoteParameters(r)))}}class ca extends oa{constructor(e,t,r){super("recv",e,r),this._transportCreated=!1,this._consumerInfos=new Map,this._signaling=t,t.on("on-subpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))}),jr.log("init recvhandler",this)}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-subpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-subpc-state",n)})}async addConsumerTracks(e){if(E.unifiedPlan&&g){const t=[];for(const r of e){const e=await this.addConsumerTrack(r);t.push(e)}return t}jr.log("add consumers",e);const t=[],r=Array.from(this._consumerInfos.values());for(const n of e){const e=r.find(e=>e.consumerId===n.id);if(e&&!e.closed)t.push(e);else{const e=this.genNewConsumerInfo(n);if(E.unifiedPlan){const t=n.mid;e.mid=t,this._consumerInfos.set(t,e)}else this._consumerInfos.set(n.id,e);t.push(e)}}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>(E.unifiedPlan,this._pc.createAnswer())).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{for(let r=0;r!!e.receiver.track&&(e.receiver.track.id===n.trackID||e.mid===n.mid));e&&(i.track=e.receiver.track)}else if(E.getReceivers){const e=this._pc.getReceivers().find(e=>{const{track:t}=e;return!!t&&n.trackID===t.id});e&&(i.track=e.track)}else{const e=this._pc.getRemoteStreams().find(e=>e.id===n.streamId);e&&(i.track=e.getTrackById(n.trackID))}if(!i.track)throw kn("remote track not found");jr.log("subscribe: get new track",i.track)}}return e.map(e=>e.track)})}genNewConsumerInfo(e){const t=e.rtpParameters.encodings[0],r=e.rtpParameters.rtcp.cname,n=e.mid;return{kind:e.kind,streamId:E.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:E.unifiedPlan?`consumer-${e.kind}-${n}`:`consumer-${e.kind}-${t.ssrc}`,ssrc:t.ssrc,rtxSsrc:t.rtx?t.rtx.ssrc:void 0,cname:r,consumerId:e.id,closed:!1}}async addConsumerTrack(e){jr.log("add consumer",e);let t=null;const r=Array.from(this._consumerInfos.values()).find(t=>t.consumerId===e.id);if(r&&!r.closed)t=r;else{const r=this.genNewConsumerInfo(e);if(E.unifiedPlan){const t=e.mid;r.mid=t,this._consumerInfos.set(t,r)}else this._consumerInfos.set(e.id,r);t=r}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("set ontrack"),this._pc.ontrack=(e=>{jr.log("ontrack",e.receiver.track)}),jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{let r=null;if(E.unifiedPlan&&E.supportTransceivers&&e&&t){const n=this._pc.getTransceivers().find(r=>!!r.receiver.track&&((r.receiver.track.id===t.trackID||r.mid===t.mid)&&(e.track=r.receiver.track,!0)));n&&(r=n.receiver.track)}else if(e&&t){const n=this._pc.getReceivers().find(r=>{const{track:n}=r;return!!n&&(t.trackID===n.id&&(e.track=n,!0))});n&&(r=n.track)}if(!r&&e)throw kn("remote track not found");return jr.log("subscribe: get new track",r,r.readyState),r})}removeConsumerTracks(e){jr.log("remove consumer",e);let t=!1;for(const r of e){const e=Array.from(this._consumerInfos.values()).find(e=>e.consumerId===r.id&&!e.closed);e?(t=!0,E.unifiedPlan?(r.track=null,e.closed=!0):this._consumerInfos.delete(r.id)):jr.log("can not find unpublish track target, ignore")}return t?Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("unsubscribe set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.log("unsubscribe set local answer",e),this._pc.setLocalDescription(e))):Promise.resolve()}restartICE(e,t){return jr.log("recv restart ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>{this._pc.setLocalDescription(e)})}async setupTransport(e){if(this._transportCreated)return await this._pcReady;const t=Date.now(),r=await this.safeEmitAsPromise("@needsubpc",e);return gn.addEvent("SubscriberPC",{signal_take_time:Date.now()-t,result_code:r.code,down_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(e=>({track_id:e.trackid,status:e.status}))}),this.pcid=r.pcid,this._transportCreated=!0,this._pcReady=this.getReady(r),jr.log("init subscribe, get transport remote",r),await this._remoteSdp.setTransportRemoteParameters(r),r}}function da(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=aa(n),"chrome"===b.name&&t&&(n=function(e,t){const r=Yi.parse(e);t&&"chrome"===b.name&&(r.media=r.media.map(e=>{if(!e.ssrcGroups||0===e.ssrcGroups.length||!e.ssrcs||0===e.ssrcs.length)return e;const r=e.ssrcGroups.find(e=>"FID"===e.semantics);if(!r)return e;const[n,i]=r.ssrcs.split(" ").map(e=>parseInt(e,10));let a,o;e.ssrcs.forEach(e=>{"cname"===e.attribute&&(a=e.value),"msid"===e.attribute&&(o=e.value)});const s=[];if(s.push(n),t>=2){const t=n+1,r=i+1;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}if(t>=3){const t=n+2,r=i+2;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}return e.ssrcGroups.push({semantics:"SIM",ssrcs:s.join(" ")}),e}));const n=Yi.write(r).split("\r\n");let i=n.findIndex(e=>0===e.indexOf("a=ssrc-group:FID"));for(;-1!==i&&0===n[i].indexOf("a=ssrc-group:FID");){const e=n[i].split(" ")[2];for(let t=i-1;t>=0;t--)if(n[t].indexOf(e)>0){n.splice(t+1,0,n[i]),n.splice(i+1,1);break}i++}return n.join("\r\n")}(n,3)),{type:r,sdp:n}):e})}function ua(e,t,r,n){switch(e){case"send":return new sa(t,r,n);case"recv":return new ca(t,r,n)}}var la;!function(e){e.SEND_TRACKS="@transport:send-tracks",e.RESTART_SEND_ICE="@transport:send-restart-ice",e.REMOVE_TRACKS="@transport:remove-tracks",e.INIT_RECV="@transport:init-recv",e.RESTART_RECV_ICE="@transport:recv-restart-ice",e.ADD_CONUMERS="@transport:add-consumers",e.REMOVE_CONSUMERS="@transport:remove-consumers"}(la||(la={}));class Aa extends bi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Vr("SendQueue"),this.recvCommandQueue=new Vr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=ua("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=ua("recv",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),this.handleRecvHandler(),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this)),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this)),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e})}get publishTracks(){return Array.from(this._publishTracks.values())}resolveInitSubPcPromise(){this.initSubPcPromiseResolve&&(this.initSubPcPromiseResolve(),this.initSubPcPromiseResolve=void 0)}handleSendHandler(){this.sendHandler.on("@needpubpc",(e,t,r,n)=>{this.safeEmitAsPromise("@needpubpc",e,t).then(r).catch(n)}).on("@connectionstatechange",e=>{switch(jr.log("pubpc connectionstatechange",e),gn.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartSendICE(this.sendHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.sendHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartSendICE(this.sendHandler.pcid))})}}).on("@needpubtracks",(e,t,r,n)=>{const i=e.map(ko),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(gn.addEvent("PublishTracks",{signal_take_time:Date.now()-a,result_code:t.code,tracks:t.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),t.code){case 0:break;case 10052:return n(Zn());case 10061:return this.reconnectProducer(),n(qn(10061,t.error));default:return n(qn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(qn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{gn.addEvent("UnPublishTracks",{tracks:e.map(e=>({track_id:e.trackID}))}),this.signaling.request("unpub-tracks",{tracks:e.map(e=>({trackid:e.trackID}))}).then(e=>{t(e)})}).on("@send-qos-message",e=>{this.signaling.request("send-qos-message",e)})}async sendTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(la.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(la.REMOVE_TRACKS,e)}async restartSendICE(e){return E.supportRestartICE?this.sendCommandQueue.push(la.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case la.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case la.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case la.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new ji(this,"send",e));for(const e of t)this._publishTracks.set(e.track.mediaTrack.id,e);return t}removeTrackFromPublishTracks(e){for(const t of e)this._publishTracks.delete(t.mediaTrack.id)}async _execAddProducerTracks(e){const t=await this.sendHandler.addProducerTracks(e.map(e=>e.track));for(const r of e){const e=ri(t.tracks,"localid",r.track.mediaTrack.id);e&&(r.addTrackId(e.trackid),r.track.setInfo({versionid:e.versionid}),r.track.resetStats())}return e.map(e=>e.connectStatus=B.Connect),t}_execRemoveTracks(e){return this.removeTrackFromPublishTracks(e.map(e=>e.track)),e.map(e=>e.release()),this.sendHandler.removeProducerTracks(e)}async _execRestartSendICE(e){this.sendHandler._isRestartingICE=!0;const t=await this.signaling.request("pubpc-restart",{pcid:e});if(0!==t.code)return this.sendHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.reconnectProducer();try{await this.sendHandler.restartICE(t.iceParameters,t.iceCandidates),this.sendHandler._isRestartingICE=!1}catch(e){jr.debug("restart ice faild",t.code,t.error),this.sendHandler._isRestartingICE=!1,this.reconnectProducer()}}reconnectProducer(){this.resetSendCommandQueue(),this.sendHandler.close();const e=this.publishTracks;this.sendHandler=ua("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=B.Connecting}),this.emit("@needrepub",e)}handleRecvHandler(){this.recvHandler.on("@needsubpc",(e,t,r)=>{this.safeEmitAsPromise("@needsubpc",e).then(t,r)}).on("@connectionstatechange",e=>{switch(jr.log("sub pc connection state change",e),gn.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartRecvICE(this.recvHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.recvHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartRecvICE(this.recvHandler.pcid))})}})}appendConsumer(e){this.consumerQueue.push(e)}async addConsumers(){const e=this.consumerQueue;return this.consumerQueue=[],this.recvCommandQueue.push(la.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(la.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(la.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return E.supportRestartICE?this.recvCommandQueue.push(la.RESTART_RECV_ICE,e):this.resetRecvHandler()}async _removeConsumers(e){await this.recvHandler.removeConsumerTracks(e)}async _initRecvHandler(e){return this.recvHandler.isPcReady?(await this.initSubPcPromise,null):await this.recvHandler.setupTransport(e)}async _addConsumers(e){if(0===e.length)return Promise.resolve([]);return await this.recvHandler.addConsumerTracks(e)}async _execRestartRecvICE(e){this.recvHandler._isRestartingICE=!0;const t=await this.signaling.request("subpc-restart",{pcid:e});if(0!==t.code)return this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.resetRecvHandler();try{await this.recvHandler.restartICE(t.iceParameters,t.iceCandidates),this.recvHandler._isRestartingICE=!1}catch(e){this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),this.resetRecvHandler()}}handleRecvCommandTask(e,t){switch(e.method){case la.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case la.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case la.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case la.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Vr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Vr("RecvQueue"),this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this))}resetRecvHandler(){this.resetRecvCommandQueue(),this.emit("@needresetrecv"),this.recvHandler.close(),this.recvHandler=ua("recv",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e}),this.handleRecvHandler(),this.emit("@needresub")}release(){this.recvHandler.close(),this.sendHandler.close(),this.publishTracks.forEach(e=>e.release())}}const ha=new bi;function fa(e,t){return new Promise(r=>{let n;const i=Date.now(),a=new WebSocket(e);a.onopen=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!0,reason:"ok",connectTime:t})}),a.onerror=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"onerror",connectTime:t})}),n=setTimeout(()=>{const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"timeout",connectTime:t}),a.close()},t)})}var pa;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(pa||(pa={}));const ma={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class ga extends C{constructor(e=ma){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new Hi,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=pa.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==pa.Connected)return void n(kn("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===dn.LIVE&&this._role===un.AUDIENCE)return void n(kn("no permission. Audience in Live mode has no permission to publish."));e.forEach(e=>e.userID=this.userID),e.forEach(e=>e.selfEndedCallback=this.unpublish.bind(this));const i=this.connectionTransport,a=this.signaling;let o;if(t){const t=e.map(e=>e.mediaTrack.id);o=i.publishTracks.filter(e=>-1!==t.indexOf(e.track.mediaTrack.id))}else{const t=i.publishTracks.map(e=>e.track.mediaTrack.id);if(e.filter(e=>-1===t.indexOf(e.mediaTrack.id)).length!==e.length)return void n(kn("there are already published tracks in the provided tracks"));o=i.addTrackToPublishTracks(e)}if(jr.debug("start publish",o,t),!t){const e=o.map(e=>e.startConnect());Promise.all(e).then(()=>r()).catch(()=>{n(Gn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=ri(this.users,"userID",this.userID);t&&(t.addTracks(o.map(e=>e.track)),t.addPublishedTrackInfo(o.map(e=>({trackID:e.trackID,muted:!!e.track.info.muted,kind:e.track.info.kind,tag:e.track.info.tag,userID:this.userID,versionid:e.track.info.versionid,profiles:e.track.info.profiles})))),e.forEach(e=>{e.on("@get-stats",(t,r,n)=>{if(!this.connectionTransport)return r([]);const i=e.isReplacedByImageTrack?e.imageStreamTrack.mediaTrack:e.mediaTrack;this.connectionTransport.sendHandler.getStats(i,t).then(r,n)})}),this.getAllMerger().forEach(t=>t.controller.onAddTracks(e.map(e=>e.info)))}catch(t){if(t instanceof Sn)switch(t.code){case 10061:case 30001:return;case 10052:return jr.warning(t,"republish"),void setTimeout(()=>this._publish(e,!0),1e3);default:i.removeTrackFromPublishTracks(e),n(t)}else jr.warning(t,"republish"),setTimeout(()=>this._publish(e,!0),1e3)}})),this._subscribe=((e,t,r=!1,n)=>new Promise(async(i,a)=>{if(this.roomState!==pa.Connected)return void a(kn("can not connected to the room, please joinRoom first"));if(0===e.length)return void i([]);jr.debug("subscribe",e,t);const o=this._trackInfo.filter(t=>e.includes(t.trackid));if(o.length!==e.length)return void a(Kn(10041,`can not find track in room ${e}`));let s;const c=this.connectionTransport,d=this.signaling;if(t)s=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));else{const e=this.subscribeTracks.map(e=>e.trackID),t=o.filter(t=>!e.includes(t.trackid));s=t.map(e=>new ji(c,"recv",void 0,e.trackid,e.mid)),this.subscribeTracks=this.subscribeTracks.concat(s)}n&&Object.entries(n).forEach(([e,t])=>{this.profiles.set(e,t)}),jr.log("sub tracks",s,n);try{if(!t){const e=s.map(e=>e.startConnect());Promise.all(e).then(()=>i(s.map(e=>e.track))).catch(()=>{a(Gn())})}let n=await c.initRecvHandler(s.map(e=>e.trackID));if(!n){const e=Date.now();n=await d.request("sub-tracks",{tracks:s.map(e=>{const t=e.trackID;return this.profiles.get(t)?{trackid:t,profile:this.profiles.get(t)}:{trackid:t}})}),gn.addEvent("SubscribeTracks",{result_code:n.code,signal_take_time:Date.now()-e,tracks:n.tracks.map(e=>({track_id:e.trackid,status:e.status}))})}switch(jr.log("get sub res data",n),n.code){case 0:break;case 10052:throw Zn();case 10062:throw c.resetRecvHandler(),Kn(10062,n.error);default:throw Kn(n.code,n.error)}const u=n.tracks.filter(e=>!!e.status),l=n.tracks.filter(e=>!e.status).map(e=>e.trackid);if(u.length-1!==l.indexOf(e.trackID));M(this.subscribeTracks,e=>-1!==l.indexOf(e.trackID)),e.map(e=>e.release())}n.tracks=u;for(const e of n.tracks||[]){const t=s.find(t=>t.trackID===e.trackid),r=o.find(t=>t.trackid===e.trackid);if(!t||!r)continue;const n=e.rtpparams;t.appendConsumner(n,r.kind)}await c.addConsumers(),c.resolveInitSubPcPromise();for(const e of s){const{consumer:t}=e;if(!t||!t.track)continue;const r=t.track;let n=e.track;const i=o.find(e=>e.trackid===t.id);if(!i)continue;n?n.resume(r):"audio"===r.kind?(n=new Ui(r,i.playerid,"remote")).initAudioManager():n=new Li(r,i.playerid,"remote",i.profiles||[]),n.setInfo({trackID:i.trackid,userID:i.playerid,tag:i.tag,kind:i.kind,muted:i.muted,versionid:i.versionid}),n.setMaster(i.master),n.removeAllListeners("@get-stats"),n.removeAllListeners("@ended"),n.on("@get-stats",(e,t,r)=>{if(!this.connectionTransport)return t([]);this.connectionTransport.recvHandler.getStats(n.mediaTrack,e).then(t,r)}),n.once("@ended",async()=>{if(n&&n.info.trackID){jr.warning("remote track ended, try to resubscribe");try{await this._unsubscribe([n.info.trackID],!0)}catch(e){}await this._subscribe([n.info.trackID],!0)}}),e.track=n;const a=this.users.find(e=>e.userID===i.playerid);a&&a.addTracks([n])}s.forEach(e=>e.connectStatus=B.Connect);let A=n.tracks.map(e=>{if(void 0===e.muted)for(let t=0;t{e.consumer&&r.push(e.consumer)}),await c.removeConsumers(r),!(t instanceof Sn))return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);switch(t.code){case 10062:case 30001:return;case 10052:return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);default:M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},ma,e),this.config=e,jr.log("config",e),jr.log("version",Hr),jr.log("browser report",E,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(So)}get roomState(){return this._roomState}set roomState(e){this._roomState!==e&&(this._roomState=e,jr.debug("roomState change",this._roomState),this.emit("room-state-change",this._roomState),gn.addEvent("RoomStateChanged",{room_state:e,event_grade:this._roomState===pa.Reconnecting?An.SERVERE:An.NORMAL,event_category:hn.CORE}))}_setReconnectTimes(e){this.config.reconnectTimes=e,this.signaling&&(this.signaling.reconnectTimes=e)}set simulcast(e){this.config.simulcast=e,this.connectionTransport&&(this.connectionTransport.simulcast=e,this.connectionTransport.sendHandler._simulcast=e,this.connectionTransport.recvHandler._simulcast=e)}_getReconnectTimes(){return this.config.reconnectTimes||ma.reconnectTimes}setRequestTimeout(e){this.config.requestTimeout=e}_setProfile(e,t){if(this.profile=t,this.profiles.set(e,t),!this.subscribeTracks.some(t=>t.trackID===e))return;this.signaling.sendWsMsg("set-sub-profile",{tracks:[{trackid:e,profile:this.profile}]})}getForwardJobTracks(){return this.forwardJobTracks}get publishedTracks(){return this.connectionTransport?this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==pa.Idle)throw kn("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===dn.RTC||this._mode===dn.LIVE&&this._role===un.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===dn.RTC)throw kn("client role can only be set in client mode LIVE.");if(e===un.AUDIENCE&&this.publishedTracks.length>0&&e===un.AUDIENCE)throw kn("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==pa.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(gn.addEvent("SetClientRole",{result_code:t.code,user_role:e===un.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Jn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();let n=0;this._mode===dn.LIVE&&(n=1);const i=this._role===un.BROADCASTER?0:1;if(gn.addEvent("JoinRoom",{room_token:e,user_data:t,room_type:n,user_role:i,audience_latency_level:0}),this.roomState!==pa.Idle)throw kn("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=pa.Connecting;try{this.roomToken=e,this.userData=t;const n=ti(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,gn.setUserBase(this.userID,this.roomName,this.appId),jr.log("join room, token:",e),jr.debug(`join room, roomName: ${this.roomName}, userID: ${this.userID}`),!this.roomName.match(/^[a-zA-Z0-9_-]{1,64}$/))throw this.roomState=pa.Idle,kn("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{1,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{1,50}$/))throw this.roomState=pa.Idle,kn("invalid userID. userID must match /^[a-zA-Z0-9_-]{1,50}$/");try{const t=await vi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,gn.setSessionId(t.sessionId),gn.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:0,join_node_info:this.signaling.url,join_error_message:"",event_grade:An.NORMAL,event_category:hn.CORE}),this._mode===dn.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=pa.Idle,jr.debug("joinRoomWithToken fail: "+t.message),gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:t.code?t.code:-1,join_node_info:this.signaling?this.signaling.url:"",join_error_message:t.message||t.error||"",event_grade:An.SERVERE,event_category:hn.CORE}),t}}async joinRoomWithAccess(e){const t=ei(e),{capsdp:r}=await async function(){let e=Ao(),{isH264:t,sdp:r}=await na(e),n=5;for(;!t&&n>0;)e.close(),e=Ao(),({isH264:t,sdp:r}=await na(e)),n--;E.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${zi}`);const i={capsdp:r=aa(r),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===pa.Idle)throw kn("roomState is idle, maybe because you left the room.");const n=new _i(e,r,this._getReconnectTimes(),this.config.requestTimeout,this.userData,this._privileges);n.on("@error",this.handleDisconnect.bind(this)).on("@ws-state-change",(e,t)=>{switch(t){case Si.CONNECTING:this.roomState===pa.Connected?this.roomState=pa.Reconnecting:this.roomState!==pa.Reconnecting&&(this.roomState=pa.Connecting)}}).on("@needupdateaccesstoken",(e,t)=>{this.updateAccessToken().then(e).catch(t)}).on("on-player-in",this.handlePlayerIn.bind(this)).on("on-player-out",this.handlePlayerOut.bind(this)).on("on-add-tracks",e=>{this.filterSignalTracks(e),this.handleAddTracks(e)}).on("on-remove-tracks",e=>{this.filterSignalTracks(e),this.handleRemoveTracks(e)}).on("mute-tracks",e=>{this.filterSignalTracks(e),this.handleMute(e)}).on("on-messages",this.handleCustomMessages.bind(this)).on("on-qos-messages",this.handleQosMessages.bind(this)).on("on-pubpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartRecvICE(e.pcid).catch(jr.debug)}).on("on-sub-profile-changed",e=>{this.emit("on-sub-profile-changed",e)}).on("on-job-connected",e=>{this.emit("forward-job-connected",{jobId:e.id})}).on("on-job-disconnected",e=>{this.emit("forward-job-disconnected",{jobId:e.id})}).on("on-merge-job-connected",e=>{this.emit("merge-job-connected",{jobId:e.id})}).on("on-merge-job-disconnected",e=>{this.emit("merge-job-disconnected",{jobId:e.id})}).on("on-media-relay-state",e=>{const t=e.roomid.slice(e.roomid.indexOf(":")+1);this.emit("media-relay-state-changed",t,e.state)}).on("disconnect",this.handleDisconnect.bind(this)).on("on-player-reconnect",this.handleRemoteUserReconnecting.bind(this)).on("on-player-reconnect-in",this.handleRemoteUserReconnected.bind(this)),jr.log("init signaling websocket"),this.signaling=n;try{let e;e=t.roomServers&&t.roomServers.length>0?t.roomServers.sort((e,t)=>t.score-e.score).map(e=>e.url):[t.signalingurl2];const{ws:r,url:i}=await function(e,t){let r=[],n=!1;return new Promise((i,a)=>{for(const o of e)fa(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:t.url,socket_connect_time:t.connectTime,socket_connect_success:t.status,socket_connect_error_message:t.reason,event_grade:n?An.NORMAL:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:"connect"}),r.length!==e.length||n||a(_n("websocket connect failed."))})})}(e,this.config.requestTimeout),a=await n.initWs(!0,r,i);n.on("@signalingauth",this.handleAuth.bind(this)),await this.handleAuth(a)}catch(e){if(this.signaling&&(this.signaling.release(),this.signaling=void 0),10052===e.code)return await ci(1e3),this.joinRoomWithToken(this.roomToken,this.userData);throw e}for(let e of this.users)e.userID!==this.userID&&this.emit("user-join",e);return this.trackInfoList.length>0&&this.emit("track-add",this.trackInfoList),this.users}async _unpublish(e){if(this.roomState!==pa.Connected)throw kn("not connected to the room");if(0===e.length)return;jr.debug("unpublish",e);const t=this.connectionTransport,r=t.publishTracks.filter(t=>-1!==e.indexOf(t.trackID));if(r.length!==e.length)throw kn("can not find target trackid to unpublish");await t.removeTracks(r),this.getAllMerger().forEach(e=>e.controller.onRemoveTracks(r.map(e=>e.track.info)));const n=ri(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==pa.Connected)throw kn("can not createMergeJob, room state is not connected");const n=t({},G,r,{id:e});jr.debug("send create merge job",n,e);const i=Date.now(),a=await this.signaling.request("create-merge-job",n);if(gn.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw Wn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==pa.Connected)throw kn("can not createForwardJob, room state is not connected");const t=!!e.audioTrackId&&!e.videoTrackId,r=[e.audioTrackId,e.videoTrackId].filter(Boolean).map(e=>({trackid:e})),n={id:e.jobId,publishUrl:e.publishUrl,audioOnly:t,tracks:r};if(e&&e.userConfigExtraInfo){if(i=e.userConfigExtraInfo,!(new Blob([i]).size<=1e3))throw kn("userConfigExtraInfo Up to 1000 Bytes");n.seiTemplate={value:e.userConfigExtraInfo}}var i;const a=Date.now(),o=await this.signaling.request("create-forward-job",n);if(gn.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw zn(o.code,o.error);this.forwardJobTracks[e.jobId]?jr.warning("forward job id already exist",e.jobId):(this.forwardJobTracks[e.jobId]=[],e.audioTrackId&&this.forwardJobTracks[e.jobId].push(e.audioTrackId),e.videoTrackId&&this.forwardJobTracks[e.jobId].push(e.videoTrackId))}async stopForwardJob(e){if(this.roomState!==pa.Connected)throw kn("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw kn(`no forward job id ${e}`);gn.addEvent("StopForwardJob",{id:e||""}),await this.signaling.request("stop-forward",{id:e,delayMillisecond:0}),delete this.forwardJobTracks[e]}setDefaultMergeStream(e,t,r){if(r&&!this.mergeJobTracks[r])throw Ln(r);this.merger&&!r&&(this.merger.release(),this.merger=void 0),r&&this.mergeJobMerger[r]&&(this.mergeJobMerger[r].release(),delete this.mergeJobMerger[r]);const n=this.CreateMergerSessionController();r?this.mergeJobMerger[r]=new Ei(e,t,n,r):this.merger=new Ei(e,t,n,r)}_stopMerge(e){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw Ln(e);gn.addEvent("StopMerge",{id:e||""}),this.signaling.sendWsMsg("stop-merge",{id:e}),e?(delete this.mergeJobTracks[e],this.mergeJobMerger[e]&&(this.mergeJobMerger[e].release(),delete this.mergeJobMerger[e])):(this.defaultMergeJobTracks=[],this.merger&&(this.merger.release(),this.merger=void 0))}async _addMergeTracks(e,t){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,add:r};jr.debug("addMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(gn.addEvent("UpdateMergeTracks",{id:t||"",add:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""})),result_code:i.code}),0!==i.code)throw Jn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r={id:t,remove:e.map(e=>({trackid:e}))};jr.debug("removeMergeTracks",r),M(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(gn.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Jn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,all:r,mode:1};jr.debug("updateMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e)),gn.addEvent("UpdateMergeTracks",{id:t||"",all:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""}))}),await this.signaling.request("update-merge-tracks",n)}async _unsubscribe(e,t){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));if(jr.debug("unsubscribe",r),0===r.length)return;const n=Date.now(),i=await this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))});gn.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e})),result_code:i.code,signal_take_time:Date.now()-n}),t||(r.forEach(e=>e.release()),M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer))}_muteTracks(e){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const t=this.connectionTransport,r={};e.forEach(e=>{r[e.trackID]=e.muted});const n=t.publishTracks.filter(e=>void 0!==r[e.trackID]);n.forEach(e=>{e.setMute(r[e.trackID])}),gn.addEvent("MuteTracks",{tracks:n.map(e=>({track_id:e.trackID,muted:e.track.info.muted,kind:e.track.info.kind}))}),this.signaling.sendWsMsg("mute-tracks",{tracks:e.map(e=>({trackid:e.trackID,muted:e.muted}))})}async kickoutUser(e){jr.log("kickoutUser",e),await this.control("kickplayer",e)}sendCustomMessage(e,t,r){if(this.roomState!==pa.Connected)throw kn("room state is not connected, can not send message");const n=r||si(8),i=t&&0!==t.length?t:void 0;this.signaling.sendWsMsg("send-message",{msgid:n,target:i,type:"normal",text:e}),jr.debug("send custom message",e,i,n)}async replaceTrack(e,t){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("replaceTrack",e,t);const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("pushCameraTrackWithImage",{trackID:e,source:t});const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw kn(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new Gi),void 0===t&&r.track.isReplacedByImageTrack?(await this.connectionTransport.sendHandler.replaceProducerTrack(r,"video"),r.track.isReplacedByImageTrack=!1,void r.track.switchPlayingTrack()):void 0!==t&&r.track&&!r.track.isReplacedByImageTrack?(await r.track.imageStreamTrack.setSource(t),await this.connectionTransport.sendHandler.replaceProducerTrack(r,"image"),r.track.isReplacedByImageTrack=!0,void r.track.switchPlayingTrack()):void 0}leaveRoom(){this.roomState!==pa.Idle?(jr.log("leave room"),gn.addEvent("LeaveRoom",{leave_reason_code:0}),this.signaling&&(Object.keys(this.forwardJobTracks).forEach(e=>this.stopForwardJob(e)),this.signaling.sendDisconnect()),this.releaseRoom()):jr.log("can not leave room, please join room first")}_releasePublishTracks(){}async control(e,t){if(this.roomState!==pa.Connected)throw kn("can not connected to the room, please run joinRoom first");const r=await this.signaling.request("control",{command:e,playerid:t});if(r.error)throw Qn(r.code,r.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),M(this._trackInfo,t=>t.playerid===e.playerid),M(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),ai(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=_o(e);this._users.set(t.userID,t),ai(()=>{jr.debug("user-join",t),this.emit("user-join",t)})}handleAddTracks({tracks:e}){jr.log("receive track-add",e,t({},this._trackInfo));const r=new Set;for(const t of e){const e=ri(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>yo(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([So(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))ai(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});ai(()=>{jr.debug("track-add",e.map(So)),this.emit("track-add",e.map(So))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=M(this._trackInfo,t=>e.map(e=>e.trackid).includes(t.trackid)),n=new Set;for(const e of r){const t=this._users.get(e.playerid);if(!t)continue;t.removePublishedTrackInfo([e.trackid]),t.removeTracksByTrackId([e.trackid]),n.add(t.userID);const r=M(this.subscribeTracks,t=>t.trackID===e.trackid)[0];r&&r.release()}if(this.cleanTrackIdsFromMergeJobs(e.map(e=>e.trackid)),"stream"===this.sessionMode)for(const e of Array.from(n)){const t=this._users.get(e);if(t.published){const e=t.publishedTrackInfo.map(e=>yo(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else ai(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}ai(()=>{jr.debug("track-remove",r.map(So)),this.emit("track-remove",r.map(So))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=ri(this._trackInfo,"trackid",e);if(!n)return;const i=this._users.get(n.playerid);if(!i)return;const a=i.publishedTrackInfo.find(t=>t.trackID===e);a&&(a.muted=r);const o=i.tracks.find(t=>t.info.trackID===e);o&&(o.info.muted=r,o.setMute(r)),n.muted=r;const s=this.subscribeTracks.filter(t=>t.trackID===e)[0];s&&s.setMute(r);let c=void 0;for(let e=0;e{jr.log("user-mute",d),this.emit("user-mute",d)})}ai(()=>{jr.log("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted}))),this.emit("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted})))})}handleCustomMessages({messages:e}){this.emit("messages-received",e.map(bo))}handleQosMessages({messages:e}){const t=[];e.forEach(e=>{try{const r=JSON.parse(e.qos);r.tracks_qos.forEach(n=>{t.push({userID:e.playerid,networkGrade:r.networkGrade,kind:n.kind,trackID:n.track,packetLossRate:n.lostRate,rtt:n.rtt})})}catch(e){jr.warning("parse SignalingQosMessage error: ",e)}}),ha.emit("remote-track-stats",t),this.emit("remote-track-stats",t)}handleDisconnect(e){if(jr.log("handle disconnect",e.code,e),-1===[0,10005,10006].indexOf(e.code)&&gn.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:-1,socket_node_info:this.signaling.url}),gn.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=pa.Reconnecting,void setTimeout(()=>this.signaling.initWs(),1e3);switch(e.code){case 10006:this.emit("disconnect",{code:e.code,data:{userID:e.kickedid}});break;default:this.emit("disconnect",{code:e.code})}this.releaseRoom()}handleRemoteUserReconnecting(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnecting",t),this.emit("remote-user-reconnecting",t))}handleRemoteUserReconnected(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnected",t),this.emit("remote-user-reconnected",t))}async updateAccessToken(){const e=ti(this.roomToken),t=await vi(e,this.roomToken,this.config.requestTimeout);gn.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=ei(t.accessToken);if(!this.signaling)throw kn("room state is idle when updateAccessToken");this.signaling.accessToken=this.accessToken,this.signaling.setUrl(r.signalingurl2)}async handleAuth(e){if(this.filterSignalTracks(e),jr.debug("handleAuth",e),e.error)return void await this.joinRoomWithToken(this.roomToken,this.userData);e.tracks=e.tracks||[],e.tracks=e.tracks.filter(e=>e.playerid!==this.userID),e.players=e.players||[];const t=this.roomState===pa.Reconnecting;let r={join:[],leave:[],add:[],remove:[],mute:[]};const n=Array.from(this._users.keys()),i=e.players.map(e=>e.playerid);if(r=function(e,t,r,n,i){const a={join:[],leave:[],add:[],remove:[],mute:[]},o=t.map(e=>e.trackid),s=r.map(e=>e.trackid);return o.forEach((n,i)=>{if(t[i].playerid!==e)if(-1===s.indexOf(n))a.remove.push(t[i]);else{const e=r.find(e=>e.trackid===n),o=t[i];e.versionid!==o.versionid&&(a.remove.push(o),a.add.push(e))}}),s.forEach((n,i)=>{if(r[i].playerid===e)return;const s=o.indexOf(n);-1===s?(a.add.push(r[i]),a.mute.push({trackid:n,muted:r[i].muted})):r[i].muted!==t[s].muted&&a.mute.push({trackid:n,muted:r[i].muted})}),n.forEach(t=>{t!==e&&-1===i.indexOf(t)&&a.leave.push({playerid:t})}),i.forEach(t=>{t!==e&&-1===n.indexOf(t)&&a.join.push({playerid:t})}),a}(this.userID,this._trackInfo,e.tracks,n,i),this.roomState=pa.Connected,t)jr.debug("get missing events",r),r.remove.length>0&&this.handleRemoveTracks({tracks:r.remove}),r.leave.length>0&&r.leave.forEach(this.handlePlayerOut.bind(this)),r.join.length>0&&r.join.forEach(this.handlePlayerIn.bind(this)),r.add.length>0&&this.handleAddTracks({tracks:r.add}),r.mute.length>0&&this.handleMute({tracks:r.mute});else{this._trackInfo=e.tracks,this._users.clear();for(const t of e.players||[]){const e=_o(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(So)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===B.Connecting);this.connectionTransport.extendedRtpCapabilities=e.rtpcaps,(!this.connectionTransport.sendHandler.isPcReady||this.connectionTransport.sendHandler._isRestartingICE||t.length>0)&&this.connectionTransport.reconnectProducer(),(!this.connectionTransport.recvHandler.isPcReady||this.connectionTransport.recvHandler._isRestartingICE||r.length>0)&&this.connectionTransport.resetRecvHandler()}else this.connectionTransport=this.createConnectionTransport(e.rtpcaps)}createConnectionTransport(e){const t=this.signaling,r=new Aa(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(ko),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(i)}),r.on("@needsubpc",(e,r,n)=>{t.request("subpc",{tracks:e.map(e=>this.profiles.get(e)?{trackid:e,profile:this.profiles.get(e)}:{trackid:e}),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void r(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=B.Connecting),this._subscribe(e,!0)}).on("@needrepub",e=>{this._publish(e.map(e=>e.track),!0)}).on("@needresetrecv",()=>{this.subscribeTracks.filter(e=>!!e.track).forEach(e=>{e.track.removeAllListeners("@ended")})}),r}cleanTrackIdsFromMergeJobs(e){M(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)M(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new wi,t=t=>{e.onAddTracks(t)},r=t=>{e.onRemoveTracks(t)};return this.on("track-add",t),this.on("track-remove",r),e.getCurrentTracks=(()=>{if(!this.connectionTransport)return[];const e=this._trackInfo.map(So),t=this.connectionTransport.publishTracks.map(e=>e.track.info);return e.concat(t)}),e.addMergeTrack=((e,t)=>{this._addMergeTracks(e,t)}),e.release=(()=>{this.off("track-add",t),this.off("track-remove",r)}),e}getAllMerger(){const e=[];this.merger&&e.push(this.merger);for(const t in this.mergeJobMerger)e.push(this.mergeJobMerger[t]);return e}releaseRoom(){this.releaseSession(),this.signaling&&(this.signaling.release(),this.signaling=void 0),gn.addEvent("UnInit",{id:`${this.sessionMode}_${Date.now()}`},!0),this.connectionTransport&&(this.connectionTransport.release(),this.connectionTransport=void 0),this.getAllMerger().map(e=>{e.release()}),this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this.merger=void 0,this.mergeJobMerger={},this.roomState=pa.Idle,this._trackInfo=[],this._users.clear(),this.userID=void 0,this.subscribeTracks.forEach(e=>{e.release()}),this.subscribeTracks=[],this.profile=void 0,this.profiles.clear(),clearInterval(this.volumeIndicatorTimer),this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"]}registerVolumeIndicatorEvent(){clearInterval(this.volumeIndicatorTimer),this.volumeIndicatorTimer=setInterval(()=>{if(!this.connectionTransport)return!1;const e=[...this.subscribedTracks,...this.publishedTracks].filter(e=>"audio"===e.info.kind&&!e.info.muted).map(e=>({trackID:e.info.trackID,userID:e.userID,level:e.getCurrentVolumeLevel()||0,muted:e.info.muted}));if(0===this.volumeIndicatorHistory.length)this.volumeIndicatorHistory.push(e.filter(e=>e.level>=.1));else{const r=this.volumeIndicatorHistory[this.volumeIndicatorHistory.length-1],n={};r.forEach(e=>n[e.trackID]=e.level);const i=[];for(let r of e)r.level>=.1?n[r.trackID]?r.level>n[r.trackID]?i.push(r):i.push(t({},r,{level:n[r.trackID]})):i.push(r):n[r.trackID]&&i.push(t({},r,{level:n[r.trackID]}));this.volumeIndicatorHistory.push(i),4===this.volumeIndicatorHistory.length&&(this.emit("volume-indicator",i.filter(e=>!e.muted).map(e=>({trackID:e.trackID,userID:e.userID,level:e.level}))),this.volumeIndicatorHistory=[])}},500)}async startMediaRelay(e){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("start-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("StartMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("update-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("UpdateMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(gn.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Jn(e.code,e.error);const r=e.status;return Object.keys(r).reduce((e,n)=>t({},e,{[n]:r[n].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}}class va extends ga{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",gn.addEvent("Init",{id:`${this.sessionMode}_${Date.now()}`})}get mergeStreamTracks(){return this.defaultMergeJobTracks}get mergeStreamJobTracks(){return this.mergeJobTracks}async join(e,t){return await this.joinRoomWithToken(e,t)}leave(){this.leaveRoom(),this.isAudioMastered=!1,this.isVideoMastered=!1}async publish(e){const t=this.isAudioMastered,r=this.isVideoMastered;for(const t of e)"audio"===t.info.kind&&(this.isAudioMastered?t.setMaster(!1):(t.setMaster(!0),this.isAudioMastered=!0)),"video"===t.info.kind&&(this.isVideoMastered?t.setMaster(!1):(t.setMaster(!0),this.isVideoMastered=!0));try{return await this._publish(e)}catch(e){throw this.isAudioMastered=t,this.isVideoMastered=r,e}}async unpublish(e){const t=await this._unpublish(e);return this.isAudioMastered=this.publishedTracks.some(e=>!("audio"!==e.info.kind||!e.master)),this.isVideoMastered=this.publishedTracks.some(e=>!("video"!==e.info.kind||!e.master)),t}async subscribe(e,t=!1,r){return await this._subscribe(e,!1,t,r)}async unsubscribe(e){return await this._unsubscribe(e)}setProfile(e,t){this._setProfile(e,t)}setReconnectTimes(e){this._setReconnectTimes(e)}getReconnectTimes(){return this._getReconnectTimes()}muteTracks(e){this._muteTracks(e)}async addMergeStreamTracks(e,t){await this._addMergeTracks(e,t)}async removeMergeStreamTracks(e,t){await this._removeMergeTracks(e,t)}stopMergeStream(e){this._stopMerge(e)}filterSignalTracks(){}releaseSession(){}}class Ta{constructor(e,t){this.networkQuality=tn.UNKNOWN,this._client=e,this._user=t,this.userID=t.userID,this.userData=t.userData}getVideoTracks(){let e=[];for(let t of this._client._remoteTracks)t.isVideo()&&t.userID===this.userID&&e.push(t);return e}getAudioTracks(){let e=[];for(let t of this._client._remoteTracks)t.isAudio()&&t.userID===this.userID&&e.push(t);return e}}class ba extends C{constructor(){super(...arguments),this._isMuted=!1}get mediaElement(){return this._track&&this._track.mediaElement}get track(){return this._track}set track(e){e&&(this._track=e,this._track.on("ended",()=>{ha.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{ha.emit("audioBuffer",t,e.mediaTrack.id)}),this.trackID=this._track.info.trackID,this.userID=this._track.info.userID,this.tag=this._track.info.tag,this._kind=this._track.info.kind,this._isMuted=!!this._track.info.muted)}play(e,t={}){return this._track?"boolean"==typeof t?this._track.play(e,t,{}):this._track.play(e,void 0,t):Promise.reject()}isAudio(){return"audio"===this._kind}isVideo(){return"video"===this._kind}isMuted(){return this._isMuted}getMediaStreamTrack(){return this.track?this.track.mediaTrack:void 0}}class Sa extends ba{constructor(e){super(),this._isSubScribed=!1,this.uplinkStats={uplinkRTT:0,uplinkLostRate:0},this._kind=e.kind,this.trackID=e.trackID,this.userID=e.userID,this.tag=e.tag,ha.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),ha.on("mute-tracks",e=>{for(const t of e)t.trackID===this.trackID&&(this._isMuted=t.muted,this.emit("mute-state-changed",t.muted))})}isSubscribed(){return this._isSubScribed}}class ya extends Sa{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=rn.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),ha.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=rn.HIGH,this.emit("profile-changed",rn.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=rn.MEDIUM,this.emit("profile-changed",rn.MEDIUM);break;case"low":this.profile=rn.LOW,this.emit("profile-changed",rn.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){ha.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw kn("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?rn.LOW:rn.HIGH;ha.emit("set-profile",this.trackID,t)}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){const e={downlinkFrameRate:0,downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkFrameRate=t[0].frameRate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,this.isMultiProfileEnabled&&(e.profile=this.profile),e)}}class ka extends Sa{constructor(e){super(e),ha.on("audioBuffer",(e,t)=>{this._track&&t===this._track.mediaTrack.id&&this.emit("audioFrame",e)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,e)}}class _a extends C{constructor(e){super(),this.connectionState=Ur.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new va({transportPolicy:e}),this.session.on("user-join",e=>{const t=new Ta(this,e);this.remoteUsers.push(t),this.emit("user-joined",e.userID,e.userData)}),this.session.on("user-leave",e=>{this.remoteUsers=this.remoteUsers.filter(t=>t.userID!==e.userID),this.emit("user-left",e.userID)}),this.session.on("track-add",e=>{if(0===e.length)return;const t=e.map(e=>"audio"===e.kind?new ka(e):new ya(e));this._remoteTracks.push(...t);const r=Gr(t,e=>e.userID);Object.entries(r).forEach(([e,t])=>{this.emit("user-published",e,t)})}),this.session.on("track-remove",e=>{if(0===e.length)return;const t=e[0].userID,r=new Set;for(const t of e)r.add(t.trackID);let n=[],i=[];for(const e of this._remoteTracks)r.has(e.trackID)?n.push(e):i.push(e);this._remoteTracks=i,this.emit("user-unpublished",t,n)}),this.session.on("mute-tracks",e=>{0!==e.length&&ha.emit("mute-tracks",e)}),ha.on("set-mute-tracks",(e,t,r)=>{if(r===this.getClientKey())this.session.muteTracks([{trackID:e,muted:t}]);else if(""===r)throw kn("can not setMuted,please publish track first")}),this.session.on("room-state-change",e=>{switch(e){case pa.Idle:this.connectionState=Ur.DISCONNECTED;break;case pa.Connecting:this.connectionState=Ur.CONNECTING;break;case pa.Reconnecting:this.connectionState=Ur.RECONNECTING;break;case pa.Connected:this.connectionState=this.connectionState===Ur.CONNECTING?Ur.CONNECTED:Ur.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===Ur.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=nn.LEAVE;break;case 10006:e=nn.KICKED_OUT;break;default:e=nn.ERROR}let t={reason:e};if(e===nn.ERROR)switch(t.errorCode=this._disconnectedInfo.code,t.errorCode){case 10001:t.errorMessage="token 错误";break;case 10002:t.errorMessage="token 过期";break;case 10004:t.errorMessage="reconnect token 过期";break;case 10007:t.errorMessage="断线重连失败";break;case 10022:t.errorMessage="该用户在其他页面或终端登录";break;case 10011:t.errorMessage="房间人数已满";break;case 10012:t.errorMessage="房间已关闭";break;default:t.errorMessage="unexpected error"}this.release(),this.emit("connection-state-changed",this.connectionState,t)}else this.emit("connection-state-changed",this.connectionState)}),this.session.on("messages-received",e=>{for(let t of e){const e={ID:t.msgid,userID:t.userID,content:t.data,timestamp:t.timestamp};this.emit("message-received",e)}}),this.session.on("media-relay-state-changed",(e,t)=>{this.emit("media-relay-state-changed",e,t)}),this.session.on("remote-user-reconnecting",e=>{this.emit("user-reconnecting",e.userID)}),this.session.on("remote-user-reconnected",e=>{this.emit("user-reconnected",e.userID)}),this.session.on("forward-job-connected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{ha.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),ha.on("remote-track-stats",e=>{for(let t of e){const e=this.remoteUsers.filter(e=>e.userID===t.userID)[0];if(!e)return;switch(t.networkGrade){case x.INVALID:e.networkQuality=tn.UNKNOWN;break;case x.POOR:e.networkQuality=tn.POOR;break;case x.FAIR:e.networkQuality=tn.FAIR;break;case x.GOOD:e.networkQuality=tn.GOOD;break;case x.EXCELLENT:e.networkQuality=tn.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),ha.on("set-profile",(e,t)=>{switch(t){case rn.HIGH:this.session.setProfile(e,"high");break;case rn.MEDIUM:this.session.setProfile(e,"medium");break;case rn.LOW:this.session.setProfile(e,"low")}}),ha.on("setMediaStreamTrack",(e,t,r,n,i)=>{if(r===this.getClientKey())this.session.replaceTrack(e,t).then(n).catch(i);else if(""===r)throw kn("can not setMediaStreamTrack,please publish track first")})}setTransportPolicy(e){this.session.config.transportPolicy=e}get userID(){return this.session.userID}get userData(){return this.session.userData}get roomName(){return this.session.roomName}getRemoteUser(e){return this.remoteUsers.find(t=>t.userID===e)}async setClientMode(e){this.session.setClientMode(e)}async setClientRole(e){await this.session.setClientRole(e)}async join(e,t){await this.session.joinRoomWithToken(e,t)}async leave(){await Promise.resolve().then(()=>this.session.leave()),this.release()}release(){this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[]}async publish(e){if(Array.isArray(e)){e.find(e=>e.isVideo())&&(this.session.simulcast=!!e.filter(e=>e.isVideo()).find(e=>e.isMultiProfileEnabled)),await this.session.publish(e.map(e=>e.track));for(const t of e)t.trackID=t.track.info.trackID,t.userID=this.session.userID,t.client=this.getClientKey();this._localTracks.push(...e)}else e.isVideo()&&e.isMultiProfileEnabled&&(this.session.config.simulcast=!0),await this.session.publish([e.track]),e.trackID=e.track.info.trackID,e.userID=this.session.userID,e.client=this.getClientKey(),this._localTracks.push(e)}getClientKey(){return Nr(`${this.roomName?this.roomName:""}${this.userID?this.userID:""}${this.session.appId?this.session.appId:""}`)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw kn("target tracks has not published");await this.session.unpublish(e.map(e=>e.trackID)),this._localTracks=this._localTracks.filter(t=>!e.includes(t))}else{if(!this._localTracks.includes(e))throw kn("target tracks has not published");await this.session.unpublish([e.trackID]),this._localTracks=this._localTracks.filter(t=>t!==e)}}async subscribe(e){let t;if(Array.isArray(e)){t=await this.session.subscribe(e.map(e=>e.trackID));let r=[],n=[];for(let i of t){const t=e.filter(e=>e.trackID===i.info.trackID);if(0===t.length)continue;const a=t[0];a.track=i,a._isSubScribed=!0,"audio"===i.info.kind?n.push(a):r.push(a)}return{audioTracks:n,videoTracks:r}}if((t=await this.session.subscribe([e.trackID])).length>0){const r=t[0];return e.track=r,e._isSubScribed=!0,"audio"===r.info.kind?{videoTracks:[],audioTracks:[e]}:{audioTracks:[],videoTracks:[e]}}return{audioTracks:[],videoTracks:[]}}async unsubscribe(e){Array.isArray(e)?(await this.session.unsubscribe(e.map(e=>e.trackID)),e.forEach(e=>{e._isSubScribed=!1})):(await this.session.unsubscribe([e.trackID]),e._isSubScribed=!1)}async sendMessage(e,t,r){Array.isArray(r)?await Promise.resolve().then(()=>this.session.sendCustomMessage(t,r.map(e=>e.userID),e)):await Promise.resolve().then(()=>this.session.sendCustomMessage(t,[],e))}async startDirectLiveStreaming(e){await this.session.createForwardJob(ii({userConfigExtraInfo:e.userConfigExtraInfo,jobId:e.streamID,publishUrl:e.url,audioTrackId:e.audioTrack&&e.audioTrack.trackID,videoTrackId:e.videoTrack&&e.videoTrack.trackID}))}async stopDirectLiveStreaming(e){await this.session.stopForwardJob(e)}async startTranscodingLiveStreaming(e){await this.session.createMergeJob(e.streamID,ii({publishUrl:e.url,height:e.height,width:e.width,fps:e.videoFrameRate,kbps:e.bitrate,stretchMode:e.renderMode,watermarks:e.watermarks&&e.watermarks.map(e=>({x:e.x,y:e.y,w:e.width,h:e.height,url:e.url})),background:e.background&&{x:e.background.x,y:e.background.y,w:e.background.width,h:e.background.height,url:e.background.url},maxRate:e.maxBitrate,minRate:e.minBitrate,holdLastFrame:e.holdLastFrame})),e.transcodingTracks&&await this.setTranscodingLiveStreamingTracks(e.streamID,e.transcodingTracks)}async stopTranscodingLiveStreaming(e){await this.session.stopMergeStream(e)}async setTranscodingLiveStreamingTracks(e,t){const r=t.map(e=>ii({trackID:e.trackID,x:e.x,y:e.y,w:e.width,h:e.height,z:e.zOrder,stretchMode:e.renderMode}));e?await this.session.addMergeStreamTracks(r,e):await this.session.addMergeStreamTracks(r)}async removeTranscodingLiveStreamingTracks(e,t){e?await this.session.removeMergeStreamTracks(t.map(e=>e.trackID),e):await this.session.removeMergeStreamTracks(t.map(e=>e.trackID))}getNetworkQuality(){let e=tn.UNKNOWN;const t=this._localTracks.reduce((e,t)=>t.track?[...e,...t.track.getStats().map(e=>e.networkGrade)]:[...e],[]);return t.includes(x.POOR)?e=tn.POOR:t.includes(x.FAIR)?e=tn.FAIR:t.includes(x.GOOD)?e=tn.GOOD:t.includes(x.EXCELLENT)?e=tn.EXCELLENT:e}getUserNetworkQuality(e){let t=tn.UNKNOWN;const r=this.remoteUsers.filter(t=>t.userID===e)[0];return r?t=r.networkQuality:(jr.warning("cannot find userID: ",e),t)}enableAudioVolumeIndicator(){this.session.registerVolumeIndicatorEvent()}async kickOutUser(e){this.remoteUsers.find(t=>t.userID===e)?await this.session.kickoutUser(e):jr.warning("cannot find userID: ",e)}async startMediaRelay(e){return this.session.startMediaRelay(e)}async updateMediaRelay(e){return this.session.updateMediaRelay(e)}async stopMediaRelay(){return this.session.stopMediaRelay()}}class wa extends ba{constructor(e){super(),this.track=e,this.client="",ha.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,ha.emit("set-mute-tracks",this.trackID,e,this.client)}destroy(){this.track&&this.track.release()}}class Ea extends wa{constructor(e){super(e),ha.on("audioBuffer",(t,r)=>{r===e.mediaTrack.id&&this.emit("audioFrame",t)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={uplinkBitrate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.uplinkBitrate=t[0].bitrate,e.uplinkRTT=t[0].rtt,e.uplinkLostRate=t[0].packetLossRate,e)}}class Ca extends wa{constructor(e){super(e),this.isMultiProfileEnabled=!1}getLowStreamConfig(){if(this._track)return this._track.lowStreamConfig}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){if(!this._track)return[];let e=this._track.getStats();if(0===e.length)return[];if(1===e.length){return e.map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}))}{const t=(e=e.filter(e=>0!==e.bitrate).sort((e,t)=>e.bitrate-t.bitrate)).map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}));return t[0]&&(t[0].profile=rn.LOW),t[1]&&(t[1].profile=rn.MEDIUM),t[2]&&(t[2].profile=rn.HIGH),2==t.length&&t[1].profile===rn.MEDIUM&&(t[1].profile=rn.HIGH),t}}setOptimizationMode(e){if(!this._track)return!1;const t=this._track.mediaTrack;return"contentHint"in t&&(t.contentHint=e,t.contentHint===e)}}class Ma extends Ca{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class Pa extends Ui{constructor(e){const t=Ii.createMediaStreamDestination();super(t.stream.getAudioTracks()[0],e,"local"),this.sourceType=L.MIXING,this.initAudioManager(!0),this.destination=t,this.inputList=[]}appendAudioSource(e){this.inputList.find(t=>t.track===e)?jr.warning("track is already in the track list"):(this.inputList.push({track:e}),e.on("ended",()=>{this.emit("ended")}),e.audioManager.gainNode.connect(this.destination))}removeAudioSource(e){const t=this.inputList.find(t=>t.track===e);if(t){try{t.track.audioManager.gainNode.disconnect(this.destination)}catch(e){}M(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class Ia{constructor(e,t){this.effectSourceMap=new Map,this.playback=!0,this.output=e,this.playbackEngine=t}get effectList(){return Array.from(this.effectSourceMap.keys())}getEffectTrack(e){return this.effectSourceMap.get(e)}playEffect(e,t){const r=this.effectSourceMap.get(e);r?(t&&r.setVolume(t),this.playback&&r.audioManager.audioSource&&this.playbackEngine.addAudioNode(r.audioManager.gainNode),r.startAudioSource()):jr.warning("can not find target effect",e)}async addEffectSource(e,t){if(this.effectSourceMap.has(t))return void jr.warning("duplicate effect key!",t);const r=await xa.createAudioTrackFromSource(e);this.effectSourceMap.set(t,r),this.output.appendAudioSource(r)}removeEffectSource(e){let t=[];t=e?[e]:Array.from(this.effectSourceMap.keys());for(const e of t){const t=this.effectSourceMap.get(e);if(!t)return;this.output.removeAudioSource(t),t.release(),this.effectSourceMap.delete(e)}}}class Ra{constructor(){this.gainNode=Ii.createGain(),this.gainNode.connect(Ii.destination)}setPlayingVolume(e){this.gainNode.gain.setValueAtTime(e,Ii.currentTime)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class Da{constructor(e){if(this.playbackEngine=new Ra,this.sourcePlayebackState=!1,!(e instanceof Ui))throw kn("audio mixing manager: origin track is not audio track");this.outputTrack=new Pa,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new Ia(this.outputTrack,this.playbackEngine),this.musicManager=new Ba(this.outputTrack,this.playbackEngine)}getMusicPlaybackState(){return this.musicManager.playback}setMusicPlaybackState(e){this.musicManager.playback!==e&&(this.musicManager.playback=e,this.musicManager.audioNode&&(e?this.playbackEngine.addAudioNode(this.musicManager.audioNode):this.playbackEngine.removeAudioNode(this.musicManager.audioNode)))}getSourcePlaybackState(){return this.sourcePlayebackState}setSourcePlaybackState(e){this.sourcePlayebackState!==e&&(this.sourcePlayebackState=e,this.source.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(this.source.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.source.audioManager.gainNode)))}getEffectPlaybackState(){return this.effectManager.playback}setEffectPlaybackState(e){this.effectManager.playback!==e&&(this.effectManager.playback=e,this.effectManager.effectSourceMap.forEach((t,r)=>{t.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(t.audioManager.gainNode):this.playbackEngine.removeAudioNode(t.audioManager.gainNode))}))}setBitrate(e){this.outputTrack.setInfo({kbps:e})}setTag(e){this.outputTrack.setInfo({tag:e})}release(){this.effectManager.removeEffectSource(),this.musicManager.stopMusicMixing(),this.outputTrack.removeAudioSource(this.source),this.outputTrack.release(),this.playbackEngine.release()}}class Oa extends Da{constructor(e){if(!e._audioTrack)throw kn("input stream do not have audio track");super(e._audioTrack),this.input=e;const t=[this.outputTrack];this.input._videoTrack&&t.push(this.input._videoTrack),this.outputStream=new Bo(t,"send",this.input.userID)}setBitrate(e,t){e&&this.outputStream._audioTrack&&this.outputStream._audioTrack.setKbps(e),t&&this.outputStream._videoTrack&&this.outputStream._videoTrack.setKbps(t)}}var xa;!function(e){async function t(e,t="anonymous",r,n){return new Promise((i,a)=>{const o=document.createElement("audio");o.preload="auto",o.src=e,o.crossOrigin=t,o.addEventListener("error",()=>{a(Fn())});const s=()=>{o.removeEventListener("canplay",s);const e=new xo(o);n&&e.setKbps(n),e.setInfo({tag:r}),i(e)};o.addEventListener("canplay",s)})}function r(e,t,r){return new Promise((n,a)=>{const o=new FileReader;o.onload=(e=>{i(e.target.result).then(e=>{const i=new xo(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(()=>{a(Fn())})}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new xo(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===Ii.state&&await Ii.resume();return await(()=>new Promise((t,r)=>{Ii.decodeAudioData(e,e=>{t(e)},e=>{r(Pn(e))})}))()}e.createAudioTrackFromURL=t,e.createAudioTrackFromFile=r,e.createAudioTrackFromBuffer=n,e.createAudioTrackFromSource=async function(e,i,a){return e instanceof File?await r(e,i,a):e instanceof AudioBuffer?n(e,i,a):"string"==typeof e?await t(e,"anonymous",i,a):Promise.reject(Fn())},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new Da(e)},e.createAudioMixingManagerFromStream=function(e){return new Oa(e)}}(xa||(xa={}));class Ba extends C{constructor(e,t){super(),this.musicOption={loop:!1,volume:1},this.playback=!0,this.output=e,this.playbackEngine=t}get audioNode(){return this.musicTrack?this.musicTrack.audioManager.gainNode:null}setMusicOption(e){this.musicOption=Object.assign(this.musicOption,e),this.musicTrack&&(this.musicTrack.setVolume(this.musicOption.volume),this.musicTrack.setLoop(this.musicOption.loop))}async startMusicMixing(e,t=!1){if(this.musicTrack)return this.stopMusicMixing(t),await this.startMusicMixing(e);try{if(this.musicTrack=await xa.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw kn("can not find audio source");this.playback&&this.audioNode&&this.playbackEngine.addAudioNode(this.audioNode),this.musicTrack.on("audio-state-change",(e,t)=>{this.emit("music-state-change",e,t)}),this.musicTrack.startAudioSource()}catch(e){e instanceof Sn&&this.emit("error",e)}}pauseMusicMixing(){this.musicTrack?this.musicTrack.pauseAudioSource():jr.warning("can not find target music, please run startAudioMixing")}resumeMusicMixing(){this.musicTrack?this.musicTrack.resumeAudioSource():jr.warning("can not find target music, please run startAudioMixing")}stopMusicMixing(e=!1){this.musicTrack&&(this.musicTrack.stopAudioSource(e),this.output.removeAudioSource(this.musicTrack),this.musicTrack.release(),this.musicTrack=void 0)}getMusicDuration(){return this.musicTrack?this.musicTrack.getDuration():0}getMusicCurrentTime(){return this.musicTrack?this.musicTrack.getCurrentTime():0}setMusicCurrentTime(e){if(this.musicTrack&&(this.musicTrack.setCurrentTime(e),!this.musicTrack.audioManager.audioSource))throw kn("can not find audio source")}}class La extends C{constructor(e,t,r){super(),this.mixingTrack=e,this.source=t,this.playbackEngine=r,this.musicVolume=1,this.audioMusicManger=new Ba(this.mixingTrack,this.playbackEngine),this.handleAudioMusicManger()}handleAudioMusicManger(){this.audioMusicManger.on("error",e=>{throw this.emit(La.ERROR,e.code,e.message),e}),this.audioMusicManger.on("music-state-change",e=>{switch(e){case H.IDLE:this.emit(La.STATE_CHANGED,$r.IDLE);break;case H.LOADING:break;case H.PLAY:this.emit(La.STATE_CHANGED,$r.MIXING);break;case H.PAUSE:this.emit(La.STATE_CHANGED,$r.PAUSED);break;case H.END:this.loopCount>1?(--this.loopCount,this._start(this.loopCount,!0)):this.emit(La.STATE_CHANGED,$r.COMPLETED);break;case H.STOP:this.emit(La.STATE_CHANGED,$r.STOPPED)}})}async start(e=1){this._start(e)}stop(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}resume(){this.audioMusicManger.resumeMusicMixing()}pause(){this.audioMusicManger.pauseMusicMixing()}getDuration(){return this.audioMusicManger.getMusicDuration()}getCurrentPosition(){return this.audioMusicManger.getMusicCurrentTime()}seekTo(e){this.audioMusicManger.setMusicCurrentTime(e)}getMixingVolume(){return this.musicVolume}setMixingVolume(e){let t=Number(e);t=isNaN(t)?0:t,this.musicVolume=t,this.audioMusicManger.setMusicOption({volume:this.musicVolume})}release(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}async _start(e=1,t=!1){this.loopCount=Math.max(-1,Number(e)),this.audioMusicManger.setMusicOption({loop:-1===this.loopCount,volume:this.musicVolume}),0!==this.loopCount&&await this.audioMusicManger.startMusicMixing(this.source,t)}}La.STATE_CHANGED="state-changed",La.ERROR="error";class Na extends C{constructor(e,t,r){super(),this.outputTrack=e,this.playbackEngine=t,this.effectID=r,this.playback=!0,this.loopCount=1}getDuration(){return this.getValidateAudioTrack().getDuration()}getID(){return this.effectID}getFilePath(){return this._filePath}setLoopCount(e){this.loopCount=-1===e?Number.MAX_SAFE_INTEGER:Math.max(0,Number(e)),0===this.loopCount&&this.stopEffect()}getLoopCount(){return this.loopCount===Number.MAX_SAFE_INTEGER?-1:this.loopCount}playEffect(e){if(this.loopCount>0){const t=this.getValidateAudioTrack();e&&t.setVolume(e),this.playback&&t.audioManager.audioSource&&this.playbackEngine.addAudioNode(t.audioManager.gainNode),t.startAudioSource()}}stopEffect(){const e=this.getValidateAudioTrack();this.loopCount=1,e.stopAudioSource()}resumeEffect(){this.getValidateAudioTrack().resumeAudioSource()}pauseEffect(){this.getValidateAudioTrack().pauseAudioSource()}getCurrentPosition(){return this.getValidateAudioTrack().getCurrentTime()}async addEffectSource(e){try{this.audioTrack=await xa.createAudioTrackFromSource(e),this._filePath="string"==typeof e?e:URL.createObjectURL(e),this.handleAudioTrack(),this.outputTrack.appendAudioSource(this.audioTrack)}catch(e){e instanceof Sn&&this.emit(Na.ERROR,e)}}removeEffectSource(){void 0!==this.audioTrack&&(this.outputTrack.removeAudioSource(this.audioTrack),this.audioTrack.release(),this.audioTrack=void 0)}getValidateAudioTrack(){if(void 0===this.audioTrack){const e=jn();throw this.emit(Na.ERROR,e),e}return this.audioTrack}handleAudioTrack(){this.audioTrack&&this.audioTrack.on("audio-state-change",e=>{switch(e){case H.END:this.loopCount>1?(this.loopCount=this.loopCount===Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:this.loopCount-1,this.playEffect(this.loopCount)):this.emit(Na.FINISHED)}})}}Na.FINISHED="finished",Na.ERROR="error";class Ga extends C{constructor(e,t){super(),this.mixingTrack=e,this.playbackEngine=t,this.audioEffectMap=new Map,this.startedList=new Map}addListener(e,t){return super.addListener(e,t)}async createAudioEffect(e,t){if(this.audioEffectMap.has(e)){const e=Vn();throw this.emit(Ga.ERROR,e.code,e.message),e}{const r=new Na(this.mixingTrack,this.playbackEngine,e);return this.handleAudioEffect(e,r),await r.addEffectSource(t),this.audioEffectMap.set(e,r),r}}start(e){this.getValidateAudioEffect(e).playEffect(1),this.startedList.set(e,!0)}stop(e){this.getValidateAudioEffect(e).stopEffect()}pause(e){this.getValidateAudioEffect(e).pauseEffect()}resume(e){this.getValidateAudioEffect(e).resumeEffect()}stopAll(){this.audioEffectMap.forEach(e=>{e.stopEffect()})}pauseAll(){this.audioEffectMap.forEach(e=>{e.pauseEffect()})}resumeAll(){this.audioEffectMap.forEach(e=>{e.resumeEffect()})}getCurrentPosition(e){const t=this.getValidateAudioEffect(e);return this.startedList.get(e)?Math.floor(1e3*t.getCurrentPosition()):0}setVolume(e,t){this.getValidateAudioEffect(e).getValidateAudioTrack().setVolume(t)}getVolume(e){return this.getValidateAudioEffect(e).getValidateAudioTrack().getVolume()}setAllEffectsVolume(e){this.audioEffectMap.forEach(t=>{t.getValidateAudioTrack().setVolume(e)})}release(){this.audioEffectMap.forEach(e=>{e.removeEffectSource()}),this.audioEffectMap.clear()}getValidateAudioEffect(e){const t=this.audioEffectMap.get(e);if(void 0===t){const e=Un();throw this.emit(Ga.ERROR,e),e}return t}handleAudioEffect(e,t){t.on(Na.FINISHED,()=>{this.emit(Ga.FINISHED,e)}),t.on(Na.ERROR,e=>{throw this.emit(Ga.ERROR,e.code,e.message),e})}}Ga.FINISHED="finished",Ga.ERROR="error";class Ha extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:case H.STOP:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){this._mixingManager.musicManager.setMusicOption({loop:e}),await this._mixingManager.musicManager.startMusicMixing(this.source)}stop(){this._mixingManager.musicManager.stopMusicMixing()}resume(){this._mixingManager.musicManager.resumeMusicMixing()}pause(){this._mixingManager.musicManager.pauseMusicMixing()}getDuration(){return this._mixingManager.musicManager.getMusicDuration()}getCurrentPosition(){return this._mixingManager.musicManager.getMusicCurrentTime()}seekTo(e){this._mixingManager.musicManager.setMusicCurrentTime(e)}setPlayingVolume(e){this._mixingManager.playbackEngine.setPlayingVolume(e)}setMixingVolume(e,t){this._mixingManager.source.setVolume(e),this._mixingManager.musicManager.setMusicOption({volume:t})}}class Fa extends Ea{constructor(e){const t=new Da(e);super(t.outputTrack),this.sourceTrack=e,this.outputTrack=t.outputTrack,this.mixingManager=t,this.playbackEngine=new Ra,this.earMonitorEnable=!1}createAudioMusicMixer(e){return this.audioMusicMixer&&this.audioMusicMixer.release(),this.audioMusicMixer=new La(this.outputTrack,e,this.playbackEngine),this.audioMusicMixer}createAudioEffectMixer(){return this.audioEffectMixer?this.audioEffectMixer:(this.audioEffectMixer=new Ga(this.outputTrack,this.playbackEngine),this.audioEffectMixer)}isEarMonitorEnabled(){return this.earMonitorEnable}setEarMonitorEnabled(e){this.earMonitorEnable=e,this.earMonitorEnable?this.playbackEngine.addAudioNode(this.sourceTrack.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.sourceTrack.audioManager.gainNode)}setPlayingVolume(e){let t=Number(e);t=isNaN(t)?0:t>1?1:t<0?0:t,this.playbackEngine.setPlayingVolume(t)}destroy(){this.mixingManager.release(),this.audioEffectMixer&&this.audioEffectMixer.release(),this.audioMusicMixer&&this.audioMusicMixer.release(),this.playbackEngine.release(),this.sourceTrack.release()}createAudioMixer(e){return new Ha(this.mixingManager,e)}setVolume(e){this.sourceTrack&&this.sourceTrack.setVolume(e)}}class ja extends Ca{constructor(e){super(e)}}class Va extends Ea{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){e&&this._track.setLoop(e),this._track.startAudioSource()}stop(){this._track.stopAudioSource()}resume(){this._track.resumeAudioSource()}pause(){this._track.pauseAudioSource()}getDuration(){return this._track.getDuration()}getCurrentPosition(){return this._track.getCurrentTime()}seekTo(e){this._track.setCurrentTime(e)}}const Ua="data:audio/mpeg;base64,SUQzAwAAAAAfdlRJVDIAAAALAAAB//6wZY+JMpPzl1RQRTEAAAABAAAAVEFMQgAAAAEAAABUWUVSAAAAAQAAAFRDT04AAAABAAAAVFJDSwAAAAEAAABDT01NAAAAHwAAAGVuZwBvbmxpbmUtYXVkaW8tY29udmVydGVyLmNvbQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/7UMAAAAAAAAAAAAAAAAAAAAAAAEluZm8AAAAPAAAAIQAAG8AADg4OFhYWHh4eJSUlLS0tNDQ0PDw8Q0NDS0tLUlJSWlpaYWFhaWlpcHBweHh4f39/h4eHj4+PlpaWnp6epaWlra2ttLS0vLy8w8PDy8vL0tLS2tra4eHh6enp8PDw+Pj4////AAAAAExhdmM1OC4xMwAAAAAAAAAAAAAAACQGkQAAAAAAABvAI9ArKwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+1DEAAPAAAGkAAAAIAAANIAAAAQgUuQ2C0ggHpVv2yykMn99MBkmlkbANsGRtN/9DKn6+WMLYws4Lh4WxkjxRTCyjBeEm3+nZCzjyFLIzIKSqMgLKkIP1kOAiDKPuoPHEJhZAyGA11lGJAQwQrN4Rbybog81Oo5/HL4hDAzMhfDIORCH6sJWPxCHi7OvCHrs+08SyrYcjCunFEIUcF3h+GRk/0ezsbcciMXCMV+nqHuc7pCyQEknfL87AuS5wm9PnAe5Y7Ggvq5YntSi4JZp//tSxF2BAAABpAAAACEAm9fYYKG5sVGC+JNCz/TxyljU6F40ShUKyWObiUFhgEjStZ2CVnUitUbMqIzyCqxoUKH3NoM9MdurRtIOQGCAUMFCSESeQjFxRAgYXbXJF0nVe9uFo28sYY7vaCij0ID9hSkkXuTJaCDJFz8gUSiyxc8sXPLPuoSix9OQOB8P8UEoLx8INHg3fTIDwaLh4YNPIFEl33fQs/pyKfc+yxe8tkLuDJtK//QaH9/82KCiVSikopLdrY0AnUanBzTSVpS9C97/+1LEmwISLPzKLWHhSkMzXxT0objEkfG4QCz4OIieKEYpLmuJkMtc5uJdtmDor6SYLaLLX0raXraxBc+7cAr3hDL0qGSsCBwGZqypjA4ElVUY7GnEmFjhwPID30wHCGbtHoN0Z2QB0OAoDhALxQAnYOxcBA+YMFMbLwgKWUbl2Ifrr24gYTadbLMVv/+Mq24Gp3l3/h86KJLTckkhrKhq26mLTJpLGV7fiEblMVS/XOw9nrQlCwNYepQTYgRNCkqGmA1BWGYwNiGrgoDxJm5IFv/7UsRngFKU9SesMNqKVSCldaex+CXJcyfnSS9gOg3353q5gGIk2prcmlvRauYXkE9NM7dDYEWxIRGycMUtXE9qcRhJr8C1O0lVxpn0Kp/m6zF/wRLtSXM4z1RlXWHEd1DXzWM+UW8Ph44xqf///9YEMAABKDji+CgJAK7SWrtM+kLV3seiQMQh5uzbyxuDKYFdoAcmgOJZwcmBsFRkU1rTIqfKZIOMefJpi0XnywvZJR7aIsFdUXI0PYFFX46ocVsWQNp3kq67hYrZ1+B9jnnr//tSxDCAkd0fJwywccHgHeXxhhlw0cdooYK+gHjEOABLZZgYoYOoha7T6UpF/cNAmHxceFk3G7tDTxQeftfcUR4yLAGNEAABjLIu8PEIvus6sXZI0l/YEcBYAi5TEtDaViW8tUmhow2InK0p77jhdbeL1T/1lDS5pDRoaD1pMZGvVbCaVUagkijWnZZ96+TGDn23cr1MU+dv4fIbSmumc8DLQPKiAURQKMEpsSjzxxZ/7knKQBPNsT9UTwW5ZEgAAAi6EyEFKkWBDVKYCjOtzNz/+1LECwAMaGM7qLzBwYyP57WGGDCVOsqXUqVdqZlalUTFyum6B6yWHxKtfJ102ZWAmRDKgGKm50SkSRURkXbmJQqXCSwIKYJnAmGHJVFP5Rz7zcAIfFk1KXvpt2GxUQOCIwByRMAAFAlSgpAjMNQ8juOgiKhoYJIHB/jdGqTq0yaTTZenn0fTOdih3rwVkZPSk/GucPt+pjheShUIMHrA4BmQ6ecxGPKokxEtyAYL11Oo4YOAIvsHPAVTxpwg482MiPpbRYoCNuRgAEglOCRk4//7UsQFgAu4bT+sMGVBfRZntYSM+HIk6vqeMSCuSkM5F5bEQlk5Ptzp4h0YiQfCQ4LCAJJ66Ay034GEiBh1I8OIcZNrDJ0CtF40XfZPB4TPaTGXgUoPhuzNH7XhK9yydOvhjHxIQ/e0KuNMkAAAAuICRAlnsIdx2ZI+hATsEgUIiAC0abFoVUl4s+KU8Y1KK7EAxKkZHFLy8g0ZoX2HZdiKzaFS7p/jzo4VFLXt1YCQKFLl9KFoSC6AfcK8pQp3ULnCDeovRY8OT+xIBJpKPFQD//tSxAUACtCpQ6YYbIFUj2h1hgw4gD04ikwjCAIbw/nRingHLMRPNKQhE6uZE36qFjtpR42aCmPJUDGvE/BMa9n/9ijarn7LWG7Vbg6MCSCSn2S8UkXut/rOz56xjvQS0rCft+aIbkklAIkPGBmSx3JSwUD8OXEgoGJXMUUHuqmnVxp0WqTG1SmSj6rUNEuDOFqQYVYiPDTnAk2LixIzzwmDyUCKdCYKhEJD4yhWe3HRFaGAC6xVBXdWh0Uk5ZHMBYyEl5SybRFAgQCMIxAtY4f/+1LEDQAKhGlL56RloSqJZzGEmOBohpRiSG2F4Y7OCKCqEH5Z7UjVAZPgJgu0MFD6Xko0XsCIHsOmRuwydoeKKQONTv3OCCSpGAH2FVDlAlZRogBlsDCAQCfCsLoxxm8qVFBGDo8IxS4UIGygImCZNLcvIYCgbEmHAwdMmhdxAcCRsnoKjknVgIkiKLc9GlPo2hquKP/Wis6lAwAQBrN81FlZbkuy0KgqxigfmZl0DCeBofolpYVFMlFI0HJ2SAtf7Y4bQQXbfBhn6Oc/joGPk//7UsQbgApkeTCssGnBUY2pdPSM5BZITGvPiYYSXI7CRsyzKCVjlrVPOFlp9eBRhTcNr/vY3bpFLjPRI1TiGcuWg3BEGTIlJNCwgaBIFTZvolcQhPAShI4USOykeGVnFICwWHg61MSOmQMqQSWYFH0fTowBBNYmIgFL0bVGTRtdbv/f+n6VBUSZJAASRciGgy5liuXZZgbBq4T/QDlEJzRfXkiMwxN01xqHg5g+7BJpjM+v3yescqw+RuInWTjoiKngfCQo0v+zcxQwyX4+ttMy//tSxCWACfBpO6wwxUFLjGgw9Izs+2j1fuDbkrMAVK5HBzgpCdrRIkAdQcSFhcSNBtyo6imj6JdDFDx8SvYEJYXTiAsCEjhoiLkWS5QctQcLA+/kkD1pSKnBZrQIw4+5AZZenuS8URKQCTLdKg4m2y01KKMZZlzCDGoe7IIsASGhUPjxCgbARPv1kbWJTWOnGbfljF9Ti3bCSDlx2h8SOkyu4RKQPPD2Qw6OC2MbL0oJ4iatyRTloqCDhRL6fSCMAAAK4DLBnFrNdlDgUrjgcbD/+1LEMgAKLHNLh6TFsUyU5qWEjPhMbExcgCpAhIGnL2X51kh0iVQRZQQOuowcUaDmbvclmzMn387nP/fhOQfMJUFFp73K2sEZ2OSy+nLpEazQxbVRal+7tFlBALj2M4ghjEoBCYyAqZLbFw+HFeLWA5JzByKCpyUH/g6RyJ9HXpcNWoKaPNM4i/E5E3bxRD3Pe9hFhMJi9IqbmXFlEP5QEyIq8kU+wKkJkoghJNzAVDwXgkA9ciBE4BbZ2QEikHCtQMSk44haxACDjJ5Z0EEjmP/7UsQ9gAoQs0kmGG5xTwan9MSYmE7jpAw0RrGMdUNFLAEBGaxahOJDJxYFcwUlXeLKYLo72/oIKhTz5BdCag4k6ATJSda8IyHYGTovkg+aA0Z0M8OSgog7CQpDTjiTAw8abfl1o59z3iKVZq+6DxUPKWZ24aYlYuVT2UOqHrJzaVEmLWrV3n9AoKs/ohn/aguuaCU0k3AlKYUkJKFEIjxiSduHBqUg9ogMyXuEb3fNyM92e8OEDqqSRSriAmTYBRDcdNH6sQ1b0Rf0sIVxUBxy//tSxEkACihtPUwwwYE5jmjoww2SFcqgWYzRUazFdyXkP10MAAAAAYnBaB4CxiZq1IljkJIwOE5meE9wQSNhGLRMOZYxEgYi+ngx0h2xAQgXDqllDI99JcVujUNCbCbbLxGUaPFkraoagWPipq5XjdK7P8WN1jjZBRaQSoZy+HwzRk8FD1ImZFsBSbJCNJ7b1E0e6+Jc6gKCVFhgtbJsY6iIiC4xpEs1pgacY87QJyb+9abaKg0GSBUms2HuqjX/w5YJ//1KD5UASmvACU7USp//+1LEVwAKKGU3JhhuwUSM6LT2DDx7Y+CxY0AUTmjALRAthrHJHm/aasmceDjn0BHWOxU2zDHD+qkcQbUFQ4JQ6MNAwLuhNTNs2zEzAWHrD0ImyrDGnIIYQKs2f+4GeV1IoyNFPA8BAD3GYjjuIQ6GKosgGLEiET0Op7Cq5Qo5QoHkxZdokyNsjC77QKWXnP5EQxRwgxzCy2TPq7yB9TRKOzX5U0RU8ZCvXWLybyn3pjXBAGSma+pqEO/OPbQwuC45WnIIZvPCtkXXrojyITkkAv/7UsRjgApgezssJGXBSxMo9MSNFKIzdzlgD2gk2svFxytcWsjvlmhKn1eSZn3q8MwoZki5AIrYePhhwjXAzgG+GD+jt7IAIBR2aMkZI0QDF14mkgBY3rlyYPZeI50Jxj6keGaIj7pUBpWdRClqy6/6dsW3++zDROLlF4gIHR4oJ1kgg2+5sUpz4TjxXvb9c26t5rs31QwEAABBLdMNhCpOXUQXM4TOGsP+9DKHFdtg8ifKunQ1iQRNGMBRUN42jZYVbEGzfYIEDwGA8JpAgxwc//tSxG6CCjitMgykbwE9juaZhhh4nRe7ZadDN4KR5vVPgyWqARjOO/53YiIYW+4PU2PJ4uQmu4J3j/P+Tb/+36/6rWr1zqmve437/sLIQAA2k9ySNBNCHihLSTkHRKHM0OhCNiOPRmH7ZCF5eWvLTJuuuMC3FvQFRKkGyEisiDMK1MQKg5UT/rIblCO1IpX+v55fO+/2lMF/fXX1KNKW90n5eX8i/LTsdooMnT3UgutZNX/iZQQAAAxk2cYkSJaEAEngiYh+4SwKR8HuwyJlDnz/+1LEe4AOSHs3TCTQiaEn56mWDLhsSAlNRIaVYyNm6wThPzA8QQiULALDsPwJlspB6L07ymp9G8ndvclRH69p0OilmBW9D8qpXtBikk6XtILNNfT8uJeLNc0t5zu07wut2Htqm1m7v7xBvx7iJe2fe7Nn7HlBIOvNur62iJ+VL3/lUAEEFQ4azSgXqweuhMaUpW6TET7Q4/jcHbAMcwjV2o1dI1TsZSN6+kFCoVdpx5uI1tlo4vpLpCdvRJ3JQg5eaql/X3NfUxslzvnZI7rW5f/7UsRsAZE9KyjNsNLB5B6lqZeZOPsqTqh1523vbVZub7n7/kzCbmh46qxpqMaoiNHNOjQ0uVfeubvtqjanZ5oeQAIALpnZgH5SIyAEP07HlV1HV4rXgCZXSu2eZIzFOmiWZSvw7tO7rcJ6elMDytrkojMjgtLDeOdJTHLWtYX8Y0WUZvPZ03xsfsqHi2Vkb3SYxsjMN+5spPVUqFUVHJK7K6zB+QjlRl/v3GjQ+6DhYrKdGXX/V1QQONm1K/f+/o2oxngAAMZ2QIIQVNFqjRgA//tSxEiAEH2bLOyYtworIOTJpKLIsBQGJ3l0YGaeylxnIUxZyoSwEv04xetvWGwZLazmMPd5sDmNIWDjFMzdnIEk+BVYmk0H5lg3sH1NJUNFlYOJipQWOmmMujEGQPNWhssKjpaZvMTcaNrnZFB/YbK33jTpYmnJu5izzkyguOQAwOpwwLA0vSmHlCx2ZfS+i7ENAKQAAAfNJ0QbCRbhrfSJQgp4agASxIiXhGSAbow8MLRLDpCP4jIkqlJxZAPE4nJio+484qaaoKtOLx4Ia43/+1LEHwAM7JEvLLBpwdEeJamGGXC18RMGDqjRVQ0OIWKB3aNaRAqybOdYGgk2hDudAKFvARw6K3mqcdou8sAiwAAIRLgYY40NbnADxrUcWWtbo3ebYGJoYCUFxfE9MIJ6uMRxRHRNO9D4kE4sBq+PQ41rFmPcmRLwfbvtwhub5jZLrfkItmuz9rTPrUoykMzC1e3748PW8VU329//ESoYDsFS+7OAwKhdZN5Qm1R18CZLSgIfAACKStFFFmg87S1XMlbjDtA+pQ8tAuWBSYHJOf/7UsQPAAy9JTVMMKnBeh8naYSM6NVw2vHy85fsugSHv/WB6J+CcmY7KIolRrqj95fKdEVSEpc7PF2Zlbd0VHpZagOjNVTLkNOf5nm//EDkxYoDs2ZYKNdCJDyb0A92QCm27sF4RJKNkKu5S8GYLnwIE40jEICEw0goijjkSKDOtMYmUBA49fs4eMUnoZEec7ISy4/9L3K1yhllsuq84+fkR//J+9XChEDixZ+tpoTiqBR4GNET7Ou6jZJ1AU+jUAEiacoBKW4WpMjX60dZxp9G//tSxAqACoxpQ6eYbGFHCebplhjgtPQuwsaobCZzorZNuwyvYGJ+fgg0gQOMDBRBRZgk6w2RjhC0awkSdJ6j7jx1ZIWaUpeWCPohsYLuGvUuz2/9QG7iABJJ0GTwX8DgmE224vUwNCGxTXGqHENJ94l2WQplp/nmiHoJdLDjzwy0XcMIui5MeBFiqrpgqxo9De8mMkNEvHAVFjb2I6iQTSRPExROlqoASWRIBKNuagE4aIl1ToqzQYgRBMjFQwMjEimdDxdz/T7m535NK11OAIX/+1LEFQAKcHs9p7BnwVAM57WEmRAIrENipTmOynjrhcTIDIReAws5AlkB6pfdIk7sfUY1q1MLhpKMZc///rAC2kaATablw2AUUlG1t+GkuLEGuuUBIiKhs0TjjhK5lHJybTu7GKuZJzDy5bMzrMQB4GD9yAA8kxKVi6JlhogtjhVtBs1cfPQWrU07/Mo6Pbo0KqoDvuAGk3LhPxJQWEwlzHZct3yoCgnMuQHyY/YXco39WxS2IcqoxqFYQroj1ShRyoC98bXoyUd3OfaDzK7Wh//7UsQfAEtZAzlMJEfBSomncYYYYJKrWzK/AeyWyvyasoM8/2Iepx0MNezzzluPXlBQBSrNIC8TMAjC/TpiSSBSsQSSqMTVw24WASWBbmqKjqvuvHU7HhE24KklMeNB0+WaIqCgUKbBYSBJoooel6Wza0hIVlgTW1j2W6F1CooLO1/fqXUe37e2FWpuXgkBQWGYEEQvfLhyiN2xqOHFkgwhIzGY/yevZAt3LGsQihk41qRnGIsFRgCTSyhJAgZGrjhbfeHzomeMHNGMFy8Wq3UE//tSxCYACqBvR6YYbSFHieb1lhhgzYCVds9VDfsuAMSZQABJKcoxCZoSnEFnwqIg/iUZJUhcfTgIJAZXkiZUkEr/knjQR6bmjZcSQ2KCxM8RFdFkkf6wAqhhnIqYyXFrXxV7PK2ImDKL3Oo70Cun0AXZG0gE425upMoUwVwgiCwaSyZDE7FrCZWZEtmpmbPkeKvK9IgtBBYVtBZgaKBUVD7hUewpYoJRQWFCqQStTZXoC8te5m9j/wbCYAeMde/J+YFLWa6w7td3CnbIpeYitGb/+1LEMIAKsGE9rDBjgWcOKPT2GKShB5iPC5UOxmvCsilY+VHprIOdOKxp9eHAp1VM8ZXOfaqmhftPThYiRPGRUDBEpPHWnwy4QkzmxMEXnGXiccbCYIHRZCqddkr6e7MbDnrqBebrRILkjm67MlxMBdDuCJ9OQUZ6eDQuWKmF0a+q1gRMOlNi9wZ0iNmLppmeecfiZa8jEYyTKB7Roq6J3n6iosRETJhw1QoGjo0YO/NTq81f1u/qBds0cKLjac4hZCyJSCWLsoDSCzbYNExEHf/7UsQ2gAqAk0GnsGVBTZJotPSM5OOkDs0Uh8O9anh4GckBP7c1wiiWeK6sfkX5+cuJ0CZrjIAWwcfGWYHYXRHIExhVQrV60MH39fp9KqnVAGlAAEoqU2QHYpMKzWF5AYXDqXEhuaD33FwwOOHwsEtZFi2JMckTwyzOUWJjBUOg094PhddDoqLvvSPUHzCrnM/KrQGL5oVUzumnspfW+/vUqZv6ASrAALSUvHeAlnCpDiTBqyiQakICQcHyIgJ0CBdNBjcUQZaGTdzAEd2T86mZ//tSxECACohVN0wwxQGEkCfo9IzooUEU4VwQ4gPhhpQIjhoeCwq1JOTEN9VWt8BgS+9h/tJirxjULUNGqsSBDI4TuQTZUcC/xIoRqlQUk0xBJBQlWzRF8pdIx+LWXC0rLFmuLWqmaBSASd9m1cPDUL+ihaYK1iOUjZSUo+RmpPtnMxamMCoaAQsJZ+7en3GxyUlUZhyf//FYmen2cWcKBCR9lINRyXgGyGQGzpVVkLwBSYgKTZUdiSWwLiGMI0mQQ+nOh930zwfJERkhSQJCNgD/+1LEQ4AKpKtDR7Bo0UwKaDWWGGAEYCD6APOvolzoxDFVQmxzwnQ8mQQYap5P+8PnBx+OCPTVAkV5iTZHL7rfxwq5Wbzbrvq89BCLLrRd1J6mZzKobw9GAUIEC9OM5FDnLDFAzKlTSuBJrqMUHVNhzaur0j3Lgnqxc7fcMurjzSCzVP8O///X77wWpX7ev/8+gBNUuSAEhRxNpRJuQAHhLLDGXQBxAHpVoA4+7xfNdZaIMAF0HkicaRAVgHsHKYIxT8EceOkOdr53pDakdomzjP/7UsRNAAtEcU31gYAqYSbmtzTwAelqwkmxLb1Iui+ZtPHcXcUlagUyvNKFnt9K7owP/qM5qtrfv4M+/77pNeW89Fcssj95PBiVvqurZ3/ExBz/aJRieRKODyTX/+P/X3/pibzb3RUPImPEvALKAGAAAgArwFi3Cif+bImX+lmP+BDZooObSf8DSrgBmw5JEcAQ2Bi0AGfOGJMocCw8DAlgMmKBYE6KSfh6QN1gbuHUAaARb/AwoQckVgAUMFkofXqV/AXDBYEPqAuCCyUG2osh//tSxDGAEoFFELmqAAAAADSDgAAESVSqv4ciFkIqIpEG6oNsS8JtC33//8OSGTAQDCxIL7BjoXyC5ocsR0Hza9f//k+XkkxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+1LERYPAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==";class qa extends Ca{constructor(e,t,r,n){super(e),this.drawImage=(()=>{this.drawImageOnce(),requestAnimationFrame(this.drawImage)}),this.drawImageOnce=(()=>{if(this.ctx)for(const e of this.canvasSources)this.ctx.drawImage(e.source,e.x,e.y,e.width,e.heigth)}),this.canvas=t,this.ctx=r,this.updateSources(n).then(this.drawImage).catch(e=>{jr.warning(e)});const i=new Audio;i.src=Ua,i.autoplay=!0,i.loop=!0,i.muted=!0,i.ontimeupdate=(()=>{this.drawImageOnce()}),this.audioElement=i}async updateSources(e){this.sources=e,this.canvasSources=[];const t=await Promise.all(e.map(e=>Ni.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;rthis.mMax&&(this.mFiltered=this.mMax),this.mLastFilteredTimestamp=Date.now(),this.applied=!0}Filtered(){return this.mFiltered}LastFilteredTime(){return this.mLastFilteredTimestamp}UpdateBase(e){this.mAlpha=e}}function Ja(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Qa(r),e[t])}Qa.kValueUndefined=-1,Qa.AlphaForPacketLossFractionSmoother=.9999,Qa.SMOOTH_VIDEO_INTERVAL=1e3,Qa.SMOOTH_AUDIO_INTERVAL=5e3;const Za=Ja(),$a=Ja(),Ya=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function eo(e,t){let r;r=e>9||t>100?x.POOR:e>5||t>80?x.FAIR:e>1||t>40?x.GOOD:x.EXCELLENT;const n=navigator;return n.connection&&n.connection.effectiveType&&["slow-2g","2g","3g"].includes(n.connection.effectiveType)&&(r=x.POOR),r}const to={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},ro={nack_count:0,fir_count:0,pli_count:0,width:0,height:0,jitter_buffer_delay:0,bytes_sent:0,frame_encoded:0,bytes_received:0,frame_decoded:0},no={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var io,ao,oo;function so(e,t){let r=e||0;const n={chrome:["86.0.4240","87.0.4280"]};return n[b.name]&&n[b.name].includes(b.version)&&t===ao.InBoundRtp?(r=Math.min(e/32767,1),Ka.create({code:Xa.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&Ka.create({code:Xa.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function co(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function uo(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function lo(e,t,r,n){const i=t-e,a=n-r;if(i<=0||a<=0)return 0;const o=i/a;return o>1?1:o}function Ao(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};E.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return E.unifiedPlan&&E.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function ho(e,t,r,n=600){if(r){const i=[{rid:"hi",active:!0,maxBitrate:1e3*n},{rid:"lo",active:!0,maxBitrate:1e3*r.bitrate,scaleResolutionDownBy:r.scaleResolutionDownBy}];return await t.addTransceiver(e,{direction:"sendonly",sendEncodings:i})}return await t.addTransceiver(e,{direction:"sendonly"})}!function(e){e.Video="video",e.Audio="audio"}(io||(io={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(ao||(ao={})),function(e){e.In="in",e.Out="out"}(oo||(oo={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(mo="PermissionDeniedError",po)return po("PermissionDeniedError");throw Nn()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(mo="desktop");"rtcmulticonnection-extension-loaded"===e&&jr.warning("your chrome screen sharing plugin is not the latest version, or you have other screen sharing plugins.");e.sourceId&&po&&po(fo=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let fo,po,mo="screen";async function go(){return await(()=>new Promise((e,t)=>{"desktop"!==mo?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==mo)},2e3)):e(!0)}))()}async function vo(e,t){const r=t.source;return await(()=>new Promise((n,i)=>{const a={mozMediaSource:r||"window",mediaSource:r||"window",height:t.height,width:t.width};if(g)return void n(a);const o={mandatory:{chromeMediaSource:mo,maxWidth:Mo(t.width),maxHeight:Mo(t.height)},optional:[]};"desktop"!==mo?n(o):e?function(e){if(fo)return e(fo);po=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(Nn())}):function(e,t=!1,r=!1){po=e,t?window.postMessage("qnrtc:get-sourceId-screen","*"):r?window.postMessage("qnrtc:get-sourceId-window","*"):window.postMessage("qnrtc:get-sourceId","*")}(function(e){o.mandatory.chromeMediaSourceId=e,"PermissionDeniedError"!==e?n(o):i(Nn())},"screen"===r,"window"===r)}))()}class To{constructor(e,t){this.tracks=[],this.publishedTrackInfo=[],this.userID=e,this.userData=t}get published(){return this.publishedTrackInfo.length>0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=mi(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{M(this.tracks,t=>t===e)})}removeTracksByTrackId(e){M(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=mi(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){M(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function bo(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function So(e){return{trackID:e.trackid,tag:e.tag,mid:e.mid||void 0,kind:e.kind,userID:e.playerid,muted:e.muted,versionid:e.versionid,profiles:e.profiles||[]}}function yo(e,t){return{trackid:e.trackID,mid:e.mid||void 0,kind:e.kind,master:t,muted:!!e.muted,playerid:e.userID,tag:e.tag||"",versionid:e.versionid}}function ko(e){if(!e.info.mid&&E.unifiedPlan)throw kn("can not find track mid!");return{localid:e.mediaTrack.id,localmid:e.info.mid||void 0,master:e.master,kind:e.info.kind,kbps:e.info.kbps,tag:e.info.tag}}function _o(e){return new To(e.playerid,e.playerdata)}function wo(e,t,r){let n;return"audio"===e.kind?(n=new Ui(e)).initAudioManager(!0):n=new Li(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function Eo(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const Co=e=>(function(e){0===Object.keys(e.audio).length&&"boolean"!=typeof e.audio&&(e.audio=!0);0===Object.keys(e.video).length&&"boolean"!=typeof e.video&&(e.video=!0);return e})(function(e){if(E.minMaxWithIdeal)return e;return["video","screen"].forEach(t=>{"object"==typeof e[t]&&"object"==typeof e[t].width&&e[t].width.ideal&&delete e[t].width.ideal,"object"==typeof e[t]&&"object"==typeof e[t].height&&e[t].height.ideal&&delete e[t].height.ideal}),e}(ii(e)));function Mo(e){if(e)return"number"==typeof e?e:e.exact?e.exact:e.max?e.max:e.ideal?e.ideal:e.min?e.min:void 0}const Po="fk6fk2rnb",Io="https://api-demo.qnsdk.com",Ro="/v1",Do=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function Oo(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new va,i=new va,a=await async function(){let e="unknow";try{e=await pn()}catch(e){}return e+"_"+si(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await Go.getLocalTracks({video:{enabled:!0},audio:{enabled:!0}});if(c=f.find(e=>"video"===e.info.kind),s=f.find(e=>"audio"===e.info.kind),void 0===c||void 0===s)throw kn("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Io}${Ro}${Do(e,t,Po)}`;try{let e;if("AbortController"in window){const t=new AbortController;setTimeout(()=>t.abort(),5e3),e=await fetch(r,{signal:t.signal,headers:{"Content-Type":"application/json"}})}else e=await fetch(r,{headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error(e.statusText);return e.text()}catch(e){throw e}})(a,e).then(e=>t.joinRoomWithToken(e)).then(r).catch(n)});await Promise.all([p("userA",n),p("userB",i)]);const m=e=>new Promise((t,r)=>{e.trackInfoList.length>0?e.subscribe(e.trackInfoList.map(e=>e.trackID)).then(t).catch(r):e.on("track-add",n=>{e.subscribe(n.map(e=>e.trackID)).then(t).catch(r)})});await Promise.all([n.publish([c]),i.publish([s]),m(n),m(i)]);const g=[],v=[],T=[],b=[],S=[],y=30;let k=0;await new Promise(e=>{o=setInterval(()=>{const t=n.publishedTracks[0].getStats(),r=i.publishedTracks[0].getStats();t.length>0&&r.length>0&&s&&(g.push(t[0].rtt),v.push(t[0].packetLossRate),T.push(r[0].bitrate),b.push(t[0].bitrate),S.push(s.getCurrentVolumeLevel())),g.length>15&&(clearInterval(o),e()),k>y&&(jr.warning("abnormal track stats: less than 15 valid stats in 30s"),clearInterval(o),e()),k+=1},1e3)}),jr.log(JSON.stringify({detailTestResult:{rtts:g,packetLossRates:v,audioBitrates:T,videoBitrates:b,volumnLevels:S}})),g.length>0&&(d=Math.ceil(g.reduce((e,t)=>e+t,0)/g.length),u=v.reduce((e,t)=>e+t,0)/v.length,l=T.reduce((e,t)=>e+t,0)/T.length,A=b.reduce((e,t)=>e+t,0)/b.length,h=S.reduce((e,t)=>e+t,0)/S.length),t=!0}catch(e){t=!1,r="string"==typeof e?e:e instanceof Sn?JSON.stringify(e):e.message}finally{return n.roomState===pa.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===pa.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),gn.addEvent("SystemRequirementsTest",{room_name:a,ok:t,reason:r,avg_rtt:d,avg_packet_loss_rate:u,avg_volumn_level:h,avg_audio_bitrate:l,avg_video_bitrate:A,test_take_time:Date.now()-e,event_grade:t?An.NORMAL:An.SERVERE},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class xo extends Ui{constructor(e,t){if(!E.mediaStreamDest)throw wn("your browser does not support audio buffer input!");const r=new xi;r.initAudioContext(),e instanceof AudioBuffer?(r.setAudioBufferSource(),r.setAudioBuffer(e)):e instanceof HTMLAudioElement&&r.setMediaElementSource(e),super(r.audioStream.stream.getTracks()[0],t,"local"),this.sourceType=L.EXTERNAL,this.isLoop=!1,this.originSource=e,this.audioManager=r,this.handleAudioManagerEvents()}setLoop(e){this.isLoop=e,this.audioManager.setAudioSourceLoop(e)}startAudioSource(){this.audioManager.playAudioSource()}pauseAudioSource(){this.audioManager.pauseAudioSource()}resumeAudioSource(){this.audioManager.resumeAudioSource()}stopAudioSource(e=!1){this.audioManager.stopAudioSource(!1,e)}getCurrentTime(){return this.audioManager.getAudioSourceCurrentTime()||0}setCurrentTime(e){this.audioManager.setAudioSourceCurrentTime(e)}getDuration(){return this.audioManager.getAudioSourceDuration()||0}handleAudioManagerEvents(){this.audioManager.on("@audio-source-state-change",(e,t)=>{this.emit("audio-state-change",e,t)})}}class Bo extends C{constructor(e,t="send",r){super(),this.trackList=[],this.isDestroyed=!1,this.enableAudio=!0,this.enableVideo=!0,this.muteAudio=!1,this.muteVideo=!1,this.onAudioEnded=(e=>{this.emit("audio-ended",e)}),this.onVideoEnded=(e=>{this.emit("video-ended",e)}),this.onAudioSourceStateChange=((e,t)=>{this.emit("audio-source-state-change",e,t)}),this.direction=t,this.userID=r,e.forEach(e=>{e.setMaster(!0),e.on("mute",()=>{this.updateTrackState()}),e.on("release",()=>{M(this.trackList,t=>t===e),this.updateTrackState(),0===this.trackList.length&&this.release()}),this.trackList.push(e)}),this.updateTrackState()}get audioSourceIsLoop(){return this._audioTrack instanceof xo&&this._audioTrack.isLoop}setVolume(e){this._audioTrack&&this._audioTrack.setVolume(e)}play(e,t){this.trackList.forEach(r=>r.play(e,t)),this._audioTrack&&(this.audio=this._audioTrack.mediaElement),this._videoTrack&&(this.video=this._videoTrack.mediaElement)}getCurrentTimeDomainData(){return this._audioTrack?this._audioTrack.getCurrentTimeDomainData():new Uint8Array(0)}getCurrentFrequencyData(){return this._audioTrack?this._audioTrack.getCurrentFrequencyData():new Uint8Array(0)}getCurrentVolumeLevel(){return this._audioTrack?this._audioTrack.getCurrentVolumeLevel():0}getStats(){let e=Ya();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=Ya();if(this._videoTrack){const e=this._videoTrack.getStats();e.length>0&&(t=e[0])}return{timestamp:Date.now(),videoBitrate:t.bitrate,audioBitrate:e.bitrate,videoPacketLoss:t.packetLoss,audioPacketLoss:e.packetLoss,videoPackets:t.packets,audioPackets:e.packets,videoPacketLossRate:t.packetLossRate,audioPacketLossRate:e.packetLossRate,videoBytes:t.bytes,audioBytes:e.bytes,pctype:this.direction}}getCurrentFrameDataURL(){return this._videoTrack?this._videoTrack.getCurrentFrameDataURL():"data:,"}setAudioSourceLoop(e){this._audioTrack instanceof xo&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof xo?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof xo?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof xo)return this._audioTrack.setCurrentTime(e)}setKbps(e,t){e&&this._videoTrack&&this._videoTrack.setKbps(e),t&&this._audioTrack&&this._audioTrack.setKbps(t)}updateTrackState(){this.trackList.forEach(e=>{"audio"===e.info.kind?(this._audioTrack&&(this._audioTrack.off("ended",this.onAudioEnded),this._audioTrack.off("audio-state-change",this.onAudioSourceStateChange)),this.audioTrack=e.mediaTrack,this._audioTrack=e,this._audioTrack.on("ended",this.onAudioEnded),this._audioTrack instanceof xo&&this._audioTrack.on("audio-state-change",this.onAudioSourceStateChange)):(this._videoTrack&&this._videoTrack.off("ended",this.onVideoEnded),this.videoTrack=e.mediaTrack,this._videoTrack=e,this._videoTrack.on("ended",this.onVideoEnded))}),this.audioTrack?(this.enableAudio=!0,this.muteAudio=!this.audioTrack.enabled):this.enableAudio=!1,this.videoTrack?(this.enableVideo=!0,this.muteVideo=!this.videoTrack.enabled):this.enableVideo=!1}release(){if(!this.isDestroyed){for(let e=0;e"videoinput"===e.kind);case"microphones":return this.deviceInfo.filter(e=>"audioinput"===e.kind);case"playback":return this.deviceInfo.filter(e=>"audiooutput"===e.kind)}}async getElectronScreenSources(e){let t;try{const{ipcRenderer:e}=window.require("electron");t={getSources:t=>e.invoke("QNRTC_DESKTOP_CAPTURER_GET_SOURCES",t)}}catch(e){throw jr.warning(e),Rn(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case cn.ALL:r.types.push("window","screen");break;case cn.SCREEN:r.types.push("screen");break;case cn.WINDOW:r.types.push("window")}try{return(await t.getSources(r)).map(e=>({ID:e.id,name:e.name,url:e.thumbnail.toDataURL()}))}catch(e){throw jr.warning(e),kn(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(!0===e.audio&&(t={audio:{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop"}}}),e.sourceID)t={video:{mandatory:{chromeMediaSourceId:e.sourceID,chromeMediaSource:"desktop"}}};else{const e=await this.getElectronScreenSources();if(0===e.length)return[];t={video:{mandatory:{chromeMediaSourceId:await async function(e){return new Promise((t,r)=>{const n=document.createElement("div");n.setAttribute("style","position: fixed; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);");const i=document.createElement("div");i.setAttribute("style","text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;"),i.innerText="share screen";const a=document.createElement("div");a.setAttribute("style","width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;"),n.appendChild(i),n.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 12%;"),o.innerText="QiNiu Web Screensharing wants to share the contents. Choose what you'd like to share.";const s=document.createElement("div");s.setAttribute("style","width: 100%; height: 80%; background: #FFF; border: solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around; overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");const c=document.createElement("button");c.setAttribute("style","width: 85px;"),c.innerText="cancel",c.onclick=(()=>{document.body.removeChild(n),r(Mn("user cancel selection"))});const d=document.createElement("div");d.setAttribute("style","text-align: right; padding: 16px 0;"),d.appendChild(c),a.appendChild(o),a.appendChild(s),a.appendChild(d);for(const r of e){const e=document.createElement("div");e.setAttribute("style","width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;"),e.onclick=(()=>{document.body.removeChild(n),t(r.ID)});const i=document.createElement("div");i.setAttribute("style","height: 120px; display: table-cell; vertical-align: middle;");const a=document.createElement("img");a.setAttribute("style","width: 100%; background: #333333; box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);"),a.src=r.url,i.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 40px; line-height: 40px; display: inline-block; width: 70%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"),o.innerText=r.name,e.appendChild(i),e.appendChild(o),s.appendChild(e)}document.body.appendChild(n)})}(e),chromeMediaSource:"desktop"}}}}e.width&&(t.video.maxWidth=e.width,t.video.minWidth=e.width),e.height&&(t.video.maxHeight=e.height,t.video.minHeight=e.height);try{jr.log("electron getUserMedia constraints: ",t),r=await navigator.mediaDevices.getUserMedia(t)}catch(e){throw kn(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())"audio"===t.kind?n.push(wo(t,e.audioTag,e.bitrate)):(e.optimizationMode&&No(t,e.optimizationMode),n.push(wo(t,e.tag,e.bitrate)));return n}async getLocalTracks(e=Lo){if(jr.debug("get local tracks",e),R(e)&&I(e)){const t={screen:e.screen},r={video:e.video,audio:e.audio},n=await Promise.all([this.getLocalTracks(t),this.getLocalTracks(r)]);return n[0].concat(n[1])}const t=await async function(e){if(!e)return{audio:!0,video:!0};if(R(e)){if(I(e))throw kn("can not get mediaStream with video and screen are all enabled");if(!E.screenSharing)throw wn("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!E.getDisplayMedia)&&!await go())throw Cn("")}const t=!(!e.audio||!e.audio.enabled||e.audio.source)&&{deviceId:e.audio.deviceId,sampleRate:e.audio.sampleRate,sampleSize:e.audio.sampleSize,channelCount:e.audio.channelCount,autoGainControl:e.audio.autoGainControl,echoCancellation:e.audio.echoCancellation,noiseSuppression:e.audio.noiseSuppression},r=!(!e.video||!e.video.enabled)&&{frameRate:e.video.frameRate,height:e.video.height,width:e.video.width,deviceId:e.video.deviceId,facingMode:e.video.facingMode};if(R(e)&&e.screen){if(E.getDisplayMedia&&!e.screen.forceChromePlugin)return Co({audio:t,video:{displaySurface:Eo(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await vo(!1,e.screen);return Co({audio:t,video:r})}return Co({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&gn.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId,event_grade:An.GENERAL,event_category:hn.VIDEO}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&gn.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId,event_grade:An.GENERAL,event_category:hn.AUDIO});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?Mn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),R(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),I(e)&&(n=e.video.bitrate,a=e.video.tag);const s=r?r.getTracks():[],c=[];for(const t of s){let r;e.video&&e.video.optimizationMode&&(r=e.video.optimizationMode),e.screen&&e.screen.optimizationMode&&(r=e.screen.optimizationMode),r&&No(t,r)}for(const e of s){let t;t="audio"===e.kind?wo(e,o,i):wo(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await xa.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&R(e)&&I(e))throw kn("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new Bo(t,"send")}async getUserMedia(e,r,n=!0){if(jr.debug("request to get user media, config",e),jr.debug("request to get user media, constraints",r),!r.audio&&!r.video)return null;let i;if(R(e))i=await this.getDisplayMedia(r,e);else if(i=await navigator.mediaDevices.getUserMedia(r),!S&&"getSettings"in MediaStreamTrack.prototype&&n){const n=r.video;if(n&&"boolean"!=typeof n){const a=n.width,o=n.height;if("number"==typeof a&&"number"==typeof o){const s=i.getVideoTracks(),c=s&&s[0],{height:d=o,width:u=a}=c.getSettings();if(u&&d){const s=(o-d)*(a-u);if(s*s>10){const s=o/a;return d/ue.stop()),this.getUserMedia(e,t({},r,{video:n}),!1)}}}}}return i}async getDisplayMedia(e,t){let r,n;e.audio&&(r=await navigator.mediaDevices.getUserMedia({audio:e.audio}));const i=t.screen&&t.screen.audio&&!e.audio?{video:e.video,audio:t.screen.audio}:{video:e.video};return n=E.getDisplayMedia&&t.screen&&!t.screen.forceChromePlugin?await navigator.mediaDevices.getDisplayMedia(i):await navigator.mediaDevices.getUserMedia(i),r&&n.addTrack(r.getAudioTracks()[0]),n}async updateDeivceInfo(){this.deviceInfo=await navigator.mediaDevices.enumerateDevices();const e=this.deviceInfo.map(e=>e.deviceId),t=Object.keys(this.deviceMap);let r=!1;t.forEach(t=>{if(-1===e.indexOf(t)&&"@default"!==t){this.emit("device-remove",this.deviceMap[t].device);const e=this.deviceMap[t].device;this.emit("device-changed",{device:e,state:qr.INACTIVE});const n="audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",i="AudioDeviceInOut"===n?hn.AUDIO:hn.VIDEO;gn.addEvent(n,{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label,event_grade:An.GENERAL,event_category:i}),delete this.deviceMap[t],r=!0}else this.deviceMap[t].tick+=1}),e.forEach((e,n)=>{if(-1===t.indexOf(e)&&"@default"!==e){this.deviceMap[e]={device:this.deviceInfo[n],tick:0};const t=this.deviceMap[e].device;this.emit("device-changed",{device:t,state:qr.ACTIVE}),this.emit("device-add",t);const i="audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",a="AudioDeviceInOut"===i?hn.AUDIO:hn.VIDEO;gn.addEvent(i,{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId,event_grade:An.GENERAL,event_category:a}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class Ho{static get VERSION(){return Hr}static isBrowserSupported(){return E.support}static async checkSystemRequirements(){return await Oo()}static setLogLevel(e){switch(e){case an.VERBOSE:jr.setLevel("log");break;case an.INFO:jr.setLevel("debug");break;case an.WARNING:case an.ERROR:jr.setLevel("warning");break;case an.NONE:jr.setLevel("disable")}}static async isChromeExtensionAvailable(){return await go()}static createClient(){const e=new _a(this._transportPolicy);return Ho._clients.push(e),e}static async getCameras(e=!1){return Go.getDeviceInfo(e,"cameras")}static async getMicrophones(e=!1){return Go.getDeviceInfo(e,"microphones")}static async getPlaybackDevices(e=!1){return Go.getDeviceInfo(e,"playback")}static async getDevices(e=!1){return Go.getDeviceInfo(e,"all")}static async createCameraVideoTrack(e){let r;if(jr.log("createCameraVideoTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Wr[e.encoderConfig]))throw Hn()}else r=t({},zr,e.encoderConfig);else r=zr;const n=(await Go.getLocalTracks({video:ii({enabled:!0,width:r.width,height:r.height,frameRate:r.frameRate,bitrate:r.bitrate,tag:e&&e.tag,facingMode:e&&e.facingMode,optimizationMode:e&&e.optimizationMode,deviceId:e&&e.cameraId})}))[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(n.lowStreamConfig=e.encoderConfig.lowStreamConfig);const i=new Ma(n);return void 0!==r.isMultiProfileEnabled&&(i.isMultiProfileEnabled=r.isMultiProfileEnabled),jr.log("createCameraVideoTrack end",i),i}static async createMicrophoneAudioTrack(e){let r;if(jr.log("createMicrophoneAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag})}),i=new Fa(n[0]);return jr.log("createMicrophoneAudioTrack end",i),i}static async createScreenVideoTrack(e,r){let n;if(jr.log("createScreenVideoTrack start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Qr[e.encoderConfig]))throw Hn()}else n=t({},Jr,e.encoderConfig);else n=Jr;let i=[];if(y)i=await Go.createElectronScreenTrack(ii({sourceID:e&&e.electronScreenSourceID,screenBitrate:n.bitrate,width:n.width,height:n.height,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag}));else{let a=ii({enabled:!0,width:n.width,height:n.height,bitrate:n.bitrate,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag});if(e&&e.chromeExtensionSourceType)switch(e.chromeExtensionSourceType){case Zr.ALL:a=t({},a,{forceChromePlugin:!0});break;case Zr.SCREEN:case Zr.WINDOW:a=t({},a,{forceChromePlugin:!0,source:e.chromeExtensionSourceType})}i=await Go.getLocalTracks({screen:a})}if(1===i.length&&"video"===i[0].info.kind&&"enable"===r)throw i[0].release(),In();if(1===i.length&&"video"===i[0].info.kind){const t=i[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(t.lowStreamConfig=e.encoderConfig.lowStreamConfig);const r=new ja(t);return void 0!==n.isMultiProfileEnabled&&(r.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",r),r}{const t=i.filter(e=>"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw kn(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new Ea(t),o=new ja(r);return void 0!==n.isMultiProfileEnabled&&(o.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",[o,a]),[o,a]}}static async createMicrophoneAndCameraTracks(e,r){let n,i;if(jr.log("createMicrophoneAndCameraTracks start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Xr[e.encoderConfig]))throw Hn()}else n=t({},Kr,e.encoderConfig);else n=Kr;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=Wr[r.encoderConfig]))throw Hn()}else i=t({},zr,r.encoderConfig);else i=zr;const a=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:n.bitrate,sampleRate:n.sampleRate,sampleSize:n.sampleSize,channelCount:n.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag}),video:ii({enabled:!0,width:i.width,height:i.height,frameRate:i.frameRate,bitrate:i.bitrate,tag:r&&r.tag,facingMode:r&&r.facingMode,deviceId:r&&r.cameraId})}),o=a.filter(e=>"audio"===e.info.kind)[0],s=a.filter(e=>"video"===e.info.kind)[0];if(!o||!s)throw kn(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new Fa(o),d=new Ma(s);return void 0!==i.isMultiProfileEnabled&&(d.isMultiProfileEnabled=i.isMultiProfileEnabled),jr.log("createMicrophoneAndCameraTracks end",[c,d]),[c,d]}static async createBufferSourceAudioTrack(e){let r;if(jr.log("createBufferSourceAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,source:e.source,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,tag:e&&e.tag})}),i=new Va(n[0],e.source);return jr.log("createBufferSourceAudioTrack end",i),i}static createCanvasVideoTrack(e){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");if(null===r)throw wn("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw wn("capture stream error, canvas track not supported");n=t.mozCaptureStream(15)}const i=n.getTracks()[0];e.optimizationMode&&"contentHint"in i&&(i.contentHint=e.optimizationMode);const a=wo(i,e.tag);return new qa(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=wo(e.mediaStreamTrack,e.tag,e.bitrate);return new Wa(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=wo(e.mediaStreamTrack,e.tag,e.bitrate);return new za(t)}static setTransportPolicy(e){e===on.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===on.FORCE_UDP&&(this._transportPolicy="forceUdp"),this._clients.forEach(e=>e.setTransportPolicy(this._transportPolicy))}static async checkAudioTrackIsActive(e,t=5e3){const r=Math.min(200,t);return new Promise((t,n)=>{if(e.isAudio()){const n=.01,i=200;let a=e.getVolumeLevel()||0,o=e.getVolumeLevel()||0,s=o<=n,c=!0;if(e.isMuted())t(!1);else{const d=setInterval(()=>{e.isMuted()?(t(!1),clearInterval(d)):(a=o,(o=e.getVolumeLevel()||0)>n&&(s=!1),o!==a&&(c=!1))},i);setTimeout(()=>setTimeout(()=>{d&&(clearInterval(d),t(!s&&!c))},0),r)}}else n(kn("only support audio track"))})}static async checkVideoTrackIsActive(e,t=5e3){return new Promise((r,n)=>{if(e.isVideo()){const i=e.getMediaStreamTrack();if(e.isMuted()&&r(!1),void 0===i)n(kn("cannot find mediaStreamTrack"));else{const a=document.createElement("video");a.style.width="1px",a.style.height="1px",a.setAttribute("muted",""),a.muted=!0,a.setAttribute("playsinline",""),a.controls=!1,a.style.opacity="0.01",a.style.position="fixed",a.style.left="0",a.style.top="0",document.body.appendChild(a),a.srcObject=new MediaStream([i]),a.play();const o=document.createElement("canvas");o.width=160,o.height=120;const s=o.getContext("2d");if(s){let n=!1,i=null;const c=setInterval(()=>{e.isMuted()&&(c&&(clearInterval(c),r(!1)),a&&a.remove()),s.drawImage(a,0,0,160,120);const t=s.getImageData(0,0,o.width,o.height);var d=Math.floor(t.data.length/3);if(i){for(let e=0;e{setTimeout(()=>{c&&(clearInterval(c),r(n)),a&&a.remove()},0)},t)}else n(kn("can not get canvas 2d context"))}}else n(kn("only support video track"))})}static async getElectronScreenSources(e){return Go.getElectronScreenSources(e)}}return Ho._clients=[],Ho._transportPolicy="preferUdp",Go.on("device-changed",e=>{switch(e.device.kind){case"audioinput":Ho.onMicrophoneChanged&&Ho.onMicrophoneChanged(e);break;case"audiooutput":Ho.onPlaybackDeviceChanged&&Ho.onPlaybackDeviceChanged(e);break;case"videoinput":Ho.onCameraChanged&&Ho.onCameraChanged(e)}}),Ho}); diff --git a/Demo/package.json b/Demo/package.json index 3dcef9d..98e1e83 100644 --- a/Demo/package.json +++ b/Demo/package.json @@ -1,6 +1,6 @@ { "name": "multiple-track-demo", - "version": "4.1.8", + "version": "4.1.9", "private": true, "description": "multiple track demo", "author": "Yao Zhi ", @@ -33,7 +33,7 @@ "mobx": "^5.8.0", "mobx-react": "^5.4.3", "mobx-react-router": "^4.0.5", - "qnweb-rtc": "^4.1.8", + "qnweb-rtc": "^4.1.9", "qs": "^6.6.0", "react": "^16.8.0", "react-app-polyfill": "^0.2.0", diff --git a/Release/qnweb-rtc.js b/Release/qnweb-rtc.js index f53faaf..c597972 100644 --- a/Release/qnweb-rtc.js +++ b/Release/qnweb-rtc.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).QNRTC=t()}(this,function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};var t=function(t){for(var r=1;r)?=?)";var _=s++;o[_]=o[d]+"|x|X|\\*";var w=s++;o[w]=o[c]+"|x|X|\\*";var E=s++;o[E]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var C=s++;o[C]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var I=s++;o[I]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var R=s++;o[R]="(?:~>?)";var D=s++;o[D]="(\\s*)"+o[R]+"\\s+",a[D]=new RegExp(o[D],"g");var O=s++;o[O]="^"+o[R]+o[E]+"$";var x=s++;o[x]="^"+o[R]+o[C]+"$";var B=s++;o[B]="(?:\\^)";var L=s++;o[L]="(\\s*)"+o[B]+"\\s+",a[L]=new RegExp(o[L],"g");var G=s++;o[G]="^"+o[B]+o[E]+"$";var N=s++;o[N]="^"+o[B]+o[C]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var F=s++;o[F]="^"+o[k]+"\\s*("+b+")$|^$";var j=s++;o[j]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[E]+")",a[j]=new RegExp(o[j],"g");var V=s++;o[V]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="(<|>)?=?\\s*\\*";for(var W=0;W<35;W++)r(W,o[W]),a[W]||(a[W]=new RegExp(o[W]));function z(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X)return e;if("string"!=typeof e)return null;if(e.length>n)return null;if(!(t.loose?a[y]:a[T]).test(e))return null;try{return new X(e,t)}catch(e){return null}}function X(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>n)throw new TypeError("version is longer than "+n+" characters");if(!(this instanceof X))return new X(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var o=e.trim().match(t.loose?a[y]:a[T]);if(!o)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+o[1],this.minor=+o[2],this.patch=+o[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");o[4]?this.prerelease=o[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new X(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(Y(e,t))return null;var r=z(e),n=z(t);if(r.prerelease.length||n.prerelease.length){for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return"pre"+i;return"prerelease"}for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return i},t.compareIdentifiers=Q;var K=/^[0-9]+$/;function Q(e,t){var r=K.test(e),n=K.test(t);return r&&n&&(e=+e,t=+t),r&&!n?-1:n&&!r?1:et?1:0}function J(e,t,r){return new X(e,r).compare(new X(t,r))}function Z(e,t,r){return J(e,t,r)>0}function $(e,t,r){return J(e,t,r)<0}function Y(e,t,r){return 0===J(e,t,r)}function ee(e,t,r){return 0!==J(e,t,r)}function te(e,t,r){return J(e,t,r)>=0}function re(e,t,r){return J(e,t,r)<=0}function ne(e,t,r,n){var i;switch(t){case"===":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e===r;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e!==r;break;case"":case"=":case"==":i=Y(e,r,n);break;case"!=":i=ee(e,r,n);break;case">":i=Z(e,r,n);break;case">=":i=te(e,r,n);break;case"<":i=$(e,r,n);break;case"<=":i=re(e,r,n);break;default:throw new TypeError("Invalid operator: "+t)}return i}function ie(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ie){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ie))return new ie(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ae?this.value="":this.value=this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){return Q(t,e)},t.major=function(e,t){return new X(e,t).major},t.minor=function(e,t){return new X(e,t).minor},t.patch=function(e,t){return new X(e,t).patch},t.compare=J,t.compareLoose=function(e,t){return J(e,t,!0)},t.rcompare=function(e,t,r){return J(t,e,r)},t.sort=function(e,r){return e.sort(function(e,n){return t.compare(e,n,r)})},t.rsort=function(e,r){return e.sort(function(e,n){return t.rcompare(e,n,r)})},t.gt=Z,t.lt=$,t.eq=Y,t.neq=ee,t.gte=te,t.lte=re,t.cmp=ne,t.Comparator=ie;var ae={};function oe(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof oe)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new oe(e.raw,t);if(e instanceof ie)return new oe(e.value,t);if(!(this instanceof oe))return new oe(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function se(e){return!e||"x"===e.toLowerCase()||"*"===e}function ce(e,t,r,n,i,a,o,s,c,d,u,l,A){return((t=se(r)?"":se(n)?">="+r+".0.0":se(i)?">="+r+"."+n+".0":">="+t)+" "+(s=se(c)?"":se(d)?"<"+(+c+1)+".0.0":se(u)?"<"+c+"."+(+d+1)+".0":l?"<="+c+"."+d+"."+u+"-"+l:"<="+s)).trim()}function de(e,t,n){for(var i=0;i0){var a=e[i].semver;if(a.major===t.major&&a.minor===t.minor&&a.patch===t.patch)return!0}return!1}return!0}function ue(e,t,r){try{t=new oe(t,r)}catch(e){return!1}return t.test(e)}function le(e,t,r,n){var i,a,o,s,c;switch(e=new X(e,n),t=new oe(t,n),r){case">":i=Z,a=re,o=$,s=">",c=">=";break;case"<":i=$,a=te,o=Z,s="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ue(e,t,n))return!1;for(var d=0;d=0.0.0")),l=l||e,A=A||e,i(e.semver,l.semver,n)?l=e:o(e.semver,A.semver,n)&&(A=e)}),l.operator===s||l.operator===c)return!1;if((!A.operator||A.operator===s)&&a(e,A.semver))return!1;if(A.operator===c&&o(e,A.semver))return!1}return!0}ie.prototype.parse=function(e){var t=this.options.loose?a[H]:a[F],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new X(r[2],this.options.loose):this.semver=ae},ie.prototype.toString=function(){return this.value},ie.prototype.test=function(e){return r("Comparator.test",e,this.options.loose),this.semver===ae||("string"==typeof e&&(e=new X(e,this.options)),ne(e,this.operator,this.semver,this.options))},ie.prototype.intersects=function(e,t){if(!(e instanceof ie))throw new TypeError("a Comparator is required");var r;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return r=new oe(e.value,t),ue(this.value,r,t);if(""===e.operator)return r=new oe(this.value,t),ue(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),a=this.semver.version===e.semver.version,o=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),s=ne(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),c=ne(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||a&&o||s||c},t.Range=oe,oe.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},oe.prototype.toString=function(){return this.range},oe.prototype.parseRange=function(e){var t=this.options.loose;e=e.trim();var n=t?a[U]:a[V];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[j],"$1$2$3"),r("comparator trim",e,a[j]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[F],o=e.split(" ").map(function(e){return function(e,t){return r("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){r("caret",e,t),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[N]:a[G];return e.replace(n,function(t,n,i,a,o){var s;return r("caret",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s="0"===n?">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":">="+n+"."+i+".0 <"+(+n+1)+".0.0":o?(r("replaceCaret pr",o),"-"!==o.charAt(0)&&(o="-"+o),s="0"===n?"0"===i?">="+n+"."+i+"."+a+o+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+o+" <"+(+n+1)+".0.0"):(r("no pr"),s="0"===n?"0"===i?">="+n+"."+i+"."+a+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+" <"+(+n+1)+".0.0"),r("caret return",s),s})}(e,t)}).join(" ")}(e,t),r("caret",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[x]:a[O];return e.replace(n,function(t,n,i,a,o){var s;return r("tilde",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":o?(r("replaceTilde pr",o),"-"!==o.charAt(0)&&(o="-"+o),s=">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0"):s=">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0",r("tilde return",s),s})}(e,t)}).join(" ")}(e,t),r("tildes",e),e=function(e,t){return r("replaceXRanges",e,t),e.split(/\s+/).map(function(e){return function(e,t){e=e.trim(),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[P]:a[M];return e.replace(n,function(t,n,i,a,o,s){r("xRange",e,t,n,i,a,o,s);var c=se(i),d=c||se(a),u=d||se(o),l=u;return"="===n&&l&&(n=""),c?t=">"===n||"<"===n?"<0.0.0":"*":n&&l?(d&&(a=0),u&&(o=0),">"===n?(n=">=",d?(i=+i+1,a=0,o=0):u&&(a=+a+1,o=0)):"<="===n&&(n="<",d?i=+i+1:a=+a+1),t=n+i+"."+a+"."+o):d?t=">="+i+".0.0 <"+(+i+1)+".0.0":u&&(t=">="+i+"."+a+".0 <"+i+"."+(+a+1)+".0"),r("xRange return",t),t})}(e,t)}).join(" ")}(e,t),r("xrange",e),e=function(e,t){return r("replaceStars",e,t),e.trim().replace(a[q],"")}(e,t),r("stars",e),e}(e,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(o=o.filter(function(e){return!!e.match(i)})),o=o.map(function(e){return new ie(e,this.options)},this)},oe.prototype.intersects=function(e,t){if(!(e instanceof oe))throw new TypeError("a Range is required");return this.set.some(function(r){return r.every(function(r){return e.set.some(function(e){return e.every(function(e){return r.intersects(e,t)})})})})},t.toComparators=function(e,t){return new oe(e,t).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},oe.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new X(e,this.options));for(var t=0;t",r)},t.outside=le,t.prerelease=function(e,t){var r=z(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new oe(e,r),t=new oe(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof X)return e;if("string"!=typeof e)return null;var t=e.match(a[I]);return null==t?null:z((t[1]||"0")+"."+(t[2]||"0")+"."+(t[3]||"0"))}}),A=(l.SEMVER_SPEC_VERSION,l.re,l.src,l.parse,l.valid,l.clean,l.SemVer,l.inc,l.diff,l.compareIdentifiers,l.rcompareIdentifiers,l.major,l.minor,l.patch,l.compare,l.compareLoose,l.rcompare,l.sort,l.rsort,l.gt),h=l.lt,f=(l.eq,l.neq,l.gte),p=l.lte,m=(l.cmp,l.Comparator,l.Range,l.toComparators,l.satisfies,l.maxSatisfying,l.minSatisfying,l.validRange,l.ltr,l.gtr,l.outside,l.prerelease,l.intersects,l.coerce,u(function(e){(function(t){if(e.exports)return function(t){e.exports=t()};if("undefined"!=typeof window)return function(e){window.MobileDetect=e()};throw new Error("unknown environment")})()(function(){var e,t={mobileDetectRules:{phones:{iPhone:"\\biPhone\\b|\\biPod\\b",BlackBerry:"BlackBerry|\\bBB10\\b|rim[0-9]+|\\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\\b-[0-9]+",Pixel:"; \\bPixel\\b",HTC:"HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel",Nexus:"Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 5X|Nexus 6",Dell:"Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b",Motorola:"Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b|XT1068|XT1092|XT1052",Samsung:"\\bSamsung\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F|SM-G610F|SM-G981B|SM-G892A|SM-A530F",LG:"\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710",Sony:"SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533|SOV34|601SO|F8332",Asus:"Asus.*Galaxy|PadFone.*Mobile",Xiaomi:"^(?!.*\\bx11\\b).*xiaomi.*$|POCOPHONE F1|MI 8|Redmi Note 9S|Redmi Note 5A Prime|N2G47H|M2001J2G|M2001J2I|M1805E10A|M2004J11G|M1902F1G|M2002J9G|M2004J19G|M2003J6A1G",NokiaLumia:"Lumia [0-9]{3,4}",Micromax:"Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b",Palm:"PalmSource|Palm",Vertu:"Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature",Pantech:"PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790",Fly:"IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250",Wiko:"KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM",iMobile:"i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)",SimValley:"\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b",Wolfgang:"AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q",Alcatel:"Alcatel",Nintendo:"Nintendo (3DS|Switch)",Amoi:"Amoi",INQ:"INQ",OnePlus:"ONEPLUS",GenericPhone:"Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser"},tablets:{iPad:"iPad|iPad.*Mobile",NexusTablet:"Android.*Nexus[\\s]+(7|9|10)",GoogleTablet:"Android.*Pixel C",SamsungTablet:"SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V|SM-P610|SM-T290|SM-T515|SM-T590|SM-T595|SM-T725|SM-T817P|SM-P585N0|SM-T395|SM-T295|SM-T865|SM-P610N|SM-P615|SM-T970|SM-T380|SM-T5950|SM-T905|SM-T231|SM-T500|SM-T860",Kindle:"Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)",SurfaceTablet:"Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)",HPTablet:"HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10",AsusTablet:"^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\bP027\\b|\\bP024\\b|\\bP00C\\b",BlackBerryTablet:"PlayBook|RIM Tablet",HTCtablet:"HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410",MotorolaTablet:"xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617",NookTablet:"Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2",AcerTablet:"Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20\\b|\\bA3-A30|A3-A40",ToshibaTablet:"Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO",LGTablet:"\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b",FujitsuTablet:"Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b",PrestigioTablet:"PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002",LenovoTablet:"Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X|TB-X704F|TB-X104F|TB3-X70F|TB-X705F|TB-8504F|TB3-X70L|TB3-710F|TB-X704L",DellTablet:"Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7",YarvikTablet:"Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b",MedionTablet:"Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB",ArnovaTablet:"97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2",IntensoTablet:"INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004",IRUTablet:"M702pro",MegafonTablet:"MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b",EbodaTablet:"E-Boda (Supreme|Impresspeed|Izzycomm|Essential)",AllViewTablet:"Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)",ArchosTablet:"\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b",AinolTablet:"NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark",NokiaLumiaTablet:"Lumia 2520",SonyTablet:"Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712",PhilipsTablet:"\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b",CubeTablet:"Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT",CobyTablet:"MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010",MIDTablet:"M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10",MSITablet:"MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b",SMiTTablet:"Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)",RockChipTablet:"Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A",FlyTablet:"IQ310|Fly Vision",bqTablet:"Android.*(bq)?.*\\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\\b|Maxwell.*Lite|Maxwell.*Plus",HuaweiTablet:"MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19",NecTablet:"\\bN-06D|\\bN-08D",PantechTablet:"Pantech.*P4100",BronchoTablet:"Broncho.*(N701|N708|N802|a710)",VersusTablet:"TOUCHPAD.*[78910]|\\bTOUCHTAB\\b",ZyncTablet:"z1000|Z99 2G|z930|z990|z909|Z919|z900",PositivoTablet:"TB07STA|TB10STA|TB07FTA|TB10FTA",NabiTablet:"Android.*\\bNabi",KoboTablet:"Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build",DanewTablet:"DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b",TexetTablet:"NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE",PlaystationTablet:"Playstation.*(Portable|Vita)",TrekstorTablet:"ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab",PyleAudioTablet:"\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b",AdvanTablet:"Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ",DanyTechTablet:"Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1",GalapadTablet:"Android [0-9.]+; [a-z-]+; \\bG1\\b",MicromaxTablet:"Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b",KarbonnTablet:"Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b",AllFineTablet:"Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide",PROSCANTablet:"\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b",YONESTablet:"BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026",ChangJiaTablet:"TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503",GUTablet:"TX-A1301|TX-M9002|Q702|kf026",PointOfViewTablet:"TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10",OvermaxTablet:"OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027",HCLTablet:"HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync",DPSTablet:"DPS Dream 9|DPS Dual 7",VistureTablet:"V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10",CrestaTablet:"CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989",MediatekTablet:"\\bMT8125|MT8389|MT8135|MT8377\\b",ConcordeTablet:"Concorde([ ]+)?Tab|ConCorde ReadMan",GoCleverTablet:"GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042",ModecomTablet:"FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003",VoninoTablet:"\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b",ECSTablet:"V07OT2|TM105A|S10OT1|TR10CS1",StorexTablet:"eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab",VodafoneTablet:"SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400",EssentielBTablet:"Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2",RossMoorTablet:"RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711",iMobileTablet:"i-mobile i-note",TolinoTablet:"tolino tab [0-9.]+|tolino shine",AudioSonicTablet:"\\bC-22Q|T7-QC|T-17B|T-17P\\b",AMPETablet:"Android.* A78 ",SkkTablet:"Android.* (SKYPAD|PHOENIX|CYCLOPS)",TecnoTablet:"TECNO P9|TECNO DP8D",JXDTablet:"Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b",iJoyTablet:"Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)",FX2Tablet:"FX2 PAD7|FX2 PAD10",XoroTablet:"KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151",ViewsonicTablet:"ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a",VerizonTablet:"QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1",OdysTablet:"LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10",CaptivaTablet:"CAPTIVA PAD",IconbitTablet:"NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S",TeclastTablet:"T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi",OndaTablet:"\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+|V10 \\b4G\\b",JaytechTablet:"TPC-PA762",BlaupunktTablet:"Endeavour 800NG|Endeavour 1010",DigmaTablet:"\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b",EvolioTablet:"ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b",LavaTablet:"QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b",AocTablet:"MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712",MpmanTablet:"MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010",CelkonTablet:"CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b",WolderTablet:"miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b",MediacomTablet:"M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA",MiTablet:"\\bMI PAD\\b|\\bHM NOTE 1W\\b",NibiruTablet:"Nibiru M1|Nibiru Jupiter One",NexoTablet:"NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI",LeaderTablet:"TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100",UbislateTablet:"UbiSlate[\\s]?7C",PocketBookTablet:"Pocketbook",KocasoTablet:"\\b(TB-1207)\\b",HisenseTablet:"\\b(F5281|E2371)\\b",Hudl:"Hudl HT7S3|Hudl 2",TelstraTablet:"T-Hub2",GenericTablet:"Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bTP750\\b|\\bQTAQZ3\\b|WVT101|TM1088|KT107"},oss:{AndroidOS:"Android",BlackBerryOS:"blackberry|\\bBB10\\b|rim tablet os",PalmOS:"PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino",SymbianOS:"Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b",WindowsMobileOS:"Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;",WindowsPhoneOS:"Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;",iOS:"\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia",iPadOS:"CPU OS 13",SailfishOS:"Sailfish",MeeGoOS:"MeeGo",MaemoOS:"Maemo",JavaOS:"J2ME/|\\bMIDP\\b|\\bCLDC\\b",webOS:"webOS|hpwOS",badaOS:"\\bBada\\b",BREWOS:"BREW"},uas:{Chrome:"\\bCrMo\\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?",Dolfin:"\\bDolfin\\b",Opera:"Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+$|Coast/[0-9.]+",Skyfire:"Skyfire",Edge:"\\bEdgiOS\\b|Mobile Safari/[.0-9]* Edge",IE:"IEMobile|MSIEMobile",Firefox:"fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS",Bolt:"bolt",TeaShark:"teashark",Blazer:"Blazer",Safari:"Version((?!\\bEdgiOS\\b).)*Mobile.*Safari|Safari.*Mobile|MobileSafari",WeChat:"\\bMicroMessenger\\b",UCBrowser:"UC.*Browser|UCWEB",baiduboxapp:"baiduboxapp",baidubrowser:"baidubrowser",DiigoBrowser:"DiigoBrowser",Mercury:"\\bMercury\\b",ObigoBrowser:"Obigo",NetFront:"NF-Browser",GenericBrowser:"NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger",PaleMoon:"Android.*PaleMoon|Mobile.*PaleMoon"},props:{Mobile:"Mobile/[VER]",Build:"Build/[VER]",Version:"Version/[VER]",VendorID:"VendorID/[VER]",iPad:"iPad.*CPU[a-z ]+[VER]",iPhone:"iPhone.*CPU[a-z ]+[VER]",iPod:"iPod.*CPU[a-z ]+[VER]",Kindle:"Kindle/[VER]",Chrome:["Chrome/[VER]","CriOS/[VER]","CrMo/[VER]"],Coast:["Coast/[VER]"],Dolfin:"Dolfin/[VER]",Firefox:["Firefox/[VER]","FxiOS/[VER]"],Fennec:"Fennec/[VER]",Edge:"Edge/[VER]",IE:["IEMobile/[VER];","IEMobile [VER]","MSIE [VER];","Trident/[0-9.]+;.*rv:[VER]"],NetFront:"NetFront/[VER]",NokiaBrowser:"NokiaBrowser/[VER]",Opera:[" OPR/[VER]","Opera Mini/[VER]","Version/[VER]"],"Opera Mini":"Opera Mini/[VER]","Opera Mobi":"Version/[VER]",UCBrowser:["UCWEB[VER]","UC.*Browser/[VER]"],MQQBrowser:"MQQBrowser/[VER]",MicroMessenger:"MicroMessenger/[VER]",baiduboxapp:"baiduboxapp/[VER]",baidubrowser:"baidubrowser/[VER]",SamsungBrowser:"SamsungBrowser/[VER]",Iron:"Iron/[VER]",Safari:["Version/[VER]","Safari/[VER]"],Skyfire:"Skyfire/[VER]",Tizen:"Tizen/[VER]",Webkit:"webkit[ /][VER]",PaleMoon:"PaleMoon/[VER]",SailfishBrowser:"SailfishBrowser/[VER]",Gecko:"Gecko/[VER]",Trident:"Trident/[VER]",Presto:"Presto/[VER]",Goanna:"Goanna/[VER]",iOS:" \\bi?OS\\b [VER][ ;]{1}",Android:"Android [VER]",Sailfish:"Sailfish [VER]",BlackBerry:["BlackBerry[\\w]+/[VER]","BlackBerry.*Version/[VER]","Version/[VER]"],BREW:"BREW [VER]",Java:"Java/[VER]","Windows Phone OS":["Windows Phone OS [VER]","Windows Phone [VER]"],"Windows Phone":"Windows Phone [VER]","Windows CE":"Windows CE/[VER]","Windows NT":"Windows NT [VER]",Symbian:["SymbianOS/[VER]","Symbian/[VER]"],webOS:["webOS/[VER]","hpwOS/[VER];"]},utils:{Bot:"Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp|AspiegelBot",MobileBot:"Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2",DesktopMode:"WPDesktop",TV:"SonyDTV|HbbTV",WebKit:"(webkit)[ /]([\\w.]+)",Console:"\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\\b",Watch:"SM-V700"}},detectMobileBrowsers:{fullPattern:/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i,shortPattern:/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,tabletPattern:/android|ipad|playbook|silk/i}},r=Object.prototype.hasOwnProperty;function n(e,t){return null!=e&&null!=t&&e.toLowerCase()===t.toLowerCase()}function i(e,t){var r,n,i=e.length;if(!i||!t)return!1;for(r=t.toLowerCase(),n=0;n=0&&(o=o.substring(0,d)+"([\\w._\\+]+)"+o.substring(d+5)),i[s]=new RegExp(o,"i");u.props[n]=i}a(u.oss),a(u.phones),a(u.tablets),a(u.uas),a(u.utils),u.oss0={WindowsPhoneOS:u.oss.WindowsPhoneOS,WindowsMobileOS:u.oss.WindowsMobileOS}}(),t.findMatch=function(e,t){for(var n in e)if(r.call(e,n)&&e[n].test(t))return n;return null},t.findMatches=function(e,t){var n=[];for(var i in e)r.call(e,i)&&e[i].test(t)&&n.push(i);return n},t.getVersionStr=function(e,n){var i,a,o,s,c=t.mobileDetectRules.props;if(r.call(c,e))for(o=(i=c[e]).length,a=0;a1&&(e=t[0]+".",t.shift(),e+=t.join("")),Number(e)},t.isMobileFallback=function(e){return t.detectMobileBrowsers.fullPattern.test(e)||t.detectMobileBrowsers.shortPattern.test(e.substr(0,4))},t.isTabletFallback=function(e){return t.detectMobileBrowsers.tabletPattern.test(e)},t.prepareDetectionCache=function(e,r,n){if(void 0===e.mobile){var i,a,s;if(a=t.findMatch(t.mobileDetectRules.tablets,r))return e.mobile=e.tablet=a,void(e.phone=null);if(i=t.findMatch(t.mobileDetectRules.phones,r))return e.mobile=e.phone=i,void(e.tablet=null);t.isMobileFallback(r)?void 0===(s=o.isPhoneSized(n))?(e.mobile=t.FALLBACK_MOBILE,e.tablet=e.phone=null):s?(e.mobile=e.phone=t.FALLBACK_PHONE,e.tablet=null):(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):t.isTabletFallback(r)?(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):e.mobile=e.tablet=e.phone=null}},t.mobileGrade=function(e){var t=null!==e.mobile();return e.os("iOS")&&e.version("iPad")>=4.3||e.os("iOS")&&e.version("iPhone")>=3.1||e.os("iOS")&&e.version("iPod")>=3.1||e.version("Android")>2.1&&e.is("Webkit")||e.version("Windows Phone OS")>=7||e.is("BlackBerry")&&e.version("BlackBerry")>=6||e.match("Playbook.*Tablet")||e.version("webOS")>=1.4&&e.match("Palm|Pre|Pixi")||e.match("hp.*TouchPad")||e.is("Firefox")&&e.version("Firefox")>=12||e.is("Chrome")&&e.is("AndroidOS")&&e.version("Android")>=4||e.is("Skyfire")&&e.version("Skyfire")>=4.1&&e.is("AndroidOS")&&e.version("Android")>=2.3||e.is("Opera")&&e.version("Opera Mobi")>11&&e.is("AndroidOS")||e.is("MeeGoOS")||e.is("Tizen")||e.is("Dolfin")&&e.version("Bada")>=2||(e.is("UC Browser")||e.is("Dolfin"))&&e.version("Android")>=2.3||e.match("Kindle Fire")||e.is("Kindle")&&e.version("Kindle")>=3||e.is("AndroidOS")&&e.is("NookTablet")||e.version("Chrome")>=11&&!t||e.version("Safari")>=5&&!t||e.version("Firefox")>=4&&!t||e.version("MSIE")>=7&&!t||e.version("Opera")>=10&&!t?"A":e.os("iOS")&&e.version("iPad")<4.3||e.os("iOS")&&e.version("iPhone")<3.1||e.os("iOS")&&e.version("iPod")<3.1||e.is("Blackberry")&&e.version("BlackBerry")>=5&&e.version("BlackBerry")<6||e.version("Opera Mini")>=5&&e.version("Opera Mini")<=6.5&&(e.version("Android")>=2.3||e.is("iOS"))||e.match("NokiaN8|NokiaC7|N97.*Series60|Symbian/3")||e.version("Opera Mobi")>=11&&e.is("SymbianOS")?"B":(e.version("BlackBerry")<5||e.match("MSIEMobile|Windows CE.*Mobile")||e.version("Windows Mobile"),"C")},t.detectOS=function(e){return t.findMatch(t.mobileDetectRules.oss0,e)||t.findMatch(t.mobileDetectRules.oss,e)},t.getDeviceSmallerSide=function(){return window.screen.width-1,v=!!window.chrome,T=navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i),b=function(){const e=s();if(!navigator||!navigator.appVersion||!e)return e;const r=/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/.exec(window.navigator.appVersion);return r&&r[1]?t({},e,{chromeVersion:r[1]}):e}()||{},S=!!new m(navigator.userAgent).mobile(),y=navigator.userAgent.toLowerCase().indexOf("electron")>-1;function k(){try{return!!window&&("RTCPeerConnection"in window&&("WebSocket"in window&&(!!navigator&&(!!navigator.mediaDevices&&!!navigator.mediaDevices.getUserMedia))))}catch(e){return!1}}function _(){const e=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia,t=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getSupportedConstraints&&navigator.mediaDevices.getSupportedConstraints().displaySurface;return g?!!e&&!!t:!!e}function w(){return"createMediaStreamDestination"in(window.AudioContext||window.webkitAudioContext||window.Object).prototype}const E=function(){if(!b)return{support:k(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0};switch(b.name){case"chrome":return{support:k(),mediaStreamDest:f(b.version,"55.0.0"),replaceTrack:f(b.version,"65.0.0"),screenSharing:f(b.version,"55.0.0"),connectionState:f(b.version,"72.0.0"),stats:f(b.version,"67.0.0"),ondevicechange:f(b.version,"57.0.0"),minMaxWithIdeal:f(b.version,"56.0.0"),supportTransceivers:f(b.version,"69.0.0"),unifiedPlan:f(b.version,"72.0.0"),supportRestartICE:!0,getReceivers:f(b.version,"59.0.0"),needH264FmtpLine:p(b.version,"51.0.0"),audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!0,setPlaybackDevice:!0};case"ios":case"safari":return{support:k(),replaceTrack:f(b.version,"11.0.0"),stats:!1,ondevicechange:!1,connectionState:!0,mediaStreamDest:f(b.version,"12.0.0"),screenSharing:f(b.version,"13.0.0"),unifiedPlan:f(b.version,"12.1.0"),supportTransceivers:!0,minMaxWithIdeal:!1,supportRestartICE:!0,getReceivers:!0,audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!1};case"firefox":return{support:k(),replaceTrack:!0,stats:!0,ondevicechange:f(b.version,"52.0.0"),connectionState:!0,mediaStreamDest:!0,screenSharing:!0,minMaxWithIdeal:!0,unifiedPlan:!0,supportTransceivers:f(b.version,"59.0.0"),supportRestartICE:!1,getReceivers:!0,audioContextOptions:f(b.version,"55.0.0"),getDisplayMedia:_(),disconnectAudioNode:!0};case"crios":case"ios-webview":return{support:k(),getDisplayMedia:_(),mediaStreamDest:w(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),mediaStreamDest:w(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0}}}();"chrome"===b.name&&function(){const e=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),(e={})[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(e){return new Promise((t,r)=>{navigator.getUserMedia(e,t,r)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:t,enumerateDevices:()=>new Promise(e=>{const t={audio:"audioinput",video:"videoinput"};return window.MediaStreamTrack.getSources(r=>{e(r.map(e=>({label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""})))})})}),navigator.mediaDevices.getSupportedConstraints||(navigator.mediaDevices.getSupportedConstraints=(()=>({deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}))),navigator.mediaDevices.getUserMedia){const t=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(r){return function(t,r){if(A(b.version,"61.0.0"))return r(t);if((t=JSON.parse(JSON.stringify(t)))&&"object"==typeof t.audio){const r=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};r((t=JSON.parse(JSON.stringify(t))).audio,"autoGainControl","googAutoGainControl"),r(t.audio,"noiseSuppression","googNoiseSuppression"),t.audio=e(t.audio)}if(t&&"object"==typeof t.video){let n=t.video.facingMode;n=n&&("object"==typeof n?n:{ideal:n});const i=h(b.version,"66.0.0");if(n&&("user"===n.exact||"environment"===n.exact||"user"===n.ideal||"environment"===n.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode||i)){delete t.video.facingMode;let i=void 0;if("environment"===n.exact||"environment"===n.ideal?i=["back","rear"]:"user"!==n.exact&&"user"!==n.ideal||(i=["front"]),i)return navigator.mediaDevices.enumerateDevices().then(a=>{let o=(a=a.filter(e=>"videoinput"===e.kind)).find(e=>i.some(t=>e.label.toLowerCase().includes(t)));return!o&&a.length&&i.includes("back")&&(o=a[a.length-1]),o&&(t.video.deviceId=n.exact?{exact:o.deviceId}:{ideal:o.deviceId}),t.video=e(t.video),r(t)})}t.video=e(t.video)}return r(t)}(r,e=>t(e).then(t=>{if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return t},e=>Promise.reject(e)))}}else navigator.mediaDevices.getUserMedia=function(e){return t(e)}}(),"firefox"===b.name&&function(){const e=function(e){return new Promise((t,r)=>{!function(e,t,r){e=JSON.parse(JSON.stringify(e)),navigator.mozGetUserMedia(e,t,e=>{r(e)})}(e,t,r)})};navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:e,addEventListener(){},removeEventListener(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise(e=>{e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})}}();var C=u(function(e){!function(t){function r(){}var n=r.prototype,i=t.EventEmitter;function a(e,t){for(var r=e.length;r--;)if(e[r].listener===t)return r;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}n.getListeners=function(e){var t,r,n=this._getEvents();if(e instanceof RegExp)for(r in t={},n)n.hasOwnProperty(r)&&e.test(r)&&(t[r]=n[r]);else t=n[e]||(n[e]=[]);return t},n.flattenListeners=function(e){var t,r=[];for(t=0;td))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ee:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Pe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},we.prototype.clear=function(){this.__data__={hash:new ke,map:new(ue||_e),string:new ke}},we.prototype.delete=function(e){return Ne(this,e).delete(e)},we.prototype.get=function(e){return Ne(this,e).get(e)},we.prototype.has=function(e){return Ne(this,e).has(e)},we.prototype.set=function(e,t){return Ne(this,e).set(e,t),this},Ee.prototype.add=Ee.prototype.push=function(e){return this.__data__.set(e,i),this},Ee.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.clear=function(){this.__data__=new _e},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var n=this.__data__;if(n instanceof _e){var i=n.__data__;if(!ue||i.length-1&&e%1==0&&ei?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var a=Array(i);++n-1&&e%1==0&&e<=d}function nt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function it(e){return!!e&&"object"==typeof e}function at(e){return"symbol"==typeof e||it(e)&&re.call(e)==k}var ot=j?function(e){return function(t){return e(t)}}(j):function(e){return it(e)&&rt(e.length)&&!!O[re.call(e)]};function st(e){return et(e)?Me(e):Be(e)}function ct(e){return e}e.exports=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],a=e.length;for(t=xe(t);++n!!e&&!!e.audio&&e.audio.enabled,I=e=>!!e&&!!e.video&&e.video.enabled,R=e=>!!e&&!!e.screen&&e.screen.enabled;var D,O,x,B,L;function G(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(D||(D={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(O||(O={})),function(e){e[e.INVALID=-1]="INVALID",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.FAIR=3]="FAIR",e[e.POOR=4]="POOR"}(x||(x={})),function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connect=2]="Connect"}(B||(B={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(L||(L={}));const N={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var H;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.STOP="stop",e.END="end"}(H||(H={}));const F={Init:1,UnInit:2,JoinRoom:3,MCSAuth:4,SignalAuth:5,LeaveRoom:6,PublisherPC:7,PublishTracks:8,UnPublishTracks:9,SubscriberPC:10,SubscribeTracks:11,UnSubscribeTracks:13,MuteTracks:14,ICEConnectionState:15,CallbackStatistics:16,KickoutUser:17,RoomStateChanged:18,AudioDeviceInOut:19,VideoDeviceInOut:20,SDKError:21,ApplicationState:22,CreateMergeJob:24,UpdateMergeTracks:25,StopMerge:26,AuthorizationStatus:27,DeviceChanged:28,DefaultSetting:29,MediaStatistics:30,AbnormalDisconnect:31,CreateForwardJob:36,StopForwardJob:37,WebsocketConnect:40,NetworkChange:46,SystemRequirementsTest:47,AutoplayFail:49,TrackEnded:50,WebSDKException:51,VideoPlayQuality:53,AudioPlayQuality:54,JoinRoomResult:55,SetClientRole:56,StartMediaRelay:57,UpdateMediaRelay:58,StopMediaRelay:59,MCURelayAuth:60};var j=u(function(e){var t,r;t=c,r=function(){var e=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},t=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},r=function(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])},n=function(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=t(e,[4283543511,3981806797]),e=i(e,[0,e[0]>>>1]),e=t(e,[3301882366,444984403]),e=i(e,[0,e[0]>>>1])},o=function(o,s){s=s||0;for(var c=(o=o||"").length%16,d=o.length-c,u=[0,s],l=[0,s],A=[0,0],h=[0,0],f=[2277735313,289559509],p=[1291169091,658871167],m=0;m>>0).toString(16)).slice(-8)+("00000000"+(u[1]>>>0).toString(16)).slice(-8)+("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)},s={preprocessor:null,audio:{timeout:1e3,excludeIOS11:!0},fonts:{swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",userDefinedFonts:[],extendedJsFonts:!1},screen:{detectScreenOrientation:!0},plugins:{sortPluginsFor:[/palemoon/i],excludeIE:!1},extraComponents:[],excludes:{enumerateDevices:!0,pixelRatio:!0,doNotTrack:!0,fontsFlash:!0},NOT_AVAILABLE:"not available",ERROR:"error",EXCLUDED:"excluded"},c=function(e,t){if(Array.prototype.forEach&&e.forEach===Array.prototype.forEach)e.forEach(t);else if(e.length===+e.length)for(var r=0,n=e.length;rt.name?1:e.name=0?"Windows Phone":t.indexOf("win")>=0?"Windows":t.indexOf("android")>=0?"Android":t.indexOf("linux")>=0?"Linux":t.indexOf("iphone")>=0||t.indexOf("ipad")>=0?"iOS":t.indexOf("mac")>=0?"Mac":"Other",("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)&&"Windows Phone"!==e&&"Android"!==e&&"iOS"!==e&&"Other"!==e)return!0;if(void 0!==r){if((r=r.toLowerCase()).indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e)return!0;if(r.indexOf("linux")>=0&&"Linux"!==e&&"Android"!==e)return!0;if(r.indexOf("mac")>=0&&"Mac"!==e&&"iOS"!==e)return!0;if((-1===r.indexOf("win")&&-1===r.indexOf("linux")&&-1===r.indexOf("mac"))!=("Other"===e))return!0}return n.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e||((n.indexOf("linux")>=0||n.indexOf("android")>=0||n.indexOf("pike")>=0)&&"Linux"!==e&&"Android"!==e||((n.indexOf("mac")>=0||n.indexOf("ipad")>=0||n.indexOf("ipod")>=0||n.indexOf("iphone")>=0)&&"Mac"!==e&&"iOS"!==e||((-1===n.indexOf("win")&&-1===n.indexOf("linux")&&-1===n.indexOf("mac"))!=("Other"===e)||void 0===navigator.plugins&&"Windows"!==e&&"Windows Phone"!==e)))},R=function(){var e,t=navigator.userAgent.toLowerCase(),r=navigator.productSub;if(("Chrome"===(e=t.indexOf("firefox")>=0?"Firefox":t.indexOf("opera")>=0||t.indexOf("opr")>=0?"Opera":t.indexOf("chrome")>=0?"Chrome":t.indexOf("safari")>=0?"Safari":t.indexOf("trident")>=0?"Internet Explorer":"Other")||"Safari"===e||"Opera"===e)&&"20030107"!==r)return!0;var n,i=eval.toString().length;if(37===i&&"Safari"!==e&&"Firefox"!==e&&"Other"!==e)return!0;if(39===i&&"Internet Explorer"!==e&&"Other"!==e)return!0;if(33===i&&"Chrome"!==e&&"Opera"!==e&&"Other"!==e)return!0;try{throw"a"}catch(e){try{e.toSource(),n=!0}catch(e){n=!1}}return n&&"Firefox"!==e&&"Other"!==e},D=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},O=function(){if(!D())return!1;var e=N();return!!window.WebGLRenderingContext&&!!e},x=function(){return"Microsoft Internet Explorer"===navigator.appName||!("Netscape"!==navigator.appName||!/Trident/.test(navigator.userAgent))},B=function(){return void 0!==window.swfobject},L=function(){return window.swfobject.hasFlashPlayerVersion("9.0.0")},G=function(e,t){window.___fp_swf_loaded=function(t){e(t)};var r=t.fonts.swfContainerId;!function(e){var t=document.createElement("div");t.setAttribute("id",e.fonts.swfContainerId),document.body.appendChild(t)}();var n={onReady:"___fp_swf_loaded"};window.swfobject.embedSWF(t.fonts.swfPath,r,"1","1","9.0.0",!1,n,{allowScriptAccess:"always",menu:"false"},{})},N=function(){var e=document.createElement("canvas"),t=null;try{t=e.getContext("webgl")||e.getContext("experimental-webgl")}catch(e){}return t||(t=null),t},H=[{key:"userAgent",getData:function(e){e(navigator.userAgent)}},{key:"language",getData:function(e,t){e(navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||t.NOT_AVAILABLE)}},{key:"colorDepth",getData:function(e,t){e(window.screen.colorDepth||t.NOT_AVAILABLE)}},{key:"deviceMemory",getData:function(e,t){e(navigator.deviceMemory||t.NOT_AVAILABLE)}},{key:"pixelRatio",getData:function(e,t){e(window.devicePixelRatio||t.NOT_AVAILABLE)}},{key:"hardwareConcurrency",getData:function(e,t){e(T(t))}},{key:"screenResolution",getData:function(e,t){e(l(t))}},{key:"availableScreenResolution",getData:function(e,t){e(A(t))}},{key:"timezoneOffset",getData:function(e){e((new Date).getTimezoneOffset())}},{key:"timezone",getData:function(e,t){window.Intl&&window.Intl.DateTimeFormat?e((new window.Intl.DateTimeFormat).resolvedOptions().timeZone):e(t.NOT_AVAILABLE)}},{key:"sessionStorage",getData:function(e,t){e(m(t))}},{key:"localStorage",getData:function(e,t){e(g(t))}},{key:"indexedDb",getData:function(e,t){e(v(t))}},{key:"addBehavior",getData:function(e){e(!(!document.body||!document.body.addBehavior))}},{key:"openDatabase",getData:function(e){e(!!window.openDatabase)}},{key:"cpuClass",getData:function(e,t){e(b(t))}},{key:"platform",getData:function(e,t){e(S(t))}},{key:"doNotTrack",getData:function(e,t){e(y(t))}},{key:"plugins",getData:function(e,t){x()?t.plugins.excludeIE?e(t.EXCLUDED):e(f(t)):e(h(t))}},{key:"canvas",getData:function(e,t){D()?e(_(t)):e(t.NOT_AVAILABLE)}},{key:"webgl",getData:function(e,t){O()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){O()?e(E()):e()}},{key:"adBlock",getData:function(e){e(C())}},{key:"hasLiedLanguages",getData:function(e){e(M())}},{key:"hasLiedResolution",getData:function(e){e(P())}},{key:"hasLiedOs",getData:function(e){e(I())}},{key:"hasLiedBrowser",getData:function(e){e(R())}},{key:"touchSupport",getData:function(e){e(k())}},{key:"fonts",getData:function(e,t){var r=["monospace","sans-serif","serif"],n=["Andale Mono","Arial","Arial Black","Arial Hebrew","Arial MT","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Bitstream Vera Sans Mono","Book Antiqua","Bookman Old Style","Calibri","Cambria","Cambria Math","Century","Century Gothic","Century Schoolbook","Comic Sans","Comic Sans MS","Consolas","Courier","Courier New","Geneva","Georgia","Helvetica","Helvetica Neue","Impact","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","LUCIDA GRANDE","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Microsoft Sans Serif","Monaco","Monotype Corsiva","MS Gothic","MS Outlook","MS PGothic","MS Reference Sans Serif","MS Sans Serif","MS Serif","MYRIAD","MYRIAD PRO","Palatino","Palatino Linotype","Segoe Print","Segoe Script","Segoe UI","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tahoma","Times","Times New Roman","Times New Roman PS","Trebuchet MS","Verdana","Wingdings","Wingdings 2","Wingdings 3"];t.fonts.extendedJsFonts&&(n=n.concat(["Abadi MT Condensed Light","Academy Engraved LET","ADOBE CASLON PRO","Adobe Garamond","ADOBE GARAMOND PRO","Agency FB","Aharoni","Albertus Extra Bold","Albertus Medium","Algerian","Amazone BT","American Typewriter","American Typewriter Condensed","AmerType Md BT","Andalus","Angsana New","AngsanaUPC","Antique Olive","Aparajita","Apple Chancery","Apple Color Emoji","Apple SD Gothic Neo","Arabic Typesetting","ARCHER","ARNO PRO","Arrus BT","Aurora Cn BT","AvantGarde Bk BT","AvantGarde Md BT","AVENIR","Ayuthaya","Bandy","Bangla Sangam MN","Bank Gothic","BankGothic Md BT","Baskerville","Baskerville Old Face","Batang","BatangChe","Bauer Bodoni","Bauhaus 93","Bazooka","Bell MT","Bembo","Benguiat Bk BT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","BernhardFashion BT","BernhardMod BT","Big Caslon","BinnerD","Blackadder ITC","BlairMdITC TT","Bodoni 72","Bodoni 72 Oldstyle","Bodoni 72 Smallcaps","Bodoni MT","Bodoni MT Black","Bodoni MT Condensed","Bodoni MT Poster Compressed","Bookshelf Symbol 7","Boulder","Bradley Hand","Bradley Hand ITC","Bremen Bd BT","Britannic Bold","Broadway","Browallia New","BrowalliaUPC","Brush Script MT","Californian FB","Calisto MT","Calligrapher","Candara","CaslonOpnface BT","Castellar","Centaur","Cezanne","CG Omega","CG Times","Chalkboard","Chalkboard SE","Chalkduster","Charlesworth","Charter Bd BT","Charter BT","Chaucer","ChelthmITC Bk BT","Chiller","Clarendon","Clarendon Condensed","CloisterBlack BT","Cochin","Colonna MT","Constantia","Cooper Black","Copperplate","Copperplate Gothic","Copperplate Gothic Bold","Copperplate Gothic Light","CopperplGoth Bd BT","Corbel","Cordia New","CordiaUPC","Cornerstone","Coronet","Cuckoo","Curlz MT","DaunPenh","Dauphin","David","DB LCD Temp","DELICIOUS","Denmark","DFKai-SB","Didot","DilleniaUPC","DIN","DokChampa","Dotum","DotumChe","Ebrima","Edwardian Script ITC","Elephant","English 111 Vivace BT","Engravers MT","EngraversGothic BT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC","EucrosiaUPC","Euphemia","Euphemia UCAS","EUROSTILE","Exotc350 Bd BT","FangSong","Felix Titling","Fixedsys","FONTIN","Footlight MT Light","Forte","FrankRuehl","Fransiscan","Freefrm721 Blk BT","FreesiaUPC","Freestyle Script","French Script MT","FrnkGothITC Bk BT","Fruitger","FRUTIGER","Futura","Futura Bk BT","Futura Lt BT","Futura Md BT","Futura ZBlk BT","FuturaBlack BT","Gabriola","Galliard BT","Gautami","Geeza Pro","Geometr231 BT","Geometr231 Hv BT","Geometr231 Lt BT","GeoSlab 703 Lt BT","GeoSlab 703 XBd BT","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Gisha","Gloucester MT Extra Condensed","GOTHAM","GOTHAM BOLD","Goudy Old Style","Goudy Stout","GoudyHandtooled BT","GoudyOLSt BT","Gujarati Sangam MN","Gulim","GulimChe","Gungsuh","GungsuhChe","Gurmukhi MN","Haettenschweiler","Harlow Solid Italic","Harrington","Heather","Heiti SC","Heiti TC","HELV","Herald","High Tower Text","Hiragino Kaku Gothic ProN","Hiragino Mincho ProN","Hoefler Text","Humanst 521 Cn BT","Humanst521 BT","Humanst521 Lt BT","Imprint MT Shadow","Incised901 Bd BT","Incised901 BT","Incised901 Lt BT","INCONSOLATA","Informal Roman","Informal011 BT","INTERSTATE","IrisUPC","Iskoola Pota","JasmineUPC","Jazz LET","Jenson","Jester","Jokerman","Juice ITC","Kabel Bk BT","Kabel Ult BT","Kailasa","KaiTi","Kalinga","Kannada Sangam MN","Kartika","Kaufmann Bd BT","Kaufmann BT","Khmer UI","KodchiangUPC","Kokila","Korinna BT","Kristen ITC","Krungthep","Kunstler Script","Lao UI","Latha","Leelawadee","Letter Gothic","Levenim MT","LilyUPC","Lithograph","Lithograph Light","Long Island","Lydian BT","Magneto","Maiandra GD","Malayalam Sangam MN","Malgun Gothic","Mangal","Marigold","Marion","Marker Felt","Market","Marlett","Matisse ITC","Matura MT Script Capitals","Meiryo","Meiryo UI","Microsoft Himalaya","Microsoft JhengHei","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Tai Le","Microsoft Uighur","Microsoft YaHei","Microsoft Yi Baiti","MingLiU","MingLiU_HKSCS","MingLiU_HKSCS-ExtB","MingLiU-ExtB","Minion","Minion Pro","Miriam","Miriam Fixed","Mistral","Modern","Modern No. 20","Mona Lisa Solid ITC TT","Mongolian Baiti","MONO","MoolBoran","Mrs Eaves","MS LineDraw","MS Mincho","MS PMincho","MS Reference Specialty","MS UI Gothic","MT Extra","MUSEO","MV Boli","Nadeem","Narkisim","NEVIS","News Gothic","News GothicMT","NewsGoth BT","Niagara Engraved","Niagara Solid","Noteworthy","NSimSun","Nyala","OCR A Extended","Old Century","Old English Text MT","Onyx","Onyx BT","OPTIMA","Oriya Sangam MN","OSAKA","OzHandicraft BT","Palace Script MT","Papyrus","Parchment","Party LET","Pegasus","Perpetua","Perpetua Titling MT","PetitaBold","Pickwick","Plantagenet Cherokee","Playbill","PMingLiU","PMingLiU-ExtB","Poor Richard","Poster","PosterBodoni BT","PRINCETOWN LET","Pristina","PTBarnum BT","Pythagoras","Raavi","Rage Italic","Ravie","Ribbon131 Bd BT","Rockwell","Rockwell Condensed","Rockwell Extra Bold","Rod","Roman","Sakkal Majalla","Santa Fe LET","Savoye LET","Sceptre","Script","Script MT Bold","SCRIPTINA","Serifa","Serifa BT","Serifa Th BT","ShelleyVolante BT","Sherwood","Shonar Bangla","Showcard Gothic","Shruti","Signboard","SILKSCREEN","SimHei","Simplified Arabic","Simplified Arabic Fixed","SimSun","SimSun-ExtB","Sinhala Sangam MN","Sketch Rockwell","Skia","Small Fonts","Snap ITC","Snell Roundhand","Socket","Souvenir Lt BT","Staccato222 BT","Steamer","Stencil","Storybook","Styllo","Subway","Swis721 BlkEx BT","Swiss911 XCm BT","Sylfaen","Synchro LET","System","Tamil Sangam MN","Technical","Teletype","Telugu Sangam MN","Tempus Sans ITC","Terminal","Thonburi","Traditional Arabic","Trajan","TRAJAN PRO","Tristan","Tubular","Tunga","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold","TypoUpright BT","Unicorn","Univers","Univers CE 55 Medium","Univers Condensed","Utsaah","Vagabond","Vani","Vijaya","Viner Hand ITC","VisualUI","Vivaldi","Vladimir Script","Vrinda","Westminster","WHITNEY","Wide Latin","ZapfEllipt BT","ZapfHumnst BT","ZapfHumnst Dm BT","Zapfino","Zurich BlkEx BT","Zurich Ex BT","ZWAdobeF"]));n=(n=n.concat(t.fonts.userDefinedFonts)).filter(function(e,t){return n.indexOf(e)===t});var i=document.getElementsByTagName("body")[0],a=document.createElement("div"),o=document.createElement("div"),s={},c={},d=function(){var e=document.createElement("span");return e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="72px",e.style.fontStyle="normal",e.style.fontWeight="normal",e.style.letterSpacing="normal",e.style.lineBreak="auto",e.style.lineHeight="normal",e.style.textTransform="none",e.style.textAlign="left",e.style.textDecoration="none",e.style.textShadow="none",e.style.whiteSpace="normal",e.style.wordBreak="normal",e.style.wordSpacing="normal",e.innerHTML="mmmmmmmmmmlli",e},u=function(e,t){var r=d();return r.style.fontFamily="'"+e+"',"+t,r},l=function(e){for(var t=!1,n=0;n=e.components.length)t(r.data);else{var o=e.components[n];if(e.excludes[o.key])i(!1);else{if(!a&&o.pauseBefore)return n-=1,void setTimeout(function(){i(!0)},1);try{o.getData(function(e){r.addPreprocessedComponent(o.key,e),i(!1)},e)}catch(e){r.addPreprocessedComponent(o.key,String(e)),i(!1)}}}};i(!1)},F.getPromise=function(e){return new Promise(function(t,r){F.get(e,t)})},F.getV18=function(e,t){return null==t&&(t=e,e={}),F.get(e,function(r){for(var n=[],i=0;i=43)}}).catch(function(){return!1})}(e).then(function(e){return A=e})}function v(e){var t=h[e.name],r={};r.promise=new o(function(e,t){r.resolve=e,r.reject=t}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function T(e){var t=h[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function b(e,t){var r=h[e.name],n=r.deferredOperations.pop();if(n)return n.reject(t),n.promise}function S(e,t){return new o(function(r,n){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);v(e),e.db.close()}var a=[e.name];t&&a.push(e.version);var o=i.open.apply(i,a);t&&(o.onupgradeneeded=function(t){var r=o.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(l)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),n(o.error)},o.onsuccess=function(){r(o.result),T(e)}})}function y(e){return S(e,!1)}function k(e){return S(e,!0)}function _(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function w(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return o.resolve().then(function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),k(e)}).then(function(){return function(e){v(e);for(var t=h[e.name],r=t.forages,n=0;n>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&a;return d}function Q(e){var t,r=new Uint8Array(e),n="";for(t=0;t>2],n+=I[(3&r[t])<<4|r[t+1]>>4],n+=I[(15&r[t+1])<<2|r[t+2]>>6],n+=I[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var J={serialize:function(e,t){var r="";if(e&&(r=X.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===X.call(e.buffer))){var n,i=O;e instanceof ArrayBuffer?(n=e,i+=B):(n=e.buffer,"[object Int8Array]"===r?i+=G:"[object Uint8Array]"===r?i+=N:"[object Uint8ClampedArray]"===r?i+=H:"[object Int16Array]"===r?i+=F:"[object Uint16Array]"===r?i+=V:"[object Int32Array]"===r?i+=j:"[object Uint32Array]"===r?i+=U:"[object Float32Array]"===r?i+=q:"[object Float64Array]"===r?i+=W:t(new Error("Failed to get type for BinaryArray"))),t(i+Q(n))}else if("[object Blob]"===r){var a=new FileReader;a.onload=function(){var r=R+e.type+"~"+Q(this.result);t(O+L+r)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,x)!==O)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(x,z);if(n===L&&D.test(r)){var i=r.match(D);t=i[1],r=r.substring(i[0].length)}var o=K(r);switch(n){case B:return o;case L:return a([o],{type:t});case G:return new Int8Array(o);case N:return new Uint8Array(o);case H:return new Uint8ClampedArray(o);case F:return new Int16Array(o);case V:return new Uint16Array(o);case j:return new Int32Array(o);case U:return new Uint32Array(o);case q:return new Float32Array(o);case W:return new Float64Array(o);default:throw new Error("Unkown type: "+n)}},stringToBuffer:K,bufferToString:Q};function Z(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function $(e,t,r,n,i,a){e.executeSql(r,n,i,function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(e,s){s.rows.length?a(e,o):Z(e,t,function(){e.executeSql(r,n,i,a)},a)},a):a(e,o)},a)}var Y={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new o(function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction(function(i){Z(i,r,function(){t._dbInfo=r,e()},function(e,t){n(t)})},n)});return r.serializer=J,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT * FROM "+i.storeName,[],function(r,n){for(var a=n.rows,o=a.length,s=0;s0)return void o(e.apply(a,[t,c,n,i-1]));s(r)}})})}).catch(s)});return s(c,n),c}.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=d(e);var n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},clear:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"DELETE FROM "+n.storeName,[],function(){e()},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},length:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(t,r){var n=r.rows.item(0).c;e(n)},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},key:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},keys:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT key FROM "+n.storeName,[],function(t,r){for(var n=[],i=0;i '__WebKitDatabaseInfoTable__'",[],function(r,n){for(var i=[],a=0;a0}var re={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=J,o.resolve()):o.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then(function(){for(var t=r._dbInfo,n=t.keyPrefix,i=n.length,a=localStorage.length,o=1,s=0;s=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}});return s(r,e),r},length:function(e){var t=this.keys().then(function(e){return e.length});return s(t,e),t},key:function(e,t){var r=this,n=r.ready().then(function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t});return s(n,t),n},keys:function(e){var t=this,r=t.ready().then(function(){for(var e=t._dbInfo,r=localStorage.length,n=[],i=0;i=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}}):o.reject("Invalid arguments"),t),n}},ne=function(e,t){for(var r=e.length,n=0;n=0;)e[t]=0}const q=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),W=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),z=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),X=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K=new Array(576);U(K);const Q=new Array(60);U(Q);const J=new Array(512);U(J);const Z=new Array(256);U(Z);const $=new Array(29);U($);const Y=new Array(30);function ee(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let te,re,ne;function ie(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U(Y);const ae=e=>e<256?J[e]:J[256+(e>>>7)],oe=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},se=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<{se(e,r[2*t],r[2*t+1])},de=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},ue=(e,t,r)=>{const n=new Array(16);let i,a,o=0;for(i=1;i<=15;i++)n[i]=o=o+r[i-1]<<1;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=de(n[t]++,t))}},le=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},Ae=e=>{e.bi_valid>8?oe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},he=(e,t,r,n)=>{const i=2*t,a=2*r;return e[i]{const n=e.heap[r];let i=r<<1;for(;i<=e.heap_len&&(i{let n,i,a,o,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?ce(e,i,t):(a=Z[i],ce(e,a+256+1,t),0!==(o=q[a])&&(i-=$[a],se(e,i,o)),a=ae(--n),ce(e,a,r),0!==(o=W[a])&&(n-=Y[a],se(e,n,o)))}while(s{const r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems;let o,s,c,d=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)fe(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],fe(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[2*c]=r[2*o]+r[2*s],e.depth[c]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[2*o+1]=r[2*s+1]=c,e.heap[1]=c++,fe(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let d,u,l,A,h,f,p=0;for(A=0;A<=15;A++)e.bl_count[A]=0;for(r[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)(A=r[2*r[2*(u=e.heap[d])+1]+1]+1)>c&&(A=c,p++),r[2*u+1]=A,u>n||(e.bl_count[A]++,h=0,u>=s&&(h=o[u-s]),f=r[2*u],e.opt_len+=f*(A+h),a&&(e.static_len+=f*(i[2*u+1]+h)));if(0!==p){do{for(A=c-1;0===e.bl_count[A];)A--;e.bl_count[A]--,e.bl_count[A+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(A=c;0!==A;A--)for(u=e.bl_count[A];0!==u;)(l=e.heap[--d])>n||(r[2*l+1]!==A&&(e.opt_len+=(A-r[2*l+1])*r[2*l],r[2*l+1]=A),u--)}})(e,t),ue(r,d,e.bl_count)},ge=(e,t,r)=>{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=t[2*(n+1)+1],++s{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),n=0;n<=r;n++)if(i=o,o=t[2*(n+1)+1],!(++s{se(e,0+(n?1:0),3),((e,t,r,n)=>{Ae(e),n&&(oe(e,r),oe(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var Se={_tr_init:e=>{Te||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for($[n]=r,e=0;e<1<>=7;n<30;n++)for(Y[n]=i<<7,e=0;e<1<{let i,a,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),me(e,e.l_desc),me(e,e.d_desc),o=(e=>{let t;for(ge(e,e.dyn_ltree,e.l_desc.max_code),ge(e,e.dyn_dtree,e.d_desc.max_code),me(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*X[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?be(e,t,r,n):4===e.strategy||a===i?(se(e,2+(n?1:0),3),pe(e,K,Q)):(se(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(se(e,t-257,5),se(e,r-1,5),se(e,n-4,4),i=0;i(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Z[r]+256+1)]++,e.dyn_dtree[2*ae(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{se(e,2,3),ce(e,256,K),(e=>{16===e.bi_valid?(oe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var ye=(e,t,r,n)=>{let i=65535&e|0,a=e>>>16&65535|0,o=0;for(;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0};const ke=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var _e=(e,t,r,n)=>{const i=ke,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},we={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ee={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ce,_tr_stored_block:Me,_tr_flush_block:Pe,_tr_tally:Ie,_tr_align:Re}=Se,{Z_NO_FLUSH:De,Z_PARTIAL_FLUSH:Oe,Z_FULL_FLUSH:xe,Z_FINISH:Be,Z_BLOCK:Le,Z_OK:Ge,Z_STREAM_END:Ne,Z_STREAM_ERROR:He,Z_DATA_ERROR:Fe,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Ve,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:We,Z_FIXED:ze,Z_DEFAULT_STRATEGY:Xe,Z_UNKNOWN:Ke,Z_DEFLATED:Qe}=Ee,Je=286,Ze=30,$e=19,Ye=2*Je+1,et=15,tt=(e,t)=>(e.msg=we[t],t),rt=e=>(e<<1)-(e>4?9:0),nt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let it=(e,t,r)=>(t<{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ot=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,at(e.strm)},st=(e,t)=>{e.pending_buf[e.pending++]=t},ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},dt=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=ye(e.adler,t,i,r):2===e.state.wrap&&(e.adler=_e(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ut=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,u=e.w_mask,l=e.prev,A=e.strstart+258;let h=d[a+o-1],f=d[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(d[(r=t)+o]===f&&d[r+o-1]===h&&d[r]===d[a]&&d[++r]===d[a+1]){a+=2,r++;do{}while(d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&ao){if(e.match_start=t,o=n,n>=s)break;h=d[a+o-1],f=d[a+o]}}}while((t=l[t&u])>c&&0!=--i);return o<=e.lookahead?o:e.lookahead},lt=e=>{const t=e.w_size;let r,n,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-262)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=n=e.hash_size;do{i=e.head[--r],e.head[r]=i>=t?i-t:0}while(--n);r=n=t;do{i=e.prev[--r],e.prev[r]=i>=t?i-t:0}while(--n);a+=t}if(0===e.strm.avail_in)break;if(n=dt(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=it(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=it(e,e.ins_h,e.window[o+3-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},At=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ut(e,r)),e.match_length>=3)if(n=Ie(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=it(e,e.ins_h,e.window[e.strstart+1]);else n=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2},ht=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Ie(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(ot(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Ie(e,0,e.window[e.strstart-1]))&&ot(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ie(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2};function ft(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}const pt=[new ft(0,0,0,0,(e,t)=>{let r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(lt(e),0===e.lookahead&&t===De)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,ot(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(ot(e,!1),e.strm.avail_out),1)}),new ft(4,4,8,4,At),new ft(4,5,16,8,At),new ft(4,6,32,32,At),new ft(4,4,16,16,ht),new ft(8,16,32,32,ht),new ft(8,16,128,128,ht),new ft(8,32,128,256,ht),new ft(32,128,258,1024,ht),new ft(32,258,258,4096,ht)];function mt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qe,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*Ye),this.dyn_dtree=new Uint16Array(2*(2*Ze+1)),this.bl_tree=new Uint16Array(2*(2*$e+1)),nt(this.dyn_ltree),nt(this.dyn_dtree),nt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(et+1),this.heap=new Uint16Array(2*Je+1),nt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Je+1),nt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const gt=e=>{if(!e||!e.state)return tt(e,He);e.total_in=e.total_out=0,e.data_type=Ke;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=De,Ce(t),Ge},vt=e=>{const t=gt(e);return t===Ge&&(e=>{e.window_size=2*e.w_size,nt(e.head),e.max_lazy_match=pt[e.level].max_lazy,e.good_match=pt[e.level].good_length,e.nice_match=pt[e.level].nice_length,e.max_chain_length=pt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0})(e.state),t},Tt=(e,t,r,n,i,a)=>{if(!e)return He;let o=1;if(t===Ve&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Qe||n<8||n>15||t<0||t>9||a<0||a>ze)return tt(e,He);8===n&&(n=9);const s=new mt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<Tt(e,t,Qe,15,8,Xe),deflateInit2:Tt,deflateReset:vt,deflateResetKeep:gt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?He:(e.state.gzhead=t,Ge):He,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Le||t<0)return e?tt(e,He):He;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Be)return tt(e,0===e.avail_out?je:He);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,st(i,31),st(i,139),st(i,8),i.gzhead?(st(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),st(i,255&i.gzhead.time),st(i,i.gzhead.time>>8&255),st(i,i.gzhead.time>>16&255),st(i,i.gzhead.time>>24&255),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(st(i,255&i.gzhead.extra.length),st(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=_e(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(st(i,0),st(i,0),st(i,0),st(i,0),st(i,0),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,3),i.status=113);else{let t=Qe+(i.w_bits-8<<4)<<8,r=-1;t|=(r=i.strategy>=qe||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,ct(i,t),0!==i.strstart&&(ct(i,e.adler>>>16),ct(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending!==i.pending_buf_size));)st(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&at(e),i.pending+2<=i.pending_buf_size&&(st(i,255&e.adler),st(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(at(e),0===e.avail_out)return i.last_flush=-1,Ge}else if(0===e.avail_in&&rt(t)<=rt(a)&&t!==Be)return tt(e,je);if(666===i.status&&0!==e.avail_in)return tt(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==De&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(lt(e),0===e.lookahead)){if(t===De)return 1;break}if(e.match_length=0,r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===We?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(lt(e),e.lookahead<=258&&t===De)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=o[i=e.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){a=e.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Ie(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):pt[i.level].func(i,t);if(3!==r&&4!==r||(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),Ge;if(2===r&&(t===Oe?Re(i):t!==Le&&(Me(i,0,0,!1),t===xe&&(nt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),at(e),0===e.avail_out))return i.last_flush=-1,Ge}return t!==Be?Ge:i.wrap<=0?Ne:(2===i.wrap?(st(i,255&e.adler),st(i,e.adler>>8&255),st(i,e.adler>>16&255),st(i,e.adler>>24&255),st(i,255&e.total_in),st(i,e.total_in>>8&255),st(i,e.total_in>>16&255),st(i,e.total_in>>24&255)):(ct(i,e.adler>>>16),ct(i,65535&e.adler)),at(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Ge:Ne)},deflateEnd:e=>{if(!e||!e.state)return He;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?tt(e,He):(e.state=null,113===t?tt(e,Fe):Ge)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return He;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return He;if(1===i&&(e.adler=ye(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(nt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}const a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,lt(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=it(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,lt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,n.wrap=i,Ge},deflateInfo:"pako deflate (from Nodeca project)"};const St=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var yt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)St(r,t)&&(e[t]=r[t])}}return e},flattenChunks:e=>{let t=0;for(let r=0,n=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;_t[254]=_t[254]=1;var wt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,n,i,a,o=e.length,s=0;for(i=0;i>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},buf2string:(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const a=new Array(2*r);for(i=0,n=0;n4)a[i++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?a[i++]=65533:t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&kt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+_t[e[r]]>t?r:t}};var Et=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ct=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:It,Z_FINISH:Rt,Z_OK:Dt,Z_STREAM_END:Ot,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Bt,Z_DEFLATED:Lt}=Ee;function Gt(e){this.options=yt.assign({level:xt,method:Lt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Bt},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=bt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Dt)throw new Error(we[r]);if(t.header&&bt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?wt.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=bt.deflateSetDictionary(this.strm,e))!==Dt)throw new Error(we[r]);this._dict_set=!0}}function Nt(e,t){const r=new Gt(t);if(r.push(e,!0),r.err)throw r.msg||we[r.err];return r.result}Gt.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize;let i,a;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Rt:Mt,"string"==typeof e?r.input=wt.string2buf(e):"[object ArrayBuffer]"===Ct.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a===Pt||a===It)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=bt.deflate(r,a))===Ot)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=bt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Dt;if(0!==r.avail_out){if(a>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Gt.prototype.onData=function(e){this.chunks.push(e)},Gt.prototype.onEnd=function(e){e===Dt&&(this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ht={Deflate:Gt,deflate:Nt,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Nt(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Nt(e,t)},constants:Ee};var Ft=function(e,t){let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_,w;const E=e.state;r=e.next_in,_=e.input,n=r+(e.avail_in-5),i=e.next_out,w=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,d=E.whave,u=E.wnext,l=E.window,A=E.hold,h=E.bits,f=E.lencode,p=E.distcode,m=(1<>>=T=v>>>24,h-=T,0===(T=v>>>16&255))w[i++]=65535&v;else{if(!(16&T)){if(0==(64&T)){v=f[(65535&v)+(A&(1<>>=T,h-=T),h<15&&(A+=_[r++]<>>=T=v>>>24,h-=T,!(16&(T=v>>>16&255))){if(0==(64&T)){v=p[(65535&v)+(A&(1<s){e.msg="invalid distance too far back",E.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&E.sane){e.msg="invalid distance too far back",E.mode=30;break e}if(y=0,k=l,0===u){if(y+=c-T,T2;)w[i++]=k[y++],w[i++]=k[y++],w[i++]=k[y++],b-=3;b&&(w[i++]=k[y++],b>1&&(w[i++]=k[y++]))}else{y=i-S;do{w[i++]=w[y++],w[i++]=w[y++],w[i++]=w[y++],b-=3}while(b>2);b&&(w[i++]=w[y++],b>1&&(w[i++]=w[y++]))}break}}break}}while(r>3,A&=(1<<(h-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r{const c=s.bits;let d,u,l,A,h,f,p=0,m=0,g=0,v=0,T=0,b=0,S=0,y=0,k=0,_=0,w=null,E=0;const C=new Uint16Array(16),M=new Uint16Array(16);let P,I,R,D=null,O=0;for(p=0;p<=15;p++)C[p]=0;for(m=0;m=1&&0===C[v];v--);if(T>v&&(T=v),0===v)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(M[1]=0,p=1;p<15;p++)M[p+1]=M[p]+C[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){P=p-S,o[m]f?(I=D[O+o[m]],R=w[E+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=P<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--C[p]){if(p===v)break;p=t[r+o[m]]}if(p>T&&(_&A)!==l){for(0===S&&(S=T),h+=g,y=1<<(b=p-S);b+S852||2===e&&k>592)return 1;i[l=_&A]=T<<24|b<<16|h-a|0}}return 0!==_&&(i[h+_]=p-S<<24|64<<16|0),s.bits=T,0};const{Z_FINISH:zt,Z_BLOCK:Xt,Z_TREES:Kt,Z_OK:Qt,Z_STREAM_END:Jt,Z_NEED_DICT:Zt,Z_STREAM_ERROR:$t,Z_DATA_ERROR:Yt,Z_MEM_ERROR:er,Z_BUF_ERROR:tr,Z_DEFLATED:rr}=Ee,nr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ir(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ar=e=>{if(!e||!e.state)return $t;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Qt},or=e=>{if(!e||!e.state)return $t;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ar(e)},sr=(e,t)=>{let r;if(!e||!e.state)return $t;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?$t:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,or(e))},cr=(e,t)=>{if(!e)return $t;const r=new ir;e.state=r,r.window=null;const n=sr(e,t);return n!==Qt&&(e.state=null),n};let dr,ur,lr=!0;const Ar=e=>{if(lr){dr=new Int32Array(512),ur=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Wt(1,e.lens,0,288,dr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Wt(2,e.lens,0,32,ur,0,e.work,{bits:5}),lr=!1}e.lencode=dr,e.lenbits=9,e.distcode=ur,e.distbits=5},hr=(e,t,r,n)=>{let i;const a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whavecr(e,15),inflateInit2:cr,inflate:(e,t)=>{let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_=0;const w=new Uint8Array(4);let E,C;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return $t;12===(r=e.state).mode&&(r.mode=13),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,l=s,A=c,k=Qt;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0),d=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&d)!==rr){e.msg="unknown compression method",r.mode=30;break}if(u-=4,y=8+(15&(d>>>=4)),0===r.wbits)r.wbits=y;else if(y>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>8&255,w[2]=d>>>16&255,w[3]=d>>>24&255,r.check=_e(r.check,w,4,0)),d=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>8),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>s&&(h=s),h&&(r.head&&(y=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),y)),512&r.flags&&(r.check=_e(r.check,n,h,a)),s-=h,a+=h,r.length-=h),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;h=0;do{y=n[a+h++],r.head&&y&&r.length<65536&&(r.head.name+=String.fromCharCode(y))}while(y&&h>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===s)break e;s--,d+=n[a++]<>>=1)){case 0:r.mode=14;break;case 1:if(Ar(r),r.mode=20,t===Kt){d>>>=2,u-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}d>>>=2,u-=2;break;case 14:for(d>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,d+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&d,d=0,u=0,r.mode=15,t===Kt)break e;case 15:r.mode=16;case 16:if(h=r.length){if(h>s&&(h=s),h>c&&(h=c),0===h)break e;i.set(n.subarray(a,a+h),o),s-=h,a+=h,c-=h,o+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===s)break e;s--,d+=n[a++]<>>=5,u-=5,r.ndist=1+(31&d),d>>>=5,u-=5,r.ncode=4+(15&d),d>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,E={bits:r.lenbits},k=Wt(0,r.lens,0,19,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=m,u-=m,r.lens[r.have++]=v;else{if(16===v){for(C=m+2;u>>=m,u-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}y=r.lens[r.have-1],h=3+(3&d),d>>>=2,u-=2}else if(17===v){for(C=m+3;u>>=m)),d>>>=3,u-=3}else{for(C=m+7;u>>=m)),d>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=y}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,E={bits:r.lenbits},k=Wt(1,r.lens,0,r.nlen,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,E={bits:r.distbits},k=Wt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,E),r.distbits=E.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Kt)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=d,r.bits=u,Ft(e,A),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(_=r.lencode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,r.length=v,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(_=r.distcode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=v,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===c)break e;if(h=A-c,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,f=r.wsize-h):f=r.wnext-h,h>r.length&&(h=r.length),p=r.window}else p=i,f=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do{i[o++]=p[f++]}while(--h);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[o++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===s)break e;s--,d|=n[a++]<{if(!e||!e.state)return $t;let t=e.state;return t.window&&(t.window=null),e.state=null,Qt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return $t;const r=e.state;return 0==(2&r.wrap)?$t:(r.head=t,t.done=!1,Qt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?$t:11===n.mode&&(i=ye(i=1,t,r,0))!==n.check?Yt:(a=hr(e,t,r,r))?(n.mode=31,er):(n.havedict=1,Qt):$t},inflateInfo:"pako inflate (from Nodeca project)"};var pr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const mr=Object.prototype.toString,{Z_NO_FLUSH:gr,Z_FINISH:vr,Z_OK:Tr,Z_STREAM_END:br,Z_NEED_DICT:Sr,Z_STREAM_ERROR:yr,Z_DATA_ERROR:kr,Z_MEM_ERROR:_r}=Ee;function wr(e){this.options=yt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=fr.inflateInit2(this.strm,t.windowBits);if(r!==Tr)throw new Error(we[r]);if(this.header=new pr,fr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wt.string2buf(t.dictionary):"[object ArrayBuffer]"===mr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=fr.inflateSetDictionary(this.strm,t.dictionary))!==Tr))throw new Error(we[r])}function Er(e,t){const r=new wr(t);if(r.push(e),r.err)throw r.msg||we[r.err];return r.result}wr.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let a,o,s;if(this.ended)return!1;for(o=t===~~t?t:!0===t?vr:gr,"[object ArrayBuffer]"===mr.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a=fr.inflate(r,o))===Sr&&i&&((a=fr.inflateSetDictionary(r,i))===Tr?a=fr.inflate(r,o):a===kr&&(a=Sr));r.avail_in>0&&a===br&&r.state.wrap>0&&0!==e[r.next_in];)fr.inflateReset(r),a=fr.inflate(r,o);switch(a){case yr:case kr:case Sr:case _r:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===br))if("string"===this.options.to){let e=wt.utf8border(r.output,r.next_out),t=r.next_out-e,i=wt.buf2string(r.output,e);r.next_out=t,r.avail_out=n-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(a!==Tr||0!==s){if(a===br)return a=fr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},wr.prototype.onData=function(e){this.chunks.push(e)},wr.prototype.onEnd=function(e){e===Tr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:wr,inflate:Er,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Er(e,t)},ungzip:Er,constants:Ee};const{Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr}=Ht,{Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br}=Cr;var Lr={Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr,Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br,constants:Ee},Gr=u(function(e){!function(t){function r(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function n(e,t,n,i,a,o){return r((s=r(r(t,e),r(i,o)))<<(c=a)|s>>>32-c,n);var s,c}function i(e,t,r,i,a,o,s){return n(t&r|~t&i,e,t,a,o,s)}function a(e,t,r,i,a,o,s){return n(t&i|r&~i,e,t,a,o,s)}function o(e,t,r,i,a,o,s){return n(t^r^i,e,t,a,o,s)}function s(e,t,r,i,a,o,s){return n(r^(t|~i),e,t,a,o,s)}function c(e,t){var n,c,d,u,l;e[t>>5]|=128<>>9<<4)]=t;var A=1732584193,h=-271733879,f=-1732584194,p=271733878;for(n=0;n>5]>>>t%32&255);return r}function u(e){var t,r=[];for(r[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+"0123456789abcdef".charAt(15&t);return n}function A(e){return unescape(encodeURIComponent(e))}function h(e){return function(e){return d(c(u(e),8*e.length))}(A(e))}function f(e,t){return function(e,t){var r,n,i=u(e),a=[],o=[];for(a[15]=o[15]=void 0,i.length>16&&(i=c(i,8*e.length)),r=0;r<16;r+=1)a[r]=909522486^i[r],o[r]=1549556828^i[r];return n=c(a.concat(u(t)),512+8*t.length),d(c(o.concat(n),640))}(A(e),A(t))}function p(e,t,r){return t?r?f(t,e):l(f(t,e)):r?h(e):l(h(e))}e.exports?e.exports=p:t.md5=p}(c)}),Nr=u(function(e,t){var r=200,n="Expected a function",i="__lodash_hash_undefined__",a=1,o=2,s=1/0,d=9007199254740991,u="[object Arguments]",l="[object Array]",A="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Function]",m="[object GeneratorFunction]",g="[object Map]",v="[object Number]",T="[object Object]",b="[object RegExp]",S="[object Set]",y="[object String]",k="[object Symbol]",_="[object ArrayBuffer]",w="[object DataView]",E=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,C=/^\w*$/,M=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,O={};O["[object Float32Array]"]=O["[object Float64Array]"]=O["[object Int8Array]"]=O["[object Int16Array]"]=O["[object Int32Array]"]=O["[object Uint8Array]"]=O["[object Uint8ClampedArray]"]=O["[object Uint16Array]"]=O["[object Uint32Array]"]=!0,O[u]=O[l]=O[_]=O[A]=O[w]=O[h]=O[f]=O[p]=O[g]=O[v]=O[T]=O[b]=O[S]=O[y]=O["[object WeakMap]"]=!1;var x="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=x||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&x.process,F=function(){try{return H&&H.binding("util")}catch(e){}}(),j=F&&F.isTypedArray;function V(e,t,r,n){for(var i=-1,a=e?e.length:0;++i-1},we.prototype.set=function(e,t){var r=this.__data__,n=Ie(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ee.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ee.prototype.delete=function(e){return qe(this,e).delete(e)},Ee.prototype.get=function(e){return qe(this,e).get(e)},Ee.prototype.has=function(e){return qe(this,e).has(e)},Ee.prototype.set=function(e,t){return qe(this,e).set(e,t),this},Ce.prototype.add=Ce.prototype.push=function(e){return this.__data__.set(e,i),this},Ce.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.clear=function(){this.__data__=new we},Me.prototype.delete=function(e){return this.__data__.delete(e)},Me.prototype.get=function(e){return this.__data__.get(e)},Me.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.set=function(e,t){var n=this.__data__;if(n instanceof we){var i=n.__data__;if(!le||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ut(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function lt(e){return!!e&&"object"==typeof e}function At(e){return"symbol"==typeof e||lt(e)&&ne.call(e)==k}var ht=j?function(e){return function(t){return e(t)}}(j):function(e){return lt(e)&&dt(e.length)&&!!O[ne.call(e)]};function ft(e){return st(e)?Pe(e):je(e)}function pt(e){return e}e.exports=rt});const Hr="4.1.8";function Fr(){const e=new Date;function t(e){const t=e.toString();return t.length<2?"0"+t:t}return`[${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${e.getMilliseconds()}]`}const jr=new class{constructor(e){this.level=e}setLevel(e){this.level=e}log(...e){if("log"!==this.level)return;const t=`${Fr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Fr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Fr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Vr extends C{constructor(e,t=!0){super(),this._closed=!1,this._busy=!1,this._queue=[],this.name=e||"TaskQueue",this.isDebug=t}close(){this._closed=!0}push(e,t){return this.isDebug&&jr.debug(`${this.name} push()`,e,t),new Promise((r,n)=>{this._queue.push({method:e,data:t,resolve:r,reject:n}),this._handlePendingCommands()})}_handlePendingCommands(){if(this._busy)return;const e=this._queue,t=e[0];t&&(this._busy=!0,this._handleCommand(t).then(()=>{this._busy=!1,e.shift(),this._handlePendingCommands()}))}_handleCommand(e){if(this.isDebug&&jr.debug(`${this.name} _handleCommand() `,e.method,e.data),this._closed)return e.reject(new $n("closed")),Promise.resolve();const t={promise:null};return this.emit("exec",e,t),Promise.resolve().then(()=>t.promise).then(t=>{this.isDebug&&jr.debug(`${this.name} _handleCommand() | command succeeded`,e.method),this._closed?e.reject(new $n("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}var Ur,qr;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}(Ur||(Ur={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}(qr||(qr={}));const Wr={"360p":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:30,bitrate:1130},"1080p":{width:1920,height:1080,frameRate:30,bitrate:2080},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4850},"4k":{width:3840,height:2160,frameRate:30,bitrate:8910}},zr=Wr["480p"],Xr={LOW:{sampleRate:16e3,stereo:!1,bitrate:24,sampleSize:16},STANDARD:{sampleRate:48e3,stereo:!1,bitrate:64,sampleSize:16},STANDARD_STEREO:{sampleRate:48e3,stereo:!0,bitrate:80,sampleSize:16},HIGH:{sampleRate:48e3,stereo:!1,bitrate:96,sampleSize:16},HIGH_STEREO:{sampleRate:48e3,stereo:!0,bitrate:128,sampleSize:16}},Kr=Xr.STANDARD,Qr={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},Jr=Qr["720p"];var Zr,$r,Yr,en,tn,rn,nn,an,on,sn,cn,dn,un,ln,An,hn;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(Zr||(Zr={})),function(e){e.IDLE="IDLE",e.PlAYING="PlAYING",e.MIXING="MIXING",e.PAUSED="PAUSED",e.STOPPED="STOPPED",e.COMPLETED="COMPLETED"}($r||($r={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(Yr||(Yr={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(en||(en={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(tn||(tn={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(rn||(rn={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(nn||(nn={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(an||(an={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(on||(on={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(sn||(sn={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(cn||(cn={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(dn||(dn={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(un||(un={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.STOPPED=1]="STOPPED",e[e.INVALID_TOKEN=2]="INVALID_TOKEN",e[e.NO_ROOM=3]="NO_ROOM",e[e.ROOM_CLOSED=4]="ROOM_CLOSED",e[e.PLAYER_EXISTED=5]="PLAYER_EXISTED"}(ln||(ln={})),function(e){e.NORMAL="NORMAL",e.GENERAL="GENERAL",e.SERVERE="SERVERE"}(An||(An={})),function(e){e.CORE="Core",e.API="API",e.AUDIO="Audio",e.VIDEO="Video",e.SIGNAL="Signal"}(hn||(hn={}));const fn="qnrtcqosevents";function pn(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Gr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Gr(JSON.stringify(t));e(r)})},500)})}function mn(e){const t=[];for(let r=0;r>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return new Uint8Array(t)}const gn=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Vr("qossubmit",!1),pn().then(e=>{this.deviceId=e,this.base.device_id=this.deviceId}).catch(()=>{this.deviceId="unknow",this.base.device_id=this.deviceId}),this.base={qos_version:"2.0",device_id:"",bundle_id:"",url:window.location.href,app_version:"",sdk_version:Hr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(ni)}setSessionId(e){for(let t=this.events.length-1;t>=0;t-=1){const r=this.events[t];if(r.session_id)break;r.session_id=e}this.sessionId=e}setUserBase(e,t,r){this.userBase={user_id:e,room_name:t,app_id:r};for(let e=this.events.length-1;e>=0;e-=1){const t=this.events[e];if(t.user_base)break;t.user_base=this.userBase}}addEvent(e,r,n){const i=t({timestamp:Date.now(),event_id:F[e],event_name:e},r);this.submitQueue.push("add",i).catch(ni),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(ni)}initSubmitQueue(){this.submitQueue.on("exec",(e,t)=>{switch(e.method){case"submit":return void(t.promise=this._submit(e.data));case"add":return void(t.promise=this._addEvent(e.data));case"resume":return void(t.promise=this._recoverStoredEvents())}})}async _recoverStoredEvents(){const e=await V.getItem(fn);jr.log("get item",e),await V.removeItem(fn),e&&(this.events=JSON.parse(window.atob(decodeURIComponent(e))),this.events=this.events.filter(e=>!!e.session_id&&!!e.user_base).sort((e,t)=>e.event.timestamp-t.event.timestamp))}_addEvent(e){return this.events.push({user_base:this.userBase,event:e,session_id:this.sessionId}),this.submit(),Promise.resolve()}saveEvents(){const e=encodeURIComponent(window.btoa(JSON.stringify(this.events)));V.setItem(fn,e).catch(ni)}submitCheck(){return!!(this.sessionId&&this.deviceId&&this.userBase)&&(Date.now()-this.lastSubmitTime>3e5||this.events.length>=30)}async _submit(e=!1){if(e||this.submitCheck())try{const e=this.encodeQosSubmitData();for(const t of e)if(!(await fetch("https://pili-rtc-qos.qiniuapi.com/v1/rtcevent",{method:"POST",headers:{"Content-Type":"application/x-gzip"},body:t.buffer})).ok)throw kn("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await V.removeItem(fn)}catch(e){jr.log(e)}else this.saveEvents()}encodeQosSubmitData(){const e=Nr(this.events,e=>e.session_id||""+JSON.stringify(e.user_base)),t=[];for(const r in e){const n=e[r];if(0===n.length)continue;const i={session_id:n[0].session_id,user_base:n[0].user_base,base:this.base,items:n.map(e=>e.event)};jr.log("encode",i);const a=new Uint8Array(Lr.gzip(mn(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function vn(e,t){let r;switch(e){case"prompt":r=O.prompt;break;case"granted":r=O.granted;break;case"denied":r=O.denied;break;default:return}let n=An.NORMAL;(r===O.prompt||O.denied)&&(n=An.SERVERE),gn.addEvent("AuthorizationStatus",{type:t,status:r,event_grade:n,event_category:hn.CORE})}function Tn(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{vn(e.state,D[t]),e.onchange=(()=>{vn(e.state,D[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Tn("camera"),Tn("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{gn.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2,event_grade:An.GENERAL,event_category:hn.CORE})});const bn=(()=>{let e=x.INVALID,t="unknow";const r=e=>{let t;switch(e){case"cellular":t=0;break;case"wifi":t=1;break;case"ethernet":t=2;break;default:t=-1}return t},n=()=>{gn.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e,event_grade:An.GENERAL,event_category:hn.CORE})},i=navigator,a=i.connection||i.mozConnection||i.webkitConnection;return a&&a.type&&(t=a.type,a.onchange=(()=>{t!==a.type&&(t=a.type,n())})),n(),t=>{t!==e&&(e=t,n())}})();class Sn extends Error{constructor(e,t){super(t),this.code=e,this.error=t,gn.addEvent("SDKError",{error_code:e,error_msg:t})}}const yn=e=>new Sn(10053,`invalid parameters: ${e}`),kn=e=>new Sn(21005,`piliRTC: unexpected error ${e}`),_n=e=>new Sn(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),wn=e=>new Sn(21006,`not support! ${e}`),En=e=>new Sn(21007,`track play is not allowed: ${e}`),Cn=e=>new Sn(23003,`plugin not avaliable! ${e}`),Mn=e=>new Sn(23004,`NotAllowedError: no permission to access media device. ${e}`),Pn=e=>new Sn(22011,`can not decode audio data, ${e.toString()}`),In=()=>new Sn(23005,"no audio track when createScreenVideoTrack withAudio enable"),Rn=e=>new Sn(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),Dn=e=>new Sn(24e3,`relay error, can not get relayToken. Error: ${e}`),On=e=>new Sn(24001,`invalid client mode, ${e}`),xn=e=>new Sn(24002,`invalid client role, ${e}`),Bn=()=>kn("websocket abort"),Ln=e=>yn(`can not set merge layout stream, no merge job id ${e}`),Gn=()=>Mn("can not sharing screen/window on chrome"),Nn=()=>kn("subscribe/publish operation is aborted"),Hn=()=>yn("cannot found preset"),Fn=()=>new Sn(22003,"mix source error"),jn=()=>new Sn(22002,"mixed source does not find a valid track"),Vn=()=>new Sn(22001,"effectID already exists, cannot create QNAudioEffect"),Un=()=>new Sn(22004,"effectID is not exists, pleast createAudioEffect firstt"),qn=(e,t)=>new Sn(e,`publish error, signaling code: ${e}, msg: ${t}`),Wn=(e,t)=>new Sn(e,`create merge job error, signaling code: ${e}, msg: ${t}`),zn=(e,t)=>new Sn(e,`create forward job error, signaling code: ${e}, msg: ${t}`),Xn=(e,t)=>new Sn(e,`media format not support, ${t}`),Kn=(e,t)=>new Sn(e,`subscribe error, signaling code: ${e}, msg: ${t}`),Qn=(e,t)=>new Sn(e,`send control error, code: ${e}, msg: ${t}`),Jn=(e,t)=>new Sn(e,t),Zn=()=>new Sn(10052,"server unavailable");class $n extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,$n):this.stack=new Error(e).stack}}var Yn=Object.freeze({QNRTCError:Sn,ERROR_INVALID_PARAMETER:yn,ERROR_FATAL:kn,ERROR_AUTH_FAILED:_n,ERROR_RECONNECT_FAILED:e=>new Sn(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:wn,ERROR_PLAY_NOT_ALLOWED:En,ERROR_PLUGIN_NOT_AVAILABLE:Cn,ERROR_DEVICE_NOT_ALLOWED:Mn,ERROR_AUDIO_DECODE_ERROR:Pn,CREATE_SCREEN_AUDIO_ERROR:In,ERROR_ELECTRON_REQUIRE_ERROR:Rn,ERROR_RELAY_TOKEN:Dn,ERROR_INVALID_CLIENT_MODE:On,ERROR_INVALID_CLIENT_ROLE:xn,WS_ABORT:Bn,NO_MERGE_JOB:Ln,SCREEN_PERMISSION_DENIED:Gn,SUB_PUB_ABORT:Nn,PRESET_NOT_FOUND:Hn,ERROR_AUDIO_MIXING_IO_EXCEPTION:Fn,ERROR_AUDIO_MIXING_AUDIO_NOT_FOUND:jn,ERROR_EFFECT_ID_IS_EXIST:Vn,ERROR_EFFECT_ID_IS_NOT_EXIST:Un,PUBLISH_ERROR:qn,CREATE_MERGE_JOB_ERROR:Wn,CREATE_FORWARD_JOB_ERROR:zn,UNSUPPORT_FMT:Xn,JOIN_ROOM_ERROR:(e,t)=>new Sn(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Kn,UNPUBLISH_ERROR:(e,t)=>new Sn(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Sn(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:Qn,SERVER_ERROR:Jn,SERVER_UNAVAILABLE:Zn,InvalidStateError:$n});function ei(e){const t=e.split(".")[1];if(!t)throw new Error("parse jwt error, can not find payload string.");const r=atob(t);return JSON.parse(r)}function ti(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw kn(`can not parse roomToken, ${e}`)}}function ri(e,t,r){if(!r)return null;for(let n=0;n=4)return e;for(const r in e)void 0===e[r]&&delete e[r],e[r]instanceof File||e[r]instanceof ArrayBuffer||"object"==typeof e[r]&&(e[r]=ii(e[r],t+1));return e}function ai(e){Promise.resolve().then(e)}function oi(e){return("0"+e.toString(16)).substr(-2)}function si(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,oi).join("")}function ci(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const di={};function ui(e,t){if(!di[t])return di[t]=!0,e()}function li(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Ai(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>{r.abort(),n({networkCode:-1,message:"请求超时"})},t),i=fetch(e,{signal:r.signal})}else i=fetch(e);i.then(e=>(function(e,t,r){e>=400&&r({retry:!1,message:t}),200!==e&&r({retry:!0,message:t})}(e.status,e.statusText,n),e.json())).then(r).catch(n)})}async function hi(e){const t=e.match(/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/);if(e.match(/^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$/)||t)return e;try{const t=await fetch(`https://${e}/ip`);return(await t.json()).ip}catch(t){return jr.warning("resolve ice failed, retry",t),await ci(1e3),await hi(e)}}var fi,pi=u(function(e){!function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){if(!s&&d)return d();if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a=d,o=0;o0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},r=n.log,d=n.detectBrowser(e),u={browserDetails:d,commonShim:c,extractVersion:n.extractVersion,disableLog:n.disableLog,disableWarnings:n.disableWarnings};switch(d.browser){case"chrome":if(!i||!i.shimPeerConnection||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;if(null===d.version)return r("Chrome shim can not determine version, not shimming."),u;r("adapter.js shimming chrome."),u.browserShim=i,c.shimAddIceCandidateNullOrEmpty(e,d),i.shimGetUserMedia(e,d),i.shimMediaStream(e,d),i.shimPeerConnection(e,d),i.shimOnTrack(e,d),i.shimAddTrackRemoveTrack(e,d),i.shimGetSendersWithDtmf(e,d),i.shimGetStats(e,d),i.shimSenderReceiverGetStats(e,d),i.fixNegotiationNeeded(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;case"firefox":if(!o||!o.shimPeerConnection||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=o,c.shimAddIceCandidateNullOrEmpty(e,d),o.shimGetUserMedia(e,d),o.shimPeerConnection(e,d),o.shimOnTrack(e,d),o.shimRemoveStream(e,d),o.shimSenderGetStats(e,d),o.shimReceiverGetStats(e,d),o.shimRTCDataChannel(e,d),o.shimAddTransceiver(e,d),o.shimGetParameters(e,d),o.shimCreateOffer(e,d),o.shimCreateAnswer(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"edge":if(!a||!a.shimPeerConnection||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=a,a.shimGetUserMedia(e,d),a.shimGetDisplayMedia(e,d),a.shimPeerConnection(e,d),a.shimReplaceTrack(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"safari":if(!s||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=s,c.shimAddIceCandidateNullOrEmpty(e,d),s.shimRTCIceServerUrls(e,d),s.shimCreateOfferLegacy(e,d),s.shimCallbacksAPI(e,d),s.shimLocalStreamsAPI(e,d),s.shimRemoteStreamsAPI(e,d),s.shimTrackEventTransceiver(e,d),s.shimGetUserMedia(e,d),s.shimAudioContext(e,d),c.shimRTCIceCandidate(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;default:r("Unsupported browser!")}return u};var n=d(e("./utils")),i=d(e("./chrome/chrome_shim")),a=d(e("./edge/edge_shim")),o=d(e("./firefox/firefox_shim")),s=d(e("./safari/safari_shim")),c=d(e("./common_shim"));function d(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":12,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11}],3:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},r.shimOnTrack=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)o.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e});else{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 t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.track.id}):{track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}),t.stream.getTracks().forEach(function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.id}):{track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}},r.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):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 r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach(function(e){r._senders.push(t(r,e))})};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach(function(e){var r=t._senders.find(function(t){return t.track===e});r&&t._senders.splice(t._senders.indexOf(r),1)})}}else if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t},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}})}},r.shimGetStats=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],a=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var o=function(e){var t={},r=e.result();return r.forEach(function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){r[t]=e.stat(t)}),t[r.id]=r}),t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return t.apply(this,[function(e){i(s(o(e)))},n])}return new Promise(function(r,n){t.apply(e,[function(e){r(s(o(e)))},n])}).then(i,a)}},r.shimSenderReceiverGetStats=function(e){if(!("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return o.filterStats(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t}),o.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(t){return o.filterStats(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],r=void 0,n=void 0,i=void 0;return this.getSenders().forEach(function(e){e.track===t&&(r?i=!0:r=e)}),this.getReceivers().forEach(function(e){return e.track===t&&(n?i=!0:n=e),e.track===t}),i||r&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}},r.shimAddTrackRemoveTrackWithNative=c,r.shimAddTrackRemoveTrack=function(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return c(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(function(e){var t=r.getSenders().find(function(t){return t.track===e});if(t)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;function a(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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(t,r){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var a=this.getSenders().find(function(e){return e.track===t});if(a)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var o=this._streams[r.id];if(o)o.addTrack(t),Promise.resolve().then(function(){n.dispatchEvent(new Event("negotiationneeded"))});else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=a(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then(function(t){return a(e,t)})});e.RTCPeerConnection.prototype[t]=n[t]});var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=(e=this,t=arguments[0],r=t.sdp,Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:r})),o.apply(this,arguments)):o.apply(this,arguments);var e,t,r};var d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=d.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=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");var r=e._pc===this;if(!r)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var n=void 0;Object.keys(this._streams).forEach(function(r){var i=t._streams[r].getTracks().find(function(t){return e.track===t});i&&(n=t._streams[r])}),n&&(1===n.getTracks().length?this.removeStream(this._reverseStreams[n.id]):n.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}},r.shimPeerConnection=function(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection);if(!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})},r.fixNegotiationNeeded=function(e,t){o.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js"));function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter(function(e){return-1===n.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]}),i.apply(this,arguments)}}},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;if("function"!=typeof t)return void console.error("shimGetDisplayMedia: getSourceId argument is not a function");e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,a=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)})}}},{}],5:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator;if(!r.mediaDevices)return;var a=function(e){if("object"!==(void 0===e?"undefined":n(e))||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var i="object"===n(e[r])?e[r]:{ideal:e[r]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);var a=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];var o={};"number"==typeof i.ideal?(o[a("min",r)]=i.ideal,t.optional.push(o),(o={})[a("max",r)]=i.ideal,t.optional.push(o)):(o[a("",r)]=i.ideal,t.optional.push(o))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[a("",r)]=i.exact):["min","max"].forEach(function(e){void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[a(e,r)]=i[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,o){if(t.version>=61)return o(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===n(e.audio)){var s=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),s(e.audio,"autoGainControl","googAutoGainControl"),s(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=a(e.audio)}if(e&&"object"===n(e.video)){var c=e.video.facingMode;c=c&&("object"===(void 0===c?"undefined":n(c))?c:{ideal:c});var d=t.version<66;if(c&&("user"===c.exact||"environment"===c.exact||"user"===c.ideal||"environment"===c.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||d)){delete e.video.facingMode;var u=void 0;if("environment"===c.exact||"environment"===c.ideal?u=["back","rear"]:"user"!==c.exact&&"user"!==c.ideal||(u=["front"]),u)return r.mediaDevices.enumerateDevices().then(function(t){var r=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return e.label.toLowerCase().includes(t)})});return!r&&t.length&&u.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=c.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=a(e.video),i("chrome: "+JSON.stringify(e)),o(e)})}e.video=a(e.video)}return i("chrome: "+JSON.stringify(e)),o(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(r.getUserMedia=function(e,t,n){o(e,function(e){r.webkitGetUserMedia(e,t,function(e){n&&n(s(e))})})}.bind(r),r.mediaDevices.getUserMedia){var c=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return o(e,function(e){return c(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(s(e))})})}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js")).log},{"../utils.js":11}],6:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimRTCIceCandidate=function(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":n(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 r=new t(e),i=o.default.parseCandidate(e.candidate),a=Object.assign(r,i);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,s.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})},r.shimMaxMessageSize=function(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),n=e.sdpSemantics;"plan-b"===n&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;var t=o.default.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=o.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){var i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),a=function(e){var r=65536;"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637);return r}(i),s=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=o.default.matchPrefix(e.sdp,"a=max-message-size:");i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637);return n}(arguments[0],i),c=void 0;c=0===a&&0===s?Number.POSITIVE_INFINITY:0===a||0===s?Math.max(a,s):Math.min(a,s);var d={};Object.defineProperty(d,"maxMessageSize",{get:function(){return c}}),this._sctp=d}return r.apply(this,arguments)}},r.shimSendThrowTypeError=function(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=r.apply(this,arguments);return t(e,this),e},s.wrapPeerConnectionEvent(e,"datachannel",function(e){return t(e.channel,e.target),e})},r.shimConnectionState=function(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"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 r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})},r.removeExtmapAllowMixed=function(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return r.apply(this,arguments)}},r.shimAddIceCandidateNullOrEmpty=function(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;var r=e.RTCPeerConnection.prototype.addIceCandidate;if(!r||0===r.length)return;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}};var i,a=e("sdp"),o=(i=a)&&i.__esModule?i:{default:i},s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("./utils"))},{"./utils":11,sdp:13}],7:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimOnTrack=function(e){"object"===(void 0===e?"undefined":n(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}}})},r.shimPeerConnection=function(e,t){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection);t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r;return e}({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]});var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),n=e[0],a=e[1],o=e[2];return i.apply(this,[n||null]).then(function(e){if(t.version<53&&!a)try{e.forEach(function(e){e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(a,o)}},r.shimSenderGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.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)}},r.shimReceiverGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});o.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}},r.shimRemoveStream=function(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype)return;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)})}},r.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},r.shimAddTransceiver=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(function(e){if("rid"in e){if(!/^[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 n=t.apply(this,arguments);if(r){var i=n.sender,a=i.getParameters();"encodings"in a&&(1!==a.encodings.length||0!==Object.keys(a.encodings[0]).length)||(a.encodings=e.sendEncodings,i.sendEncodings=e.sendEncodings,this.setParametersPromises.push(i.setParameters(a).then(function(){delete i.sendEncodings}).catch(function(){delete i.sendEncodings})))}return n})},r.shimGetParameters=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCRtpSender)return;var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})},r.shimCreateOffer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}},r.shimCreateAnswer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)}}},{}],9:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator,a=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){i.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":n(e))&&"object"===n(e.audio)&&(e=JSON.parse(JSON.stringify(e)),o(e.audio,"autoGainControl","mozAutoGainControl"),o(e.audio,"noiseSuppression","mozNoiseSuppression")),s(e)},a&&a.prototype.getSettings){var c=a.prototype.getSettings;a.prototype.getSettings=function(){var e=c.apply(this,arguments);return o(e,"mozAutoGainControl","autoGainControl"),o(e,"mozNoiseSuppression","noiseSuppression"),e}}if(a&&a.prototype.applyConstraints){var d=a.prototype.applyConstraints;a.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":n(e))&&(e=JSON.parse(JSON.stringify(e)),o(e,"autoGainControl","mozAutoGainControl"),o(e,"noiseSuppression","mozNoiseSuppression")),d.apply(this,[e])}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11}],10:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimLocalStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;"getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams});if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(function(n){return t.call(r,n,e)}),e.getVideoTracks().forEach(function(n){return t.call(r,n,e)})},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=Array(n>1?n-1:0),a=1;a=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}})}),t.apply(e,arguments)}}},r.shimCallbacksAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype,r=t.createOffer,i=t.createAnswer,a=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n};var c=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=c,c=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=c,c=function(e,t,r){var n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=c},r.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(a(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))},r.shimConstraints=a,r.shimRTCIceServerUrls=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],a=0;a=r&&parseInt(n[r],10)}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function c(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach(function(n){n.endsWith("Id")?c(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach(function(t){c(e,e.get(t),r)})}))}},{}],12:[function(e,t,r){},{}],13:[function(e,t,r){var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},n.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},n.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),r},n.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},n.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},n.getCryptoParameters=function(e,t){return n.matchPrefix(e+t,"a=crypto:").map(n.parseCryptoLine)},n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0],i=n.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){r+=n.writeExtmap(e)}),r},n.parseRtpEncodingParameters=function(e){var t,r=[],i=n.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,d=n.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});d.length>0&&d[0].length>1&&d[0][0]===c&&(t=d[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),a&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},r.push(n))}}),0===r.length&&c&&r.push({ssrc:c});var u=n.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,r.forEach(function(e){e.maxBitrate=u})),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var a=n.matchPrefix(e,"a=rtcp-mux");return t.mux=a.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var i=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),i=n.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var a=n.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var o=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var i=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,i){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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 o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,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:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a},n.getDirection=function(e,t){for(var r=n.splitLines(e),i=0;i-1}function U(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Me.prototype.set=function(e,t){var r=this.__data__,n=Oe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new Ce,map:new(fe||Me),string:new Ce}},Pe.prototype.delete=function(e){return Ue(this,e).delete(e)},Pe.prototype.get=function(e){return Ue(this,e).get(e)},Pe.prototype.has=function(e){return Ue(this,e).has(e)},Pe.prototype.set=function(e,t){return Ue(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,i),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.clear=function(){this.__data__=new Me},Re.prototype.delete=function(e){return this.__data__.delete(e)},Re.prototype.get=function(e){return this.__data__.get(e)},Re.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Me){var i=n.__data__;if(!fe||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ie:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ot(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function st(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||st(e)&&oe.call(e)==k}var dt=j?function(e){return function(t){return e(t)}}(j):function(e){return st(e)&&at(e.length)&&!!O[oe.call(e)]};function ut(e){return nt(e)?De(e):He(e)}function lt(e){return e}e.exports=function(e,t){return e&&e.length?function(e,t,n){var i=-1,a=V,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=U;else if(o>=r){var u=t?null:je(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}var Si;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(Si||(Si={}));const{JOIN_ROOM_ERROR:yi,ERROR_RECONNECT_FAILED:ki}=Yn;class _i extends bi{constructor(e,t,r,n,i,a=["subscribe","publish"]){super(),this.privileges=[],this.rpcid=si(16),this.startInitTime=-1,this.startAuthTime=0,this.initWs=((e=!1,t,r)=>new Promise((n,i)=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.close(),this.ws.onclose=null),e)this.ws=t,this.setUrl(r);else{this.startInitTime=Date.now();try{this.wsConnectTimeoutID=setTimeout(()=>{this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close());const t=this.wsConnectTimeout/1e3+"s timeout";gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,socket_connect_error_message:t,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=Si.CONNECTING}catch(e){throw kn(`init signaling websocket faild!\nError: ${e}`)}}this.ws.onerror=this.onWsError,this.ws.onclose=this.onWsClose.bind(this,n,i);const a=()=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.emit("ws:onopen"),jr.log("signaling: websocket open",this.url),e||(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!0,event_grade:An.NORMAL,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Hr,capsdp:this.capsdp,msgsn:this.customMsgNumber,supportdomain:!0,privileges:this.privileges};this.playerdata&&(t.playerdata=this.playerdata),this.startAuthTime=Date.now(),this.request("auth",t).then(t=>{switch(0!==t.code&&(gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:t.code,auth_error_message:t.error,auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.SERVERE,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.startAuthTime=0),t.code){case 0:this.ws.onclose=this.onWsClose.bind(this,null,null),this.reconnectToken=t.reconntoken,jr.log("signaling: websocket authed"),this._state=Si.OPEN,gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:0,auth_error_message:"",auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.emit("@signalingauth",t),this.startAuthTime=0,n(t);break;case 10001:case 10002:case 10011:case 10022:case 10012:case 10004:this.emit("@error",t),i(ki(t.error));break;case 10005:this.emit("@error",t),i(ki(t.error));case 10052:if(jr.debug("10052 auth, retry",e),this.reconnectToken=void 0,e){i(yi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(Xn(10054,t.error));break;default:i(kn(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=Si.CLOSED,this.release())})};this.ws.onopen=(()=>{a()}),e&&a()})),this.onWsMsg=(e=>{const t=e.data;this.emit("ws:onmessage",t);const r=t.indexOf("=");if(!(r>0))throw kn(`signaling model can not parse message: ${t}`);{const e=t.substring(0,r),n=JSON.parse(t.substring(r+1));this.receiveWsMsg(e,n)}}),this.onWsError=(e=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),jr.warning("signaling: websocket error",e),this.emit("@ws:error",e),-1!==this.startInitTime&&(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:""}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw Bn();const r=JSON.stringify(t);try{this.ws.send(`${e}=${r}`),this.emit("send",e,t)}catch(e){throw jr.warning("signaling: websocket send error",e),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)}),Bn()}}),this.handlePing=(()=>{this.sendWsMsg("pong",{}),this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.reconnectTimeoutID=setTimeout(()=>{jr.debug("signaling: websocket heartbeat timeout"),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)})},9e3)}),this.receiveWsMsg=((e,t)=>{switch(this.emit("receive",e,t),e){case"ping":this.handlePing();break;case"auth-res":this.emit("@auth-res",t);case"pubpc-res":case"subpc-res":case"pub-tracks":case"webrtc-candidate":case"on-player-in":case"on-player-out":case"disconnect":case"mute-tracks":case"on-add-tracks":case"on-remove-tracks":case"on-player-reconnect":case"on-player-reconnect-in":this.emit(e,t);break;case"sub-res":case"unsub-res":this.emit(e,t),this.emit(`${e}-${t.streamid}`,t);break;case"control-res":this.emit(e,t),this.emit(`${e}-${t.command}-${t.playerid}`,t);break;case"on-pubpc-connected":case"on-pubpc-disconnected":this.emit("on-pubpc-state",{pcid:t.pcid,connected:"on-pubpc-connected"===e}),this.emit(`${e}-${t.pcid}`,t);break;case"on-subpc-disconnected":case"on-subpc-connected":this.emit("on-subpc-state",{pcid:t.pcid,connected:"on-subpc-connected"===e}),this.emit(e,t);break;case"pub-tracks-res":this.emit(e,t);break;case"on-messages":case"on-qos-messages":t.messages=t.messages.sort((e,t)=>e.msgsn-t.msgsn),this.customMsgNumber=t.messages[t.messages.length-1].msgsn,this.emit(e,t);break;case"unpub-tracks-res":case"sub-tracks-res":case"unsub-tracks-res":case"on-pubpc-restart-notify":case"on-subpc-restart-notify":case"set-sub-profile-res":case"on-sub-profile-changed":case"pubpc-restart-res":case"subpc-restart-res":case"create-merge-job-res":case"create-forward-job-res":case"stop-forward-res":case"on-job-connected":case"on-job-disconnected":case"on-merge-job-connected":case"on-merge-job-disconnected":case"update-merge-tracks-res":case"set-privileges-res":case"start-media-relay-res":case"update-media-relay-res":case"stop-media-relay-res":case"on-media-relay-state":this.emit(e,t)}}),this.accessToken=e,this.capsdp=t,this.reconnectTimes=r,this.wsConnectTimeout=n,this.playerdata=i,this.privileges=a,this._state=Si.CONNECTING}set _state(e){this.emit("@ws-state-change",this.__state,e),this.__state=e}get state(){return this.__state}set reconnectTimes(e){this._reconnectTimes=e,this.currentLeftReconnectTimes=e}get reconnectTimes(){return this._reconnectTimes}setUrl(e){this.url=e+`?rpcid=${this.rpcid}`}onWsClose(e,t,r){this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this._state=Si.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:r.code,auth_error_message:r.toString(),auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:this.url,auth_reason:"connect"});let n=this.reconnectPromise;switch(r.code){case 1e3:this.emit("@closed");break;case 1001:case 1005:case 1006:n=this.reconnect();break;case 1007:case 1008:case 1009:case 1010:break;case 1011:n=this.reconnect();break;case 1012:n=this.reconnect(5e3);break;case 1013:n=this.reconnect();break;case 1014:n=this.reconnect(5e3)}e&&t&&(n?n.then(e).catch(e=>{jr.warning("signaling: reconnect error",e)}):t(r))}sendDisconnect(){if(this.state===Si.OPEN)try{this.sendWsMsg("disconnect",{})}catch(e){}}reconnect(e=1e3){return this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.reconnectPromise&&this._state===Si.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=Si.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=ci(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=Si.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=si(8);return t.rpcid=r,jr.log("ws request",r,e,t),this.sendWsMsg(e,t),new Promise(t=>{const n=i=>{i.rpcid===r&&(jr.log("ws response",r,e,i),this.off(`${e}-res`,n),t(i))};this.on(`${e}-res`,n)})}release(){this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.removeEvent(),this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close())}}class wi{}class Ei{constructor(e,t,r,n){this.videoTrackInfo=[],this.audioTrackInfo=[],this.layoutLevel=0,this.width=e,this.height=t,this.jobID=n,this.controller=r,this.controller.getCurrentTracks().forEach(e=>{"audio"===e.kind?this.audioTrackInfo.push(e):this.videoTrackInfo.push(e)}),this.controller.addMergeTrack(this.audioTrackInfo.map(e=>({trackID:e.trackID})),this.jobID),this.initLayout(),this.controller.onAddTracks=(e=>{const t=e.filter(e=>"audio"===e.kind),r=e.filter(e=>"video"===e.kind);this.controller.addMergeTrack(t.map(e=>({trackID:e.trackID})),this.jobID),r.forEach(this.handleAddVideoTrack.bind(this))}),this.controller.onRemoveTracks=(e=>{e.filter(e=>"video"===e.kind).forEach(this.handleRemoveVideoTrack.bind(this))}),jr.log("init default merger, init layout: ",this.layout)}initLayout(){const e=this.videoTrackInfo.length;this.layoutLevel=0,this.layout={"level-0":{items:{"item-0":{x:0,y:0,isExpand:!1,isExpanded:!1,index:0}},itemWidth:this.width,itemHeight:this.height,maxItems:1,currentItems:0,splitWidthFlag:this.width=this.height;if(0!==e){for(;Math.pow(2,this.layoutLevel)=this.height?a:0,y:this.width{const n=this.layout[`level-${this.layoutLevel-1}`].items[r],i=2*n.index;t[`item-${i}`]={x:n.x,y:n.y,isExpand:!1,isExpanded:!1,index:i},t[`item-${i+1}`]=e?{x:n.x+a,y:n.y,isExpand:!1,isExpanded:!1,index:i+1}:{x:n.x,y:n.y+o,isExpand:!1,isExpanded:!1,index:i+1}})}jr.log(`merger: increase layout level, current level: ${this.layoutLevel}`,this.layout)}setLevelLayoutStream(){const e=this.videoTrackInfo.length,t=this.layout[`level-${this.layoutLevel}`];let r=t.maxItems-e,n=0;for(let e=0;e0?e%2==0?(t.items[`item-${e}`].isExpand=!0,t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1):(t.items[`item-${e}`].isExpanded=!0,r-=1):(t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1);t.currentItems=e}sendMergeOpt(e,t){const r=this.layout[`level-${e}`],n=r.items[`item-${t}`];if(!n.trackID||n.isExpanded)return;let i=r.itemWidth,a=r.itemHeight;n.isExpand&&(r.splitWidthFlag?i*=2:a*=2);const o={x:n.x,y:n.y,w:i,h:a,z:0,trackID:n.trackID};this.controller.addMergeTrack([o],this.jobID)}handleRemoveVideoTrack(e){M(this.videoTrackInfo,t=>t.trackID===e.trackID);const t=this.layout[`level-${this.layoutLevel}`];if(this.layoutLevel>0&&this.videoTrackInfo.length<=this.layout[`level-${this.layoutLevel-1}`].maxItems)this.layoutLevel-=1,jr.log(`merger: reduce layout level, current level: ${this.layoutLevel}`,this.layout),this.setLevelLayoutStream();else for(const r in t.items){const n=t.items[r];if(n.trackID===e.trackID){n.index%2==0?(t.items[`item-${n.index+1}`]?(n.isExpand=!0,n.trackID=t.items[`item-${n.index+1}`].trackID,t.items[`item-${n.index+1}`].isExpanded=!0,t.items[`item-${n.index+1}`].trackID=void 0):n.trackID=void 0,this.sendMergeOpt(this.layoutLevel,n.index)):(n.isExpanded=!0,n.trackID=void 0,t.items[`item-${n.index-1}`].isExpand=!0,this.sendMergeOpt(this.layoutLevel,n.index-1));break}}}handleAddVideoTrack(e){const t=this.videoTrackInfo.length;if(this.videoTrackInfo.push(e),this.videoTrackInfo=mi(this.videoTrackInfo,"trackID"),this.videoTrackInfo.length===t)return void jr.log("handle add video track ignore",e);const r=this.layout[`level-${this.layoutLevel}`];if(this.videoTrackInfo.length<=r.maxItems){for(const t in r.items){const n=r.items[t];if(!n.trackID){n.trackID=e.trackID,n.isExpanded&&(n.isExpanded=!1,r.items[`item-${n.index-1}`].isExpand=!1,this.sendMergeOpt(this.layoutLevel,n.index-1)),this.sendMergeOpt(this.layoutLevel,n.index);break}}r.currentItems=this.videoTrackInfo.length}else this.updateLayoutLevel(!r.splitWidthFlag),this.setLevelLayoutStream()}release(){this.controller.release()}}function Ci(e){const t=document.createElement("audio"),r=new MediaStream([e]);return t.style.visibility="hidden",t.className="qnrtc-audio-player qnrtc-stream-player",t.dataset.localid=e.id,t.srcObject=r,t.autoplay=!0,t}function Mi(e){const t=document.createElement("video"),r=new MediaStream([e]);return t.style.width="100%",t.style.height="100%",t.style.objectFit="contain",t.muted=!0,t.className="qnrtc-video-player qnrtc-stream-player",t.dataset.localid=e.id,t.setAttribute("playsinline",!0),t.autoplay=!0,t.srcObject=r,T&&(t.setAttribute("controls",!0),ai(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),t}class Pi extends bi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=L.NORMAL,this.onended=(async e=>{"local"===this.direction?(jr.warning("track ended",this.mediaTrack,this.info.trackID),this.info.trackID&&this._selfEndedCallback&&await this._selfEndedCallback([this.info.trackID]),this.emit("ended",e),gn.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label,event_grade:An.SERVERE}),this.release()):this.emit("@ended",e)}),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.userID=t,r&&(this.direction=r),this.info={kind:e.kind,muted:!e.enabled,userID:this.userID,versionid:0,profiles:n||[]},this.handleMediaPause=this.handleMediaPause.bind(this)}async setPlaybackDevice(e){if(E.setPlaybackDevice||wn("setPlaybackDevice api not support"),this.playbackDevice=e,this.mediaElement)return this.mediaElement.setSinkId(e)}play(e,t,r={mirror:!1}){return new Promise((n,i)=>{this.removeMediaElement();const a="video"===this.info.kind?Mi:Ci;this.mediaElement=a(this.mediaTrack),"audio"===this.info.kind&&void 0!==t&&(this.mediaElement.muted=t),r.mirror?this.mediaElement.style.transform="rotateY(180deg)":this.mediaElement.style.transform="",this.mediaElement.setAttribute("controls",!0),e.appendChild(this.mediaElement),this.mediaElement.onplaying=(()=>{this.mediaElement.onplaying=null,n()}),Promise.resolve().then(()=>{if(this.mediaElement.removeAttribute("controls"),this.playbackDevice)return this.setPlaybackDevice(this.playbackDevice)}).then(()=>{(function(e,t=3e3){const r=async()=>{if(e.paused)return e.play()};return new Promise((n,i)=>{const a=setTimeout(()=>{r().then(n).catch(i)},t);e.onloadedmetadata=(()=>{clearTimeout(a),r().then(n).catch(i)}),"WeixinJSBridge"in window?window.WeixinJSBridge.invoke("getNetworkType",{},()=>{r().then(n).catch(ni)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(ni)},!1)})})(this.mediaElement).then(n).catch(e=>{const t=e instanceof Error?e.name+", "+e.message:"play failed"+String(e);"NotAllowedError"===e.name?(i(En(t)),gn.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t,event_grade:An.SERVERE})):i(kn(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(li),900)}switchPlayingTrack(){if(this.mediaElement){if(this.isReplacedByImageTrack&&this.imageStreamTrack)this.mediaElement.srcObject=new MediaStream([this.imageStreamTrack.mediaTrack]);else{if(this.isReplacedByImageTrack||!this.mediaTrack)return;this.mediaElement.srcObject=new MediaStream([this.mediaTrack])}this.mediaElement.paused||this.mediaElement.play().catch(li)}}resume(e){if(this.mediaTrack.removeEventListener("ended",this.onended),this.mediaTrack.stop(),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.mediaElement){const t=new MediaStream([e]);this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t}this.removeEvent("@get-stats"),this.resetStats()}getStats(){return this.statsInterval||this.startGetStatsInterval(),this.stats}getCurrentFrameDataURL(){return this.mediaElement&&this.mediaElement instanceof HTMLVideoElement?function(e){const t=document.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;const r=t.getContext("2d");return r?(r.drawImage(e,0,0,e.videoWidth,e.videoHeight),t.toDataURL()):"data:,"}(this.mediaElement):"data:,"}setMaster(e){this.master=e}setMute(e){this.info.muted=e,this.mediaTrack.enabled=!e,this.emit("mute",e)}setKbps(e){this.info.kbps=e}setInfo(e){this.info=t({},this.info,e)}removeMediaElement(){this.mediaElement&&(this.mediaElement.removeEventListener("pause",this.handleMediaPause),this.mediaElement.remove(),this.mediaElement=void 0)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),"local"!==this.direction&&E.unifiedPlan||this.mediaTrack.stop(),this.removeMediaElement(),this.imageStreamTrack&&(this.imageStreamTrack.release(),this.imageStreamTrack=void 0)}reset(){this.info.trackID=void 0,this.info.userID=void 0,this.info.versionid=0,this.userID=void 0,this.resetStats()}resetStats(){this.stats=[],this.lastStats=[]}async startGetStatsInterval(){this.statsInterval=window.setInterval(async()=>{const e=this.getListeners("@get-stats");if(!e||0===e.length)return[];this.stats=await this.safeEmitAsPromise("@get-stats",this.lastStats),this.lastStats=[...this.stats]},1e3)}set selfEndedCallback(e){this._selfEndedCallback=e}setVolume(e){jr.warning("not implement")}getCurrentTimeDomainData(){return jr.warning("not implement"),new Uint8Array}getCurrentFrequencyData(){return jr.warning("not implement"),new Uint8Array}getVolume(){return jr.warning("not implement"),0}getCurrentVolumeLevel(){return jr.warning("not implement"),0}setLoop(e){jr.warning("not implement")}startAudioSource(){jr.warning("not implement")}pauseAudioSource(){jr.warning("not implement")}resumeAudioSource(){jr.warning("not implement")}stopAudioSource(){jr.warning("not implement")}getCurrentTime(){return jr.warning("not implement"),0}setCurrentTime(e){jr.warning("not implement")}getDuration(){return jr.warning("not implement"),0}}class Ii{static loadImage(e){if(e instanceof File)return Ii.loadImageFromFile(e);if(e instanceof ArrayBuffer)return Ii.loadImageFromArrayBuffer(e);if("string"==typeof e)return Ii.loadImageFromUrl(e);throw wn("unsupported image source")}static loadImageFromUrl(e){return new Promise((t,r)=>{var n=new Image;n.crossOrigin="Anonymous",n.src=e,n.onload=function(){t(n)},n.onerror=function(e){r(e)}})}static loadImageFromFile(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=(e=>{n.result&&t(Ii.loadImageFromUrl(n.result))}),n.onerror=(e=>{r(e)}),n.readAsDataURL(e)})}static loadImageFromArrayBuffer(e){return new Promise((t,r)=>{const n=new Blob([e]),i=URL.createObjectURL(n);t(Ii.loadImageFromUrl(i))})}}class Ri{constructor(){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}async setSource(e){e!==this.source&&(this.source=e,await this.createImageStreamTrack(e))}get id(){if(this.mediaTrack)return this.mediaTrack.id}async createImageStreamTrack(e){let t;t=e instanceof File?await Ii.loadImageFromFile(e):e instanceof ArrayBuffer?await Ii.loadImageFromArrayBuffer(e):await Ii.loadImageFromUrl(e),this.canvas.width=t.width,this.canvas.height=t.height,this.drawIntervalId&&clearInterval(this.drawIntervalId),this.drawIntervalId=setInterval(()=>{this.ctx.drawImage(t,0,0)},900);const r=this.canvas.captureStream(1);this.mediaTrack=r.getTracks()[0]}release(){this.drawIntervalId&&clearInterval(this.drawIntervalId)}}class Di{constructor(){this.recordedChunks=[]}releaseMediaElement(){jr.log("Recorder release Media Element",this.mediaElement),this.mediaElement&&this.mediaElement.parentElement&&this.mediaElement.parentElement.removeChild(this.mediaElement)}release(){this.recorder&&"inactive"!==this.recorder.state&&this.recorder.stop(),this.recorder=void 0,this.recordedChunks=[],this.recordedBlob=void 0,this.recordedUrl&&(window.URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=void 0),this.releaseMediaElement()}setMimeType(e){if(jr.log("Recorder setMimeType, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");return!!window.MediaRecorder.isTypeSupported(e)&&(this.mimeType=e,!0)}start(e){if(jr.log("Recorder start, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw kn("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw kn("MediaRecorder is active, cannot start again.");if(e.reduce((e,t)=>("video"===t.mediaTrack.kind&&(e[0]+=1),"audio"===t.mediaTrack.kind&&(e[1]+=1),e),[0,0]).some(e=>e>1))throw kn("Invalid parameters.");this.release();try{const t=new MediaStream(e.map(e=>e.mediaTrack)),r=window;if(this.mimeType){const e={mimeType:this.mimeType};this.recorder=new r.MediaRecorder(t,e)}else this.recorder=new r.MediaRecorder(t);this.recorder.ondataavailable=(e=>{jr.debug("Recorder data, ",e.data),this.recordedChunks.push(e.data)}),this.recorder.start(Di.recorderTimeslice)}catch(e){throw kn("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw kn("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw kn("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw kn("MediaRecorder is in inactive state, cannot do stop.");try{if(this.recorder.stop(),this.mimeType){const e={type:this.mimeType};this.recordedBlob=new Blob(this.recordedChunks,e)}else this.recordedBlob=new Blob(this.recordedChunks);return this.recordedUrl=window.URL.createObjectURL(this.recordedBlob),this.recordedBlob}catch(e){throw kn("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw kn("No recorded data, please start record first.");this.releaseMediaElement();const r=document.createElement("video");return r.style.width="100%",r.style.height="100%",r.style.objectFit="contain",r.controls=!0,r.muted=t,r.className="qnrtc-recorder-video-player",r.setAttribute("playsinline",!0),r.autoplay=!0,r.src=this.recordedUrl,e.appendChild(r),this.mediaElement=r,new Promise((e,t)=>{let n;try{n=r.play()}catch(e){t(e)}n?n.then(e).catch(e=>{t(e);try{throw kn("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw kn("No recorded data, please start record first.");const t=document.createElement("a");t.style.display="none",t.href=this.recordedUrl,t.download=e,document.body.appendChild(t),t.click(),setTimeout(()=>{document.body.removeChild(t)},100)}}Di.recorderTimeslice=1e3;class Oi{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class xi{constructor(e,t,r,n,i){this._connectStatus=B.Idle,this.track=r,this.trackID=n,this.mid=i,this.transport=e,this.direction=t}get connectStatus(){return this._connectStatus}set connectStatus(e){if(e!==this._connectStatus){const t=this._connectStatus;this._connectStatus=e,ai(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=B.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===B.Connect&&e(),n===B.Idle&&t()})})}appendConsumner(e,t){this.consumer=new Oi(this.trackID,this.mid,t,e),this.transport.appendConsumer(this.consumer)}setMute(e){this.track&&this.track.setMute(e)}addTrackId(e){this.track&&(this.trackID=e,this.track.setInfo({trackID:e}))}release(){this.consumer&&this.transport?(this.transport.recvHandler.isPcReady&&this.transport.removeConsumers([this.consumer]),this.track&&this.track.release()):this.track&&this.track.reset()}}const Bi=window.AudioContext||window.webkitAudioContext||window.Object,Li=E.audioContextOptions?new Bi({latencyHint:"interactive"}):new Bi;if(window.audioContext=Li,window.Promise){const e=()=>{(function(e){return new Promise((t,r)=>{if("suspended"===e.state){jr.log("audio context state is suspended");const n=()=>{e.resume().then(()=>{document.body.removeEventListener("touchstart",n),document.body.removeEventListener("touchend",n),document.body.removeEventListener("mousedown",n),document.body.removeEventListener("mouseup",n),t(!0)}).catch(r)};document.body.addEventListener("touchstart",n,!0),document.body.addEventListener("touchend",n,!0),document.body.addEventListener("mousedown",n,!0),document.body.addEventListener("mouseup",n,!0),n()}else t(!1)})})(Li).then(e=>{jr.debug("web audio context unlocked",e)}).catch(e=>{jr.warning("can not unlock web audio context",e)}),window.removeEventListener("load",e)};document.body?e():window.addEventListener("load",e),Li.onstatechange=(()=>{e()})}const Gi=2048,Ni=4096,Hi=["play","playing","pause","ended","waiting","seeking"];class Fi extends bi{constructor(){super(),this.audioSource=null,this._audioSourceState=H.IDLE,this.bufferSourceDuration={startTime:0,pauseTime:0,lastPauseTime:0,offsetTime:0,stopTime:0},this.handleMediaElementEvents=(e=>{switch(e.type){case"playing":case"play":this.audioSourceState=H.PLAY;break;case"waiting":case"seeking":this.audioSourceState=H.LOADING;break;case"ended":this.audioSourceElement&&(this.audioSourceElement.currentTime=0),this.audioSourceState=H.END}})}get audioSourceState(){return this._audioSourceState}set audioSourceState(e){e!==this._audioSourceState&&(this.emit("@audio-source-state-change",e,this._audioSourceState),this._audioSourceState=e)}initAudioContext(){jr.log("init audio context",Li.state),"suspended"===Li.state&&(jr.log("audio context suspended"),Li.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",Li.state),this.analyserNode=Li.createAnalyser(),this.analyserNode.fftSize=Gi,this.gainNode=Li.createGain(),function(e){if(E.disconnectAudioNode)return;const t=e.connect,r=e.disconnect;e.connect=((r,n,i)=>(e._inputNodes||(e._inputNodes=[]),r instanceof AudioNode?(e._inputNodes.push(r),e._inputNodes=mi(e._inputNodes,e=>e),t.call(e,r,n,i)):t.call(e,r,n),e)),e.disconnect=((t,n,i)=>{if(!t)return r.call(e),void(e._inputNodes=[]);r.call(e,t,n,i),M(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),E.mediaStreamDest&&(this.audioStream=Li.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=Li.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=Li.createBufferSource(),this.audioSource.onended=(()=>{this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Li.currentTime,this.audioSourceState=H.END}),this.connect()}setMediaElementSource(e){this.audioSource=Li.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Hi)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.isAudioSource()?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.isAudioSource()&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.isAudioSource()){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Li.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(li)):null===this.audioSource&&this.audioSourceBuffer&&(this.resetBufferSourceDuration(),this.setAudioBufferSource(),this.setAudioBuffer(this.audioSourceBuffer),this.setAudioSourceLoop(!!this.audioSourceLoop),this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Li.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY)}resumeAudioSource(){if(this.isAudioSource()){if(this.audioSourceState!==H.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=Li.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=H.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(li)}pauseAudioSource(){this.isAudioSource()?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=Li.currentTime),this.audioSourceState=H.PAUSE):this.audioSourceElement&&(this.audioSourceElement.pause(),this.audioSourceState!==H.END&&(this.audioSourceState=H.PAUSE))}stopAudioSource(e=!1,t=!1){this.isAudioSource()?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Li.currentTime,e||!1!==t||(this.audioSourceState=H.STOP)):this.audioSourceElement&&(!1===t&&(this.audioSourceState=H.STOP),this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.isAudioSource()){let e=Li.currentTime;const t=this.getAudioSourceDuration();this.bufferSourceDuration.lastPauseTime&&(e=this.bufferSourceDuration.lastPauseTime),this.bufferSourceDuration.stopTime&&(e=this.bufferSourceDuration.stopTime);const r=this.bufferSourceDuration.offsetTime+e-this.bufferSourceDuration.startTime-this.bufferSourceDuration.pauseTime;return Math.max(0,r%t)}return 0}setAudioSourceCurrentTime(e){this.audioSourceElement?this.audioSourceElement.currentTime=e:this.isAudioSource()&&(this.stopAudioSource(!0),this.playAudioSource(e))}getAudioSourceDuration(){return this.audioSourceElement?this.audioSourceElement.duration:this.audioSourceBuffer?this.audioSourceBuffer.duration:0}release(){if(this.audioSource instanceof MediaStreamAudioSourceNode&&this.audioSource.mediaStream&&this.audioSource.mediaStream.getTracks().map(e=>e.stop()),this.audioSource&&this.audioSource.disconnect(),this.gainNode.disconnect(),this.audioSourceElement){for(const e of Hi)this.audioSourceElement.removeEventListener(e,this.handleMediaElementEvents);this.audioSourceElement.src="",this.audioSourceElement.load(),this.audioSourceElement.remove(),this.audioSourceElement=void 0}this.scriptNode&&this.scriptNode.disconnect()}connect(){this.audioSource?(this.audioSource.connect(this.analyserNode),this.audioSource.connect(this.gainNode),this.audioStream&&(this.gainNode.connect(this.audioStream),this.onAudioBuffer())):jr.warning("no audio source, can not connect")}handleAudioBuffer(e){const t=e.inputBuffer;this.emit("audioBuffer",t),this.audioBufferCallback&&this.audioBufferCallback(t)}onAudioBuffer(e,t=Ni){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=Li.createScriptProcessor(t),this.audioSource.connect(this.scriptNode),this.scriptNode.connect(this.audioStream),this.scriptNode.onaudioprocess=this.handleAudioBuffer.bind(this)))}resetBufferSourceDuration(){this.bufferSourceDuration={offsetTime:0,startTime:0,lastPauseTime:0,pauseTime:0,stopTime:0}}isAudioSource(){const{audioSource:e}=this;return e instanceof AudioBufferSourceNode||e instanceof AudioScheduledSourceNode}}const ji=0;class Vi extends Pi{constructor(e,t,r){if("audio"!==e.kind)throw new Error("audio track only!");super(e,t,r),this.mediaStream=new MediaStream,this.mediaStream.addTrack(e)}resume(e){this.mediaTrack=e,this.removeEvent("@get-stats"),this.resetStats();const t=new MediaStream([e]);this.mediaStream=t,this.mediaElement&&(this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t),this.audioManager&&(this.audioManager.release(),this.initAudioManager())}initAudioManager(e){this.audioManager=new Fi,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&E.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){this.audioManager.gainNode.gain.setValueAtTime(e,Li.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Gi);return this.audioManager.analyserNode.getByteTimeDomainData(e),e}getCurrentFrequencyData(){const e=new Uint8Array(this.audioManager.analyserNode.frequencyBinCount);return this.audioManager.analyserNode.getByteFrequencyData(e),e}getVolume(){return this.audioManager.gainNode.gain.value}getCurrentVolumeLevel(){const e=this.getCurrentFrequencyData();let t=0,r=e.length;return e.forEach((n,i)=>{const a=i*(Li.sampleRate||44100)/e.length;if(a>22050)return void(r-=1);const o=function(e){const t=e*e;return 1.2588966*14884e4*t*t/((t+424.36)*Math.sqrt((t+11599.29)*(t+544496.41))*(t+14884e4))}(a)*n/255;o<=ji?r-=1:t+=o*o}),0===r?0:Math.sqrt(t/r)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),this.audioManager&&this.audioManager.release(),this.removeMediaElement(),this.mediaTrack.stop()}}var Ui=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i};var qi=function(e,t){if(null==e)return{};var r,n,i=Ui(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i};const Wi="\n";var zi=u(function(e){var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach(function(e){t[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})}),Xi=(zi.v,zi.o,zi.s,zi.i,zi.u,zi.e,zi.p,zi.z,zi.r,zi.t,zi.c,zi.b,zi.m,zi.a,u(function(e,t){var r=function(e){return String(Number(e))===e?Number(e):e},n=function(e,t,n){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var a=e.push?{}:i?t[e.name]:t;!function(e,t,n,i){if(i&&!n)t[i]=r(e[1]);else for(var a=0;a1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),i=0;i=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})}.apply(null,n)},Ji=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Zi=["i","c","b","a"],$i={write:function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var r=t.outerOrder||Ji,n=t.innerOrder||Zi,i=[];return r.forEach(function(t){zi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Qi(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Qi(t,r,e))})})}),e.media.forEach(function(e){i.push(Qi("m",zi.m[0],e)),n.forEach(function(t){zi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Qi(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Qi(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Xi.parse,parseParams:Xi.parseParams,parseFmtpConfig:Xi.parseFmtpConfig,parsePayloads:Xi.parsePayloads,parseRemoteCandidates:Xi.parseRemoteCandidates,parseImageAttributes:Xi.parseImageAttributes,parseSimulcastStreamList:Xi.parseSimulcastStreamList};const Yi="qiniu-rtc-client";function ea(e){return e.map(e=>{const t={component:1,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,transport:e.protocol,type:e.type};return e.tcpType&&(t.tcptype=e.tcpType),t})}class ta{constructor(e,t){this.lastSubMids=[],this.sessionVersion=0,this.direction=e,this.extendedRtpCapabilities=t}get transportRemoteParameters(){return this._transportRemoteParameters}async setTransportRemoteParameters(e){for(const t of e.iceCandidates)t.ip=await hi(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");return E.unifiedPlan?function(e,t,r,n,i){const a=$i.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Yi},o.name="-",o.timing={start:0,stop:0},o.icelite=t.iceParameters.iceLite?"ice-lite":void 0,o.msidSemantic={semantic:"WMS",token:"*"},o.media=[],o.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};for(const r of a.media){const a="inactive"===r.direction,s=r.type,c="audio"===s?e.codecs[0]:e.codecs[1],d=e.headerExtensions.filter(e=>e.kind===s),u={type:r.type,port:i&&i.has(String(r.mid))?0:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:r.mid,iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ea(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"sendonly"===r.direction||"sendrecv"===r.direction?"recvonly":"inactive",rtp:[{payload:c.sendPayloadType,codec:c.name,rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}],rtcpFb:[],fmtp:[{payload:c.sendPayloadType,config:Object.keys(c.parameters).map(e=>`${e}=${c.parameters[e]};`).join("")}],payloads:c.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:d.map(e=>({uri:e.uri,value:e.sendId}))};c.rtcpFeedback&&c.rtcpFeedback.length>0&&c.rtcpFeedback.forEach(e=>{u.rtcpFb.push({payload:c.sendPayloadType,type:e.type,subtype:e.parameter})}),c.sendRtxPayloadType&&(u.rtp.push({payload:c.sendRtxPayloadType,codec:"rtx",rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}),u.fmtp.push({payload:c.sendRtxPayloadType,config:`apt=${c.sendPayloadType};`}),u.payloads=`${c.sendPayloadType} ${c.sendRtxPayloadType}`),na(s,u,e,c);const l=n[u.mid];"video"===u.type&&l&&!a&&(u.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],u.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(u)}const s=(a.media||[]).filter(e=>e.hasOwnProperty("mid")&&0!==e.port).map(e=>String(e.mid));s.length>0&&(o.groups=[{type:"BUNDLE",mids:s.join(" ")}]);return $i.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=$i.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Yi},n.name="-",n.timing={start:0,stop:0},n.icelite=t.iceParameters.iceLite?"ice-lite":void 0,n.msidSemantic={semantic:"WMS",token:"*"},n.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};const i=[];for(const r of n.media){const n=r.type,a=e.codecs.find(e=>e.kind===n),o=(e.headerExtensions||[]).filter(e=>e.kind===n);if(!a)throw kn("can not find codec"+n);const s={type:n,mid:n,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ea(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"recvonly",rtp:[{payload:a.sendPayloadType,codec:a.name,rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}],rtcpFb:[],fmtp:[{payload:a.sendPayloadType,config:Object.keys(a.parameters).map(e=>`${e}=${a.parameters[e]};`).join("")}],payloads:a.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:o.map(e=>({uri:e.uri,value:e.sendId}))};a.rtcpFeedback&&a.rtcpFeedback.length>0&&a.rtcpFeedback.forEach(e=>{s.rtcpFb.push({payload:a.sendPayloadType,type:e.type,subtype:e.parameter})}),a.sendRtxPayloadType&&(s.rtp.push({payload:a.sendRtxPayloadType,codec:"rtx",rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}),s.fmtp.push({payload:a.sendRtxPayloadType,config:`apt=${a.sendPayloadType};`}),s.payloads=`${a.sendPayloadType} ${a.sendRtxPayloadType}`),i.push(s)}return n.media=i,$i.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");if(E.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=M(e,e=>e.mid===n)[0];t&&r.push(t)}return r=r.concat(e),t=r.map(e=>e.mid),r}(e,this.lastSubMids);return this.lastSubMids=t.map(e=>e.mid),this.sessionVersion+=1,function(e,t,r,n){jr.debug("consumerInfos",e);const i={},a=e.map(e=>e.mid);i.version=0,i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:n,username:Yi},i.name="-",i.timing={start:0,stop:0},i.icelite=r.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},a.length>0&&(i.groups=[{type:"BUNDLE",mids:a.join(" ")}]);i.media=[],i.fingerprint={type:r.dtlsParameters.fingerprints[0].algorithm,hash:r.dtlsParameters.fingerprints[0].value};for(const n of e){const e="audio"===n.kind?t.codecs[0]:t.codecs[1],a=t.headerExtensions.filter(e=>e.kind===n.kind),o={type:n.kind,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:n.mid,msid:`${n.streamId} ${n.trackID}`,iceUfrag:r.iceParameters.usernameFragment,icePwd:r.iceParameters.password,candidates:ea(r.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===r.dtlsParameters.role?"actpass":"active",direction:n.closed?"inactive":"sendonly",rtp:[{payload:e.recvPayloadType,codec:e.name,rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}],rtcpFb:[],fmtp:[{payload:e.recvPayloadType,config:Object.keys(e.parameters).map(t=>`${t}=${e.parameters[t]};`).join("")}],payloads:e.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:n.closed?[]:a.map(e=>({uri:e.uri,value:e.recvId})),ssrcs:!n.closed&&n.ssrc?[{id:n.ssrc,attribute:"cname",value:n.cname}]:[],ssrcGroups:[]};e.rtcpFeedback&&e.rtcpFeedback.length>0&&e.rtcpFeedback.forEach(t=>{o.rtcpFb.push({payload:e.recvPayloadType,type:t.type,subtype:t.parameter})}),e.recvRtxPayloadType&&(o.rtp.push({payload:e.recvRtxPayloadType,codec:"rtx",rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}),o.fmtp.push({payload:e.recvRtxPayloadType,config:`apt=${e.recvPayloadType};`}),o.payloads=`${e.recvPayloadType} ${e.recvRtxPayloadType}`),na(n.kind,o,t,e,!0),n.rtxSsrc&&!n.closed&&(o.ssrcs=o.ssrcs.concat([{id:n.rtxSsrc,attribute:"cname",value:n.cname}]),o.ssrcGroups.push({semantics:"FID",ssrcs:`${n.ssrc} ${n.rtxSsrc}`})),i.media.push(o)}return $i.write(i)}(t,this.extendedRtpCapabilities,this.transportRemoteParameters,this.sessionVersion)}{const t=new Set;return e.forEach(e=>t.add(e.kind)),0===e.length&&(t.add("audio"),t.add("video")),function(e,t,r,n){e=["audio","video"];const i={version:0};i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:2,username:Yi},i.name="-",i.timing={start:0,stop:0},i.icelite=n.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},i.groups=[{type:"BUNDLE",mids:e.join(" ")}],i.media=[],i.fingerprint={type:n.dtlsParameters.fingerprints[0].algorithm,hash:n.dtlsParameters.fingerprints[0].value};for(const a of e){const e=t.filter(e=>e.kind===a),o=r.codecs.find(e=>e.kind===a),s=(r.headerExtensions||[]).filter(e=>e.kind===a);if(!o)throw kn("no codec"+a);const c={type:a,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:a,iceUfrag:n.iceParameters.usernameFragment,icePwd:n.iceParameters.password,candidates:ea(n.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===n.dtlsParameters.role?"actpass":"active",direction:"sendonly",rtp:[{payload:o.recvPayloadType,codec:o.name,rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}],rtcpFb:[],fmtp:[{payload:o.recvPayloadType,config:Object.keys(o.parameters).map(e=>`${e}=${o.parameters[e]};`).join("")}],payloads:o.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ssrcs:[],ssrcGroups:[],ext:s.map(e=>({uri:e.uri,value:e.recvId}))};o.rtcpFeedback&&o.rtcpFeedback.length>0&&o.rtcpFeedback.forEach(e=>{c.rtcpFb.push({payload:o.recvPayloadType,type:e.type,subtype:e.parameter})}),o.recvRtxPayloadType&&(c.rtp.push({payload:o.recvRtxPayloadType,codec:"rtx",rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}),c.fmtp.push({payload:o.recvRtxPayloadType,config:`apt=${o.recvPayloadType};`}),c.payloads=`${o.recvPayloadType} ${o.recvRtxPayloadType}`);for(const t of e)c.ssrcs.push({id:t.ssrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.ssrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"cname",value:`${t.cname}`}),t.rtxSsrc&&(c.ssrcGroups.push({semantics:"FID",ssrcs:`${t.ssrc} ${t.rtxSsrc}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"cname",value:`${t.cname}`}));i.media.push(c)}return $i.write(i)}(Array.from(t),e,this.extendedRtpCapabilities,this.transportRemoteParameters)}}async updateICEData(e,t){if(this.transportRemoteParameters){for(const e of t)e.ip=await hi(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function ra(e){const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});return t.sdp?{isH264:-1!==t.sdp.toLowerCase().indexOf("h264"),sdp:t.sdp}:{isH264:!1,sdp:""}}function na(e,t,r,n,i=!1){const a=r.codecs.filter(t=>t.kind===e&&t.name!==n.name);if(a.length>0){let e=i?n.recvPayloadType:n.sendPayloadType;const r=[];a.forEach(n=>{const a=i?n.recvPayloadType:n.sendPayloadType;r.push(a),t.rtp.push({payload:a,codec:n.name,rate:n.clockRate,encoding:n.channels>1?n.channels:void 0}),t.fmtp.push({payload:a,config:`${e}/${e}`})}),t.payloads=`${t.payloads} ${r.join(" ")}`}}function ia(e){const t=$i.parse(e);if(!("media"in t))return $i.write(t);if(!Array.isArray(t.media))return $i.write(t);for(const e of t.media)"ext"in e&&Array.isArray(e.ext)&&"video"===e.type&&(e.ext=e.ext.filter(e=>"urn:3gpp:video-orientation"!==e.uri));return $i.write(t)}class aa extends bi{constructor(e,t,r){super(),this._isRestartingICE=!1,this.isPcReady=!1,this.midRidEncoding={},this.removeMids=new Set,this.lastMediaStatistics=[],this.intervalId=-1,this.playQualityIntervalId=-1,this.qualityStats=new Map,this._direction=e,this._pc=lo(),this._extendedRtpCapabilities=t,this._remoteSdp=new ta(e,t),this._simulcast=!!r&&r.simulcast,this.coreInstance=r&&r.core,this._pc.addEventListener("iceconnectionstatechange",()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected"),this.registerMediaStatisticStatsReport(),this.registerPlayQualityReport();break;case"failed":this.emit("@connectionstatechange","failed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"disconnected":this.emit("@connectionstatechange","disconnected"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"closed":this.emit("@connectionstatechange","closed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport()}})}async getStats(e,r){return await async function(e,r,n,i){if(E.stats){const a=await async function(e,t,r){let n;try{n=await e.getStats(t)}catch(e){return jr.debug("get stats error, fallback to default",e),[]}if(!n)return jr.debug("get null stats, fallback to default"),[];const i=[];for(const e of n.values())if("send"===r&&"outbound-rtp"===e.type&&!e.isRemote||"recv"===r&&"inbound-rtp"===e.type&&!e.isRemote){const t=$a(),a=n.get(e.remoteId);t.packetLoss=co(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=so(e)||so(a)||0,t.id=e.id,t.kind=e.kind,e.frameWidth&&(t.width=e.frameWidth),e.frameHeight&&(t.height=e.frameHeight),e.framesPerSecond&&(t.frameRate=e.framesPerSecond),e.framerateMean&&(t.frameRate=Math.ceil(e.framerateMean)),i.push(t)}return i}(e,r,n);return function(e,r){if(!r||0===r.length)return e;if(r.length!==e.length)return e;const n=Object.values(Nr([...e,...r],"id"));if(!n.every(e=>2===e.length))return e;return n.map(([e,r])=>{const n=(e.timestamp-r.timestamp)/1e3;if(n<=0)return e;const i=t({},e),a=uo(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=Ya(a,i.rtt);const o=Ja(e.id,e.kind);return o.Apply(a),i.packetLossRate=o.Filtered()<0?0:o.Filtered(),i.bitrate=8*(e.bytes-r.bytes)/n,i.bitrate<0?r:i})}(a,i)}return ui(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}(this._pc,e,this._direction,r)}registerPlayQualityReport(){"send"!==this._direction&&(this.unregisterPlayQualityReport(),this.playQualityIntervalId=window.setInterval(async()=>{const e=await async function(e,t){let r;try{r=await e.getStats()}catch(e){return ui(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return ui(()=>{jr.debug("get null media statistic stats, fallback to default")},"getStats error"),[];const n=[...r.values()];return t.subscribedTracks.map(e=>{const t=e.mediaTrack,r=n.find(e=>e.type===io.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===io.InBoundRtp&&e.trackId===r.id);return i?{time:Date.now(),trackID:e.info.trackID,kind:"video"===i.kind?"video":"audio",framesDecoded:i.framesDecoded||-1,totalSamplesReceived:i.totalSamplesReceived||-1}:void 0}).filter(G)}(this._pc,this.coreInstance);for(const t of e){const e=this.qualityStats.get(t.trackID);e?e.push(t):this.qualityStats.set(t.trackID,[t])}this.addQualityStats()},2e3))}unregisterPlayQualityReport(){"send"!==this._direction&&-1!==this.playQualityIntervalId&&(window.clearInterval(this.playQualityIntervalId),this.addQualityStats(!0),this.playQualityIntervalId=-1)}addQualityStats(e=!1){const t=[...this.qualityStats.values()];if(t.some(e=>e.length>=30)||e){jr.log("quality stats",this.qualityStats);for(const e of t){if(0===e.length)continue;const t=e[0].trackID,r=2*e.length*1e3;if("video"===e[0].kind){const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].framesDecoded===e[n-1].framesDecoded?t+2:t,0);gn.addEvent("VideoPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}else{const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].totalSamplesReceived===e[n-1].totalSamplesReceived?t+2:t,0);gn.addEvent("AudioPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}}this.qualityStats=new Map}}registerMediaStatisticStatsReport(){this.unregisterMediaStatisticStatsReport(),this.intervalId=window.setInterval(async()=>{const e=await async function(e,r){let n;try{n=await e.getStats()}catch(e){return jr.debug("get media statistic stats error, fallback to default",e),[]}if(!n)return jr.debug("get null media statistic stats, fallback to default"),[];const i=[...n.values()];return i.filter(e=>(e.type===io.InBoundRtp||e.type===io.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[io.MediaSource]:r.filter(e=>e.type===io.MediaSource).find(t=>t.id===e.mediaSourceId),[io.Track]:r.filter(e=>e.type===io.Track).find(t=>t.id===e.trackId),[io.RemoteInBound]:r.filter(e=>e.type===io.RemoteInBound).find(t=>t.id===e.remoteId)};let a=function(e,r,n){const i={id:e,track_id:r,kind:"audio",kbps:0,framerate:0,packet_lost_rate:0,rtt:0,extra_stats:null,calculation_stats:t({},ro)};n===no.Audio?i.extra_stats=t({},eo):i.extra_stats=t({},to);return i}(e.id,e.trackID,e.mediaType);a.rtt=so(i[io.RemoteInBound])||so(e)||0,a.calculation_stats.packets_lost=co(e,i[io.RemoteInBound])||0,e.mediaType===no.Video?(a=function(e,t){return t.kind=e.kind,t.extra_stats.nack_count=e.nackCount,t.extra_stats.fir_count=e.firCount,t.extra_stats.pli_count=e.pliCount,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.frame_encoded=e.framesEncoded||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.frame_decoded=e.framesDecoded||0,t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[io.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[io.MediaSource],a)),i[io.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.width=e.frameWidth,t.extra_stats.height=e.frameHeight,t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[io.Track],a,n))):(a=function(e,t){return t.kind=e.kind,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.track_audio_volume=oo(e.audioLevel,e.type),t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[io.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=oo(e.audioLevel,e.type),t}(i[io.MediaSource],a)),i[io.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[io.Track],a,n)));return a})(e,i,r))}(this._pc,this.coreInstance);e&&e.length>0&&(this.addMediaStatistics(e,this.lastMediaStatistics),this.lastMediaStatistics=e)},3e3)}unregisterMediaStatisticStatsReport(){-1!==this.intervalId&&(window.clearInterval(this.intervalId),this.lastMediaStatistics=[],this.intervalId=-1)}addMediaStatistics(e,r){const n=e.map(e=>{const n=Za(e.id,e.kind),i=r.find(t=>t.id===e.id);if(!i)return e;const a=i.calculation_stats,{calculation_stats:o}=e,s=qi(e,["calculation_stats"]);return t({},s,function(e,t,r){if(!e||!t)return{framerate:0,kbps:0,packet_lost_rate:0};const n=(e.timestamp-t.timestamp)/1e3,i=0===n?0:(e.frames_sent-t.frames_sent+(e.frames_received-t.frames_received))/n,a=0===n?0:(e.bytes_sent-t.bytes_sent+(e.bytes_received-t.bytes_received))/(1024*n/8),o=uo(t.packets_lost,e.packets_lost,t.packets_received+t.packets_sent,e.packets_received+e.packets_sent);r.Apply(o);const s=r.Filtered()<0?0:100*r.Filtered();return{framerate:Math.ceil(i),kbps:Math.ceil(a),packet_lost_rate:Math.ceil(s)}}(o,a,n))});jr.log("media statistics",n),gn.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=Ya(n.sort((e,t)=>t.packet_lost_rate-e.packet_lost_rate)[0].packet_lost_rate,n.sort((e,t)=>t.rtt-e.rtt)[0].rtt);bn(i);const a=n.map(e=>({kind:e.kind,lostRate:e.packet_lost_rate,rtt:e.rtt,track:e.track_id}));this.emit("@send-qos-message",{qos:JSON.stringify({networkGrade:i,tracks_qos:a})})}getCurrentIceConnectionState(){return this._pc.iceConnectionState}close(){jr.log("handle",this._direction,"close"),this.removeEvent(),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport(),this._pc.close(),this.isPcReady=!1}}class oa extends aa{constructor(e,t,r){super("send",e,r),jr.log("init send handler"),this._transportReady=!1,this._stream=new MediaStream,this._signaling=t,t.on("on-pubpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))})}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-pubpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-pubpc-state",n)})}addProducerTracks(e){jr.debug("add producer",e);const t=e.filter(e=>!this._stream.getTrackById(e.mediaTrack.id));if(0===t.length)return Promise.reject(new Error("track already added"));let r;const n=[];let i,a=!0;return Promise.resolve().then(async()=>{for(const e of t)this._stream.addTrack(e.mediaTrack);if(E.unifiedPlan&&E.supportTransceivers)for(const e of t){const t=await Ao(e.mediaTrack,this._pc,e.lowStreamConfig,e.info.kbps);jr.debug("add transceiver",t,t.mid),n.push(t)}else jr.debug("add tracks",t),r=t.map(e=>this._pc.addTrack(e.mediaTrack,this._stream));return ca(this._pc,this._simulcast)}).then(e=>{let t;return E.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Wi}`),t={type:"offer",sdp:e.sdp},i=t.sdp,jr.log("publish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{for(const t of n){if(!t.sender.track)continue;const r=e.find(e=>e.mediaTrack===t.sender.track);if(!r||!t.mid)throw kn("can not get transceiver mid!");r.setInfo({mid:t.mid}),this.midRidEncoding[t.mid]=r.lowStreamConfig}if(!this._transportReady)return a=!1,this._setupTransport(e)}).then(()=>this._remoteSdp.createRemoteAnswer(i,this.midRidEncoding,this.removeMids)).then(e=>{const t={type:"answer",sdp:e};return jr.debug("addProducer answer",t),this._pc.setRemoteDescription(t)}).then(()=>this._pcReady).then(()=>a?this.safeEmitAsPromise("@needpubtracks",e,i):Promise.resolve(this._remoteSdp.transportRemoteParameters)).catch(e=>{jr.log("add producer error",e);try{for(const e of r)this._pc.removeTrack(e);for(const e of n)e.direction="inactive"}catch(e){}for(const e of t)this._stream.removeTrack(e.mediaTrack);throw e instanceof Sn?e:kn(e)})}removeProducerTracks(e){jr.debug("removeProducerTracks",e);const t=e.filter(e=>void 0!==e.track&&!!this._stream.getTrackById(e.track.mediaTrack.id)).map(e=>e.track.isReplacedByImageTrack?e.track.imageStreamTrack.mediaTrack:e.track.mediaTrack);let r;return Promise.resolve().then(()=>{E.unifiedPlan&&E.supportTransceivers&&this._pc.getTransceivers().forEach(e=>{e.sender.track&&e.mid&&t.includes(e.sender.track)&&this.removeMids.add(e.mid)});const e=this._pc.getSenders().filter(e=>e.track&&t.includes(e.track));if(0===e.length)return jr.warning("removeProducerTracks [nothing to remove]"),Promise.reject("removeProducerTracks: nothing to remote");for(const t of e)this._pc.removeTrack(t);for(const e of t)this._stream.removeTrack(e);return ca(this._pc,this._simulcast)}).then(e=>{const t=new RTCSessionDescription(e);return r=t.sdp,jr.log("unpublish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(r,this.midRidEncoding,this.removeMids)};return jr.log("unpublish: set remote answer",e),this._pc.setRemoteDescription(e)}).catch(e=>{if(0!==this._stream.getTracks().length)throw e instanceof Sn?e:kn(e);jr.debug("removeProducer() | ignoring expected error due no sending tracks: %s",e.toString())}).then(()=>{this.safeEmitAsPromise("@needunpubtracks",e)})}async replaceTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");e.track&&(e.track.mediaTrack=t,e.track.removeMediaElement());const n=r.track;await r.replaceTrack(t),this._stream.removeTrack(n),this._stream.addTrack(t)}async replaceProducerTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");"image"===t?(jr.debug("replaceTrack",e.track.imageStreamTrack.mediaTrack),await r.replaceTrack(e.track.imageStreamTrack.mediaTrack)):"video"===t&&(jr.debug("replaceTrack",e.track.mediaTrack),await r.replaceTrack(e.track.mediaTrack))}restartICE(e,t){return jr.log("restart send ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>ca(this._pc,this._simulcast,{iceRestart:!0})).then(e=>this._pc.setLocalDescription(e)).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(this._pc.localDescription.sdp,this.midRidEncoding,this.removeMids)};return this._pc.setRemoteDescription(e)})}_setupTransport(e){const t=Date.now();return Promise.resolve().then(()=>this._pc.localDescription?this._pc.localDescription:ca(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(gn.addEvent("PublisherPC",{signal_take_time:Date.now()-t,result_code:r.code,up_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),this.pcid=r.pcid,this._transportReady=!0,this._pcReady=this.getReady(r),this._remoteSdp.setTransportRemoteParameters(r)))}}class sa extends aa{constructor(e,t,r){super("recv",e,r),this._transportCreated=!1,this._consumerInfos=new Map,this._signaling=t,t.on("on-subpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))}),jr.log("init recvhandler",this)}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-subpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-subpc-state",n)})}async addConsumerTracks(e){if(E.unifiedPlan&&g){const t=[];for(const r of e){const e=await this.addConsumerTrack(r);t.push(e)}return t}jr.log("add consumers",e);const t=[],r=Array.from(this._consumerInfos.values());for(const n of e){const e=r.find(e=>e.consumerId===n.id);if(e&&!e.closed)t.push(e);else{const e=this.genNewConsumerInfo(n);if(E.unifiedPlan){const t=n.mid;e.mid=t,this._consumerInfos.set(t,e)}else this._consumerInfos.set(n.id,e);t.push(e)}}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>(E.unifiedPlan,this._pc.createAnswer())).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{for(let r=0;r!!e.receiver.track&&(e.receiver.track.id===n.trackID||e.mid===n.mid));e&&(i.track=e.receiver.track)}else if(E.getReceivers){const e=this._pc.getReceivers().find(e=>{const{track:t}=e;return!!t&&n.trackID===t.id});e&&(i.track=e.track)}else{const e=this._pc.getRemoteStreams().find(e=>e.id===n.streamId);e&&(i.track=e.getTrackById(n.trackID))}if(!i.track)throw kn("remote track not found");jr.log("subscribe: get new track",i.track)}}return e.map(e=>e.track)})}genNewConsumerInfo(e){const t=e.rtpParameters.encodings[0],r=e.rtpParameters.rtcp.cname,n=e.mid;return{kind:e.kind,streamId:E.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:E.unifiedPlan?`consumer-${e.kind}-${n}`:`consumer-${e.kind}-${t.ssrc}`,ssrc:t.ssrc,rtxSsrc:t.rtx?t.rtx.ssrc:void 0,cname:r,consumerId:e.id,closed:!1}}async addConsumerTrack(e){jr.log("add consumer",e);let t=null;const r=Array.from(this._consumerInfos.values()).find(t=>t.consumerId===e.id);if(r&&!r.closed)t=r;else{const r=this.genNewConsumerInfo(e);if(E.unifiedPlan){const t=e.mid;r.mid=t,this._consumerInfos.set(t,r)}else this._consumerInfos.set(e.id,r);t=r}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("set ontrack"),this._pc.ontrack=(e=>{jr.log("ontrack",e.receiver.track)}),jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{let r=null;if(E.unifiedPlan&&E.supportTransceivers&&e&&t){const n=this._pc.getTransceivers().find(r=>!!r.receiver.track&&((r.receiver.track.id===t.trackID||r.mid===t.mid)&&(e.track=r.receiver.track,!0)));n&&(r=n.receiver.track)}else if(e&&t){const n=this._pc.getReceivers().find(r=>{const{track:n}=r;return!!n&&(t.trackID===n.id&&(e.track=n,!0))});n&&(r=n.track)}if(!r&&e)throw kn("remote track not found");return jr.log("subscribe: get new track",r,r.readyState),r})}removeConsumerTracks(e){jr.log("remove consumer",e);let t=!1;for(const r of e){const e=Array.from(this._consumerInfos.values()).find(e=>e.consumerId===r.id&&!e.closed);e?(t=!0,E.unifiedPlan?(r.track=null,e.closed=!0):this._consumerInfos.delete(r.id)):jr.log("can not find unpublish track target, ignore")}return t?Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("unsubscribe set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.log("unsubscribe set local answer",e),this._pc.setLocalDescription(e))):Promise.resolve()}restartICE(e,t){return jr.log("recv restart ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>{this._pc.setLocalDescription(e)})}async setupTransport(e){if(this._transportCreated)return await this._pcReady;const t=Date.now(),r=await this.safeEmitAsPromise("@needsubpc",e);return gn.addEvent("SubscriberPC",{signal_take_time:Date.now()-t,result_code:r.code,down_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(e=>({track_id:e.trackid,status:e.status}))}),this.pcid=r.pcid,this._transportCreated=!0,this._pcReady=this.getReady(r),jr.log("init subscribe, get transport remote",r),await this._remoteSdp.setTransportRemoteParameters(r),r}}function ca(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=ia(n),"chrome"===b.name&&t&&(n=function(e,t){const r=$i.parse(e);t&&"chrome"===b.name&&(r.media=r.media.map(e=>{if(!e.ssrcGroups||0===e.ssrcGroups.length||!e.ssrcs||0===e.ssrcs.length)return e;const r=e.ssrcGroups.find(e=>"FID"===e.semantics);if(!r)return e;const[n,i]=r.ssrcs.split(" ").map(e=>parseInt(e,10));let a,o;e.ssrcs.forEach(e=>{"cname"===e.attribute&&(a=e.value),"msid"===e.attribute&&(o=e.value)});const s=[];if(s.push(n),t>=2){const t=n+1,r=i+1;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}if(t>=3){const t=n+2,r=i+2;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}return e.ssrcGroups.push({semantics:"SIM",ssrcs:s.join(" ")}),e}));const n=$i.write(r).split("\r\n");let i=n.findIndex(e=>0===e.indexOf("a=ssrc-group:FID"));for(;-1!==i&&0===n[i].indexOf("a=ssrc-group:FID");){const e=n[i].split(" ")[2];for(let t=i-1;t>=0;t--)if(n[t].indexOf(e)>0){n.splice(t+1,0,n[i]),n.splice(i+1,1);break}i++}return n.join("\r\n")}(n,3)),{type:r,sdp:n}):e})}function da(e,t,r,n){switch(e){case"send":return new oa(t,r,n);case"recv":return new sa(t,r,n)}}var ua;!function(e){e.SEND_TRACKS="@transport:send-tracks",e.RESTART_SEND_ICE="@transport:send-restart-ice",e.REMOVE_TRACKS="@transport:remove-tracks",e.INIT_RECV="@transport:init-recv",e.RESTART_RECV_ICE="@transport:recv-restart-ice",e.ADD_CONUMERS="@transport:add-consumers",e.REMOVE_CONSUMERS="@transport:remove-consumers"}(ua||(ua={}));class la extends bi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Vr("SendQueue"),this.recvCommandQueue=new Vr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=da("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=da("recv",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),this.handleRecvHandler(),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this)),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this)),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e})}get publishTracks(){return Array.from(this._publishTracks.values())}resolveInitSubPcPromise(){this.initSubPcPromiseResolve&&(this.initSubPcPromiseResolve(),this.initSubPcPromiseResolve=void 0)}handleSendHandler(){this.sendHandler.on("@needpubpc",(e,t,r,n)=>{this.safeEmitAsPromise("@needpubpc",e,t).then(r).catch(n)}).on("@connectionstatechange",e=>{switch(jr.log("pubpc connectionstatechange",e),gn.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartSendICE(this.sendHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.sendHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartSendICE(this.sendHandler.pcid))})}}).on("@needpubtracks",(e,t,r,n)=>{const i=e.map(yo),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(gn.addEvent("PublishTracks",{signal_take_time:Date.now()-a,result_code:t.code,tracks:t.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),t.code){case 0:break;case 10052:return n(Zn());case 10061:return this.reconnectProducer(),n(qn(10061,t.error));default:return n(qn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(qn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{gn.addEvent("UnPublishTracks",{tracks:e.map(e=>({track_id:e.trackID}))}),this.signaling.request("unpub-tracks",{tracks:e.map(e=>({trackid:e.trackID}))}).then(e=>{t(e)})}).on("@send-qos-message",e=>{this.signaling.request("send-qos-message",e)})}async sendTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(ua.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(ua.REMOVE_TRACKS,e)}async restartSendICE(e){return E.supportRestartICE?this.sendCommandQueue.push(ua.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case ua.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case ua.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case ua.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new xi(this,"send",e));for(const e of t)this._publishTracks.set(e.track.mediaTrack.id,e);return t}removeTrackFromPublishTracks(e){for(const t of e)this._publishTracks.delete(t.mediaTrack.id)}async _execAddProducerTracks(e){const t=await this.sendHandler.addProducerTracks(e.map(e=>e.track));for(const r of e){const e=ri(t.tracks,"localid",r.track.mediaTrack.id);e&&(r.addTrackId(e.trackid),r.track.setInfo({versionid:e.versionid}),r.track.resetStats())}return e.map(e=>e.connectStatus=B.Connect),t}_execRemoveTracks(e){return this.removeTrackFromPublishTracks(e.map(e=>e.track)),e.map(e=>e.release()),this.sendHandler.removeProducerTracks(e)}async _execRestartSendICE(e){this.sendHandler._isRestartingICE=!0;const t=await this.signaling.request("pubpc-restart",{pcid:e});if(0!==t.code)return this.sendHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.reconnectProducer();try{await this.sendHandler.restartICE(t.iceParameters,t.iceCandidates),this.sendHandler._isRestartingICE=!1}catch(e){jr.debug("restart ice faild",t.code,t.error),this.sendHandler._isRestartingICE=!1,this.reconnectProducer()}}reconnectProducer(){this.resetSendCommandQueue(),this.sendHandler.close();const e=this.publishTracks;this.sendHandler=da("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=B.Connecting}),this.emit("@needrepub",e)}handleRecvHandler(){this.recvHandler.on("@needsubpc",(e,t,r)=>{this.safeEmitAsPromise("@needsubpc",e).then(t,r)}).on("@connectionstatechange",e=>{switch(jr.log("sub pc connection state change",e),gn.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartRecvICE(this.recvHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.recvHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartRecvICE(this.recvHandler.pcid))})}})}appendConsumer(e){this.consumerQueue.push(e)}async addConsumers(){const e=this.consumerQueue;return this.consumerQueue=[],this.recvCommandQueue.push(ua.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(ua.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(ua.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return E.supportRestartICE?this.recvCommandQueue.push(ua.RESTART_RECV_ICE,e):this.resetRecvHandler()}async _removeConsumers(e){await this.recvHandler.removeConsumerTracks(e)}async _initRecvHandler(e){return this.recvHandler.isPcReady?(await this.initSubPcPromise,null):await this.recvHandler.setupTransport(e)}async _addConsumers(e){if(0===e.length)return Promise.resolve([]);return await this.recvHandler.addConsumerTracks(e)}async _execRestartRecvICE(e){this.recvHandler._isRestartingICE=!0;const t=await this.signaling.request("subpc-restart",{pcid:e});if(0!==t.code)return this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.resetRecvHandler();try{await this.recvHandler.restartICE(t.iceParameters,t.iceCandidates),this.recvHandler._isRestartingICE=!1}catch(e){this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),this.resetRecvHandler()}}handleRecvCommandTask(e,t){switch(e.method){case ua.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case ua.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case ua.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case ua.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Vr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Vr("RecvQueue"),this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this))}resetRecvHandler(){this.resetRecvCommandQueue(),this.emit("@needresetrecv"),this.recvHandler.close(),this.recvHandler=da("recv",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e}),this.handleRecvHandler(),this.emit("@needresub")}release(){this.recvHandler.close(),this.sendHandler.close(),this.publishTracks.forEach(e=>e.release())}}const Aa=new bi;function ha(e,t){return new Promise(r=>{let n;const i=Date.now(),a=new WebSocket(e);a.onopen=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!0,reason:"ok",connectTime:t})}),a.onerror=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"onerror",connectTime:t})}),n=setTimeout(()=>{const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"timeout",connectTime:t}),a.close()},t)})}var fa;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(fa||(fa={}));const pa={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class ma extends C{constructor(e=pa){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new Di,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=fa.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==fa.Connected)return void n(kn("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===dn.LIVE&&this._role===un.AUDIENCE)return void n(kn("no permission. Audience in Live mode has no permission to publish."));e.forEach(e=>e.userID=this.userID),e.forEach(e=>e.selfEndedCallback=this.unpublish.bind(this));const i=this.connectionTransport,a=this.signaling;let o;if(t){const t=e.map(e=>e.mediaTrack.id);o=i.publishTracks.filter(e=>-1!==t.indexOf(e.track.mediaTrack.id))}else{const t=i.publishTracks.map(e=>e.track.mediaTrack.id);if(e.filter(e=>-1===t.indexOf(e.mediaTrack.id)).length!==e.length)return void n(kn("there are already published tracks in the provided tracks"));o=i.addTrackToPublishTracks(e)}if(jr.debug("start publish",o,t),!t){const e=o.map(e=>e.startConnect());Promise.all(e).then(()=>r()).catch(()=>{n(Nn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=ri(this.users,"userID",this.userID);t&&(t.addTracks(o.map(e=>e.track)),t.addPublishedTrackInfo(o.map(e=>({trackID:e.trackID,muted:!!e.track.info.muted,kind:e.track.info.kind,tag:e.track.info.tag,userID:this.userID,versionid:e.track.info.versionid,profiles:e.track.info.profiles})))),e.forEach(e=>{e.on("@get-stats",(t,r,n)=>{if(!this.connectionTransport)return r([]);const i=e.isReplacedByImageTrack?e.imageStreamTrack.mediaTrack:e.mediaTrack;this.connectionTransport.sendHandler.getStats(i,t).then(r,n)})}),this.getAllMerger().forEach(t=>t.controller.onAddTracks(e.map(e=>e.info)))}catch(t){if(t instanceof Sn)switch(t.code){case 10061:case 30001:return;case 10052:return jr.warning(t,"republish"),void setTimeout(()=>this._publish(e,!0),1e3);default:i.removeTrackFromPublishTracks(e),n(t)}else jr.warning(t,"republish"),setTimeout(()=>this._publish(e,!0),1e3)}})),this._subscribe=((e,t,r=!1,n)=>new Promise(async(i,a)=>{if(this.roomState!==fa.Connected)return void a(kn("can not connected to the room, please joinRoom first"));if(0===e.length)return void i([]);jr.debug("subscribe",e,t);const o=this._trackInfo.filter(t=>e.includes(t.trackid));if(o.length!==e.length)return void a(Kn(10041,`can not find track in room ${e}`));let s;const c=this.connectionTransport,d=this.signaling;if(t)s=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));else{const e=this.subscribeTracks.map(e=>e.trackID),t=o.filter(t=>!e.includes(t.trackid));s=t.map(e=>new xi(c,"recv",void 0,e.trackid,e.mid)),this.subscribeTracks=this.subscribeTracks.concat(s)}n&&Object.entries(n).forEach(([e,t])=>{this.profiles.set(e,t)}),jr.log("sub tracks",s,n);try{if(!t){const e=s.map(e=>e.startConnect());Promise.all(e).then(()=>i(s.map(e=>e.track))).catch(()=>{a(Nn())})}let n=await c.initRecvHandler(s.map(e=>e.trackID));if(!n){const e=Date.now();n=await d.request("sub-tracks",{tracks:s.map(e=>{const t=e.trackID;return this.profiles.get(t)?{trackid:t,profile:this.profiles.get(t)}:{trackid:t}})}),gn.addEvent("SubscribeTracks",{result_code:n.code,signal_take_time:Date.now()-e,tracks:n.tracks.map(e=>({track_id:e.trackid,status:e.status}))})}switch(jr.log("get sub res data",n),n.code){case 0:break;case 10052:throw Zn();case 10062:throw c.resetRecvHandler(),Kn(10062,n.error);default:throw Kn(n.code,n.error)}const u=n.tracks.filter(e=>!!e.status),l=n.tracks.filter(e=>!e.status).map(e=>e.trackid);if(u.length-1!==l.indexOf(e.trackID));M(this.subscribeTracks,e=>-1!==l.indexOf(e.trackID)),e.map(e=>e.release())}n.tracks=u;for(const e of n.tracks||[]){const t=s.find(t=>t.trackID===e.trackid),r=o.find(t=>t.trackid===e.trackid);if(!t||!r)continue;const n=e.rtpparams;t.appendConsumner(n,r.kind)}await c.addConsumers(),c.resolveInitSubPcPromise();for(const e of s){const{consumer:t}=e;if(!t||!t.track)continue;const r=t.track;let n=e.track;const i=o.find(e=>e.trackid===t.id);if(!i)continue;n?n.resume(r):"audio"===r.kind?(n=new Vi(r,i.playerid,"remote")).initAudioManager():n=new Pi(r,i.playerid,"remote",i.profiles||[]),n.setInfo({trackID:i.trackid,userID:i.playerid,tag:i.tag,kind:i.kind,muted:i.muted,versionid:i.versionid}),n.setMaster(i.master),n.removeAllListeners("@get-stats"),n.removeAllListeners("@ended"),n.on("@get-stats",(e,t,r)=>{if(!this.connectionTransport)return t([]);this.connectionTransport.recvHandler.getStats(n.mediaTrack,e).then(t,r)}),n.once("@ended",async()=>{if(n&&n.info.trackID){jr.warning("remote track ended, try to resubscribe");try{await this._unsubscribe([n.info.trackID],!0)}catch(e){}await this._subscribe([n.info.trackID],!0)}}),e.track=n;const a=this.users.find(e=>e.userID===i.playerid);a&&a.addTracks([n])}s.forEach(e=>e.connectStatus=B.Connect);let A=n.tracks.map(e=>{if(void 0===e.muted)for(let t=0;t{e.consumer&&r.push(e.consumer)}),await c.removeConsumers(r),!(t instanceof Sn))return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);switch(t.code){case 10062:case 30001:return;case 10052:return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);default:M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},pa,e),this.config=e,jr.log("config",e),jr.log("version",Hr),jr.log("browser report",E,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(bo)}get roomState(){return this._roomState}set roomState(e){this._roomState!==e&&(this._roomState=e,jr.debug("roomState change",this._roomState),this.emit("room-state-change",this._roomState),gn.addEvent("RoomStateChanged",{room_state:e,event_grade:this._roomState===fa.Reconnecting?An.SERVERE:An.NORMAL,event_category:hn.CORE}))}_setReconnectTimes(e){this.config.reconnectTimes=e,this.signaling&&(this.signaling.reconnectTimes=e)}set simulcast(e){this.config.simulcast=e,this.connectionTransport&&(this.connectionTransport.simulcast=e,this.connectionTransport.sendHandler._simulcast=e,this.connectionTransport.recvHandler._simulcast=e)}_getReconnectTimes(){return this.config.reconnectTimes||pa.reconnectTimes}setRequestTimeout(e){this.config.requestTimeout=e}_setProfile(e,t){if(this.profile=t,this.profiles.set(e,t),!this.subscribeTracks.some(t=>t.trackID===e))return;this.signaling.sendWsMsg("set-sub-profile",{tracks:[{trackid:e,profile:this.profile}]})}getForwardJobTracks(){return this.forwardJobTracks}get publishedTracks(){return this.connectionTransport?this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==fa.Idle)throw kn("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===dn.RTC||this._mode===dn.LIVE&&this._role===un.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===dn.RTC)throw kn("client role can only be set in client mode LIVE.");if(e===un.AUDIENCE&&this.publishedTracks.length>0&&e===un.AUDIENCE)throw kn("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==fa.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(gn.addEvent("SetClientRole",{result_code:t.code,user_role:e===un.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Jn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();let n=0;this._mode===dn.LIVE&&(n=1);const i=this._role===un.BROADCASTER?0:1;if(gn.addEvent("JoinRoom",{room_token:e,user_data:t,room_type:n,user_role:i,audience_latency_level:0}),this.roomState!==fa.Idle)throw kn("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=fa.Connecting;try{this.roomToken=e,this.userData=t;const n=ti(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,gn.setUserBase(this.userID,this.roomName,this.appId),jr.log("join room, token:",e),jr.debug(`join room, roomName: ${this.roomName}, userID: ${this.userID}`),!this.roomName.match(/^[a-zA-Z0-9_-]{1,64}$/))throw this.roomState=fa.Idle,kn("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{1,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{1,50}$/))throw this.roomState=fa.Idle,kn("invalid userID. userID must match /^[a-zA-Z0-9_-]{1,50}$/");try{const t=await vi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,gn.setSessionId(t.sessionId),gn.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:0,join_node_info:this.signaling.url,join_error_message:"",event_grade:An.NORMAL,event_category:hn.CORE}),this._mode===dn.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=fa.Idle,jr.debug("joinRoomWithToken fail: "+t.message),gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:t.code?t.code:-1,join_node_info:this.signaling?this.signaling.url:"",join_error_message:t.message||t.error||"",event_grade:An.SERVERE,event_category:hn.CORE}),t}}async joinRoomWithAccess(e){const t=ei(e),{capsdp:r}=await async function(){let e=lo(),{isH264:t,sdp:r}=await ra(e),n=5;for(;!t&&n>0;)e.close(),e=lo(),({isH264:t,sdp:r}=await ra(e)),n--;E.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Wi}`);const i={capsdp:r=ia(r),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===fa.Idle)throw kn("roomState is idle, maybe because you left the room.");const n=new _i(e,r,this._getReconnectTimes(),this.config.requestTimeout,this.userData,this._privileges);n.on("@error",this.handleDisconnect.bind(this)).on("@ws-state-change",(e,t)=>{switch(t){case Si.CONNECTING:this.roomState===fa.Connected?this.roomState=fa.Reconnecting:this.roomState!==fa.Reconnecting&&(this.roomState=fa.Connecting)}}).on("@needupdateaccesstoken",(e,t)=>{this.updateAccessToken().then(e).catch(t)}).on("on-player-in",this.handlePlayerIn.bind(this)).on("on-player-out",this.handlePlayerOut.bind(this)).on("on-add-tracks",e=>{this.filterSignalTracks(e),this.handleAddTracks(e)}).on("on-remove-tracks",e=>{this.filterSignalTracks(e),this.handleRemoveTracks(e)}).on("mute-tracks",e=>{this.filterSignalTracks(e),this.handleMute(e)}).on("on-messages",this.handleCustomMessages.bind(this)).on("on-qos-messages",this.handleQosMessages.bind(this)).on("on-pubpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartRecvICE(e.pcid).catch(jr.debug)}).on("on-sub-profile-changed",e=>{this.emit("on-sub-profile-changed",e)}).on("on-job-connected",e=>{this.emit("forward-job-connected",{jobId:e.id})}).on("on-job-disconnected",e=>{this.emit("forward-job-disconnected",{jobId:e.id})}).on("on-merge-job-connected",e=>{this.emit("merge-job-connected",{jobId:e.id})}).on("on-merge-job-disconnected",e=>{this.emit("merge-job-disconnected",{jobId:e.id})}).on("on-media-relay-state",e=>{const t=e.roomid.slice(e.roomid.indexOf(":")+1);this.emit("media-relay-state-changed",t,e.state)}).on("disconnect",this.handleDisconnect.bind(this)).on("on-player-reconnect",this.handleRemoteUserReconnecting.bind(this)).on("on-player-reconnect-in",this.handleRemoteUserReconnected.bind(this)),jr.log("init signaling websocket"),this.signaling=n;try{let e;e=t.roomServers&&t.roomServers.length>0?t.roomServers.sort((e,t)=>t.score-e.score).map(e=>e.url):[t.signalingurl2];const{ws:r,url:i}=await function(e,t){let r=[],n=!1;return new Promise((i,a)=>{for(const o of e)ha(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:t.url,socket_connect_time:t.connectTime,socket_connect_success:t.status,socket_connect_error_message:t.reason,event_grade:n?An.NORMAL:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:"connect"}),r.length!==e.length||n||a(_n("websocket connect failed."))})})}(e,this.config.requestTimeout),a=await n.initWs(!0,r,i);n.on("@signalingauth",this.handleAuth.bind(this)),await this.handleAuth(a)}catch(e){if(this.signaling&&(this.signaling.release(),this.signaling=void 0),10052===e.code)return await ci(1e3),this.joinRoomWithToken(this.roomToken,this.userData);throw e}for(let e of this.users)e.userID!==this.userID&&this.emit("user-join",e);return this.trackInfoList.length>0&&this.emit("track-add",this.trackInfoList),this.users}async _unpublish(e){if(this.roomState!==fa.Connected)throw kn("not connected to the room");if(0===e.length)return;jr.debug("unpublish",e);const t=this.connectionTransport,r=t.publishTracks.filter(t=>-1!==e.indexOf(t.trackID));if(r.length!==e.length)throw kn("can not find target trackid to unpublish");await t.removeTracks(r),this.getAllMerger().forEach(e=>e.controller.onRemoveTracks(r.map(e=>e.track.info)));const n=ri(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==fa.Connected)throw kn("can not createMergeJob, room state is not connected");const n=t({},N,r,{id:e});jr.debug("send create merge job",n,e);const i=Date.now(),a=await this.signaling.request("create-merge-job",n);if(gn.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw Wn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==fa.Connected)throw kn("can not createForwardJob, room state is not connected");const t=!!e.audioTrackId&&!e.videoTrackId,r=[e.audioTrackId,e.videoTrackId].filter(Boolean).map(e=>({trackid:e})),n={id:e.jobId,publishUrl:e.publishUrl,audioOnly:t,tracks:r};if(e&&e.userConfigExtraInfo){if(i=e.userConfigExtraInfo,!(new Blob([i]).size<=1e3))throw kn("userConfigExtraInfo Up to 1000 Bytes");n.seiTemplate={value:e.userConfigExtraInfo}}var i;const a=Date.now(),o=await this.signaling.request("create-forward-job",n);if(gn.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw zn(o.code,o.error);this.forwardJobTracks[e.jobId]?jr.warning("forward job id already exist",e.jobId):(this.forwardJobTracks[e.jobId]=[],e.audioTrackId&&this.forwardJobTracks[e.jobId].push(e.audioTrackId),e.videoTrackId&&this.forwardJobTracks[e.jobId].push(e.videoTrackId))}async stopForwardJob(e){if(this.roomState!==fa.Connected)throw kn("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw kn(`no forward job id ${e}`);gn.addEvent("StopForwardJob",{id:e||""}),await this.signaling.request("stop-forward",{id:e,delayMillisecond:0}),delete this.forwardJobTracks[e]}setDefaultMergeStream(e,t,r){if(r&&!this.mergeJobTracks[r])throw Ln(r);this.merger&&!r&&(this.merger.release(),this.merger=void 0),r&&this.mergeJobMerger[r]&&(this.mergeJobMerger[r].release(),delete this.mergeJobMerger[r]);const n=this.CreateMergerSessionController();r?this.mergeJobMerger[r]=new Ei(e,t,n,r):this.merger=new Ei(e,t,n,r)}_stopMerge(e){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw Ln(e);gn.addEvent("StopMerge",{id:e||""}),this.signaling.sendWsMsg("stop-merge",{id:e}),e?(delete this.mergeJobTracks[e],this.mergeJobMerger[e]&&(this.mergeJobMerger[e].release(),delete this.mergeJobMerger[e])):(this.defaultMergeJobTracks=[],this.merger&&(this.merger.release(),this.merger=void 0))}async _addMergeTracks(e,t){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,add:r};jr.debug("addMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(gn.addEvent("UpdateMergeTracks",{id:t||"",add:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""})),result_code:i.code}),0!==i.code)throw Jn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r={id:t,remove:e.map(e=>({trackid:e}))};jr.debug("removeMergeTracks",r),M(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(gn.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Jn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==fa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,all:r,mode:1};jr.debug("updateMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e)),gn.addEvent("UpdateMergeTracks",{id:t||"",all:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""}))}),await this.signaling.request("update-merge-tracks",n)}async _unsubscribe(e,t){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));if(jr.debug("unsubscribe",r),0===r.length)return;const n=Date.now(),i=await this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))});gn.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e})),result_code:i.code,signal_take_time:Date.now()-n}),t||(r.forEach(e=>e.release()),M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer))}_muteTracks(e){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const t=this.connectionTransport,r={};e.forEach(e=>{r[e.trackID]=e.muted});const n=t.publishTracks.filter(e=>void 0!==r[e.trackID]);n.forEach(e=>{e.setMute(r[e.trackID])}),gn.addEvent("MuteTracks",{tracks:n.map(e=>({track_id:e.trackID,muted:e.track.info.muted,kind:e.track.info.kind}))}),this.signaling.sendWsMsg("mute-tracks",{tracks:e.map(e=>({trackid:e.trackID,muted:e.muted}))})}async kickoutUser(e){jr.log("kickoutUser",e),await this.control("kickplayer",e)}sendCustomMessage(e,t,r){if(this.roomState!==fa.Connected)throw kn("room state is not connected, can not send message");const n=r||si(8),i=t&&0!==t.length?t:void 0;this.signaling.sendWsMsg("send-message",{msgid:n,target:i,type:"normal",text:e}),jr.debug("send custom message",e,i,n)}async replaceTrack(e,t){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("replaceTrack",e,t);const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("pushCameraTrackWithImage",{trackID:e,source:t});const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw kn(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new Ri),void 0===t&&r.track.isReplacedByImageTrack?(await this.connectionTransport.sendHandler.replaceProducerTrack(r,"video"),r.track.isReplacedByImageTrack=!1,void r.track.switchPlayingTrack()):void 0!==t&&r.track&&!r.track.isReplacedByImageTrack?(await r.track.imageStreamTrack.setSource(t),await this.connectionTransport.sendHandler.replaceProducerTrack(r,"image"),r.track.isReplacedByImageTrack=!0,void r.track.switchPlayingTrack()):void 0}leaveRoom(){this.roomState!==fa.Idle?(jr.log("leave room"),gn.addEvent("LeaveRoom",{leave_reason_code:0}),this.signaling&&(Object.keys(this.forwardJobTracks).forEach(e=>this.stopForwardJob(e)),this.signaling.sendDisconnect()),this.releaseRoom()):jr.log("can not leave room, please join room first")}_releasePublishTracks(){}async control(e,t){if(this.roomState!==fa.Connected)throw kn("can not connected to the room, please run joinRoom first");const r=await this.signaling.request("control",{command:e,playerid:t});if(r.error)throw Qn(r.code,r.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),M(this._trackInfo,t=>t.playerid===e.playerid),M(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),ai(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=ko(e);this._users.set(t.userID,t),ai(()=>{jr.debug("user-join",t),this.emit("user-join",t)})}handleAddTracks({tracks:e}){jr.log("receive track-add",e,t({},this._trackInfo));const r=new Set;for(const t of e){const e=ri(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>So(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([bo(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))ai(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});ai(()=>{jr.debug("track-add",e.map(bo)),this.emit("track-add",e.map(bo))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=M(this._trackInfo,t=>e.map(e=>e.trackid).includes(t.trackid)),n=new Set;for(const e of r){const t=this._users.get(e.playerid);if(!t)continue;t.removePublishedTrackInfo([e.trackid]),t.removeTracksByTrackId([e.trackid]),n.add(t.userID);const r=M(this.subscribeTracks,t=>t.trackID===e.trackid)[0];r&&r.release()}if(this.cleanTrackIdsFromMergeJobs(e.map(e=>e.trackid)),"stream"===this.sessionMode)for(const e of Array.from(n)){const t=this._users.get(e);if(t.published){const e=t.publishedTrackInfo.map(e=>So(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else ai(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}ai(()=>{jr.debug("track-remove",r.map(bo)),this.emit("track-remove",r.map(bo))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=ri(this._trackInfo,"trackid",e);if(!n)return;const i=this._users.get(n.playerid);if(!i)return;const a=i.publishedTrackInfo.find(t=>t.trackID===e);a&&(a.muted=r);const o=i.tracks.find(t=>t.info.trackID===e);o&&(o.info.muted=r,o.setMute(r)),n.muted=r;const s=this.subscribeTracks.filter(t=>t.trackID===e)[0];s&&s.setMute(r);let c=void 0;for(let e=0;e{jr.log("user-mute",d),this.emit("user-mute",d)})}ai(()=>{jr.log("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted}))),this.emit("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted})))})}handleCustomMessages({messages:e}){this.emit("messages-received",e.map(To))}handleQosMessages({messages:e}){const t=[];e.forEach(e=>{try{const r=JSON.parse(e.qos);r.tracks_qos.forEach(n=>{t.push({userID:e.playerid,networkGrade:r.networkGrade,kind:n.kind,trackID:n.track,packetLossRate:n.lostRate,rtt:n.rtt})})}catch(e){jr.warning("parse SignalingQosMessage error: ",e)}}),Aa.emit("remote-track-stats",t),this.emit("remote-track-stats",t)}handleDisconnect(e){if(jr.log("handle disconnect",e.code,e),-1===[0,10005,10006].indexOf(e.code)&&gn.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:-1,socket_node_info:this.signaling.url}),gn.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=fa.Reconnecting,void setTimeout(()=>this.signaling.initWs(),1e3);switch(e.code){case 10006:this.emit("disconnect",{code:e.code,data:{userID:e.kickedid}});break;default:this.emit("disconnect",{code:e.code})}this.releaseRoom()}handleRemoteUserReconnecting(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnecting",t),this.emit("remote-user-reconnecting",t))}handleRemoteUserReconnected(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnected",t),this.emit("remote-user-reconnected",t))}async updateAccessToken(){const e=ti(this.roomToken),t=await vi(e,this.roomToken,this.config.requestTimeout);gn.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=ei(t.accessToken);if(!this.signaling)throw kn("room state is idle when updateAccessToken");this.signaling.accessToken=this.accessToken,this.signaling.setUrl(r.signalingurl2)}async handleAuth(e){if(this.filterSignalTracks(e),jr.debug("handleAuth",e),e.error)return void await this.joinRoomWithToken(this.roomToken,this.userData);e.tracks=e.tracks||[],e.tracks=e.tracks.filter(e=>e.playerid!==this.userID),e.players=e.players||[];const t=this.roomState===fa.Reconnecting;let r={join:[],leave:[],add:[],remove:[],mute:[]};const n=Array.from(this._users.keys()),i=e.players.map(e=>e.playerid);if(r=function(e,t,r,n,i){const a={join:[],leave:[],add:[],remove:[],mute:[]},o=t.map(e=>e.trackid),s=r.map(e=>e.trackid);return o.forEach((n,i)=>{if(t[i].playerid!==e)if(-1===s.indexOf(n))a.remove.push(t[i]);else{const e=r.find(e=>e.trackid===n),o=t[i];e.versionid!==o.versionid&&(a.remove.push(o),a.add.push(e))}}),s.forEach((n,i)=>{if(r[i].playerid===e)return;const s=o.indexOf(n);-1===s?(a.add.push(r[i]),a.mute.push({trackid:n,muted:r[i].muted})):r[i].muted!==t[s].muted&&a.mute.push({trackid:n,muted:r[i].muted})}),n.forEach(t=>{t!==e&&-1===i.indexOf(t)&&a.leave.push({playerid:t})}),i.forEach(t=>{t!==e&&-1===n.indexOf(t)&&a.join.push({playerid:t})}),a}(this.userID,this._trackInfo,e.tracks,n,i),this.roomState=fa.Connected,t)jr.debug("get missing events",r),r.remove.length>0&&this.handleRemoveTracks({tracks:r.remove}),r.leave.length>0&&r.leave.forEach(this.handlePlayerOut.bind(this)),r.join.length>0&&r.join.forEach(this.handlePlayerIn.bind(this)),r.add.length>0&&this.handleAddTracks({tracks:r.add}),r.mute.length>0&&this.handleMute({tracks:r.mute});else{this._trackInfo=e.tracks,this._users.clear();for(const t of e.players||[]){const e=ko(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(bo)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===B.Connecting);this.connectionTransport.extendedRtpCapabilities=e.rtpcaps,(!this.connectionTransport.sendHandler.isPcReady||this.connectionTransport.sendHandler._isRestartingICE||t.length>0)&&this.connectionTransport.reconnectProducer(),(!this.connectionTransport.recvHandler.isPcReady||this.connectionTransport.recvHandler._isRestartingICE||r.length>0)&&this.connectionTransport.resetRecvHandler()}else this.connectionTransport=this.createConnectionTransport(e.rtpcaps)}createConnectionTransport(e){const t=this.signaling,r=new la(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(yo),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(i)}),r.on("@needsubpc",(e,r,n)=>{t.request("subpc",{tracks:e.map(e=>this.profiles.get(e)?{trackid:e,profile:this.profiles.get(e)}:{trackid:e}),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void r(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=B.Connecting),this._subscribe(e,!0)}).on("@needrepub",e=>{this._publish(e.map(e=>e.track),!0)}).on("@needresetrecv",()=>{this.subscribeTracks.filter(e=>!!e.track).forEach(e=>{e.track.removeAllListeners("@ended")})}),r}cleanTrackIdsFromMergeJobs(e){M(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)M(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new wi,t=t=>{e.onAddTracks(t)},r=t=>{e.onRemoveTracks(t)};return this.on("track-add",t),this.on("track-remove",r),e.getCurrentTracks=(()=>{if(!this.connectionTransport)return[];const e=this._trackInfo.map(bo),t=this.connectionTransport.publishTracks.map(e=>e.track.info);return e.concat(t)}),e.addMergeTrack=((e,t)=>{this._addMergeTracks(e,t)}),e.release=(()=>{this.off("track-add",t),this.off("track-remove",r)}),e}getAllMerger(){const e=[];this.merger&&e.push(this.merger);for(const t in this.mergeJobMerger)e.push(this.mergeJobMerger[t]);return e}releaseRoom(){this.releaseSession(),this.signaling&&(this.signaling.release(),this.signaling=void 0),gn.addEvent("UnInit",{id:`${this.sessionMode}_${Date.now()}`},!0),this.connectionTransport&&(this.connectionTransport.release(),this.connectionTransport=void 0),this.getAllMerger().map(e=>{e.release()}),this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this.merger=void 0,this.mergeJobMerger={},this.roomState=fa.Idle,this._trackInfo=[],this._users.clear(),this.userID=void 0,this.subscribeTracks.forEach(e=>{e.release()}),this.subscribeTracks=[],this.profile=void 0,this.profiles.clear(),clearInterval(this.volumeIndicatorTimer),this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"]}registerVolumeIndicatorEvent(){clearInterval(this.volumeIndicatorTimer),this.volumeIndicatorTimer=setInterval(()=>{if(!this.connectionTransport)return!1;const e=[...this.subscribedTracks,...this.publishedTracks].filter(e=>"audio"===e.info.kind&&!e.info.muted).map(e=>({trackID:e.info.trackID,userID:e.userID,level:e.getCurrentVolumeLevel()||0,muted:e.info.muted}));if(0===this.volumeIndicatorHistory.length)this.volumeIndicatorHistory.push(e.filter(e=>e.level>=.1));else{const r=this.volumeIndicatorHistory[this.volumeIndicatorHistory.length-1],n={};r.forEach(e=>n[e.trackID]=e.level);const i=[];for(let r of e)r.level>=.1?n[r.trackID]?r.level>n[r.trackID]?i.push(r):i.push(t({},r,{level:n[r.trackID]})):i.push(r):n[r.trackID]&&i.push(t({},r,{level:n[r.trackID]}));this.volumeIndicatorHistory.push(i),4===this.volumeIndicatorHistory.length&&(this.emit("volume-indicator",i.filter(e=>!e.muted).map(e=>({trackID:e.trackID,userID:e.userID,level:e.level}))),this.volumeIndicatorHistory=[])}},500)}async startMediaRelay(e){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("start-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("StartMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("update-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("UpdateMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==fa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(gn.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Jn(e.code,e.error);const r=e.status;return Object.keys(r).reduce((e,n)=>t({},e,{[n]:r[n].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}}class ga extends ma{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",gn.addEvent("Init",{id:`${this.sessionMode}_${Date.now()}`})}get mergeStreamTracks(){return this.defaultMergeJobTracks}get mergeStreamJobTracks(){return this.mergeJobTracks}async join(e,t){return await this.joinRoomWithToken(e,t)}leave(){this.leaveRoom(),this.isAudioMastered=!1,this.isVideoMastered=!1}async publish(e){const t=this.isAudioMastered,r=this.isVideoMastered;for(const t of e)"audio"===t.info.kind&&(this.isAudioMastered?t.setMaster(!1):(t.setMaster(!0),this.isAudioMastered=!0)),"video"===t.info.kind&&(this.isVideoMastered?t.setMaster(!1):(t.setMaster(!0),this.isVideoMastered=!0));try{return await this._publish(e)}catch(e){throw this.isAudioMastered=t,this.isVideoMastered=r,e}}async unpublish(e){const t=await this._unpublish(e);return this.isAudioMastered=this.publishedTracks.some(e=>!("audio"!==e.info.kind||!e.master)),this.isVideoMastered=this.publishedTracks.some(e=>!("video"!==e.info.kind||!e.master)),t}async subscribe(e,t=!1,r){return await this._subscribe(e,!1,t,r)}async unsubscribe(e){return await this._unsubscribe(e)}setProfile(e,t){this._setProfile(e,t)}setReconnectTimes(e){this._setReconnectTimes(e)}getReconnectTimes(){return this._getReconnectTimes()}muteTracks(e){this._muteTracks(e)}async addMergeStreamTracks(e,t){await this._addMergeTracks(e,t)}async removeMergeStreamTracks(e,t){await this._removeMergeTracks(e,t)}stopMergeStream(e){this._stopMerge(e)}filterSignalTracks(){}releaseSession(){}}class va{constructor(e,t){this.networkQuality=tn.UNKNOWN,this._client=e,this._user=t,this.userID=t.userID,this.userData=t.userData}getVideoTracks(){let e=[];for(let t of this._client._remoteTracks)t.isVideo()&&t.userID===this.userID&&e.push(t);return e}getAudioTracks(){let e=[];for(let t of this._client._remoteTracks)t.isAudio()&&t.userID===this.userID&&e.push(t);return e}}class Ta extends C{constructor(){super(...arguments),this._isMuted=!1}get mediaElement(){return this._track&&this._track.mediaElement}get track(){return this._track}set track(e){e&&(this._track=e,this._track.on("ended",()=>{Aa.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{Aa.emit("audioBuffer",t,e.mediaTrack.id)}),this.trackID=this._track.info.trackID,this.userID=this._track.info.userID,this.tag=this._track.info.tag,this._kind=this._track.info.kind,this._isMuted=!!this._track.info.muted)}play(e,t={}){return this._track?"boolean"==typeof t?this._track.play(e,t,{}):this._track.play(e,void 0,t):Promise.reject()}isAudio(){return"audio"===this._kind}isVideo(){return"video"===this._kind}isMuted(){return this._isMuted}getMediaStreamTrack(){return this.track?this.track.mediaTrack:void 0}}class ba extends Ta{constructor(e){super(),this._isSubScribed=!1,this.uplinkStats={uplinkRTT:0,uplinkLostRate:0},this._kind=e.kind,this.trackID=e.trackID,this.userID=e.userID,this.tag=e.tag,Aa.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),Aa.on("mute-tracks",e=>{for(const t of e)t.trackID===this.trackID&&(this._isMuted=t.muted,this.emit("mute-state-changed",t.muted))})}isSubscribed(){return this._isSubScribed}}class Sa extends ba{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=rn.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),Aa.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=rn.HIGH,this.emit("profile-changed",rn.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=rn.MEDIUM,this.emit("profile-changed",rn.MEDIUM);break;case"low":this.profile=rn.LOW,this.emit("profile-changed",rn.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){Aa.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw kn("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?rn.LOW:rn.HIGH;Aa.emit("set-profile",this.trackID,t)}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){const e={downlinkFrameRate:0,downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkFrameRate=t[0].frameRate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,this.isMultiProfileEnabled&&(e.profile=this.profile),e)}}class ya extends ba{constructor(e){super(e),Aa.on("audioBuffer",(e,t)=>{this._track&&t===this._track.mediaTrack.id&&this.emit("audioFrame",e)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,e)}}class ka extends C{constructor(e){super(),this.connectionState=Ur.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new ga({transportPolicy:e}),this.session.on("user-join",e=>{const t=new va(this,e);this.remoteUsers.push(t),this.emit("user-joined",e.userID,e.userData)}),this.session.on("user-leave",e=>{this.remoteUsers=this.remoteUsers.filter(t=>t.userID!==e.userID),this.emit("user-left",e.userID)}),this.session.on("track-add",e=>{if(0===e.length)return;const t=e.map(e=>"audio"===e.kind?new ya(e):new Sa(e));this._remoteTracks.push(...t);const r=Nr(t,e=>e.userID);Object.entries(r).forEach(([e,t])=>{this.emit("user-published",e,t)})}),this.session.on("track-remove",e=>{if(0===e.length)return;const t=e[0].userID,r=new Set;for(const t of e)r.add(t.trackID);let n=[],i=[];for(const e of this._remoteTracks)r.has(e.trackID)?n.push(e):i.push(e);this._remoteTracks=i,this.emit("user-unpublished",t,n)}),this.session.on("mute-tracks",e=>{0!==e.length&&Aa.emit("mute-tracks",e)}),Aa.on("set-mute-tracks",(e,t,r)=>{if(r===this.getClientKey())this.session.muteTracks([{trackID:e,muted:t}]);else if(""===r)throw kn("can not setMuted,please publish track first")}),this.session.on("room-state-change",e=>{switch(e){case fa.Idle:this.connectionState=Ur.DISCONNECTED;break;case fa.Connecting:this.connectionState=Ur.CONNECTING;break;case fa.Reconnecting:this.connectionState=Ur.RECONNECTING;break;case fa.Connected:this.connectionState=this.connectionState===Ur.CONNECTING?Ur.CONNECTED:Ur.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===Ur.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=nn.LEAVE;break;case 10006:e=nn.KICKED_OUT;break;default:e=nn.ERROR}let t={reason:e};if(e===nn.ERROR)switch(t.errorCode=this._disconnectedInfo.code,t.errorCode){case 10001:t.errorMessage="token 错误";break;case 10002:t.errorMessage="token 过期";break;case 10004:t.errorMessage="reconnect token 过期";break;case 10007:t.errorMessage="断线重连失败";break;case 10022:t.errorMessage="该用户在其他页面或终端登录";break;case 10011:t.errorMessage="房间人数已满";break;case 10012:t.errorMessage="房间已关闭";break;default:t.errorMessage="unexpected error"}this.release(),this.emit("connection-state-changed",this.connectionState,t)}else this.emit("connection-state-changed",this.connectionState)}),this.session.on("messages-received",e=>{for(let t of e){const e={ID:t.msgid,userID:t.userID,content:t.data,timestamp:t.timestamp};this.emit("message-received",e)}}),this.session.on("media-relay-state-changed",(e,t)=>{this.emit("media-relay-state-changed",e,t)}),this.session.on("remote-user-reconnecting",e=>{this.emit("user-reconnecting",e.userID)}),this.session.on("remote-user-reconnected",e=>{this.emit("user-reconnected",e.userID)}),this.session.on("forward-job-connected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{Aa.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),Aa.on("remote-track-stats",e=>{for(let t of e){const e=this.remoteUsers.filter(e=>e.userID===t.userID)[0];if(!e)return;switch(t.networkGrade){case x.INVALID:e.networkQuality=tn.UNKNOWN;break;case x.POOR:e.networkQuality=tn.POOR;break;case x.FAIR:e.networkQuality=tn.FAIR;break;case x.GOOD:e.networkQuality=tn.GOOD;break;case x.EXCELLENT:e.networkQuality=tn.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),Aa.on("set-profile",(e,t)=>{switch(t){case rn.HIGH:this.session.setProfile(e,"high");break;case rn.MEDIUM:this.session.setProfile(e,"medium");break;case rn.LOW:this.session.setProfile(e,"low")}}),Aa.on("setMediaStreamTrack",(e,t,r,n,i)=>{if(r===this.getClientKey())this.session.replaceTrack(e,t).then(n).catch(i);else if(""===r)throw kn("can not setMediaStreamTrack,please publish track first")})}setTransportPolicy(e){this.session.config.transportPolicy=e}get userID(){return this.session.userID}get userData(){return this.session.userData}get roomName(){return this.session.roomName}getRemoteUser(e){return this.remoteUsers.find(t=>t.userID===e)}async setClientMode(e){this.session.setClientMode(e)}async setClientRole(e){await this.session.setClientRole(e)}async join(e,t){await this.session.joinRoomWithToken(e,t)}async leave(){await Promise.resolve().then(()=>this.session.leave()),this.release()}release(){this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[]}async publish(e){if(Array.isArray(e)){e.find(e=>e.isVideo())&&(this.session.simulcast=!!e.filter(e=>e.isVideo()).find(e=>e.isMultiProfileEnabled)),await this.session.publish(e.map(e=>e.track));for(const t of e)t.trackID=t.track.info.trackID,t.userID=this.session.userID,t.client=this.getClientKey();this._localTracks.push(...e)}else e.isVideo()&&e.isMultiProfileEnabled&&(this.session.config.simulcast=!0),await this.session.publish([e.track]),e.trackID=e.track.info.trackID,e.userID=this.session.userID,e.client=this.getClientKey(),this._localTracks.push(e)}getClientKey(){return Gr(`${this.roomName?this.roomName:""}${this.userID?this.userID:""}${this.session.appId?this.session.appId:""}`)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw kn("target tracks has not published");await this.session.unpublish(e.map(e=>e.trackID)),this._localTracks=this._localTracks.filter(t=>!e.includes(t))}else{if(!this._localTracks.includes(e))throw kn("target tracks has not published");await this.session.unpublish([e.trackID]),this._localTracks=this._localTracks.filter(t=>t!==e)}}async subscribe(e){let t;if(Array.isArray(e)){t=await this.session.subscribe(e.map(e=>e.trackID));let r=[],n=[];for(let i of t){const t=e.filter(e=>e.trackID===i.info.trackID);if(0===t.length)continue;const a=t[0];a.track=i,a._isSubScribed=!0,"audio"===i.info.kind?n.push(a):r.push(a)}return{audioTracks:n,videoTracks:r}}if((t=await this.session.subscribe([e.trackID])).length>0){const r=t[0];return e.track=r,e._isSubScribed=!0,"audio"===r.info.kind?{videoTracks:[],audioTracks:[e]}:{audioTracks:[],videoTracks:[e]}}return{audioTracks:[],videoTracks:[]}}async unsubscribe(e){Array.isArray(e)?(await this.session.unsubscribe(e.map(e=>e.trackID)),e.forEach(e=>{e._isSubScribed=!1})):(await this.session.unsubscribe([e.trackID]),e._isSubScribed=!1)}async sendMessage(e,t,r){Array.isArray(r)?await Promise.resolve().then(()=>this.session.sendCustomMessage(t,r.map(e=>e.userID),e)):await Promise.resolve().then(()=>this.session.sendCustomMessage(t,[],e))}async startDirectLiveStreaming(e){await this.session.createForwardJob(ii({userConfigExtraInfo:e.userConfigExtraInfo,jobId:e.streamID,publishUrl:e.url,audioTrackId:e.audioTrack&&e.audioTrack.trackID,videoTrackId:e.videoTrack&&e.videoTrack.trackID}))}async stopDirectLiveStreaming(e){await this.session.stopForwardJob(e)}async startTranscodingLiveStreaming(e){await this.session.createMergeJob(e.streamID,ii({publishUrl:e.url,height:e.height,width:e.width,fps:e.videoFrameRate,kbps:e.bitrate,stretchMode:e.renderMode,watermarks:e.watermarks&&e.watermarks.map(e=>({x:e.x,y:e.y,w:e.width,h:e.height,url:e.url})),background:e.background&&{x:e.background.x,y:e.background.y,w:e.background.width,h:e.background.height,url:e.background.url},maxRate:e.maxBitrate,minRate:e.minBitrate,holdLastFrame:e.holdLastFrame})),e.transcodingTracks&&await this.setTranscodingLiveStreamingTracks(e.streamID,e.transcodingTracks)}async stopTranscodingLiveStreaming(e){await this.session.stopMergeStream(e)}async setTranscodingLiveStreamingTracks(e,t){const r=t.map(e=>ii({trackID:e.trackID,x:e.x,y:e.y,w:e.width,h:e.height,z:e.zOrder,stretchMode:e.renderMode}));e?await this.session.addMergeStreamTracks(r,e):await this.session.addMergeStreamTracks(r)}async removeTranscodingLiveStreamingTracks(e,t){e?await this.session.removeMergeStreamTracks(t.map(e=>e.trackID),e):await this.session.removeMergeStreamTracks(t.map(e=>e.trackID))}getNetworkQuality(){let e=tn.UNKNOWN;const t=this._localTracks.reduce((e,t)=>t.track?[...e,...t.track.getStats().map(e=>e.networkGrade)]:[...e],[]);return t.includes(x.POOR)?e=tn.POOR:t.includes(x.FAIR)?e=tn.FAIR:t.includes(x.GOOD)?e=tn.GOOD:t.includes(x.EXCELLENT)?e=tn.EXCELLENT:e}getUserNetworkQuality(e){let t=tn.UNKNOWN;const r=this.remoteUsers.filter(t=>t.userID===e)[0];return r?t=r.networkQuality:(jr.warning("cannot find userID: ",e),t)}enableAudioVolumeIndicator(){this.session.registerVolumeIndicatorEvent()}async kickOutUser(e){this.remoteUsers.find(t=>t.userID===e)?await this.session.kickoutUser(e):jr.warning("cannot find userID: ",e)}async startMediaRelay(e){return this.session.startMediaRelay(e)}async updateMediaRelay(e){return this.session.updateMediaRelay(e)}async stopMediaRelay(){return this.session.stopMediaRelay()}}class _a extends Ta{constructor(e){super(),this.track=e,this.client="",Aa.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,Aa.emit("set-mute-tracks",this.trackID,e,this.client)}destroy(){this.track&&this.track.release()}}class wa extends _a{constructor(e){super(e),Aa.on("audioBuffer",(t,r)=>{r===e.mediaTrack.id&&this.emit("audioFrame",t)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={uplinkBitrate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.uplinkBitrate=t[0].bitrate,e.uplinkRTT=t[0].rtt,e.uplinkLostRate=t[0].packetLossRate,e)}}class Ea extends _a{constructor(e){super(e),this.isMultiProfileEnabled=!1}getLowStreamConfig(){if(this._track)return this._track.lowStreamConfig}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){if(!this._track)return[];let e=this._track.getStats();if(0===e.length)return[];if(1===e.length){return e.map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}))}{const t=(e=e.filter(e=>0!==e.bitrate).sort((e,t)=>e.bitrate-t.bitrate)).map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}));return t[0]&&(t[0].profile=rn.LOW),t[1]&&(t[1].profile=rn.MEDIUM),t[2]&&(t[2].profile=rn.HIGH),2==t.length&&t[1].profile===rn.MEDIUM&&(t[1].profile=rn.HIGH),t}}setOptimizationMode(e){if(!this._track)return!1;const t=this._track.mediaTrack;return"contentHint"in t&&(t.contentHint=e,t.contentHint===e)}}class Ca extends Ea{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class Ma extends Vi{constructor(e){const t=Li.createMediaStreamDestination();super(t.stream.getAudioTracks()[0],e,"local"),this.sourceType=L.MIXING,this.initAudioManager(!0),this.destination=t,this.inputList=[]}appendAudioSource(e){this.inputList.find(t=>t.track===e)?jr.warning("track is already in the track list"):(this.inputList.push({track:e}),e.on("ended",()=>{this.emit("ended")}),e.audioManager.gainNode.connect(this.destination))}removeAudioSource(e){const t=this.inputList.find(t=>t.track===e);if(t){try{t.track.audioManager.gainNode.disconnect(this.destination)}catch(e){}M(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class Pa{constructor(e,t){this.effectSourceMap=new Map,this.playback=!0,this.output=e,this.playbackEngine=t}get effectList(){return Array.from(this.effectSourceMap.keys())}getEffectTrack(e){return this.effectSourceMap.get(e)}playEffect(e,t){const r=this.effectSourceMap.get(e);r?(t&&r.setVolume(t),this.playback&&r.audioManager.audioSource&&this.playbackEngine.addAudioNode(r.audioManager.gainNode),r.startAudioSource()):jr.warning("can not find target effect",e)}async addEffectSource(e,t){if(this.effectSourceMap.has(t))return void jr.warning("duplicate effect key!",t);const r=await Oa.createAudioTrackFromSource(e);this.effectSourceMap.set(t,r),this.output.appendAudioSource(r)}removeEffectSource(e){let t=[];t=e?[e]:Array.from(this.effectSourceMap.keys());for(const e of t){const t=this.effectSourceMap.get(e);if(!t)return;this.output.removeAudioSource(t),t.release(),this.effectSourceMap.delete(e)}}}class Ia{constructor(){this.gainNode=Li.createGain(),this.gainNode.connect(Li.destination)}setPlayingVolume(e){this.gainNode.gain.setValueAtTime(e,Li.currentTime)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class Ra{constructor(e){if(this.playbackEngine=new Ia,this.sourcePlayebackState=!1,!(e instanceof Vi))throw kn("audio mixing manager: origin track is not audio track");this.outputTrack=new Ma,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new Pa(this.outputTrack,this.playbackEngine),this.musicManager=new xa(this.outputTrack,this.playbackEngine)}getMusicPlaybackState(){return this.musicManager.playback}setMusicPlaybackState(e){this.musicManager.playback!==e&&(this.musicManager.playback=e,this.musicManager.audioNode&&(e?this.playbackEngine.addAudioNode(this.musicManager.audioNode):this.playbackEngine.removeAudioNode(this.musicManager.audioNode)))}getSourcePlaybackState(){return this.sourcePlayebackState}setSourcePlaybackState(e){this.sourcePlayebackState!==e&&(this.sourcePlayebackState=e,this.source.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(this.source.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.source.audioManager.gainNode)))}getEffectPlaybackState(){return this.effectManager.playback}setEffectPlaybackState(e){this.effectManager.playback!==e&&(this.effectManager.playback=e,this.effectManager.effectSourceMap.forEach((t,r)=>{t.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(t.audioManager.gainNode):this.playbackEngine.removeAudioNode(t.audioManager.gainNode))}))}setBitrate(e){this.outputTrack.setInfo({kbps:e})}setTag(e){this.outputTrack.setInfo({tag:e})}release(){this.effectManager.removeEffectSource(),this.musicManager.stopMusicMixing(),this.outputTrack.removeAudioSource(this.source),this.outputTrack.release(),this.playbackEngine.release()}}class Da extends Ra{constructor(e){if(!e._audioTrack)throw kn("input stream do not have audio track");super(e._audioTrack),this.input=e;const t=[this.outputTrack];this.input._videoTrack&&t.push(this.input._videoTrack),this.outputStream=new xo(t,"send",this.input.userID)}setBitrate(e,t){e&&this.outputStream._audioTrack&&this.outputStream._audioTrack.setKbps(e),t&&this.outputStream._videoTrack&&this.outputStream._videoTrack.setKbps(t)}}var Oa;!function(e){async function t(e,t="anonymous",r,n){return new Promise((i,a)=>{const o=document.createElement("audio");o.preload="auto",o.src=e,o.crossOrigin=t,o.addEventListener("error",()=>{a(Fn())});const s=()=>{o.removeEventListener("canplay",s);const e=new Oo(o);n&&e.setKbps(n),e.setInfo({tag:r}),i(e)};o.addEventListener("canplay",s)})}function r(e,t,r){return new Promise((n,a)=>{const o=new FileReader;o.onload=(e=>{i(e.target.result).then(e=>{const i=new Oo(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(()=>{a(Fn())})}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new Oo(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===Li.state&&await Li.resume();return await(()=>new Promise((t,r)=>{Li.decodeAudioData(e,e=>{t(e)},e=>{r(Pn(e))})}))()}e.createAudioTrackFromURL=t,e.createAudioTrackFromFile=r,e.createAudioTrackFromBuffer=n,e.createAudioTrackFromSource=async function(e,i,a){return e instanceof File?await r(e,i,a):e instanceof AudioBuffer?n(e,i,a):"string"==typeof e?await t(e,"anonymous",i,a):Promise.reject(Fn())},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new Ra(e)},e.createAudioMixingManagerFromStream=function(e){return new Da(e)}}(Oa||(Oa={}));class xa extends C{constructor(e,t){super(),this.musicOption={loop:!1,volume:1},this.playback=!0,this.output=e,this.playbackEngine=t}get audioNode(){return this.musicTrack?this.musicTrack.audioManager.gainNode:null}setMusicOption(e){this.musicOption=Object.assign(this.musicOption,e),this.musicTrack&&(this.musicTrack.setVolume(this.musicOption.volume),this.musicTrack.setLoop(this.musicOption.loop))}async startMusicMixing(e,t=!1){if(this.musicTrack)return this.stopMusicMixing(t),await this.startMusicMixing(e);try{if(this.musicTrack=await Oa.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw kn("can not find audio source");this.playback&&this.audioNode&&this.playbackEngine.addAudioNode(this.audioNode),this.musicTrack.on("audio-state-change",(e,t)=>{this.emit("music-state-change",e,t)}),this.musicTrack.startAudioSource()}catch(e){e instanceof Sn&&this.emit("error",e)}}pauseMusicMixing(){this.musicTrack?this.musicTrack.pauseAudioSource():jr.warning("can not find target music, please run startAudioMixing")}resumeMusicMixing(){this.musicTrack?this.musicTrack.resumeAudioSource():jr.warning("can not find target music, please run startAudioMixing")}stopMusicMixing(e=!1){this.musicTrack&&(this.musicTrack.stopAudioSource(e),this.output.removeAudioSource(this.musicTrack),this.musicTrack.release(),this.musicTrack=void 0)}getMusicDuration(){return this.musicTrack?this.musicTrack.getDuration():0}getMusicCurrentTime(){return this.musicTrack?this.musicTrack.getCurrentTime():0}setMusicCurrentTime(e){if(this.musicTrack&&(this.musicTrack.setCurrentTime(e),!this.musicTrack.audioManager.audioSource))throw kn("can not find audio source")}}class Ba extends C{constructor(e,t,r){super(),this.mixingTrack=e,this.source=t,this.playbackEngine=r,this.musicVolume=1,this.audioMusicManger=new xa(this.mixingTrack,this.playbackEngine),this.handleAudioMusicManger()}handleAudioMusicManger(){this.audioMusicManger.on("error",e=>{throw this.emit(Ba.ERROR,e.code,e.message),e}),this.audioMusicManger.on("music-state-change",e=>{switch(e){case H.IDLE:this.emit(Ba.STATE_CHANGED,$r.IDLE);break;case H.LOADING:break;case H.PLAY:this.emit(Ba.STATE_CHANGED,$r.MIXING);break;case H.PAUSE:this.emit(Ba.STATE_CHANGED,$r.PAUSED);break;case H.END:this.loopCount>1?(--this.loopCount,this._start(this.loopCount,!0)):this.emit(Ba.STATE_CHANGED,$r.COMPLETED);break;case H.STOP:this.emit(Ba.STATE_CHANGED,$r.STOPPED)}})}async start(e=1){this._start(e)}stop(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}resume(){this.audioMusicManger.resumeMusicMixing()}pause(){this.audioMusicManger.pauseMusicMixing()}getDuration(){return this.audioMusicManger.getMusicDuration()}getCurrentPosition(){return this.audioMusicManger.getMusicCurrentTime()}seekTo(e){this.audioMusicManger.setMusicCurrentTime(e)}getMixingVolume(){return this.musicVolume}setMixingVolume(e){let t=Number(e);t=isNaN(t)?0:t,this.musicVolume=t,this.audioMusicManger.setMusicOption({volume:this.musicVolume})}release(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}async _start(e=1,t=!1){this.loopCount=Math.max(-1,Number(e)),this.audioMusicManger.setMusicOption({loop:-1===this.loopCount,volume:this.musicVolume}),0!==this.loopCount&&await this.audioMusicManger.startMusicMixing(this.source,t)}}Ba.STATE_CHANGED="state-changed",Ba.ERROR="error";class La extends C{constructor(e,t,r){super(),this.outputTrack=e,this.playbackEngine=t,this.effectID=r,this.playback=!0,this.loopCount=1}getDuration(){return this.getValidateAudioTrack().getDuration()}getID(){return this.effectID}getFilePath(){return this._filePath}setLoopCount(e){this.loopCount=-1===e?Number.MAX_SAFE_INTEGER:Math.max(0,Number(e)),0===this.loopCount&&this.stopEffect()}getLoopCount(){return this.loopCount===Number.MAX_SAFE_INTEGER?-1:this.loopCount}playEffect(e){if(this.loopCount>0){const t=this.getValidateAudioTrack();e&&t.setVolume(e),this.playback&&t.audioManager.audioSource&&this.playbackEngine.addAudioNode(t.audioManager.gainNode),t.startAudioSource()}}stopEffect(){const e=this.getValidateAudioTrack();this.loopCount=1,e.stopAudioSource()}resumeEffect(){this.getValidateAudioTrack().resumeAudioSource()}pauseEffect(){this.getValidateAudioTrack().pauseAudioSource()}getCurrentPosition(){return this.getValidateAudioTrack().getCurrentTime()}async addEffectSource(e){try{this.audioTrack=await Oa.createAudioTrackFromSource(e),this._filePath="string"==typeof e?e:URL.createObjectURL(e),this.handleAudioTrack(),this.outputTrack.appendAudioSource(this.audioTrack)}catch(e){e instanceof Sn&&this.emit(La.ERROR,e)}}removeEffectSource(){void 0!==this.audioTrack&&(this.outputTrack.removeAudioSource(this.audioTrack),this.audioTrack.release(),this.audioTrack=void 0)}getValidateAudioTrack(){if(void 0===this.audioTrack){const e=jn();throw this.emit(La.ERROR,e),e}return this.audioTrack}handleAudioTrack(){this.audioTrack&&this.audioTrack.on("audio-state-change",e=>{switch(e){case H.END:this.loopCount>1?(this.loopCount=this.loopCount===Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:this.loopCount-1,this.playEffect(this.loopCount)):this.emit(La.FINISHED)}})}}La.FINISHED="finished",La.ERROR="error";class Ga extends C{constructor(e,t){super(),this.mixingTrack=e,this.playbackEngine=t,this.audioEffectMap=new Map,this.startedList=new Map}addListener(e,t){return super.addListener(e,t)}async createAudioEffect(e,t){if(this.audioEffectMap.has(e)){const e=Vn();throw this.emit(Ga.ERROR,e.code,e.message),e}{const r=new La(this.mixingTrack,this.playbackEngine,e);return this.handleAudioEffect(e,r),await r.addEffectSource(t),this.audioEffectMap.set(e,r),r}}start(e){this.getValidateAudioEffect(e).playEffect(1),this.startedList.set(e,!0)}stop(e){this.getValidateAudioEffect(e).stopEffect()}pause(e){this.getValidateAudioEffect(e).pauseEffect()}resume(e){this.getValidateAudioEffect(e).resumeEffect()}stopAll(){this.audioEffectMap.forEach(e=>{e.stopEffect()})}pauseAll(){this.audioEffectMap.forEach(e=>{e.pauseEffect()})}resumeAll(){this.audioEffectMap.forEach(e=>{e.resumeEffect()})}getCurrentPosition(e){const t=this.getValidateAudioEffect(e);return this.startedList.get(e)?Math.floor(1e3*t.getCurrentPosition()):0}setVolume(e,t){this.getValidateAudioEffect(e).getValidateAudioTrack().setVolume(t)}getVolume(e){return this.getValidateAudioEffect(e).getValidateAudioTrack().getVolume()}setAllEffectsVolume(e){this.audioEffectMap.forEach(t=>{t.getValidateAudioTrack().setVolume(e)})}release(){this.audioEffectMap.forEach(e=>{e.removeEffectSource()}),this.audioEffectMap.clear()}getValidateAudioEffect(e){const t=this.audioEffectMap.get(e);if(void 0===t){const e=Un();throw this.emit(Ga.ERROR,e),e}return t}handleAudioEffect(e,t){t.on(La.FINISHED,()=>{this.emit(Ga.FINISHED,e)}),t.on(La.ERROR,e=>{throw this.emit(Ga.ERROR,e.code,e.message),e})}}Ga.FINISHED="finished",Ga.ERROR="error";class Na extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:case H.STOP:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){this._mixingManager.musicManager.setMusicOption({loop:e}),await this._mixingManager.musicManager.startMusicMixing(this.source)}stop(){this._mixingManager.musicManager.stopMusicMixing()}resume(){this._mixingManager.musicManager.resumeMusicMixing()}pause(){this._mixingManager.musicManager.pauseMusicMixing()}getDuration(){return this._mixingManager.musicManager.getMusicDuration()}getCurrentPosition(){return this._mixingManager.musicManager.getMusicCurrentTime()}seekTo(e){this._mixingManager.musicManager.setMusicCurrentTime(e)}setPlayingVolume(e){this._mixingManager.playbackEngine.setPlayingVolume(e)}setMixingVolume(e,t){this._mixingManager.source.setVolume(e),this._mixingManager.musicManager.setMusicOption({volume:t})}}class Ha extends wa{constructor(e){const t=new Ra(e);super(t.outputTrack),this.sourceTrack=e,this.outputTrack=t.outputTrack,this.mixingManager=t,this.playbackEngine=new Ia,this.earMonitorEnable=!1}createAudioMusicMixer(e){return this.audioMusicMixer&&this.audioMusicMixer.release(),this.audioMusicMixer=new Ba(this.outputTrack,e,this.playbackEngine),this.audioMusicMixer}createAudioEffectMixer(){return this.audioEffectMixer?this.audioEffectMixer:(this.audioEffectMixer=new Ga(this.outputTrack,this.playbackEngine),this.audioEffectMixer)}isEarMonitorEnabled(){return this.earMonitorEnable}setEarMonitorEnabled(e){this.earMonitorEnable=e,this.earMonitorEnable?this.playbackEngine.addAudioNode(this.sourceTrack.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.sourceTrack.audioManager.gainNode)}setPlayingVolume(e){let t=Number(e);t=isNaN(t)?0:t>1?1:t<0?0:t,this.playbackEngine.setPlayingVolume(t)}destroy(){this.mixingManager.release(),this.audioEffectMixer&&this.audioEffectMixer.release(),this.audioMusicMixer&&this.audioMusicMixer.release(),this.playbackEngine.release(),this.sourceTrack.release()}createAudioMixer(e){return new Na(this.mixingManager,e)}setVolume(e){this.sourceTrack&&this.sourceTrack.setVolume(e)}}class Fa extends Ea{constructor(e){super(e)}}class ja extends wa{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){e&&this._track.setLoop(e),this._track.startAudioSource()}stop(){this._track.stopAudioSource()}resume(){this._track.resumeAudioSource()}pause(){this._track.pauseAudioSource()}getDuration(){return this._track.getDuration()}getCurrentPosition(){return this._track.getCurrentTime()}seekTo(e){this._track.setCurrentTime(e)}}const Va="data:audio/mpeg;base64,SUQzAwAAAAAfdlRJVDIAAAALAAAB//6wZY+JMpPzl1RQRTEAAAABAAAAVEFMQgAAAAEAAABUWUVSAAAAAQAAAFRDT04AAAABAAAAVFJDSwAAAAEAAABDT01NAAAAHwAAAGVuZwBvbmxpbmUtYXVkaW8tY29udmVydGVyLmNvbQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/7UMAAAAAAAAAAAAAAAAAAAAAAAEluZm8AAAAPAAAAIQAAG8AADg4OFhYWHh4eJSUlLS0tNDQ0PDw8Q0NDS0tLUlJSWlpaYWFhaWlpcHBweHh4f39/h4eHj4+PlpaWnp6epaWlra2ttLS0vLy8w8PDy8vL0tLS2tra4eHh6enp8PDw+Pj4////AAAAAExhdmM1OC4xMwAAAAAAAAAAAAAAACQGkQAAAAAAABvAI9ArKwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+1DEAAPAAAGkAAAAIAAANIAAAAQgUuQ2C0ggHpVv2yykMn99MBkmlkbANsGRtN/9DKn6+WMLYws4Lh4WxkjxRTCyjBeEm3+nZCzjyFLIzIKSqMgLKkIP1kOAiDKPuoPHEJhZAyGA11lGJAQwQrN4Rbybog81Oo5/HL4hDAzMhfDIORCH6sJWPxCHi7OvCHrs+08SyrYcjCunFEIUcF3h+GRk/0ezsbcciMXCMV+nqHuc7pCyQEknfL87AuS5wm9PnAe5Y7Ggvq5YntSi4JZp//tSxF2BAAABpAAAACEAm9fYYKG5sVGC+JNCz/TxyljU6F40ShUKyWObiUFhgEjStZ2CVnUitUbMqIzyCqxoUKH3NoM9MdurRtIOQGCAUMFCSESeQjFxRAgYXbXJF0nVe9uFo28sYY7vaCij0ID9hSkkXuTJaCDJFz8gUSiyxc8sXPLPuoSix9OQOB8P8UEoLx8INHg3fTIDwaLh4YNPIFEl33fQs/pyKfc+yxe8tkLuDJtK//QaH9/82KCiVSikopLdrY0AnUanBzTSVpS9C97/+1LEmwISLPzKLWHhSkMzXxT0objEkfG4QCz4OIieKEYpLmuJkMtc5uJdtmDor6SYLaLLX0raXraxBc+7cAr3hDL0qGSsCBwGZqypjA4ElVUY7GnEmFjhwPID30wHCGbtHoN0Z2QB0OAoDhALxQAnYOxcBA+YMFMbLwgKWUbl2Ifrr24gYTadbLMVv/+Mq24Gp3l3/h86KJLTckkhrKhq26mLTJpLGV7fiEblMVS/XOw9nrQlCwNYepQTYgRNCkqGmA1BWGYwNiGrgoDxJm5IFv/7UsRngFKU9SesMNqKVSCldaex+CXJcyfnSS9gOg3353q5gGIk2prcmlvRauYXkE9NM7dDYEWxIRGycMUtXE9qcRhJr8C1O0lVxpn0Kp/m6zF/wRLtSXM4z1RlXWHEd1DXzWM+UW8Ph44xqf///9YEMAABKDji+CgJAK7SWrtM+kLV3seiQMQh5uzbyxuDKYFdoAcmgOJZwcmBsFRkU1rTIqfKZIOMefJpi0XnywvZJR7aIsFdUXI0PYFFX46ocVsWQNp3kq67hYrZ1+B9jnnr//tSxDCAkd0fJwywccHgHeXxhhlw0cdooYK+gHjEOABLZZgYoYOoha7T6UpF/cNAmHxceFk3G7tDTxQeftfcUR4yLAGNEAABjLIu8PEIvus6sXZI0l/YEcBYAi5TEtDaViW8tUmhow2InK0p77jhdbeL1T/1lDS5pDRoaD1pMZGvVbCaVUagkijWnZZ96+TGDn23cr1MU+dv4fIbSmumc8DLQPKiAURQKMEpsSjzxxZ/7knKQBPNsT9UTwW5ZEgAAAi6EyEFKkWBDVKYCjOtzNz/+1LECwAMaGM7qLzBwYyP57WGGDCVOsqXUqVdqZlalUTFyum6B6yWHxKtfJ102ZWAmRDKgGKm50SkSRURkXbmJQqXCSwIKYJnAmGHJVFP5Rz7zcAIfFk1KXvpt2GxUQOCIwByRMAAFAlSgpAjMNQ8juOgiKhoYJIHB/jdGqTq0yaTTZenn0fTOdih3rwVkZPSk/GucPt+pjheShUIMHrA4BmQ6ecxGPKokxEtyAYL11Oo4YOAIvsHPAVTxpwg482MiPpbRYoCNuRgAEglOCRk4//7UsQFgAu4bT+sMGVBfRZntYSM+HIk6vqeMSCuSkM5F5bEQlk5Ptzp4h0YiQfCQ4LCAJJ66Ay034GEiBh1I8OIcZNrDJ0CtF40XfZPB4TPaTGXgUoPhuzNH7XhK9yydOvhjHxIQ/e0KuNMkAAAAuICRAlnsIdx2ZI+hATsEgUIiAC0abFoVUl4s+KU8Y1KK7EAxKkZHFLy8g0ZoX2HZdiKzaFS7p/jzo4VFLXt1YCQKFLl9KFoSC6AfcK8pQp3ULnCDeovRY8OT+xIBJpKPFQD//tSxAUACtCpQ6YYbIFUj2h1hgw4gD04ikwjCAIbw/nRingHLMRPNKQhE6uZE36qFjtpR42aCmPJUDGvE/BMa9n/9ijarn7LWG7Vbg6MCSCSn2S8UkXut/rOz56xjvQS0rCft+aIbkklAIkPGBmSx3JSwUD8OXEgoGJXMUUHuqmnVxp0WqTG1SmSj6rUNEuDOFqQYVYiPDTnAk2LixIzzwmDyUCKdCYKhEJD4yhWe3HRFaGAC6xVBXdWh0Uk5ZHMBYyEl5SybRFAgQCMIxAtY4f/+1LEDQAKhGlL56RloSqJZzGEmOBohpRiSG2F4Y7OCKCqEH5Z7UjVAZPgJgu0MFD6Xko0XsCIHsOmRuwydoeKKQONTv3OCCSpGAH2FVDlAlZRogBlsDCAQCfCsLoxxm8qVFBGDo8IxS4UIGygImCZNLcvIYCgbEmHAwdMmhdxAcCRsnoKjknVgIkiKLc9GlPo2hquKP/Wis6lAwAQBrN81FlZbkuy0KgqxigfmZl0DCeBofolpYVFMlFI0HJ2SAtf7Y4bQQXbfBhn6Oc/joGPk//7UsQbgApkeTCssGnBUY2pdPSM5BZITGvPiYYSXI7CRsyzKCVjlrVPOFlp9eBRhTcNr/vY3bpFLjPRI1TiGcuWg3BEGTIlJNCwgaBIFTZvolcQhPAShI4USOykeGVnFICwWHg61MSOmQMqQSWYFH0fTowBBNYmIgFL0bVGTRtdbv/f+n6VBUSZJAASRciGgy5liuXZZgbBq4T/QDlEJzRfXkiMwxN01xqHg5g+7BJpjM+v3yescqw+RuInWTjoiKngfCQo0v+zcxQwyX4+ttMy//tSxCWACfBpO6wwxUFLjGgw9Izs+2j1fuDbkrMAVK5HBzgpCdrRIkAdQcSFhcSNBtyo6imj6JdDFDx8SvYEJYXTiAsCEjhoiLkWS5QctQcLA+/kkD1pSKnBZrQIw4+5AZZenuS8URKQCTLdKg4m2y01KKMZZlzCDGoe7IIsASGhUPjxCgbARPv1kbWJTWOnGbfljF9Ti3bCSDlx2h8SOkyu4RKQPPD2Qw6OC2MbL0oJ4iatyRTloqCDhRL6fSCMAAAK4DLBnFrNdlDgUrjgcbD/+1LEMgAKLHNLh6TFsUyU5qWEjPhMbExcgCpAhIGnL2X51kh0iVQRZQQOuowcUaDmbvclmzMn387nP/fhOQfMJUFFp73K2sEZ2OSy+nLpEazQxbVRal+7tFlBALj2M4ghjEoBCYyAqZLbFw+HFeLWA5JzByKCpyUH/g6RyJ9HXpcNWoKaPNM4i/E5E3bxRD3Pe9hFhMJi9IqbmXFlEP5QEyIq8kU+wKkJkoghJNzAVDwXgkA9ciBE4BbZ2QEikHCtQMSk44haxACDjJ5Z0EEjmP/7UsQ9gAoQs0kmGG5xTwan9MSYmE7jpAw0RrGMdUNFLAEBGaxahOJDJxYFcwUlXeLKYLo72/oIKhTz5BdCag4k6ATJSda8IyHYGTovkg+aA0Z0M8OSgog7CQpDTjiTAw8abfl1o59z3iKVZq+6DxUPKWZ24aYlYuVT2UOqHrJzaVEmLWrV3n9AoKs/ohn/aguuaCU0k3AlKYUkJKFEIjxiSduHBqUg9ogMyXuEb3fNyM92e8OEDqqSRSriAmTYBRDcdNH6sQ1b0Rf0sIVxUBxy//tSxEkACihtPUwwwYE5jmjoww2SFcqgWYzRUazFdyXkP10MAAAAAYnBaB4CxiZq1IljkJIwOE5meE9wQSNhGLRMOZYxEgYi+ngx0h2xAQgXDqllDI99JcVujUNCbCbbLxGUaPFkraoagWPipq5XjdK7P8WN1jjZBRaQSoZy+HwzRk8FD1ImZFsBSbJCNJ7b1E0e6+Jc6gKCVFhgtbJsY6iIiC4xpEs1pgacY87QJyb+9abaKg0GSBUms2HuqjX/w5YJ//1KD5UASmvACU7USp//+1LEVwAKKGU3JhhuwUSM6LT2DDx7Y+CxY0AUTmjALRAthrHJHm/aasmceDjn0BHWOxU2zDHD+qkcQbUFQ4JQ6MNAwLuhNTNs2zEzAWHrD0ImyrDGnIIYQKs2f+4GeV1IoyNFPA8BAD3GYjjuIQ6GKosgGLEiET0Op7Cq5Qo5QoHkxZdokyNsjC77QKWXnP5EQxRwgxzCy2TPq7yB9TRKOzX5U0RU8ZCvXWLybyn3pjXBAGSma+pqEO/OPbQwuC45WnIIZvPCtkXXrojyITkkAv/7UsRjgApgezssJGXBSxMo9MSNFKIzdzlgD2gk2svFxytcWsjvlmhKn1eSZn3q8MwoZki5AIrYePhhwjXAzgG+GD+jt7IAIBR2aMkZI0QDF14mkgBY3rlyYPZeI50Jxj6keGaIj7pUBpWdRClqy6/6dsW3++zDROLlF4gIHR4oJ1kgg2+5sUpz4TjxXvb9c26t5rs31QwEAABBLdMNhCpOXUQXM4TOGsP+9DKHFdtg8ifKunQ1iQRNGMBRUN42jZYVbEGzfYIEDwGA8JpAgxwc//tSxG6CCjitMgykbwE9juaZhhh4nRe7ZadDN4KR5vVPgyWqARjOO/53YiIYW+4PU2PJ4uQmu4J3j/P+Tb/+36/6rWr1zqmve437/sLIQAA2k9ySNBNCHihLSTkHRKHM0OhCNiOPRmH7ZCF5eWvLTJuuuMC3FvQFRKkGyEisiDMK1MQKg5UT/rIblCO1IpX+v55fO+/2lMF/fXX1KNKW90n5eX8i/LTsdooMnT3UgutZNX/iZQQAAAxk2cYkSJaEAEngiYh+4SwKR8HuwyJlDnz/+1LEe4AOSHs3TCTQiaEn56mWDLhsSAlNRIaVYyNm6wThPzA8QQiULALDsPwJlspB6L07ymp9G8ndvclRH69p0OilmBW9D8qpXtBikk6XtILNNfT8uJeLNc0t5zu07wut2Htqm1m7v7xBvx7iJe2fe7Nn7HlBIOvNur62iJ+VL3/lUAEEFQ4azSgXqweuhMaUpW6TET7Q4/jcHbAMcwjV2o1dI1TsZSN6+kFCoVdpx5uI1tlo4vpLpCdvRJ3JQg5eaql/X3NfUxslzvnZI7rW5f/7UsRsAZE9KyjNsNLB5B6lqZeZOPsqTqh1523vbVZub7n7/kzCbmh46qxpqMaoiNHNOjQ0uVfeubvtqjanZ5oeQAIALpnZgH5SIyAEP07HlV1HV4rXgCZXSu2eZIzFOmiWZSvw7tO7rcJ6elMDytrkojMjgtLDeOdJTHLWtYX8Y0WUZvPZ03xsfsqHi2Vkb3SYxsjMN+5spPVUqFUVHJK7K6zB+QjlRl/v3GjQ+6DhYrKdGXX/V1QQONm1K/f+/o2oxngAAMZ2QIIQVNFqjRgA//tSxEiAEH2bLOyYtworIOTJpKLIsBQGJ3l0YGaeylxnIUxZyoSwEv04xetvWGwZLazmMPd5sDmNIWDjFMzdnIEk+BVYmk0H5lg3sH1NJUNFlYOJipQWOmmMujEGQPNWhssKjpaZvMTcaNrnZFB/YbK33jTpYmnJu5izzkyguOQAwOpwwLA0vSmHlCx2ZfS+i7ENAKQAAAfNJ0QbCRbhrfSJQgp4agASxIiXhGSAbow8MLRLDpCP4jIkqlJxZAPE4nJio+484qaaoKtOLx4Ia43/+1LEHwAM7JEvLLBpwdEeJamGGXC18RMGDqjRVQ0OIWKB3aNaRAqybOdYGgk2hDudAKFvARw6K3mqcdou8sAiwAAIRLgYY40NbnADxrUcWWtbo3ebYGJoYCUFxfE9MIJ6uMRxRHRNO9D4kE4sBq+PQ41rFmPcmRLwfbvtwhub5jZLrfkItmuz9rTPrUoykMzC1e3748PW8VU329//ESoYDsFS+7OAwKhdZN5Qm1R18CZLSgIfAACKStFFFmg87S1XMlbjDtA+pQ8tAuWBSYHJOf/7UsQPAAy9JTVMMKnBeh8naYSM6NVw2vHy85fsugSHv/WB6J+CcmY7KIolRrqj95fKdEVSEpc7PF2Zlbd0VHpZagOjNVTLkNOf5nm//EDkxYoDs2ZYKNdCJDyb0A92QCm27sF4RJKNkKu5S8GYLnwIE40jEICEw0goijjkSKDOtMYmUBA49fs4eMUnoZEec7ISy4/9L3K1yhllsuq84+fkR//J+9XChEDixZ+tpoTiqBR4GNET7Ou6jZJ1AU+jUAEiacoBKW4WpMjX60dZxp9G//tSxAqACoxpQ6eYbGFHCebplhjgtPQuwsaobCZzorZNuwyvYGJ+fgg0gQOMDBRBRZgk6w2RjhC0awkSdJ6j7jx1ZIWaUpeWCPohsYLuGvUuz2/9QG7iABJJ0GTwX8DgmE224vUwNCGxTXGqHENJ94l2WQplp/nmiHoJdLDjzwy0XcMIui5MeBFiqrpgqxo9De8mMkNEvHAVFjb2I6iQTSRPExROlqoASWRIBKNuagE4aIl1ToqzQYgRBMjFQwMjEimdDxdz/T7m535NK11OAIX/+1LEFQAKcHs9p7BnwVAM57WEmRAIrENipTmOynjrhcTIDIReAws5AlkB6pfdIk7sfUY1q1MLhpKMZc///rAC2kaATablw2AUUlG1t+GkuLEGuuUBIiKhs0TjjhK5lHJybTu7GKuZJzDy5bMzrMQB4GD9yAA8kxKVi6JlhogtjhVtBs1cfPQWrU07/Mo6Pbo0KqoDvuAGk3LhPxJQWEwlzHZct3yoCgnMuQHyY/YXco39WxS2IcqoxqFYQroj1ShRyoC98bXoyUd3OfaDzK7Wh//7UsQfAEtZAzlMJEfBSomncYYYYJKrWzK/AeyWyvyasoM8/2Iepx0MNezzzluPXlBQBSrNIC8TMAjC/TpiSSBSsQSSqMTVw24WASWBbmqKjqvuvHU7HhE24KklMeNB0+WaIqCgUKbBYSBJoooel6Wza0hIVlgTW1j2W6F1CooLO1/fqXUe37e2FWpuXgkBQWGYEEQvfLhyiN2xqOHFkgwhIzGY/yevZAt3LGsQihk41qRnGIsFRgCTSyhJAgZGrjhbfeHzomeMHNGMFy8Wq3UE//tSxCYACqBvR6YYbSFHieb1lhhgzYCVds9VDfsuAMSZQABJKcoxCZoSnEFnwqIg/iUZJUhcfTgIJAZXkiZUkEr/knjQR6bmjZcSQ2KCxM8RFdFkkf6wAqhhnIqYyXFrXxV7PK2ImDKL3Oo70Cun0AXZG0gE425upMoUwVwgiCwaSyZDE7FrCZWZEtmpmbPkeKvK9IgtBBYVtBZgaKBUVD7hUewpYoJRQWFCqQStTZXoC8te5m9j/wbCYAeMde/J+YFLWa6w7td3CnbIpeYitGb/+1LEMIAKsGE9rDBjgWcOKPT2GKShB5iPC5UOxmvCsilY+VHprIOdOKxp9eHAp1VM8ZXOfaqmhftPThYiRPGRUDBEpPHWnwy4QkzmxMEXnGXiccbCYIHRZCqddkr6e7MbDnrqBebrRILkjm67MlxMBdDuCJ9OQUZ6eDQuWKmF0a+q1gRMOlNi9wZ0iNmLppmeecfiZa8jEYyTKB7Roq6J3n6iosRETJhw1QoGjo0YO/NTq81f1u/qBds0cKLjac4hZCyJSCWLsoDSCzbYNExEHf/7UsQ2gAqAk0GnsGVBTZJotPSM5OOkDs0Uh8O9anh4GckBP7c1wiiWeK6sfkX5+cuJ0CZrjIAWwcfGWYHYXRHIExhVQrV60MH39fp9KqnVAGlAAEoqU2QHYpMKzWF5AYXDqXEhuaD33FwwOOHwsEtZFi2JMckTwyzOUWJjBUOg094PhddDoqLvvSPUHzCrnM/KrQGL5oVUzumnspfW+/vUqZv6ASrAALSUvHeAlnCpDiTBqyiQakICQcHyIgJ0CBdNBjcUQZaGTdzAEd2T86mZ//tSxECACohVN0wwxQGEkCfo9IzooUEU4VwQ4gPhhpQIjhoeCwq1JOTEN9VWt8BgS+9h/tJirxjULUNGqsSBDI4TuQTZUcC/xIoRqlQUk0xBJBQlWzRF8pdIx+LWXC0rLFmuLWqmaBSASd9m1cPDUL+ihaYK1iOUjZSUo+RmpPtnMxamMCoaAQsJZ+7en3GxyUlUZhyf//FYmen2cWcKBCR9lINRyXgGyGQGzpVVkLwBSYgKTZUdiSWwLiGMI0mQQ+nOh930zwfJERkhSQJCNgD/+1LEQ4AKpKtDR7Bo0UwKaDWWGGAEYCD6APOvolzoxDFVQmxzwnQ8mQQYap5P+8PnBx+OCPTVAkV5iTZHL7rfxwq5Wbzbrvq89BCLLrRd1J6mZzKobw9GAUIEC9OM5FDnLDFAzKlTSuBJrqMUHVNhzaur0j3Lgnqxc7fcMurjzSCzVP8O///X77wWpX7ev/8+gBNUuSAEhRxNpRJuQAHhLLDGXQBxAHpVoA4+7xfNdZaIMAF0HkicaRAVgHsHKYIxT8EceOkOdr53pDakdomzjP/7UsRNAAtEcU31gYAqYSbmtzTwAelqwkmxLb1Iui+ZtPHcXcUlagUyvNKFnt9K7owP/qM5qtrfv4M+/77pNeW89Fcssj95PBiVvqurZ3/ExBz/aJRieRKODyTX/+P/X3/pibzb3RUPImPEvALKAGAAAgArwFi3Cif+bImX+lmP+BDZooObSf8DSrgBmw5JEcAQ2Bi0AGfOGJMocCw8DAlgMmKBYE6KSfh6QN1gbuHUAaARb/AwoQckVgAUMFkofXqV/AXDBYEPqAuCCyUG2osh//tSxDGAEoFFELmqAAAAADSDgAAESVSqv4ciFkIqIpEG6oNsS8JtC33//8OSGTAQDCxIL7BjoXyC5ocsR0Hza9f//k+XkkxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+1LERYPAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==";class Ua extends Ea{constructor(e,t,r,n){super(e),this.drawImage=(()=>{this.drawImageOnce(),requestAnimationFrame(this.drawImage)}),this.drawImageOnce=(()=>{if(this.ctx)for(const e of this.canvasSources)this.ctx.drawImage(e.source,e.x,e.y,e.width,e.heigth)}),this.canvas=t,this.ctx=r,this.updateSources(n).then(this.drawImage).catch(e=>{jr.warning(e)});const i=new Audio;i.src=Va,i.autoplay=!0,i.loop=!0,i.muted=!0,i.ontimeupdate=(()=>{this.drawImageOnce()}),this.audioElement=i}async updateSources(e){this.sources=e,this.canvasSources=[];const t=await Promise.all(e.map(e=>Ii.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;rthis.mMax&&(this.mFiltered=this.mMax),this.mLastFilteredTimestamp=Date.now(),this.applied=!0}Filtered(){return this.mFiltered}LastFilteredTime(){return this.mLastFilteredTimestamp}UpdateBase(e){this.mAlpha=e}}function Qa(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Ka(r),e[t])}Ka.kValueUndefined=-1,Ka.AlphaForPacketLossFractionSmoother=.9999,Ka.SMOOTH_VIDEO_INTERVAL=1e3,Ka.SMOOTH_AUDIO_INTERVAL=5e3;const Ja=Qa(),Za=Qa(),$a=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function Ya(e,t){let r;r=e>9||t>100?x.POOR:e>5||t>80?x.FAIR:e>1||t>40?x.GOOD:x.EXCELLENT;const n=navigator;return n.connection&&n.connection.effectiveType&&["slow-2g","2g","3g"].includes(n.connection.effectiveType)&&(r=x.POOR),r}const eo={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},to={nack_count:0,fir_count:0,pli_count:0,width:0,height:0,jitter_buffer_delay:0,bytes_sent:0,frame_encoded:0,bytes_received:0,frame_decoded:0},ro={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var no,io,ao;function oo(e,t){let r=e||0;const n={chrome:["86.0.4240","87.0.4280"]};return n[b.name]&&n[b.name].includes(b.version)&&t===io.InBoundRtp?(r=Math.min(e/32767,1),Xa.create({code:za.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&Xa.create({code:za.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function so(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function co(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function uo(e,t,r,n){const i=t-e,a=n-r;if(i<=0||a<=0)return 0;const o=i/a;return o>1?1:o}function lo(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};E.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return E.unifiedPlan&&E.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function Ao(e,t,r,n=600){if(r){const i=[{rid:"hi",active:!0,maxBitrate:1e3*n},{rid:"lo",active:!0,maxBitrate:1e3*r.bitrate,scaleResolutionDownBy:r.scaleResolutionDownBy}];return await t.addTransceiver(e,{direction:"sendonly",sendEncodings:i})}return await t.addTransceiver(e,{direction:"sendonly"})}!function(e){e.Video="video",e.Audio="audio"}(no||(no={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(io||(io={})),function(e){e.In="in",e.Out="out"}(ao||(ao={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(po="PermissionDeniedError",fo)return fo("PermissionDeniedError");throw Gn()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(po="desktop");"rtcmulticonnection-extension-loaded"===e&&jr.warning("your chrome screen sharing plugin is not the latest version, or you have other screen sharing plugins.");e.sourceId&&fo&&fo(ho=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let ho,fo,po="screen";async function mo(){return await(()=>new Promise((e,t)=>{"desktop"!==po?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==po)},2e3)):e(!0)}))()}async function go(e,t){const r=t.source;return await(()=>new Promise((n,i)=>{const a={mozMediaSource:r||"window",mediaSource:r||"window",height:t.height,width:t.width};if(g)return void n(a);const o={mandatory:{chromeMediaSource:po,maxWidth:Co(t.width),maxHeight:Co(t.height)},optional:[]};"desktop"!==po?n(o):e?function(e){if(ho)return e(ho);fo=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(Gn())}):function(e,t=!1,r=!1){fo=e,t?window.postMessage("qnrtc:get-sourceId-screen","*"):r?window.postMessage("qnrtc:get-sourceId-window","*"):window.postMessage("qnrtc:get-sourceId","*")}(function(e){o.mandatory.chromeMediaSourceId=e,"PermissionDeniedError"!==e?n(o):i(Gn())},"screen"===r,"window"===r)}))()}class vo{constructor(e,t){this.tracks=[],this.publishedTrackInfo=[],this.userID=e,this.userData=t}get published(){return this.publishedTrackInfo.length>0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=mi(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{M(this.tracks,t=>t===e)})}removeTracksByTrackId(e){M(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=mi(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){M(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function To(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function bo(e){return{trackID:e.trackid,tag:e.tag,mid:e.mid||void 0,kind:e.kind,userID:e.playerid,muted:e.muted,versionid:e.versionid,profiles:e.profiles||[]}}function So(e,t){return{trackid:e.trackID,mid:e.mid||void 0,kind:e.kind,master:t,muted:!!e.muted,playerid:e.userID,tag:e.tag||"",versionid:e.versionid}}function yo(e){if(!e.info.mid&&E.unifiedPlan)throw kn("can not find track mid!");return{localid:e.mediaTrack.id,localmid:e.info.mid||void 0,master:e.master,kind:e.info.kind,kbps:e.info.kbps,tag:e.info.tag}}function ko(e){return new vo(e.playerid,e.playerdata)}function _o(e,t,r){let n;return"audio"===e.kind?(n=new Vi(e)).initAudioManager(!0):n=new Pi(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function wo(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const Eo=e=>(function(e){0===Object.keys(e.audio).length&&"boolean"!=typeof e.audio&&(e.audio=!0);0===Object.keys(e.video).length&&"boolean"!=typeof e.video&&(e.video=!0);return e})(function(e){if(E.minMaxWithIdeal)return e;return["video","screen"].forEach(t=>{"object"==typeof e[t]&&"object"==typeof e[t].width&&e[t].width.ideal&&delete e[t].width.ideal,"object"==typeof e[t]&&"object"==typeof e[t].height&&e[t].height.ideal&&delete e[t].height.ideal}),e}(ii(e)));function Co(e){if(e)return"number"==typeof e?e:e.exact?e.exact:e.max?e.max:e.ideal?e.ideal:e.min?e.min:void 0}const Mo="fk6fk2rnb",Po="https://api-demo.qnsdk.com",Io="/v1",Ro=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function Do(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new ga,i=new ga,a=await async function(){let e="unknow";try{e=await pn()}catch(e){}return e+"_"+si(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await Go.getLocalTracks({video:{enabled:!0},audio:{enabled:!0}});if(c=f.find(e=>"video"===e.info.kind),s=f.find(e=>"audio"===e.info.kind),void 0===c||void 0===s)throw kn("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Po}${Io}${Ro(e,t,Mo)}`;try{let e;if("AbortController"in window){const t=new AbortController;setTimeout(()=>t.abort(),5e3),e=await fetch(r,{signal:t.signal,headers:{"Content-Type":"application/json"}})}else e=await fetch(r,{headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error(e.statusText);return e.text()}catch(e){throw e}})(a,e).then(e=>t.joinRoomWithToken(e)).then(r).catch(n)});await Promise.all([p("userA",n),p("userB",i)]);const m=e=>new Promise((t,r)=>{e.trackInfoList.length>0?e.subscribe(e.trackInfoList.map(e=>e.trackID)).then(t).catch(r):e.on("track-add",n=>{e.subscribe(n.map(e=>e.trackID)).then(t).catch(r)})});await Promise.all([n.publish([c]),i.publish([s]),m(n),m(i)]);const g=[],v=[],T=[],b=[],S=[],y=30;let k=0;await new Promise(e=>{o=setInterval(()=>{const t=n.publishedTracks[0].getStats(),r=i.publishedTracks[0].getStats();t.length>0&&r.length>0&&s&&(g.push(t[0].rtt),v.push(t[0].packetLossRate),T.push(r[0].bitrate),b.push(t[0].bitrate),S.push(s.getCurrentVolumeLevel())),g.length>15&&(clearInterval(o),e()),k>y&&(jr.warning("abnormal track stats: less than 15 valid stats in 30s"),clearInterval(o),e()),k+=1},1e3)}),jr.log(JSON.stringify({detailTestResult:{rtts:g,packetLossRates:v,audioBitrates:T,videoBitrates:b,volumnLevels:S}})),g.length>0&&(d=Math.ceil(g.reduce((e,t)=>e+t,0)/g.length),u=v.reduce((e,t)=>e+t,0)/v.length,l=T.reduce((e,t)=>e+t,0)/T.length,A=b.reduce((e,t)=>e+t,0)/b.length,h=S.reduce((e,t)=>e+t,0)/S.length),t=!0}catch(e){t=!1,r="string"==typeof e?e:e instanceof Sn?JSON.stringify(e):e.message}finally{return n.roomState===fa.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===fa.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),gn.addEvent("SystemRequirementsTest",{room_name:a,ok:t,reason:r,avg_rtt:d,avg_packet_loss_rate:u,avg_volumn_level:h,avg_audio_bitrate:l,avg_video_bitrate:A,test_take_time:Date.now()-e,event_grade:t?An.NORMAL:An.SERVERE},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class Oo extends Vi{constructor(e,t){if(!E.mediaStreamDest)throw wn("your browser does not support audio buffer input!");const r=new Fi;r.initAudioContext(),e instanceof AudioBuffer?(r.setAudioBufferSource(),r.setAudioBuffer(e)):e instanceof HTMLAudioElement&&r.setMediaElementSource(e),super(r.audioStream.stream.getTracks()[0],t,"local"),this.sourceType=L.EXTERNAL,this.isLoop=!1,this.originSource=e,this.audioManager=r,this.handleAudioManagerEvents()}setLoop(e){this.isLoop=e,this.audioManager.setAudioSourceLoop(e)}startAudioSource(){this.audioManager.playAudioSource()}pauseAudioSource(){this.audioManager.pauseAudioSource()}resumeAudioSource(){this.audioManager.resumeAudioSource()}stopAudioSource(e=!1){this.audioManager.stopAudioSource(!1,e)}getCurrentTime(){return this.audioManager.getAudioSourceCurrentTime()||0}setCurrentTime(e){this.audioManager.setAudioSourceCurrentTime(e)}getDuration(){return this.audioManager.getAudioSourceDuration()||0}handleAudioManagerEvents(){this.audioManager.on("@audio-source-state-change",(e,t)=>{this.emit("audio-state-change",e,t)})}}class xo extends C{constructor(e,t="send",r){super(),this.trackList=[],this.isDestroyed=!1,this.enableAudio=!0,this.enableVideo=!0,this.muteAudio=!1,this.muteVideo=!1,this.onAudioEnded=(e=>{this.emit("audio-ended",e)}),this.onVideoEnded=(e=>{this.emit("video-ended",e)}),this.onAudioSourceStateChange=((e,t)=>{this.emit("audio-source-state-change",e,t)}),this.direction=t,this.userID=r,e.forEach(e=>{e.setMaster(!0),e.on("mute",()=>{this.updateTrackState()}),e.on("release",()=>{M(this.trackList,t=>t===e),this.updateTrackState(),0===this.trackList.length&&this.release()}),this.trackList.push(e)}),this.updateTrackState()}get audioSourceIsLoop(){return this._audioTrack instanceof Oo&&this._audioTrack.isLoop}setVolume(e){this._audioTrack&&this._audioTrack.setVolume(e)}play(e,t){this.trackList.forEach(r=>r.play(e,t)),this._audioTrack&&(this.audio=this._audioTrack.mediaElement),this._videoTrack&&(this.video=this._videoTrack.mediaElement)}getCurrentTimeDomainData(){return this._audioTrack?this._audioTrack.getCurrentTimeDomainData():new Uint8Array(0)}getCurrentFrequencyData(){return this._audioTrack?this._audioTrack.getCurrentFrequencyData():new Uint8Array(0)}getCurrentVolumeLevel(){return this._audioTrack?this._audioTrack.getCurrentVolumeLevel():0}getStats(){let e=$a();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=$a();if(this._videoTrack){const e=this._videoTrack.getStats();e.length>0&&(t=e[0])}return{timestamp:Date.now(),videoBitrate:t.bitrate,audioBitrate:e.bitrate,videoPacketLoss:t.packetLoss,audioPacketLoss:e.packetLoss,videoPackets:t.packets,audioPackets:e.packets,videoPacketLossRate:t.packetLossRate,audioPacketLossRate:e.packetLossRate,videoBytes:t.bytes,audioBytes:e.bytes,pctype:this.direction}}getCurrentFrameDataURL(){return this._videoTrack?this._videoTrack.getCurrentFrameDataURL():"data:,"}setAudioSourceLoop(e){this._audioTrack instanceof Oo&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof Oo&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof Oo?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof Oo?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof Oo)return this._audioTrack.setCurrentTime(e)}setKbps(e,t){e&&this._videoTrack&&this._videoTrack.setKbps(e),t&&this._audioTrack&&this._audioTrack.setKbps(t)}updateTrackState(){this.trackList.forEach(e=>{"audio"===e.info.kind?(this._audioTrack&&(this._audioTrack.off("ended",this.onAudioEnded),this._audioTrack.off("audio-state-change",this.onAudioSourceStateChange)),this.audioTrack=e.mediaTrack,this._audioTrack=e,this._audioTrack.on("ended",this.onAudioEnded),this._audioTrack instanceof Oo&&this._audioTrack.on("audio-state-change",this.onAudioSourceStateChange)):(this._videoTrack&&this._videoTrack.off("ended",this.onVideoEnded),this.videoTrack=e.mediaTrack,this._videoTrack=e,this._videoTrack.on("ended",this.onVideoEnded))}),this.audioTrack?(this.enableAudio=!0,this.muteAudio=!this.audioTrack.enabled):this.enableAudio=!1,this.videoTrack?(this.enableVideo=!0,this.muteVideo=!this.videoTrack.enabled):this.enableVideo=!1}release(){if(!this.isDestroyed){for(let e=0;e"videoinput"===e.kind);case"microphones":return this.deviceInfo.filter(e=>"audioinput"===e.kind);case"playback":return this.deviceInfo.filter(e=>"audiooutput"===e.kind)}}async getElectronScreenSources(e){let t;try{const{ipcRenderer:e}=window.require("electron");t={getSources:t=>e.invoke("QNRTC_DESKTOP_CAPTURER_GET_SOURCES",t)}}catch(e){throw jr.warning(e),Rn(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case cn.ALL:r.types.push("window","screen");break;case cn.SCREEN:r.types.push("screen");break;case cn.WINDOW:r.types.push("window")}try{return(await t.getSources(r)).map(e=>({ID:e.id,name:e.name,url:e.thumbnail.toDataURL()}))}catch(e){throw jr.warning(e),kn(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(!0===e.audio&&(t={audio:{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop"}}}),e.sourceID)t={video:{mandatory:{chromeMediaSourceId:e.sourceID,chromeMediaSource:"desktop"}}};else{const e=await this.getElectronScreenSources();if(0===e.length)return[];t={video:{mandatory:{chromeMediaSourceId:await async function(e){return new Promise((t,r)=>{const n=document.createElement("div");n.setAttribute("style","position: fixed; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);");const i=document.createElement("div");i.setAttribute("style","text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;"),i.innerText="share screen";const a=document.createElement("div");a.setAttribute("style","width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;"),n.appendChild(i),n.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 12%;"),o.innerText="QiNiu Web Screensharing wants to share the contents. Choose what you'd like to share.";const s=document.createElement("div");s.setAttribute("style","width: 100%; height: 80%; background: #FFF; border: solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around; overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");const c=document.createElement("button");c.setAttribute("style","width: 85px;"),c.innerText="cancel",c.onclick=(()=>{document.body.removeChild(n),r(Mn("user cancel selection"))});const d=document.createElement("div");d.setAttribute("style","text-align: right; padding: 16px 0;"),d.appendChild(c),a.appendChild(o),a.appendChild(s),a.appendChild(d);for(const r of e){const e=document.createElement("div");e.setAttribute("style","width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;"),e.onclick=(()=>{document.body.removeChild(n),t(r.ID)});const i=document.createElement("div");i.setAttribute("style","height: 120px; display: table-cell; vertical-align: middle;");const a=document.createElement("img");a.setAttribute("style","width: 100%; background: #333333; box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);"),a.src=r.url,i.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 40px; line-height: 40px; display: inline-block; width: 70%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"),o.innerText=r.name,e.appendChild(i),e.appendChild(o),s.appendChild(e)}document.body.appendChild(n)})}(e),chromeMediaSource:"desktop"}}}}e.width&&(t.video.maxWidth=e.width,t.video.minWidth=e.width),e.height&&(t.video.maxHeight=e.height,t.video.minHeight=e.height);try{jr.log("electron getUserMedia constraints: ",t),r=await navigator.mediaDevices.getUserMedia(t)}catch(e){throw kn(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())"audio"===t.kind?n.push(_o(t,e.audioTag,e.bitrate)):(e.optimizationMode&&Lo(t,e.optimizationMode),n.push(_o(t,e.tag,e.bitrate)));return n}async getLocalTracks(e=Bo){if(jr.debug("get local tracks",e),R(e)&&I(e)){const t={screen:e.screen},r={video:e.video,audio:e.audio},n=await Promise.all([this.getLocalTracks(t),this.getLocalTracks(r)]);return n[0].concat(n[1])}const t=await async function(e){if(!e)return{audio:!0,video:!0};if(R(e)){if(I(e))throw kn("can not get mediaStream with video and screen are all enabled");if(!E.screenSharing)throw wn("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!E.getDisplayMedia)&&!await mo())throw Cn("")}const t=!(!e.audio||!e.audio.enabled||e.audio.source)&&{deviceId:e.audio.deviceId,sampleRate:e.audio.sampleRate,sampleSize:e.audio.sampleSize,channelCount:e.audio.channelCount,autoGainControl:e.audio.autoGainControl,echoCancellation:e.audio.echoCancellation,noiseSuppression:e.audio.noiseSuppression},r=!(!e.video||!e.video.enabled)&&{frameRate:e.video.frameRate,height:e.video.height,width:e.video.width,deviceId:e.video.deviceId,facingMode:e.video.facingMode};if(R(e)&&e.screen){if(E.getDisplayMedia&&!e.screen.forceChromePlugin)return Eo({audio:t,video:{displaySurface:wo(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await go(!1,e.screen);return Eo({audio:t,video:r})}return Eo({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&gn.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId,event_grade:An.GENERAL,event_category:hn.VIDEO}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&gn.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId,event_grade:An.GENERAL,event_category:hn.AUDIO});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?Mn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),R(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),I(e)&&(n=e.video.bitrate,a=e.video.tag);const s=r?r.getTracks():[],c=[];for(const t of s){let r;e.video&&e.video.optimizationMode&&(r=e.video.optimizationMode),e.screen&&e.screen.optimizationMode&&(r=e.screen.optimizationMode),r&&Lo(t,r)}for(const e of s){let t;t="audio"===e.kind?_o(e,o,i):_o(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await Oa.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&R(e)&&I(e))throw kn("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new xo(t,"send")}async getUserMedia(e,r,n=!0){if(jr.debug("request to get user media, config",e),jr.debug("request to get user media, constraints",r),!r.audio&&!r.video)return null;let i;if(R(e))i=await this.getDisplayMedia(r,e);else if(i=await navigator.mediaDevices.getUserMedia(r),!S&&"getSettings"in MediaStreamTrack.prototype&&n){const n=r.video;if(n&&"boolean"!=typeof n){const a=n.width,o=n.height;if("number"==typeof a&&"number"==typeof o){const s=i.getVideoTracks(),c=s&&s[0],{height:d=o,width:u=a}=c.getSettings();if(u&&d){const s=(o-d)*(a-u);if(s*s>10){const s=o/a;return d/ue.stop()),this.getUserMedia(e,t({},r,{video:n}),!1)}}}}}return i}async getDisplayMedia(e,t){let r,n;e.audio&&(r=await navigator.mediaDevices.getUserMedia({audio:e.audio}));const i=t.screen&&t.screen.audio&&!e.audio?{video:e.video,audio:t.screen.audio}:{video:e.video};return n=E.getDisplayMedia&&t.screen&&!t.screen.forceChromePlugin?await navigator.mediaDevices.getDisplayMedia(i):await navigator.mediaDevices.getUserMedia(i),r&&n.addTrack(r.getAudioTracks()[0]),n}async updateDeivceInfo(){this.deviceInfo=await navigator.mediaDevices.enumerateDevices();const e=this.deviceInfo.map(e=>e.deviceId),t=Object.keys(this.deviceMap);let r=!1;t.forEach(t=>{if(-1===e.indexOf(t)&&"@default"!==t){this.emit("device-remove",this.deviceMap[t].device);const e=this.deviceMap[t].device;this.emit("device-changed",{device:e,state:qr.INACTIVE});const n="audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",i="AudioDeviceInOut"===n?hn.AUDIO:hn.VIDEO;gn.addEvent(n,{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label,event_grade:An.GENERAL,event_category:i}),delete this.deviceMap[t],r=!0}else this.deviceMap[t].tick+=1}),e.forEach((e,n)=>{if(-1===t.indexOf(e)&&"@default"!==e){this.deviceMap[e]={device:this.deviceInfo[n],tick:0};const t=this.deviceMap[e].device;this.emit("device-changed",{device:t,state:qr.ACTIVE}),this.emit("device-add",t);const i="audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",a="AudioDeviceInOut"===i?hn.AUDIO:hn.VIDEO;gn.addEvent(i,{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId,event_grade:An.GENERAL,event_category:a}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class No{static get VERSION(){return Hr}static isBrowserSupported(){return E.support}static async checkSystemRequirements(){return await Do()}static setLogLevel(e){switch(e){case an.VERBOSE:jr.setLevel("log");break;case an.INFO:jr.setLevel("debug");break;case an.WARNING:case an.ERROR:jr.setLevel("warning");break;case an.NONE:jr.setLevel("disable")}}static async isChromeExtensionAvailable(){return await mo()}static createClient(){const e=new ka(this._transportPolicy);return No._clients.push(e),e}static async getCameras(e=!1){return Go.getDeviceInfo(e,"cameras")}static async getMicrophones(e=!1){return Go.getDeviceInfo(e,"microphones")}static async getPlaybackDevices(e=!1){return Go.getDeviceInfo(e,"playback")}static async getDevices(e=!1){return Go.getDeviceInfo(e,"all")}static async createCameraVideoTrack(e){let r;if(jr.log("createCameraVideoTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Wr[e.encoderConfig]))throw Hn()}else r=t({},zr,e.encoderConfig);else r=zr;const n=(await Go.getLocalTracks({video:ii({enabled:!0,width:r.width,height:r.height,frameRate:r.frameRate,bitrate:r.bitrate,tag:e&&e.tag,facingMode:e&&e.facingMode,optimizationMode:e&&e.optimizationMode,deviceId:e&&e.cameraId})}))[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(n.lowStreamConfig=e.encoderConfig.lowStreamConfig);const i=new Ca(n);return void 0!==r.isMultiProfileEnabled&&(i.isMultiProfileEnabled=r.isMultiProfileEnabled),jr.log("createCameraVideoTrack end",i),i}static async createMicrophoneAudioTrack(e){let r;if(jr.log("createMicrophoneAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag})}),i=new Ha(n[0]);return jr.log("createMicrophoneAudioTrack end",i),i}static async createScreenVideoTrack(e,r){let n;if(jr.log("createScreenVideoTrack start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Qr[e.encoderConfig]))throw Hn()}else n=t({},Jr,e.encoderConfig);else n=Jr;let i=[];if(y)i=await Go.createElectronScreenTrack(ii({sourceID:e&&e.electronScreenSourceID,screenBitrate:n.bitrate,width:n.width,height:n.height,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag}));else{let a=ii({enabled:!0,width:n.width,height:n.height,bitrate:n.bitrate,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag});if(e&&e.chromeExtensionSourceType)switch(e.chromeExtensionSourceType){case Zr.ALL:a=t({},a,{forceChromePlugin:!0});break;case Zr.SCREEN:case Zr.WINDOW:a=t({},a,{forceChromePlugin:!0,source:e.chromeExtensionSourceType})}i=await Go.getLocalTracks({screen:a})}if(1===i.length&&"video"===i[0].info.kind&&"enable"===r)throw i[0].release(),In();if(1===i.length&&"video"===i[0].info.kind){const t=i[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(t.lowStreamConfig=e.encoderConfig.lowStreamConfig);const r=new Fa(t);return void 0!==n.isMultiProfileEnabled&&(r.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",r),r}{const t=i.filter(e=>"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw kn(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new wa(t),o=new Fa(r);return void 0!==n.isMultiProfileEnabled&&(o.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",[o,a]),[o,a]}}static async createMicrophoneAndCameraTracks(e,r){let n,i;if(jr.log("createMicrophoneAndCameraTracks start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Xr[e.encoderConfig]))throw Hn()}else n=t({},Kr,e.encoderConfig);else n=Kr;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=Wr[r.encoderConfig]))throw Hn()}else i=t({},zr,r.encoderConfig);else i=zr;const a=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:n.bitrate,sampleRate:n.sampleRate,sampleSize:n.sampleSize,channelCount:n.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag}),video:ii({enabled:!0,width:i.width,height:i.height,frameRate:i.frameRate,bitrate:i.bitrate,tag:r&&r.tag,facingMode:r&&r.facingMode,deviceId:r&&r.cameraId})}),o=a.filter(e=>"audio"===e.info.kind)[0],s=a.filter(e=>"video"===e.info.kind)[0];if(!o||!s)throw kn(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new Ha(o),d=new Ca(s);return void 0!==i.isMultiProfileEnabled&&(d.isMultiProfileEnabled=i.isMultiProfileEnabled),jr.log("createMicrophoneAndCameraTracks end",[c,d]),[c,d]}static async createBufferSourceAudioTrack(e){let r;if(jr.log("createBufferSourceAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,source:e.source,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,tag:e&&e.tag})}),i=new ja(n[0],e.source);return jr.log("createBufferSourceAudioTrack end",i),i}static createCanvasVideoTrack(e){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");if(null===r)throw wn("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw wn("capture stream error, canvas track not supported");n=t.mozCaptureStream(15)}const i=n.getTracks()[0];e.optimizationMode&&"contentHint"in i&&(i.contentHint=e.optimizationMode);const a=_o(i,e.tag);return new Ua(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=_o(e.mediaStreamTrack,e.tag,e.bitrate);return new qa(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=_o(e.mediaStreamTrack,e.tag,e.bitrate);return new Wa(t)}static setTransportPolicy(e){e===on.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===on.FORCE_UDP&&(this._transportPolicy="forceUdp"),this._clients.forEach(e=>e.setTransportPolicy(this._transportPolicy))}static async checkAudioTrackIsActive(e,t=5e3){const r=Math.min(200,t);return new Promise((t,n)=>{if(e.isAudio()){const n=.01,i=200;let a=e.getVolumeLevel()||0,o=e.getVolumeLevel()||0,s=o<=n,c=!0;if(e.isMuted())t(!1);else{const d=setInterval(()=>{e.isMuted()?(t(!1),clearInterval(d)):(a=o,(o=e.getVolumeLevel()||0)>n&&(s=!1),o!==a&&(c=!1))},i);setTimeout(()=>setTimeout(()=>{d&&(clearInterval(d),t(!s&&!c))},0),r)}}else n(kn("only support audio track"))})}static async checkVideoTrackIsActive(e,t=5e3){return new Promise((r,n)=>{if(e.isVideo()){const i=e.getMediaStreamTrack();if(e.isMuted()&&r(!1),void 0===i)n(kn("cannot find mediaStreamTrack"));else{const a=document.createElement("video");a.style.width="1px",a.style.height="1px",a.setAttribute("muted",""),a.muted=!0,a.setAttribute("playsinline",""),a.controls=!1,a.style.opacity="0.01",a.style.position="fixed",a.style.left="0",a.style.top="0",document.body.appendChild(a),a.srcObject=new MediaStream([i]),a.play();const o=document.createElement("canvas");o.width=160,o.height=120;const s=o.getContext("2d");if(s){let n=!1,i=null;const c=setInterval(()=>{e.isMuted()&&(c&&(clearInterval(c),r(!1)),a&&a.remove()),s.drawImage(a,0,0,160,120);const t=s.getImageData(0,0,o.width,o.height);var d=Math.floor(t.data.length/3);if(i){for(let e=0;e{setTimeout(()=>{c&&(clearInterval(c),r(n)),a&&a.remove()},0)},t)}else n(kn("can not get canvas 2d context"))}}else n(kn("only support video track"))})}static async getElectronScreenSources(e){return Go.getElectronScreenSources(e)}}return No._clients=[],No._transportPolicy="preferUdp",Go.on("device-changed",e=>{switch(e.device.kind){case"audioinput":No.onMicrophoneChanged&&No.onMicrophoneChanged(e);break;case"audiooutput":No.onPlaybackDeviceChanged&&No.onPlaybackDeviceChanged(e);break;case"videoinput":No.onCameraChanged&&No.onCameraChanged(e)}}),No}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).QNRTC=t()}(this,function(){"use strict";var e=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e};var t=function(t){for(var r=1;r)?=?)";var _=s++;o[_]=o[d]+"|x|X|\\*";var w=s++;o[w]=o[c]+"|x|X|\\*";var E=s++;o[E]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var C=s++;o[C]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var I=s++;o[I]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var R=s++;o[R]="(?:~>?)";var D=s++;o[D]="(\\s*)"+o[R]+"\\s+",a[D]=new RegExp(o[D],"g");var O=s++;o[O]="^"+o[R]+o[E]+"$";var x=s++;o[x]="^"+o[R]+o[C]+"$";var B=s++;o[B]="(?:\\^)";var L=s++;o[L]="(\\s*)"+o[B]+"\\s+",a[L]=new RegExp(o[L],"g");var N=s++;o[N]="^"+o[B]+o[E]+"$";var G=s++;o[G]="^"+o[B]+o[C]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var F=s++;o[F]="^"+o[k]+"\\s*("+b+")$|^$";var j=s++;o[j]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[E]+")",a[j]=new RegExp(o[j],"g");var V=s++;o[V]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="(<|>)?=?\\s*\\*";for(var W=0;W<35;W++)r(W,o[W]),a[W]||(a[W]=new RegExp(o[W]));function z(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X)return e;if("string"!=typeof e)return null;if(e.length>n)return null;if(!(t.loose?a[y]:a[T]).test(e))return null;try{return new X(e,t)}catch(e){return null}}function X(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof X){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>n)throw new TypeError("version is longer than "+n+" characters");if(!(this instanceof X))return new X(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var o=e.trim().match(t.loose?a[y]:a[T]);if(!o)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+o[1],this.minor=+o[2],this.patch=+o[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");o[4]?this.prerelease=o[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new X(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(Y(e,t))return null;var r=z(e),n=z(t);if(r.prerelease.length||n.prerelease.length){for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return"pre"+i;return"prerelease"}for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return i},t.compareIdentifiers=Q;var K=/^[0-9]+$/;function Q(e,t){var r=K.test(e),n=K.test(t);return r&&n&&(e=+e,t=+t),r&&!n?-1:n&&!r?1:et?1:0}function J(e,t,r){return new X(e,r).compare(new X(t,r))}function Z(e,t,r){return J(e,t,r)>0}function $(e,t,r){return J(e,t,r)<0}function Y(e,t,r){return 0===J(e,t,r)}function ee(e,t,r){return 0!==J(e,t,r)}function te(e,t,r){return J(e,t,r)>=0}function re(e,t,r){return J(e,t,r)<=0}function ne(e,t,r,n){var i;switch(t){case"===":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e===r;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e!==r;break;case"":case"=":case"==":i=Y(e,r,n);break;case"!=":i=ee(e,r,n);break;case">":i=Z(e,r,n);break;case">=":i=te(e,r,n);break;case"<":i=$(e,r,n);break;case"<=":i=re(e,r,n);break;default:throw new TypeError("Invalid operator: "+t)}return i}function ie(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ie){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ie))return new ie(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ae?this.value="":this.value=this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){return Q(t,e)},t.major=function(e,t){return new X(e,t).major},t.minor=function(e,t){return new X(e,t).minor},t.patch=function(e,t){return new X(e,t).patch},t.compare=J,t.compareLoose=function(e,t){return J(e,t,!0)},t.rcompare=function(e,t,r){return J(t,e,r)},t.sort=function(e,r){return e.sort(function(e,n){return t.compare(e,n,r)})},t.rsort=function(e,r){return e.sort(function(e,n){return t.rcompare(e,n,r)})},t.gt=Z,t.lt=$,t.eq=Y,t.neq=ee,t.gte=te,t.lte=re,t.cmp=ne,t.Comparator=ie;var ae={};function oe(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof oe)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new oe(e.raw,t);if(e instanceof ie)return new oe(e.value,t);if(!(this instanceof oe))return new oe(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function se(e){return!e||"x"===e.toLowerCase()||"*"===e}function ce(e,t,r,n,i,a,o,s,c,d,u,l,A){return((t=se(r)?"":se(n)?">="+r+".0.0":se(i)?">="+r+"."+n+".0":">="+t)+" "+(s=se(c)?"":se(d)?"<"+(+c+1)+".0.0":se(u)?"<"+c+"."+(+d+1)+".0":l?"<="+c+"."+d+"."+u+"-"+l:"<="+s)).trim()}function de(e,t,n){for(var i=0;i0){var a=e[i].semver;if(a.major===t.major&&a.minor===t.minor&&a.patch===t.patch)return!0}return!1}return!0}function ue(e,t,r){try{t=new oe(t,r)}catch(e){return!1}return t.test(e)}function le(e,t,r,n){var i,a,o,s,c;switch(e=new X(e,n),t=new oe(t,n),r){case">":i=Z,a=re,o=$,s=">",c=">=";break;case"<":i=$,a=te,o=Z,s="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ue(e,t,n))return!1;for(var d=0;d=0.0.0")),l=l||e,A=A||e,i(e.semver,l.semver,n)?l=e:o(e.semver,A.semver,n)&&(A=e)}),l.operator===s||l.operator===c)return!1;if((!A.operator||A.operator===s)&&a(e,A.semver))return!1;if(A.operator===c&&o(e,A.semver))return!1}return!0}ie.prototype.parse=function(e){var t=this.options.loose?a[H]:a[F],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new X(r[2],this.options.loose):this.semver=ae},ie.prototype.toString=function(){return this.value},ie.prototype.test=function(e){return r("Comparator.test",e,this.options.loose),this.semver===ae||("string"==typeof e&&(e=new X(e,this.options)),ne(e,this.operator,this.semver,this.options))},ie.prototype.intersects=function(e,t){if(!(e instanceof ie))throw new TypeError("a Comparator is required");var r;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return r=new oe(e.value,t),ue(this.value,r,t);if(""===e.operator)return r=new oe(this.value,t),ue(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),a=this.semver.version===e.semver.version,o=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),s=ne(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),c=ne(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||a&&o||s||c},t.Range=oe,oe.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},oe.prototype.toString=function(){return this.range},oe.prototype.parseRange=function(e){var t=this.options.loose;e=e.trim();var n=t?a[U]:a[V];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[j],"$1$2$3"),r("comparator trim",e,a[j]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[F],o=e.split(" ").map(function(e){return function(e,t){return r("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){r("caret",e,t),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[G]:a[N];return e.replace(n,function(t,n,i,a,o){var s;return r("caret",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s="0"===n?">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":">="+n+"."+i+".0 <"+(+n+1)+".0.0":o?(r("replaceCaret pr",o),"-"!==o.charAt(0)&&(o="-"+o),s="0"===n?"0"===i?">="+n+"."+i+"."+a+o+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+o+" <"+(+n+1)+".0.0"):(r("no pr"),s="0"===n?"0"===i?">="+n+"."+i+"."+a+" <"+n+"."+i+"."+(+a+1):">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+a+" <"+(+n+1)+".0.0"),r("caret return",s),s})}(e,t)}).join(" ")}(e,t),r("caret",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[x]:a[O];return e.replace(n,function(t,n,i,a,o){var s;return r("tilde",e,t,n,i,a,o),se(n)?s="":se(i)?s=">="+n+".0.0 <"+(+n+1)+".0.0":se(a)?s=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":o?(r("replaceTilde pr",o),"-"!==o.charAt(0)&&(o="-"+o),s=">="+n+"."+i+"."+a+o+" <"+n+"."+(+i+1)+".0"):s=">="+n+"."+i+"."+a+" <"+n+"."+(+i+1)+".0",r("tilde return",s),s})}(e,t)}).join(" ")}(e,t),r("tildes",e),e=function(e,t){return r("replaceXRanges",e,t),e.split(/\s+/).map(function(e){return function(e,t){e=e.trim(),t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1});var n=t.loose?a[P]:a[M];return e.replace(n,function(t,n,i,a,o,s){r("xRange",e,t,n,i,a,o,s);var c=se(i),d=c||se(a),u=d||se(o),l=u;return"="===n&&l&&(n=""),c?t=">"===n||"<"===n?"<0.0.0":"*":n&&l?(d&&(a=0),u&&(o=0),">"===n?(n=">=",d?(i=+i+1,a=0,o=0):u&&(a=+a+1,o=0)):"<="===n&&(n="<",d?i=+i+1:a=+a+1),t=n+i+"."+a+"."+o):d?t=">="+i+".0.0 <"+(+i+1)+".0.0":u&&(t=">="+i+"."+a+".0 <"+i+"."+(+a+1)+".0"),r("xRange return",t),t})}(e,t)}).join(" ")}(e,t),r("xrange",e),e=function(e,t){return r("replaceStars",e,t),e.trim().replace(a[q],"")}(e,t),r("stars",e),e}(e,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(o=o.filter(function(e){return!!e.match(i)})),o=o.map(function(e){return new ie(e,this.options)},this)},oe.prototype.intersects=function(e,t){if(!(e instanceof oe))throw new TypeError("a Range is required");return this.set.some(function(r){return r.every(function(r){return e.set.some(function(e){return e.every(function(e){return r.intersects(e,t)})})})})},t.toComparators=function(e,t){return new oe(e,t).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},oe.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new X(e,this.options));for(var t=0;t",r)},t.outside=le,t.prerelease=function(e,t){var r=z(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new oe(e,r),t=new oe(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof X)return e;if("string"!=typeof e)return null;var t=e.match(a[I]);return null==t?null:z((t[1]||"0")+"."+(t[2]||"0")+"."+(t[3]||"0"))}}),A=(l.SEMVER_SPEC_VERSION,l.re,l.src,l.parse,l.valid,l.clean,l.SemVer,l.inc,l.diff,l.compareIdentifiers,l.rcompareIdentifiers,l.major,l.minor,l.patch,l.compare,l.compareLoose,l.rcompare,l.sort,l.rsort,l.gt),h=l.lt,f=(l.eq,l.neq,l.gte),p=l.lte,m=(l.cmp,l.Comparator,l.Range,l.toComparators,l.satisfies,l.maxSatisfying,l.minSatisfying,l.validRange,l.ltr,l.gtr,l.outside,l.prerelease,l.intersects,l.coerce,u(function(e){(function(t){if(e.exports)return function(t){e.exports=t()};if("undefined"!=typeof window)return function(e){window.MobileDetect=e()};throw new Error("unknown environment")})()(function(){var e,t={mobileDetectRules:{phones:{iPhone:"\\biPhone\\b|\\biPod\\b",BlackBerry:"BlackBerry|\\bBB10\\b|rim[0-9]+|\\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\\b-[0-9]+",Pixel:"; \\bPixel\\b",HTC:"HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\\bEVO\\b|T-Mobile G1|Z520m|Android [0-9.]+; Pixel",Nexus:"Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 5X|Nexus 6",Dell:"Dell[;]? (Streak|Aero|Venue|Venue Pro|Flash|Smoke|Mini 3iX)|XCD28|XCD35|\\b001DL\\b|\\b101DL\\b|\\bGS01\\b",Motorola:"Motorola|DROIDX|DROID BIONIC|\\bDroid\\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925|XT1021|\\bMoto E\\b|XT1068|XT1092|XT1052",Samsung:"\\bSamsung\\b|SM-G950F|SM-G955F|SM-G9250|GT-19300|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750|SM-G9006V|SM-G9008V|SM-G9009D|SM-G900A|SM-G900D|SM-G900F|SM-G900H|SM-G900I|SM-G900J|SM-G900K|SM-G900L|SM-G900M|SM-G900P|SM-G900R4|SM-G900S|SM-G900T|SM-G900V|SM-G900W8|SHV-E160K|SCH-P709|SCH-P729|SM-T2558|GT-I9205|SM-G9350|SM-J120F|SM-G920F|SM-G920V|SM-G930F|SM-N910C|SM-A310F|GT-I9190|SM-J500FN|SM-G903F|SM-J330F|SM-G610F|SM-G981B|SM-G892A|SM-A530F",LG:"\\bLG\\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802|MS323|M257)|LM-G710",Sony:"SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533|SOV34|601SO|F8332",Asus:"Asus.*Galaxy|PadFone.*Mobile",Xiaomi:"^(?!.*\\bx11\\b).*xiaomi.*$|POCOPHONE F1|MI 8|Redmi Note 9S|Redmi Note 5A Prime|N2G47H|M2001J2G|M2001J2I|M1805E10A|M2004J11G|M1902F1G|M2002J9G|M2004J19G|M2003J6A1G",NokiaLumia:"Lumia [0-9]{3,4}",Micromax:"Micromax.*\\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\\b",Palm:"PalmSource|Palm",Vertu:"Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature",Pantech:"PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790",Fly:"IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250",Wiko:"KITE 4G|HIGHWAY|GETAWAY|STAIRWAY|DARKSIDE|DARKFULL|DARKNIGHT|DARKMOON|SLIDE|WAX 4G|RAINBOW|BLOOM|SUNSET|GOA(?!nna)|LENNY|BARRY|IGGY|OZZY|CINK FIVE|CINK PEAX|CINK PEAX 2|CINK SLIM|CINK SLIM 2|CINK +|CINK KING|CINK PEAX|CINK SLIM|SUBLIM",iMobile:"i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)",SimValley:"\\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\\b",Wolfgang:"AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q",Alcatel:"Alcatel",Nintendo:"Nintendo (3DS|Switch)",Amoi:"Amoi",INQ:"INQ",OnePlus:"ONEPLUS",GenericPhone:"Tapatalk|PDA;|SAGEM|\\bmmp\\b|pocket|\\bpsp\\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\\bwap\\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser"},tablets:{iPad:"iPad|iPad.*Mobile",NexusTablet:"Android.*Nexus[\\s]+(7|9|10)",GoogleTablet:"Android.*Pixel C",SamsungTablet:"SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-T337V|SM-T537V|SM-T707V|SM-T807V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T537A|SM-T707A|SM-T807A|SM-T237|SM-T807P|SM-P607T|SM-T217T|SM-T337T|SM-T807T|SM-T116NQ|SM-T116BU|SM-P550|SM-T350|SM-T550|SM-T9000|SM-P9000|SM-T705Y|SM-T805|GT-P3113|SM-T710|SM-T810|SM-T815|SM-T360|SM-T533|SM-T113|SM-T335|SM-T715|SM-T560|SM-T670|SM-T677|SM-T377|SM-T567|SM-T357T|SM-T555|SM-T561|SM-T713|SM-T719|SM-T813|SM-T819|SM-T580|SM-T355Y?|SM-T280|SM-T817A|SM-T820|SM-W700|SM-P580|SM-T587|SM-P350|SM-P555M|SM-P355M|SM-T113NU|SM-T815Y|SM-T585|SM-T285|SM-T825|SM-W708|SM-T835|SM-T830|SM-T837V|SM-T720|SM-T510|SM-T387V|SM-P610|SM-T290|SM-T515|SM-T590|SM-T595|SM-T725|SM-T817P|SM-P585N0|SM-T395|SM-T295|SM-T865|SM-P610N|SM-P615|SM-T970|SM-T380|SM-T5950|SM-T905|SM-T231|SM-T500|SM-T860",Kindle:"Kindle|Silk.*Accelerated|Android.*\\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI|KFARWI|KFFOWI|KFGIWI|KFMEWI)\\b|Android.*Silk/[0-9.]+ like Chrome/[0-9.]+ (?!Mobile)",SurfaceTablet:"Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)",HPTablet:"HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10",AsusTablet:"^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\\bK00F\\b|\\bK00C\\b|\\bK00E\\b|\\bK00L\\b|TX201LA|ME176C|ME102A|\\bM80TA\\b|ME372CL|ME560CG|ME372CG|ME302KL| K010 | K011 | K017 | K01E |ME572C|ME103K|ME170C|ME171C|\\bME70C\\b|ME581C|ME581CL|ME8510C|ME181C|P01Y|PO1MA|P01Z|\\bP027\\b|\\bP024\\b|\\bP00C\\b",BlackBerryTablet:"PlayBook|RIM Tablet",HTCtablet:"HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410",MotorolaTablet:"xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617",NookTablet:"Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2",AcerTablet:"Android.*; \\b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\\b|W3-810|\\bA3-A10\\b|\\bA3-A11\\b|\\bA3-A20\\b|\\bA3-A30|A3-A40",ToshibaTablet:"Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO",LGTablet:"\\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\\b",FujitsuTablet:"Android.*\\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\\b",PrestigioTablet:"PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD|PMP812E|PMP812E3G|PMP812F|PMP810E|PMP880TD|PMT3017|PMT3037|PMT3047|PMT3057|PMT7008|PMT5887|PMT5001|PMT5002",LenovoTablet:"Lenovo TAB|Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|YT3-850M|YT3-X90L|YT3-X90F|YT3-X90X|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)|TB-X103F|TB-X304X|TB-X304F|TB-X304L|TB-X505F|TB-X505L|TB-X505X|TB-X605F|TB-X605L|TB-8703F|TB-8703X|TB-8703N|TB-8704N|TB-8704F|TB-8704X|TB-8704V|TB-7304F|TB-7304I|TB-7304X|Tab2A7-10F|Tab2A7-20F|TB2-X30L|YT3-X50L|YT3-X50F|YT3-X50M|YT-X705F|YT-X703F|YT-X703L|YT-X705L|YT-X705X|TB2-X30F|TB2-X30L|TB2-X30M|A2107A-F|A2107A-H|TB3-730F|TB3-730M|TB3-730X|TB-7504F|TB-7504X|TB-X704F|TB-X104F|TB3-X70F|TB-X705F|TB-8504F|TB3-X70L|TB3-710F|TB-X704L",DellTablet:"Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7",YarvikTablet:"Android.*\\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\\b",MedionTablet:"Android.*\\bOYO\\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB",ArnovaTablet:"97G4|AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2",IntensoTablet:"INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004",IRUTablet:"M702pro",MegafonTablet:"MegaFon V9|\\bZTE V9\\b|Android.*\\bMT7A\\b",EbodaTablet:"E-Boda (Supreme|Impresspeed|Izzycomm|Essential)",AllViewTablet:"Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)",ArchosTablet:"\\b(101G9|80G9|A101IT)\\b|Qilive 97R|Archos5|\\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|c|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\\b",AinolTablet:"NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark",NokiaLumiaTablet:"Lumia 2520",SonyTablet:"Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551|SGP621|SGP641|SGP612|SOT31|SGP771|SGP611|SGP612|SGP712",PhilipsTablet:"\\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\\b",CubeTablet:"Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT",CobyTablet:"MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010",MIDTablet:"M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733|MID4X10",MSITablet:"MSI \\b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\\b",SMiTTablet:"Android.*(\\bMID\\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)",RockChipTablet:"Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A",FlyTablet:"IQ310|Fly Vision",bqTablet:"Android.*(bq)?.*\\b(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant|Aquaris ([E|M]10|M8))\\b|Maxwell.*Lite|Maxwell.*Plus",HuaweiTablet:"MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim|M2-A01L|BAH-L09|BAH-W09|AGS-L09|CMR-AL19",NecTablet:"\\bN-06D|\\bN-08D",PantechTablet:"Pantech.*P4100",BronchoTablet:"Broncho.*(N701|N708|N802|a710)",VersusTablet:"TOUCHPAD.*[78910]|\\bTOUCHTAB\\b",ZyncTablet:"z1000|Z99 2G|z930|z990|z909|Z919|z900",PositivoTablet:"TB07STA|TB10STA|TB07FTA|TB10FTA",NabiTablet:"Android.*\\bNabi",KoboTablet:"Kobo Touch|\\bK080\\b|\\bVox\\b Build|\\bArc\\b Build",DanewTablet:"DSlide.*\\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\\b",TexetTablet:"NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE",PlaystationTablet:"Playstation.*(Portable|Vita)",TrekstorTablet:"ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab",PyleAudioTablet:"\\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\\b",AdvanTablet:"Android.* \\b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\\b ",DanyTechTablet:"Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1",GalapadTablet:"Android [0-9.]+; [a-z-]+; \\bG1\\b",MicromaxTablet:"Funbook|Micromax.*\\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\\b",KarbonnTablet:"Android.*\\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\\b",AllFineTablet:"Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide",PROSCANTablet:"\\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\\b",YONESTablet:"BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026",ChangJiaTablet:"TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503",GUTablet:"TX-A1301|TX-M9002|Q702|kf026",PointOfViewTablet:"TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10",OvermaxTablet:"OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)|Qualcore 1027",HCLTablet:"HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync",DPSTablet:"DPS Dream 9|DPS Dual 7",VistureTablet:"V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10",CrestaTablet:"CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989",MediatekTablet:"\\bMT8125|MT8389|MT8135|MT8377\\b",ConcordeTablet:"Concorde([ ]+)?Tab|ConCorde ReadMan",GoCleverTablet:"GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042",ModecomTablet:"FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003",VoninoTablet:"\\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\\bQ8\\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\\b",ECSTablet:"V07OT2|TM105A|S10OT1|TR10CS1",StorexTablet:"eZee[_']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab",VodafoneTablet:"SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7|VF-1497|VFD 1400",EssentielBTablet:"Smart[ ']?TAB[ ]+?[0-9]+|Family[ ']?TAB2",RossMoorTablet:"RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711",iMobileTablet:"i-mobile i-note",TolinoTablet:"tolino tab [0-9.]+|tolino shine",AudioSonicTablet:"\\bC-22Q|T7-QC|T-17B|T-17P\\b",AMPETablet:"Android.* A78 ",SkkTablet:"Android.* (SKYPAD|PHOENIX|CYCLOPS)",TecnoTablet:"TECNO P9|TECNO DP8D",JXDTablet:"Android.* \\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\\b",iJoyTablet:"Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)",FX2Tablet:"FX2 PAD7|FX2 PAD10",XoroTablet:"KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151",ViewsonicTablet:"ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a",VerizonTablet:"QTAQZ3|QTAIR7|QTAQTZ3|QTASUN1|QTASUN2|QTAXIA1",OdysTablet:"LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\\bXELIO\\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10",CaptivaTablet:"CAPTIVA PAD",IconbitTablet:"NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S",TeclastTablet:"T98 4G|\\bP80\\b|\\bX90HD\\b|X98 Air|X98 Air 3G|\\bX89\\b|P80 3G|\\bX80h\\b|P98 Air|\\bX89HD\\b|P98 3G|\\bP90HD\\b|P89 3G|X98 3G|\\bP70h\\b|P79HD 3G|G18d 3G|\\bP79HD\\b|\\bP89s\\b|\\bA88\\b|\\bP10HD\\b|\\bP19HD\\b|G18 3G|\\bP78HD\\b|\\bA78\\b|\\bP75\\b|G17s 3G|G17h 3G|\\bP85t\\b|\\bP90\\b|\\bP11\\b|\\bP98t\\b|\\bP98HD\\b|\\bG18d\\b|\\bP85s\\b|\\bP11HD\\b|\\bP88s\\b|\\bA80HD\\b|\\bA80se\\b|\\bA10h\\b|\\bP89\\b|\\bP78s\\b|\\bG18\\b|\\bP85\\b|\\bA70h\\b|\\bA70\\b|\\bG17\\b|\\bP18\\b|\\bA80s\\b|\\bA11s\\b|\\bP88HD\\b|\\bA80h\\b|\\bP76s\\b|\\bP76h\\b|\\bP98\\b|\\bA10HD\\b|\\bP78\\b|\\bP88\\b|\\bA11\\b|\\bA10t\\b|\\bP76a\\b|\\bP76t\\b|\\bP76e\\b|\\bP85HD\\b|\\bP85a\\b|\\bP86\\b|\\bP75HD\\b|\\bP76v\\b|\\bA12\\b|\\bP75a\\b|\\bA15\\b|\\bP76Ti\\b|\\bP81HD\\b|\\bA10\\b|\\bT760VE\\b|\\bT720HD\\b|\\bP76\\b|\\bP73\\b|\\bP71\\b|\\bP72\\b|\\bT720SE\\b|\\bC520Ti\\b|\\bT760\\b|\\bT720VE\\b|T720-3GE|T720-WiFi",OndaTablet:"\\b(V975i|Vi30|VX530|V701|Vi60|V701s|Vi50|V801s|V719|Vx610w|VX610W|V819i|Vi10|VX580W|Vi10|V711s|V813|V811|V820w|V820|Vi20|V711|VI30W|V712|V891w|V972|V819w|V820w|Vi60|V820w|V711|V813s|V801|V819|V975s|V801|V819|V819|V818|V811|V712|V975m|V101w|V961w|V812|V818|V971|V971s|V919|V989|V116w|V102w|V973|Vi40)\\b[\\s]+|V10 \\b4G\\b",JaytechTablet:"TPC-PA762",BlaupunktTablet:"Endeavour 800NG|Endeavour 1010",DigmaTablet:"\\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\\b",EvolioTablet:"ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\\bEvotab\\b|\\bNeura\\b",LavaTablet:"QPAD E704|\\bIvoryS\\b|E-TAB IVORY|\\bE-TAB\\b",AocTablet:"MW0811|MW0812|MW0922|MTK8382|MW1031|MW0831|MW0821|MW0931|MW0712",MpmanTablet:"MP11 OCTA|MP10 OCTA|MPQC1114|MPQC1004|MPQC994|MPQC974|MPQC973|MPQC804|MPQC784|MPQC780|\\bMPG7\\b|MPDCG75|MPDCG71|MPDC1006|MP101DC|MPDC9000|MPDC905|MPDC706HD|MPDC706|MPDC705|MPDC110|MPDC100|MPDC99|MPDC97|MPDC88|MPDC8|MPDC77|MP709|MID701|MID711|MID170|MPDC703|MPQC1010",CelkonTablet:"CT695|CT888|CT[\\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\\bCT-1\\b",WolderTablet:"miTab \\b(DIAMOND|SPACE|BROOKLYN|NEO|FLY|MANHATTAN|FUNK|EVOLUTION|SKY|GOCAR|IRON|GENIUS|POP|MINT|EPSILON|BROADWAY|JUMP|HOP|LEGEND|NEW AGE|LINE|ADVANCE|FEEL|FOLLOW|LIKE|LINK|LIVE|THINK|FREEDOM|CHICAGO|CLEVELAND|BALTIMORE-GH|IOWA|BOSTON|SEATTLE|PHOENIX|DALLAS|IN 101|MasterChef)\\b",MediacomTablet:"M-MPI10C3G|M-SP10EG|M-SP10EGP|M-SP10HXAH|M-SP7HXAH|M-SP10HXBH|M-SP8HXAH|M-SP8MXA",MiTablet:"\\bMI PAD\\b|\\bHM NOTE 1W\\b",NibiruTablet:"Nibiru M1|Nibiru Jupiter One",NexoTablet:"NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI",LeaderTablet:"TBLT10Q|TBLT10I|TBL-10WDKB|TBL-10WDKBO2013|TBL-W230V2|TBL-W450|TBL-W500|SV572|TBLT7I|TBA-AC7-8G|TBLT79|TBL-8W16|TBL-10W32|TBL-10WKB|TBL-W100",UbislateTablet:"UbiSlate[\\s]?7C",PocketBookTablet:"Pocketbook",KocasoTablet:"\\b(TB-1207)\\b",HisenseTablet:"\\b(F5281|E2371)\\b",Hudl:"Hudl HT7S3|Hudl 2",TelstraTablet:"T-Hub2",GenericTablet:"Android.*\\b97D\\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\\bA7EB\\b|CatNova8|A1_07|CT704|CT1002|\\bM721\\b|rk30sdk|\\bEVOTAB\\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\\bM6pro\\b|CT1020W|arc 10HD|\\bTP750\\b|\\bQTAQZ3\\b|WVT101|TM1088|KT107"},oss:{AndroidOS:"Android",BlackBerryOS:"blackberry|\\bBB10\\b|rim tablet os",PalmOS:"PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino",SymbianOS:"Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\\bS60\\b",WindowsMobileOS:"Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Windows Mobile|Windows Phone [0-9.]+|WCE;",WindowsPhoneOS:"Windows Phone 10.0|Windows Phone 8.1|Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;",iOS:"\\biPhone.*Mobile|\\biPod|\\biPad|AppleCoreMedia",iPadOS:"CPU OS 13",SailfishOS:"Sailfish",MeeGoOS:"MeeGo",MaemoOS:"Maemo",JavaOS:"J2ME/|\\bMIDP\\b|\\bCLDC\\b",webOS:"webOS|hpwOS",badaOS:"\\bBada\\b",BREWOS:"BREW"},uas:{Chrome:"\\bCrMo\\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?",Dolfin:"\\bDolfin\\b",Opera:"Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+$|Coast/[0-9.]+",Skyfire:"Skyfire",Edge:"\\bEdgiOS\\b|Mobile Safari/[.0-9]* Edge",IE:"IEMobile|MSIEMobile",Firefox:"fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS",Bolt:"bolt",TeaShark:"teashark",Blazer:"Blazer",Safari:"Version((?!\\bEdgiOS\\b).)*Mobile.*Safari|Safari.*Mobile|MobileSafari",WeChat:"\\bMicroMessenger\\b",UCBrowser:"UC.*Browser|UCWEB",baiduboxapp:"baiduboxapp",baidubrowser:"baidubrowser",DiigoBrowser:"DiigoBrowser",Mercury:"\\bMercury\\b",ObigoBrowser:"Obigo",NetFront:"NF-Browser",GenericBrowser:"NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger",PaleMoon:"Android.*PaleMoon|Mobile.*PaleMoon"},props:{Mobile:"Mobile/[VER]",Build:"Build/[VER]",Version:"Version/[VER]",VendorID:"VendorID/[VER]",iPad:"iPad.*CPU[a-z ]+[VER]",iPhone:"iPhone.*CPU[a-z ]+[VER]",iPod:"iPod.*CPU[a-z ]+[VER]",Kindle:"Kindle/[VER]",Chrome:["Chrome/[VER]","CriOS/[VER]","CrMo/[VER]"],Coast:["Coast/[VER]"],Dolfin:"Dolfin/[VER]",Firefox:["Firefox/[VER]","FxiOS/[VER]"],Fennec:"Fennec/[VER]",Edge:"Edge/[VER]",IE:["IEMobile/[VER];","IEMobile [VER]","MSIE [VER];","Trident/[0-9.]+;.*rv:[VER]"],NetFront:"NetFront/[VER]",NokiaBrowser:"NokiaBrowser/[VER]",Opera:[" OPR/[VER]","Opera Mini/[VER]","Version/[VER]"],"Opera Mini":"Opera Mini/[VER]","Opera Mobi":"Version/[VER]",UCBrowser:["UCWEB[VER]","UC.*Browser/[VER]"],MQQBrowser:"MQQBrowser/[VER]",MicroMessenger:"MicroMessenger/[VER]",baiduboxapp:"baiduboxapp/[VER]",baidubrowser:"baidubrowser/[VER]",SamsungBrowser:"SamsungBrowser/[VER]",Iron:"Iron/[VER]",Safari:["Version/[VER]","Safari/[VER]"],Skyfire:"Skyfire/[VER]",Tizen:"Tizen/[VER]",Webkit:"webkit[ /][VER]",PaleMoon:"PaleMoon/[VER]",SailfishBrowser:"SailfishBrowser/[VER]",Gecko:"Gecko/[VER]",Trident:"Trident/[VER]",Presto:"Presto/[VER]",Goanna:"Goanna/[VER]",iOS:" \\bi?OS\\b [VER][ ;]{1}",Android:"Android [VER]",Sailfish:"Sailfish [VER]",BlackBerry:["BlackBerry[\\w]+/[VER]","BlackBerry.*Version/[VER]","Version/[VER]"],BREW:"BREW [VER]",Java:"Java/[VER]","Windows Phone OS":["Windows Phone OS [VER]","Windows Phone [VER]"],"Windows Phone":"Windows Phone [VER]","Windows CE":"Windows CE/[VER]","Windows NT":"Windows NT [VER]",Symbian:["SymbianOS/[VER]","Symbian/[VER]"],webOS:["webOS/[VER]","hpwOS/[VER];"]},utils:{Bot:"Googlebot|facebookexternalhit|Google-AMPHTML|s~amp-validator|AdsBot-Google|Google Keyword Suggestion|Facebot|YandexBot|YandexMobileBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|Exabot|MJ12bot|YandexImages|TurnitinBot|Pingdom|contentkingapp|AspiegelBot",MobileBot:"Googlebot-Mobile|AdsBot-Google-Mobile|YahooSeeker/M1A1-R2D2",DesktopMode:"WPDesktop",TV:"SonyDTV|HbbTV",WebKit:"(webkit)[ /]([\\w.]+)",Console:"\\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\\b",Watch:"SM-V700"}},detectMobileBrowsers:{fullPattern:/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i,shortPattern:/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i,tabletPattern:/android|ipad|playbook|silk/i}},r=Object.prototype.hasOwnProperty;function n(e,t){return null!=e&&null!=t&&e.toLowerCase()===t.toLowerCase()}function i(e,t){var r,n,i=e.length;if(!i||!t)return!1;for(r=t.toLowerCase(),n=0;n=0&&(o=o.substring(0,d)+"([\\w._\\+]+)"+o.substring(d+5)),i[s]=new RegExp(o,"i");u.props[n]=i}a(u.oss),a(u.phones),a(u.tablets),a(u.uas),a(u.utils),u.oss0={WindowsPhoneOS:u.oss.WindowsPhoneOS,WindowsMobileOS:u.oss.WindowsMobileOS}}(),t.findMatch=function(e,t){for(var n in e)if(r.call(e,n)&&e[n].test(t))return n;return null},t.findMatches=function(e,t){var n=[];for(var i in e)r.call(e,i)&&e[i].test(t)&&n.push(i);return n},t.getVersionStr=function(e,n){var i,a,o,s,c=t.mobileDetectRules.props;if(r.call(c,e))for(o=(i=c[e]).length,a=0;a1&&(e=t[0]+".",t.shift(),e+=t.join("")),Number(e)},t.isMobileFallback=function(e){return t.detectMobileBrowsers.fullPattern.test(e)||t.detectMobileBrowsers.shortPattern.test(e.substr(0,4))},t.isTabletFallback=function(e){return t.detectMobileBrowsers.tabletPattern.test(e)},t.prepareDetectionCache=function(e,r,n){if(void 0===e.mobile){var i,a,s;if(a=t.findMatch(t.mobileDetectRules.tablets,r))return e.mobile=e.tablet=a,void(e.phone=null);if(i=t.findMatch(t.mobileDetectRules.phones,r))return e.mobile=e.phone=i,void(e.tablet=null);t.isMobileFallback(r)?void 0===(s=o.isPhoneSized(n))?(e.mobile=t.FALLBACK_MOBILE,e.tablet=e.phone=null):s?(e.mobile=e.phone=t.FALLBACK_PHONE,e.tablet=null):(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):t.isTabletFallback(r)?(e.mobile=e.tablet=t.FALLBACK_TABLET,e.phone=null):e.mobile=e.tablet=e.phone=null}},t.mobileGrade=function(e){var t=null!==e.mobile();return e.os("iOS")&&e.version("iPad")>=4.3||e.os("iOS")&&e.version("iPhone")>=3.1||e.os("iOS")&&e.version("iPod")>=3.1||e.version("Android")>2.1&&e.is("Webkit")||e.version("Windows Phone OS")>=7||e.is("BlackBerry")&&e.version("BlackBerry")>=6||e.match("Playbook.*Tablet")||e.version("webOS")>=1.4&&e.match("Palm|Pre|Pixi")||e.match("hp.*TouchPad")||e.is("Firefox")&&e.version("Firefox")>=12||e.is("Chrome")&&e.is("AndroidOS")&&e.version("Android")>=4||e.is("Skyfire")&&e.version("Skyfire")>=4.1&&e.is("AndroidOS")&&e.version("Android")>=2.3||e.is("Opera")&&e.version("Opera Mobi")>11&&e.is("AndroidOS")||e.is("MeeGoOS")||e.is("Tizen")||e.is("Dolfin")&&e.version("Bada")>=2||(e.is("UC Browser")||e.is("Dolfin"))&&e.version("Android")>=2.3||e.match("Kindle Fire")||e.is("Kindle")&&e.version("Kindle")>=3||e.is("AndroidOS")&&e.is("NookTablet")||e.version("Chrome")>=11&&!t||e.version("Safari")>=5&&!t||e.version("Firefox")>=4&&!t||e.version("MSIE")>=7&&!t||e.version("Opera")>=10&&!t?"A":e.os("iOS")&&e.version("iPad")<4.3||e.os("iOS")&&e.version("iPhone")<3.1||e.os("iOS")&&e.version("iPod")<3.1||e.is("Blackberry")&&e.version("BlackBerry")>=5&&e.version("BlackBerry")<6||e.version("Opera Mini")>=5&&e.version("Opera Mini")<=6.5&&(e.version("Android")>=2.3||e.is("iOS"))||e.match("NokiaN8|NokiaC7|N97.*Series60|Symbian/3")||e.version("Opera Mobi")>=11&&e.is("SymbianOS")?"B":(e.version("BlackBerry")<5||e.match("MSIEMobile|Windows CE.*Mobile")||e.version("Windows Mobile"),"C")},t.detectOS=function(e){return t.findMatch(t.mobileDetectRules.oss0,e)||t.findMatch(t.mobileDetectRules.oss,e)},t.getDeviceSmallerSide=function(){return window.screen.width-1,v=!!window.chrome,T=navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPhone/i),b=function(){const e=s();if(!navigator||!navigator.appVersion||!e)return e;const r=/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/.exec(window.navigator.appVersion);return r&&r[1]?t({},e,{chromeVersion:r[1]}):e}()||{},S=!!new m(navigator.userAgent).mobile(),y=navigator.userAgent.toLowerCase().indexOf("electron")>-1;function k(){try{return!!window&&("RTCPeerConnection"in window&&("WebSocket"in window&&(!!navigator&&(!!navigator.mediaDevices&&!!navigator.mediaDevices.getUserMedia))))}catch(e){return!1}}function _(){const e=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia,t=navigator&&navigator.mediaDevices&&navigator.mediaDevices.getSupportedConstraints&&navigator.mediaDevices.getSupportedConstraints().displaySurface;return g?!!e&&!!t:!!e}function w(){return"createMediaStreamDestination"in(window.AudioContext||window.webkitAudioContext||window.Object).prototype}const E=function(){if(!b)return{support:k(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0};switch(b.name){case"chrome":return{support:k(),mediaStreamDest:f(b.version,"55.0.0"),replaceTrack:f(b.version,"65.0.0"),screenSharing:f(b.version,"55.0.0"),connectionState:f(b.version,"72.0.0"),stats:f(b.version,"67.0.0"),ondevicechange:f(b.version,"57.0.0"),minMaxWithIdeal:f(b.version,"56.0.0"),supportTransceivers:f(b.version,"69.0.0"),unifiedPlan:f(b.version,"72.0.0"),supportRestartICE:!0,getReceivers:f(b.version,"59.0.0"),needH264FmtpLine:p(b.version,"51.0.0"),audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!0,setPlaybackDevice:!0};case"ios":case"safari":return{support:k(),replaceTrack:f(b.version,"11.0.0"),stats:!1,ondevicechange:!1,connectionState:!0,mediaStreamDest:f(b.version,"12.0.0"),screenSharing:f(b.version,"13.0.0"),unifiedPlan:f(b.version,"12.1.0"),supportTransceivers:!0,minMaxWithIdeal:!1,supportRestartICE:!0,getReceivers:!0,audioContextOptions:!0,getDisplayMedia:_(),disconnectAudioNode:!1};case"firefox":return{support:k(),replaceTrack:!0,stats:!0,ondevicechange:f(b.version,"52.0.0"),connectionState:!0,mediaStreamDest:!0,screenSharing:!0,minMaxWithIdeal:!0,unifiedPlan:!0,supportTransceivers:f(b.version,"59.0.0"),supportRestartICE:!1,getReceivers:!0,audioContextOptions:f(b.version,"55.0.0"),getDisplayMedia:_(),disconnectAudioNode:!0};case"crios":case"ios-webview":return{support:k(),getDisplayMedia:_(),mediaStreamDest:w(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),mediaStreamDest:w(),supportRestartICE:!0,getDisplayMedia:_(),disconnectAudioNode:!0}}}();"chrome"===b.name&&function(){const e=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),(e={})[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(e){return new Promise((t,r)=>{navigator.getUserMedia(e,t,r)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:t,enumerateDevices:()=>new Promise(e=>{const t={audio:"audioinput",video:"videoinput"};return window.MediaStreamTrack.getSources(r=>{e(r.map(e=>({label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""})))})})}),navigator.mediaDevices.getSupportedConstraints||(navigator.mediaDevices.getSupportedConstraints=(()=>({deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}))),navigator.mediaDevices.getUserMedia){const t=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(r){return function(t,r){if(A(b.version,"61.0.0"))return r(t);if((t=JSON.parse(JSON.stringify(t)))&&"object"==typeof t.audio){const r=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};r((t=JSON.parse(JSON.stringify(t))).audio,"autoGainControl","googAutoGainControl"),r(t.audio,"noiseSuppression","googNoiseSuppression"),t.audio=e(t.audio)}if(t&&"object"==typeof t.video){let n=t.video.facingMode;n=n&&("object"==typeof n?n:{ideal:n});const i=h(b.version,"66.0.0");if(n&&("user"===n.exact||"environment"===n.exact||"user"===n.ideal||"environment"===n.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode||i)){delete t.video.facingMode;let i=void 0;if("environment"===n.exact||"environment"===n.ideal?i=["back","rear"]:"user"!==n.exact&&"user"!==n.ideal||(i=["front"]),i)return navigator.mediaDevices.enumerateDevices().then(a=>{let o=(a=a.filter(e=>"videoinput"===e.kind)).find(e=>i.some(t=>e.label.toLowerCase().includes(t)));return!o&&a.length&&i.includes("back")&&(o=a[a.length-1]),o&&(t.video.deviceId=n.exact?{exact:o.deviceId}:{ideal:o.deviceId}),t.video=e(t.video),r(t)})}t.video=e(t.video)}return r(t)}(r,e=>t(e).then(t=>{if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return t},e=>Promise.reject(e)))}}else navigator.mediaDevices.getUserMedia=function(e){return t(e)}}(),"firefox"===b.name&&function(){const e=function(e){return new Promise((t,r)=>{!function(e,t,r){e=JSON.parse(JSON.stringify(e)),navigator.mozGetUserMedia(e,t,e=>{r(e)})}(e,t,r)})};navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:e,addEventListener(){},removeEventListener(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise(e=>{e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})}}();var C=u(function(e){!function(t){function r(){}var n=r.prototype,i=t.EventEmitter;function a(e,t){for(var r=e.length;r--;)if(e[r].listener===t)return r;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}n.getListeners=function(e){var t,r,n=this._getEvents();if(e instanceof RegExp)for(r in t={},n)n.hasOwnProperty(r)&&e.test(r)&&(t[r]=n[r]);else t=n[e]||(n[e]=[]);return t},n.flattenListeners=function(e){var t,r=[];for(t=0;td))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ee:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Pe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},we.prototype.clear=function(){this.__data__={hash:new ke,map:new(ue||_e),string:new ke}},we.prototype.delete=function(e){return Ge(this,e).delete(e)},we.prototype.get=function(e){return Ge(this,e).get(e)},we.prototype.has=function(e){return Ge(this,e).has(e)},we.prototype.set=function(e,t){return Ge(this,e).set(e,t),this},Ee.prototype.add=Ee.prototype.push=function(e){return this.__data__.set(e,i),this},Ee.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.clear=function(){this.__data__=new _e},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var n=this.__data__;if(n instanceof _e){var i=n.__data__;if(!ue||i.length-1&&e%1==0&&ei?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var a=Array(i);++n-1&&e%1==0&&e<=d}function nt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function it(e){return!!e&&"object"==typeof e}function at(e){return"symbol"==typeof e||it(e)&&re.call(e)==k}var ot=j?function(e){return function(t){return e(t)}}(j):function(e){return it(e)&&rt(e.length)&&!!O[re.call(e)]};function st(e){return et(e)?Me(e):Be(e)}function ct(e){return e}e.exports=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],a=e.length;for(t=xe(t);++n!!e&&!!e.audio&&e.audio.enabled,I=e=>!!e&&!!e.video&&e.video.enabled,R=e=>!!e&&!!e.screen&&e.screen.enabled;var D,O,x,B,L;function N(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(D||(D={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(O||(O={})),function(e){e[e.INVALID=-1]="INVALID",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.FAIR=3]="FAIR",e[e.POOR=4]="POOR"}(x||(x={})),function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connect=2]="Connect"}(B||(B={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(L||(L={}));const G={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var H;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.STOP="stop",e.END="end"}(H||(H={}));const F={Init:1,UnInit:2,JoinRoom:3,MCSAuth:4,SignalAuth:5,LeaveRoom:6,PublisherPC:7,PublishTracks:8,UnPublishTracks:9,SubscriberPC:10,SubscribeTracks:11,UnSubscribeTracks:13,MuteTracks:14,ICEConnectionState:15,CallbackStatistics:16,KickoutUser:17,RoomStateChanged:18,AudioDeviceInOut:19,VideoDeviceInOut:20,SDKError:21,ApplicationState:22,CreateMergeJob:24,UpdateMergeTracks:25,StopMerge:26,AuthorizationStatus:27,DeviceChanged:28,DefaultSetting:29,MediaStatistics:30,AbnormalDisconnect:31,CreateForwardJob:36,StopForwardJob:37,WebsocketConnect:40,NetworkChange:46,SystemRequirementsTest:47,AutoplayFail:49,TrackEnded:50,WebSDKException:51,VideoPlayQuality:53,AudioPlayQuality:54,JoinRoomResult:55,SetClientRole:56,StartMediaRelay:57,UpdateMediaRelay:58,StopMediaRelay:59,MCURelayAuth:60};var j=u(function(e){var t,r;t=c,r=function(){var e=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},t=function(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]},r=function(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])},n=function(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=t(e,[4283543511,3981806797]),e=i(e,[0,e[0]>>>1]),e=t(e,[3301882366,444984403]),e=i(e,[0,e[0]>>>1])},o=function(o,s){s=s||0;for(var c=(o=o||"").length%16,d=o.length-c,u=[0,s],l=[0,s],A=[0,0],h=[0,0],f=[2277735313,289559509],p=[1291169091,658871167],m=0;m>>0).toString(16)).slice(-8)+("00000000"+(u[1]>>>0).toString(16)).slice(-8)+("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)},s={preprocessor:null,audio:{timeout:1e3,excludeIOS11:!0},fonts:{swfContainerId:"fingerprintjs2",swfPath:"flash/compiled/FontList.swf",userDefinedFonts:[],extendedJsFonts:!1},screen:{detectScreenOrientation:!0},plugins:{sortPluginsFor:[/palemoon/i],excludeIE:!1},extraComponents:[],excludes:{enumerateDevices:!0,pixelRatio:!0,doNotTrack:!0,fontsFlash:!0},NOT_AVAILABLE:"not available",ERROR:"error",EXCLUDED:"excluded"},c=function(e,t){if(Array.prototype.forEach&&e.forEach===Array.prototype.forEach)e.forEach(t);else if(e.length===+e.length)for(var r=0,n=e.length;rt.name?1:e.name=0?"Windows Phone":t.indexOf("win")>=0?"Windows":t.indexOf("android")>=0?"Android":t.indexOf("linux")>=0?"Linux":t.indexOf("iphone")>=0||t.indexOf("ipad")>=0?"iOS":t.indexOf("mac")>=0?"Mac":"Other",("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)&&"Windows Phone"!==e&&"Android"!==e&&"iOS"!==e&&"Other"!==e)return!0;if(void 0!==r){if((r=r.toLowerCase()).indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e)return!0;if(r.indexOf("linux")>=0&&"Linux"!==e&&"Android"!==e)return!0;if(r.indexOf("mac")>=0&&"Mac"!==e&&"iOS"!==e)return!0;if((-1===r.indexOf("win")&&-1===r.indexOf("linux")&&-1===r.indexOf("mac"))!=("Other"===e))return!0}return n.indexOf("win")>=0&&"Windows"!==e&&"Windows Phone"!==e||((n.indexOf("linux")>=0||n.indexOf("android")>=0||n.indexOf("pike")>=0)&&"Linux"!==e&&"Android"!==e||((n.indexOf("mac")>=0||n.indexOf("ipad")>=0||n.indexOf("ipod")>=0||n.indexOf("iphone")>=0)&&"Mac"!==e&&"iOS"!==e||((-1===n.indexOf("win")&&-1===n.indexOf("linux")&&-1===n.indexOf("mac"))!=("Other"===e)||void 0===navigator.plugins&&"Windows"!==e&&"Windows Phone"!==e)))},R=function(){var e,t=navigator.userAgent.toLowerCase(),r=navigator.productSub;if(("Chrome"===(e=t.indexOf("firefox")>=0?"Firefox":t.indexOf("opera")>=0||t.indexOf("opr")>=0?"Opera":t.indexOf("chrome")>=0?"Chrome":t.indexOf("safari")>=0?"Safari":t.indexOf("trident")>=0?"Internet Explorer":"Other")||"Safari"===e||"Opera"===e)&&"20030107"!==r)return!0;var n,i=eval.toString().length;if(37===i&&"Safari"!==e&&"Firefox"!==e&&"Other"!==e)return!0;if(39===i&&"Internet Explorer"!==e&&"Other"!==e)return!0;if(33===i&&"Chrome"!==e&&"Opera"!==e&&"Other"!==e)return!0;try{throw"a"}catch(e){try{e.toSource(),n=!0}catch(e){n=!1}}return n&&"Firefox"!==e&&"Other"!==e},D=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},O=function(){if(!D())return!1;var e=G();return!!window.WebGLRenderingContext&&!!e},x=function(){return"Microsoft Internet Explorer"===navigator.appName||!("Netscape"!==navigator.appName||!/Trident/.test(navigator.userAgent))},B=function(){return void 0!==window.swfobject},L=function(){return window.swfobject.hasFlashPlayerVersion("9.0.0")},N=function(e,t){window.___fp_swf_loaded=function(t){e(t)};var r=t.fonts.swfContainerId;!function(e){var t=document.createElement("div");t.setAttribute("id",e.fonts.swfContainerId),document.body.appendChild(t)}();var n={onReady:"___fp_swf_loaded"};window.swfobject.embedSWF(t.fonts.swfPath,r,"1","1","9.0.0",!1,n,{allowScriptAccess:"always",menu:"false"},{})},G=function(){var e=document.createElement("canvas"),t=null;try{t=e.getContext("webgl")||e.getContext("experimental-webgl")}catch(e){}return t||(t=null),t},H=[{key:"userAgent",getData:function(e){e(navigator.userAgent)}},{key:"language",getData:function(e,t){e(navigator.language||navigator.userLanguage||navigator.browserLanguage||navigator.systemLanguage||t.NOT_AVAILABLE)}},{key:"colorDepth",getData:function(e,t){e(window.screen.colorDepth||t.NOT_AVAILABLE)}},{key:"deviceMemory",getData:function(e,t){e(navigator.deviceMemory||t.NOT_AVAILABLE)}},{key:"pixelRatio",getData:function(e,t){e(window.devicePixelRatio||t.NOT_AVAILABLE)}},{key:"hardwareConcurrency",getData:function(e,t){e(T(t))}},{key:"screenResolution",getData:function(e,t){e(l(t))}},{key:"availableScreenResolution",getData:function(e,t){e(A(t))}},{key:"timezoneOffset",getData:function(e){e((new Date).getTimezoneOffset())}},{key:"timezone",getData:function(e,t){window.Intl&&window.Intl.DateTimeFormat?e((new window.Intl.DateTimeFormat).resolvedOptions().timeZone):e(t.NOT_AVAILABLE)}},{key:"sessionStorage",getData:function(e,t){e(m(t))}},{key:"localStorage",getData:function(e,t){e(g(t))}},{key:"indexedDb",getData:function(e,t){e(v(t))}},{key:"addBehavior",getData:function(e){e(!(!document.body||!document.body.addBehavior))}},{key:"openDatabase",getData:function(e){e(!!window.openDatabase)}},{key:"cpuClass",getData:function(e,t){e(b(t))}},{key:"platform",getData:function(e,t){e(S(t))}},{key:"doNotTrack",getData:function(e,t){e(y(t))}},{key:"plugins",getData:function(e,t){x()?t.plugins.excludeIE?e(t.EXCLUDED):e(f(t)):e(h(t))}},{key:"canvas",getData:function(e,t){D()?e(_(t)):e(t.NOT_AVAILABLE)}},{key:"webgl",getData:function(e,t){O()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){O()?e(E()):e()}},{key:"adBlock",getData:function(e){e(C())}},{key:"hasLiedLanguages",getData:function(e){e(M())}},{key:"hasLiedResolution",getData:function(e){e(P())}},{key:"hasLiedOs",getData:function(e){e(I())}},{key:"hasLiedBrowser",getData:function(e){e(R())}},{key:"touchSupport",getData:function(e){e(k())}},{key:"fonts",getData:function(e,t){var r=["monospace","sans-serif","serif"],n=["Andale Mono","Arial","Arial Black","Arial Hebrew","Arial MT","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Bitstream Vera Sans Mono","Book Antiqua","Bookman Old Style","Calibri","Cambria","Cambria Math","Century","Century Gothic","Century Schoolbook","Comic Sans","Comic Sans MS","Consolas","Courier","Courier New","Geneva","Georgia","Helvetica","Helvetica Neue","Impact","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","LUCIDA GRANDE","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Microsoft Sans Serif","Monaco","Monotype Corsiva","MS Gothic","MS Outlook","MS PGothic","MS Reference Sans Serif","MS Sans Serif","MS Serif","MYRIAD","MYRIAD PRO","Palatino","Palatino Linotype","Segoe Print","Segoe Script","Segoe UI","Segoe UI Light","Segoe UI Semibold","Segoe UI Symbol","Tahoma","Times","Times New Roman","Times New Roman PS","Trebuchet MS","Verdana","Wingdings","Wingdings 2","Wingdings 3"];t.fonts.extendedJsFonts&&(n=n.concat(["Abadi MT Condensed Light","Academy Engraved LET","ADOBE CASLON PRO","Adobe Garamond","ADOBE GARAMOND PRO","Agency FB","Aharoni","Albertus Extra Bold","Albertus Medium","Algerian","Amazone BT","American Typewriter","American Typewriter Condensed","AmerType Md BT","Andalus","Angsana New","AngsanaUPC","Antique Olive","Aparajita","Apple Chancery","Apple Color Emoji","Apple SD Gothic Neo","Arabic Typesetting","ARCHER","ARNO PRO","Arrus BT","Aurora Cn BT","AvantGarde Bk BT","AvantGarde Md BT","AVENIR","Ayuthaya","Bandy","Bangla Sangam MN","Bank Gothic","BankGothic Md BT","Baskerville","Baskerville Old Face","Batang","BatangChe","Bauer Bodoni","Bauhaus 93","Bazooka","Bell MT","Bembo","Benguiat Bk BT","Berlin Sans FB","Berlin Sans FB Demi","Bernard MT Condensed","BernhardFashion BT","BernhardMod BT","Big Caslon","BinnerD","Blackadder ITC","BlairMdITC TT","Bodoni 72","Bodoni 72 Oldstyle","Bodoni 72 Smallcaps","Bodoni MT","Bodoni MT Black","Bodoni MT Condensed","Bodoni MT Poster Compressed","Bookshelf Symbol 7","Boulder","Bradley Hand","Bradley Hand ITC","Bremen Bd BT","Britannic Bold","Broadway","Browallia New","BrowalliaUPC","Brush Script MT","Californian FB","Calisto MT","Calligrapher","Candara","CaslonOpnface BT","Castellar","Centaur","Cezanne","CG Omega","CG Times","Chalkboard","Chalkboard SE","Chalkduster","Charlesworth","Charter Bd BT","Charter BT","Chaucer","ChelthmITC Bk BT","Chiller","Clarendon","Clarendon Condensed","CloisterBlack BT","Cochin","Colonna MT","Constantia","Cooper Black","Copperplate","Copperplate Gothic","Copperplate Gothic Bold","Copperplate Gothic Light","CopperplGoth Bd BT","Corbel","Cordia New","CordiaUPC","Cornerstone","Coronet","Cuckoo","Curlz MT","DaunPenh","Dauphin","David","DB LCD Temp","DELICIOUS","Denmark","DFKai-SB","Didot","DilleniaUPC","DIN","DokChampa","Dotum","DotumChe","Ebrima","Edwardian Script ITC","Elephant","English 111 Vivace BT","Engravers MT","EngraversGothic BT","Eras Bold ITC","Eras Demi ITC","Eras Light ITC","Eras Medium ITC","EucrosiaUPC","Euphemia","Euphemia UCAS","EUROSTILE","Exotc350 Bd BT","FangSong","Felix Titling","Fixedsys","FONTIN","Footlight MT Light","Forte","FrankRuehl","Fransiscan","Freefrm721 Blk BT","FreesiaUPC","Freestyle Script","French Script MT","FrnkGothITC Bk BT","Fruitger","FRUTIGER","Futura","Futura Bk BT","Futura Lt BT","Futura Md BT","Futura ZBlk BT","FuturaBlack BT","Gabriola","Galliard BT","Gautami","Geeza Pro","Geometr231 BT","Geometr231 Hv BT","Geometr231 Lt BT","GeoSlab 703 Lt BT","GeoSlab 703 XBd BT","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Gisha","Gloucester MT Extra Condensed","GOTHAM","GOTHAM BOLD","Goudy Old Style","Goudy Stout","GoudyHandtooled BT","GoudyOLSt BT","Gujarati Sangam MN","Gulim","GulimChe","Gungsuh","GungsuhChe","Gurmukhi MN","Haettenschweiler","Harlow Solid Italic","Harrington","Heather","Heiti SC","Heiti TC","HELV","Herald","High Tower Text","Hiragino Kaku Gothic ProN","Hiragino Mincho ProN","Hoefler Text","Humanst 521 Cn BT","Humanst521 BT","Humanst521 Lt BT","Imprint MT Shadow","Incised901 Bd BT","Incised901 BT","Incised901 Lt BT","INCONSOLATA","Informal Roman","Informal011 BT","INTERSTATE","IrisUPC","Iskoola Pota","JasmineUPC","Jazz LET","Jenson","Jester","Jokerman","Juice ITC","Kabel Bk BT","Kabel Ult BT","Kailasa","KaiTi","Kalinga","Kannada Sangam MN","Kartika","Kaufmann Bd BT","Kaufmann BT","Khmer UI","KodchiangUPC","Kokila","Korinna BT","Kristen ITC","Krungthep","Kunstler Script","Lao UI","Latha","Leelawadee","Letter Gothic","Levenim MT","LilyUPC","Lithograph","Lithograph Light","Long Island","Lydian BT","Magneto","Maiandra GD","Malayalam Sangam MN","Malgun Gothic","Mangal","Marigold","Marion","Marker Felt","Market","Marlett","Matisse ITC","Matura MT Script Capitals","Meiryo","Meiryo UI","Microsoft Himalaya","Microsoft JhengHei","Microsoft New Tai Lue","Microsoft PhagsPa","Microsoft Tai Le","Microsoft Uighur","Microsoft YaHei","Microsoft Yi Baiti","MingLiU","MingLiU_HKSCS","MingLiU_HKSCS-ExtB","MingLiU-ExtB","Minion","Minion Pro","Miriam","Miriam Fixed","Mistral","Modern","Modern No. 20","Mona Lisa Solid ITC TT","Mongolian Baiti","MONO","MoolBoran","Mrs Eaves","MS LineDraw","MS Mincho","MS PMincho","MS Reference Specialty","MS UI Gothic","MT Extra","MUSEO","MV Boli","Nadeem","Narkisim","NEVIS","News Gothic","News GothicMT","NewsGoth BT","Niagara Engraved","Niagara Solid","Noteworthy","NSimSun","Nyala","OCR A Extended","Old Century","Old English Text MT","Onyx","Onyx BT","OPTIMA","Oriya Sangam MN","OSAKA","OzHandicraft BT","Palace Script MT","Papyrus","Parchment","Party LET","Pegasus","Perpetua","Perpetua Titling MT","PetitaBold","Pickwick","Plantagenet Cherokee","Playbill","PMingLiU","PMingLiU-ExtB","Poor Richard","Poster","PosterBodoni BT","PRINCETOWN LET","Pristina","PTBarnum BT","Pythagoras","Raavi","Rage Italic","Ravie","Ribbon131 Bd BT","Rockwell","Rockwell Condensed","Rockwell Extra Bold","Rod","Roman","Sakkal Majalla","Santa Fe LET","Savoye LET","Sceptre","Script","Script MT Bold","SCRIPTINA","Serifa","Serifa BT","Serifa Th BT","ShelleyVolante BT","Sherwood","Shonar Bangla","Showcard Gothic","Shruti","Signboard","SILKSCREEN","SimHei","Simplified Arabic","Simplified Arabic Fixed","SimSun","SimSun-ExtB","Sinhala Sangam MN","Sketch Rockwell","Skia","Small Fonts","Snap ITC","Snell Roundhand","Socket","Souvenir Lt BT","Staccato222 BT","Steamer","Stencil","Storybook","Styllo","Subway","Swis721 BlkEx BT","Swiss911 XCm BT","Sylfaen","Synchro LET","System","Tamil Sangam MN","Technical","Teletype","Telugu Sangam MN","Tempus Sans ITC","Terminal","Thonburi","Traditional Arabic","Trajan","TRAJAN PRO","Tristan","Tubular","Tunga","Tw Cen MT","Tw Cen MT Condensed","Tw Cen MT Condensed Extra Bold","TypoUpright BT","Unicorn","Univers","Univers CE 55 Medium","Univers Condensed","Utsaah","Vagabond","Vani","Vijaya","Viner Hand ITC","VisualUI","Vivaldi","Vladimir Script","Vrinda","Westminster","WHITNEY","Wide Latin","ZapfEllipt BT","ZapfHumnst BT","ZapfHumnst Dm BT","Zapfino","Zurich BlkEx BT","Zurich Ex BT","ZWAdobeF"]));n=(n=n.concat(t.fonts.userDefinedFonts)).filter(function(e,t){return n.indexOf(e)===t});var i=document.getElementsByTagName("body")[0],a=document.createElement("div"),o=document.createElement("div"),s={},c={},d=function(){var e=document.createElement("span");return e.style.position="absolute",e.style.left="-9999px",e.style.fontSize="72px",e.style.fontStyle="normal",e.style.fontWeight="normal",e.style.letterSpacing="normal",e.style.lineBreak="auto",e.style.lineHeight="normal",e.style.textTransform="none",e.style.textAlign="left",e.style.textDecoration="none",e.style.textShadow="none",e.style.whiteSpace="normal",e.style.wordBreak="normal",e.style.wordSpacing="normal",e.innerHTML="mmmmmmmmmmlli",e},u=function(e,t){var r=d();return r.style.fontFamily="'"+e+"',"+t,r},l=function(e){for(var t=!1,n=0;n=e.components.length)t(r.data);else{var o=e.components[n];if(e.excludes[o.key])i(!1);else{if(!a&&o.pauseBefore)return n-=1,void setTimeout(function(){i(!0)},1);try{o.getData(function(e){r.addPreprocessedComponent(o.key,e),i(!1)},e)}catch(e){r.addPreprocessedComponent(o.key,String(e)),i(!1)}}}};i(!1)},F.getPromise=function(e){return new Promise(function(t,r){F.get(e,t)})},F.getV18=function(e,t){return null==t&&(t=e,e={}),F.get(e,function(r){for(var n=[],i=0;i=43)}}).catch(function(){return!1})}(e).then(function(e){return A=e})}function v(e){var t=h[e.name],r={};r.promise=new o(function(e,t){r.resolve=e,r.reject=t}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function T(e){var t=h[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function b(e,t){var r=h[e.name],n=r.deferredOperations.pop();if(n)return n.reject(t),n.promise}function S(e,t){return new o(function(r,n){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return r(e.db);v(e),e.db.close()}var a=[e.name];t&&a.push(e.version);var o=i.open.apply(i,a);t&&(o.onupgradeneeded=function(t){var r=o.result;try{r.createObjectStore(e.storeName),t.oldVersion<=1&&r.createObjectStore(l)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),n(o.error)},o.onsuccess=function(){r(o.result),T(e)}})}function y(e){return S(e,!1)}function k(e){return S(e,!0)}function _(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.versione.db.version;if(n&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function w(e){var t=function(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return o.resolve().then(function(){if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),k(e)}).then(function(){return function(e){v(e);for(var t=h[e.name],r=t.forages,n=0;n>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&a;return d}function Q(e){var t,r=new Uint8Array(e),n="";for(t=0;t>2],n+=I[(3&r[t])<<4|r[t+1]>>4],n+=I[(15&r[t+1])<<2|r[t+2]>>6],n+=I[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}var J={serialize:function(e,t){var r="";if(e&&(r=X.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===X.call(e.buffer))){var n,i=O;e instanceof ArrayBuffer?(n=e,i+=B):(n=e.buffer,"[object Int8Array]"===r?i+=N:"[object Uint8Array]"===r?i+=G:"[object Uint8ClampedArray]"===r?i+=H:"[object Int16Array]"===r?i+=F:"[object Uint16Array]"===r?i+=V:"[object Int32Array]"===r?i+=j:"[object Uint32Array]"===r?i+=U:"[object Float32Array]"===r?i+=q:"[object Float64Array]"===r?i+=W:t(new Error("Failed to get type for BinaryArray"))),t(i+Q(n))}else if("[object Blob]"===r){var a=new FileReader;a.onload=function(){var r=R+e.type+"~"+Q(this.result);t(O+L+r)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),t(null,r)}},deserialize:function(e){if(e.substring(0,x)!==O)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(x,z);if(n===L&&D.test(r)){var i=r.match(D);t=i[1],r=r.substring(i[0].length)}var o=K(r);switch(n){case B:return o;case L:return a([o],{type:t});case N:return new Int8Array(o);case G:return new Uint8Array(o);case H:return new Uint8ClampedArray(o);case F:return new Int16Array(o);case V:return new Uint16Array(o);case j:return new Int32Array(o);case U:return new Uint32Array(o);case q:return new Float32Array(o);case W:return new Float64Array(o);default:throw new Error("Unkown type: "+n)}},stringToBuffer:K,bufferToString:Q};function Z(e,t,r,n){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,n)}function $(e,t,r,n,i,a){e.executeSql(r,n,i,function(e,o){o.code===o.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(e,s){s.rows.length?a(e,o):Z(e,t,function(){e.executeSql(r,n,i,a)},a)},a):a(e,o)},a)}var Y={_driver:"webSQLStorage",_initStorage:function(e){var t=this,r={db:null};if(e)for(var n in e)r[n]="string"!=typeof e[n]?e[n].toString():e[n];var i=new o(function(e,n){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return n(e)}r.db.transaction(function(i){Z(i,r,function(){t._dbInfo=r,e()},function(e,t){n(t)})},n)});return r.serializer=J,i},_support:"function"==typeof openDatabase,iterate:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT * FROM "+i.storeName,[],function(r,n){for(var a=n.rows,o=a.length,s=0;s0)return void o(e.apply(a,[t,c,n,i-1]));s(r)}})})}).catch(s)});return s(c,n),c}.apply(this,[e,t,r,1])},removeItem:function(e,t){var r=this;e=d(e);var n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){t()},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},clear:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"DELETE FROM "+n.storeName,[],function(){e()},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},length:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(t,r){var n=r.rows.item(0).c;e(n)},function(e,t){r(t)})})}).catch(r)});return s(r,e),r},key:function(e,t){var r=this,n=new o(function(t,n){r.ready().then(function(){var i=r._dbInfo;i.db.transaction(function(r){$(r,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,r){var n=r.rows.length?r.rows.item(0).key:null;t(n)},function(e,t){n(t)})})}).catch(n)});return s(n,t),n},keys:function(e){var t=this,r=new o(function(e,r){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(t){$(t,n,"SELECT key FROM "+n.storeName,[],function(t,r){for(var n=[],i=0;i '__WebKitDatabaseInfoTable__'",[],function(r,n){for(var i=[],a=0;a0}var re={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var r in e)t[r]=e[r];return t.keyPrefix=ee(e,this._defaultConfig),te()?(this._dbInfo=t,t.serializer=J,o.resolve()):o.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var r=this,n=r.ready().then(function(){for(var t=r._dbInfo,n=t.keyPrefix,i=n.length,a=localStorage.length,o=1,s=0;s=0;r--){var n=localStorage.key(r);0===n.indexOf(e)&&localStorage.removeItem(n)}});return s(r,e),r},length:function(e){var t=this.keys().then(function(e){return e.length});return s(t,e),t},key:function(e,t){var r=this,n=r.ready().then(function(){var t,n=r._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(n.keyPrefix.length)),t});return s(n,t),n},keys:function(e){var t=this,r=t.ready().then(function(){for(var e=t._dbInfo,r=localStorage.length,n=[],i=0;i=0;t--){var r=localStorage.key(t);0===r.indexOf(e)&&localStorage.removeItem(r)}}):o.reject("Invalid arguments"),t),n}},ne=function(e,t){for(var r=e.length,n=0;n=0;)e[t]=0}const q=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),W=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),z=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),X=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K=new Array(576);U(K);const Q=new Array(60);U(Q);const J=new Array(512);U(J);const Z=new Array(256);U(Z);const $=new Array(29);U($);const Y=new Array(30);function ee(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let te,re,ne;function ie(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U(Y);const ae=e=>e<256?J[e]:J[256+(e>>>7)],oe=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},se=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<{se(e,r[2*t],r[2*t+1])},de=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},ue=(e,t,r)=>{const n=new Array(16);let i,a,o=0;for(i=1;i<=15;i++)n[i]=o=o+r[i-1]<<1;for(a=0;a<=t;a++){let t=e[2*a+1];0!==t&&(e[2*a]=de(n[t]++,t))}},le=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},Ae=e=>{e.bi_valid>8?oe(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},he=(e,t,r,n)=>{const i=2*t,a=2*r;return e[i]{const n=e.heap[r];let i=r<<1;for(;i<=e.heap_len&&(i{let n,i,a,o,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?ce(e,i,t):(a=Z[i],ce(e,a+256+1,t),0!==(o=q[a])&&(i-=$[a],se(e,i,o)),a=ae(--n),ce(e,a,r),0!==(o=W[a])&&(n-=Y[a],se(e,n,o)))}while(s{const r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems;let o,s,c,d=-1;for(e.heap_len=0,e.heap_max=573,o=0;o>1;o>=1;o--)fe(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],fe(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,r[2*c]=r[2*o]+r[2*s],e.depth[c]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,r[2*o+1]=r[2*s+1]=c,e.heap[1]=c++,fe(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let d,u,l,A,h,f,p=0;for(A=0;A<=15;A++)e.bl_count[A]=0;for(r[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)(A=r[2*r[2*(u=e.heap[d])+1]+1]+1)>c&&(A=c,p++),r[2*u+1]=A,u>n||(e.bl_count[A]++,h=0,u>=s&&(h=o[u-s]),f=r[2*u],e.opt_len+=f*(A+h),a&&(e.static_len+=f*(i[2*u+1]+h)));if(0!==p){do{for(A=c-1;0===e.bl_count[A];)A--;e.bl_count[A]--,e.bl_count[A+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(A=c;0!==A;A--)for(u=e.bl_count[A];0!==u;)(l=e.heap[--d])>n||(r[2*l+1]!==A&&(e.opt_len+=(A-r[2*l+1])*r[2*l],r[2*l+1]=A),u--)}})(e,t),ue(r,d,e.bl_count)},ge=(e,t,r)=>{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=t[2*(n+1)+1],++s{let n,i,a=-1,o=t[1],s=0,c=7,d=4;for(0===o&&(c=138,d=3),n=0;n<=r;n++)if(i=o,o=t[2*(n+1)+1],!(++s{se(e,0+(n?1:0),3),((e,t,r,n)=>{Ae(e),n&&(oe(e,r),oe(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var Se={_tr_init:e=>{Te||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for($[n]=r,e=0;e<1<>=7;n<30;n++)for(Y[n]=i<<7,e=0;e<1<{let i,a,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),me(e,e.l_desc),me(e,e.d_desc),o=(e=>{let t;for(ge(e,e.dyn_ltree,e.l_desc.max_code),ge(e,e.dyn_dtree,e.d_desc.max_code),me(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*X[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?be(e,t,r,n):4===e.strategy||a===i?(se(e,2+(n?1:0),3),pe(e,K,Q)):(se(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(se(e,t-257,5),se(e,r-1,5),se(e,n-4,4),i=0;i(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Z[r]+256+1)]++,e.dyn_dtree[2*ae(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{se(e,2,3),ce(e,256,K),(e=>{16===e.bi_valid?(oe(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var ye=(e,t,r,n)=>{let i=65535&e|0,a=e>>>16&65535|0,o=0;for(;0!==r;){r-=o=r>2e3?2e3:r;do{a=a+(i=i+t[n++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0};const ke=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var _e=(e,t,r,n)=>{const i=ke,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},we={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ee={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Ce,_tr_stored_block:Me,_tr_flush_block:Pe,_tr_tally:Ie,_tr_align:Re}=Se,{Z_NO_FLUSH:De,Z_PARTIAL_FLUSH:Oe,Z_FULL_FLUSH:xe,Z_FINISH:Be,Z_BLOCK:Le,Z_OK:Ne,Z_STREAM_END:Ge,Z_STREAM_ERROR:He,Z_DATA_ERROR:Fe,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Ve,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:We,Z_FIXED:ze,Z_DEFAULT_STRATEGY:Xe,Z_UNKNOWN:Ke,Z_DEFLATED:Qe}=Ee,Je=286,Ze=30,$e=19,Ye=2*Je+1,et=15,tt=(e,t)=>(e.msg=we[t],t),rt=e=>(e<<1)-(e>4?9:0),nt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let it=(e,t,r)=>(t<{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ot=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,at(e.strm)},st=(e,t)=>{e.pending_buf[e.pending++]=t},ct=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},dt=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=ye(e.adler,t,i,r):2===e.state.wrap&&(e.adler=_e(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ut=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,d=e.window,u=e.w_mask,l=e.prev,A=e.strstart+258;let h=d[a+o-1],f=d[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(d[(r=t)+o]===f&&d[r+o-1]===h&&d[r]===d[a]&&d[++r]===d[a+1]){a+=2,r++;do{}while(d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&d[++a]===d[++r]&&ao){if(e.match_start=t,o=n,n>=s)break;h=d[a+o-1],f=d[a+o]}}}while((t=l[t&u])>c&&0!=--i);return o<=e.lookahead?o:e.lookahead},lt=e=>{const t=e.w_size;let r,n,i,a,o;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-262)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=n=e.hash_size;do{i=e.head[--r],e.head[r]=i>=t?i-t:0}while(--n);r=n=t;do{i=e.prev[--r],e.prev[r]=i>=t?i-t:0}while(--n);a+=t}if(0===e.strm.avail_in)break;if(n=dt(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=it(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=it(e,e.ins_h,e.window[o+3-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},At=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ut(e,r)),e.match_length>=3)if(n=Ie(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=it(e,e.ins_h,e.window[e.strstart+1]);else n=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2},ht=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(lt(e),e.lookahead<262&&t===De)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Ie(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=it(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(ot(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Ie(e,0,e.window[e.strstart-1]))&&ot(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ie(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2};function ft(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}const pt=[new ft(0,0,0,0,(e,t)=>{let r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(lt(e),0===e.lookahead&&t===De)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,ot(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(ot(e,!1),e.strm.avail_out),1)}),new ft(4,4,8,4,At),new ft(4,5,16,8,At),new ft(4,6,32,32,At),new ft(4,4,16,16,ht),new ft(8,16,32,32,ht),new ft(8,16,128,128,ht),new ft(8,32,128,256,ht),new ft(32,128,258,1024,ht),new ft(32,258,258,4096,ht)];function mt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qe,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*Ye),this.dyn_dtree=new Uint16Array(2*(2*Ze+1)),this.bl_tree=new Uint16Array(2*(2*$e+1)),nt(this.dyn_ltree),nt(this.dyn_dtree),nt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(et+1),this.heap=new Uint16Array(2*Je+1),nt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Je+1),nt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const gt=e=>{if(!e||!e.state)return tt(e,He);e.total_in=e.total_out=0,e.data_type=Ke;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=De,Ce(t),Ne},vt=e=>{const t=gt(e);return t===Ne&&(e=>{e.window_size=2*e.w_size,nt(e.head),e.max_lazy_match=pt[e.level].max_lazy,e.good_match=pt[e.level].good_length,e.nice_match=pt[e.level].nice_length,e.max_chain_length=pt[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0})(e.state),t},Tt=(e,t,r,n,i,a)=>{if(!e)return He;let o=1;if(t===Ve&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Qe||n<8||n>15||t<0||t>9||a<0||a>ze)return tt(e,He);8===n&&(n=9);const s=new mt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<Tt(e,t,Qe,15,8,Xe),deflateInit2:Tt,deflateReset:vt,deflateResetKeep:gt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?He:(e.state.gzhead=t,Ne):He,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Le||t<0)return e?tt(e,He):He;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Be)return tt(e,0===e.avail_out?je:He);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,st(i,31),st(i,139),st(i,8),i.gzhead?(st(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),st(i,255&i.gzhead.time),st(i,i.gzhead.time>>8&255),st(i,i.gzhead.time>>16&255),st(i,i.gzhead.time>>24&255),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(st(i,255&i.gzhead.extra.length),st(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=_e(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(st(i,0),st(i,0),st(i,0),st(i,0),st(i,0),st(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),st(i,3),i.status=113);else{let t=Qe+(i.w_bits-8<<4)<<8,r=-1;t|=(r=i.strategy>=qe||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,ct(i,t),0!==i.strstart&&(ct(i,e.adler>>>16),ct(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending!==i.pending_buf_size));)st(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),at(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=_e(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&at(e),i.pending+2<=i.pending_buf_size&&(st(i,255&e.adler),st(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(at(e),0===e.avail_out)return i.last_flush=-1,Ne}else if(0===e.avail_in&&rt(t)<=rt(a)&&t!==Be)return tt(e,je);if(666===i.status&&0!==e.avail_in)return tt(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==De&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(lt(e),0===e.lookahead)){if(t===De)return 1;break}if(e.match_length=0,r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===We?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(lt(e),e.lookahead<=258&&t===De)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=o[i=e.strstart-1])===o[++i]&&n===o[++i]&&n===o[++i]){a=e.strstart+258;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Ie(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ie(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ot(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Be?(ot(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(ot(e,!1),0===e.strm.avail_out)?1:2})(i,t):pt[i.level].func(i,t);if(3!==r&&4!==r||(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),Ne;if(2===r&&(t===Oe?Re(i):t!==Le&&(Me(i,0,0,!1),t===xe&&(nt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),at(e),0===e.avail_out))return i.last_flush=-1,Ne}return t!==Be?Ne:i.wrap<=0?Ge:(2===i.wrap?(st(i,255&e.adler),st(i,e.adler>>8&255),st(i,e.adler>>16&255),st(i,e.adler>>24&255),st(i,255&e.total_in),st(i,e.total_in>>8&255),st(i,e.total_in>>16&255),st(i,e.total_in>>24&255)):(ct(i,e.adler>>>16),ct(i,65535&e.adler)),at(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Ne:Ge)},deflateEnd:e=>{if(!e||!e.state)return He;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?tt(e,He):(e.state=null,113===t?tt(e,Fe):Ne)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return He;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return He;if(1===i&&(e.adler=ye(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(nt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}const a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,lt(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=it(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,lt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,n.wrap=i,Ne},deflateInfo:"pako deflate (from Nodeca project)"};const St=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var yt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)St(r,t)&&(e[t]=r[t])}}return e},flattenChunks:e=>{let t=0;for(let r=0,n=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;_t[254]=_t[254]=1;var wt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,n,i,a,o=e.length,s=0;for(i=0;i>>6,t[a++]=128|63&r):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r);return t},buf2string:(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const a=new Array(2*r);for(i=0,n=0;n4)a[i++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n1?a[i++]=65533:t<65536?a[i++]=t:(t-=65536,a[i++]=55296|t>>10&1023,a[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&kt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+_t[e[r]]>t?r:t}};var Et=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ct=Object.prototype.toString,{Z_NO_FLUSH:Mt,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:It,Z_FINISH:Rt,Z_OK:Dt,Z_STREAM_END:Ot,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Bt,Z_DEFLATED:Lt}=Ee;function Nt(e){this.options=yt.assign({level:xt,method:Lt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Bt},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=bt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Dt)throw new Error(we[r]);if(t.header&&bt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?wt.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=bt.deflateSetDictionary(this.strm,e))!==Dt)throw new Error(we[r]);this._dict_set=!0}}function Gt(e,t){const r=new Nt(t);if(r.push(e,!0),r.err)throw r.msg||we[r.err];return r.result}Nt.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize;let i,a;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Rt:Mt,"string"==typeof e?r.input=wt.string2buf(e):"[object ArrayBuffer]"===Ct.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a===Pt||a===It)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=bt.deflate(r,a))===Ot)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=bt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Dt;if(0!==r.avail_out){if(a>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Nt.prototype.onData=function(e){this.chunks.push(e)},Nt.prototype.onEnd=function(e){e===Dt&&(this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ht={Deflate:Nt,deflate:Gt,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Gt(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Gt(e,t)},constants:Ee};var Ft=function(e,t){let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_,w;const E=e.state;r=e.next_in,_=e.input,n=r+(e.avail_in-5),i=e.next_out,w=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,d=E.whave,u=E.wnext,l=E.window,A=E.hold,h=E.bits,f=E.lencode,p=E.distcode,m=(1<>>=T=v>>>24,h-=T,0===(T=v>>>16&255))w[i++]=65535&v;else{if(!(16&T)){if(0==(64&T)){v=f[(65535&v)+(A&(1<>>=T,h-=T),h<15&&(A+=_[r++]<>>=T=v>>>24,h-=T,!(16&(T=v>>>16&255))){if(0==(64&T)){v=p[(65535&v)+(A&(1<s){e.msg="invalid distance too far back",E.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&E.sane){e.msg="invalid distance too far back",E.mode=30;break e}if(y=0,k=l,0===u){if(y+=c-T,T2;)w[i++]=k[y++],w[i++]=k[y++],w[i++]=k[y++],b-=3;b&&(w[i++]=k[y++],b>1&&(w[i++]=k[y++]))}else{y=i-S;do{w[i++]=w[y++],w[i++]=w[y++],w[i++]=w[y++],b-=3}while(b>2);b&&(w[i++]=w[y++],b>1&&(w[i++]=w[y++]))}break}}break}}while(r>3,A&=(1<<(h-=b<<3))-1,e.next_in=r,e.next_out=i,e.avail_in=r{const c=s.bits;let d,u,l,A,h,f,p=0,m=0,g=0,v=0,T=0,b=0,S=0,y=0,k=0,_=0,w=null,E=0;const C=new Uint16Array(16),M=new Uint16Array(16);let P,I,R,D=null,O=0;for(p=0;p<=15;p++)C[p]=0;for(m=0;m=1&&0===C[v];v--);if(T>v&&(T=v),0===v)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(g=1;g0&&(0===e||1!==v))return-1;for(M[1]=0,p=1;p<15;p++)M[p+1]=M[p]+C[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){P=p-S,o[m]f?(I=D[O+o[m]],R=w[E+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=P<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--C[p]){if(p===v)break;p=t[r+o[m]]}if(p>T&&(_&A)!==l){for(0===S&&(S=T),h+=g,y=1<<(b=p-S);b+S852||2===e&&k>592)return 1;i[l=_&A]=T<<24|b<<16|h-a|0}}return 0!==_&&(i[h+_]=p-S<<24|64<<16|0),s.bits=T,0};const{Z_FINISH:zt,Z_BLOCK:Xt,Z_TREES:Kt,Z_OK:Qt,Z_STREAM_END:Jt,Z_NEED_DICT:Zt,Z_STREAM_ERROR:$t,Z_DATA_ERROR:Yt,Z_MEM_ERROR:er,Z_BUF_ERROR:tr,Z_DEFLATED:rr}=Ee,nr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ir(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ar=e=>{if(!e||!e.state)return $t;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Qt},or=e=>{if(!e||!e.state)return $t;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ar(e)},sr=(e,t)=>{let r;if(!e||!e.state)return $t;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?$t:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,or(e))},cr=(e,t)=>{if(!e)return $t;const r=new ir;e.state=r,r.window=null;const n=sr(e,t);return n!==Qt&&(e.state=null),n};let dr,ur,lr=!0;const Ar=e=>{if(lr){dr=new Int32Array(512),ur=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Wt(1,e.lens,0,288,dr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Wt(2,e.lens,0,32,ur,0,e.work,{bits:5}),lr=!1}e.lencode=dr,e.lenbits=9,e.distcode=ur,e.distbits=5},hr=(e,t,r,n)=>{let i;const a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whavecr(e,15),inflateInit2:cr,inflate:(e,t)=>{let r,n,i,a,o,s,c,d,u,l,A,h,f,p,m,g,v,T,b,S,y,k,_=0;const w=new Uint8Array(4);let E,C;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return $t;12===(r=e.state).mode&&(r.mode=13),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,l=s,A=c,k=Qt;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0),d=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&d)!==rr){e.msg="unknown compression method",r.mode=30;break}if(u-=4,y=8+(15&(d>>>=4)),0===r.wbits)r.wbits=y;else if(y>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>8&255,w[2]=d>>>16&255,w[3]=d>>>24&255,r.check=_e(r.check,w,4,0)),d=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>8),512&r.flags&&(w[0]=255&d,w[1]=d>>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===s)break e;s--,d+=n[a++]<>>8&255,r.check=_e(r.check,w,2,0)),d=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>s&&(h=s),h&&(r.head&&(y=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),y)),512&r.flags&&(r.check=_e(r.check,n,h,a)),s-=h,a+=h,r.length-=h),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break e;h=0;do{y=n[a+h++],r.head&&y&&r.length<65536&&(r.head.name+=String.fromCharCode(y))}while(y&&h>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===s)break e;s--,d+=n[a++]<>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===s)break e;s--,d+=n[a++]<>>=1)){case 0:r.mode=14;break;case 1:if(Ar(r),r.mode=20,t===Kt){d>>>=2,u-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}d>>>=2,u-=2;break;case 14:for(d>>>=7&u,u-=7&u;u<32;){if(0===s)break e;s--,d+=n[a++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&d,d=0,u=0,r.mode=15,t===Kt)break e;case 15:r.mode=16;case 16:if(h=r.length){if(h>s&&(h=s),h>c&&(h=c),0===h)break e;i.set(n.subarray(a,a+h),o),s-=h,a+=h,c-=h,o+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===s)break e;s--,d+=n[a++]<>>=5,u-=5,r.ndist=1+(31&d),d>>>=5,u-=5,r.ncode=4+(15&d),d>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,u-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,E={bits:r.lenbits},k=Wt(0,r.lens,0,19,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=m,u-=m,r.lens[r.have++]=v;else{if(16===v){for(C=m+2;u>>=m,u-=m,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}y=r.lens[r.have-1],h=3+(3&d),d>>>=2,u-=2}else if(17===v){for(C=m+3;u>>=m)),d>>>=3,u-=3}else{for(C=m+7;u>>=m)),d>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=y}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,E={bits:r.lenbits},k=Wt(1,r.lens,0,r.nlen,r.lencode,0,r.work,E),r.lenbits=E.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,E={bits:r.distbits},k=Wt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,E),r.distbits=E.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Kt)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,r.hold=d,r.bits=u,Ft(e,A),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,s=e.avail_in,d=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(_=r.lencode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,r.length=v,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(_=r.distcode[d&(1<>>16&255,v=65535&_,!((m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>T)])>>>16&255,v=65535&_,!(T+(m=_>>>24)<=u);){if(0===s)break e;s--,d+=n[a++]<>>=T,u-=T,r.back+=T}if(d>>>=m,u-=m,r.back+=m,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=v,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(C=r.extra;u>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===c)break e;if(h=A-c,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,f=r.wsize-h):f=r.wnext-h,h>r.length&&(h=r.length),p=r.window}else p=i,f=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do{i[o++]=p[f++]}while(--h);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[o++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===s)break e;s--,d|=n[a++]<{if(!e||!e.state)return $t;let t=e.state;return t.window&&(t.window=null),e.state=null,Qt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return $t;const r=e.state;return 0==(2&r.wrap)?$t:(r.head=t,t.done=!1,Qt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?$t:11===n.mode&&(i=ye(i=1,t,r,0))!==n.check?Yt:(a=hr(e,t,r,r))?(n.mode=31,er):(n.havedict=1,Qt):$t},inflateInfo:"pako inflate (from Nodeca project)"};var pr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const mr=Object.prototype.toString,{Z_NO_FLUSH:gr,Z_FINISH:vr,Z_OK:Tr,Z_STREAM_END:br,Z_NEED_DICT:Sr,Z_STREAM_ERROR:yr,Z_DATA_ERROR:kr,Z_MEM_ERROR:_r}=Ee;function wr(e){this.options=yt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Et,this.strm.avail_out=0;let r=fr.inflateInit2(this.strm,t.windowBits);if(r!==Tr)throw new Error(we[r]);if(this.header=new pr,fr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wt.string2buf(t.dictionary):"[object ArrayBuffer]"===mr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=fr.inflateSetDictionary(this.strm,t.dictionary))!==Tr))throw new Error(we[r])}function Er(e,t){const r=new wr(t);if(r.push(e),r.err)throw r.msg||we[r.err];return r.result}wr.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let a,o,s;if(this.ended)return!1;for(o=t===~~t?t:!0===t?vr:gr,"[object ArrayBuffer]"===mr.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(a=fr.inflate(r,o))===Sr&&i&&((a=fr.inflateSetDictionary(r,i))===Tr?a=fr.inflate(r,o):a===kr&&(a=Sr));r.avail_in>0&&a===br&&r.state.wrap>0&&0!==e[r.next_in];)fr.inflateReset(r),a=fr.inflate(r,o);switch(a){case yr:case kr:case Sr:case _r:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===br))if("string"===this.options.to){let e=wt.utf8border(r.output,r.next_out),t=r.next_out-e,i=wt.buf2string(r.output,e);r.next_out=t,r.avail_out=n-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(a!==Tr||0!==s){if(a===br)return a=fr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},wr.prototype.onData=function(e){this.chunks.push(e)},wr.prototype.onEnd=function(e){e===Tr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=yt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:wr,inflate:Er,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Er(e,t)},ungzip:Er,constants:Ee};const{Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr}=Ht,{Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br}=Cr;var Lr={Deflate:Mr,deflate:Pr,deflateRaw:Ir,gzip:Rr,Inflate:Dr,inflate:Or,inflateRaw:xr,ungzip:Br,constants:Ee},Nr=u(function(e){!function(t){function r(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function n(e,t,n,i,a,o){return r((s=r(r(t,e),r(i,o)))<<(c=a)|s>>>32-c,n);var s,c}function i(e,t,r,i,a,o,s){return n(t&r|~t&i,e,t,a,o,s)}function a(e,t,r,i,a,o,s){return n(t&i|r&~i,e,t,a,o,s)}function o(e,t,r,i,a,o,s){return n(t^r^i,e,t,a,o,s)}function s(e,t,r,i,a,o,s){return n(r^(t|~i),e,t,a,o,s)}function c(e,t){var n,c,d,u,l;e[t>>5]|=128<>>9<<4)]=t;var A=1732584193,h=-271733879,f=-1732584194,p=271733878;for(n=0;n>5]>>>t%32&255);return r}function u(e){var t,r=[];for(r[(e.length>>2)-1]=void 0,t=0;t>5]|=(255&e.charCodeAt(t/8))<>>4&15)+"0123456789abcdef".charAt(15&t);return n}function A(e){return unescape(encodeURIComponent(e))}function h(e){return function(e){return d(c(u(e),8*e.length))}(A(e))}function f(e,t){return function(e,t){var r,n,i=u(e),a=[],o=[];for(a[15]=o[15]=void 0,i.length>16&&(i=c(i,8*e.length)),r=0;r<16;r+=1)a[r]=909522486^i[r],o[r]=1549556828^i[r];return n=c(a.concat(u(t)),512+8*t.length),d(c(o.concat(n),640))}(A(e),A(t))}function p(e,t,r){return t?r?f(t,e):l(f(t,e)):r?h(e):l(h(e))}e.exports?e.exports=p:t.md5=p}(c)}),Gr=u(function(e,t){var r=200,n="Expected a function",i="__lodash_hash_undefined__",a=1,o=2,s=1/0,d=9007199254740991,u="[object Arguments]",l="[object Array]",A="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Function]",m="[object GeneratorFunction]",g="[object Map]",v="[object Number]",T="[object Object]",b="[object RegExp]",S="[object Set]",y="[object String]",k="[object Symbol]",_="[object ArrayBuffer]",w="[object DataView]",E=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,C=/^\w*$/,M=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,O={};O["[object Float32Array]"]=O["[object Float64Array]"]=O["[object Int8Array]"]=O["[object Int16Array]"]=O["[object Int32Array]"]=O["[object Uint8Array]"]=O["[object Uint8ClampedArray]"]=O["[object Uint16Array]"]=O["[object Uint32Array]"]=!0,O[u]=O[l]=O[_]=O[A]=O[w]=O[h]=O[f]=O[p]=O[g]=O[v]=O[T]=O[b]=O[S]=O[y]=O["[object WeakMap]"]=!1;var x="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=x||B||Function("return this")(),N=t&&!t.nodeType&&t,G=N&&e&&!e.nodeType&&e,H=G&&G.exports===N&&x.process,F=function(){try{return H&&H.binding("util")}catch(e){}}(),j=F&&F.isTypedArray;function V(e,t,r,n){for(var i=-1,a=e?e.length:0;++i-1},we.prototype.set=function(e,t){var r=this.__data__,n=Ie(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ee.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ee.prototype.delete=function(e){return qe(this,e).delete(e)},Ee.prototype.get=function(e){return qe(this,e).get(e)},Ee.prototype.has=function(e){return qe(this,e).has(e)},Ee.prototype.set=function(e,t){return qe(this,e).set(e,t),this},Ce.prototype.add=Ce.prototype.push=function(e){return this.__data__.set(e,i),this},Ce.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.clear=function(){this.__data__=new we},Me.prototype.delete=function(e){return this.__data__.delete(e)},Me.prototype.get=function(e){return this.__data__.get(e)},Me.prototype.has=function(e){return this.__data__.has(e)},Me.prototype.set=function(e,t){var n=this.__data__;if(n instanceof we){var i=n.__data__;if(!le||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ut(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function lt(e){return!!e&&"object"==typeof e}function At(e){return"symbol"==typeof e||lt(e)&&ne.call(e)==k}var ht=j?function(e){return function(t){return e(t)}}(j):function(e){return lt(e)&&dt(e.length)&&!!O[ne.call(e)]};function ft(e){return st(e)?Pe(e):je(e)}function pt(e){return e}e.exports=rt});const Hr="4.1.9";function Fr(){const e=new Date;function t(e){const t=e.toString();return t.length<2?"0"+t:t}return`[${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${e.getMilliseconds()}]`}const jr=new class{constructor(e){this.level=e}setLevel(e){this.level=e}log(...e){if("log"!==this.level)return;const t=`${Fr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Fr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Fr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Vr extends C{constructor(e,t=!0){super(),this._closed=!1,this._busy=!1,this._queue=[],this.name=e||"TaskQueue",this.isDebug=t}close(){this._closed=!0}push(e,t){return this.isDebug&&jr.debug(`${this.name} push()`,e,t),new Promise((r,n)=>{this._queue.push({method:e,data:t,resolve:r,reject:n}),this._handlePendingCommands()})}_handlePendingCommands(){if(this._busy)return;const e=this._queue,t=e[0];t&&(this._busy=!0,this._handleCommand(t).then(()=>{this._busy=!1,e.shift(),this._handlePendingCommands()}))}_handleCommand(e){if(this.isDebug&&jr.debug(`${this.name} _handleCommand() `,e.method,e.data),this._closed)return e.reject(new $n("closed")),Promise.resolve();const t={promise:null};return this.emit("exec",e,t),Promise.resolve().then(()=>t.promise).then(t=>{this.isDebug&&jr.debug(`${this.name} _handleCommand() | command succeeded`,e.method),this._closed?e.reject(new $n("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}var Ur,qr;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}(Ur||(Ur={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}(qr||(qr={}));const Wr={"360p":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:30,bitrate:1130},"1080p":{width:1920,height:1080,frameRate:30,bitrate:2080},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4850},"4k":{width:3840,height:2160,frameRate:30,bitrate:8910}},zr=Wr["480p"],Xr={LOW:{sampleRate:16e3,stereo:!1,bitrate:24,sampleSize:16},STANDARD:{sampleRate:48e3,stereo:!1,bitrate:64,sampleSize:16},STANDARD_STEREO:{sampleRate:48e3,stereo:!0,bitrate:80,sampleSize:16},HIGH:{sampleRate:48e3,stereo:!1,bitrate:96,sampleSize:16},HIGH_STEREO:{sampleRate:48e3,stereo:!0,bitrate:128,sampleSize:16}},Kr=Xr.STANDARD,Qr={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},Jr=Qr["720p"];var Zr,$r,Yr,en,tn,rn,nn,an,on,sn,cn,dn,un,ln,An,hn;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(Zr||(Zr={})),function(e){e.IDLE="IDLE",e.PlAYING="PlAYING",e.MIXING="MIXING",e.PAUSED="PAUSED",e.STOPPED="STOPPED",e.COMPLETED="COMPLETED"}($r||($r={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(Yr||(Yr={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(en||(en={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(tn||(tn={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(rn||(rn={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(nn||(nn={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(an||(an={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(on||(on={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(sn||(sn={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(cn||(cn={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(dn||(dn={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(un||(un={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.STOPPED=1]="STOPPED",e[e.INVALID_TOKEN=2]="INVALID_TOKEN",e[e.NO_ROOM=3]="NO_ROOM",e[e.ROOM_CLOSED=4]="ROOM_CLOSED",e[e.PLAYER_EXISTED=5]="PLAYER_EXISTED"}(ln||(ln={})),function(e){e.NORMAL="NORMAL",e.GENERAL="GENERAL",e.SERVERE="SERVERE"}(An||(An={})),function(e){e.CORE="Core",e.API="API",e.AUDIO="Audio",e.VIDEO="Video",e.SIGNAL="Signal"}(hn||(hn={}));const fn="qnrtcqosevents";function pn(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Nr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Nr(JSON.stringify(t));e(r)})},500)})}function mn(e){const t=[];for(let r=0;r>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return new Uint8Array(t)}const gn=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Vr("qossubmit",!1),pn().then(e=>{this.deviceId=e,this.base.device_id=this.deviceId}).catch(()=>{this.deviceId="unknow",this.base.device_id=this.deviceId}),this.base={qos_version:"2.0",device_id:"",bundle_id:"",url:window.location.href,app_version:"",sdk_version:Hr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(ni)}setSessionId(e){for(let t=this.events.length-1;t>=0;t-=1){const r=this.events[t];if(r.session_id)break;r.session_id=e}this.sessionId=e}setUserBase(e,t,r){this.userBase={user_id:e,room_name:t,app_id:r};for(let e=this.events.length-1;e>=0;e-=1){const t=this.events[e];if(t.user_base)break;t.user_base=this.userBase}}addEvent(e,r,n){const i=t({timestamp:Date.now(),event_id:F[e],event_name:e},r);this.submitQueue.push("add",i).catch(ni),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(ni)}initSubmitQueue(){this.submitQueue.on("exec",(e,t)=>{switch(e.method){case"submit":return void(t.promise=this._submit(e.data));case"add":return void(t.promise=this._addEvent(e.data));case"resume":return void(t.promise=this._recoverStoredEvents())}})}async _recoverStoredEvents(){const e=await V.getItem(fn);jr.log("get item",e),await V.removeItem(fn),e&&(this.events=JSON.parse(window.atob(decodeURIComponent(e))),this.events=this.events.filter(e=>!!e.session_id&&!!e.user_base).sort((e,t)=>e.event.timestamp-t.event.timestamp))}_addEvent(e){return this.events.push({user_base:this.userBase,event:e,session_id:this.sessionId}),this.submit(),Promise.resolve()}saveEvents(){const e=encodeURIComponent(window.btoa(JSON.stringify(this.events)));V.setItem(fn,e).catch(ni)}submitCheck(){return!!(this.sessionId&&this.deviceId&&this.userBase)&&(Date.now()-this.lastSubmitTime>3e5||this.events.length>=30)}async _submit(e=!1){if(e||this.submitCheck())try{const e=this.encodeQosSubmitData();for(const t of e)if(!(await fetch("https://pili-rtc-qos.qiniuapi.com/v1/rtcevent",{method:"POST",headers:{"Content-Type":"application/x-gzip"},body:t.buffer})).ok)throw kn("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await V.removeItem(fn)}catch(e){jr.log(e)}else this.saveEvents()}encodeQosSubmitData(){const e=Gr(this.events,e=>e.session_id||""+JSON.stringify(e.user_base)),t=[];for(const r in e){const n=e[r];if(0===n.length)continue;const i={session_id:n[0].session_id,user_base:n[0].user_base,base:this.base,items:n.map(e=>e.event)};jr.log("encode",i);const a=new Uint8Array(Lr.gzip(mn(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function vn(e,t){let r;switch(e){case"prompt":r=O.prompt;break;case"granted":r=O.granted;break;case"denied":r=O.denied;break;default:return}let n=An.NORMAL;(r===O.prompt||O.denied)&&(n=An.SERVERE),gn.addEvent("AuthorizationStatus",{type:t,status:r,event_grade:n,event_category:hn.CORE})}function Tn(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{vn(e.state,D[t]),e.onchange=(()=>{vn(e.state,D[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Tn("camera"),Tn("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{gn.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2,event_grade:An.GENERAL,event_category:hn.CORE})});const bn=(()=>{let e=x.INVALID,t="unknow";const r=e=>{let t;switch(e){case"cellular":t=0;break;case"wifi":t=1;break;case"ethernet":t=2;break;default:t=-1}return t},n=()=>{gn.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e,event_grade:An.GENERAL,event_category:hn.CORE})},i=navigator,a=i.connection||i.mozConnection||i.webkitConnection;return a&&a.type&&(t=a.type,a.onchange=(()=>{t!==a.type&&(t=a.type,n())})),n(),t=>{t!==e&&(e=t,n())}})();class Sn extends Error{constructor(e,t){super(t),this.code=e,this.error=t,gn.addEvent("SDKError",{error_code:e,error_msg:t})}}const yn=e=>new Sn(10053,`invalid parameters: ${e}`),kn=e=>new Sn(21005,`piliRTC: unexpected error ${e}`),_n=e=>new Sn(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),wn=e=>new Sn(21006,`not support! ${e}`),En=e=>new Sn(21007,`track play is not allowed: ${e}`),Cn=e=>new Sn(23003,`plugin not avaliable! ${e}`),Mn=e=>new Sn(23004,`NotAllowedError: no permission to access media device. ${e}`),Pn=e=>new Sn(22011,`can not decode audio data, ${e.toString()}`),In=()=>new Sn(23005,"no audio track when createScreenVideoTrack withAudio enable"),Rn=e=>new Sn(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),Dn=e=>new Sn(24e3,`relay error, can not get relayToken. Error: ${e}`),On=e=>new Sn(24001,`invalid client mode, ${e}`),xn=e=>new Sn(24002,`invalid client role, ${e}`),Bn=()=>kn("websocket abort"),Ln=e=>yn(`can not set merge layout stream, no merge job id ${e}`),Nn=()=>Mn("can not sharing screen/window on chrome"),Gn=()=>kn("subscribe/publish operation is aborted"),Hn=()=>yn("cannot found preset"),Fn=()=>new Sn(22003,"mix source error"),jn=()=>new Sn(22002,"mixed source does not find a valid track"),Vn=()=>new Sn(22001,"effectID already exists, cannot create QNAudioEffect"),Un=()=>new Sn(22004,"effectID is not exists, pleast createAudioEffect firstt"),qn=(e,t)=>new Sn(e,`publish error, signaling code: ${e}, msg: ${t}`),Wn=(e,t)=>new Sn(e,`create merge job error, signaling code: ${e}, msg: ${t}`),zn=(e,t)=>new Sn(e,`create forward job error, signaling code: ${e}, msg: ${t}`),Xn=(e,t)=>new Sn(e,`media format not support, ${t}`),Kn=(e,t)=>new Sn(e,`subscribe error, signaling code: ${e}, msg: ${t}`),Qn=(e,t)=>new Sn(e,`send control error, code: ${e}, msg: ${t}`),Jn=(e,t)=>new Sn(e,t),Zn=()=>new Sn(10052,"server unavailable");class $n extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,$n):this.stack=new Error(e).stack}}var Yn=Object.freeze({QNRTCError:Sn,ERROR_INVALID_PARAMETER:yn,ERROR_FATAL:kn,ERROR_AUTH_FAILED:_n,ERROR_RECONNECT_FAILED:e=>new Sn(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:wn,ERROR_PLAY_NOT_ALLOWED:En,ERROR_PLUGIN_NOT_AVAILABLE:Cn,ERROR_DEVICE_NOT_ALLOWED:Mn,ERROR_AUDIO_DECODE_ERROR:Pn,CREATE_SCREEN_AUDIO_ERROR:In,ERROR_ELECTRON_REQUIRE_ERROR:Rn,ERROR_RELAY_TOKEN:Dn,ERROR_INVALID_CLIENT_MODE:On,ERROR_INVALID_CLIENT_ROLE:xn,WS_ABORT:Bn,NO_MERGE_JOB:Ln,SCREEN_PERMISSION_DENIED:Nn,SUB_PUB_ABORT:Gn,PRESET_NOT_FOUND:Hn,ERROR_AUDIO_MIXING_IO_EXCEPTION:Fn,ERROR_AUDIO_MIXING_AUDIO_NOT_FOUND:jn,ERROR_EFFECT_ID_IS_EXIST:Vn,ERROR_EFFECT_ID_IS_NOT_EXIST:Un,PUBLISH_ERROR:qn,CREATE_MERGE_JOB_ERROR:Wn,CREATE_FORWARD_JOB_ERROR:zn,UNSUPPORT_FMT:Xn,JOIN_ROOM_ERROR:(e,t)=>new Sn(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Kn,UNPUBLISH_ERROR:(e,t)=>new Sn(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Sn(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:Qn,SERVER_ERROR:Jn,SERVER_UNAVAILABLE:Zn,InvalidStateError:$n});function ei(e){const t=e.split(".")[1];if(!t)throw new Error("parse jwt error, can not find payload string.");const r=atob(t);return JSON.parse(r)}function ti(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw kn(`can not parse roomToken, ${e}`)}}function ri(e,t,r){if(!r)return null;for(let n=0;n=4)return e;for(const r in e)void 0===e[r]&&delete e[r],e[r]instanceof File||e[r]instanceof ArrayBuffer||"object"==typeof e[r]&&(e[r]=ii(e[r],t+1));return e}function ai(e){Promise.resolve().then(e)}function oi(e){return("0"+e.toString(16)).substr(-2)}function si(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,oi).join("")}function ci(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const di={};function ui(e,t){if(!di[t])return di[t]=!0,e()}function li(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Ai(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>{r.abort(),n({networkCode:-1,message:"请求超时"})},t),i=fetch(e,{signal:r.signal})}else i=fetch(e);i.then(e=>(function(e,t,r){e>=400&&r({retry:!1,message:t}),200!==e&&r({retry:!0,message:t})}(e.status,e.statusText,n),e.json())).then(r).catch(n)})}async function hi(e){const t=e.match(/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/);if(e.match(/^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$/)||t)return e;try{const t=await fetch(`https://${e}/ip`);return(await t.json()).ip}catch(t){return jr.warning("resolve ice failed, retry",t),await ci(1e3),await hi(e)}}var fi,pi=u(function(e){!function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){if(!s&&d)return d();if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=r[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,r,n)}return r[o].exports}for(var a=d,o=0;o0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},r=n.log,d=n.detectBrowser(e),u={browserDetails:d,commonShim:c,extractVersion:n.extractVersion,disableLog:n.disableLog,disableWarnings:n.disableWarnings};switch(d.browser){case"chrome":if(!i||!i.shimPeerConnection||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;if(null===d.version)return r("Chrome shim can not determine version, not shimming."),u;r("adapter.js shimming chrome."),u.browserShim=i,c.shimAddIceCandidateNullOrEmpty(e,d),i.shimGetUserMedia(e,d),i.shimMediaStream(e,d),i.shimPeerConnection(e,d),i.shimOnTrack(e,d),i.shimAddTrackRemoveTrack(e,d),i.shimGetSendersWithDtmf(e,d),i.shimGetStats(e,d),i.shimSenderReceiverGetStats(e,d),i.fixNegotiationNeeded(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;case"firefox":if(!o||!o.shimPeerConnection||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=o,c.shimAddIceCandidateNullOrEmpty(e,d),o.shimGetUserMedia(e,d),o.shimPeerConnection(e,d),o.shimOnTrack(e,d),o.shimRemoveStream(e,d),o.shimSenderGetStats(e,d),o.shimReceiverGetStats(e,d),o.shimRTCDataChannel(e,d),o.shimAddTransceiver(e,d),o.shimGetParameters(e,d),o.shimCreateOffer(e,d),o.shimCreateAnswer(e,d),c.shimRTCIceCandidate(e,d),c.shimConnectionState(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"edge":if(!a||!a.shimPeerConnection||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=a,a.shimGetUserMedia(e,d),a.shimGetDisplayMedia(e,d),a.shimPeerConnection(e,d),a.shimReplaceTrack(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d);break;case"safari":if(!s||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=s,c.shimAddIceCandidateNullOrEmpty(e,d),s.shimRTCIceServerUrls(e,d),s.shimCreateOfferLegacy(e,d),s.shimCallbacksAPI(e,d),s.shimLocalStreamsAPI(e,d),s.shimRemoteStreamsAPI(e,d),s.shimTrackEventTransceiver(e,d),s.shimGetUserMedia(e,d),s.shimAudioContext(e,d),c.shimRTCIceCandidate(e,d),c.shimMaxMessageSize(e,d),c.shimSendThrowTypeError(e,d),c.removeExtmapAllowMixed(e,d);break;default:r("Unsupported browser!")}return u};var n=d(e("./utils")),i=d(e("./chrome/chrome_shim")),a=d(e("./edge/edge_shim")),o=d(e("./firefox/firefox_shim")),s=d(e("./safari/safari_shim")),c=d(e("./common_shim"));function d(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":12,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11}],3:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},r.shimOnTrack=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||"ontrack"in e.RTCPeerConnection.prototype)o.wrapPeerConnectionEvent(e,"track",function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e});else{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 t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.track.id}):{track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}),t.stream.getTracks().forEach(function(n){var i=void 0;i=e.RTCPeerConnection.prototype.getReceivers?r.getReceivers().find(function(e){return e.track&&e.track.id===n.id}):{track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}},r.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):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 r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach(function(e){r._senders.push(t(r,e))})};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach(function(e){var r=t._senders.find(function(t){return t.track===e});r&&t._senders.splice(t._senders.indexOf(r),1)})}}else if("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t},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}})}},r.shimGetStats=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Array.prototype.slice.call(arguments),n=r[0],i=r[1],a=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var o=function(e){var t={},r=e.result();return r.forEach(function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){r[t]=e.stat(t)}),t[r.id]=r}),t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){return t.apply(this,[function(e){i(s(o(e)))},n])}return new Promise(function(r,n){t.apply(e,[function(e){r(s(o(e)))},n])}).then(i,a)}},r.shimSenderReceiverGetStats=function(e){if(!("object"===(void 0===e?"undefined":n(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then(function(t){return o.filterStats(t,e.track,!0)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(this,[]);return t.forEach(function(t){return t._pc=e}),t}),o.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(t){return o.filterStats(t,e.track,!1)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype))return;var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],r=void 0,n=void 0,i=void 0;return this.getSenders().forEach(function(e){e.track===t&&(r?i=!0:r=e)}),this.getReceivers().forEach(function(e){return e.track===t&&(n?i=!0:n=e),e.track===t}),i||r&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}},r.shimAddTrackRemoveTrackWithNative=c,r.shimAddTrackRemoveTrack=function(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return c(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map(function(t){return e._reverseStreams[t.id]})};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(function(e){var t=r.getSenders().find(function(t){return t.track===e});if(t)throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;function a(e,t){var r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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(t,r){var n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(function(e){return e===t}))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var a=this.getSenders().find(function(e){return e.track===t});if(a)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var o=this._streams[r.id];if(o)o.addTrack(t),Promise.resolve().then(function(){n.dispatchEvent(new Event("negotiationneeded"))});else{var s=new e.MediaStream([t]);this._streams[r.id]=s,this._reverseStreams[s.id]=r,this.addStream(s)}return this.getSenders().find(function(e){return e.track===t})},["createOffer","createAnswer"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=a(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then(function(t){return a(e,t)})});e.RTCPeerConnection.prototype[t]=n[t]});var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=(e=this,t=arguments[0],r=t.sdp,Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:r})),o.apply(this,arguments)):o.apply(this,arguments);var e,t,r};var d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=d.get.apply(this);return""===e.type?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=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");var r=e._pc===this;if(!r)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var n=void 0;Object.keys(this._streams).forEach(function(r){var i=t._streams[r].getTracks().find(function(t){return e.track===t});i&&(n=t._streams[r])}),n&&(1===n.getTracks().length?this.removeStream(this._reverseStreams[n.id]):n.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}},r.shimPeerConnection=function(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection);if(!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=s({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})},r.fixNegotiationNeeded=function(e,t){o.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js"));function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(t){return e._shimmedLocalStreams[t][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(function(e){if(t.getSenders().find(function(t){return t.track===e}))throw new DOMException("Track already exists.","InvalidAccessError")});var n=this.getSenders();r.apply(this,arguments);var i=this.getSenders().filter(function(e){return-1===n.indexOf(e)});this._shimmedLocalStreams[e.id]=[e].concat(i)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(function(r){var n=t._shimmedLocalStreams[r].indexOf(e);-1!==n&&t._shimmedLocalStreams[r].splice(n,1),1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]}),i.apply(this,arguments)}}},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;if("function"!=typeof t)return void console.error("shimGetDisplayMedia: getSourceId argument is not a function");e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,a=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)})}}},{}],5:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator;if(!r.mediaDevices)return;var a=function(e){if("object"!==(void 0===e?"undefined":n(e))||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var i="object"===n(e[r])?e[r]:{ideal:e[r]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);var a=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];var o={};"number"==typeof i.ideal?(o[a("min",r)]=i.ideal,t.optional.push(o),(o={})[a("max",r)]=i.ideal,t.optional.push(o)):(o[a("",r)]=i.ideal,t.optional.push(o))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[a("",r)]=i.exact):["min","max"].forEach(function(e){void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[a(e,r)]=i[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},o=function(e,o){if(t.version>=61)return o(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===n(e.audio)){var s=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),s(e.audio,"autoGainControl","googAutoGainControl"),s(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=a(e.audio)}if(e&&"object"===n(e.video)){var c=e.video.facingMode;c=c&&("object"===(void 0===c?"undefined":n(c))?c:{ideal:c});var d=t.version<66;if(c&&("user"===c.exact||"environment"===c.exact||"user"===c.ideal||"environment"===c.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||d)){delete e.video.facingMode;var u=void 0;if("environment"===c.exact||"environment"===c.ideal?u=["back","rear"]:"user"!==c.exact&&"user"!==c.ideal||(u=["front"]),u)return r.mediaDevices.enumerateDevices().then(function(t){var r=(t=t.filter(function(e){return"videoinput"===e.kind})).find(function(e){return u.some(function(t){return e.label.toLowerCase().includes(t)})});return!r&&t.length&&u.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=c.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=a(e.video),i("chrome: "+JSON.stringify(e)),o(e)})}e.video=a(e.video)}return i("chrome: "+JSON.stringify(e)),o(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(r.getUserMedia=function(e,t,n){o(e,function(e){r.webkitGetUserMedia(e,t,function(e){n&&n(s(e))})})}.bind(r),r.mediaDevices.getUserMedia){var c=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return o(e,function(e){return c(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(s(e))})})}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils.js")).log},{"../utils.js":11}],6:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimRTCIceCandidate=function(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":n(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 r=new t(e),i=o.default.parseCandidate(e.candidate),a=Object.assign(r,i);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,s.wrapPeerConnectionEvent(e,"icecandidate",function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t})},r.shimMaxMessageSize=function(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),n=e.sdpSemantics;"plan-b"===n&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;var t=o.default.splitSections(e.sdp);return t.shift(),t.some(function(e){var t=o.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){var i=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),a=function(e){var r=65536;"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637);return r}(i),s=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=o.default.matchPrefix(e.sdp,"a=max-message-size:");i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637);return n}(arguments[0],i),c=void 0;c=0===a&&0===s?Number.POSITIVE_INFINITY:0===a||0===s?Math.max(a,s):Math.min(a,s);var d={};Object.defineProperty(d,"maxMessageSize",{get:function(){return c}}),this._sctp=d}return r.apply(this,arguments)}},r.shimSendThrowTypeError=function(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=r.apply(this,arguments);return t(e,this),e},s.wrapPeerConnectionEvent(e,"datachannel",function(e){return t(e.channel,e.target),e})},r.shimConnectionState=function(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"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 r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})},r.removeExtmapAllowMixed=function(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var n=t.sdp.split("\n").filter(function(e){return"a=extmap-allow-mixed"!==e.trim()}).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return r.apply(this,arguments)}},r.shimAddIceCandidateNullOrEmpty=function(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;var r=e.RTCPeerConnection.prototype.addIceCandidate;if(!r||0===r.length)return;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}};var i,a=e("sdp"),o=(i=a)&&i.__esModule?i:{default:i},s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("./utils"))},{"./utils":11,sdp:13}],7:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=r.shimGetUserMedia=void 0;var n="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},i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimOnTrack=function(e){"object"===(void 0===e?"undefined":n(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}}})},r.shimPeerConnection=function(e,t){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection);t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t],n=function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r;return e}({},t,function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]});var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),n=e[0],a=e[1],o=e[2];return i.apply(this,[n||null]).then(function(e){if(t.version<53&&!a)try{e.forEach(function(e){e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach(function(t,n){e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(a,o)}},r.shimSenderGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.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)}},r.shimReceiverGetStats=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach(function(t){return t._pc=e}),r});o.wrapPeerConnectionEvent(e,"track",function(e){return e.receiver._pc=e.srcElement,e}),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}},r.shimRemoveStream=function(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype)return;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(r){r.track&&e.getTracks().includes(r.track)&&t.removeTrack(r)})}},r.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},r.shimAddTransceiver=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(function(e){if("rid"in e){if(!/^[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 n=t.apply(this,arguments);if(r){var i=n.sender,a=i.getParameters();"encodings"in a&&(1!==a.encodings.length||0!==Object.keys(a.encodings[0]).length)||(a.encodings=e.sendEncodings,i.sendEncodings=e.sendEncodings,this.setParametersPromises.push(i.setParameters(a).then(function(){delete i.sendEncodings}).catch(function(){delete i.sendEncodings})))}return n})},r.shimGetParameters=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCRtpSender)return;var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})},r.shimCreateOffer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}},r.shimCreateAnswer=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,r=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return t.apply(e,r)}).finally(function(){e.setParametersPromises=[]}):t.apply(this,arguments)}};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=function(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices)return;if(!e.navigator.mediaDevices)return;e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)}}},{}],9:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimGetUserMedia=function(e,t){var r=e&&e.navigator,a=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){i.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":n(e))&&"object"===n(e.audio)&&(e=JSON.parse(JSON.stringify(e)),o(e.audio,"autoGainControl","mozAutoGainControl"),o(e.audio,"noiseSuppression","mozNoiseSuppression")),s(e)},a&&a.prototype.getSettings){var c=a.prototype.getSettings;a.prototype.getSettings=function(){var e=c.apply(this,arguments);return o(e,"mozAutoGainControl","autoGainControl"),o(e,"mozNoiseSuppression","noiseSuppression"),e}}if(a&&a.prototype.applyConstraints){var d=a.prototype.applyConstraints;a.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":n(e))&&(e=JSON.parse(JSON.stringify(e)),o(e,"autoGainControl","mozAutoGainControl"),o(e,"noiseSuppression","mozNoiseSuppression")),d.apply(this,[e])}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(e("../utils"))},{"../utils":11}],10:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n="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};r.shimLocalStreamsAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;"getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams});if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(function(n){return t.call(r,n,e)}),e.getVideoTracks().forEach(function(n){return t.call(r,n,e)})},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=Array(n>1?n-1:0),a=1;a=0)){e._remoteStreams.push(t);var r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}})}),t.apply(e,arguments)}}},r.shimCallbacksAPI=function(e){if("object"!==(void 0===e?"undefined":n(e))||!e.RTCPeerConnection)return;var t=e.RTCPeerConnection.prototype,r=t.createOffer,i=t.createAnswer,a=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n};var c=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=c,c=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=c,c=function(e,t,r){var n=s.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=c},r.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(a(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))},r.shimConstraints=a,r.shimRTCIceServerUrls=function(e){if(!e.RTCPeerConnection)return;var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],a=0;a=r&&parseInt(n[r],10)}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function c(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach(function(n){n.endsWith("Id")?c(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach(function(t){c(e,e.get(t),r)})}))}},{}],12:[function(e,t,r){},{}],13:[function(e,t,r){var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},n.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},n.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),r},n.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},n.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},n.getCryptoParameters=function(e,t){return n.matchPrefix(e+t,"a=crypto:").map(n.parseCryptoLine)},n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0],i=n.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),i=3;i0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach(function(e){r+=n.writeExtmap(e)}),r},n.parseRtpEncodingParameters=function(e){var t,r=[],i=n.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,d=n.matchPrefix(e,"a=ssrc-group:FID").map(function(e){return e.substr(17).split(" ").map(function(e){return parseInt(e,10)})});d.length>0&&d[0].length>1&&d[0][0]===c&&(t=d[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),a&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},r.push(n))}}),0===r.length&&c&&r.push({ssrc:c});var u=n.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,r.forEach(function(e){e.maxBitrate=u})),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var a=n.matchPrefix(e,"a=rtcp-mux");return t.mux=a.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var i=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),i=n.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var a=n.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var o=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var i=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,i){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"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 o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,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:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a},n.getDirection=function(e,t){for(var r=n.splitLines(e),i=0;i-1}function U(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Me.prototype.set=function(e,t){var r=this.__data__,n=Oe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new Ce,map:new(fe||Me),string:new Ce}},Pe.prototype.delete=function(e){return Ue(this,e).delete(e)},Pe.prototype.get=function(e){return Ue(this,e).get(e)},Pe.prototype.has=function(e){return Ue(this,e).has(e)},Pe.prototype.set=function(e,t){return Ue(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,i),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.clear=function(){this.__data__=new Me},Re.prototype.delete=function(e){return this.__data__.delete(e)},Re.prototype.get=function(e){return this.__data__.get(e)},Re.prototype.has=function(e){return this.__data__.has(e)},Re.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Me){var i=n.__data__;if(!fe||i.lengthd))return!1;var l=s.get(e);if(l&&s.get(t))return l==t;var A=-1,h=!0,f=i&a?new Ie:void 0;for(s.set(e,t),s.set(t,e);++A-1&&e%1==0&&e-1&&e%1==0&&e<=d}function ot(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function st(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||st(e)&&oe.call(e)==k}var dt=j?function(e){return function(t){return e(t)}}(j):function(e){return st(e)&&at(e.length)&&!!O[oe.call(e)]};function ut(e){return nt(e)?De(e):He(e)}function lt(e){return e}e.exports=function(e,t){return e&&e.length?function(e,t,n){var i=-1,a=V,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=U;else if(o>=r){var u=t?null:je(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}var Si;!function(e){e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(Si||(Si={}));const{JOIN_ROOM_ERROR:yi,ERROR_RECONNECT_FAILED:ki}=Yn;class _i extends bi{constructor(e,t,r,n,i,a=["subscribe","publish"]){super(),this.privileges=[],this.rpcid=si(16),this.startInitTime=-1,this.startAuthTime=0,this.initWs=((e=!1,t,r)=>new Promise((n,i)=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN&&(this.ws.close(),this.ws.onclose=null),e)this.ws=t,this.setUrl(r);else{this.startInitTime=Date.now();try{this.wsConnectTimeoutID=setTimeout(()=>{this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close());const t=this.wsConnectTimeout/1e3+"s timeout";gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,socket_connect_error_message:t,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=Si.CONNECTING}catch(e){throw kn(`init signaling websocket faild!\nError: ${e}`)}}this.ws.onerror=this.onWsError,this.ws.onclose=this.onWsClose.bind(this,n,i);const a=()=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.emit("ws:onopen"),jr.log("signaling: websocket open",this.url),e||(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!0,event_grade:An.NORMAL,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:e?"connect":"reconnect"}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Hr,capsdp:this.capsdp,msgsn:this.customMsgNumber,supportdomain:!0,privileges:this.privileges};this.playerdata&&(t.playerdata=this.playerdata),this.startAuthTime=Date.now(),this.request("auth",t).then(t=>{switch(0!==t.code&&(gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:t.code,auth_error_message:t.error,auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.SERVERE,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.startAuthTime=0),t.code){case 0:this.ws.onclose=this.onWsClose.bind(this,null,null),this.reconnectToken=t.reconntoken,jr.log("signaling: websocket authed"),this._state=Si.OPEN,gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:0,auth_error_message:"",auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:r,auth_reason:e?"connect":"reconnect"}),this.emit("@signalingauth",t),this.startAuthTime=0,n(t);break;case 10001:case 10002:case 10011:case 10022:case 10012:case 10004:this.emit("@error",t),i(ki(t.error));break;case 10005:this.emit("@error",t),i(ki(t.error));case 10052:if(jr.debug("10052 auth, retry",e),this.reconnectToken=void 0,e){i(yi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(Xn(10054,t.error));break;default:i(kn(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=Si.CLOSED,this.release())})};this.ws.onopen=(()=>{a()}),e&&a()})),this.onWsMsg=(e=>{const t=e.data;this.emit("ws:onmessage",t);const r=t.indexOf("=");if(!(r>0))throw kn(`signaling model can not parse message: ${t}`);{const e=t.substring(0,r),n=JSON.parse(t.substring(r+1));this.receiveWsMsg(e,n)}}),this.onWsError=(e=>{this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),jr.warning("signaling: websocket error",e),this.emit("@ws:error",e),-1!==this.startInitTime&&(gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:this.url,socket_connect_time:Date.now()-this.startInitTime,socket_connect_success:!1,event_grade:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:""}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw Bn();const r=JSON.stringify(t);try{this.ws.send(`${e}=${r}`),this.emit("send",e,t)}catch(e){throw jr.warning("signaling: websocket send error",e),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)}),Bn()}}),this.handlePing=(()=>{this.sendWsMsg("pong",{}),this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.reconnectTimeoutID=setTimeout(()=>{jr.debug("signaling: websocket heartbeat timeout"),this.reconnect().catch(e=>{jr.warning("signaling: reconnect error",e)})},9e3)}),this.receiveWsMsg=((e,t)=>{switch(this.emit("receive",e,t),e){case"ping":this.handlePing();break;case"auth-res":this.emit("@auth-res",t);case"pubpc-res":case"subpc-res":case"pub-tracks":case"webrtc-candidate":case"on-player-in":case"on-player-out":case"disconnect":case"mute-tracks":case"on-add-tracks":case"on-remove-tracks":case"on-player-reconnect":case"on-player-reconnect-in":this.emit(e,t);break;case"sub-res":case"unsub-res":this.emit(e,t),this.emit(`${e}-${t.streamid}`,t);break;case"control-res":this.emit(e,t),this.emit(`${e}-${t.command}-${t.playerid}`,t);break;case"on-pubpc-connected":case"on-pubpc-disconnected":this.emit("on-pubpc-state",{pcid:t.pcid,connected:"on-pubpc-connected"===e}),this.emit(`${e}-${t.pcid}`,t);break;case"on-subpc-disconnected":case"on-subpc-connected":this.emit("on-subpc-state",{pcid:t.pcid,connected:"on-subpc-connected"===e}),this.emit(e,t);break;case"pub-tracks-res":this.emit(e,t);break;case"on-messages":case"on-qos-messages":t.messages=t.messages.sort((e,t)=>e.msgsn-t.msgsn),this.customMsgNumber=t.messages[t.messages.length-1].msgsn,this.emit(e,t);break;case"unpub-tracks-res":case"sub-tracks-res":case"unsub-tracks-res":case"on-pubpc-restart-notify":case"on-subpc-restart-notify":case"set-sub-profile-res":case"on-sub-profile-changed":case"pubpc-restart-res":case"subpc-restart-res":case"create-merge-job-res":case"create-forward-job-res":case"stop-forward-res":case"on-job-connected":case"on-job-disconnected":case"on-merge-job-connected":case"on-merge-job-disconnected":case"update-merge-tracks-res":case"set-privileges-res":case"start-media-relay-res":case"update-media-relay-res":case"stop-media-relay-res":case"on-media-relay-state":this.emit(e,t)}}),this.accessToken=e,this.capsdp=t,this.reconnectTimes=r,this.wsConnectTimeout=n,this.playerdata=i,this.privileges=a,this._state=Si.CONNECTING}set _state(e){this.emit("@ws-state-change",this.__state,e),this.__state=e}get state(){return this.__state}set reconnectTimes(e){this._reconnectTimes=e,this.currentLeftReconnectTimes=e}get reconnectTimes(){return this._reconnectTimes}setUrl(e){this.url=e+`?rpcid=${this.rpcid}`}onWsClose(e,t,r){this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this._state=Si.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&gn.addEvent("SignalAuth",{auth_start_time:this.startAuthTime,auth_dns_time:0,auth_server_ip:this.url,auth_error_code:r.code,auth_error_message:r.toString(),auth_take_time:Date.now()-this.startAuthTime,access_token:this.accessToken,event_grade:An.NORMAL,event_category:hn.CORE,auth_server_info:this.url,auth_reason:"connect"});let n=this.reconnectPromise;switch(r.code){case 1e3:this.emit("@closed");break;case 1001:case 1005:case 1006:n=this.reconnect();break;case 1007:case 1008:case 1009:case 1010:break;case 1011:n=this.reconnect();break;case 1012:n=this.reconnect(5e3);break;case 1013:n=this.reconnect();break;case 1014:n=this.reconnect(5e3)}e&&t&&(n?n.then(e).catch(e=>{jr.warning("signaling: reconnect error",e)}):t(r))}sendDisconnect(){if(this.state===Si.OPEN)try{this.sendWsMsg("disconnect",{})}catch(e){}}reconnect(e=1e3){return this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.reconnectPromise&&this._state===Si.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=Si.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=ci(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=Si.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=si(8);return t.rpcid=r,jr.log("ws request",r,e,t),this.sendWsMsg(e,t),new Promise(t=>{const n=i=>{i.rpcid===r&&(jr.log("ws response",r,e,i),this.off(`${e}-res`,n),t(i))};this.on(`${e}-res`,n)})}release(){this.reconnectTimeoutID&&clearTimeout(this.reconnectTimeoutID),this.wsConnectTimeoutID&&clearTimeout(this.wsConnectTimeoutID),this.removeEvent(),this.ws&&(this.ws.onopen=null,this.ws.onclose=null,this.ws.onerror=null,this.ws.close())}}class wi{}class Ei{constructor(e,t,r,n){this.videoTrackInfo=[],this.audioTrackInfo=[],this.layoutLevel=0,this.width=e,this.height=t,this.jobID=n,this.controller=r,this.controller.getCurrentTracks().forEach(e=>{"audio"===e.kind?this.audioTrackInfo.push(e):this.videoTrackInfo.push(e)}),this.controller.addMergeTrack(this.audioTrackInfo.map(e=>({trackID:e.trackID})),this.jobID),this.initLayout(),this.controller.onAddTracks=(e=>{const t=e.filter(e=>"audio"===e.kind),r=e.filter(e=>"video"===e.kind);this.controller.addMergeTrack(t.map(e=>({trackID:e.trackID})),this.jobID),r.forEach(this.handleAddVideoTrack.bind(this))}),this.controller.onRemoveTracks=(e=>{e.filter(e=>"video"===e.kind).forEach(this.handleRemoveVideoTrack.bind(this))}),jr.log("init default merger, init layout: ",this.layout)}initLayout(){const e=this.videoTrackInfo.length;this.layoutLevel=0,this.layout={"level-0":{items:{"item-0":{x:0,y:0,isExpand:!1,isExpanded:!1,index:0}},itemWidth:this.width,itemHeight:this.height,maxItems:1,currentItems:0,splitWidthFlag:this.width=this.height;if(0!==e){for(;Math.pow(2,this.layoutLevel)=this.height?a:0,y:this.width{const n=this.layout[`level-${this.layoutLevel-1}`].items[r],i=2*n.index;t[`item-${i}`]={x:n.x,y:n.y,isExpand:!1,isExpanded:!1,index:i},t[`item-${i+1}`]=e?{x:n.x+a,y:n.y,isExpand:!1,isExpanded:!1,index:i+1}:{x:n.x,y:n.y+o,isExpand:!1,isExpanded:!1,index:i+1}})}jr.log(`merger: increase layout level, current level: ${this.layoutLevel}`,this.layout)}setLevelLayoutStream(){const e=this.videoTrackInfo.length,t=this.layout[`level-${this.layoutLevel}`];let r=t.maxItems-e,n=0;for(let e=0;e0?e%2==0?(t.items[`item-${e}`].isExpand=!0,t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1):(t.items[`item-${e}`].isExpanded=!0,r-=1):(t.items[`item-${e}`].trackID=this.videoTrackInfo[n].trackID,this.sendMergeOpt(this.layoutLevel,e),n+=1);t.currentItems=e}sendMergeOpt(e,t){const r=this.layout[`level-${e}`],n=r.items[`item-${t}`];if(!n.trackID||n.isExpanded)return;let i=r.itemWidth,a=r.itemHeight;n.isExpand&&(r.splitWidthFlag?i*=2:a*=2);const o={x:n.x,y:n.y,w:i,h:a,z:0,trackID:n.trackID};this.controller.addMergeTrack([o],this.jobID)}handleRemoveVideoTrack(e){M(this.videoTrackInfo,t=>t.trackID===e.trackID);const t=this.layout[`level-${this.layoutLevel}`];if(this.layoutLevel>0&&this.videoTrackInfo.length<=this.layout[`level-${this.layoutLevel-1}`].maxItems)this.layoutLevel-=1,jr.log(`merger: reduce layout level, current level: ${this.layoutLevel}`,this.layout),this.setLevelLayoutStream();else for(const r in t.items){const n=t.items[r];if(n.trackID===e.trackID){n.index%2==0?(t.items[`item-${n.index+1}`]?(n.isExpand=!0,n.trackID=t.items[`item-${n.index+1}`].trackID,t.items[`item-${n.index+1}`].isExpanded=!0,t.items[`item-${n.index+1}`].trackID=void 0):n.trackID=void 0,this.sendMergeOpt(this.layoutLevel,n.index)):(n.isExpanded=!0,n.trackID=void 0,t.items[`item-${n.index-1}`].isExpand=!0,this.sendMergeOpt(this.layoutLevel,n.index-1));break}}}handleAddVideoTrack(e){const t=this.videoTrackInfo.length;if(this.videoTrackInfo.push(e),this.videoTrackInfo=mi(this.videoTrackInfo,"trackID"),this.videoTrackInfo.length===t)return void jr.log("handle add video track ignore",e);const r=this.layout[`level-${this.layoutLevel}`];if(this.videoTrackInfo.length<=r.maxItems){for(const t in r.items){const n=r.items[t];if(!n.trackID){n.trackID=e.trackID,n.isExpanded&&(n.isExpanded=!1,r.items[`item-${n.index-1}`].isExpand=!1,this.sendMergeOpt(this.layoutLevel,n.index-1)),this.sendMergeOpt(this.layoutLevel,n.index);break}}r.currentItems=this.videoTrackInfo.length}else this.updateLayoutLevel(!r.splitWidthFlag),this.setLevelLayoutStream()}release(){this.controller.release()}}function Ci(e){const t=document.createElement("audio"),r=new MediaStream([e]);return t.style.visibility="hidden",t.className="qnrtc-audio-player qnrtc-stream-player",t.dataset.localid=e.id,t.srcObject=r,t.autoplay=!0,{element:t,stream:r}}function Mi(e){const t=document.createElement("video"),r=new MediaStream([e]);return t.style.width="100%",t.style.height="100%",t.style.objectFit="contain",t.muted=!0,t.className="qnrtc-video-player qnrtc-stream-player",t.dataset.localid=e.id,t.setAttribute("playsinline",!0),t.autoplay=!0,t.srcObject=r,T&&(t.setAttribute("controls",!0),ai(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),{element:t,stream:r}}const Pi=window.AudioContext||window.webkitAudioContext||window.Object,Ii=E.audioContextOptions?new Pi({latencyHint:"interactive"}):new Pi;if(window.audioContext=Ii,window.Promise){const e=()=>{(function(e){return new Promise((t,r)=>{if("suspended"===e.state){jr.log("audio context state is suspended");const n=()=>{e.resume().then(()=>{document.body.removeEventListener("touchstart",n),document.body.removeEventListener("touchend",n),document.body.removeEventListener("mousedown",n),document.body.removeEventListener("mouseup",n),t(!0)}).catch(r)};document.body.addEventListener("touchstart",n,!0),document.body.addEventListener("touchend",n,!0),document.body.addEventListener("mousedown",n,!0),document.body.addEventListener("mouseup",n,!0),n()}else t(!1)})})(Ii).then(e=>{jr.debug("web audio context unlocked",e)}).catch(e=>{jr.warning("can not unlock web audio context",e)}),window.removeEventListener("load",e)};document.body?e():window.addEventListener("load",e),Ii.onstatechange=(()=>{e()})}const Ri=2048,Di=4096,Oi=["play","playing","pause","ended","waiting","seeking"];class xi extends bi{constructor(){super(),this.audioSource=null,this._audioSourceState=H.IDLE,this.bufferSourceDuration={startTime:0,pauseTime:0,lastPauseTime:0,offsetTime:0,stopTime:0},this.handleMediaElementEvents=(e=>{switch(e.type){case"playing":case"play":this.audioSourceState=H.PLAY;break;case"waiting":case"seeking":this.audioSourceState=H.LOADING;break;case"ended":this.audioSourceElement&&(this.audioSourceElement.currentTime=0),this.audioSourceState=H.END}})}get audioSourceState(){return this._audioSourceState}set audioSourceState(e){e!==this._audioSourceState&&(this.emit("@audio-source-state-change",e,this._audioSourceState),this._audioSourceState=e)}initAudioContext(){jr.log("init audio context",Ii.state),"suspended"===Ii.state&&(jr.log("audio context suspended"),Ii.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",Ii.state),this.analyserNode=Ii.createAnalyser(),this.analyserNode.fftSize=Ri,this.gainNode=Ii.createGain(),function(e){if(E.disconnectAudioNode)return;const t=e.connect,r=e.disconnect;e.connect=((r,n,i)=>(e._inputNodes||(e._inputNodes=[]),r instanceof AudioNode?(e._inputNodes.push(r),e._inputNodes=mi(e._inputNodes,e=>e),t.call(e,r,n,i)):t.call(e,r,n),e)),e.disconnect=((t,n,i)=>{if(!t)return r.call(e),void(e._inputNodes=[]);r.call(e,t,n,i),M(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),E.mediaStreamDest&&(this.audioStream=Ii.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=Ii.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=Ii.createBufferSource(),this.audioSource.onended=(()=>{this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Ii.currentTime,this.audioSourceState=H.END}),this.connect()}setMediaElementSource(e){this.audioSource=Ii.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Oi)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.isAudioSource()?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.isAudioSource()&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.isAudioSource()){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Ii.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(li)):null===this.audioSource&&this.audioSourceBuffer&&(this.resetBufferSourceDuration(),this.setAudioBufferSource(),this.setAudioBuffer(this.audioSourceBuffer),this.setAudioSourceLoop(!!this.audioSourceLoop),this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Ii.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=H.PLAY)}resumeAudioSource(){if(this.isAudioSource()){if(this.audioSourceState!==H.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=Ii.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=H.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(li)}pauseAudioSource(){this.isAudioSource()?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=Ii.currentTime),this.audioSourceState=H.PAUSE):this.audioSourceElement&&(this.audioSourceElement.pause(),this.audioSourceState!==H.END&&(this.audioSourceState=H.PAUSE))}stopAudioSource(e=!1,t=!1){this.isAudioSource()?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Ii.currentTime,e||!1!==t||(this.audioSourceState=H.STOP)):this.audioSourceElement&&(!1===t&&(this.audioSourceState=H.STOP),this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.isAudioSource()){let e=Ii.currentTime;const t=this.getAudioSourceDuration();this.bufferSourceDuration.lastPauseTime&&(e=this.bufferSourceDuration.lastPauseTime),this.bufferSourceDuration.stopTime&&(e=this.bufferSourceDuration.stopTime);const r=this.bufferSourceDuration.offsetTime+e-this.bufferSourceDuration.startTime-this.bufferSourceDuration.pauseTime;return Math.max(0,r%t)}return 0}setAudioSourceCurrentTime(e){this.audioSourceElement?this.audioSourceElement.currentTime=e:this.isAudioSource()&&(this.stopAudioSource(!0),this.playAudioSource(e))}getAudioSourceDuration(){return this.audioSourceElement?this.audioSourceElement.duration:this.audioSourceBuffer?this.audioSourceBuffer.duration:0}release(){if(this.audioSource&&this.audioSource.disconnect(),this.gainNode.disconnect(),this.audioSourceElement){for(const e of Oi)this.audioSourceElement.removeEventListener(e,this.handleMediaElementEvents);this.audioSourceElement.src="",this.audioSourceElement.load(),this.audioSourceElement.remove(),this.audioSourceElement=void 0}this.scriptNode&&this.scriptNode.disconnect()}connect(){this.audioSource?(this.audioSource.connect(this.analyserNode),this.audioSource.connect(this.gainNode),this.audioStream&&(this.gainNode.connect(this.audioStream),this.onAudioBuffer())):jr.warning("no audio source, can not connect")}handleAudioBuffer(e){const t=e.inputBuffer;this.emit("audioBuffer",t),this.audioBufferCallback&&this.audioBufferCallback(t)}onAudioBuffer(e,t=Di){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=Ii.createScriptProcessor(t),this.audioSource.connect(this.scriptNode),this.scriptNode.connect(this.audioStream),this.scriptNode.onaudioprocess=this.handleAudioBuffer.bind(this)))}resetBufferSourceDuration(){this.bufferSourceDuration={offsetTime:0,startTime:0,lastPauseTime:0,pauseTime:0,stopTime:0}}isAudioSource(){const{audioSource:e}=this;return e instanceof AudioBufferSourceNode||e instanceof AudioScheduledSourceNode}}class Bi{constructor(e,t){this.streamSourceNode=Ii.createMediaStreamSource(e),this.gainNode=Ii.createGain(),this.mediaElement=t,this.mediaElement.volume=0,this.mediaElement.addEventListener("pause",()=>{this.release()}),this.mediaElement.addEventListener("play",()=>{this.connect()}),this.connect()}release(){this.gainNode.disconnect(),this.streamSourceNode.disconnect()}connect(){this.streamSourceNode.connect(this.gainNode).connect(Ii.destination)}setVolume(e){this.gainNode.gain.value=e}}class Li extends bi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=L.NORMAL,this.onended=(async e=>{"local"===this.direction?(jr.warning("track ended",this.mediaTrack,this.info.trackID),this.info.trackID&&this._selfEndedCallback&&await this._selfEndedCallback([this.info.trackID]),this.emit("ended",e),gn.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label,event_grade:An.SERVERE}),this.release()):this.emit("@ended",e)}),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.userID=t,r&&(this.direction=r),this.info={kind:e.kind,muted:!e.enabled,userID:this.userID,versionid:0,profiles:n||[]},this.handleMediaPause=this.handleMediaPause.bind(this)}async setPlaybackDevice(e){if(E.setPlaybackDevice||wn("setPlaybackDevice api not support"),this.playbackDevice=e,this.mediaElement)return this.mediaElement.setSinkId(e)}play(e,t,r={mirror:!1}){return new Promise((n,i)=>{this.removeMediaElement();const a="video"===this.info.kind?Mi:Ci,{element:o,stream:s}=a(this.mediaTrack);this.mediaElement=o,"audio"===this.info.kind&&("remote"===this.direction&&(this.remoteAudioHelper=new Bi(s,o)),void 0!==t&&(this.mediaElement.muted=t)),r.mirror?this.mediaElement.style.transform="rotateY(180deg)":this.mediaElement.style.transform="",this.mediaElement.setAttribute("controls",!0),e.appendChild(this.mediaElement),this.mediaElement.onplaying=(()=>{this.mediaElement.onplaying=null,n()}),Promise.resolve().then(()=>{if(this.mediaElement.removeAttribute("controls"),this.playbackDevice)return this.setPlaybackDevice(this.playbackDevice)}).then(()=>{(function(e,t=3e3){const r=async()=>{if(e.paused)return e.play()};return new Promise((n,i)=>{const a=setTimeout(()=>{r().then(n).catch(i)},t);e.onloadedmetadata=(()=>{clearTimeout(a),r().then(n).catch(i)}),"WeixinJSBridge"in window?window.WeixinJSBridge.invoke("getNetworkType",{},()=>{r().then(n).catch(ni)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(ni)},!1)})})(this.mediaElement).then(n).catch(e=>{const t=e instanceof Error?e.name+", "+e.message:"play failed"+String(e);"NotAllowedError"===e.name?(i(En(t)),gn.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t,event_grade:An.SERVERE})):i(kn(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(li),900)}switchPlayingTrack(){if(this.mediaElement){if(this.isReplacedByImageTrack&&this.imageStreamTrack)this.mediaElement.srcObject=new MediaStream([this.imageStreamTrack.mediaTrack]);else{if(this.isReplacedByImageTrack||!this.mediaTrack)return;this.mediaElement.srcObject=new MediaStream([this.mediaTrack])}this.mediaElement.paused||this.mediaElement.play().catch(li)}}resume(e){if(this.mediaTrack.removeEventListener("ended",this.onended),this.mediaTrack.stop(),this.mediaTrack=e,this.mediaTrack.addEventListener("ended",this.onended),this.mediaElement){const t=new MediaStream([e]);this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t}this.removeEvent("@get-stats"),this.resetStats()}getStats(){return this.statsInterval||this.startGetStatsInterval(),this.stats}getCurrentFrameDataURL(){return this.mediaElement&&this.mediaElement instanceof HTMLVideoElement?function(e){const t=document.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight;const r=t.getContext("2d");return r?(r.drawImage(e,0,0,e.videoWidth,e.videoHeight),t.toDataURL()):"data:,"}(this.mediaElement):"data:,"}setMaster(e){this.master=e}setMute(e){this.info.muted=e,this.mediaTrack.enabled=!e,this.emit("mute",e)}setKbps(e){this.info.kbps=e}setInfo(e){this.info=t({},this.info,e)}removeMediaElement(){this.mediaElement&&(this.mediaElement.removeEventListener("pause",this.handleMediaPause),this.mediaElement.remove(),this.mediaElement=void 0)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),"local"!==this.direction&&E.unifiedPlan||this.mediaTrack.stop(),this.removeMediaElement(),this.imageStreamTrack&&(this.imageStreamTrack.release(),this.imageStreamTrack=void 0),this.remoteAudioHelper&&(this.remoteAudioHelper.release(),this.remoteAudioHelper=void 0)}reset(){this.info.trackID=void 0,this.info.userID=void 0,this.info.versionid=0,this.userID=void 0,this.resetStats()}resetStats(){this.stats=[],this.lastStats=[]}async startGetStatsInterval(){this.statsInterval=window.setInterval(async()=>{const e=this.getListeners("@get-stats");if(!e||0===e.length)return[];this.stats=await this.safeEmitAsPromise("@get-stats",this.lastStats),this.lastStats=[...this.stats]},1e3)}set selfEndedCallback(e){this._selfEndedCallback=e}setVolume(e){jr.warning("not implement")}getCurrentTimeDomainData(){return jr.warning("not implement"),new Uint8Array}getCurrentFrequencyData(){return jr.warning("not implement"),new Uint8Array}getVolume(){return jr.warning("not implement"),0}getCurrentVolumeLevel(){return jr.warning("not implement"),0}setLoop(e){jr.warning("not implement")}startAudioSource(){jr.warning("not implement")}pauseAudioSource(){jr.warning("not implement")}resumeAudioSource(){jr.warning("not implement")}stopAudioSource(){jr.warning("not implement")}getCurrentTime(){return jr.warning("not implement"),0}setCurrentTime(e){jr.warning("not implement")}getDuration(){return jr.warning("not implement"),0}}class Ni{static loadImage(e){if(e instanceof File)return Ni.loadImageFromFile(e);if(e instanceof ArrayBuffer)return Ni.loadImageFromArrayBuffer(e);if("string"==typeof e)return Ni.loadImageFromUrl(e);throw wn("unsupported image source")}static loadImageFromUrl(e){return new Promise((t,r)=>{var n=new Image;n.crossOrigin="Anonymous",n.src=e,n.onload=function(){t(n)},n.onerror=function(e){r(e)}})}static loadImageFromFile(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=(e=>{n.result&&t(Ni.loadImageFromUrl(n.result))}),n.onerror=(e=>{r(e)}),n.readAsDataURL(e)})}static loadImageFromArrayBuffer(e){return new Promise((t,r)=>{const n=new Blob([e]),i=URL.createObjectURL(n);t(Ni.loadImageFromUrl(i))})}}class Gi{constructor(){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d")}async setSource(e){e!==this.source&&(this.source=e,await this.createImageStreamTrack(e))}get id(){if(this.mediaTrack)return this.mediaTrack.id}async createImageStreamTrack(e){let t;t=e instanceof File?await Ni.loadImageFromFile(e):e instanceof ArrayBuffer?await Ni.loadImageFromArrayBuffer(e):await Ni.loadImageFromUrl(e),this.canvas.width=t.width,this.canvas.height=t.height,this.drawIntervalId&&clearInterval(this.drawIntervalId),this.drawIntervalId=setInterval(()=>{this.ctx.drawImage(t,0,0)},900);const r=this.canvas.captureStream(1);this.mediaTrack=r.getTracks()[0]}release(){this.drawIntervalId&&clearInterval(this.drawIntervalId)}}class Hi{constructor(){this.recordedChunks=[]}releaseMediaElement(){jr.log("Recorder release Media Element",this.mediaElement),this.mediaElement&&this.mediaElement.parentElement&&this.mediaElement.parentElement.removeChild(this.mediaElement)}release(){this.recorder&&"inactive"!==this.recorder.state&&this.recorder.stop(),this.recorder=void 0,this.recordedChunks=[],this.recordedBlob=void 0,this.recordedUrl&&(window.URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=void 0),this.releaseMediaElement()}setMimeType(e){if(jr.log("Recorder setMimeType, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");return!!window.MediaRecorder.isTypeSupported(e)&&(this.mimeType=e,!0)}start(e){if(jr.log("Recorder start, ",e),!("MediaRecorder"in window))throw wn("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw kn("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw kn("MediaRecorder is active, cannot start again.");if(e.reduce((e,t)=>("video"===t.mediaTrack.kind&&(e[0]+=1),"audio"===t.mediaTrack.kind&&(e[1]+=1),e),[0,0]).some(e=>e>1))throw kn("Invalid parameters.");this.release();try{const t=new MediaStream(e.map(e=>e.mediaTrack)),r=window;if(this.mimeType){const e={mimeType:this.mimeType};this.recorder=new r.MediaRecorder(t,e)}else this.recorder=new r.MediaRecorder(t);this.recorder.ondataavailable=(e=>{jr.debug("Recorder data, ",e.data),this.recordedChunks.push(e.data)}),this.recorder.start(Hi.recorderTimeslice)}catch(e){throw kn("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw kn("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw kn("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw kn("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw kn("MediaRecorder is in inactive state, cannot do stop.");try{if(this.recorder.stop(),this.mimeType){const e={type:this.mimeType};this.recordedBlob=new Blob(this.recordedChunks,e)}else this.recordedBlob=new Blob(this.recordedChunks);return this.recordedUrl=window.URL.createObjectURL(this.recordedBlob),this.recordedBlob}catch(e){throw kn("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw kn("No recorded data, please start record first.");this.releaseMediaElement();const r=document.createElement("video");return r.style.width="100%",r.style.height="100%",r.style.objectFit="contain",r.controls=!0,r.muted=t,r.className="qnrtc-recorder-video-player",r.setAttribute("playsinline",!0),r.autoplay=!0,r.src=this.recordedUrl,e.appendChild(r),this.mediaElement=r,new Promise((e,t)=>{let n;try{n=r.play()}catch(e){t(e)}n?n.then(e).catch(e=>{t(e);try{throw kn("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw kn("No recorded data, please start record first.");const t=document.createElement("a");t.style.display="none",t.href=this.recordedUrl,t.download=e,document.body.appendChild(t),t.click(),setTimeout(()=>{document.body.removeChild(t)},100)}}Hi.recorderTimeslice=1e3;class Fi{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class ji{constructor(e,t,r,n,i){this._connectStatus=B.Idle,this.track=r,this.trackID=n,this.mid=i,this.transport=e,this.direction=t}get connectStatus(){return this._connectStatus}set connectStatus(e){if(e!==this._connectStatus){const t=this._connectStatus;this._connectStatus=e,ai(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=B.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===B.Connect&&e(),n===B.Idle&&t()})})}appendConsumner(e,t){this.consumer=new Fi(this.trackID,this.mid,t,e),this.transport.appendConsumer(this.consumer)}setMute(e){this.track&&this.track.setMute(e)}addTrackId(e){this.track&&(this.trackID=e,this.track.setInfo({trackID:e}))}release(){this.consumer&&this.transport?(this.transport.recvHandler.isPcReady&&this.transport.removeConsumers([this.consumer]),this.track&&this.track.release()):this.track&&this.track.reset()}}const Vi=0;class Ui extends Li{constructor(e,t,r){if("audio"!==e.kind)throw new Error("audio track only!");super(e,t,r),this.mediaStream=new MediaStream,this.mediaStream.addTrack(e)}resume(e){this.mediaTrack=e,this.removeEvent("@get-stats"),this.resetStats();const t=new MediaStream([e]);this.mediaStream=t,this.mediaElement&&(this.mediaElement.dataset.localid=e.id,this.mediaElement.srcObject=t),this.audioManager&&(this.audioManager.release(),this.initAudioManager())}initAudioManager(e){this.audioManager=new xi,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&E.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){e<0||e>100?jr.warning(`available volume value is between 0 to 100 , current ${e} is unavailable`):"local"!=this.direction?this.remoteAudioHelper.setVolume(e):this.audioManager.gainNode.gain.setValueAtTime(e,Ii.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Ri);return this.audioManager.analyserNode.getByteTimeDomainData(e),e}getCurrentFrequencyData(){const e=new Uint8Array(this.audioManager.analyserNode.frequencyBinCount);return this.audioManager.analyserNode.getByteFrequencyData(e),e}getVolume(){return this.audioManager.gainNode.gain.value}getCurrentVolumeLevel(){const e=this.getCurrentFrequencyData();let t=0,r=e.length;return e.forEach((n,i)=>{const a=i*(Ii.sampleRate||44100)/e.length;if(a>22050)return void(r-=1);const o=function(e){const t=e*e;return 1.2588966*14884e4*t*t/((t+424.36)*Math.sqrt((t+11599.29)*(t+544496.41))*(t+14884e4))}(a)*n/255;o<=Vi?r-=1:t+=o*o}),0===r?0:Math.sqrt(t/r)}release(){this.emit("release"),this.removeEvent(),this.statsInterval&&window.clearInterval(this.statsInterval),this.audioManager&&this.audioManager.release(),this.removeMediaElement()}}var qi=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i};var Wi=function(e,t){if(null==e)return{};var r,n,i=qi(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i};const zi="\n";var Xi=u(function(e){var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%d trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach(function(e){t[e].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})})}),Ki=(Xi.v,Xi.o,Xi.s,Xi.i,Xi.u,Xi.e,Xi.p,Xi.z,Xi.r,Xi.t,Xi.c,Xi.b,Xi.m,Xi.a,u(function(e,t){var r=function(e){return String(Number(e))===e?Number(e):e},n=function(e,t,n){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var a=e.push?{}:i?t[e.name]:t;!function(e,t,n,i){if(i&&!n)t[i]=r(e[1]);else for(var a=0;a1&&(e[n[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],n=e.split(" ").map(r),i=0;i=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})}.apply(null,n)},Zi=["v","o","s","i","u","e","p","c","b","t","r","z","a"],$i=["i","c","b","a"],Yi={write:function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var r=t.outerOrder||Zi,n=t.innerOrder||$i,i=[];return r.forEach(function(t){Xi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ji(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ji(t,r,e))})})}),e.media.forEach(function(e){i.push(Ji("m",Xi.m[0],e)),n.forEach(function(t){Xi[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ji(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ji(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Ki.parse,parseParams:Ki.parseParams,parseFmtpConfig:Ki.parseFmtpConfig,parsePayloads:Ki.parsePayloads,parseRemoteCandidates:Ki.parseRemoteCandidates,parseImageAttributes:Ki.parseImageAttributes,parseSimulcastStreamList:Ki.parseSimulcastStreamList};const ea="qiniu-rtc-client";function ta(e){return e.map(e=>{const t={component:1,foundation:e.foundation,ip:e.ip,port:e.port,priority:e.priority,transport:e.protocol,type:e.type};return e.tcpType&&(t.tcptype=e.tcpType),t})}class ra{constructor(e,t){this.lastSubMids=[],this.sessionVersion=0,this.direction=e,this.extendedRtpCapabilities=t}get transportRemoteParameters(){return this._transportRemoteParameters}async setTransportRemoteParameters(e){for(const t of e.iceCandidates)t.ip=await hi(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");return E.unifiedPlan?function(e,t,r,n,i){const a=Yi.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:ea},o.name="-",o.timing={start:0,stop:0},o.icelite=t.iceParameters.iceLite?"ice-lite":void 0,o.msidSemantic={semantic:"WMS",token:"*"},o.media=[],o.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};for(const r of a.media){const a="inactive"===r.direction,s=r.type,c="audio"===s?e.codecs[0]:e.codecs[1],d=e.headerExtensions.filter(e=>e.kind===s),u={type:r.type,port:i&&i.has(String(r.mid))?0:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:r.mid,iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ta(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"sendonly"===r.direction||"sendrecv"===r.direction?"recvonly":"inactive",rtp:[{payload:c.sendPayloadType,codec:c.name,rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}],rtcpFb:[],fmtp:[{payload:c.sendPayloadType,config:Object.keys(c.parameters).map(e=>`${e}=${c.parameters[e]};`).join("")}],payloads:c.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:d.map(e=>({uri:e.uri,value:e.sendId}))};c.rtcpFeedback&&c.rtcpFeedback.length>0&&c.rtcpFeedback.forEach(e=>{u.rtcpFb.push({payload:c.sendPayloadType,type:e.type,subtype:e.parameter})}),c.sendRtxPayloadType&&(u.rtp.push({payload:c.sendRtxPayloadType,codec:"rtx",rate:c.clockRate,encoding:c.channels>1?c.channels:void 0}),u.fmtp.push({payload:c.sendRtxPayloadType,config:`apt=${c.sendPayloadType};`}),u.payloads=`${c.sendPayloadType} ${c.sendRtxPayloadType}`),ia(s,u,e,c);const l=n[u.mid];"video"===u.type&&l&&!a&&(u.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],u.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(u)}const s=(a.media||[]).filter(e=>e.hasOwnProperty("mid")&&0!==e.port).map(e=>String(e.mid));s.length>0&&(o.groups=[{type:"BUNDLE",mids:s.join(" ")}]);return Yi.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=Yi.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:ea},n.name="-",n.timing={start:0,stop:0},n.icelite=t.iceParameters.iceLite?"ice-lite":void 0,n.msidSemantic={semantic:"WMS",token:"*"},n.fingerprint={type:t.dtlsParameters.fingerprints[0].algorithm,hash:t.dtlsParameters.fingerprints[0].value};const i=[];for(const r of n.media){const n=r.type,a=e.codecs.find(e=>e.kind===n),o=(e.headerExtensions||[]).filter(e=>e.kind===n);if(!a)throw kn("can not find codec"+n);const s={type:n,mid:n,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},iceUfrag:t.iceParameters.usernameFragment,icePwd:t.iceParameters.password,candidates:ta(t.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===t.dtlsParameters.role?"actpass":"active",direction:"recvonly",rtp:[{payload:a.sendPayloadType,codec:a.name,rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}],rtcpFb:[],fmtp:[{payload:a.sendPayloadType,config:Object.keys(a.parameters).map(e=>`${e}=${a.parameters[e]};`).join("")}],payloads:a.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:o.map(e=>({uri:e.uri,value:e.sendId}))};a.rtcpFeedback&&a.rtcpFeedback.length>0&&a.rtcpFeedback.forEach(e=>{s.rtcpFb.push({payload:a.sendPayloadType,type:e.type,subtype:e.parameter})}),a.sendRtxPayloadType&&(s.rtp.push({payload:a.sendRtxPayloadType,codec:"rtx",rate:a.clockRate,encoding:a.channels>1?a.channels:void 0}),s.fmtp.push({payload:a.sendRtxPayloadType,config:`apt=${a.sendPayloadType};`}),s.payloads=`${a.sendPayloadType} ${a.sendRtxPayloadType}`),i.push(s)}return n.media=i,Yi.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw kn("no transportRemoteParameters!");if(E.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=M(e,e=>e.mid===n)[0];t&&r.push(t)}return r=r.concat(e),t=r.map(e=>e.mid),r}(e,this.lastSubMids);return this.lastSubMids=t.map(e=>e.mid),this.sessionVersion+=1,function(e,t,r,n){jr.debug("consumerInfos",e);const i={},a=e.map(e=>e.mid);i.version=0,i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:n,username:ea},i.name="-",i.timing={start:0,stop:0},i.icelite=r.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},a.length>0&&(i.groups=[{type:"BUNDLE",mids:a.join(" ")}]);i.media=[],i.fingerprint={type:r.dtlsParameters.fingerprints[0].algorithm,hash:r.dtlsParameters.fingerprints[0].value};for(const n of e){const e="audio"===n.kind?t.codecs[0]:t.codecs[1],a=t.headerExtensions.filter(e=>e.kind===n.kind),o={type:n.kind,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:n.mid,msid:`${n.streamId} ${n.trackID}`,iceUfrag:r.iceParameters.usernameFragment,icePwd:r.iceParameters.password,candidates:ta(r.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===r.dtlsParameters.role?"actpass":"active",direction:n.closed?"inactive":"sendonly",rtp:[{payload:e.recvPayloadType,codec:e.name,rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}],rtcpFb:[],fmtp:[{payload:e.recvPayloadType,config:Object.keys(e.parameters).map(t=>`${t}=${e.parameters[t]};`).join("")}],payloads:e.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:n.closed?[]:a.map(e=>({uri:e.uri,value:e.recvId})),ssrcs:!n.closed&&n.ssrc?[{id:n.ssrc,attribute:"cname",value:n.cname}]:[],ssrcGroups:[]};e.rtcpFeedback&&e.rtcpFeedback.length>0&&e.rtcpFeedback.forEach(t=>{o.rtcpFb.push({payload:e.recvPayloadType,type:t.type,subtype:t.parameter})}),e.recvRtxPayloadType&&(o.rtp.push({payload:e.recvRtxPayloadType,codec:"rtx",rate:e.clockRate,encoding:e.channels>1?e.channels:void 0}),o.fmtp.push({payload:e.recvRtxPayloadType,config:`apt=${e.recvPayloadType};`}),o.payloads=`${e.recvPayloadType} ${e.recvRtxPayloadType}`),ia(n.kind,o,t,e,!0),n.rtxSsrc&&!n.closed&&(o.ssrcs=o.ssrcs.concat([{id:n.rtxSsrc,attribute:"cname",value:n.cname}]),o.ssrcGroups.push({semantics:"FID",ssrcs:`${n.ssrc} ${n.rtxSsrc}`})),i.media.push(o)}return Yi.write(i)}(t,this.extendedRtpCapabilities,this.transportRemoteParameters,this.sessionVersion)}{const t=new Set;return e.forEach(e=>t.add(e.kind)),0===e.length&&(t.add("audio"),t.add("video")),function(e,t,r,n){e=["audio","video"];const i={version:0};i.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344377",sessionVersion:2,username:ea},i.name="-",i.timing={start:0,stop:0},i.icelite=n.iceParameters.iceLite?"ice-lite":void 0,i.msidSemantic={semantic:"WMS",token:"*"},i.groups=[{type:"BUNDLE",mids:e.join(" ")}],i.media=[],i.fingerprint={type:n.dtlsParameters.fingerprints[0].algorithm,hash:n.dtlsParameters.fingerprints[0].value};for(const a of e){const e=t.filter(e=>e.kind===a),o=r.codecs.find(e=>e.kind===a),s=(r.headerExtensions||[]).filter(e=>e.kind===a);if(!o)throw kn("no codec"+a);const c={type:a,port:7,protocol:"RTP/SAVPF",connection:{ip:"127.0.0.1",version:4},mid:a,iceUfrag:n.iceParameters.usernameFragment,icePwd:n.iceParameters.password,candidates:ta(n.iceCandidates),endOfCandidates:"end-of-candidates",iceOptions:"renomination",setup:"server"===n.dtlsParameters.role?"actpass":"active",direction:"sendonly",rtp:[{payload:o.recvPayloadType,codec:o.name,rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}],rtcpFb:[],fmtp:[{payload:o.recvPayloadType,config:Object.keys(o.parameters).map(e=>`${e}=${o.parameters[e]};`).join("")}],payloads:o.recvPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ssrcs:[],ssrcGroups:[],ext:s.map(e=>({uri:e.uri,value:e.recvId}))};o.rtcpFeedback&&o.rtcpFeedback.length>0&&o.rtcpFeedback.forEach(e=>{c.rtcpFb.push({payload:o.recvPayloadType,type:e.type,subtype:e.parameter})}),o.recvRtxPayloadType&&(c.rtp.push({payload:o.recvRtxPayloadType,codec:"rtx",rate:o.clockRate,encoding:o.channels>1?o.channels:void 0}),c.fmtp.push({payload:o.recvRtxPayloadType,config:`apt=${o.recvPayloadType};`}),c.payloads=`${o.recvPayloadType} ${o.recvRtxPayloadType}`);for(const t of e)c.ssrcs.push({id:t.ssrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.ssrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.ssrc,attribute:"cname",value:`${t.cname}`}),t.rtxSsrc&&(c.ssrcGroups.push({semantics:"FID",ssrcs:`${t.ssrc} ${t.rtxSsrc}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"msid",value:`${t.streamId} ${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"mslabel",value:`${t.streamId}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"label",value:`${t.trackID}`}),c.ssrcs.push({id:t.rtxSsrc,attribute:"cname",value:`${t.cname}`}));i.media.push(c)}return Yi.write(i)}(Array.from(t),e,this.extendedRtpCapabilities,this.transportRemoteParameters)}}async updateICEData(e,t){if(this.transportRemoteParameters){for(const e of t)e.ip=await hi(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function na(e){const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});return t.sdp?{isH264:-1!==t.sdp.toLowerCase().indexOf("h264"),sdp:t.sdp}:{isH264:!1,sdp:""}}function ia(e,t,r,n,i=!1){const a=r.codecs.filter(t=>t.kind===e&&t.name!==n.name);if(a.length>0){let e=i?n.recvPayloadType:n.sendPayloadType;const r=[];a.forEach(n=>{const a=i?n.recvPayloadType:n.sendPayloadType;r.push(a),t.rtp.push({payload:a,codec:n.name,rate:n.clockRate,encoding:n.channels>1?n.channels:void 0}),t.fmtp.push({payload:a,config:`${e}/${e}`})}),t.payloads=`${t.payloads} ${r.join(" ")}`}}function aa(e){const t=Yi.parse(e);if(!("media"in t))return Yi.write(t);if(!Array.isArray(t.media))return Yi.write(t);for(const e of t.media)"ext"in e&&Array.isArray(e.ext)&&"video"===e.type&&(e.ext=e.ext.filter(e=>"urn:3gpp:video-orientation"!==e.uri));return Yi.write(t)}class oa extends bi{constructor(e,t,r){super(),this._isRestartingICE=!1,this.isPcReady=!1,this.midRidEncoding={},this.removeMids=new Set,this.lastMediaStatistics=[],this.intervalId=-1,this.playQualityIntervalId=-1,this.qualityStats=new Map,this._direction=e,this._pc=Ao(),this._extendedRtpCapabilities=t,this._remoteSdp=new ra(e,t),this._simulcast=!!r&&r.simulcast,this.coreInstance=r&&r.core,this._pc.addEventListener("iceconnectionstatechange",()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected"),this.registerMediaStatisticStatsReport(),this.registerPlayQualityReport();break;case"failed":this.emit("@connectionstatechange","failed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"disconnected":this.emit("@connectionstatechange","disconnected"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport();break;case"closed":this.emit("@connectionstatechange","closed"),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport()}})}async getStats(e,r){return await async function(e,r,n,i){if(E.stats){const a=await async function(e,t,r){let n;try{n=await e.getStats(t)}catch(e){return jr.debug("get stats error, fallback to default",e),[]}if(!n)return jr.debug("get null stats, fallback to default"),[];const i=[];for(const e of n.values())if("send"===r&&"outbound-rtp"===e.type&&!e.isRemote||"recv"===r&&"inbound-rtp"===e.type&&!e.isRemote){const t=Ya(),a=n.get(e.remoteId);t.packetLoss=uo(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=co(e)||co(a)||0,t.id=e.id,t.kind=e.kind,e.frameWidth&&(t.width=e.frameWidth),e.frameHeight&&(t.height=e.frameHeight),e.framesPerSecond&&(t.frameRate=e.framesPerSecond),e.framerateMean&&(t.frameRate=Math.ceil(e.framerateMean)),i.push(t)}return i}(e,r,n);return function(e,r){if(!r||0===r.length)return e;if(r.length!==e.length)return e;const n=Object.values(Gr([...e,...r],"id"));if(!n.every(e=>2===e.length))return e;return n.map(([e,r])=>{const n=(e.timestamp-r.timestamp)/1e3;if(n<=0)return e;const i=t({},e),a=lo(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=eo(a,i.rtt);const o=Za(e.id,e.kind);return o.Apply(a),i.packetLossRate=o.Filtered()<0?0:o.Filtered(),i.bitrate=8*(e.bytes-r.bytes)/n,i.bitrate<0?r:i})}(a,i)}return ui(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}(this._pc,e,this._direction,r)}registerPlayQualityReport(){"send"!==this._direction&&(this.unregisterPlayQualityReport(),this.playQualityIntervalId=window.setInterval(async()=>{const e=await async function(e,t){let r;try{r=await e.getStats()}catch(e){return ui(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return ui(()=>{jr.debug("get null media statistic stats, fallback to default")},"getStats error"),[];const n=[...r.values()];return t.subscribedTracks.map(e=>{const t=e.mediaTrack,r=n.find(e=>e.type===ao.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===ao.InBoundRtp&&e.trackId===r.id);return i?{time:Date.now(),trackID:e.info.trackID,kind:"video"===i.kind?"video":"audio",framesDecoded:i.framesDecoded||-1,totalSamplesReceived:i.totalSamplesReceived||-1}:void 0}).filter(N)}(this._pc,this.coreInstance);for(const t of e){const e=this.qualityStats.get(t.trackID);e?e.push(t):this.qualityStats.set(t.trackID,[t])}this.addQualityStats()},2e3))}unregisterPlayQualityReport(){"send"!==this._direction&&-1!==this.playQualityIntervalId&&(window.clearInterval(this.playQualityIntervalId),this.addQualityStats(!0),this.playQualityIntervalId=-1)}addQualityStats(e=!1){const t=[...this.qualityStats.values()];if(t.some(e=>e.length>=30)||e){jr.log("quality stats",this.qualityStats);for(const e of t){if(0===e.length)continue;const t=e[0].trackID,r=2*e.length*1e3;if("video"===e[0].kind){const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].framesDecoded===e[n-1].framesDecoded?t+2:t,0);gn.addEvent("VideoPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}else{const n=1e3*e.reduce((t,r,n)=>n>=1&&e[n].totalSamplesReceived===e[n-1].totalSamplesReceived?t+2:t,0);gn.addEvent("AudioPlayQuality",{track_id:t,freeze_duration:n,total_duration:r})}}this.qualityStats=new Map}}registerMediaStatisticStatsReport(){this.unregisterMediaStatisticStatsReport(),this.intervalId=window.setInterval(async()=>{const e=await async function(e,r){let n;try{n=await e.getStats()}catch(e){return jr.debug("get media statistic stats error, fallback to default",e),[]}if(!n)return jr.debug("get null media statistic stats, fallback to default"),[];const i=[...n.values()];return i.filter(e=>(e.type===ao.InBoundRtp||e.type===ao.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[ao.MediaSource]:r.filter(e=>e.type===ao.MediaSource).find(t=>t.id===e.mediaSourceId),[ao.Track]:r.filter(e=>e.type===ao.Track).find(t=>t.id===e.trackId),[ao.RemoteInBound]:r.filter(e=>e.type===ao.RemoteInBound).find(t=>t.id===e.remoteId)};let a=function(e,r,n){const i={id:e,track_id:r,kind:"audio",kbps:0,framerate:0,packet_lost_rate:0,rtt:0,extra_stats:null,calculation_stats:t({},no)};n===io.Audio?i.extra_stats=t({},to):i.extra_stats=t({},ro);return i}(e.id,e.trackID,e.mediaType);a.rtt=co(i[ao.RemoteInBound])||co(e)||0,a.calculation_stats.packets_lost=uo(e,i[ao.RemoteInBound])||0,e.mediaType===io.Video?(a=function(e,t){return t.kind=e.kind,t.extra_stats.nack_count=e.nackCount,t.extra_stats.fir_count=e.firCount,t.extra_stats.pli_count=e.pliCount,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.frame_encoded=e.framesEncoded||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.frame_decoded=e.framesDecoded||0,t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[ao.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[ao.MediaSource],a)),i[ao.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.width=e.frameWidth,t.extra_stats.height=e.frameHeight,t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[ao.Track],a,n))):(a=function(e,t){return t.kind=e.kind,t.extra_stats.bytes_sent=e.bytesSent||0,t.extra_stats.bytes_received=e.bytesReceived||0,t.extra_stats.track_audio_volume=so(e.audioLevel,e.type),t.calculation_stats.bytes_received=e.bytesReceived||0,t.calculation_stats.bytes_sent=e.bytesSent||0,t.calculation_stats.packets_received=e.packetsReceived||0,t.calculation_stats.packets_sent=e.packetsSent||0,t.calculation_stats.timestamp=e.timestamp||0,t}(e,a),i[ao.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=so(e.audioLevel,e.type),t}(i[ao.MediaSource],a)),i[ao.Track]&&(a=function(e,t,r){const n=[...r.publishedTracks,...r.subscribedTracks].find(t=>t.mediaTrack.id===e.trackIdentifier);return t.track_id=n&&n.info&&n.info.trackID||"",t.extra_stats.jitter_buffer_delay=e.jitterBufferDelay||0,t.calculation_stats.frames_sent=e.framesSent||0,t.calculation_stats.frames_received=e.framesReceived||0,t}(i[ao.Track],a,n)));return a})(e,i,r))}(this._pc,this.coreInstance);e&&e.length>0&&(this.addMediaStatistics(e,this.lastMediaStatistics),this.lastMediaStatistics=e)},3e3)}unregisterMediaStatisticStatsReport(){-1!==this.intervalId&&(window.clearInterval(this.intervalId),this.lastMediaStatistics=[],this.intervalId=-1)}addMediaStatistics(e,r){const n=e.map(e=>{const n=$a(e.id,e.kind),i=r.find(t=>t.id===e.id);if(!i)return e;const a=i.calculation_stats,{calculation_stats:o}=e,s=Wi(e,["calculation_stats"]);return t({},s,function(e,t,r){if(!e||!t)return{framerate:0,kbps:0,packet_lost_rate:0};const n=(e.timestamp-t.timestamp)/1e3,i=0===n?0:(e.frames_sent-t.frames_sent+(e.frames_received-t.frames_received))/n,a=0===n?0:(e.bytes_sent-t.bytes_sent+(e.bytes_received-t.bytes_received))/(1024*n/8),o=lo(t.packets_lost,e.packets_lost,t.packets_received+t.packets_sent,e.packets_received+e.packets_sent);r.Apply(o);const s=r.Filtered()<0?0:100*r.Filtered();return{framerate:Math.ceil(i),kbps:Math.ceil(a),packet_lost_rate:Math.ceil(s)}}(o,a,n))});jr.log("media statistics",n),gn.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=eo(n.sort((e,t)=>t.packet_lost_rate-e.packet_lost_rate)[0].packet_lost_rate,n.sort((e,t)=>t.rtt-e.rtt)[0].rtt);bn(i);const a=n.map(e=>({kind:e.kind,lostRate:e.packet_lost_rate,rtt:e.rtt,track:e.track_id}));this.emit("@send-qos-message",{qos:JSON.stringify({networkGrade:i,tracks_qos:a})})}getCurrentIceConnectionState(){return this._pc.iceConnectionState}close(){jr.log("handle",this._direction,"close"),this.removeEvent(),this.unregisterMediaStatisticStatsReport(),this.unregisterPlayQualityReport(),this._pc.close(),this.isPcReady=!1}}class sa extends oa{constructor(e,t,r){super("send",e,r),jr.log("init send handler"),this._transportReady=!1,this._stream=new MediaStream,this._signaling=t,t.on("on-pubpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))})}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-pubpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-pubpc-state",n)})}addProducerTracks(e){jr.debug("add producer",e);const t=e.filter(e=>!this._stream.getTrackById(e.mediaTrack.id));if(0===t.length)return Promise.reject(new Error("track already added"));let r;const n=[];let i,a=!0;return Promise.resolve().then(async()=>{for(const e of t)this._stream.addTrack(e.mediaTrack);if(E.unifiedPlan&&E.supportTransceivers)for(const e of t){const t=await ho(e.mediaTrack,this._pc,e.lowStreamConfig,e.info.kbps);jr.debug("add transceiver",t,t.mid),n.push(t)}else jr.debug("add tracks",t),r=t.map(e=>this._pc.addTrack(e.mediaTrack,this._stream));return da(this._pc,this._simulcast)}).then(e=>{let t;return E.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${zi}`),t={type:"offer",sdp:e.sdp},i=t.sdp,jr.log("publish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{for(const t of n){if(!t.sender.track)continue;const r=e.find(e=>e.mediaTrack===t.sender.track);if(!r||!t.mid)throw kn("can not get transceiver mid!");r.setInfo({mid:t.mid}),this.midRidEncoding[t.mid]=r.lowStreamConfig}if(!this._transportReady)return a=!1,this._setupTransport(e)}).then(()=>this._remoteSdp.createRemoteAnswer(i,this.midRidEncoding,this.removeMids)).then(e=>{const t={type:"answer",sdp:e};return jr.debug("addProducer answer",t),this._pc.setRemoteDescription(t)}).then(()=>this._pcReady).then(()=>a?this.safeEmitAsPromise("@needpubtracks",e,i):Promise.resolve(this._remoteSdp.transportRemoteParameters)).catch(e=>{jr.log("add producer error",e);try{for(const e of r)this._pc.removeTrack(e);for(const e of n)e.direction="inactive"}catch(e){}for(const e of t)this._stream.removeTrack(e.mediaTrack);throw e instanceof Sn?e:kn(e)})}removeProducerTracks(e){jr.debug("removeProducerTracks",e);const t=e.filter(e=>void 0!==e.track&&!!this._stream.getTrackById(e.track.mediaTrack.id)).map(e=>e.track.isReplacedByImageTrack?e.track.imageStreamTrack.mediaTrack:e.track.mediaTrack);let r;return Promise.resolve().then(()=>{E.unifiedPlan&&E.supportTransceivers&&this._pc.getTransceivers().forEach(e=>{e.sender.track&&e.mid&&t.includes(e.sender.track)&&this.removeMids.add(e.mid)});const e=this._pc.getSenders().filter(e=>e.track&&t.includes(e.track));if(0===e.length)return jr.warning("removeProducerTracks [nothing to remove]"),Promise.reject("removeProducerTracks: nothing to remote");for(const t of e)this._pc.removeTrack(t);for(const e of t)this._stream.removeTrack(e);return da(this._pc,this._simulcast)}).then(e=>{const t=new RTCSessionDescription(e);return r=t.sdp,jr.log("unpublish: set local offer",t),this._pc.setLocalDescription(t)}).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(r,this.midRidEncoding,this.removeMids)};return jr.log("unpublish: set remote answer",e),this._pc.setRemoteDescription(e)}).catch(e=>{if(0!==this._stream.getTracks().length)throw e instanceof Sn?e:kn(e);jr.debug("removeProducer() | ignoring expected error due no sending tracks: %s",e.toString())}).then(()=>{this.safeEmitAsPromise("@needunpubtracks",e)})}async replaceTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");e.track&&(e.track.mediaTrack=t,e.track.removeMediaElement());const n=r.track;await r.replaceTrack(t),this._stream.removeTrack(n),this._stream.addTrack(t)}async replaceProducerTrack(e,t){if(!this._pc.getSenders)throw kn("getSenders is not supported.");const r=this._pc.getSenders().find(t=>{if(!t.track)return!1;if(!e.track)return!1;const r=t.track.id;return!(!e.track.mediaTrack||r!==e.track.mediaTrack.id)||!(!e.track.imageStreamTrack||r!==e.track.imageStreamTrack.id)});if(!r)throw kn(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw kn("replaceTrack is not supported.");"image"===t?(jr.debug("replaceTrack",e.track.imageStreamTrack.mediaTrack),await r.replaceTrack(e.track.imageStreamTrack.mediaTrack)):"video"===t&&(jr.debug("replaceTrack",e.track.mediaTrack),await r.replaceTrack(e.track.mediaTrack))}restartICE(e,t){return jr.log("restart send ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>da(this._pc,this._simulcast,{iceRestart:!0})).then(e=>this._pc.setLocalDescription(e)).then(()=>{const e={type:"answer",sdp:this._remoteSdp.createRemoteAnswer(this._pc.localDescription.sdp,this.midRidEncoding,this.removeMids)};return this._pc.setRemoteDescription(e)})}_setupTransport(e){const t=Date.now();return Promise.resolve().then(()=>this._pc.localDescription?this._pc.localDescription:da(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(gn.addEvent("PublisherPC",{signal_take_time:Date.now()-t,result_code:r.code,up_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),this.pcid=r.pcid,this._transportReady=!0,this._pcReady=this.getReady(r),this._remoteSdp.setTransportRemoteParameters(r)))}}class ca extends oa{constructor(e,t,r){super("recv",e,r),this._transportCreated=!1,this._consumerInfos=new Map,this._signaling=t,t.on("on-subpc-state",e=>{this._remoteSdp.transportRemoteParameters&&e.pcid===this._remoteSdp.transportRemoteParameters.pcid&&(e.connected||this.emit("@connectionstatechange","remote-disconnected"))}),jr.log("init recvhandler",this)}getReady(e){return new Promise((t,r)=>{const n=r=>{if(r.pcid===e.pcid){if(this._signaling.off("on-subpc-state",n),!r.connected)return;this.isPcReady=!0,t()}};this._signaling.on("on-subpc-state",n)})}async addConsumerTracks(e){if(E.unifiedPlan&&g){const t=[];for(const r of e){const e=await this.addConsumerTrack(r);t.push(e)}return t}jr.log("add consumers",e);const t=[],r=Array.from(this._consumerInfos.values());for(const n of e){const e=r.find(e=>e.consumerId===n.id);if(e&&!e.closed)t.push(e);else{const e=this.genNewConsumerInfo(n);if(E.unifiedPlan){const t=n.mid;e.mid=t,this._consumerInfos.set(t,e)}else this._consumerInfos.set(n.id,e);t.push(e)}}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>(E.unifiedPlan,this._pc.createAnswer())).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{for(let r=0;r!!e.receiver.track&&(e.receiver.track.id===n.trackID||e.mid===n.mid));e&&(i.track=e.receiver.track)}else if(E.getReceivers){const e=this._pc.getReceivers().find(e=>{const{track:t}=e;return!!t&&n.trackID===t.id});e&&(i.track=e.track)}else{const e=this._pc.getRemoteStreams().find(e=>e.id===n.streamId);e&&(i.track=e.getTrackById(n.trackID))}if(!i.track)throw kn("remote track not found");jr.log("subscribe: get new track",i.track)}}return e.map(e=>e.track)})}genNewConsumerInfo(e){const t=e.rtpParameters.encodings[0],r=e.rtpParameters.rtcp.cname,n=e.mid;return{kind:e.kind,streamId:E.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:E.unifiedPlan?`consumer-${e.kind}-${n}`:`consumer-${e.kind}-${t.ssrc}`,ssrc:t.ssrc,rtxSsrc:t.rtx?t.rtx.ssrc:void 0,cname:r,consumerId:e.id,closed:!1}}async addConsumerTrack(e){jr.log("add consumer",e);let t=null;const r=Array.from(this._consumerInfos.values()).find(t=>t.consumerId===e.id);if(r&&!r.closed)t=r;else{const r=this.genNewConsumerInfo(e);if(E.unifiedPlan){const t=e.mid;r.mid=t,this._consumerInfos.set(t,r)}else this._consumerInfos.set(e.id,r);t=r}return Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("set ontrack"),this._pc.ontrack=(e=>{jr.log("ontrack",e.receiver.track)}),jr.debug("subscribe: set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.debug("subscribe, set local answer",e),this._pc.setLocalDescription(e))).then(()=>this._pcReady).then(()=>{let r=null;if(E.unifiedPlan&&E.supportTransceivers&&e&&t){const n=this._pc.getTransceivers().find(r=>!!r.receiver.track&&((r.receiver.track.id===t.trackID||r.mid===t.mid)&&(e.track=r.receiver.track,!0)));n&&(r=n.receiver.track)}else if(e&&t){const n=this._pc.getReceivers().find(r=>{const{track:n}=r;return!!n&&(t.trackID===n.id&&(e.track=n,!0))});n&&(r=n.track)}if(!r&&e)throw kn("remote track not found");return jr.log("subscribe: get new track",r,r.readyState),r})}removeConsumerTracks(e){jr.log("remove consumer",e);let t=!1;for(const r of e){const e=Array.from(this._consumerInfos.values()).find(e=>e.consumerId===r.id&&!e.closed);e?(t=!0,E.unifiedPlan?(r.track=null,e.closed=!0):this._consumerInfos.delete(r.id)):jr.log("can not find unpublish track target, ignore")}return t?Promise.resolve().then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return jr.log("unsubscribe set remote offer",e),this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>(jr.log("unsubscribe set local answer",e),this._pc.setLocalDescription(e))):Promise.resolve()}restartICE(e,t){return jr.log("recv restart ice"),this._isRestartingICE=!0,Promise.resolve().then(()=>this._remoteSdp.updateICEData(e,t)).then(()=>{const e={type:"offer",sdp:this._remoteSdp.createRemoteOffer(Array.from(this._consumerInfos.values()))};return this._pc.setRemoteDescription(e)}).then(()=>this._pc.createAnswer()).then(e=>{this._pc.setLocalDescription(e)})}async setupTransport(e){if(this._transportCreated)return await this._pcReady;const t=Date.now(),r=await this.safeEmitAsPromise("@needsubpc",e);return gn.addEvent("SubscriberPC",{signal_take_time:Date.now()-t,result_code:r.code,down_stream_ip:(r.iceCandidates||[]).map(({ip:e})=>e).join(","),tracks:r.tracks.map(e=>({track_id:e.trackid,status:e.status}))}),this.pcid=r.pcid,this._transportCreated=!0,this._pcReady=this.getReady(r),jr.log("init subscribe, get transport remote",r),await this._remoteSdp.setTransportRemoteParameters(r),r}}function da(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=aa(n),"chrome"===b.name&&t&&(n=function(e,t){const r=Yi.parse(e);t&&"chrome"===b.name&&(r.media=r.media.map(e=>{if(!e.ssrcGroups||0===e.ssrcGroups.length||!e.ssrcs||0===e.ssrcs.length)return e;const r=e.ssrcGroups.find(e=>"FID"===e.semantics);if(!r)return e;const[n,i]=r.ssrcs.split(" ").map(e=>parseInt(e,10));let a,o;e.ssrcs.forEach(e=>{"cname"===e.attribute&&(a=e.value),"msid"===e.attribute&&(o=e.value)});const s=[];if(s.push(n),t>=2){const t=n+1,r=i+1;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}if(t>=3){const t=n+2,r=i+2;e.ssrcs.push({id:t,attribute:"cname",value:a}),e.ssrcs.push({id:t,attribute:"msid",value:o}),e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:o}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}),s.push(t)}return e.ssrcGroups.push({semantics:"SIM",ssrcs:s.join(" ")}),e}));const n=Yi.write(r).split("\r\n");let i=n.findIndex(e=>0===e.indexOf("a=ssrc-group:FID"));for(;-1!==i&&0===n[i].indexOf("a=ssrc-group:FID");){const e=n[i].split(" ")[2];for(let t=i-1;t>=0;t--)if(n[t].indexOf(e)>0){n.splice(t+1,0,n[i]),n.splice(i+1,1);break}i++}return n.join("\r\n")}(n,3)),{type:r,sdp:n}):e})}function ua(e,t,r,n){switch(e){case"send":return new sa(t,r,n);case"recv":return new ca(t,r,n)}}var la;!function(e){e.SEND_TRACKS="@transport:send-tracks",e.RESTART_SEND_ICE="@transport:send-restart-ice",e.REMOVE_TRACKS="@transport:remove-tracks",e.INIT_RECV="@transport:init-recv",e.RESTART_RECV_ICE="@transport:recv-restart-ice",e.ADD_CONUMERS="@transport:add-consumers",e.REMOVE_CONSUMERS="@transport:remove-consumers"}(la||(la={}));class Aa extends bi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Vr("SendQueue"),this.recvCommandQueue=new Vr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=ua("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=ua("recv",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),this.handleRecvHandler(),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this)),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this)),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e})}get publishTracks(){return Array.from(this._publishTracks.values())}resolveInitSubPcPromise(){this.initSubPcPromiseResolve&&(this.initSubPcPromiseResolve(),this.initSubPcPromiseResolve=void 0)}handleSendHandler(){this.sendHandler.on("@needpubpc",(e,t,r,n)=>{this.safeEmitAsPromise("@needpubpc",e,t).then(r).catch(n)}).on("@connectionstatechange",e=>{switch(jr.log("pubpc connectionstatechange",e),gn.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartSendICE(this.sendHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.sendHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartSendICE(this.sendHandler.pcid))})}}).on("@needpubtracks",(e,t,r,n)=>{const i=e.map(ko),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(gn.addEvent("PublishTracks",{signal_take_time:Date.now()-a,result_code:t.code,tracks:t.tracks.map(t=>{const r=e.find(e=>e.mediaTrack.id===t.localid);if(r)return{local_id:t.localid,track_id:t.trackid,source_type:r.sourceType,kind:r.info.kind,tag:r.info.tag||"",muted:!!r.info.muted,master:!!r.master,kbps:r.info.kbps||-1,encode_video_width:0,encode_video_height:0}}).filter(e=>void 0!==e)}),t.code){case 0:break;case 10052:return n(Zn());case 10061:return this.reconnectProducer(),n(qn(10061,t.error));default:return n(qn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(qn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{gn.addEvent("UnPublishTracks",{tracks:e.map(e=>({track_id:e.trackID}))}),this.signaling.request("unpub-tracks",{tracks:e.map(e=>({trackid:e.trackID}))}).then(e=>{t(e)})}).on("@send-qos-message",e=>{this.signaling.request("send-qos-message",e)})}async sendTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(la.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(la.REMOVE_TRACKS,e)}async restartSendICE(e){return E.supportRestartICE?this.sendCommandQueue.push(la.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case la.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case la.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case la.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new ji(this,"send",e));for(const e of t)this._publishTracks.set(e.track.mediaTrack.id,e);return t}removeTrackFromPublishTracks(e){for(const t of e)this._publishTracks.delete(t.mediaTrack.id)}async _execAddProducerTracks(e){const t=await this.sendHandler.addProducerTracks(e.map(e=>e.track));for(const r of e){const e=ri(t.tracks,"localid",r.track.mediaTrack.id);e&&(r.addTrackId(e.trackid),r.track.setInfo({versionid:e.versionid}),r.track.resetStats())}return e.map(e=>e.connectStatus=B.Connect),t}_execRemoveTracks(e){return this.removeTrackFromPublishTracks(e.map(e=>e.track)),e.map(e=>e.release()),this.sendHandler.removeProducerTracks(e)}async _execRestartSendICE(e){this.sendHandler._isRestartingICE=!0;const t=await this.signaling.request("pubpc-restart",{pcid:e});if(0!==t.code)return this.sendHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.reconnectProducer();try{await this.sendHandler.restartICE(t.iceParameters,t.iceCandidates),this.sendHandler._isRestartingICE=!1}catch(e){jr.debug("restart ice faild",t.code,t.error),this.sendHandler._isRestartingICE=!1,this.reconnectProducer()}}reconnectProducer(){this.resetSendCommandQueue(),this.sendHandler.close();const e=this.publishTracks;this.sendHandler=ua("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=B.Connecting}),this.emit("@needrepub",e)}handleRecvHandler(){this.recvHandler.on("@needsubpc",(e,t,r)=>{this.safeEmitAsPromise("@needsubpc",e).then(t,r)}).on("@connectionstatechange",e=>{switch(jr.log("sub pc connection state change",e),gn.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid,event_grade:"failed"===e?An.SERVERE:An.NORMAL,event_category:hn.CORE}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Si.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===Si.OPEN?this.restartRecvICE(this.recvHandler.pcid):this.signaling.once("@signalingauth",e=>{"disconnected"===this.recvHandler.getCurrentIceConnectionState()&&(this.extendedRtpCapabilities=e.rtpcaps,this.restartRecvICE(this.recvHandler.pcid))})}})}appendConsumer(e){this.consumerQueue.push(e)}async addConsumers(){const e=this.consumerQueue;return this.consumerQueue=[],this.recvCommandQueue.push(la.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(la.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(la.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return E.supportRestartICE?this.recvCommandQueue.push(la.RESTART_RECV_ICE,e):this.resetRecvHandler()}async _removeConsumers(e){await this.recvHandler.removeConsumerTracks(e)}async _initRecvHandler(e){return this.recvHandler.isPcReady?(await this.initSubPcPromise,null):await this.recvHandler.setupTransport(e)}async _addConsumers(e){if(0===e.length)return Promise.resolve([]);return await this.recvHandler.addConsumerTracks(e)}async _execRestartRecvICE(e){this.recvHandler._isRestartingICE=!0;const t=await this.signaling.request("subpc-restart",{pcid:e});if(0!==t.code)return this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),void this.resetRecvHandler();try{await this.recvHandler.restartICE(t.iceParameters,t.iceCandidates),this.recvHandler._isRestartingICE=!1}catch(e){this.recvHandler._isRestartingICE=!1,jr.debug("restart ice faild",t.code,t.error),this.resetRecvHandler()}}handleRecvCommandTask(e,t){switch(e.method){case la.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case la.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case la.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case la.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Vr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Vr("RecvQueue"),this.recvInitCommandQueue=new Vr("RecvInitQueue"),this.recvCommandQueue.on("exec",this.handleRecvCommandTask.bind(this)),this.recvInitCommandQueue.on("exec",this.handleRecvInitCommandTask.bind(this))}resetRecvHandler(){this.resetRecvCommandQueue(),this.emit("@needresetrecv"),this.recvHandler.close(),this.recvHandler=ua("recv",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.initSubPcPromise=new Promise(e=>{this.initSubPcPromiseResolve=e}),this.handleRecvHandler(),this.emit("@needresub")}release(){this.recvHandler.close(),this.sendHandler.close(),this.publishTracks.forEach(e=>e.release())}}const ha=new bi;function fa(e,t){return new Promise(r=>{let n;const i=Date.now(),a=new WebSocket(e);a.onopen=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!0,reason:"ok",connectTime:t})}),a.onerror=(()=>{n&&clearTimeout(n);const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"onerror",connectTime:t})}),n=setTimeout(()=>{const t=Date.now()-i;r({ws:a,url:e,status:!1,reason:"timeout",connectTime:t}),a.close()},t)})}var pa;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(pa||(pa={}));const ma={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class ga extends C{constructor(e=ma){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new Hi,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=pa.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==pa.Connected)return void n(kn("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===dn.LIVE&&this._role===un.AUDIENCE)return void n(kn("no permission. Audience in Live mode has no permission to publish."));e.forEach(e=>e.userID=this.userID),e.forEach(e=>e.selfEndedCallback=this.unpublish.bind(this));const i=this.connectionTransport,a=this.signaling;let o;if(t){const t=e.map(e=>e.mediaTrack.id);o=i.publishTracks.filter(e=>-1!==t.indexOf(e.track.mediaTrack.id))}else{const t=i.publishTracks.map(e=>e.track.mediaTrack.id);if(e.filter(e=>-1===t.indexOf(e.mediaTrack.id)).length!==e.length)return void n(kn("there are already published tracks in the provided tracks"));o=i.addTrackToPublishTracks(e)}if(jr.debug("start publish",o,t),!t){const e=o.map(e=>e.startConnect());Promise.all(e).then(()=>r()).catch(()=>{n(Gn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=ri(this.users,"userID",this.userID);t&&(t.addTracks(o.map(e=>e.track)),t.addPublishedTrackInfo(o.map(e=>({trackID:e.trackID,muted:!!e.track.info.muted,kind:e.track.info.kind,tag:e.track.info.tag,userID:this.userID,versionid:e.track.info.versionid,profiles:e.track.info.profiles})))),e.forEach(e=>{e.on("@get-stats",(t,r,n)=>{if(!this.connectionTransport)return r([]);const i=e.isReplacedByImageTrack?e.imageStreamTrack.mediaTrack:e.mediaTrack;this.connectionTransport.sendHandler.getStats(i,t).then(r,n)})}),this.getAllMerger().forEach(t=>t.controller.onAddTracks(e.map(e=>e.info)))}catch(t){if(t instanceof Sn)switch(t.code){case 10061:case 30001:return;case 10052:return jr.warning(t,"republish"),void setTimeout(()=>this._publish(e,!0),1e3);default:i.removeTrackFromPublishTracks(e),n(t)}else jr.warning(t,"republish"),setTimeout(()=>this._publish(e,!0),1e3)}})),this._subscribe=((e,t,r=!1,n)=>new Promise(async(i,a)=>{if(this.roomState!==pa.Connected)return void a(kn("can not connected to the room, please joinRoom first"));if(0===e.length)return void i([]);jr.debug("subscribe",e,t);const o=this._trackInfo.filter(t=>e.includes(t.trackid));if(o.length!==e.length)return void a(Kn(10041,`can not find track in room ${e}`));let s;const c=this.connectionTransport,d=this.signaling;if(t)s=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));else{const e=this.subscribeTracks.map(e=>e.trackID),t=o.filter(t=>!e.includes(t.trackid));s=t.map(e=>new ji(c,"recv",void 0,e.trackid,e.mid)),this.subscribeTracks=this.subscribeTracks.concat(s)}n&&Object.entries(n).forEach(([e,t])=>{this.profiles.set(e,t)}),jr.log("sub tracks",s,n);try{if(!t){const e=s.map(e=>e.startConnect());Promise.all(e).then(()=>i(s.map(e=>e.track))).catch(()=>{a(Gn())})}let n=await c.initRecvHandler(s.map(e=>e.trackID));if(!n){const e=Date.now();n=await d.request("sub-tracks",{tracks:s.map(e=>{const t=e.trackID;return this.profiles.get(t)?{trackid:t,profile:this.profiles.get(t)}:{trackid:t}})}),gn.addEvent("SubscribeTracks",{result_code:n.code,signal_take_time:Date.now()-e,tracks:n.tracks.map(e=>({track_id:e.trackid,status:e.status}))})}switch(jr.log("get sub res data",n),n.code){case 0:break;case 10052:throw Zn();case 10062:throw c.resetRecvHandler(),Kn(10062,n.error);default:throw Kn(n.code,n.error)}const u=n.tracks.filter(e=>!!e.status),l=n.tracks.filter(e=>!e.status).map(e=>e.trackid);if(u.length-1!==l.indexOf(e.trackID));M(this.subscribeTracks,e=>-1!==l.indexOf(e.trackID)),e.map(e=>e.release())}n.tracks=u;for(const e of n.tracks||[]){const t=s.find(t=>t.trackID===e.trackid),r=o.find(t=>t.trackid===e.trackid);if(!t||!r)continue;const n=e.rtpparams;t.appendConsumner(n,r.kind)}await c.addConsumers(),c.resolveInitSubPcPromise();for(const e of s){const{consumer:t}=e;if(!t||!t.track)continue;const r=t.track;let n=e.track;const i=o.find(e=>e.trackid===t.id);if(!i)continue;n?n.resume(r):"audio"===r.kind?(n=new Ui(r,i.playerid,"remote")).initAudioManager():n=new Li(r,i.playerid,"remote",i.profiles||[]),n.setInfo({trackID:i.trackid,userID:i.playerid,tag:i.tag,kind:i.kind,muted:i.muted,versionid:i.versionid}),n.setMaster(i.master),n.removeAllListeners("@get-stats"),n.removeAllListeners("@ended"),n.on("@get-stats",(e,t,r)=>{if(!this.connectionTransport)return t([]);this.connectionTransport.recvHandler.getStats(n.mediaTrack,e).then(t,r)}),n.once("@ended",async()=>{if(n&&n.info.trackID){jr.warning("remote track ended, try to resubscribe");try{await this._unsubscribe([n.info.trackID],!0)}catch(e){}await this._subscribe([n.info.trackID],!0)}}),e.track=n;const a=this.users.find(e=>e.userID===i.playerid);a&&a.addTracks([n])}s.forEach(e=>e.connectStatus=B.Connect);let A=n.tracks.map(e=>{if(void 0===e.muted)for(let t=0;t{e.consumer&&r.push(e.consumer)}),await c.removeConsumers(r),!(t instanceof Sn))return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);switch(t.code){case 10062:case 30001:return;case 10052:return jr.warning(t,"resubscribe"),void setTimeout(()=>this._subscribe(e,!0),1e3);default:M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},ma,e),this.config=e,jr.log("config",e),jr.log("version",Hr),jr.log("browser report",E,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(So)}get roomState(){return this._roomState}set roomState(e){this._roomState!==e&&(this._roomState=e,jr.debug("roomState change",this._roomState),this.emit("room-state-change",this._roomState),gn.addEvent("RoomStateChanged",{room_state:e,event_grade:this._roomState===pa.Reconnecting?An.SERVERE:An.NORMAL,event_category:hn.CORE}))}_setReconnectTimes(e){this.config.reconnectTimes=e,this.signaling&&(this.signaling.reconnectTimes=e)}set simulcast(e){this.config.simulcast=e,this.connectionTransport&&(this.connectionTransport.simulcast=e,this.connectionTransport.sendHandler._simulcast=e,this.connectionTransport.recvHandler._simulcast=e)}_getReconnectTimes(){return this.config.reconnectTimes||ma.reconnectTimes}setRequestTimeout(e){this.config.requestTimeout=e}_setProfile(e,t){if(this.profile=t,this.profiles.set(e,t),!this.subscribeTracks.some(t=>t.trackID===e))return;this.signaling.sendWsMsg("set-sub-profile",{tracks:[{trackid:e,profile:this.profile}]})}getForwardJobTracks(){return this.forwardJobTracks}get publishedTracks(){return this.connectionTransport?this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===B.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==pa.Idle)throw kn("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===dn.RTC||this._mode===dn.LIVE&&this._role===un.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===dn.RTC)throw kn("client role can only be set in client mode LIVE.");if(e===un.AUDIENCE&&this.publishedTracks.length>0&&e===un.AUDIENCE)throw kn("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==pa.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(gn.addEvent("SetClientRole",{result_code:t.code,user_role:e===un.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Jn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();let n=0;this._mode===dn.LIVE&&(n=1);const i=this._role===un.BROADCASTER?0:1;if(gn.addEvent("JoinRoom",{room_token:e,user_data:t,room_type:n,user_role:i,audience_latency_level:0}),this.roomState!==pa.Idle)throw kn("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=pa.Connecting;try{this.roomToken=e,this.userData=t;const n=ti(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,gn.setUserBase(this.userID,this.roomName,this.appId),jr.log("join room, token:",e),jr.debug(`join room, roomName: ${this.roomName}, userID: ${this.userID}`),!this.roomName.match(/^[a-zA-Z0-9_-]{1,64}$/))throw this.roomState=pa.Idle,kn("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{1,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{1,50}$/))throw this.roomState=pa.Idle,kn("invalid userID. userID must match /^[a-zA-Z0-9_-]{1,50}$/");try{const t=await vi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,gn.setSessionId(t.sessionId),gn.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:0,join_node_info:this.signaling.url,join_error_message:"",event_grade:An.NORMAL,event_category:hn.CORE}),this._mode===dn.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=pa.Idle,jr.debug("joinRoomWithToken fail: "+t.message),gn.addEvent("JoinRoomResult",{join_start_time:r,join_take_time:Date.now()-r,join_result_code:t.code?t.code:-1,join_node_info:this.signaling?this.signaling.url:"",join_error_message:t.message||t.error||"",event_grade:An.SERVERE,event_category:hn.CORE}),t}}async joinRoomWithAccess(e){const t=ei(e),{capsdp:r}=await async function(){let e=Ao(),{isH264:t,sdp:r}=await na(e),n=5;for(;!t&&n>0;)e.close(),e=Ao(),({isH264:t,sdp:r}=await na(e)),n--;E.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${zi}`);const i={capsdp:r=aa(r),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===pa.Idle)throw kn("roomState is idle, maybe because you left the room.");const n=new _i(e,r,this._getReconnectTimes(),this.config.requestTimeout,this.userData,this._privileges);n.on("@error",this.handleDisconnect.bind(this)).on("@ws-state-change",(e,t)=>{switch(t){case Si.CONNECTING:this.roomState===pa.Connected?this.roomState=pa.Reconnecting:this.roomState!==pa.Reconnecting&&(this.roomState=pa.Connecting)}}).on("@needupdateaccesstoken",(e,t)=>{this.updateAccessToken().then(e).catch(t)}).on("on-player-in",this.handlePlayerIn.bind(this)).on("on-player-out",this.handlePlayerOut.bind(this)).on("on-add-tracks",e=>{this.filterSignalTracks(e),this.handleAddTracks(e)}).on("on-remove-tracks",e=>{this.filterSignalTracks(e),this.handleRemoveTracks(e)}).on("mute-tracks",e=>{this.filterSignalTracks(e),this.handleMute(e)}).on("on-messages",this.handleCustomMessages.bind(this)).on("on-qos-messages",this.handleQosMessages.bind(this)).on("on-pubpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;gn.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:0,socket_node_info:n.url}),t&&E.supportRestartICE&&t.restartRecvICE(e.pcid).catch(jr.debug)}).on("on-sub-profile-changed",e=>{this.emit("on-sub-profile-changed",e)}).on("on-job-connected",e=>{this.emit("forward-job-connected",{jobId:e.id})}).on("on-job-disconnected",e=>{this.emit("forward-job-disconnected",{jobId:e.id})}).on("on-merge-job-connected",e=>{this.emit("merge-job-connected",{jobId:e.id})}).on("on-merge-job-disconnected",e=>{this.emit("merge-job-disconnected",{jobId:e.id})}).on("on-media-relay-state",e=>{const t=e.roomid.slice(e.roomid.indexOf(":")+1);this.emit("media-relay-state-changed",t,e.state)}).on("disconnect",this.handleDisconnect.bind(this)).on("on-player-reconnect",this.handleRemoteUserReconnecting.bind(this)).on("on-player-reconnect-in",this.handleRemoteUserReconnected.bind(this)),jr.log("init signaling websocket"),this.signaling=n;try{let e;e=t.roomServers&&t.roomServers.length>0?t.roomServers.sort((e,t)=>t.score-e.score).map(e=>e.url):[t.signalingurl2];const{ws:r,url:i}=await function(e,t){let r=[],n=!1;return new Promise((i,a)=>{for(const o of e)fa(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),gn.addEvent("WebsocketConnect",{happy_dns_resolve_time:0,happy_dns_take_effect:!1,socket_node_info:t.url,socket_connect_time:t.connectTime,socket_connect_success:t.status,socket_connect_error_message:t.reason,event_grade:n?An.NORMAL:An.SERVERE,event_category:hn.CORE,dns_resolve_time:0,dns_take_effect:!1,dns_resolved_ip:"",socket_connect_reason:"connect"}),r.length!==e.length||n||a(_n("websocket connect failed."))})})}(e,this.config.requestTimeout),a=await n.initWs(!0,r,i);n.on("@signalingauth",this.handleAuth.bind(this)),await this.handleAuth(a)}catch(e){if(this.signaling&&(this.signaling.release(),this.signaling=void 0),10052===e.code)return await ci(1e3),this.joinRoomWithToken(this.roomToken,this.userData);throw e}for(let e of this.users)e.userID!==this.userID&&this.emit("user-join",e);return this.trackInfoList.length>0&&this.emit("track-add",this.trackInfoList),this.users}async _unpublish(e){if(this.roomState!==pa.Connected)throw kn("not connected to the room");if(0===e.length)return;jr.debug("unpublish",e);const t=this.connectionTransport,r=t.publishTracks.filter(t=>-1!==e.indexOf(t.trackID));if(r.length!==e.length)throw kn("can not find target trackid to unpublish");await t.removeTracks(r),this.getAllMerger().forEach(e=>e.controller.onRemoveTracks(r.map(e=>e.track.info)));const n=ri(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==pa.Connected)throw kn("can not createMergeJob, room state is not connected");const n=t({},G,r,{id:e});jr.debug("send create merge job",n,e);const i=Date.now(),a=await this.signaling.request("create-merge-job",n);if(gn.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw Wn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==pa.Connected)throw kn("can not createForwardJob, room state is not connected");const t=!!e.audioTrackId&&!e.videoTrackId,r=[e.audioTrackId,e.videoTrackId].filter(Boolean).map(e=>({trackid:e})),n={id:e.jobId,publishUrl:e.publishUrl,audioOnly:t,tracks:r};if(e&&e.userConfigExtraInfo){if(i=e.userConfigExtraInfo,!(new Blob([i]).size<=1e3))throw kn("userConfigExtraInfo Up to 1000 Bytes");n.seiTemplate={value:e.userConfigExtraInfo}}var i;const a=Date.now(),o=await this.signaling.request("create-forward-job",n);if(gn.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw zn(o.code,o.error);this.forwardJobTracks[e.jobId]?jr.warning("forward job id already exist",e.jobId):(this.forwardJobTracks[e.jobId]=[],e.audioTrackId&&this.forwardJobTracks[e.jobId].push(e.audioTrackId),e.videoTrackId&&this.forwardJobTracks[e.jobId].push(e.videoTrackId))}async stopForwardJob(e){if(this.roomState!==pa.Connected)throw kn("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw kn(`no forward job id ${e}`);gn.addEvent("StopForwardJob",{id:e||""}),await this.signaling.request("stop-forward",{id:e,delayMillisecond:0}),delete this.forwardJobTracks[e]}setDefaultMergeStream(e,t,r){if(r&&!this.mergeJobTracks[r])throw Ln(r);this.merger&&!r&&(this.merger.release(),this.merger=void 0),r&&this.mergeJobMerger[r]&&(this.mergeJobMerger[r].release(),delete this.mergeJobMerger[r]);const n=this.CreateMergerSessionController();r?this.mergeJobMerger[r]=new Ei(e,t,n,r):this.merger=new Ei(e,t,n,r)}_stopMerge(e){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw Ln(e);gn.addEvent("StopMerge",{id:e||""}),this.signaling.sendWsMsg("stop-merge",{id:e}),e?(delete this.mergeJobTracks[e],this.mergeJobMerger[e]&&(this.mergeJobMerger[e].release(),delete this.mergeJobMerger[e])):(this.defaultMergeJobTracks=[],this.merger&&(this.merger.release(),this.merger=void 0))}async _addMergeTracks(e,t){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,add:r};jr.debug("addMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(gn.addEvent("UpdateMergeTracks",{id:t||"",add:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""})),result_code:i.code}),0!==i.code)throw Jn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r={id:t,remove:e.map(e=>({trackid:e}))};jr.debug("removeMergeTracks",r),M(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(gn.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Jn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==pa.Connected)throw kn("can not addMergeTracks, room state is not connected");if(t&&!this.mergeJobTracks[t])throw Ln(t);const r=e.map(e=>({trackid:e.trackID,x:e.x,y:e.y,w:e.w,h:e.h,z:e.z,stretchMode:e.stretchMode})),n={id:t,all:r,mode:1};jr.debug("updateMergeTracks",n),t?(this.mergeJobTracks[t]=this.mergeJobTracks[t].concat(e.map(e=>e.trackID)),this.mergeJobTracks[t]=mi(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=mi(this.defaultMergeJobTracks,e=>e)),gn.addEvent("UpdateMergeTracks",{id:t||"",all:r.map(e=>({track_id:e.trackid,x:e.x||0,y:e.y||0,w:e.w||0,h:e.h||0,z:e.z||0,stretchMode:e.stretchMode||""}))}),await this.signaling.request("update-merge-tracks",n)}async _unsubscribe(e,t){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));if(jr.debug("unsubscribe",r),0===r.length)return;const n=Date.now(),i=await this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))});gn.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e})),result_code:i.code,signal_take_time:Date.now()-n}),t||(r.forEach(e=>e.release()),M(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer))}_muteTracks(e){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");const t=this.connectionTransport,r={};e.forEach(e=>{r[e.trackID]=e.muted});const n=t.publishTracks.filter(e=>void 0!==r[e.trackID]);n.forEach(e=>{e.setMute(r[e.trackID])}),gn.addEvent("MuteTracks",{tracks:n.map(e=>({track_id:e.trackID,muted:e.track.info.muted,kind:e.track.info.kind}))}),this.signaling.sendWsMsg("mute-tracks",{tracks:e.map(e=>({trackid:e.trackID,muted:e.muted}))})}async kickoutUser(e){jr.log("kickoutUser",e),await this.control("kickplayer",e)}sendCustomMessage(e,t,r){if(this.roomState!==pa.Connected)throw kn("room state is not connected, can not send message");const n=r||si(8),i=t&&0!==t.length?t:void 0;this.signaling.sendWsMsg("send-message",{msgid:n,target:i,type:"normal",text:e}),jr.debug("send custom message",e,i,n)}async replaceTrack(e,t){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("replaceTrack",e,t);const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");jr.log("pushCameraTrackWithImage",{trackID:e,source:t});const r=this.connectionTransport.publishTracks.find(t=>t.trackID===e);if(void 0===r||void 0===r.track)throw kn(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw kn(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new Gi),void 0===t&&r.track.isReplacedByImageTrack?(await this.connectionTransport.sendHandler.replaceProducerTrack(r,"video"),r.track.isReplacedByImageTrack=!1,void r.track.switchPlayingTrack()):void 0!==t&&r.track&&!r.track.isReplacedByImageTrack?(await r.track.imageStreamTrack.setSource(t),await this.connectionTransport.sendHandler.replaceProducerTrack(r,"image"),r.track.isReplacedByImageTrack=!0,void r.track.switchPlayingTrack()):void 0}leaveRoom(){this.roomState!==pa.Idle?(jr.log("leave room"),gn.addEvent("LeaveRoom",{leave_reason_code:0}),this.signaling&&(Object.keys(this.forwardJobTracks).forEach(e=>this.stopForwardJob(e)),this.signaling.sendDisconnect()),this.releaseRoom()):jr.log("can not leave room, please join room first")}_releasePublishTracks(){}async control(e,t){if(this.roomState!==pa.Connected)throw kn("can not connected to the room, please run joinRoom first");const r=await this.signaling.request("control",{command:e,playerid:t});if(r.error)throw Qn(r.code,r.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),M(this._trackInfo,t=>t.playerid===e.playerid),M(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),ai(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=_o(e);this._users.set(t.userID,t),ai(()=>{jr.debug("user-join",t),this.emit("user-join",t)})}handleAddTracks({tracks:e}){jr.log("receive track-add",e,t({},this._trackInfo));const r=new Set;for(const t of e){const e=ri(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>yo(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([So(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))ai(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});ai(()=>{jr.debug("track-add",e.map(So)),this.emit("track-add",e.map(So))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=M(this._trackInfo,t=>e.map(e=>e.trackid).includes(t.trackid)),n=new Set;for(const e of r){const t=this._users.get(e.playerid);if(!t)continue;t.removePublishedTrackInfo([e.trackid]),t.removeTracksByTrackId([e.trackid]),n.add(t.userID);const r=M(this.subscribeTracks,t=>t.trackID===e.trackid)[0];r&&r.release()}if(this.cleanTrackIdsFromMergeJobs(e.map(e=>e.trackid)),"stream"===this.sessionMode)for(const e of Array.from(n)){const t=this._users.get(e);if(t.published){const e=t.publishedTrackInfo.map(e=>yo(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else ai(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}ai(()=>{jr.debug("track-remove",r.map(So)),this.emit("track-remove",r.map(So))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=ri(this._trackInfo,"trackid",e);if(!n)return;const i=this._users.get(n.playerid);if(!i)return;const a=i.publishedTrackInfo.find(t=>t.trackID===e);a&&(a.muted=r);const o=i.tracks.find(t=>t.info.trackID===e);o&&(o.info.muted=r,o.setMute(r)),n.muted=r;const s=this.subscribeTracks.filter(t=>t.trackID===e)[0];s&&s.setMute(r);let c=void 0;for(let e=0;e{jr.log("user-mute",d),this.emit("user-mute",d)})}ai(()=>{jr.log("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted}))),this.emit("mute-tracks",e.map(e=>({trackID:e.trackid,muted:e.muted})))})}handleCustomMessages({messages:e}){this.emit("messages-received",e.map(bo))}handleQosMessages({messages:e}){const t=[];e.forEach(e=>{try{const r=JSON.parse(e.qos);r.tracks_qos.forEach(n=>{t.push({userID:e.playerid,networkGrade:r.networkGrade,kind:n.kind,trackID:n.track,packetLossRate:n.lostRate,rtt:n.rtt})})}catch(e){jr.warning("parse SignalingQosMessage error: ",e)}}),ha.emit("remote-track-stats",t),this.emit("remote-track-stats",t)}handleDisconnect(e){if(jr.log("handle disconnect",e.code,e),-1===[0,10005,10006].indexOf(e.code)&&gn.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error,event_grade:An.SERVERE,event_category:hn.CORE,event_reason_code:-1,socket_node_info:this.signaling.url}),gn.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=pa.Reconnecting,void setTimeout(()=>this.signaling.initWs(),1e3);switch(e.code){case 10006:this.emit("disconnect",{code:e.code,data:{userID:e.kickedid}});break;default:this.emit("disconnect",{code:e.code})}this.releaseRoom()}handleRemoteUserReconnecting(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnecting",t),this.emit("remote-user-reconnecting",t))}handleRemoteUserReconnected(e){const t=this.users.find(t=>t.userID===e.playerid);t&&(jr.debug("remote-user-reconnected",t),this.emit("remote-user-reconnected",t))}async updateAccessToken(){const e=ti(this.roomToken),t=await vi(e,this.roomToken,this.config.requestTimeout);gn.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=ei(t.accessToken);if(!this.signaling)throw kn("room state is idle when updateAccessToken");this.signaling.accessToken=this.accessToken,this.signaling.setUrl(r.signalingurl2)}async handleAuth(e){if(this.filterSignalTracks(e),jr.debug("handleAuth",e),e.error)return void await this.joinRoomWithToken(this.roomToken,this.userData);e.tracks=e.tracks||[],e.tracks=e.tracks.filter(e=>e.playerid!==this.userID),e.players=e.players||[];const t=this.roomState===pa.Reconnecting;let r={join:[],leave:[],add:[],remove:[],mute:[]};const n=Array.from(this._users.keys()),i=e.players.map(e=>e.playerid);if(r=function(e,t,r,n,i){const a={join:[],leave:[],add:[],remove:[],mute:[]},o=t.map(e=>e.trackid),s=r.map(e=>e.trackid);return o.forEach((n,i)=>{if(t[i].playerid!==e)if(-1===s.indexOf(n))a.remove.push(t[i]);else{const e=r.find(e=>e.trackid===n),o=t[i];e.versionid!==o.versionid&&(a.remove.push(o),a.add.push(e))}}),s.forEach((n,i)=>{if(r[i].playerid===e)return;const s=o.indexOf(n);-1===s?(a.add.push(r[i]),a.mute.push({trackid:n,muted:r[i].muted})):r[i].muted!==t[s].muted&&a.mute.push({trackid:n,muted:r[i].muted})}),n.forEach(t=>{t!==e&&-1===i.indexOf(t)&&a.leave.push({playerid:t})}),i.forEach(t=>{t!==e&&-1===n.indexOf(t)&&a.join.push({playerid:t})}),a}(this.userID,this._trackInfo,e.tracks,n,i),this.roomState=pa.Connected,t)jr.debug("get missing events",r),r.remove.length>0&&this.handleRemoveTracks({tracks:r.remove}),r.leave.length>0&&r.leave.forEach(this.handlePlayerOut.bind(this)),r.join.length>0&&r.join.forEach(this.handlePlayerIn.bind(this)),r.add.length>0&&this.handleAddTracks({tracks:r.add}),r.mute.length>0&&this.handleMute({tracks:r.mute});else{this._trackInfo=e.tracks,this._users.clear();for(const t of e.players||[]){const e=_o(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(So)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===B.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===B.Connecting);this.connectionTransport.extendedRtpCapabilities=e.rtpcaps,(!this.connectionTransport.sendHandler.isPcReady||this.connectionTransport.sendHandler._isRestartingICE||t.length>0)&&this.connectionTransport.reconnectProducer(),(!this.connectionTransport.recvHandler.isPcReady||this.connectionTransport.recvHandler._isRestartingICE||r.length>0)&&this.connectionTransport.resetRecvHandler()}else this.connectionTransport=this.createConnectionTransport(e.rtpcaps)}createConnectionTransport(e){const t=this.signaling,r=new Aa(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(ko),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(i)}),r.on("@needsubpc",(e,r,n)=>{t.request("subpc",{tracks:e.map(e=>this.profiles.get(e)?{trackid:e,profile:this.profiles.get(e)}:{trackid:e}),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void r(e);case 10052:throw Zn();default:throw kn(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=B.Connecting),this._subscribe(e,!0)}).on("@needrepub",e=>{this._publish(e.map(e=>e.track),!0)}).on("@needresetrecv",()=>{this.subscribeTracks.filter(e=>!!e.track).forEach(e=>{e.track.removeAllListeners("@ended")})}),r}cleanTrackIdsFromMergeJobs(e){M(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)M(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new wi,t=t=>{e.onAddTracks(t)},r=t=>{e.onRemoveTracks(t)};return this.on("track-add",t),this.on("track-remove",r),e.getCurrentTracks=(()=>{if(!this.connectionTransport)return[];const e=this._trackInfo.map(So),t=this.connectionTransport.publishTracks.map(e=>e.track.info);return e.concat(t)}),e.addMergeTrack=((e,t)=>{this._addMergeTracks(e,t)}),e.release=(()=>{this.off("track-add",t),this.off("track-remove",r)}),e}getAllMerger(){const e=[];this.merger&&e.push(this.merger);for(const t in this.mergeJobMerger)e.push(this.mergeJobMerger[t]);return e}releaseRoom(){this.releaseSession(),this.signaling&&(this.signaling.release(),this.signaling=void 0),gn.addEvent("UnInit",{id:`${this.sessionMode}_${Date.now()}`},!0),this.connectionTransport&&(this.connectionTransport.release(),this.connectionTransport=void 0),this.getAllMerger().map(e=>{e.release()}),this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this.merger=void 0,this.mergeJobMerger={},this.roomState=pa.Idle,this._trackInfo=[],this._users.clear(),this.userID=void 0,this.subscribeTracks.forEach(e=>{e.release()}),this.subscribeTracks=[],this.profile=void 0,this.profiles.clear(),clearInterval(this.volumeIndicatorTimer),this._mode=dn.RTC,this._role=un.AUDIENCE,this._privileges=["subscribe","publish"]}registerVolumeIndicatorEvent(){clearInterval(this.volumeIndicatorTimer),this.volumeIndicatorTimer=setInterval(()=>{if(!this.connectionTransport)return!1;const e=[...this.subscribedTracks,...this.publishedTracks].filter(e=>"audio"===e.info.kind&&!e.info.muted).map(e=>({trackID:e.info.trackID,userID:e.userID,level:e.getCurrentVolumeLevel()||0,muted:e.info.muted}));if(0===this.volumeIndicatorHistory.length)this.volumeIndicatorHistory.push(e.filter(e=>e.level>=.1));else{const r=this.volumeIndicatorHistory[this.volumeIndicatorHistory.length-1],n={};r.forEach(e=>n[e.trackID]=e.level);const i=[];for(let r of e)r.level>=.1?n[r.trackID]?r.level>n[r.trackID]?i.push(r):i.push(t({},r,{level:n[r.trackID]})):i.push(r):n[r.trackID]&&i.push(t({},r,{level:n[r.trackID]}));this.volumeIndicatorHistory.push(i),4===this.volumeIndicatorHistory.length&&(this.emit("volume-indicator",i.filter(e=>!e.muted).map(e=>({trackID:e.trackID,userID:e.userID,level:e.level}))),this.volumeIndicatorHistory=[])}},500)}async startMediaRelay(e){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("start-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("StartMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const r=await Promise.all(e.destRoomInfos.map(async e=>{const t=ti(e.roomToken),r=await Ti(t,e.roomToken,this.config.requestTimeout);return{roomName:e.roomName,playerId:t.userId,token:r.relayToken}})),n=await this.signaling.request("update-media-relay",{destinationInfos:r.reduce((e,r)=>t({},e,{[r.roomName]:t({},r)}),{})});if(gn.addEvent("UpdateMediaRelay",{result_code:n.code,destination_infos:r.map(e=>({room_name:e.roomName,room_token:e.token,uid:e.playerId}))}),0!==n.code)throw Jn(n.code,n.error);const i=n.status;return Object.keys(i).reduce((e,r)=>t({},e,{[r]:i[r].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==pa.Connected)throw kn("no signaling model, please run joinRoomWithToken first");if(this._mode===dn.RTC)throw On("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===un.AUDIENCE)throw xn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(gn.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Jn(e.code,e.error);const r=e.status;return Object.keys(r).reduce((e,n)=>t({},e,{[n]:r[n].state}),{})}catch(e){throw e instanceof Sn?e:kn(e instanceof Error?e.message:String(e))}}}class va extends ga{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",gn.addEvent("Init",{id:`${this.sessionMode}_${Date.now()}`})}get mergeStreamTracks(){return this.defaultMergeJobTracks}get mergeStreamJobTracks(){return this.mergeJobTracks}async join(e,t){return await this.joinRoomWithToken(e,t)}leave(){this.leaveRoom(),this.isAudioMastered=!1,this.isVideoMastered=!1}async publish(e){const t=this.isAudioMastered,r=this.isVideoMastered;for(const t of e)"audio"===t.info.kind&&(this.isAudioMastered?t.setMaster(!1):(t.setMaster(!0),this.isAudioMastered=!0)),"video"===t.info.kind&&(this.isVideoMastered?t.setMaster(!1):(t.setMaster(!0),this.isVideoMastered=!0));try{return await this._publish(e)}catch(e){throw this.isAudioMastered=t,this.isVideoMastered=r,e}}async unpublish(e){const t=await this._unpublish(e);return this.isAudioMastered=this.publishedTracks.some(e=>!("audio"!==e.info.kind||!e.master)),this.isVideoMastered=this.publishedTracks.some(e=>!("video"!==e.info.kind||!e.master)),t}async subscribe(e,t=!1,r){return await this._subscribe(e,!1,t,r)}async unsubscribe(e){return await this._unsubscribe(e)}setProfile(e,t){this._setProfile(e,t)}setReconnectTimes(e){this._setReconnectTimes(e)}getReconnectTimes(){return this._getReconnectTimes()}muteTracks(e){this._muteTracks(e)}async addMergeStreamTracks(e,t){await this._addMergeTracks(e,t)}async removeMergeStreamTracks(e,t){await this._removeMergeTracks(e,t)}stopMergeStream(e){this._stopMerge(e)}filterSignalTracks(){}releaseSession(){}}class Ta{constructor(e,t){this.networkQuality=tn.UNKNOWN,this._client=e,this._user=t,this.userID=t.userID,this.userData=t.userData}getVideoTracks(){let e=[];for(let t of this._client._remoteTracks)t.isVideo()&&t.userID===this.userID&&e.push(t);return e}getAudioTracks(){let e=[];for(let t of this._client._remoteTracks)t.isAudio()&&t.userID===this.userID&&e.push(t);return e}}class ba extends C{constructor(){super(...arguments),this._isMuted=!1}get mediaElement(){return this._track&&this._track.mediaElement}get track(){return this._track}set track(e){e&&(this._track=e,this._track.on("ended",()=>{ha.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{ha.emit("audioBuffer",t,e.mediaTrack.id)}),this.trackID=this._track.info.trackID,this.userID=this._track.info.userID,this.tag=this._track.info.tag,this._kind=this._track.info.kind,this._isMuted=!!this._track.info.muted)}play(e,t={}){return this._track?"boolean"==typeof t?this._track.play(e,t,{}):this._track.play(e,void 0,t):Promise.reject()}isAudio(){return"audio"===this._kind}isVideo(){return"video"===this._kind}isMuted(){return this._isMuted}getMediaStreamTrack(){return this.track?this.track.mediaTrack:void 0}}class Sa extends ba{constructor(e){super(),this._isSubScribed=!1,this.uplinkStats={uplinkRTT:0,uplinkLostRate:0},this._kind=e.kind,this.trackID=e.trackID,this.userID=e.userID,this.tag=e.tag,ha.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),ha.on("mute-tracks",e=>{for(const t of e)t.trackID===this.trackID&&(this._isMuted=t.muted,this.emit("mute-state-changed",t.muted))})}isSubscribed(){return this._isSubScribed}}class ya extends Sa{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=rn.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),ha.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=rn.HIGH,this.emit("profile-changed",rn.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=rn.MEDIUM,this.emit("profile-changed",rn.MEDIUM);break;case"low":this.profile=rn.LOW,this.emit("profile-changed",rn.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){ha.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw kn("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?rn.LOW:rn.HIGH;ha.emit("set-profile",this.trackID,t)}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){const e={downlinkFrameRate:0,downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkFrameRate=t[0].frameRate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,this.isMultiProfileEnabled&&(e.profile=this.profile),e)}}class ka extends Sa{constructor(e){super(e),ha.on("audioBuffer",(e,t)=>{this._track&&t===this._track.mediaTrack.id&&this.emit("audioFrame",e)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={downlinkBitrate:0,downlinkLostRate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.downlinkBitrate=t[0].bitrate,e.downlinkLostRate=t[0].packetLossRate,e.uplinkLostRate=this.uplinkStats.uplinkLostRate,e.uplinkRTT=this.uplinkStats.uplinkRTT,e)}}class _a extends C{constructor(e){super(),this.connectionState=Ur.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new va({transportPolicy:e}),this.session.on("user-join",e=>{const t=new Ta(this,e);this.remoteUsers.push(t),this.emit("user-joined",e.userID,e.userData)}),this.session.on("user-leave",e=>{this.remoteUsers=this.remoteUsers.filter(t=>t.userID!==e.userID),this.emit("user-left",e.userID)}),this.session.on("track-add",e=>{if(0===e.length)return;const t=e.map(e=>"audio"===e.kind?new ka(e):new ya(e));this._remoteTracks.push(...t);const r=Gr(t,e=>e.userID);Object.entries(r).forEach(([e,t])=>{this.emit("user-published",e,t)})}),this.session.on("track-remove",e=>{if(0===e.length)return;const t=e[0].userID,r=new Set;for(const t of e)r.add(t.trackID);let n=[],i=[];for(const e of this._remoteTracks)r.has(e.trackID)?n.push(e):i.push(e);this._remoteTracks=i,this.emit("user-unpublished",t,n)}),this.session.on("mute-tracks",e=>{0!==e.length&&ha.emit("mute-tracks",e)}),ha.on("set-mute-tracks",(e,t,r)=>{if(r===this.getClientKey())this.session.muteTracks([{trackID:e,muted:t}]);else if(""===r)throw kn("can not setMuted,please publish track first")}),this.session.on("room-state-change",e=>{switch(e){case pa.Idle:this.connectionState=Ur.DISCONNECTED;break;case pa.Connecting:this.connectionState=Ur.CONNECTING;break;case pa.Reconnecting:this.connectionState=Ur.RECONNECTING;break;case pa.Connected:this.connectionState=this.connectionState===Ur.CONNECTING?Ur.CONNECTED:Ur.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===Ur.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=nn.LEAVE;break;case 10006:e=nn.KICKED_OUT;break;default:e=nn.ERROR}let t={reason:e};if(e===nn.ERROR)switch(t.errorCode=this._disconnectedInfo.code,t.errorCode){case 10001:t.errorMessage="token 错误";break;case 10002:t.errorMessage="token 过期";break;case 10004:t.errorMessage="reconnect token 过期";break;case 10007:t.errorMessage="断线重连失败";break;case 10022:t.errorMessage="该用户在其他页面或终端登录";break;case 10011:t.errorMessage="房间人数已满";break;case 10012:t.errorMessage="房间已关闭";break;default:t.errorMessage="unexpected error"}this.release(),this.emit("connection-state-changed",this.connectionState,t)}else this.emit("connection-state-changed",this.connectionState)}),this.session.on("messages-received",e=>{for(let t of e){const e={ID:t.msgid,userID:t.userID,content:t.data,timestamp:t.timestamp};this.emit("message-received",e)}}),this.session.on("media-relay-state-changed",(e,t)=>{this.emit("media-relay-state-changed",e,t)}),this.session.on("remote-user-reconnecting",e=>{this.emit("user-reconnecting",e.userID)}),this.session.on("remote-user-reconnected",e=>{this.emit("user-reconnected",e.userID)}),this.session.on("forward-job-connected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,en.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{ha.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),ha.on("remote-track-stats",e=>{for(let t of e){const e=this.remoteUsers.filter(e=>e.userID===t.userID)[0];if(!e)return;switch(t.networkGrade){case x.INVALID:e.networkQuality=tn.UNKNOWN;break;case x.POOR:e.networkQuality=tn.POOR;break;case x.FAIR:e.networkQuality=tn.FAIR;break;case x.GOOD:e.networkQuality=tn.GOOD;break;case x.EXCELLENT:e.networkQuality=tn.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),ha.on("set-profile",(e,t)=>{switch(t){case rn.HIGH:this.session.setProfile(e,"high");break;case rn.MEDIUM:this.session.setProfile(e,"medium");break;case rn.LOW:this.session.setProfile(e,"low")}}),ha.on("setMediaStreamTrack",(e,t,r,n,i)=>{if(r===this.getClientKey())this.session.replaceTrack(e,t).then(n).catch(i);else if(""===r)throw kn("can not setMediaStreamTrack,please publish track first")})}setTransportPolicy(e){this.session.config.transportPolicy=e}get userID(){return this.session.userID}get userData(){return this.session.userData}get roomName(){return this.session.roomName}getRemoteUser(e){return this.remoteUsers.find(t=>t.userID===e)}async setClientMode(e){this.session.setClientMode(e)}async setClientRole(e){await this.session.setClientRole(e)}async join(e,t){await this.session.joinRoomWithToken(e,t)}async leave(){await Promise.resolve().then(()=>this.session.leave()),this.release()}release(){this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[]}async publish(e){if(Array.isArray(e)){e.find(e=>e.isVideo())&&(this.session.simulcast=!!e.filter(e=>e.isVideo()).find(e=>e.isMultiProfileEnabled)),await this.session.publish(e.map(e=>e.track));for(const t of e)t.trackID=t.track.info.trackID,t.userID=this.session.userID,t.client=this.getClientKey();this._localTracks.push(...e)}else e.isVideo()&&e.isMultiProfileEnabled&&(this.session.config.simulcast=!0),await this.session.publish([e.track]),e.trackID=e.track.info.trackID,e.userID=this.session.userID,e.client=this.getClientKey(),this._localTracks.push(e)}getClientKey(){return Nr(`${this.roomName?this.roomName:""}${this.userID?this.userID:""}${this.session.appId?this.session.appId:""}`)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw kn("target tracks has not published");await this.session.unpublish(e.map(e=>e.trackID)),this._localTracks=this._localTracks.filter(t=>!e.includes(t))}else{if(!this._localTracks.includes(e))throw kn("target tracks has not published");await this.session.unpublish([e.trackID]),this._localTracks=this._localTracks.filter(t=>t!==e)}}async subscribe(e){let t;if(Array.isArray(e)){t=await this.session.subscribe(e.map(e=>e.trackID));let r=[],n=[];for(let i of t){const t=e.filter(e=>e.trackID===i.info.trackID);if(0===t.length)continue;const a=t[0];a.track=i,a._isSubScribed=!0,"audio"===i.info.kind?n.push(a):r.push(a)}return{audioTracks:n,videoTracks:r}}if((t=await this.session.subscribe([e.trackID])).length>0){const r=t[0];return e.track=r,e._isSubScribed=!0,"audio"===r.info.kind?{videoTracks:[],audioTracks:[e]}:{audioTracks:[],videoTracks:[e]}}return{audioTracks:[],videoTracks:[]}}async unsubscribe(e){Array.isArray(e)?(await this.session.unsubscribe(e.map(e=>e.trackID)),e.forEach(e=>{e._isSubScribed=!1})):(await this.session.unsubscribe([e.trackID]),e._isSubScribed=!1)}async sendMessage(e,t,r){Array.isArray(r)?await Promise.resolve().then(()=>this.session.sendCustomMessage(t,r.map(e=>e.userID),e)):await Promise.resolve().then(()=>this.session.sendCustomMessage(t,[],e))}async startDirectLiveStreaming(e){await this.session.createForwardJob(ii({userConfigExtraInfo:e.userConfigExtraInfo,jobId:e.streamID,publishUrl:e.url,audioTrackId:e.audioTrack&&e.audioTrack.trackID,videoTrackId:e.videoTrack&&e.videoTrack.trackID}))}async stopDirectLiveStreaming(e){await this.session.stopForwardJob(e)}async startTranscodingLiveStreaming(e){await this.session.createMergeJob(e.streamID,ii({publishUrl:e.url,height:e.height,width:e.width,fps:e.videoFrameRate,kbps:e.bitrate,stretchMode:e.renderMode,watermarks:e.watermarks&&e.watermarks.map(e=>({x:e.x,y:e.y,w:e.width,h:e.height,url:e.url})),background:e.background&&{x:e.background.x,y:e.background.y,w:e.background.width,h:e.background.height,url:e.background.url},maxRate:e.maxBitrate,minRate:e.minBitrate,holdLastFrame:e.holdLastFrame})),e.transcodingTracks&&await this.setTranscodingLiveStreamingTracks(e.streamID,e.transcodingTracks)}async stopTranscodingLiveStreaming(e){await this.session.stopMergeStream(e)}async setTranscodingLiveStreamingTracks(e,t){const r=t.map(e=>ii({trackID:e.trackID,x:e.x,y:e.y,w:e.width,h:e.height,z:e.zOrder,stretchMode:e.renderMode}));e?await this.session.addMergeStreamTracks(r,e):await this.session.addMergeStreamTracks(r)}async removeTranscodingLiveStreamingTracks(e,t){e?await this.session.removeMergeStreamTracks(t.map(e=>e.trackID),e):await this.session.removeMergeStreamTracks(t.map(e=>e.trackID))}getNetworkQuality(){let e=tn.UNKNOWN;const t=this._localTracks.reduce((e,t)=>t.track?[...e,...t.track.getStats().map(e=>e.networkGrade)]:[...e],[]);return t.includes(x.POOR)?e=tn.POOR:t.includes(x.FAIR)?e=tn.FAIR:t.includes(x.GOOD)?e=tn.GOOD:t.includes(x.EXCELLENT)?e=tn.EXCELLENT:e}getUserNetworkQuality(e){let t=tn.UNKNOWN;const r=this.remoteUsers.filter(t=>t.userID===e)[0];return r?t=r.networkQuality:(jr.warning("cannot find userID: ",e),t)}enableAudioVolumeIndicator(){this.session.registerVolumeIndicatorEvent()}async kickOutUser(e){this.remoteUsers.find(t=>t.userID===e)?await this.session.kickoutUser(e):jr.warning("cannot find userID: ",e)}async startMediaRelay(e){return this.session.startMediaRelay(e)}async updateMediaRelay(e){return this.session.updateMediaRelay(e)}async stopMediaRelay(){return this.session.stopMediaRelay()}}class wa extends ba{constructor(e){super(),this.track=e,this.client="",ha.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,ha.emit("set-mute-tracks",this.trackID,e,this.client)}destroy(){this.track&&this.track.release()}}class Ea extends wa{constructor(e){super(e),ha.on("audioBuffer",(t,r)=>{r===e.mediaTrack.id&&this.emit("audioFrame",t)})}setVolume(e){this.track&&this.track.setVolume(e)}getVolumeLevel(){if(this.track)return this.track.getCurrentVolumeLevel()}getCurrentTimeDomainData(){if(this.track)return this.track.getCurrentTimeDomainData()}getCurrentFrequencyDomainData(){if(this.track)return this.track.getCurrentFrequencyData()}async setPlaybackDevice(e){if(this.track)return this.track.setPlaybackDevice(e)}getStats(){const e={uplinkBitrate:0,uplinkRTT:0,uplinkLostRate:0};if(!this._track)return e;const t=this._track.getStats();return 0===t.length?e:(e.uplinkBitrate=t[0].bitrate,e.uplinkRTT=t[0].rtt,e.uplinkLostRate=t[0].packetLossRate,e)}}class Ca extends wa{constructor(e){super(e),this.isMultiProfileEnabled=!1}getLowStreamConfig(){if(this._track)return this._track.lowStreamConfig}getCurrentFrameData(){return this._track?this._track.getCurrentFrameDataURL():"data:,"}getStats(){if(!this._track)return[];let e=this._track.getStats();if(0===e.length)return[];if(1===e.length){return e.map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}))}{const t=(e=e.filter(e=>0!==e.bitrate).sort((e,t)=>e.bitrate-t.bitrate)).map(e=>({uplinkBitrate:e.bitrate,uplinkFrameRate:e.frameRate,uplinkLostRate:e.packetLossRate,uplinkRTT:e.rtt}));return t[0]&&(t[0].profile=rn.LOW),t[1]&&(t[1].profile=rn.MEDIUM),t[2]&&(t[2].profile=rn.HIGH),2==t.length&&t[1].profile===rn.MEDIUM&&(t[1].profile=rn.HIGH),t}}setOptimizationMode(e){if(!this._track)return!1;const t=this._track.mediaTrack;return"contentHint"in t&&(t.contentHint=e,t.contentHint===e)}}class Ma extends Ca{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class Pa extends Ui{constructor(e){const t=Ii.createMediaStreamDestination();super(t.stream.getAudioTracks()[0],e,"local"),this.sourceType=L.MIXING,this.initAudioManager(!0),this.destination=t,this.inputList=[]}appendAudioSource(e){this.inputList.find(t=>t.track===e)?jr.warning("track is already in the track list"):(this.inputList.push({track:e}),e.on("ended",()=>{this.emit("ended")}),e.audioManager.gainNode.connect(this.destination))}removeAudioSource(e){const t=this.inputList.find(t=>t.track===e);if(t){try{t.track.audioManager.gainNode.disconnect(this.destination)}catch(e){}M(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class Ia{constructor(e,t){this.effectSourceMap=new Map,this.playback=!0,this.output=e,this.playbackEngine=t}get effectList(){return Array.from(this.effectSourceMap.keys())}getEffectTrack(e){return this.effectSourceMap.get(e)}playEffect(e,t){const r=this.effectSourceMap.get(e);r?(t&&r.setVolume(t),this.playback&&r.audioManager.audioSource&&this.playbackEngine.addAudioNode(r.audioManager.gainNode),r.startAudioSource()):jr.warning("can not find target effect",e)}async addEffectSource(e,t){if(this.effectSourceMap.has(t))return void jr.warning("duplicate effect key!",t);const r=await xa.createAudioTrackFromSource(e);this.effectSourceMap.set(t,r),this.output.appendAudioSource(r)}removeEffectSource(e){let t=[];t=e?[e]:Array.from(this.effectSourceMap.keys());for(const e of t){const t=this.effectSourceMap.get(e);if(!t)return;this.output.removeAudioSource(t),t.release(),this.effectSourceMap.delete(e)}}}class Ra{constructor(){this.gainNode=Ii.createGain(),this.gainNode.connect(Ii.destination)}setPlayingVolume(e){this.gainNode.gain.setValueAtTime(e,Ii.currentTime)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class Da{constructor(e){if(this.playbackEngine=new Ra,this.sourcePlayebackState=!1,!(e instanceof Ui))throw kn("audio mixing manager: origin track is not audio track");this.outputTrack=new Pa,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new Ia(this.outputTrack,this.playbackEngine),this.musicManager=new Ba(this.outputTrack,this.playbackEngine)}getMusicPlaybackState(){return this.musicManager.playback}setMusicPlaybackState(e){this.musicManager.playback!==e&&(this.musicManager.playback=e,this.musicManager.audioNode&&(e?this.playbackEngine.addAudioNode(this.musicManager.audioNode):this.playbackEngine.removeAudioNode(this.musicManager.audioNode)))}getSourcePlaybackState(){return this.sourcePlayebackState}setSourcePlaybackState(e){this.sourcePlayebackState!==e&&(this.sourcePlayebackState=e,this.source.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(this.source.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.source.audioManager.gainNode)))}getEffectPlaybackState(){return this.effectManager.playback}setEffectPlaybackState(e){this.effectManager.playback!==e&&(this.effectManager.playback=e,this.effectManager.effectSourceMap.forEach((t,r)=>{t.audioManager.audioSource&&(e?this.playbackEngine.addAudioNode(t.audioManager.gainNode):this.playbackEngine.removeAudioNode(t.audioManager.gainNode))}))}setBitrate(e){this.outputTrack.setInfo({kbps:e})}setTag(e){this.outputTrack.setInfo({tag:e})}release(){this.effectManager.removeEffectSource(),this.musicManager.stopMusicMixing(),this.outputTrack.removeAudioSource(this.source),this.outputTrack.release(),this.playbackEngine.release()}}class Oa extends Da{constructor(e){if(!e._audioTrack)throw kn("input stream do not have audio track");super(e._audioTrack),this.input=e;const t=[this.outputTrack];this.input._videoTrack&&t.push(this.input._videoTrack),this.outputStream=new Bo(t,"send",this.input.userID)}setBitrate(e,t){e&&this.outputStream._audioTrack&&this.outputStream._audioTrack.setKbps(e),t&&this.outputStream._videoTrack&&this.outputStream._videoTrack.setKbps(t)}}var xa;!function(e){async function t(e,t="anonymous",r,n){return new Promise((i,a)=>{const o=document.createElement("audio");o.preload="auto",o.src=e,o.crossOrigin=t,o.addEventListener("error",()=>{a(Fn())});const s=()=>{o.removeEventListener("canplay",s);const e=new xo(o);n&&e.setKbps(n),e.setInfo({tag:r}),i(e)};o.addEventListener("canplay",s)})}function r(e,t,r){return new Promise((n,a)=>{const o=new FileReader;o.onload=(e=>{i(e.target.result).then(e=>{const i=new xo(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(()=>{a(Fn())})}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new xo(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===Ii.state&&await Ii.resume();return await(()=>new Promise((t,r)=>{Ii.decodeAudioData(e,e=>{t(e)},e=>{r(Pn(e))})}))()}e.createAudioTrackFromURL=t,e.createAudioTrackFromFile=r,e.createAudioTrackFromBuffer=n,e.createAudioTrackFromSource=async function(e,i,a){return e instanceof File?await r(e,i,a):e instanceof AudioBuffer?n(e,i,a):"string"==typeof e?await t(e,"anonymous",i,a):Promise.reject(Fn())},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new Da(e)},e.createAudioMixingManagerFromStream=function(e){return new Oa(e)}}(xa||(xa={}));class Ba extends C{constructor(e,t){super(),this.musicOption={loop:!1,volume:1},this.playback=!0,this.output=e,this.playbackEngine=t}get audioNode(){return this.musicTrack?this.musicTrack.audioManager.gainNode:null}setMusicOption(e){this.musicOption=Object.assign(this.musicOption,e),this.musicTrack&&(this.musicTrack.setVolume(this.musicOption.volume),this.musicTrack.setLoop(this.musicOption.loop))}async startMusicMixing(e,t=!1){if(this.musicTrack)return this.stopMusicMixing(t),await this.startMusicMixing(e);try{if(this.musicTrack=await xa.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw kn("can not find audio source");this.playback&&this.audioNode&&this.playbackEngine.addAudioNode(this.audioNode),this.musicTrack.on("audio-state-change",(e,t)=>{this.emit("music-state-change",e,t)}),this.musicTrack.startAudioSource()}catch(e){e instanceof Sn&&this.emit("error",e)}}pauseMusicMixing(){this.musicTrack?this.musicTrack.pauseAudioSource():jr.warning("can not find target music, please run startAudioMixing")}resumeMusicMixing(){this.musicTrack?this.musicTrack.resumeAudioSource():jr.warning("can not find target music, please run startAudioMixing")}stopMusicMixing(e=!1){this.musicTrack&&(this.musicTrack.stopAudioSource(e),this.output.removeAudioSource(this.musicTrack),this.musicTrack.release(),this.musicTrack=void 0)}getMusicDuration(){return this.musicTrack?this.musicTrack.getDuration():0}getMusicCurrentTime(){return this.musicTrack?this.musicTrack.getCurrentTime():0}setMusicCurrentTime(e){if(this.musicTrack&&(this.musicTrack.setCurrentTime(e),!this.musicTrack.audioManager.audioSource))throw kn("can not find audio source")}}class La extends C{constructor(e,t,r){super(),this.mixingTrack=e,this.source=t,this.playbackEngine=r,this.musicVolume=1,this.audioMusicManger=new Ba(this.mixingTrack,this.playbackEngine),this.handleAudioMusicManger()}handleAudioMusicManger(){this.audioMusicManger.on("error",e=>{throw this.emit(La.ERROR,e.code,e.message),e}),this.audioMusicManger.on("music-state-change",e=>{switch(e){case H.IDLE:this.emit(La.STATE_CHANGED,$r.IDLE);break;case H.LOADING:break;case H.PLAY:this.emit(La.STATE_CHANGED,$r.MIXING);break;case H.PAUSE:this.emit(La.STATE_CHANGED,$r.PAUSED);break;case H.END:this.loopCount>1?(--this.loopCount,this._start(this.loopCount,!0)):this.emit(La.STATE_CHANGED,$r.COMPLETED);break;case H.STOP:this.emit(La.STATE_CHANGED,$r.STOPPED)}})}async start(e=1){this._start(e)}stop(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}resume(){this.audioMusicManger.resumeMusicMixing()}pause(){this.audioMusicManger.pauseMusicMixing()}getDuration(){return this.audioMusicManger.getMusicDuration()}getCurrentPosition(){return this.audioMusicManger.getMusicCurrentTime()}seekTo(e){this.audioMusicManger.setMusicCurrentTime(e)}getMixingVolume(){return this.musicVolume}setMixingVolume(e){let t=Number(e);t=isNaN(t)?0:t,this.musicVolume=t,this.audioMusicManger.setMusicOption({volume:this.musicVolume})}release(){this.loopCount=1,this.audioMusicManger.stopMusicMixing()}async _start(e=1,t=!1){this.loopCount=Math.max(-1,Number(e)),this.audioMusicManger.setMusicOption({loop:-1===this.loopCount,volume:this.musicVolume}),0!==this.loopCount&&await this.audioMusicManger.startMusicMixing(this.source,t)}}La.STATE_CHANGED="state-changed",La.ERROR="error";class Na extends C{constructor(e,t,r){super(),this.outputTrack=e,this.playbackEngine=t,this.effectID=r,this.playback=!0,this.loopCount=1}getDuration(){return this.getValidateAudioTrack().getDuration()}getID(){return this.effectID}getFilePath(){return this._filePath}setLoopCount(e){this.loopCount=-1===e?Number.MAX_SAFE_INTEGER:Math.max(0,Number(e)),0===this.loopCount&&this.stopEffect()}getLoopCount(){return this.loopCount===Number.MAX_SAFE_INTEGER?-1:this.loopCount}playEffect(e){if(this.loopCount>0){const t=this.getValidateAudioTrack();e&&t.setVolume(e),this.playback&&t.audioManager.audioSource&&this.playbackEngine.addAudioNode(t.audioManager.gainNode),t.startAudioSource()}}stopEffect(){const e=this.getValidateAudioTrack();this.loopCount=1,e.stopAudioSource()}resumeEffect(){this.getValidateAudioTrack().resumeAudioSource()}pauseEffect(){this.getValidateAudioTrack().pauseAudioSource()}getCurrentPosition(){return this.getValidateAudioTrack().getCurrentTime()}async addEffectSource(e){try{this.audioTrack=await xa.createAudioTrackFromSource(e),this._filePath="string"==typeof e?e:URL.createObjectURL(e),this.handleAudioTrack(),this.outputTrack.appendAudioSource(this.audioTrack)}catch(e){e instanceof Sn&&this.emit(Na.ERROR,e)}}removeEffectSource(){void 0!==this.audioTrack&&(this.outputTrack.removeAudioSource(this.audioTrack),this.audioTrack.release(),this.audioTrack=void 0)}getValidateAudioTrack(){if(void 0===this.audioTrack){const e=jn();throw this.emit(Na.ERROR,e),e}return this.audioTrack}handleAudioTrack(){this.audioTrack&&this.audioTrack.on("audio-state-change",e=>{switch(e){case H.END:this.loopCount>1?(this.loopCount=this.loopCount===Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:this.loopCount-1,this.playEffect(this.loopCount)):this.emit(Na.FINISHED)}})}}Na.FINISHED="finished",Na.ERROR="error";class Ga extends C{constructor(e,t){super(),this.mixingTrack=e,this.playbackEngine=t,this.audioEffectMap=new Map,this.startedList=new Map}addListener(e,t){return super.addListener(e,t)}async createAudioEffect(e,t){if(this.audioEffectMap.has(e)){const e=Vn();throw this.emit(Ga.ERROR,e.code,e.message),e}{const r=new Na(this.mixingTrack,this.playbackEngine,e);return this.handleAudioEffect(e,r),await r.addEffectSource(t),this.audioEffectMap.set(e,r),r}}start(e){this.getValidateAudioEffect(e).playEffect(1),this.startedList.set(e,!0)}stop(e){this.getValidateAudioEffect(e).stopEffect()}pause(e){this.getValidateAudioEffect(e).pauseEffect()}resume(e){this.getValidateAudioEffect(e).resumeEffect()}stopAll(){this.audioEffectMap.forEach(e=>{e.stopEffect()})}pauseAll(){this.audioEffectMap.forEach(e=>{e.pauseEffect()})}resumeAll(){this.audioEffectMap.forEach(e=>{e.resumeEffect()})}getCurrentPosition(e){const t=this.getValidateAudioEffect(e);return this.startedList.get(e)?Math.floor(1e3*t.getCurrentPosition()):0}setVolume(e,t){this.getValidateAudioEffect(e).getValidateAudioTrack().setVolume(t)}getVolume(e){return this.getValidateAudioEffect(e).getValidateAudioTrack().getVolume()}setAllEffectsVolume(e){this.audioEffectMap.forEach(t=>{t.getValidateAudioTrack().setVolume(e)})}release(){this.audioEffectMap.forEach(e=>{e.removeEffectSource()}),this.audioEffectMap.clear()}getValidateAudioEffect(e){const t=this.audioEffectMap.get(e);if(void 0===t){const e=Un();throw this.emit(Ga.ERROR,e),e}return t}handleAudioEffect(e,t){t.on(Na.FINISHED,()=>{this.emit(Ga.FINISHED,e)}),t.on(Na.ERROR,e=>{throw this.emit(Ga.ERROR,e.code,e.message),e})}}Ga.FINISHED="finished",Ga.ERROR="error";class Ha extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:case H.STOP:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){this._mixingManager.musicManager.setMusicOption({loop:e}),await this._mixingManager.musicManager.startMusicMixing(this.source)}stop(){this._mixingManager.musicManager.stopMusicMixing()}resume(){this._mixingManager.musicManager.resumeMusicMixing()}pause(){this._mixingManager.musicManager.pauseMusicMixing()}getDuration(){return this._mixingManager.musicManager.getMusicDuration()}getCurrentPosition(){return this._mixingManager.musicManager.getMusicCurrentTime()}seekTo(e){this._mixingManager.musicManager.setMusicCurrentTime(e)}setPlayingVolume(e){this._mixingManager.playbackEngine.setPlayingVolume(e)}setMixingVolume(e,t){this._mixingManager.source.setVolume(e),this._mixingManager.musicManager.setMusicOption({volume:t})}}class Fa extends Ea{constructor(e){const t=new Da(e);super(t.outputTrack),this.sourceTrack=e,this.outputTrack=t.outputTrack,this.mixingManager=t,this.playbackEngine=new Ra,this.earMonitorEnable=!1}createAudioMusicMixer(e){return this.audioMusicMixer&&this.audioMusicMixer.release(),this.audioMusicMixer=new La(this.outputTrack,e,this.playbackEngine),this.audioMusicMixer}createAudioEffectMixer(){return this.audioEffectMixer?this.audioEffectMixer:(this.audioEffectMixer=new Ga(this.outputTrack,this.playbackEngine),this.audioEffectMixer)}isEarMonitorEnabled(){return this.earMonitorEnable}setEarMonitorEnabled(e){this.earMonitorEnable=e,this.earMonitorEnable?this.playbackEngine.addAudioNode(this.sourceTrack.audioManager.gainNode):this.playbackEngine.removeAudioNode(this.sourceTrack.audioManager.gainNode)}setPlayingVolume(e){let t=Number(e);t=isNaN(t)?0:t>1?1:t<0?0:t,this.playbackEngine.setPlayingVolume(t)}destroy(){this.mixingManager.release(),this.audioEffectMixer&&this.audioEffectMixer.release(),this.audioMusicMixer&&this.audioMusicMixer.release(),this.playbackEngine.release(),this.sourceTrack.release()}createAudioMixer(e){return new Ha(this.mixingManager,e)}setVolume(e){this.sourceTrack&&this.sourceTrack.setVolume(e)}}class ja extends Ca{constructor(e){super(e)}}class Va extends Ea{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case H.IDLE:case H.LOADING:return;case H.PLAY:return void this.emit("state-changed",$r.PlAYING);case H.PAUSE:return void this.emit("state-changed",$r.PAUSED);case H.END:return void this.emit("state-changed",$r.STOPPED)}})}async start(e){e&&this._track.setLoop(e),this._track.startAudioSource()}stop(){this._track.stopAudioSource()}resume(){this._track.resumeAudioSource()}pause(){this._track.pauseAudioSource()}getDuration(){return this._track.getDuration()}getCurrentPosition(){return this._track.getCurrentTime()}seekTo(e){this._track.setCurrentTime(e)}}const Ua="data:audio/mpeg;base64,SUQzAwAAAAAfdlRJVDIAAAALAAAB//6wZY+JMpPzl1RQRTEAAAABAAAAVEFMQgAAAAEAAABUWUVSAAAAAQAAAFRDT04AAAABAAAAVFJDSwAAAAEAAABDT01NAAAAHwAAAGVuZwBvbmxpbmUtYXVkaW8tY29udmVydGVyLmNvbQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/7UMAAAAAAAAAAAAAAAAAAAAAAAEluZm8AAAAPAAAAIQAAG8AADg4OFhYWHh4eJSUlLS0tNDQ0PDw8Q0NDS0tLUlJSWlpaYWFhaWlpcHBweHh4f39/h4eHj4+PlpaWnp6epaWlra2ttLS0vLy8w8PDy8vL0tLS2tra4eHh6enp8PDw+Pj4////AAAAAExhdmM1OC4xMwAAAAAAAAAAAAAAACQGkQAAAAAAABvAI9ArKwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+1DEAAPAAAGkAAAAIAAANIAAAAQgUuQ2C0ggHpVv2yykMn99MBkmlkbANsGRtN/9DKn6+WMLYws4Lh4WxkjxRTCyjBeEm3+nZCzjyFLIzIKSqMgLKkIP1kOAiDKPuoPHEJhZAyGA11lGJAQwQrN4Rbybog81Oo5/HL4hDAzMhfDIORCH6sJWPxCHi7OvCHrs+08SyrYcjCunFEIUcF3h+GRk/0ezsbcciMXCMV+nqHuc7pCyQEknfL87AuS5wm9PnAe5Y7Ggvq5YntSi4JZp//tSxF2BAAABpAAAACEAm9fYYKG5sVGC+JNCz/TxyljU6F40ShUKyWObiUFhgEjStZ2CVnUitUbMqIzyCqxoUKH3NoM9MdurRtIOQGCAUMFCSESeQjFxRAgYXbXJF0nVe9uFo28sYY7vaCij0ID9hSkkXuTJaCDJFz8gUSiyxc8sXPLPuoSix9OQOB8P8UEoLx8INHg3fTIDwaLh4YNPIFEl33fQs/pyKfc+yxe8tkLuDJtK//QaH9/82KCiVSikopLdrY0AnUanBzTSVpS9C97/+1LEmwISLPzKLWHhSkMzXxT0objEkfG4QCz4OIieKEYpLmuJkMtc5uJdtmDor6SYLaLLX0raXraxBc+7cAr3hDL0qGSsCBwGZqypjA4ElVUY7GnEmFjhwPID30wHCGbtHoN0Z2QB0OAoDhALxQAnYOxcBA+YMFMbLwgKWUbl2Ifrr24gYTadbLMVv/+Mq24Gp3l3/h86KJLTckkhrKhq26mLTJpLGV7fiEblMVS/XOw9nrQlCwNYepQTYgRNCkqGmA1BWGYwNiGrgoDxJm5IFv/7UsRngFKU9SesMNqKVSCldaex+CXJcyfnSS9gOg3353q5gGIk2prcmlvRauYXkE9NM7dDYEWxIRGycMUtXE9qcRhJr8C1O0lVxpn0Kp/m6zF/wRLtSXM4z1RlXWHEd1DXzWM+UW8Ph44xqf///9YEMAABKDji+CgJAK7SWrtM+kLV3seiQMQh5uzbyxuDKYFdoAcmgOJZwcmBsFRkU1rTIqfKZIOMefJpi0XnywvZJR7aIsFdUXI0PYFFX46ocVsWQNp3kq67hYrZ1+B9jnnr//tSxDCAkd0fJwywccHgHeXxhhlw0cdooYK+gHjEOABLZZgYoYOoha7T6UpF/cNAmHxceFk3G7tDTxQeftfcUR4yLAGNEAABjLIu8PEIvus6sXZI0l/YEcBYAi5TEtDaViW8tUmhow2InK0p77jhdbeL1T/1lDS5pDRoaD1pMZGvVbCaVUagkijWnZZ96+TGDn23cr1MU+dv4fIbSmumc8DLQPKiAURQKMEpsSjzxxZ/7knKQBPNsT9UTwW5ZEgAAAi6EyEFKkWBDVKYCjOtzNz/+1LECwAMaGM7qLzBwYyP57WGGDCVOsqXUqVdqZlalUTFyum6B6yWHxKtfJ102ZWAmRDKgGKm50SkSRURkXbmJQqXCSwIKYJnAmGHJVFP5Rz7zcAIfFk1KXvpt2GxUQOCIwByRMAAFAlSgpAjMNQ8juOgiKhoYJIHB/jdGqTq0yaTTZenn0fTOdih3rwVkZPSk/GucPt+pjheShUIMHrA4BmQ6ecxGPKokxEtyAYL11Oo4YOAIvsHPAVTxpwg482MiPpbRYoCNuRgAEglOCRk4//7UsQFgAu4bT+sMGVBfRZntYSM+HIk6vqeMSCuSkM5F5bEQlk5Ptzp4h0YiQfCQ4LCAJJ66Ay034GEiBh1I8OIcZNrDJ0CtF40XfZPB4TPaTGXgUoPhuzNH7XhK9yydOvhjHxIQ/e0KuNMkAAAAuICRAlnsIdx2ZI+hATsEgUIiAC0abFoVUl4s+KU8Y1KK7EAxKkZHFLy8g0ZoX2HZdiKzaFS7p/jzo4VFLXt1YCQKFLl9KFoSC6AfcK8pQp3ULnCDeovRY8OT+xIBJpKPFQD//tSxAUACtCpQ6YYbIFUj2h1hgw4gD04ikwjCAIbw/nRingHLMRPNKQhE6uZE36qFjtpR42aCmPJUDGvE/BMa9n/9ijarn7LWG7Vbg6MCSCSn2S8UkXut/rOz56xjvQS0rCft+aIbkklAIkPGBmSx3JSwUD8OXEgoGJXMUUHuqmnVxp0WqTG1SmSj6rUNEuDOFqQYVYiPDTnAk2LixIzzwmDyUCKdCYKhEJD4yhWe3HRFaGAC6xVBXdWh0Uk5ZHMBYyEl5SybRFAgQCMIxAtY4f/+1LEDQAKhGlL56RloSqJZzGEmOBohpRiSG2F4Y7OCKCqEH5Z7UjVAZPgJgu0MFD6Xko0XsCIHsOmRuwydoeKKQONTv3OCCSpGAH2FVDlAlZRogBlsDCAQCfCsLoxxm8qVFBGDo8IxS4UIGygImCZNLcvIYCgbEmHAwdMmhdxAcCRsnoKjknVgIkiKLc9GlPo2hquKP/Wis6lAwAQBrN81FlZbkuy0KgqxigfmZl0DCeBofolpYVFMlFI0HJ2SAtf7Y4bQQXbfBhn6Oc/joGPk//7UsQbgApkeTCssGnBUY2pdPSM5BZITGvPiYYSXI7CRsyzKCVjlrVPOFlp9eBRhTcNr/vY3bpFLjPRI1TiGcuWg3BEGTIlJNCwgaBIFTZvolcQhPAShI4USOykeGVnFICwWHg61MSOmQMqQSWYFH0fTowBBNYmIgFL0bVGTRtdbv/f+n6VBUSZJAASRciGgy5liuXZZgbBq4T/QDlEJzRfXkiMwxN01xqHg5g+7BJpjM+v3yescqw+RuInWTjoiKngfCQo0v+zcxQwyX4+ttMy//tSxCWACfBpO6wwxUFLjGgw9Izs+2j1fuDbkrMAVK5HBzgpCdrRIkAdQcSFhcSNBtyo6imj6JdDFDx8SvYEJYXTiAsCEjhoiLkWS5QctQcLA+/kkD1pSKnBZrQIw4+5AZZenuS8URKQCTLdKg4m2y01KKMZZlzCDGoe7IIsASGhUPjxCgbARPv1kbWJTWOnGbfljF9Ti3bCSDlx2h8SOkyu4RKQPPD2Qw6OC2MbL0oJ4iatyRTloqCDhRL6fSCMAAAK4DLBnFrNdlDgUrjgcbD/+1LEMgAKLHNLh6TFsUyU5qWEjPhMbExcgCpAhIGnL2X51kh0iVQRZQQOuowcUaDmbvclmzMn387nP/fhOQfMJUFFp73K2sEZ2OSy+nLpEazQxbVRal+7tFlBALj2M4ghjEoBCYyAqZLbFw+HFeLWA5JzByKCpyUH/g6RyJ9HXpcNWoKaPNM4i/E5E3bxRD3Pe9hFhMJi9IqbmXFlEP5QEyIq8kU+wKkJkoghJNzAVDwXgkA9ciBE4BbZ2QEikHCtQMSk44haxACDjJ5Z0EEjmP/7UsQ9gAoQs0kmGG5xTwan9MSYmE7jpAw0RrGMdUNFLAEBGaxahOJDJxYFcwUlXeLKYLo72/oIKhTz5BdCag4k6ATJSda8IyHYGTovkg+aA0Z0M8OSgog7CQpDTjiTAw8abfl1o59z3iKVZq+6DxUPKWZ24aYlYuVT2UOqHrJzaVEmLWrV3n9AoKs/ohn/aguuaCU0k3AlKYUkJKFEIjxiSduHBqUg9ogMyXuEb3fNyM92e8OEDqqSRSriAmTYBRDcdNH6sQ1b0Rf0sIVxUBxy//tSxEkACihtPUwwwYE5jmjoww2SFcqgWYzRUazFdyXkP10MAAAAAYnBaB4CxiZq1IljkJIwOE5meE9wQSNhGLRMOZYxEgYi+ngx0h2xAQgXDqllDI99JcVujUNCbCbbLxGUaPFkraoagWPipq5XjdK7P8WN1jjZBRaQSoZy+HwzRk8FD1ImZFsBSbJCNJ7b1E0e6+Jc6gKCVFhgtbJsY6iIiC4xpEs1pgacY87QJyb+9abaKg0GSBUms2HuqjX/w5YJ//1KD5UASmvACU7USp//+1LEVwAKKGU3JhhuwUSM6LT2DDx7Y+CxY0AUTmjALRAthrHJHm/aasmceDjn0BHWOxU2zDHD+qkcQbUFQ4JQ6MNAwLuhNTNs2zEzAWHrD0ImyrDGnIIYQKs2f+4GeV1IoyNFPA8BAD3GYjjuIQ6GKosgGLEiET0Op7Cq5Qo5QoHkxZdokyNsjC77QKWXnP5EQxRwgxzCy2TPq7yB9TRKOzX5U0RU8ZCvXWLybyn3pjXBAGSma+pqEO/OPbQwuC45WnIIZvPCtkXXrojyITkkAv/7UsRjgApgezssJGXBSxMo9MSNFKIzdzlgD2gk2svFxytcWsjvlmhKn1eSZn3q8MwoZki5AIrYePhhwjXAzgG+GD+jt7IAIBR2aMkZI0QDF14mkgBY3rlyYPZeI50Jxj6keGaIj7pUBpWdRClqy6/6dsW3++zDROLlF4gIHR4oJ1kgg2+5sUpz4TjxXvb9c26t5rs31QwEAABBLdMNhCpOXUQXM4TOGsP+9DKHFdtg8ifKunQ1iQRNGMBRUN42jZYVbEGzfYIEDwGA8JpAgxwc//tSxG6CCjitMgykbwE9juaZhhh4nRe7ZadDN4KR5vVPgyWqARjOO/53YiIYW+4PU2PJ4uQmu4J3j/P+Tb/+36/6rWr1zqmve437/sLIQAA2k9ySNBNCHihLSTkHRKHM0OhCNiOPRmH7ZCF5eWvLTJuuuMC3FvQFRKkGyEisiDMK1MQKg5UT/rIblCO1IpX+v55fO+/2lMF/fXX1KNKW90n5eX8i/LTsdooMnT3UgutZNX/iZQQAAAxk2cYkSJaEAEngiYh+4SwKR8HuwyJlDnz/+1LEe4AOSHs3TCTQiaEn56mWDLhsSAlNRIaVYyNm6wThPzA8QQiULALDsPwJlspB6L07ymp9G8ndvclRH69p0OilmBW9D8qpXtBikk6XtILNNfT8uJeLNc0t5zu07wut2Htqm1m7v7xBvx7iJe2fe7Nn7HlBIOvNur62iJ+VL3/lUAEEFQ4azSgXqweuhMaUpW6TET7Q4/jcHbAMcwjV2o1dI1TsZSN6+kFCoVdpx5uI1tlo4vpLpCdvRJ3JQg5eaql/X3NfUxslzvnZI7rW5f/7UsRsAZE9KyjNsNLB5B6lqZeZOPsqTqh1523vbVZub7n7/kzCbmh46qxpqMaoiNHNOjQ0uVfeubvtqjanZ5oeQAIALpnZgH5SIyAEP07HlV1HV4rXgCZXSu2eZIzFOmiWZSvw7tO7rcJ6elMDytrkojMjgtLDeOdJTHLWtYX8Y0WUZvPZ03xsfsqHi2Vkb3SYxsjMN+5spPVUqFUVHJK7K6zB+QjlRl/v3GjQ+6DhYrKdGXX/V1QQONm1K/f+/o2oxngAAMZ2QIIQVNFqjRgA//tSxEiAEH2bLOyYtworIOTJpKLIsBQGJ3l0YGaeylxnIUxZyoSwEv04xetvWGwZLazmMPd5sDmNIWDjFMzdnIEk+BVYmk0H5lg3sH1NJUNFlYOJipQWOmmMujEGQPNWhssKjpaZvMTcaNrnZFB/YbK33jTpYmnJu5izzkyguOQAwOpwwLA0vSmHlCx2ZfS+i7ENAKQAAAfNJ0QbCRbhrfSJQgp4agASxIiXhGSAbow8MLRLDpCP4jIkqlJxZAPE4nJio+484qaaoKtOLx4Ia43/+1LEHwAM7JEvLLBpwdEeJamGGXC18RMGDqjRVQ0OIWKB3aNaRAqybOdYGgk2hDudAKFvARw6K3mqcdou8sAiwAAIRLgYY40NbnADxrUcWWtbo3ebYGJoYCUFxfE9MIJ6uMRxRHRNO9D4kE4sBq+PQ41rFmPcmRLwfbvtwhub5jZLrfkItmuz9rTPrUoykMzC1e3748PW8VU329//ESoYDsFS+7OAwKhdZN5Qm1R18CZLSgIfAACKStFFFmg87S1XMlbjDtA+pQ8tAuWBSYHJOf/7UsQPAAy9JTVMMKnBeh8naYSM6NVw2vHy85fsugSHv/WB6J+CcmY7KIolRrqj95fKdEVSEpc7PF2Zlbd0VHpZagOjNVTLkNOf5nm//EDkxYoDs2ZYKNdCJDyb0A92QCm27sF4RJKNkKu5S8GYLnwIE40jEICEw0goijjkSKDOtMYmUBA49fs4eMUnoZEec7ISy4/9L3K1yhllsuq84+fkR//J+9XChEDixZ+tpoTiqBR4GNET7Ou6jZJ1AU+jUAEiacoBKW4WpMjX60dZxp9G//tSxAqACoxpQ6eYbGFHCebplhjgtPQuwsaobCZzorZNuwyvYGJ+fgg0gQOMDBRBRZgk6w2RjhC0awkSdJ6j7jx1ZIWaUpeWCPohsYLuGvUuz2/9QG7iABJJ0GTwX8DgmE224vUwNCGxTXGqHENJ94l2WQplp/nmiHoJdLDjzwy0XcMIui5MeBFiqrpgqxo9De8mMkNEvHAVFjb2I6iQTSRPExROlqoASWRIBKNuagE4aIl1ToqzQYgRBMjFQwMjEimdDxdz/T7m535NK11OAIX/+1LEFQAKcHs9p7BnwVAM57WEmRAIrENipTmOynjrhcTIDIReAws5AlkB6pfdIk7sfUY1q1MLhpKMZc///rAC2kaATablw2AUUlG1t+GkuLEGuuUBIiKhs0TjjhK5lHJybTu7GKuZJzDy5bMzrMQB4GD9yAA8kxKVi6JlhogtjhVtBs1cfPQWrU07/Mo6Pbo0KqoDvuAGk3LhPxJQWEwlzHZct3yoCgnMuQHyY/YXco39WxS2IcqoxqFYQroj1ShRyoC98bXoyUd3OfaDzK7Wh//7UsQfAEtZAzlMJEfBSomncYYYYJKrWzK/AeyWyvyasoM8/2Iepx0MNezzzluPXlBQBSrNIC8TMAjC/TpiSSBSsQSSqMTVw24WASWBbmqKjqvuvHU7HhE24KklMeNB0+WaIqCgUKbBYSBJoooel6Wza0hIVlgTW1j2W6F1CooLO1/fqXUe37e2FWpuXgkBQWGYEEQvfLhyiN2xqOHFkgwhIzGY/yevZAt3LGsQihk41qRnGIsFRgCTSyhJAgZGrjhbfeHzomeMHNGMFy8Wq3UE//tSxCYACqBvR6YYbSFHieb1lhhgzYCVds9VDfsuAMSZQABJKcoxCZoSnEFnwqIg/iUZJUhcfTgIJAZXkiZUkEr/knjQR6bmjZcSQ2KCxM8RFdFkkf6wAqhhnIqYyXFrXxV7PK2ImDKL3Oo70Cun0AXZG0gE425upMoUwVwgiCwaSyZDE7FrCZWZEtmpmbPkeKvK9IgtBBYVtBZgaKBUVD7hUewpYoJRQWFCqQStTZXoC8te5m9j/wbCYAeMde/J+YFLWa6w7td3CnbIpeYitGb/+1LEMIAKsGE9rDBjgWcOKPT2GKShB5iPC5UOxmvCsilY+VHprIOdOKxp9eHAp1VM8ZXOfaqmhftPThYiRPGRUDBEpPHWnwy4QkzmxMEXnGXiccbCYIHRZCqddkr6e7MbDnrqBebrRILkjm67MlxMBdDuCJ9OQUZ6eDQuWKmF0a+q1gRMOlNi9wZ0iNmLppmeecfiZa8jEYyTKB7Roq6J3n6iosRETJhw1QoGjo0YO/NTq81f1u/qBds0cKLjac4hZCyJSCWLsoDSCzbYNExEHf/7UsQ2gAqAk0GnsGVBTZJotPSM5OOkDs0Uh8O9anh4GckBP7c1wiiWeK6sfkX5+cuJ0CZrjIAWwcfGWYHYXRHIExhVQrV60MH39fp9KqnVAGlAAEoqU2QHYpMKzWF5AYXDqXEhuaD33FwwOOHwsEtZFi2JMckTwyzOUWJjBUOg094PhddDoqLvvSPUHzCrnM/KrQGL5oVUzumnspfW+/vUqZv6ASrAALSUvHeAlnCpDiTBqyiQakICQcHyIgJ0CBdNBjcUQZaGTdzAEd2T86mZ//tSxECACohVN0wwxQGEkCfo9IzooUEU4VwQ4gPhhpQIjhoeCwq1JOTEN9VWt8BgS+9h/tJirxjULUNGqsSBDI4TuQTZUcC/xIoRqlQUk0xBJBQlWzRF8pdIx+LWXC0rLFmuLWqmaBSASd9m1cPDUL+ihaYK1iOUjZSUo+RmpPtnMxamMCoaAQsJZ+7en3GxyUlUZhyf//FYmen2cWcKBCR9lINRyXgGyGQGzpVVkLwBSYgKTZUdiSWwLiGMI0mQQ+nOh930zwfJERkhSQJCNgD/+1LEQ4AKpKtDR7Bo0UwKaDWWGGAEYCD6APOvolzoxDFVQmxzwnQ8mQQYap5P+8PnBx+OCPTVAkV5iTZHL7rfxwq5Wbzbrvq89BCLLrRd1J6mZzKobw9GAUIEC9OM5FDnLDFAzKlTSuBJrqMUHVNhzaur0j3Lgnqxc7fcMurjzSCzVP8O///X77wWpX7ev/8+gBNUuSAEhRxNpRJuQAHhLLDGXQBxAHpVoA4+7xfNdZaIMAF0HkicaRAVgHsHKYIxT8EceOkOdr53pDakdomzjP/7UsRNAAtEcU31gYAqYSbmtzTwAelqwkmxLb1Iui+ZtPHcXcUlagUyvNKFnt9K7owP/qM5qtrfv4M+/77pNeW89Fcssj95PBiVvqurZ3/ExBz/aJRieRKODyTX/+P/X3/pibzb3RUPImPEvALKAGAAAgArwFi3Cif+bImX+lmP+BDZooObSf8DSrgBmw5JEcAQ2Bi0AGfOGJMocCw8DAlgMmKBYE6KSfh6QN1gbuHUAaARb/AwoQckVgAUMFkofXqV/AXDBYEPqAuCCyUG2osh//tSxDGAEoFFELmqAAAAADSDgAAESVSqv4ciFkIqIpEG6oNsS8JtC33//8OSGTAQDCxIL7BjoXyC5ocsR0Hza9f//k+XkkxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+1LERYPAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==";class qa extends Ca{constructor(e,t,r,n){super(e),this.drawImage=(()=>{this.drawImageOnce(),requestAnimationFrame(this.drawImage)}),this.drawImageOnce=(()=>{if(this.ctx)for(const e of this.canvasSources)this.ctx.drawImage(e.source,e.x,e.y,e.width,e.heigth)}),this.canvas=t,this.ctx=r,this.updateSources(n).then(this.drawImage).catch(e=>{jr.warning(e)});const i=new Audio;i.src=Ua,i.autoplay=!0,i.loop=!0,i.muted=!0,i.ontimeupdate=(()=>{this.drawImageOnce()}),this.audioElement=i}async updateSources(e){this.sources=e,this.canvasSources=[];const t=await Promise.all(e.map(e=>Ni.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;rthis.mMax&&(this.mFiltered=this.mMax),this.mLastFilteredTimestamp=Date.now(),this.applied=!0}Filtered(){return this.mFiltered}LastFilteredTime(){return this.mLastFilteredTimestamp}UpdateBase(e){this.mAlpha=e}}function Ja(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Qa(r),e[t])}Qa.kValueUndefined=-1,Qa.AlphaForPacketLossFractionSmoother=.9999,Qa.SMOOTH_VIDEO_INTERVAL=1e3,Qa.SMOOTH_AUDIO_INTERVAL=5e3;const Za=Ja(),$a=Ja(),Ya=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function eo(e,t){let r;r=e>9||t>100?x.POOR:e>5||t>80?x.FAIR:e>1||t>40?x.GOOD:x.EXCELLENT;const n=navigator;return n.connection&&n.connection.effectiveType&&["slow-2g","2g","3g"].includes(n.connection.effectiveType)&&(r=x.POOR),r}const to={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},ro={nack_count:0,fir_count:0,pli_count:0,width:0,height:0,jitter_buffer_delay:0,bytes_sent:0,frame_encoded:0,bytes_received:0,frame_decoded:0},no={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var io,ao,oo;function so(e,t){let r=e||0;const n={chrome:["86.0.4240","87.0.4280"]};return n[b.name]&&n[b.name].includes(b.version)&&t===ao.InBoundRtp?(r=Math.min(e/32767,1),Ka.create({code:Xa.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&Ka.create({code:Xa.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function co(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function uo(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function lo(e,t,r,n){const i=t-e,a=n-r;if(i<=0||a<=0)return 0;const o=i/a;return o>1?1:o}function Ao(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};E.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return E.unifiedPlan&&E.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function ho(e,t,r,n=600){if(r){const i=[{rid:"hi",active:!0,maxBitrate:1e3*n},{rid:"lo",active:!0,maxBitrate:1e3*r.bitrate,scaleResolutionDownBy:r.scaleResolutionDownBy}];return await t.addTransceiver(e,{direction:"sendonly",sendEncodings:i})}return await t.addTransceiver(e,{direction:"sendonly"})}!function(e){e.Video="video",e.Audio="audio"}(io||(io={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(ao||(ao={})),function(e){e.In="in",e.Out="out"}(oo||(oo={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(mo="PermissionDeniedError",po)return po("PermissionDeniedError");throw Nn()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(mo="desktop");"rtcmulticonnection-extension-loaded"===e&&jr.warning("your chrome screen sharing plugin is not the latest version, or you have other screen sharing plugins.");e.sourceId&&po&&po(fo=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let fo,po,mo="screen";async function go(){return await(()=>new Promise((e,t)=>{"desktop"!==mo?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==mo)},2e3)):e(!0)}))()}async function vo(e,t){const r=t.source;return await(()=>new Promise((n,i)=>{const a={mozMediaSource:r||"window",mediaSource:r||"window",height:t.height,width:t.width};if(g)return void n(a);const o={mandatory:{chromeMediaSource:mo,maxWidth:Mo(t.width),maxHeight:Mo(t.height)},optional:[]};"desktop"!==mo?n(o):e?function(e){if(fo)return e(fo);po=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(Nn())}):function(e,t=!1,r=!1){po=e,t?window.postMessage("qnrtc:get-sourceId-screen","*"):r?window.postMessage("qnrtc:get-sourceId-window","*"):window.postMessage("qnrtc:get-sourceId","*")}(function(e){o.mandatory.chromeMediaSourceId=e,"PermissionDeniedError"!==e?n(o):i(Nn())},"screen"===r,"window"===r)}))()}class To{constructor(e,t){this.tracks=[],this.publishedTrackInfo=[],this.userID=e,this.userData=t}get published(){return this.publishedTrackInfo.length>0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=mi(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{M(this.tracks,t=>t===e)})}removeTracksByTrackId(e){M(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=mi(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){M(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function bo(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function So(e){return{trackID:e.trackid,tag:e.tag,mid:e.mid||void 0,kind:e.kind,userID:e.playerid,muted:e.muted,versionid:e.versionid,profiles:e.profiles||[]}}function yo(e,t){return{trackid:e.trackID,mid:e.mid||void 0,kind:e.kind,master:t,muted:!!e.muted,playerid:e.userID,tag:e.tag||"",versionid:e.versionid}}function ko(e){if(!e.info.mid&&E.unifiedPlan)throw kn("can not find track mid!");return{localid:e.mediaTrack.id,localmid:e.info.mid||void 0,master:e.master,kind:e.info.kind,kbps:e.info.kbps,tag:e.info.tag}}function _o(e){return new To(e.playerid,e.playerdata)}function wo(e,t,r){let n;return"audio"===e.kind?(n=new Ui(e)).initAudioManager(!0):n=new Li(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function Eo(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const Co=e=>(function(e){0===Object.keys(e.audio).length&&"boolean"!=typeof e.audio&&(e.audio=!0);0===Object.keys(e.video).length&&"boolean"!=typeof e.video&&(e.video=!0);return e})(function(e){if(E.minMaxWithIdeal)return e;return["video","screen"].forEach(t=>{"object"==typeof e[t]&&"object"==typeof e[t].width&&e[t].width.ideal&&delete e[t].width.ideal,"object"==typeof e[t]&&"object"==typeof e[t].height&&e[t].height.ideal&&delete e[t].height.ideal}),e}(ii(e)));function Mo(e){if(e)return"number"==typeof e?e:e.exact?e.exact:e.max?e.max:e.ideal?e.ideal:e.min?e.min:void 0}const Po="fk6fk2rnb",Io="https://api-demo.qnsdk.com",Ro="/v1",Do=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function Oo(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new va,i=new va,a=await async function(){let e="unknow";try{e=await pn()}catch(e){}return e+"_"+si(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await Go.getLocalTracks({video:{enabled:!0},audio:{enabled:!0}});if(c=f.find(e=>"video"===e.info.kind),s=f.find(e=>"audio"===e.info.kind),void 0===c||void 0===s)throw kn("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Io}${Ro}${Do(e,t,Po)}`;try{let e;if("AbortController"in window){const t=new AbortController;setTimeout(()=>t.abort(),5e3),e=await fetch(r,{signal:t.signal,headers:{"Content-Type":"application/json"}})}else e=await fetch(r,{headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error(e.statusText);return e.text()}catch(e){throw e}})(a,e).then(e=>t.joinRoomWithToken(e)).then(r).catch(n)});await Promise.all([p("userA",n),p("userB",i)]);const m=e=>new Promise((t,r)=>{e.trackInfoList.length>0?e.subscribe(e.trackInfoList.map(e=>e.trackID)).then(t).catch(r):e.on("track-add",n=>{e.subscribe(n.map(e=>e.trackID)).then(t).catch(r)})});await Promise.all([n.publish([c]),i.publish([s]),m(n),m(i)]);const g=[],v=[],T=[],b=[],S=[],y=30;let k=0;await new Promise(e=>{o=setInterval(()=>{const t=n.publishedTracks[0].getStats(),r=i.publishedTracks[0].getStats();t.length>0&&r.length>0&&s&&(g.push(t[0].rtt),v.push(t[0].packetLossRate),T.push(r[0].bitrate),b.push(t[0].bitrate),S.push(s.getCurrentVolumeLevel())),g.length>15&&(clearInterval(o),e()),k>y&&(jr.warning("abnormal track stats: less than 15 valid stats in 30s"),clearInterval(o),e()),k+=1},1e3)}),jr.log(JSON.stringify({detailTestResult:{rtts:g,packetLossRates:v,audioBitrates:T,videoBitrates:b,volumnLevels:S}})),g.length>0&&(d=Math.ceil(g.reduce((e,t)=>e+t,0)/g.length),u=v.reduce((e,t)=>e+t,0)/v.length,l=T.reduce((e,t)=>e+t,0)/T.length,A=b.reduce((e,t)=>e+t,0)/b.length,h=S.reduce((e,t)=>e+t,0)/S.length),t=!0}catch(e){t=!1,r="string"==typeof e?e:e instanceof Sn?JSON.stringify(e):e.message}finally{return n.roomState===pa.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===pa.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),gn.addEvent("SystemRequirementsTest",{room_name:a,ok:t,reason:r,avg_rtt:d,avg_packet_loss_rate:u,avg_volumn_level:h,avg_audio_bitrate:l,avg_video_bitrate:A,test_take_time:Date.now()-e,event_grade:t?An.NORMAL:An.SERVERE},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class xo extends Ui{constructor(e,t){if(!E.mediaStreamDest)throw wn("your browser does not support audio buffer input!");const r=new xi;r.initAudioContext(),e instanceof AudioBuffer?(r.setAudioBufferSource(),r.setAudioBuffer(e)):e instanceof HTMLAudioElement&&r.setMediaElementSource(e),super(r.audioStream.stream.getTracks()[0],t,"local"),this.sourceType=L.EXTERNAL,this.isLoop=!1,this.originSource=e,this.audioManager=r,this.handleAudioManagerEvents()}setLoop(e){this.isLoop=e,this.audioManager.setAudioSourceLoop(e)}startAudioSource(){this.audioManager.playAudioSource()}pauseAudioSource(){this.audioManager.pauseAudioSource()}resumeAudioSource(){this.audioManager.resumeAudioSource()}stopAudioSource(e=!1){this.audioManager.stopAudioSource(!1,e)}getCurrentTime(){return this.audioManager.getAudioSourceCurrentTime()||0}setCurrentTime(e){this.audioManager.setAudioSourceCurrentTime(e)}getDuration(){return this.audioManager.getAudioSourceDuration()||0}handleAudioManagerEvents(){this.audioManager.on("@audio-source-state-change",(e,t)=>{this.emit("audio-state-change",e,t)})}}class Bo extends C{constructor(e,t="send",r){super(),this.trackList=[],this.isDestroyed=!1,this.enableAudio=!0,this.enableVideo=!0,this.muteAudio=!1,this.muteVideo=!1,this.onAudioEnded=(e=>{this.emit("audio-ended",e)}),this.onVideoEnded=(e=>{this.emit("video-ended",e)}),this.onAudioSourceStateChange=((e,t)=>{this.emit("audio-source-state-change",e,t)}),this.direction=t,this.userID=r,e.forEach(e=>{e.setMaster(!0),e.on("mute",()=>{this.updateTrackState()}),e.on("release",()=>{M(this.trackList,t=>t===e),this.updateTrackState(),0===this.trackList.length&&this.release()}),this.trackList.push(e)}),this.updateTrackState()}get audioSourceIsLoop(){return this._audioTrack instanceof xo&&this._audioTrack.isLoop}setVolume(e){this._audioTrack&&this._audioTrack.setVolume(e)}play(e,t){this.trackList.forEach(r=>r.play(e,t)),this._audioTrack&&(this.audio=this._audioTrack.mediaElement),this._videoTrack&&(this.video=this._videoTrack.mediaElement)}getCurrentTimeDomainData(){return this._audioTrack?this._audioTrack.getCurrentTimeDomainData():new Uint8Array(0)}getCurrentFrequencyData(){return this._audioTrack?this._audioTrack.getCurrentFrequencyData():new Uint8Array(0)}getCurrentVolumeLevel(){return this._audioTrack?this._audioTrack.getCurrentVolumeLevel():0}getStats(){let e=Ya();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=Ya();if(this._videoTrack){const e=this._videoTrack.getStats();e.length>0&&(t=e[0])}return{timestamp:Date.now(),videoBitrate:t.bitrate,audioBitrate:e.bitrate,videoPacketLoss:t.packetLoss,audioPacketLoss:e.packetLoss,videoPackets:t.packets,audioPackets:e.packets,videoPacketLossRate:t.packetLossRate,audioPacketLossRate:e.packetLossRate,videoBytes:t.bytes,audioBytes:e.bytes,pctype:this.direction}}getCurrentFrameDataURL(){return this._videoTrack?this._videoTrack.getCurrentFrameDataURL():"data:,"}setAudioSourceLoop(e){this._audioTrack instanceof xo&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof xo&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof xo?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof xo?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof xo)return this._audioTrack.setCurrentTime(e)}setKbps(e,t){e&&this._videoTrack&&this._videoTrack.setKbps(e),t&&this._audioTrack&&this._audioTrack.setKbps(t)}updateTrackState(){this.trackList.forEach(e=>{"audio"===e.info.kind?(this._audioTrack&&(this._audioTrack.off("ended",this.onAudioEnded),this._audioTrack.off("audio-state-change",this.onAudioSourceStateChange)),this.audioTrack=e.mediaTrack,this._audioTrack=e,this._audioTrack.on("ended",this.onAudioEnded),this._audioTrack instanceof xo&&this._audioTrack.on("audio-state-change",this.onAudioSourceStateChange)):(this._videoTrack&&this._videoTrack.off("ended",this.onVideoEnded),this.videoTrack=e.mediaTrack,this._videoTrack=e,this._videoTrack.on("ended",this.onVideoEnded))}),this.audioTrack?(this.enableAudio=!0,this.muteAudio=!this.audioTrack.enabled):this.enableAudio=!1,this.videoTrack?(this.enableVideo=!0,this.muteVideo=!this.videoTrack.enabled):this.enableVideo=!1}release(){if(!this.isDestroyed){for(let e=0;e"videoinput"===e.kind);case"microphones":return this.deviceInfo.filter(e=>"audioinput"===e.kind);case"playback":return this.deviceInfo.filter(e=>"audiooutput"===e.kind)}}async getElectronScreenSources(e){let t;try{const{ipcRenderer:e}=window.require("electron");t={getSources:t=>e.invoke("QNRTC_DESKTOP_CAPTURER_GET_SOURCES",t)}}catch(e){throw jr.warning(e),Rn(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case cn.ALL:r.types.push("window","screen");break;case cn.SCREEN:r.types.push("screen");break;case cn.WINDOW:r.types.push("window")}try{return(await t.getSources(r)).map(e=>({ID:e.id,name:e.name,url:e.thumbnail.toDataURL()}))}catch(e){throw jr.warning(e),kn(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(!0===e.audio&&(t={audio:{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop"}}}),e.sourceID)t={video:{mandatory:{chromeMediaSourceId:e.sourceID,chromeMediaSource:"desktop"}}};else{const e=await this.getElectronScreenSources();if(0===e.length)return[];t={video:{mandatory:{chromeMediaSourceId:await async function(e){return new Promise((t,r)=>{const n=document.createElement("div");n.setAttribute("style","position: fixed; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);");const i=document.createElement("div");i.setAttribute("style","text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;"),i.innerText="share screen";const a=document.createElement("div");a.setAttribute("style","width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;"),n.appendChild(i),n.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 12%;"),o.innerText="QiNiu Web Screensharing wants to share the contents. Choose what you'd like to share.";const s=document.createElement("div");s.setAttribute("style","width: 100%; height: 80%; background: #FFF; border: solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around; overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");const c=document.createElement("button");c.setAttribute("style","width: 85px;"),c.innerText="cancel",c.onclick=(()=>{document.body.removeChild(n),r(Mn("user cancel selection"))});const d=document.createElement("div");d.setAttribute("style","text-align: right; padding: 16px 0;"),d.appendChild(c),a.appendChild(o),a.appendChild(s),a.appendChild(d);for(const r of e){const e=document.createElement("div");e.setAttribute("style","width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;"),e.onclick=(()=>{document.body.removeChild(n),t(r.ID)});const i=document.createElement("div");i.setAttribute("style","height: 120px; display: table-cell; vertical-align: middle;");const a=document.createElement("img");a.setAttribute("style","width: 100%; background: #333333; box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);"),a.src=r.url,i.appendChild(a);const o=document.createElement("div");o.setAttribute("style","height: 40px; line-height: 40px; display: inline-block; width: 70%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"),o.innerText=r.name,e.appendChild(i),e.appendChild(o),s.appendChild(e)}document.body.appendChild(n)})}(e),chromeMediaSource:"desktop"}}}}e.width&&(t.video.maxWidth=e.width,t.video.minWidth=e.width),e.height&&(t.video.maxHeight=e.height,t.video.minHeight=e.height);try{jr.log("electron getUserMedia constraints: ",t),r=await navigator.mediaDevices.getUserMedia(t)}catch(e){throw kn(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())"audio"===t.kind?n.push(wo(t,e.audioTag,e.bitrate)):(e.optimizationMode&&No(t,e.optimizationMode),n.push(wo(t,e.tag,e.bitrate)));return n}async getLocalTracks(e=Lo){if(jr.debug("get local tracks",e),R(e)&&I(e)){const t={screen:e.screen},r={video:e.video,audio:e.audio},n=await Promise.all([this.getLocalTracks(t),this.getLocalTracks(r)]);return n[0].concat(n[1])}const t=await async function(e){if(!e)return{audio:!0,video:!0};if(R(e)){if(I(e))throw kn("can not get mediaStream with video and screen are all enabled");if(!E.screenSharing)throw wn("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!E.getDisplayMedia)&&!await go())throw Cn("")}const t=!(!e.audio||!e.audio.enabled||e.audio.source)&&{deviceId:e.audio.deviceId,sampleRate:e.audio.sampleRate,sampleSize:e.audio.sampleSize,channelCount:e.audio.channelCount,autoGainControl:e.audio.autoGainControl,echoCancellation:e.audio.echoCancellation,noiseSuppression:e.audio.noiseSuppression},r=!(!e.video||!e.video.enabled)&&{frameRate:e.video.frameRate,height:e.video.height,width:e.video.width,deviceId:e.video.deviceId,facingMode:e.video.facingMode};if(R(e)&&e.screen){if(E.getDisplayMedia&&!e.screen.forceChromePlugin)return Co({audio:t,video:{displaySurface:Eo(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await vo(!1,e.screen);return Co({audio:t,video:r})}return Co({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&gn.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId,event_grade:An.GENERAL,event_category:hn.VIDEO}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&gn.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId,event_grade:An.GENERAL,event_category:hn.AUDIO});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?Mn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),R(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),I(e)&&(n=e.video.bitrate,a=e.video.tag);const s=r?r.getTracks():[],c=[];for(const t of s){let r;e.video&&e.video.optimizationMode&&(r=e.video.optimizationMode),e.screen&&e.screen.optimizationMode&&(r=e.screen.optimizationMode),r&&No(t,r)}for(const e of s){let t;t="audio"===e.kind?wo(e,o,i):wo(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await xa.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&R(e)&&I(e))throw kn("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new Bo(t,"send")}async getUserMedia(e,r,n=!0){if(jr.debug("request to get user media, config",e),jr.debug("request to get user media, constraints",r),!r.audio&&!r.video)return null;let i;if(R(e))i=await this.getDisplayMedia(r,e);else if(i=await navigator.mediaDevices.getUserMedia(r),!S&&"getSettings"in MediaStreamTrack.prototype&&n){const n=r.video;if(n&&"boolean"!=typeof n){const a=n.width,o=n.height;if("number"==typeof a&&"number"==typeof o){const s=i.getVideoTracks(),c=s&&s[0],{height:d=o,width:u=a}=c.getSettings();if(u&&d){const s=(o-d)*(a-u);if(s*s>10){const s=o/a;return d/ue.stop()),this.getUserMedia(e,t({},r,{video:n}),!1)}}}}}return i}async getDisplayMedia(e,t){let r,n;e.audio&&(r=await navigator.mediaDevices.getUserMedia({audio:e.audio}));const i=t.screen&&t.screen.audio&&!e.audio?{video:e.video,audio:t.screen.audio}:{video:e.video};return n=E.getDisplayMedia&&t.screen&&!t.screen.forceChromePlugin?await navigator.mediaDevices.getDisplayMedia(i):await navigator.mediaDevices.getUserMedia(i),r&&n.addTrack(r.getAudioTracks()[0]),n}async updateDeivceInfo(){this.deviceInfo=await navigator.mediaDevices.enumerateDevices();const e=this.deviceInfo.map(e=>e.deviceId),t=Object.keys(this.deviceMap);let r=!1;t.forEach(t=>{if(-1===e.indexOf(t)&&"@default"!==t){this.emit("device-remove",this.deviceMap[t].device);const e=this.deviceMap[t].device;this.emit("device-changed",{device:e,state:qr.INACTIVE});const n="audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",i="AudioDeviceInOut"===n?hn.AUDIO:hn.VIDEO;gn.addEvent(n,{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label,event_grade:An.GENERAL,event_category:i}),delete this.deviceMap[t],r=!0}else this.deviceMap[t].tick+=1}),e.forEach((e,n)=>{if(-1===t.indexOf(e)&&"@default"!==e){this.deviceMap[e]={device:this.deviceInfo[n],tick:0};const t=this.deviceMap[e].device;this.emit("device-changed",{device:t,state:qr.ACTIVE}),this.emit("device-add",t);const i="audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",a="AudioDeviceInOut"===i?hn.AUDIO:hn.VIDEO;gn.addEvent(i,{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId,event_grade:An.GENERAL,event_category:a}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class Ho{static get VERSION(){return Hr}static isBrowserSupported(){return E.support}static async checkSystemRequirements(){return await Oo()}static setLogLevel(e){switch(e){case an.VERBOSE:jr.setLevel("log");break;case an.INFO:jr.setLevel("debug");break;case an.WARNING:case an.ERROR:jr.setLevel("warning");break;case an.NONE:jr.setLevel("disable")}}static async isChromeExtensionAvailable(){return await go()}static createClient(){const e=new _a(this._transportPolicy);return Ho._clients.push(e),e}static async getCameras(e=!1){return Go.getDeviceInfo(e,"cameras")}static async getMicrophones(e=!1){return Go.getDeviceInfo(e,"microphones")}static async getPlaybackDevices(e=!1){return Go.getDeviceInfo(e,"playback")}static async getDevices(e=!1){return Go.getDeviceInfo(e,"all")}static async createCameraVideoTrack(e){let r;if(jr.log("createCameraVideoTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Wr[e.encoderConfig]))throw Hn()}else r=t({},zr,e.encoderConfig);else r=zr;const n=(await Go.getLocalTracks({video:ii({enabled:!0,width:r.width,height:r.height,frameRate:r.frameRate,bitrate:r.bitrate,tag:e&&e.tag,facingMode:e&&e.facingMode,optimizationMode:e&&e.optimizationMode,deviceId:e&&e.cameraId})}))[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(n.lowStreamConfig=e.encoderConfig.lowStreamConfig);const i=new Ma(n);return void 0!==r.isMultiProfileEnabled&&(i.isMultiProfileEnabled=r.isMultiProfileEnabled),jr.log("createCameraVideoTrack end",i),i}static async createMicrophoneAudioTrack(e){let r;if(jr.log("createMicrophoneAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag})}),i=new Fa(n[0]);return jr.log("createMicrophoneAudioTrack end",i),i}static async createScreenVideoTrack(e,r){let n;if(jr.log("createScreenVideoTrack start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Qr[e.encoderConfig]))throw Hn()}else n=t({},Jr,e.encoderConfig);else n=Jr;let i=[];if(y)i=await Go.createElectronScreenTrack(ii({sourceID:e&&e.electronScreenSourceID,screenBitrate:n.bitrate,width:n.width,height:n.height,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag}));else{let a=ii({enabled:!0,width:n.width,height:n.height,bitrate:n.bitrate,optimizationMode:e&&e.optimizationMode,tag:e&&e.screenVideoTag,audio:!(!r||!["enable","auto"].includes(r))||void 0,audioTag:e&&e.screenAudioTag});if(e&&e.chromeExtensionSourceType)switch(e.chromeExtensionSourceType){case Zr.ALL:a=t({},a,{forceChromePlugin:!0});break;case Zr.SCREEN:case Zr.WINDOW:a=t({},a,{forceChromePlugin:!0,source:e.chromeExtensionSourceType})}i=await Go.getLocalTracks({screen:a})}if(1===i.length&&"video"===i[0].info.kind&&"enable"===r)throw i[0].release(),In();if(1===i.length&&"video"===i[0].info.kind){const t=i[0];e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(t.lowStreamConfig=e.encoderConfig.lowStreamConfig);const r=new ja(t);return void 0!==n.isMultiProfileEnabled&&(r.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",r),r}{const t=i.filter(e=>"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw kn(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new Ea(t),o=new ja(r);return void 0!==n.isMultiProfileEnabled&&(o.isMultiProfileEnabled=n.isMultiProfileEnabled),jr.log("createScreenVideoTrack end",[o,a]),[o,a]}}static async createMicrophoneAndCameraTracks(e,r){let n,i;if(jr.log("createMicrophoneAndCameraTracks start",e,r),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(n=Xr[e.encoderConfig]))throw Hn()}else n=t({},Kr,e.encoderConfig);else n=Kr;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=Wr[r.encoderConfig]))throw Hn()}else i=t({},zr,r.encoderConfig);else i=zr;const a=await Go.getLocalTracks({audio:ii({enabled:!0,bitrate:n.bitrate,sampleRate:n.sampleRate,sampleSize:n.sampleSize,channelCount:n.stereo?2:1,autoGainControl:e&&e.AGC,noiseSuppression:e&&e.ANS,echoCancellation:e&&e.AEC,deviceId:e&&e.microphoneId,tag:e&&e.tag}),video:ii({enabled:!0,width:i.width,height:i.height,frameRate:i.frameRate,bitrate:i.bitrate,tag:r&&r.tag,facingMode:r&&r.facingMode,deviceId:r&&r.cameraId})}),o=a.filter(e=>"audio"===e.info.kind)[0],s=a.filter(e=>"video"===e.info.kind)[0];if(!o||!s)throw kn(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new Fa(o),d=new Ma(s);return void 0!==i.isMultiProfileEnabled&&(d.isMultiProfileEnabled=i.isMultiProfileEnabled),jr.log("createMicrophoneAndCameraTracks end",[c,d]),[c,d]}static async createBufferSourceAudioTrack(e){let r;if(jr.log("createBufferSourceAudioTrack start",e),e&&e.encoderConfig)if("string"==typeof e.encoderConfig){if(!(r=Xr[e.encoderConfig]))throw Hn()}else r=t({},Kr,e.encoderConfig);else r=Kr;const n=await Go.getLocalTracks({audio:ii({enabled:!0,source:e.source,bitrate:r.bitrate,sampleRate:r.sampleRate,sampleSize:r.sampleSize,channelCount:r.stereo?2:1,tag:e&&e.tag})}),i=new Va(n[0],e.source);return jr.log("createBufferSourceAudioTrack end",i),i}static createCanvasVideoTrack(e){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");if(null===r)throw wn("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw wn("capture stream error, canvas track not supported");n=t.mozCaptureStream(15)}const i=n.getTracks()[0];e.optimizationMode&&"contentHint"in i&&(i.contentHint=e.optimizationMode);const a=wo(i,e.tag);return new qa(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=wo(e.mediaStreamTrack,e.tag,e.bitrate);return new Wa(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=wo(e.mediaStreamTrack,e.tag,e.bitrate);return new za(t)}static setTransportPolicy(e){e===on.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===on.FORCE_UDP&&(this._transportPolicy="forceUdp"),this._clients.forEach(e=>e.setTransportPolicy(this._transportPolicy))}static async checkAudioTrackIsActive(e,t=5e3){const r=Math.min(200,t);return new Promise((t,n)=>{if(e.isAudio()){const n=.01,i=200;let a=e.getVolumeLevel()||0,o=e.getVolumeLevel()||0,s=o<=n,c=!0;if(e.isMuted())t(!1);else{const d=setInterval(()=>{e.isMuted()?(t(!1),clearInterval(d)):(a=o,(o=e.getVolumeLevel()||0)>n&&(s=!1),o!==a&&(c=!1))},i);setTimeout(()=>setTimeout(()=>{d&&(clearInterval(d),t(!s&&!c))},0),r)}}else n(kn("only support audio track"))})}static async checkVideoTrackIsActive(e,t=5e3){return new Promise((r,n)=>{if(e.isVideo()){const i=e.getMediaStreamTrack();if(e.isMuted()&&r(!1),void 0===i)n(kn("cannot find mediaStreamTrack"));else{const a=document.createElement("video");a.style.width="1px",a.style.height="1px",a.setAttribute("muted",""),a.muted=!0,a.setAttribute("playsinline",""),a.controls=!1,a.style.opacity="0.01",a.style.position="fixed",a.style.left="0",a.style.top="0",document.body.appendChild(a),a.srcObject=new MediaStream([i]),a.play();const o=document.createElement("canvas");o.width=160,o.height=120;const s=o.getContext("2d");if(s){let n=!1,i=null;const c=setInterval(()=>{e.isMuted()&&(c&&(clearInterval(c),r(!1)),a&&a.remove()),s.drawImage(a,0,0,160,120);const t=s.getImageData(0,0,o.width,o.height);var d=Math.floor(t.data.length/3);if(i){for(let e=0;e{setTimeout(()=>{c&&(clearInterval(c),r(n)),a&&a.remove()},0)},t)}else n(kn("can not get canvas 2d context"))}}else n(kn("only support video track"))})}static async getElectronScreenSources(e){return Go.getElectronScreenSources(e)}}return Ho._clients=[],Ho._transportPolicy="preferUdp",Go.on("device-changed",e=>{switch(e.device.kind){case"audioinput":Ho.onMicrophoneChanged&&Ho.onMicrophoneChanged(e);break;case"audiooutput":Ho.onPlaybackDeviceChanged&&Ho.onPlaybackDeviceChanged(e);break;case"videoinput":Ho.onCameraChanged&&Ho.onCameraChanged(e)}}),Ho}); diff --git a/ReleaseNotes/release-note-4.1.9.md b/ReleaseNotes/release-note-4.1.9.md new file mode 100644 index 0000000..5b23886 --- /dev/null +++ b/ReleaseNotes/release-note-4.1.9.md @@ -0,0 +1,13 @@ +# QNRTCWeb v4.1.9 + +## 简介 +QNRTCWeb 是七牛云推出的一款适用于 Web 平台的实时音视频 SDK,提供了包括音视频通话、静音、发布、订阅多种功能,提供灵活的接口,支持高度定制以及二次开发。 + +## 修复 +- 修复远端音频无法设置音量问题 +- 修复远端音频订阅问题 + +## 问题反馈 +当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 `issues` 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 `Labels` 中指明类型为 bug 或者其他。 + +[通过这里查看已有的 issues 和提交 bug](https://github.com/pili-engineering/QNRTC-Web/issues)