From 8f48f92fe931cbb1284289947072194ff21aa315 Mon Sep 17 00:00:00 2001 From: tongjie <794095300@qq.com> Date: Fri, 17 Jun 2022 11:08:37 +0800 Subject: [PATCH] release/4.1.3 --- API-Examples-Web/assets/qnweb-rtc.js | 2 +- Demo/package-lock.json | 517 +++++++++++++++++++++------ Demo/package.json | 4 +- Release/qnweb-rtc.js | 2 +- ReleaseNotes/release-note-4.1.3.md | 13 + 5 files changed, 426 insertions(+), 112 deletions(-) create mode 100644 ReleaseNotes/release-note-4.1.3.md diff --git a/API-Examples-Web/assets/qnweb-rtc.js b/API-Examples-Web/assets/qnweb-rtc.js index 6f340db..64e4b6a 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 C=s++;o[C]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var E=s++;o[E]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";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 x=s++;o[x]="^"+o[R]+o[C]+"$";var O=s++;o[O]="^"+o[R]+o[E]+"$";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[C]+"$";var N=s++;o[N]="^"+o[B]+o[E]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var j=s++;o[j]="^"+o[k]+"\\s*("+b+")$|^$";var F=s++;o[F]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[C]+")",a[F]=new RegExp(o[F],"g");var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var V=s++;o[V]="(<|>)?=?\\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[j],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[q]:a[U];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[F],"$1$2$3"),r("comparator trim",e,a[F]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[j],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[O]:a[x];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[M]:a[P];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[V],"")}(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}const w=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:_(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),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 Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Me(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},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)},Ee.prototype.clear=function(){this.__data__=new _e},Ee.prototype.delete=function(e){return this.__data__.delete(e)},Ee.prototype.get=function(e){return this.__data__.get(e)},Ee.prototype.has=function(e){return this.__data__.has(e)},Ee.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=F?function(e){return function(t){return e(t)}}(F):function(e){return it(e)&&rt(e.length)&&!!x[re.call(e)]};function st(e){return et(e)?Pe(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=Oe(t);++n!!e&&!!e.audio&&e.audio.enabled,M=e=>!!e&&!!e.video&&e.video.enabled,I=e=>!!e&&!!e.screen&&e.screen.enabled;var R,D,x,O,B;function L(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(R||(R={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(D||(D={})),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"}(O||(O={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(B||(B={}));const G={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var N;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.END="end"}(N||(N={}));const H={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"))},x=function(){if(!D())return!1;var e=N();return!!window.WebGLRenderingContext&&!!e},O=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){O()?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){x()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){x()?e(C()):e()}},{key:"adBlock",getData:function(e){e(E())}},{key:"hasLiedLanguages",getData:function(e){e(P())}},{key:"hasLiedResolution",getData:function(e){e(M())}},{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)},j.getPromise=function(e){return new Promise(function(t,r){j.get(e,t)})},j.getV18=function(e,t){return null==t&&(t=e,e={}),j.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=x;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+=j:"[object Uint16Array]"===r?i+=U:"[object Int32Array]"===r?i+=F:"[object Uint32Array]"===r?i+=q:"[object Float32Array]"===r?i+=V:"[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(x+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,O)!==x)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(O,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 j:return new Int16Array(o);case U:return new Uint16Array(o);case F:return new Int32Array(o);case q:return new Uint32Array(o);case V: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]),V=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]),W=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),X=new Array(576);U(X);const K=new Array(60);U(K);const Q=new Array(512);U(Q);const J=new Array(256);U(J);const Z=new Array(29);U(Z);const $=new Array(30);function Y(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 ee,te,re;function ne(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U($);const ie=e=>e<256?Q[e]:Q[256+(e>>>7)],ae=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},oe=(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<{oe(e,r[2*t],r[2*t+1])},ce=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},de=(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]=ce(n[t]++,t))}},ue=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},le=e=>{e.bi_valid>8?ae(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ae=(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?se(e,i,t):(a=J[i],se(e,a+256+1,t),0!==(o=q[a])&&(i-=Z[a],oe(e,i,o)),a=ie(--n),se(e,a,r),0!==(o=V[a])&&(n-=$[a],oe(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--)he(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],he(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++,he(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),de(r,d,e.bl_count)},me=(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{oe(e,0+(n?1:0),3),((e,t,r,n)=>{le(e),n&&(ae(e,r),ae(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var be={_tr_init:e=>{ve||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for(Z[n]=r,e=0;e<1<>=7;n<30;n++)for($[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)),pe(e,e.l_desc),pe(e,e.d_desc),o=(e=>{let t;for(me(e,e.dyn_ltree,e.l_desc.max_code),me(e,e.dyn_dtree,e.d_desc.max_code),pe(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*z[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?Te(e,t,r,n):4===e.strategy||a===i?(oe(e,2+(n?1:0),3),fe(e,X,K)):(oe(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(oe(e,t-257,5),oe(e,r-1,5),oe(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*(J[r]+256+1)]++,e.dyn_dtree[2*ie(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{oe(e,2,3),se(e,256,X),(e=>{16===e.bi_valid?(ae(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 Se=(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 ye=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 ke=(e,t,r,n)=>{const i=ye,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},_e={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"},we={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:Ee,_tr_flush_block:Pe,_tr_tally:Me,_tr_align:Ie}=be,{Z_NO_FLUSH:Re,Z_PARTIAL_FLUSH:De,Z_FULL_FLUSH:xe,Z_FINISH:Oe,Z_BLOCK:Be,Z_OK:Le,Z_STREAM_END:Ge,Z_STREAM_ERROR:Ne,Z_DATA_ERROR:He,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Fe,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:Ve,Z_FIXED:We,Z_DEFAULT_STRATEGY:ze,Z_UNKNOWN:Xe,Z_DEFLATED:Ke}=we,Qe=286,Je=30,Ze=19,$e=2*Qe+1,Ye=15,et=(e,t)=>(e.msg=_e[t],t),tt=e=>(e<<1)-(e>4?9:0),rt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let nt=(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))},at=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,it(e.strm)},ot=(e,t)=>{e.pending_buf[e.pending++]=t},st=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ct=(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=Se(e.adler,t,i,r):2===e.state.wrap&&(e.adler=ke(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},dt=(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},ut=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=ct(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=nt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=nt(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)},lt=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=dt(e,r)),e.match_length>=3)if(n=Me(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=nt(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=nt(e,e.ins_h,e.window[e.strstart+1]);else n=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2},At=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=Me(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=nt(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&&(at(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Me(e,0,e.window[e.strstart-1]))&&at(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=Me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2};function ht(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 ft=[new ht(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(ut(e),0===e.lookahead&&t===Re)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,at(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(at(e,!1),e.strm.avail_out),1)}),new ht(4,4,8,4,lt),new ht(4,5,16,8,lt),new ht(4,6,32,32,lt),new ht(4,4,16,16,At),new ht(8,16,32,32,At),new ht(8,16,128,128,At),new ht(8,32,128,256,At),new ht(32,128,258,1024,At),new ht(32,258,258,4096,At)];function pt(){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=Ke,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*$e),this.dyn_dtree=new Uint16Array(2*(2*Je+1)),this.bl_tree=new Uint16Array(2*(2*Ze+1)),rt(this.dyn_ltree),rt(this.dyn_dtree),rt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Ye+1),this.heap=new Uint16Array(2*Qe+1),rt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Qe+1),rt(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 mt=e=>{if(!e||!e.state)return et(e,Ne);e.total_in=e.total_out=0,e.data_type=Xe;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=Re,Ce(t),Le},gt=e=>{const t=mt(e);return t===Le&&(e=>{e.window_size=2*e.w_size,rt(e.head),e.max_lazy_match=ft[e.level].max_lazy,e.good_match=ft[e.level].good_length,e.nice_match=ft[e.level].nice_length,e.max_chain_length=ft[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},vt=(e,t,r,n,i,a)=>{if(!e)return Ne;let o=1;if(t===Fe&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Ke||n<8||n>15||t<0||t>9||a<0||a>We)return et(e,Ne);8===n&&(n=9);const s=new pt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<vt(e,t,Ke,15,8,ze),deflateInit2:vt,deflateReset:gt,deflateResetKeep:mt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?Ne:(e.state.gzhead=t,Le):Ne,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Be||t<0)return e?et(e,Ne):Ne;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Oe)return et(e,0===e.avail_out?je:Ne);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,ot(i,31),ot(i,139),ot(i,8),i.gzhead?(ot(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)),ot(i,255&i.gzhead.time),ot(i,i.gzhead.time>>8&255),ot(i,i.gzhead.time>>16&255),ot(i,i.gzhead.time>>24&255),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ot(i,255&i.gzhead.extra.length),ot(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=ke(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,3),i.status=113);else{let t=Ke+(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,st(i,t),0!==i.strstart&&(st(i,e.adler>>>16),st(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending!==i.pending_buf_size));)ot(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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&&it(e),i.pending+2<=i.pending_buf_size&&(ot(i,255&e.adler),ot(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(it(e),0===e.avail_out)return i.last_flush=-1,Le}else if(0===e.avail_in&&tt(t)<=tt(a)&&t!==Oe)return et(e,je);if(666===i.status&&0!==e.avail_in)return et(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==Re&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(ut(e),0===e.lookahead)){if(t===Re)return 1;break}if(e.match_length=0,r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Ve?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(ut(e),e.lookahead<=258&&t===Re)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=Me(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):ft[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),Le;if(2===r&&(t===De?Ie(i):t!==Be&&(Ee(i,0,0,!1),t===xe&&(rt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),it(e),0===e.avail_out))return i.last_flush=-1,Le}return t!==Oe?Le:i.wrap<=0?Ge:(2===i.wrap?(ot(i,255&e.adler),ot(i,e.adler>>8&255),ot(i,e.adler>>16&255),ot(i,e.adler>>24&255),ot(i,255&e.total_in),ot(i,e.total_in>>8&255),ot(i,e.total_in>>16&255),ot(i,e.total_in>>24&255)):(st(i,e.adler>>>16),st(i,65535&e.adler)),it(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Le:Ge)},deflateEnd:e=>{if(!e||!e.state)return Ne;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?et(e,Ne):(e.state=null,113===t?et(e,He):Le)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return Ne;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Ne;if(1===i&&(e.adler=Se(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(rt(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,ut(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=nt(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,ut(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,Le},deflateInfo:"pako deflate (from Nodeca project)"};const bt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var St={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)bt(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;kt[254]=kt[254]=1;var _t={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&&yt)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+kt[e[r]]>t?r:t}};var wt=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:Et,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:Mt,Z_FINISH:It,Z_OK:Rt,Z_STREAM_END:Dt,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Ot,Z_DEFLATED:Bt}=we;function Lt(e){this.options=St.assign({level:xt,method:Bt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ot},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 wt,this.strm.avail_out=0;let r=Tt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Rt)throw new Error(_e[r]);if(t.header&&Tt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?_t.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=Tt.deflateSetDictionary(this.strm,e))!==Rt)throw new Error(_e[r]);this._dict_set=!0}}function Gt(e,t){const r=new Lt(t);if(r.push(e,!0),r.err)throw r.msg||_e[r.err];return r.result}Lt.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?It:Et,"string"==typeof e?r.input=_t.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===Mt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=Tt.deflate(r,a))===Dt)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Tt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Rt;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},Lt.prototype.onData=function(e){this.chunks.push(e)},Lt.prototype.onEnd=function(e){e===Rt&&(this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Nt={Deflate:Lt,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:we};var Ht=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 C=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=C.dmax,c=C.wsize,d=C.whave,u=C.wnext,l=C.window,A=C.hold,h=C.bits,f=C.lencode,p=C.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",C.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&C.sane){e.msg="invalid distance too far back",C.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,C=0;const E=new Uint16Array(16),P=new Uint16Array(16);let M,I,R,D=null,x=0;for(p=0;p<=15;p++)E[p]=0;for(m=0;m=1&&0===E[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(P[1]=0,p=1;p<15;p++)P[p+1]=P[p]+E[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){M=p-S,o[m]f?(I=D[x+o[m]],R=w[C+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=M<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--E[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:Wt,Z_BLOCK:zt,Z_TREES:Xt,Z_OK:Kt,Z_STREAM_END:Qt,Z_NEED_DICT:Jt,Z_STREAM_ERROR:Zt,Z_DATA_ERROR:$t,Z_MEM_ERROR:Yt,Z_BUF_ERROR:er,Z_DEFLATED:tr}=we,rr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function nr(){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 ir=e=>{if(!e||!e.state)return Zt;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,Kt},ar=e=>{if(!e||!e.state)return Zt;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ir(e)},or=(e,t)=>{let r;if(!e||!e.state)return Zt;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Zt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ar(e))},sr=(e,t)=>{if(!e)return Zt;const r=new nr;e.state=r,r.window=null;const n=or(e,t);return n!==Kt&&(e.state=null),n};let cr,dr,ur=!0;const lr=e=>{if(ur){cr=new Int32Array(512),dr=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(Vt(1,e.lens,0,288,cr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Vt(2,e.lens,0,32,dr,0,e.work,{bits:5}),ur=!1}e.lencode=cr,e.lenbits=9,e.distcode=dr,e.distbits=5},Ar=(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.whavesr(e,15),inflateInit2:sr,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 C,E;const P=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 Zt;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=Kt;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=ke(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)!==tr){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=ke(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=ke(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=ke(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=ke(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=ke(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(lr(r),r.mode=20,t===Xt){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===Xt)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[P[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,C={bits:r.lenbits},k=Vt(0,r.lens,0,19,r.lencode,0,r.work,C),r.lenbits=C.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(E=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(E=m+3;u>>=m)),d>>>=3,u-=3}else{for(E=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,C={bits:r.lenbits},k=Vt(1,r.lens,0,r.nlen,r.lencode,0,r.work,C),r.lenbits=C.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,C={bits:r.distbits},k=Vt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,C),r.distbits=C.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Xt)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,Ht(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(E=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(E=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 Zt;let t=e.state;return t.window&&(t.window=null),e.state=null,Kt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return Zt;const r=e.state;return 0==(2&r.wrap)?Zt:(r.head=t,t.done=!1,Kt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?Zt:11===n.mode&&(i=Se(i=1,t,r,0))!==n.check?$t:(a=Ar(e,t,r,r))?(n.mode=31,Yt):(n.havedict=1,Kt):Zt},inflateInfo:"pako inflate (from Nodeca project)"};var fr=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 pr=Object.prototype.toString,{Z_NO_FLUSH:mr,Z_FINISH:gr,Z_OK:vr,Z_STREAM_END:Tr,Z_NEED_DICT:br,Z_STREAM_ERROR:Sr,Z_DATA_ERROR:yr,Z_MEM_ERROR:kr}=we;function _r(e){this.options=St.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 wt,this.strm.avail_out=0;let r=hr.inflateInit2(this.strm,t.windowBits);if(r!==vr)throw new Error(_e[r]);if(this.header=new fr,hr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=_t.string2buf(t.dictionary):"[object ArrayBuffer]"===pr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=hr.inflateSetDictionary(this.strm,t.dictionary))!==vr))throw new Error(_e[r])}function wr(e,t){const r=new _r(t);if(r.push(e),r.err)throw r.msg||_e[r.err];return r.result}_r.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?gr:mr,"[object ArrayBuffer]"===pr.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=hr.inflate(r,o))===br&&i&&((a=hr.inflateSetDictionary(r,i))===vr?a=hr.inflate(r,o):a===yr&&(a=br));r.avail_in>0&&a===Tr&&r.state.wrap>0&&0!==e[r.next_in];)hr.inflateReset(r),a=hr.inflate(r,o);switch(a){case Sr:case yr:case br:case kr:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===Tr))if("string"===this.options.to){let e=_t.utf8border(r.output,r.next_out),t=r.next_out-e,i=_t.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!==vr||0!==s){if(a===Tr)return a=hr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===vr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:_r,inflate:wr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,wr(e,t)},ungzip:wr,constants:we};const{Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir}=Nt,{Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or}=Cr;var Br={Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir,Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or,constants:we},Lr=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(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},Ce.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ce.prototype.delete=function(e){return Ve(this,e).delete(e)},Ce.prototype.get=function(e){return Ve(this,e).get(e)},Ce.prototype.has=function(e){return Ve(this,e).has(e)},Ce.prototype.set=function(e,t){return Ve(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)},Pe.prototype.clear=function(){this.__data__=new we},Pe.prototype.delete=function(e){return this.__data__.delete(e)},Pe.prototype.get=function(e){return this.__data__.get(e)},Pe.prototype.has=function(e){return this.__data__.has(e)},Pe.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 Ee: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=F?function(e){return function(t){return e(t)}}(F):function(e){return lt(e)&&dt(e.length)&&!!x[ne.call(e)]};function ft(e){return st(e)?Me(e):Fe(e)}function pt(e){return e}e.exports=rt});const Nr="4.1.2";function Hr(){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=`${Hr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Hr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Hr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Fr 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 kn("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 kn("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}const Ur="qnrtcqosevents";function qr(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})},500)})}function Vr(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 Wr=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Fr("qossubmit",!1),qr().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:Nr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(Pn)}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:H[e],event_name:e},r);this.submitQueue.push("add",i).catch(Pn),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(Pn)}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 F.getItem(Ur);jr.log("get item",e),await F.removeItem(Ur),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)));F.setItem(Ur,e).catch(Pn)}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 Zr("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await F.removeItem(Ur)}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(Br.gzip(Vr(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function zr(e,t){let r;switch(e){case"prompt":r=D.prompt;break;case"granted":r=D.granted;break;case"denied":r=D.denied;break;default:return}Wr.addEvent("AuthorizationStatus",{type:t,status:r})}function Xr(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{zr(e.state,R[t]),e.onchange=(()=>{zr(e.state,R[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Xr("camera"),Xr("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{Wr.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2})});const Kr=(()=>{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=()=>{Wr.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e})},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 Qr extends Error{constructor(e,t){super(t),this.code=e,this.error=t,Wr.addEvent("SDKError",{error_code:e,error_msg:t})}}const Jr=e=>new Qr(10053,`invalid parameters: ${e}`),Zr=e=>new Qr(21005,`piliRTC: unexpected error ${e}`),$r=e=>new Qr(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),Yr=e=>new Qr(21006,`not support! ${e}`),en=e=>new Qr(21007,`track play is not allowed: ${e}`),tn=e=>new Qr(23003,`plugin not avaliable! ${e}`),rn=e=>new Qr(23004,`NotAllowedError: no permission to access media device. ${e}`),nn=e=>new Qr(22011,`can not decode audio data, ${e.toString()}`),an=()=>new Qr(23005,"no audio track when createScreenVideoTrack withAudio enable"),on=e=>new Qr(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),sn=e=>new Qr(24e3,`relay error, can not get relayToken. Error: ${e}`),cn=e=>new Qr(24001,`invalid client mode, ${e}`),dn=e=>new Qr(24002,`invalid client role, ${e}`),un=()=>Zr("websocket abort"),ln=e=>Jr(`can not set merge layout stream, no merge job id ${e}`),An=()=>rn("can not sharing screen/window on chrome"),hn=()=>Zr("subscribe/publish operation is aborted"),fn=()=>Jr("cannot found preset"),pn=(e,t)=>new Qr(e,`publish error, signaling code: ${e}, msg: ${t}`),mn=(e,t)=>new Qr(e,`create merge job error, signaling code: ${e}, msg: ${t}`),gn=(e,t)=>new Qr(e,`create forward job error, signaling code: ${e}, msg: ${t}`),vn=(e,t)=>new Qr(e,`media format not support, ${t}`),Tn=(e,t)=>new Qr(e,`subscribe error, signaling code: ${e}, msg: ${t}`),bn=(e,t)=>new Qr(e,`send control error, code: ${e}, msg: ${t}`),Sn=(e,t)=>new Qr(e,t),yn=()=>new Qr(10052,"server unavailable");class kn extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,kn):this.stack=new Error(e).stack}}var _n=Object.freeze({QNRTCError:Qr,ERROR_INVALID_PARAMETER:Jr,ERROR_FATAL:Zr,ERROR_AUTH_FAILED:$r,ERROR_RECONNECT_FAILED:e=>new Qr(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:Yr,ERROR_PLAY_NOT_ALLOWED:en,ERROR_PLUGIN_NOT_AVAILABLE:tn,ERROR_DEVICE_NOT_ALLOWED:rn,ERROR_AUDIO_DECODE_ERROR:nn,CREATE_SCREEN_AUDIO_ERROR:an,ERROR_ELECTRON_REQUIRE_ERROR:on,ERROR_RELAY_TOKEN:sn,ERROR_INVALID_CLIENT_MODE:cn,ERROR_INVALID_CLIENT_ROLE:dn,WS_ABORT:un,NO_MERGE_JOB:ln,SCREEN_PERMISSION_DENIED:An,SUB_PUB_ABORT:hn,PRESET_NOT_FOUND:fn,PUBLISH_ERROR:pn,CREATE_MERGE_JOB_ERROR:mn,CREATE_FORWARD_JOB_ERROR:gn,UNSUPPORT_FMT:vn,JOIN_ROOM_ERROR:(e,t)=>new Qr(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Tn,UNPUBLISH_ERROR:(e,t)=>new Qr(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Qr(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:bn,SERVER_ERROR:Sn,SERVER_UNAVAILABLE:yn,InvalidStateError:kn});function wn(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 Cn(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw Zr(`can not parse roomToken, ${e}`)}}function En(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]=Mn(e[r],t+1));return e}function In(e){Promise.resolve().then(e)}function Rn(e){return("0"+e.toString(16)).substr(-2)}function Dn(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,Rn).join("")}function xn(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const On={};function Bn(e,t){if(!On[t])return On[t]=!0,e()}function Ln(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Gn(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>r.abort(),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 Nn(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 xn(1e3),await Nn(e)}}var Hn;!function(e){e[e.AudioLevelUnusual=0]="AudioLevelUnusual"}(Hn||(Hn={}));class jn{static create(e){this.instance||(this.instance=new jn);const r=this.instance.getValidStandard(e.code);return this.instance.qosAddEvent(t({valid_standard:r},e)),this.instance}constructor(){}qosAddEvent(e){Wr.addEvent("WebSDKException",e)}getValidStandard(e){switch(e){case Hn.AudioLevelUnusual:return"0-1"}}}class Fn{constructor(e,t=Fn.AlphaForPacketLossFractionSmoother){this.mLastFilteredTimestamp=Date.now(),this.mMax=Fn.kValueUndefined,this.smooth_interval="audio"===e?Fn.SMOOTH_AUDIO_INTERVAL:Fn.SMOOTH_VIDEO_INTERVAL,this.Reset(t)}Reset(e){this.mAlpha=e,this.mFiltered=Fn.kValueUndefined}Apply(e){const t=Date.now()-this.mLastFilteredTimestamp;if(tthis.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 Un(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Fn(r),e[t])}Fn.kValueUndefined=-1,Fn.AlphaForPacketLossFractionSmoother=.9999,Fn.SMOOTH_VIDEO_INTERVAL=1e3,Fn.SMOOTH_AUDIO_INTERVAL=5e3;const qn=Un(),Vn=Un(),Wn=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function zn(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 Xn={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},Kn={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},Qn={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var Jn,Zn,$n;async function Yn(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===Zn.InBoundRtp||e.type===Zn.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[Zn.MediaSource]:r.filter(e=>e.type===Zn.MediaSource).find(t=>t.id===e.mediaSourceId),[Zn.Track]:r.filter(e=>e.type===Zn.Track).find(t=>t.id===e.trackId),[Zn.RemoteInBound]:r.filter(e=>e.type===Zn.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({},Qn)};return n===Jn.Audio?i.extra_stats=t({},Xn):i.extra_stats=t({},Kn),i}(e.id,e.trackID,e.mediaType);a.rtt=ti(i[Zn.RemoteInBound])||ti(e)||0,a.calculation_stats.packets_lost=ri(e,i[Zn.RemoteInBound])||0,e.mediaType===Jn.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[Zn.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.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=ei(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[Zn.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=ei(e.audioLevel,e.type),t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.Track],a,n)));return a})(e,i,r))}function ei(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===Zn.InBoundRtp?(r=Math.min(e/32767,1),jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function ti(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function ri(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function ni(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 ii(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};w.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return w.unifiedPlan&&w.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function ai(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"})}async function oi(e,r,n,i){if(w.stats){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=ni(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=zn(a,i.rtt);const o=qn(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})}(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=Wn(),a=n.get(e.remoteId);t.packetLoss=ri(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=ti(e)||ti(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),i)}return Bn(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}!function(e){e.Video="video",e.Audio="audio"}(Jn||(Jn={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(Zn||(Zn={})),function(e){e.In="in",e.Out="out"}($n||($n={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(di="PermissionDeniedError",ci)return ci("PermissionDeniedError");throw An()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(di="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&&ci&&ci(si=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let si,ci,di="screen";async function ui(){return await(()=>new Promise((e,t)=>{"desktop"!==di?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==di)},2e3)):e(!0)}))()}async function li(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:di,maxWidth:Ci(t.width),maxHeight:Ci(t.height)},optional:[]};"desktop"!==di?n(o):e?function(e){if(si)return e(si);ci=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(An())}):function(e,t=!1,r=!1){ci=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(An())},"screen"===r,"window"===r)}))()}var Ai=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(e,t){return!!(e?e.length:0)&&function(e,t,r){if(t!=t)return function(e,t,r,n){var i=e.length,a=r+(n?1:-1);for(;n?a--:++a-1}function q(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Pe.prototype.set=function(e,t){var r=this.__data__,n=xe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Me.prototype.clear=function(){this.__data__={hash:new Ee,map:new(fe||Pe),string:new Ee}},Me.prototype.delete=function(e){return qe(this,e).delete(e)},Me.prototype.get=function(e){return qe(this,e).get(e)},Me.prototype.has=function(e){return qe(this,e).has(e)},Me.prototype.set=function(e,t){return qe(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 Pe},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 Pe){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=F?function(e){return function(t){return e(t)}}(F):function(e){return st(e)&&at(e.length)&&!!x[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=U,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=q;else if(o>=r){var u=t?null:Fe(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=Ai(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{E(this.tracks,t=>t===e)})}removeTracksByTrackId(e){E(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=Ai(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){E(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function fi(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 pi(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),In(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),t}class mi extends C{safeEmit(e,...t){try{this.emit(e,...t)}catch(t){jr.warning("safeEmit() | event listener threw an error [event:%s]:%o",e,t)}}safeEmitAsPromise(e,...t){return new Promise((r,n)=>{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}class gi extends mi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=B.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),Wr.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label}),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(w.setPlaybackDevice||Yr("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?pi:fi;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(Pn)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(Pn)},!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)),Wr.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t})):i(Zr(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(Ln),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(Ln)}}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&&w.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}}function vi(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function Ti(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 bi(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 Si(e){if(!e.info.mid&&w.unifiedPlan)throw Zr("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 yi(e){return new hi(e.playerid,e.playerdata)}function ki(e,t,r){let n;return"audio"===e.kind?(n=new Ra(e)).initAudioManager(!0):n=new gi(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function _i(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const wi=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(w.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}(Mn(e)));function Ci(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}var Ei=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")})})}),Pi=(Ei.v,Ei.o,Ei.s,Ei.i,Ei.u,Ei.e,Ei.p,Ei.z,Ei.r,Ei.t,Ei.c,Ei.b,Ei.m,Ei.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)},Ri=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Di=["i","c","b","a"],xi={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||Ri,n=t.innerOrder||Di,i=[];return r.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})}),e.media.forEach(function(e){i.push(Ii("m",Ei.m[0],e)),n.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Pi.parse,parseParams:Pi.parseParams,parseFmtpConfig:Pi.parseFmtpConfig,parsePayloads:Pi.parsePayloads,parseRemoteCandidates:Pi.parseRemoteCandidates,parseImageAttributes:Pi.parseImageAttributes,parseSimulcastStreamList:Pi.parseSimulcastStreamList};const Oi="\n",Bi="qiniu-rtc-client";function Li(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 Gi{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 Nn(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");return w.unifiedPlan?function(e,t,r,n,i){const a=xi.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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){r.direction;const a=r.type,s="audio"===a?e.codecs[0]:e.codecs[1],c=e.headerExtensions.filter(e=>e.kind===a),d={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:Li(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:s.sendPayloadType,codec:s.name,rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}],rtcpFb:[],fmtp:[{payload:s.sendPayloadType,config:Object.keys(s.parameters).map(e=>`${e}=${s.parameters[e]};`).join("")}],payloads:s.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:c.map(e=>({uri:e.uri,value:e.sendId}))};s.rtcpFeedback&&s.rtcpFeedback.length>0&&s.rtcpFeedback.forEach(e=>{d.rtcpFb.push({payload:s.sendPayloadType,type:e.type,subtype:e.parameter})}),s.sendRtxPayloadType&&(d.rtp.push({payload:s.sendRtxPayloadType,codec:"rtx",rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}),d.fmtp.push({payload:s.sendRtxPayloadType,config:`apt=${s.sendPayloadType};`}),d.payloads=`${s.sendPayloadType} ${s.sendRtxPayloadType}`);const u=n[d.mid];"video"===d.type&&u&&(d.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],d.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(d)}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 xi.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=xi.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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 Zr("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:Li(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,xi.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");if(w.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=E(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:Bi},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:Li(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}`),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 xi.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:Bi},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 Zr("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:Li(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 xi.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 Nn(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function Ni(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 Hi(e){const t=xi.parse(e);if(!("media"in t))return xi.write(t);if(!Array.isArray(t.media))return xi.write(t);for(const e of t.media)"rtp"in e&&Array.isArray(e.rtp)&&"audio"===e.type&&(e.rtp=e.rtp.filter(t=>!("codec"in t)||("red"!==t.codec.toLowerCase()||("payload"in t&&"fmtp"in e&&Array.isArray(e.fmtp)&&(e.fmtp=e.fmtp.filter(e=>e.payload!==t.payload)),!1))));return xi.write(t)}var ji,Fi=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;inew 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 e=this.wsConnectTimeout/1e3+"s timeout";Wr.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:e}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=Wi.CONNECTING}catch(e){throw Zr(`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||(Wr.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}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Nr,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&&(Wr.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}),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=Wi.OPEN,Wr.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}),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(Xi(t.error));break;case 10005:this.emit("@error",t),i(Xi(t.error));case 10052:if(jr.debug("10052 auth, retry",e),this.reconnectToken=void 0,e){i(zi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(vn(10054,t.error));break;default:i(Zr(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=Wi.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 Zr(`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&&(Wr.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}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw un();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)}),un()}}),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=Wi.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=Wi.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&Wr.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});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===Wi.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===Wi.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=Wi.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=xn(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=Wi.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=Dn(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 Qi{}class Ji{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){E(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=Ai(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()}}var Zi,$i;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}(Zi||(Zi={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}($i||($i={}));const Yi={"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}},ea=Yi["480p"],ta={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}},ra=ta.STANDARD,na={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},ia=na["720p"];var aa,oa,sa,ca,da,ua,la,Aa,ha,fa,pa,ma,ga,va;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(aa||(aa={})),function(e){e.PlAYING="PlAYING",e.PAUSED="PAUSED",e.STOPPED="STOPPED"}(oa||(oa={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(sa||(sa={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(ca||(ca={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(da||(da={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(ua||(ua={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(la||(la={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(Aa||(Aa={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(ha||(ha={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(fa||(fa={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(pa||(pa={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(ma||(ma={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(ga||(ga={})),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"}(va||(va={}));class Ta{static loadImage(e){if(e instanceof File)return Ta.loadImageFromFile(e);if(e instanceof ArrayBuffer)return Ta.loadImageFromArrayBuffer(e);if("string"==typeof e)return Ta.loadImageFromUrl(e);throw Yr("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(Ta.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(Ta.loadImageFromUrl(i))})}}class ba{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 Ta.loadImageFromFile(e):e instanceof ArrayBuffer?await Ta.loadImageFromArrayBuffer(e):await Ta.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 Sa{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 Yr("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 Yr("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw Zr("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw Zr("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 Zr("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(Sa.recorderTimeslice)}catch(e){throw Zr("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw Zr("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw Zr("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw Zr("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 Zr("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw Zr("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 Zr("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw Zr("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)}}Sa.recorderTimeslice=1e3;class ya{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class ka{constructor(e,t,r,n,i){this._connectStatus=O.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,In(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=O.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===O.Connect&&e(),n===O.Idle&&t()})})}appendConsumner(e,t){this.consumer=new ya(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 _a=window.AudioContext||window.webkitAudioContext||window.Object,wa=w.audioContextOptions?new _a({latencyHint:"interactive"}):new _a;if(window.audioContext=wa,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)})})(wa).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),wa.onstatechange=(()=>{e()})}const Ca=2048,Ea=4096,Pa=["play","playing","pause","ended","waiting","seeking"];class Ma extends mi{constructor(){super(),this.audioSource=null,this._audioSourceState=N.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=N.PLAY;break;case"pause":if(this.audioSourceState===N.END)break;this.audioSourceState=N.PAUSE;break;case"waiting":case"seeking":this.audioSourceState=N.LOADING;break;case"ended":this.audioSourceState=N.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",wa.state),"suspended"===wa.state&&(jr.log("audio context suspended"),wa.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",wa.state),this.analyserNode=wa.createAnalyser(),this.analyserNode.fftSize=Ca,this.gainNode=wa.createGain(),function(e){if(w.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=Ai(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),E(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),w.mediaStreamDest&&(this.audioStream=wa.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=wa.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=wa.createBufferSource(),this.audioSource.onended=(()=>this.stopAudioSource()),this.connect()}setMediaElementSource(e){this.audioSource=wa.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Pa)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.audioSource instanceof AudioBufferSourceNode?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.audioSource instanceof AudioBufferSourceNode&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.audioSource instanceof AudioBufferSourceNode){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=wa.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(Ln)):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=wa.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY)}resumeAudioSource(){if(this.audioSource instanceof AudioBufferSourceNode){if(this.audioSourceState!==N.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=wa.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=N.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(Ln)}pauseAudioSource(){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=wa.currentTime),this.audioSourceState=N.PAUSE):this.audioSourceElement&&this.audioSourceElement.pause()}stopAudioSource(e=!1){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=wa.currentTime,e||(this.audioSourceState=N.END)):this.audioSourceElement&&(this.audioSourceState=N.END,this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.audioSource instanceof AudioBufferSourceNode){let e=wa.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.audioSource instanceof AudioBufferSourceNode&&(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 Pa)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=Ea){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=wa.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}}}const Ia=0;class Ra extends gi{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 Ma,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&w.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){this.audioManager.gainNode.gain.setValueAtTime(e,wa.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Ca);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*(wa.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<=Ia?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 Da=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 xa,Oa=function(e,t){if(null==e)return{};var r,n,i=Da(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};class Ba extends mi{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=ii(),this._extendedRtpCapabilities=t,this._remoteSdp=new Gi(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,t){return await oi(this._pc,e,this._direction,t)}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 Bn(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return Bn(()=>{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===Zn.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===Zn.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(L)}(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);Wr.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);Wr.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 Yn(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=Vn(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=Oa(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=ni(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),Wr.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=zn(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);Kr(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 La extends Ba{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(w.unifiedPlan&&w.supportTransceivers)for(const e of t){const t=await ai(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 Na(this._pc,this._simulcast)}).then(e=>{let t;return w.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`),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 Zr("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 Qr?e:Zr(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(()=>{w.unifiedPlan&&w.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 Na(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 Qr?e:Zr(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 Zr("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 Zr(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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 Zr("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 Zr(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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(()=>Na(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:Na(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(Wr.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 Ga extends Ba{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(w.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(w.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(()=>(w.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(w.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 Zr("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:w.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:w.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(w.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(w.unifiedPlan&&w.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 Zr("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,w.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 Wr.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 Na(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=Hi(n),"chrome"===b.name&&t&&(n=function(e,t){const r=xi.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=xi.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 Ha(e,t,r,n){switch(e){case"send":return new La(t,r,n);case"recv":return new Ga(t,r,n)}}!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"}(xa||(xa={}));class ja extends mi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Fr("SendQueue"),this.recvCommandQueue=new Fr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Fr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=Ha("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=Ha("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),Wr.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Wi.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===Wi.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(Si),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(Wr.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(yn());case 10061:return this.reconnectProducer(),n(pn(10061,t.error));default:return n(pn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(pn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{Wr.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(xa.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(xa.REMOVE_TRACKS,e)}async restartSendICE(e){return w.supportRestartICE?this.sendCommandQueue.push(xa.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case xa.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case xa.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case xa.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new ka(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=En(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=O.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=Ha("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=O.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),Wr.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Wi.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===Wi.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(xa.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(xa.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(xa.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return w.supportRestartICE?this.recvCommandQueue.push(xa.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 xa.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case xa.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case xa.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case xa.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Fr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Fr("RecvQueue"),this.recvInitCommandQueue=new Fr("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=Ha("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 Fa=new mi;function Ua(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 qa;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(qa||(qa={}));const Va={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class Wa extends C{constructor(e=Va){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new Sa,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=qa.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=ma.RTC,this._role=ga.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==qa.Connected)return void n(Zr("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===ma.LIVE&&this._role===ga.AUDIENCE)return void n(Zr("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(Zr("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(hn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=En(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 Qr)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!==qa.Connected)return void a(Zr("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(Tn(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 ka(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(hn())})}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}})}),Wr.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 yn();case 10062:throw c.resetRecvHandler(),Tn(10062,n.error);default:throw Tn(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));E(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 Ra(r,i.playerid,"remote")).initAudioManager():n=new gi(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=O.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 Qr))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:E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},Va,e),this.config=e,jr.log("config",e),jr.log("version",Nr),jr.log("browser report",w,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(Ti)}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),Wr.addEvent("RoomStateChanged",{room_state:e}))}_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||Va.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===O.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===O.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==qa.Idle)throw Zr("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===ma.RTC||this._mode===ma.LIVE&&this._role===ga.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===ma.RTC)throw Zr("client role can only be set in client mode LIVE.");if(e===ga.AUDIENCE&&this.publishedTracks.length>0&&e===ga.AUDIENCE)throw Zr("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==qa.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(Wr.addEvent("SetClientRole",{result_code:t.code,user_role:e===ga.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Sn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();if(Wr.addEvent("JoinRoom",{room_token:e,user_data:t}),this.roomState!==qa.Idle)throw Zr("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=qa.Connecting;try{this.roomToken=e,this.userData=t;const n=Cn(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,Wr.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_-]{3,64}$/))throw this.roomState=qa.Idle,Zr("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{3,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{3,50}$/))throw this.roomState=qa.Idle,Zr("invalid userID. userID must match /^[a-zA-Z0-9_-]{3,50}$/");try{const t=await qi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,Wr.setSessionId(t.sessionId),Wr.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return Wr.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:""}),this._mode===ma.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=qa.Idle,jr.debug("joinRoomWithToken fail: "+t.message),Wr.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||""}),t}}async joinRoomWithAccess(e){const t=wn(e),{capsdp:r}=await async function(){let e=ii(),{isH264:t,sdp:r}=await Ni(e),n=5;for(;!t&&n>0;)e.close(),e=ii(),({isH264:t,sdp:r}=await Ni(e)),n--;w.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`);const i={capsdp:r=Hi(r),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===qa.Idle)throw Zr("roomState is idle, maybe because you left the room.");const n=new Ki(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 Wi.CONNECTING:this.roomState===qa.Connected?this.roomState=qa.Reconnecting:this.roomState!==qa.Reconnecting&&(this.roomState=qa.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;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error}),t&&w.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error}),t&&w.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)Ua(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),Wr.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}),r.length!==e.length||n||a($r("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 xn(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!==qa.Connected)throw Zr("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 Zr("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=En(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==qa.Connected)throw Zr("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(Wr.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw mn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==qa.Connected)throw Zr("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 Zr("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(Wr.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw gn(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!==qa.Connected)throw Zr("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw Zr(`no forward job id ${e}`);Wr.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 Ji(e,t,n,r):this.merger=new Ji(e,t,n,r)}_stopMerge(e){if(this.roomState!==qa.Connected)throw Zr("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw ln(e);Wr.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!==qa.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(Wr.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 Sn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==qa.Connected)throw Zr("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),E(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(Wr.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Sn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==qa.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e)),Wr.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!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));jr.debug("unsubscribe",r),0!==r.length&&(Wr.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e}))}),this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))}),t||(r.forEach(e=>e.release()),E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer)))}_muteTracks(e){if(this.roomState!==qa.Connected)throw Zr("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])}),Wr.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!==qa.Connected)throw Zr("room state is not connected, can not send message");const n=r||Dn(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!==qa.Connected)throw Zr("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 Zr(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==qa.Connected)throw Zr("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 Zr(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw Zr(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new ba),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!==qa.Idle?(jr.log("leave room"),Wr.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!==qa.Connected)throw Zr("can not connected to the room, please run joinRoom first");const r=Date.now(),n=await this.signaling.request("control",{command:e,playerid:t});if("kickplayer"===e&&Wr.addEvent("KickoutUser",{signal_take_time:Date.now()-r,user_id:t,result_code:n.code}),n.error)throw bn(n.code,n.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),E(this._trackInfo,t=>t.playerid===e.playerid),E(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),In(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=yi(e);this._users.set(t.userID,t),In(()=>{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=En(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>bi(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([Ti(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))In(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});In(()=>{jr.debug("track-add",e.map(Ti)),this.emit("track-add",e.map(Ti))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=E(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=E(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=>bi(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else In(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}In(()=>{jr.debug("track-remove",r.map(Ti)),this.emit("track-remove",r.map(Ti))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=En(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)})}In(()=>{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(vi))}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)}}),Fa.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)&&Wr.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error}),Wr.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=qa.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=Cn(this.roomToken),t=await qi(e,this.roomToken,this.config.requestTimeout);Wr.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=wn(t.accessToken);if(!this.signaling)throw Zr("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===qa.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=qa.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=yi(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(Ti)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===O.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===O.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 ja(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(Si),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw yn();default:throw Zr(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 yn();default:throw Zr(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=O.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){E(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)E(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new Qi,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(Ti),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),Wr.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=qa.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=ma.RTC,this._role=ga.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!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ma.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===ga.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Vi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ma.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===ga.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Vi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ma.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===ga.AUDIENCE)throw dn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(Wr.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}}class za extends Wa{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",Wr.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(){}}const Xa="fk6fk2rnb",Ka="https://api-demo.qnsdk.com",Qa="/v1",Ja=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function Za(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new za,i=new za,a=await async function(){let e="unknow";try{e=await qr()}catch(e){}return e+"_"+Dn(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await uo.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 Zr("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Ka}${Qa}${Ja(e,t,Xa)}`;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 Qr?JSON.stringify(e):e.message}finally{return n.roomState===qa.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===qa.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),Wr.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},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class $a extends Ra{constructor(e,t){if(!w.mediaStreamDest)throw Yr("your browser does not support audio buffer input!");const r=new Ma;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=B.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(){this.audioManager.stopAudioSource()}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 Ya 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",()=>{E(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 $a&&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=Wn();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=Wn();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 $a&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof $a?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof $a?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof $a)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 $a&&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;et.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){}E(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class to{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 oo.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 ro 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){if(this.musicTrack)return this.stopMusicMixing(),await this.startMusicMixing(e);if(this.musicTrack=await oo.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw Zr("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()}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(){this.musicTrack&&(this.musicTrack.stopAudioSource(),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 Zr("can not find audio source")}}class no{constructor(){this.volume=1,this.gainNode=wa.createGain(),this.gainNode.connect(wa.destination)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class io{constructor(e){if(this.playbackEngine=new no,this.sourcePlayebackState=!1,!(e instanceof Ra))throw Zr("audio mixing manager: origin track is not audio track");this.outputTrack=new eo,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new to(this.outputTrack,this.playbackEngine),this.musicManager=new ro(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 ao extends io{constructor(e){if(!e._audioTrack)throw Zr("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 Ya(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 oo;!function(e){function t(e,t="anonymous",r,n){const i=document.createElement("audio");i.preload="auto",i.src=e,i.crossOrigin=t;const a=new $a(i);return n&&a.setKbps(n),a.setInfo({tag:r}),a}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 $a(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(a)}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new $a(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===wa.state&&await wa.resume();return await(()=>new Promise((t,r)=>{wa.decodeAudioData(e,e=>{t(e)},e=>{r(nn(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):t(e,"anonymous",i,a)},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new io(e)},e.createAudioMixingManagerFromStream=function(e){return new ao(e)}}(oo||(oo={}));const so={audio:{enabled:!0},video:{enabled:!0,bitrate:600}};function co(e,t){"video"===e.kind&&("contentHint"in e?(e.contentHint=t,e.contentHint!==t&&jr.warning("invalid optimizationMode ",t)):jr.warning("optimizationMode not support in this browser"))}const uo=new class extends C{constructor(){super(),this.deviceMap={},w.support&&(this.updateDeivceInfo(),window.setInterval(this.updateDeivceInfo.bind(this),1e3))}async getDeviceInfo(e,t){if(!e){const e={audio:!1,video:!1};switch(t){case"all":e.audio=!0,e.video=!0;break;case"cameras":e.video=!0;break;case"microphones":case"playback":e.audio=!0}try{const t=await navigator.mediaDevices.getUserMedia(e);this.updateDeivceInfo();const r=t.getTracks();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),on(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case pa.ALL:r.types.push("window","screen");break;case pa.SCREEN:r.types.push("screen");break;case pa.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),Zr(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(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(rn("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 Zr(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())e.optimizationMode&&co(t,e.optimizationMode),n.push(ki(t,e.tag,e.bitrate));return n}async getLocalTracks(e=so){if(jr.debug("get local tracks",e),I(e)&&M(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(I(e)){if(M(e))throw Zr("can not get mediaStream with video and screen are all enabled");if(!w.screenSharing)throw Yr("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!w.getDisplayMedia)&&!await ui())throw tn("")}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(I(e)&&e.screen){if(w.getDisplayMedia&&!e.screen.forceChromePlugin)return wi({audio:t,video:{displaySurface:_i(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await li(!1,e.screen);return wi({audio:t,video:r})}return wi({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&Wr.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&Wr.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?rn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),I(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),M(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&&co(t,r)}for(const e of s){let t;t="audio"===e.kind?ki(e,o,i):ki(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await oo.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&I(e)&&M(e))throw Zr("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new Ya(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(I(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=w.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:$i.INACTIVE}),Wr.addEvent("audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label}),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:$i.ACTIVE}),this.emit("device-add",t),Wr.addEvent("audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class lo{constructor(e,t){this.networkQuality=da.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 Ao 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",()=>{Fa.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{Fa.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 ho extends Ao{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,Fa.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),Fa.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 fo extends ho{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=ua.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),Fa.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=ua.HIGH,this.emit("profile-changed",ua.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=ua.MEDIUM,this.emit("profile-changed",ua.MEDIUM);break;case"low":this.profile=ua.LOW,this.emit("profile-changed",ua.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){Fa.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw Zr("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?ua.LOW:ua.HIGH;Fa.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 po extends ho{constructor(e){super(e),Fa.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 mo extends C{constructor(e){super(),this.connectionState=Zi.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new za({transportPolicy:e}),this.session.on("user-join",e=>{const t=new lo(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 po(e):new fo(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&&Fa.emit("mute-tracks",e)}),Fa.on("set-mute-tracks",(e,t)=>{this.session.muteTracks([{trackID:e,muted:t}])}),this.session.on("room-state-change",e=>{switch(e){case qa.Idle:this.connectionState=Zi.DISCONNECTED;break;case qa.Connecting:this.connectionState=Zi.CONNECTING;break;case qa.Reconnecting:this.connectionState=Zi.RECONNECTING;break;case qa.Connected:this.connectionState=this.connectionState===Zi.CONNECTING?Zi.CONNECTED:Zi.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===Zi.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=la.LEAVE;break;case 10006:e=la.KICKED_OUT;break;default:e=la.ERROR}let t={reason:e};if(e===la.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,ca.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,ca.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,ca.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,ca.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{Fa.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),Fa.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=da.UNKNOWN;break;case x.POOR:e.networkQuality=da.POOR;break;case x.FAIR:e.networkQuality=da.FAIR;break;case x.GOOD:e.networkQuality=da.GOOD;break;case x.EXCELLENT:e.networkQuality=da.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),Fa.on("set-profile",(e,t)=>{switch(t){case ua.HIGH:this.session.setProfile(e,"high");break;case ua.MEDIUM:this.session.setProfile(e,"medium");break;case ua.LOW:this.session.setProfile(e,"low")}}),Fa.on("setMediaStreamTrack",(e,t,r,n)=>{this.session.replaceTrack(e,t).then(r).catch(n)})}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;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,this._localTracks.push(e)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw Zr("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 Zr("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(Mn({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,Mn({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=>Mn({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=da.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=da.POOR:t.includes(x.FAIR)?e=da.FAIR:t.includes(x.GOOD)?e=da.GOOD:t.includes(x.EXCELLENT)?e=da.EXCELLENT:e}getUserNetworkQuality(e){let t=da.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 go extends Ao{constructor(e){super(),this.track=e,Fa.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,Fa.emit("set-mute-tracks",this.trackID,e)}destroy(){this.track&&this.track.release()}}class vo extends go{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=ua.LOW),t[1]&&(t[1].profile=ua.MEDIUM),t[2]&&(t[2].profile=ua.HIGH),2==t.length&&t[1].profile===ua.MEDIUM&&(t[1].profile=ua.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 To extends vo{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class bo extends go{constructor(e){super(e),Fa.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 So extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",oa.PlAYING);case N.PAUSE:return void this.emit("state-changed",oa.PAUSED);case N.END:return void this.emit("state-changed",oa.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.musicManager.setMusicOption({volume:e})}setMixingVolume(e,t){}}class yo extends bo{constructor(e){const t=new io(e);super(t.outputTrack),this._sourceTrack=e,this._mixingManager=t,this.mixerList=[]}createAudioMixer(e){const t=new So(this._mixingManager,e);return this.mixerList.push(t),t}destroy(){this._mixingManager.release(),this._sourceTrack.release()}}class ko extends vo{constructor(e){super(e)}}class _o extends bo{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",oa.PlAYING);case N.PAUSE:return void this.emit("state-changed",oa.PAUSED);case N.END:return void this.emit("state-changed",oa.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)}}class wo extends bo{constructor(e){super(e)}async setMediaStreamTrack(e){return Fa.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}class Co extends vo{constructor(e){super(e)}async setMediaStreamTrack(e){return Fa.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}const Eo="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 Po extends vo{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=Eo,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=>Ta.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;r"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw Zr(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new bo(t),o=new ko(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=ta[e.encoderConfig]))throw fn()}else n=t({},ra,e.encoderConfig);else n=ra;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=Yi[r.encoderConfig]))throw fn()}else i=t({},ea,r.encoderConfig);else i=ea;const a=await uo.getLocalTracks({audio:Mn({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:Mn({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 Zr(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new yo(o),d=new To(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=ta[e.encoderConfig]))throw fn()}else r=t({},ra,e.encoderConfig);else r=ra;const n=await uo.getLocalTracks({audio:Mn({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 _o(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 Yr("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw Yr("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=ki(i,e.tag);return new Po(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new wo(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new Co(t)}static setTransportPolicy(e){e===ha.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===ha.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(Zr("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(Zr("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(Zr("can not get canvas 2d context"))}}else n(Zr("only support video track"))})}static async getElectronScreenSources(e){return uo.getElectronScreenSources(e)}}return Mo._clients=[],Mo._transportPolicy="preferUdp",uo.on("device-changed",e=>{switch(e.device.kind){case"audioinput":Mo.onMicrophoneChanged&&Mo.onMicrophoneChanged(e);break;case"audiooutput":Mo.onPlaybackDeviceChanged&&Mo.onPlaybackDeviceChanged(e);break;case"videoinput":Mo.onCameraChanged&&Mo.onCameraChanged(e)}}),Mo}); +!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 C=s++;o[C]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var E=s++;o[E]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";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 x=s++;o[x]="^"+o[R]+o[C]+"$";var O=s++;o[O]="^"+o[R]+o[E]+"$";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[C]+"$";var N=s++;o[N]="^"+o[B]+o[E]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var j=s++;o[j]="^"+o[k]+"\\s*("+b+")$|^$";var F=s++;o[F]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[C]+")",a[F]=new RegExp(o[F],"g");var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var V=s++;o[V]="(<|>)?=?\\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[j],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[q]:a[U];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[F],"$1$2$3"),r("comparator trim",e,a[F]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[j],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[O]:a[x];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[M]:a[P];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[V],"")}(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}const w=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:_(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),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 Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Me(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},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)},Ee.prototype.clear=function(){this.__data__=new _e},Ee.prototype.delete=function(e){return this.__data__.delete(e)},Ee.prototype.get=function(e){return this.__data__.get(e)},Ee.prototype.has=function(e){return this.__data__.has(e)},Ee.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=F?function(e){return function(t){return e(t)}}(F):function(e){return it(e)&&rt(e.length)&&!!x[re.call(e)]};function st(e){return et(e)?Pe(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=Oe(t);++n!!e&&!!e.audio&&e.audio.enabled,M=e=>!!e&&!!e.video&&e.video.enabled,I=e=>!!e&&!!e.screen&&e.screen.enabled;var R,D,x,O,B;function L(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(R||(R={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(D||(D={})),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"}(O||(O={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(B||(B={}));const G={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var N;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.END="end"}(N||(N={}));const H={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"))},x=function(){if(!D())return!1;var e=N();return!!window.WebGLRenderingContext&&!!e},O=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){O()?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){x()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){x()?e(C()):e()}},{key:"adBlock",getData:function(e){e(E())}},{key:"hasLiedLanguages",getData:function(e){e(P())}},{key:"hasLiedResolution",getData:function(e){e(M())}},{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)},j.getPromise=function(e){return new Promise(function(t,r){j.get(e,t)})},j.getV18=function(e,t){return null==t&&(t=e,e={}),j.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=x;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+=j:"[object Uint16Array]"===r?i+=U:"[object Int32Array]"===r?i+=F:"[object Uint32Array]"===r?i+=q:"[object Float32Array]"===r?i+=V:"[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(x+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,O)!==x)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(O,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 j:return new Int16Array(o);case U:return new Uint16Array(o);case F:return new Int32Array(o);case q:return new Uint32Array(o);case V: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]),V=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]),W=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),X=new Array(576);U(X);const K=new Array(60);U(K);const Q=new Array(512);U(Q);const J=new Array(256);U(J);const Z=new Array(29);U(Z);const $=new Array(30);function Y(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 ee,te,re;function ne(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U($);const ie=e=>e<256?Q[e]:Q[256+(e>>>7)],ae=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},oe=(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<{oe(e,r[2*t],r[2*t+1])},ce=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},de=(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]=ce(n[t]++,t))}},ue=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},le=e=>{e.bi_valid>8?ae(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ae=(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?se(e,i,t):(a=J[i],se(e,a+256+1,t),0!==(o=q[a])&&(i-=Z[a],oe(e,i,o)),a=ie(--n),se(e,a,r),0!==(o=V[a])&&(n-=$[a],oe(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--)he(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],he(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++,he(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),de(r,d,e.bl_count)},me=(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{oe(e,0+(n?1:0),3),((e,t,r,n)=>{le(e),n&&(ae(e,r),ae(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var be={_tr_init:e=>{ve||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for(Z[n]=r,e=0;e<1<>=7;n<30;n++)for($[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)),pe(e,e.l_desc),pe(e,e.d_desc),o=(e=>{let t;for(me(e,e.dyn_ltree,e.l_desc.max_code),me(e,e.dyn_dtree,e.d_desc.max_code),pe(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*z[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?Te(e,t,r,n):4===e.strategy||a===i?(oe(e,2+(n?1:0),3),fe(e,X,K)):(oe(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(oe(e,t-257,5),oe(e,r-1,5),oe(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*(J[r]+256+1)]++,e.dyn_dtree[2*ie(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{oe(e,2,3),se(e,256,X),(e=>{16===e.bi_valid?(ae(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 Se=(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 ye=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 ke=(e,t,r,n)=>{const i=ye,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},_e={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"},we={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:Ee,_tr_flush_block:Pe,_tr_tally:Me,_tr_align:Ie}=be,{Z_NO_FLUSH:Re,Z_PARTIAL_FLUSH:De,Z_FULL_FLUSH:xe,Z_FINISH:Oe,Z_BLOCK:Be,Z_OK:Le,Z_STREAM_END:Ge,Z_STREAM_ERROR:Ne,Z_DATA_ERROR:He,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Fe,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:Ve,Z_FIXED:We,Z_DEFAULT_STRATEGY:ze,Z_UNKNOWN:Xe,Z_DEFLATED:Ke}=we,Qe=286,Je=30,Ze=19,$e=2*Qe+1,Ye=15,et=(e,t)=>(e.msg=_e[t],t),tt=e=>(e<<1)-(e>4?9:0),rt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let nt=(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))},at=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,it(e.strm)},ot=(e,t)=>{e.pending_buf[e.pending++]=t},st=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ct=(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=Se(e.adler,t,i,r):2===e.state.wrap&&(e.adler=ke(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},dt=(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},ut=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=ct(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=nt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=nt(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)},lt=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=dt(e,r)),e.match_length>=3)if(n=Me(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=nt(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=nt(e,e.ins_h,e.window[e.strstart+1]);else n=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2},At=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=Me(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=nt(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&&(at(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Me(e,0,e.window[e.strstart-1]))&&at(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=Me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2};function ht(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 ft=[new ht(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(ut(e),0===e.lookahead&&t===Re)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,at(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(at(e,!1),e.strm.avail_out),1)}),new ht(4,4,8,4,lt),new ht(4,5,16,8,lt),new ht(4,6,32,32,lt),new ht(4,4,16,16,At),new ht(8,16,32,32,At),new ht(8,16,128,128,At),new ht(8,32,128,256,At),new ht(32,128,258,1024,At),new ht(32,258,258,4096,At)];function pt(){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=Ke,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*$e),this.dyn_dtree=new Uint16Array(2*(2*Je+1)),this.bl_tree=new Uint16Array(2*(2*Ze+1)),rt(this.dyn_ltree),rt(this.dyn_dtree),rt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Ye+1),this.heap=new Uint16Array(2*Qe+1),rt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Qe+1),rt(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 mt=e=>{if(!e||!e.state)return et(e,Ne);e.total_in=e.total_out=0,e.data_type=Xe;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=Re,Ce(t),Le},gt=e=>{const t=mt(e);return t===Le&&(e=>{e.window_size=2*e.w_size,rt(e.head),e.max_lazy_match=ft[e.level].max_lazy,e.good_match=ft[e.level].good_length,e.nice_match=ft[e.level].nice_length,e.max_chain_length=ft[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},vt=(e,t,r,n,i,a)=>{if(!e)return Ne;let o=1;if(t===Fe&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Ke||n<8||n>15||t<0||t>9||a<0||a>We)return et(e,Ne);8===n&&(n=9);const s=new pt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<vt(e,t,Ke,15,8,ze),deflateInit2:vt,deflateReset:gt,deflateResetKeep:mt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?Ne:(e.state.gzhead=t,Le):Ne,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Be||t<0)return e?et(e,Ne):Ne;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Oe)return et(e,0===e.avail_out?je:Ne);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,ot(i,31),ot(i,139),ot(i,8),i.gzhead?(ot(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)),ot(i,255&i.gzhead.time),ot(i,i.gzhead.time>>8&255),ot(i,i.gzhead.time>>16&255),ot(i,i.gzhead.time>>24&255),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ot(i,255&i.gzhead.extra.length),ot(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=ke(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,3),i.status=113);else{let t=Ke+(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,st(i,t),0!==i.strstart&&(st(i,e.adler>>>16),st(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending!==i.pending_buf_size));)ot(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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&&it(e),i.pending+2<=i.pending_buf_size&&(ot(i,255&e.adler),ot(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(it(e),0===e.avail_out)return i.last_flush=-1,Le}else if(0===e.avail_in&&tt(t)<=tt(a)&&t!==Oe)return et(e,je);if(666===i.status&&0!==e.avail_in)return et(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==Re&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(ut(e),0===e.lookahead)){if(t===Re)return 1;break}if(e.match_length=0,r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Ve?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(ut(e),e.lookahead<=258&&t===Re)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=Me(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):ft[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),Le;if(2===r&&(t===De?Ie(i):t!==Be&&(Ee(i,0,0,!1),t===xe&&(rt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),it(e),0===e.avail_out))return i.last_flush=-1,Le}return t!==Oe?Le:i.wrap<=0?Ge:(2===i.wrap?(ot(i,255&e.adler),ot(i,e.adler>>8&255),ot(i,e.adler>>16&255),ot(i,e.adler>>24&255),ot(i,255&e.total_in),ot(i,e.total_in>>8&255),ot(i,e.total_in>>16&255),ot(i,e.total_in>>24&255)):(st(i,e.adler>>>16),st(i,65535&e.adler)),it(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Le:Ge)},deflateEnd:e=>{if(!e||!e.state)return Ne;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?et(e,Ne):(e.state=null,113===t?et(e,He):Le)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return Ne;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Ne;if(1===i&&(e.adler=Se(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(rt(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,ut(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=nt(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,ut(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,Le},deflateInfo:"pako deflate (from Nodeca project)"};const bt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var St={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)bt(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;kt[254]=kt[254]=1;var _t={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&&yt)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+kt[e[r]]>t?r:t}};var wt=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:Et,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:Mt,Z_FINISH:It,Z_OK:Rt,Z_STREAM_END:Dt,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Ot,Z_DEFLATED:Bt}=we;function Lt(e){this.options=St.assign({level:xt,method:Bt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ot},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 wt,this.strm.avail_out=0;let r=Tt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Rt)throw new Error(_e[r]);if(t.header&&Tt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?_t.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=Tt.deflateSetDictionary(this.strm,e))!==Rt)throw new Error(_e[r]);this._dict_set=!0}}function Gt(e,t){const r=new Lt(t);if(r.push(e,!0),r.err)throw r.msg||_e[r.err];return r.result}Lt.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?It:Et,"string"==typeof e?r.input=_t.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===Mt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=Tt.deflate(r,a))===Dt)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Tt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Rt;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},Lt.prototype.onData=function(e){this.chunks.push(e)},Lt.prototype.onEnd=function(e){e===Rt&&(this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Nt={Deflate:Lt,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:we};var Ht=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 C=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=C.dmax,c=C.wsize,d=C.whave,u=C.wnext,l=C.window,A=C.hold,h=C.bits,f=C.lencode,p=C.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",C.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&C.sane){e.msg="invalid distance too far back",C.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,C=0;const E=new Uint16Array(16),P=new Uint16Array(16);let M,I,R,D=null,x=0;for(p=0;p<=15;p++)E[p]=0;for(m=0;m=1&&0===E[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(P[1]=0,p=1;p<15;p++)P[p+1]=P[p]+E[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){M=p-S,o[m]f?(I=D[x+o[m]],R=w[C+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=M<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--E[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:Wt,Z_BLOCK:zt,Z_TREES:Xt,Z_OK:Kt,Z_STREAM_END:Qt,Z_NEED_DICT:Jt,Z_STREAM_ERROR:Zt,Z_DATA_ERROR:$t,Z_MEM_ERROR:Yt,Z_BUF_ERROR:er,Z_DEFLATED:tr}=we,rr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function nr(){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 ir=e=>{if(!e||!e.state)return Zt;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,Kt},ar=e=>{if(!e||!e.state)return Zt;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ir(e)},or=(e,t)=>{let r;if(!e||!e.state)return Zt;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Zt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ar(e))},sr=(e,t)=>{if(!e)return Zt;const r=new nr;e.state=r,r.window=null;const n=or(e,t);return n!==Kt&&(e.state=null),n};let cr,dr,ur=!0;const lr=e=>{if(ur){cr=new Int32Array(512),dr=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(Vt(1,e.lens,0,288,cr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Vt(2,e.lens,0,32,dr,0,e.work,{bits:5}),ur=!1}e.lencode=cr,e.lenbits=9,e.distcode=dr,e.distbits=5},Ar=(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.whavesr(e,15),inflateInit2:sr,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 C,E;const P=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 Zt;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=Kt;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=ke(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)!==tr){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=ke(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=ke(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=ke(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=ke(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=ke(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(lr(r),r.mode=20,t===Xt){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===Xt)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[P[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,C={bits:r.lenbits},k=Vt(0,r.lens,0,19,r.lencode,0,r.work,C),r.lenbits=C.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(E=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(E=m+3;u>>=m)),d>>>=3,u-=3}else{for(E=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,C={bits:r.lenbits},k=Vt(1,r.lens,0,r.nlen,r.lencode,0,r.work,C),r.lenbits=C.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,C={bits:r.distbits},k=Vt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,C),r.distbits=C.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Xt)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,Ht(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(E=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(E=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 Zt;let t=e.state;return t.window&&(t.window=null),e.state=null,Kt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return Zt;const r=e.state;return 0==(2&r.wrap)?Zt:(r.head=t,t.done=!1,Kt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?Zt:11===n.mode&&(i=Se(i=1,t,r,0))!==n.check?$t:(a=Ar(e,t,r,r))?(n.mode=31,Yt):(n.havedict=1,Kt):Zt},inflateInfo:"pako inflate (from Nodeca project)"};var fr=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 pr=Object.prototype.toString,{Z_NO_FLUSH:mr,Z_FINISH:gr,Z_OK:vr,Z_STREAM_END:Tr,Z_NEED_DICT:br,Z_STREAM_ERROR:Sr,Z_DATA_ERROR:yr,Z_MEM_ERROR:kr}=we;function _r(e){this.options=St.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 wt,this.strm.avail_out=0;let r=hr.inflateInit2(this.strm,t.windowBits);if(r!==vr)throw new Error(_e[r]);if(this.header=new fr,hr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=_t.string2buf(t.dictionary):"[object ArrayBuffer]"===pr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=hr.inflateSetDictionary(this.strm,t.dictionary))!==vr))throw new Error(_e[r])}function wr(e,t){const r=new _r(t);if(r.push(e),r.err)throw r.msg||_e[r.err];return r.result}_r.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?gr:mr,"[object ArrayBuffer]"===pr.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=hr.inflate(r,o))===br&&i&&((a=hr.inflateSetDictionary(r,i))===vr?a=hr.inflate(r,o):a===yr&&(a=br));r.avail_in>0&&a===Tr&&r.state.wrap>0&&0!==e[r.next_in];)hr.inflateReset(r),a=hr.inflate(r,o);switch(a){case Sr:case yr:case br:case kr:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===Tr))if("string"===this.options.to){let e=_t.utf8border(r.output,r.next_out),t=r.next_out-e,i=_t.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!==vr||0!==s){if(a===Tr)return a=hr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===vr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:_r,inflate:wr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,wr(e,t)},ungzip:wr,constants:we};const{Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir}=Nt,{Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or}=Cr;var Br={Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir,Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or,constants:we},Lr=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(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},Ce.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ce.prototype.delete=function(e){return Ve(this,e).delete(e)},Ce.prototype.get=function(e){return Ve(this,e).get(e)},Ce.prototype.has=function(e){return Ve(this,e).has(e)},Ce.prototype.set=function(e,t){return Ve(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)},Pe.prototype.clear=function(){this.__data__=new we},Pe.prototype.delete=function(e){return this.__data__.delete(e)},Pe.prototype.get=function(e){return this.__data__.get(e)},Pe.prototype.has=function(e){return this.__data__.has(e)},Pe.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 Ee: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=F?function(e){return function(t){return e(t)}}(F):function(e){return lt(e)&&dt(e.length)&&!!x[ne.call(e)]};function ft(e){return st(e)?Me(e):Fe(e)}function pt(e){return e}e.exports=rt});const Nr="4.1.3";function Hr(){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=`${Hr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Hr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Hr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Fr 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 kn("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 kn("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}const Ur="qnrtcqosevents";function qr(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})},500)})}function Vr(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 Wr=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Fr("qossubmit",!1),qr().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:Nr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(Pn)}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:H[e],event_name:e},r);this.submitQueue.push("add",i).catch(Pn),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(Pn)}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 F.getItem(Ur);jr.log("get item",e),await F.removeItem(Ur),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)));F.setItem(Ur,e).catch(Pn)}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 Zr("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await F.removeItem(Ur)}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(Br.gzip(Vr(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function zr(e,t){let r;switch(e){case"prompt":r=D.prompt;break;case"granted":r=D.granted;break;case"denied":r=D.denied;break;default:return}Wr.addEvent("AuthorizationStatus",{type:t,status:r})}function Xr(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{zr(e.state,R[t]),e.onchange=(()=>{zr(e.state,R[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Xr("camera"),Xr("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{Wr.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2})});const Kr=(()=>{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=()=>{Wr.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e})},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 Qr extends Error{constructor(e,t){super(t),this.code=e,this.error=t,Wr.addEvent("SDKError",{error_code:e,error_msg:t})}}const Jr=e=>new Qr(10053,`invalid parameters: ${e}`),Zr=e=>new Qr(21005,`piliRTC: unexpected error ${e}`),$r=e=>new Qr(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),Yr=e=>new Qr(21006,`not support! ${e}`),en=e=>new Qr(21007,`track play is not allowed: ${e}`),tn=e=>new Qr(23003,`plugin not avaliable! ${e}`),rn=e=>new Qr(23004,`NotAllowedError: no permission to access media device. ${e}`),nn=e=>new Qr(22011,`can not decode audio data, ${e.toString()}`),an=()=>new Qr(23005,"no audio track when createScreenVideoTrack withAudio enable"),on=e=>new Qr(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),sn=e=>new Qr(24e3,`relay error, can not get relayToken. Error: ${e}`),cn=e=>new Qr(24001,`invalid client mode, ${e}`),dn=e=>new Qr(24002,`invalid client role, ${e}`),un=()=>Zr("websocket abort"),ln=e=>Jr(`can not set merge layout stream, no merge job id ${e}`),An=()=>rn("can not sharing screen/window on chrome"),hn=()=>Zr("subscribe/publish operation is aborted"),fn=()=>Jr("cannot found preset"),pn=(e,t)=>new Qr(e,`publish error, signaling code: ${e}, msg: ${t}`),mn=(e,t)=>new Qr(e,`create merge job error, signaling code: ${e}, msg: ${t}`),gn=(e,t)=>new Qr(e,`create forward job error, signaling code: ${e}, msg: ${t}`),vn=(e,t)=>new Qr(e,`media format not support, ${t}`),Tn=(e,t)=>new Qr(e,`subscribe error, signaling code: ${e}, msg: ${t}`),bn=(e,t)=>new Qr(e,`send control error, code: ${e}, msg: ${t}`),Sn=(e,t)=>new Qr(e,t),yn=()=>new Qr(10052,"server unavailable");class kn extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,kn):this.stack=new Error(e).stack}}var _n=Object.freeze({QNRTCError:Qr,ERROR_INVALID_PARAMETER:Jr,ERROR_FATAL:Zr,ERROR_AUTH_FAILED:$r,ERROR_RECONNECT_FAILED:e=>new Qr(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:Yr,ERROR_PLAY_NOT_ALLOWED:en,ERROR_PLUGIN_NOT_AVAILABLE:tn,ERROR_DEVICE_NOT_ALLOWED:rn,ERROR_AUDIO_DECODE_ERROR:nn,CREATE_SCREEN_AUDIO_ERROR:an,ERROR_ELECTRON_REQUIRE_ERROR:on,ERROR_RELAY_TOKEN:sn,ERROR_INVALID_CLIENT_MODE:cn,ERROR_INVALID_CLIENT_ROLE:dn,WS_ABORT:un,NO_MERGE_JOB:ln,SCREEN_PERMISSION_DENIED:An,SUB_PUB_ABORT:hn,PRESET_NOT_FOUND:fn,PUBLISH_ERROR:pn,CREATE_MERGE_JOB_ERROR:mn,CREATE_FORWARD_JOB_ERROR:gn,UNSUPPORT_FMT:vn,JOIN_ROOM_ERROR:(e,t)=>new Qr(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Tn,UNPUBLISH_ERROR:(e,t)=>new Qr(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Qr(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:bn,SERVER_ERROR:Sn,SERVER_UNAVAILABLE:yn,InvalidStateError:kn});function wn(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 Cn(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw Zr(`can not parse roomToken, ${e}`)}}function En(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]=Mn(e[r],t+1));return e}function In(e){Promise.resolve().then(e)}function Rn(e){return("0"+e.toString(16)).substr(-2)}function Dn(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,Rn).join("")}function xn(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const On={};function Bn(e,t){if(!On[t])return On[t]=!0,e()}function Ln(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Gn(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>r.abort(),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 Nn(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 xn(1e3),await Nn(e)}}var Hn;!function(e){e[e.AudioLevelUnusual=0]="AudioLevelUnusual"}(Hn||(Hn={}));class jn{static create(e){this.instance||(this.instance=new jn);const r=this.instance.getValidStandard(e.code);return this.instance.qosAddEvent(t({valid_standard:r},e)),this.instance}constructor(){}qosAddEvent(e){Wr.addEvent("WebSDKException",e)}getValidStandard(e){switch(e){case Hn.AudioLevelUnusual:return"0-1"}}}class Fn{constructor(e,t=Fn.AlphaForPacketLossFractionSmoother){this.mLastFilteredTimestamp=Date.now(),this.mMax=Fn.kValueUndefined,this.smooth_interval="audio"===e?Fn.SMOOTH_AUDIO_INTERVAL:Fn.SMOOTH_VIDEO_INTERVAL,this.Reset(t)}Reset(e){this.mAlpha=e,this.mFiltered=Fn.kValueUndefined}Apply(e){const t=Date.now()-this.mLastFilteredTimestamp;if(tthis.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 Un(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Fn(r),e[t])}Fn.kValueUndefined=-1,Fn.AlphaForPacketLossFractionSmoother=.9999,Fn.SMOOTH_VIDEO_INTERVAL=1e3,Fn.SMOOTH_AUDIO_INTERVAL=5e3;const qn=Un(),Vn=Un(),Wn=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function zn(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 Xn={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},Kn={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},Qn={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var Jn,Zn,$n;async function Yn(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===Zn.InBoundRtp||e.type===Zn.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[Zn.MediaSource]:r.filter(e=>e.type===Zn.MediaSource).find(t=>t.id===e.mediaSourceId),[Zn.Track]:r.filter(e=>e.type===Zn.Track).find(t=>t.id===e.trackId),[Zn.RemoteInBound]:r.filter(e=>e.type===Zn.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({},Qn)};return n===Jn.Audio?i.extra_stats=t({},Xn):i.extra_stats=t({},Kn),i}(e.id,e.trackID,e.mediaType);a.rtt=ti(i[Zn.RemoteInBound])||ti(e)||0,a.calculation_stats.packets_lost=ri(e,i[Zn.RemoteInBound])||0,e.mediaType===Jn.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[Zn.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.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=ei(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[Zn.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=ei(e.audioLevel,e.type),t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.Track],a,n)));return a})(e,i,r))}function ei(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===Zn.InBoundRtp?(r=Math.min(e/32767,1),jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function ti(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function ri(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function ni(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 ii(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};w.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return w.unifiedPlan&&w.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function ai(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"})}async function oi(e,r,n,i){if(w.stats){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=ni(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=zn(a,i.rtt);const o=qn(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})}(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=Wn(),a=n.get(e.remoteId);t.packetLoss=ri(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=ti(e)||ti(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),i)}return Bn(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}!function(e){e.Video="video",e.Audio="audio"}(Jn||(Jn={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(Zn||(Zn={})),function(e){e.In="in",e.Out="out"}($n||($n={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(di="PermissionDeniedError",ci)return ci("PermissionDeniedError");throw An()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(di="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&&ci&&ci(si=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let si,ci,di="screen";async function ui(){return await(()=>new Promise((e,t)=>{"desktop"!==di?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==di)},2e3)):e(!0)}))()}async function li(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:di,maxWidth:Ci(t.width),maxHeight:Ci(t.height)},optional:[]};"desktop"!==di?n(o):e?function(e){if(si)return e(si);ci=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(An())}):function(e,t=!1,r=!1){ci=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(An())},"screen"===r,"window"===r)}))()}var Ai=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(e,t){return!!(e?e.length:0)&&function(e,t,r){if(t!=t)return function(e,t,r,n){var i=e.length,a=r+(n?1:-1);for(;n?a--:++a-1}function q(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Pe.prototype.set=function(e,t){var r=this.__data__,n=xe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Me.prototype.clear=function(){this.__data__={hash:new Ee,map:new(fe||Pe),string:new Ee}},Me.prototype.delete=function(e){return qe(this,e).delete(e)},Me.prototype.get=function(e){return qe(this,e).get(e)},Me.prototype.has=function(e){return qe(this,e).has(e)},Me.prototype.set=function(e,t){return qe(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 Pe},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 Pe){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=F?function(e){return function(t){return e(t)}}(F):function(e){return st(e)&&at(e.length)&&!!x[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=U,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=q;else if(o>=r){var u=t?null:Fe(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=Ai(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{E(this.tracks,t=>t===e)})}removeTracksByTrackId(e){E(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=Ai(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){E(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function fi(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 pi(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),In(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),t}class mi extends C{safeEmit(e,...t){try{this.emit(e,...t)}catch(t){jr.warning("safeEmit() | event listener threw an error [event:%s]:%o",e,t)}}safeEmitAsPromise(e,...t){return new Promise((r,n)=>{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}class gi extends mi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=B.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),Wr.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label}),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(w.setPlaybackDevice||Yr("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?pi:fi;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(Pn)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(Pn)},!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)),Wr.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t})):i(Zr(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(Ln),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(Ln)}}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&&w.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}}function vi(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function Ti(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 bi(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 Si(e){if(!e.info.mid&&w.unifiedPlan)throw Zr("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 yi(e){return new hi(e.playerid,e.playerdata)}function ki(e,t,r){let n;return"audio"===e.kind?(n=new Da(e)).initAudioManager(!0):n=new gi(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function _i(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const wi=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(w.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}(Mn(e)));function Ci(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}var Ei=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")})})}),Pi=(Ei.v,Ei.o,Ei.s,Ei.i,Ei.u,Ei.e,Ei.p,Ei.z,Ei.r,Ei.t,Ei.c,Ei.b,Ei.m,Ei.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)},Ri=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Di=["i","c","b","a"],xi={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||Ri,n=t.innerOrder||Di,i=[];return r.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})}),e.media.forEach(function(e){i.push(Ii("m",Ei.m[0],e)),n.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Pi.parse,parseParams:Pi.parseParams,parseFmtpConfig:Pi.parseFmtpConfig,parsePayloads:Pi.parsePayloads,parseRemoteCandidates:Pi.parseRemoteCandidates,parseImageAttributes:Pi.parseImageAttributes,parseSimulcastStreamList:Pi.parseSimulcastStreamList};const Oi="\n",Bi="qiniu-rtc-client";function Li(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 Gi{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 Nn(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");return w.unifiedPlan?function(e,t,r,n,i){const a=xi.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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){r.direction;const a=r.type,s="audio"===a?e.codecs[0]:e.codecs[1],c=e.headerExtensions.filter(e=>e.kind===a),d={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:Li(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:s.sendPayloadType,codec:s.name,rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}],rtcpFb:[],fmtp:[{payload:s.sendPayloadType,config:Object.keys(s.parameters).map(e=>`${e}=${s.parameters[e]};`).join("")}],payloads:s.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:c.map(e=>({uri:e.uri,value:e.sendId}))};s.rtcpFeedback&&s.rtcpFeedback.length>0&&s.rtcpFeedback.forEach(e=>{d.rtcpFb.push({payload:s.sendPayloadType,type:e.type,subtype:e.parameter})}),s.sendRtxPayloadType&&(d.rtp.push({payload:s.sendRtxPayloadType,codec:"rtx",rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}),d.fmtp.push({payload:s.sendRtxPayloadType,config:`apt=${s.sendPayloadType};`}),d.payloads=`${s.sendPayloadType} ${s.sendRtxPayloadType}`);const u=n[d.mid];"video"===d.type&&u&&(d.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],d.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(d)}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 xi.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=xi.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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 Zr("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:Li(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,xi.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");if(w.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=E(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:Bi},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:Li(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}`),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 xi.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:Bi},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 Zr("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:Li(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 xi.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 Nn(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function Ni(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 Hi(e){const t=xi.parse(e);if(!("media"in t))return xi.write(t);if(!Array.isArray(t.media))return xi.write(t);for(const e of t.media)"rtp"in e&&Array.isArray(e.rtp)&&"audio"===e.type&&(e.rtp=e.rtp.filter(t=>!("codec"in t)||("red"!==t.codec.toLowerCase()||("payload"in t&&"fmtp"in e&&Array.isArray(e.fmtp)&&(e.fmtp=e.fmtp.filter(e=>e.payload!==t.payload)),!1))));return xi.write(t)}function ji(e){const t=xi.parse(e);if(!("media"in t))return xi.write(t);if(!Array.isArray(t.media))return xi.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 xi.write(t)}var Fi,Ui=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;inew 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 e=this.wsConnectTimeout/1e3+"s timeout";Wr.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:e}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=zi.CONNECTING}catch(e){throw Zr(`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||(Wr.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}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Nr,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&&(Wr.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}),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=zi.OPEN,Wr.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}),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(Xi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(vn(10054,t.error));break;default:i(Zr(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=zi.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 Zr(`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&&(Wr.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}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw un();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)}),un()}}),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=zi.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=zi.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&Wr.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});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===zi.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===zi.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=zi.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=xn(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=zi.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=Dn(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 Ji{}class Zi{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){E(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=Ai(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()}}var $i,Yi;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}($i||($i={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}(Yi||(Yi={}));const ea={"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}},ta=ea["480p"],ra={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}},na=ra.STANDARD,ia={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},aa=ia["720p"];var oa,sa,ca,da,ua,la,Aa,ha,fa,pa,ma,ga,va,Ta;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(oa||(oa={})),function(e){e.PlAYING="PlAYING",e.PAUSED="PAUSED",e.STOPPED="STOPPED"}(sa||(sa={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(ca||(ca={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(da||(da={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(ua||(ua={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(la||(la={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(Aa||(Aa={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(ha||(ha={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(fa||(fa={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(pa||(pa={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(ma||(ma={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(ga||(ga={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(va||(va={})),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"}(Ta||(Ta={}));class ba{static loadImage(e){if(e instanceof File)return ba.loadImageFromFile(e);if(e instanceof ArrayBuffer)return ba.loadImageFromArrayBuffer(e);if("string"==typeof e)return ba.loadImageFromUrl(e);throw Yr("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(ba.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(ba.loadImageFromUrl(i))})}}class Sa{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 ba.loadImageFromFile(e):e instanceof ArrayBuffer?await ba.loadImageFromArrayBuffer(e):await ba.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 ya{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 Yr("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 Yr("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw Zr("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw Zr("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 Zr("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(ya.recorderTimeslice)}catch(e){throw Zr("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw Zr("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw Zr("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw Zr("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 Zr("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw Zr("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 Zr("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw Zr("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)}}ya.recorderTimeslice=1e3;class ka{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class _a{constructor(e,t,r,n,i){this._connectStatus=O.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,In(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=O.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===O.Connect&&e(),n===O.Idle&&t()})})}appendConsumner(e,t){this.consumer=new ka(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 wa=window.AudioContext||window.webkitAudioContext||window.Object,Ca=w.audioContextOptions?new wa({latencyHint:"interactive"}):new wa;if(window.audioContext=Ca,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)})})(Ca).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),Ca.onstatechange=(()=>{e()})}const Ea=2048,Pa=4096,Ma=["play","playing","pause","ended","waiting","seeking"];class Ia extends mi{constructor(){super(),this.audioSource=null,this._audioSourceState=N.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=N.PLAY;break;case"pause":if(this.audioSourceState===N.END)break;this.audioSourceState=N.PAUSE;break;case"waiting":case"seeking":this.audioSourceState=N.LOADING;break;case"ended":this.audioSourceState=N.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",Ca.state),"suspended"===Ca.state&&(jr.log("audio context suspended"),Ca.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",Ca.state),this.analyserNode=Ca.createAnalyser(),this.analyserNode.fftSize=Ea,this.gainNode=Ca.createGain(),function(e){if(w.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=Ai(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),E(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),w.mediaStreamDest&&(this.audioStream=Ca.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=Ca.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=Ca.createBufferSource(),this.audioSource.onended=(()=>this.stopAudioSource()),this.connect()}setMediaElementSource(e){this.audioSource=Ca.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Ma)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.audioSource instanceof AudioBufferSourceNode?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.audioSource instanceof AudioBufferSourceNode&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.audioSource instanceof AudioBufferSourceNode){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Ca.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(Ln)):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=Ca.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY)}resumeAudioSource(){if(this.audioSource instanceof AudioBufferSourceNode){if(this.audioSourceState!==N.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=Ca.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=N.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(Ln)}pauseAudioSource(){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=Ca.currentTime),this.audioSourceState=N.PAUSE):this.audioSourceElement&&this.audioSourceElement.pause()}stopAudioSource(e=!1){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Ca.currentTime,e||(this.audioSourceState=N.END)):this.audioSourceElement&&(this.audioSourceState=N.END,this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.audioSource instanceof AudioBufferSourceNode){let e=Ca.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.audioSource instanceof AudioBufferSourceNode&&(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 Ma)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=Pa){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=Ca.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}}}const Ra=0;class Da extends gi{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 Ia,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&w.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){this.audioManager.gainNode.gain.setValueAtTime(e,Ca.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Ea);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*(Ca.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<=Ra?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 xa=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 Oa,Ba=function(e,t){if(null==e)return{};var r,n,i=xa(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};class La extends mi{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=ii(),this._extendedRtpCapabilities=t,this._remoteSdp=new Gi(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,t){return await oi(this._pc,e,this._direction,t)}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 Bn(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return Bn(()=>{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===Zn.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===Zn.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(L)}(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);Wr.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);Wr.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 Yn(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=Vn(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=Ba(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=ni(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),Wr.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=zn(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);Kr(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 Ga extends La{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(w.unifiedPlan&&w.supportTransceivers)for(const e of t){const t=await ai(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 Ha(this._pc,this._simulcast)}).then(e=>{let t;return w.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`),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 Zr("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 Qr?e:Zr(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(()=>{w.unifiedPlan&&w.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 Ha(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 Qr?e:Zr(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 Zr("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 Zr(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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 Zr("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 Zr(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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(()=>Ha(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:Ha(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(Wr.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 Na extends La{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(w.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(w.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(()=>(w.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(w.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 Zr("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:w.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:w.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(w.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(w.unifiedPlan&&w.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 Zr("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,w.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 Wr.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 Ha(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=ji(n=Hi(n)),"chrome"===b.name&&t&&(n=function(e,t){const r=xi.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=xi.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 ja(e,t,r,n){switch(e){case"send":return new Ga(t,r,n);case"recv":return new Na(t,r,n)}}!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"}(Oa||(Oa={}));class Fa extends mi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Fr("SendQueue"),this.recvCommandQueue=new Fr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Fr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=ja("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=ja("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),Wr.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===zi.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===zi.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(Si),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(Wr.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(yn());case 10061:return this.reconnectProducer(),n(pn(10061,t.error));default:return n(pn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(pn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{Wr.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(Oa.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(Oa.REMOVE_TRACKS,e)}async restartSendICE(e){return w.supportRestartICE?this.sendCommandQueue.push(Oa.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case Oa.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case Oa.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case Oa.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new _a(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=En(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=O.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=ja("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=O.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),Wr.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===zi.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===zi.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(Oa.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(Oa.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(Oa.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return w.supportRestartICE?this.recvCommandQueue.push(Oa.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 Oa.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case Oa.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case Oa.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case Oa.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Fr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Fr("RecvQueue"),this.recvInitCommandQueue=new Fr("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=ja("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 Ua=new mi;function qa(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 Va;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(Va||(Va={}));const Wa={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class za extends C{constructor(e=Wa){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new ya,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=Va.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=ga.RTC,this._role=va.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==Va.Connected)return void n(Zr("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===ga.LIVE&&this._role===va.AUDIENCE)return void n(Zr("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(Zr("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(hn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=En(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 Qr)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!==Va.Connected)return void a(Zr("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(Tn(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 _a(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(hn())})}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}})}),Wr.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 yn();case 10062:throw c.resetRecvHandler(),Tn(10062,n.error);default:throw Tn(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));E(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 Da(r,i.playerid,"remote")).initAudioManager():n=new gi(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=O.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 Qr))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:E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},Wa,e),this.config=e,jr.log("config",e),jr.log("version",Nr),jr.log("browser report",w,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(Ti)}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),Wr.addEvent("RoomStateChanged",{room_state:e}))}_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||Wa.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===O.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===O.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==Va.Idle)throw Zr("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===ga.RTC||this._mode===ga.LIVE&&this._role===va.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===ga.RTC)throw Zr("client role can only be set in client mode LIVE.");if(e===va.AUDIENCE&&this.publishedTracks.length>0&&e===va.AUDIENCE)throw Zr("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==Va.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(Wr.addEvent("SetClientRole",{result_code:t.code,user_role:e===va.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Sn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();if(Wr.addEvent("JoinRoom",{room_token:e,user_data:t}),this.roomState!==Va.Idle)throw Zr("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=Va.Connecting;try{this.roomToken=e,this.userData=t;const n=Cn(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,Wr.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_-]{3,64}$/))throw this.roomState=Va.Idle,Zr("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{3,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{3,50}$/))throw this.roomState=Va.Idle,Zr("invalid userID. userID must match /^[a-zA-Z0-9_-]{3,50}$/");try{const t=await Vi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,Wr.setSessionId(t.sessionId),Wr.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return Wr.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:""}),this._mode===ga.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=Va.Idle,jr.debug("joinRoomWithToken fail: "+t.message),Wr.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||""}),t}}async joinRoomWithAccess(e){const t=wn(e),{capsdp:r}=await async function(){let e=ii(),{isH264:t,sdp:r}=await Ni(e),n=5;for(;!t&&n>0;)e.close(),e=ii(),({isH264:t,sdp:r}=await Ni(e)),n--;w.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`);const i={capsdp:r=ji(r=Hi(r)),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===Va.Idle)throw Zr("roomState is idle, maybe because you left the room.");const n=new Qi(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 zi.CONNECTING:this.roomState===Va.Connected?this.roomState=Va.Reconnecting:this.roomState!==Va.Reconnecting&&(this.roomState=Va.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;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error}),t&&w.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error}),t&&w.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)qa(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),Wr.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}),r.length!==e.length||n||a($r("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 xn(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!==Va.Connected)throw Zr("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 Zr("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=En(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==Va.Connected)throw Zr("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(Wr.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw mn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==Va.Connected)throw Zr("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 Zr("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(Wr.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw gn(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!==Va.Connected)throw Zr("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw Zr(`no forward job id ${e}`);Wr.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 Zi(e,t,n,r):this.merger=new Zi(e,t,n,r)}_stopMerge(e){if(this.roomState!==Va.Connected)throw Zr("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw ln(e);Wr.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!==Va.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(Wr.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 Sn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==Va.Connected)throw Zr("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),E(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(Wr.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Sn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==Va.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e)),Wr.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!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));jr.debug("unsubscribe",r),0!==r.length&&(Wr.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e}))}),this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))}),t||(r.forEach(e=>e.release()),E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer)))}_muteTracks(e){if(this.roomState!==Va.Connected)throw Zr("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])}),Wr.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!==Va.Connected)throw Zr("room state is not connected, can not send message");const n=r||Dn(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!==Va.Connected)throw Zr("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 Zr(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==Va.Connected)throw Zr("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 Zr(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw Zr(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new Sa),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!==Va.Idle?(jr.log("leave room"),Wr.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!==Va.Connected)throw Zr("can not connected to the room, please run joinRoom first");const r=Date.now(),n=await this.signaling.request("control",{command:e,playerid:t});if("kickplayer"===e&&Wr.addEvent("KickoutUser",{signal_take_time:Date.now()-r,user_id:t,result_code:n.code}),n.error)throw bn(n.code,n.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),E(this._trackInfo,t=>t.playerid===e.playerid),E(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),In(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=yi(e);this._users.set(t.userID,t),In(()=>{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=En(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>bi(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([Ti(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))In(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});In(()=>{jr.debug("track-add",e.map(Ti)),this.emit("track-add",e.map(Ti))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=E(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=E(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=>bi(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else In(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}In(()=>{jr.debug("track-remove",r.map(Ti)),this.emit("track-remove",r.map(Ti))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=En(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)})}In(()=>{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(vi))}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)}}),Ua.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)&&Wr.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error}),Wr.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=Va.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=Cn(this.roomToken),t=await Vi(e,this.roomToken,this.config.requestTimeout);Wr.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=wn(t.accessToken);if(!this.signaling)throw Zr("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===Va.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=Va.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=yi(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(Ti)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===O.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===O.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 Fa(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(Si),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw yn();default:throw Zr(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 yn();default:throw Zr(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=O.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){E(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)E(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new Ji,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(Ti),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),Wr.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=Va.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=ga.RTC,this._role=va.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!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ga.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===va.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Wi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ga.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===va.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Wi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ga.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===va.AUDIENCE)throw dn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(Wr.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}}class Xa extends za{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",Wr.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(){}}const Ka="fk6fk2rnb",Qa="https://api-demo.qnsdk.com",Ja="/v1",Za=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function $a(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new Xa,i=new Xa,a=await async function(){let e="unknow";try{e=await qr()}catch(e){}return e+"_"+Dn(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await lo.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 Zr("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Qa}${Ja}${Za(e,t,Ka)}`;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 Qr?JSON.stringify(e):e.message}finally{return n.roomState===Va.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===Va.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),Wr.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},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class Ya extends Da{constructor(e,t){if(!w.mediaStreamDest)throw Yr("your browser does not support audio buffer input!");const r=new Ia;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=B.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(){this.audioManager.stopAudioSource()}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 eo 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",()=>{E(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 Ya&&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=Wn();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=Wn();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 Ya&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof Ya?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof Ya?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof Ya)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 Ya&&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;et.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){}E(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class ro{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 so.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 no 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){if(this.musicTrack)return this.stopMusicMixing(),await this.startMusicMixing(e);if(this.musicTrack=await so.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw Zr("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()}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(){this.musicTrack&&(this.musicTrack.stopAudioSource(),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 Zr("can not find audio source")}}class io{constructor(){this.volume=1,this.gainNode=Ca.createGain(),this.gainNode.connect(Ca.destination)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class ao{constructor(e){if(this.playbackEngine=new io,this.sourcePlayebackState=!1,!(e instanceof Da))throw Zr("audio mixing manager: origin track is not audio track");this.outputTrack=new to,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new ro(this.outputTrack,this.playbackEngine),this.musicManager=new no(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 oo extends ao{constructor(e){if(!e._audioTrack)throw Zr("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 eo(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 so;!function(e){function t(e,t="anonymous",r,n){const i=document.createElement("audio");i.preload="auto",i.src=e,i.crossOrigin=t;const a=new Ya(i);return n&&a.setKbps(n),a.setInfo({tag:r}),a}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 Ya(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(a)}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new Ya(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===Ca.state&&await Ca.resume();return await(()=>new Promise((t,r)=>{Ca.decodeAudioData(e,e=>{t(e)},e=>{r(nn(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):t(e,"anonymous",i,a)},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new ao(e)},e.createAudioMixingManagerFromStream=function(e){return new oo(e)}}(so||(so={}));const co={audio:{enabled:!0},video:{enabled:!0,bitrate:600}};function uo(e,t){"video"===e.kind&&("contentHint"in e?(e.contentHint=t,e.contentHint!==t&&jr.warning("invalid optimizationMode ",t)):jr.warning("optimizationMode not support in this browser"))}const lo=new class extends C{constructor(){super(),this.deviceMap={},w.support&&(this.updateDeivceInfo(),window.setInterval(this.updateDeivceInfo.bind(this),1e3))}async getDeviceInfo(e,t){if(!e){const e={audio:!1,video:!1};switch(t){case"all":e.audio=!0,e.video=!0;break;case"cameras":e.video=!0;break;case"microphones":case"playback":e.audio=!0}try{const t=await navigator.mediaDevices.getUserMedia(e);this.updateDeivceInfo();const r=t.getTracks();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),on(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case ma.ALL:r.types.push("window","screen");break;case ma.SCREEN:r.types.push("screen");break;case ma.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),Zr(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(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(rn("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 Zr(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())e.optimizationMode&&uo(t,e.optimizationMode),n.push(ki(t,e.tag,e.bitrate));return n}async getLocalTracks(e=co){if(jr.debug("get local tracks",e),I(e)&&M(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(I(e)){if(M(e))throw Zr("can not get mediaStream with video and screen are all enabled");if(!w.screenSharing)throw Yr("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!w.getDisplayMedia)&&!await ui())throw tn("")}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(I(e)&&e.screen){if(w.getDisplayMedia&&!e.screen.forceChromePlugin)return wi({audio:t,video:{displaySurface:_i(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await li(!1,e.screen);return wi({audio:t,video:r})}return wi({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&Wr.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&Wr.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?rn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),I(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),M(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&&uo(t,r)}for(const e of s){let t;t="audio"===e.kind?ki(e,o,i):ki(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await so.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&I(e)&&M(e))throw Zr("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new eo(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(I(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=w.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:Yi.INACTIVE}),Wr.addEvent("audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label}),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:Yi.ACTIVE}),this.emit("device-add",t),Wr.addEvent("audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class Ao{constructor(e,t){this.networkQuality=ua.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 ho 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",()=>{Ua.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{Ua.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 fo extends ho{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,Ua.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),Ua.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 po extends fo{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=la.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),Ua.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=la.HIGH,this.emit("profile-changed",la.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=la.MEDIUM,this.emit("profile-changed",la.MEDIUM);break;case"low":this.profile=la.LOW,this.emit("profile-changed",la.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){Ua.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw Zr("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?la.LOW:la.HIGH;Ua.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 mo extends fo{constructor(e){super(e),Ua.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 go extends C{constructor(e){super(),this.connectionState=$i.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new Xa({transportPolicy:e}),this.session.on("user-join",e=>{const t=new Ao(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 mo(e):new po(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&&Ua.emit("mute-tracks",e)}),Ua.on("set-mute-tracks",(e,t)=>{this.session.muteTracks([{trackID:e,muted:t}])}),this.session.on("room-state-change",e=>{switch(e){case Va.Idle:this.connectionState=$i.DISCONNECTED;break;case Va.Connecting:this.connectionState=$i.CONNECTING;break;case Va.Reconnecting:this.connectionState=$i.RECONNECTING;break;case Va.Connected:this.connectionState=this.connectionState===$i.CONNECTING?$i.CONNECTED:$i.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===$i.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=Aa.LEAVE;break;case 10006:e=Aa.KICKED_OUT;break;default:e=Aa.ERROR}let t={reason:e};if(e===Aa.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,da.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,da.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,da.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,da.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{Ua.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),Ua.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=ua.UNKNOWN;break;case x.POOR:e.networkQuality=ua.POOR;break;case x.FAIR:e.networkQuality=ua.FAIR;break;case x.GOOD:e.networkQuality=ua.GOOD;break;case x.EXCELLENT:e.networkQuality=ua.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),Ua.on("set-profile",(e,t)=>{switch(t){case la.HIGH:this.session.setProfile(e,"high");break;case la.MEDIUM:this.session.setProfile(e,"medium");break;case la.LOW:this.session.setProfile(e,"low")}}),Ua.on("setMediaStreamTrack",(e,t,r,n)=>{this.session.replaceTrack(e,t).then(r).catch(n)})}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;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,this._localTracks.push(e)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw Zr("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 Zr("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(Mn({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,Mn({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=>Mn({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=ua.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=ua.POOR:t.includes(x.FAIR)?e=ua.FAIR:t.includes(x.GOOD)?e=ua.GOOD:t.includes(x.EXCELLENT)?e=ua.EXCELLENT:e}getUserNetworkQuality(e){let t=ua.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 vo extends ho{constructor(e){super(),this.track=e,Ua.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,Ua.emit("set-mute-tracks",this.trackID,e)}destroy(){this.track&&this.track.release()}}class To extends vo{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=la.LOW),t[1]&&(t[1].profile=la.MEDIUM),t[2]&&(t[2].profile=la.HIGH),2==t.length&&t[1].profile===la.MEDIUM&&(t[1].profile=la.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 bo extends To{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class So extends vo{constructor(e){super(e),Ua.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 yo extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",sa.PlAYING);case N.PAUSE:return void this.emit("state-changed",sa.PAUSED);case N.END:return void this.emit("state-changed",sa.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.musicManager.setMusicOption({volume:e})}setMixingVolume(e,t){}}class ko extends So{constructor(e){const t=new ao(e);super(t.outputTrack),this._sourceTrack=e,this._mixingManager=t,this.mixerList=[]}createAudioMixer(e){const t=new yo(this._mixingManager,e);return this.mixerList.push(t),t}destroy(){this._mixingManager.release(),this._sourceTrack.release()}}class _o extends To{constructor(e){super(e)}}class wo extends So{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",sa.PlAYING);case N.PAUSE:return void this.emit("state-changed",sa.PAUSED);case N.END:return void this.emit("state-changed",sa.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)}}class Co extends So{constructor(e){super(e)}async setMediaStreamTrack(e){return Ua.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}class Eo extends To{constructor(e){super(e)}async setMediaStreamTrack(e){return Ua.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}const Po="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 Mo extends To{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=Po,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=>ba.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;r"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw Zr(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new So(t),o=new _o(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=ra[e.encoderConfig]))throw fn()}else n=t({},na,e.encoderConfig);else n=na;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=ea[r.encoderConfig]))throw fn()}else i=t({},ta,r.encoderConfig);else i=ta;const a=await lo.getLocalTracks({audio:Mn({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:Mn({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 Zr(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new ko(o),d=new bo(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=ra[e.encoderConfig]))throw fn()}else r=t({},na,e.encoderConfig);else r=na;const n=await lo.getLocalTracks({audio:Mn({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 wo(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 Yr("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw Yr("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=ki(i,e.tag);return new Mo(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new Co(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new Eo(t)}static setTransportPolicy(e){e===fa.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===fa.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(Zr("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(Zr("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(Zr("can not get canvas 2d context"))}}else n(Zr("only support video track"))})}static async getElectronScreenSources(e){return lo.getElectronScreenSources(e)}}return Io._clients=[],Io._transportPolicy="preferUdp",lo.on("device-changed",e=>{switch(e.device.kind){case"audioinput":Io.onMicrophoneChanged&&Io.onMicrophoneChanged(e);break;case"audiooutput":Io.onPlaybackDeviceChanged&&Io.onPlaybackDeviceChanged(e);break;case"videoinput":Io.onCameraChanged&&Io.onCameraChanged(e)}}),Io}); diff --git a/Demo/package-lock.json b/Demo/package-lock.json index 82cdc28..9e49423 100644 --- a/Demo/package-lock.json +++ b/Demo/package-lock.json @@ -1,6 +1,6 @@ { "name": "multiple-track-demo", - "version": "2.6.0", + "version": "4.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -943,6 +943,129 @@ "warning": "^4.0.1" } }, + "@microsoft/api-extractor": { + "version": "7.25.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.25.1.tgz", + "integrity": "sha512-/RE3G1oGD5d1QNhXdapVsFfgYIadLrhl9jjYIheADC54Jetwdb/Oc3rZpZiyoeYLBPl0JVWUplc94QdfvhvmaA==", + "requires": { + "@microsoft/api-extractor-model": "7.18.1", + "@microsoft/tsdoc": "0.14.1", + "@microsoft/tsdoc-config": "~0.16.1", + "@rushstack/node-core-library": "3.45.6", + "@rushstack/rig-package": "0.3.12", + "@rushstack/ts-command-line": "4.11.1", + "colors": "~1.2.1", + "lodash": "~4.17.15", + "resolve": "~1.17.0", + "semver": "~7.3.0", + "source-map": "~0.6.1", + "typescript": "~4.6.3" + }, + "dependencies": { + "colors": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", + "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==" + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, + "@microsoft/api-extractor-model": { + "version": "7.18.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.18.1.tgz", + "integrity": "sha512-aF9b9KU4+LCcXRbpwa+c/jOMZDsbomkehbjVNRMfCcRueeZ5KyBiERxWwc/Vk1mBFmDqkvYjK7RUxWYT2BsLAw==", + "requires": { + "@microsoft/tsdoc": "0.14.1", + "@microsoft/tsdoc-config": "~0.16.1", + "@rushstack/node-core-library": "3.45.6" + } + }, + "@microsoft/tsdoc": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.14.1.tgz", + "integrity": "sha512-6Wci+Tp3CgPt/B9B0a3J4s3yMgLNSku6w5TV6mN+61C71UqsRBv2FUibBf3tPGlNxebgPHMEUzKpb1ggE8KCKw==" + }, + "@microsoft/tsdoc-config": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.16.1.tgz", + "integrity": "sha512-2RqkwiD4uN6MLnHFljqBlZIXlt/SaUT6cuogU1w2ARw4nKuuppSmR0+s+NC+7kXBQykd9zzu0P4HtBpZT5zBpQ==", + "requires": { + "@microsoft/tsdoc": "0.14.1", + "ajv": "~6.12.6", + "jju": "~1.4.0", + "resolve": "~1.19.0" + }, + "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "resolve": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", + "requires": { + "is-core-module": "^2.1.0", + "path-parse": "^1.0.6" + } + } + } + }, "@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", @@ -957,6 +1080,115 @@ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz", "integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==" }, + "@rushstack/node-core-library": { + "version": "3.45.6", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.45.6.tgz", + "integrity": "sha512-RKGjkakEPcc5em1Dej6ql8OQobofp1IPKUDU2angme5XH7BFJzL5CAuU4zxIXaS8IT5HUV3WXd/GIkPAnrKNyw==", + "requires": { + "@types/node": "12.20.24", + "colors": "~1.2.1", + "fs-extra": "~7.0.1", + "import-lazy": "~4.0.0", + "jju": "~1.4.0", + "resolve": "~1.17.0", + "semver": "~7.3.0", + "timsort": "~0.3.0", + "z-schema": "~5.0.2" + }, + "dependencies": { + "@types/node": { + "version": "12.20.24", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.24.tgz", + "integrity": "sha512-yxDeaQIAJlMav7fH5AQqPH1u8YIuhYJXYBzxaQ4PifsU0GDO38MSdmEDeRlIxrKbC6NbEaaEHDanWb+y30U8SQ==" + }, + "colors": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", + "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==" + }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, + "@rushstack/rig-package": { + "version": "0.3.12", + "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.3.12.tgz", + "integrity": "sha512-ZzxuBWG0wbOtI+9IHYvOsr3QN52GtxTWpcaHMsQ/PC9us2ve/k0xK0XOMu+CtStyHSnBG2nDdnF9vFv9HMYOZg==", + "requires": { + "resolve": "~1.17.0", + "strip-json-comments": "~3.1.1" + }, + "dependencies": { + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "requires": { + "path-parse": "^1.0.6" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" + } + } + }, + "@rushstack/ts-command-line": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.11.1.tgz", + "integrity": "sha512-Xo8LaQOXlNSfp+qIuIPb1tfX7b4H21ksqiMo/HbeZI5AX1klHMqKjWcEs0AqgE9huvQj6cvnCla8Eq/GDcwMIg==", + "requires": { + "@types/argparse": "1.0.38", + "argparse": "~1.0.9", + "colors": "~1.2.1", + "string-argv": "~0.3.1" + }, + "dependencies": { + "colors": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", + "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==" + } + } + }, "@svgr/core": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/@svgr/core/-/core-2.4.1.tgz", @@ -984,10 +1216,15 @@ "loader-utils": "^1.1.0" } }, + "@types/argparse": { + "version": "1.0.38", + "resolved": "https://registry.npmjs.org/@types/argparse/-/argparse-1.0.38.tgz", + "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==" + }, "@types/blueimp-md5": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@types/blueimp-md5/-/blueimp-md5-2.7.0.tgz", - "integrity": "sha1-QEIigGgAR4yieC6K1GWQq6fxRic=" + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/@types/blueimp-md5/-/blueimp-md5-2.18.0.tgz", + "integrity": "sha512-f4A+++lGZGJvVSgeyMkqA7BEf2BVQli6F+qEykKb49c5ieWQBkfpn6CP5c1IZr2Yi2Ofl6Fj+v0e1fN18Z8Cnw==" }, "@types/clipboard": { "version": "2.0.1", @@ -1020,30 +1257,30 @@ } }, "@types/lodash": { - "version": "4.14.168", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.168.tgz", - "integrity": "sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q==" + "version": "4.14.182", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz", + "integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==" }, "@types/lodash.groupby": { - "version": "4.6.6", - "resolved": "https://registry.npmjs.org/@types/lodash.groupby/-/lodash.groupby-4.6.6.tgz", - "integrity": "sha512-kwg3T7Ia63KtDNoQQR8hKrLHCAgrH4I44l5uEMuA6JCbj7DiSccaV4tNV1vbjtAOpX990SolVthJCmBVtRVRgw==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/@types/lodash.groupby/-/lodash.groupby-4.6.7.tgz", + "integrity": "sha512-dFUR1pqdMgjIBbgPJ/8axJX6M1C7zsL+HF4qdYMQeJ7XOp0Qbf37I3zh9gpXr/ks6tgEYPDRqyZRAnFYvewYHQ==", "requires": { "@types/lodash": "*" } }, "@types/lodash.remove": { - "version": "4.7.6", - "resolved": "https://registry.npmjs.org/@types/lodash.remove/-/lodash.remove-4.7.6.tgz", - "integrity": "sha512-RPZHKzbDu5vqdySn4LwYcg31tdGA0eoRiggzUgHGofRtm2VDp/junkHSmfkExZzmrSFfoqpXawE+ojUuN78YLw==", + "version": "4.7.7", + "resolved": "https://registry.npmjs.org/@types/lodash.remove/-/lodash.remove-4.7.7.tgz", + "integrity": "sha512-jZrQtY6zdukkFFinY+yxikzU3hCS6SEXsTy103Ao+2YsZq2H+D/NpXuAoZpcpn7BTMBUsgr2NO7l4UYHxKXXjw==", "requires": { "@types/lodash": "*" } }, "@types/lodash.uniqby": { - "version": "4.7.6", - "resolved": "https://registry.npmjs.org/@types/lodash.uniqby/-/lodash.uniqby-4.7.6.tgz", - "integrity": "sha512-9wBhrm1y6asW50Joj6tsySCNUgzK2tCqL7vtKIej0E9RyeBFdcte7fxUosmFuMoOU0eHqOMK76kCCrK99jxHgg==", + "version": "4.7.7", + "resolved": "https://registry.npmjs.org/@types/lodash.uniqby/-/lodash.uniqby-4.7.7.tgz", + "integrity": "sha512-sv2g6vkCIvEUsK5/Vq17haoZaisfj2EWW8mP7QWlnKi6dByoNmeuHDDXHR7sabuDqwO4gvU7ModIL22MmnOocg==", "requires": { "@types/lodash": "*" } @@ -1053,6 +1290,11 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" }, + "@types/pako": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@types/pako/-/pako-1.0.4.tgz", + "integrity": "sha512-Z+5bJSm28EXBSUJEgx29ioWeEEHUh6TiMkZHDhLwjc9wVFH+ressbkmX6waUZc5R3Gobn4Qu5llGxaoflZ+yhA==" + }, "@types/prop-types": { "version": "15.5.8", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.5.8.tgz", @@ -1113,9 +1355,9 @@ } }, "@types/sdp-transform": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/@types/sdp-transform/-/sdp-transform-2.4.4.tgz", - "integrity": "sha512-cTpXVbNaN1YL++3mYArwlaujujeVe8ty66rbZPdFWx94fxM7jFjs5X621esca40yRe45htNdXROMIr2cgI+xGg==" + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/@types/sdp-transform/-/sdp-transform-2.4.5.tgz", + "integrity": "sha512-GVO0gnmbyO3Oxm2HdPsYUNcyihZE3GyCY8ysMYHuQGfLhGZq89Nm4lSzULWTzZoyHtg+VO/IdrnxZHPnPSGnAg==" }, "@types/seedrandom": { "version": "2.4.27", @@ -2597,9 +2839,9 @@ "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==" }, "blueimp-md5": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.18.0.tgz", - "integrity": "sha512-vE52okJvzsVWhcgUHOv+69OG3Mdg151xyn41aVQN/5W5S+S43qZhxECtYLAEHMSFWX6Mv5IZrzj3T5+JqXfj5Q==" + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" }, "bn.js": { "version": "4.11.8", @@ -3486,11 +3728,6 @@ "parse-json": "^4.0.0" } }, - "crc32": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/crc32/-/crc32-0.2.2.tgz", - "integrity": "sha1-etIg1v/c0Rn5/BJ6d3LKzqOQpLo=" - }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -4021,11 +4258,6 @@ } } }, - "deflate-js": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/deflate-js/-/deflate-js-0.2.3.tgz", - "integrity": "sha1-+Fq7WOvFFRowYUdHPVfD5PfkQms=" - }, "del": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/del/-/del-3.0.0.tgz", @@ -5380,12 +5612,20 @@ "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", "requires": { + "core-js": "^1.0.0", "isomorphic-fetch": "^2.1.1", "loose-envify": "^1.0.0", "object-assign": "^4.1.0", "promise": "^7.1.1", "setimmediate": "^1.0.5", "ua-parser-js": "^0.7.18" + }, + "dependencies": { + "core-js": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha512-ZiPp9pZlgxpWRu0M+YWbm6+aQ84XEfH1JRXvfOc/fILWI0VKhLC2LX13X1NYq4fULzLMq7Hfh43CSo2/aIaUPA==" + } } }, "figgy-pudding": { @@ -6556,15 +6796,6 @@ "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=" }, - "gzip-js": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/gzip-js/-/gzip-js-0.3.2.tgz", - "integrity": "sha1-IxF+/usozzhSSN7/Df+tiUg22Ws=", - "requires": { - "crc32": ">= 0.2.2", - "deflate-js": ">= 0.2.2" - } - }, "gzip-size": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-5.0.0.tgz", @@ -7327,7 +7558,7 @@ "immediate": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=" + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==" }, "immer": { "version": "1.10.0", @@ -7359,6 +7590,11 @@ "resolve-from": "^3.0.0" } }, + "import-lazy": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", + "integrity": "sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==" + }, "import-local": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-1.0.0.tgz", @@ -7547,6 +7783,14 @@ "rgba-regex": "^1.0.0" } }, + "is-core-module": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "requires": { + "has": "^1.0.3" + } + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "http://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -8423,6 +8667,11 @@ "merge-stream": "^1.0.1" } }, + "jju": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==" + }, "joi": { "version": "11.4.0", "resolved": "https://registry.npmjs.org/joi/-/joi-11.4.0.tgz", @@ -8701,7 +8950,7 @@ "lie": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", - "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=", + "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==", "requires": { "immediate": "~3.0.5" } @@ -8790,9 +9039,9 @@ } }, "localforage": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.9.0.tgz", - "integrity": "sha512-rR1oyNrKulpe+VM9cYmcFn6tsHuokyVHFaCM3+osEmxaHTbEk8oQu6eGDfS6DQLWi/N67XRmB8ECG37OES368g==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", + "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==", "requires": { "lie": "3.1.1" } @@ -8826,10 +9075,20 @@ "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=" }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==" + }, "lodash.groupby": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz", - "integrity": "sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E=" + "integrity": "sha512-5dcWxm23+VAoz+awKmBaiBvzox8+RqMgFhi7UvX9DHZr2HdxHXM/Wrf8cfKpsW37RNrvtPn6hSwNqurSILbmJw==" + }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==" }, "lodash.memoize": { "version": "4.1.2", @@ -8839,7 +9098,7 @@ "lodash.remove": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.remove/-/lodash.remove-4.7.0.tgz", - "integrity": "sha1-8x0x58OaBpDVB07A02JxYjNO5iY=" + "integrity": "sha512-GnwkSsEXGXirSxh3YI+jc/qvptE2DV8ZjA4liK0NT1MJ3mNDMFhX3bY+4Wr8onlNItYuPp7/4u19Fi55mvzkTw==" }, "lodash.sortby": { "version": "4.7.0", @@ -8876,7 +9135,7 @@ "lodash.uniqby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz", - "integrity": "sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI=" + "integrity": "sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww==" }, "loglevel": { "version": "1.6.1", @@ -9189,6 +9448,11 @@ "minimist": "0.0.8" } }, + "mobile-detect": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/mobile-detect/-/mobile-detect-1.4.5.tgz", + "integrity": "sha512-yc0LhH6tItlvfLBugVUEtgawwFU2sIe+cSdmRJJCTMZ5GEJyLxNyC/NIOAOGk67Fa8GNpOttO3Xz/1bHpXFD/g==" + }, "mobx": { "version": "5.8.0", "resolved": "https://registry.npmjs.org/mobx/-/mobx-5.8.0.tgz", @@ -9849,48 +10113,6 @@ "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" }, - "pili-rtc-web": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/pili-rtc-web/-/pili-rtc-web-2.4.1.tgz", - "integrity": "sha512-HwXE7F3Rc3JCNmo2zqph6ylKYhMcXLklyAna//K+DX4yIIbKC+rV55/XovWSMHS8/T1kTW9icAsMXDPSVLUIrA==", - "requires": { - "@babel/runtime": "^7.3.1", - "@types/blueimp-md5": "^2.7.0", - "@types/detect-browser": "^2.0.1", - "@types/lodash.groupby": "^4.6.6", - "@types/lodash.remove": "^4.7.4", - "@types/lodash.uniqby": "^4.7.4", - "@types/sdp-transform": "^2.4.0", - "@types/semver": "^5.5.0", - "blueimp-md5": "^2.10.0", - "detect-browser": "^3.0.1", - "fingerprintjs2": "^2.0.6", - "gzip-js": "^0.3.2", - "localforage": "^1.7.2", - "lodash.groupby": "^4.6.0", - "lodash.remove": "^4.7.0", - "lodash.uniqby": "^4.7.0", - "sdp-transform": "^2.4.1", - "semver": "^5.6.0", - "webrtc-adapter": "^7.2.0", - "wolfy87-eventemitter": "^5.2.5" - }, - "dependencies": { - "@babel/runtime": { - "version": "7.13.9", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.13.9.tgz", - "integrity": "sha512-aY2kU+xgJ3dJ1eU6FMB9EH8dIe8dmusF1xEku52joLvw6eAFN0AI+WxCLDnpev2LEejWBAy2sBvBOBAjI3zmvA==", - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "regenerator-runtime": { - "version": "0.13.7", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", - "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" - } - } - }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", @@ -11974,6 +12196,65 @@ "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" }, + "qnweb-rtc": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/qnweb-rtc/-/qnweb-rtc-4.1.3.tgz", + "integrity": "sha512-B5N1IhJ5xyS8MFJQ4lmvrGc9sOkuaIE4I5RuBZTHZ0gm7VSi29LQHUBDADOgFXMIp+0wI5hKH6yRC3+x4owlfQ==", + "requires": { + "@babel/runtime": "^7.3.1", + "@microsoft/api-extractor": "^7.18.7", + "@types/blueimp-md5": "^2.7.0", + "@types/detect-browser": "^2.0.1", + "@types/lodash.groupby": "^4.6.6", + "@types/lodash.remove": "^4.7.4", + "@types/lodash.uniqby": "^4.7.4", + "@types/pako": "^1.0.3", + "@types/sdp-transform": "^2.4.0", + "@types/semver": "^5.5.0", + "blueimp-md5": "^2.10.0", + "detect-browser": "^3.0.1", + "fingerprintjs2": "^2.0.6", + "localforage": "^1.7.2", + "lodash.groupby": "^4.6.0", + "lodash.remove": "^4.7.0", + "lodash.uniqby": "^4.7.0", + "mobile-detect": "^1.4.5", + "pako": "^2.0.4", + "rimraf": "^3.0.2", + "sdp-transform": "^2.4.1", + "semver": "^5.6.0", + "webrtc-adapter": "^8.0.0", + "wolfy87-eventemitter": "^5.2.5" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.3.tgz", + "integrity": "sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug==", + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "pako": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.0.4.tgz", + "integrity": "sha512-v8tweI900AUkZN6heMU/4Uy4cXRc2AYNRggVmTR+dEncawDJgCdLMximOVA2p4qO57WMynangsfGRb5WD6L1Bg==" + }, + "regenerator-runtime": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + } + } + }, "qs": { "version": "6.6.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.6.0.tgz", @@ -13120,14 +13401,6 @@ "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz", "integrity": "sha512-OfWGQTb9vnwRjwtA2QwpG2ICclHC3pgXZO5xt8H2EfgDquO0qVdSb5T88L4qJVAEugbS56pAuV4XZM58UX8ulw==" }, - "rtcpeerconnection-shim": { - "version": "1.2.15", - "resolved": "https://registry.npmjs.org/rtcpeerconnection-shim/-/rtcpeerconnection-shim-1.2.15.tgz", - "integrity": "sha512-C6DxhXt7bssQ1nHb154lqeL0SXz5Dx4RczXZu2Aa/L1NJFnEVDxFwCBo3fqtuljhHIGceg5JKBV4XJ0gW5JKyw==", - "requires": { - "sdp": "^2.6.0" - } - }, "run-async": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", @@ -13543,9 +13816,9 @@ } }, "sdp": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/sdp/-/sdp-2.12.0.tgz", - "integrity": "sha512-jhXqQAQVM+8Xj5EjJGVweuEzgtGWb3tmEEpl3CLP3cStInSbVHSg0QWOGQzNq8pSID4JkpeV2mPqlMDLrm0/Vw==" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sdp/-/sdp-3.0.3.tgz", + "integrity": "sha512-8EkfckS+XZQaPLyChu4ey7PghrdcraCVNpJe2Gfdi2ON1ylQ7OasuKX+b37R9slnRChwIAiQgt+oj8xXGD8x+A==" }, "sdp-transform": { "version": "2.14.1", @@ -14174,6 +14447,11 @@ "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=" }, + "string-argv": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", + "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==" + }, "string-length": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz", @@ -15087,6 +15365,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "validator": { + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.7.0.tgz", + "integrity": "sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw==" + }, "value-equal": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-0.4.0.tgz", @@ -15741,12 +16024,11 @@ } }, "webrtc-adapter": { - "version": "7.7.0", - "resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-7.7.0.tgz", - "integrity": "sha512-7Bp9OBnx642oJRkom1tNAbeJjUadAq2rh5xLL9YXPw5hVyt2h4hHr5bcoPYDs1stp/mZHSPSQA34YISdnr0DBQ==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-8.1.1.tgz", + "integrity": "sha512-1yXevP7TeZGmklEXkvQVrZp3fOSJlLeXNGCA7NovQokxgP3/e2T3EVGL0eKU87S9vKppWjvRWqnJeSANEspOBg==", "requires": { - "rtcpeerconnection-shim": "^1.2.15", - "sdp": "^2.12.0" + "sdp": "^3.0.2" } }, "websocket-driver": { @@ -16102,6 +16384,25 @@ "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" } } + }, + "z-schema": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.3.tgz", + "integrity": "sha512-sGvEcBOTNum68x9jCpCVGPFJ6mWnkD0YxOcddDlJHRx3tKdB2q8pCHExMVZo/AV/6geuVJXG7hljDaWG8+5GDw==", + "requires": { + "commander": "^2.20.3", + "lodash.get": "^4.4.2", + "lodash.isequal": "^4.5.0", + "validator": "^13.7.0" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "optional": true + } + } } } -} \ No newline at end of file +} diff --git a/Demo/package.json b/Demo/package.json index b0e4c49..f1159b8 100644 --- a/Demo/package.json +++ b/Demo/package.json @@ -1,6 +1,6 @@ { "name": "multiple-track-demo", - "version": "4.1.2", + "version": "4.1.3", "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.2", + "qnweb-rtc": "^4.1.3", "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 6f340db..64e4b6a 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 C=s++;o[C]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var E=s++;o[E]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";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 x=s++;o[x]="^"+o[R]+o[C]+"$";var O=s++;o[O]="^"+o[R]+o[E]+"$";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[C]+"$";var N=s++;o[N]="^"+o[B]+o[E]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var j=s++;o[j]="^"+o[k]+"\\s*("+b+")$|^$";var F=s++;o[F]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[C]+")",a[F]=new RegExp(o[F],"g");var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var V=s++;o[V]="(<|>)?=?\\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[j],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[q]:a[U];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[F],"$1$2$3"),r("comparator trim",e,a[F]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[j],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[O]:a[x];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[M]:a[P];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[V],"")}(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}const w=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:_(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),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 Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Me(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},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)},Ee.prototype.clear=function(){this.__data__=new _e},Ee.prototype.delete=function(e){return this.__data__.delete(e)},Ee.prototype.get=function(e){return this.__data__.get(e)},Ee.prototype.has=function(e){return this.__data__.has(e)},Ee.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=F?function(e){return function(t){return e(t)}}(F):function(e){return it(e)&&rt(e.length)&&!!x[re.call(e)]};function st(e){return et(e)?Pe(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=Oe(t);++n!!e&&!!e.audio&&e.audio.enabled,M=e=>!!e&&!!e.video&&e.video.enabled,I=e=>!!e&&!!e.screen&&e.screen.enabled;var R,D,x,O,B;function L(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(R||(R={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(D||(D={})),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"}(O||(O={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(B||(B={}));const G={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var N;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.END="end"}(N||(N={}));const H={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"))},x=function(){if(!D())return!1;var e=N();return!!window.WebGLRenderingContext&&!!e},O=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){O()?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){x()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){x()?e(C()):e()}},{key:"adBlock",getData:function(e){e(E())}},{key:"hasLiedLanguages",getData:function(e){e(P())}},{key:"hasLiedResolution",getData:function(e){e(M())}},{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)},j.getPromise=function(e){return new Promise(function(t,r){j.get(e,t)})},j.getV18=function(e,t){return null==t&&(t=e,e={}),j.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=x;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+=j:"[object Uint16Array]"===r?i+=U:"[object Int32Array]"===r?i+=F:"[object Uint32Array]"===r?i+=q:"[object Float32Array]"===r?i+=V:"[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(x+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,O)!==x)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(O,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 j:return new Int16Array(o);case U:return new Uint16Array(o);case F:return new Int32Array(o);case q:return new Uint32Array(o);case V: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]),V=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]),W=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),X=new Array(576);U(X);const K=new Array(60);U(K);const Q=new Array(512);U(Q);const J=new Array(256);U(J);const Z=new Array(29);U(Z);const $=new Array(30);function Y(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 ee,te,re;function ne(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U($);const ie=e=>e<256?Q[e]:Q[256+(e>>>7)],ae=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},oe=(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<{oe(e,r[2*t],r[2*t+1])},ce=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},de=(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]=ce(n[t]++,t))}},ue=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},le=e=>{e.bi_valid>8?ae(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ae=(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?se(e,i,t):(a=J[i],se(e,a+256+1,t),0!==(o=q[a])&&(i-=Z[a],oe(e,i,o)),a=ie(--n),se(e,a,r),0!==(o=V[a])&&(n-=$[a],oe(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--)he(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],he(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++,he(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),de(r,d,e.bl_count)},me=(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{oe(e,0+(n?1:0),3),((e,t,r,n)=>{le(e),n&&(ae(e,r),ae(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var be={_tr_init:e=>{ve||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for(Z[n]=r,e=0;e<1<>=7;n<30;n++)for($[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)),pe(e,e.l_desc),pe(e,e.d_desc),o=(e=>{let t;for(me(e,e.dyn_ltree,e.l_desc.max_code),me(e,e.dyn_dtree,e.d_desc.max_code),pe(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*z[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?Te(e,t,r,n):4===e.strategy||a===i?(oe(e,2+(n?1:0),3),fe(e,X,K)):(oe(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(oe(e,t-257,5),oe(e,r-1,5),oe(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*(J[r]+256+1)]++,e.dyn_dtree[2*ie(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{oe(e,2,3),se(e,256,X),(e=>{16===e.bi_valid?(ae(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 Se=(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 ye=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 ke=(e,t,r,n)=>{const i=ye,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},_e={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"},we={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:Ee,_tr_flush_block:Pe,_tr_tally:Me,_tr_align:Ie}=be,{Z_NO_FLUSH:Re,Z_PARTIAL_FLUSH:De,Z_FULL_FLUSH:xe,Z_FINISH:Oe,Z_BLOCK:Be,Z_OK:Le,Z_STREAM_END:Ge,Z_STREAM_ERROR:Ne,Z_DATA_ERROR:He,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Fe,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:Ve,Z_FIXED:We,Z_DEFAULT_STRATEGY:ze,Z_UNKNOWN:Xe,Z_DEFLATED:Ke}=we,Qe=286,Je=30,Ze=19,$e=2*Qe+1,Ye=15,et=(e,t)=>(e.msg=_e[t],t),tt=e=>(e<<1)-(e>4?9:0),rt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let nt=(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))},at=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,it(e.strm)},ot=(e,t)=>{e.pending_buf[e.pending++]=t},st=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ct=(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=Se(e.adler,t,i,r):2===e.state.wrap&&(e.adler=ke(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},dt=(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},ut=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=ct(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=nt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=nt(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)},lt=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=dt(e,r)),e.match_length>=3)if(n=Me(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=nt(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=nt(e,e.ins_h,e.window[e.strstart+1]);else n=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2},At=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=Me(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=nt(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&&(at(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Me(e,0,e.window[e.strstart-1]))&&at(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=Me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2};function ht(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 ft=[new ht(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(ut(e),0===e.lookahead&&t===Re)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,at(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(at(e,!1),e.strm.avail_out),1)}),new ht(4,4,8,4,lt),new ht(4,5,16,8,lt),new ht(4,6,32,32,lt),new ht(4,4,16,16,At),new ht(8,16,32,32,At),new ht(8,16,128,128,At),new ht(8,32,128,256,At),new ht(32,128,258,1024,At),new ht(32,258,258,4096,At)];function pt(){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=Ke,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*$e),this.dyn_dtree=new Uint16Array(2*(2*Je+1)),this.bl_tree=new Uint16Array(2*(2*Ze+1)),rt(this.dyn_ltree),rt(this.dyn_dtree),rt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Ye+1),this.heap=new Uint16Array(2*Qe+1),rt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Qe+1),rt(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 mt=e=>{if(!e||!e.state)return et(e,Ne);e.total_in=e.total_out=0,e.data_type=Xe;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=Re,Ce(t),Le},gt=e=>{const t=mt(e);return t===Le&&(e=>{e.window_size=2*e.w_size,rt(e.head),e.max_lazy_match=ft[e.level].max_lazy,e.good_match=ft[e.level].good_length,e.nice_match=ft[e.level].nice_length,e.max_chain_length=ft[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},vt=(e,t,r,n,i,a)=>{if(!e)return Ne;let o=1;if(t===Fe&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Ke||n<8||n>15||t<0||t>9||a<0||a>We)return et(e,Ne);8===n&&(n=9);const s=new pt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<vt(e,t,Ke,15,8,ze),deflateInit2:vt,deflateReset:gt,deflateResetKeep:mt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?Ne:(e.state.gzhead=t,Le):Ne,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Be||t<0)return e?et(e,Ne):Ne;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Oe)return et(e,0===e.avail_out?je:Ne);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,ot(i,31),ot(i,139),ot(i,8),i.gzhead?(ot(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)),ot(i,255&i.gzhead.time),ot(i,i.gzhead.time>>8&255),ot(i,i.gzhead.time>>16&255),ot(i,i.gzhead.time>>24&255),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ot(i,255&i.gzhead.extra.length),ot(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=ke(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,3),i.status=113);else{let t=Ke+(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,st(i,t),0!==i.strstart&&(st(i,e.adler>>>16),st(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending!==i.pending_buf_size));)ot(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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&&it(e),i.pending+2<=i.pending_buf_size&&(ot(i,255&e.adler),ot(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(it(e),0===e.avail_out)return i.last_flush=-1,Le}else if(0===e.avail_in&&tt(t)<=tt(a)&&t!==Oe)return et(e,je);if(666===i.status&&0!==e.avail_in)return et(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==Re&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(ut(e),0===e.lookahead)){if(t===Re)return 1;break}if(e.match_length=0,r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Ve?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(ut(e),e.lookahead<=258&&t===Re)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=Me(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):ft[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),Le;if(2===r&&(t===De?Ie(i):t!==Be&&(Ee(i,0,0,!1),t===xe&&(rt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),it(e),0===e.avail_out))return i.last_flush=-1,Le}return t!==Oe?Le:i.wrap<=0?Ge:(2===i.wrap?(ot(i,255&e.adler),ot(i,e.adler>>8&255),ot(i,e.adler>>16&255),ot(i,e.adler>>24&255),ot(i,255&e.total_in),ot(i,e.total_in>>8&255),ot(i,e.total_in>>16&255),ot(i,e.total_in>>24&255)):(st(i,e.adler>>>16),st(i,65535&e.adler)),it(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Le:Ge)},deflateEnd:e=>{if(!e||!e.state)return Ne;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?et(e,Ne):(e.state=null,113===t?et(e,He):Le)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return Ne;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Ne;if(1===i&&(e.adler=Se(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(rt(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,ut(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=nt(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,ut(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,Le},deflateInfo:"pako deflate (from Nodeca project)"};const bt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var St={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)bt(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;kt[254]=kt[254]=1;var _t={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&&yt)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+kt[e[r]]>t?r:t}};var wt=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:Et,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:Mt,Z_FINISH:It,Z_OK:Rt,Z_STREAM_END:Dt,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Ot,Z_DEFLATED:Bt}=we;function Lt(e){this.options=St.assign({level:xt,method:Bt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ot},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 wt,this.strm.avail_out=0;let r=Tt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Rt)throw new Error(_e[r]);if(t.header&&Tt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?_t.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=Tt.deflateSetDictionary(this.strm,e))!==Rt)throw new Error(_e[r]);this._dict_set=!0}}function Gt(e,t){const r=new Lt(t);if(r.push(e,!0),r.err)throw r.msg||_e[r.err];return r.result}Lt.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?It:Et,"string"==typeof e?r.input=_t.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===Mt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=Tt.deflate(r,a))===Dt)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Tt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Rt;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},Lt.prototype.onData=function(e){this.chunks.push(e)},Lt.prototype.onEnd=function(e){e===Rt&&(this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Nt={Deflate:Lt,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:we};var Ht=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 C=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=C.dmax,c=C.wsize,d=C.whave,u=C.wnext,l=C.window,A=C.hold,h=C.bits,f=C.lencode,p=C.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",C.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&C.sane){e.msg="invalid distance too far back",C.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,C=0;const E=new Uint16Array(16),P=new Uint16Array(16);let M,I,R,D=null,x=0;for(p=0;p<=15;p++)E[p]=0;for(m=0;m=1&&0===E[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(P[1]=0,p=1;p<15;p++)P[p+1]=P[p]+E[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){M=p-S,o[m]f?(I=D[x+o[m]],R=w[C+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=M<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--E[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:Wt,Z_BLOCK:zt,Z_TREES:Xt,Z_OK:Kt,Z_STREAM_END:Qt,Z_NEED_DICT:Jt,Z_STREAM_ERROR:Zt,Z_DATA_ERROR:$t,Z_MEM_ERROR:Yt,Z_BUF_ERROR:er,Z_DEFLATED:tr}=we,rr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function nr(){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 ir=e=>{if(!e||!e.state)return Zt;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,Kt},ar=e=>{if(!e||!e.state)return Zt;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ir(e)},or=(e,t)=>{let r;if(!e||!e.state)return Zt;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Zt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ar(e))},sr=(e,t)=>{if(!e)return Zt;const r=new nr;e.state=r,r.window=null;const n=or(e,t);return n!==Kt&&(e.state=null),n};let cr,dr,ur=!0;const lr=e=>{if(ur){cr=new Int32Array(512),dr=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(Vt(1,e.lens,0,288,cr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Vt(2,e.lens,0,32,dr,0,e.work,{bits:5}),ur=!1}e.lencode=cr,e.lenbits=9,e.distcode=dr,e.distbits=5},Ar=(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.whavesr(e,15),inflateInit2:sr,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 C,E;const P=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 Zt;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=Kt;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=ke(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)!==tr){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=ke(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=ke(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=ke(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=ke(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=ke(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(lr(r),r.mode=20,t===Xt){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===Xt)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[P[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,C={bits:r.lenbits},k=Vt(0,r.lens,0,19,r.lencode,0,r.work,C),r.lenbits=C.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(E=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(E=m+3;u>>=m)),d>>>=3,u-=3}else{for(E=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,C={bits:r.lenbits},k=Vt(1,r.lens,0,r.nlen,r.lencode,0,r.work,C),r.lenbits=C.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,C={bits:r.distbits},k=Vt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,C),r.distbits=C.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Xt)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,Ht(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(E=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(E=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 Zt;let t=e.state;return t.window&&(t.window=null),e.state=null,Kt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return Zt;const r=e.state;return 0==(2&r.wrap)?Zt:(r.head=t,t.done=!1,Kt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?Zt:11===n.mode&&(i=Se(i=1,t,r,0))!==n.check?$t:(a=Ar(e,t,r,r))?(n.mode=31,Yt):(n.havedict=1,Kt):Zt},inflateInfo:"pako inflate (from Nodeca project)"};var fr=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 pr=Object.prototype.toString,{Z_NO_FLUSH:mr,Z_FINISH:gr,Z_OK:vr,Z_STREAM_END:Tr,Z_NEED_DICT:br,Z_STREAM_ERROR:Sr,Z_DATA_ERROR:yr,Z_MEM_ERROR:kr}=we;function _r(e){this.options=St.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 wt,this.strm.avail_out=0;let r=hr.inflateInit2(this.strm,t.windowBits);if(r!==vr)throw new Error(_e[r]);if(this.header=new fr,hr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=_t.string2buf(t.dictionary):"[object ArrayBuffer]"===pr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=hr.inflateSetDictionary(this.strm,t.dictionary))!==vr))throw new Error(_e[r])}function wr(e,t){const r=new _r(t);if(r.push(e),r.err)throw r.msg||_e[r.err];return r.result}_r.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?gr:mr,"[object ArrayBuffer]"===pr.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=hr.inflate(r,o))===br&&i&&((a=hr.inflateSetDictionary(r,i))===vr?a=hr.inflate(r,o):a===yr&&(a=br));r.avail_in>0&&a===Tr&&r.state.wrap>0&&0!==e[r.next_in];)hr.inflateReset(r),a=hr.inflate(r,o);switch(a){case Sr:case yr:case br:case kr:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===Tr))if("string"===this.options.to){let e=_t.utf8border(r.output,r.next_out),t=r.next_out-e,i=_t.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!==vr||0!==s){if(a===Tr)return a=hr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===vr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:_r,inflate:wr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,wr(e,t)},ungzip:wr,constants:we};const{Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir}=Nt,{Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or}=Cr;var Br={Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir,Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or,constants:we},Lr=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(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},Ce.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ce.prototype.delete=function(e){return Ve(this,e).delete(e)},Ce.prototype.get=function(e){return Ve(this,e).get(e)},Ce.prototype.has=function(e){return Ve(this,e).has(e)},Ce.prototype.set=function(e,t){return Ve(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)},Pe.prototype.clear=function(){this.__data__=new we},Pe.prototype.delete=function(e){return this.__data__.delete(e)},Pe.prototype.get=function(e){return this.__data__.get(e)},Pe.prototype.has=function(e){return this.__data__.has(e)},Pe.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 Ee: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=F?function(e){return function(t){return e(t)}}(F):function(e){return lt(e)&&dt(e.length)&&!!x[ne.call(e)]};function ft(e){return st(e)?Me(e):Fe(e)}function pt(e){return e}e.exports=rt});const Nr="4.1.2";function Hr(){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=`${Hr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Hr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Hr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Fr 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 kn("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 kn("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}const Ur="qnrtcqosevents";function qr(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})},500)})}function Vr(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 Wr=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Fr("qossubmit",!1),qr().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:Nr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(Pn)}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:H[e],event_name:e},r);this.submitQueue.push("add",i).catch(Pn),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(Pn)}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 F.getItem(Ur);jr.log("get item",e),await F.removeItem(Ur),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)));F.setItem(Ur,e).catch(Pn)}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 Zr("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await F.removeItem(Ur)}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(Br.gzip(Vr(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function zr(e,t){let r;switch(e){case"prompt":r=D.prompt;break;case"granted":r=D.granted;break;case"denied":r=D.denied;break;default:return}Wr.addEvent("AuthorizationStatus",{type:t,status:r})}function Xr(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{zr(e.state,R[t]),e.onchange=(()=>{zr(e.state,R[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Xr("camera"),Xr("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{Wr.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2})});const Kr=(()=>{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=()=>{Wr.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e})},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 Qr extends Error{constructor(e,t){super(t),this.code=e,this.error=t,Wr.addEvent("SDKError",{error_code:e,error_msg:t})}}const Jr=e=>new Qr(10053,`invalid parameters: ${e}`),Zr=e=>new Qr(21005,`piliRTC: unexpected error ${e}`),$r=e=>new Qr(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),Yr=e=>new Qr(21006,`not support! ${e}`),en=e=>new Qr(21007,`track play is not allowed: ${e}`),tn=e=>new Qr(23003,`plugin not avaliable! ${e}`),rn=e=>new Qr(23004,`NotAllowedError: no permission to access media device. ${e}`),nn=e=>new Qr(22011,`can not decode audio data, ${e.toString()}`),an=()=>new Qr(23005,"no audio track when createScreenVideoTrack withAudio enable"),on=e=>new Qr(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),sn=e=>new Qr(24e3,`relay error, can not get relayToken. Error: ${e}`),cn=e=>new Qr(24001,`invalid client mode, ${e}`),dn=e=>new Qr(24002,`invalid client role, ${e}`),un=()=>Zr("websocket abort"),ln=e=>Jr(`can not set merge layout stream, no merge job id ${e}`),An=()=>rn("can not sharing screen/window on chrome"),hn=()=>Zr("subscribe/publish operation is aborted"),fn=()=>Jr("cannot found preset"),pn=(e,t)=>new Qr(e,`publish error, signaling code: ${e}, msg: ${t}`),mn=(e,t)=>new Qr(e,`create merge job error, signaling code: ${e}, msg: ${t}`),gn=(e,t)=>new Qr(e,`create forward job error, signaling code: ${e}, msg: ${t}`),vn=(e,t)=>new Qr(e,`media format not support, ${t}`),Tn=(e,t)=>new Qr(e,`subscribe error, signaling code: ${e}, msg: ${t}`),bn=(e,t)=>new Qr(e,`send control error, code: ${e}, msg: ${t}`),Sn=(e,t)=>new Qr(e,t),yn=()=>new Qr(10052,"server unavailable");class kn extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,kn):this.stack=new Error(e).stack}}var _n=Object.freeze({QNRTCError:Qr,ERROR_INVALID_PARAMETER:Jr,ERROR_FATAL:Zr,ERROR_AUTH_FAILED:$r,ERROR_RECONNECT_FAILED:e=>new Qr(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:Yr,ERROR_PLAY_NOT_ALLOWED:en,ERROR_PLUGIN_NOT_AVAILABLE:tn,ERROR_DEVICE_NOT_ALLOWED:rn,ERROR_AUDIO_DECODE_ERROR:nn,CREATE_SCREEN_AUDIO_ERROR:an,ERROR_ELECTRON_REQUIRE_ERROR:on,ERROR_RELAY_TOKEN:sn,ERROR_INVALID_CLIENT_MODE:cn,ERROR_INVALID_CLIENT_ROLE:dn,WS_ABORT:un,NO_MERGE_JOB:ln,SCREEN_PERMISSION_DENIED:An,SUB_PUB_ABORT:hn,PRESET_NOT_FOUND:fn,PUBLISH_ERROR:pn,CREATE_MERGE_JOB_ERROR:mn,CREATE_FORWARD_JOB_ERROR:gn,UNSUPPORT_FMT:vn,JOIN_ROOM_ERROR:(e,t)=>new Qr(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Tn,UNPUBLISH_ERROR:(e,t)=>new Qr(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Qr(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:bn,SERVER_ERROR:Sn,SERVER_UNAVAILABLE:yn,InvalidStateError:kn});function wn(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 Cn(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw Zr(`can not parse roomToken, ${e}`)}}function En(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]=Mn(e[r],t+1));return e}function In(e){Promise.resolve().then(e)}function Rn(e){return("0"+e.toString(16)).substr(-2)}function Dn(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,Rn).join("")}function xn(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const On={};function Bn(e,t){if(!On[t])return On[t]=!0,e()}function Ln(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Gn(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>r.abort(),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 Nn(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 xn(1e3),await Nn(e)}}var Hn;!function(e){e[e.AudioLevelUnusual=0]="AudioLevelUnusual"}(Hn||(Hn={}));class jn{static create(e){this.instance||(this.instance=new jn);const r=this.instance.getValidStandard(e.code);return this.instance.qosAddEvent(t({valid_standard:r},e)),this.instance}constructor(){}qosAddEvent(e){Wr.addEvent("WebSDKException",e)}getValidStandard(e){switch(e){case Hn.AudioLevelUnusual:return"0-1"}}}class Fn{constructor(e,t=Fn.AlphaForPacketLossFractionSmoother){this.mLastFilteredTimestamp=Date.now(),this.mMax=Fn.kValueUndefined,this.smooth_interval="audio"===e?Fn.SMOOTH_AUDIO_INTERVAL:Fn.SMOOTH_VIDEO_INTERVAL,this.Reset(t)}Reset(e){this.mAlpha=e,this.mFiltered=Fn.kValueUndefined}Apply(e){const t=Date.now()-this.mLastFilteredTimestamp;if(tthis.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 Un(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Fn(r),e[t])}Fn.kValueUndefined=-1,Fn.AlphaForPacketLossFractionSmoother=.9999,Fn.SMOOTH_VIDEO_INTERVAL=1e3,Fn.SMOOTH_AUDIO_INTERVAL=5e3;const qn=Un(),Vn=Un(),Wn=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function zn(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 Xn={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},Kn={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},Qn={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var Jn,Zn,$n;async function Yn(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===Zn.InBoundRtp||e.type===Zn.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[Zn.MediaSource]:r.filter(e=>e.type===Zn.MediaSource).find(t=>t.id===e.mediaSourceId),[Zn.Track]:r.filter(e=>e.type===Zn.Track).find(t=>t.id===e.trackId),[Zn.RemoteInBound]:r.filter(e=>e.type===Zn.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({},Qn)};return n===Jn.Audio?i.extra_stats=t({},Xn):i.extra_stats=t({},Kn),i}(e.id,e.trackID,e.mediaType);a.rtt=ti(i[Zn.RemoteInBound])||ti(e)||0,a.calculation_stats.packets_lost=ri(e,i[Zn.RemoteInBound])||0,e.mediaType===Jn.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[Zn.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.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=ei(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[Zn.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=ei(e.audioLevel,e.type),t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.Track],a,n)));return a})(e,i,r))}function ei(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===Zn.InBoundRtp?(r=Math.min(e/32767,1),jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function ti(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function ri(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function ni(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 ii(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};w.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return w.unifiedPlan&&w.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function ai(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"})}async function oi(e,r,n,i){if(w.stats){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=ni(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=zn(a,i.rtt);const o=qn(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})}(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=Wn(),a=n.get(e.remoteId);t.packetLoss=ri(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=ti(e)||ti(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),i)}return Bn(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}!function(e){e.Video="video",e.Audio="audio"}(Jn||(Jn={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(Zn||(Zn={})),function(e){e.In="in",e.Out="out"}($n||($n={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(di="PermissionDeniedError",ci)return ci("PermissionDeniedError");throw An()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(di="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&&ci&&ci(si=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let si,ci,di="screen";async function ui(){return await(()=>new Promise((e,t)=>{"desktop"!==di?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==di)},2e3)):e(!0)}))()}async function li(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:di,maxWidth:Ci(t.width),maxHeight:Ci(t.height)},optional:[]};"desktop"!==di?n(o):e?function(e){if(si)return e(si);ci=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(An())}):function(e,t=!1,r=!1){ci=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(An())},"screen"===r,"window"===r)}))()}var Ai=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(e,t){return!!(e?e.length:0)&&function(e,t,r){if(t!=t)return function(e,t,r,n){var i=e.length,a=r+(n?1:-1);for(;n?a--:++a-1}function q(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Pe.prototype.set=function(e,t){var r=this.__data__,n=xe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Me.prototype.clear=function(){this.__data__={hash:new Ee,map:new(fe||Pe),string:new Ee}},Me.prototype.delete=function(e){return qe(this,e).delete(e)},Me.prototype.get=function(e){return qe(this,e).get(e)},Me.prototype.has=function(e){return qe(this,e).has(e)},Me.prototype.set=function(e,t){return qe(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 Pe},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 Pe){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=F?function(e){return function(t){return e(t)}}(F):function(e){return st(e)&&at(e.length)&&!!x[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=U,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=q;else if(o>=r){var u=t?null:Fe(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=Ai(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{E(this.tracks,t=>t===e)})}removeTracksByTrackId(e){E(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=Ai(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){E(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function fi(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 pi(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),In(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),t}class mi extends C{safeEmit(e,...t){try{this.emit(e,...t)}catch(t){jr.warning("safeEmit() | event listener threw an error [event:%s]:%o",e,t)}}safeEmitAsPromise(e,...t){return new Promise((r,n)=>{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}class gi extends mi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=B.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),Wr.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label}),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(w.setPlaybackDevice||Yr("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?pi:fi;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(Pn)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(Pn)},!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)),Wr.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t})):i(Zr(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(Ln),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(Ln)}}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&&w.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}}function vi(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function Ti(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 bi(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 Si(e){if(!e.info.mid&&w.unifiedPlan)throw Zr("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 yi(e){return new hi(e.playerid,e.playerdata)}function ki(e,t,r){let n;return"audio"===e.kind?(n=new Ra(e)).initAudioManager(!0):n=new gi(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function _i(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const wi=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(w.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}(Mn(e)));function Ci(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}var Ei=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")})})}),Pi=(Ei.v,Ei.o,Ei.s,Ei.i,Ei.u,Ei.e,Ei.p,Ei.z,Ei.r,Ei.t,Ei.c,Ei.b,Ei.m,Ei.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)},Ri=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Di=["i","c","b","a"],xi={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||Ri,n=t.innerOrder||Di,i=[];return r.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})}),e.media.forEach(function(e){i.push(Ii("m",Ei.m[0],e)),n.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Pi.parse,parseParams:Pi.parseParams,parseFmtpConfig:Pi.parseFmtpConfig,parsePayloads:Pi.parsePayloads,parseRemoteCandidates:Pi.parseRemoteCandidates,parseImageAttributes:Pi.parseImageAttributes,parseSimulcastStreamList:Pi.parseSimulcastStreamList};const Oi="\n",Bi="qiniu-rtc-client";function Li(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 Gi{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 Nn(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");return w.unifiedPlan?function(e,t,r,n,i){const a=xi.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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){r.direction;const a=r.type,s="audio"===a?e.codecs[0]:e.codecs[1],c=e.headerExtensions.filter(e=>e.kind===a),d={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:Li(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:s.sendPayloadType,codec:s.name,rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}],rtcpFb:[],fmtp:[{payload:s.sendPayloadType,config:Object.keys(s.parameters).map(e=>`${e}=${s.parameters[e]};`).join("")}],payloads:s.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:c.map(e=>({uri:e.uri,value:e.sendId}))};s.rtcpFeedback&&s.rtcpFeedback.length>0&&s.rtcpFeedback.forEach(e=>{d.rtcpFb.push({payload:s.sendPayloadType,type:e.type,subtype:e.parameter})}),s.sendRtxPayloadType&&(d.rtp.push({payload:s.sendRtxPayloadType,codec:"rtx",rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}),d.fmtp.push({payload:s.sendRtxPayloadType,config:`apt=${s.sendPayloadType};`}),d.payloads=`${s.sendPayloadType} ${s.sendRtxPayloadType}`);const u=n[d.mid];"video"===d.type&&u&&(d.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],d.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(d)}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 xi.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=xi.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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 Zr("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:Li(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,xi.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");if(w.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=E(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:Bi},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:Li(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}`),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 xi.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:Bi},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 Zr("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:Li(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 xi.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 Nn(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function Ni(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 Hi(e){const t=xi.parse(e);if(!("media"in t))return xi.write(t);if(!Array.isArray(t.media))return xi.write(t);for(const e of t.media)"rtp"in e&&Array.isArray(e.rtp)&&"audio"===e.type&&(e.rtp=e.rtp.filter(t=>!("codec"in t)||("red"!==t.codec.toLowerCase()||("payload"in t&&"fmtp"in e&&Array.isArray(e.fmtp)&&(e.fmtp=e.fmtp.filter(e=>e.payload!==t.payload)),!1))));return xi.write(t)}var ji,Fi=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;inew 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 e=this.wsConnectTimeout/1e3+"s timeout";Wr.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:e}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=Wi.CONNECTING}catch(e){throw Zr(`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||(Wr.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}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Nr,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&&(Wr.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}),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=Wi.OPEN,Wr.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}),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(Xi(t.error));break;case 10005:this.emit("@error",t),i(Xi(t.error));case 10052:if(jr.debug("10052 auth, retry",e),this.reconnectToken=void 0,e){i(zi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(vn(10054,t.error));break;default:i(Zr(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=Wi.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 Zr(`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&&(Wr.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}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw un();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)}),un()}}),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=Wi.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=Wi.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&Wr.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});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===Wi.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===Wi.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=Wi.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=xn(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=Wi.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=Dn(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 Qi{}class Ji{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){E(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=Ai(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()}}var Zi,$i;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}(Zi||(Zi={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}($i||($i={}));const Yi={"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}},ea=Yi["480p"],ta={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}},ra=ta.STANDARD,na={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},ia=na["720p"];var aa,oa,sa,ca,da,ua,la,Aa,ha,fa,pa,ma,ga,va;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(aa||(aa={})),function(e){e.PlAYING="PlAYING",e.PAUSED="PAUSED",e.STOPPED="STOPPED"}(oa||(oa={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(sa||(sa={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(ca||(ca={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(da||(da={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(ua||(ua={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(la||(la={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(Aa||(Aa={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(ha||(ha={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(fa||(fa={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(pa||(pa={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(ma||(ma={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(ga||(ga={})),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"}(va||(va={}));class Ta{static loadImage(e){if(e instanceof File)return Ta.loadImageFromFile(e);if(e instanceof ArrayBuffer)return Ta.loadImageFromArrayBuffer(e);if("string"==typeof e)return Ta.loadImageFromUrl(e);throw Yr("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(Ta.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(Ta.loadImageFromUrl(i))})}}class ba{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 Ta.loadImageFromFile(e):e instanceof ArrayBuffer?await Ta.loadImageFromArrayBuffer(e):await Ta.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 Sa{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 Yr("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 Yr("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw Zr("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw Zr("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 Zr("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(Sa.recorderTimeslice)}catch(e){throw Zr("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw Zr("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw Zr("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw Zr("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 Zr("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw Zr("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 Zr("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw Zr("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)}}Sa.recorderTimeslice=1e3;class ya{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class ka{constructor(e,t,r,n,i){this._connectStatus=O.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,In(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=O.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===O.Connect&&e(),n===O.Idle&&t()})})}appendConsumner(e,t){this.consumer=new ya(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 _a=window.AudioContext||window.webkitAudioContext||window.Object,wa=w.audioContextOptions?new _a({latencyHint:"interactive"}):new _a;if(window.audioContext=wa,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)})})(wa).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),wa.onstatechange=(()=>{e()})}const Ca=2048,Ea=4096,Pa=["play","playing","pause","ended","waiting","seeking"];class Ma extends mi{constructor(){super(),this.audioSource=null,this._audioSourceState=N.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=N.PLAY;break;case"pause":if(this.audioSourceState===N.END)break;this.audioSourceState=N.PAUSE;break;case"waiting":case"seeking":this.audioSourceState=N.LOADING;break;case"ended":this.audioSourceState=N.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",wa.state),"suspended"===wa.state&&(jr.log("audio context suspended"),wa.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",wa.state),this.analyserNode=wa.createAnalyser(),this.analyserNode.fftSize=Ca,this.gainNode=wa.createGain(),function(e){if(w.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=Ai(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),E(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),w.mediaStreamDest&&(this.audioStream=wa.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=wa.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=wa.createBufferSource(),this.audioSource.onended=(()=>this.stopAudioSource()),this.connect()}setMediaElementSource(e){this.audioSource=wa.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Pa)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.audioSource instanceof AudioBufferSourceNode?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.audioSource instanceof AudioBufferSourceNode&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.audioSource instanceof AudioBufferSourceNode){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=wa.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(Ln)):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=wa.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY)}resumeAudioSource(){if(this.audioSource instanceof AudioBufferSourceNode){if(this.audioSourceState!==N.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=wa.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=N.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(Ln)}pauseAudioSource(){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=wa.currentTime),this.audioSourceState=N.PAUSE):this.audioSourceElement&&this.audioSourceElement.pause()}stopAudioSource(e=!1){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=wa.currentTime,e||(this.audioSourceState=N.END)):this.audioSourceElement&&(this.audioSourceState=N.END,this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.audioSource instanceof AudioBufferSourceNode){let e=wa.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.audioSource instanceof AudioBufferSourceNode&&(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 Pa)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=Ea){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=wa.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}}}const Ia=0;class Ra extends gi{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 Ma,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&w.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){this.audioManager.gainNode.gain.setValueAtTime(e,wa.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Ca);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*(wa.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<=Ia?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 Da=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 xa,Oa=function(e,t){if(null==e)return{};var r,n,i=Da(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};class Ba extends mi{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=ii(),this._extendedRtpCapabilities=t,this._remoteSdp=new Gi(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,t){return await oi(this._pc,e,this._direction,t)}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 Bn(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return Bn(()=>{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===Zn.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===Zn.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(L)}(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);Wr.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);Wr.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 Yn(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=Vn(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=Oa(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=ni(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),Wr.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=zn(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);Kr(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 La extends Ba{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(w.unifiedPlan&&w.supportTransceivers)for(const e of t){const t=await ai(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 Na(this._pc,this._simulcast)}).then(e=>{let t;return w.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`),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 Zr("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 Qr?e:Zr(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(()=>{w.unifiedPlan&&w.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 Na(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 Qr?e:Zr(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 Zr("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 Zr(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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 Zr("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 Zr(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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(()=>Na(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:Na(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(Wr.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 Ga extends Ba{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(w.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(w.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(()=>(w.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(w.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 Zr("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:w.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:w.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(w.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(w.unifiedPlan&&w.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 Zr("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,w.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 Wr.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 Na(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=Hi(n),"chrome"===b.name&&t&&(n=function(e,t){const r=xi.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=xi.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 Ha(e,t,r,n){switch(e){case"send":return new La(t,r,n);case"recv":return new Ga(t,r,n)}}!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"}(xa||(xa={}));class ja extends mi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Fr("SendQueue"),this.recvCommandQueue=new Fr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Fr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=Ha("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=Ha("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),Wr.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Wi.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===Wi.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(Si),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(Wr.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(yn());case 10061:return this.reconnectProducer(),n(pn(10061,t.error));default:return n(pn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(pn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{Wr.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(xa.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(xa.REMOVE_TRACKS,e)}async restartSendICE(e){return w.supportRestartICE?this.sendCommandQueue.push(xa.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case xa.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case xa.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case xa.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new ka(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=En(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=O.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=Ha("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=O.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),Wr.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===Wi.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===Wi.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(xa.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(xa.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(xa.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return w.supportRestartICE?this.recvCommandQueue.push(xa.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 xa.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case xa.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case xa.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case xa.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Fr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Fr("RecvQueue"),this.recvInitCommandQueue=new Fr("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=Ha("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 Fa=new mi;function Ua(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 qa;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(qa||(qa={}));const Va={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class Wa extends C{constructor(e=Va){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new Sa,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=qa.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=ma.RTC,this._role=ga.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==qa.Connected)return void n(Zr("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===ma.LIVE&&this._role===ga.AUDIENCE)return void n(Zr("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(Zr("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(hn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=En(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 Qr)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!==qa.Connected)return void a(Zr("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(Tn(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 ka(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(hn())})}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}})}),Wr.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 yn();case 10062:throw c.resetRecvHandler(),Tn(10062,n.error);default:throw Tn(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));E(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 Ra(r,i.playerid,"remote")).initAudioManager():n=new gi(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=O.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 Qr))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:E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},Va,e),this.config=e,jr.log("config",e),jr.log("version",Nr),jr.log("browser report",w,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(Ti)}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),Wr.addEvent("RoomStateChanged",{room_state:e}))}_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||Va.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===O.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===O.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==qa.Idle)throw Zr("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===ma.RTC||this._mode===ma.LIVE&&this._role===ga.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===ma.RTC)throw Zr("client role can only be set in client mode LIVE.");if(e===ga.AUDIENCE&&this.publishedTracks.length>0&&e===ga.AUDIENCE)throw Zr("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==qa.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(Wr.addEvent("SetClientRole",{result_code:t.code,user_role:e===ga.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Sn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();if(Wr.addEvent("JoinRoom",{room_token:e,user_data:t}),this.roomState!==qa.Idle)throw Zr("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=qa.Connecting;try{this.roomToken=e,this.userData=t;const n=Cn(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,Wr.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_-]{3,64}$/))throw this.roomState=qa.Idle,Zr("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{3,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{3,50}$/))throw this.roomState=qa.Idle,Zr("invalid userID. userID must match /^[a-zA-Z0-9_-]{3,50}$/");try{const t=await qi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,Wr.setSessionId(t.sessionId),Wr.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return Wr.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:""}),this._mode===ma.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=qa.Idle,jr.debug("joinRoomWithToken fail: "+t.message),Wr.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||""}),t}}async joinRoomWithAccess(e){const t=wn(e),{capsdp:r}=await async function(){let e=ii(),{isH264:t,sdp:r}=await Ni(e),n=5;for(;!t&&n>0;)e.close(),e=ii(),({isH264:t,sdp:r}=await Ni(e)),n--;w.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`);const i={capsdp:r=Hi(r),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===qa.Idle)throw Zr("roomState is idle, maybe because you left the room.");const n=new Ki(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 Wi.CONNECTING:this.roomState===qa.Connected?this.roomState=qa.Reconnecting:this.roomState!==qa.Reconnecting&&(this.roomState=qa.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;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error}),t&&w.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error}),t&&w.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)Ua(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),Wr.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}),r.length!==e.length||n||a($r("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 xn(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!==qa.Connected)throw Zr("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 Zr("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=En(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==qa.Connected)throw Zr("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(Wr.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw mn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==qa.Connected)throw Zr("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 Zr("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(Wr.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw gn(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!==qa.Connected)throw Zr("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw Zr(`no forward job id ${e}`);Wr.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 Ji(e,t,n,r):this.merger=new Ji(e,t,n,r)}_stopMerge(e){if(this.roomState!==qa.Connected)throw Zr("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw ln(e);Wr.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!==qa.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(Wr.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 Sn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==qa.Connected)throw Zr("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),E(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(Wr.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Sn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==qa.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e)),Wr.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!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));jr.debug("unsubscribe",r),0!==r.length&&(Wr.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e}))}),this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))}),t||(r.forEach(e=>e.release()),E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer)))}_muteTracks(e){if(this.roomState!==qa.Connected)throw Zr("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])}),Wr.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!==qa.Connected)throw Zr("room state is not connected, can not send message");const n=r||Dn(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!==qa.Connected)throw Zr("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 Zr(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==qa.Connected)throw Zr("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 Zr(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw Zr(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new ba),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!==qa.Idle?(jr.log("leave room"),Wr.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!==qa.Connected)throw Zr("can not connected to the room, please run joinRoom first");const r=Date.now(),n=await this.signaling.request("control",{command:e,playerid:t});if("kickplayer"===e&&Wr.addEvent("KickoutUser",{signal_take_time:Date.now()-r,user_id:t,result_code:n.code}),n.error)throw bn(n.code,n.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),E(this._trackInfo,t=>t.playerid===e.playerid),E(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),In(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=yi(e);this._users.set(t.userID,t),In(()=>{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=En(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>bi(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([Ti(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))In(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});In(()=>{jr.debug("track-add",e.map(Ti)),this.emit("track-add",e.map(Ti))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=E(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=E(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=>bi(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else In(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}In(()=>{jr.debug("track-remove",r.map(Ti)),this.emit("track-remove",r.map(Ti))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=En(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)})}In(()=>{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(vi))}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)}}),Fa.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)&&Wr.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error}),Wr.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=qa.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=Cn(this.roomToken),t=await qi(e,this.roomToken,this.config.requestTimeout);Wr.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=wn(t.accessToken);if(!this.signaling)throw Zr("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===qa.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=qa.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=yi(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(Ti)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===O.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===O.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 ja(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(Si),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw yn();default:throw Zr(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 yn();default:throw Zr(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=O.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){E(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)E(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new Qi,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(Ti),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),Wr.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=qa.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=ma.RTC,this._role=ga.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!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ma.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===ga.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Vi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ma.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===ga.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Vi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==qa.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ma.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===ga.AUDIENCE)throw dn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(Wr.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}}class za extends Wa{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",Wr.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(){}}const Xa="fk6fk2rnb",Ka="https://api-demo.qnsdk.com",Qa="/v1",Ja=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function Za(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new za,i=new za,a=await async function(){let e="unknow";try{e=await qr()}catch(e){}return e+"_"+Dn(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await uo.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 Zr("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Ka}${Qa}${Ja(e,t,Xa)}`;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 Qr?JSON.stringify(e):e.message}finally{return n.roomState===qa.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===qa.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),Wr.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},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class $a extends Ra{constructor(e,t){if(!w.mediaStreamDest)throw Yr("your browser does not support audio buffer input!");const r=new Ma;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=B.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(){this.audioManager.stopAudioSource()}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 Ya 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",()=>{E(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 $a&&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=Wn();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=Wn();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 $a&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof $a&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof $a?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof $a?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof $a)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 $a&&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;et.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){}E(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class to{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 oo.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 ro 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){if(this.musicTrack)return this.stopMusicMixing(),await this.startMusicMixing(e);if(this.musicTrack=await oo.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw Zr("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()}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(){this.musicTrack&&(this.musicTrack.stopAudioSource(),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 Zr("can not find audio source")}}class no{constructor(){this.volume=1,this.gainNode=wa.createGain(),this.gainNode.connect(wa.destination)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class io{constructor(e){if(this.playbackEngine=new no,this.sourcePlayebackState=!1,!(e instanceof Ra))throw Zr("audio mixing manager: origin track is not audio track");this.outputTrack=new eo,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new to(this.outputTrack,this.playbackEngine),this.musicManager=new ro(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 ao extends io{constructor(e){if(!e._audioTrack)throw Zr("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 Ya(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 oo;!function(e){function t(e,t="anonymous",r,n){const i=document.createElement("audio");i.preload="auto",i.src=e,i.crossOrigin=t;const a=new $a(i);return n&&a.setKbps(n),a.setInfo({tag:r}),a}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 $a(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(a)}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new $a(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===wa.state&&await wa.resume();return await(()=>new Promise((t,r)=>{wa.decodeAudioData(e,e=>{t(e)},e=>{r(nn(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):t(e,"anonymous",i,a)},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new io(e)},e.createAudioMixingManagerFromStream=function(e){return new ao(e)}}(oo||(oo={}));const so={audio:{enabled:!0},video:{enabled:!0,bitrate:600}};function co(e,t){"video"===e.kind&&("contentHint"in e?(e.contentHint=t,e.contentHint!==t&&jr.warning("invalid optimizationMode ",t)):jr.warning("optimizationMode not support in this browser"))}const uo=new class extends C{constructor(){super(),this.deviceMap={},w.support&&(this.updateDeivceInfo(),window.setInterval(this.updateDeivceInfo.bind(this),1e3))}async getDeviceInfo(e,t){if(!e){const e={audio:!1,video:!1};switch(t){case"all":e.audio=!0,e.video=!0;break;case"cameras":e.video=!0;break;case"microphones":case"playback":e.audio=!0}try{const t=await navigator.mediaDevices.getUserMedia(e);this.updateDeivceInfo();const r=t.getTracks();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),on(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case pa.ALL:r.types.push("window","screen");break;case pa.SCREEN:r.types.push("screen");break;case pa.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),Zr(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(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(rn("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 Zr(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())e.optimizationMode&&co(t,e.optimizationMode),n.push(ki(t,e.tag,e.bitrate));return n}async getLocalTracks(e=so){if(jr.debug("get local tracks",e),I(e)&&M(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(I(e)){if(M(e))throw Zr("can not get mediaStream with video and screen are all enabled");if(!w.screenSharing)throw Yr("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!w.getDisplayMedia)&&!await ui())throw tn("")}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(I(e)&&e.screen){if(w.getDisplayMedia&&!e.screen.forceChromePlugin)return wi({audio:t,video:{displaySurface:_i(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await li(!1,e.screen);return wi({audio:t,video:r})}return wi({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&Wr.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&Wr.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?rn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),I(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),M(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&&co(t,r)}for(const e of s){let t;t="audio"===e.kind?ki(e,o,i):ki(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await oo.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&I(e)&&M(e))throw Zr("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new Ya(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(I(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=w.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:$i.INACTIVE}),Wr.addEvent("audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label}),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:$i.ACTIVE}),this.emit("device-add",t),Wr.addEvent("audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class lo{constructor(e,t){this.networkQuality=da.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 Ao 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",()=>{Fa.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{Fa.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 ho extends Ao{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,Fa.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),Fa.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 fo extends ho{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=ua.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),Fa.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=ua.HIGH,this.emit("profile-changed",ua.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=ua.MEDIUM,this.emit("profile-changed",ua.MEDIUM);break;case"low":this.profile=ua.LOW,this.emit("profile-changed",ua.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){Fa.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw Zr("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?ua.LOW:ua.HIGH;Fa.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 po extends ho{constructor(e){super(e),Fa.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 mo extends C{constructor(e){super(),this.connectionState=Zi.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new za({transportPolicy:e}),this.session.on("user-join",e=>{const t=new lo(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 po(e):new fo(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&&Fa.emit("mute-tracks",e)}),Fa.on("set-mute-tracks",(e,t)=>{this.session.muteTracks([{trackID:e,muted:t}])}),this.session.on("room-state-change",e=>{switch(e){case qa.Idle:this.connectionState=Zi.DISCONNECTED;break;case qa.Connecting:this.connectionState=Zi.CONNECTING;break;case qa.Reconnecting:this.connectionState=Zi.RECONNECTING;break;case qa.Connected:this.connectionState=this.connectionState===Zi.CONNECTING?Zi.CONNECTED:Zi.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===Zi.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=la.LEAVE;break;case 10006:e=la.KICKED_OUT;break;default:e=la.ERROR}let t={reason:e};if(e===la.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,ca.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,ca.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,ca.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,ca.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{Fa.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),Fa.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=da.UNKNOWN;break;case x.POOR:e.networkQuality=da.POOR;break;case x.FAIR:e.networkQuality=da.FAIR;break;case x.GOOD:e.networkQuality=da.GOOD;break;case x.EXCELLENT:e.networkQuality=da.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),Fa.on("set-profile",(e,t)=>{switch(t){case ua.HIGH:this.session.setProfile(e,"high");break;case ua.MEDIUM:this.session.setProfile(e,"medium");break;case ua.LOW:this.session.setProfile(e,"low")}}),Fa.on("setMediaStreamTrack",(e,t,r,n)=>{this.session.replaceTrack(e,t).then(r).catch(n)})}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;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,this._localTracks.push(e)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw Zr("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 Zr("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(Mn({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,Mn({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=>Mn({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=da.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=da.POOR:t.includes(x.FAIR)?e=da.FAIR:t.includes(x.GOOD)?e=da.GOOD:t.includes(x.EXCELLENT)?e=da.EXCELLENT:e}getUserNetworkQuality(e){let t=da.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 go extends Ao{constructor(e){super(),this.track=e,Fa.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,Fa.emit("set-mute-tracks",this.trackID,e)}destroy(){this.track&&this.track.release()}}class vo extends go{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=ua.LOW),t[1]&&(t[1].profile=ua.MEDIUM),t[2]&&(t[2].profile=ua.HIGH),2==t.length&&t[1].profile===ua.MEDIUM&&(t[1].profile=ua.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 To extends vo{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class bo extends go{constructor(e){super(e),Fa.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 So extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",oa.PlAYING);case N.PAUSE:return void this.emit("state-changed",oa.PAUSED);case N.END:return void this.emit("state-changed",oa.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.musicManager.setMusicOption({volume:e})}setMixingVolume(e,t){}}class yo extends bo{constructor(e){const t=new io(e);super(t.outputTrack),this._sourceTrack=e,this._mixingManager=t,this.mixerList=[]}createAudioMixer(e){const t=new So(this._mixingManager,e);return this.mixerList.push(t),t}destroy(){this._mixingManager.release(),this._sourceTrack.release()}}class ko extends vo{constructor(e){super(e)}}class _o extends bo{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",oa.PlAYING);case N.PAUSE:return void this.emit("state-changed",oa.PAUSED);case N.END:return void this.emit("state-changed",oa.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)}}class wo extends bo{constructor(e){super(e)}async setMediaStreamTrack(e){return Fa.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}class Co extends vo{constructor(e){super(e)}async setMediaStreamTrack(e){return Fa.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}const Eo="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 Po extends vo{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=Eo,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=>Ta.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;r"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw Zr(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new bo(t),o=new ko(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=ta[e.encoderConfig]))throw fn()}else n=t({},ra,e.encoderConfig);else n=ra;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=Yi[r.encoderConfig]))throw fn()}else i=t({},ea,r.encoderConfig);else i=ea;const a=await uo.getLocalTracks({audio:Mn({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:Mn({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 Zr(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new yo(o),d=new To(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=ta[e.encoderConfig]))throw fn()}else r=t({},ra,e.encoderConfig);else r=ra;const n=await uo.getLocalTracks({audio:Mn({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 _o(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 Yr("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw Yr("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=ki(i,e.tag);return new Po(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new wo(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new Co(t)}static setTransportPolicy(e){e===ha.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===ha.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(Zr("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(Zr("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(Zr("can not get canvas 2d context"))}}else n(Zr("only support video track"))})}static async getElectronScreenSources(e){return uo.getElectronScreenSources(e)}}return Mo._clients=[],Mo._transportPolicy="preferUdp",uo.on("device-changed",e=>{switch(e.device.kind){case"audioinput":Mo.onMicrophoneChanged&&Mo.onMicrophoneChanged(e);break;case"audiooutput":Mo.onPlaybackDeviceChanged&&Mo.onPlaybackDeviceChanged(e);break;case"videoinput":Mo.onCameraChanged&&Mo.onCameraChanged(e)}}),Mo}); +!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 C=s++;o[C]="[v=\\s]*("+o[w]+")(?:\\.("+o[w]+")(?:\\.("+o[w]+")(?:"+o[p]+")?"+o[v]+"?)?)?";var E=s++;o[E]="[v=\\s]*("+o[_]+")(?:\\.("+o[_]+")(?:\\.("+o[_]+")(?:"+o[m]+")?"+o[v]+"?)?)?";var P=s++;o[P]="^"+o[k]+"\\s*"+o[C]+"$";var M=s++;o[M]="^"+o[k]+"\\s*"+o[E]+"$";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 x=s++;o[x]="^"+o[R]+o[C]+"$";var O=s++;o[O]="^"+o[R]+o[E]+"$";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[C]+"$";var N=s++;o[N]="^"+o[B]+o[E]+"$";var H=s++;o[H]="^"+o[k]+"\\s*("+S+")$|^$";var j=s++;o[j]="^"+o[k]+"\\s*("+b+")$|^$";var F=s++;o[F]="(\\s*)"+o[k]+"\\s*("+S+"|"+o[C]+")",a[F]=new RegExp(o[F],"g");var U=s++;o[U]="^\\s*("+o[C]+")\\s+-\\s+("+o[C]+")\\s*$";var q=s++;o[q]="^\\s*("+o[E]+")\\s+-\\s+("+o[E]+")\\s*$";var V=s++;o[V]="(<|>)?=?\\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[j],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[q]:a[U];e=e.replace(n,ce),r("hyphen replace",e),e=e.replace(a[F],"$1$2$3"),r("comparator trim",e,a[F]),e=(e=(e=e.replace(a[D],"$1~")).replace(a[L],"$1^")).split(/\s+/).join(" ");var i=t?a[H]:a[j],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[O]:a[x];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[M]:a[P];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[V],"")}(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}const w=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:_(),unifiedPlan:!0,supportTransceivers:!0,supportRestartICE:!0,disconnectAudioNode:!0};default:return{support:k(),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 Ce:void 0;for(s.set(e,t),s.set(t,e);++A-1},_e.prototype.set=function(e,t){var r=this.__data__,n=Me(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},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)},Ee.prototype.clear=function(){this.__data__=new _e},Ee.prototype.delete=function(e){return this.__data__.delete(e)},Ee.prototype.get=function(e){return this.__data__.get(e)},Ee.prototype.has=function(e){return this.__data__.has(e)},Ee.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=F?function(e){return function(t){return e(t)}}(F):function(e){return it(e)&&rt(e.length)&&!!x[re.call(e)]};function st(e){return et(e)?Pe(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=Oe(t);++n!!e&&!!e.audio&&e.audio.enabled,M=e=>!!e&&!!e.video&&e.video.enabled,I=e=>!!e&&!!e.screen&&e.screen.enabled;var R,D,x,O,B;function L(e){return void 0!==e}!function(e){e[e.camera=0]="camera",e[e.microphone=1]="microphone"}(R||(R={})),function(e){e[e.prompt=1]="prompt",e[e.denied=2]="denied",e[e.granted=3]="granted"}(D||(D={})),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"}(O||(O={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.EXTERNAL=1]="EXTERNAL",e[e.MIXING=2]="MIXING"}(B||(B={}));const G={publishUrl:"",height:720,width:1080,fps:25,kbps:1e3,audioOnly:!1,stretchMode:"aspectFill"};var N;!function(e){e.IDLE="idle",e.LOADING="loading",e.PLAY="play",e.PAUSE="pause",e.END="end"}(N||(N={}));const H={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"))},x=function(){if(!D())return!1;var e=N();return!!window.WebGLRenderingContext&&!!e},O=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){O()?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){x()?e(w()):e(t.NOT_AVAILABLE)}},{key:"webglVendorAndRenderer",getData:function(e){x()?e(C()):e()}},{key:"adBlock",getData:function(e){e(E())}},{key:"hasLiedLanguages",getData:function(e){e(P())}},{key:"hasLiedResolution",getData:function(e){e(M())}},{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)},j.getPromise=function(e){return new Promise(function(t,r){j.get(e,t)})},j.getV18=function(e,t){return null==t&&(t=e,e={}),j.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=x;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+=j:"[object Uint16Array]"===r?i+=U:"[object Int32Array]"===r?i+=F:"[object Uint32Array]"===r?i+=q:"[object Float32Array]"===r?i+=V:"[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(x+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,O)!==x)return JSON.parse(e);var t,r=e.substring(z),n=e.substring(O,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 j:return new Int16Array(o);case U:return new Uint16Array(o);case F:return new Int32Array(o);case q:return new Uint32Array(o);case V: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]),V=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]),W=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),X=new Array(576);U(X);const K=new Array(60);U(K);const Q=new Array(512);U(Q);const J=new Array(256);U(J);const Z=new Array(29);U(Z);const $=new Array(30);function Y(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 ee,te,re;function ne(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}U($);const ie=e=>e<256?Q[e]:Q[256+(e>>>7)],ae=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},oe=(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<{oe(e,r[2*t],r[2*t+1])},ce=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},de=(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]=ce(n[t]++,t))}},ue=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},le=e=>{e.bi_valid>8?ae(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ae=(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?se(e,i,t):(a=J[i],se(e,a+256+1,t),0!==(o=q[a])&&(i-=Z[a],oe(e,i,o)),a=ie(--n),se(e,a,r),0!==(o=V[a])&&(n-=$[a],oe(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--)he(e,r,o);c=a;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],he(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++,he(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),de(r,d,e.bl_count)},me=(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{oe(e,0+(n?1:0),3),((e,t,r,n)=>{le(e),n&&(ae(e,r),ae(e,~r)),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r})(e,t,r,!0)};var be={_tr_init:e=>{ve||((()=>{let e,t,r,n,i;const a=new Array(16);for(r=0,n=0;n<28;n++)for(Z[n]=r,e=0;e<1<>=7;n<30;n++)for($[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)),pe(e,e.l_desc),pe(e,e.d_desc),o=(e=>{let t;for(me(e,e.dyn_ltree,e.l_desc.max_code),me(e,e.dyn_dtree,e.d_desc.max_code),pe(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*z[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?Te(e,t,r,n):4===e.strategy||a===i?(oe(e,2+(n?1:0),3),fe(e,X,K)):(oe(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(oe(e,t-257,5),oe(e,r-1,5),oe(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*(J[r]+256+1)]++,e.dyn_dtree[2*ie(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{oe(e,2,3),se(e,256,X),(e=>{16===e.bi_valid?(ae(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 Se=(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 ye=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 ke=(e,t,r,n)=>{const i=ye,a=n+r;e^=-1;for(let r=n;r>>8^i[255&(e^t[r])];return-1^e},_e={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"},we={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:Ee,_tr_flush_block:Pe,_tr_tally:Me,_tr_align:Ie}=be,{Z_NO_FLUSH:Re,Z_PARTIAL_FLUSH:De,Z_FULL_FLUSH:xe,Z_FINISH:Oe,Z_BLOCK:Be,Z_OK:Le,Z_STREAM_END:Ge,Z_STREAM_ERROR:Ne,Z_DATA_ERROR:He,Z_BUF_ERROR:je,Z_DEFAULT_COMPRESSION:Fe,Z_FILTERED:Ue,Z_HUFFMAN_ONLY:qe,Z_RLE:Ve,Z_FIXED:We,Z_DEFAULT_STRATEGY:ze,Z_UNKNOWN:Xe,Z_DEFLATED:Ke}=we,Qe=286,Je=30,Ze=19,$e=2*Qe+1,Ye=15,et=(e,t)=>(e.msg=_e[t],t),tt=e=>(e<<1)-(e>4?9:0),rt=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let nt=(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))},at=(e,t)=>{Pe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,it(e.strm)},ot=(e,t)=>{e.pending_buf[e.pending++]=t},st=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ct=(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=Se(e.adler,t,i,r):2===e.state.wrap&&(e.adler=ke(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},dt=(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},ut=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=ct(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=nt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=nt(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)},lt=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=dt(e,r)),e.match_length>=3)if(n=Me(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=nt(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=nt(e,e.ins_h,e.window[e.strstart+1]);else n=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2},At=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(ut(e),e.lookahead<262&&t===Re)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=nt(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=Me(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=nt(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&&(at(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=Me(e,0,e.window[e.strstart-1]))&&at(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=Me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2};function ht(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 ft=[new ht(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(ut(e),0===e.lookahead&&t===Re)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,at(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(at(e,!1),e.strm.avail_out),1)}),new ht(4,4,8,4,lt),new ht(4,5,16,8,lt),new ht(4,6,32,32,lt),new ht(4,4,16,16,At),new ht(8,16,32,32,At),new ht(8,16,128,128,At),new ht(8,32,128,256,At),new ht(32,128,258,1024,At),new ht(32,258,258,4096,At)];function pt(){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=Ke,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*$e),this.dyn_dtree=new Uint16Array(2*(2*Je+1)),this.bl_tree=new Uint16Array(2*(2*Ze+1)),rt(this.dyn_ltree),rt(this.dyn_dtree),rt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Ye+1),this.heap=new Uint16Array(2*Qe+1),rt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Qe+1),rt(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 mt=e=>{if(!e||!e.state)return et(e,Ne);e.total_in=e.total_out=0,e.data_type=Xe;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=Re,Ce(t),Le},gt=e=>{const t=mt(e);return t===Le&&(e=>{e.window_size=2*e.w_size,rt(e.head),e.max_lazy_match=ft[e.level].max_lazy,e.good_match=ft[e.level].good_length,e.nice_match=ft[e.level].nice_length,e.max_chain_length=ft[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},vt=(e,t,r,n,i,a)=>{if(!e)return Ne;let o=1;if(t===Fe&&(t=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Ke||n<8||n>15||t<0||t>9||a<0||a>We)return et(e,Ne);8===n&&(n=9);const s=new pt;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<vt(e,t,Ke,15,8,ze),deflateInit2:vt,deflateReset:gt,deflateResetKeep:mt,deflateSetHeader:(e,t)=>e&&e.state?2!==e.state.wrap?Ne:(e.state.gzhead=t,Le):Ne,deflate:(e,t)=>{let r,n;if(!e||!e.state||t>Be||t<0)return e?et(e,Ne):Ne;const i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Oe)return et(e,0===e.avail_out?je:Ne);i.strm=e;const a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,ot(i,31),ot(i,139),ot(i,8),i.gzhead?(ot(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)),ot(i,255&i.gzhead.time),ot(i,i.gzhead.time>>8&255),ot(i,i.gzhead.time>>16&255),ot(i,i.gzhead.time>>24&255),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ot(i,255&i.gzhead.extra.length),ot(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=ke(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,0),ot(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),ot(i,3),i.status=113);else{let t=Ke+(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,st(i,t),0!==i.strstart&&(st(i,e.adler>>>16),st(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending!==i.pending_buf_size));)ot(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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=ke(e.adler,i.pending_buf,i.pending-r,r)),it(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindexr&&(e.adler=ke(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&&it(e),i.pending+2<=i.pending_buf_size&&(ot(i,255&e.adler),ot(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(it(e),0===e.avail_out)return i.last_flush=-1,Le}else if(0===e.avail_in&&tt(t)<=tt(a)&&t!==Oe)return et(e,je);if(666===i.status&&0!==e.avail_in)return et(e,je);if(0!==e.avail_in||0!==i.lookahead||t!==Re&&666!==i.status){let r=i.strategy===qe?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(ut(e),0===e.lookahead)){if(t===Re)return 1;break}if(e.match_length=0,r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Ve?((e,t)=>{let r,n,i,a;const o=e.window;for(;;){if(e.lookahead<=258){if(ut(e),e.lookahead<=258&&t===Re)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=Me(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(at(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Oe?(at(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(at(e,!1),0===e.strm.avail_out)?1:2})(i,t):ft[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),Le;if(2===r&&(t===De?Ie(i):t!==Be&&(Ee(i,0,0,!1),t===xe&&(rt(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),it(e),0===e.avail_out))return i.last_flush=-1,Le}return t!==Oe?Le:i.wrap<=0?Ge:(2===i.wrap?(ot(i,255&e.adler),ot(i,e.adler>>8&255),ot(i,e.adler>>16&255),ot(i,e.adler>>24&255),ot(i,255&e.total_in),ot(i,e.total_in>>8&255),ot(i,e.total_in>>16&255),ot(i,e.total_in>>24&255)):(st(i,e.adler>>>16),st(i,65535&e.adler)),it(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Le:Ge)},deflateEnd:e=>{if(!e||!e.state)return Ne;const t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?et(e,Ne):(e.state=null,113===t?et(e,He):Le)},deflateSetDictionary:(e,t)=>{let r=t.length;if(!e||!e.state)return Ne;const n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Ne;if(1===i&&(e.adler=Se(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(rt(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,ut(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=nt(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,ut(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,Le},deflateInfo:"pako deflate (from Nodeca project)"};const bt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var St={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)bt(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;kt[254]=kt[254]=1;var _t={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&&yt)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+kt[e[r]]>t?r:t}};var wt=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:Et,Z_SYNC_FLUSH:Pt,Z_FULL_FLUSH:Mt,Z_FINISH:It,Z_OK:Rt,Z_STREAM_END:Dt,Z_DEFAULT_COMPRESSION:xt,Z_DEFAULT_STRATEGY:Ot,Z_DEFLATED:Bt}=we;function Lt(e){this.options=St.assign({level:xt,method:Bt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ot},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 wt,this.strm.avail_out=0;let r=Tt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Rt)throw new Error(_e[r]);if(t.header&&Tt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?_t.string2buf(t.dictionary):"[object ArrayBuffer]"===Ct.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(r=Tt.deflateSetDictionary(this.strm,e))!==Rt)throw new Error(_e[r]);this._dict_set=!0}}function Gt(e,t){const r=new Lt(t);if(r.push(e,!0),r.err)throw r.msg||_e[r.err];return r.result}Lt.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?It:Et,"string"==typeof e?r.input=_t.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===Mt)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=Tt.deflate(r,a))===Dt)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Tt.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Rt;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},Lt.prototype.onData=function(e){this.chunks.push(e)},Lt.prototype.onEnd=function(e){e===Rt&&(this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Nt={Deflate:Lt,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:we};var Ht=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 C=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=C.dmax,c=C.wsize,d=C.whave,u=C.wnext,l=C.window,A=C.hold,h=C.bits,f=C.lencode,p=C.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",C.mode=30;break e}if(A>>>=T,h-=T,S>(T=i-a)){if((T=S-T)>d&&C.sane){e.msg="invalid distance too far back",C.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,C=0;const E=new Uint16Array(16),P=new Uint16Array(16);let M,I,R,D=null,x=0;for(p=0;p<=15;p++)E[p]=0;for(m=0;m=1&&0===E[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(P[1]=0,p=1;p<15;p++)P[p+1]=P[p]+E[p];for(m=0;m852||2===e&&k>592)return 1;for(;;){M=p-S,o[m]f?(I=D[x+o[m]],R=w[C+o[m]]):(I=96,R=0),d=1<>S)+(u-=d)]=M<<24|I<<16|R|0}while(0!==u);for(d=1<>=1;if(0!==d?(_&=d-1,_+=d):_=0,m++,0==--E[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:Wt,Z_BLOCK:zt,Z_TREES:Xt,Z_OK:Kt,Z_STREAM_END:Qt,Z_NEED_DICT:Jt,Z_STREAM_ERROR:Zt,Z_DATA_ERROR:$t,Z_MEM_ERROR:Yt,Z_BUF_ERROR:er,Z_DEFLATED:tr}=we,rr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function nr(){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 ir=e=>{if(!e||!e.state)return Zt;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,Kt},ar=e=>{if(!e||!e.state)return Zt;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,ir(e)},or=(e,t)=>{let r;if(!e||!e.state)return Zt;const n=e.state;return t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Zt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,ar(e))},sr=(e,t)=>{if(!e)return Zt;const r=new nr;e.state=r,r.window=null;const n=or(e,t);return n!==Kt&&(e.state=null),n};let cr,dr,ur=!0;const lr=e=>{if(ur){cr=new Int32Array(512),dr=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(Vt(1,e.lens,0,288,cr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Vt(2,e.lens,0,32,dr,0,e.work,{bits:5}),ur=!1}e.lencode=cr,e.lenbits=9,e.distcode=dr,e.distbits=5},Ar=(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.whavesr(e,15),inflateInit2:sr,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 C,E;const P=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 Zt;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=Kt;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=ke(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)!==tr){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=ke(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=ke(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=ke(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=ke(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=ke(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(lr(r),r.mode=20,t===Xt){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===Xt)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[P[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,C={bits:r.lenbits},k=Vt(0,r.lens,0,19,r.lencode,0,r.work,C),r.lenbits=C.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(E=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(E=m+3;u>>=m)),d>>>=3,u-=3}else{for(E=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,C={bits:r.lenbits},k=Vt(1,r.lens,0,r.nlen,r.lencode,0,r.work,C),r.lenbits=C.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,C={bits:r.distbits},k=Vt(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,C),r.distbits=C.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===Xt)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,Ht(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(E=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(E=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 Zt;let t=e.state;return t.window&&(t.window=null),e.state=null,Kt},inflateGetHeader:(e,t)=>{if(!e||!e.state)return Zt;const r=e.state;return 0==(2&r.wrap)?Zt:(r.head=t,t.done=!1,Kt)},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,a;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?Zt:11===n.mode&&(i=Se(i=1,t,r,0))!==n.check?$t:(a=Ar(e,t,r,r))?(n.mode=31,Yt):(n.havedict=1,Kt):Zt},inflateInfo:"pako inflate (from Nodeca project)"};var fr=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 pr=Object.prototype.toString,{Z_NO_FLUSH:mr,Z_FINISH:gr,Z_OK:vr,Z_STREAM_END:Tr,Z_NEED_DICT:br,Z_STREAM_ERROR:Sr,Z_DATA_ERROR:yr,Z_MEM_ERROR:kr}=we;function _r(e){this.options=St.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 wt,this.strm.avail_out=0;let r=hr.inflateInit2(this.strm,t.windowBits);if(r!==vr)throw new Error(_e[r]);if(this.header=new fr,hr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=_t.string2buf(t.dictionary):"[object ArrayBuffer]"===pr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=hr.inflateSetDictionary(this.strm,t.dictionary))!==vr))throw new Error(_e[r])}function wr(e,t){const r=new _r(t);if(r.push(e),r.err)throw r.msg||_e[r.err];return r.result}_r.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?gr:mr,"[object ArrayBuffer]"===pr.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=hr.inflate(r,o))===br&&i&&((a=hr.inflateSetDictionary(r,i))===vr?a=hr.inflate(r,o):a===yr&&(a=br));r.avail_in>0&&a===Tr&&r.state.wrap>0&&0!==e[r.next_in];)hr.inflateReset(r),a=hr.inflate(r,o);switch(a){case Sr:case yr:case br:case kr:return this.onEnd(a),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||a===Tr))if("string"===this.options.to){let e=_t.utf8border(r.output,r.next_out),t=r.next_out-e,i=_t.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!==vr||0!==s){if(a===Tr)return a=hr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},_r.prototype.onData=function(e){this.chunks.push(e)},_r.prototype.onEnd=function(e){e===vr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=St.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Cr={Inflate:_r,inflate:wr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,wr(e,t)},ungzip:wr,constants:we};const{Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir}=Nt,{Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or}=Cr;var Br={Deflate:Er,deflate:Pr,deflateRaw:Mr,gzip:Ir,Inflate:Rr,inflate:Dr,inflateRaw:xr,ungzip:Or,constants:we},Lr=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(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},Ce.prototype.clear=function(){this.__data__={hash:new _e,map:new(le||we),string:new _e}},Ce.prototype.delete=function(e){return Ve(this,e).delete(e)},Ce.prototype.get=function(e){return Ve(this,e).get(e)},Ce.prototype.has=function(e){return Ve(this,e).has(e)},Ce.prototype.set=function(e,t){return Ve(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)},Pe.prototype.clear=function(){this.__data__=new we},Pe.prototype.delete=function(e){return this.__data__.delete(e)},Pe.prototype.get=function(e){return this.__data__.get(e)},Pe.prototype.has=function(e){return this.__data__.has(e)},Pe.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 Ee: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=F?function(e){return function(t){return e(t)}}(F):function(e){return lt(e)&&dt(e.length)&&!!x[ne.call(e)]};function ft(e){return st(e)?Me(e):Fe(e)}function pt(e){return e}e.exports=rt});const Nr="4.1.3";function Hr(){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=`${Hr()} %cLOG-QNRTC`;console.info(t,"color: #66ccff; font-weight: bold;",...e)}debug(...e){if("log"!==this.level&&"debug"!==this.level)return;const t=`${Hr()} %cDEBUG-QNRTC`;console.info(t,"color: #A28148; font-weight: bold;",...e)}warning(...e){if("disable"===this.level)return;const t=`${Hr()} %cWARNING-QNRTC`;console.warn(t,"color: #E44F44; font-weight: bold;",...e)}}("log");class Fr 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 kn("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 kn("closed")):e.resolve(t)}).catch(t=>{this.isDebug&&jr.warning(`${this.name} _handleCommand() | command failed [method:%s]: %o`,e.method,t),e.reject(t)})}}const Ur="qnrtcqosevents";function qr(){return new Promise((e,t)=>{window.requestIdleCallback?window.requestIdleCallback(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})}):setTimeout(()=>{j.get(t=>{const r=Lr(JSON.stringify(t));e(r)})},500)})}function Vr(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 Wr=new class{constructor(){this.events=[],this.lastSubmitTime=Date.now(),this.submitQueue=new Fr("qossubmit",!1),qr().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:Nr,device_model:`${b.name}${b.version}`,os_platform:"Web",os_version:"",host_environment:b.os},this.initSubmitQueue(),this.submitQueue.push("resume").catch(Pn)}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:H[e],event_name:e},r);this.submitQueue.push("add",i).catch(Pn),this.submit(n)}submit(e=!1){this.submitQueue.push("submit",e).catch(Pn)}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 F.getItem(Ur);jr.log("get item",e),await F.removeItem(Ur),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)));F.setItem(Ur,e).catch(Pn)}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 Zr("rtcevent error");this.lastSubmitTime=Date.now(),this.events=[],await F.removeItem(Ur)}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(Br.gzip(Vr(JSON.stringify(i))));t.push(a)}return t}};{const e=navigator;function zr(e,t){let r;switch(e){case"prompt":r=D.prompt;break;case"granted":r=D.granted;break;case"denied":r=D.denied;break;default:return}Wr.addEvent("AuthorizationStatus",{type:t,status:r})}function Xr(t){e&&e.permissions&&e.permissions.query({name:t}).then(e=>{zr(e.state,R[t]),e.onchange=(()=>{zr(e.state,R[t])})}).catch(e=>{jr.debug("error when queryPermission",e)})}Xr("camera"),Xr("microphone")}document.visibilityState&&document.addEventListener("visibilitychange",()=>{Wr.addEvent("ApplicationState",{state:"visible"===document.visibilityState?0:2})});const Kr=(()=>{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=()=>{Wr.addEvent("NetworkChange",{network_type:r(t),network_name:t,network_grade:e})},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 Qr extends Error{constructor(e,t){super(t),this.code=e,this.error=t,Wr.addEvent("SDKError",{error_code:e,error_msg:t})}}const Jr=e=>new Qr(10053,`invalid parameters: ${e}`),Zr=e=>new Qr(21005,`piliRTC: unexpected error ${e}`),$r=e=>new Qr(21001,`enterRoom error, can not get accessToken. Error: ${e}\n please check enterRoom arguments`),Yr=e=>new Qr(21006,`not support! ${e}`),en=e=>new Qr(21007,`track play is not allowed: ${e}`),tn=e=>new Qr(23003,`plugin not avaliable! ${e}`),rn=e=>new Qr(23004,`NotAllowedError: no permission to access media device. ${e}`),nn=e=>new Qr(22011,`can not decode audio data, ${e.toString()}`),an=()=>new Qr(23005,"no audio track when createScreenVideoTrack withAudio enable"),on=e=>new Qr(23008,`require('electron') error, please checkout if electron environment is ok: ${e}`),sn=e=>new Qr(24e3,`relay error, can not get relayToken. Error: ${e}`),cn=e=>new Qr(24001,`invalid client mode, ${e}`),dn=e=>new Qr(24002,`invalid client role, ${e}`),un=()=>Zr("websocket abort"),ln=e=>Jr(`can not set merge layout stream, no merge job id ${e}`),An=()=>rn("can not sharing screen/window on chrome"),hn=()=>Zr("subscribe/publish operation is aborted"),fn=()=>Jr("cannot found preset"),pn=(e,t)=>new Qr(e,`publish error, signaling code: ${e}, msg: ${t}`),mn=(e,t)=>new Qr(e,`create merge job error, signaling code: ${e}, msg: ${t}`),gn=(e,t)=>new Qr(e,`create forward job error, signaling code: ${e}, msg: ${t}`),vn=(e,t)=>new Qr(e,`media format not support, ${t}`),Tn=(e,t)=>new Qr(e,`subscribe error, signaling code: ${e}, msg: ${t}`),bn=(e,t)=>new Qr(e,`send control error, code: ${e}, msg: ${t}`),Sn=(e,t)=>new Qr(e,t),yn=()=>new Qr(10052,"server unavailable");class kn extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,kn):this.stack=new Error(e).stack}}var _n=Object.freeze({QNRTCError:Qr,ERROR_INVALID_PARAMETER:Jr,ERROR_FATAL:Zr,ERROR_AUTH_FAILED:$r,ERROR_RECONNECT_FAILED:e=>new Qr(21003,`reconnect failed!${e}`),ERROR_NOT_SUPPORT:Yr,ERROR_PLAY_NOT_ALLOWED:en,ERROR_PLUGIN_NOT_AVAILABLE:tn,ERROR_DEVICE_NOT_ALLOWED:rn,ERROR_AUDIO_DECODE_ERROR:nn,CREATE_SCREEN_AUDIO_ERROR:an,ERROR_ELECTRON_REQUIRE_ERROR:on,ERROR_RELAY_TOKEN:sn,ERROR_INVALID_CLIENT_MODE:cn,ERROR_INVALID_CLIENT_ROLE:dn,WS_ABORT:un,NO_MERGE_JOB:ln,SCREEN_PERMISSION_DENIED:An,SUB_PUB_ABORT:hn,PRESET_NOT_FOUND:fn,PUBLISH_ERROR:pn,CREATE_MERGE_JOB_ERROR:mn,CREATE_FORWARD_JOB_ERROR:gn,UNSUPPORT_FMT:vn,JOIN_ROOM_ERROR:(e,t)=>new Qr(e,`joinRoom error, code: ${e}, ${t}`),SUB_ERROR:Tn,UNPUBLISH_ERROR:(e,t)=>new Qr(e,"unpublish error, code: ${code}, msg: ${msg}"),UNSUB_ERROR:(e,t)=>new Qr(e,"unsubscribe error, code: ${code}, msg: ${msg}"),CONTROL_ERROR:bn,SERVER_ERROR:Sn,SERVER_UNAVAILABLE:yn,InvalidStateError:kn});function wn(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 Cn(e){try{const t=e.split(":")[2],r=atob(t);return JSON.parse(r)}catch(e){throw Zr(`can not parse roomToken, ${e}`)}}function En(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]=Mn(e[r],t+1));return e}function In(e){Promise.resolve().then(e)}function Rn(e){return("0"+e.toString(16)).substr(-2)}function Dn(e=5){const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,Rn).join("")}function xn(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}const On={};function Bn(e,t){if(!On[t])return On[t]=!0,e()}function Ln(e){jr.warning("play failed!",e),jr.warning("play failed due to browser security policy, see: http://s.qnsdk.com/s/Txsdz")}function Gn(e,t){return new Promise((r,n)=>{let i;if("AbortController"in window){const r=new AbortController;setTimeout(()=>r.abort(),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 Nn(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 xn(1e3),await Nn(e)}}var Hn;!function(e){e[e.AudioLevelUnusual=0]="AudioLevelUnusual"}(Hn||(Hn={}));class jn{static create(e){this.instance||(this.instance=new jn);const r=this.instance.getValidStandard(e.code);return this.instance.qosAddEvent(t({valid_standard:r},e)),this.instance}constructor(){}qosAddEvent(e){Wr.addEvent("WebSDKException",e)}getValidStandard(e){switch(e){case Hn.AudioLevelUnusual:return"0-1"}}}class Fn{constructor(e,t=Fn.AlphaForPacketLossFractionSmoother){this.mLastFilteredTimestamp=Date.now(),this.mMax=Fn.kValueUndefined,this.smooth_interval="audio"===e?Fn.SMOOTH_AUDIO_INTERVAL:Fn.SMOOTH_VIDEO_INTERVAL,this.Reset(t)}Reset(e){this.mAlpha=e,this.mFiltered=Fn.kValueUndefined}Apply(e){const t=Date.now()-this.mLastFilteredTimestamp;if(tthis.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 Un(){const e={};return(t,r)=>t in e?e[t]:(e[t]=new Fn(r),e[t])}Fn.kValueUndefined=-1,Fn.AlphaForPacketLossFractionSmoother=.9999,Fn.SMOOTH_VIDEO_INTERVAL=1e3,Fn.SMOOTH_AUDIO_INTERVAL=5e3;const qn=Un(),Vn=Un(),Wn=()=>({id:"",kind:"audio",packetLossRate:0,bitrate:0,bytes:0,packets:0,packetLoss:0,frameRate:0,rtt:0,timestamp:Date.now(),networkGrade:x.INVALID});function zn(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 Xn={track_audio_volume:0,jitter_buffer_delay:0,bytes_sent:0,bytes_received:0},Kn={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},Qn={frames_received:0,frames_sent:0,packets_lost:0,packets_received:0,packets_sent:0,timestamp:0,bytes_sent:0,bytes_received:0};var Jn,Zn,$n;async function Yn(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===Zn.InBoundRtp||e.type===Zn.OutBoundRtp)&&i.find(t=>t.id===e.trackId&&"track"===t.type)).map(e=>(function(e,r,n){const i={[Zn.MediaSource]:r.filter(e=>e.type===Zn.MediaSource).find(t=>t.id===e.mediaSourceId),[Zn.Track]:r.filter(e=>e.type===Zn.Track).find(t=>t.id===e.trackId),[Zn.RemoteInBound]:r.filter(e=>e.type===Zn.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({},Qn)};return n===Jn.Audio?i.extra_stats=t({},Xn):i.extra_stats=t({},Kn),i}(e.id,e.trackID,e.mediaType);a.rtt=ti(i[Zn.RemoteInBound])||ti(e)||0,a.calculation_stats.packets_lost=ri(e,i[Zn.RemoteInBound])||0,e.mediaType===Jn.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[Zn.MediaSource]&&(a=function(e,t){return t.framerate=e.framesPerSecond,t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.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=ei(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[Zn.MediaSource]&&(a=function(e,t){return t.extra_stats.track_audio_volume=ei(e.audioLevel,e.type),t}(i[Zn.MediaSource],a)),i[Zn.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[Zn.Track],a,n)));return a})(e,i,r))}function ei(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===Zn.InBoundRtp?(r=Math.min(e/32767,1),jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}})):(r>1||r<0)&&jn.create({code:Hn.AudioLevelUnusual,actual_value:e,extra_info:{stats_report_type:t}}),r}function ti(e){if(e)return e.roundTripTime?1e3*e.roundTripTime:e.googRtt?e.googRtt:e.mozRtt?e.mozRtt:void 0}function ri(e,t){return"inbound-rtp"===e.type?e.packetsLost:"outbound-rtp"===e.type&&t?t.packetsLost:void 0}function ni(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 ii(){const e={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceServers:[]};w.unifiedPlan?e.sdpSemantics="unified-plan":e.sdpSemantics="plan-b";const t=new RTCPeerConnection(e);return w.unifiedPlan&&w.supportTransceivers&&(t.addTransceiver("audio",{direction:"inactive"}),t.addTransceiver("video",{direction:"inactive"})),t}async function ai(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"})}async function oi(e,r,n,i){if(w.stats){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=ni(r.packetLoss,e.packetLoss,r.packets,e.packets);i.networkGrade=zn(a,i.rtt);const o=qn(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})}(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=Wn(),a=n.get(e.remoteId);t.packetLoss=ri(e,a)||0,t.bytes="send"===r?e.bytesSent:e.bytesReceived,t.packets="send"===r?e.packetsSent:e.packetsReceived,t.rtt=ti(e)||ti(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),i)}return Bn(()=>{jr.warning("your browser does not support getStats")},"not-support-stats-warning"),[]}!function(e){e.Video="video",e.Audio="audio"}(Jn||(Jn={})),function(e){e.MediaSource="media-source",e.Track="track",e.OutBoundRtp="outbound-rtp",e.InBoundRtp="inbound-rtp",e.RemoteInBound="remote-inbound-rtp"}(Zn||(Zn={})),function(e){e.In="in",e.Out="out"}($n||($n={})),window.addEventListener("message",e=>{e.origin===window.location.origin&&function(e){if("PermissionDeniedError"===e){if(di="PermissionDeniedError",ci)return ci("PermissionDeniedError");throw An()}"qnrtc:rtcmulticonnection-extension-loaded"===e&&(di="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&&ci&&ci(si=e.sourceId,!0===e.canRequestAudioTrack)}(e.data)});let si,ci,di="screen";async function ui(){return await(()=>new Promise((e,t)=>{"desktop"!==di?(window.postMessage("qnrtc:are-you-there","*"),setTimeout(()=>{e("screen"!==di)},2e3)):e(!0)}))()}async function li(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:di,maxWidth:Ci(t.width),maxHeight:Ci(t.height)},optional:[]};"desktop"!==di?n(o):e?function(e){if(si)return e(si);ci=e,window.postMessage("qnrtc:audio-plus-tab","*")}(function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),"PermissionDeniedError"!==e?n(o):i(An())}):function(e,t=!1,r=!1){ci=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(An())},"screen"===r,"window"===r)}))()}var Ai=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]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,E=/^\w*$/,P=/^\./,M=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,I=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,x={};x["[object Float32Array]"]=x["[object Float64Array]"]=x["[object Int8Array]"]=x["[object Int16Array]"]=x["[object Int32Array]"]=x["[object Uint8Array]"]=x["[object Uint8ClampedArray]"]=x["[object Uint16Array]"]=x["[object Uint32Array]"]=!0,x[u]=x[l]=x[_]=x[A]=x[w]=x[h]=x[f]=x[p]=x[g]=x[v]=x[T]=x[b]=x[S]=x[y]=x["[object WeakMap]"]=!1;var O="object"==typeof c&&c&&c.Object===Object&&c,B="object"==typeof self&&self&&self.Object===Object&&self,L=O||B||Function("return this")(),G=t&&!t.nodeType&&t,N=G&&e&&!e.nodeType&&e,H=N&&N.exports===G&&O.process,j=function(){try{return H&&H.binding("util")}catch(e){}}(),F=j&&j.isTypedArray;function U(e,t){return!!(e?e.length:0)&&function(e,t,r){if(t!=t)return function(e,t,r,n){var i=e.length,a=r+(n?1:-1);for(;n?a--:++a-1}function q(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Pe.prototype.set=function(e,t){var r=this.__data__,n=xe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Me.prototype.clear=function(){this.__data__={hash:new Ee,map:new(fe||Pe),string:new Ee}},Me.prototype.delete=function(e){return qe(this,e).delete(e)},Me.prototype.get=function(e){return qe(this,e).get(e)},Me.prototype.has=function(e){return qe(this,e).has(e)},Me.prototype.set=function(e,t){return qe(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 Pe},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 Pe){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=F?function(e){return function(t){return e(t)}}(F):function(e){return st(e)&&at(e.length)&&!!x[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=U,o=e.length,s=!0,c=[],d=c;if(n)s=!1,a=q;else if(o>=r){var u=t?null:Fe(e);if(u)return Q(u);s=!1,a=z,d=new Ie}else d=t?[]:c;e:for(;++i0}addTracks(e){this.tracks=this.tracks.concat(e),this.tracks=Ai(this.tracks,"mediaTrack");for(const e of this.tracks)e.once("release",()=>{E(this.tracks,t=>t===e)})}removeTracksByTrackId(e){E(this.tracks,t=>!!t.info.trackID&&-1!==e.indexOf(t.info.trackID))}addPublishedTrackInfo(e){this.publishedTrackInfo=this.publishedTrackInfo.concat(e),this.publishedTrackInfo=Ai(this.publishedTrackInfo,"trackID")}removePublishedTrackInfo(e){E(this.publishedTrackInfo,t=>-1!==e.indexOf(t.trackID))}}function fi(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 pi(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),In(()=>{t&&t.srcObject&&t.removeAttribute("controls")})),t}class mi extends C{safeEmit(e,...t){try{this.emit(e,...t)}catch(t){jr.warning("safeEmit() | event listener threw an error [event:%s]:%o",e,t)}}safeEmitAsPromise(e,...t){return new Promise((r,n)=>{const i=r;this.safeEmit(e,...t,i,t=>{jr.warning("safeEmitAsPromise() | errback called [event:%s]:%o",e,t),n(t)})})}}class gi extends mi{constructor(e,t,r,n){super(),this.master=!1,this.stats=[],this.isReplacedByImageTrack=!1,this.direction="local",this.sourceType=B.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),Wr.addEvent("TrackEnded",{track_id:this.info.trackID,kind:this.info.kind,label:this.mediaTrack.label}),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(w.setPlaybackDevice||Yr("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?pi:fi;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(Pn)},!1):document.addEventListener("WeixinJSBridgeReady",()=>{r().then(n).catch(Pn)},!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)),Wr.addEvent("AutoplayFail",{track_id:this.info.trackID,local_id:this.mediaTrack.id,label:this.mediaTrack.label,kind:this.info.kind,reason:t})):i(Zr(t))})})})}handleMediaPause(){setTimeout(()=>this.mediaElement.play().catch(Ln),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(Ln)}}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&&w.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}}function vi(e){return{timestamp:e.msgts,data:e.text,userID:e.playerid,type:e.type,msgid:e.msgid}}function Ti(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 bi(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 Si(e){if(!e.info.mid&&w.unifiedPlan)throw Zr("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 yi(e){return new hi(e.playerid,e.playerdata)}function ki(e,t,r){let n;return"audio"===e.kind?(n=new Da(e)).initAudioManager(!0):n=new gi(e),r&&n.setKbps(r),n.setInfo({tag:t}),n}function _i(e){switch(e){case"window":return"application";case"screen":return["window","monitor"];default:return}}const wi=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(w.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}(Mn(e)));function Ci(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}var Ei=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")})})}),Pi=(Ei.v,Ei.o,Ei.s,Ei.i,Ei.u,Ei.e,Ei.p,Ei.z,Ei.r,Ei.t,Ei.c,Ei.b,Ei.m,Ei.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)},Ri=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Di=["i","c","b","a"],xi={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||Ri,n=t.innerOrder||Di,i=[];return r.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})}),e.media.forEach(function(e){i.push(Ii("m",Ei.m[0],e)),n.forEach(function(t){Ei[t].forEach(function(r){r.name in e&&null!=e[r.name]?i.push(Ii(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){i.push(Ii(t,r,e))})})})}),i.join("\r\n")+"\r\n"},parse:Pi.parse,parseParams:Pi.parseParams,parseFmtpConfig:Pi.parseFmtpConfig,parsePayloads:Pi.parsePayloads,parseRemoteCandidates:Pi.parseRemoteCandidates,parseImageAttributes:Pi.parseImageAttributes,parseSimulcastStreamList:Pi.parseSimulcastStreamList};const Oi="\n",Bi="qiniu-rtc-client";function Li(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 Gi{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 Nn(t.ip);this._transportRemoteParameters=e}createRemoteAnswer(e,t,r){if(jr.log("create remote answer",t,r),!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");return w.unifiedPlan?function(e,t,r,n,i){const a=xi.parse(r),o={version:0};o.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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){r.direction;const a=r.type,s="audio"===a?e.codecs[0]:e.codecs[1],c=e.headerExtensions.filter(e=>e.kind===a),d={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:Li(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:s.sendPayloadType,codec:s.name,rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}],rtcpFb:[],fmtp:[{payload:s.sendPayloadType,config:Object.keys(s.parameters).map(e=>`${e}=${s.parameters[e]};`).join("")}],payloads:s.sendPayloadType,rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",ext:c.map(e=>({uri:e.uri,value:e.sendId}))};s.rtcpFeedback&&s.rtcpFeedback.length>0&&s.rtcpFeedback.forEach(e=>{d.rtcpFb.push({payload:s.sendPayloadType,type:e.type,subtype:e.parameter})}),s.sendRtxPayloadType&&(d.rtp.push({payload:s.sendRtxPayloadType,codec:"rtx",rate:s.clockRate,encoding:s.channels>1?s.channels:void 0}),d.fmtp.push({payload:s.sendRtxPayloadType,config:`apt=${s.sendPayloadType};`}),d.payloads=`${s.sendPayloadType} ${s.sendRtxPayloadType}`);const u=n[d.mid];"video"===d.type&&u&&(d.rids=[{id:"hi",direction:"recv"},{id:"lo",direction:"recv"}],d.simulcast={dir1:"recv",list1:"hi;lo"}),o.media.push(d)}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 xi.write(o)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e,t,r):function(e,t,r){const n=xi.parse(r);n.version=0,n.origin={address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"5975129998295344376",sessionVersion:2,username:Bi},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 Zr("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:Li(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,xi.write(n)}(this.extendedRtpCapabilities,this.transportRemoteParameters,e)}createRemoteOffer(e){if(!this.transportRemoteParameters)throw Zr("no transportRemoteParameters!");if(w.unifiedPlan){const t=function(e,t){let r=[];for(const n of t){const t=E(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:Bi},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:Li(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}`),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 xi.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:Bi},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 Zr("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:Li(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 xi.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 Nn(e.ip);this.transportRemoteParameters.iceCandidates=t,this.transportRemoteParameters.iceParameters=e}}}async function Ni(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 Hi(e){const t=xi.parse(e);if(!("media"in t))return xi.write(t);if(!Array.isArray(t.media))return xi.write(t);for(const e of t.media)"rtp"in e&&Array.isArray(e.rtp)&&"audio"===e.type&&(e.rtp=e.rtp.filter(t=>!("codec"in t)||("red"!==t.codec.toLowerCase()||("payload"in t&&"fmtp"in e&&Array.isArray(e.fmtp)&&(e.fmtp=e.fmtp.filter(e=>e.payload!==t.payload)),!1))));return xi.write(t)}function ji(e){const t=xi.parse(e);if(!("media"in t))return xi.write(t);if(!Array.isArray(t.media))return xi.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 xi.write(t)}var Fi,Ui=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;inew 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 e=this.wsConnectTimeout/1e3+"s timeout";Wr.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:e}),this.startInitTime=-1,this.reconnect().catch(e=>{jr.warning("signaling: reconnect timeout error",e)})},this.wsConnectTimeout),this.ws=new WebSocket(this.url),this._state=zi.CONNECTING}catch(e){throw Zr(`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||(Wr.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}),this.startInitTime=-1),this.ws.onmessage=this.onWsMsg;const t={token:this.accessToken,reconntoken:this.reconnectToken,agent:`${b.name}${b.version}`,sdkversion:Nr,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&&(Wr.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}),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=zi.OPEN,Wr.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}),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(Xi(t.code,t.error));break}return void this.emit("@error",t);case 10054:i(vn(10054,t.error));break;default:i(Zr(t.error))}0!==t.code&&(this.reconnectToken=void 0,this._state=zi.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 Zr(`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&&(Wr.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}),this.startInitTime=-1)}),this.sendWsMsg=((e,t)=>{if(this.ws.readyState!==WebSocket.OPEN)throw un();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)}),un()}}),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=zi.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=zi.CLOSED,jr.warning("signaling: websocket onclose",r),this.startAuthTime&&Wr.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});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===zi.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===zi.CONNECTING?this.reconnectPromise:this.currentLeftReconnectTimes<=0?(this.emit("@error",{code:10007}),Promise.reject("websocket reconnectTimes run out, reconnect stops.")):(this.currentLeftReconnectTimes-=1,this._state=zi.CONNECTING,jr.debug("signaling: websocket reconnecting, currentLeftReconnectTimes remaining: ",this.currentLeftReconnectTimes),this.reconnectPromise=xn(e).then(()=>this.initWs()).then(e=>(this.reconnectPromise=void 0,this.currentLeftReconnectTimes=this.reconnectTimes,e)).catch(e=>(this._state=zi.CLOSED,this.emit("error",e),Promise.reject(e))),this.reconnectPromise)}request(e,t){const r=Dn(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 Ji{}class Zi{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){E(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=Ai(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()}}var $i,Yi;!function(e){e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.CONNECTED="CONNECTED",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}($i||($i={})),function(e){e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE"}(Yi||(Yi={}));const ea={"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}},ta=ea["480p"],ra={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}},na=ra.STANDARD,ia={"480p":{width:640,height:480,frameRate:5},"720p":{width:1280,height:720,frameRate:5},"1080p":{width:1920,height:1080,frameRate:5}},aa=ia["720p"];var oa,sa,ca,da,ua,la,Aa,ha,fa,pa,ma,ga,va,Ta;!function(e){e.WINDOW="window",e.SCREEN="screen",e.ALL="all"}(oa||(oa={})),function(e){e.PlAYING="PlAYING",e.PAUSED="PAUSED",e.STOPPED="STOPPED"}(sa||(sa={})),function(e){e.FILL="scaleToFit",e.ASPECT_FILL="aspectFill",e.ASPECT_FIT="aspectFit"}(ca||(ca={})),function(e){e.STARTED="STARTED",e.STOPPED="STOPPED"}(da||(da={})),function(e){e.UNKNOWN="UNKNOWN",e.EXCELLENT="EXCELLENT",e.GOOD="GOOD",e.FAIR="FAIR",e.POOR="POOR"}(ua||(ua={})),function(e){e.LOW="LOW",e.MEDIUM="MEDIUM",e.HIGH="HIGH"}(la||(la={})),function(e){e.LEAVE="LEAVE",e.KICKED_OUT="KICKED_OUT",e.ERROR="ERROR"}(Aa||(Aa={})),function(e){e.VERBOSE="VERBOSE",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(ha||(ha={})),function(e){e.FORCE_UDP="FORCE_UDP",e.FORCE_TCP="FORCE_TCP",e.PREFER_UDP="PREFER_UDP"}(fa||(fa={})),function(e){e.MOTION="motion",e.DETAIL="detail",e.DEFAULT=""}(pa||(pa={})),function(e){e.SCREEN="screen",e.WINDOW="window",e.ALL="all"}(ma||(ma={})),function(e){e.RTC="RTC",e.LIVE="LIVE"}(ga||(ga={})),function(e){e.BROADCASTER="BROADCASTER",e.AUDIENCE="AUDIENCE"}(va||(va={})),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"}(Ta||(Ta={}));class ba{static loadImage(e){if(e instanceof File)return ba.loadImageFromFile(e);if(e instanceof ArrayBuffer)return ba.loadImageFromArrayBuffer(e);if("string"==typeof e)return ba.loadImageFromUrl(e);throw Yr("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(ba.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(ba.loadImageFromUrl(i))})}}class Sa{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 ba.loadImageFromFile(e):e instanceof ArrayBuffer?await ba.loadImageFromArrayBuffer(e):await ba.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 ya{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 Yr("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 Yr("MediaRecorder is not supported.");if(void 0===e||0===e.length||e.length>2)throw Zr("Invalid parameters.");if(this.recorder&&"inactive"!==this.recorder.state)throw Zr("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 Zr("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(ya.recorderTimeslice)}catch(e){throw Zr("MediaRecoder start error: "+e.message)}}pause(){if(jr.log("Recorder pause"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("recording"!==this.recorder.state)throw Zr("MediaRecorder is not in recording state, cannot do pause.");this.recorder.pause()}resume(){if(jr.log("Recorder resume"),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("paused"!==this.recorder.state)throw Zr("MediaRecorder is not in paused state, cannot do resume.");this.recorder.resume()}stop(){if(jr.log("Recorder stop, ",this.recordedChunks),!this.recorder)throw Zr("No MediaRecorder, please try to start first.");if("inactive"===this.recorder.state)throw Zr("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 Zr("MediaRecorder stop error: "+e.message)}}play(e,t=!0){if(jr.log("Recorder play, ",e,t),!this.recordedUrl)throw Zr("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 Zr("MediaRecoder play error: "+e.message)}catch(e){}}):e()})}download(e){if(jr.log("Recorder download, "+e),!this.recordedUrl)throw Zr("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)}}ya.recorderTimeslice=1e3;class ka{constructor(e,t,r,n){this.id=e,this.mid=t,this.kind=r,this.rtpParameters=n,this.track=null}}class _a{constructor(e,t,r,n,i){this._connectStatus=O.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,In(()=>{this.onConnectStatusChange&&this.onConnectStatusChange(t,this._connectStatus)})}}startConnect(){return this.connectStatus=O.Connecting,new Promise((e,t)=>{this.onConnectStatusChange=((r,n)=>{n===O.Connect&&e(),n===O.Idle&&t()})})}appendConsumner(e,t){this.consumer=new ka(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 wa=window.AudioContext||window.webkitAudioContext||window.Object,Ca=w.audioContextOptions?new wa({latencyHint:"interactive"}):new wa;if(window.audioContext=Ca,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)})})(Ca).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),Ca.onstatechange=(()=>{e()})}const Ea=2048,Pa=4096,Ma=["play","playing","pause","ended","waiting","seeking"];class Ia extends mi{constructor(){super(),this.audioSource=null,this._audioSourceState=N.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=N.PLAY;break;case"pause":if(this.audioSourceState===N.END)break;this.audioSourceState=N.PAUSE;break;case"waiting":case"seeking":this.audioSourceState=N.LOADING;break;case"ended":this.audioSourceState=N.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",Ca.state),"suspended"===Ca.state&&(jr.log("audio context suspended"),Ca.resume().catch(e=>{jr.warning("resume audiocontext failed! see: http://s.qnsdk.com/s/Txsdz",e)})),jr.log("init audio finish",Ca.state),this.analyserNode=Ca.createAnalyser(),this.analyserNode.fftSize=Ea,this.gainNode=Ca.createGain(),function(e){if(w.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=Ai(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),E(e._inputNodes,e=>e===t);for(const t of e._inputNodes)e.connect(t)})}(this.gainNode),w.mediaStreamDest&&(this.audioStream=Ca.createMediaStreamDestination())}setMediaStreamSource(e){this.audioSource=Ca.createMediaStreamSource(e),this.connect()}setAudioBufferSource(){this.audioSource=Ca.createBufferSource(),this.audioSource.onended=(()=>this.stopAudioSource()),this.connect()}setMediaElementSource(e){this.audioSource=Ca.createMediaElementSource(e),this.audioSourceElement=e;for(const e of Ma)this.audioSourceElement.addEventListener(e,this.handleMediaElementEvents);this.connect()}setAudioSourceLoop(e){this.audioSourceLoop=e,this.audioSource instanceof AudioBufferSourceNode?this.audioSource.loop=!!e:this.audioSourceElement&&(this.audioSourceElement.loop=!!e)}setAudioBuffer(e){this.audioSource instanceof AudioBufferSourceNode&&(this.audioSource.buffer=e,this.audioSourceBuffer=e)}playAudioSource(e=0){if(this.audioSource instanceof AudioBufferSourceNode){this.resetBufferSourceDuration();try{this.audioSource.start(0,e),this.bufferSourceDuration.startTime=Ca.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY}catch(t){this.stopAudioSource(),this.playAudioSource(e)}}else this.audioSourceElement?(this.audioSourceElement.currentTime=0,this.audioSourceElement.play().catch(Ln)):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=Ca.currentTime,this.bufferSourceDuration.offsetTime=e,this.audioSourceState=N.PLAY)}resumeAudioSource(){if(this.audioSource instanceof AudioBufferSourceNode){if(this.audioSourceState!==N.PAUSE)return;this.audioSource.playbackRate.value=1,this.bufferSourceDuration.pauseTime+=Ca.currentTime-this.bufferSourceDuration.lastPauseTime,this.bufferSourceDuration.lastPauseTime=0,this.audioSourceState=N.PLAY}else this.audioSourceElement&&this.audioSourceElement.play().catch(Ln)}pauseAudioSource(){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.playbackRate.value=g?1e-7:Number.MIN_VALUE,this.bufferSourceDuration.lastPauseTime||(this.bufferSourceDuration.lastPauseTime=Ca.currentTime),this.audioSourceState=N.PAUSE):this.audioSourceElement&&this.audioSourceElement.pause()}stopAudioSource(e=!1){this.audioSource instanceof AudioBufferSourceNode?(this.audioSource.onended=null,this.audioSource.stop(),this.audioSource.disconnect(),this.audioSource=null,this.bufferSourceDuration.stopTime=Ca.currentTime,e||(this.audioSourceState=N.END)):this.audioSourceElement&&(this.audioSourceState=N.END,this.audioSourceElement.pause(),this.audioSourceElement.currentTime=0)}getAudioSourceCurrentTime(){if(this.audioSourceElement)return this.audioSourceElement.currentTime;if(this.audioSource instanceof AudioBufferSourceNode){let e=Ca.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.audioSource instanceof AudioBufferSourceNode&&(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 Ma)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=Pa){this.audioBufferCallback=e,this.audioBufferSize=t,this.audioStream&&this.audioSource&&(this.scriptNode||(this.scriptNode=Ca.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}}}const Ra=0;class Da extends gi{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 Ia,this.audioManager.initAudioContext(),this.audioManager.setMediaStreamSource(this.mediaStream),this.audioManager.on("audioBuffer",e=>{this.emit("audioBuffer",e)}),e&&w.mediaStreamDest&&(this.mediaStream=this.audioManager.audioStream.stream,this.mediaTrack=this.mediaStream.getTracks()[0])}setVolume(e){this.audioManager.gainNode.gain.setValueAtTime(e,Ca.currentTime)}getCurrentTimeDomainData(){const e=new Uint8Array(Ea);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*(Ca.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<=Ra?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 xa=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 Oa,Ba=function(e,t){if(null==e)return{};var r,n,i=xa(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};class La extends mi{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=ii(),this._extendedRtpCapabilities=t,this._remoteSdp=new Gi(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,t){return await oi(this._pc,e,this._direction,t)}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 Bn(()=>{jr.debug("get media statistic stats error, fallback to default",e)},"getStats error"),[]}if(!r)return Bn(()=>{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===Zn.Track&&e.trackIdentifier===t.id);if(!r)return;const i=n.find(e=>e.type===Zn.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(L)}(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);Wr.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);Wr.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 Yn(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=Vn(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=Ba(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=ni(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),Wr.addEvent("MediaStatistics",{cpu_loading:0,track_stats:n});let i=zn(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);Kr(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 Ga extends La{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(w.unifiedPlan&&w.supportTransceivers)for(const e of t){const t=await ai(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 Ha(this._pc,this._simulcast)}).then(e=>{let t;return w.needH264FmtpLine&&(e.sdp+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`),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 Zr("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 Qr?e:Zr(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(()=>{w.unifiedPlan&&w.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 Ha(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 Qr?e:Zr(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 Zr("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 Zr(`sender not found when replaceTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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 Zr("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 Zr(`sender not found when replaceProducerTrack: ${e.trackID}`);if(!r.replaceTrack)throw Zr("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(()=>Ha(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:Ha(this._pc,this._simulcast)).then(t=>this.safeEmitAsPromise("@needpubpc",t.sdp,e)).then(r=>(Wr.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 Na extends La{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(w.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(w.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(()=>(w.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(w.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 Zr("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:w.unifiedPlan?`recv-stream-${n}`:`recv-stream-${t.ssrc}`,trackID:w.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(w.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(w.unifiedPlan&&w.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 Zr("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,w.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 Wr.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 Ha(e,t,r){return e.createOffer(r).then(e=>{let{type:r,sdp:n}=e;return n?(n=ji(n=Hi(n)),"chrome"===b.name&&t&&(n=function(e,t){const r=xi.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=xi.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 ja(e,t,r,n){switch(e){case"send":return new Ga(t,r,n);case"recv":return new Na(t,r,n)}}!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"}(Oa||(Oa={}));class Fa extends mi{constructor(e,t,r,n){super(),this.sendCommandQueue=new Fr("SendQueue"),this.recvCommandQueue=new Fr("RecvQueue"),this.simulcast=!1,this.recvInitCommandQueue=new Fr("RecvInitQueue"),this.sendTrackQueue=[],this.consumerQueue=[],this._publishTracks=new Map,this.extendedRtpCapabilities=e,this.signaling=t,this.simulcast=!!n,this.coreInstance=r,this.sendHandler=ja("send",e,t,{simulcast:this.simulcast,core:this.coreInstance}),this.recvHandler=ja("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),Wr.addEvent("ICEConnectionState",{pc_type:0,state:e,id:this.sendHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===zi.OPEN?this.reconnectProducer():this.sendHandler.close();break;case"disconnected":if(this.sendHandler._isRestartingICE||!this.sendHandler.pcid)return;this.signaling.state===zi.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(Si),a=Date.now();this.signaling.request("pub-tracks",{tracks:i,sdp:t}).then(t=>{switch(Wr.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(yn());case 10061:return this.reconnectProducer(),n(pn(10061,t.error));default:return n(pn(t.code,t.error))}for(const e of t.tracks)if(!e.status)return void n(pn(t.code,t.error));r(t)},n)}).on("@needunpubtracks",(e,t,r)=>{Wr.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(Oa.SEND_TRACKS,e)}removeTracks(e){return 0===e.length?Promise.resolve():this.sendCommandQueue.push(Oa.REMOVE_TRACKS,e)}async restartSendICE(e){return w.supportRestartICE?this.sendCommandQueue.push(Oa.RESTART_SEND_ICE,e):Promise.resolve(this.reconnectProducer())}handleSendCommandTask(e,t){switch(e.method){case Oa.SEND_TRACKS:return void(t.promise=this._execAddProducerTracks(e.data));case Oa.REMOVE_TRACKS:return void(t.promise=this._execRemoveTracks(e.data));case Oa.RESTART_SEND_ICE:return void(t.promise=this._execRestartSendICE(e.data))}}addTrackToPublishTracks(e){const t=e.map(e=>new _a(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=En(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=O.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=ja("send",this.extendedRtpCapabilities,this.signaling,{simulcast:this.simulcast,core:this.coreInstance}),this.handleSendHandler(),e.forEach(e=>{e.connectStatus=O.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),Wr.addEvent("ICEConnectionState",{pc_type:1,state:e,id:this.recvHandler.pcid}),e){case"remote-disconnected":case"closed":case"failed":this.signaling.state===zi.OPEN?this.resetRecvHandler():this.recvHandler.close();break;case"disconnected":if(this.recvHandler._isRestartingICE||!this.recvHandler.pcid)return;this.signaling.state===zi.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(Oa.ADD_CONUMERS,e)}initRecvHandler(e){return this.recvInitCommandQueue.push(Oa.INIT_RECV,e)}async removeConsumers(e){await this.recvCommandQueue.push(Oa.REMOVE_CONSUMERS,e)}async restartRecvICE(e){return w.supportRestartICE?this.recvCommandQueue.push(Oa.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 Oa.ADD_CONUMERS:return void(t.promise=this._addConsumers(e.data));case Oa.REMOVE_CONSUMERS:return void(t.promise=this._removeConsumers(e.data));case Oa.RESTART_RECV_ICE:return void(t.promise=this._execRestartRecvICE(e.data))}}handleRecvInitCommandTask(e,t){switch(e.method){case Oa.INIT_RECV:return void(t.promise=this._initRecvHandler(e.data))}}resetSendCommandQueue(){jr.log("reset send queue"),this.sendCommandQueue=new Fr("SendQueue"),this.sendCommandQueue.on("exec",this.handleSendCommandTask.bind(this))}resetRecvCommandQueue(){jr.log("reset recv queue"),this.recvCommandQueue=new Fr("RecvQueue"),this.recvInitCommandQueue=new Fr("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=ja("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 Ua=new mi;function qa(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 Va;!function(e){e[e.Idle=0]="Idle",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Reconnecting=3]="Reconnecting"}(Va||(Va={}));const Wa={transportPolicy:"preferUdp",simulcast:!1,reconnectTimes:3,requestTimeout:5e3};class za extends C{constructor(e=Wa){super(),this.profiles=new Map,this._trackInfo=[],this.recorder=new ya,this.volumeIndicatorHistory=[],this.subscribeTracks=[],this._users=new Map,this._roomState=Va.Idle,this.mergeJobMerger={},this.defaultMergeJobTracks=[],this.mergeJobTracks={},this.forwardJobTracks={},this._mode=ga.RTC,this._role=va.AUDIENCE,this._privileges=["subscribe","publish"],this._publish=((e,t)=>new Promise(async(r,n)=>{if(this.roomState!==Va.Connected)return void n(Zr("not connected to the room, please run joinRoom first"));if(0===e.length&&r(),this._mode===ga.LIVE&&this._role===va.AUDIENCE)return void n(Zr("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(Zr("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(hn())})}try{await i.sendTracks(o),a.sendWsMsg("mute-tracks",{tracks:o.map(e=>({trackid:e.trackID,muted:!!e.track.info.muted}))});const t=En(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 Qr)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!==Va.Connected)return void a(Zr("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(Tn(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 _a(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(hn())})}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}})}),Wr.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 yn();case 10062:throw c.resetRecvHandler(),Tn(10062,n.error);default:throw Tn(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));E(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 Da(r,i.playerid,"remote")).initAudioManager():n=new gi(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=O.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 Qr))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:E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID)),a(t)}}i(s.map(e=>e.track))})),e=t({},Wa,e),this.config=e,jr.log("config",e),jr.log("version",Nr),jr.log("browser report",w,b)}get users(){return Array.from(this._users.values())}get trackInfoList(){return this._trackInfo.map(Ti)}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),Wr.addEvent("RoomStateChanged",{room_state:e}))}_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||Wa.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===O.Connect).map(e=>e.track):[]}get subscribedTracks(){return this.subscribeTracks.filter(e=>e.connectStatus===O.Connect).map(e=>e.track)}async setClientMode(e){if(this.roomState!==Va.Idle)throw Zr("can not setClientMode, room state is not idle");this._mode=e,this._setPrivileges()}_setPrivileges(){this._mode===ga.RTC||this._mode===ga.LIVE&&this._role===va.BROADCASTER?this._privileges=["subscribe","publish"]:this._privileges=["subscribe"]}async setClientRole(e){if(this._mode===ga.RTC)throw Zr("client role can only be set in client mode LIVE.");if(e===va.AUDIENCE&&this.publishedTracks.length>0&&e===va.AUDIENCE)throw Zr("cannot change to audience, please unpublish all tracks first.");if(this._role=e,this._setPrivileges(),this.roomState!==Va.Connected)return;const t=await this.signaling.request("set-privileges",{privileges:this._privileges});if(Wr.addEvent("SetClientRole",{result_code:t.code,user_role:e===va.BROADCASTER?0:1,audience_latency_level:0}),0!==t.code)throw Sn(t.code,t.error)}async joinRoomWithToken(e,t){const r=Date.now();if(Wr.addEvent("JoinRoom",{room_token:e,user_data:t}),this.roomState!==Va.Idle)throw Zr("roomState is not idle! Do not repeat join room, please run leaveRoom first");this.roomState=Va.Connecting;try{this.roomToken=e,this.userData=t;const n=Cn(e);if(this.userID=n.userId,this.roomName=n.roomName,this.appId=n.appId,Wr.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_-]{3,64}$/))throw this.roomState=Va.Idle,Zr("invalid roomname. roomname must match /^[a-zA-Z0-9_-]{3,64}$/");if(!this.userID.match(/^[a-zA-Z0-9_-]{3,50}$/))throw this.roomState=Va.Idle,Zr("invalid userID. userID must match /^[a-zA-Z0-9_-]{3,50}$/");try{const t=await Vi(n,e,this.config.requestTimeout);this.accessToken=t.accessToken,Wr.setSessionId(t.sessionId),Wr.setUserBase(this.userID,this.roomName,this.appId)}catch(e){throw e}const i=await this.joinRoomWithAccess(this.accessToken);return Wr.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:""}),this._mode===ga.LIVE&&await this.setClientRole(this._role),i}catch(e){const t=e;throw this.roomState=Va.Idle,jr.debug("joinRoomWithToken fail: "+t.message),Wr.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||""}),t}}async joinRoomWithAccess(e){const t=wn(e),{capsdp:r}=await async function(){let e=ii(),{isH264:t,sdp:r}=await Ni(e),n=5;for(;!t&&n>0;)e.close(),e=ii(),({isH264:t,sdp:r}=await Ni(e)),n--;w.needH264FmtpLine&&(r+=`a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f${Oi}`);const i={capsdp:r=ji(r=Hi(r)),agent:navigator.userAgent};return e.close(),i}();if(this._roomState===Va.Idle)throw Zr("roomState is idle, maybe because you left the room.");const n=new Qi(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 zi.CONNECTING:this.roomState===Va.Connected?this.roomState=Va.Reconnecting:this.roomState!==Va.Reconnecting&&(this.roomState=Va.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;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-pubpc-restart-notify",event_description:e.error}),t&&w.supportRestartICE&&t.restartSendICE(e.pcid).catch(jr.debug)}).on("on-subpc-restart-notify",e=>{const t=this.connectionTransport;Wr.addEvent("AbnormalDisconnect",{event_reason:"on-subpc-restart-notify",event_description:e.error}),t&&w.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)qa(o,t).then(t=>{r.push(t),t.status&&(i({ws:t.ws,url:t.url}),n=!0),Wr.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}),r.length!==e.length||n||a($r("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 xn(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!==Va.Connected)throw Zr("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 Zr("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=En(this.users,"userID",this.userID);n&&(n.removeTracksByTrackId(e),n.removePublishedTrackInfo(e)),this.cleanTrackIdsFromMergeJobs(e)}async createMergeJob(e,r){if(this.roomState!==Va.Connected)throw Zr("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(Wr.addEvent("CreateMergeJob",{signal_take_time:Date.now()-i,id:e,result_code:a.code}),0!==a.code)throw mn(a.code,a.error);this.mergeJobTracks[e]?jr.warning("merge job id already exist",e):this.mergeJobTracks[e]=[]}async createForwardJob(e){if(this.roomState!==Va.Connected)throw Zr("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 Zr("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(Wr.addEvent("CreateForwardJob",{signal_take_time:Date.now()-a,id:e.jobId,result_code:o.code}),0!==o.code)throw gn(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!==Va.Connected)throw Zr("can not stopForwardJob, room state is not connected");if(e&&!this.forwardJobTracks[e])throw Zr(`no forward job id ${e}`);Wr.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 Zi(e,t,n,r):this.merger=new Zi(e,t,n,r)}_stopMerge(e){if(this.roomState!==Va.Connected)throw Zr("can not addMergeTracks, room state is not connected");if(e&&!this.mergeJobTracks[e])throw ln(e);Wr.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!==Va.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e));const i=await this.signaling.request("update-merge-tracks",n);if(Wr.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 Sn(i.code,i.error)}async _removeMergeTracks(e,t){if(this.roomState!==Va.Connected)throw Zr("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),E(t?this.mergeJobTracks[t]:this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));const n=await this.signaling.request("update-merge-tracks",r);if(Wr.addEvent("UpdateMergeTracks",{id:t||"",remove:r.remove.map(e=>({track_id:e.trackid})),result_code:n.code}),0!==n.code)throw Sn(n.code,n.error)}async updateMergeTracks(e,t){if(this.roomState!==Va.Connected)throw Zr("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]=Ai(this.mergeJobTracks[t],e=>e)):(this.defaultMergeJobTracks=this.defaultMergeJobTracks.concat(e.map(e=>e.trackID)),this.defaultMergeJobTracks=Ai(this.defaultMergeJobTracks,e=>e)),Wr.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!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");const r=this.subscribeTracks.filter(t=>-1!==e.indexOf(t.trackID));jr.debug("unsubscribe",r),0!==r.length&&(Wr.addEvent("UnSubscribeTracks",{tracks:e.map(e=>({track_id:e}))}),this.signaling.request("unsub-tracks",{tracks:r.map(e=>({trackid:e.trackID}))}),t||(r.forEach(e=>e.release()),E(this.subscribeTracks,t=>-1!==e.indexOf(t.trackID))),await this.connectionTransport.removeConsumers(r.map(e=>e.consumer)))}_muteTracks(e){if(this.roomState!==Va.Connected)throw Zr("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])}),Wr.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!==Va.Connected)throw Zr("room state is not connected, can not send message");const n=r||Dn(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!==Va.Connected)throw Zr("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 Zr(`track not exist: ${e}`);return this.connectionTransport.sendHandler.replaceTrack(r,t)}async pushCameraTrackWithImage(e,t){if(this.roomState!==Va.Connected)throw Zr("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 Zr(`track not exist: ${e}`);if("video"!==r.track.info.kind)throw Zr(`track kind is not video: ${e}`);return r.track.imageStreamTrack||(r.track.imageStreamTrack=new Sa),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!==Va.Idle?(jr.log("leave room"),Wr.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!==Va.Connected)throw Zr("can not connected to the room, please run joinRoom first");const r=Date.now(),n=await this.signaling.request("control",{command:e,playerid:t});if("kickplayer"===e&&Wr.addEvent("KickoutUser",{signal_take_time:Date.now()-r,user_id:t,result_code:n.code}),n.error)throw bn(n.code,n.error)}handlePlayerOut(e){const t=this._users.get(e.playerid);if(t){this._users.delete(e.playerid),E(this._trackInfo,t=>t.playerid===e.playerid),E(this.subscribeTracks,e=>e.track.userID===t.userID).forEach(e=>e.release()),In(()=>{jr.debug("user-leave",t),this.emit("user-leave",t)})}}handlePlayerIn(e){const t=yi(e);this._users.set(t.userID,t),In(()=>{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=En(this.users,"userID",t.playerid);if(e)if(e.published&&!r.has(e.userID)&&"stream"===this.sessionMode){const r=e.publishedTrackInfo.map(e=>bi(e,!0));this.handleRemoveTracks({tracks:r}),r.push(t),this.handleAddTracks({tracks:r})}else this._trackInfo.push(t),e.addPublishedTrackInfo([Ti(t)]),r.add(e.userID)}if("stream"===this.sessionMode)for(const e of Array.from(r))In(()=>{jr.debug("user-publish",this._users.get(e)),this.emit("user-publish",this._users.get(e))});In(()=>{jr.debug("track-add",e.map(Ti)),this.emit("track-add",e.map(Ti))})}handleRemoveTracks({tracks:e}){jr.log("receive track-remove",e,t({},this._trackInfo));const r=E(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=E(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=>bi(e,!0));this.handleRemoveTracks({tracks:e}),this.handleAddTracks({tracks:e})}else In(()=>{jr.debug("user-unpublish",t),this.emit("user-unpublish",t)})}In(()=>{jr.debug("track-remove",r.map(Ti)),this.emit("track-remove",r.map(Ti))})}handleMute({tracks:e}){for(const t of e){const e=t.trackid,r=t.muted,n=En(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)})}In(()=>{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(vi))}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)}}),Ua.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)&&Wr.addEvent("AbnormalDisconnect",{event_reason:"websocket_error",event_description:e.error}),Wr.addEvent("LeaveRoom",{leave_reason_code:e.code}),10052===e.code&&this.roomToken)return this.roomState=Va.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=Cn(this.roomToken),t=await Vi(e,this.roomToken,this.config.requestTimeout);Wr.setSessionId(t.sessionId),this.accessToken=t.accessToken;const r=wn(t.accessToken);if(!this.signaling)throw Zr("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===Va.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=Va.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=yi(t),r=this._trackInfo.filter(t=>t.playerid===e.userID);e.addPublishedTrackInfo(r.map(Ti)),this._users.set(e.userID,e)}}if(this.connectionTransport){const t=this.connectionTransport.publishTracks.filter(e=>e.connectStatus===O.Connecting),r=this.subscribeTracks.filter(e=>e.connectStatus===O.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 Fa(e,t,this,this.config.simulcast);return r.on("@needpubpc",(e,r,n,i)=>{t.request("pubpc",{sdp:e,tracks:r.map(Si),policy:this.config.transportPolicy}).then(e=>{switch(e.code){case 0:return void n(e);case 10052:throw yn();default:throw Zr(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 yn();default:throw Zr(e.error)}}).catch(n)}).on("@needresub",()=>{const e=this.subscribeTracks.map(e=>e.trackID);this.subscribeTracks.forEach(e=>e.connectStatus=O.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){E(this.defaultMergeJobTracks,t=>-1!==e.indexOf(t));for(const t in this.mergeJobTracks)E(t,t=>-1!==e.indexOf(t))}CreateMergerSessionController(){const e=new Ji,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(Ti),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),Wr.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=Va.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=ga.RTC,this._role=va.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!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ga.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===va.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Wi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async updateMediaRelay(e){if(this.roomState!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ga.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===va.AUDIENCE)throw dn("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=Cn(e.roomToken),r=await Wi(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(Wr.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 Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}async stopMediaRelay(){if(this.roomState!==Va.Connected)throw Zr("no signaling model, please run joinRoomWithToken first");if(this._mode===ga.RTC)throw cn("no permission. only BROADCASTER in LIVE mode has permission to media relay");if(this._role===va.AUDIENCE)throw dn("no permission. only BROADCASTER in LIVE mode has permission to media relay");try{const e=await this.signaling.request("stop-media-relay",{});if(Wr.addEvent("StopMediaRelay",{result_code:e.code}),0!==e.code)throw Sn(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 Qr?e:Zr(e instanceof Error?e.message:String(e))}}}class Xa extends za{constructor(e){super(e),this.isAudioMastered=!1,this.isVideoMastered=!1,this.sessionMode="track",Wr.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(){}}const Ka="fk6fk2rnb",Qa="https://api-demo.qnsdk.com",Ja="/v1",Za=(e,t,r)=>`/rtc/token/app/${r}/room/${e}/user/${t}`;async function $a(){jr.log("start checkSystemRequirements");const e=Date.now();let t=!1,r="";const n=new Xa,i=new Xa,a=await async function(){let e="unknow";try{e=await qr()}catch(e){}return e+"_"+Dn(8)}();let o,s,c,d=-1,u=-1,l=-1,A=-1,h=-1;try{const f=await lo.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 Zr("getLocalTracks failed.");const p=(e,t)=>new Promise((r,n)=>{(async function(e,t){const r=`${Qa}${Ja}${Za(e,t,Ka)}`;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 Qr?JSON.stringify(e):e.message}finally{return n.roomState===Va.Connected&&(await n.unpublish(n.publishedTracks.map(e=>e.info.trackID)),n.leaveRoom()),i.roomState===Va.Connected&&(await i.unpublish(i.publishedTracks.map(e=>e.info.trackID)),i.leaveRoom()),c&&c.release(),s&&s.release(),clearTimeout(void 0),clearInterval(o),Wr.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},!0),{roomName:a,ok:t,reason:r,avgRTT:d,avgPacketLossRate:u,avgVolumnLevel:h,avgAudioBitrate:l,avgVideoBitrate:A}}}class Ya extends Da{constructor(e,t){if(!w.mediaStreamDest)throw Yr("your browser does not support audio buffer input!");const r=new Ia;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=B.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(){this.audioManager.stopAudioSource()}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 eo 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",()=>{E(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 Ya&&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=Wn();if(this._audioTrack){const t=this._audioTrack.getStats();t.length>0&&(e=t[0])}let t=Wn();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 Ya&&this._audioTrack.setLoop(e)}startAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.startAudioSource()}pauseAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.pauseAudioSource()}resumeAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.resumeAudioSource()}stopAudioSource(){this._audioTrack instanceof Ya&&this._audioTrack.stopAudioSource()}getAudioSourceCurrentTime(){return this._audioTrack instanceof Ya?this._audioTrack.getCurrentTime():0}getAudioSourceDuration(){return this._audioTrack instanceof Ya?this._audioTrack.getDuration():0}setAudioSourceCurrentTime(e){if(this._audioTrack instanceof Ya)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 Ya&&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;et.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){}E(this.inputList,e=>e===t)}}release(){for(const e of this.inputList)this.removeAudioSource(e.track);super.release()}}class ro{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 so.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 no 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){if(this.musicTrack)return this.stopMusicMixing(),await this.startMusicMixing(e);if(this.musicTrack=await so.createAudioTrackFromSource(e),this.output.appendAudioSource(this.musicTrack),this.setMusicOption({}),!this.musicTrack.audioManager.audioSource)throw Zr("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()}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(){this.musicTrack&&(this.musicTrack.stopAudioSource(),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 Zr("can not find audio source")}}class io{constructor(){this.volume=1,this.gainNode=Ca.createGain(),this.gainNode.connect(Ca.destination)}addAudioNode(e){e.connect(this.gainNode)}removeAudioNode(e){e.disconnect(this.gainNode)}release(){this.gainNode.disconnect()}}class ao{constructor(e){if(this.playbackEngine=new io,this.sourcePlayebackState=!1,!(e instanceof Da))throw Zr("audio mixing manager: origin track is not audio track");this.outputTrack=new to,this.outputTrack.info=e.info,this.outputTrack.appendAudioSource(e),this.source=e,this.effectManager=new ro(this.outputTrack,this.playbackEngine),this.musicManager=new no(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 oo extends ao{constructor(e){if(!e._audioTrack)throw Zr("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 eo(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 so;!function(e){function t(e,t="anonymous",r,n){const i=document.createElement("audio");i.preload="auto",i.src=e,i.crossOrigin=t;const a=new Ya(i);return n&&a.setKbps(n),a.setInfo({tag:r}),a}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 Ya(e);r&&i.setKbps(r),i.setInfo({tag:t}),n(i)}).catch(a)}),o.readAsArrayBuffer(e)})}function n(e,t,r){const n=new Ya(e);return r&&n.setKbps(r),n.setInfo({tag:t}),n}async function i(e){"suspended"===Ca.state&&await Ca.resume();return await(()=>new Promise((t,r)=>{Ca.decodeAudioData(e,e=>{t(e)},e=>{r(nn(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):t(e,"anonymous",i,a)},e.decodeAudioData=i,e.createAudioMixingManagerFromTrack=function(e){return new ao(e)},e.createAudioMixingManagerFromStream=function(e){return new oo(e)}}(so||(so={}));const co={audio:{enabled:!0},video:{enabled:!0,bitrate:600}};function uo(e,t){"video"===e.kind&&("contentHint"in e?(e.contentHint=t,e.contentHint!==t&&jr.warning("invalid optimizationMode ",t)):jr.warning("optimizationMode not support in this browser"))}const lo=new class extends C{constructor(){super(),this.deviceMap={},w.support&&(this.updateDeivceInfo(),window.setInterval(this.updateDeivceInfo.bind(this),1e3))}async getDeviceInfo(e,t){if(!e){const e={audio:!1,video:!1};switch(t){case"all":e.audio=!0,e.video=!0;break;case"cameras":e.video=!0;break;case"microphones":case"playback":e.audio=!0}try{const t=await navigator.mediaDevices.getUserMedia(e);this.updateDeivceInfo();const r=t.getTracks();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),on(e instanceof Error?e.message:String(e))}let r={types:[],thumbnailSize:{width:150,height:150}};switch(e){case void 0:case ma.ALL:r.types.push("window","screen");break;case ma.SCREEN:r.types.push("screen");break;case ma.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),Zr(`Electron getSources error, ${e instanceof Error?e.message:String(e)}`)}}async createElectronScreenTrack(e={}){let t,r;if(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(rn("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 Zr(`Electron getUserMedia error, ${e instanceof Error?e.message:""}, config: ${JSON.stringify(t)}`)}let n=[];for(const t of r.getTracks())e.optimizationMode&&uo(t,e.optimizationMode),n.push(ki(t,e.tag,e.bitrate));return n}async getLocalTracks(e=co){if(jr.debug("get local tracks",e),I(e)&&M(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(I(e)){if(M(e))throw Zr("can not get mediaStream with video and screen are all enabled");if(!w.screenSharing)throw Yr("your browser can not share screen");const t=e.screen;if(v&&(t.forceChromePlugin||!w.getDisplayMedia)&&!await ui())throw tn("")}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(I(e)&&e.screen){if(w.getDisplayMedia&&!e.screen.forceChromePlugin)return wi({audio:t,video:{displaySurface:_i(e.screen.source),width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}});const r=await li(!1,e.screen);return wi({audio:t,video:r})}return wi({audio:t,video:r})}(e);let r;t.video&&"object"==typeof t.video&&t.video.deviceId&&Wr.addEvent("DeviceChanged",{type:0,desc:t.video.deviceId}),t.audio&&"object"==typeof t.audio&&t.audio.deviceId&&Wr.addEvent("DeviceChanged",{type:1,desc:t.audio.deviceId});try{r=await this.getUserMedia(e,t,!0)}catch(e){throw"NotAllowedError"===e.name?rn(""):e}let n=void 0,i=void 0,a=void 0,o=void 0;P(e)&&(i=e.audio.bitrate,o=e.audio.tag),I(e)&&(n=e.screen.bitrate,a=e.screen.tag,o=e.screen.audioTag),M(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&&uo(t,r)}for(const e of s){let t;t="audio"===e.kind?ki(e,o,i):ki(e,a,n),c.push(t)}if(e.audio&&e.audio.source){const t=await so.createAudioTrackFromSource(e.audio.source,o,i);c.push(t)}return this.updateDeivceInfo(),c}async getLocalStream(e){if(e&&I(e)&&M(e))throw Zr("can not get local stream with video and screen");const t=await this.getLocalTracks(e);return new eo(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(I(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=w.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:Yi.INACTIVE}),Wr.addEvent("audioinput"===e.kind||"audiooutput"===e.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===e.kind?1:0,device_state:0,device_label:e.label,device_id:e.deviceId,device_info:e.label}),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:Yi.ACTIVE}),this.emit("device-add",t),Wr.addEvent("audioinput"===t.kind||"audiooutput"===t.kind?"AudioDeviceInOut":"VideoDeviceInOut",{device_type:"audiooutput"===t.kind?1:0,device_state:1,device_label:t.label,device_id:t.deviceId}),r=!0}}),r&&this.emit("device-update",this.deviceInfo)}};class Ao{constructor(e,t){this.networkQuality=ua.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 ho 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",()=>{Ua.emit("trackEnded",e.mediaTrack.id)}),this._track.on("audioBuffer",t=>{Ua.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 fo extends ho{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,Ua.on("remote-track-stats",e=>{for(let t of e)t.trackID===this.trackID&&(this.uplinkStats.uplinkLostRate=t.packetLossRate,this.uplinkStats.uplinkRTT=t.rtt)}),Ua.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 po extends fo{constructor(e){super(e),this.isMultiProfileEnabled=!1,this.isLowStreamEnabled=!1,this.profile=la.HIGH,e.profiles.length>0&&(this.isMultiProfileEnabled=!0,this.isLowStreamEnabled=!0),Ua.on("sub-profile-changed",(e,t)=>{if(e===this.trackID)switch(t){case"high":this.profile=la.HIGH,this.emit("profile-changed",la.HIGH),this.emit("low-stream-state-changed",!1);break;case"medium":this.profile=la.MEDIUM,this.emit("profile-changed",la.MEDIUM);break;case"low":this.profile=la.LOW,this.emit("profile-changed",la.LOW),this.emit("low-stream-state-changed",!0)}})}setProfile(e){Ua.emit("set-profile",this.trackID,e)}setLowStream(e){if(!this.isLowStreamEnabled)throw Zr("isLowStreamEnabled is false, do not setLowStream on normal track");const t=e?la.LOW:la.HIGH;Ua.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 mo extends fo{constructor(e){super(e),Ua.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 go extends C{constructor(e){super(),this.connectionState=$i.DISCONNECTED,this._localTracks=[],this._remoteTracks=[],this._disconnectedInfo={code:0},this.remoteUsers=[],this.session=new Xa({transportPolicy:e}),this.session.on("user-join",e=>{const t=new Ao(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 mo(e):new po(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&&Ua.emit("mute-tracks",e)}),Ua.on("set-mute-tracks",(e,t)=>{this.session.muteTracks([{trackID:e,muted:t}])}),this.session.on("room-state-change",e=>{switch(e){case Va.Idle:this.connectionState=$i.DISCONNECTED;break;case Va.Connecting:this.connectionState=$i.CONNECTING;break;case Va.Reconnecting:this.connectionState=$i.RECONNECTING;break;case Va.Connected:this.connectionState=this.connectionState===$i.CONNECTING?$i.CONNECTED:$i.RECONNECTED;break;default:jr.warning("Invalid roomState: ",e)}if(this.connectionState===$i.DISCONNECTED){let e;switch(this._disconnectedInfo.code){case 0:e=Aa.LEAVE;break;case 10006:e=Aa.KICKED_OUT;break;default:e=Aa.ERROR}let t={reason:e};if(e===Aa.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,da.STARTED)}),this.session.on("forward-job-disconnected",e=>{this.emit("direct-livestreaming-state-changed",e.jobId,da.STOPPED)}),this.session.on("merge-job-connected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,da.STARTED)}),this.session.on("merge-job-disconnected",e=>{this.emit("transcoding-livestreaming-state-changed",e.jobId,da.STOPPED)}),this.session.on("disconnect",e=>{this._disconnectedInfo=e}),this.session.on("on-sub-profile-changed",e=>{Ua.emit("sub-profile-changed",e.trackid,e.profile)}),this.session.on("volume-indicator",e=>{this.emit("volume-indicator",e)}),Ua.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=ua.UNKNOWN;break;case x.POOR:e.networkQuality=ua.POOR;break;case x.FAIR:e.networkQuality=ua.FAIR;break;case x.GOOD:e.networkQuality=ua.GOOD;break;case x.EXCELLENT:e.networkQuality=ua.EXCELLENT;break;default:jr.warning("unkonw network grade: ",t.networkGrade)}}}),Ua.on("set-profile",(e,t)=>{switch(t){case la.HIGH:this.session.setProfile(e,"high");break;case la.MEDIUM:this.session.setProfile(e,"medium");break;case la.LOW:this.session.setProfile(e,"low")}}),Ua.on("setMediaStreamTrack",(e,t,r,n)=>{this.session.replaceTrack(e,t).then(r).catch(n)})}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;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,this._localTracks.push(e)}async unpublish(e){if(Array.isArray(e)){if(this._localTracks.filter(t=>e.includes(t)).length!==e.length)throw Zr("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 Zr("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(Mn({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,Mn({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=>Mn({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=ua.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=ua.POOR:t.includes(x.FAIR)?e=ua.FAIR:t.includes(x.GOOD)?e=ua.GOOD:t.includes(x.EXCELLENT)?e=ua.EXCELLENT:e}getUserNetworkQuality(e){let t=ua.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 vo extends ho{constructor(e){super(),this.track=e,Ua.on("trackEnded",e=>{this._track&&e===this._track.mediaTrack.id&&this.emit("ended")})}setMuted(e){this._isMuted=e,Ua.emit("set-mute-tracks",this.trackID,e)}destroy(){this.track&&this.track.release()}}class To extends vo{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=la.LOW),t[1]&&(t[1].profile=la.MEDIUM),t[2]&&(t[2].profile=la.HIGH),2==t.length&&t[1].profile===la.MEDIUM&&(t[1].profile=la.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 bo extends To{constructor(e){super(e)}play(e,t={}){return"object"==typeof t&&void 0===t.mirror&&(t.mirror=!0),super.play(e,t)}}class So extends vo{constructor(e){super(e),Ua.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 yo extends C{constructor(e,t){super(),this._mixingManager=e,this.source=t,this._mixingManager.musicManager.on("music-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",sa.PlAYING);case N.PAUSE:return void this.emit("state-changed",sa.PAUSED);case N.END:return void this.emit("state-changed",sa.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.musicManager.setMusicOption({volume:e})}setMixingVolume(e,t){}}class ko extends So{constructor(e){const t=new ao(e);super(t.outputTrack),this._sourceTrack=e,this._mixingManager=t,this.mixerList=[]}createAudioMixer(e){const t=new yo(this._mixingManager,e);return this.mixerList.push(t),t}destroy(){this._mixingManager.release(),this._sourceTrack.release()}}class _o extends To{constructor(e){super(e)}}class wo extends So{constructor(e,t){super(e),this.source=t,e.on("audio-state-change",e=>{switch(e){case N.IDLE:case N.LOADING:return;case N.PLAY:return void this.emit("state-changed",sa.PlAYING);case N.PAUSE:return void this.emit("state-changed",sa.PAUSED);case N.END:return void this.emit("state-changed",sa.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)}}class Co extends So{constructor(e){super(e)}async setMediaStreamTrack(e){return Ua.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}class Eo extends To{constructor(e){super(e)}async setMediaStreamTrack(e){return Ua.safeEmitAsPromise("setMediaStreamTrack",this.trackID,e)}}const Po="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 Mo extends To{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=Po,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=>ba.loadImage(e.source)));this.ctx&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r=0;r"audio"===e.info.kind)[0],r=i.filter(e=>"video"===e.info.kind)[0];if(!t||!r)throw Zr(`createScreenVideoTrack error, audioTrack: ${t}, videoTrack: ${r}`);e&&e.encoderConfig&&"string"!=typeof e.encoderConfig&&e.encoderConfig.lowStreamConfig&&(r.lowStreamConfig=e.encoderConfig.lowStreamConfig);const a=new So(t),o=new _o(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=ra[e.encoderConfig]))throw fn()}else n=t({},na,e.encoderConfig);else n=na;if(r&&r.encoderConfig)if("string"==typeof r.encoderConfig){if(!(i=ea[r.encoderConfig]))throw fn()}else i=t({},ta,r.encoderConfig);else i=ta;const a=await lo.getLocalTracks({audio:Mn({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:Mn({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 Zr(`createMicrophoneAndCameraTracks error, audioTrack: ${o}, videoTrack: ${s}`);r&&r.encoderConfig&&"string"!=typeof r.encoderConfig&&r.encoderConfig.lowStreamConfig&&(s.lowStreamConfig=r.encoderConfig.lowStreamConfig);const c=new ko(o),d=new bo(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=ra[e.encoderConfig]))throw fn()}else r=t({},na,e.encoderConfig);else r=na;const n=await lo.getLocalTracks({audio:Mn({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 wo(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 Yr("get context error, canvas track not supported");let n;if(t.captureStream)n=t.captureStream(15);else{if(!t.mozCaptureStream)throw Yr("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=ki(i,e.tag);return new Mo(a,t,r,e.sources)}static createCustomAudioTrack(e){const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new Co(t)}static createCustomVideoTrack(e){e.optimizationMode&&"contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint=e.optimizationMode);const t=ki(e.mediaStreamTrack,e.tag,e.bitrate);return new Eo(t)}static setTransportPolicy(e){e===fa.FORCE_TCP&&(this._transportPolicy="forceTcp"),e===fa.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(Zr("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(Zr("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(Zr("can not get canvas 2d context"))}}else n(Zr("only support video track"))})}static async getElectronScreenSources(e){return lo.getElectronScreenSources(e)}}return Io._clients=[],Io._transportPolicy="preferUdp",lo.on("device-changed",e=>{switch(e.device.kind){case"audioinput":Io.onMicrophoneChanged&&Io.onMicrophoneChanged(e);break;case"audiooutput":Io.onPlaybackDeviceChanged&&Io.onPlaybackDeviceChanged(e);break;case"videoinput":Io.onCameraChanged&&Io.onCameraChanged(e)}}),Io}); diff --git a/ReleaseNotes/release-note-4.1.3.md b/ReleaseNotes/release-note-4.1.3.md new file mode 100644 index 0000000..8ff3183 --- /dev/null +++ b/ReleaseNotes/release-note-4.1.3.md @@ -0,0 +1,13 @@ +# QNRTCWeb v4.1.3 + +## 简介 +QNRTCWeb 是七牛云推出的一款适用于 Web 平台的实时音视频 SDK,提供了包括音视频通话、静音、发布、订阅多种功能,提供灵活的接口,支持高度定制以及二次开发。 + +## 修复 +- 修复 iOS 上使用合流/单路转推时播放画面旋转问题 + + +## 问题反馈 +当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 `issues` 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 `Labels` 中指明类型为 bug 或者其他。 + +[通过这里查看已有的 issues 和提交 bug](https://github.com/pili-engineering/QNRTC-Web/issues)