text: (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[888],{5126:function(e,t,n){"use strict";function i(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map((function(e){return"'"+e+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function o(e){return!!e&&!!e[P]}function a(e){return!!e&&(function(e){if(!e||"object"!=typeof e)return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===H}(e)||Array.isArray(e)||!!e[K]||!!e.constructor[K]||g(e)||f(e))}function r(e,t,n){void 0===n&&(n=!1),0===s(e)?(n?Object.keys:Q)(e).forEach((function(i){n&&"symbol"==typeof i||t(i,e[i],e)})):e.forEach((function(n,i){return t(i,n,e)}))}function s(e){var t=e[P];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:g(e)?2:f(e)?3:0}function c(e,t){return 2===s(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function l(e,t){return 2===s(e)?e.get(t):e[t]}function u(e,t,n){var i=s(e);2===i?e.set(t,n):3===i?(e.delete(t),e.add(n)):e[t]=n}function d(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function g(e){return Y&&e instanceof Map}function f(e){return L&&e instanceof Set}function h(e){return e.o||e.t}function p(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=_(e);delete t[P];for(var n=Q(t),i=0;i<n.length;i++){var o=n[i],a=t[o];!1===a.writable&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(t[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(Object.getPrototypeOf(e),t)}function C(e,t){return void 0===t&&(t=!1),I(e)||o(e)||!a(e)||(s(e)>1&&(e.set=e.add=e.clear=e.delete=m),Object.freeze(e),t&&r(e,(function(e,t){return C(t,!0)}),!0)),e}function m(){i(2)}function I(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function y(e){var t=z[e];return t||i(18,e),t}function b(e,t){z[e]||(z[e]=t)}function v(){return x}function A(e,t){t&&(y("Patches"),e.u=[],e.s=[],e.v=t)}function S(e){w(e),e.p.forEach(k),e.p=null}function w(e){e===x&&(x=e.l)}function Z(e){return x={p:[],l:x,h:e,m:!0,_:0}}function k(e){var t=e[P];0===t.i||1===t.i?t.j():t.O=!0}function V(e,t){t._=t.p.length;var n=t.p[0],o=void 0!==e&&e!==n;return t.h.g||y("ES5").S(t,e,o),o?(n[P].P&&(S(t),i(4)),a(e)&&(e=R(t,e),t.l||W(t,e)),t.u&&y("Patches").M(n[P],e,t.u,t.s)):e=R(t,n,[]),S(t),t.u&&t.v(t.u,t.s),e!==J?e:void 0}function R(e,t,n){if(I(t))return t;var i=t[P];if(!i)return r(t,(function(o,a){return T(e,i,t,o,a,n)}),!0),t;if(i.A!==e)return t;if(!i.P)return W(e,i.t,!0),i.t;if(!i.I){i.I=!0,i.A._--;var o=4===i.i||5===i.i?i.o=p(i.k):i.o;r(3===i.i?new Set(o):o,(function(t,a){return T(e,i,o,t,a,n)})),W(e,o,!1),n&&e.u&&y("Patches").R(i,n,e.u,e.s)}return i.o}function T(e,t,n,i,r,s){if(o(r)){var l=R(e,r,s&&t&&3!==t.i&&!c(t.D,i)?s.concat(i):void 0);if(u(n,i,l),!o(l))return;e.m=!1}if(a(r)&&!I(r)){if(!e.h.F&&e._<1)return;R(e,r),t&&t.A.l||W(e,r)}}function W(e,t,n){void 0===n&&(n=!1),e.h.F&&e.m&&C(t,n)}function G(e,t){var n=e[P];return(n?h(n):e)[t]}function O(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var i=Object.getOwnPropertyDescriptor(n,t);if(i)return i;n=Object.getPrototypeOf(n)}}function E(e){e.P||(e.P=!0,e.l&&E(e.l))}function N(e){e.o||(e.o=p(e.t))}function M(e,t,n){var i=g(t)?y("MapSet").N(t,n):f(t)?y("MapSet").T(t,n):e.g?function(e,t){var n=Array.isArray(e),i={i:n?1:0,A:t?t.A:v(),P:!1,I:!1,D:{},l:t,t:e,k:null,o:null,j:null,C:!1},o=i,a=$;n&&(o=[i],a=q);var r=Proxy.revocable(o,a),s=r.revoke,c=r.proxy;return i.k=c,i.j=s,c}(t,n):y("ES5").J(t,n);return(n?n.A:v()).p.push(i),i}function D(e){return o(e)||i(22,e),function e(t){if(!a(t))return t;var n,i=t[P],o=s(t);if(i){if(!i.P&&(i.i<4||!y("ES5").K(i)))return i.t;i.I=!0,n=B(t,o),i.I=!1}else n=B(t,o);return r(n,(function(t,o){i&&l(i.t,t)===o||u(n,t,e(o))})),3===o?new Set(n):n}(e)}function B(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return p(e)}function X(){function e(e,t){var n=a[e];return n?n.enumerable=t:a[e]=n={configurable:!0,enumerable:t,get:function(){var t=this[P];return $.get(t,e)},set:function(t){var n=this[P];$.set(n,e,t)}},n}function t(e){for(var t=e.length-1;t>=0;t--){var o=e[t][P];if(!o.P)switch(o.i){case 5:i(o)&&E(o);break;case 4:n(o)&&E(o)}}}function n(e){for(var t=e.t,n=e.k,i=Q(n),o=i.length-1;o>=0;o--){var a=i[o];if(a!==P){var r=t[a];if(void 0===r&&!c(t,a))return!0;var s=n[a],l=s&&s[P];if(l?l.t!==r:!d(s,r))return!0}}var u=!!t[P];return i.length!==Q(t).length+(u?0:1)}function i(e){var t=e.k;if(t.length!==e.t.length)return!0;var n=Object.getOwnPropertyDescriptor(t,t.length-1);return!(!n||n.get)}var a={};b("ES5",{J:function(t,n){var i=Array.isArray(t),o=function(t,n){if(t){for(var i=Array(n.length),o=0;o<n.length;o++)Object.defineProperty(i,""+o,e(o,!0));return i}var a=_(n);delete a[P];for(var r=Q(a),s=0;s<r.length;s++){var c=r[s];a[c]=e(c,t||!!a[c].enumerable)}return Object.create(Object.getPrototypeOf(n),a)}(i,t),a={i:i?5:4,A:n?n.A:v(),P:!1,I:!1,D:{},l:n,t:t,k:o,o:null,O:!1,C:!1};return Object.defineProperty(o,P,{value:a,writable:!0}),o},S:function(e,n,a){a?o(n)&&n[P].A===e&&t(e.p):(e.u&&function e(t){if(t&&"object"==typeof t){var n=t[P];if(n){var o=n.t,a=n.k,s=n.D,l=n.i;if(4===l)r(a,(function(t){t!==P&&(void 0!==o[t]||c(o,t)?s[t]||e(a[t]):(s[t]=!0,E(n)))})),r(o,(function(e){void 0!==a[e]||c(a,e)||(s[e]=!1,E(n))}));else if(5===l){if(i(n)&&(E(n),s.length=!0),a.length<o.length)for(var u=a.length;u<o.length;u++)s[u]=!1;else for(var d=o.length;d<a.length;d++)s[d]=!0;for(var g=Math.min(a.length,o.length),f=0;f<g;f++)void 0===s[f]&&e(a[f])}}}}(e.p[0]),t(e.p))},K:function(e){return 4===e.i?n(e):i(e)}})}n.d(t,{xC:function(){return Ee},oM:function(){return De}});var F,x,j="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),Y="undefined"!=typeof Map,L="undefined"!=typeof Set,U="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,J=j?Symbol.for("immer-nothing"):((F={})["immer-nothing"]=!0,F),K=j?Symbol.for("immer-draftable"):"__$immer_draftable",P=j?Symbol.for("immer-state"):"__$immer_state",H=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),Q="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,_=Object.getOwnPropertyDescriptors||function(e){var t={};return Q(e).forEach((function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)})),t},z={},$={get:function(e,t){if(t===P)return e;var n=h(e);if(!c(n,t))return function(e,t,n){var i,o=O(t,n);return o?"value"in o?o.value:null===(i=o.get)||void 0===i?void 0:i.call(e.k):void 0}(e,n,t);var i=n[t];return e.I||!a(i)?i:i===G(e.t,t)?(N(e),e.o[t]=M(e.A.h,i,e)):i},has:function(e,t){return t in h(e)},ownKeys:function(e){return Reflect.ownKeys(h(e))},set:function(e,t,n){var i=O(h(e),t);if(null==i?void 0:i.set)return i.set.call(e.k,n),!0;if(!e.P){var o=G(h(e),t),a=null==o?void 0:o[P];if(a&&a.t===n)return e.o[t]=n,e.D[t]=!1,!0;if(d(n,o)&&(void 0!==n||c(e.t,t)))return!0;N(e),E(e)}return e.o[t]===n&&"number"!=typeof n&&(void 0!==n||t in e.o)||(e.o[t]=n,e.D[t]=!0,!0)},deleteProperty:function(e,t){return void 0!==G(e.t,t)||t in e.t?(e.D[t]=!1,N(e),E(e)):delete e.D[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=h(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:i.enumerable,value:n[t]}:i},defineProperty:function(){i(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){i(12)}},q={};r($,(function(e,t){q[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),q.deleteProperty=function(e,t){return $.deleteProperty.call(this,e[0],t)},q.set=function(e,t,n){return $.set.call(this,e[0],t,n,e[0])};var ee=new(function(){function e(e){var t=this;this.g=U,this.F=!0,this.produce=function(e,n,o){if("function"==typeof e&&"function"!=typeof n){var r=n;n=e;var s=t;return function(e){var t=this;void 0===e&&(e=r);for(var i=arguments.length,o=Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return s.produce(e,(function(e){var i;return(i=n).call.apply(i,[t,e].concat(o))}))}}var c;if("function"!=typeof n&&i(6),void 0!==o&&"function"!=typeof o&&i(7),a(e)){var l=Z(t),u=M(t,e,void 0),d=!0;try{c=n(u),d=!1}finally{d?S(l):w(l)}return"undefined"!=typeof Promise&&c instanceof Promise?c.then((function(e){return A(l,o),V(e,l)}),(function(e){throw S(l),e})):(A(l,o),V(c,l))}if(!e||"object"!=typeof e){if((c=n(e))===J)return;return void 0===c&&(c=e),t.F&&C(c,!0),c}i(21,e)},this.produceWithPatches=function(e,n){return"function"==typeof e?function(n){for(var i=arguments.length,o=Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return t.produceWithPatches(n,(function(t){return e.apply(void 0,[t].concat(o))}))}:[t.produce(e,n,(function(e,t){i=e,o=t})),i,o];var i,o},"boolean"==typeof(null==e?void 0:e.useProxies)&&this.setUseProxies(e.useProxies),"boolean"==typeof(null==e?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze)}var t=e.prototype;return t.createDraft=function(e){a(e)||i(8),o(e)&&(e=D(e));var t=Z(this),n=M(this,e,void 0);return n[P].C=!0,w(t),n},t.finishDraft=function(e,t){var n=(e&&e[P]).A;return A(n,t),V(void 0,n)},t.setAutoFreeze=function(e){this.F=e},t.setUseProxies=function(e){e&&!U&&i(20),this.g=e},t.applyPatches=function(e,t){var n;for(n=t.length-1;n>=0;n--){var i=t[n];if(0===i.path.length&&"replace"===i.op){e=i.value;break}}var a=y("Patches").$;return o(e)?a(e,t):this.produce(e,(function(e){return a(e,t.slice(n+1))}))},e}()),te=ee.produce,ne=(ee.produceWithPatches.bind(ee),ee.setAutoFreeze.bind(ee),ee.setUseProxies.bind(ee),ee.applyPatches.bind(ee),ee.createDraft.bind(ee),ee.finishDraft.bind(ee),te);function ie(e,t){return e===t}function oe(e,t,n){if(null===t||null===n||t.length!==n.length)return!1;for(var i=t.length,o=0;o<i;o++)if(!e(t[o],n[o]))return!1;return!0}function ae(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"===typeof e}))){var n=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+n+"]")}return t}!function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i]}((function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ie,n=null,i=null;return function(){return oe(t,n,arguments)||(i=e.apply(null,arguments)),n=arguments,i}}));function re(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function se(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?se(Object(n),!0).forEach((function(t){re(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):se(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function le(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var ue="function"===typeof Symbol&&Symbol.observable||"@@observable",de=function(){return Math.random().toString(36).substring(7).split("").join(".")},ge={INIT:"@@redux/INIT"+de(),REPLACE:"@@redux/REPLACE"+de(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+de()}};function fe(e){if("object"!==typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function he(e,t,n){var i;if("function"===typeof t&&"function"===typeof n||"function"===typeof n&&"function"===typeof arguments[3])throw new Error(le(0));if("function"===typeof t&&"undefined"===typeof n&&(n=t,t=void 0),"undefined"!==typeof n){if("function"!==typeof n)throw new Error(le(1));return n(he)(e,t)}if("function"!==typeof e)throw new Error(le(2));var o=e,a=t,r=[],s=r,c=!1;function l(){s===r&&(s=r.slice())}function u(){if(c)throw new Error(le(3));return a}function d(e){if("function"!==typeof e)throw new Error(le(4));if(c)throw new Error(le(5));var t=!0;return l(),s.push(e),function(){if(t){if(c)throw new Error(le(6));t=!1,l();var n=s.indexOf(e);s.splice(n,1),r=null}}}function g(e){if(!fe(e))throw new Error(le(7));if("undefined"===typeof e.type)throw new Error(le(8));if(c)throw new Error(le(9));try{c=!0,a=o(a,e)}finally{c=!1}for(var t=r=s,n=0;n<t.length;n++){(0,t[n])()}return e}function f(e){if("function"!==typeof e)throw new Error(le(10));o=e,g({type:ge.REPLACE})}function h(){var e,t=d;return(e={subscribe:function(e){if("object"!==typeof e||null===e)throw new Error(le(11));function n(){e.next&&e.next(u())}return n(),{unsubscribe:t(n)}}})[ue]=function(){return this},e}return g({type:ge.INIT}),(i={dispatch:g,subscribe:d,getState:u,replaceReducer:f})[ue]=h,i}function pe(e){for(var t=Object.keys(e),n={},i=0;i<t.length;i++){var o=t[i];0,"function"===typeof e[o]&&(n[o]=e[o])}var a,r=Object.keys(n);try{!function(e){Object.keys(e).forEach((function(t){var n=e[t];if("undefined"===typeof n(void 0,{type:ge.INIT}))throw new Error(le(12));if("undefined"===typeof n(void 0,{type:ge.PROBE_UNKNOWN_ACTION()}))throw new Error(le(13))}))}(n)}catch(s){a=s}return function(e,t){if(void 0===e&&(e={}),a)throw a;for(var i=!1,o={},s=0;s<r.length;s++){var c=r[s],l=n[c],u=e[c],d=l(u,t);if("undefined"===typeof d){t&&t.type;throw new Error(le(14))}o[c]=d,i=i||d!==u}return(i=i||r.length!==Object.keys(e).length)?o:e}}function Ce(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}function me(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),i=function(){throw new Error(le(15))},o={getState:n.getState,dispatch:function(){return i.apply(void 0,arguments)}},a=t.map((function(e){return e(o)}));return i=Ce.apply(void 0,a)(n.dispatch),ce(ce({},n),{},{dispatch:i})}}}function Ie(e){return function(t){var n=t.dispatch,i=t.getState;return function(t){return function(o){return"function"===typeof o?o(n,i,e):t(o)}}}}var ye=Ie();ye.withExtraArgument=Ie;var be=ye,ve=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){if("function"!==typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Ae=function(e,t){for(var n=0,i=t.length,o=e.length;n<i;n++,o++)e[o]=t[n];return e},Se=Object.defineProperty,we=(Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols),Ze=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable,Ve=function(e,t,n){return t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},Re=function(e,t){for(var n in t||(t={}))Ze.call(t,n)&&Ve(e,n,t[n]);if(we)for(var i=0,o=we(t);i<o.length;i++){n=o[i];ke.call(t,n)&&Ve(e,n,t[n])}return e},Te="undefined"!==typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"===typeof arguments[0]?Ce:Ce.apply(null,arguments)};"undefined"!==typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function We(e){if("object"!==typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var Ge=function(e){function t(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=e.apply(this,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return ve(t,e),Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.prototype.concat.apply(this,t)},t.prototype.prepend=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return 1===e.length&&Array.isArray(e[0])?new(t.bind.apply(t,Ae([void 0],e[0].concat(this)))):new(t.bind.apply(t,Ae([void 0],e.concat(this))))},t}(Array);function Oe(){return function(e){return function(e){void 0===e&&(e={});var t=e.thunk,n=void 0===t||t,i=(e.immutableCheck,e.serializableCheck,new Ge);n&&(!function(e){return"boolean"===typeof e}(n)?i.push(be.withExtraArgument(n.extraArgument)):i.push(be));0;return i}(e)}}function Ee(e){var t,n=Oe(),i=e||{},o=i.reducer,a=void 0===o?void 0:o,r=i.middleware,s=void 0===r?n():r,c=i.devTools,l=void 0===c||c,u=i.preloadedState,d=void 0===u?void 0:u,g=i.enhancers,f=void 0===g?void 0:g;if("function"===typeof a)t=a;else{if(!We(a))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');t=pe(a)}var h=s;"function"===typeof h&&(h=h(n));var p=me.apply(void 0,h),C=Ce;l&&(C=Te(Re({trace:!1},"object"===typeof l&&l)));var m=[p];return Array.isArray(f)?m=Ae([p],f):"function"===typeof f&&(m=f(m)),he(t,d,C.apply(void 0,m))}function Ne(e,t){function n(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(t){var o=t.apply(void 0,n);if(!o)throw new Error("prepareAction did not return an object");return Re(Re({type:e,payload:o.payload},"meta"in o&&{meta:o.meta}),"error"in o&&{error:o.error})}return{type:e,payload:n[0]}}return n.toString=function(){return""+e},n.type=e,n.match=function(t){return t.type===e},n}function Me(e){var t,n={},i=[],o={addCase:function(e,t){var i="string"===typeof e?e:e.type;if(i in n)throw new Error("addCase cannot be called with two reducers for the same action type");return n[i]=t,o},addMatcher:function(e,t){return i.push({matcher:e,reducer:t}),o},addDefaultCase:function(e){return t=e,o}};return e(o),[n,i,t]}function De(e){var t=e.name,n=e.initialState;if(!t)throw new Error("`name` is a required option for createSlice");var i=e.reducers||{},r="function"===typeof e.extraReducers?Me(e.extraReducers):[e.extraReducers],s=r[0],c=void 0===s?{}:s,l=r[1],u=void 0===l?[]:l,d=r[2],g=void 0===d?void 0:d,f=Object.keys(i),h={},p={},C={};f.forEach((function(e){var n,o,a=i[e],r=t+"/"+e;"reducer"in a?(n=a.reducer,o=a.prepare):n=a,h[e]=n,p[r]=n,C[e]=o?Ne(r,o):Ne(r)}));var m=function(e,t,n,i){void 0===n&&(n=[]);var r="function"===typeof t?Me(t):[t,n,i],s=r[0],c=r[1],l=r[2],u=ne(e,(function(){}));return function(e,t){void 0===e&&(e=u);var n=Ae([s[t.type]],c.filter((function(e){return(0,e.matcher)(t)})).map((function(e){return e.reducer})));return 0===n.filter((function(e){return!!e})).length&&(n=[l]),n.reduce((function(e,n){if(n){var i;if(o(e))return"undefined"===typeof(i=n(e,t))?e:i;if(a(e))return ne(e,(function(e){return n(e,t)}));if("undefined"===typeof(i=n(e,t))){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return i}return e}),e)}}(n,Re(Re({},c),p),u,g);return{name:t,reducer:m,actions:C,caseReducers:h}}X()},4020:function(e){"use strict";var t="%[a-f0-9]{2}",n=new RegExp(t,"gi"),i=new RegExp("("+t+")+","gi");function o(e,t){try{return decodeURIComponent(e.join(""))}catch(a){}if(1===e.length)return e;t=t||1;var n=e.slice(0,t),i=e.slice(t);return Array.prototype.concat.call([],o(n),o(i))}function a(e){try{return decodeURIComponent(e)}catch(a){for(var t=e.match(n),i=1;i<t.length;i++)t=(e=o(t,i).join("")).match(n);return e}}e.exports=function(e){if("string"!==typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var n={"%FE%FF":"\ufffd\ufffd","%FF%FE":"\ufffd\ufffd"},o=i.exec(e);o;){try{n[o[0]]=decodeURIComponent(o[0])}catch(t){var r=a(o[0]);r!==o[0]&&(n[o[0]]=r)}o=i.exec(e)}n["%C2"]="\ufffd";for(var s=Object.keys(n),c=0;c<s.length;c++){var l=s[c];e=e.replace(new RegExp(l,"g"),n[l])}return e}(e)}}},2806:function(e){"use strict";e.exports=function(e,t){for(var n={},i=Object.keys(e),o=Array.isArray(t),a=0;a<i.length;a++){var r=i[a],s=e[r];(o?-1!==t.indexOf(r):t(r,s,e))&&(n[r]=s)}return n}},8679:function(e,t,n){"use strict";var i=n(9864),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},a={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},r={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function c(e){return i.isMemo(e)?r:s[e.$$typeof]||o}s[i.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[i.Memo]=r;var l=Object.defineProperty,u=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,g=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,i){if("string"!==typeof n){if(h){var o=f(n);o&&o!==h&&e(t,o,i)}var r=u(n);d&&(r=r.concat(d(n)));for(var s=c(t),p=c(n),C=0;C<r.length;++C){var m=r[C];if(!a[m]&&(!i||!i[m])&&(!p||!p[m])&&(!s||!s[m])){var I=g(n,m);try{l(t,m,I)}catch(y){}}}}return t}},8253:function(e,t,n){"use strict";n.d(t,{Yr:function(){return w},Hi:function(){return N},b_:function(){return D},E1:function(){return Z},I6:function(){return Re},i8:function(){return B},du:function(){return X},$p:function(){return F},VY:function(){return x},PQ:function(){return j},mK:function(){return Y},hS:function(){return L},SV:function(){return U},XP:function(){return J},yn:function(){return K},gF:function(){return W},cA:function(){return P},Xk:function(){return H},Ll:function(){return Q},Gc:function(){return _},ew:function(){return z},eU:function(){return $},pD:function(){return q},I$:function(){return ee},c0:function(){return R},LN:function(){return te},lW:function(){return ne},pv:function(){return ie},rY:function(){return ae},Bx:function(){return oe},yq:function(){return re},vq:function(){return se},Nd:function(){return ce},eW:function(){return le},co:function(){return ue},b3:function(){return de},H_:function(){return O},pI:function(){return k},y5:function(){return ge},yC:function(){return fe},vX:function(){return T},fj:function(){return he},Ik:function(){return pe},H6:function(){return Ce},l7:function(){return me},vM:function(){return Ie},CV:function(){return ye},TT:function(){return be},qV:function(){return ve},ge:function(){return Ae},as:function(){return Se},h2:function(){return we},w6:function(){return Ze},lZ:function(){return ke},e_:function(){return Ve},Lb:function(){return V}});var i=n(6311),o=n(266),a=n(809),r=n.n(a),s=n(5126),c=n(4492),l=n(4007),u=n(8052);function d(e,t){var n="undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"===typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,r=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return r=e.done,e},e:function(e){s=!0,a=e},f:function(){try{r||null==n.return||n.return()}finally{if(s)throw a}}}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var f={alertMessages:[],audio:!0,audioBitRate:"",audioCodecType:"",audioContentHint:"",audioInput:"",audioInputDevices:[],audioOutput:"",audioOutputDevices:[],autoGainControl:"",clientId:"",channelId:"sora",googCpuOveruseDetection:null,timelineMessages:[],debug:!1,debugFilterText:"",debugType:"timeline",dataChannelSignaling:"",dataChannelMessaging:"",dataChannelMessages:[],displayResolution:"",displaySettings:{audio:!1,audioBitRate:!1,audioCodecType:!1,audioContentHint:!1,audioConstraints:!1,audioInput:!1,audioOutput:!1,audioTrack:!1,cameraDevice:!1,displayResolution:!1,mediaType:!1,micDevice:!1,simulcastRid:!1,spotlightFocusRid:!1,spotlightNumber:!1,spotlightUnfocusRid:!1,video:!1,videoBitRate:!1,videoCodecType:!1,videoContentHint:!1,videoConstraints:!1,videoInput:!1,videoTrack:!1},e2ee:!1,echoCancellation:"",echoCancellationType:"",enabledClientId:!1,enabledDataChannel:!1,enabledDataChannelMessaging:!1,enabledMetadata:!1,enabledSignalingNotifyMetadata:!1,enabledSignalingUrlCandidates:!1,fakeVolume:"0",fakeContents:{worker:null,colorCode:0,gainNode:null},frameRate:"",soraContents:{connectionStatus:"disconnected",sora:null,connectionId:null,clientId:null,localMediaStream:null,remoteMediaStreams:[],prevStatsReport:[],statsReport:[]},ignoreDisconnectWebSocket:"",logMessages:[],mediaType:"getUserMedia",metadata:"",multistream:!1,mute:!1,noiseSuppression:"",notifyMessages:[],pushMessages:[],resolution:"",showStats:!1,simulcast:!1,spotlight:!1,signalingMessages:[],signalingNotifyMetadata:"",signalingUrlCandidates:[],simulcastRid:"",spotlightNumber:"",spotlightFocusRid:"",spotlightUnfocusRid:"",focusedSpotlightConnectionIds:{},video:!0,videoBitRate:"",videoCodecType:"",videoContentHint:"",videoInput:"",videoInputDevices:[],version:JSON.parse('{"i8":"2021.2.0-canary.20"}').i8,cameraDevice:!0,videoTrack:!0,micDevice:!0,audioTrack:!0,role:"sendonly"},h=(0,s.oM)({name:"soraDevtools",initialState:f,reducers:{resetState:function(e){Object.assign(e,f)},setAudio:function(e,t){e.audio=t.payload},setAudioInput:function(e,t){e.audioInput=t.payload},setAudioOutput:function(e,t){e.audioOutput=t.payload},setAudioBitRate:function(e,t){e.audioBitRate=t.payload},setAudioCodecType:function(e,t){e.audioCodecType=t.payload},setAudioContentHint:function(e,t){if(e.audioContentHint=t.payload,e.soraContents.localMediaStream){var n,i=d(e.soraContents.localMediaStream.getAudioTracks());try{for(i.s();!(n=i.n()).done;){n.value.contentHint=e.audioContentHint}}catch(o){i.e(o)}finally{i.f()}}},setAutoGainControl:function(e,t){e.autoGainControl=t.payload},setClientId:function(e,t){e.clientId=t.payload},setChannelId:function(e,t){e.channelId=t.payload},setTimelineMessage:function(e,t){e.timelineMessages.push(t.payload)},setDataChannelSignaling:function(e,t){e.dataChannelSignaling=t.payload},setDataChannelMessaging:function(e,t){e.dataChannelMessaging=t.payload},setDataChannelMessage:function(e,t){e.dataChannelMessages.push(t.payload)},setGoogCpuOveruseDetection:function(e,t){e.googCpuOveruseDetection=t.payload},setDisplayResolution:function(e,t){e.displayResolution=t.payload},setE2EE:function(e,t){e.e2ee=t.payload},setEchoCancellation:function(e,t){e.echoCancellation=t.payload},setEchoCancellationType:function(e,t){e.echoCancellationType=t.payload},setEnabledClientId:function(e,t){e.enabledClientId=t.payload},setEnabledDataChannelMessaging:function(e,t){e.enabledDataChannelMessaging=t.payload},setEnabledDataChannel:function(e,t){e.enabledDataChannel=t.payload},setEnabledMetadata:function(e,t){e.enabledMetadata=t.payload},setIgnoreDisconnectWebSocket:function(e,t){e.ignoreDisconnectWebSocket=t.payload},setSignalingMessage:function(e,t){e.signalingMessages.push(t.payload)},setEnabledSignalingNotifyMetadata:function(e,t){e.enabledSignalingNotifyMetadata=t.payload},setEnabledSignalingUrlCandidates:function(e,t){e.enabledSignalingUrlCandidates=t.payload},setFakeVolume:function(e,t){var n=parseFloat(t.payload);isNaN(n)?e.fakeVolume="0":e.fakeVolume=1<n?"1":String(n),e.fakeContents.gainNode&&e.fakeContents.gainNode.gain.setValueAtTime(parseFloat(e.fakeVolume),0)},setFakeContentsGainNode:function(e,t){e.fakeContents.gainNode=t.payload},setInitialFakeContents:function(e){e.fakeContents.colorCode=Math.floor(16777215*Math.random());var t=URL.createObjectURL(new Blob([l.lt],{type:"application/javascript"}));e.fakeContents.worker=new Worker(t)},setInitialDisplaySettings:function(e,t){e.displaySettings=t.payload},setFrameRate:function(e,t){e.frameRate=t.payload},setMute:function(e,t){e.mute=t.payload},setNoiseSuppression:function(e,t){e.noiseSuppression=t.payload},setMediaType:function(e,t){e.mediaType=t.payload},setMetadata:function(e,t){e.metadata=t.payload},setResolution:function(e,t){e.resolution=t.payload},setSignalingNotifyMetadata:function(e,t){e.signalingNotifyMetadata=t.payload},setSignalingUrlCandidates:function(e,t){e.signalingUrlCandidates=t.payload},setSimulcastRid:function(e,t){e.simulcastRid=t.payload},setSpotlightNumber:function(e,t){e.spotlightNumber=t.payload},setSpotlightFocusRid:function(e,t){e.spotlightFocusRid=t.payload},setSpotlightUnfocusRid:function(e,t){e.spotlightUnfocusRid=t.payload},setVideo:function(e,t){e.video=t.payload},setVideoInput:function(e,t){e.videoInput=t.payload},setVideoBitRate:function(e,t){e.videoBitRate=t.payload},setVideoCodecType:function(e,t){e.videoCodecType=t.payload},setVideoContentHint:function(e,t){if(e.videoContentHint=t.payload,e.soraContents.localMediaStream){var n,i=d(e.soraContents.localMediaStream.getVideoTracks());try{for(i.s();!(n=i.n()).done;){n.value.contentHint=e.videoContentHint}}catch(o){i.e(o)}finally{i.f()}}},setSora:function(e,t){e.soraContents.sora=t.payload,e.soraContents.sora?(e.soraContents.connectionId=e.soraContents.sora.connectionId,e.soraContents.clientId=e.soraContents.sora.clientId):(e.soraContents.connectionId=null,e.soraContents.clientId=null)},setSoraConnectionStatus:function(e,t){e.soraContents.connectionStatus=t.payload},setLocalMediaStream:function(e,t){e.soraContents.localMediaStream&&e.soraContents.localMediaStream.getTracks().forEach((function(e){e.stop()})),e.soraContents.localMediaStream=t.payload},setRemoteMediaStream:function(e,t){e.soraContents.remoteMediaStreams.push(t.payload)},setStatsReport:function(e,t){e.soraContents.prevStatsReport=e.soraContents.statsReport,e.soraContents.statsReport=t.payload},removeRemoteMediaStream:function(e,t){var n=e.soraContents.remoteMediaStreams.filter((function(e){return e.id!==t.payload}));e.soraContents.remoteMediaStreams=n},removeAllRemoteMediaStreams:function(e){e.soraContents.remoteMediaStreams=[]},setAudioInputDevices:function(e,t){e.audioInputDevices=t.payload},setVideoInputDevices:function(e,t){e.videoInputDevices=t.payload},setAudioOutputDevices:function(e,t){e.audioOutputDevices=t.payload},setSoraInfoAlertMessage:function(e,t){var n={title:"Sora info",type:"info",message:t.payload,timestamp:(new Date).getTime()};p(e.alertMessages,e.logMessages,n)},setSoraErrorAlertMessage:function(e,t){var n={title:"Sora error",type:"error",message:t.payload,timestamp:(new Date).getTime()};p(e.alertMessages,e.logMessages,n)},setAPIInfoAlertMessage:function(e,t){var n={title:"API info",type:"info",message:t.payload,timestamp:(new Date).getTime()};p(e.alertMessages,e.logMessages,n)},setAPIErrorAlertMessage:function(e,t){var n={title:"API error",type:"error",message:t.payload,timestamp:(new Date).getTime()};p(e.alertMessages,e.logMessages,n)},deleteAlertMessage:function(e,t){var n=e.alertMessages.filter((function(e){return e.timestamp!==t.payload}));e.alertMessages=n},setDebug:function(e,t){e.debug=t.payload},setDebugFilterText:function(e,t){e.debugFilterText=t.payload},setDebugType:function(e,t){e.debugFilterText="",e.debugType=t.payload},setLogMessages:function(e,t){e.logMessages.push({timestamp:(new Date).getTime(),message:{title:t.payload.title,description:t.payload.description}})},setNotifyMessages:function(e,t){e.notifyMessages.push(t.payload)},setPushMessages:function(e,t){e.pushMessages.push(t.payload)},setFocusedSpotlightConnectionId:function(e,t){e.focusedSpotlightConnectionIds[t.payload]=!0},setUnFocusedSpotlightConnectionId:function(e,t){e.focusedSpotlightConnectionIds[t.payload]=!1},deleteFocusedSpotlightConnectionId:function(e,t){delete e.focusedSpotlightConnectionIds[t.payload]},setShowStats:function(e,t){e.showStats=t.payload},setCameraDevice:function(e,t){e.cameraDevice=t.payload},setMicDevice:function(e,t){e.micDevice=t.payload},setAudioTrack:function(e,t){if(e.audioTrack=t.payload,e.soraContents.localMediaStream){var n,i=d(e.soraContents.localMediaStream.getAudioTracks());try{for(i.s();!(n=i.n()).done;){n.value.enabled=e.audioTrack}}catch(o){i.e(o)}finally{i.f()}}},setVideoTrack:function(e,t){if(e.videoTrack=t.payload,e.soraContents.localMediaStream){var n,i=d(e.soraContents.localMediaStream.getVideoTracks());try{for(i.s();!(n=i.n()).done;){n.value.enabled=e.videoTrack}}catch(o){i.e(o)}finally{i.f()}}},setRole:function(e,t){e.role=t.payload},setMultistream:function(e,t){e.multistream=t.payload},setSimulcast:function(e,t){e.simulcast=t.payload},setSpotlight:function(e,t){e.spotlight=t.payload}}});function p(e,t,n){if(5<=e.length)for(var i=0;i<=e.length-5;i++)e.pop();e.unshift(n),t.push({timestamp:n.timestamp,message:{title:"ALERT MESSAGE ".concat(n.title),description:JSON.stringify({title:n.title,type:n.type,message:n.message})}})}function C(e,t){return m.apply(this,arguments)}function m(){return(m=(0,o.Z)(r().mark((function e(t,n){var i,o,a,s,c,l,g,f,p,C,m,I,y,b,A,S,w,Z,k,V,R,T,W,G,O,E,N,M;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i="MEDIA_CONSTRAINTS","getDisplayMedia"!==n.mediaType){e.next=16;break}if(n.video&&n.cameraDevice){e.next=4;break}return e.abrupt("return",[new MediaStream,null]);case 4:if(void 0!==navigator.mediaDevices){e.next=6;break}throw new Error("Failed to call getUserMedia. Make sure domain is secure");case 6:return o={video:!0},t(h.actions.setLogMessages({title:i,description:JSON.stringify(o)})),t(h.actions.setTimelineMessage(v("media-constraints",o))),e.next=11,navigator.mediaDevices.getDisplayMedia(o);case 11:a=e.sent,t(h.actions.setTimelineMessage(v("succeed-get-display-media"))),s=d(a.getVideoTracks());try{for(s.s();!(c=s.n()).done;)void 0!==(l=c.value).contentHint&&(l.contentHint=n.videoContentHint),l.enabled=n.videoTrack}catch(r){s.e(r)}finally{s.f()}return e.abrupt("return",[a,null]);case 16:if("fakeMedia"!==n.mediaType||!n.fakeContents.worker){e.next=28;break}g=(0,u._8)({audio:n.audio&&n.micDevice,video:n.video&&n.cameraDevice,frameRate:n.frameRate,resolution:n.resolution,volume:n.fakeVolume}),t(h.actions.setLogMessages({title:i,description:JSON.stringify(g)})),t(h.actions.setTimelineMessage(v("media-constraints",g))),f=(0,u.gU)(g),p=f.canvas,C=f.mediaStream,m=f.gainNode,null!==p&&(n.fakeContents.worker.onmessage=function(e){var t=e.data;"update"===t.type&&(0,u.zW)(p,n.fakeContents.colorCode,g.fontSize,t.counter.toString())},n.fakeContents.worker.postMessage({type:"stop"}),n.fakeContents.worker.postMessage({type:"start",interval:1e3/g.frameRate})),I=d(C.getVideoTracks());try{for(I.s();!(y=I.n()).done;)void 0!==(b=y.value).contentHint&&(b.contentHint=n.videoContentHint),b.enabled=n.videoTrack}catch(r){I.e(r)}finally{I.f()}A=d(C.getAudioTracks());try{for(A.s();!(S=A.n()).done;)void 0!==(w=S.value).contentHint&&(w.contentHint=n.audioContentHint),w.enabled=n.audioTrack}catch(r){A.e(r)}finally{A.f()}return t(h.actions.setTimelineMessage(v("succeed-create-fake-media"))),e.abrupt("return",[C,m]);case 28:if(void 0!==navigator.mediaDevices){e.next=30;break}throw new Error("Failed to call getUserMedia. Make sure domain is secure");case 30:if(Z=new MediaStream,!(k=(0,u.dV)({audio:n.audio&&n.micDevice,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,echoCancellation:n.echoCancellation,echoCancellationType:n.echoCancellationType,audioInput:n.audioInput}))){e.next=40;break}return t(h.actions.setLogMessages({title:i,description:JSON.stringify({audio:k})})),t(h.actions.setTimelineMessage(v("audio-media-constraints",{audio:k}))),e.next=37,navigator.mediaDevices.getUserMedia({audio:k});case 37:V=e.sent,t(h.actions.setTimelineMessage(v("succeed-audio-get-user-media"))),Z.addTrack(V.getAudioTracks()[0]);case 40:if(!(R=(0,u.Tm)({video:n.video&&n.cameraDevice,frameRate:n.frameRate,resolution:n.resolution,videoInput:n.videoInput}))){e.next=49;break}return t(h.actions.setLogMessages({title:i,description:JSON.stringify({video:R})})),t(h.actions.setTimelineMessage(v("video-media-constraints",{video:R}))),e.next=46,navigator.mediaDevices.getUserMedia({video:R});case 46:T=e.sent,t(h.actions.setTimelineMessage(v("succeed-video-get-user-media"))),Z.addTrack(T.getVideoTracks()[0]);case 49:W=d(Z.getVideoTracks());try{for(W.s();!(G=W.n()).done;)void 0!==(O=G.value).contentHint&&(O.contentHint=n.videoContentHint),O.enabled=n.videoTrack}catch(r){W.e(r)}finally{W.f()}E=d(Z.getAudioTracks());try{for(E.s();!(N=E.n()).done;)void 0!==(M=N.value).contentHint&&(M.contentHint=n.audioContentHint),M.enabled=n.audioTrack}catch(r){E.e(r)}finally{E.f()}return e.abrupt("return",[Z,null]);case 54:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function I(e,t,n){n.on("log",(function(t,n){e(h.actions.setLogMessages({title:t,description:JSON.stringify(n)}))})),n.on("notify",(function(t,n){"spotlight.focused"===t.event_type&&"string"===typeof t.connection_id&&e(h.actions.setFocusedSpotlightConnectionId(t.connection_id)),"spotlight.unfocused"===t.event_type&&"string"===typeof t.connection_id&&e(h.actions.setUnFocusedSpotlightConnectionId(t.connection_id)),"connection.destroyed"===t.event_type&&"string"===typeof t.connection_id&&e(h.actions.deleteFocusedSpotlightConnectionId(t.connection_id)),e(h.actions.setNotifyMessages({timestamp:(new Date).getTime(),message:t,transportType:n}))})),n.on("push",(function(t,n){e(h.actions.setPushMessages({timestamp:(new Date).getTime(),message:t,transportType:n}))})),n.on("track",(function(n){e(h.actions.setTimelineMessage(v("event-on-track"))),t().soraContents.remoteMediaStreams.find((function(e){return e.id===n.streams[0].id}))||e(h.actions.setRemoteMediaStream(n.streams[0]))})),n.on("removetrack",(function(n){e(h.actions.setTimelineMessage(v("event-on-removetrack"))),t().soraContents.remoteMediaStreams.find((function(e){if(null!==n&&void 0!==n&&n.target)return e.id===n.target.id}))&&e(h.actions.removeRemoteMediaStream(n.target.id))})),n.on("disconnect",(function(n){var i={type:n.type,title:n.title};void 0!==n.code&&(i.code=n.code),void 0!==n.reason&&(i.reason=n.reason),void 0!==n.params&&(i.params=n.params),e(h.actions.setTimelineMessage(v("event-on-disconnect",i)));var o=t(),a=o.fakeContents,r=o.soraContents,s=r.localMediaStream,c=r.remoteMediaStreams;s&&s.getTracks().forEach((function(e){e.stop()})),c.forEach((function(e){e.getTracks().forEach((function(e){e.stop()}))})),a.worker&&a.worker.postMessage({type:"stop"}),e(h.actions.setSora(null)),e(h.actions.setLocalMediaStream(null)),e(h.actions.removeAllRemoteMediaStreams()),e(h.actions.setSoraInfoAlertMessage("Disconnect Sora.")),e(h.actions.setTimelineMessage(v("disconnected")))})),n.on("timeline",(function(t){var n={timestamp:(new Date).getTime(),type:t.type,data:t.data,dataChannelId:t.dataChannelId,dataChannelLabel:t.dataChannelLabel,logType:t.logType};e(h.actions.setTimelineMessage(n)),t.data&&"object"===typeof t.data&&"sdp"in t.data&&e(h.actions.setTimelineMessage(v("".concat(t.type,"-sdp"),t.data.sdp)))})),n.on("signaling",(function(t){var n={timestamp:(new Date).getTime(),transportType:t.transportType,type:t.type,data:t.data};e(h.actions.setSignalingMessage(n))})),n.on("message",(function(t){e(h.actions.setDataChannelMessage({timestamp:(new Date).getTime(),label:t.label,data:t.data}))}))}function y(e){var t={audio:e.audio,video:e.video};e.audioCodecType&&(t.audioCodecType=e.audioCodecType);var n=parseInt(e.audioBitRate,10);n&&(t.audioBitRate=n),e.videoCodecType&&(t.videoCodecType=e.videoCodecType);var i=parseInt(e.videoBitRate,10);if(i&&(t.videoBitRate=i),e.multistream&&(t.multistream=!0),e.e2ee&&(t.e2ee=!0),e.spotlight&&(t.spotlight=!0,e.spotlightNumber&&(t.spotlightNumber=parseInt(e.spotlightNumber)),!0===t.spotlight&&e.spotlightFocusRid&&(t.spotlightFocusRid=e.spotlightFocusRid),!0===t.spotlight&&e.spotlightUnfocusRid&&(t.spotlightUnfocusRid=e.spotlightUnfocusRid)),e.simulcast&&(t.simulcast=!0,e.simulcastRid&&(t.simulcastRid=e.simulcastRid)),e.enabledSignalingNotifyMetadata&&(t.signalingNotifyMetadata=(0,u.BB)(!0,e.signalingNotifyMetadata)),e.enabledClientId&&(t.clientId=e.clientId),e.enabledDataChannel&&("true"===e.dataChannelSignaling?t.dataChannelSignaling=!0:"false"===e.dataChannelSignaling&&(t.dataChannelSignaling=!1),"true"===e.ignoreDisconnectWebSocket?t.ignoreDisconnectWebSocket=!0:"false"===e.ignoreDisconnectWebSocket&&(t.ignoreDisconnectWebSocket=!1)),""!==e.dataChannelMessaging){var o=[];try{o=JSON.parse(e.dataChannelMessaging)}catch(a){console.warn("Illegal format DataChannelMessaging")}Array.isArray(o)&&(t.dataChannels=o)}return t}function b(e){return{audio:e.audio,audioBitRate:e.audioBitRate,audioCodecType:e.audioCodecType,clientId:e.clientId,dataChannelMessaging:e.enabledDataChannelMessaging?e.dataChannelMessaging:"",dataChannelSignaling:e.dataChannelSignaling,e2ee:e.e2ee,enabledClientId:e.enabledClientId,enabledDataChannel:e.enabledDataChannel,enabledSignalingNotifyMetadata:e.enabledSignalingNotifyMetadata,ignoreDisconnectWebSocket:e.ignoreDisconnectWebSocket,multistream:e.multistream,signalingNotifyMetadata:e.signalingNotifyMetadata,simulcast:e.simulcast,simulcastRid:e.simulcastRid,spotlight:e.spotlight,spotlightFocusRid:e.spotlightFocusRid,spotlightNumber:e.spotlightNumber,spotlightUnfocusRid:e.spotlightUnfocusRid,video:e.video,videoBitRate:e.videoBitRate,videoCodecType:e.videoCodecType}}function v(e,t){return{type:e,logType:"sora-devtools",timestamp:(new Date).getTime(),data:t}}function A(e,t){return S.apply(this,arguments)}function S(){return(S=(0,o.Z)(r().mark((function e(t,n){var i,o,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.pc||"closed"===(null===(i=n.pc)||void 0===i?void 0:i.iceConnectionState)){e.next=7;break}return e.next=3,n.pc.getStats();case 3:o=e.sent,a=[],o.forEach((function(e){a.push(e)})),t(h.actions.setStatsReport(a));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var w=function(){return function(){var e=(0,o.Z)(r().mark((function e(t,n){var a,s,l,d,g,f,p,m,S,w,Z,k,V,R;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t(h.actions.setTimelineMessage(v("start-connection"))),t(h.actions.setSoraConnectionStatus("connecting")),!(a=n()).soraContents.sora){e.next=6;break}return e.next=6,a.soraContents.sora.disconnect();case 6:if(s=(0,u.EO)(a.enabledSignalingUrlCandidates,a.signalingUrlCandidates),t(h.actions.setLogMessages({title:"SIGNALING_URL",description:JSON.stringify(s)})),l=c.Z.connection(s,a.debug),d=b(a),g=y(d),f=(0,u.BB)(a.enabledMetadata,a.metadata),e.prev=12,"sendonly"!==a.role){e.next=28;break}return(p=l.sendonly(a.channelId,null,g)).metadata=f,"boolean"===typeof a.googCpuOveruseDetection&&(p.constraints={optional:[{googCpuOveruseDetection:a.googCpuOveruseDetection}]}),I(t,n,p),e.next=20,C(t,a).catch((function(e){throw t(h.actions.setSoraErrorAlertMessage(e.toString())),t(h.actions.setSoraConnectionStatus("disconnected")),e}));case 20:return w=e.sent,Z=(0,i.Z)(w,2),m=Z[0],S=Z[1],e.next=26,p.connect(m);case 26:e.next=49;break;case 28:if("sendrecv"!==a.role){e.next=43;break}return(p=l.sendrecv(a.channelId,null,g)).metadata=f,"boolean"===typeof a.googCpuOveruseDetection&&(p.constraints={optional:[{googCpuOveruseDetection:a.googCpuOveruseDetection}]}),I(t,n,p),e.next=35,C(t,a).catch((function(e){throw t(h.actions.setSoraErrorAlertMessage(e.toString())),t(h.actions.setSoraConnectionStatus("disconnected")),e}));case 35:return k=e.sent,V=(0,i.Z)(k,2),m=V[0],S=V[1],e.next=41,p.connect(m);case 41:e.next=49;break;case 43:if("recvonly"!==a.role){e.next=49;break}return(p=l.recvonly(a.channelId,null,g)).metadata=f,I(t,n,p),e.next=49,p.connect();case 49:e.next=56;break;case 51:throw e.prev=51,e.t0=e.catch(12),e.t0 instanceof Error&&t(h.actions.setSoraErrorAlertMessage("Failed to connect Sora. ".concat(e.t0.message))),t(h.actions.setSoraConnectionStatus("disconnected")),e.t0;case 56:if(void 0!==p){e.next=58;break}throw new Error("Failed to connect Sora. Connection object is 'undefined'");case 58:return t(h.actions.setSoraInfoAlertMessage("Succeeded to connect Sora.")),e.next=61,A(t,p);case 61:R=setInterval((0,o.Z)(r().mark((function e(){var i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n(),!(o=i.soraContents).sora){e.next=6;break}return e.next=4,A(t,o.sora);case 4:e.next=7;break;case 6:clearInterval(R);case 7:case"end":return e.stop()}}),e)}))),1e3),t(h.actions.setSora(p)),m&&t(h.actions.setLocalMediaStream(m)),S&&t(h.actions.setFakeContentsGainNode(S)),t(h.actions.setSoraConnectionStatus("connected")),t(h.actions.setTimelineMessage(v("connected")));case 67:case"end":return e.stop()}}),e,null,[[12,51]])})));return function(t,n){return e.apply(this,arguments)}}()},Z=function(){return function(){var e=(0,o.Z)(r().mark((function e(t,n){var i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n(),!(o=i.soraContents).sora){e.next=6;break}return t(h.actions.setSoraConnectionStatus("disconnecting")),e.next=5,o.sora.disconnect();case 5:t(h.actions.setSoraConnectionStatus("disconnected"));case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()},k=function(){return function(){var e=(0,o.Z)(r().mark((function e(t,n){var i,o,a,s;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,u.PW)();case 2:i=e.sent,o=[],a=[],s=[],i.forEach((function(e){""!==e.deviceId&&("audioinput"===e.kind?o.push(e.toJSON()):"audiooutput"===e.kind?s.push(e.toJSON()):"videoinput"===e.kind&&a.push(e.toJSON()))})),t(h.actions.setAudioInputDevices(o)),t(h.actions.setVideoInputDevices(a)),t(h.actions.setAudioOutputDevices(s));case 10:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()},V=function(){return function(){var e=(0,o.Z)(r().mark((function e(t,n){var o,a,s,c,l;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((o=n()).soraContents.sora){e.next=3;break}return e.abrupt("return");case 3:return o.soraContents.localMediaStream&&o.soraContents.localMediaStream.getTracks().forEach((function(e){e.stop()})),e.next=6,C(t,o).catch((function(e){throw t(h.actions.setSoraErrorAlertMessage(e.toString())),t(h.actions.setSoraConnectionStatus("disconnected")),e}));case 6:a=e.sent,s=(0,i.Z)(a,2),c=s[0],l=s[1],c.getTracks().forEach((function(e){if(o.soraContents.sora&&o.soraContents.sora.pc){var t=o.soraContents.sora.pc.getSenders().find((function(t){return!!t.track&&t.track.kind===e.kind}));t&&t.replaceTrack(e)}})),t(h.actions.setLocalMediaStream(c)),t(h.actions.setFakeContentsGainNode(l));case 13:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()},R=function(e){return function(){var t=(0,o.Z)(r().mark((function t(n,i){var o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=14;break}o="Faild to execute WebAssembly '".concat("https://sora-e2ee-wasm.shiguredo.jp/2020.2/wasm.wasm","'."),t.next=5;break;case 5:return t.prev=5,t.next=8,c.Z.initE2EE("https://sora-e2ee-wasm.shiguredo.jp/2020.2/wasm.wasm");case 8:t.next=14;break;case 10:return t.prev=10,t.t0=t.catch(5),n(h.actions.setSoraErrorAlertMessage(o)),t.abrupt("return");case 14:n(h.actions.setE2EE(e));case 15:case"end":return t.stop()}}),t,null,[[5,10]])})));return function(e,n){return t.apply(this,arguments)}}()},T=function(e){return function(){var t=(0,o.Z)(r().mark((function t(n,o){var a,s,c,l,u,d;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((a=o()).soraContents.localMediaStream&&a.soraContents.sora){t.next=4;break}return n(h.actions.setMicDevice(e)),t.abrupt("return");case 4:if(!e){t.next=18;break}return s={audio:a.audio,audioContentHint:a.audioContentHint,audioInput:a.audioInput,audioTrack:a.audioTrack,autoGainControl:a.autoGainControl,cameraDevice:a.cameraDevice,echoCancellation:a.echoCancellation,echoCancellationType:a.echoCancellationType,fakeContents:a.fakeContents,fakeVolume:a.fakeVolume,frameRate:a.frameRate,mediaType:a.mediaType,micDevice:e,noiseSuppression:a.noiseSuppression,resolution:a.resolution,video:!1,videoContentHint:a.videoContentHint,videoInput:a.videoInput,videoTrack:a.videoTrack},t.next=8,C(n,s).catch((function(e){throw n(h.actions.setSoraErrorAlertMessage(e.toString())),e}));case 8:if(c=t.sent,l=(0,i.Z)(c,2),u=l[0],d=l[1],!(0<u.getAudioTracks().length)){t.next=16;break}return t.next=15,a.soraContents.sora.replaceAudioTrack(a.soraContents.localMediaStream,u.getAudioTracks()[0]);case 15:n(h.actions.setFakeContentsGainNode(d));case 16:t.next=19;break;case 18:a.soraContents.sora.stopAudioTrack(a.soraContents.localMediaStream);case 19:n(h.actions.setMicDevice(e));case 20:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()},W=function(e){return function(){var t=(0,o.Z)(r().mark((function t(n,o){var a,s,c,l,u,d;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((a=o()).soraContents.localMediaStream&&a.soraContents.sora){t.next=4;break}return n(h.actions.setCameraDevice(e)),t.abrupt("return");case 4:if(!e){t.next=15;break}return s={audio:!1,audioContentHint:a.audioContentHint,audioInput:a.audioInput,audioTrack:a.audioTrack,autoGainControl:a.autoGainControl,cameraDevice:e,echoCancellation:a.echoCancellation,echoCancellationType:a.echoCancellationType,fakeContents:a.fakeContents,fakeVolume:a.fakeVolume,frameRate:a.frameRate,mediaType:a.mediaType,micDevice:a.micDevice,noiseSuppression:a.noiseSuppression,resolution:a.resolution,video:a.video,videoContentHint:a.videoContentHint,videoInput:a.videoInput,videoTrack:a.videoTrack},t.next=8,C(n,s).catch((function(e){throw n(h.actions.setSoraErrorAlertMessage(e.toString())),e}));case 8:c=t.sent,l=(0,i.Z)(c,2),u=l[0],d=l[1],0<u.getVideoTracks().length&&(a.soraContents.sora.replaceVideoTrack(a.soraContents.localMediaStream,u.getVideoTracks()[0]),n(h.actions.setFakeContentsGainNode(d))),t.next=16;break;case 15:a.soraContents.sora.stopVideoTrack(a.soraContents.localMediaStream);case 16:n(h.actions.setCameraDevice(e));case 17:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()};function G(e,t,n,i){void 0!==n&&e(t(n)),void 0!==i&&e(t(i))}var O=function(e){return function(){var t=(0,o.Z)(r().mark((function t(n,i){var o,a,s,l,d,g,f,p,C,m,I,y;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n(h.actions.resetState()),o=(0,u.dD)(),G(n,h.actions.setAudio,e.audio,o.audio),G(n,h.actions.setAudioBitRate,e.audioBitRate,o.audioBitRate),G(n,h.actions.setAudioCodecType,e.audioCodecType,o.audioCodecType),t.next=7,(0,u.PW)();case 7:if(void 0!==(a=t.sent).find((function(e){return"audioinput"===e.kind&&e.deviceId===o.audioInput}))&&G(n,h.actions.setAudioInput,e.audioInput,o.audioInput),void 0!==a.find((function(e){return"audiooutput"===e.kind&&e.deviceId===o.audioOutput}))&&G(n,h.actions.setAudioOutput,e.audioOutput,o.audioOutput),void 0!==a.find((function(e){return"videoinput"===e.kind&&e.deviceId===o.videoInput}))&&G(n,h.actions.setVideoInput,e.videoInput,o.videoInput),G(n,h.actions.setAutoGainControl,e.autoGainControl,o.autoGainControl),G(n,h.actions.setChannelId,e.channelId,o.channelId),G(n,h.actions.setDisplayResolution,e.displayResolution,o.displayResolution),G(n,h.actions.setE2EE,e.e2ee,o.e2ee),G(n,h.actions.setEchoCancellation,e.echoCancellation,o.echoCancellation),G(n,h.actions.setEchoCancellationType,e.echoCancellationType,o.echoCancellationType),G(n,h.actions.setMediaType,e.mediaType,o.mediaType),G(n,h.actions.setFakeVolume,e.fakeVolume,o.fakeVolume),G(n,h.actions.setFrameRate,e.frameRate,o.frameRate),G(n,h.actions.setNoiseSuppression,e.noiseSuppression,o.noiseSuppression),G(n,h.actions.setResolution,e.resolution,o.resolution),G(n,h.actions.setShowStats,e.showStats,o.showStats),G(n,h.actions.setSimulcastRid,e.simulcastRid,o.simulcastRid),G(n,h.actions.setSpotlightNumber,e.spotlightNumber,o.spotlightNumber),G(n,h.actions.setSpotlightFocusRid,e.spotlightFocusRid,o.spotlightFocusRid),G(n,h.actions.setSpotlightUnfocusRid,e.spotlightUnfocusRid,o.spotlightUnfocusRid),G(n,h.actions.setVideo,e.video,o.video),G(n,h.actions.setVideoBitRate,e.videoBitRate,o.videoBitRate),G(n,h.actions.setVideoCodecType,e.videoCodecType,o.videoCodecType),G(n,h.actions.setDebug,e.debug,o.debug),G(n,h.actions.setDebugType,e.debugType,o.debugType),G(n,h.actions.setMute,e.mute,o.mute),G(n,h.actions.setDataChannelSignaling,e.dataChannelSignaling,o.dataChannelSignaling),G(n,h.actions.setIgnoreDisconnectWebSocket,e.ignoreDisconnectWebSocket,o.ignoreDisconnectWebSocket),G(n,h.actions.setMicDevice,e.micDevice,o.micDevice),G(n,h.actions.setCameraDevice,e.cameraDevice,o.cameraDevice),G(n,h.actions.setAudioTrack,e.audioTrack,o.audioTrack),G(n,h.actions.setVideoTrack,e.videoTrack,o.videoTrack),void 0!==o.googCpuOveruseDetection&&n(h.actions.setGoogCpuOveruseDetection(o.googCpuOveruseDetection)),G(n,h.actions.setClientId,e.clientId,o.clientId),G(n,h.actions.setMetadata,e.metadata,o.metadata),G(n,h.actions.setSignalingNotifyMetadata,e.signalingNotifyMetadata,o.signalingNotifyMetadata),G(n,h.actions.setSignalingUrlCandidates,e.signalingUrlCandidates,o.signalingUrlCandidates),G(n,h.actions.setDataChannelMessaging,e.dataChannelMessaging,o.dataChannelMessaging),G(n,h.actions.setAudioContentHint,e.audioContentHint,o.audioContentHint),G(n,h.actions.setVideoContentHint,e.videoContentHint,o.videoContentHint),n(h.actions.setInitialFakeContents()),null===e.role||void 0===e.role){t.next=52;break}n(h.actions.setRole(e.role)),t.next=53;break;case 52:throw new Error("Failed to initialize. Invalid role parameter '".concat(e.role,"'."));case 53:if("boolean"!==typeof e.multistream){t.next=57;break}n(h.actions.setMultistream(e.multistream)),t.next=58;break;case 57:throw new Error("Failed to initialize. Invalid multistream parameter '".concat(e.multistream,"'."));case 58:if("boolean"!==typeof e.simulcast){t.next=62;break}n(h.actions.setSimulcast(e.simulcast)),t.next=63;break;case 62:throw new Error("Failed to initialize. Invalid simulcast parameter '".concat(e.simulcast,"'."));case 63:if("boolean"!==typeof e.spotlight){t.next=67;break}n(h.actions.setSpotlight(e.spotlight)),t.next=68;break;case 67:throw new Error("Failed to initialize. Invalid spotlight parameter '".concat(e.spotlight,"'."));case 68:if(n(h.actions.setInitialDisplaySettings((0,u.JJ)(e.role,e.multistream,e.simulcast,e.spotlight,!!e.dataChannelMessagingOnly))),s=i(),l=s.clientId,d=s.dataChannelMessaging,g=s.dataChannelSignaling,f=s.e2ee,p=s.ignoreDisconnectWebSocket,C=s.metadata,m=s.signalingNotifyMetadata,I=s.signalingUrlCandidates,!f){t.next=84;break}y="Faild to execute WebAssembly '".concat("https://sora-e2ee-wasm.shiguredo.jp/2020.2/wasm.wasm","'."),t.next=75;break;case 75:return t.prev=75,t.next=78,c.Z.initE2EE("https://sora-e2ee-wasm.shiguredo.jp/2020.2/wasm.wasm");case 78:t.next=84;break;case 80:return t.prev=80,t.t0=t.catch(75),n(h.actions.setSoraErrorAlertMessage(y)),t.abrupt("return");case 84:""!==l&&n(h.actions.setEnabledClientId(!0)),""!==C&&n(h.actions.setEnabledMetadata(!0)),""!==m&&n(h.actions.setEnabledSignalingNotifyMetadata(!0)),0<I.length&&n(h.actions.setEnabledSignalingUrlCandidates(!0)),""===g&&""===p||n(h.actions.setEnabledDataChannel(!0)),""!==d&&n(h.actions.setEnabledDataChannelMessaging(!0));case 90:case"end":return t.stop()}}),t,null,[[75,80]])})));return function(e,n){return t.apply(this,arguments)}}()};function E(e,t){if(t)return e}var N=function(){return function(e,t){var n=t(),i={mediaType:E(n.mediaType,n.displaySettings.mediaType),channelId:n.channelId,audio:E(n.audio,n.displaySettings.audio),audioBitRate:E(n.audioBitRate,n.displaySettings.audioBitRate),audioCodecType:E(n.audioCodecType,n.displaySettings.audioCodecType),audioContentHint:E(n.audioContentHint,n.displaySettings.audioContentHint),autoGainControl:E(n.autoGainControl,n.displaySettings.audioConstraints),noiseSuppression:E(n.noiseSuppression,n.displaySettings.audioConstraints),echoCancellation:E(n.echoCancellation,n.displaySettings.audioConstraints),echoCancellationType:E(n.echoCancellationType,n.displaySettings.audioConstraints),video:E(n.video,n.displaySettings.video),videoBitRate:E(n.videoBitRate,n.displaySettings.videoBitRate),videoCodecType:E(n.videoCodecType,n.displaySettings.videoCodecType),videoContentHint:E(n.videoContentHint,n.displaySettings.videoContentHint),resolution:E(n.resolution,n.displaySettings.videoConstraints),frameRate:E(n.frameRate,n.displaySettings.videoConstraints),simulcastRid:E(n.simulcastRid,n.displaySettings.simulcastRid),audioInput:E(n.audioInput,n.displaySettings.audioInput),audioOutput:E(n.audioOutput,n.displaySettings.audioOutput),videoInput:E(n.videoInput,n.displaySettings.videoInput),displayResolution:n.displayResolution,micDevice:E(n.micDevice,n.displaySettings.micDevice),cameraDevice:E(n.cameraDevice,n.displaySettings.cameraDevice),audioTrack:E(n.audioTrack,n.displaySettings.audioTrack),videoTrack:E(n.videoTrack,n.displaySettings.videoTrack),spotlightNumber:E(n.spotlightNumber,n.displaySettings.spotlightNumber),spotlightFocusRid:E(n.spotlightFocusRid,n.displaySettings.spotlightFocusRid),spotlightUnfocusRid:E(n.spotlightUnfocusRid,n.displaySettings.spotlightUnfocusRid),e2ee:n.e2ee,clientId:E(n.clientId,n.enabledClientId),metadata:E(n.metadata,n.enabledMetadata),signalingNotifyMetadata:E(n.signalingNotifyMetadata,n.enabledSignalingNotifyMetadata),dataChannelSignaling:E(n.dataChannelSignaling,n.enabledDataChannel),ignoreDisconnectWebSocket:E(n.ignoreDisconnectWebSocket,n.enabledDataChannel),signalingUrlCandidates:E(n.signalingUrlCandidates,n.enabledSignalingUrlCandidates),dataChannelMessaging:E(n.dataChannelMessaging,n.enabledDataChannelMessaging),debug:n.debug,fakeVolume:"fakeMedia"===n.mediaType?n.fakeVolume:void 0},o=Object.keys(i).map((function(e){var t=i[e];if(void 0!==t)return"signalingUrlCandidates"===e?"".concat(e,"=").concat(encodeURIComponent(JSON.stringify(t))):"".concat(e,"=").concat(encodeURIComponent(t))})).filter((function(e){return void 0!==e}));(0,u.f7)("".concat(location.origin).concat(location.pathname,"?").concat(o.join("&")))}},M=h.actions,D=M.deleteAlertMessage,B=M.setAPIErrorAlertMessage,X=M.setAPIInfoAlertMessage,F=M.setAudio,x=M.setAudioBitRate,j=M.setAudioCodecType,Y=M.setAudioContentHint,L=M.setAudioInput,U=M.setAudioOutput,J=M.setAudioTrack,K=M.setAutoGainControl,P=M.setChannelId,H=M.setClientId,Q=M.setDataChannelMessaging,_=M.setDataChannelSignaling,z=M.setDebug,$=M.setDebugFilterText,q=M.setDebugType,ee=M.setDisplayResolution,te=M.setEchoCancellation,ne=M.setEchoCancellationType,ie=M.setEnabledClientId,oe=M.setEnabledDataChannelMessaging,ae=M.setEnabledDataChannel,re=M.setEnabledMetadata,se=M.setEnabledSignalingNotifyMetadata,ce=M.setEnabledSignalingUrlCandidates,le=M.setFakeVolume,ue=M.setFrameRate,de=M.setIgnoreDisconnectWebSocket,ge=(M.setLocalMediaStream,M.setLogMessages,M.setMediaType),fe=M.setMetadata,he=M.setNoiseSuppression,pe=(M.setNotifyMessages,M.setResolution),Ce=M.setSignalingNotifyMetadata,me=M.setSignalingUrlCandidates,Ie=M.setSimulcastRid,ye=(M.setSora,M.setSoraErrorAlertMessage,M.setSoraInfoAlertMessage,M.setSpotlightFocusRid),be=M.setSpotlightNumber,ve=M.setSpotlightUnfocusRid,Ae=M.setVideo,Se=M.setVideoBitRate,we=M.setVideoCodecType,Ze=M.setVideoContentHint,ke=M.setVideoInput,Ve=M.setVideoTrack,Re=h.reducer},3826:function(e,t,n){"use strict";n.d(t,{h:function(){return a}});var i=n(5126),o=(n(4500),n(8253)),a=(0,i.xC)({reducer:o.I6,middleware:function(e){var t=e({serializableCheck:{ignoredActions:["soraDevtools/setSora","soraDevtools/setLocalMediaStream","soraDevtools/setRemoteMediaStream","soraDevtools/setFakeContentsGainNode"],ignoredPaths:["soraContents","fakeContents","dataChannelMessages","logMessages","notifyMessages","pushMessages","signalingMessages"]},immutableCheck:{ignoredPaths:["soraContents","fakeContents","dataChannelMessages","logMessages","notifyMessages","pushMessages","signalingMessages"]}});return t}})},4007:function(e,t,n){"use strict";n.d(t,{o1:function(){return i},xR:function(){return o},Sh:function(){return a},Q5:function(){return r},Vf:function(){return s},hJ:function(){return c},YX:function(){return l},iN:function(){return u},ad:function(){return d},PS:function(){return g},cJ:function(){return f},w_:function(){return h},Xr:function(){return p},I7:function(){return C},WJ:function(){return m},l9:function(){return I},kt:function(){return y},aF:function(){return b},nT:function(){return v},QO:function(){return A},lt:function(){return S}});var i=["","OPUS"],o=["","8","16","24","32","64","96","128","256"],a=["","VP8","VP9","H264","H265","AV1"],r=["","10","30","50","100","300","500","800","1000","1500","2000","2500","3000","5000","10000","15000","20000","30000","50000"],s=["","UHD 4096x2160","UHD 3840x2160","3840x1920","FHD","HD","VGA","QVGA","HQVGA","QCIF","QQVGA"],c=["","VGA","QVGA"],l=["","60","30","24","20","15","10"],u=["","true","false"],d=["","true","false"],g=["","true","false"],f=["","browser","system"],h=["getUserMedia","getDisplayMedia","fakeMedia"],p=["","1","2","3","4","5","6","7","8"],C=["","none","r0","r1","r2"],m=["","r0","r1","r2"],I=["","true","false"],y=["","true","false"],b=["log","notify","push","stats","timeline","signaling","messaging"],v=["","speech","speech-recognition","music"],A=["","motion","detail","text"],S='\nself.onmessage = (event) => {\n  const data = event.data;\n  if (data.type === "start") {\n    const interval = data.interval;\n    self.counter = 0;\n    const intervalId = setInterval(() => {\n      const message = { type: "update", counter: self.counter };\n      self.postMessage(message);\n      self.counter++;\n    }, interval);\n    self.intervalId = intervalId;\n  } else if (data.type === "stop") {\n    if (self.intervalId) {\n      clearInterval(self.intervalId);\n    }\n    const message = { type: "stop" };\n    self.postMessage(message);\n  }\n};\n'},9064:function(e,t,n){"use strict";n.r(t);var i=n(2809),o=(n(2243),n(2004),n(9704)),a=n(3826),r=n(5893);function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){(0,i.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}t.default=function(e){var t=e.Component,n=e.pageProps;return(0,r.jsx)(o.zt,{store:a.h,children:(0,r.jsx)(t,c({},n))})}},8052:function(e,t,n){"use strict";n.d(t,{o5:function(){return c},f7:function(){return l},yP:function(){return u},nu:function(){return d},ou:function(){return g},Uz:function(){return f},zM:function(){return h},ko:function(){return p},F9:function(){return C},Ee:function(){return m},E7:function(){return I},Tp:function(){return y},Gn:function(){return b},EQ:function(){return v},iF:function(){return A},zG:function(){return S},nm:function(){return w},ug:function(){return Z},to:function(){return k},ej:function(){return V},s2:function(){return R},dD:function(){return T},EO:function(){return W},fl:function(){return G},dV:function(){return O},Tm:function(){return E},_8:function(){return N},gU:function(){return M},zW:function(){return D},BB:function(){return X},Sg:function(){return F},PW:function(){return x},JJ:function(){return Y}});var i=n(266),o=n(809),a=n.n(o),r=n(7563),s=n(4007);function c(e){var t=new Date(e),n=t.getFullYear(),i=t.getMonth()+1,o=t.getDate(),a=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0"),s=t.getSeconds().toString().padStart(2,"0"),c=t.getMilliseconds().toString().padStart(3,"0");return"".concat(n,"-").concat(i,"-").concat(o," ").concat(a,":").concat(r,":").concat(s,".").concat(c)}function l(e){return navigator.clipboard?navigator.clipboard.writeText(e):Promise.resolve()}function u(e){return s.o1.indexOf(e)>=0}function d(e){return s.xR.indexOf(e)>=0}function g(e){return s.Sh.indexOf(e)>=0}function f(e){return s.Q5.indexOf(e)>=0}function h(e){return s.Vf.indexOf(e)>=0}function p(e){return s.hJ.indexOf(e)>=0}function C(e){return s.YX.indexOf(e)>=0}function m(e){return s.iN.indexOf(e)>=0}function I(e){return s.ad.indexOf(e)>=0}function y(e){return s.PS.indexOf(e)>=0}function b(e){return s.cJ.indexOf(e)>=0}function v(e){return s.Xr.indexOf(e)>=0}function A(e){return s.I7.indexOf(e)>=0}function S(e){return s.WJ.indexOf(e)>=0}function w(e){return s.w_.indexOf(e)>=0}function Z(e){return s.l9.indexOf(e)>=0}function k(e){return s.kt.indexOf(e)>=0}function V(e){return s.nT.indexOf(e)>=0}function R(e){return s.QO.indexOf(e)>=0}function T(){var e=r.parse(location.search,{parseBooleans:!0}),t=e.audio,n=e.audioBitRate,i=e.audioCodecType,o=e.audioInput,a=e.audioOutput,c=e.audioTrack,l=e.autoGainControl,V=e.cameraDevice,R=e.channelId,T=e.clientId,W=e.dataChannelSignaling,G=e.dataChannelMessaging,O=e.debug,E=e.debugType,N=e.displayResolution,M=e.e2ee,D=e.echoCancellation,B=e.echoCancellationType,X=e.fakeVolume,F=e.frameRate,x=e.googCpuOveruseDetection,j=e.ignoreDisconnectWebSocket,Y=e.mediaType,L=e.metadata,U=e.micDevice,J=e.mute,K=e.noiseSuppression,P=e.resolution,H=e.showStats,Q=e.signalingNotifyMetadata,_=e.signalingUrlCandidates,z=e.simulcastRid,$=e.spotlightFocusRid,q=e.spotlightNumber,ee=e.spotlightUnfocusRid,te=e.video,ne=e.videoBitRate,ie=e.videoCodecType,oe=e.videoInput,ae=e.videoTrack,re={};"boolean"===typeof t&&(re.audio=t),"string"===typeof n&&d(n)&&(re.audioBitRate=n),"string"===typeof i&&u(i)&&(re.audioCodecType=i);var se=String(l);m(se)&&(re.autoGainControl=se),void 0!==R&&(re.channelId=String(R)),void 0!==T&&(re.clientId=String(T)),"boolean"===typeof x&&(re.googCpuOveruseDetection=x),"boolean"===typeof O&&(re.debug=O),"string"===typeof E&&function(e){return s.aF.indexOf(e)>=0}(E)&&(re.debugType=E),"string"===typeof N&&p(N)&&(re.displayResolution=N),"boolean"===typeof M&&(re.e2ee=M);var ce=String(D);y(ce)&&(re.echoCancellation=ce),"string"===typeof B&&b(B)&&(re.echoCancellationType=B);var le=String(K);if(I(le)&&(re.noiseSuppression=le),X&&(re.fakeVolume=String(X)),"string"===typeof F&&C(F)&&(re.frameRate=F),"string"===typeof Y&&w(Y)&&(re.mediaType=Y),L&&(re.metadata=String(L)),"boolean"===typeof H&&(re.showStats=H),Q&&(re.signalingNotifyMetadata=String(Q)),_&&"string"===typeof _){var ue=JSON.parse(_);Array.isArray(ue)&&(re.signalingUrlCandidates=ue)}"string"===typeof z&&S(z)&&(re.simulcastRid=z),"string"===typeof q&&v(q)&&(re.spotlightNumber=q),"string"===typeof $&&A($)&&(re.spotlightFocusRid=$),"string"===typeof ee&&A(ee)&&(re.spotlightUnfocusRid=ee),"string"===typeof P&&h(P)&&(re.resolution=P),"boolean"===typeof te&&(re.video=te),"string"===typeof ne&&f(ne)&&(re.videoBitRate=ne),"string"===typeof ie&&g(ie)&&(re.videoCodecType=ie),o&&(re.audioInput=String(o)),oe&&(re.videoInput=String(oe)),a&&(re.audioOutput=String(a)),"boolean"===typeof J&&(re.mute=J);var de=String(W);Z(de)&&(re.dataChannelSignaling=de);var ge=String(j);return k(ge)&&(re.ignoreDisconnectWebSocket=ge),"boolean"===typeof U&&(re.micDevice=U),"boolean"===typeof V&&(re.cameraDevice=V),"boolean"===typeof c&&(re.audioTrack=c),"boolean"===typeof ae&&(re.videoTrack=ae),"string"===typeof G&&(re.dataChannelMessaging=G),re}function W(e,t){if(e)return t.filter((function(e){return""!==e}));var n="https:"===window.location.protocol?"wss://":"ws://",i=window.location.port?":".concat(window.location.port):"";return n+window.location.hostname+i+"/signaling"}function G(e){switch(e){case"QQVGA":return{width:160,height:120};case"QCIF":return{width:176,height:144};case"HQVGA":return{width:240,height:160};case"QVGA":return{width:320,height:240};case"VGA":return{width:640,height:480};case"SD":return{width:720,height:480};case"HD":return{width:1280,height:720};case"FHD":return{width:1920,height:1080};case"UHD 3840x2160":return{width:3840,height:2160};case"UHD 4096x2160":return{width:4096,height:2160};case"3840x1920":return{width:3840,height:1920};default:return{width:0,height:0}}}function O(e){var t=e.audio,n=e.autoGainControl,i=e.noiseSuppression,o=e.echoCancellation,a=e.echoCancellationType,r=e.audioInput;if(!t)return!1;if(!n&&!i&&!o&&!a&&!r)return t;var s={};r&&(s.deviceId={exact:r});var c=B(n);void 0!==c&&(s.autoGainControl=c);var l=B(i);void 0!==l&&(s.noiseSuppression=l);var u=B(o);return void 0!==u&&(s.echoCancellation=u),a&&(s.echoCancellationType=a),s}function E(e){var t=e.video,n=e.frameRate,i=e.resolution,o=e.videoInput;if(!t)return!1;if(!n&&!i&&!o)return t;var a={};if(n&&(a.frameRate={min:parseInt(n,10),max:parseInt(n,10)}),i){var r=G(i),s=r.width,c=r.height;0<s&&0<c&&(a.width={exact:s},a.height={exact:c})}return o&&(a.deviceId={exact:o}),a}function N(e){var t=parseInt(e.frameRate,10)||30,n=G(e.resolution),i=n.width||240,o=n.height||160,a=Math.floor(i/5);return{audio:e.audio,video:e.video,frameRate:t,width:i,height:o,fontSize:a,volume:parseFloat(e.volume)}}function M(e){var t=new MediaStream,n=null;if(e.video){(n=document.createElement("canvas")).getContext("2d"),n.width=e.width,n.height=e.height;var i=n.captureStream(e.frameRate).getTracks();t.addTrack(i[0])}var o=null;if(e.audio){var a=new(window.AudioContext||window.webkitAudioContext),r=a.createOscillator();r.type="sine",o=a.createGain(),r.connect(o),r.start(0);var s=a.createMediaStreamDestination();o.connect(s);var c=s.stream.getTracks();t.addTrack(c[0]),o.gain.setValueAtTime(e.volume,0)}return{canvas:n,mediaStream:t,gainNode:o}}function D(e,t,n,i){if(null!==e){var o=e.getContext("2d");if(o){o.globalCompositeOperation="source-over",o.clearRect(0,0,e.width,e.height),o.fillStyle="#"+("0".repeat(6)+t.toString(16)).slice(-6),o.fillRect(0,0,e.width,e.height),o.fillStyle="#"+("0".repeat(6)+(16777215-t).toString(16)).slice(-6),o.font="".concat(n,"px Arial");var a=e.width/2-n/2,r=n/4*(i.length-1),s=e.height/2+n/2.5;o.fillText(i,a-r,s)}}}function B(e){return"true"===e||"false"!==e&&void 0}function X(e,t){if(e){try{return JSON.parse(t)}catch(n){}return t}}function F(e){if(!RTCRtpSender.getCapabilities)return e;var t=RTCRtpSender.getCapabilities("video");if(!t||!t.codecs)return e;var n=t.codecs.map((function(e){return e.mimeType.replace("video/","")}));return n.includes(e)?e:n.includes("VP9")?"VP9":n.includes("VP8")?"VP8":n.includes("H264")?"H264":n.includes("AV1X")?"AV1":n.includes("H265")?"H265":e}function x(){return j.apply(this,arguments)}function j(){return(j=(0,i.Z)(a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==navigator.mediaDevices){e.next=2;break}return e.abrupt("return",[]);case 2:return e.prev=2,e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return e.abrupt("return",e.sent);case 8:e.prev=8,e.t0=e.catch(2);case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,null,[[2,8]])})))).apply(this,arguments)}function Y(e,t,n,i,o){var a={audio:!1,audioBitRate:!1,audioCodecType:!1,audioContentHint:!1,audioConstraints:!1,audioInput:!1,audioOutput:!1,audioTrack:!1,cameraDevice:!1,displayResolution:!1,mediaType:!1,micDevice:!1,simulcastRid:!1,spotlightFocusRid:!1,spotlightNumber:!1,spotlightUnfocusRid:!1,video:!1,videoBitRate:!1,videoCodecType:!1,videoContentHint:!1,videoConstraints:!1,videoInput:!1,videoTrack:!1};return o||(a.audio=!0,a.video=!0,a.displayResolution=!0,"sendonly"===e||"sendrecv"===e?(a.audioBitRate=!0,a.audioCodecType=!0,a.audioContentHint=!0,a.audioConstraints=!0,a.audioInput=!0,a.audioOutput=!0,a.audioTrack=!0,a.cameraDevice=!0,a.mediaType=!0,a.micDevice=!0,a.videoBitRate=!0,a.videoCodecType=!0,a.videoContentHint=!0,a.videoConstraints=!0,a.videoInput=!0,a.videoTrack=!0):"recvonly"===e&&(a.audioCodecType=!0,a.videoCodecType=!0,a.audioOutput=!0),"recvonly"===e&&t&&(a.audioCodecType=!1,a.videoCodecType=!1),"recvonly"!==e&&"sendrecv"!==e||!n||i||(a.simulcastRid=!0),i&&(a.spotlightNumber=!0),"recvonly"!==e&&"sendrecv"!==e||!n||(a.spotlightFocusRid=!0,a.spotlightUnfocusRid=!0)),a}},6363:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_app",function(){return n(9064)}])},2243:function(){},2004:function(){},4155:function(e){var t,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function r(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"===typeof setTimeout?setTimeout:o}catch(e){t=o}try{n="function"===typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var s,c=[],l=!1,u=-1;function d(){l&&s&&(l=!1,s.length?c=s.concat(c):u=-1,c.length&&g())}function g(){if(!l){var e=r(d);l=!0;for(var t=c.length;t;){for(s=c,c=[];++u<t;)s&&s[u].run();u=-1,t=c.length}s=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function h(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new f(e,t)),1!==c.length||l||r(g)},f.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=h,i.addListener=h,i.once=h,i.off=h,i.removeListener=h,i.removeAllListeners=h,i.emit=h,i.prependListener=h,i.prependOnceListener=h,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},7563:function(e,t,n){"use strict";const i=n(610),o=n(4020),a=n(500),r=n(2806),s=Symbol("encodeFragmentIdentifier");function c(e){if("string"!==typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function l(e,t){return t.encode?t.strict?i(e):encodeURIComponent(e):e}function u(e,t){return t.decode?o(e):e}function d(e){return Array.isArray(e)?e.sort():"object"===typeof e?d(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function g(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function f(e){const t=(e=g(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function h(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"===typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function p(e,t){c((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const n=function(e){let t;switch(e.arrayFormat){case"index":return(e,n,i)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===i[e]&&(i[e]={}),i[e][t[1]]=n):i[e]=n};case"bracket":return(e,n,i)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==i[e]?i[e]=[].concat(i[e],n):i[e]=[n]:i[e]=n};case"comma":case"separator":return(t,n,i)=>{const o="string"===typeof n&&n.includes(e.arrayFormatSeparator),a="string"===typeof n&&!o&&u(n,e).includes(e.arrayFormatSeparator);n=a?u(n,e):n;const r=o||a?n.split(e.arrayFormatSeparator).map((t=>u(t,e))):null===n?n:u(n,e);i[t]=r};case"bracket-separator":return(t,n,i)=>{const o=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!o)return void(i[t]=n?u(n,e):n);const a=null===n?[]:n.split(e.arrayFormatSeparator).map((t=>u(t,e)));void 0!==i[t]?i[t]=[].concat(i[t],a):i[t]=a};default:return(e,t,n)=>{void 0!==n[e]?n[e]=[].concat(n[e],t):n[e]=t}}}(t),i=Object.create(null);if("string"!==typeof e)return i;if(!(e=e.trim().replace(/^[?#&]/,"")))return i;for(const o of e.split("&")){if(""===o)continue;let[e,r]=a(t.decode?o.replace(/\+/g," "):o,"=");r=void 0===r?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?r:u(r,t),n(u(e,t),r,i)}for(const o of Object.keys(i)){const e=i[o];if("object"===typeof e&&null!==e)for(const n of Object.keys(e))e[n]=h(e[n],t);else i[o]=h(e,t)}return!1===t.sort?i:(!0===t.sort?Object.keys(i).sort():Object.keys(i).sort(t.sort)).reduce(((e,t)=>{const n=i[t];return Boolean(n)&&"object"===typeof n&&!Array.isArray(n)?e[t]=d(n):e[t]=n,e}),Object.create(null))}t.extract=f,t.parse=p,t.stringify=(e,t)=>{if(!e)return"";c((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const n=n=>{return t.skipNull&&(null===(i=e[n])||void 0===i)||t.skipEmptyString&&""===e[n];var i},i=function(e){switch(e.arrayFormat){case"index":return t=>(n,i)=>{const o=n.length;return void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?n:null===i?[...n,[l(t,e),"[",o,"]"].join("")]:[...n,[l(t,e),"[",l(o,e),"]=",l(i,e)].join("")]};case"bracket":return t=>(n,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?n:null===i?[...n,[l(t,e),"[]"].join("")]:[...n,[l(t,e),"[]=",l(i,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return n=>(i,o)=>void 0===o||e.skipNull&&null===o||e.skipEmptyString&&""===o?i:(o=null===o?"":o,0===i.length?[[l(n,e),t,l(o,e)].join("")]:[[i,l(o,e)].join(e.arrayFormatSeparator)])}default:return t=>(n,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?n:null===i?[...n,l(t,e)]:[...n,[l(t,e),"=",l(i,e)].join("")]}}(t),o={};for(const r of Object.keys(e))n(r)||(o[r]=e[r]);const a=Object.keys(o);return!1!==t.sort&&a.sort(t.sort),a.map((n=>{const o=e[n];return void 0===o?"":null===o?l(n,t):Array.isArray(o)?0===o.length&&"bracket-separator"===t.arrayFormat?l(n,t)+"[]":o.reduce(i(n),[]).join("&"):l(n,t)+"="+l(o,t)})).filter((e=>e.length>0)).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[n,i]=a(e,"#");return Object.assign({url:n.split("?")[0]||"",query:p(f(e),t)},t&&t.parseFragmentIdentifier&&i?{fragmentIdentifier:u(i,t)}:{})},t.stringifyUrl=(e,n)=>{n=Object.assign({encode:!0,strict:!0,[s]:!0},n);const i=g(e.url).split("?")[0]||"",o=t.extract(e.url),a=t.parse(o,{sort:!1}),r=Object.assign(a,e.query);let c=t.stringify(r,n);c&&(c=`?${c}`);let u=function(e){let t="";const n=e.indexOf("#");return-1!==n&&(t=e.slice(n)),t}(e.url);return e.fragmentIdentifier&&(u=`#${n[s]?l(e.fragmentIdentifier,n):e.fragmentIdentifier}`),`${i}${c}${u}`},t.pick=(e,n,i)=>{i=Object.assign({parseFragmentIdentifier:!0,[s]:!1},i);const{url:o,query:a,fragmentIdentifier:c}=t.parseUrl(e,i);return t.stringifyUrl({url:o,query:r(a,n),fragmentIdentifier:c},i)},t.exclude=(e,n,i)=>{const o=Array.isArray(n)?e=>!n.includes(e):(e,t)=>!n(e,t);return t.pick(e,o,i)}},9921:function(e,t){"use strict";var n="function"===typeof Symbol&&Symbol.for,i=n?Symbol.for("react.element"):60103,o=n?Symbol.for("react.portal"):60106,a=n?Symbol.for("react.fragment"):60107,r=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,c=n?Symbol.for("react.provider"):60109,l=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,d=n?Symbol.for("react.concurrent_mode"):60111,g=n?Symbol.for("react.forward_ref"):60112,f=n?Symbol.for("react.suspense"):60113,h=n?Symbol.for("react.suspense_list"):60120,p=n?Symbol.for("react.memo"):60115,C=n?Symbol.for("react.lazy"):60116,m=n?Symbol.for("react.block"):60121,I=n?Symbol.for("react.fundamental"):60117,y=n?Symbol.for("react.responder"):60118,b=n?Symbol.for("react.scope"):60119;function v(e){if("object"===typeof e&&null!==e){var t=e.$$typeof;switch(t){case i:switch(e=e.type){case u:case d:case a:case s:case r:case f:return e;default:switch(e=e&&e.$$typeof){case l:case g:case C:case p:case c:return e;default:return t}}case o:return t}}}function A(e){return v(e)===d}t.AsyncMode=u,t.ConcurrentMode=d,t.ContextConsumer=l,t.ContextProvider=c,t.Element=i,t.ForwardRef=g,t.Fragment=a,t.Lazy=C,t.Memo=p,t.Portal=o,t.Profiler=s,t.StrictMode=r,t.Suspense=f,t.isAsyncMode=function(e){return A(e)||v(e)===u},t.isConcurrentMode=A,t.isContextConsumer=function(e){return v(e)===l},t.isContextProvider=function(e){return v(e)===c},t.isElement=function(e){return"object"===typeof e&&null!==e&&e.$$typeof===i},t.isForwardRef=function(e){return v(e)===g},t.isFragment=function(e){return v(e)===a},t.isLazy=function(e){return v(e)===C},t.isMemo=function(e){return v(e)===p},t.isPortal=function(e){return v(e)===o},t.isProfiler=function(e){return v(e)===s},t.isStrictMode=function(e){return v(e)===r},t.isSuspense=function(e){return v(e)===f},t.isValidElementType=function(e){return"string"===typeof e||"function"===typeof e||e===a||e===d||e===s||e===r||e===f||e===h||"object"===typeof e&&null!==e&&(e.$$typeof===C||e.$$typeof===p||e.$$typeof===c||e.$$typeof===l||e.$$typeof===g||e.$$typeof===I||e.$$typeof===y||e.$$typeof===b||e.$$typeof===m)},t.typeOf=v},9864:function(e,t,n){"use strict";e.exports=n(9921)},9704:function(e,t,n){"use strict";n.d(t,{zt:function(){return u},I0:function(){return p},v9:function(){return y}});var i=n(7294),o=(n(5697),i.createContext(null));var a=function(e){e()},r=function(){return a};var s={notify:function(){},get:function(){return[]}};function c(e,t){var n,i=s;function o(){c.onStateChange&&c.onStateChange()}function a(){n||(n=t?t.addNestedSub(o):e.subscribe(o),i=function(){var e=r(),t=null,n=null;return{clear:function(){t=null,n=null},notify:function(){e((function(){for(var e=t;e;)e.callback(),e=e.next}))},get:function(){for(var e=[],n=t;n;)e.push(n),n=n.next;return e},subscribe:function(e){var i=!0,o=n={callback:e,next:null,prev:n};return o.prev?o.prev.next=o:t=o,function(){i&&null!==t&&(i=!1,o.next?o.next.prev=o.prev:n=o.prev,o.prev?o.prev.next=o.next:t=o.next)}}}}())}var c={addNestedSub:function(e){return a(),i.subscribe(e)},notifyNestedSubs:function(){i.notify()},handleChangeWrapper:o,isSubscribed:function(){return Boolean(n)},trySubscribe:a,tryUnsubscribe:function(){n&&(n(),n=void 0,i.clear(),i=s)},getListeners:function(){return i}};return c}var l="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?i.useLayoutEffect:i.useEffect;var u=function(e){var t=e.store,n=e.context,a=e.children,r=(0,i.useMemo)((function(){var e=c(t);return e.onStateChange=e.notifyNestedSubs,{store:t,subscription:e}}),[t]),s=(0,i.useMemo)((function(){return t.getState()}),[t]);l((function(){var e=r.subscription;return e.trySubscribe(),s!==t.getState()&&e.notifyNestedSubs(),function(){e.tryUnsubscribe(),e.onStateChange=null}}),[r,s]);var u=n||o;return i.createElement(u.Provider,{value:r},a)};n(8679),n(9864);n(7462);function d(){return(0,i.useContext)(o)}function g(e){void 0===e&&(e=o);var t=e===o?d:function(){return(0,i.useContext)(e)};return function(){return t().store}}var f=g();function h(e){void 0===e&&(e=o);var t=e===o?f:g(e);return function(){return t().dispatch}}var p=h(),C=function(e,t){return e===t};function m(e){void 0===e&&(e=o);var t=e===o?d:function(){return(0,i.useContext)(e)};return function(e,n){void 0===n&&(n=C);var o=t(),a=function(e,t,n,o){var a,r=(0,i.useReducer)((function(e){return e+1}),0)[1],s=(0,i.useMemo)((function(){return c(n,o)}),[n,o]),u=(0,i.useRef)(),d=(0,i.useRef)(),g=(0,i.useRef)(),f=(0,i.useRef)(),h=n.getState();try{if(e!==d.current||h!==g.current||u.current){var p=e(h);a=void 0!==f.current&&t(p,f.current)?f.current:p}else a=f.current}catch(C){throw u.current&&(C.message+="\nThe error may be correlated with this previous error:\n"+u.current.stack+"\n\n"),C}return l((function(){d.current=e,g.current=h,f.current=a,u.current=void 0})),l((function(){function e(){try{var e=n.getState();if(e===g.current)return;var i=d.current(e);if(t(i,f.current))return;f.current=i,g.current=e}catch(C){u.current=C}r()}return s.onStateChange=e,s.trySubscribe(),e(),function(){return s.tryUnsubscribe()}}),[n,s]),a}(e,n,o.store,o.subscription);return(0,i.useDebugValue)(a),a}}var I,y=m(),b=n(3935);I=b.unstable_batchedUpdates,a=I},4500:function(e,t,n){!function(e){"use strict";function t(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function i(e,t){Object.defineProperty(this,"kind",{value:e,enumerable:!0}),t&&t.length&&Object.defineProperty(this,"path",{value:t,enumerable:!0})}function o(e,t,n){o.super_.call(this,"E",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0}),Object.defineProperty(this,"rhs",{value:n,enumerable:!0})}function a(e,t){a.super_.call(this,"N",e),Object.defineProperty(this,"rhs",{value:t,enumerable:!0})}function r(e,t){r.super_.call(this,"D",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0})}function s(e,t,n){s.super_.call(this,"A",e),Object.defineProperty(this,"index",{value:t,enumerable:!0}),Object.defineProperty(this,"item",{value:n,enumerable:!0})}function c(e,t,n){var i=e.slice((n||t)+1||e.length);return e.length=t<0?e.length+t:t,e.push.apply(e,i),e}function l(e){var t="undefined"==typeof e?"undefined":W(e);return"object"!==t?t:e===Math?"math":null===e?"null":Array.isArray(e)?"array":"[object Date]"===Object.prototype.toString.call(e)?"date":"function"==typeof e.toString&&/^\/.*\//.test(e.toString())?"regexp":"object"}function u(e,t,n,i,d,g,f){f=f||[];var h=(d=d||[]).slice(0);if("undefined"!=typeof g){if(i){if("function"==typeof i&&i(h,g))return;if("object"===("undefined"==typeof i?"undefined":W(i))){if(i.prefilter&&i.prefilter(h,g))return;if(i.normalize){var p=i.normalize(h,g,e,t);p&&(e=p[0],t=p[1])}}}h.push(g)}"regexp"===l(e)&&"regexp"===l(t)&&(e=e.toString(),t=t.toString());var C="undefined"==typeof e?"undefined":W(e),m="undefined"==typeof t?"undefined":W(t),I="undefined"!==C||f&&f[f.length-1].lhs&&f[f.length-1].lhs.hasOwnProperty(g),y="undefined"!==m||f&&f[f.length-1].rhs&&f[f.length-1].rhs.hasOwnProperty(g);if(!I&&y)n(new a(h,t));else if(!y&&I)n(new r(h,e));else if(l(e)!==l(t))n(new o(h,e,t));else if("date"===l(e)&&e-t!==0)n(new o(h,e,t));else if("object"===C&&null!==e&&null!==t)if(f.filter((function(t){return t.lhs===e})).length)e!==t&&n(new o(h,e,t));else{if(f.push({lhs:e,rhs:t}),Array.isArray(e)){var b;for(e.length,b=0;b<e.length;b++)b>=t.length?n(new s(h,b,new r(void 0,e[b]))):u(e[b],t[b],n,i,h,b,f);for(;b<t.length;)n(new s(h,b,new a(void 0,t[b++])))}else{var v=Object.keys(e),A=Object.keys(t);v.forEach((function(o,a){var r=A.indexOf(o);r>=0?(u(e[o],t[o],n,i,h,o,f),A=c(A,r)):u(e[o],void 0,n,i,h,o,f)})),A.forEach((function(e){u(void 0,t[e],n,i,h,e,f)}))}f.length=f.length-1}else e!==t&&("number"===C&&isNaN(e)&&isNaN(t)||n(new o(h,e,t)))}function d(e,t,n,i){return i=i||[],u(e,t,(function(e){e&&i.push(e)}),n),i.length?i:void 0}function g(e,t,n){if(n.path&&n.path.length){var i,o=e[t],a=n.path.length-1;for(i=0;i<a;i++)o=o[n.path[i]];switch(n.kind){case"A":g(o[n.path[i]],n.index,n.item);break;case"D":delete o[n.path[i]];break;case"E":case"N":o[n.path[i]]=n.rhs}}else switch(n.kind){case"A":g(e[t],n.index,n.item);break;case"D":e=c(e,t);break;case"E":case"N":e[t]=n.rhs}return e}function f(e,t,n){if(e&&t&&n&&n.kind){for(var i=e,o=-1,a=n.path?n.path.length-1:0;++o<a;)"undefined"==typeof i[n.path[o]]&&(i[n.path[o]]="number"==typeof n.path[o]?[]:{}),i=i[n.path[o]];switch(n.kind){case"A":g(n.path?i[n.path[o]]:i,n.index,n.item);break;case"D":delete i[n.path[o]];break;case"E":case"N":i[n.path[o]]=n.rhs}}}function h(e,t,n){if(n.path&&n.path.length){var i,o=e[t],a=n.path.length-1;for(i=0;i<a;i++)o=o[n.path[i]];switch(n.kind){case"A":h(o[n.path[i]],n.index,n.item);break;case"D":case"E":o[n.path[i]]=n.lhs;break;case"N":delete o[n.path[i]]}}else switch(n.kind){case"A":h(e[t],n.index,n.item);break;case"D":case"E":e[t]=n.lhs;break;case"N":e=c(e,t)}return e}function p(e,t,n){if(e&&t&&n&&n.kind){var i,o,a=e;for(o=n.path.length-1,i=0;i<o;i++)"undefined"==typeof a[n.path[i]]&&(a[n.path[i]]={}),a=a[n.path[i]];switch(n.kind){case"A":h(a[n.path[i]],n.index,n.item);break;case"D":case"E":a[n.path[i]]=n.lhs;break;case"N":delete a[n.path[i]]}}}function C(e,t,n){e&&t&&u(e,t,(function(i){n&&!n(e,t,i)||f(e,t,i)}))}function m(e){return"color: "+E[e].color+"; font-weight: bold"}function I(e){var t=e.kind,n=e.path,i=e.lhs,o=e.rhs,a=e.index,r=e.item;switch(t){case"E":return[n.join("."),i,"\u2192",o];case"N":return[n.join("."),o];case"D":return[n.join(".")];case"A":return[n.join(".")+"["+a+"]",r];default:return[]}}function y(e,t,n,i){var o=d(e,t);try{i?n.groupCollapsed("diff"):n.group("diff")}catch(e){n.log("diff")}o?o.forEach((function(e){var t=e.kind,i=I(e);n.log.apply(n,["%c "+E[t].text,m(t)].concat(G(i)))})):n.log("\u2014\u2014 no diff \u2014\u2014");try{n.groupEnd()}catch(e){n.log("\u2014\u2014 diff end \u2014\u2014 ")}}function b(e,t,n,i){switch("undefined"==typeof e?"undefined":W(e)){case"object":return"function"==typeof e[i]?e[i].apply(e,G(n)):e[i];case"function":return e(t);default:return e}}function v(e){var t=e.timestamp,n=e.duration;return function(e,i,o){var a=["action"];return a.push("%c"+String(e.type)),t&&a.push("%c@ "+i),n&&a.push("%c(in "+o.toFixed(2)+" ms)"),a.join(" ")}}function A(e,t){var n=t.logger,i=t.actionTransformer,o=t.titleFormatter,a=void 0===o?v(t):o,r=t.collapsed,s=t.colors,c=t.level,l=t.diff,u="undefined"==typeof t.titleFormatter;e.forEach((function(o,d){var g=o.started,f=o.startedTime,h=o.action,p=o.prevState,C=o.error,m=o.took,I=o.nextState,v=e[d+1];v&&(I=v.prevState,m=v.started-g);var A=i(h),S="function"==typeof r?r((function(){return I}),h,o):r,w=R(f),Z=s.title?"color: "+s.title(A)+";":"",k=["color: gray; font-weight: lighter;"];k.push(Z),t.timestamp&&k.push("color: gray; font-weight: lighter;"),t.duration&&k.push("color: gray; font-weight: lighter;");var V=a(A,w,m);try{S?s.title&&u?n.groupCollapsed.apply(n,["%c "+V].concat(k)):n.groupCollapsed(V):s.title&&u?n.group.apply(n,["%c "+V].concat(k)):n.group(V)}catch(e){n.log(V)}var T=b(c,A,[p],"prevState"),W=b(c,A,[A],"action"),G=b(c,A,[C,p],"error"),O=b(c,A,[I],"nextState");if(T)if(s.prevState){var E="color: "+s.prevState(p)+"; font-weight: bold";n[T]("%c prev state",E,p)}else n[T]("prev state",p);if(W)if(s.action){var N="color: "+s.action(A)+"; font-weight: bold";n[W]("%c action    ",N,A)}else n[W]("action    ",A);if(C&&G)if(s.error){var M="color: "+s.error(C,p)+"; font-weight: bold;";n[G]("%c error     ",M,C)}else n[G]("error     ",C);if(O)if(s.nextState){var D="color: "+s.nextState(I)+"; font-weight: bold";n[O]("%c next state",D,I)}else n[O]("next state",I);l&&y(p,I,n,S);try{n.groupEnd()}catch(e){n.log("\u2014\u2014 log end \u2014\u2014")}}))}function S(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},N,e),n=t.logger,i=t.stateTransformer,o=t.errorTransformer,a=t.predicate,r=t.logErrors,s=t.diffPredicate;if("undefined"==typeof n)return function(){return function(e){return function(t){return e(t)}}};if(e.getState&&e.dispatch)return console.error("[redux-logger] redux-logger not installed. Make sure to pass logger instance as middleware:\n// Logger with default options\nimport { logger } from 'redux-logger'\nconst store = createStore(\n  reducer,\n  applyMiddleware(logger)\n)\n// Or you can create your own logger with custom options http://bit.ly/redux-logger-options\nimport createLogger from 'redux-logger'\nconst logger = createLogger({\n  // ...options\n});\nconst store = createStore(\n  reducer,\n  applyMiddleware(logger)\n)\n"),function(){return function(e){return function(t){return e(t)}}};var c=[];return function(e){var n=e.getState;return function(e){return function(l){if("function"==typeof a&&!a(n,l))return e(l);var u={};c.push(u),u.started=T.now(),u.startedTime=new Date,u.prevState=i(n()),u.action=l;var d=void 0;if(r)try{d=e(l)}catch(e){u.error=o(e)}else d=e(l);u.took=T.now()-u.started,u.nextState=i(n());var g=t.diff&&"function"==typeof s?s(n,l):t.diff;if(A(c,Object.assign({},t,{diff:g})),c.length=0,u.error)throw u.error;return d}}}}var w,Z,k=function(e,t){return new Array(t+1).join(e)},V=function(e,t){return k("0",t-e.toString().length)+e},R=function(e){return V(e.getHours(),2)+":"+V(e.getMinutes(),2)+":"+V(e.getSeconds(),2)+"."+V(e.getMilliseconds(),3)},T="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance:Date,W="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},G=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},O=[];w="object"===("undefined"==typeof n.g?"undefined":W(n.g))&&n.g?n.g:"undefined"!=typeof window?window:{},(Z=w.DeepDiff)&&O.push((function(){"undefined"!=typeof Z&&w.DeepDiff===d&&(w.DeepDiff=Z,Z=void 0)})),t(o,i),t(a,i),t(r,i),t(s,i),Object.defineProperties(d,{diff:{value:d,enumerable:!0},observableDiff:{value:u,enumerable:!0},applyDiff:{value:C,enumerable:!0},applyChange:{value:f,enumerable:!0},revertChange:{value:p,enumerable:!0},isConflict:{value:function(){return"undefined"!=typeof Z},enumerable:!0},noConflict:{value:function(){return O&&(O.forEach((function(e){e()})),O=null),d},enumerable:!0}});var E={E:{color:"#2196F3",text:"CHANGED:"},N:{color:"#4CAF50",text:"ADDED:"},D:{color:"#F44336",text:"DELETED:"},A:{color:"#2196F3",text:"ARRAY:"}},N={level:"log",logger:console,logErrors:!0,collapsed:void 0,predicate:void 0,duration:!1,timestamp:!0,stateTransformer:function(e){return e},actionTransformer:function(e){return e},errorTransformer:function(e){return e},colors:{title:function(){return"inherit"},prevState:function(){return"#9E9E9E"},action:function(){return"#03A9F4"},nextState:function(){return"#4CAF50"},error:function(){return"#F20404"}},diff:!1,diffPredicate:void 0,transformer:void 0},M=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.dispatch,n=e.getState;return"function"==typeof t||"function"==typeof n?S()({dispatch:t,getState:n}):void console.error("\n[redux-logger v3] BREAKING CHANGE\n[redux-logger v3] Since 3.0.0 redux-logger exports by default logger with default settings.\n[redux-logger v3] Change\n[redux-logger v3] import createLogger from 'redux-logger'\n[redux-logger v3] to\n[redux-logger v3] import { createLogger } from 'redux-logger'\n")};e.defaults=N,e.createLogger=S,e.logger=M,e.default=M,Object.defineProperty(e,"__esModule",{value:!0})}(t)},500:function(e){"use strict";e.exports=(e,t)=>{if("string"!==typeof e||"string"!==typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const n=e.indexOf(t);return-1===n?[e]:[e.slice(0,n),e.slice(n+t.length)]}},610:function(e){"use strict";e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`))},7462:function(e,t,n){"use strict";function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}n.d(t,{Z:function(){return i}})},266:function(e,t,n){"use strict";function i(e,t,n,i,o,a,r){try{var s=e[a](r),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(i,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,a){var r=e.apply(t,n);function s(e){i(r,o,a,s,c,"next",e)}function c(e){i(r,o,a,s,c,"throw",e)}s(void 0)}))}}n.d(t,{Z:function(){return o}})},2809:function(e,t,n){"use strict";function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,{Z:function(){return i}})},6311:function(e,t,n){"use strict";function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,o,a=[],r=!0,s=!1;try{for(n=n.call(e);!(r=(i=n.next()).done)&&(a.push(i.value),!t||a.length!==t);r=!0);}catch(c){s=!0,o=c}finally{try{r||null==n.return||n.return()}finally{if(s)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"===typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}n.d(t,{Z:function(){return o}})},4492:function(e,t,n){"use strict";n.d(t,{Z:function(){return se}});var i=n(4155);class o{constructor(){if(!!!RTCRtpSender.prototype.createEncodedStreams)throw new Error("E2EE is not supported in this browser.");this.worker=null,this.onWorkerDisconnect=null}startWorker(){const e=atob("InVzZSBzdHJpY3QiOwovKiBlc2xpbnQtZGlzYWJsZSBAdHlwZXNjcmlwdC1lc2xpbnQvbm8tdW51c2VkLXZhcnMgKi8KY29uc3QgY29ubmVjdGlvbklkTGVuZ3RoID0gMjY7CmZ1bmN0aW9uIGJ5dGVDb3VudChuKSB7CiAgICBpZiAobiA9PSAwKSB7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICAvLyBsb2cyNTYoeCkgPSBsb2coeCkgLyBsb2coMjU2KQogICAgcmV0dXJuIE1hdGguZmxvb3IoTWF0aC5sb2cobikgLyBNYXRoLmxvZygyICoqIDgpICsgMSk7Cn0KZnVuY3Rpb24gYXJyYXlCdWZmZXJUb051bWJlcihhcnJheUJ1ZmZlcikgewogICAgLy8gMzJiaXQg44G+44Gn44KS5oOz5a6aIChCaWdJbn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WwuYnVmZmVyLCAiSEtERiIsIGZhbHNlLCBbImRlcml2ZUJpdHMiLCAiZGVyaXZlS2V5Il0pCiAgICAgICAgICAgICAgICAudGhlbigobWF0ZXJpYWwpID0+IHsKICAgICAgICAgICAgICAgIGdlbmVyYXRlRGVyaXZlS2V5KG1hdGVyaWFsKS50aGVuKChkZXJpdmVLZXkpID0+IHsKICAgICAgICAgICAgICAgICAgICBzZXRTZWxmRGVyaXZlS2V5KHNlbGZDb25uZWN0aW9uSWQsIHNlbGZLZXlJZCwgZGVyaXZlS2V5KTsKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgZ2VuZXJhdGVXcml0ZUlWKG1hdGVyaWFsKS50aGVuKCh3cml0ZUlWKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgc2V0V3JpdGVJVihzZWxmQ29ubmVjdGlvbklkLCBzZWxmS2V5SWQsIHdyaXRlSVYpOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQodGltZW91dElkKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgfSwgd2FpdGluZ1RpbWUgfHwgMCk7CiAgICAgICAgLy8gVE9ETzogKzEwMDAg44Gn6Y2155Sf5oiQ5b6M44Gr5a6f6KGM44GV44KM44KL44KI44GG44Gr44GX44Gm44GE44KL44GM55+t44GE5aC05ZCI44Gv5Ly444Gw44GZCiAgICAgICAgY29uc3QgcmVtb3ZhbFdhaXRpbmdUaW1lID0gKHdhaXRpbmdUaW1lIHx8IDApICsgMTAwMDsKICAgICAgICBpZiAocmVtb3ZhbFRpbWVvdXRJZCkgewogICAgICAgICAgICAvLyDli5XkvZzmuIjjgb/jgr/jgqTjg57jg7zmnInjgooKICAgICAgICAgICAgaWYgKHdhaXRpbmdUaW1lKSB7CiAgICAgICAgICAgICAgICAvLyBjb25uZWN0aW9uLmRlc3Ryb3llZAogICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KHJlbW92YWxUaW1lb3V0SWQpOwogICAgICAgICAgICAgICAgcmVtb3ZhbFRpbWVvdXRJZCA9IHNldFRpbWVvdXQoKCkgPT4gewogICAgICAgICAgICAgICAgICAgIHJlbW92ZU9sZFJlbW90ZURlcml2ZUtleXMoKTsKICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQocmVtb3ZhbFRpbWVvdXRJZCk7CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZhbFRpbWVvdXRJZCA9IDA7CiAgICAgICAgICAgICAgICB9LCByZW1vdmFsV2FpdGluZ1RpbWUpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGVsc2UgewogICAgICAgICAgICAvLyDli5XkvZzmuIjjgb/jgr/jgqTjg57jg7zjgarjgZcKICAgICAgICAgICAgLy8gY29ubmVjdGlvbi5jcmVhdGVkIOOBruWgtOWQiOOCguWwkeOBl+Wun+ihjOOCkumBheOCieOBm+OCiwogICAgICAgICAgICByZW1vdmFsVGltZW91dElkID0gc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICByZW1vdmVPbGRSZW1vdGVEZXJpdmVLZXlzKCk7CiAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQocmVtb3ZhbFRpbWVvdXRJZCk7CiAgICAgICAgICAgICAgICByZW1vdmFsVGltZW91dElkID0gMDsKICAgICAgICAgICAgfSwgcmVtb3ZhbFdhaXRpbmdUaW1lKTsKICAgICAgICB9CiAgICB9CiAgICBlbHNlIGlmICh0eXBlID09PSAicmVtb3RlU2VjcmV0S2V5TWF0ZXJpYWxzIikgewogICAgICAgIGNvbnN0IHsgcmVtb3RlU2VjcmV0S2V5TWF0ZXJpYWxzIH0gPSBldmVudC5kYXRhOwogICAgICAgIGZvciAoY29uc3QgW2Nvbm5lY3Rpb25JZCwgcmVtb3RlU2VjcmV0S2V5TWF0ZXJpYWxdIG9mIE9iamVjdC5lbnRyaWVzKHJlbW90ZVNlY3JldEtleU1hdGVyaWFscykpIHsKICAgICAgICAgICAgY29uc3QgeyBrZXlJZCwgc2VjcmV0S2V5TWF0ZXJpYWwgfSA9IHJlbW90ZVNlY3JldEtleU1hdGVyaWFsOwogICAgICAgICAgICBjcnlwdG8uc3VidGxlCiAgICAgICAgICAgICAgICAuaW1wb3J0S2V5KCJyYXciLCBzZWNyZXRLZXlNYXRlcmlhbC5idWZmZXIsICJIS0RGIiwgZmFsc2UsIFsiZGVyaXZlQml0cyIsICJkZXJpdmVLZXkiXSkKICAgICAgICAgICAgICAgIC50aGVuKChtYXRlcmlhbCkgPT4gewogICAgICAgICAgICAgICAgZ2VuZXJhdGVEZXJpdmVLZXkobWF0ZXJpYWwpLnRoZW4oKGRlcml2ZUtleSkgPT4gewogICAgICAgICAgICAgICAgICAgIHNldFJlbW90ZURlcml2ZUtleShjb25uZWN0aW9uSWQsIGtleUlkLCBkZXJpdmVLZXkpOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBnZW5lcmF0ZVdyaXRlSVYobWF0ZXJpYWwpLnRoZW4oKHdyaXRlSVYpID0+IHsKICAgICAgICAgICAgICAgICAgICBzZXRXcml0ZUlWKGNvbm5lY3Rpb25JZCwga2V5SWQsIHdyaXRlSVYpOwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBzZXRMYXRlc3RSZW1vdGVLZXlJZChjb25uZWN0aW9uSWQsIGtleUlkKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgfQogICAgfQogICAgZWxzZSBpZiAodHlwZSA9PT0gInJlbW92ZVJlbW90ZURlcml2ZUtleSIpIHsKICAgICAgICBjb25zdCB7IGNvbm5lY3Rpb25JZCB9ID0gZXZlbnQuZGF0YTsKICAgICAgICByZW1vdmVEZXJpdmVLZXkoY29ubmVjdGlvbklkKTsKICAgIH0KICAgIGVsc2UgaWYgKHR5cGUgPT09ICJlbmNyeXB0IikgewogICAgICAgIGNvbnN0IHsgcmVhZGFibGVTdHJlYW0sIHdyaXRhYmxlU3RyZWFtIH0gPSBldmVudC5kYXRhOwogICAgICAgIGNvbnN0IHRyYW5zZm9ybVN0cmVhbSA9IG5ldyBUcmFuc2Zvcm1TdHJlYW0oewogICAgICAgICAgICB0cmFuc2Zvcm06IGVuY3J5cHRGdW5jdGlvbiwKICAgICAgICB9KTsKICAgICAgICByZWFkYWJsZVN0cmVhbS5waXBlVGhyb3VnaCh0cmFuc2Zvcm1TdHJlYW0pLnBpcGVUbyh3cml0YWJsZVN0cmVhbSk7CiAgICB9CiAgICBlbHNlIGlmICh0eXBlID09PSAiZGVjcnlwdCIpIHsKICAgICAgICBjb25zdCB7IHJlYWRhYmxlU3RyZWFtLCB3cml0YWJsZVN0cmVhbSB9ID0gZXZlbnQuZGF0YTsKICAgICAgICBjb25zdCB0cmFuc2Zvcm1TdHJlYW0gPSBuZXcgVHJhbnNmb3JtU3RyZWFtKHsKICAgICAgICAgICAgdHJhbnNmb3JtOiBkZWNyeXB0RnVuY3Rpb24sCiAgICAgICAgfSk7CiAgICAgICAgcmVhZGFibGVTdHJlYW0ucGlwZVRocm91Z2godHJhbnNmb3JtU3RyZWFtKS5waXBlVG8od3JpdGFibGVTdHJlYW0pOwogICAgfQogICAgZWxzZSBpZiAodHlwZSA9PT0gImNsZWFyIikgewogICAgICAgIGNvdW50TWFwLmNsZWFyKCk7CiAgICAgICAgd3JpdGVJVk1hcC5jbGVhcigpOwogICAgICAgIHJlbW90ZURlcml2ZUtleU1hcC5jbGVhcigpOwogICAgICAgIGxhdGVzdFJlbW90ZUtleUlkTWFwLmNsZWFyKCk7CiAgICAgICAgc2VsZkRlcml2ZUtleU1hcC5jbGVhcigpOwogICAgfQp9Owo=");this.worker=new Worker(URL.createObjectURL(new Blob([e],{type:"application/javascript"}))),this.worker.onmessage=e=>{const{operation:t}=e.data;"disconnect"===t&&"function"===typeof this.onWorkerDisconnect&&this.onWorkerDisconnect()}}clearWorker(){this.worker&&this.worker.postMessage({type:"clear"})}terminateWorker(){this.worker&&this.worker.terminate()}async init(){const{preKeyBundle:e}=await window.e2ee.init();return e}setupSenderTransform(e){if(!e.track)return;const t=e.createEncodedStreams(),n=t.readableStream||t.readable,i=t.writableStream||t.writable;if(!this.worker)throw new Error("Worker is null. Call startWorker in advance.");const o={type:"encrypt",readableStream:n,writableStream:i};this.worker.postMessage(o,[n,i])}setupReceiverTransform(e){const t=e.createEncodedStreams(),n=t.readableStream||t.readable,i=t.writableStream||t.writable;if(!this.worker)throw new Error("Worker is null. Call startWorker in advance.");const o={type:"decrypt",readableStream:n,writableStream:i};this.worker.postMessage(o,[n,i])}postRemoteSecretKeyMaterials(e){if(!this.worker)throw new Error("Worker is null. Call startWorker in advance.");this.worker.postMessage({type:"remoteSecretKeyMaterials",remoteSecretKeyMaterials:e.remoteSecretKeyMaterials})}postRemoveRemoteDeriveKey(e){if(!this.worker)throw new Error("Worker is null. Call startWorker in advance.");this.worker.postMessage({type:"removeRemoteDeriveKey",connectionId:e})}postSelfSecretKeyMaterial(e,t,n,i=0){if(!this.worker)throw new Error("Worker is null. Call startWorker in advance.");this.worker.postMessage({type:"selfSecretKeyMaterial",selfConnectionId:e,selfKeyId:t,selfSecretKeyMaterial:n,waitingTime:i})}startSession(e,t){const[n,i]=window.e2ee.startSession(e,t.identityKey,t.signedPreKey,t.preKeySignature);if(i)throw i;return n}stopSession(e){const[t,n]=window.e2ee.stopSession(e);if(n)throw n;return t}receiveMessage(e){const[t,n]=window.e2ee.receiveMessage(e);if(n)throw n;return t}start(e){const[t,n]=window.e2ee.start(e);if(n)throw n;return t}addPreKeyBundle(e,t){const n=window.e2ee.addPreKeyBundle(e,t.identityKey,t.signedPreKey,t.preKeySignature);if(n)throw n}selfFingerprint(){return window.e2ee.selfFingerprint()}remoteFingerprints(){return window.e2ee.remoteFingerprints()}static async loadWasm(e){if(void 0===!window.e2ee)return void console.warn("E2ee wasm is already loaded. Will not be reload.");if((()=>{if("undefined"!==typeof global);else if("undefined"!==typeof window)window.global=window;else{if("undefined"===typeof self)throw new Error("cannot export Go (neither global, window nor self is defined)");self.global=self}if(global.require||"undefined"===typeof require||(global.require=require),!global.fs&&global.require){const e=require("fs");0!==Object.keys(e)&&(global.fs=e)}const e=()=>{const e=new Error("not implemented");return e.code="ENOSYS",e};if(!global.fs){let t="";global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(e,i){t+=n.decode(i);const o=t.lastIndexOf("\n");return-1!=o&&(console.log(t.substr(0,o)),t=t.substr(o+1)),i.length},write(t,n,i,o,a,r){0===i&&o===n.length&&null===a?r(null,this.writeSync(t,n)):r(e())},chmod(t,n,i){i(e())},chown(t,n,i,o){o(e())},close(t,n){n(e())},fchmod(t,n,i){i(e())},fchown(t,n,i,o){o(e())},fstat(t,n){n(e())},fsync(e,t){t(null)},ftruncate(t,n,i){i(e())},lchown(t,n,i,o){o(e())},link(t,n,i){i(e())},lstat(t,n){n(e())},mkdir(t,n,i){i(e())},open(t,n,i,o){o(e())},read(t,n,i,o,a,r){r(e())},readdir(t,n){n(e())},readlink(t,n){n(e())},rename(t,n,i){i(e())},rmdir(t,n){n(e())},stat(t,n){n(e())},symlink(t,n,i){i(e())},truncate(t,n,i){i(e())},unlink(t,n){n(e())},utimes(t,n,i,o){o(e())}}}if(global.process||(global.process={getuid:()=>-1,getgid:()=>-1,geteuid:()=>-1,getegid:()=>-1,getgroups(){throw e()},pid:-1,ppid:-1,umask(){throw e()},cwd(){throw e()},chdir(){throw e()}}),!global.crypto){const e=require("crypto");global.crypto={getRandomValues(t){e.randomFillSync(t)}}}global.performance||(global.performance={now(){const[e,t]=i.hrtime();return 1e3*e+t/1e6}}),global.TextEncoder||(global.TextEncoder=require("util").TextEncoder),global.TextDecoder||(global.TextDecoder=require("util").TextDecoder);const t=new TextEncoder("utf-8"),n=new TextDecoder("utf-8");if(global.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{0!==e&&console.warn("exit code:",e)},this._exitPromise=new Promise((e=>{this._resolveExitPromise=e})),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const e=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=e=>this.mem.getUint32(e+0,!0)+4294967296*this.mem.getInt32(e+4,!0),o=e=>{const t=this.mem.getFloat64(e,!0);if(0===t)return;if(!isNaN(t))return t;const n=this.mem.getUint32(e,!0);return this._values[n]},a=(e,t)=>{const n=2146959360;if("number"===typeof t&&0!==t)return isNaN(t)?(this.mem.setUint32(e+4,n,!0),void this.mem.setUint32(e,0,!0)):void this.mem.setFloat64(e,t,!0);if(void 0===t)return void this.mem.setFloat64(e,0,!0);let i=this._ids.get(t);void 0===i&&(i=this._idPool.pop(),void 0===i&&(i=this._values.length),this._values[i]=t,this._goRefCounts[i]=0,this._ids.set(t,i)),this._goRefCounts[i]++;let o=0;switch(typeof t){case"object":null!==t&&(o=1);break;case"string":o=2;break;case"symbol":o=3;break;case"function":o=4}this.mem.setUint32(e+4,n|o,!0),this.mem.setUint32(e,i,!0)},r=e=>{const t=i(e+0),n=i(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,n)},s=e=>{const t=i(e+0),n=i(e+8),a=new Array(n);for(let i=0;i<n;i++)a[i]=o(t+8*i);return a},c=e=>{const t=i(e+0),o=i(e+8);return n.decode(new DataView(this._inst.exports.mem.buffer,t,o))},l=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{const t=i(e+8),n=i(e+16),o=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,n,o))},"runtime.resetMemoryDataView":e=>{this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{e(t+8,1e6*(l+performance.now()))},"runtime.walltime1":t=>{const n=(new Date).getTime();e(t+8,n/1e3),this.mem.setInt32(t+16,n%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout((()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()}),i(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{crypto.getRandomValues(r(e+8))},"syscall/js.finalizeRef":e=>{const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,0===this._goRefCounts[t]){const e=this._values[t];this._values[t]=null,this._ids.delete(e),this._idPool.push(t)}},"syscall/js.stringVal":e=>{a(e+24,c(e+8))},"syscall/js.valueGet":e=>{const t=Reflect.get(o(e+8),c(e+16));e=this._inst.exports.getsp(),a(e+32,t)},"syscall/js.valueSet":e=>{Reflect.set(o(e+8),c(e+16),o(e+32))},"syscall/js.valueDelete":e=>{Reflect.deleteProperty(o(e+8),c(e+16))},"syscall/js.valueIndex":e=>{a(e+24,Reflect.get(o(e+8),i(e+16)))},"syscall/js.valueSetIndex":e=>{Reflect.set(o(e+8),i(e+16),o(e+24))},"syscall/js.valueCall":e=>{try{const t=o(e+8),n=Reflect.get(t,c(e+16)),i=s(e+32),r=Reflect.apply(n,t,i);e=this._inst.exports.getsp(),a(e+56,r),this.mem.setUint8(e+64,1)}catch(N){a(e+56,N),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{try{const t=o(e+8),n=s(e+16),i=Reflect.apply(t,void 0,n);e=this._inst.exports.getsp(),a(e+40,i),this.mem.setUint8(e+48,1)}catch(N){a(e+40,N),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{try{const t=o(e+8),n=s(e+16),i=Reflect.construct(t,n);e=this._inst.exports.getsp(),a(e+40,i),this.mem.setUint8(e+48,1)}catch(N){a(e+40,N),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":t=>{e(t+16,parseInt(o(t+8).length))},"syscall/js.valuePrepareString":n=>{const i=t.encode(String(o(n+8)));a(n+16,i),e(n+24,i.length)},"syscall/js.valueLoadString":e=>{const t=o(e+8);r(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{this.mem.setUint8(e+24,o(e+8)instanceof o(e+16)?1:0)},"syscall/js.copyBytesToGo":t=>{const n=r(t+8),i=o(t+32);if(!(i instanceof Uint8Array||i instanceof Uint8ClampedArray))return void this.mem.setUint8(t+48,0);const a=i.subarray(0,n.length);n.set(a),e(t+40,a.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{const n=o(t+8),i=r(t+16);if(!(n instanceof Uint8Array||n instanceof Uint8ClampedArray))return void this.mem.setUint8(t+48,0);const a=i.subarray(0,n.length);n.set(a),e(t+40,a.length),this.mem.setUint8(t+48,1)},debug:e=>{console.log(e)}}}}async run(e){this._inst=e,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[global,5],[this,6]]),this._idPool=[],this.exited=!1;let n=4096;const i=e=>{const i=n,o=t.encode(e+"\0");return new Uint8Array(this.mem.buffer,n,o.length).set(o),n+=o.length,n%8!==0&&(n+=8-n%8),i},o=this.argv.length,a=[];this.argv.forEach((e=>{a.push(i(e))})),a.push(0),Object.keys(this.env).sort().forEach((e=>{a.push(i(`${e}=${this.env[e]}`))})),a.push(0);const r=n;a.forEach((e=>{this.mem.setUint32(n,e,!0),this.mem.setUint32(n+4,0,!0),n+=8})),this._inst.exports.run(o,r),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(e){const t=this;return function(){const n={id:e,this:this,args:arguments};return t._pendingEvent=n,t._resume(),n.result}}},global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){i.argv.length<3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),i.exit(1));const e=new Go;e.argv=i.argv.slice(2),e.env=Object.assign({TMPDIR:require("os").tmpdir()},i.env),e.exit=i.exit,WebAssembly.instantiate(fs.readFileSync(i.argv[2]),e.importObject).then((t=>(i.on("exit",(t=>{0!==t||e.exited||(e._pendingEvent={id:0},e._resume())})),e.run(t.instance)))).catch((e=>{console.error(e),i.exit(1)}))}})(),!window.Go)throw new Error(`Failed to load module Go. window.Go is ${window.Go}.`);const t=new Go,{instance:n}=await WebAssembly.instantiateStreaming(fetch(e),t.importObject);if(t.run(n),!window.e2ee)throw new Error(`Failed to load module e2ee. window.e2ee is ${window.e2ee}.`)}static version(){return"2021.2.0-canary.3"}static wasmVersion(){return window.e2ee.version()}}var a=Uint8Array,r=Uint16Array,s=Uint32Array,c=new a([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,0,0,0]),l=new a([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,0,0]),u=new a([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d=function(e,t){for(var n=new r(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var o=new s(n[30]);for(i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)o[a]=a-n[i]<<5|i;return[n,o]},g=d(c,2),f=g[0],h=g[1];f[28]=258,h[258]=28;for(var p=d(l,0),C=p[0],m=p[1],I=new r(32768),y=0;y<32768;++y){var b=(43690&y)>>>1|(21845&y)<<1;b=(61680&(b=(52428&b)>>>2|(13107&b)<<2))>>>4|(3855&b)<<4,I[y]=((65280&b)>>>8|(255&b)<<8)>>>1}var v=function(e,t,n){for(var i=e.length,o=0,a=new r(t);o<i;++o)++a[e[o]-1];var s,c=new r(t);for(o=0;o<t;++o)c[o]=c[o-1]+a[o-1]<<1;if(n){s=new r(1<<t);var l=15-t;for(o=0;o<i;++o)if(e[o])for(var u=o<<4|e[o],d=t-e[o],g=c[e[o]-1]++<<d,f=g|(1<<d)-1;g<=f;++g)s[I[g]>>>l]=u}else for(s=new r(i),o=0;o<i;++o)e[o]&&(s[o]=I[c[e[o]-1]++]>>>15-e[o]);return s},A=new a(288);for(y=0;y<144;++y)A[y]=8;for(y=144;y<256;++y)A[y]=9;for(y=256;y<280;++y)A[y]=7;for(y=280;y<288;++y)A[y]=8;var S=new a(32);for(y=0;y<32;++y)S[y]=5;var w=v(A,9,0),Z=v(A,9,1),k=v(S,5,0),V=v(S,5,1),R=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},T=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},W=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},G=function(e){return(e+7)/8|0},O=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof r?r:e instanceof s?s:a)(n-t);return i.set(e.subarray(t,n)),i},E=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],N=function(e,t,n){var i=new Error(t||E[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,N),!n)throw i;return i},M=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8},D=function(e,t,n){n<<=7&t;var i=t/8|0;e[i]|=n,e[i+1]|=n>>>8,e[i+2]|=n>>>16},B=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var o=n.length,s=n.slice();if(!o)return[U,0];if(1==o){var c=new a(n[0].s+1);return c[n[0].s]=1,[c,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var l=n[0],u=n[1],d=0,g=1,f=2;for(n[0]={s:-1,f:l.f+u.f,l:l,r:u};g!=o-1;)l=n[n[d].f<n[f].f?d++:f++],u=n[d!=g&&n[d].f<n[f].f?d++:f++],n[g++]={s:-1,f:l.f+u.f,l:l,r:u};var h=s[0].s;for(i=1;i<o;++i)s[i].s>h&&(h=s[i].s);var p=new r(h+1),C=X(n[g-1],p,0);if(C>t){i=0;var m=0,I=C-t,y=1<<I;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i<o;++i){var b=s[i].s;if(!(p[b]>t))break;m+=y-(1<<C-p[b]),p[b]=t}for(m>>>=I;m>0;){var v=s[i].s;p[v]<t?m-=1<<t-p[v]++-1:++i}for(;i>=0&&m;--i){var A=s[i].s;p[A]==t&&(--p[A],++m)}C=t}return[new a(p),C]},X=function(e,t,n){return-1==e.s?Math.max(X(e.l,t,n+1),X(e.r,t,n+1)):t[e.s]=n},F=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new r(++t),i=0,o=e[0],a=1,s=function(e){n[i++]=e},c=1;c<=t;++c)if(e[c]==o&&c!=t)++a;else{if(!o&&a>2){for(;a>138;a-=138)s(32754);a>2&&(s(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(s(o),--a;a>6;a-=6)s(8304);a>2&&(s(a-3<<5|8208),a=0)}for(;a--;)s(o);a=1,o=e[c]}return[n.subarray(0,i),t]},x=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},j=function(e,t,n){var i=n.length,o=G(t+2);e[o]=255&i,e[o+1]=i>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var a=0;a<i;++a)e[o+a+4]=n[a];return 8*(o+4+i)},Y=function(e,t,n,i,o,a,s,d,g,f,h){M(t,h++,n),++o[256];for(var p=B(o,15),C=p[0],m=p[1],I=B(a,15),y=I[0],b=I[1],Z=F(C),V=Z[0],R=Z[1],T=F(y),W=T[0],G=T[1],O=new r(19),E=0;E<V.length;++E)O[31&V[E]]++;for(E=0;E<W.length;++E)O[31&W[E]]++;for(var N=B(O,7),X=N[0],Y=N[1],L=19;L>4&&!X[u[L-1]];--L);var U,J,K,P,H=f+5<<3,Q=x(o,A)+x(a,S)+s,_=x(o,C)+x(a,y)+s+14+3*L+x(O,X)+(2*O[16]+3*O[17]+7*O[18]);if(H<=Q&&H<=_)return j(t,h,e.subarray(g,g+f));if(M(t,h,1+(_<Q)),h+=2,_<Q){U=v(C,m,0),J=C,K=v(y,b,0),P=y;var z=v(X,Y,0);M(t,h,R-257),M(t,h+5,G-1),M(t,h+10,L-4),h+=14;for(E=0;E<L;++E)M(t,h+3*E,X[u[E]]);h+=3*L;for(var $=[V,W],q=0;q<2;++q){var ee=$[q];for(E=0;E<ee.length;++E){var te=31&ee[E];M(t,h,z[te]),h+=X[te],te>15&&(M(t,h,ee[E]>>>5&127),h+=ee[E]>>>12)}}}else U=w,J=A,K=k,P=S;for(E=0;E<d;++E)if(i[E]>255){te=i[E]>>>18&31;D(t,h,U[te+257]),h+=J[te+257],te>7&&(M(t,h,i[E]>>>23&31),h+=c[te]);var ne=31&i[E];D(t,h,K[ne]),h+=P[ne],ne>3&&(D(t,h,i[E]>>>5&8191),h+=l[ne])}else D(t,h,U[i[E]]),h+=J[i[E]];return D(t,h,U[256]),h+J[256]},L=new s([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),U=new a(0),J=function(e,t,n,i,o){return function(e,t,n,i,o,u){var d=e.length,g=new a(i+d+5*(1+Math.ceil(d/7e3))+o),f=g.subarray(i,g.length-o),p=0;if(!t||d<8)for(var C=0;C<=d;C+=65535){var I=C+65535;I<d?p=j(f,p,e.subarray(C,I)):(f[C]=u,p=j(f,p,e.subarray(C,d)))}else{for(var y=L[t-1],b=y>>>13,v=8191&y,A=(1<<n)-1,S=new r(32768),w=new r(A+1),Z=Math.ceil(n/3),k=2*Z,V=function(t){return(e[t]^e[t+1]<<Z^e[t+2]<<k)&A},R=new s(25e3),T=new r(288),W=new r(32),E=0,N=0,M=(C=0,0),D=0,B=0;C<d;++C){var X=V(C),F=32767&C,x=w[X];if(S[F]=x,w[X]=F,D<=C){var J=d-C;if((E>7e3||M>24576)&&J>423){p=Y(e,f,0,R,T,W,N,M,B,C-B,p),M=E=N=0,B=C;for(var K=0;K<286;++K)T[K]=0;for(K=0;K<30;++K)W[K]=0}var P=2,H=0,Q=v,_=F-x&32767;if(J>2&&X==V(C-_))for(var z=Math.min(b,J)-1,$=Math.min(32767,C),q=Math.min(258,J);_<=$&&--Q&&F!=x;){if(e[C+P]==e[C+P-_]){for(var ee=0;ee<q&&e[C+ee]==e[C+ee-_];++ee);if(ee>P){if(P=ee,H=_,ee>z)break;var te=Math.min(_,ee-2),ne=0;for(K=0;K<te;++K){var ie=C-_+K+32768&32767,oe=ie-S[ie]+32768&32767;oe>ne&&(ne=oe,x=ie)}}}_+=(F=x)-(x=S[F])+32768&32767}if(H){R[M++]=268435456|h[P]<<18|m[H];var ae=31&h[P],re=31&m[H];N+=c[ae]+l[re],++T[257+ae],++W[re],D=C+P,++E}else R[M++]=e[C],++T[e[C]]}}p=Y(e,f,u,R,T,W,N,M,B,C-B,p),!u&&7&p&&(p=j(f,p+1,U))}return O(g,0,i+G(p)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,i,!o)};function K(e,t){t||(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var i=e,o=t,a=0|n.length,r=0;r!=a;){for(var s=Math.min(r+2655,a);r<s;++r)o+=i+=n[r];i=(65535&i)+15*(i>>16),o=(65535&o)+15*(o>>16)}e=i,t=o},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}}();n.p(e);var i=J(e,t,2,4);return function(e,t){var n=t.level,i=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=i<<6|(i?32-2*i:1)}(i,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(i,i.length-4,n.d()),i}function P(e,t){return function(e,t,n){var i=e.length;if(!i||n&&n.f&&!n.l)return t||new a(0);var o=!t||n,r=!n||n.i;n||(n={}),t||(t=new a(3*i));var s=function(e){var n=t.length;if(e>n){var i=new a(Math.max(2*n,e));i.set(t),t=i}},d=n.f||0,g=n.p||0,h=n.b||0,p=n.l,m=n.d,I=n.m,y=n.n,b=8*i;do{if(!p){d=T(e,g,1);var A=T(e,g+1,3);if(g+=3,!A){var S=e[(Y=G(g)+4)-4]|e[Y-3]<<8,w=Y+S;if(w>i){r&&N(0);break}o&&s(h+S),t.set(e.subarray(Y,w),h),n.b=h+=S,n.p=g=8*w,n.f=d;continue}if(1==A)p=Z,m=V,I=9,y=5;else if(2==A){var k=T(e,g,31)+257,E=T(e,g+10,15)+4,M=k+T(e,g+5,31)+1;g+=14;for(var D=new a(M),B=new a(19),X=0;X<E;++X)B[u[X]]=T(e,g+3*X,7);g+=3*E;var F=R(B),x=(1<<F)-1,j=v(B,F,1);for(X=0;X<M;){var Y,L=j[T(e,g,x)];if(g+=15&L,(Y=L>>>4)<16)D[X++]=Y;else{var U=0,J=0;for(16==Y?(J=3+T(e,g,3),g+=2,U=D[X-1]):17==Y?(J=3+T(e,g,7),g+=3):18==Y&&(J=11+T(e,g,127),g+=7);J--;)D[X++]=U}}var K=D.subarray(0,k),P=D.subarray(k);I=R(K),y=R(P),p=v(K,I,1),m=v(P,y,1)}else N(1);if(g>b){r&&N(0);break}}o&&s(h+131072);for(var H=(1<<I)-1,Q=(1<<y)-1,_=g;;_=g){var z=(U=p[W(e,g)&H])>>>4;if((g+=15&U)>b){r&&N(0);break}if(U||N(2),z<256)t[h++]=z;else{if(256==z){_=g,p=null;break}var $=z-254;if(z>264){var q=c[X=z-257];$=T(e,g,(1<<q)-1)+f[X],g+=q}var ee=m[W(e,g)&Q],te=ee>>>4;if(ee||N(3),g+=15&ee,P=C[te],te>3&&(q=l[te],P+=W(e,g)&(1<<q)-1,g+=q),g>b){r&&N(0);break}o&&s(h+131072);for(var ne=h+$;h<ne;h+=4)t[h]=t[h-P],t[h+1]=t[h+1-P],t[h+2]=t[h+2-P],t[h+3]=t[h+3-P];h=ne}}n.l=p,n.p=_,n.b=h,n.f=d,p&&(d=1,n.m=I,n.d=m,n.n=y)}while(!d);return h==t.length?t:O(t,0,h)}(((8!=(15&(n=e)[0])||n[0]>>>4>7||(n[0]<<8|n[1])%31)&&N(6,"invalid zlib data"),32&n[1]&&N(6,"invalid zlib data: preset dictionaries not supported"),e.subarray(2,-4)),t);var n}var H="undefined"!=typeof TextDecoder&&new TextDecoder;try{H.decode(U,{stream:!0}),1}catch(ce){}function Q(e){if("object"!==typeof e||null===e)throw new Error("Failed to parse options dataChannels. Options dataChannels element must be type 'object'");const t=e,n={};return"string"===typeof t.label&&(n.label=t.label),"string"===typeof t.direction&&(n.direction=t.direction),"boolean"===typeof t.ordered&&(n.ordered=t.ordered),"boolean"===typeof t.compress&&(n.compress=t.compress),"number"===typeof t.maxPacketLifeTime&&(n.max_packet_life_time=t.maxPacketLifeTime),"number"===typeof t.maxRetransmits&&(n.max_retransmits=t.maxRetransmits),"string"===typeof t.protocol&&(n.protocol=t.protocol),n}function _(){return"safari"===function(){const e=window.navigator.userAgent.toLocaleLowerCase();return-1!==e.indexOf("edge")?"edge":-1!==e.indexOf("chrome")&&-1===e.indexOf("edge")?"chrome":-1!==e.indexOf("safari")&&-1===e.indexOf("chrome")?"safari":-1!==e.indexOf("opera")?"opera":-1!==e.indexOf("firefox")?"firefox":null}()}function z(e,t,n,i,o,a){if("sendrecv"!==t&&"sendonly"!==t&&"recvonly"!==t)throw new Error("Unknown role type");if(null===n||void 0===n)throw new Error("channelId can not be null or undefined");const r={type:"connect",sora_client:"Sora JavaScript SDK 2021.2.0-canary.3",environment:window.navigator.userAgent,role:t,channel_id:n,sdp:e,audio:!0,video:!0};if(void 0!==i&&(r.metadata=i),a&&(r.redirect=!0),"signalingNotifyMetadata"in o&&(r.signaling_notify_metadata=o.signalingNotifyMetadata),"multistream"in o&&!0===o.multistream&&(r.multistream=!0,"spotlight"in o&&(r.spotlight=o.spotlight,"spotlightNumber"in o&&(r.spotlight_number=o.spotlightNumber)),!0===r.spotlight)){const e=["none","r0","r1","r2"];void 0!==o.spotlightFocusRid&&0<=e.indexOf(o.spotlightFocusRid)&&(r.spotlight_focus_rid=o.spotlightFocusRid),void 0!==o.spotlightUnfocusRid&&0<=e.indexOf(o.spotlightUnfocusRid)&&(r.spotlight_unfocus_rid=o.spotlightUnfocusRid)}if("simulcast"in o||"simulcastRid"in o){"simulcast"in o&&!0===o.simulcast&&(r.simulcast=!0);const e=["r0","r1","r2"];void 0!==o.simulcastRid&&0<=e.indexOf(o.simulcastRid)&&(r.simulcast_rid=o.simulcastRid)}"clientId"in o&&void 0!==o.clientId&&(r.client_id=o.clientId),"dataChannelSignaling"in o&&"boolean"===typeof o.dataChannelSignaling&&(r.data_channel_signaling=o.dataChannelSignaling),"ignoreDisconnectWebSocket"in o&&"boolean"===typeof o.ignoreDisconnectWebSocket&&(r.ignore_disconnect_websocket=o.ignoreDisconnectWebSocket);const s=["audioCodecType","audioBitRate"],c=["audioOpusParamsChannels","audioOpusParamsClockRate","audioOpusParamsMaxplaybackrate","audioOpusParamsStereo","audioOpusParamsSpropStereo","audioOpusParamsMinptime","audioOpusParamsPtime","audioOpusParamsUseinbandfec","audioOpusParamsUsedtx"],l=["videoCodecType","videoBitRate"],u=Object.assign({},o);Object.keys(u).forEach((e=>{"audio"===e&&"boolean"===typeof u[e]||"video"===e&&"boolean"===typeof u[e]||0<=s.indexOf(e)&&null!==u[e]||0<=c.indexOf(e)&&null!==u[e]||0<=l.indexOf(e)&&null!==u[e]||delete u[e]})),void 0!==u.audio&&(r.audio=u.audio);const d=Object.keys(u).some((e=>0<=s.indexOf(e)));r.audio&&d&&(r.audio={},"audioCodecType"in u&&(r.audio.codec_type=u.audioCodecType),"audioBitRate"in u&&(r.audio.bit_rate=u.audioBitRate));const g=Object.keys(u).some((e=>0<=c.indexOf(e)));r.audio&&g&&("object"!=typeof r.audio&&(r.audio={}),r.audio.opus_params={},"audioOpusParamsChannels"in u&&(r.audio.opus_params.channels=u.audioOpusParamsChannels),"audioOpusParamsClockRate"in u&&(r.audio.opus_params.clock_rate=u.audioOpusParamsClockRate),"audioOpusParamsMaxplaybackrate"in u&&(r.audio.opus_params.maxplaybackrate=u.audioOpusParamsMaxplaybackrate),"audioOpusParamsStereo"in u&&(r.audio.opus_params.stereo=u.audioOpusParamsStereo),"audioOpusParamsSpropStereo"in u&&(r.audio.opus_params.sprop_stereo=u.audioOpusParamsSpropStereo),"audioOpusParamsMinptime"in u&&(r.audio.opus_params.minptime=u.audioOpusParamsMinptime),"audioOpusParamsPtime"in u&&(r.audio.opus_params.ptime=u.audioOpusParamsPtime),"audioOpusParamsUseinbandfec"in u&&(r.audio.opus_params.useinbandfec=u.audioOpusParamsUseinbandfec),"audioOpusParamsUsedtx"in u&&(r.audio.opus_params.usedtx=u.audioOpusParamsUsedtx)),void 0!==u.video&&(r.video=u.video);const f=Object.keys(u).some((e=>0<=l.indexOf(e)));if(r.video&&f&&(r.video={},"videoCodecType"in u&&(r.video.codec_type=u.videoCodecType),"videoBitRate"in u&&(r.video.bit_rate=u.videoBitRate)),r.simulcast&&!function(){if(!window.RTCRtpSender)return!1;if(!RTCRtpSender.getCapabilities)return!1;const e=RTCRtpSender.getCapabilities("video");if(!e)return!1;const t=e.headerExtensions.map((e=>e.uri));return["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"].every((e=>t.includes(e)))}()&&"recvonly"!==t)throw new Error("Simulcast can not be used with this browser");if(!0===o.e2ee){if(void 0===r.signaling_notify_metadata&&(r.signaling_notify_metadata={}),null===r.signaling_notify_metadata||"object"!==typeof r.signaling_notify_metadata)throw new Error("E2EE failed. Options signalingNotifyMetadata must be type 'object'");!0===r.video&&(r.video={}),r.video&&(r.video.codec_type="VP8"),r.e2ee=!0}return Array.isArray(o.dataChannels)&&0<o.dataChannels.length&&(r.data_channels=function(e){const t=[];for(const n of e)t.push(Q(n));return t}(o.dataChannels)),r}function $(e){return void 0!==e.authn_metadata?e.authn_metadata:void 0!==e.metadata?e.metadata:null}function q(e){return"object"===typeof e&&null!==e&&"pre_key_bundle"in e?e.pre_key_bundle:null}class ee extends Error{}function te(e,t,n){const i=new Event(e);try{i.data=JSON.parse(JSON.stringify(t))}catch(o){i.data=t}return i.transportType=n,i}function ne(e,t,n,i,o){const a=new Event(e);try{a.data=JSON.parse(JSON.stringify(t))}catch(r){a.data=t}return a.logType=n,a.dataChannelId=i,a.dataChannelLabel=o,a}class ie{constructor(e,t,n,i,o,a){this.role=t,this.channelId=n,this.metadata=i,this.signalingUrlCandidates=e,this.options=o,this.connectionTimeout=6e4,"number"===typeof this.options.timeout&&(console.warn("@deprecated timeout option will be removed in a future version. Use connectionTimeout."),this.connectionTimeout=this.options.timeout),"number"===typeof this.options.connectionTimeout&&(this.connectionTimeout=this.options.connectionTimeout),this.disconnectWaitTimeout=3e3,"number"===typeof this.options.disconnectWaitTimeout&&(this.disconnectWaitTimeout=this.options.disconnectWaitTimeout),this.signalingCandidateTimeout=3e3,"number"===typeof this.options.signalingCandidateTimeout&&(this.signalingCandidateTimeout=this.options.signalingCandidateTimeout),this.constraints=null,this.debug=a,this.clientId=null,this.connectionId=null,this.remoteConnectionIds=[],this.stream=null,this.ws=null,this.pc=null,this.encodings=[],this.callbacks={disconnect:()=>{},push:()=>{},addstream:()=>{},track:()=>{},removestream:()=>{},removetrack:()=>{},notify:()=>{},log:()=>{},timeout:()=>{},timeline:()=>{},signaling:()=>{},message:()=>{}},this.authMetadata=null,this.e2ee=null,this.connectionTimeoutTimerId=0,this.monitorSignalingWebSocketEventTimerId=0,this.monitorIceConnectionStateChangeTimerId=0,this.dataChannels={},this.mids={audio:"",video:""},this.signalingSwitched=!1,this.signalingOfferMessageDataChannels={}}on(e,t){"addstream"===e?console.warn("@deprecated addstream callback will be removed in a future version. Use track callback."):"removestream"===e&&console.warn("@deprecated removestream callback will be removed in a future version. Use removetrack callback."),e in this.callbacks&&(this.callbacks[e]=t)}stopAudioTrack(e){for(const t of e.getAudioTracks())t.enabled=!1;return new Promise((t=>{setTimeout((async()=>{for(const t of e.getAudioTracks())if(t.stop(),e.removeTrack(t),null!==this.pc){const e=this.pc.getSenders().find((e=>e.track&&e.track.id===t.id));e&&await e.replaceTrack(null)}t()}),100)}))}stopVideoTrack(e){for(const t of e.getVideoTracks())t.enabled=!1;return new Promise((t=>{setTimeout((async()=>{for(const t of e.getVideoTracks())if(t.stop(),e.removeTrack(t),null!==this.pc){const e=this.pc.getSenders().find((e=>e.track&&e.track.id===t.id));e&&await e.replaceTrack(null)}t()}),100)}))}async replaceAudioTrack(e,t){await this.stopAudioTrack(e);const n=this.getAudioTransceiver();if(null===n)throw new Error("Unable to set an audio track. Audio track sender is undefined");e.addTrack(t),await n.sender.replaceTrack(t)}async replaceVideoTrack(e,t){await this.stopVideoTrack(e);const n=this.getVideoTransceiver();if(null===n)throw new Error("Unable to set video track. Video track sender is undefined");e.addTrack(t),await n.sender.replaceTrack(t)}stopStream(){return new Promise(((e,t)=>(this.debug&&console.warn("@deprecated closing MediaStream in disconnect will be removed in a future version. Close every track in the MediaStream by yourself."),this.stream?(this.stream.getTracks().forEach((e=>{e.stop()})),this.stream=null,e()):e())))}async signalingTerminate(){await this.stopStream();for(const e of Object.keys(this.dataChannels)){const t=this.dataChannels[e];t&&t.close(),delete this.dataChannels[e]}this.ws&&(this.ws.close(),this.ws=null),this.pc&&this.pc.close(),this.e2ee&&this.e2ee.terminateWorker(),this.initializeConnection()}async abendPeerConnectionState(e){this.clearMonitorIceConnectionStateChange(),await this.stopStream(),this.pc&&(this.pc.ondatachannel=null,this.pc.oniceconnectionstatechange=null,this.pc.onicegatheringstatechange=null,this.pc.onconnectionstatechange=null),this.ws&&(this.ws.onclose=e=>{this.writeWebSocketTimelineLog("onclose",{code:e.code,reason:e.reason})},this.ws.onmessage=null,this.ws.onerror=null);for(const n of Object.keys(this.dataChannels)){const e=this.dataChannels[n];e&&(e.onclose=e=>{const t=e.currentTarget;this.writeDataChannelTimelineLog("onclose",t),this.trace("CLOSE DATA CHANNEL",t.label)},e.onmessage=null,e.onerror=null)}for(const n of Object.keys(this.dataChannels)){const e=this.dataChannels[n];e&&e.close(),delete this.dataChannels[n]}this.ws&&(this.ws.close(),this.ws=null),this.pc&&this.pc.close(),this.e2ee&&this.e2ee.terminateWorker(),this.initializeConnection();const t=this.soraCloseEvent("abend",e);this.callbacks.disconnect(t),this.writeSoraTimelineLog("disconnect-abend",t)}async abend(e,t){this.clearMonitorIceConnectionStateChange(),await this.stopStream(),this.pc&&(this.pc.ondatachannel=null,this.pc.oniceconnectionstatechange=null,this.pc.onicegatheringstatechange=null,this.pc.onconnectionstatechange=null),this.ws&&(this.ws.onclose=e=>{this.writeWebSocketTimelineLog("onclose",{code:e.code,reason:e.reason})},this.ws.onmessage=null,this.ws.onerror=null);for(const i of Object.keys(this.dataChannels)){const e=this.dataChannels[i];e&&(e.onclose=e=>{const t=e.currentTarget;this.writeDataChannelTimelineLog("onclose",t),this.trace("CLOSE DATA CHANNEL",t.label)},e.onmessage=null,e.onerror=null)}if(this.dataChannels.signaling){const t={type:"disconnect",reason:e};if(this.signalingOfferMessageDataChannels.signaling&&!0===this.signalingOfferMessageDataChannels.signaling.compress){const e=K((new TextEncoder).encode(JSON.stringify(t)),{});if("open"===this.dataChannels.signaling.readyState)try{this.dataChannels.signaling.send(e),this.writeDataChannelSignalingLog("send-disconnect",this.dataChannels.signaling,t)}catch(ce){const t=ce.message;this.writeDataChannelSignalingLog("failed-to-send-disconnect",this.dataChannels.signaling,t)}}else if("open"===this.dataChannels.signaling.readyState)try{this.dataChannels.signaling.send(JSON.stringify(t)),this.writeDataChannelSignalingLog("send-disconnect",this.dataChannels.signaling,t)}catch(ce){const t=ce.message;this.writeDataChannelSignalingLog("failed-to-send-disconnect",this.dataChannels.signaling,t)}}for(const i of Object.keys(this.dataChannels)){const e=this.dataChannels[i];e&&(e.onerror=null,e.close()),delete this.dataChannels[i]}if(await this.disconnectWebSocket(e),await this.disconnectPeerConnection(),this.e2ee&&this.e2ee.terminateWorker(),this.initializeConnection(),"WEBSOCKET-ONCLOSE"===e&&t&&(1e3===t.code||1005===t.code)){const e=this.soraCloseEvent("normal","DISCONNECT",t);return this.writeSoraTimelineLog("disconnect-normal",e),void this.callbacks.disconnect(e)}const n=this.soraCloseEvent("abend",e,t);this.writeSoraTimelineLog("disconnect-abend",n),this.callbacks.disconnect(this.soraCloseEvent("abend",e,t))}initializeConnection(){this.clientId=null,this.connectionId=null,this.remoteConnectionIds=[],this.stream=null,this.ws=null,this.pc=null,this.encodings=[],this.authMetadata=null,this.e2ee=null,this.dataChannels={},this.mids={audio:"",video:""},this.signalingSwitched=!1,this.signalingOfferMessageDataChannels={},this.clearConnectionTimeout()}disconnectWebSocket(e){let t=0;return this.signalingSwitched?(this.ws&&(this.ws.close(),this.ws=null),Promise.resolve(null)):new Promise(((n,i)=>{if(!this.ws)return n(null);if(this.ws.onclose=e=>(this.ws&&(this.ws.close(),this.ws=null),clearTimeout(t),this.writeWebSocketTimelineLog("onclose",{code:e.code,reason:e.reason}),n({code:e.code,reason:e.reason})),1!==this.ws.readyState)return this.ws.close(),this.ws=null,n(null);{const i={type:"disconnect",reason:e};this.ws.send(JSON.stringify(i)),this.writeWebSocketSignalingLog("send-disconnect",i),t=setTimeout((()=>{this.ws&&(this.ws.close(),this.ws=null),n(null)}),this.disconnectWaitTimeout)}}))}disconnectDataChannel(){const e=()=>{for(const e of Object.keys(this.dataChannels)){const t=this.dataChannels[e];t&&(t.onerror=null,t.close()),delete this.dataChannels[e]}};return new Promise(((t,n)=>{if(!this.dataChannels.signaling)return e(),t({code:4999,reason:""});const i=setTimeout((()=>(e(),n())),this.disconnectWaitTimeout),o=[];for(const r of Object.keys(this.dataChannels)){const n=this.dataChannels[r];if(n){n.onerror=()=>(clearTimeout(i),e(),t({code:4999,reason:""}));const a=()=>new Promise(((e,t)=>{let i=0;const o=setInterval((()=>{i++,"closed"===n.readyState&&(clearInterval(o),e()),this.disconnectWaitTimeout<100*i&&(e(),clearInterval(o))}),100)}));o.push(a())}}Promise.all(o).then((()=>{0===Object.keys(this.dataChannels).length?t(null):t({code:4999,reason:""})})).finally((()=>{e(),clearTimeout(i)}));const a={type:"disconnect",reason:"NO-ERROR"};if(this.signalingOfferMessageDataChannels.signaling&&!0===this.signalingOfferMessageDataChannels.signaling.compress){const e=K((new TextEncoder).encode(JSON.stringify(a)),{});if("open"===this.dataChannels.signaling.readyState)try{this.dataChannels.signaling.send(e),this.writeDataChannelSignalingLog("send-disconnect",this.dataChannels.signaling,a)}catch(ce){const t=ce.message;this.writeDataChannelSignalingLog("failed-to-send-disconnect",this.dataChannels.signaling,t)}}else if("open"===this.dataChannels.signaling.readyState)try{this.dataChannels.signaling.send(JSON.stringify(a)),this.writeDataChannelSignalingLog("send-disconnect",this.dataChannels.signaling,a)}catch(ce){const t=ce.message;this.writeDataChannelSignalingLog("failed-to-send-disconnect",this.dataChannels.signaling,t)}}))}disconnectPeerConnection(){return new Promise(((e,t)=>(this.pc&&"closed"!==this.pc.connectionState&&this.pc.close(),e())))}async disconnect(){this.clearMonitorIceConnectionStateChange(),await this.stopStream(),this.pc&&(this.pc.ondatachannel=null,this.pc.oniceconnectionstatechange=null,this.pc.onicegatheringstatechange=null,this.pc.onconnectionstatechange=null),this.ws&&(this.ws.onclose=e=>{this.writeWebSocketTimelineLog("onclose",{code:e.code,reason:e.reason})},this.ws.onmessage=null,this.ws.onerror=null);for(const n of Object.keys(this.dataChannels)){const e=this.dataChannels[n];e&&(e.onmessage=null,e.onclose=e=>{const t=e.currentTarget;this.writeDataChannelTimelineLog("onclose",t),this.trace("CLOSE DATA CHANNEL",t.label)})}let e=null;if(this.signalingSwitched){try{const t=await this.disconnectDataChannel();null!==t&&(e=this.soraCloseEvent("normal","DISCONNECT",t))}catch(t){e=this.soraCloseEvent("abend","DISCONNECT-TIMEOUT")}await this.disconnectWebSocket("NO-ERROR"),await this.disconnectPeerConnection()}else{const t=await this.disconnectWebSocket("NO-ERROR");await this.disconnectPeerConnection(),null!==t&&(e=this.soraCloseEvent("normal","DISCONNECT",t))}this.e2ee&&this.e2ee.terminateWorker(),this.initializeConnection(),e&&("abend"===e.type?this.writeSoraTimelineLog("disconnect-abend",e):"normal"===e.type&&this.writeSoraTimelineLog("disconnect-normal",e),this.callbacks.disconnect(e))}setupE2EE(){!0===this.options.e2ee&&(this.e2ee=new o,this.e2ee.onWorkerDisconnect=async()=>{await this.abend("INTERNAL-ERROR",{reason:"CRASH-E2EE-WORKER"})},this.e2ee.startWorker())}startE2EE(){if(!0===this.options.e2ee&&this.e2ee){if(!this.connectionId){const e=new Error;throw e.message="E2EE failed. Self connectionId is null",e}this.e2ee.clearWorker();const e=this.e2ee.start(this.connectionId);this.e2ee.postSelfSecretKeyMaterial(this.connectionId,e.selfKeyId,e.selfSecretKeyMaterial)}}async getSignalingWebSocket(e){if("string"===typeof e){const t=e;return new Promise(((e,n)=>{const i=new WebSocket(t);i.onclose=e=>{const t=new ee(`Signaling failed. CloseEventCode:${e.code} CloseEventReason:'${e.reason}'`);t.code=e.code,t.reason=e.reason,this.writeWebSocketTimelineLog("onclose",t),n(t)},i.onopen=t=>{e(i)}}))}if(Array.isArray(e)){let t=!1;const n=e=>new Promise(((n,i)=>{const o=new WebSocket(e),a=setTimeout((()=>{this.writeWebSocketSignalingLog("signaling-url-canidate",{type:"timeout",url:o.url}),o&&!t&&(o.onclose=null,o.onerror=null,o.onopen=null,o.close(),i())}),this.signalingCandidateTimeout);o.onclose=e=>{this.writeWebSocketSignalingLog("signaling-url-canidate",{type:"close",url:o.url,message:"WebSocket closed",code:e.code,reason:e.reason}),o&&o.close(),clearInterval(a),i()},o.onerror=e=>{this.writeWebSocketSignalingLog("signaling-url-canidate",{type:"error",url:o.url,message:"Failed to connect WebSocket"}),o&&(o.onclose=null,o.close()),clearInterval(a),i()},o.onopen=e=>{o&&(clearInterval(a),t?(this.writeWebSocketSignalingLog("signaling-url-canidate",{type:"open",url:o.url,selected:!1}),o.onerror=null,o.onclose=null,o.onopen=null,o.close(),i()):(this.writeWebSocketSignalingLog("signaling-url-canidate",{type:"open",url:o.url,selected:!0}),o.onerror=null,o.onclose=null,o.onopen=null,t=!0,n(o)))}}));try{return await Promise.any(e.map((e=>n(e))))}catch(ce){throw new ee("Signaling failed. All signaling URL candidates failed to connect")}}throw new ee("Signaling failed. Invalid format signaling URL candidates")}async signaling(e,t=!1){const n=await this.createOffer();return this.trace("CREATE OFFER",n),new Promise(((i,o)=>{this.writeWebSocketSignalingLog("new-websocket",e.url),e.binaryType="arraybuffer",e.onclose=async e=>{const t=new ee(`Signaling failed. CloseEventCode:${e.code} CloseEventReason:'${e.reason}'`);t.code=e.code,t.reason=e.reason,this.writeWebSocketTimelineLog("onclose",t),await this.signalingTerminate(),o(t)},e.onmessage=async e=>{if(e.data instanceof ArrayBuffer)return this.writeWebSocketSignalingLog("onmessage-e2ee",e.data),void this.signalingOnMessageE2EE(e.data);const t=JSON.parse(e.data);if("offer"==t.type)this.writeWebSocketSignalingLog("onmessage-offer",t),this.signalingOnMessageTypeOffer(t),i(t);else if("update"==t.type)this.writeWebSocketSignalingLog("onmessage-update",t),await this.signalingOnMessageTypeUpdate(t);else if("re-offer"==t.type)this.writeWebSocketSignalingLog("onmessage-re-offer",t),await this.signalingOnMessageTypeReOffer(t);else if("ping"==t.type)await this.signalingOnMessageTypePing(t);else if("push"==t.type)this.callbacks.push(t,"websocket");else if("notify"==t.type)"connection.created"===t.event_type?this.writeWebSocketTimelineLog("notify-connection.created",t):"connection.destroyed"===t.event_type&&this.writeWebSocketTimelineLog("notify-connection.destroyed",t),this.signalingOnMessageTypeNotify(t,"websocket");else if("switched"==t.type)this.writeWebSocketSignalingLog("onmessage-switched",t),this.signalingOnMessageTypeSwitched(t);else if("redirect"==t.type){this.writeWebSocketSignalingLog("onmessage-redirect",t);const e=await this.signalingOnMessageTypeRedirect(t);i(e)}},(async()=>{let i;try{i=z(n.sdp||"",this.role,this.channelId,this.metadata,this.options,t)}catch(a){return void o(a)}if(i.e2ee&&this.e2ee){const e=await this.e2ee.init();i.signaling_notify_metadata.pre_key_bundle=e}this.trace("SIGNALING CONNECT MESSAGE",i),e&&(e.send(JSON.stringify(i)),this.writeWebSocketSignalingLog(`send-${i.type}`,i),this.ws=e)})()}))}async connectPeerConnection(e){let t=Object.assign({},e.config);if(this.e2ee&&(t=Object.assign({encodedInsertableStreams:!0},t)),void 0!==window.RTCPeerConnection.generateCertificate){const e=await window.RTCPeerConnection.generateCertificate({name:"ECDSA",namedCurve:"P-256"});t=Object.assign({certificates:[e]},t)}this.trace("PEER CONNECTION CONFIG",t),this.writePeerConnectionTimelineLog("new-peerconnection",t),this.pc=new window.RTCPeerConnection(t,this.constraints),this.pc.oniceconnectionstatechange=e=>{this.pc&&(this.writePeerConnectionTimelineLog("oniceconnectionstatechange",{connectionState:this.pc.connectionState,iceConnectionState:this.pc.iceConnectionState,iceGatheringState:this.pc.iceGatheringState}),this.trace("ONICECONNECTIONSTATECHANGE ICECONNECTIONSTATE",this.pc.iceConnectionState))},this.pc.onicegatheringstatechange=e=>{this.pc&&this.writePeerConnectionTimelineLog("onicegatheringstatechange",{connectionState:this.pc.connectionState,iceConnectionState:this.pc.iceConnectionState,iceGatheringState:this.pc.iceGatheringState})},this.pc.onconnectionstatechange=e=>{this.pc&&this.writePeerConnectionTimelineLog("onconnectionstatechange",{connectionState:this.pc.connectionState,iceConnectionState:this.pc.iceConnectionState,iceGatheringState:this.pc.iceGatheringState})},this.pc.ondatachannel=e=>{this.onDataChannel(e)}}async setRemoteDescription(e){if(!this.pc)return;const t=new RTCSessionDescription({type:"offer",sdp:e.sdp});await this.pc.setRemoteDescription(t),this.writePeerConnectionTimelineLog("set-remote-description",t)}async createAnswer(e){if(!this.pc)return;for(const n of Object.values(this.mids)){const e=this.pc.getTransceivers().find((e=>e.mid===n));e&&"recvonly"===e.direction&&(e.direction="sendrecv")}if(this.options.simulcast&&("sendrecv"===this.role||"sendonly"===this.role)){const t=this.pc.getTransceivers().find((e=>{if(e.mid&&0<=e.mid.indexOf("video")&&null!==e.sender.track&&(null===e.currentDirection||"sendonly"===e.currentDirection))return e}));if(t){await this.setSenderParameters(t,this.encodings),await this.setRemoteDescription(e),this.trace("TRANSCEIVER SENDER GET_PARAMETERS",t.sender.getParameters()),await this.setSenderParameters(t,this.encodings);const n=await this.pc.createAnswer();return await this.pc.setLocalDescription(n),void this.trace("TRANSCEIVER SENDER GET_PARAMETERS",t.sender.getParameters())}}const t=await this.pc.createAnswer();this.writePeerConnectionTimelineLog("create-answer",t),await this.pc.setLocalDescription(t),this.writePeerConnectionTimelineLog("set-local-description",t)}sendAnswer(){if(this.pc&&this.ws&&this.pc.localDescription){this.trace("ANSWER SDP",this.pc.localDescription.sdp);const e={type:"answer",sdp:this.pc.localDescription.sdp};this.ws.send(JSON.stringify(e)),this.writeWebSocketSignalingLog("send-answer",e)}}onIceCandidate(){return new Promise(((e,t)=>{this.pc&&(this.pc.oniceconnectionstatechange=t=>{this.pc&&(this.writePeerConnectionTimelineLog("oniceconnectionstatechange",{connectionState:this.pc.connectionState,iceConnectionState:this.pc.iceConnectionState,iceGatheringState:this.pc.iceGatheringState}),this.trace("ONICECONNECTIONSTATECHANGE ICECONNECTIONSTATE",this.pc.iceConnectionState),"connected"===this.pc.iceConnectionState&&e())},this.pc.onicecandidate=t=>{if(this.writePeerConnectionTimelineLog("onicecandidate",t.candidate),this.pc&&this.trace("ONICECANDIDATE ICEGATHERINGSTATE",this.pc.iceGatheringState),null===t.candidate)e();else{const e=t.candidate.toJSON(),n=Object.assign(e,{type:"candidate"});this.trace("ONICECANDIDATE CANDIDATE MESSAGE",n),this.sendSignalingMessage(n)}})}))}waitChangeConnectionStateConnected(){return new Promise(((e,t)=>{if(this.pc&&void 0===this.pc.connectionState)return void e();const n=setInterval((()=>{if(this.pc)this.pc&&"connected"===this.pc.connectionState&&(clearInterval(n),e());else{const e=new Error;e.message="PeerConnection connectionState did not change to 'connected'",clearInterval(n),t(e)}}),10)}))}monitorSignalingWebSocketEvent(){return new Promise(((e,t)=>{this.monitorSignalingWebSocketEventTimerId=setInterval((()=>{this.ws&&(this.clearMonitorSignalingWebSocketEvent(),this.ws.onclose=async e=>{const n=new ee(`Signaling failed. CloseEventCode:${e.code} CloseEventReason:'${e.reason}'`);n.code=e.code,n.reason=e.reason,this.writeWebSocketTimelineLog("onclose",n),await this.signalingTerminate(),t(n)},this.ws.onerror=async e=>{const n=new ee("Signaling failed. WebSocket onerror was called");this.writeWebSocketSignalingLog("onerror",n),await this.signalingTerminate(),t(n)})}),100)}))}monitorWebSocketEvent(){this.ws&&(this.ws.onclose=async e=>{this.writeWebSocketTimelineLog("onclose",{code:e.code,reason:e.reason}),await this.abend("WEBSOCKET-ONCLOSE",{code:e.code,reason:e.reason})},this.ws.onerror=async e=>{this.writeWebSocketSignalingLog("onerror"),await this.abend("WEBSOCKET-ONERROR")})}monitorPeerConnectionState(){this.pc&&(this.pc.oniceconnectionstatechange=async e=>{this.pc&&void 0===this.pc.connectionState&&(this.writePeerConnectionTimelineLog("oniceconnectionstatechange",{connectionState:this.pc.connectionState,iceConnectionState:this.pc.iceConnectionState,iceGatheringState:this.pc.iceGatheringState}),this.trace("ONICECONNECTIONSTATECHANGE ICECONNECTIONSTATE",this.pc.iceConnectionState),clearTimeout(this.monitorIceConnectionStateChangeTimerId),"failed"===this.pc.iceConnectionState?await this.abendPeerConnectionState("ICE-CONNECTION-STATE-FAILED"):"disconnected"===this.pc.iceConnectionState&&(this.monitorIceConnectionStateChangeTimerId=setTimeout((async()=>{this.pc&&"disconnected"===this.pc.iceConnectionState&&await this.abendPeerConnectionState("ICE-CONNECTION-STATE-DISCONNECTED-TIMEOUT")}),1e4)))},this.pc.onconnectionstatechange=async e=>{this.pc&&(this.writePeerConnectionTimelineLog("onconnectionstatechange",{connectionState:this.pc.connectionState,iceConnectionState:this.pc.iceConnectionState,iceGatheringState:this.pc.iceGatheringState}),"failed"===this.pc.connectionState&&await this.abendPeerConnectionState("CONNECTION-STATE-FAILED"))})}setConnectionTimeout(){return new Promise(((e,t)=>{0<this.connectionTimeout&&(this.connectionTimeoutTimerId=setTimeout((async()=>{if(!this.pc||this.pc&&void 0!==this.pc.connectionState&&"connected"!==this.pc.connectionState){const e=new Error;e.message="Signaling connection timeout",this.callbacks.timeout(),this.trace("DISCONNECT","Signaling connection timeout"),this.writePeerConnectionTimelineLog("signaling-connection-timeout",{connectionTimeout:this.connectionTimeout}),await this.signalingTerminate(),t(e)}}),this.connectionTimeout))}))}clearConnectionTimeout(){clearTimeout(this.connectionTimeoutTimerId)}clearMonitorSignalingWebSocketEvent(){clearInterval(this.monitorSignalingWebSocketEventTimerId)}clearMonitorIceConnectionStateChange(){clearInterval(this.monitorIceConnectionStateChangeTimerId)}trace(e,t){this.callbacks.log(e,t),this.debug&&function(e,t,n){const i=e=>{if(e&&"object"===typeof e){let n=null;try{n=Object.keys(JSON.parse(JSON.stringify(e)))}catch(t){}n&&Array.isArray(n)?n.forEach((t=>{console.group(t),i(e[t]),console.groupEnd()})):console.info(e)}else console.info(e)};let o="";window.performance&&(o="["+(window.performance.now()/1e3).toFixed(3)+"]"),e&&(o=o+"["+e+"]"),void 0!==console.info&&void 0!==console.group?(console.group(o+" "+t),i(n),console.groupEnd()):console.log(o+" "+t+"\n",n)}(this.clientId,e,t)}writeWebSocketSignalingLog(e,t){this.callbacks.signaling(te(e,t,"websocket")),this.writeWebSocketTimelineLog(e,t)}writeDataChannelSignalingLog(e,t,n){this.callbacks.signaling(te(e,n,"datachannel")),this.writeDataChannelTimelineLog(e,t,n)}writeWebSocketTimelineLog(e,t){const n=ne(e,t,"websocket");this.callbacks.timeline(n)}writeDataChannelTimelineLog(e,t,n){const i=ne(e,n,"datachannel",t.id,t.label);this.callbacks.timeline(i)}writePeerConnectionTimelineLog(e,t){const n=ne(e,t,"peerconnection");this.callbacks.timeline(n)}writeSoraTimelineLog(e,t){const n=ne(e,t,"sora");this.callbacks.timeline(n)}async createOffer(){const e=new window.RTCPeerConnection({iceServers:[]});if(_()){e.addTransceiver("video",{direction:"recvonly"}),e.addTransceiver("audio",{direction:"recvonly"});const t=await e.createOffer();return e.close(),this.writePeerConnectionTimelineLog("create-offer",t),t}const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});return e.close(),this.writePeerConnectionTimelineLog("create-offer",t),t}signalingOnMessageE2EE(e){if(this.e2ee){const t=new Uint8Array(e),n=this.e2ee.receiveMessage(t);this.e2ee.postRemoteSecretKeyMaterials(n),n.messages.forEach((e=>{this.sendE2EEMessage(e.buffer)}))}}signalingOnMessageTypeOffer(e){if(this.clientId=e.client_id,this.connectionId=e.connection_id,void 0!==e.metadata&&(this.authMetadata=e.metadata),Array.isArray(e.encodings)&&(this.encodings=e.encodings),void 0!==e.mid&&void 0!==e.mid.audio&&(this.mids.audio=e.mid.audio),void 0!==e.mid&&void 0!==e.mid.video&&(this.mids.video=e.mid.video),e.data_channels)for(const t of e.data_channels)this.signalingOfferMessageDataChannels[t.label]=t;this.trace("SIGNALING OFFER MESSAGE",e),this.trace("OFFER SDP",e.sdp)}sendUpdateAnswer(){this.pc&&this.ws&&this.pc.localDescription&&(this.trace("ANSWER SDP",this.pc.localDescription.sdp),this.sendSignalingMessage({type:"update",sdp:this.pc.localDescription.sdp}))}sendReAnswer(){this.pc&&this.pc.localDescription&&(this.trace("RE ANSWER SDP",this.pc.localDescription.sdp),this.sendSignalingMessage({type:"re-answer",sdp:this.pc.localDescription.sdp}))}async signalingOnMessageTypeUpdate(e){this.trace("SIGNALING UPDATE MESSGE",e),this.trace("UPDATE SDP",e.sdp),await this.setRemoteDescription(e),await this.createAnswer(e),this.sendUpdateAnswer()}async signalingOnMessageTypeReOffer(e){this.trace("SIGNALING RE OFFER MESSGE",e),this.trace("RE OFFER SDP",e.sdp),await this.setRemoteDescription(e),await this.createAnswer(e),this.sendReAnswer()}async signalingOnMessageTypePing(e){const t={type:"pong"};if(e.stats){const e=await this.getStats();t.stats=e}this.ws&&this.ws.send(JSON.stringify(t))}signalingOnMessageTypeNotify(e,t){if("connection.created"===e.event_type){const t=e.connection_id;if(this.connectionId!==t){const n=q($(e));if(n&&this.e2ee&&t){const e=this.e2ee.startSession(t,n);this.e2ee.postRemoteSecretKeyMaterials(e),e.messages.forEach((e=>{this.sendE2EEMessage(e.buffer)})),this.e2ee.postSelfSecretKeyMaterial(e.selfConnectionId,e.selfKeyId,e.selfSecretKeyMaterial)}}(function(e){return e.data&&Array.isArray(e.data)?e.data:e.metadata_list&&Array.isArray(e.metadata_list)?e.metadata_list:[]})(e).forEach((e=>{const t=q($(e)),n=e.connection_id;n&&this.e2ee&&t&&this.e2ee.addPreKeyBundle(n,t)}))}else if("connection.destroyed"===e.event_type){const t=q($(e)),n=e.connection_id;if(t&&this.e2ee&&n){const e=this.e2ee.stopSession(n);this.e2ee.postSelfSecretKeyMaterial(e.selfConnectionId,e.selfKeyId,e.selfSecretKeyMaterial,5e3),e.messages.forEach((e=>{this.sendE2EEMessage(e.buffer)})),this.e2ee.postRemoveRemoteDeriveKey(n)}}this.callbacks.notify(e,t)}signalingOnMessageTypeSwitched(e){this.signalingSwitched=!0,this.ws&&e.ignore_disconnect_websocket&&(this.ws&&(this.ws.onclose=null,this.ws.close(),this.ws=null),this.writeWebSocketSignalingLog("close"))}async signalingOnMessageTypeRedirect(e){this.ws&&(this.ws.onclose=null,this.ws.onerror=null,this.ws.close(),this.ws=null);const t=await this.getSignalingWebSocket(e.location);return await this.signaling(t,!0)}async setSenderParameters(e,t){const n=e.sender.getParameters();n.encodings=t,await e.sender.setParameters(n),this.trace("TRANSCEIVER SENDER SET_PARAMETERS",n),this.writePeerConnectionTimelineLog("transceiver-sender-set-parameters",n)}async getStats(){const e=[];if(!this.pc)return e;return(await this.pc.getStats()).forEach((t=>{e.push(t)})),e}onDataChannel(e){const t=e.channel;var n;this.writeDataChannelTimelineLog("ondatachannel",t,{binaryType:(n=t).binaryType,bufferedAmount:n.bufferedAmount,bufferedAmountLowThreshold:n.bufferedAmountLowThreshold,id:n.id,label:n.label,maxPacketLifeTime:n.maxPacketLifeTime,maxRetransmits:n.maxRetransmits,negotiated:n.negotiated,ordered:n.ordered,protocol:n.protocol,readyState:n.readyState,reliable:n.reliable}),e.channel.onbufferedamountlow=e=>{const t=e.currentTarget;this.writeDataChannelTimelineLog("onbufferedamountlow",t)},e.channel.onopen=e=>{const t=e.currentTarget;t.bufferedAmountLowThreshold=65536,t.binaryType="arraybuffer",this.dataChannels[t.label]=t,this.trace("OPEN DATA CHANNEL",t.label),"signaling"===t.label&&this.ws?this.writeDataChannelSignalingLog("onopen",t):this.writeDataChannelTimelineLog("onopen",t)},e.channel.onclose=async e=>{const t=e.currentTarget;this.writeDataChannelTimelineLog("onclose",t),this.trace("CLOSE DATA CHANNEL",t.label),await this.disconnect()},e.channel.onerror=async e=>{const t=e.currentTarget;this.writeDataChannelTimelineLog("onerror",t),this.trace("ERROR DATA CHANNEL",t.label),await this.abend("DATA-CHANNEL-ONERROR",{params:{label:t.label}})},"signaling"===e.channel.label?e.channel.onmessage=async e=>{const t=e.currentTarget;let n=e.data;if(this.signalingOfferMessageDataChannels.signaling&&!0===this.signalingOfferMessageDataChannels.signaling.compress){const t=P(new Uint8Array(e.data));n=(new TextDecoder).decode(t)}const i=JSON.parse(n);this.writeDataChannelSignalingLog(`onmessage-${i.type}`,t,i),"re-offer"===i.type&&await this.signalingOnMessageTypeReOffer(i)}:"notify"===e.channel.label?e.channel.onmessage=e=>{const t=e.currentTarget;let n=e.data;if(this.signalingOfferMessageDataChannels.notify&&!0===this.signalingOfferMessageDataChannels.notify.compress){const t=P(new Uint8Array(e.data));n=(new TextDecoder).decode(t)}const i=JSON.parse(n);"connection.created"===i.event_type?this.writeDataChannelTimelineLog("notify-connection.created",t,i):"connection.destroyed"===i.event_type&&this.writeDataChannelTimelineLog("notify-connection.destroyed",t,i),this.signalingOnMessageTypeNotify(i,"datachannel")}:"push"===e.channel.label?e.channel.onmessage=e=>{let t=e.data;if(this.signalingOfferMessageDataChannels.push&&!0===this.signalingOfferMessageDataChannels.push.compress){const n=P(new Uint8Array(e.data));t=(new TextDecoder).decode(n)}const n=JSON.parse(t);this.callbacks.push(n,"datachannel")}:"e2ee"===e.channel.label?e.channel.onmessage=e=>{const t=e.currentTarget,n=e.data;this.signalingOnMessageE2EE(n),this.writeDataChannelSignalingLog("onmessage-e2ee",t,n)}:"stats"===e.channel.label?e.channel.onmessage=async e=>{let t=e.data;if(this.signalingOfferMessageDataChannels.stats&&!0===this.signalingOfferMessageDataChannels.stats.compress){const n=P(new Uint8Array(e.data));t=(new TextDecoder).decode(n)}if("req-stats"===JSON.parse(t).type){const e=await this.getStats();this.sendStatsMessage(e)}}:/^#[a-zA-Z][a-zA-Z-]{1,30}$/.exec(e.channel.label)&&(e.channel.onmessage=e=>{if(null===e.target)return;const t=e.target;let n=e.data;const i=this.signalingOfferMessageDataChannels[t.label];if(void 0!==i&&!0===i.compress){const t=P(new Uint8Array(e.data));n=(new TextDecoder).decode(t)}const o=JSON.parse(n);this.callbacks.message(function(e,t){const n=new Event("message");return n.label=e,n.data=t,n}(t.label,o))})}sendSignalingMessage(e){if(this.dataChannels.signaling){if(this.signalingOfferMessageDataChannels.signaling&&!0===this.signalingOfferMessageDataChannels.signaling.compress){const t=K((new TextEncoder).encode(JSON.stringify(e)),{});this.dataChannels.signaling.send(t)}else this.dataChannels.signaling.send(JSON.stringify(e));this.writeDataChannelSignalingLog(`send-${e.type}`,this.dataChannels.signaling,e)}else null!==this.ws&&(this.ws.send(JSON.stringify(e)),this.writeWebSocketSignalingLog(`send-${e.type}`,e))}sendE2EEMessage(e){this.dataChannels.e2ee?(this.dataChannels.e2ee.send(e),this.writeDataChannelSignalingLog("send-e2ee",this.dataChannels.e2ee,e)):null!==this.ws&&(this.ws.send(e),this.writeWebSocketSignalingLog("send-e2ee",e))}sendStatsMessage(e){if(this.dataChannels.stats){const t={type:"stats",reports:e};if(this.signalingOfferMessageDataChannels.stats&&!0===this.signalingOfferMessageDataChannels.stats.compress){const e=K((new TextEncoder).encode(JSON.stringify(t)),{});this.dataChannels.stats.send(e)}else this.dataChannels.stats.send(JSON.stringify(t))}}getAudioTransceiver(){if(this.pc&&this.mids.audio){return this.pc.getTransceivers().find((e=>e.mid===this.mids.audio))||null}return null}getVideoTransceiver(){if(this.pc&&this.mids.video){return this.pc.getTransceivers().find((e=>e.mid===this.mids.video))||null}return null}soraCloseEvent(e,t,n){return new class extends Event{constructor(e,t,n){super(e),n&&(n.code&&(this.code=n.code),n.reason&&(this.reason=n.reason),n.params&&(this.params=n.params)),this.title=t}}(e,t,n)}sendMessage(e,t){const n=this.dataChannels[e];if(null===this.pc)return;if(void 0===n)throw new Error("Could not find DataChannel");const i=this.signalingOfferMessageDataChannels[e];if(void 0!==i&&!0===i.compress){const e=K((new TextEncoder).encode(JSON.stringify(t)),{});n.send(e)}else n.send(JSON.stringify(t))}get e2eeSelfFingerprint(){if(this.options.e2ee&&this.e2ee)return this.e2ee.selfFingerprint()}get e2eeRemoteFingerprints(){if(this.options.e2ee&&this.e2ee)return this.e2ee.remoteFingerprints()}get audio(){return null!==this.getAudioTransceiver()}get video(){return null!==this.getVideoTransceiver()}get signalingUrl(){return this.signalingUrlCandidates}get connectedSignalingUrl(){return this.ws?this.ws.url:""}get messagingDataChannels(){const e=Object.keys(this.signalingOfferMessageDataChannels).filter((e=>/^#[a-zA-Z][a-zA-Z-]{1,30}$/.exec(e))),t=[];for(const n of e){const e=this.dataChannels[n];if(!e)continue;const i=this.signalingOfferMessageDataChannels[n];if(!i)continue;const o={label:e.label,ordered:e.ordered,protocol:e.protocol,compress:i.compress,direction:i.direction};"number"===typeof e.maxPacketLifeTime&&(o.maxPacketLifeTime=e.maxPacketLifeTime),"number"===typeof e.maxRetransmits&&(o.maxRetransmits=e.maxRetransmits),t.push(o)}return t}}class oe extends ie{async connect(e){return this.options.multistream?await Promise.race([this.multiStream(e).finally((()=>{this.clearConnectionTimeout(),this.clearMonitorSignalingWebSocketEvent()})),this.setConnectionTimeout(),this.monitorSignalingWebSocketEvent()]):await Promise.race([this.singleStream(e).finally((()=>{this.clearConnectionTimeout(),this.clearMonitorSignalingWebSocketEvent()})),this.setConnectionTimeout(),this.monitorSignalingWebSocketEvent()]),this.monitorWebSocketEvent(),this.monitorPeerConnectionState(),e}async singleStream(e){await this.disconnect(),this.setupE2EE();const t=await this.getSignalingWebSocket(this.signalingUrlCandidates),n=await this.signaling(t);return this.startE2EE(),await this.connectPeerConnection(n),await this.setRemoteDescription(n),e.getTracks().forEach((t=>{this.pc&&this.pc.addTrack(t,e)})),this.stream=e,await this.createAnswer(n),this.sendAnswer(),this.pc&&this.e2ee&&this.pc.getSenders().forEach((e=>{this.e2ee&&this.e2ee.setupSenderTransform(e)})),await this.onIceCandidate(),await this.waitChangeConnectionStateConnected(),e}async multiStream(e){await this.disconnect(),this.setupE2EE();const t=await this.getSignalingWebSocket(this.signalingUrlCandidates),n=await this.signaling(t);return this.startE2EE(),await this.connectPeerConnection(n),this.pc&&(this.pc.ontrack=e=>{const t=e.streams[0];if(!t)return;const n={"stream.id":t.id,id:e.track.id,label:e.track.label,enabled:e.track.enabled,kind:e.track.kind,muted:e.track.muted,readyState:e.track.readyState};this.writePeerConnectionTimelineLog("ontrack",n),"default"!==t.id&&t.id!==this.connectionId&&(this.e2ee&&this.e2ee.setupReceiverTransform(e.receiver),this.callbacks.track(e),t.onremovetrack=e=>{if(this.callbacks.removetrack(e),e.target){const t=this.remoteConnectionIds.indexOf(e.target.id);-1<t&&(delete this.remoteConnectionIds[t],e.stream=e.target,this.callbacks.removestream(e))}},-1<this.remoteConnectionIds.indexOf(t.id)||(e.stream=t,this.remoteConnectionIds.push(t.id),this.callbacks.addstream(e)))}),await this.setRemoteDescription(n),e.getTracks().forEach((t=>{this.pc&&this.pc.addTrack(t,e)})),this.stream=e,await this.createAnswer(n),this.sendAnswer(),this.pc&&this.e2ee&&this.pc.getSenders().forEach((e=>{this.e2ee&&this.e2ee.setupSenderTransform(e)})),await this.onIceCandidate(),await this.waitChangeConnectionStateConnected(),e}}class ae extends ie{async connect(){if(this.options.multistream)return await Promise.race([this.multiStream().finally((()=>{this.clearConnectionTimeout(),this.clearMonitorSignalingWebSocketEvent()})),this.setConnectionTimeout(),this.monitorSignalingWebSocketEvent()]),this.monitorWebSocketEvent(),void this.monitorPeerConnectionState();{const e=await Promise.race([this.singleStream().finally((()=>{this.clearConnectionTimeout(),this.clearMonitorSignalingWebSocketEvent()})),this.setConnectionTimeout(),this.monitorSignalingWebSocketEvent()]);return this.monitorWebSocketEvent(),this.monitorPeerConnectionState(),e}}async singleStream(){await this.disconnect(),this.setupE2EE();const e=await this.getSignalingWebSocket(this.signalingUrlCandidates),t=await this.signaling(e);return this.startE2EE(),await this.connectPeerConnection(t),this.pc&&(this.pc.ontrack=e=>{this.stream=e.streams[0];const t=this.stream.id;if("default"===t)return;const n={"stream.id":t,id:e.track.id,label:e.track.label,enabled:e.track.enabled,kind:e.track.kind,muted:e.track.muted,readyState:e.track.readyState};this.writePeerConnectionTimelineLog("ontrack",n),this.e2ee&&this.e2ee.setupReceiverTransform(e.receiver),this.callbacks.track(e),this.stream.onremovetrack=e=>{if(this.callbacks.removetrack(e),e.target){const t=this.remoteConnectionIds.indexOf(e.target.id);-1<t&&(delete this.remoteConnectionIds[t],e.stream=e.target,this.callbacks.removestream(e))}},-1<this.remoteConnectionIds.indexOf(t)||(e.stream=this.stream,this.remoteConnectionIds.push(t),this.callbacks.addstream(e))}),await this.setRemoteDescription(t),await this.createAnswer(t),this.sendAnswer(),await this.onIceCandidate(),await this.waitChangeConnectionStateConnected(),this.stream||new MediaStream}async multiStream(){await this.disconnect(),this.setupE2EE();const e=await this.getSignalingWebSocket(this.signalingUrlCandidates),t=await this.signaling(e);this.startE2EE(),await this.connectPeerConnection(t),this.pc&&(this.pc.ontrack=e=>{const t=e.streams[0];if("default"===t.id)return;if(t.id===this.connectionId)return;const n={"stream.id":t.id,id:e.track.id,label:e.track.label,enabled:e.track.enabled,kind:e.track.kind,muted:e.track.muted,readyState:e.track.readyState};this.writePeerConnectionTimelineLog("ontrack",n),this.e2ee&&this.e2ee.setupReceiverTransform(e.receiver),this.callbacks.track(e),t.onremovetrack=e=>{if(this.callbacks.removetrack(e),e.target){const t=this.remoteConnectionIds.indexOf(e.target.id);-1<t&&(delete this.remoteConnectionIds[t],e.stream=e.target,this.callbacks.removestream(e))}},-1<this.remoteConnectionIds.indexOf(t.id)||(e.stream=t,this.remoteConnectionIds.push(t.id),this.callbacks.addstream(e))}),await this.setRemoteDescription(t),await this.createAnswer(t),this.sendAnswer(),await this.onIceCandidate(),await this.waitChangeConnectionStateConnected()}}class re{constructor(e,t=!1){this.signalingUrlCandidates=e,this.debug=t}sendrecv(e,t=null,n={audio:!0,video:!0}){return new oe(this.signalingUrlCandidates,"sendrecv",e,t,n,this.debug)}sendonly(e,t=null,n={audio:!0,video:!0}){return new oe(this.signalingUrlCandidates,"sendonly",e,t,n,this.debug)}recvonly(e,t=null,n={audio:!0,video:!0}){return new ae(this.signalingUrlCandidates,"recvonly",e,t,n,this.debug)}get signalingUrl(){return this.signalingUrlCandidates}}var se={initE2EE:async function(e){await o.loadWasm(e)},connection:function(e,t=!1){return new re(e,t)},version:function(){return"2021.2.0-canary.3"},helpers:{applyMediaStreamConstraints:async function(e,t){if(t.audio&&"boolean"!==typeof t.audio)for(const n of e.getAudioTracks())await n.applyConstraints(t.audio);if(t.video&&"boolean"!==typeof t.video)for(const n of e.getVideoTracks())await n.applyConstraints(t.video)}}}}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[774,179],(function(){return t(6363),t(4651)}));var n=e.O();_N_E=n}]);