@formant/data-sdk 1.78.1 → 1.78.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/data-sdk.cjs.js +1 -1
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +15 -15
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +15 -15
- package/dist/data-sdk.umd.js +1 -1
- package/dist/types/data-sdk/src/stores/AuthenticationStore.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/data-sdk.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Rn=Object.defineProperty;var Bn=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var he=(e,t,n)=>(Bn(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t,n){try{if(t.get("formant_prod"))return"https://api.formant.io";if(t.get("formant_stage"))return"https://api-stage.formant.io";if(t.get("formant_dev"))return"https://api-dev.formant.io";if(t.get("formant_local"))return"https://api.formant.local";if(t.get("formant_url")){const r=t.get("formant_url");if(r!==null)try{return new URL(r).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${r}`)}}if(n){if(n.includes("app-dev.formant.io")||n.includes("localhost"))return"https://api-dev.formant.io";if(n.includes("app-stage.formant.io"))return"https://api-stage.formant.io";if(n.includes("app.formant.io"))return"https://api.formant.io"}}catch{}if(n){if(n.includes("app-dev.formant.io"))return"https://api-dev.formant.io";if(n.includes("app-stage.formant.io"))return"https://api-stage.formant.io";if(n.includes("app.formant.io"))return"https://api.formant.io"}return typeof e!="undefined"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}exports.FORMANT_API_URL=whichFormantApiUrl(typeof window!="undefined"?window:globalThis,new URLSearchParams(typeof window!="undefined"&&window.location?window.location.search:void 0),typeof window!="undefined"&&window.location?window.location.host:void 0);const setFormantApiUrl=e=>{exports.FORMANT_API_URL=e};function addAccessTokenRefreshListener(e){function t(n){const r=n.data;r.type==="auth_token"&&e(r.token)}return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function getCurrentModuleContext(){return typeof window!="undefined"&&window.location?new URLSearchParams(window.location.search).get("module"):null}function sendAppMessage(e){if(!(window&&window.parent))throw new Error("cannot send message to non-existent parent");window.parent.postMessage(e,"*")}function refreshAuthToken(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"refresh_auth_token",module:e})}var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var base64={exports:{}};/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */base64.exports;(function(e,t){(function(n){var r=t,o=e&&e.exports==r&&e,s=typeof commonjsGlobal=="object"&&commonjsGlobal;(s.global===s||s.window===s)&&(n=s);var g=function(p){this.message=p};g.prototype=new Error,g.prototype.name="InvalidCharacterError";var l=function(p){throw new g(p)},u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,d=function(p){p=String(p).replace(c,"");var U=p.length;U%4==0&&(p=p.replace(/==?$/,""),U=p.length),(U%4==1||/[^+a-zA-Z0-9/]/.test(p))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var E=0,M,W,y="",m=-1;++m<U;)W=u.indexOf(p.charAt(m)),M=E%4?M*64+W:W,E++%4&&(y+=String.fromCharCode(255&M>>(-2*E&6)));return y},B=function(p){p=String(p),/[^\0-\xFF]/.test(p)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var U=p.length%3,E="",M=-1,W,y,m,h,T=p.length-U;++M<T;)W=p.charCodeAt(M)<<16,y=p.charCodeAt(++M)<<8,m=p.charCodeAt(++M),h=W+y+m,E+=u.charAt(h>>18&63)+u.charAt(h>>12&63)+u.charAt(h>>6&63)+u.charAt(h&63);return U==2?(W=p.charCodeAt(M)<<8,y=p.charCodeAt(++M),h=W+y,E+=u.charAt(h>>10)+u.charAt(h>>4&63)+u.charAt(h<<2&63)+"="):U==1&&(h=p.charCodeAt(M),E+=u.charAt(h>>2)+u.charAt(h<<4&63)+"=="),E},Q={encode:B,decode:d,version:"1.0.0"};if(r&&!r.nodeType)if(o)o.exports=Q;else for(var f in Q)Q.hasOwnProperty(f)&&(r[f]=Q[f]);else n.base64=Q})(commonjsGlobal)})(base64,base64.exports);var base64Exports=base64.exports;class LoginFailureError extends Error{constructor(n){super("login failed");he(this,"reason");this.reason=n,this.name="LoginFailureError",Object.setPrototypeOf(this,new.target.prototype)}}class LoginChallengedError extends Error{constructor(n){super("login challenged");he(this,"challenge");this.challenge=n,this.name="LoginChallengedError",Object.setPrototypeOf(this,new.target.prototype)}}class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){he(this,"_refreshToken");he(this,"_isShareToken",!1);he(this,"_currentOrganization");he(this,"_currentUser");he(this,"_defaultDeviceId");he(this,"_token");he(this,"_waitingForAuth",new Set);he(this,"_refreshTimer");he(this,"_apiUrl");he(this,"_refreshAuthToken");he(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}set apiUrl(t){this._apiUrl=t,setFormantApiUrl(t)}get apiUrl(){return this._apiUrl}get token(){return this._token}get currentUser(){return this._currentUser}get currentOrganization(){return this._currentOrganization}get defaultDeviceId(){return this._defaultDeviceId}get refreshToken(){return this._refreshToken}get isShareToken(){return this._isShareToken}async login(t,n,r={}){const{advanced:o=!1}=r;try{const s=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),g=await s.json();if(s.status!==200)throw new LoginFailureError(g.message);if("challenge"in g)throw new LoginChallengedError(g.challenge);const{authentication:l}=g;return await this.loginWithToken(l.accessToken,l.refreshToken),o?{result:"success",authentication:l}:l}catch(s){if(o||console.error("login() failed",{err:s}),this._waitingForAuth.forEach(g=>g(!1)),this._waitingForAuth.clear(),!o)throw s;return s instanceof LoginChallengedError?{result:"challenged",challenge:s.challenge}:{result:"failure",reason:s instanceof LoginFailureError?s.reason:s instanceof Error?s.message:String(s)}}}async loginWithToken(t,n){var o;const r=JSON.parse(base64Exports.decode(t.split(".")[1]));try{let s;if(this._isShareToken=r["formant:claims"]&&r["formant:claims"].type=="share",r["formant:claims"]&&(this._currentOrganization=r["formant:claims"].organizationId),r["custom:organization_id"]&&(this._currentOrganization=r["custom:organization_id"]),this._isShareToken||(s=r.sub),r["formant:claims"]&&r["formant:claims"].userId&&(s=r["formant:claims"].userId),s&&((o=this._currentUser)==null?void 0:o.id)!==s){const g=await fetch(`${this._apiUrl}/v1/admin/users/${s}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),l=await g.json();if(g.status!==200)throw new Error(l.message);this._currentUser=l}this._token=t,this._waitingForAuth.forEach(g=>g(!0))}catch(s){console.error("loginWithToken() failed",{err:s}),this._waitingForAuth.forEach(g=>g(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const g=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:this._refreshToken})})).json();this._token=g.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}async loginToPeer(t,n,r){if((await fetch(`${t}/login`,{method:"POST",body:JSON.stringify({username:n,password:r}),headers:{"Content-Type":"application/json"}})).status!==200)throw new LoginFailureError("Invalid authentication")}getCurrentUser(){return this._currentUser}async waitTilAuthenticated(){return this.token!==void 0?!0:new Promise(t=>{this._waitingForAuth.add(t)})}async listenForRefresh(){const n=()=>{this._refreshTimer=void 0,this._refreshAuthToken()};this._addAccessTokenRefreshListener(r=>{this._refreshTimer&&clearTimeout(this._refreshTimer),this._refreshTimer=setTimeout(n,36e5),this.loginWithToken(r)}),this._refreshTimer=setTimeout(n,36e5)}async forgotPassword(t){await fetch(`${this._apiUrl}/v1/admin/auth/forgot-password`,{method:"POST",body:JSON.stringify({email:t}),headers:{"Content-Type":"application/json"}})}async confirmForgotPassword(t){return(await fetch(`${this._apiUrl}/v1/admin/auth/confirm-forgot-password`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).ok}async respondToNewPasswordRequiredChallenge(t){const n=await fetch(`${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});if(n.ok)return await n.json();throw new Error("respond-to-new-password-required-challenge failed")}async loginWithGoogle(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/login-google`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async refresh(t){const r=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})})).json();await this.loginWithToken(r.authentication.accessToken,t)}async checkSso(t,n){return await(await fetch(`${this._apiUrl}/v1/admin/auth/check-sso`,{method:"POST",body:JSON.stringify({email:t,allowUserAutoCreation:n}),headers:{"Content-Type":"application/json"}})).json()}async loginWithSso(t,n){const o=await(await fetch(`${this._apiUrl}/v1/admin/auth/login-sso`,{method:"POST",body:JSON.stringify({token:t,refreshToken:n}),headers:{"Content-Type":"application/json"}})).json();if(!o.authentication)throw new Error("Failed to login with SSO");return await this.loginWithToken(o.authentication.accessToken,o.authentication.refreshToken)}}const Authentication=new AuthenticationStore({apiUrl:exports.FORMANT_API_URL,refreshAuthToken,addAccessTokenRefreshListener});class Account{static async listAccounts(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createAccounts(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getAccount(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchAccount(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteAccount(t){if(!Authentication.token)throw new Error("Not authenticated");if(!(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).ok)throw new Error("Unable to delete account")}static async getAccountTree(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}/tree`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}async function getModuleConfiguration(e){return(await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/module-configurations/${e}`,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).configuration}function disableAnalyticsBottomBar(){sendAppMessage({type:"hide_analytics_date_picker"})}function goToDevice(e){sendAppMessage({type:"go_to_device",deviceId:e})}function goToTime(e){sendAppMessage({type:"go_to_time",time:e.getTime()})}function requestModuleData(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"request_module_data",module:e})}function sendChannelData(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"send_channel_data",source:n,channel:e,data:t})}function setModuleDateTimeRange(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"set_module_data_time_range",module:n,before:e,after:t||0})}function setupModuleMenus(e){const t=getCurrentModuleContext();if(!t)throw new Error("No module context");sendAppMessage({type:"setup_module_menus",module:t,menus:e})}function showMessage(e){sendAppMessage({type:"show_message",message:e})}function addChannelDataListener(e,t){const n=r=>{const o=r.data;o.type==="channel_data"&&o.channel===e&&t({source:o.source,data:o.data})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addMenuListener(e){const t=n=>{const r=n.data;r.type==="module_menu_item_clicked"&&e(r.menu)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleConfigurationListener(e){const t=n=>{const r=n.data;r.type==="module_configuration"&&e(r)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleDataListener(e){const t=getCurrentModuleContext();t&&sendAppMessage({type:"request_module_data",module:t});const n=r=>{const o=r.data;o.type==="module_data"&&e({streams:o.streams,time:o.time,queryRange:o.queryRange})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addOverviewDeviceListener(e){sendAppMessage({type:"request_devices"});const t=n=>{const r=n.data;r.type==="overview_devices"&&e(r.data)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function _typeof(e){return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(e)}function toInteger(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function requiredArgs(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function toDate(e){requiredArgs(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||_typeof(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function addDays(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);return isNaN(r)?new Date(NaN):(r&&n.setDate(n.getDate()+r),n)}function addMonths(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);if(isNaN(r))return new Date(NaN);if(!r)return n;var o=n.getDate(),s=new Date(n.getTime());s.setMonth(n.getMonth()+r+1,0);var g=s.getDate();return o>=g?s:(n.setFullYear(s.getFullYear(),s.getMonth(),o),n)}function addMilliseconds(e,t){requiredArgs(2,arguments);var n=toDate(e).getTime(),r=toInteger(t);return new Date(n+r)}var MILLISECONDS_IN_HOUR=36e5;function addHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_HOUR)}var defaultOptions={};function getDefaultOptions(){return defaultOptions}function startOfWeek(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=getDefaultOptions(),B=toInteger((n=(r=(o=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(u=d.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=toDate(e),f=Q.getDay(),p=(f<B?7:0)+f-B;return Q.setDate(Q.getDate()-p),Q.setHours(0,0,0,0),Q}function startOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(0,0,0,0),t}var MILLISECONDS_IN_MINUTE=6e4;function addMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_MINUTE)}function addQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*3;return addMonths(e,r)}function addSeconds(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*1e3)}function addWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*7;return addDays(e,r)}function addYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,n*12)}function getQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=Math.floor(t.getMonth()/3)+1;return n}var roundingMap={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},defaultRoundingMethod="trunc";function getRoundingMethod(e){return e?roundingMap[e]:roundingMap[defaultRoundingMethod]}function endOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(23,59,59,999),t}function endOfMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function eachDayOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},o=toDate(r.start),s=toDate(r.end),g=s.getTime();if(!(o.getTime()<=g))throw new RangeError("Invalid interval");var l=[],u=o;u.setHours(0,0,0,0);var c=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(c<1||isNaN(c))throw new RangeError("`options.step` must be a number greater than 1");for(;u.getTime()<=g;)l.push(toDate(u)),u.setDate(u.getDate()+c),u.setHours(0,0,0,0);return l}function eachHourOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},o=toDate(r.start),s=toDate(r.end),g=o.getTime(),l=s.getTime();if(!(g<=l))throw new RangeError("Invalid interval");var u=[],c=o;c.setMinutes(0,0,0);var d=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(d<1||isNaN(d))throw new RangeError("`options.step` must be a number greater than 1");for(;c.getTime()<=l;)u.push(toDate(c)),c=addHours(c,d);return u}function startOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(0,0),t}function eachMinuteOfInterval(e,t){var n;requiredArgs(1,arguments);var r=startOfMinute(toDate(e.start)),o=toDate(e.end),s=r.getTime(),g=o.getTime();if(s>=g)throw new RangeError("Invalid interval");var l=[],u=r,c=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(c<1||isNaN(c))throw new RangeError("`options.step` must be a number equal to or greater than 1");for(;u.getTime()<=g;)l.push(toDate(u)),u=addMinutes(u,c);return l}function eachMonthOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime(),s=[];if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var g=n;for(g.setHours(0,0,0,0),g.setDate(1);g.getTime()<=o;)s.push(toDate(g)),g.setMonth(g.getMonth()+1);return s}function startOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3;return t.setMonth(r,1),t.setHours(0,0,0,0),t}function eachQuarterOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime();if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var s=startOfQuarter(n),g=startOfQuarter(r);o=g.getTime();for(var l=[],u=s;u.getTime()<=o;)l.push(toDate(u)),u=addQuarters(u,1);return l}function eachWeekOfInterval(e,t){requiredArgs(1,arguments);var n=e||{},r=toDate(n.start),o=toDate(n.end),s=o.getTime();if(!(r.getTime()<=s))throw new RangeError("Invalid interval");var g=startOfWeek(r,t),l=startOfWeek(o,t);g.setHours(15),l.setHours(15),s=l.getTime();for(var u=[],c=g;c.getTime()<=s;)c.setHours(0),u.push(toDate(c)),c=addWeeks(c,1),c.setHours(15);return u}function startOfMonth(e){requiredArgs(1,arguments);var t=toDate(e);return t.setDate(1),t.setHours(0,0,0,0),t}function endOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(23,59,59,999),t}function startOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=new Date(0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function eachYearOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime();if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var s=[],g=n;for(g.setHours(0,0,0,0),g.setMonth(0,1);g.getTime()<=o;)s.push(toDate(g)),g.setFullYear(g.getFullYear()+1);return s}function endOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(59,59,999),t}function endOfWeek(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=getDefaultOptions(),B=toInteger((n=(r=(o=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(u=d.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=toDate(e),f=Q.getDay(),p=(f<B?-7:0)+6-(f-B);return Q.setDate(Q.getDate()+p),Q.setHours(23,59,59,999),Q}function endOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(59,999),t}function endOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3+3;return t.setMonth(r,0),t.setHours(23,59,59,999),t}function getDay(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getDay();return n}function getHours(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getHours();return n}function getMinutes(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMinutes();return n}function getMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return n}function getWeekYear(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=toDate(e),B=d.getFullYear(),Q=getDefaultOptions(),f=toInteger((n=(r=(o=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.firstWeekContainsDate)!==null&&o!==void 0?o:Q.firstWeekContainsDate)!==null&&r!==void 0?r:(u=Q.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1);if(!(f>=1&&f<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setFullYear(B+1,0,f),p.setHours(0,0,0,0);var U=startOfWeek(p,t),E=new Date(0);E.setFullYear(B,0,f),E.setHours(0,0,0,0);var M=startOfWeek(E,t);return d.getTime()>=U.getTime()?B+1:d.getTime()>=M.getTime()?B:B-1}function startOfWeekYear(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=getDefaultOptions(),B=toInteger((n=(r=(o=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.firstWeekContainsDate)!==null&&o!==void 0?o:d.firstWeekContainsDate)!==null&&r!==void 0?r:(u=d.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1),Q=getWeekYear(e,t),f=new Date(0);f.setFullYear(Q,0,B),f.setHours(0,0,0,0);var p=startOfWeek(f,t);return p}var MILLISECONDS_IN_WEEK=6048e5;function getWeek(e,t){requiredArgs(1,arguments);var n=toDate(e),r=startOfWeek(n,t).getTime()-startOfWeekYear(n,t).getTime();return Math.round(r/MILLISECONDS_IN_WEEK)+1}function getYear(e){return requiredArgs(1,arguments),toDate(e).getFullYear()}function startOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(0,0,0),t}function subDays(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addDays(e,-n)}function roundToNearestMinutes(e,t){var n;if(arguments.length<1)throw new TypeError("1 argument required, but only none provided present");var r=toInteger((n=t==null?void 0:t.nearestTo)!==null&&n!==void 0?n:1);if(r<1||r>30)throw new RangeError("`options.nearestTo` must be between 1 and 30");var o=toDate(e),s=o.getSeconds(),g=o.getMinutes()+s/60,l=getRoundingMethod(t==null?void 0:t.roundingMethod),u=l(g/r)*r,c=g%r,d=Math.round(c/r)*r;return new Date(o.getFullYear(),o.getMonth(),o.getDate(),o.getHours(),u+d)}function subMonths(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,-n)}function subHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addHours(e,-n)}function subMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMinutes(e,-n)}function subQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addQuarters(e,-n)}function subWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addWeeks(e,-n)}function subYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addYears(e,-n)}const millisecond$2=1,second$2=1e3,minute$2=60*second$2,hour$2=60*minute$2,day$2=24*hour$2,week$2=7*day$2,month$2=30*day$2,year$2=365*day$2,duration$2={millisecond:millisecond$2,second:second$2,minute:minute$2,hour:hour$2,day:day$2,week:week$2,month:month$2,year:year$2};function filterDataByType$1(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime$1(e,t,n){const r=t.getTime(),o=n.getTime();return e.map(s=>({...s,points:s.points.filter(([g])=>g>=r&&g<o)})).filter(({points:s})=>s.length>0)}let StoreCache$1=class{constructor({capacity:t,timeout:n}={}){he(this,"entries",new Map);he(this,"metadata",new Map);he(this,"capacity");he(this,"staleIntervalMs");this.capacity=t||1e4,this.staleIntervalMs=n||duration$2.minute}get(t,n){const r=this.keyToCacheKey(t);return this.isStale(r)&&!this.isGenerating(r)&&n&&this.generate(t,n),this.entries.get(r)}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,staleAt:performance.now()+this.staleIntervalMs});const o=this.entries.get(r);JSON.stringify(o)===JSON.stringify(n)||(this.entries.set(r,n),this.enforceMaxSize())}clear(){this.entries.clear(),[...this.metadata.values()].forEach(t=>t.generating=!1)}clearKey(t){this.metadata.delete(t),this.entries.delete(t)}keyToCacheKey(t){return JSON.stringify(t)}enforceMaxSize(){for(;this.metadata.size>this.capacity&&this.metadata.size>0;){const[t]=[...this.metadata.entries()].reduce(([n,r],[o,s])=>s.staleAt<r.staleAt?[o,s]:[n,r]);this.clearKey(t)}}isStale(t){const n=this.metadata.get(t);return n?(n==null?void 0:n.staleAt)<performance.now():!0}isGenerating(t){const n=this.metadata.get(t);return n?n.generating:!1}generate(t,n){const r=this.keyToCacheKey(t),o=this.metadata.get(r)||{},s=n().then(g=>{const l=this.metadata.get(r);return(l==null?void 0:l.generating)!==s||this.set(t,g),g}).catch(g=>{throw this.metadata.delete(r),g});this.metadata.set(r,{...o,generating:s,staleAt:performance.now()+this.staleIntervalMs})}};async function queryTelemetry(e){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${exports.FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}let QueryStore$1=class{constructor(){he(this,"queryStoreCache",new StoreCache$1({capacity:1e4,timeout:20*duration$2.second}));he(this,"liveQueryStoreCache",new StoreCache$1({capacity:1e4,timeout:200*duration$2.millisecond}))}moduleQuery(t,n,r,o,s,g=!1){const l={...t,names:[...n],types:[...r]},u=this.query(l,o,s,g);return u===void 0||u==="too much data"?u:filterDataByType$1(u,r)}query(t,n,r,o=!1){const s={...t,start:startOfMinute(n).toISOString(),end:o?r.toISOString():addMinutes(roundToNearestMinutes(r),1).toISOString(),latestOnly:o},g=r>addSeconds(new Date,-20);let l;return g?l=this.liveQueryCache(s):l=this.queryCache(s),!l||l==="too much data"||o?l:filterDataByTime$1(l,n,r)}queryCache(t){return this.queryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}liveQueryCache(t){return this.liveQueryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}};const queryStore=new QueryStore$1;function addStreamListener(e,t,n){const r=o=>{const s=o.data;if(s.type==="module_data"){const{start:g,end:l}=s.queryRange;n(queryStore.moduleQuery({},e,t,new Date(g),new Date(l),!1))}};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)}async function getDate(e,t,n){return new Promise(r=>{sendAppMessage({type:"request_date",minTime:t,maxTime:n,time:e});const o=s=>{const g=s.data;g.type==="date_response"&&(window.removeEventListener("message",o),r(g.data))};window.addEventListener("message",o)})}async function prompt(e,t){return new Promise(n=>{const r=Math.random().toString();sendAppMessage({type:"prompt",promptId:r,schema:e,okText:t==null?void 0:t.okText,cancelText:t==null?void 0:t.cancelText});const o=s=>{const g=s.data;g.type==="prompt_response"&&g.promptId===r&&n(g.data),window.removeEventListener("message",o)};window.addEventListener("message",o)})}const Yt=class{static isModule(){return getCurrentModuleContext()!==null}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window!="undefined"&&window.location&&(t=new URLSearchParams(window.location.search));const n=t.get("configuration");if(!(n===null||n.trim()===""))return getModuleConfiguration(n.trim())}static get isOnline(){return Yt._isOnline}static listenForConnectionEvents(){const t=n=>{const{data:r}=n;r.type==="formant_online"&&(this._isOnline=r.online)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}static checkConnection(t=1e3){return new Promise((n,r)=>{const o=setTimeout(()=>r(new Error("deadline expired: took too long")),t),s=g=>{window.removeEventListener("message",s),clearTimeout(o);const{data:l}=g;l.type==="formant_online"&&(this._isOnline=l.online,n(l.online))};window.addEventListener("message",s),sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((g,l)=>{setTimeout(()=>{n=!0,l(new Error("deadline expired: took too long"))},t)}),o=g=>new Promise(l=>setTimeout(l,g)),s=async()=>{for(await o(50);!n&&!(this.isOnline||await this.checkConnection);)await o(500)};return Promise.race([r,s()])}};let App=Yt;he(App,"getCurrentModuleContext",getCurrentModuleContext),he(App,"disableAnalyticsBottomBar",disableAnalyticsBottomBar),he(App,"goToDevice",goToDevice),he(App,"goToTime",goToTime),he(App,"refreshAuthToken",refreshAuthToken),he(App,"requestModuleData",requestModuleData),he(App,"sendChannelData",sendChannelData),he(App,"setModuleDateTimeRange",setModuleDateTimeRange),he(App,"setupModuleMenus",setupModuleMenus),he(App,"showMessage",showMessage),he(App,"addAccessTokenRefreshListener",addAccessTokenRefreshListener),he(App,"addChannelDataListener",addChannelDataListener),he(App,"addMenuListener",addMenuListener),he(App,"addModuleConfigurationListener",addModuleConfigurationListener),he(App,"addModuleDataListener",addModuleDataListener),he(App,"addOverviewDeviceListener",addOverviewDeviceListener),he(App,"addStreamListener",addStreamListener),he(App,"getDate",getDate),he(App,"prompt",prompt),he(App,"_isOnline",null);function stringToArrayBuffer(e){return Uint8Array.from(base64Exports.decode(e),t=>t.charCodeAt(0))}function fork$1(e){}function browser(){const{userAgent:e}=navigator;return e?e.includes("Firefox/")?"Firefox":e.includes("Edg/")?"Edge":e.includes("Chrome/")?"Chrome":e.includes("Safari/")?"Safari":e.includes("MSIE/")||e.includes("Trident/")?"IE":"Other":"Other"}const rtcAudioChunkStreamType="audio-chunk";class AudioPlayer{constructor(t,n){he(this,"muted",!1);he(this,"hasReceivedData",!1);he(this,"audioContext");he(this,"chunks",[]);he(this,"isPlaying",!1);he(this,"startTime",0);he(this,"lastChunkOffset",0);he(this,"bufferSize",3);he(this,"receive",async t=>{var g;const n=(g=t.payload.audioChunk)==null?void 0:g.chunk_data;if(!n)return;this.hasReceivedData||(this.hasReceivedData=!0);const{audioContext:r,muted:o}=this;if(!r||t.header.stream.streamType!==rtcAudioChunkStreamType||o!==!1)return;const s=stringToArrayBuffer(n);try{await r.decodeAudioData(s.buffer,this.scheduleChunk)}catch(l){console.warn("Error decoding audio buffer, changing audioWireFormat on agent",{error:l}),this.changeAudioWireFormat("wav")}});he(this,"scheduleChunk",t=>{const{audioContext:n}=this;if(!n)return;(this.chunks.length>this.bufferSize||this.isPlaying===!1)&&(this.chunks.forEach(o=>{o.stop()}),this.isPlaying=!1,this.chunks=[]);const r=this.createChunk(t);r&&r.buffer&&(this.isPlaying===!1&&(this.startTime=n.currentTime,this.lastChunkOffset=0,this.isPlaying=!0),r.start(this.startTime+this.lastChunkOffset,0,t.duration),this.lastChunkOffset+=r.buffer.duration,this.chunks.push(r))});this.device=t,this.stream=n,this.device.startListeningToRealtimeDataStream(n),this.device.addRealtimeListener((o,s)=>{this.receive(s)}),browser()==="Safari"||browser()==="IE"?this.changeAudioWireFormat("wav"):this.changeAudioWireFormat("opus");const r=window.AudioContext||window.webkitAudioContext;this.audioContext=new r}async play(){var t,n;((t=this.audioContext)==null?void 0:t.state)==="suspended"&&await((n=this.audioContext)==null?void 0:n.resume()),this.muted=!1}async pause(){await this.audioContext.suspend(),this.muted=!0}destroy(){this.device.stopListeningToRealtimeDataStream(this.stream)}createChunk(t){const{audioContext:n}=this;if(!n)return;const r=n.createBufferSource();return r.buffer=t,r.connect(n.destination),r.loop=!1,r.onended=o=>{this.chunks.splice(this.chunks.indexOf(r),1),this.chunks.length===0&&(this.isPlaying=!1)},r}changeAudioWireFormat(t){const{stream:n}=this;(async()=>await this.device.changeStreamAudioType(n.name,t))()}}class CaptureStream{constructor(t){he(this,"token");this.captureSession=t}async ingestJSON(t){if(!this.token){const r=await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/capture-sessions/${this.captureSession.code}/authenticate`,{method:"POST"})).json();this.token=r.token}await fetch(`${exports.FORMANT_API_URL}/v1/ingest`,{method:"POST",body:JSON.stringify({deviceId:this.captureSession.deviceId,name:this.captureSession.streamName,type:"json",points:[[Date.now(),JSON.stringify(t)]]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.token}})}}class DataChannel{constructor(t){he(this,"ready",!1);he(this,"listeners",[]);he(this,"openListeners",[]);he(this,"closeListeners",[]);he(this,"errorListeners",[]);he(this,"binaryListeners",[]);he(this,"error");he(this,"decoder",new TextDecoder);this.dataChannel=t,this.dataChannel.binaryType="arraybuffer",this.dataChannel.onopen=()=>{this.setReady()},this.dataChannel.onclose=()=>{this.ready=!1,this.closeListeners.forEach(n=>n())},this.dataChannel.onerror=n=>{console.error(n),this.error="An error occurred in DataChannel",this.errorListeners.forEach(r=>r(n))},this.dataChannel.onmessage=n=>{this.listeners.forEach(r=>{const o=new Uint8Array(n.data),s=this.decoder.decode(o);r(s)}),this.binaryListeners.forEach(r=>{r(new Uint8Array(n.data))})}}setReady(){this.ready=!0,this.openListeners.forEach(t=>t())}addOpenListener(t){this.openListeners.push(t)}removeOpenListener(t){this.openListeners=this.openListeners.filter(n=>n!==t)}addCloseListener(t){this.closeListeners.push(t)}removeCloseListener(t){this.closeListeners=this.closeListeners.filter(n=>n!==t)}addErrorListener(t){this.errorListeners.push(t)}removeErrorListener(t){this.errorListeners=this.errorListeners.filter(n=>n!==t)}async waitTilReady(){return this.ready?!0:new Promise((n,r)=>{let o=setInterval(()=>{this.dataChannel.readyState==="open"&&this.setReady(),this.ready&&(clearInterval(o),n(!0)),this.error&&r(this.error)},10)})}send(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}sendBinary(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}addListener(t){this.listeners.push(t)}removeListener(t){const n=this.listeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.listeners.splice(n,1)}addBinaryListener(t){this.binaryListeners.push(t)}removeBinaryListener(t){const n=this.binaryListeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.binaryListeners.splice(n,1)}}var dist={exports:{}};/*! For license information please see index.js.LICENSE.txt */(function(module,exports){(function(e,t){module.exports=t()})(window,function(){return function(e){function t(c){for(var d,B,Q=c[0],f=c[1],p=0,U=[];p<Q.length;p++)B=Q[p],Object.prototype.hasOwnProperty.call(r,B)&&r[B]&&U.push(r[B][0]),r[B]=0;for(d in f)Object.prototype.hasOwnProperty.call(f,d)&&(e[d]=f[d]);for(u&&u(c);U.length;)U.shift()()}var n={},r={0:0};function o(c){if(n[c])return n[c].exports;var d=n[c]={i:c,l:!1,exports:{}};return e[c].call(d.exports,d,d.exports,o),d.l=!0,d.exports}o.e=function(){return Promise.resolve()},o.m=e,o.c=n,o.d=function(c,d,B){o.o(c,d)||Object.defineProperty(c,d,{enumerable:!0,get:B})},o.r=function(c){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(c,"__esModule",{value:!0})},o.t=function(c,d){if(1&d&&(c=o(c)),8&d||4&d&&typeof c=="object"&&c&&c.__esModule)return c;var B=Object.create(null);if(o.r(B),Object.defineProperty(B,"default",{enumerable:!0,value:c}),2&d&&typeof c!="string")for(var Q in c)o.d(B,Q,function(f){return c[f]}.bind(null,Q));return B},o.n=function(c){var d=c&&c.__esModule?function(){return c.default}:function(){return c};return o.d(d,"a",d),d},o.o=function(c,d){return Object.prototype.hasOwnProperty.call(c,d)},o.p="",o.oe=function(c){throw console.error(c),c};var s=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],g=s.push.bind(s);s.push=t,s=s.slice();for(var l=0;l<s.length;l++)t(s[l]);var u=g;return o(o.s=233)}([function(e,t,n){n.d(t,"a",function(){return V});var r=n(16),o=n(55),s=n(15),g=n.n(s),l=n(18);function u(K,Y){if(Y.length<K)throw new TypeError(K+" argument"+(K>1?"s":"")+" required, but only "+Y.length+" present")}function c(K){if(K===null||K===!0||K===!1)return NaN;var Y=Number(K);return isNaN(Y)?Y:Y<0?Math.ceil(Y):Math.floor(Y)}var d={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},B=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Q=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,f=/^([+-])(\d{2})(?::?(\d{2}))?$/;function p(K){var Y,te={},oe=K.split(d.dateTimeDelimiter);if(oe.length>2)return te;if(/:/.test(oe[0])?Y=oe[0]:(te.date=oe[0],Y=oe[1],d.timeZoneDelimiter.test(te.date)&&(te.date=K.split(d.timeZoneDelimiter)[0],Y=K.substr(te.date.length,K.length))),Y){var ge=d.timezone.exec(Y);ge?(te.time=Y.replace(ge[1],""),te.timezone=ge[1]):te.time=Y}return te}function U(K,Y){var te=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+Y)+"})|(\\d{2}|[+-]\\d{"+(2+Y)+"})$)"),oe=K.match(te);if(!oe)return{year:NaN,restDateString:""};var ge=oe[1]?parseInt(oe[1]):null,Se=oe[2]?parseInt(oe[2]):null;return{year:Se===null?ge:100*Se,restDateString:K.slice((oe[1]||oe[2]).length)}}function E(K,Y){if(Y===null)return new Date(NaN);var te=K.match(B);if(!te)return new Date(NaN);var oe=!!te[4],ge=M(te[1]),Se=M(te[2])-1,ve=M(te[3]),ye=M(te[4]),Je=M(te[5])-1;if(oe)return function(be,we,Ze){return we>=1&&we<=53&&Ze>=0&&Ze<=6}(0,ye,Je)?function(be,we,Ze){var Oe=new Date(0);Oe.setUTCFullYear(be,0,4);var it=Oe.getUTCDay()||7,mt=7*(we-1)+Ze+1-it;return Oe.setUTCDate(Oe.getUTCDate()+mt),Oe}(Y,ye,Je):new Date(NaN);var Ee=new Date(0);return function(be,we,Ze){return we>=0&&we<=11&&Ze>=1&&Ze<=(h[we]||(T(be)?29:28))}(Y,Se,ve)&&function(be,we){return we>=1&&we<=(T(be)?366:365)}(Y,ge)?(Ee.setUTCFullYear(Y,Se,Math.max(ge,ve)),Ee):new Date(NaN)}function M(K){return K?parseInt(K):1}function W(K){var Y=K.match(Q);if(!Y)return NaN;var te=y(Y[1]),oe=y(Y[2]),ge=y(Y[3]);return function(Se,ve,ye){return Se===24?ve===0&&ye===0:ye>=0&&ye<60&&ve>=0&&ve<60&&Se>=0&&Se<25}(te,oe,ge)?36e5*te+6e4*oe+1e3*ge:NaN}function y(K){return K&&parseFloat(K.replace(",","."))||0}function m(K){if(K==="Z")return 0;var Y=K.match(f);if(!Y)return 0;var te=Y[1]==="+"?-1:1,oe=parseInt(Y[2]),ge=Y[3]&&parseInt(Y[3])||0;return function(Se,ve){return ve>=0&&ve<=59}(0,ge)?te*(36e5*oe+6e4*ge):NaN}var h=[31,null,31,30,31,30,31,31,30,31,30,31];function T(K){return K%400==0||K%4==0&&K%100!=0}var I=n(40);function X(K){return u(1,arguments),K instanceof Date||Object(I.a)(K)==="object"&&Object.prototype.toString.call(K)==="[object Date]"}function F(K){u(1,arguments);var Y=Object.prototype.toString.call(K);return K instanceof Date||Object(I.a)(K)==="object"&&Y==="[object Date]"?new Date(K.getTime()):typeof K=="number"||Y==="[object Number]"?new Date(K):(typeof K!="string"&&Y!=="[object String]"||typeof console=="undefined"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function R(K){const Y=function(te,oe){var ge;u(1,arguments);var Se=c((ge=oe==null?void 0:oe.additionalDigits)!==null&&ge!==void 0?ge:2);if(Se!==2&&Se!==1&&Se!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof te!="string"&&Object.prototype.toString.call(te)!=="[object String]")return new Date(NaN);var ve,ye=p(te);if(ye.date){var Je=U(ye.date,Se);ve=E(Je.restDateString,Je.year)}if(!ve||isNaN(ve.getTime()))return new Date(NaN);var Ee,be=ve.getTime(),we=0;if(ye.time&&(we=W(ye.time),isNaN(we)))return new Date(NaN);if(!ye.timezone){var Ze=new Date(be+we),Oe=new Date(0);return Oe.setFullYear(Ze.getUTCFullYear(),Ze.getUTCMonth(),Ze.getUTCDate()),Oe.setHours(Ze.getUTCHours(),Ze.getUTCMinutes(),Ze.getUTCSeconds(),Ze.getUTCMilliseconds()),Oe}return Ee=m(ye.timezone),isNaN(Ee)?new Date(NaN):new Date(be+we+Ee)}(K);if(!function(te){if(u(1,arguments),!X(te)&&typeof te!="number")return!1;var oe=F(te);return!isNaN(Number(oe))}(Y))throw new Error(`Invalid ISO 8601 date string (${K})`);return Y}const x=Math.pow(2,20),w=x;var _=n(3),j=n(28);function C(K){return g()(K,{cycles:!0})}var J=function(K,Y){var te={};for(var oe in K)Object.prototype.hasOwnProperty.call(K,oe)&&Y.indexOf(oe)<0&&(te[oe]=K[oe]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ge=0;for(oe=Object.getOwnPropertySymbols(K);ge<oe.length;ge++)Y.indexOf(oe[ge])<0&&Object.prototype.propertyIsEnumerable.call(K,oe[ge])&&(te[oe[ge]]=K[oe[ge]])}return te};function v(K,Y={}){const{redacted:te=!0}=Y,oe=Je=>te?Object(j.a)(Je):Je;if(!K.stack)return{message:C(oe(K))};const{name:ge,message:Se,stack:ve}=K,ye=J(K,["name","message","stack"]);return{name:ge,message:Se!==void 0?Se:C(oe(K)),stack:ve,meta:ye&&Object.keys(ye).length===0?void 0:oe(ye)}}function D(K,Y={}){const{message:te,stack:oe,meta:ge}=v(K,Y);return`${oe||te||""}${ge&&Object.keys(ge).length>0?" -- "+C(ge):""}`}var A=n(236);const b=Object(A.a)();var P=n(14),z=n.n(P),$=function(K,Y,te,oe){return new(te||(te=Promise))(function(ge,Se){function ve(Ee){try{Je(oe.next(Ee))}catch(be){Se(be)}}function ye(Ee){try{Je(oe.throw(Ee))}catch(be){Se(be)}}function Je(Ee){var be;Ee.done?ge(Ee.value):(be=Ee.value,be instanceof te?be:new te(function(we){we(be)})).then(ve,ye)}Je((oe=oe.apply(K,Y||[])).next())})},ee=function(K,Y){var te={};for(var oe in K)Object.prototype.hasOwnProperty.call(K,oe)&&Y.indexOf(oe)<0&&(te[oe]=K[oe]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ge=0;for(oe=Object.getOwnPropertySymbols(K);ge<oe.length;ge++)Y.indexOf(oe[ge])<0&&Object.prototype.propertyIsEnumerable.call(K,oe[ge])&&(te[oe[ge]]=K[oe[ge]])}return te};class re extends z.a{constructor(Y,te){super(),this.endpoint=Y,this.metadata=te,this.logClient=this.getLogClient()}getLogClient(){return $(this,void 0,void 0,function*(){const{LogClient:Y}=yield Promise.resolve().then(n.bind(null,235));return new Y(this.endpoint)})}log(Y,te){return $(this,void 0,void 0,function*(){const{level:oe,message:ge,error:Se}=Y,ve=ee(Y,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:oe,message:(""+ge).substring(0,1e3),error:Se!==void 0?v(Se):void 0,meta:Object.assign(Object.assign({},ve),this.metadata)}])}catch(ye){console.error("Failed to log to log-api: "+D(ye))}te()})}}var O=function(K,Y){var te={};for(var oe in K)Object.prototype.hasOwnProperty.call(K,oe)&&Y.indexOf(oe)<0&&(te[oe]=K[oe]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ge=0;for(oe=Object.getOwnPropertySymbols(K);ge<oe.length;ge++)Y.indexOf(oe[ge])<0&&Object.prototype.propertyIsEnumerable.call(K,oe[ge])&&(te[oe[ge]]=K[oe[ge]])}return te};const k={app:_.a,namespace:_.j,buildTag:_.c,instanceId:b},S=_.f?l.format.printf(K=>{var{timestamp:Y,level:te,message:oe,error:ge}=K,Se=O(K,["timestamp","level","message","error"]);const ve=Object.assign(Object.assign({timestamp:Y?R(Y).getTime():new Date().getTime(),level:te.toUpperCase(),message:oe},ge?{error:v(ge)}:{}),{meta:Object.assign(Object.assign({},k),Se)});return g()(ve,{cycles:!0})}):l.format.printf(K=>{var{timestamp:Y,level:te,message:oe,error:ge}=K,Se=O(K,["timestamp","level","message","error"]);let ve=`${Y||new Date().toISOString()} ${te.toUpperCase()}: ${oe} `;return Object.keys(Se).length>0&&(ve+=g()(Se,{cycles:!0})),ge&&(ve+=`
|
|
1
|
+
"use strict";var Rn=Object.defineProperty;var Bn=(e,t,n)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var he=(e,t,n)=>(Bn(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t,n){try{if(t.get("formant_prod"))return"https://api.formant.io";if(t.get("formant_stage"))return"https://api-stage.formant.io";if(t.get("formant_dev"))return"https://api-dev.formant.io";if(t.get("formant_local"))return"https://api.formant.local";if(t.get("formant_url")){const r=t.get("formant_url");if(r!==null)try{return new URL(r).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${r}`)}}if(n){if(n.includes("app-dev.formant.io")||n.includes("localhost"))return"https://api-dev.formant.io";if(n.includes("app-stage.formant.io"))return"https://api-stage.formant.io";if(n.includes("app.formant.io"))return"https://api.formant.io"}}catch{}if(n){if(n.includes("app-dev.formant.io"))return"https://api-dev.formant.io";if(n.includes("app-stage.formant.io"))return"https://api-stage.formant.io";if(n.includes("app.formant.io"))return"https://api.formant.io"}return typeof e!="undefined"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}exports.FORMANT_API_URL=whichFormantApiUrl(typeof window!="undefined"?window:globalThis,new URLSearchParams(typeof window!="undefined"&&window.location?window.location.search:void 0),typeof window!="undefined"&&window.location?window.location.host:void 0);const setFormantApiUrl=e=>{exports.FORMANT_API_URL=e};function addAccessTokenRefreshListener(e){function t(n){const r=n.data;r.type==="auth_token"&&e(r.token)}return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function getCurrentModuleContext(){return typeof window!="undefined"&&window.location?new URLSearchParams(window.location.search).get("module"):null}function sendAppMessage(e){if(!(window&&window.parent))throw new Error("cannot send message to non-existent parent");window.parent.postMessage(e,"*")}function refreshAuthToken(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"refresh_auth_token",module:e})}var commonjsGlobal=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var base64={exports:{}};/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */base64.exports;(function(e,t){(function(n){var r=t,o=e&&e.exports==r&&e,s=typeof commonjsGlobal=="object"&&commonjsGlobal;(s.global===s||s.window===s)&&(n=s);var g=function(p){this.message=p};g.prototype=new Error,g.prototype.name="InvalidCharacterError";var l=function(p){throw new g(p)},u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,d=function(p){p=String(p).replace(c,"");var U=p.length;U%4==0&&(p=p.replace(/==?$/,""),U=p.length),(U%4==1||/[^+a-zA-Z0-9/]/.test(p))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var E=0,M,W,y="",m=-1;++m<U;)W=u.indexOf(p.charAt(m)),M=E%4?M*64+W:W,E++%4&&(y+=String.fromCharCode(255&M>>(-2*E&6)));return y},B=function(p){p=String(p),/[^\0-\xFF]/.test(p)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var U=p.length%3,E="",M=-1,W,y,m,h,T=p.length-U;++M<T;)W=p.charCodeAt(M)<<16,y=p.charCodeAt(++M)<<8,m=p.charCodeAt(++M),h=W+y+m,E+=u.charAt(h>>18&63)+u.charAt(h>>12&63)+u.charAt(h>>6&63)+u.charAt(h&63);return U==2?(W=p.charCodeAt(M)<<8,y=p.charCodeAt(++M),h=W+y,E+=u.charAt(h>>10)+u.charAt(h>>4&63)+u.charAt(h<<2&63)+"="):U==1&&(h=p.charCodeAt(M),E+=u.charAt(h>>2)+u.charAt(h<<4&63)+"=="),E},Q={encode:B,decode:d,version:"1.0.0"};if(r&&!r.nodeType)if(o)o.exports=Q;else for(var f in Q)Q.hasOwnProperty(f)&&(r[f]=Q[f]);else n.base64=Q})(commonjsGlobal)})(base64,base64.exports);var base64Exports=base64.exports;class LoginFailureError extends Error{constructor(n){super("login failed");he(this,"reason");this.reason=n,this.name="LoginFailureError",Object.setPrototypeOf(this,new.target.prototype)}}class LoginChallengedError extends Error{constructor(n){super("login challenged");he(this,"challenge");this.challenge=n,this.name="LoginChallengedError",Object.setPrototypeOf(this,new.target.prototype)}}class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){he(this,"_refreshToken");he(this,"_isShareToken",!1);he(this,"_currentOrganization");he(this,"_currentUser");he(this,"_defaultDeviceId");he(this,"_token");he(this,"_waitingForAuth",new Set);he(this,"_refreshTimer");he(this,"_apiUrl");he(this,"_refreshAuthToken");he(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}set apiUrl(t){this._apiUrl=t,setFormantApiUrl(t)}get apiUrl(){return this._apiUrl}get token(){return this._token}get currentUser(){return this._currentUser}get currentOrganization(){return this._currentOrganization}get defaultDeviceId(){return this._defaultDeviceId}get refreshToken(){return this._refreshToken}get isShareToken(){return this._isShareToken}async login(t,n,r={}){const{advanced:o=!1}=r;try{const s=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),g=await s.json();if(s.status!==200)throw new LoginFailureError(g.message);if("challenge"in g)throw new LoginChallengedError(g.challenge);const{authentication:l}=g;return await this.loginWithToken(l.accessToken,l.refreshToken),o?{result:"success",authentication:l}:l}catch(s){if(o||console.error("login() failed",{err:s}),this._waitingForAuth.forEach(g=>g(!1)),this._waitingForAuth.clear(),!o)throw s;return s instanceof LoginChallengedError?{result:"challenged",challenge:s.challenge}:{result:"failure",reason:s instanceof LoginFailureError?s.reason:s instanceof Error?s.message:String(s)}}}async loginWithToken(t,n,r=!1){var s;const o=JSON.parse(base64Exports.decode(t.split(".")[1]));try{let g;if(this._isShareToken=o["formant:claims"]&&o["formant:claims"].type=="share",o["formant:claims"]&&(this._currentOrganization=o["formant:claims"].organizationId),o["custom:organization_id"]&&(this._currentOrganization=o["custom:organization_id"]),this._isShareToken||(g=o.sub),o["formant:claims"]&&o["formant:claims"].userId&&(g=o["formant:claims"].userId),g&&((s=this._currentUser)==null?void 0:s.id)!==g&&!r){const l=await fetch(`${this._apiUrl}/v1/admin/users/${g}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),u=await l.json();if(l.status!==200)throw new Error(u.message);this._currentUser=u}this._token=t,this._waitingForAuth.forEach(l=>l(!0))}catch(g){console.error("loginWithToken() failed",{err:g}),this._waitingForAuth.forEach(l=>l(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const l=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:this._refreshToken})})).json();this._token=l.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}async loginToPeer(t,n,r){if((await fetch(`${t}/login`,{method:"POST",body:JSON.stringify({username:n,password:r}),headers:{"Content-Type":"application/json"}})).status!==200)throw new LoginFailureError("Invalid authentication")}getCurrentUser(){return this._currentUser}async waitTilAuthenticated(){return this.token!==void 0?!0:new Promise(t=>{this._waitingForAuth.add(t)})}async listenForRefresh(){const n=()=>{this._refreshTimer=void 0,this._refreshAuthToken()};this._addAccessTokenRefreshListener(r=>{this._refreshTimer&&clearTimeout(this._refreshTimer),this._refreshTimer=setTimeout(n,36e5),this.loginWithToken(r)}),this._refreshTimer=setTimeout(n,36e5)}async forgotPassword(t){await fetch(`${this._apiUrl}/v1/admin/auth/forgot-password`,{method:"POST",body:JSON.stringify({email:t}),headers:{"Content-Type":"application/json"}})}async confirmForgotPassword(t){return(await fetch(`${this._apiUrl}/v1/admin/auth/confirm-forgot-password`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).ok}async respondToNewPasswordRequiredChallenge(t){const n=await fetch(`${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});if(n.ok)return await n.json();throw new Error("respond-to-new-password-required-challenge failed")}async loginWithGoogle(t){return await(await fetch(`${this._apiUrl}/v1/admin/auth/login-google`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}async refresh(t){const r=await(await fetch(`${this._apiUrl}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:t})})).json();await this.loginWithToken(r.authentication.accessToken,t)}async checkSso(t,n){return await(await fetch(`${this._apiUrl}/v1/admin/auth/check-sso`,{method:"POST",body:JSON.stringify({email:t,allowUserAutoCreation:n}),headers:{"Content-Type":"application/json"}})).json()}async loginWithSso(t,n){const o=await(await fetch(`${this._apiUrl}/v1/admin/auth/login-sso`,{method:"POST",body:JSON.stringify({token:t,refreshToken:n}),headers:{"Content-Type":"application/json"}})).json();if(!o.authentication)throw new Error("Failed to login with SSO");return await this.loginWithToken(o.authentication.accessToken,o.authentication.refreshToken)}}const Authentication=new AuthenticationStore({apiUrl:exports.FORMANT_API_URL,refreshAuthToken,addAccessTokenRefreshListener});class Account{static async listAccounts(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async createAccounts(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async getAccount(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async patchAccount(t,n){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"PATCH",body:JSON.stringify(n),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}static async deleteAccount(t){if(!Authentication.token)throw new Error("Not authenticated");if(!(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).ok)throw new Error("Unable to delete account")}static async getAccountTree(t){if(!Authentication.token)throw new Error("Not authenticated");return await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/accounts/${t}/tree`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}async function getModuleConfiguration(e){return(await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/module-configurations/${e}`,{headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).configuration}function disableAnalyticsBottomBar(){sendAppMessage({type:"hide_analytics_date_picker"})}function goToDevice(e){sendAppMessage({type:"go_to_device",deviceId:e})}function goToTime(e){sendAppMessage({type:"go_to_time",time:e.getTime()})}function requestModuleData(){const e=getCurrentModuleContext();if(!e)throw new Error("No module context");sendAppMessage({type:"request_module_data",module:e})}function sendChannelData(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"send_channel_data",source:n,channel:e,data:t})}function setModuleDateTimeRange(e,t){const n=getCurrentModuleContext();if(!n)throw new Error("No module context");sendAppMessage({type:"set_module_data_time_range",module:n,before:e,after:t||0})}function setupModuleMenus(e){const t=getCurrentModuleContext();if(!t)throw new Error("No module context");sendAppMessage({type:"setup_module_menus",module:t,menus:e})}function showMessage(e){sendAppMessage({type:"show_message",message:e})}function addChannelDataListener(e,t){const n=r=>{const o=r.data;o.type==="channel_data"&&o.channel===e&&t({source:o.source,data:o.data})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addMenuListener(e){const t=n=>{const r=n.data;r.type==="module_menu_item_clicked"&&e(r.menu)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleConfigurationListener(e){const t=n=>{const r=n.data;r.type==="module_configuration"&&e(r)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function addModuleDataListener(e){const t=getCurrentModuleContext();t&&sendAppMessage({type:"request_module_data",module:t});const n=r=>{const o=r.data;o.type==="module_data"&&e({streams:o.streams,time:o.time,queryRange:o.queryRange})};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}function addOverviewDeviceListener(e){sendAppMessage({type:"request_devices"});const t=n=>{const r=n.data;r.type==="overview_devices"&&e(r.data)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function _typeof(e){return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(e)}function toInteger(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function requiredArgs(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function toDate(e){requiredArgs(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||_typeof(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function addDays(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);return isNaN(r)?new Date(NaN):(r&&n.setDate(n.getDate()+r),n)}function addMonths(e,t){requiredArgs(2,arguments);var n=toDate(e),r=toInteger(t);if(isNaN(r))return new Date(NaN);if(!r)return n;var o=n.getDate(),s=new Date(n.getTime());s.setMonth(n.getMonth()+r+1,0);var g=s.getDate();return o>=g?s:(n.setFullYear(s.getFullYear(),s.getMonth(),o),n)}function addMilliseconds(e,t){requiredArgs(2,arguments);var n=toDate(e).getTime(),r=toInteger(t);return new Date(n+r)}var MILLISECONDS_IN_HOUR=36e5;function addHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_HOUR)}var defaultOptions={};function getDefaultOptions(){return defaultOptions}function startOfWeek(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=getDefaultOptions(),B=toInteger((n=(r=(o=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(u=d.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=toDate(e),f=Q.getDay(),p=(f<B?7:0)+f-B;return Q.setDate(Q.getDate()-p),Q.setHours(0,0,0,0),Q}function startOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(0,0,0,0),t}var MILLISECONDS_IN_MINUTE=6e4;function addMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*MILLISECONDS_IN_MINUTE)}function addQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*3;return addMonths(e,r)}function addSeconds(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMilliseconds(e,n*1e3)}function addWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t),r=n*7;return addDays(e,r)}function addYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,n*12)}function getQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=Math.floor(t.getMonth()/3)+1;return n}var roundingMap={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},defaultRoundingMethod="trunc";function getRoundingMethod(e){return e?roundingMap[e]:roundingMap[defaultRoundingMethod]}function endOfDay(e){requiredArgs(1,arguments);var t=toDate(e);return t.setHours(23,59,59,999),t}function endOfMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function eachDayOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},o=toDate(r.start),s=toDate(r.end),g=s.getTime();if(!(o.getTime()<=g))throw new RangeError("Invalid interval");var l=[],u=o;u.setHours(0,0,0,0);var c=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(c<1||isNaN(c))throw new RangeError("`options.step` must be a number greater than 1");for(;u.getTime()<=g;)l.push(toDate(u)),u.setDate(u.getDate()+c),u.setHours(0,0,0,0);return l}function eachHourOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},o=toDate(r.start),s=toDate(r.end),g=o.getTime(),l=s.getTime();if(!(g<=l))throw new RangeError("Invalid interval");var u=[],c=o;c.setMinutes(0,0,0);var d=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(d<1||isNaN(d))throw new RangeError("`options.step` must be a number greater than 1");for(;c.getTime()<=l;)u.push(toDate(c)),c=addHours(c,d);return u}function startOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(0,0),t}function eachMinuteOfInterval(e,t){var n;requiredArgs(1,arguments);var r=startOfMinute(toDate(e.start)),o=toDate(e.end),s=r.getTime(),g=o.getTime();if(s>=g)throw new RangeError("Invalid interval");var l=[],u=r,c=Number((n=t==null?void 0:t.step)!==null&&n!==void 0?n:1);if(c<1||isNaN(c))throw new RangeError("`options.step` must be a number equal to or greater than 1");for(;u.getTime()<=g;)l.push(toDate(u)),u=addMinutes(u,c);return l}function eachMonthOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime(),s=[];if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var g=n;for(g.setHours(0,0,0,0),g.setDate(1);g.getTime()<=o;)s.push(toDate(g)),g.setMonth(g.getMonth()+1);return s}function startOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3;return t.setMonth(r,1),t.setHours(0,0,0,0),t}function eachQuarterOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime();if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var s=startOfQuarter(n),g=startOfQuarter(r);o=g.getTime();for(var l=[],u=s;u.getTime()<=o;)l.push(toDate(u)),u=addQuarters(u,1);return l}function eachWeekOfInterval(e,t){requiredArgs(1,arguments);var n=e||{},r=toDate(n.start),o=toDate(n.end),s=o.getTime();if(!(r.getTime()<=s))throw new RangeError("Invalid interval");var g=startOfWeek(r,t),l=startOfWeek(o,t);g.setHours(15),l.setHours(15),s=l.getTime();for(var u=[],c=g;c.getTime()<=s;)c.setHours(0),u.push(toDate(c)),c=addWeeks(c,1),c.setHours(15);return u}function startOfMonth(e){requiredArgs(1,arguments);var t=toDate(e);return t.setDate(1),t.setHours(0,0,0,0),t}function endOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getFullYear();return t.setFullYear(n+1,0,0),t.setHours(23,59,59,999),t}function startOfYear(e){requiredArgs(1,arguments);var t=toDate(e),n=new Date(0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function eachYearOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime();if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var s=[],g=n;for(g.setHours(0,0,0,0),g.setMonth(0,1);g.getTime()<=o;)s.push(toDate(g)),g.setFullYear(g.getFullYear()+1);return s}function endOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(59,59,999),t}function endOfWeek(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=getDefaultOptions(),B=toInteger((n=(r=(o=(s=t==null?void 0:t.weekStartsOn)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(u=d.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(B>=0&&B<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var Q=toDate(e),f=Q.getDay(),p=(f<B?-7:0)+6-(f-B);return Q.setDate(Q.getDate()+p),Q.setHours(23,59,59,999),Q}function endOfMinute(e){requiredArgs(1,arguments);var t=toDate(e);return t.setSeconds(59,999),t}function endOfQuarter(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth(),r=n-n%3+3;return t.setMonth(r,0),t.setHours(23,59,59,999),t}function getDay(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getDay();return n}function getHours(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getHours();return n}function getMinutes(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMinutes();return n}function getMonth(e){requiredArgs(1,arguments);var t=toDate(e),n=t.getMonth();return n}function getWeekYear(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=toDate(e),B=d.getFullYear(),Q=getDefaultOptions(),f=toInteger((n=(r=(o=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.firstWeekContainsDate)!==null&&o!==void 0?o:Q.firstWeekContainsDate)!==null&&r!==void 0?r:(u=Q.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1);if(!(f>=1&&f<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var p=new Date(0);p.setFullYear(B+1,0,f),p.setHours(0,0,0,0);var U=startOfWeek(p,t),E=new Date(0);E.setFullYear(B,0,f),E.setHours(0,0,0,0);var M=startOfWeek(E,t);return d.getTime()>=U.getTime()?B+1:d.getTime()>=M.getTime()?B:B-1}function startOfWeekYear(e,t){var n,r,o,s,g,l,u,c;requiredArgs(1,arguments);var d=getDefaultOptions(),B=toInteger((n=(r=(o=(s=t==null?void 0:t.firstWeekContainsDate)!==null&&s!==void 0?s:t==null||(g=t.locale)===null||g===void 0||(l=g.options)===null||l===void 0?void 0:l.firstWeekContainsDate)!==null&&o!==void 0?o:d.firstWeekContainsDate)!==null&&r!==void 0?r:(u=d.locale)===null||u===void 0||(c=u.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1),Q=getWeekYear(e,t),f=new Date(0);f.setFullYear(Q,0,B),f.setHours(0,0,0,0);var p=startOfWeek(f,t);return p}var MILLISECONDS_IN_WEEK=6048e5;function getWeek(e,t){requiredArgs(1,arguments);var n=toDate(e),r=startOfWeek(n,t).getTime()-startOfWeekYear(n,t).getTime();return Math.round(r/MILLISECONDS_IN_WEEK)+1}function getYear(e){return requiredArgs(1,arguments),toDate(e).getFullYear()}function startOfHour(e){requiredArgs(1,arguments);var t=toDate(e);return t.setMinutes(0,0,0),t}function subDays(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addDays(e,-n)}function roundToNearestMinutes(e,t){var n;if(arguments.length<1)throw new TypeError("1 argument required, but only none provided present");var r=toInteger((n=t==null?void 0:t.nearestTo)!==null&&n!==void 0?n:1);if(r<1||r>30)throw new RangeError("`options.nearestTo` must be between 1 and 30");var o=toDate(e),s=o.getSeconds(),g=o.getMinutes()+s/60,l=getRoundingMethod(t==null?void 0:t.roundingMethod),u=l(g/r)*r,c=g%r,d=Math.round(c/r)*r;return new Date(o.getFullYear(),o.getMonth(),o.getDate(),o.getHours(),u+d)}function subMonths(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMonths(e,-n)}function subHours(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addHours(e,-n)}function subMinutes(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addMinutes(e,-n)}function subQuarters(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addQuarters(e,-n)}function subWeeks(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addWeeks(e,-n)}function subYears(e,t){requiredArgs(2,arguments);var n=toInteger(t);return addYears(e,-n)}const millisecond$2=1,second$2=1e3,minute$2=60*second$2,hour$2=60*minute$2,day$2=24*hour$2,week$2=7*day$2,month$2=30*day$2,year$2=365*day$2,duration$2={millisecond:millisecond$2,second:second$2,minute:minute$2,hour:hour$2,day:day$2,week:week$2,month:month$2,year:year$2};function filterDataByType$1(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime$1(e,t,n){const r=t.getTime(),o=n.getTime();return e.map(s=>({...s,points:s.points.filter(([g])=>g>=r&&g<o)})).filter(({points:s})=>s.length>0)}let StoreCache$1=class{constructor({capacity:t,timeout:n}={}){he(this,"entries",new Map);he(this,"metadata",new Map);he(this,"capacity");he(this,"staleIntervalMs");this.capacity=t||1e4,this.staleIntervalMs=n||duration$2.minute}get(t,n){const r=this.keyToCacheKey(t);return this.isStale(r)&&!this.isGenerating(r)&&n&&this.generate(t,n),this.entries.get(r)}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,staleAt:performance.now()+this.staleIntervalMs});const o=this.entries.get(r);JSON.stringify(o)===JSON.stringify(n)||(this.entries.set(r,n),this.enforceMaxSize())}clear(){this.entries.clear(),[...this.metadata.values()].forEach(t=>t.generating=!1)}clearKey(t){this.metadata.delete(t),this.entries.delete(t)}keyToCacheKey(t){return JSON.stringify(t)}enforceMaxSize(){for(;this.metadata.size>this.capacity&&this.metadata.size>0;){const[t]=[...this.metadata.entries()].reduce(([n,r],[o,s])=>s.staleAt<r.staleAt?[o,s]:[n,r]);this.clearKey(t)}}isStale(t){const n=this.metadata.get(t);return n?(n==null?void 0:n.staleAt)<performance.now():!0}isGenerating(t){const n=this.metadata.get(t);return n?n.generating:!1}generate(t,n){const r=this.keyToCacheKey(t),o=this.metadata.get(r)||{},s=n().then(g=>{const l=this.metadata.get(r);return(l==null?void 0:l.generating)!==s||this.set(t,g),g}).catch(g=>{throw this.metadata.delete(r),g});this.metadata.set(r,{...o,generating:s,staleAt:performance.now()+this.staleIntervalMs})}};async function queryTelemetry(e){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${exports.FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}let QueryStore$1=class{constructor(){he(this,"queryStoreCache",new StoreCache$1({capacity:1e4,timeout:20*duration$2.second}));he(this,"liveQueryStoreCache",new StoreCache$1({capacity:1e4,timeout:200*duration$2.millisecond}))}moduleQuery(t,n,r,o,s,g=!1){const l={...t,names:[...n],types:[...r]},u=this.query(l,o,s,g);return u===void 0||u==="too much data"?u:filterDataByType$1(u,r)}query(t,n,r,o=!1){const s={...t,start:startOfMinute(n).toISOString(),end:o?r.toISOString():addMinutes(roundToNearestMinutes(r),1).toISOString(),latestOnly:o},g=r>addSeconds(new Date,-20);let l;return g?l=this.liveQueryCache(s):l=this.queryCache(s),!l||l==="too much data"||o?l:filterDataByTime$1(l,n,r)}queryCache(t){return this.queryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}liveQueryCache(t){return this.liveQueryStoreCache.get(t,async()=>{try{return await queryTelemetry(t)}catch(n){throw n}})}};const queryStore=new QueryStore$1;function addStreamListener(e,t,n){const r=o=>{const s=o.data;if(s.type==="module_data"){const{start:g,end:l}=s.queryRange;n(queryStore.moduleQuery({},e,t,new Date(g),new Date(l),!1))}};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)}async function getDate(e,t,n){return new Promise(r=>{sendAppMessage({type:"request_date",minTime:t,maxTime:n,time:e});const o=s=>{const g=s.data;g.type==="date_response"&&(window.removeEventListener("message",o),r(g.data))};window.addEventListener("message",o)})}async function prompt(e,t){return new Promise(n=>{const r=Math.random().toString();sendAppMessage({type:"prompt",promptId:r,schema:e,okText:t==null?void 0:t.okText,cancelText:t==null?void 0:t.cancelText});const o=s=>{const g=s.data;g.type==="prompt_response"&&g.promptId===r&&n(g.data),window.removeEventListener("message",o)};window.addEventListener("message",o)})}const Yt=class{static isModule(){return getCurrentModuleContext()!==null}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window!="undefined"&&window.location&&(t=new URLSearchParams(window.location.search));const n=t.get("configuration");if(!(n===null||n.trim()===""))return getModuleConfiguration(n.trim())}static get isOnline(){return Yt._isOnline}static listenForConnectionEvents(){const t=n=>{const{data:r}=n;r.type==="formant_online"&&(this._isOnline=r.online)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}static checkConnection(t=1e3){return new Promise((n,r)=>{const o=setTimeout(()=>r(new Error("deadline expired: took too long")),t),s=g=>{window.removeEventListener("message",s),clearTimeout(o);const{data:l}=g;l.type==="formant_online"&&(this._isOnline=l.online,n(l.online))};window.addEventListener("message",s),sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((g,l)=>{setTimeout(()=>{n=!0,l(new Error("deadline expired: took too long"))},t)}),o=g=>new Promise(l=>setTimeout(l,g)),s=async()=>{for(await o(50);!n&&!(this.isOnline||await this.checkConnection);)await o(500)};return Promise.race([r,s()])}};let App=Yt;he(App,"getCurrentModuleContext",getCurrentModuleContext),he(App,"disableAnalyticsBottomBar",disableAnalyticsBottomBar),he(App,"goToDevice",goToDevice),he(App,"goToTime",goToTime),he(App,"refreshAuthToken",refreshAuthToken),he(App,"requestModuleData",requestModuleData),he(App,"sendChannelData",sendChannelData),he(App,"setModuleDateTimeRange",setModuleDateTimeRange),he(App,"setupModuleMenus",setupModuleMenus),he(App,"showMessage",showMessage),he(App,"addAccessTokenRefreshListener",addAccessTokenRefreshListener),he(App,"addChannelDataListener",addChannelDataListener),he(App,"addMenuListener",addMenuListener),he(App,"addModuleConfigurationListener",addModuleConfigurationListener),he(App,"addModuleDataListener",addModuleDataListener),he(App,"addOverviewDeviceListener",addOverviewDeviceListener),he(App,"addStreamListener",addStreamListener),he(App,"getDate",getDate),he(App,"prompt",prompt),he(App,"_isOnline",null);function stringToArrayBuffer(e){return Uint8Array.from(base64Exports.decode(e),t=>t.charCodeAt(0))}function fork$1(e){}function browser(){const{userAgent:e}=navigator;return e?e.includes("Firefox/")?"Firefox":e.includes("Edg/")?"Edge":e.includes("Chrome/")?"Chrome":e.includes("Safari/")?"Safari":e.includes("MSIE/")||e.includes("Trident/")?"IE":"Other":"Other"}const rtcAudioChunkStreamType="audio-chunk";class AudioPlayer{constructor(t,n){he(this,"muted",!1);he(this,"hasReceivedData",!1);he(this,"audioContext");he(this,"chunks",[]);he(this,"isPlaying",!1);he(this,"startTime",0);he(this,"lastChunkOffset",0);he(this,"bufferSize",3);he(this,"receive",async t=>{var g;const n=(g=t.payload.audioChunk)==null?void 0:g.chunk_data;if(!n)return;this.hasReceivedData||(this.hasReceivedData=!0);const{audioContext:r,muted:o}=this;if(!r||t.header.stream.streamType!==rtcAudioChunkStreamType||o!==!1)return;const s=stringToArrayBuffer(n);try{await r.decodeAudioData(s.buffer,this.scheduleChunk)}catch(l){console.warn("Error decoding audio buffer, changing audioWireFormat on agent",{error:l}),this.changeAudioWireFormat("wav")}});he(this,"scheduleChunk",t=>{const{audioContext:n}=this;if(!n)return;(this.chunks.length>this.bufferSize||this.isPlaying===!1)&&(this.chunks.forEach(o=>{o.stop()}),this.isPlaying=!1,this.chunks=[]);const r=this.createChunk(t);r&&r.buffer&&(this.isPlaying===!1&&(this.startTime=n.currentTime,this.lastChunkOffset=0,this.isPlaying=!0),r.start(this.startTime+this.lastChunkOffset,0,t.duration),this.lastChunkOffset+=r.buffer.duration,this.chunks.push(r))});this.device=t,this.stream=n,this.device.startListeningToRealtimeDataStream(n),this.device.addRealtimeListener((o,s)=>{this.receive(s)}),browser()==="Safari"||browser()==="IE"?this.changeAudioWireFormat("wav"):this.changeAudioWireFormat("opus");const r=window.AudioContext||window.webkitAudioContext;this.audioContext=new r}async play(){var t,n;((t=this.audioContext)==null?void 0:t.state)==="suspended"&&await((n=this.audioContext)==null?void 0:n.resume()),this.muted=!1}async pause(){await this.audioContext.suspend(),this.muted=!0}destroy(){this.device.stopListeningToRealtimeDataStream(this.stream)}createChunk(t){const{audioContext:n}=this;if(!n)return;const r=n.createBufferSource();return r.buffer=t,r.connect(n.destination),r.loop=!1,r.onended=o=>{this.chunks.splice(this.chunks.indexOf(r),1),this.chunks.length===0&&(this.isPlaying=!1)},r}changeAudioWireFormat(t){const{stream:n}=this;(async()=>await this.device.changeStreamAudioType(n.name,t))()}}class CaptureStream{constructor(t){he(this,"token");this.captureSession=t}async ingestJSON(t){if(!this.token){const r=await(await fetch(`${exports.FORMANT_API_URL}/v1/admin/capture-sessions/${this.captureSession.code}/authenticate`,{method:"POST"})).json();this.token=r.token}await fetch(`${exports.FORMANT_API_URL}/v1/ingest`,{method:"POST",body:JSON.stringify({deviceId:this.captureSession.deviceId,name:this.captureSession.streamName,type:"json",points:[[Date.now(),JSON.stringify(t)]]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.token}})}}class DataChannel{constructor(t){he(this,"ready",!1);he(this,"listeners",[]);he(this,"openListeners",[]);he(this,"closeListeners",[]);he(this,"errorListeners",[]);he(this,"binaryListeners",[]);he(this,"error");he(this,"decoder",new TextDecoder);this.dataChannel=t,this.dataChannel.binaryType="arraybuffer",this.dataChannel.onopen=()=>{this.setReady()},this.dataChannel.onclose=()=>{this.ready=!1,this.closeListeners.forEach(n=>n())},this.dataChannel.onerror=n=>{console.error(n),this.error="An error occurred in DataChannel",this.errorListeners.forEach(r=>r(n))},this.dataChannel.onmessage=n=>{this.listeners.forEach(r=>{const o=new Uint8Array(n.data),s=this.decoder.decode(o);r(s)}),this.binaryListeners.forEach(r=>{r(new Uint8Array(n.data))})}}setReady(){this.ready=!0,this.openListeners.forEach(t=>t())}addOpenListener(t){this.openListeners.push(t)}removeOpenListener(t){this.openListeners=this.openListeners.filter(n=>n!==t)}addCloseListener(t){this.closeListeners.push(t)}removeCloseListener(t){this.closeListeners=this.closeListeners.filter(n=>n!==t)}addErrorListener(t){this.errorListeners.push(t)}removeErrorListener(t){this.errorListeners=this.errorListeners.filter(n=>n!==t)}async waitTilReady(){return this.ready?!0:new Promise((n,r)=>{let o=setInterval(()=>{this.dataChannel.readyState==="open"&&this.setReady(),this.ready&&(clearInterval(o),n(!0)),this.error&&r(this.error)},10)})}send(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}sendBinary(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}addListener(t){this.listeners.push(t)}removeListener(t){const n=this.listeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.listeners.splice(n,1)}addBinaryListener(t){this.binaryListeners.push(t)}removeBinaryListener(t){const n=this.binaryListeners.indexOf(t);if(n===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.binaryListeners.splice(n,1)}}var dist={exports:{}};/*! For license information please see index.js.LICENSE.txt */(function(module,exports){(function(e,t){module.exports=t()})(window,function(){return function(e){function t(c){for(var d,B,Q=c[0],f=c[1],p=0,U=[];p<Q.length;p++)B=Q[p],Object.prototype.hasOwnProperty.call(r,B)&&r[B]&&U.push(r[B][0]),r[B]=0;for(d in f)Object.prototype.hasOwnProperty.call(f,d)&&(e[d]=f[d]);for(u&&u(c);U.length;)U.shift()()}var n={},r={0:0};function o(c){if(n[c])return n[c].exports;var d=n[c]={i:c,l:!1,exports:{}};return e[c].call(d.exports,d,d.exports,o),d.l=!0,d.exports}o.e=function(){return Promise.resolve()},o.m=e,o.c=n,o.d=function(c,d,B){o.o(c,d)||Object.defineProperty(c,d,{enumerable:!0,get:B})},o.r=function(c){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(c,"__esModule",{value:!0})},o.t=function(c,d){if(1&d&&(c=o(c)),8&d||4&d&&typeof c=="object"&&c&&c.__esModule)return c;var B=Object.create(null);if(o.r(B),Object.defineProperty(B,"default",{enumerable:!0,value:c}),2&d&&typeof c!="string")for(var Q in c)o.d(B,Q,function(f){return c[f]}.bind(null,Q));return B},o.n=function(c){var d=c&&c.__esModule?function(){return c.default}:function(){return c};return o.d(d,"a",d),d},o.o=function(c,d){return Object.prototype.hasOwnProperty.call(c,d)},o.p="",o.oe=function(c){throw console.error(c),c};var s=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],g=s.push.bind(s);s.push=t,s=s.slice();for(var l=0;l<s.length;l++)t(s[l]);var u=g;return o(o.s=233)}([function(e,t,n){n.d(t,"a",function(){return V});var r=n(16),o=n(55),s=n(15),g=n.n(s),l=n(18);function u(K,Y){if(Y.length<K)throw new TypeError(K+" argument"+(K>1?"s":"")+" required, but only "+Y.length+" present")}function c(K){if(K===null||K===!0||K===!1)return NaN;var Y=Number(K);return isNaN(Y)?Y:Y<0?Math.ceil(Y):Math.floor(Y)}var d={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},B=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Q=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,f=/^([+-])(\d{2})(?::?(\d{2}))?$/;function p(K){var Y,te={},oe=K.split(d.dateTimeDelimiter);if(oe.length>2)return te;if(/:/.test(oe[0])?Y=oe[0]:(te.date=oe[0],Y=oe[1],d.timeZoneDelimiter.test(te.date)&&(te.date=K.split(d.timeZoneDelimiter)[0],Y=K.substr(te.date.length,K.length))),Y){var ge=d.timezone.exec(Y);ge?(te.time=Y.replace(ge[1],""),te.timezone=ge[1]):te.time=Y}return te}function U(K,Y){var te=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+Y)+"})|(\\d{2}|[+-]\\d{"+(2+Y)+"})$)"),oe=K.match(te);if(!oe)return{year:NaN,restDateString:""};var ge=oe[1]?parseInt(oe[1]):null,Se=oe[2]?parseInt(oe[2]):null;return{year:Se===null?ge:100*Se,restDateString:K.slice((oe[1]||oe[2]).length)}}function E(K,Y){if(Y===null)return new Date(NaN);var te=K.match(B);if(!te)return new Date(NaN);var oe=!!te[4],ge=M(te[1]),Se=M(te[2])-1,ve=M(te[3]),ye=M(te[4]),Je=M(te[5])-1;if(oe)return function(be,we,Ze){return we>=1&&we<=53&&Ze>=0&&Ze<=6}(0,ye,Je)?function(be,we,Ze){var Oe=new Date(0);Oe.setUTCFullYear(be,0,4);var it=Oe.getUTCDay()||7,mt=7*(we-1)+Ze+1-it;return Oe.setUTCDate(Oe.getUTCDate()+mt),Oe}(Y,ye,Je):new Date(NaN);var Ee=new Date(0);return function(be,we,Ze){return we>=0&&we<=11&&Ze>=1&&Ze<=(h[we]||(T(be)?29:28))}(Y,Se,ve)&&function(be,we){return we>=1&&we<=(T(be)?366:365)}(Y,ge)?(Ee.setUTCFullYear(Y,Se,Math.max(ge,ve)),Ee):new Date(NaN)}function M(K){return K?parseInt(K):1}function W(K){var Y=K.match(Q);if(!Y)return NaN;var te=y(Y[1]),oe=y(Y[2]),ge=y(Y[3]);return function(Se,ve,ye){return Se===24?ve===0&&ye===0:ye>=0&&ye<60&&ve>=0&&ve<60&&Se>=0&&Se<25}(te,oe,ge)?36e5*te+6e4*oe+1e3*ge:NaN}function y(K){return K&&parseFloat(K.replace(",","."))||0}function m(K){if(K==="Z")return 0;var Y=K.match(f);if(!Y)return 0;var te=Y[1]==="+"?-1:1,oe=parseInt(Y[2]),ge=Y[3]&&parseInt(Y[3])||0;return function(Se,ve){return ve>=0&&ve<=59}(0,ge)?te*(36e5*oe+6e4*ge):NaN}var h=[31,null,31,30,31,30,31,31,30,31,30,31];function T(K){return K%400==0||K%4==0&&K%100!=0}var I=n(40);function X(K){return u(1,arguments),K instanceof Date||Object(I.a)(K)==="object"&&Object.prototype.toString.call(K)==="[object Date]"}function F(K){u(1,arguments);var Y=Object.prototype.toString.call(K);return K instanceof Date||Object(I.a)(K)==="object"&&Y==="[object Date]"?new Date(K.getTime()):typeof K=="number"||Y==="[object Number]"?new Date(K):(typeof K!="string"&&Y!=="[object String]"||typeof console=="undefined"||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}function R(K){const Y=function(te,oe){var ge;u(1,arguments);var Se=c((ge=oe==null?void 0:oe.additionalDigits)!==null&&ge!==void 0?ge:2);if(Se!==2&&Se!==1&&Se!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof te!="string"&&Object.prototype.toString.call(te)!=="[object String]")return new Date(NaN);var ve,ye=p(te);if(ye.date){var Je=U(ye.date,Se);ve=E(Je.restDateString,Je.year)}if(!ve||isNaN(ve.getTime()))return new Date(NaN);var Ee,be=ve.getTime(),we=0;if(ye.time&&(we=W(ye.time),isNaN(we)))return new Date(NaN);if(!ye.timezone){var Ze=new Date(be+we),Oe=new Date(0);return Oe.setFullYear(Ze.getUTCFullYear(),Ze.getUTCMonth(),Ze.getUTCDate()),Oe.setHours(Ze.getUTCHours(),Ze.getUTCMinutes(),Ze.getUTCSeconds(),Ze.getUTCMilliseconds()),Oe}return Ee=m(ye.timezone),isNaN(Ee)?new Date(NaN):new Date(be+we+Ee)}(K);if(!function(te){if(u(1,arguments),!X(te)&&typeof te!="number")return!1;var oe=F(te);return!isNaN(Number(oe))}(Y))throw new Error(`Invalid ISO 8601 date string (${K})`);return Y}const x=Math.pow(2,20),w=x;var _=n(3),j=n(28);function C(K){return g()(K,{cycles:!0})}var J=function(K,Y){var te={};for(var oe in K)Object.prototype.hasOwnProperty.call(K,oe)&&Y.indexOf(oe)<0&&(te[oe]=K[oe]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ge=0;for(oe=Object.getOwnPropertySymbols(K);ge<oe.length;ge++)Y.indexOf(oe[ge])<0&&Object.prototype.propertyIsEnumerable.call(K,oe[ge])&&(te[oe[ge]]=K[oe[ge]])}return te};function v(K,Y={}){const{redacted:te=!0}=Y,oe=Je=>te?Object(j.a)(Je):Je;if(!K.stack)return{message:C(oe(K))};const{name:ge,message:Se,stack:ve}=K,ye=J(K,["name","message","stack"]);return{name:ge,message:Se!==void 0?Se:C(oe(K)),stack:ve,meta:ye&&Object.keys(ye).length===0?void 0:oe(ye)}}function D(K,Y={}){const{message:te,stack:oe,meta:ge}=v(K,Y);return`${oe||te||""}${ge&&Object.keys(ge).length>0?" -- "+C(ge):""}`}var A=n(236);const b=Object(A.a)();var P=n(14),z=n.n(P),$=function(K,Y,te,oe){return new(te||(te=Promise))(function(ge,Se){function ve(Ee){try{Je(oe.next(Ee))}catch(be){Se(be)}}function ye(Ee){try{Je(oe.throw(Ee))}catch(be){Se(be)}}function Je(Ee){var be;Ee.done?ge(Ee.value):(be=Ee.value,be instanceof te?be:new te(function(we){we(be)})).then(ve,ye)}Je((oe=oe.apply(K,Y||[])).next())})},ee=function(K,Y){var te={};for(var oe in K)Object.prototype.hasOwnProperty.call(K,oe)&&Y.indexOf(oe)<0&&(te[oe]=K[oe]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ge=0;for(oe=Object.getOwnPropertySymbols(K);ge<oe.length;ge++)Y.indexOf(oe[ge])<0&&Object.prototype.propertyIsEnumerable.call(K,oe[ge])&&(te[oe[ge]]=K[oe[ge]])}return te};class re extends z.a{constructor(Y,te){super(),this.endpoint=Y,this.metadata=te,this.logClient=this.getLogClient()}getLogClient(){return $(this,void 0,void 0,function*(){const{LogClient:Y}=yield Promise.resolve().then(n.bind(null,235));return new Y(this.endpoint)})}log(Y,te){return $(this,void 0,void 0,function*(){const{level:oe,message:ge,error:Se}=Y,ve=ee(Y,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:oe,message:(""+ge).substring(0,1e3),error:Se!==void 0?v(Se):void 0,meta:Object.assign(Object.assign({},ve),this.metadata)}])}catch(ye){console.error("Failed to log to log-api: "+D(ye))}te()})}}var O=function(K,Y){var te={};for(var oe in K)Object.prototype.hasOwnProperty.call(K,oe)&&Y.indexOf(oe)<0&&(te[oe]=K[oe]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ge=0;for(oe=Object.getOwnPropertySymbols(K);ge<oe.length;ge++)Y.indexOf(oe[ge])<0&&Object.prototype.propertyIsEnumerable.call(K,oe[ge])&&(te[oe[ge]]=K[oe[ge]])}return te};const k={app:_.a,namespace:_.j,buildTag:_.c,instanceId:b},S=_.f?l.format.printf(K=>{var{timestamp:Y,level:te,message:oe,error:ge}=K,Se=O(K,["timestamp","level","message","error"]);const ve=Object.assign(Object.assign({timestamp:Y?R(Y).getTime():new Date().getTime(),level:te.toUpperCase(),message:oe},ge?{error:v(ge)}:{}),{meta:Object.assign(Object.assign({},k),Se)});return g()(ve,{cycles:!0})}):l.format.printf(K=>{var{timestamp:Y,level:te,message:oe,error:ge}=K,Se=O(K,["timestamp","level","message","error"]);let ve=`${Y||new Date().toISOString()} ${te.toUpperCase()}: ${oe} `;return Object.keys(Se).length>0&&(ve+=g()(Se,{cycles:!0})),ge&&(ve+=`
|
|
2
2
|
`+D(ge)),ve}),V=Object(l.createLogger)({level:_.g});if(V.add(new l.transports.Console({format:S,level:"debug"})),V.transports.forEach(K=>{K.silent=!_.h}),_.e&&V.add(new re(_.e,k)),_.i){const K=o.resolve(r.tmpdir(),`silly-${_.a}.log`);V.debug("Logging silly logs to file",{filename:K}),V.add(new l.transports.File({filename:K,maxsize:1*w,maxFiles:10,format:l.format.combine((G="silly",Object(l.format)(Y=>Y.level===G&&Y)()),S),level:"silly"}))}var G},function(e,t,n){n.d(t,"a",function(){return o});const r=864e5,o={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:r,week:6048e5,month:2592e6,year:31536e6}},function(e,t){var n,r,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function g(){throw new Error("clearTimeout has not been defined")}function l(E){if(n===setTimeout)return setTimeout(E,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(E,0);try{return n(E,0)}catch{try{return n.call(null,E,0)}catch{return n.call(this,E,0)}}}(function(){try{n=typeof setTimeout=="function"?setTimeout:s}catch{n=s}try{r=typeof clearTimeout=="function"?clearTimeout:g}catch{r=g}})();var u,c=[],d=!1,B=-1;function Q(){d&&u&&(d=!1,u.length?c=u.concat(c):B=-1,c.length&&f())}function f(){if(!d){var E=l(Q);d=!0;for(var M=c.length;M;){for(u=c,c=[];++B<M;)u&&u[B].run();B=-1,M=c.length}u=null,d=!1,function(W){if(r===clearTimeout)return clearTimeout(W);if((r===g||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(W);try{r(W)}catch{try{return r.call(null,W)}catch{return r.call(this,W)}}}(E)}}function p(E,M){this.fun=E,this.array=M}function U(){}o.nextTick=function(E){var M=new Array(arguments.length-1);if(arguments.length>1)for(var W=1;W<arguments.length;W++)M[W-1]=arguments[W];c.push(new p(E,M)),c.length!==1||d||l(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=U,o.addListener=U,o.once=U,o.off=U,o.removeListener=U,o.removeAllListeners=U,o.emit=U,o.prependListener=U,o.prependOnceListener=U,o.listeners=function(E){return[]},o.binding=function(E){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(E){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){(function(r){n.d(t,"a",function(){return g}),n.d(t,"j",function(){return l}),n.d(t,"k",function(){return u}),n.d(t,"c",function(){return c}),n.d(t,"g",function(){return d}),n.d(t,"f",function(){return B}),n.d(t,"h",function(){return Q}),n.d(t,"e",function(){return f}),n.d(t,"d",function(){return p}),n.d(t,"i",function(){return U}),n.d(t,"b",function(){return E});var o=n(100);const s=o.from({ENVIRONMENT:r.env.ENV,AGGREGATE_LEVEL:r.env.AGGREGATE_LEVEL,API_ENDPOINT:r.env.API_ENDPOINT,APP:"realtime-sdk",APP_PATH:r.env.APP_PATH,BUILD_TAG:r.env.BUILD_TAG,ENABLE_SELF_SERVE:r.env.ENABLE_SELF_SERVE,ENABLE_SENTRY:r.env.ENABLE_SENTRY,ENABLE_SENTRY_PROFILING:r.env.ENABLE_SENTRY_PROFILING,GIT_COMMIT:r.env.GIT_COMMIT,JEST_WORKER_ID:r.env.JEST_WORKER_ID,LOG_API_ENDPOINT:r.env.LOG_API_ENDPOINT,LOG_JSON:"false",LOG_LEVEL:r.env.LOG_LEVEL,LOG_TO_CONSOLE:r.env.LOG_TO_CONSOLE,LOG_TO_FILE:r.env.LOG_TO_FILE,NAMESPACE:"production",SENTRY_DSN:r.env.SENTRY_DSN,SHEET_EXPORT_MAX_ROW_COUNT:r.env.SHEET_EXPORT_MAX_ROW_COUNT,STABLE_AGENT_VERSION:r.env.STABLE_AGENT_VERSION,VERSION:r.env.VERSION,AUDIT_LOGS_ENABLED:r.env.AUDIT_LOGS_ENABLED}),g=(s.get("ENVIRONMENT").default("").asString(),s.get("APP").default("").asString()),l=(s.get("APP_PATH").default("").asString(),s.get("API_ENDPOINT").default("").asString(),s.get("NAMESPACE").default("").asString()),u=s.get("VERSION").default("").asString(),c=s.get("BUILD_TAG").default("").asString(),d=(s.get("GIT_COMMIT").default("").asString(),s.get("ENABLE_SENTRY").default("false").asBool(),s.get("ENABLE_SENTRY_PROFILING").default("false").asBool(),s.get("SENTRY_DSN").default("").asString(),s.get("LOG_LEVEL").default("debug").asString()),B=s.get("LOG_JSON").default("true").asBool(),Q=s.get("LOG_TO_CONSOLE").default("true").asBool(),f=(s.get("STABLE_AGENT_VERSION").default("").asString(),s.get("LOG_API_ENDPOINT").asString()),p=s.get("JEST_WORKER_ID").asString(),U=(s.get("SHEET_EXPORT_MAX_ROW_COUNT").default("10000").asIntPositive(),s.get("LOG_TO_FILE").default("false").asBoolStrict()),E=(s.get("ENABLE_SELF_SERVE").default("true").asBoolStrict(),s.get("AGGREGATE_LEVEL").default("hour").asEnum(["day","hour","minute"]),s.get("AUDIT_LOGS_ENABLED").default("true").asBoolStrict())}).call(this,n(2))},function(e,t,n){Object.defineProperty(t,"LEVEL",{value:Symbol.for("level")}),Object.defineProperty(t,"MESSAGE",{value:Symbol.for("message")}),Object.defineProperty(t,"SPLAT",{value:Symbol.for("splat")}),Object.defineProperty(t,"configs",{value:n(115)})},function(e,t,n){(function(r){var o=n(140),s=n(141),g=n(142);function l(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(S,V){if(l()<V)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(S=new Uint8Array(V)).__proto__=c.prototype:(S===null&&(S=new c(V)),S.length=V),S}function c(S,V,G){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(S,V,G);if(typeof S=="number"){if(typeof V=="string")throw new Error("If encoding is specified then the first argument must be a string");return Q(this,S)}return d(this,S,V,G)}function d(S,V,G,K){if(typeof V=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&V instanceof ArrayBuffer?function(Y,te,oe,ge){if(te.byteLength,oe<0||te.byteLength<oe)throw new RangeError("'offset' is out of bounds");if(te.byteLength<oe+(ge||0))throw new RangeError("'length' is out of bounds");return te=oe===void 0&&ge===void 0?new Uint8Array(te):ge===void 0?new Uint8Array(te,oe):new Uint8Array(te,oe,ge),c.TYPED_ARRAY_SUPPORT?(Y=te).__proto__=c.prototype:Y=f(Y,te),Y}(S,V,G,K):typeof V=="string"?function(Y,te,oe){if(typeof oe=="string"&&oe!==""||(oe="utf8"),!c.isEncoding(oe))throw new TypeError('"encoding" must be a valid string encoding');var ge=0|U(te,oe),Se=(Y=u(Y,ge)).write(te,oe);return Se!==ge&&(Y=Y.slice(0,Se)),Y}(S,V,G):function(Y,te){if(c.isBuffer(te)){var oe=0|p(te.length);return(Y=u(Y,oe)).length===0||te.copy(Y,0,0,oe),Y}if(te){if(typeof ArrayBuffer!="undefined"&&te.buffer instanceof ArrayBuffer||"length"in te)return typeof te.length!="number"||(ge=te.length)!=ge?u(Y,0):f(Y,te);if(te.type==="Buffer"&&g(te.data))return f(Y,te.data)}var ge;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(S,V)}function B(S){if(typeof S!="number")throw new TypeError('"size" argument must be a number');if(S<0)throw new RangeError('"size" argument must not be negative')}function Q(S,V){if(B(V),S=u(S,V<0?0:0|p(V)),!c.TYPED_ARRAY_SUPPORT)for(var G=0;G<V;++G)S[G]=0;return S}function f(S,V){var G=V.length<0?0:0|p(V.length);S=u(S,G);for(var K=0;K<G;K+=1)S[K]=255&V[K];return S}function p(S){if(S>=l())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l().toString(16)+" bytes");return 0|S}function U(S,V){if(c.isBuffer(S))return S.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(S)||S instanceof ArrayBuffer))return S.byteLength;typeof S!="string"&&(S=""+S);var G=S.length;if(G===0)return 0;for(var K=!1;;)switch(V){case"ascii":case"latin1":case"binary":return G;case"utf8":case"utf-8":case void 0:return re(S).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*G;case"hex":return G>>>1;case"base64":return O(S).length;default:if(K)return re(S).length;V=(""+V).toLowerCase(),K=!0}}function E(S,V,G){var K=!1;if((V===void 0||V<0)&&(V=0),V>this.length||((G===void 0||G>this.length)&&(G=this.length),G<=0)||(G>>>=0)<=(V>>>=0))return"";for(S||(S="utf8");;)switch(S){case"hex":return j(this,V,G);case"utf8":case"utf-8":return x(this,V,G);case"ascii":return w(this,V,G);case"latin1":case"binary":return _(this,V,G);case"base64":return R(this,V,G);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,V,G);default:if(K)throw new TypeError("Unknown encoding: "+S);S=(S+"").toLowerCase(),K=!0}}function M(S,V,G){var K=S[V];S[V]=S[G],S[G]=K}function W(S,V,G,K,Y){if(S.length===0)return-1;if(typeof G=="string"?(K=G,G=0):G>2147483647?G=2147483647:G<-2147483648&&(G=-2147483648),G=+G,isNaN(G)&&(G=Y?0:S.length-1),G<0&&(G=S.length+G),G>=S.length){if(Y)return-1;G=S.length-1}else if(G<0){if(!Y)return-1;G=0}if(typeof V=="string"&&(V=c.from(V,K)),c.isBuffer(V))return V.length===0?-1:y(S,V,G,K,Y);if(typeof V=="number")return V&=255,c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?Y?Uint8Array.prototype.indexOf.call(S,V,G):Uint8Array.prototype.lastIndexOf.call(S,V,G):y(S,[V],G,K,Y);throw new TypeError("val must be string, number or Buffer")}function y(S,V,G,K,Y){var te,oe=1,ge=S.length,Se=V.length;if(K!==void 0&&((K=String(K).toLowerCase())==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le")){if(S.length<2||V.length<2)return-1;oe=2,ge/=2,Se/=2,G/=2}function ve(be,we){return oe===1?be[we]:be.readUInt16BE(we*oe)}if(Y){var ye=-1;for(te=G;te<ge;te++)if(ve(S,te)===ve(V,ye===-1?0:te-ye)){if(ye===-1&&(ye=te),te-ye+1===Se)return ye*oe}else ye!==-1&&(te-=te-ye),ye=-1}else for(G+Se>ge&&(G=ge-Se),te=G;te>=0;te--){for(var Je=!0,Ee=0;Ee<Se;Ee++)if(ve(S,te+Ee)!==ve(V,Ee)){Je=!1;break}if(Je)return te}return-1}function m(S,V,G,K){G=Number(G)||0;var Y=S.length-G;K?(K=Number(K))>Y&&(K=Y):K=Y;var te=V.length;if(te%2!=0)throw new TypeError("Invalid hex string");K>te/2&&(K=te/2);for(var oe=0;oe<K;++oe){var ge=parseInt(V.substr(2*oe,2),16);if(isNaN(ge))return oe;S[G+oe]=ge}return oe}function h(S,V,G,K){return k(re(V,S.length-G),S,G,K)}function T(S,V,G,K){return k(function(Y){for(var te=[],oe=0;oe<Y.length;++oe)te.push(255&Y.charCodeAt(oe));return te}(V),S,G,K)}function I(S,V,G,K){return T(S,V,G,K)}function X(S,V,G,K){return k(O(V),S,G,K)}function F(S,V,G,K){return k(function(Y,te){for(var oe,ge,Se,ve=[],ye=0;ye<Y.length&&!((te-=2)<0);++ye)oe=Y.charCodeAt(ye),ge=oe>>8,Se=oe%256,ve.push(Se),ve.push(ge);return ve}(V,S.length-G),S,G,K)}function R(S,V,G){return V===0&&G===S.length?o.fromByteArray(S):o.fromByteArray(S.slice(V,G))}function x(S,V,G){G=Math.min(S.length,G);for(var K=[],Y=V;Y<G;){var te,oe,ge,Se,ve=S[Y],ye=null,Je=ve>239?4:ve>223?3:ve>191?2:1;if(Y+Je<=G)switch(Je){case 1:ve<128&&(ye=ve);break;case 2:(192&(te=S[Y+1]))==128&&(Se=(31&ve)<<6|63&te)>127&&(ye=Se);break;case 3:te=S[Y+1],oe=S[Y+2],(192&te)==128&&(192&oe)==128&&(Se=(15&ve)<<12|(63&te)<<6|63&oe)>2047&&(Se<55296||Se>57343)&&(ye=Se);break;case 4:te=S[Y+1],oe=S[Y+2],ge=S[Y+3],(192&te)==128&&(192&oe)==128&&(192&ge)==128&&(Se=(15&ve)<<18|(63&te)<<12|(63&oe)<<6|63&ge)>65535&&Se<1114112&&(ye=Se)}ye===null?(ye=65533,Je=1):ye>65535&&(ye-=65536,K.push(ye>>>10&1023|55296),ye=56320|1023&ye),K.push(ye),Y+=Je}return function(Ee){var be=Ee.length;if(be<=4096)return String.fromCharCode.apply(String,Ee);for(var we="",Ze=0;Ze<be;)we+=String.fromCharCode.apply(String,Ee.slice(Ze,Ze+=4096));return we}(K)}t.Buffer=c,t.SlowBuffer=function(S){return+S!=S&&(S=0),c.alloc(+S)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=r.TYPED_ARRAY_SUPPORT!==void 0?r.TYPED_ARRAY_SUPPORT:function(){try{var S=new Uint8Array(1);return S.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},S.foo()===42&&typeof S.subarray=="function"&&S.subarray(1,1).byteLength===0}catch{return!1}}(),t.kMaxLength=l(),c.poolSize=8192,c._augment=function(S){return S.__proto__=c.prototype,S},c.from=function(S,V,G){return d(null,S,V,G)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(S,V,G){return function(K,Y,te,oe){return B(Y),Y<=0?u(K,Y):te!==void 0?typeof oe=="string"?u(K,Y).fill(te,oe):u(K,Y).fill(te):u(K,Y)}(null,S,V,G)},c.allocUnsafe=function(S){return Q(null,S)},c.allocUnsafeSlow=function(S){return Q(null,S)},c.isBuffer=function(S){return!(S==null||!S._isBuffer)},c.compare=function(S,V){if(!c.isBuffer(S)||!c.isBuffer(V))throw new TypeError("Arguments must be Buffers");if(S===V)return 0;for(var G=S.length,K=V.length,Y=0,te=Math.min(G,K);Y<te;++Y)if(S[Y]!==V[Y]){G=S[Y],K=V[Y];break}return G<K?-1:K<G?1:0},c.isEncoding=function(S){switch(String(S).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(S,V){if(!g(S))throw new TypeError('"list" argument must be an Array of Buffers');if(S.length===0)return c.alloc(0);var G;if(V===void 0)for(V=0,G=0;G<S.length;++G)V+=S[G].length;var K=c.allocUnsafe(V),Y=0;for(G=0;G<S.length;++G){var te=S[G];if(!c.isBuffer(te))throw new TypeError('"list" argument must be an Array of Buffers');te.copy(K,Y),Y+=te.length}return K},c.byteLength=U,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var S=this.length;if(S%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var V=0;V<S;V+=2)M(this,V,V+1);return this},c.prototype.swap32=function(){var S=this.length;if(S%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var V=0;V<S;V+=4)M(this,V,V+3),M(this,V+1,V+2);return this},c.prototype.swap64=function(){var S=this.length;if(S%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var V=0;V<S;V+=8)M(this,V,V+7),M(this,V+1,V+6),M(this,V+2,V+5),M(this,V+3,V+4);return this},c.prototype.toString=function(){var S=0|this.length;return S===0?"":arguments.length===0?x(this,0,S):E.apply(this,arguments)},c.prototype.equals=function(S){if(!c.isBuffer(S))throw new TypeError("Argument must be a Buffer");return this===S||c.compare(this,S)===0},c.prototype.inspect=function(){var S="",V=t.INSPECT_MAX_BYTES;return this.length>0&&(S=this.toString("hex",0,V).match(/.{2}/g).join(" "),this.length>V&&(S+=" ... ")),"<Buffer "+S+">"},c.prototype.compare=function(S,V,G,K,Y){if(!c.isBuffer(S))throw new TypeError("Argument must be a Buffer");if(V===void 0&&(V=0),G===void 0&&(G=S?S.length:0),K===void 0&&(K=0),Y===void 0&&(Y=this.length),V<0||G>S.length||K<0||Y>this.length)throw new RangeError("out of range index");if(K>=Y&&V>=G)return 0;if(K>=Y)return-1;if(V>=G)return 1;if(this===S)return 0;for(var te=(Y>>>=0)-(K>>>=0),oe=(G>>>=0)-(V>>>=0),ge=Math.min(te,oe),Se=this.slice(K,Y),ve=S.slice(V,G),ye=0;ye<ge;++ye)if(Se[ye]!==ve[ye]){te=Se[ye],oe=ve[ye];break}return te<oe?-1:oe<te?1:0},c.prototype.includes=function(S,V,G){return this.indexOf(S,V,G)!==-1},c.prototype.indexOf=function(S,V,G){return W(this,S,V,G,!0)},c.prototype.lastIndexOf=function(S,V,G){return W(this,S,V,G,!1)},c.prototype.write=function(S,V,G,K){if(V===void 0)K="utf8",G=this.length,V=0;else if(G===void 0&&typeof V=="string")K=V,G=this.length,V=0;else{if(!isFinite(V))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");V|=0,isFinite(G)?(G|=0,K===void 0&&(K="utf8")):(K=G,G=void 0)}var Y=this.length-V;if((G===void 0||G>Y)&&(G=Y),S.length>0&&(G<0||V<0)||V>this.length)throw new RangeError("Attempt to write outside buffer bounds");K||(K="utf8");for(var te=!1;;)switch(K){case"hex":return m(this,S,V,G);case"utf8":case"utf-8":return h(this,S,V,G);case"ascii":return T(this,S,V,G);case"latin1":case"binary":return I(this,S,V,G);case"base64":return X(this,S,V,G);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,S,V,G);default:if(te)throw new TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),te=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(S,V,G){var K="";G=Math.min(S.length,G);for(var Y=V;Y<G;++Y)K+=String.fromCharCode(127&S[Y]);return K}function _(S,V,G){var K="";G=Math.min(S.length,G);for(var Y=V;Y<G;++Y)K+=String.fromCharCode(S[Y]);return K}function j(S,V,G){var K=S.length;(!V||V<0)&&(V=0),(!G||G<0||G>K)&&(G=K);for(var Y="",te=V;te<G;++te)Y+=ee(S[te]);return Y}function C(S,V,G){for(var K=S.slice(V,G),Y="",te=0;te<K.length;te+=2)Y+=String.fromCharCode(K[te]+256*K[te+1]);return Y}function J(S,V,G){if(S%1!=0||S<0)throw new RangeError("offset is not uint");if(S+V>G)throw new RangeError("Trying to access beyond buffer length")}function v(S,V,G,K,Y,te){if(!c.isBuffer(S))throw new TypeError('"buffer" argument must be a Buffer instance');if(V>Y||V<te)throw new RangeError('"value" argument is out of bounds');if(G+K>S.length)throw new RangeError("Index out of range")}function D(S,V,G,K){V<0&&(V=65535+V+1);for(var Y=0,te=Math.min(S.length-G,2);Y<te;++Y)S[G+Y]=(V&255<<8*(K?Y:1-Y))>>>8*(K?Y:1-Y)}function A(S,V,G,K){V<0&&(V=4294967295+V+1);for(var Y=0,te=Math.min(S.length-G,4);Y<te;++Y)S[G+Y]=V>>>8*(K?Y:3-Y)&255}function b(S,V,G,K,Y,te){if(G+K>S.length)throw new RangeError("Index out of range");if(G<0)throw new RangeError("Index out of range")}function P(S,V,G,K,Y){return Y||b(S,0,G,4),s.write(S,V,G,K,23,4),G+4}function z(S,V,G,K,Y){return Y||b(S,0,G,8),s.write(S,V,G,K,52,8),G+8}c.prototype.slice=function(S,V){var G,K=this.length;if((S=~~S)<0?(S+=K)<0&&(S=0):S>K&&(S=K),(V=V===void 0?K:~~V)<0?(V+=K)<0&&(V=0):V>K&&(V=K),V<S&&(V=S),c.TYPED_ARRAY_SUPPORT)(G=this.subarray(S,V)).__proto__=c.prototype;else{var Y=V-S;G=new c(Y,void 0);for(var te=0;te<Y;++te)G[te]=this[te+S]}return G},c.prototype.readUIntLE=function(S,V,G){S|=0,V|=0,G||J(S,V,this.length);for(var K=this[S],Y=1,te=0;++te<V&&(Y*=256);)K+=this[S+te]*Y;return K},c.prototype.readUIntBE=function(S,V,G){S|=0,V|=0,G||J(S,V,this.length);for(var K=this[S+--V],Y=1;V>0&&(Y*=256);)K+=this[S+--V]*Y;return K},c.prototype.readUInt8=function(S,V){return V||J(S,1,this.length),this[S]},c.prototype.readUInt16LE=function(S,V){return V||J(S,2,this.length),this[S]|this[S+1]<<8},c.prototype.readUInt16BE=function(S,V){return V||J(S,2,this.length),this[S]<<8|this[S+1]},c.prototype.readUInt32LE=function(S,V){return V||J(S,4,this.length),(this[S]|this[S+1]<<8|this[S+2]<<16)+16777216*this[S+3]},c.prototype.readUInt32BE=function(S,V){return V||J(S,4,this.length),16777216*this[S]+(this[S+1]<<16|this[S+2]<<8|this[S+3])},c.prototype.readIntLE=function(S,V,G){S|=0,V|=0,G||J(S,V,this.length);for(var K=this[S],Y=1,te=0;++te<V&&(Y*=256);)K+=this[S+te]*Y;return K>=(Y*=128)&&(K-=Math.pow(2,8*V)),K},c.prototype.readIntBE=function(S,V,G){S|=0,V|=0,G||J(S,V,this.length);for(var K=V,Y=1,te=this[S+--K];K>0&&(Y*=256);)te+=this[S+--K]*Y;return te>=(Y*=128)&&(te-=Math.pow(2,8*V)),te},c.prototype.readInt8=function(S,V){return V||J(S,1,this.length),128&this[S]?-1*(255-this[S]+1):this[S]},c.prototype.readInt16LE=function(S,V){V||J(S,2,this.length);var G=this[S]|this[S+1]<<8;return 32768&G?4294901760|G:G},c.prototype.readInt16BE=function(S,V){V||J(S,2,this.length);var G=this[S+1]|this[S]<<8;return 32768&G?4294901760|G:G},c.prototype.readInt32LE=function(S,V){return V||J(S,4,this.length),this[S]|this[S+1]<<8|this[S+2]<<16|this[S+3]<<24},c.prototype.readInt32BE=function(S,V){return V||J(S,4,this.length),this[S]<<24|this[S+1]<<16|this[S+2]<<8|this[S+3]},c.prototype.readFloatLE=function(S,V){return V||J(S,4,this.length),s.read(this,S,!0,23,4)},c.prototype.readFloatBE=function(S,V){return V||J(S,4,this.length),s.read(this,S,!1,23,4)},c.prototype.readDoubleLE=function(S,V){return V||J(S,8,this.length),s.read(this,S,!0,52,8)},c.prototype.readDoubleBE=function(S,V){return V||J(S,8,this.length),s.read(this,S,!1,52,8)},c.prototype.writeUIntLE=function(S,V,G,K){S=+S,V|=0,G|=0,K||v(this,S,V,G,Math.pow(2,8*G)-1,0);var Y=1,te=0;for(this[V]=255&S;++te<G&&(Y*=256);)this[V+te]=S/Y&255;return V+G},c.prototype.writeUIntBE=function(S,V,G,K){S=+S,V|=0,G|=0,K||v(this,S,V,G,Math.pow(2,8*G)-1,0);var Y=G-1,te=1;for(this[V+Y]=255&S;--Y>=0&&(te*=256);)this[V+Y]=S/te&255;return V+G},c.prototype.writeUInt8=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,1,255,0),c.TYPED_ARRAY_SUPPORT||(S=Math.floor(S)),this[V]=255&S,V+1},c.prototype.writeUInt16LE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[V]=255&S,this[V+1]=S>>>8):D(this,S,V,!0),V+2},c.prototype.writeUInt16BE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[V]=S>>>8,this[V+1]=255&S):D(this,S,V,!1),V+2},c.prototype.writeUInt32LE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[V+3]=S>>>24,this[V+2]=S>>>16,this[V+1]=S>>>8,this[V]=255&S):A(this,S,V,!0),V+4},c.prototype.writeUInt32BE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[V]=S>>>24,this[V+1]=S>>>16,this[V+2]=S>>>8,this[V+3]=255&S):A(this,S,V,!1),V+4},c.prototype.writeIntLE=function(S,V,G,K){if(S=+S,V|=0,!K){var Y=Math.pow(2,8*G-1);v(this,S,V,G,Y-1,-Y)}var te=0,oe=1,ge=0;for(this[V]=255&S;++te<G&&(oe*=256);)S<0&&ge===0&&this[V+te-1]!==0&&(ge=1),this[V+te]=(S/oe>>0)-ge&255;return V+G},c.prototype.writeIntBE=function(S,V,G,K){if(S=+S,V|=0,!K){var Y=Math.pow(2,8*G-1);v(this,S,V,G,Y-1,-Y)}var te=G-1,oe=1,ge=0;for(this[V+te]=255&S;--te>=0&&(oe*=256);)S<0&&ge===0&&this[V+te+1]!==0&&(ge=1),this[V+te]=(S/oe>>0)-ge&255;return V+G},c.prototype.writeInt8=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,1,127,-128),c.TYPED_ARRAY_SUPPORT||(S=Math.floor(S)),S<0&&(S=255+S+1),this[V]=255&S,V+1},c.prototype.writeInt16LE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[V]=255&S,this[V+1]=S>>>8):D(this,S,V,!0),V+2},c.prototype.writeInt16BE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[V]=S>>>8,this[V+1]=255&S):D(this,S,V,!1),V+2},c.prototype.writeInt32LE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[V]=255&S,this[V+1]=S>>>8,this[V+2]=S>>>16,this[V+3]=S>>>24):A(this,S,V,!0),V+4},c.prototype.writeInt32BE=function(S,V,G){return S=+S,V|=0,G||v(this,S,V,4,2147483647,-2147483648),S<0&&(S=4294967295+S+1),c.TYPED_ARRAY_SUPPORT?(this[V]=S>>>24,this[V+1]=S>>>16,this[V+2]=S>>>8,this[V+3]=255&S):A(this,S,V,!1),V+4},c.prototype.writeFloatLE=function(S,V,G){return P(this,S,V,!0,G)},c.prototype.writeFloatBE=function(S,V,G){return P(this,S,V,!1,G)},c.prototype.writeDoubleLE=function(S,V,G){return z(this,S,V,!0,G)},c.prototype.writeDoubleBE=function(S,V,G){return z(this,S,V,!1,G)},c.prototype.copy=function(S,V,G,K){if(G||(G=0),K||K===0||(K=this.length),V>=S.length&&(V=S.length),V||(V=0),K>0&&K<G&&(K=G),K===G||S.length===0||this.length===0)return 0;if(V<0)throw new RangeError("targetStart out of bounds");if(G<0||G>=this.length)throw new RangeError("sourceStart out of bounds");if(K<0)throw new RangeError("sourceEnd out of bounds");K>this.length&&(K=this.length),S.length-V<K-G&&(K=S.length-V+G);var Y,te=K-G;if(this===S&&G<V&&V<K)for(Y=te-1;Y>=0;--Y)S[Y+V]=this[Y+G];else if(te<1e3||!c.TYPED_ARRAY_SUPPORT)for(Y=0;Y<te;++Y)S[Y+V]=this[Y+G];else Uint8Array.prototype.set.call(S,this.subarray(G,G+te),V);return te},c.prototype.fill=function(S,V,G,K){if(typeof S=="string"){if(typeof V=="string"?(K=V,V=0,G=this.length):typeof G=="string"&&(K=G,G=this.length),S.length===1){var Y=S.charCodeAt(0);Y<256&&(S=Y)}if(K!==void 0&&typeof K!="string")throw new TypeError("encoding must be a string");if(typeof K=="string"&&!c.isEncoding(K))throw new TypeError("Unknown encoding: "+K)}else typeof S=="number"&&(S&=255);if(V<0||this.length<V||this.length<G)throw new RangeError("Out of range index");if(G<=V)return this;var te;if(V>>>=0,G=G===void 0?this.length:G>>>0,S||(S=0),typeof S=="number")for(te=V;te<G;++te)this[te]=S;else{var oe=c.isBuffer(S)?S:re(new c(S,K).toString()),ge=oe.length;for(te=0;te<G-V;++te)this[te+V]=oe[te%ge]}return this};var $=/[^+\/0-9A-Za-z-_]/g;function ee(S){return S<16?"0"+S.toString(16):S.toString(16)}function re(S,V){var G;V=V||1/0;for(var K=S.length,Y=null,te=[],oe=0;oe<K;++oe){if((G=S.charCodeAt(oe))>55295&&G<57344){if(!Y){if(G>56319){(V-=3)>-1&&te.push(239,191,189);continue}if(oe+1===K){(V-=3)>-1&&te.push(239,191,189);continue}Y=G;continue}if(G<56320){(V-=3)>-1&&te.push(239,191,189),Y=G;continue}G=65536+(Y-55296<<10|G-56320)}else Y&&(V-=3)>-1&&te.push(239,191,189);if(Y=null,G<128){if((V-=1)<0)break;te.push(G)}else if(G<2048){if((V-=2)<0)break;te.push(G>>6|192,63&G|128)}else if(G<65536){if((V-=3)<0)break;te.push(G>>12|224,G>>6&63|128,63&G|128)}else{if(!(G<1114112))throw new Error("Invalid code point");if((V-=4)<0)break;te.push(G>>18|240,G>>12&63|128,G>>6&63|128,63&G|128)}}return te}function O(S){return o.toByteArray(function(V){if((V=function(G){return G.trim?G.trim():G.replace(/^\s+|\s+$/g,"")}(V).replace($,"")).length<2)return"";for(;V.length%4!=0;)V+="=";return V}(S))}function k(S,V,G,K){for(var Y=0;Y<K&&!(Y+G>=V.length||Y>=S.length);++Y)V[Y+G]=S[Y];return Y}}).call(this,n(6))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch{typeof window=="object"&&(n=window)}e.exports=n},function(e,t){typeof Object.create=="function"?e.exports=function(n,r){r&&(n.super_=r,n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(n,r){if(r){n.super_=r;var o=function(){};o.prototype=r.prototype,n.prototype=new o,n.prototype.constructor=n}}},function(e,t,n){function r(Q){return(r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(f){return typeof f}:function(f){return f&&typeof Symbol=="function"&&f.constructor===Symbol&&f!==Symbol.prototype?"symbol":typeof f})(Q)}function o(Q,f){if(f&&(r(f)==="object"||typeof f=="function"))return f;if(f!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return s(Q)}function s(Q){if(Q===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return Q}function g(Q){var f=typeof Map=="function"?new Map:void 0;return(g=function(p){if(p===null||(U=p,Function.toString.call(U).indexOf("[native code]")===-1))return p;var U;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(f!==void 0){if(f.has(p))return f.get(p);f.set(p,E)}function E(){return l(p,arguments,d(this).constructor)}return E.prototype=Object.create(p.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),c(E,p)})(Q)}function l(Q,f,p){return(l=u()?Reflect.construct.bind():function(U,E,M){var W=[null];W.push.apply(W,E);var y=new(Function.bind.apply(U,W));return M&&c(y,M.prototype),y}).apply(null,arguments)}function u(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function c(Q,f){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,U){return p.__proto__=U,p})(Q,f)}function d(Q){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(f){return f.__proto__||Object.getPrototypeOf(f)})(Q)}var B=function(Q){(function(W,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function");W.prototype=Object.create(y&&y.prototype,{constructor:{value:W,writable:!0,configurable:!0}}),Object.defineProperty(W,"prototype",{writable:!1}),y&&c(W,y)})(M,Q);var f,p,U,E=(f=M,p=u(),function(){var W,y=d(f);if(p){var m=d(this).constructor;W=Reflect.construct(y,arguments,m)}else W=y.apply(this,arguments);return o(this,W)});function M(W){var y;return function(m,h){if(!(m instanceof h))throw new TypeError("Cannot call a class as a function")}(this,M),y=E.call(this,`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
3
3
|
Found: `.concat(W.toString().split(`
|
|
4
4
|
`)[0],`
|