@formant/data-sdk 1.13.0 → 1.13.1

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.
@@ -265,7 +265,7 @@ class AuthenticationStore {
265
265
  )).ok;
266
266
  }
267
267
  async respondToNewPasswordRequiredChallenge(t) {
268
- return await (await fetch(
268
+ const n = await fetch(
269
269
  `${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,
270
270
  {
271
271
  method: "POST",
@@ -274,7 +274,10 @@ class AuthenticationStore {
274
274
  "Content-Type": "application/json"
275
275
  }
276
276
  }
277
- )).json();
277
+ );
278
+ if (n.ok)
279
+ return await n.json();
280
+ throw new Error("respond-to-new-password-required-challenge failed");
278
281
  }
279
282
  async loginWithGoogle(t) {
280
283
  return await (await fetch(`${this._apiUrl}/v1/admin/auth/login-google`, {
@@ -1,4 +1,4 @@
1
- (function(Qe,et){typeof exports=="object"&&typeof module<"u"?et(exports):typeof define=="function"&&define.amd?define(["exports"],et):(Qe=typeof globalThis<"u"?globalThis:Qe||self,et(Qe.FormantDataSDK={}))})(this,function(exports){var et;"use strict";var vn=Object.defineProperty;var wn=(Qe,et,Je)=>et in Qe?vn(Qe,et,{enumerable:!0,configurable:!0,writable:!0,value:Je}):Qe[et]=Je;var _e=(Qe,et,Je)=>(wn(Qe,typeof et!="symbol"?et+"":et,Je),Je);const DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t){try{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 n=t.get("formant_url");if(n!==null)try{return new URL(n).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${n}`)}}}catch{}return typeof e<"u"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}const FORMANT_API_URL=whichFormantApiUrl(typeof window<"u"?window:globalThis,new URLSearchParams(typeof window<"u"&&window.location?window.location.search:void 0));var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?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,l=typeof commonjsGlobal=="object"&&commonjsGlobal;(l.global===l||l.window===l)&&(n=l);var u=function(f){this.message=f};u.prototype=new Error,u.prototype.name="InvalidCharacterError";var s=function(f){throw new u(f)},g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,d=function(f){f=String(f).replace(c,"");var p=f.length;p%4==0&&(f=f.replace(/==?$/,""),p=f.length),(p%4==1||/[^+a-zA-Z0-9/]/.test(f))&&s("Invalid character: the string to be decoded is not correctly encoded.");for(var S=0,N,B,E="",T=-1;++T<p;)B=g.indexOf(f.charAt(T)),N=S%4?N*64+B:B,S++%4&&(E+=String.fromCharCode(255&N>>(-2*S&6)));return E},w=function(f){f=String(f),/[^\0-\xFF]/.test(f)&&s("The string to be encoded contains characters outside of the Latin1 range.");for(var p=f.length%3,S="",N=-1,B,E,T,h,R=f.length-p;++N<R;)B=f.charCodeAt(N)<<16,E=f.charCodeAt(++N)<<8,T=f.charCodeAt(++N),h=B+E+T,S+=g.charAt(h>>18&63)+g.charAt(h>>12&63)+g.charAt(h>>6&63)+g.charAt(h&63);return p==2?(B=f.charCodeAt(N)<<8,E=f.charCodeAt(++N),h=B+E,S+=g.charAt(h>>10)+g.charAt(h>>4&63)+g.charAt(h<<2&63)+"="):p==1&&(h=f.charCodeAt(N),S+=g.charAt(h>>2)+g.charAt(h<<4&63)+"=="),S},v={encode:w,decode:d,version:"1.0.0"};if(r&&!r.nodeType)if(o)o.exports=v;else for(var y in v)v.hasOwnProperty(y)&&(r[y]=v[y]);else n.base64=v})(commonjsGlobal)}(base64,base64.exports);var base64Exports=base64.exports;class LoginFailureError extends Error{constructor(n){super("login failed");_e(this,"reason");this.reason=n,this.name="LoginFailureError",Object.setPrototypeOf(this,new.target.prototype)}}class LoginChallengedError extends Error{constructor(n){super("login challenged");_e(this,"challenge");this.challenge=n,this.name="LoginChallengedError",Object.setPrototypeOf(this,new.target.prototype)}}class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){_e(this,"_refreshToken");_e(this,"_isShareToken",!1);_e(this,"_currentOrganization");_e(this,"_currentUser");_e(this,"_defaultDeviceId");_e(this,"_token");_e(this,"_waitingForAuth",new Set);_e(this,"_refreshTimer");_e(this,"_apiUrl");_e(this,"_refreshAuthToken");_e(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}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 l=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),u=await l.json();if(l.status!==200)throw new LoginFailureError(u.message);if("challenge"in u)throw new LoginChallengedError(u.challenge);const{authentication:s}=u;return await this.loginWithToken(s.accessToken,s.refreshToken),o?{result:"success",authentication:s}:s}catch(l){if(o||console.error("login() failed",{err:l}),this._waitingForAuth.forEach(u=>u(!1)),this._waitingForAuth.clear(),!o)throw l;return l instanceof LoginChallengedError?{result:"challenged",challenge:l.challenge}:{result:"failure",reason:l instanceof LoginFailureError?l.reason:l instanceof Error?l.message:String(l)}}}async loginWithToken(t,n){var o;const r=JSON.parse(base64Exports.decode(t.split(".")[1]));try{let l;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||(l=r.sub),r["formant:claims"]&&r["formant:claims"].userId&&(l=r["formant:claims"].userId),l&&((o=this._currentUser)==null?void 0:o.id)!==l){const u=await fetch(`${this._apiUrl}/v1/admin/users/${l}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),s=await u.json();if(u.status!==200)throw new Error(s.message);this._currentUser=s}this._token=t,this._waitingForAuth.forEach(u=>u(!0))}catch(l){console.error("loginWithToken() failed",{err:l}),this._waitingForAuth.forEach(u=>u(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const u=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=u.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}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){return await(await fetch(`${this._apiUrl}/v1/admin/auth/respond-to-new-password-required-challenge`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json()}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)}}function getCurrentModuleContext(){return typeof window<"u"&&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})}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)}}const Authentication=new AuthenticationStore({apiUrl:FORMANT_API_URL,refreshAuthToken,addAccessTokenRefreshListener});async function getModuleConfiguration(e){return(await(await fetch(`${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<"u"&&(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(),l=new Date(n.getTime());l.setMonth(n.getMonth()+r+1,0);var u=l.getDate();return o>=u?l:(n.setFullYear(l.getFullYear(),l.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,l,u,s,g,c;requiredArgs(1,arguments);var d=getDefaultOptions(),w=toInteger((n=(r=(o=(l=t==null?void 0:t.weekStartsOn)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(g=d.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(w>=0&&w<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var v=toDate(e),y=v.getDay(),f=(y<w?7:0)+y-w;return v.setDate(v.getDate()-f),v.setHours(0,0,0,0),v}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),l=toDate(r.end),u=l.getTime();if(!(o.getTime()<=u))throw new RangeError("Invalid interval");var s=[],g=o;g.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(;g.getTime()<=u;)s.push(toDate(g)),g.setDate(g.getDate()+c),g.setHours(0,0,0,0);return s}function eachHourOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},o=toDate(r.start),l=toDate(r.end),u=o.getTime(),s=l.getTime();if(!(u<=s))throw new RangeError("Invalid interval");var g=[],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()<=s;)g.push(toDate(c)),c=addHours(c,d);return g}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),l=r.getTime(),u=o.getTime();if(l>=u)throw new RangeError("Invalid interval");var s=[],g=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(;g.getTime()<=u;)s.push(toDate(g)),g=addMinutes(g,c);return s}function eachMonthOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime(),l=[];if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var u=n;for(u.setHours(0,0,0,0),u.setDate(1);u.getTime()<=o;)l.push(toDate(u)),u.setMonth(u.getMonth()+1);return l}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 l=startOfQuarter(n),u=startOfQuarter(r);o=u.getTime();for(var s=[],g=l;g.getTime()<=o;)s.push(toDate(g)),g=addQuarters(g,1);return s}function eachWeekOfInterval(e,t){requiredArgs(1,arguments);var n=e||{},r=toDate(n.start),o=toDate(n.end),l=o.getTime();if(!(r.getTime()<=l))throw new RangeError("Invalid interval");var u=startOfWeek(r,t),s=startOfWeek(o,t);u.setHours(15),s.setHours(15),l=s.getTime();for(var g=[],c=u;c.getTime()<=l;)c.setHours(0),g.push(toDate(c)),c=addWeeks(c,1),c.setHours(15);return g}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 l=[],u=n;for(u.setHours(0,0,0,0),u.setMonth(0,1);u.getTime()<=o;)l.push(toDate(u)),u.setFullYear(u.getFullYear()+1);return l}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,l,u,s,g,c;requiredArgs(1,arguments);var d=getDefaultOptions(),w=toInteger((n=(r=(o=(l=t==null?void 0:t.weekStartsOn)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(g=d.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(w>=0&&w<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var v=toDate(e),y=v.getDay(),f=(y<w?-7:0)+6-(y-w);return v.setDate(v.getDate()+f),v.setHours(23,59,59,999),v}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,l,u,s,g,c;requiredArgs(1,arguments);var d=toDate(e),w=d.getFullYear(),v=getDefaultOptions(),y=toInteger((n=(r=(o=(l=t==null?void 0:t.firstWeekContainsDate)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&o!==void 0?o:v.firstWeekContainsDate)!==null&&r!==void 0?r:(g=v.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1);if(!(y>=1&&y<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var f=new Date(0);f.setFullYear(w+1,0,y),f.setHours(0,0,0,0);var p=startOfWeek(f,t),S=new Date(0);S.setFullYear(w,0,y),S.setHours(0,0,0,0);var N=startOfWeek(S,t);return d.getTime()>=p.getTime()?w+1:d.getTime()>=N.getTime()?w:w-1}function startOfWeekYear(e,t){var n,r,o,l,u,s,g,c;requiredArgs(1,arguments);var d=getDefaultOptions(),w=toInteger((n=(r=(o=(l=t==null?void 0:t.firstWeekContainsDate)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&o!==void 0?o:d.firstWeekContainsDate)!==null&&r!==void 0?r:(g=d.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1),v=getWeekYear(e,t),y=new Date(0);y.setFullYear(v,0,w),y.setHours(0,0,0,0);var f=startOfWeek(y,t);return f}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),l=o.getSeconds(),u=o.getMinutes()+l/60,s=getRoundingMethod(t==null?void 0:t.roundingMethod),g=s(u/r)*r,c=u%r,d=Math.round(c/r)*r;return new Date(o.getFullYear(),o.getMonth(),o.getDate(),o.getHours(),g+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=1,second=1e3,minute=60*second,hour=60*minute,day=24*hour,week=7*day,month=30*day,year=365*day,duration={millisecond,second,minute,hour,day,week,month,year};function filterDataByType(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime(e,t,n){const r=t.getTime(),o=n.getTime();return e.map(l=>({...l,points:l.points.filter(([u])=>u>=r&&u<o)})).filter(({points:l})=>l.length>0)}function fork(e){}class StoreCache{constructor({capacity:t,timeout:n}={}){_e(this,"entries",new Map);_e(this,"metadata",new Map);_e(this,"capacity");_e(this,"timeout");this.capacity=t||1e4,this.timeout=n||duration.minute}get(t,n){const r=this.keyToCacheKey(t),o=this.entries.get(r),l=this.metadata.get(r);return(o===void 0||l&&(l==null?void 0:l.expiration.getTime())<Date.now())&&!(l!=null&&l.generating)&&n&&this.generate(t,n()),o===void 0&&l&&l.lastValue!==void 0?l.lastValue:o}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,expiration:new Date(Date.now()+this.timeout),lastValue:n}),this.entries.set(r,n),this.metadata.size>this.capacity&&this.deleteOldestEntry()}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)}deleteOldestEntry(){if(this.metadata.size<1)return;const[t]=[...this.metadata.entries()].reduce(([n,r],[o,l])=>l.expiration.getTime()<r.expiration.getTime()?[o,l]:[n,r]);this.clearKey(t)}generate(t,n){const r=this.keyToCacheKey(t),o=this.metadata.get(r)||{};this.metadata.set(r,{...o,generating:!0,expiration:new Date(Date.now()+this.timeout)}),setTimeout(()=>{n.then(l=>{const u=this.metadata.get(r);!(u!=null&&u.generating)||this.set(t,l)})},0)}}async function queryTelemetry(e){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}class QueryStore{constructor(){_e(this,"queryStoreCache",new StoreCache({capacity:1e4,timeout:20*duration.second}));_e(this,"liveQueryStoreCache",new StoreCache({capacity:1e4,timeout:200*duration.millisecond}))}moduleQuery(t,n,r,o,l,u=!1){const s={...t,names:[...n],types:[...r]},g=this.query(s,o,l,u);return g===void 0||g==="too much data"?g:filterDataByType(g,r)}query(t,n,r,o=!1){const l={...t,start:startOfMinute(n).toISOString(),end:o?r.toISOString():addMinutes(roundToNearestMinutes(r),1).toISOString(),latestOnly:o},u=r>addSeconds(new Date,-20);let s;return u?s=this.liveQueryCache(l):s=this.queryCache(l),!s||s==="too much data"||o?s:filterDataByTime(s,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;function addStreamListener(e,t,n){const r=o=>{const l=o.data;if(l.type==="module_data"){const{start:u,end:s}=l.queryRange;n(queryStore.moduleQuery({},e,t,new Date(u),new Date(s),!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=l=>{const u=l.data;u.type==="date_response"&&(window.removeEventListener("message",o),r(u.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=l=>{const u=l.data;u.type==="prompt_response"&&u.promptId===r&&n(u.data),window.removeEventListener("message",o)};window.addEventListener("message",o)})}const Qe=class{static isModule(){return getCurrentModuleContext()!==null}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window<"u"&&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 Qe._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),l=u=>{window.removeEventListener("message",l),clearTimeout(o);const{data:s}=u;s.type==="formant_online"&&(this._isOnline=s.online,n(s.online))};window.addEventListener("message",l),sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((u,s)=>{setTimeout(()=>{n=!0,s(new Error("deadline expired: took too long"))},t)}),o=u=>new Promise(s=>setTimeout(s,u)),l=async()=>{for(await o(50);!n&&!(this.isOnline||await this.checkConnection);)await o(500)};return Promise.race([r,l()])}};let App=Qe;_e(App,"getCurrentModuleContext",getCurrentModuleContext),_e(App,"disableAnalyticsBottomBar",disableAnalyticsBottomBar),_e(App,"goToDevice",goToDevice),_e(App,"goToTime",goToTime),_e(App,"refreshAuthToken",refreshAuthToken),_e(App,"requestModuleData",requestModuleData),_e(App,"sendChannelData",sendChannelData),_e(App,"setModuleDateTimeRange",setModuleDateTimeRange),_e(App,"setupModuleMenus",setupModuleMenus),_e(App,"showMessage",showMessage),_e(App,"addAccessTokenRefreshListener",addAccessTokenRefreshListener),_e(App,"addChannelDataListener",addChannelDataListener),_e(App,"addMenuListener",addMenuListener),_e(App,"addModuleConfigurationListener",addModuleConfigurationListener),_e(App,"addModuleDataListener",addModuleDataListener),_e(App,"addOverviewDeviceListener",addOverviewDeviceListener),_e(App,"addStreamListener",addStreamListener),_e(App,"getDate",getDate),_e(App,"prompt",prompt),_e(App,"_isOnline",null);function defined(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}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,w,v=c[0],y=c[1],f=0,p=[];f<v.length;f++)w=v[f],Object.prototype.hasOwnProperty.call(r,w)&&r[w]&&p.push(r[w][0]),r[w]=0;for(d in y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);for(g&&g(c);p.length;)p.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,w){o.o(c,d)||Object.defineProperty(c,d,{enumerable:!0,get:w})},o.r=function(c){typeof Symbol<"u"&&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 w=Object.create(null);if(o.r(w),Object.defineProperty(w,"default",{enumerable:!0,value:c}),2&d&&typeof c!="string")for(var v in c)o.d(w,v,function(y){return c[y]}.bind(null,v));return w},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 l=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],u=l.push.bind(l);l.push=t,l=l.slice();for(var s=0;s<l.length;s++)t(l[s]);var g=u;return o(o.s=232)}([function(e,t,n){n.d(t,"a",function(){return I});var r=n(16),o=n(55),l=n(15),u=n.n(l),s=n(18);function g(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+-].*)$/},w=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,v=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,y=/^([+-])(\d{2})(?::?(\d{2}))?$/;function f(K){var Y,ne={},ie=K.split(d.dateTimeDelimiter);if(ie.length>2)return ne;if(/:/.test(ie[0])?Y=ie[0]:(ne.date=ie[0],Y=ie[1],d.timeZoneDelimiter.test(ne.date)&&(ne.date=K.split(d.timeZoneDelimiter)[0],Y=K.substr(ne.date.length,K.length))),Y){var ue=d.timezone.exec(Y);ue?(ne.time=Y.replace(ue[1],""),ne.timezone=ue[1]):ne.time=Y}return ne}function p(K,Y){var ne=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+Y)+"})|(\\d{2}|[+-]\\d{"+(2+Y)+"})$)"),ie=K.match(ne);if(!ie)return{year:NaN,restDateString:""};var ue=ie[1]?parseInt(ie[1]):null,we=ie[2]?parseInt(ie[2]):null;return{year:we===null?ue:100*we,restDateString:K.slice((ie[1]||ie[2]).length)}}function S(K,Y){if(Y===null)return new Date(NaN);var ne=K.match(w);if(!ne)return new Date(NaN);var ie=!!ne[4],ue=N(ne[1]),we=N(ne[2])-1,Oe=N(ne[3]),Ee=N(ne[4]),Ne=N(ne[5])-1;if(ie)return function(Ae,Ie,Fe){return Ie>=1&&Ie<=53&&Fe>=0&&Fe<=6}(0,Ee,Ne)?function(Ae,Ie,Fe){var Ve=new Date(0);Ve.setUTCFullYear(Ae,0,4);var rt=Ve.getUTCDay()||7,vt=7*(Ie-1)+Fe+1-rt;return Ve.setUTCDate(Ve.getUTCDate()+vt),Ve}(Y,Ee,Ne):new Date(NaN);var Te=new Date(0);return function(Ae,Ie,Fe){return Ie>=0&&Ie<=11&&Fe>=1&&Fe<=(h[Ie]||(R(Ae)?29:28))}(Y,we,Oe)&&function(Ae,Ie){return Ie>=1&&Ie<=(R(Ae)?366:365)}(Y,ue)?(Te.setUTCFullYear(Y,we,Math.max(ue,Oe)),Te):new Date(NaN)}function N(K){return K?parseInt(K):1}function B(K){var Y=K.match(v);if(!Y)return NaN;var ne=E(Y[1]),ie=E(Y[2]),ue=E(Y[3]);return function(we,Oe,Ee){return we===24?Oe===0&&Ee===0:Ee>=0&&Ee<60&&Oe>=0&&Oe<60&&we>=0&&we<25}(ne,ie,ue)?36e5*ne+6e4*ie+1e3*ue:NaN}function E(K){return K&&parseFloat(K.replace(",","."))||0}function T(K){if(K==="Z")return 0;var Y=K.match(y);if(!Y)return 0;var ne=Y[1]==="+"?-1:1,ie=parseInt(Y[2]),ue=Y[3]&&parseInt(Y[3])||0;return function(we,Oe){return Oe>=0&&Oe<=59}(0,ue)?ne*(36e5*ie+6e4*ue):NaN}var h=[31,null,31,30,31,30,31,31,30,31,30,31];function R(K){return K%400==0||K%4==0&&K%100!=0}function W(K){return(W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Y){return typeof Y}:function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y})(K)}function X(K){return g(1,arguments),K instanceof Date||W(K)==="object"&&Object.prototype.toString.call(K)==="[object Date]"}function m(K){return(m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Y){return typeof Y}:function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y})(K)}function _(K){g(1,arguments);var Y=Object.prototype.toString.call(K);return K instanceof Date||m(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>"u"||(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 G(K){const Y=function(ne,ie){var ue;g(1,arguments);var we=c((ue=ie==null?void 0:ie.additionalDigits)!==null&&ue!==void 0?ue:2);if(we!==2&&we!==1&&we!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof ne!="string"&&Object.prototype.toString.call(ne)!=="[object String]")return new Date(NaN);var Oe,Ee=f(ne);if(Ee.date){var Ne=p(Ee.date,we);Oe=S(Ne.restDateString,Ne.year)}if(!Oe||isNaN(Oe.getTime()))return new Date(NaN);var Te,Ae=Oe.getTime(),Ie=0;if(Ee.time&&(Ie=B(Ee.time),isNaN(Ie)))return new Date(NaN);if(!Ee.timezone){var Fe=new Date(Ae+Ie),Ve=new Date(0);return Ve.setFullYear(Fe.getUTCFullYear(),Fe.getUTCMonth(),Fe.getUTCDate()),Ve.setHours(Fe.getUTCHours(),Fe.getUTCMinutes(),Fe.getUTCSeconds(),Fe.getUTCMilliseconds()),Ve}return Te=T(Ee.timezone),isNaN(Te)?new Date(NaN):new Date(Ae+Ie+Te)}(K);if(!function(ne){if(g(1,arguments),!X(ne)&&typeof ne!="number")return!1;var ie=_(ne);return!isNaN(Number(ie))}(Y))throw new Error(`Invalid ISO 8601 date string (${K})`);return Y}const j=Math.pow(2,20),C=j;var z=n(4),P=n(28);function D(K){return u()(K,{cycles:!0})}var O=function(K,Y){var ne={};for(var ie in K)Object.prototype.hasOwnProperty.call(K,ie)&&Y.indexOf(ie)<0&&(ne[ie]=K[ie]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ue=0;for(ie=Object.getOwnPropertySymbols(K);ue<ie.length;ue++)Y.indexOf(ie[ue])<0&&Object.prototype.propertyIsEnumerable.call(K,ie[ue])&&(ne[ie[ue]]=K[ie[ue]])}return ne};function L(K,Y={}){const{redacted:ne=!0}=Y,ie=Ne=>ne?Object(P.a)(Ne):Ne;if(!K.stack)return{message:D(ie(K))};const{name:ue,message:we,stack:Oe}=K,Ee=O(K,["name","message","stack"]);return{name:ue,message:we!==void 0?we:D(ie(K)),stack:Oe,meta:Ee&&Object.keys(Ee).length===0?void 0:ie(Ee)}}function U(K,Y={}){const{message:ne,stack:ie,meta:ue}=L(K,Y);return`${ie||ne||""}${ue&&Object.keys(ue).length>0?` -- ${D(ue)}`:""}`}var A=n(40),V=n(14),q=n.n(V),Q=function(K,Y,ne,ie){return new(ne||(ne=Promise))(function(ue,we){function Oe(Te){try{Ne(ie.next(Te))}catch(Ae){we(Ae)}}function Ee(Te){try{Ne(ie.throw(Te))}catch(Ae){we(Ae)}}function Ne(Te){var Ae;Te.done?ue(Te.value):(Ae=Te.value,Ae instanceof ne?Ae:new ne(function(Ie){Ie(Ae)})).then(Oe,Ee)}Ne((ie=ie.apply(K,Y||[])).next())})},ee=function(K,Y){var ne={};for(var ie in K)Object.prototype.hasOwnProperty.call(K,ie)&&Y.indexOf(ie)<0&&(ne[ie]=K[ie]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ue=0;for(ie=Object.getOwnPropertySymbols(K);ue<ie.length;ue++)Y.indexOf(ie[ue])<0&&Object.prototype.propertyIsEnumerable.call(K,ie[ue])&&(ne[ie[ue]]=K[ie[ue]])}return ne};class te extends q.a{constructor(Y,ne){super(),this.endpoint=Y,this.metadata=ne,this.logClient=this.getLogClient()}getLogClient(){return Q(this,void 0,void 0,function*(){const{LogClient:Y}=yield Promise.resolve().then(n.bind(null,235));return new Y(this.endpoint)})}log(Y,ne){return Q(this,void 0,void 0,function*(){const{level:ie,message:ue,error:we}=Y,Oe=ee(Y,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:ie,message:`${ue}`.substring(0,1e3),error:we!==void 0?L(we):void 0,meta:Object.assign(Object.assign({},Oe),this.metadata)}])}catch(Ee){console.error(`Failed to log to log-api: ${U(Ee)}`)}ne()})}}var k=function(K,Y){var ne={};for(var ie in K)Object.prototype.hasOwnProperty.call(K,ie)&&Y.indexOf(ie)<0&&(ne[ie]=K[ie]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ue=0;for(ie=Object.getOwnPropertySymbols(K);ue<ie.length;ue++)Y.indexOf(ie[ue])<0&&Object.prototype.propertyIsEnumerable.call(K,ie[ue])&&(ne[ie[ue]]=K[ie[ue]])}return ne};const x={app:z.a,namespace:z.i,buildTag:z.b,instanceId:A.a},b=z.e?s.format.printf(K=>{var{timestamp:Y,level:ne,message:ie,error:ue}=K,we=k(K,["timestamp","level","message","error"]);const Oe=Object.assign(Object.assign({timestamp:Y?G(Y).getTime():new Date().getTime(),level:ne.toUpperCase(),message:ie},ue?{error:L(ue)}:{}),{meta:Object.assign(Object.assign({},x),we)});return u()(Oe,{cycles:!0})}):s.format.printf(K=>{var{timestamp:Y,level:ne,message:ie,error:ue}=K,we=k(K,["timestamp","level","message","error"]);let Oe=`${Y||new Date().toISOString()} ${ne.toUpperCase()}: ${ie} `;return Object.keys(we).length>0&&(Oe+=u()(we,{cycles:!0})),ue&&(Oe+=`
1
+ (function(Qe,et){typeof exports=="object"&&typeof module<"u"?et(exports):typeof define=="function"&&define.amd?define(["exports"],et):(Qe=typeof globalThis<"u"?globalThis:Qe||self,et(Qe.FormantDataSDK={}))})(this,function(exports){var et;"use strict";var vn=Object.defineProperty;var wn=(Qe,et,Je)=>et in Qe?vn(Qe,et,{enumerable:!0,configurable:!0,writable:!0,value:Je}):Qe[et]=Je;var _e=(Qe,et,Je)=>(wn(Qe,typeof et!="symbol"?et+"":et,Je),Je);const DEFAULT_FORMANT_API_URL="https://api.formant.io";function whichFormantApiUrl(e,t){try{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 n=t.get("formant_url");if(n!==null)try{return new URL(n).origin}catch{console.warn(`Ignoring malformed \`formant_url\` url parameter: ${n}`)}}}catch{}return typeof e<"u"&&"FORMANT_API_URL"in e&&typeof e.FORMANT_API_URL=="string"?e.FORMANT_API_URL:DEFAULT_FORMANT_API_URL}const FORMANT_API_URL=whichFormantApiUrl(typeof window<"u"?window:globalThis,new URLSearchParams(typeof window<"u"&&window.location?window.location.search:void 0));var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?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,l=typeof commonjsGlobal=="object"&&commonjsGlobal;(l.global===l||l.window===l)&&(n=l);var u=function(f){this.message=f};u.prototype=new Error,u.prototype.name="InvalidCharacterError";var s=function(f){throw new u(f)},g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=/[\t\n\f\r ]/g,d=function(f){f=String(f).replace(c,"");var p=f.length;p%4==0&&(f=f.replace(/==?$/,""),p=f.length),(p%4==1||/[^+a-zA-Z0-9/]/.test(f))&&s("Invalid character: the string to be decoded is not correctly encoded.");for(var S=0,N,B,E="",T=-1;++T<p;)B=g.indexOf(f.charAt(T)),N=S%4?N*64+B:B,S++%4&&(E+=String.fromCharCode(255&N>>(-2*S&6)));return E},w=function(f){f=String(f),/[^\0-\xFF]/.test(f)&&s("The string to be encoded contains characters outside of the Latin1 range.");for(var p=f.length%3,S="",N=-1,B,E,T,h,R=f.length-p;++N<R;)B=f.charCodeAt(N)<<16,E=f.charCodeAt(++N)<<8,T=f.charCodeAt(++N),h=B+E+T,S+=g.charAt(h>>18&63)+g.charAt(h>>12&63)+g.charAt(h>>6&63)+g.charAt(h&63);return p==2?(B=f.charCodeAt(N)<<8,E=f.charCodeAt(++N),h=B+E,S+=g.charAt(h>>10)+g.charAt(h>>4&63)+g.charAt(h<<2&63)+"="):p==1&&(h=f.charCodeAt(N),S+=g.charAt(h>>2)+g.charAt(h<<4&63)+"=="),S},v={encode:w,decode:d,version:"1.0.0"};if(r&&!r.nodeType)if(o)o.exports=v;else for(var y in v)v.hasOwnProperty(y)&&(r[y]=v[y]);else n.base64=v})(commonjsGlobal)}(base64,base64.exports);var base64Exports=base64.exports;class LoginFailureError extends Error{constructor(n){super("login failed");_e(this,"reason");this.reason=n,this.name="LoginFailureError",Object.setPrototypeOf(this,new.target.prototype)}}class LoginChallengedError extends Error{constructor(n){super("login challenged");_e(this,"challenge");this.challenge=n,this.name="LoginChallengedError",Object.setPrototypeOf(this,new.target.prototype)}}class AuthenticationStore{constructor({apiUrl:t,refreshAuthToken:n,addAccessTokenRefreshListener:r}){_e(this,"_refreshToken");_e(this,"_isShareToken",!1);_e(this,"_currentOrganization");_e(this,"_currentUser");_e(this,"_defaultDeviceId");_e(this,"_token");_e(this,"_waitingForAuth",new Set);_e(this,"_refreshTimer");_e(this,"_apiUrl");_e(this,"_refreshAuthToken");_e(this,"_addAccessTokenRefreshListener");this._apiUrl=t,this._refreshAuthToken=n,this._addAccessTokenRefreshListener=r}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 l=await fetch(`${this._apiUrl}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:n}),headers:{"Content-Type":"application/json"}}),u=await l.json();if(l.status!==200)throw new LoginFailureError(u.message);if("challenge"in u)throw new LoginChallengedError(u.challenge);const{authentication:s}=u;return await this.loginWithToken(s.accessToken,s.refreshToken),o?{result:"success",authentication:s}:s}catch(l){if(o||console.error("login() failed",{err:l}),this._waitingForAuth.forEach(u=>u(!1)),this._waitingForAuth.clear(),!o)throw l;return l instanceof LoginChallengedError?{result:"challenged",challenge:l.challenge}:{result:"failure",reason:l instanceof LoginFailureError?l.reason:l instanceof Error?l.message:String(l)}}}async loginWithToken(t,n){var o;const r=JSON.parse(base64Exports.decode(t.split(".")[1]));try{let l;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||(l=r.sub),r["formant:claims"]&&r["formant:claims"].userId&&(l=r["formant:claims"].userId),l&&((o=this._currentUser)==null?void 0:o.id)!==l){const u=await fetch(`${this._apiUrl}/v1/admin/users/${l}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),s=await u.json();if(u.status!==200)throw new Error(s.message);this._currentUser=s}this._token=t,this._waitingForAuth.forEach(u=>u(!0))}catch(l){console.error("loginWithToken() failed",{err:l}),this._waitingForAuth.forEach(u=>u(!1))}finally{this._waitingForAuth.clear()}n&&(this._refreshToken=n,setInterval(async()=>{if(this._refreshToken){const u=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=u.authentication.accessToken}},1e3*60*60))}isAuthenticated(){return this._token!==void 0}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)}}function getCurrentModuleContext(){return typeof window<"u"&&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})}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)}}const Authentication=new AuthenticationStore({apiUrl:FORMANT_API_URL,refreshAuthToken,addAccessTokenRefreshListener});async function getModuleConfiguration(e){return(await(await fetch(`${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<"u"&&(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(),l=new Date(n.getTime());l.setMonth(n.getMonth()+r+1,0);var u=l.getDate();return o>=u?l:(n.setFullYear(l.getFullYear(),l.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,l,u,s,g,c;requiredArgs(1,arguments);var d=getDefaultOptions(),w=toInteger((n=(r=(o=(l=t==null?void 0:t.weekStartsOn)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(g=d.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(w>=0&&w<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var v=toDate(e),y=v.getDay(),f=(y<w?7:0)+y-w;return v.setDate(v.getDate()-f),v.setHours(0,0,0,0),v}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),l=toDate(r.end),u=l.getTime();if(!(o.getTime()<=u))throw new RangeError("Invalid interval");var s=[],g=o;g.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(;g.getTime()<=u;)s.push(toDate(g)),g.setDate(g.getDate()+c),g.setHours(0,0,0,0);return s}function eachHourOfInterval(e,t){var n;requiredArgs(1,arguments);var r=e||{},o=toDate(r.start),l=toDate(r.end),u=o.getTime(),s=l.getTime();if(!(u<=s))throw new RangeError("Invalid interval");var g=[],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()<=s;)g.push(toDate(c)),c=addHours(c,d);return g}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),l=r.getTime(),u=o.getTime();if(l>=u)throw new RangeError("Invalid interval");var s=[],g=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(;g.getTime()<=u;)s.push(toDate(g)),g=addMinutes(g,c);return s}function eachMonthOfInterval(e){requiredArgs(1,arguments);var t=e||{},n=toDate(t.start),r=toDate(t.end),o=r.getTime(),l=[];if(!(n.getTime()<=o))throw new RangeError("Invalid interval");var u=n;for(u.setHours(0,0,0,0),u.setDate(1);u.getTime()<=o;)l.push(toDate(u)),u.setMonth(u.getMonth()+1);return l}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 l=startOfQuarter(n),u=startOfQuarter(r);o=u.getTime();for(var s=[],g=l;g.getTime()<=o;)s.push(toDate(g)),g=addQuarters(g,1);return s}function eachWeekOfInterval(e,t){requiredArgs(1,arguments);var n=e||{},r=toDate(n.start),o=toDate(n.end),l=o.getTime();if(!(r.getTime()<=l))throw new RangeError("Invalid interval");var u=startOfWeek(r,t),s=startOfWeek(o,t);u.setHours(15),s.setHours(15),l=s.getTime();for(var g=[],c=u;c.getTime()<=l;)c.setHours(0),g.push(toDate(c)),c=addWeeks(c,1),c.setHours(15);return g}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 l=[],u=n;for(u.setHours(0,0,0,0),u.setMonth(0,1);u.getTime()<=o;)l.push(toDate(u)),u.setFullYear(u.getFullYear()+1);return l}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,l,u,s,g,c;requiredArgs(1,arguments);var d=getDefaultOptions(),w=toInteger((n=(r=(o=(l=t==null?void 0:t.weekStartsOn)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.weekStartsOn)!==null&&o!==void 0?o:d.weekStartsOn)!==null&&r!==void 0?r:(g=d.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.weekStartsOn)!==null&&n!==void 0?n:0);if(!(w>=0&&w<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var v=toDate(e),y=v.getDay(),f=(y<w?-7:0)+6-(y-w);return v.setDate(v.getDate()+f),v.setHours(23,59,59,999),v}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,l,u,s,g,c;requiredArgs(1,arguments);var d=toDate(e),w=d.getFullYear(),v=getDefaultOptions(),y=toInteger((n=(r=(o=(l=t==null?void 0:t.firstWeekContainsDate)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&o!==void 0?o:v.firstWeekContainsDate)!==null&&r!==void 0?r:(g=v.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1);if(!(y>=1&&y<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var f=new Date(0);f.setFullYear(w+1,0,y),f.setHours(0,0,0,0);var p=startOfWeek(f,t),S=new Date(0);S.setFullYear(w,0,y),S.setHours(0,0,0,0);var N=startOfWeek(S,t);return d.getTime()>=p.getTime()?w+1:d.getTime()>=N.getTime()?w:w-1}function startOfWeekYear(e,t){var n,r,o,l,u,s,g,c;requiredArgs(1,arguments);var d=getDefaultOptions(),w=toInteger((n=(r=(o=(l=t==null?void 0:t.firstWeekContainsDate)!==null&&l!==void 0?l:t==null||(u=t.locale)===null||u===void 0||(s=u.options)===null||s===void 0?void 0:s.firstWeekContainsDate)!==null&&o!==void 0?o:d.firstWeekContainsDate)!==null&&r!==void 0?r:(g=d.locale)===null||g===void 0||(c=g.options)===null||c===void 0?void 0:c.firstWeekContainsDate)!==null&&n!==void 0?n:1),v=getWeekYear(e,t),y=new Date(0);y.setFullYear(v,0,w),y.setHours(0,0,0,0);var f=startOfWeek(y,t);return f}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),l=o.getSeconds(),u=o.getMinutes()+l/60,s=getRoundingMethod(t==null?void 0:t.roundingMethod),g=s(u/r)*r,c=u%r,d=Math.round(c/r)*r;return new Date(o.getFullYear(),o.getMonth(),o.getDate(),o.getHours(),g+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=1,second=1e3,minute=60*second,hour=60*minute,day=24*hour,week=7*day,month=30*day,year=365*day,duration={millisecond,second,minute,hour,day,week,month,year};function filterDataByType(e,t){return e.filter(n=>t.includes(n.type))}function filterDataByTime(e,t,n){const r=t.getTime(),o=n.getTime();return e.map(l=>({...l,points:l.points.filter(([u])=>u>=r&&u<o)})).filter(({points:l})=>l.length>0)}function fork(e){}class StoreCache{constructor({capacity:t,timeout:n}={}){_e(this,"entries",new Map);_e(this,"metadata",new Map);_e(this,"capacity");_e(this,"timeout");this.capacity=t||1e4,this.timeout=n||duration.minute}get(t,n){const r=this.keyToCacheKey(t),o=this.entries.get(r),l=this.metadata.get(r);return(o===void 0||l&&(l==null?void 0:l.expiration.getTime())<Date.now())&&!(l!=null&&l.generating)&&n&&this.generate(t,n()),o===void 0&&l&&l.lastValue!==void 0?l.lastValue:o}set(t,n){const r=this.keyToCacheKey(t);this.metadata.set(r,{generating:!1,expiration:new Date(Date.now()+this.timeout),lastValue:n}),this.entries.set(r,n),this.metadata.size>this.capacity&&this.deleteOldestEntry()}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)}deleteOldestEntry(){if(this.metadata.size<1)return;const[t]=[...this.metadata.entries()].reduce(([n,r],[o,l])=>l.expiration.getTime()<r.expiration.getTime()?[o,l]:[n,r]);this.clearKey(t)}generate(t,n){const r=this.keyToCacheKey(t),o=this.metadata.get(r)||{};this.metadata.set(r,{...o,generating:!0,expiration:new Date(Date.now()+this.timeout)}),setTimeout(()=>{n.then(l=>{const u=this.metadata.get(r);!(u!=null&&u.generating)||this.set(t,l)})},0)}}async function queryTelemetry(e){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}class QueryStore{constructor(){_e(this,"queryStoreCache",new StoreCache({capacity:1e4,timeout:20*duration.second}));_e(this,"liveQueryStoreCache",new StoreCache({capacity:1e4,timeout:200*duration.millisecond}))}moduleQuery(t,n,r,o,l,u=!1){const s={...t,names:[...n],types:[...r]},g=this.query(s,o,l,u);return g===void 0||g==="too much data"?g:filterDataByType(g,r)}query(t,n,r,o=!1){const l={...t,start:startOfMinute(n).toISOString(),end:o?r.toISOString():addMinutes(roundToNearestMinutes(r),1).toISOString(),latestOnly:o},u=r>addSeconds(new Date,-20);let s;return u?s=this.liveQueryCache(l):s=this.queryCache(l),!s||s==="too much data"||o?s:filterDataByTime(s,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;function addStreamListener(e,t,n){const r=o=>{const l=o.data;if(l.type==="module_data"){const{start:u,end:s}=l.queryRange;n(queryStore.moduleQuery({},e,t,new Date(u),new Date(s),!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=l=>{const u=l.data;u.type==="date_response"&&(window.removeEventListener("message",o),r(u.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=l=>{const u=l.data;u.type==="prompt_response"&&u.promptId===r&&n(u.data),window.removeEventListener("message",o)};window.addEventListener("message",o)})}const Qe=class{static isModule(){return getCurrentModuleContext()!==null}static async getCurrentModuleConfiguration(){let t=new URLSearchParams("");typeof window<"u"&&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 Qe._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),l=u=>{window.removeEventListener("message",l),clearTimeout(o);const{data:s}=u;s.type==="formant_online"&&(this._isOnline=s.online,n(s.online))};window.addEventListener("message",l),sendAppMessage({type:"formant_online"})})}static waitForConnection(t=5e3){let n=!1;const r=new Promise((u,s)=>{setTimeout(()=>{n=!0,s(new Error("deadline expired: took too long"))},t)}),o=u=>new Promise(s=>setTimeout(s,u)),l=async()=>{for(await o(50);!n&&!(this.isOnline||await this.checkConnection);)await o(500)};return Promise.race([r,l()])}};let App=Qe;_e(App,"getCurrentModuleContext",getCurrentModuleContext),_e(App,"disableAnalyticsBottomBar",disableAnalyticsBottomBar),_e(App,"goToDevice",goToDevice),_e(App,"goToTime",goToTime),_e(App,"refreshAuthToken",refreshAuthToken),_e(App,"requestModuleData",requestModuleData),_e(App,"sendChannelData",sendChannelData),_e(App,"setModuleDateTimeRange",setModuleDateTimeRange),_e(App,"setupModuleMenus",setupModuleMenus),_e(App,"showMessage",showMessage),_e(App,"addAccessTokenRefreshListener",addAccessTokenRefreshListener),_e(App,"addChannelDataListener",addChannelDataListener),_e(App,"addMenuListener",addMenuListener),_e(App,"addModuleConfigurationListener",addModuleConfigurationListener),_e(App,"addModuleDataListener",addModuleDataListener),_e(App,"addOverviewDeviceListener",addOverviewDeviceListener),_e(App,"addStreamListener",addStreamListener),_e(App,"getDate",getDate),_e(App,"prompt",prompt),_e(App,"_isOnline",null);function defined(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}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,w,v=c[0],y=c[1],f=0,p=[];f<v.length;f++)w=v[f],Object.prototype.hasOwnProperty.call(r,w)&&r[w]&&p.push(r[w][0]),r[w]=0;for(d in y)Object.prototype.hasOwnProperty.call(y,d)&&(e[d]=y[d]);for(g&&g(c);p.length;)p.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,w){o.o(c,d)||Object.defineProperty(c,d,{enumerable:!0,get:w})},o.r=function(c){typeof Symbol<"u"&&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 w=Object.create(null);if(o.r(w),Object.defineProperty(w,"default",{enumerable:!0,value:c}),2&d&&typeof c!="string")for(var v in c)o.d(w,v,function(y){return c[y]}.bind(null,v));return w},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 l=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],u=l.push.bind(l);l.push=t,l=l.slice();for(var s=0;s<l.length;s++)t(l[s]);var g=u;return o(o.s=232)}([function(e,t,n){n.d(t,"a",function(){return I});var r=n(16),o=n(55),l=n(15),u=n.n(l),s=n(18);function g(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+-].*)$/},w=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,v=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,y=/^([+-])(\d{2})(?::?(\d{2}))?$/;function f(K){var Y,ne={},ie=K.split(d.dateTimeDelimiter);if(ie.length>2)return ne;if(/:/.test(ie[0])?Y=ie[0]:(ne.date=ie[0],Y=ie[1],d.timeZoneDelimiter.test(ne.date)&&(ne.date=K.split(d.timeZoneDelimiter)[0],Y=K.substr(ne.date.length,K.length))),Y){var ue=d.timezone.exec(Y);ue?(ne.time=Y.replace(ue[1],""),ne.timezone=ue[1]):ne.time=Y}return ne}function p(K,Y){var ne=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+Y)+"})|(\\d{2}|[+-]\\d{"+(2+Y)+"})$)"),ie=K.match(ne);if(!ie)return{year:NaN,restDateString:""};var ue=ie[1]?parseInt(ie[1]):null,we=ie[2]?parseInt(ie[2]):null;return{year:we===null?ue:100*we,restDateString:K.slice((ie[1]||ie[2]).length)}}function S(K,Y){if(Y===null)return new Date(NaN);var ne=K.match(w);if(!ne)return new Date(NaN);var ie=!!ne[4],ue=N(ne[1]),we=N(ne[2])-1,Oe=N(ne[3]),Ee=N(ne[4]),Ne=N(ne[5])-1;if(ie)return function(Ae,Ie,Fe){return Ie>=1&&Ie<=53&&Fe>=0&&Fe<=6}(0,Ee,Ne)?function(Ae,Ie,Fe){var Ve=new Date(0);Ve.setUTCFullYear(Ae,0,4);var rt=Ve.getUTCDay()||7,vt=7*(Ie-1)+Fe+1-rt;return Ve.setUTCDate(Ve.getUTCDate()+vt),Ve}(Y,Ee,Ne):new Date(NaN);var Te=new Date(0);return function(Ae,Ie,Fe){return Ie>=0&&Ie<=11&&Fe>=1&&Fe<=(h[Ie]||(R(Ae)?29:28))}(Y,we,Oe)&&function(Ae,Ie){return Ie>=1&&Ie<=(R(Ae)?366:365)}(Y,ue)?(Te.setUTCFullYear(Y,we,Math.max(ue,Oe)),Te):new Date(NaN)}function N(K){return K?parseInt(K):1}function B(K){var Y=K.match(v);if(!Y)return NaN;var ne=E(Y[1]),ie=E(Y[2]),ue=E(Y[3]);return function(we,Oe,Ee){return we===24?Oe===0&&Ee===0:Ee>=0&&Ee<60&&Oe>=0&&Oe<60&&we>=0&&we<25}(ne,ie,ue)?36e5*ne+6e4*ie+1e3*ue:NaN}function E(K){return K&&parseFloat(K.replace(",","."))||0}function T(K){if(K==="Z")return 0;var Y=K.match(y);if(!Y)return 0;var ne=Y[1]==="+"?-1:1,ie=parseInt(Y[2]),ue=Y[3]&&parseInt(Y[3])||0;return function(we,Oe){return Oe>=0&&Oe<=59}(0,ue)?ne*(36e5*ie+6e4*ue):NaN}var h=[31,null,31,30,31,30,31,31,30,31,30,31];function R(K){return K%400==0||K%4==0&&K%100!=0}function W(K){return(W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Y){return typeof Y}:function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y})(K)}function X(K){return g(1,arguments),K instanceof Date||W(K)==="object"&&Object.prototype.toString.call(K)==="[object Date]"}function m(K){return(m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Y){return typeof Y}:function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y})(K)}function _(K){g(1,arguments);var Y=Object.prototype.toString.call(K);return K instanceof Date||m(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>"u"||(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 G(K){const Y=function(ne,ie){var ue;g(1,arguments);var we=c((ue=ie==null?void 0:ie.additionalDigits)!==null&&ue!==void 0?ue:2);if(we!==2&&we!==1&&we!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(typeof ne!="string"&&Object.prototype.toString.call(ne)!=="[object String]")return new Date(NaN);var Oe,Ee=f(ne);if(Ee.date){var Ne=p(Ee.date,we);Oe=S(Ne.restDateString,Ne.year)}if(!Oe||isNaN(Oe.getTime()))return new Date(NaN);var Te,Ae=Oe.getTime(),Ie=0;if(Ee.time&&(Ie=B(Ee.time),isNaN(Ie)))return new Date(NaN);if(!Ee.timezone){var Fe=new Date(Ae+Ie),Ve=new Date(0);return Ve.setFullYear(Fe.getUTCFullYear(),Fe.getUTCMonth(),Fe.getUTCDate()),Ve.setHours(Fe.getUTCHours(),Fe.getUTCMinutes(),Fe.getUTCSeconds(),Fe.getUTCMilliseconds()),Ve}return Te=T(Ee.timezone),isNaN(Te)?new Date(NaN):new Date(Ae+Ie+Te)}(K);if(!function(ne){if(g(1,arguments),!X(ne)&&typeof ne!="number")return!1;var ie=_(ne);return!isNaN(Number(ie))}(Y))throw new Error(`Invalid ISO 8601 date string (${K})`);return Y}const j=Math.pow(2,20),C=j;var z=n(4),P=n(28);function D(K){return u()(K,{cycles:!0})}var O=function(K,Y){var ne={};for(var ie in K)Object.prototype.hasOwnProperty.call(K,ie)&&Y.indexOf(ie)<0&&(ne[ie]=K[ie]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ue=0;for(ie=Object.getOwnPropertySymbols(K);ue<ie.length;ue++)Y.indexOf(ie[ue])<0&&Object.prototype.propertyIsEnumerable.call(K,ie[ue])&&(ne[ie[ue]]=K[ie[ue]])}return ne};function L(K,Y={}){const{redacted:ne=!0}=Y,ie=Ne=>ne?Object(P.a)(Ne):Ne;if(!K.stack)return{message:D(ie(K))};const{name:ue,message:we,stack:Oe}=K,Ee=O(K,["name","message","stack"]);return{name:ue,message:we!==void 0?we:D(ie(K)),stack:Oe,meta:Ee&&Object.keys(Ee).length===0?void 0:ie(Ee)}}function U(K,Y={}){const{message:ne,stack:ie,meta:ue}=L(K,Y);return`${ie||ne||""}${ue&&Object.keys(ue).length>0?` -- ${D(ue)}`:""}`}var A=n(40),V=n(14),q=n.n(V),Q=function(K,Y,ne,ie){return new(ne||(ne=Promise))(function(ue,we){function Oe(Te){try{Ne(ie.next(Te))}catch(Ae){we(Ae)}}function Ee(Te){try{Ne(ie.throw(Te))}catch(Ae){we(Ae)}}function Ne(Te){var Ae;Te.done?ue(Te.value):(Ae=Te.value,Ae instanceof ne?Ae:new ne(function(Ie){Ie(Ae)})).then(Oe,Ee)}Ne((ie=ie.apply(K,Y||[])).next())})},ee=function(K,Y){var ne={};for(var ie in K)Object.prototype.hasOwnProperty.call(K,ie)&&Y.indexOf(ie)<0&&(ne[ie]=K[ie]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ue=0;for(ie=Object.getOwnPropertySymbols(K);ue<ie.length;ue++)Y.indexOf(ie[ue])<0&&Object.prototype.propertyIsEnumerable.call(K,ie[ue])&&(ne[ie[ue]]=K[ie[ue]])}return ne};class te extends q.a{constructor(Y,ne){super(),this.endpoint=Y,this.metadata=ne,this.logClient=this.getLogClient()}getLogClient(){return Q(this,void 0,void 0,function*(){const{LogClient:Y}=yield Promise.resolve().then(n.bind(null,235));return new Y(this.endpoint)})}log(Y,ne){return Q(this,void 0,void 0,function*(){const{level:ie,message:ue,error:we}=Y,Oe=ee(Y,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:ie,message:`${ue}`.substring(0,1e3),error:we!==void 0?L(we):void 0,meta:Object.assign(Object.assign({},Oe),this.metadata)}])}catch(Ee){console.error(`Failed to log to log-api: ${U(Ee)}`)}ne()})}}var k=function(K,Y){var ne={};for(var ie in K)Object.prototype.hasOwnProperty.call(K,ie)&&Y.indexOf(ie)<0&&(ne[ie]=K[ie]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function"){var ue=0;for(ie=Object.getOwnPropertySymbols(K);ue<ie.length;ue++)Y.indexOf(ie[ue])<0&&Object.prototype.propertyIsEnumerable.call(K,ie[ue])&&(ne[ie[ue]]=K[ie[ue]])}return ne};const x={app:z.a,namespace:z.i,buildTag:z.b,instanceId:A.a},b=z.e?s.format.printf(K=>{var{timestamp:Y,level:ne,message:ie,error:ue}=K,we=k(K,["timestamp","level","message","error"]);const Oe=Object.assign(Object.assign({timestamp:Y?G(Y).getTime():new Date().getTime(),level:ne.toUpperCase(),message:ie},ue?{error:L(ue)}:{}),{meta:Object.assign(Object.assign({},x),we)});return u()(Oe,{cycles:!0})}):s.format.printf(K=>{var{timestamp:Y,level:ne,message:ie,error:ue}=K,we=k(K,["timestamp","level","message","error"]);let Oe=`${Y||new Date().toISOString()} ${ne.toUpperCase()}: ${ie} `;return Object.keys(we).length>0&&(Oe+=u()(we,{cycles:!0})),ue&&(Oe+=`
2
2
  ${U(ue)}`),Oe}),I=Object(s.createLogger)({level:z.f});if(I.add(new s.transports.Console({format:b,level:"debug"})),I.transports.forEach(K=>{K.silent=!z.g}),z.d&&I.add(new te(z.d,x)),z.h){const K=o.resolve(r.tmpdir(),`silly-${z.a}.log`);I.debug("Logging silly logs to file",{filename:K}),I.add(new s.transports.File({filename:K,maxsize:1*C,maxFiles:10,format:s.format.combine(($="silly",Object(s.format)(Y=>Y.level===$&&Y)()),b),level:"silly"}))}var $},function(e,t,n){n.d(t,"a",function(){return r});const r={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6}},function(e,t){var n,r,o=e.exports={};function l(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(S){if(n===setTimeout)return setTimeout(S,0);if((n===l||!n)&&setTimeout)return n=setTimeout,setTimeout(S,0);try{return n(S,0)}catch{try{return n.call(null,S,0)}catch{return n.call(this,S,0)}}}(function(){try{n=typeof setTimeout=="function"?setTimeout:l}catch{n=l}try{r=typeof clearTimeout=="function"?clearTimeout:u}catch{r=u}})();var g,c=[],d=!1,w=-1;function v(){d&&g&&(d=!1,g.length?c=g.concat(c):w=-1,c.length&&y())}function y(){if(!d){var S=s(v);d=!0;for(var N=c.length;N;){for(g=c,c=[];++w<N;)g&&g[w].run();w=-1,N=c.length}g=null,d=!1,function(B){if(r===clearTimeout)return clearTimeout(B);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(B);try{r(B)}catch{try{return r.call(null,B)}catch{return r.call(this,B)}}}(S)}}function f(S,N){this.fun=S,this.array=N}function p(){}o.nextTick=function(S){var N=new Array(arguments.length-1);if(arguments.length>1)for(var B=1;B<arguments.length;B++)N[B-1]=arguments[B];c.push(new f(S,N)),c.length!==1||d||s(y)},f.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=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,o.listeners=function(S){return[]},o.binding=function(S){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(S){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},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(116)})},function(e,t,n){(function(r){n.d(t,"a",function(){return u}),n.d(t,"i",function(){return s}),n.d(t,"j",function(){return g}),n.d(t,"b",function(){return c}),n.d(t,"f",function(){return d}),n.d(t,"e",function(){return w}),n.d(t,"g",function(){return v}),n.d(t,"d",function(){return y}),n.d(t,"c",function(){return f}),n.d(t,"h",function(){return p});var o=n(101);const l=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}),u=(l.get("ENVIRONMENT").default("").asString(),l.get("APP").default("").asString()),s=(l.get("APP_PATH").default("").asString(),l.get("API_ENDPOINT").default("").asString(),l.get("NAMESPACE").default("").asString()),g=l.get("VERSION").default("").asString(),c=l.get("BUILD_TAG").default("").asString(),d=(l.get("GIT_COMMIT").default("").asString(),l.get("ENABLE_SENTRY").default("false").asBool(),l.get("ENABLE_SENTRY_PROFILING").default("false").asBool(),l.get("SENTRY_DSN").default("").asString(),l.get("LOG_LEVEL").default("debug").asString()),w=l.get("LOG_JSON").default("true").asBool(),v=l.get("LOG_TO_CONSOLE").default("true").asBool(),y=(l.get("STABLE_AGENT_VERSION").default("").asString(),l.get("LOG_API_ENDPOINT").asString()),f=l.get("JEST_WORKER_ID").asString(),p=(l.get("SHEET_EXPORT_MAX_ROW_COUNT").default("10000").asIntPositive(),l.get("LOG_TO_FILE").default("false").asBoolStrict());l.get("ENABLE_SELF_SERVE").default("true").asBoolStrict(),l.get("AGGREGATE_LEVEL").default("hour").asEnum(["day","hour","minute"])}).call(this,n(2))},function(e,t,n){(function(r){var o=n(141),l=n(142),u=n(63);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function g(b,I){if(s()<I)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(b=new Uint8Array(I)).__proto__=c.prototype:(b===null&&(b=new c(I)),b.length=I),b}function c(b,I,$){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(b,I,$);if(typeof b=="number"){if(typeof I=="string")throw new Error("If encoding is specified then the first argument must be a string");return v(this,b)}return d(this,b,I,$)}function d(b,I,$,K){if(typeof I=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&I instanceof ArrayBuffer?function(Y,ne,ie,ue){if(ne.byteLength,ie<0||ne.byteLength<ie)throw new RangeError("'offset' is out of bounds");if(ne.byteLength<ie+(ue||0))throw new RangeError("'length' is out of bounds");return ne=ie===void 0&&ue===void 0?new Uint8Array(ne):ue===void 0?new Uint8Array(ne,ie):new Uint8Array(ne,ie,ue),c.TYPED_ARRAY_SUPPORT?(Y=ne).__proto__=c.prototype:Y=y(Y,ne),Y}(b,I,$,K):typeof I=="string"?function(Y,ne,ie){if(typeof ie=="string"&&ie!==""||(ie="utf8"),!c.isEncoding(ie))throw new TypeError('"encoding" must be a valid string encoding');var ue=0|p(ne,ie),we=(Y=g(Y,ue)).write(ne,ie);return we!==ue&&(Y=Y.slice(0,we)),Y}(b,I,$):function(Y,ne){if(c.isBuffer(ne)){var ie=0|f(ne.length);return(Y=g(Y,ie)).length===0||ne.copy(Y,0,0,ie),Y}if(ne){if(typeof ArrayBuffer<"u"&&ne.buffer instanceof ArrayBuffer||"length"in ne)return typeof ne.length!="number"||(ue=ne.length)!=ue?g(Y,0):y(Y,ne);if(ne.type==="Buffer"&&u(ne.data))return y(Y,ne.data)}var ue;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(b,I)}function w(b){if(typeof b!="number")throw new TypeError('"size" argument must be a number');if(b<0)throw new RangeError('"size" argument must not be negative')}function v(b,I){if(w(I),b=g(b,I<0?0:0|f(I)),!c.TYPED_ARRAY_SUPPORT)for(var $=0;$<I;++$)b[$]=0;return b}function y(b,I){var $=I.length<0?0:0|f(I.length);b=g(b,$);for(var K=0;K<$;K+=1)b[K]=255&I[K];return b}function f(b){if(b>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|b}function p(b,I){if(c.isBuffer(b))return b.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(b)||b instanceof ArrayBuffer))return b.byteLength;typeof b!="string"&&(b=""+b);var $=b.length;if($===0)return 0;for(var K=!1;;)switch(I){case"ascii":case"latin1":case"binary":return $;case"utf8":case"utf-8":case void 0:return te(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*$;case"hex":return $>>>1;case"base64":return k(b).length;default:if(K)return te(b).length;I=(""+I).toLowerCase(),K=!0}}function S(b,I,$){var K=!1;if((I===void 0||I<0)&&(I=0),I>this.length||(($===void 0||$>this.length)&&($=this.length),$<=0)||($>>>=0)<=(I>>>=0))return"";for(b||(b="utf8");;)switch(b){case"hex":return z(this,I,$);case"utf8":case"utf-8":return G(this,I,$);case"ascii":return j(this,I,$);case"latin1":case"binary":return C(this,I,$);case"base64":return _(this,I,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,I,$);default:if(K)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),K=!0}}function N(b,I,$){var K=b[I];b[I]=b[$],b[$]=K}function B(b,I,$,K,Y){if(b.length===0)return-1;if(typeof $=="string"?(K=$,$=0):$>2147483647?$=2147483647:$<-2147483648&&($=-2147483648),$=+$,isNaN($)&&($=Y?0:b.length-1),$<0&&($=b.length+$),$>=b.length){if(Y)return-1;$=b.length-1}else if($<0){if(!Y)return-1;$=0}if(typeof I=="string"&&(I=c.from(I,K)),c.isBuffer(I))return I.length===0?-1:E(b,I,$,K,Y);if(typeof I=="number")return I&=255,c.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?Y?Uint8Array.prototype.indexOf.call(b,I,$):Uint8Array.prototype.lastIndexOf.call(b,I,$):E(b,[I],$,K,Y);throw new TypeError("val must be string, number or Buffer")}function E(b,I,$,K,Y){var ne,ie=1,ue=b.length,we=I.length;if(K!==void 0&&((K=String(K).toLowerCase())==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le")){if(b.length<2||I.length<2)return-1;ie=2,ue/=2,we/=2,$/=2}function Oe(Ae,Ie){return ie===1?Ae[Ie]:Ae.readUInt16BE(Ie*ie)}if(Y){var Ee=-1;for(ne=$;ne<ue;ne++)if(Oe(b,ne)===Oe(I,Ee===-1?0:ne-Ee)){if(Ee===-1&&(Ee=ne),ne-Ee+1===we)return Ee*ie}else Ee!==-1&&(ne-=ne-Ee),Ee=-1}else for($+we>ue&&($=ue-we),ne=$;ne>=0;ne--){for(var Ne=!0,Te=0;Te<we;Te++)if(Oe(b,ne+Te)!==Oe(I,Te)){Ne=!1;break}if(Ne)return ne}return-1}function T(b,I,$,K){$=Number($)||0;var Y=b.length-$;K?(K=Number(K))>Y&&(K=Y):K=Y;var ne=I.length;if(ne%2!=0)throw new TypeError("Invalid hex string");K>ne/2&&(K=ne/2);for(var ie=0;ie<K;++ie){var ue=parseInt(I.substr(2*ie,2),16);if(isNaN(ue))return ie;b[$+ie]=ue}return ie}function h(b,I,$,K){return x(te(I,b.length-$),b,$,K)}function R(b,I,$,K){return x(function(Y){for(var ne=[],ie=0;ie<Y.length;++ie)ne.push(255&Y.charCodeAt(ie));return ne}(I),b,$,K)}function W(b,I,$,K){return R(b,I,$,K)}function X(b,I,$,K){return x(k(I),b,$,K)}function m(b,I,$,K){return x(function(Y,ne){for(var ie,ue,we,Oe=[],Ee=0;Ee<Y.length&&!((ne-=2)<0);++Ee)ie=Y.charCodeAt(Ee),ue=ie>>8,we=ie%256,Oe.push(we),Oe.push(ue);return Oe}(I,b.length-$),b,$,K)}function _(b,I,$){return I===0&&$===b.length?o.fromByteArray(b):o.fromByteArray(b.slice(I,$))}function G(b,I,$){$=Math.min(b.length,$);for(var K=[],Y=I;Y<$;){var ne,ie,ue,we,Oe=b[Y],Ee=null,Ne=Oe>239?4:Oe>223?3:Oe>191?2:1;if(Y+Ne<=$)switch(Ne){case 1:Oe<128&&(Ee=Oe);break;case 2:(192&(ne=b[Y+1]))==128&&(we=(31&Oe)<<6|63&ne)>127&&(Ee=we);break;case 3:ne=b[Y+1],ie=b[Y+2],(192&ne)==128&&(192&ie)==128&&(we=(15&Oe)<<12|(63&ne)<<6|63&ie)>2047&&(we<55296||we>57343)&&(Ee=we);break;case 4:ne=b[Y+1],ie=b[Y+2],ue=b[Y+3],(192&ne)==128&&(192&ie)==128&&(192&ue)==128&&(we=(15&Oe)<<18|(63&ne)<<12|(63&ie)<<6|63&ue)>65535&&we<1114112&&(Ee=we)}Ee===null?(Ee=65533,Ne=1):Ee>65535&&(Ee-=65536,K.push(Ee>>>10&1023|55296),Ee=56320|1023&Ee),K.push(Ee),Y+=Ne}return function(Te){var Ae=Te.length;if(Ae<=4096)return String.fromCharCode.apply(String,Te);for(var Ie="",Fe=0;Fe<Ae;)Ie+=String.fromCharCode.apply(String,Te.slice(Fe,Fe+=4096));return Ie}(K)}t.Buffer=c,t.SlowBuffer=function(b){return+b!=b&&(b=0),c.alloc(+b)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=r.TYPED_ARRAY_SUPPORT!==void 0?r.TYPED_ARRAY_SUPPORT:function(){try{var b=new Uint8Array(1);return b.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},b.foo()===42&&typeof b.subarray=="function"&&b.subarray(1,1).byteLength===0}catch{return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(b){return b.__proto__=c.prototype,b},c.from=function(b,I,$){return d(null,b,I,$)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(b,I,$){return function(K,Y,ne,ie){return w(Y),Y<=0?g(K,Y):ne!==void 0?typeof ie=="string"?g(K,Y).fill(ne,ie):g(K,Y).fill(ne):g(K,Y)}(null,b,I,$)},c.allocUnsafe=function(b){return v(null,b)},c.allocUnsafeSlow=function(b){return v(null,b)},c.isBuffer=function(b){return!(b==null||!b._isBuffer)},c.compare=function(b,I){if(!c.isBuffer(b)||!c.isBuffer(I))throw new TypeError("Arguments must be Buffers");if(b===I)return 0;for(var $=b.length,K=I.length,Y=0,ne=Math.min($,K);Y<ne;++Y)if(b[Y]!==I[Y]){$=b[Y],K=I[Y];break}return $<K?-1:K<$?1:0},c.isEncoding=function(b){switch(String(b).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(b,I){if(!u(b))throw new TypeError('"list" argument must be an Array of Buffers');if(b.length===0)return c.alloc(0);var $;if(I===void 0)for(I=0,$=0;$<b.length;++$)I+=b[$].length;var K=c.allocUnsafe(I),Y=0;for($=0;$<b.length;++$){var ne=b[$];if(!c.isBuffer(ne))throw new TypeError('"list" argument must be an Array of Buffers');ne.copy(K,Y),Y+=ne.length}return K},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var b=this.length;if(b%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var I=0;I<b;I+=2)N(this,I,I+1);return this},c.prototype.swap32=function(){var b=this.length;if(b%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var I=0;I<b;I+=4)N(this,I,I+3),N(this,I+1,I+2);return this},c.prototype.swap64=function(){var b=this.length;if(b%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var I=0;I<b;I+=8)N(this,I,I+7),N(this,I+1,I+6),N(this,I+2,I+5),N(this,I+3,I+4);return this},c.prototype.toString=function(){var b=0|this.length;return b===0?"":arguments.length===0?G(this,0,b):S.apply(this,arguments)},c.prototype.equals=function(b){if(!c.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||c.compare(this,b)===0},c.prototype.inspect=function(){var b="",I=t.INSPECT_MAX_BYTES;return this.length>0&&(b=this.toString("hex",0,I).match(/.{2}/g).join(" "),this.length>I&&(b+=" ... ")),"<Buffer "+b+">"},c.prototype.compare=function(b,I,$,K,Y){if(!c.isBuffer(b))throw new TypeError("Argument must be a Buffer");if(I===void 0&&(I=0),$===void 0&&($=b?b.length:0),K===void 0&&(K=0),Y===void 0&&(Y=this.length),I<0||$>b.length||K<0||Y>this.length)throw new RangeError("out of range index");if(K>=Y&&I>=$)return 0;if(K>=Y)return-1;if(I>=$)return 1;if(this===b)return 0;for(var ne=(Y>>>=0)-(K>>>=0),ie=($>>>=0)-(I>>>=0),ue=Math.min(ne,ie),we=this.slice(K,Y),Oe=b.slice(I,$),Ee=0;Ee<ue;++Ee)if(we[Ee]!==Oe[Ee]){ne=we[Ee],ie=Oe[Ee];break}return ne<ie?-1:ie<ne?1:0},c.prototype.includes=function(b,I,$){return this.indexOf(b,I,$)!==-1},c.prototype.indexOf=function(b,I,$){return B(this,b,I,$,!0)},c.prototype.lastIndexOf=function(b,I,$){return B(this,b,I,$,!1)},c.prototype.write=function(b,I,$,K){if(I===void 0)K="utf8",$=this.length,I=0;else if($===void 0&&typeof I=="string")K=I,$=this.length,I=0;else{if(!isFinite(I))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");I|=0,isFinite($)?($|=0,K===void 0&&(K="utf8")):(K=$,$=void 0)}var Y=this.length-I;if(($===void 0||$>Y)&&($=Y),b.length>0&&($<0||I<0)||I>this.length)throw new RangeError("Attempt to write outside buffer bounds");K||(K="utf8");for(var ne=!1;;)switch(K){case"hex":return T(this,b,I,$);case"utf8":case"utf-8":return h(this,b,I,$);case"ascii":return R(this,b,I,$);case"latin1":case"binary":return W(this,b,I,$);case"base64":return X(this,b,I,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,b,I,$);default:if(ne)throw new TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),ne=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function j(b,I,$){var K="";$=Math.min(b.length,$);for(var Y=I;Y<$;++Y)K+=String.fromCharCode(127&b[Y]);return K}function C(b,I,$){var K="";$=Math.min(b.length,$);for(var Y=I;Y<$;++Y)K+=String.fromCharCode(b[Y]);return K}function z(b,I,$){var K=b.length;(!I||I<0)&&(I=0),(!$||$<0||$>K)&&($=K);for(var Y="",ne=I;ne<$;++ne)Y+=ee(b[ne]);return Y}function P(b,I,$){for(var K=b.slice(I,$),Y="",ne=0;ne<K.length;ne+=2)Y+=String.fromCharCode(K[ne]+256*K[ne+1]);return Y}function D(b,I,$){if(b%1!=0||b<0)throw new RangeError("offset is not uint");if(b+I>$)throw new RangeError("Trying to access beyond buffer length")}function O(b,I,$,K,Y,ne){if(!c.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(I>Y||I<ne)throw new RangeError('"value" argument is out of bounds');if($+K>b.length)throw new RangeError("Index out of range")}function L(b,I,$,K){I<0&&(I=65535+I+1);for(var Y=0,ne=Math.min(b.length-$,2);Y<ne;++Y)b[$+Y]=(I&255<<8*(K?Y:1-Y))>>>8*(K?Y:1-Y)}function U(b,I,$,K){I<0&&(I=4294967295+I+1);for(var Y=0,ne=Math.min(b.length-$,4);Y<ne;++Y)b[$+Y]=I>>>8*(K?Y:3-Y)&255}function A(b,I,$,K,Y,ne){if($+K>b.length)throw new RangeError("Index out of range");if($<0)throw new RangeError("Index out of range")}function V(b,I,$,K,Y){return Y||A(b,0,$,4),l.write(b,I,$,K,23,4),$+4}function q(b,I,$,K,Y){return Y||A(b,0,$,8),l.write(b,I,$,K,52,8),$+8}c.prototype.slice=function(b,I){var $,K=this.length;if((b=~~b)<0?(b+=K)<0&&(b=0):b>K&&(b=K),(I=I===void 0?K:~~I)<0?(I+=K)<0&&(I=0):I>K&&(I=K),I<b&&(I=b),c.TYPED_ARRAY_SUPPORT)($=this.subarray(b,I)).__proto__=c.prototype;else{var Y=I-b;$=new c(Y,void 0);for(var ne=0;ne<Y;++ne)$[ne]=this[ne+b]}return $},c.prototype.readUIntLE=function(b,I,$){b|=0,I|=0,$||D(b,I,this.length);for(var K=this[b],Y=1,ne=0;++ne<I&&(Y*=256);)K+=this[b+ne]*Y;return K},c.prototype.readUIntBE=function(b,I,$){b|=0,I|=0,$||D(b,I,this.length);for(var K=this[b+--I],Y=1;I>0&&(Y*=256);)K+=this[b+--I]*Y;return K},c.prototype.readUInt8=function(b,I){return I||D(b,1,this.length),this[b]},c.prototype.readUInt16LE=function(b,I){return I||D(b,2,this.length),this[b]|this[b+1]<<8},c.prototype.readUInt16BE=function(b,I){return I||D(b,2,this.length),this[b]<<8|this[b+1]},c.prototype.readUInt32LE=function(b,I){return I||D(b,4,this.length),(this[b]|this[b+1]<<8|this[b+2]<<16)+16777216*this[b+3]},c.prototype.readUInt32BE=function(b,I){return I||D(b,4,this.length),16777216*this[b]+(this[b+1]<<16|this[b+2]<<8|this[b+3])},c.prototype.readIntLE=function(b,I,$){b|=0,I|=0,$||D(b,I,this.length);for(var K=this[b],Y=1,ne=0;++ne<I&&(Y*=256);)K+=this[b+ne]*Y;return K>=(Y*=128)&&(K-=Math.pow(2,8*I)),K},c.prototype.readIntBE=function(b,I,$){b|=0,I|=0,$||D(b,I,this.length);for(var K=I,Y=1,ne=this[b+--K];K>0&&(Y*=256);)ne+=this[b+--K]*Y;return ne>=(Y*=128)&&(ne-=Math.pow(2,8*I)),ne},c.prototype.readInt8=function(b,I){return I||D(b,1,this.length),128&this[b]?-1*(255-this[b]+1):this[b]},c.prototype.readInt16LE=function(b,I){I||D(b,2,this.length);var $=this[b]|this[b+1]<<8;return 32768&$?4294901760|$:$},c.prototype.readInt16BE=function(b,I){I||D(b,2,this.length);var $=this[b+1]|this[b]<<8;return 32768&$?4294901760|$:$},c.prototype.readInt32LE=function(b,I){return I||D(b,4,this.length),this[b]|this[b+1]<<8|this[b+2]<<16|this[b+3]<<24},c.prototype.readInt32BE=function(b,I){return I||D(b,4,this.length),this[b]<<24|this[b+1]<<16|this[b+2]<<8|this[b+3]},c.prototype.readFloatLE=function(b,I){return I||D(b,4,this.length),l.read(this,b,!0,23,4)},c.prototype.readFloatBE=function(b,I){return I||D(b,4,this.length),l.read(this,b,!1,23,4)},c.prototype.readDoubleLE=function(b,I){return I||D(b,8,this.length),l.read(this,b,!0,52,8)},c.prototype.readDoubleBE=function(b,I){return I||D(b,8,this.length),l.read(this,b,!1,52,8)},c.prototype.writeUIntLE=function(b,I,$,K){b=+b,I|=0,$|=0,K||O(this,b,I,$,Math.pow(2,8*$)-1,0);var Y=1,ne=0;for(this[I]=255&b;++ne<$&&(Y*=256);)this[I+ne]=b/Y&255;return I+$},c.prototype.writeUIntBE=function(b,I,$,K){b=+b,I|=0,$|=0,K||O(this,b,I,$,Math.pow(2,8*$)-1,0);var Y=$-1,ne=1;for(this[I+Y]=255&b;--Y>=0&&(ne*=256);)this[I+Y]=b/ne&255;return I+$},c.prototype.writeUInt8=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,1,255,0),c.TYPED_ARRAY_SUPPORT||(b=Math.floor(b)),this[I]=255&b,I+1},c.prototype.writeUInt16LE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[I]=255&b,this[I+1]=b>>>8):L(this,b,I,!0),I+2},c.prototype.writeUInt16BE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[I]=b>>>8,this[I+1]=255&b):L(this,b,I,!1),I+2},c.prototype.writeUInt32LE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[I+3]=b>>>24,this[I+2]=b>>>16,this[I+1]=b>>>8,this[I]=255&b):U(this,b,I,!0),I+4},c.prototype.writeUInt32BE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[I]=b>>>24,this[I+1]=b>>>16,this[I+2]=b>>>8,this[I+3]=255&b):U(this,b,I,!1),I+4},c.prototype.writeIntLE=function(b,I,$,K){if(b=+b,I|=0,!K){var Y=Math.pow(2,8*$-1);O(this,b,I,$,Y-1,-Y)}var ne=0,ie=1,ue=0;for(this[I]=255&b;++ne<$&&(ie*=256);)b<0&&ue===0&&this[I+ne-1]!==0&&(ue=1),this[I+ne]=(b/ie>>0)-ue&255;return I+$},c.prototype.writeIntBE=function(b,I,$,K){if(b=+b,I|=0,!K){var Y=Math.pow(2,8*$-1);O(this,b,I,$,Y-1,-Y)}var ne=$-1,ie=1,ue=0;for(this[I+ne]=255&b;--ne>=0&&(ie*=256);)b<0&&ue===0&&this[I+ne+1]!==0&&(ue=1),this[I+ne]=(b/ie>>0)-ue&255;return I+$},c.prototype.writeInt8=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,1,127,-128),c.TYPED_ARRAY_SUPPORT||(b=Math.floor(b)),b<0&&(b=255+b+1),this[I]=255&b,I+1},c.prototype.writeInt16LE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[I]=255&b,this[I+1]=b>>>8):L(this,b,I,!0),I+2},c.prototype.writeInt16BE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[I]=b>>>8,this[I+1]=255&b):L(this,b,I,!1),I+2},c.prototype.writeInt32LE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[I]=255&b,this[I+1]=b>>>8,this[I+2]=b>>>16,this[I+3]=b>>>24):U(this,b,I,!0),I+4},c.prototype.writeInt32BE=function(b,I,$){return b=+b,I|=0,$||O(this,b,I,4,2147483647,-2147483648),b<0&&(b=4294967295+b+1),c.TYPED_ARRAY_SUPPORT?(this[I]=b>>>24,this[I+1]=b>>>16,this[I+2]=b>>>8,this[I+3]=255&b):U(this,b,I,!1),I+4},c.prototype.writeFloatLE=function(b,I,$){return V(this,b,I,!0,$)},c.prototype.writeFloatBE=function(b,I,$){return V(this,b,I,!1,$)},c.prototype.writeDoubleLE=function(b,I,$){return q(this,b,I,!0,$)},c.prototype.writeDoubleBE=function(b,I,$){return q(this,b,I,!1,$)},c.prototype.copy=function(b,I,$,K){if($||($=0),K||K===0||(K=this.length),I>=b.length&&(I=b.length),I||(I=0),K>0&&K<$&&(K=$),K===$||b.length===0||this.length===0)return 0;if(I<0)throw new RangeError("targetStart out of bounds");if($<0||$>=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),b.length-I<K-$&&(K=b.length-I+$);var Y,ne=K-$;if(this===b&&$<I&&I<K)for(Y=ne-1;Y>=0;--Y)b[Y+I]=this[Y+$];else if(ne<1e3||!c.TYPED_ARRAY_SUPPORT)for(Y=0;Y<ne;++Y)b[Y+I]=this[Y+$];else Uint8Array.prototype.set.call(b,this.subarray($,$+ne),I);return ne},c.prototype.fill=function(b,I,$,K){if(typeof b=="string"){if(typeof I=="string"?(K=I,I=0,$=this.length):typeof $=="string"&&(K=$,$=this.length),b.length===1){var Y=b.charCodeAt(0);Y<256&&(b=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 b=="number"&&(b&=255);if(I<0||this.length<I||this.length<$)throw new RangeError("Out of range index");if($<=I)return this;var ne;if(I>>>=0,$=$===void 0?this.length:$>>>0,b||(b=0),typeof b=="number")for(ne=I;ne<$;++ne)this[ne]=b;else{var ie=c.isBuffer(b)?b:te(new c(b,K).toString()),ue=ie.length;for(ne=0;ne<$-I;++ne)this[ne+I]=ie[ne%ue]}return this};var Q=/[^+\/0-9A-Za-z-_]/g;function ee(b){return b<16?"0"+b.toString(16):b.toString(16)}function te(b,I){var $;I=I||1/0;for(var K=b.length,Y=null,ne=[],ie=0;ie<K;++ie){if(($=b.charCodeAt(ie))>55295&&$<57344){if(!Y){if($>56319){(I-=3)>-1&&ne.push(239,191,189);continue}if(ie+1===K){(I-=3)>-1&&ne.push(239,191,189);continue}Y=$;continue}if($<56320){(I-=3)>-1&&ne.push(239,191,189),Y=$;continue}$=65536+(Y-55296<<10|$-56320)}else Y&&(I-=3)>-1&&ne.push(239,191,189);if(Y=null,$<128){if((I-=1)<0)break;ne.push($)}else if($<2048){if((I-=2)<0)break;ne.push($>>6|192,63&$|128)}else if($<65536){if((I-=3)<0)break;ne.push($>>12|224,$>>6&63|128,63&$|128)}else{if(!($<1114112))throw new Error("Invalid code point");if((I-=4)<0)break;ne.push($>>18|240,$>>12&63|128,$>>6&63|128,63&$|128)}}return ne}function k(b){return o.toByteArray(function(I){if((I=function($){return $.trim?$.trim():$.replace(/^\s+|\s+$/g,"")}(I).replace(Q,"")).length<2)return"";for(;I.length%4!=0;)I+="=";return I}(b))}function x(b,I,$,K){for(var Y=0;Y<K&&!(Y+$>=I.length||Y>=b.length);++Y)I[Y+$]=b[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(v){return(r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(y){return typeof y}:function(y){return y&&typeof Symbol=="function"&&y.constructor===Symbol&&y!==Symbol.prototype?"symbol":typeof y})(v)}function o(v,y){if(y&&(r(y)==="object"||typeof y=="function"))return y;if(y!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return l(v)}function l(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function u(v){var y=typeof Map=="function"?new Map:void 0;return(u=function(f){if(f===null||(p=f,Function.toString.call(p).indexOf("[native code]")===-1))return f;var p;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(y!==void 0){if(y.has(f))return y.get(f);y.set(f,S)}function S(){return s(f,arguments,d(this).constructor)}return S.prototype=Object.create(f.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),c(S,f)})(v)}function s(v,y,f){return(s=g()?Reflect.construct.bind():function(p,S,N){var B=[null];B.push.apply(B,S);var E=new(Function.bind.apply(p,B));return N&&c(E,N.prototype),E}).apply(null,arguments)}function g(){if(typeof Reflect>"u"||!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(v,y){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,p){return f.__proto__=p,f})(v,y)}function d(v){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(y){return y.__proto__||Object.getPrototypeOf(y)})(v)}var w=function(v){(function(B,E){if(typeof E!="function"&&E!==null)throw new TypeError("Super expression must either be null or a function");B.prototype=Object.create(E&&E.prototype,{constructor:{value:B,writable:!0,configurable:!0}}),Object.defineProperty(B,"prototype",{writable:!1}),E&&c(B,E)})(N,v);var y,f,p,S=(y=N,f=g(),function(){var B,E=d(y);if(f){var T=d(this).constructor;B=Reflect.construct(E,arguments,T)}else B=E.apply(this,arguments);return o(this,B)});function N(B){var E;return function(T,h){if(!(T instanceof h))throw new TypeError("Cannot call a class as a function")}(this,N),E=S.call(this,`Format functions must be synchronous taking a two arguments: (info, opts)
3
3
  Found: `.concat(B.toString().split(`
4
4
  `)[0],`
package/package.json CHANGED
@@ -24,7 +24,7 @@
24
24
  }
25
25
  }
26
26
  },
27
- "version": "1.13.0",
27
+ "version": "1.13.1",
28
28
  "scripts": {
29
29
  "preversion": "npm run verify",
30
30
  "postversion": "make",