@factset/frontgate-js-sdk 7.0.2 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,41 @@
1
+ ## <small>7.0.4 (2025-11-06)</small>
2
+
3
+ * fix(demo-node): do not override env variable in code [9350000]
4
+ * fix(prepublish): use new import assertion syntax [e3bed89]
5
+ * fix(subscriptions): remove inflights on error [33697ce]
6
+ * fix(vite): use version without cve [1b615e6]
7
+ * chore(backstage): document further annotations [3865292]
8
+ * chore(backstage): fix documentation url [2d3c734]
9
+ * chore(Backstage): update Backstage metadata [12e6ebc]
10
+ * chore(Backstage): update Backstage metadata [9084922]
11
+ * chore(deps): lock file maintenance [968e56c]
12
+ * chore(deps): lock file maintenance [9739db8]
13
+ * chore(deps): update dependency happy-dom to ^20.0.2 [security] [bfda52c]
14
+ * chore(deps): update dependency happy-dom to v20 [security] [06475bc]
15
+ * chore(deps): update dependency node to v24 [272a875]
16
+ * chore(deps): update dependency node to v24 [515f36c]
17
+ * chore(deps): update dependency nx to v22 [62d9329]
18
+ * chore(deps): update softprops/action-gh-release action to v2.4.1 [2b084a1], closes [softprops/action-#release]
19
+ * chore(deps): update vitest monorepo to v4 [cfbe7ce]
20
+ * chore(release): update changelog for v7.0.3 [e60b73f]
21
+ * refactor(client): deduplicate imports [e8d5571]
22
+ * refactor(client): deduplicate imports [9a414fd]
23
+ * refactor(client): improve readability [ef9baa4]
24
+ * refactor(client): nicely type timeout [21d0925]
25
+ * refactor(client): properly type logger [0ac4b52]
26
+ * refactor(client): remove redundant type next to any [297f481]
27
+ * refactor(client): replace not-null assertions with expressive type assertions [b4a1622]
28
+ * refactor(client): use this type [2fc3772]
29
+ * refactor(demo-builder): deduplicate imports [d5a9e14]
30
+ * refactor(demo-builder): deduplicate imports [5287d89]
31
+ * refactor(demo-builder): remove unnecessary assignment [96f74aa]
32
+ * refactor(lint): use optional chain expression [356964e]
33
+ * Remove fortify action [69d60e9]
34
+
35
+
36
+
1
37
  ## <small>7.0.2 (2025-10-09)</small>
2
38
 
3
- * feat(functions): remove depracted usage of navigator props [3d6a16f]
4
39
  * chore(deps): lock file maintenance [e8dd0a6]
5
40
  * chore(deps): lock file maintenance [2f82edc]
6
41
  * chore(deps): lock file maintenance [da9e5e2]
@@ -12,13 +47,15 @@
12
47
  * chore(deps): update dependency @fds/lint-standards to v29 [90367f8]
13
48
  * chore(deps): update dependency happy-dom to v19 [32960ea]
14
49
  * chore(deps): update dependency vite to ^7.1.5 [security] [8879b32]
15
- * chore(deps): update softprops/action-gh-release action to v2.3.3 [00f18bb]
16
- * chore(deps): update softprops/action-gh-release action to v2.3.4 [1bf3bad]
17
- * chore(deps): update softprops/action-gh-release action to v2.4.0 [6fa1a5e]
50
+ * chore(deps): update softprops/action-gh-release action to v2.3.3 [00f18bb], closes [softprops/action-#release]
51
+ * chore(deps): update softprops/action-gh-release action to v2.3.4 [1bf3bad], closes [softprops/action-#release]
52
+ * chore(deps): update softprops/action-gh-release action to v2.4.0 [6fa1a5e], closes [softprops/action-#release]
18
53
  * chore(deps): update sonarsource/sonarqube-scan-action action to v6 [6efaefa]
19
54
  * chore(deps): update yarn to v4.10.0 [b47a139]
20
55
  * chore(deps): update yarn to v4.10.3 [7759d0a]
21
56
  * chore(epr): inform users about the npm release [8849286]
57
+ * chore(release): update changelog for v7.0.2 [e53f1ed]
58
+ * feat(functions): remove depracted usage of navigator props [3d6a16f]
22
59
  * fix(deps): update dependency lerna to v9 [976a3ba]
23
60
  * fix(functions): dont rely on navigator beeing populated [10b56b4]
24
61
  * refactor(variables): rename to prevent shadowing [e8caa54]
@@ -108,9 +145,9 @@
108
145
  * chore(deps): update dependency vite to v7 [ff16a47]
109
146
  * chore(deps): update dependency vite-tsconfig-paths to v5 [307fd61]
110
147
  * chore(deps): update factset/waffle-actions action to v2.5.2 [617d450]
111
- * chore(deps): update peaceiris/actions-gh-pages action to v3.9.3 [2070e37]
112
- * chore(deps): update peaceiris/actions-gh-pages action to v4 [6569746]
113
- * chore(deps): update softprops/action-gh-release action to v2 [cba8093]
148
+ * chore(deps): update peaceiris/actions-gh-pages action to v3.9.3 [2070e37], closes [peaceiris/actions-#pages]
149
+ * chore(deps): update peaceiris/actions-gh-pages action to v4 [6569746], closes [peaceiris/actions-#pages]
150
+ * chore(deps): update softprops/action-gh-release action to v2 [cba8093], closes [softprops/action-#release]
114
151
  * chore(deps): update sonarsource/sonarqube-scan-action action to v5 [5876377]
115
152
  * chore(deps): update yarn to v4.9.2 [750d175]
116
153
  * feat(auth): remove depracted auth interfaces [01da6bd]
@@ -404,7 +441,7 @@
404
441
 
405
442
  ## <small>6.2.5 (2024-04-29)</small>
406
443
 
407
- * chore(gh-actions): upgrade sonarcloud action [84b0aaa]
444
+ * chore(gh-actions): upgrade sonarcloud action [84b0aaa], closes [#actions]
408
445
  * chore(repo): bump version.ts [b84a41c]
409
446
  * chore(repo): update changelog [b16b9a8]
410
447
  * feat(subscriptions): add request options [8703cc3]
@@ -15,13 +15,16 @@ export class Mdg2Response {
15
15
  return this.raw.header.id_service;
16
16
  }
17
17
  isUpdateMessage() {
18
- return (Object.hasOwnProperty.call(this.raw, 'header') &&
19
- (Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) &&
20
- this.raw.Message.endsWith('Update'));
18
+ if (!Object.hasOwnProperty.call(this.raw, 'header')) {
19
+ return false;
20
+ }
21
+ return (Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) && this.raw.Message.endsWith('Update');
21
22
  }
22
23
  isLossMessage() {
23
- return (Object.hasOwnProperty.call(this.raw, 'header') &&
24
- (Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) &&
24
+ if (!Object.hasOwnProperty.call(this.raw, 'header')) {
25
+ return false;
26
+ }
27
+ return ((Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) &&
25
28
  (this.raw.Message.endsWith('LossMessage') || this.raw.Message.endsWith('Loss')));
26
29
  }
27
30
  }
@@ -193,7 +193,6 @@ export const endpointSubscriptions = (originalConfig) => {
193
193
  __classPrivateFieldGet(this, _subscriptions, "f").set(key, observer);
194
194
  const currentSubscounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
195
195
  __classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, currentSubscounts + 1);
196
- __classPrivateFieldGet(this, _inFlights, "f").delete(key);
197
196
  resolve(observer);
198
197
  });
199
198
  })
@@ -202,7 +201,9 @@ export const endpointSubscriptions = (originalConfig) => {
202
201
  });
203
202
  });
204
203
  const rejectReason = `Request timeout reached (${timeOutInMs} ms) for ${subscriptionMsg.message.Message}`;
205
- const wrappedTimeoutPromise = useTimeout(timeOutInMs, rejectReason, promise);
204
+ const wrappedTimeoutPromise = useTimeout(timeOutInMs, rejectReason, promise).finally(() => {
205
+ __classPrivateFieldGet(this, _inFlights, "f").delete(key);
206
+ });
206
207
  __classPrivateFieldGet(this, _inFlights, "f").set(key, wrappedTimeoutPromise);
207
208
  return wrappedTimeoutPromise;
208
209
  }
@@ -1 +1 @@
1
- export const PACKAGE_JSON = { version: '7.0.2', package: '@factset/frontgate-js-sdk' };
1
+ export const PACKAGE_JSON = { version: '7.0.4', package: '@factset/frontgate-js-sdk' };
@@ -18,13 +18,16 @@ class Mdg2Response {
18
18
  return this.raw.header.id_service;
19
19
  }
20
20
  isUpdateMessage() {
21
- return (Object.hasOwnProperty.call(this.raw, 'header') &&
22
- (Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) &&
23
- this.raw.Message.endsWith('Update'));
21
+ if (!Object.hasOwnProperty.call(this.raw, 'header')) {
22
+ return false;
23
+ }
24
+ return (Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) && this.raw.Message.endsWith('Update');
24
25
  }
25
26
  isLossMessage() {
26
- return (Object.hasOwnProperty.call(this.raw, 'header') &&
27
- (Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) &&
27
+ if (!Object.hasOwnProperty.call(this.raw, 'header')) {
28
+ return false;
29
+ }
30
+ return ((Object.hasOwnProperty.call(this.raw.header, 'id_service') || Object.hasOwnProperty.call(this.raw.header, 'id_job')) &&
28
31
  (this.raw.Message.endsWith('LossMessage') || this.raw.Message.endsWith('Loss')));
29
32
  }
30
33
  }
@@ -196,7 +196,6 @@ const endpointSubscriptions = (originalConfig) => {
196
196
  __classPrivateFieldGet(this, _subscriptions, "f").set(key, observer);
197
197
  const currentSubscounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
198
198
  __classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, currentSubscounts + 1);
199
- __classPrivateFieldGet(this, _inFlights, "f").delete(key);
200
199
  resolve(observer);
201
200
  });
202
201
  })
@@ -205,7 +204,9 @@ const endpointSubscriptions = (originalConfig) => {
205
204
  });
206
205
  });
207
206
  const rejectReason = `Request timeout reached (${timeOutInMs} ms) for ${subscriptionMsg.message.Message}`;
208
- const wrappedTimeoutPromise = (0, functions_1.useTimeout)(timeOutInMs, rejectReason, promise);
207
+ const wrappedTimeoutPromise = (0, functions_1.useTimeout)(timeOutInMs, rejectReason, promise).finally(() => {
208
+ __classPrivateFieldGet(this, _inFlights, "f").delete(key);
209
+ });
209
210
  __classPrivateFieldGet(this, _inFlights, "f").set(key, wrappedTimeoutPromise);
210
211
  return wrappedTimeoutPromise;
211
212
  }
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_JSON = void 0;
4
- exports.PACKAGE_JSON = { version: '7.0.2', package: '@factset/frontgate-js-sdk' };
4
+ exports.PACKAGE_JSON = { version: '7.0.4', package: '@factset/frontgate-js-sdk' };
@@ -1,6 +1,6 @@
1
1
  import type { RequestResult } from './RequestResult';
2
2
  import type { HTTPProxyResponse } from '../../../message';
3
3
  export interface HTTPProxyRequestResult extends RequestResult {
4
- data: any | any[];
4
+ data: any;
5
5
  response: HTTPProxyResponse;
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import type { Mdg2Response } from '../../../message';
2
2
  export interface RequestResult {
3
- data: any | any[];
3
+ data: any;
4
4
  response: Mdg2Response;
5
5
  }
@@ -28,5 +28,5 @@ export declare abstract class AbstractLogger {
28
28
  protected shouldLog(method: string): boolean;
29
29
  private setDefaultLevelFromLocalStorage;
30
30
  static getLogLevel(loglevel: string): LogLevel;
31
- static getLogger(name: string, LoggerClass: any): LoggerInterface;
31
+ static getLogger(name: string, LoggerClass: new (name: string) => LoggerInterface): LoggerInterface;
32
32
  }
@@ -2,13 +2,13 @@ import type { LoggerInterface } from './LoggerInterface';
2
2
  import type { LogLevel } from './AbstractLogger';
3
3
  import { AbstractLogger } from './AbstractLogger';
4
4
  export declare class ConsoleLogger extends AbstractLogger implements LoggerInterface {
5
- trace: any;
6
- debug: any;
7
- info: any;
8
- warn: any;
9
- error: any;
10
- fatal: any;
5
+ trace: (...args: unknown[]) => void;
6
+ debug: (...args: unknown[]) => void;
7
+ info: (...args: unknown[]) => void;
8
+ warn: (...args: unknown[]) => void;
9
+ error: (...args: unknown[]) => void;
10
+ fatal: (...args: unknown[]) => void;
11
11
  setLevel(level: LogLevel): void;
12
- protected getLogMethod(level: string): any;
12
+ protected getLogMethod(level: string): (...args: unknown[]) => void;
13
13
  static getLogger(name?: string): LoggerInterface;
14
14
  }
@@ -1,11 +1,11 @@
1
1
  import type { Level } from './AbstractLogger';
2
2
  export interface LoggerInterface {
3
- trace: (...args: any[]) => void;
4
- debug: (...args: any[]) => void;
5
- info: (...args: any[]) => void;
6
- warn: (...args: any[]) => void;
7
- error: (...args: any[]) => void;
8
- fatal: (...args: any[]) => void;
3
+ trace: (...args: unknown[]) => void;
4
+ debug: (...args: unknown[]) => void;
5
+ info: (...args: unknown[]) => void;
6
+ warn: (...args: unknown[]) => void;
7
+ error: (...args: unknown[]) => void;
8
+ fatal: (...args: unknown[]) => void;
9
9
  setLevel: (level: Level, persist?: boolean) => void;
10
10
  getLevel: () => Level;
11
11
  getName: () => string;
@@ -23,6 +23,6 @@ export declare class HTTPProxyRequest extends AbstractMdg2Request {
23
23
  private setHeaders;
24
24
  private setQuery;
25
25
  private setMethod;
26
- setBody(data?: HTTPProxyRequestBody): HTTPProxyRequest;
26
+ setBody(data?: HTTPProxyRequestBody): this;
27
27
  getData(): string | Record<string, unknown> | undefined;
28
28
  }
@@ -1,8 +1,7 @@
1
1
  import { type AConstructorTypeOf, type CalledHooksByConnection } from '.';
2
2
  import type { DefaultFrontgateClientHooks, FrontgateClient } from '../FrontgateClient';
3
3
  import type { HTTPProxyRequestResult } from '../common/interfaces/result/HTTPProxyRequestResult';
4
- import type { HTTPProxyRequestBody } from '../message';
5
- import { type HTTPMethod, type HTTPProxyRequestOptions } from '../message';
4
+ import type { HTTPProxyRequestBody, HTTPMethod, HTTPProxyRequestOptions } from '../message';
6
5
  export interface HTTPProxyRequestable {
7
6
  requestProxyEndpoint: (method: HTTPMethod, path: string, body?: Record<string, unknown>, options?: HTTPProxyRequestOptions, timeOutInMs?: number) => Promise<HTTPProxyRequestResult>;
8
7
  }
@@ -1,4 +1,4 @@
1
- import { type AConstructorTypeOf, type FrontgateClientWSConnectionConfig, type CalledHooksByAuth, type CalledHooksByConnection } from '../.';
1
+ import type { AConstructorTypeOf, FrontgateClientWSConnectionConfig, CalledHooksByAuth, CalledHooksByConnection } from '../.';
2
2
  import type { DefaultFrontgateClientHooks, FrontgateClient } from '../../FrontgateClient';
3
3
  import type { PtlMessage } from '../../common/interfaces';
4
4
  import { AuthenticationRequest, ConfigurationRequest } from '../../compat';
@@ -1,4 +1,4 @@
1
- import { type AConstructorTypeOf, type FrontgateClientWSConnectionConfig, type CalledHooksByAuth, type CalledHooksByConnection } from '../.';
1
+ import type { AConstructorTypeOf, FrontgateClientWSConnectionConfig, CalledHooksByAuth, CalledHooksByConnection } from '../.';
2
2
  import type { DefaultFrontgateClientHooks, FrontgateClient } from '../../FrontgateClient';
3
3
  import { type DeploymentStage } from '../../connection';
4
4
  import { AuthenticationRequest, ConfigurationRequest } from '../../compat';
@@ -1,4 +1,4 @@
1
- import { type AConstructorTypeOf, type FrontgateClientWSConnectionConfig, type CalledHooksByAuth, type CalledHooksByConnection } from '../.';
1
+ import type { AConstructorTypeOf, FrontgateClientWSConnectionConfig, CalledHooksByAuth, CalledHooksByConnection } from '../.';
2
2
  import type { DefaultFrontgateClientHooks, FrontgateClient } from '../../FrontgateClient';
3
3
  import { type DeploymentStage } from '../../connection';
4
4
  import { AuthenticationRequest, ConfigurationRequest } from '../../compat';
@@ -1,5 +1,4 @@
1
1
  import type { PtlMessage } from '../../common/interfaces';
2
- import type { DisconnectionMessage } from '../../message';
3
2
  import type { CloseEvent } from 'ws';
4
3
  import type { FrontgateClientWSConnectionConfig } from './FrontgateWSMixin';
5
4
  export * from './FrontgateWSMixin';
@@ -25,7 +24,7 @@ export interface CalledHooksByConnection {
25
24
  }) => void;
26
25
  'frontgateConnection:connected': (conf: any) => void;
27
26
  'frontgateConnection:error': (err: any) => void;
28
- 'frontgateConnection:disconnected': (event: DisconnectionMessage | any) => void;
27
+ 'frontgateConnection:disconnected': (event: any) => void;
29
28
  'frontgateConnection:beforeSerializeMessage': (msg: PtlMessage) => void;
30
29
  'frontgateConnection:beforeSendMessage': (data: {
31
30
  msg: string;
@@ -1 +1 @@
1
- (function(b,Oe){typeof exports=="object"&&typeof module<"u"?Oe(exports):typeof define=="function"&&define.amd?define(["exports"],Oe):(b=typeof globalThis<"u"?globalThis:b||self,Oe(b.fdsg={}))})(this,(function(b){"use strict";function Oe(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var et,Pt;function Mr(){if(Pt)return et;Pt=1;var r=function(g){return e(g)&&!t(g)};function e(l){return!!l&&typeof l=="object"}function t(l){var g=Object.prototype.toString.call(l);return g==="[object RegExp]"||g==="[object Date]"||o(l)}var n=typeof Symbol=="function"&&Symbol.for,s=n?Symbol.for("react.element"):60103;function o(l){return l.$$typeof===s}function i(l){return Array.isArray(l)?[]:{}}function c(l,g){return g.clone!==!1&&g.isMergeableObject(l)?E(i(l),l,g):l}function a(l,g,p){return l.concat(g).map(function(y){return c(y,p)})}function f(l,g){if(!g.customMerge)return E;var p=g.customMerge(l);return typeof p=="function"?p:E}function u(l){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(l).filter(function(g){return Object.propertyIsEnumerable.call(l,g)}):[]}function h(l){return Object.keys(l).concat(u(l))}function v(l,g){try{return g in l}catch{return!1}}function w(l,g){return v(l,g)&&!(Object.hasOwnProperty.call(l,g)&&Object.propertyIsEnumerable.call(l,g))}function M(l,g,p){var y={};return p.isMergeableObject(l)&&h(l).forEach(function(_){y[_]=c(l[_],p)}),h(g).forEach(function(_){w(l,_)||(v(l,_)&&p.isMergeableObject(g[_])?y[_]=f(_,p)(l[_],g[_],p):y[_]=c(g[_],p))}),y}function E(l,g,p){p=p||{},p.arrayMerge=p.arrayMerge||a,p.isMergeableObject=p.isMergeableObject||r,p.cloneUnlessOtherwiseSpecified=c;var y=Array.isArray(g),_=Array.isArray(l),I=y===_;return I?y?p.arrayMerge(l,g,p):M(l,g,p):c(g,p)}E.all=function(g,p){if(!Array.isArray(g))throw new Error("first argument should be an array");return g.reduce(function(y,_){return E(y,_,p)},{})};var k=E;return et=k,et}var Er=Mr();const xt=Oe(Er);function Tr(r){return!!r&&typeof r=="object"}function Ir(...r){const e=r.filter(Tr);return xt.all(e,{arrayMerge:(t,n)=>n})}function Or(r){return r.replace(/[=]/g,"").replace(/\//g,"_").replace(/\+/g,"-")}class Ft{constructor(e){const t=Or(e),n=Math.ceil(t.length/2);this.firstFactor=t.substring(0,n),this.secondFactor=t.substring(n)}getFirstFactor(){return this.firstFactor}getSecondFactor(){return this.secondFactor}}const he=-2,be=-2,$t=-1;function Cr(r){const e=[];if(r)for(let t=0;t<r.length;t++)e.push(r.readInt8(t));return e}var Ut=(r=>(r[r.DISCONNECTED=0]="DISCONNECTED",r[r.CONNECTING=1]="CONNECTING",r[r.AUTHENTICATED=2]="AUTHENTICATED",r[r.RECONNECTING=3]="RECONNECTING",r))(Ut||{}),Dt=(r=>(r[r.production=40]="production",r[r.preproduction=35]="preproduction",r[r.show=30]="show",r[r.testing=20]="testing",r))(Dt||{}),jt=(r=>(r.production="frontgate-eu.factsetdigitalsolutions.com",r.show="frontgate-eu.show.factsetdigitalsolutions.com",r))(jt||{}),Ht=(r=>(r.MAXIMUM_STRING="9223372036854775807",r.MINIMUM_STRING="-9223372036854775807",r))(Ht||{});function He(r){return r.toString().slice(0,-3)}const Gt={version:"7.0.2",package:"@factset/frontgate-js-sdk"};function Rr(){const r=Ar();return{userAgent:r.userAgent??"unknown",platform:"frontgate-js-sdk",version:Gt.version,package:Gt.package,mobile:/Mobi/i.test(r.userAgent??"unknown")}}function Ar(){return typeof navigator<"u"?navigator:typeof process<"u"?{userAgent:`node.js/io.js, ${process.version}`}:{userAgent:"unknown"}}const Nr=r=>{const e=[18,20,9],t=n=>{for(let s=n.length;s>n.length-16;s-=2){let o=parseInt(n.substring(s-2,s),16);o>127&&(o-=256),e.push(o)}};return t(r.traceId),e.push(17),t(r.spanId),e.push(24),e.push(0),e},Sr=async(r,e)=>new Promise((t,n)=>{setTimeout(()=>{n(e)},r)}),Y=async(r,e,t)=>Promise.race([Sr(r,e),t]),qt=r=>r+Math.random()*100,Lt=6e3,X=class X{constructor(){this.headerMembers={dataset:{id_dataset:0},id_job:0,flags_r2:0,resend_counter:0,timeout:Lt,authentication_identifiers:{id_application:0,id_user:0},cache_key:{value:[]},previous_response_hash:{value:[]},tracing:{value:{value:[]}}},this.flags=[]}getPtlMessage(){return this.headerMembers}getQuality(){return Object.keys(X.PRICE_QUALITY).find(t=>X.PRICE_QUALITY[t]===this.headerMembers.dataset.id_dataset)}setQuality(e){this.headerMembers.dataset.id_dataset=X.PRICE_QUALITY[e]}setIdApplication(e,t=!1){(this.headerMembers.authentication_identifiers.id_application===0||t)&&(this.headerMembers.authentication_identifiers.id_application=e)}setIdUser(e,t=!1){(this.headerMembers.authentication_identifiers.id_user===0||t)&&(this.headerMembers.authentication_identifiers.id_user=e)}setFlag(e,t=!0){const n=this.flags.indexOf(e);t&&n===-1&&this.flags.push(e),!t&&n>-1&&this.flags.splice(n,1),this.headerMembers.flags_r2=this.getFlagsValue()}getFlagsValue(){return this.flags.reduce((e,t)=>e+X.FLAG_VALUE[t],0)}isFlagValueSet(e){return this.flags.find(t=>t===e)!==void 0}setJobId(e){this.headerMembers.id_job=e}getJobId(){return this.headerMembers.id_job}countResend(){this.headerMembers.resend_counter++}getResendCounter(){return this.headerMembers.resend_counter}setTimeout(e){if(e>0){this.headerMembers.timeout=e;return}throw new Error(`Attempted to set the timeout to "${e}". The timeout must be greater than 0.`)}getTimeout(){return this.headerMembers.timeout}setTracing(e){/^0+$/.test(e.traceId)||(this.headerMembers.tracing.value.value=Nr(e))}static getDataSet(e){return Object.prototype.hasOwnProperty.call(X.PRICE_QUALITY,e)?X.PRICE_QUALITY[e]:X.PRICE_QUALITY.DLY}};X.PRICE_QUALITY={RLT:129,DLY:0,EOD:130},X.FLAG_VALUE={add_subscription:1,no_merge:2,support_caching:4,permission_denied_response:8,internal_client:16,current_state_refresh:32,subscription_use_pull_permissions:64,allow_chunked_response:128};let Ge=X;class me{constructor(e,t){this.header=new Ge,this.coreMembers={Message:e,Version:t},this.members={}}getPtlMessage(){const e={header:this.header.getPtlMessage()};return Ir(this.coreMembers,e,this.members)}}class qe{constructor(e,t){this.token=e,this.maximumIdleInterval=t}toJson(){const e=Rr();return{Message:"AuthenticationByTokenRequest",Version:1,token:{value:this.token},software:JSON.stringify(e),os:e.platform,feature_flags_wanted:{value:0},maximum_idle_interval:this.maximumIdleInterval,maximum_receivable_message_size:1048576,flags:0,cache_authentication_salt:{value:[]},cache_authentication_encrypted_secret:{encrypted_secret:[]}}}}const Z=class Z extends me{constructor(e,t,n,s,o=!1){super(Z.NAME,Z.VERSION),t&&this.header.setIdUser(t),n&&this.header.setIdApplication(n),s&&this.header.setTimeout(s),this.members.flags=o?Z.FLAG_SINGLE_USAGE:0,this.members.lifetime_seconds_r2=e??Z.LIFETIME_SECONDS_DEFAULT,this.header.setFlag("no_merge")}};Z.NAME="AuthenticationTokenRequest",Z.VERSION=6,Z.LIFETIME_SECONDS_DEFAULT=-1,Z.LIFETIME_SECONDS_MAXIMUM=-2,Z.FLAG_SINGLE_USAGE=1;let Le=Z;const ke=class ke extends me{constructor(e){super(ke.NAME,ke.VERSION),this.members.id_job_subscription=e}};ke.NAME="CancelSubscriptionRequest",ke.VERSION=6;let le=ke;const ee=class ee extends me{constructor(e,t,n={},s){super(ee.NAME,ee.VERSION),this.members.accept="application/json",this.members.content_type="application/json",this.members.body={value:[]},this.members.query="",this.members.path=t,this.setMethod(e),Object.keys(n).length>0&&(e==="POST"?this.setBody(n):this.setQuery(n)),s&&this.setOptions(s)}setOptions(e){Object.hasOwnProperty.call(e,"accept")&&(this.members.accept=e.accept),Object.hasOwnProperty.call(e,"content_type")&&(this.members.content_type=e.content_type),Object.hasOwnProperty.call(e,"subscribe")&&e.subscribe&&this.header.setFlag("add_subscription"),Object.hasOwnProperty.call(e,"no_merge")&&e.no_merge&&this.header.setFlag("no_merge"),Object.hasOwnProperty.call(e,"allowChunkedResponse")&&e.allowChunkedResponse&&this.header.setFlag("allow_chunked_response"),Object.hasOwnProperty.call(e,"idApplication")&&e.idApplication&&this.header.setIdApplication(e.idApplication),Object.hasOwnProperty.call(e,"idUser")&&e.idUser&&this.header.setIdUser(e.idUser)}setMethod(e){const t=e==="POST"?ee.METHOD.POST:ee.METHOD.GET;this.members.method={value:t}}setBody(e={}){e instanceof Array?this.members.body={value:e}:this.members.body={value:JSON.stringify(e)}}getData(){return this.members.method.value===ee.METHOD.POST?ee.ptlToJsonData(this.members.body.value):this.members.query}setQuery(e={}){this.members.query=Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}static ptlToJsonData(e){if(typeof e=="string")return JSON.parse(e);if(e instanceof Array&&e.length>0){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),JSON.parse(t)}}};ee.NAME="HighLevelRequest",ee.VERSION=3,ee.METHOD={GET:1,POST:2};let ye=ee;const V=class V extends me{constructor(e,t,n){super(V.NAME,V.VERSION),this.members.request={headers:{values:[{key:"accept",value:"application/json"},{key:"content-type",value:"application/json"}]},protocol:{value:V.PROTOCOL.HTTPS},host:"",port:0,path:t,query:"",body:{value:[]}},this.setQuery(),this.setMethod(e),n&&this.setOptions(n)}setOptions(e){e.no_merge&&this.header.setFlag("no_merge"),e.idApplication&&this.header.setIdApplication(e.idApplication),e.idUser&&this.header.setIdUser(e.idUser),e.protocol&&(this.members.request.protocol=e.protocol.toUpperCase()==="HTTP"?{value:V.PROTOCOL.HTTP}:{value:V.PROTOCOL.HTTPS}),e.method&&(this.members.request.method={value:V.METHOD[e.method]}),e.host&&(this.members.request.host=e.host),e.port&&(this.members.request.port=e.port),e.path&&(this.members.request.path=e.path),e.query&&(this.members.request.query=typeof e.query=="string"?e.query:Object.keys(e.query).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e.query[t])}`).join("&")),e.body&&this.setBody(e.body),e.headers&&this.setHeaders(e.headers)}setHeaders(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const n=e[t],s=this.members.request.headers.values.findIndex(i=>i.key===t);s!==-1&&this.members.request.headers.values.splice(s,1),this.members.request.headers.values.push({key:t,value:n})}}setQuery(){if(this.members.request.path.includes("?")){const e=this.members.request.path.split("?");this.members.request.path=e[0],this.members.request.query=e[1]}}setMethod(e){this.members.request.method={value:V.METHOD[e]}}setBody(e={}){return e instanceof Array||typeof e=="string"?this.members.request.body={value:e}:this.members.request.body={value:JSON.stringify(e)},this}getData(){if(this.members.request.body?.value)return ye.ptlToJsonData(this.members.request.body.value)}};V.NAME="HTTPProxyRequest",V.VERSION=2,V.PROTOCOL={HTTP:1,HTTPS:2},V.METHOD={GET:1,POST:2,OPTIONS:3,HEAD:4,PUT:5,DELETE:6,TRACE:7,CONNECT:8};let Be=V;const _e=class _e{constructor(){this._timeAtSender=Date.now()}getPtlMessage(){return{Message:_e.NAME,Version:_e.VERSION,time_at_sender:{microseconds:this._timeAtSender*1e3}}}resetTimeAtSender(){this._timeAtSender=Date.now()}get timeAtSender(){return this._timeAtSender}};_e.NAME="PingRequest",_e.VERSION=3;let Ve=_e;class Bt extends me{constructor(e){super(e.Message,e.version?e.version:e.Version),this._extractRequestAttributes(e)}_extractRequestAttributes(e){for(const t of Object.keys(this.coreMembers))delete e[t];this.members=xt(this.members,e)}}class fe{constructor(e){this.raw=e}get msg(){return this.raw}get name(){return this.raw.Message}get jobId(){return this.raw.header.id_job}get serviceId(){return this.raw.header.id_service}isUpdateMessage(){return Object.hasOwnProperty.call(this.raw,"header")&&(Object.hasOwnProperty.call(this.raw.header,"id_service")||Object.hasOwnProperty.call(this.raw.header,"id_job"))&&this.raw.Message.endsWith("Update")}isLossMessage(){return Object.hasOwnProperty.call(this.raw,"header")&&(Object.hasOwnProperty.call(this.raw.header,"id_service")||Object.hasOwnProperty.call(this.raw.header,"id_job"))&&(this.raw.Message.endsWith("LossMessage")||this.raw.Message.endsWith("Loss"))}}class Vt extends fe{constructor(e){if(super(e),!this.raw.token.value.b64)throw new Error("Token not set in AuthenticationTokenResponse");if(!this.raw.expiry.microseconds)throw new Error("Expiry not set in AuthenticationTokenResponse");this.token=this.raw.token.value.b64,this.expiry=parseInt(He(this.raw.expiry.microseconds),10)}getToken(){return this.token}getExpiry(){return this.expiry}}class z extends fe{get reason(){return this.raw.details}get jobId(){return this.raw.id_job}}class Wt extends fe{constructor(e){super(e);try{this.responseData=JSON.parse(this.raw.body.value)}catch(t){throw new Error(`Could not parse HighLevelResponse: ${t.message}`)}}get data(){return this.responseData.data}get meta(){return this.responseData.meta}get status(){return this.meta.status}get statusCode(){return this.status.code}}class Jt extends fe{constructor(e){super(e);try{const t=this.raw.response.body.value,n=t.substr(0,1)==="{";this.responseData=n?JSON.parse(t):t}catch(t){throw new Error(`Could not parse HTTPProxyResponse: ${t}`)}this.responseInfo=this.raw.info,this.statusReason=this.raw.response.status_reason,this.statusCode=this.raw.response.status_code.value}get data(){return this.responseData}get meta(){return this.responseData.meta}get status(){return{code:this.statusCode,reason:this.statusReason}}}const Me=class Me{constructor(e){if(e.Message!==Me.NAME)throw new Error(`Unsupported message=${e.Message}`);if(e.Version!==Me.VERSION)throw new Error(`Unsupported version=${e.Version} for message=${e.Message}`);this._timeReceivedResponse=Date.now(),this._timeAtSender=Number(He(e.time_at_sender.microseconds)),this._timeFromRequest=Number(He(e.time_from_request.microseconds))}get timeAtPeer(){return this._timeAtSender}get timeOfRequest(){return this._timeFromRequest}get timeOfResponse(){return this._timeReceivedResponse}get latencyTotal(){return this._timeReceivedResponse-this._timeFromRequest}get latencyAtPeer(){return this._timeAtSender-this._timeFromRequest}};Me.NAME="Foundation::PingResponse",Me.VERSION=2;let We=Me;class tt extends fe{constructor(e){if(super(e),typeof this.raw.body.value!="string")throw new Error("Incorrect response type in HighLevelUpdate");try{this.responseData=JSON.parse(this.raw.body.value)}catch(t){throw new Error(`Could not parse HighLevelUpdate: ${t.message}`)}}get data(){return this.responseData}}const rt=8;var d=(r=>(r[r.TRACE=10]="TRACE",r[r.DEBUG=20]="DEBUG",r[r.INFO=30]="INFO",r[r.WARN=40]="WARN",r[r.ERROR=50]="ERROR",r[r.FATAL=60]="FATAL",r[r.SILENT=100]="SILENT",r))(d||{});const ue=class ue{constructor(e=""){this.defaultLevel=40,this.noop=()=>null,this.name=e,this.setDefaultLevelFromLocalStorage(),Object.assign(ue.loggers,{[e]:this})}getName(){return this.name}setLevel(e){this.level=e}getLevel(){return typeof this.level=="number"&&isFinite(this.level)&&Math.floor(this.level)===this.level?this.level:this.defaultLevel}shouldLog(e){switch(this.getLevel()){case 100:return!1;case 60:return e==="fatal";case 50:return e==="fatal"||e==="error";case 40:return e==="fatal"||e==="error"||e==="warn";case 30:return e==="fatal"||e==="error"||e==="warn"||e==="info";case 20:return e==="fatal"||e==="error"||e==="warn"||e==="info"||e==="debug";case 10:default:return!0}}setDefaultLevelFromLocalStorage(){let e;try{if(!(typeof localStorage=="object"))return;const n=localStorage.getItem("loglevel");if(!n)return;e=n}catch{return}e&&this.setLevel(ue.getLogLevel(e))}static getLogLevel(e){const t=e.toLowerCase();switch(t){case"silent":return 100;case"fatal":return 60;case"error":return 50;case"warn":return 40;case"info":return 30;case"debug":return 20;case"trace":return 10;default:throw new Error(`Invalid log level: ${t}`)}}static getLogger(e,t){if(Object.prototype.hasOwnProperty.call(ue.loggers,e))return ue.loggers[e];const n=new t(e);return ue.loggers[e]=n,n}};ue.loggers={};let ie=ue;class Pr{static getLogLevel(e){const t=e.toLowerCase();switch(t){case"silent":return d.SILENT;case"fatal":return d.FATAL;case"error":return d.ERROR;case"warn":return d.WARN;case"info":return d.INFO;case"debug":return d.DEBUG;case"trace":return d.TRACE;default:throw new Error(`Invalid log level: ${t}`)}}}class nt extends ie{constructor(){super(...arguments),this.trace=this.getLogMethod("trace"),this.debug=this.getLogMethod("debug"),this.info=this.getLogMethod("info"),this.warn=this.getLogMethod("warn"),this.error=this.getLogMethod("error"),this.fatal=this.getLogMethod("fatal")}setLevel(e){this.level=e,this.trace=this.getLogMethod("trace"),this.debug=this.getLogMethod("debug"),this.info=this.getLogMethod("info"),this.warn=this.getLogMethod("warn"),this.error=this.getLogMethod("error"),this.fatal=this.getLogMethod("fatal")}getLogMethod(e){if(this.shouldLog(e)){const t=e==="debug"||e==="fatal"?"log":e,n=this.name?`${this.name}: [${e.toUpperCase()}] `:`-----> [${e.toUpperCase()}] `;return Function.prototype.bind.call(console[t],console,n)}return this.noop}static getLogger(e=""){return super.getLogger(e,nt)}}const xr={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};class Fr extends ie{constructor(e,t=""){super(t),this.name=t,this.logger=e,this.trace=Function.prototype.bind.call(e.trace,e),this.debug=Function.prototype.bind.call(e.debug,e),this.info=Function.prototype.bind.call(e.info,e),this.warn=Function.prototype.bind.call(e.warn,e),this.error=Function.prototype.bind.call(e.error,e),this.fatal=Function.prototype.bind.call(e.error,e)}setLevel(e){this.level=e,this.logger&&(this.logger.level=d[e].toLowerCase())}static getLogger(e=""){return Object.prototype.hasOwnProperty.call(ie.loggers,e)?ie.loggers[e]:null}}class st extends ie{constructor(){super(...arguments),this.trace=this.noop,this.debug=this.noop,this.info=this.noop,this.warn=this.noop,this.error=this.noop}static getLogger(e=""){return super.getLogger(e,st)}}const $r=()=>H(e=>class extends e{async requestAuthenticationToken(t=30,n=0,s=0,o=this.defaultTimeoutInMs){const c={message:new Le(t,n,s,o).getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",c);const a=new Promise((u,h)=>{this.hooks.hookOnce(`frontgateConnection:response:${c.callbackId}`,v=>{if(!v.Message.includes("AuthenticationTokenResponse")){h(JSON.stringify(v));return}const w=new Vt(v);u({token:w.getToken(),expiry:w.getExpiry()})})}),f=`Request timeout reached (${o} ms) for ${c.message.Message}`;return Y(o,f,a)}async requestAuthenticationTokenForCookieTokenAuthentication(t=30,n=0,s=0,o=this.defaultTimeoutInMs){const i=await this.requestAuthenticationToken(t,n,s,o);return new Ft(i.token)}},{featureName:"AuthTokenRequest",featureGroups:["Misc"]}),Ur=r=>H(t=>class extends t{async requestEndpoint(n,s,o,i,c=this.defaultTimeoutInMs){const a=new ye(n,s,o,{...i,allowChunkedResponse:!r?.disableChunkedResponse});a.header.setTimeout(c),r?.allowPermissionDeniedResponse&&a.header.setFlag("permission_denied_response");const f={message:a.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",f);const u=new Promise((v,w)=>{const M=[],E=()=>{this.hooks.hookOnce(`frontgateConnection:response:${f.callbackId}`,k=>{try{if(!k.Message.includes("HighLevelResponse")){w(JSON.stringify(k));return}if(this.#e(k))M.push({body:k.body?.value??"",processingTime:k.header?.processingTime??0}),E();else{M.push({body:k.body?.value??"",processingTime:k.header?.processingTime??0});const l=new Wt({...k,body:{value:M.map(g=>g.body).join("")},header:{...k.header,processingTime:M.reduce((g,p)=>g+p.processingTime,0)}});v({response:l,data:l.data})}}catch(l){w(l)}})};E()}),h=`Request timeout reached (${c} ms) for ${f.message.Message}`;return Y(c,h,u)}#e(n){return((n.header?.flags??0)&rt)===rt}},{featureName:"EndpointRequest",featureGroups:["Misc"]});var we=null;typeof WebSocket<"u"?we=WebSocket:typeof MozWebSocket<"u"?we=MozWebSocket:typeof global<"u"?we=global.WebSocket||global.MozWebSocket:typeof window<"u"?we=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(we=self.WebSocket||self.MozWebSocket);const zt=we,Kt=r=>H(t=>class extends t{#e;#t;#r="disconnected";#n;#s=0;#i;#a;get#o(){return this.#e&&this.#e.readyState<2?this.#r:"disconnected"}#c;#u=[];set conf(n){const s=this.#b(n);this.#c=s.messageBufferSize,this.#t=s}constructor(...n){super(...n),this.#i=he,this.#a=$t,r&&(this.conf=r),this.hooks.hook("frontgateConnection:setIdApp",s=>{this.#i=s}),this.hooks.hook("frontgateConnection:setIdUser",s=>{this.#a=s}),this.hooks.hook("frontgateConnection:sendMessage",s=>{if(s.callbackType==="job"){const o=this.#p(s.message);s.callbackId=`${o}`,this.#f(s.message)}if(this.#o==="connected"&&s.callbackType==="response")this.#h(s.message);else if(this.#o==="authenticated")this.#h(s.message);else{if(this.#u.length>=this.#c)throw new Error("Message buffer is full");this.#u.push(s)}}),this.hooks.hook("frontgateConnection:authenticated",()=>{if(!this.#t)throw new Error("No connection configuration set");for(this.log(d.DEBUG,"Draining message buffer");this.#u.length>0;){const s=this.#u.shift();s&&(this.#f(s.message),this.#h(s.message))}this.#n=setInterval(()=>{this.log(d.DEBUG,"Sending keepalive"),this.hooks.callHook("frontgateConnection:sendMessage",{message:this.#g(),callbackType:"response",callbackId:"KeepAliveMessage"})},this.#t.maximumIdleIntervalInS/2*1e3)}),this.hooks.hook("reconnect:attempt",async()=>{clearInterval(this.#n),this.log(d.DEBUG,"Reconnecting"),await this.hooks.callHook("frontgateConnection:reset");try{await this.connect(),await this.hooks.callHook("reconnect:success")}catch(s){this.log(d.ERROR,"Reconnect failed",s),await this.hooks.callHook("reconnect:failed",s)}})}async connect(){if(!this.#t)throw new Error("No connection configuration set");if(this.#o!=="disconnected")throw new Error("Client is already connected or is connecting right now");const{host:n,port:s,tls:o,pathPrefix:i}=this.#t;this.#r="connecting";const a=`${o?"wss":"ws"}://${n}:${s}${i??""}/ws`,f={encoding:"jsjson-v2"};await this.hooks.callHook("frontgateConnection:afterSetEncoding",f);const[u,h]=f.encoding.split("-"),w=[`${h?`${h}.`:""}ws-${u}.mdgms.com`],M={url:a,subProtocols:w};try{await this.hooks.callHook("frontgateConnection:beforeConnect",M)}catch(l){throw this.#r="disconnected",l}this.log(d.DEBUG,`Connecting to ${M.url} with subprotocols ${M.subProtocols}`);const E=new Promise((l,g)=>{if(!this.#t)throw new Error("No connection configuration set");this.#t.wsClientOptions&&typeof window>"u"?this.#e=new zt(M.url,M.subProtocols,this.#t.wsClientOptions):this.#e=new zt(M.url,M.subProtocols),this.#e.binaryType="arraybuffer";let p;this.#e.onopen=()=>{this.#r="connected",this.log(d.DEBUG,"Connected"),this.hooks.callHook("frontgateConnection:connected",this.#t).catch(g),p=this.hooks.hookOnce("frontgateConnection:authenticated",()=>{this.#r="authenticated",this.log(d.DEBUG,"Authenticated"),l()})},this.#e.onclose=y=>{p?.(),this.log(d.DEBUG,"Disconnected",y),this.#r==="connecting"||this.#r==="connected"?g(JSON.stringify(y)):this.hooks.callHook("frontgateConnection:disconnected",y),clearInterval(this.#n),this.#r="disconnected"},this.#e.onerror=y=>{p?.(),this.log(d.ERROR,"Error:",y),this.hooks.callHook("frontgateConnection:error",y),(this.#r==="connecting"||this.#r==="connected")&&g(new Error("Websocket error")),clearInterval(this.#n),this.#r="disconnected"},this.#e.onmessage=y=>{const{data:_}=y;this.log(d.DEBUG,"Received data:",_);const I={msg:_};this.hooks.callHook("frontgateConnection:afterReceiveMessage",I).then(()=>{this.log(d.DEBUG,"Received message",I.msg);const N=I.msg.toString("utf-8"),T=JSON.parse(N);if(this.hooks.callHook("frontgateConnection:message",T),T.Message==="Foundation::DisconnectionMessage"){this.#e?.close(),this.hooks.callHook("frontgateConnection:disconnected",T);return}this.#l(T)})}}),k=`Timeout reached (${this.defaultTimeoutInMs} ms) for connection to ${a}`;return Y(this.defaultTimeoutInMs,k,E)}async disconnect(){return new Promise(n=>{this.#h(this.#d()),this.hooks.hookOnce("frontgateConnection:disconnected",()=>{this.#e?.close(),n()})})}#d(){return{Message:"Foundation::DisconnectionMessage",Version:3,reason:{value:64},details:"client shutdown"}}#g(){return{Message:"KeepAliveMessage",Version:2}}async#h(n){await this.hooks.callHook("frontgateConnection:beforeSerializeMessage",n);const s={msg:JSON.stringify(n)};await this.hooks.callHook("frontgateConnection:beforeSendMessage",s),this.log(d.DEBUG,"Sending message:",n),this.log(d.TRACE,"Sending data:",s.msg);try{this.#e?.send(s.msg)}catch(o){const i=this.#v(o,n);this.#l(i.msg)}}#l(n){if(typeof n.header?.id_job<"u"){this.hooks.callHook(`frontgateConnection:response:${n.header.id_job}`,n);return}if(typeof n.header?.id_service<"u"&&typeof n.id_notation<"u"){this.hooks.callHook(`frontgateConnection:response:${n.header.id_service}-${n.id_notation}`,n);return}if(typeof n.id_job<"u"){this.hooks.callHook(`frontgateConnection:response:${n.id_job}`,n);return}typeof n.Message=="string"&&this.hooks.callHook(`frontgateConnection:response:${n.Message.replace("Foundation::","")}`,n)}#p(n){this.#s+=1;const s=this.#s;return n.header={...n.header,id_job:s},this.#s}#f(n){n.header||(n.header={authentication_identifiers:{id_application:void 0,id_user:void 0}}),n.header.authentication_identifiers||(n.header={...n.header,authentication_identifiers:{id_application:void 0,id_user:void 0}}),n.header.authentication_identifiers.id_application||=this.#i,n.header.authentication_identifiers.id_user||=this.#a}#v(n,s){return new z({Message:"Foundation::ErrorResponse",Version:1,id_job:s.header?.id_job,reason:8,details:n})}#b(n){const s=n.maximumIdleIntervalInS??60,o=n.maximumIdleInterval??s*1e6;return{...n,payloadContent:n.payloadContent??"foundation",maximumIdleIntervalInS:s,maximumIdleInterval:o,tls:n.tls??!0,messageBufferSize:n.messageBufferSize??512}}isConnected(){return this.#o==="authenticated"}isDisconnected(){return this.#r!=="authenticated"}isReadyToConnect(){return this.#o==="disconnected"}},{featureName:"WSConnection",disabledFeatureGroups:["Connection"]}),Dr=(r,e)=>(e&&r.setLevel(e),H(n=>class extends n{constructor(...s){super(...s),this.logger=r}},{featureName:"Logger",featureGroups:["Misc"]}));var P=Uint8Array,L=Uint16Array,ot=Int32Array,Je=new P([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ze=new P([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),it=new P([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yt=function(r,e){for(var t=new L(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var s=new ot(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)s[o]=o-t[n]<<5|n;return{b:t,r:s}},Qt=Yt(Je,2),Xt=Qt.b,at=Qt.r;Xt[28]=258,at[258]=28;for(var Zt=Yt(ze,0),jr=Zt.b,er=Zt.r,ct=new L(32768),A=0;A<32768;++A){var ae=(A&43690)>>1|(A&21845)<<1;ae=(ae&52428)>>2|(ae&13107)<<2,ae=(ae&61680)>>4|(ae&3855)<<4,ct[A]=((ae&65280)>>8|(ae&255)<<8)>>1}for(var te=(function(r,e,t){for(var n=r.length,s=0,o=new L(e);s<n;++s)r[s]&&++o[r[s]-1];var i=new L(e);for(s=1;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;var c;if(t){c=new L(1<<e);var a=15-e;for(s=0;s<n;++s)if(r[s])for(var f=s<<4|r[s],u=e-r[s],h=i[r[s]-1]++<<u,v=h|(1<<u)-1;h<=v;++h)c[ct[h]>>a]=f}else for(c=new L(n),s=0;s<n;++s)r[s]&&(c[s]=ct[i[r[s]-1]++]>>15-r[s]);return c}),ce=new P(288),A=0;A<144;++A)ce[A]=8;for(var A=144;A<256;++A)ce[A]=9;for(var A=256;A<280;++A)ce[A]=7;for(var A=280;A<288;++A)ce[A]=8;for(var Ce=new P(32),A=0;A<32;++A)Ce[A]=5;var Hr=te(ce,9,0),Gr=te(ce,9,1),qr=te(Ce,5,0),Lr=te(Ce,5,1),ut=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Q=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},ht=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},lt=function(r){return(r+7)/8|0},de=function(r,e,t){return(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new P(r.subarray(e,t))},Br=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],F=function(r,e,t){var n=new Error(e||Br[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,F),!t)throw n;return n},Vr=function(r,e,t,n){var s=r.length,o=0;if(!s||e.f&&!e.l)return t||new P(0);var i=!t,c=i||e.i!=2,a=e.i;i&&(t=new P(s*3));var f=function(De){var je=t.length;if(De>je){var Ie=new P(Math.max(je*2,De));Ie.set(t),t=Ie}},u=e.f||0,h=e.p||0,v=e.b||0,w=e.l,M=e.d,E=e.m,k=e.n,l=s*8;do{if(!w){u=Q(r,h,1);var g=Q(r,h+1,3);if(h+=3,g)if(g==1)w=Gr,M=Lr,E=9,k=5;else if(g==2){var I=Q(r,h,31)+257,N=Q(r,h+10,15)+4,T=I+Q(r,h+5,31)+1;h+=14;for(var m=new P(T),O=new P(19),C=0;C<N;++C)O[it[C]]=Q(r,h+C*3,7);h+=N*3;for(var R=ut(O),U=(1<<R)-1,q=te(O,R,1),C=0;C<T;){var $=q[Q(r,h,U)];h+=$&15;var p=$>>4;if(p<16)m[C++]=p;else{var D=0,S=0;for(p==16?(S=3+Q(r,h,3),h+=2,D=m[C-1]):p==17?(S=3+Q(r,h,7),h+=3):p==18&&(S=11+Q(r,h,127),h+=7);S--;)m[C++]=D}}var j=m.subarray(0,I),G=m.subarray(I);E=ut(j),k=ut(G),w=te(j,E,1),M=te(G,k,1)}else F(1);else{var p=lt(h)+4,y=r[p-4]|r[p-3]<<8,_=p+y;if(_>s){a&&F(0);break}c&&f(v+y),t.set(r.subarray(p,_),v),e.b=v+=y,e.p=h=_*8,e.f=u;continue}if(h>l){a&&F(0);break}}c&&f(v+131072);for(var Ue=(1<<E)-1,K=(1<<k)-1,oe=h;;oe=h){var D=w[ht(r,h)&Ue],W=D>>4;if(h+=D&15,h>l){a&&F(0);break}if(D||F(2),W<256)t[v++]=W;else if(W==256){oe=h,w=null;break}else{var J=W-254;if(W>264){var C=W-257,x=Je[C];J=Q(r,h,(1<<x)-1)+Xt[C],h+=x}var ne=M[ht(r,h)&K],Ee=ne>>4;ne||F(3),h+=ne&15;var G=jr[Ee];if(Ee>3){var x=ze[Ee];G+=ht(r,h)&(1<<x)-1,h+=x}if(h>l){a&&F(0);break}c&&f(v+131072);var Te=v+J;if(v<G){var Xe=o-G,Ze=Math.min(G,Te);for(Xe+v<0&&F(3);v<Ze;++v)t[v]=n[Xe+v]}for(;v<Te;++v)t[v]=t[v-G]}}e.l=w,e.p=oe,e.b=v,e.f=u,w&&(u=1,e.m=E,e.d=M,e.n=k)}while(!u);return v!=t.length&&i?de(t,0,v):t.subarray(0,v)},se=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8},Re=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},ft=function(r,e){for(var t=[],n=0;n<r.length;++n)r[n]&&t.push({s:n,f:r[n]});var s=t.length,o=t.slice();if(!s)return{t:sr,l:0};if(s==1){var i=new P(t[0].s+1);return i[t[0].s]=1,{t:i,l:1}}t.sort(function(_,I){return _.f-I.f}),t.push({s:-1,f:25001});var c=t[0],a=t[1],f=0,u=1,h=2;for(t[0]={s:-1,f:c.f+a.f,l:c,r:a};u!=s-1;)c=t[t[f].f<t[h].f?f++:h++],a=t[f!=u&&t[f].f<t[h].f?f++:h++],t[u++]={s:-1,f:c.f+a.f,l:c,r:a};for(var v=o[0].s,n=1;n<s;++n)o[n].s>v&&(v=o[n].s);var w=new L(v+1),M=dt(t[u-1],w,0);if(M>e){var n=0,E=0,k=M-e,l=1<<k;for(o.sort(function(I,N){return w[N.s]-w[I.s]||I.f-N.f});n<s;++n){var g=o[n].s;if(w[g]>e)E+=l-(1<<M-w[g]),w[g]=e;else break}for(E>>=k;E>0;){var p=o[n].s;w[p]<e?E-=1<<e-w[p]++-1:++n}for(;n>=0&&E;--n){var y=o[n].s;w[y]==e&&(--w[y],++E)}M=e}return{t:new P(w),l:M}},dt=function(r,e,t){return r.s==-1?Math.max(dt(r.l,e,t+1),dt(r.r,e,t+1)):e[r.s]=t},tr=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new L(++e),n=0,s=r[0],o=1,i=function(a){t[n++]=a},c=1;c<=e;++c)if(r[c]==s&&c!=e)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=r[c]}return{c:t.subarray(0,n),n:e}},Ae=function(r,e){for(var t=0,n=0;n<e.length;++n)t+=r[n]*e[n];return t},rr=function(r,e,t){var n=t.length,s=lt(e+2);r[s]=n&255,r[s+1]=n>>8,r[s+2]=r[s]^255,r[s+3]=r[s+1]^255;for(var o=0;o<n;++o)r[s+o+4]=t[o];return(s+4+n)*8},nr=function(r,e,t,n,s,o,i,c,a,f,u){se(e,u++,t),++s[256];for(var h=ft(s,15),v=h.t,w=h.l,M=ft(o,15),E=M.t,k=M.l,l=tr(v),g=l.c,p=l.n,y=tr(E),_=y.c,I=y.n,N=new L(19),T=0;T<g.length;++T)++N[g[T]&31];for(var T=0;T<_.length;++T)++N[_[T]&31];for(var m=ft(N,7),O=m.t,C=m.l,R=19;R>4&&!O[it[R-1]];--R);var U=f+5<<3,q=Ae(s,ce)+Ae(o,Ce)+i,$=Ae(s,v)+Ae(o,E)+i+14+3*R+Ae(N,O)+2*N[16]+3*N[17]+7*N[18];if(a>=0&&U<=q&&U<=$)return rr(e,u,r.subarray(a,a+f));var D,S,j,G;if(se(e,u,1+($<q)),u+=2,$<q){D=te(v,w,0),S=v,j=te(E,k,0),G=E;var Ue=te(O,C,0);se(e,u,p-257),se(e,u+5,I-1),se(e,u+10,R-4),u+=14;for(var T=0;T<R;++T)se(e,u+3*T,O[it[T]]);u+=3*R;for(var K=[g,_],oe=0;oe<2;++oe)for(var W=K[oe],T=0;T<W.length;++T){var J=W[T]&31;se(e,u,Ue[J]),u+=O[J],J>15&&(se(e,u,W[T]>>5&127),u+=W[T]>>12)}}else D=Hr,S=ce,j=qr,G=Ce;for(var T=0;T<c;++T){var x=n[T];if(x>255){var J=x>>18&31;Re(e,u,D[J+257]),u+=S[J+257],J>7&&(se(e,u,x>>23&31),u+=Je[J]);var ne=x&31;Re(e,u,j[ne]),u+=G[ne],ne>3&&(Re(e,u,x>>5&8191),u+=ze[ne])}else Re(e,u,D[x]),u+=S[x]}return Re(e,u,D[256]),u+S[256]},Wr=new ot([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),sr=new P(0),Jr=function(r,e,t,n,s,o){var i=o.z||r.length,c=new P(n+i+5*(1+Math.ceil(i/7e3))+s),a=c.subarray(n,c.length-s),f=o.l,u=(o.r||0)&7;if(e){u&&(a[0]=o.r>>3);for(var h=Wr[e-1],v=h>>13,w=h&8191,M=(1<<t)-1,E=o.p||new L(32768),k=o.h||new L(M+1),l=Math.ceil(t/3),g=2*l,p=function(St){return(r[St]^r[St+1]<<l^r[St+2]<<g)&M},y=new ot(25e3),_=new L(288),I=new L(32),N=0,T=0,m=o.i||0,O=0,C=o.w||0,R=0;m+2<i;++m){var U=p(m),q=m&32767,$=k[U];if(E[q]=$,k[U]=q,C<=m){var D=i-m;if((N>7e3||O>24576)&&(D>423||!f)){u=nr(r,a,0,y,_,I,T,O,R,m-R,u),O=N=T=0,R=m;for(var S=0;S<286;++S)_[S]=0;for(var S=0;S<30;++S)I[S]=0}var j=2,G=0,Ue=w,K=q-$&32767;if(D>2&&U==p(m-K))for(var oe=Math.min(v,D)-1,W=Math.min(32767,m),J=Math.min(258,D);K<=W&&--Ue&&q!=$;){if(r[m+j]==r[m+j-K]){for(var x=0;x<J&&r[m+x]==r[m+x-K];++x);if(x>j){if(j=x,G=K,x>oe)break;for(var ne=Math.min(K,x-2),Ee=0,S=0;S<ne;++S){var Te=m-K+S&32767,Xe=E[Te],Ze=Te-Xe&32767;Ze>Ee&&(Ee=Ze,$=Te)}}}q=$,$=E[q],K+=q-$&32767}if(G){y[O++]=268435456|at[j]<<18|er[G];var De=at[j]&31,je=er[G]&31;T+=Je[De]+ze[je],++_[257+De],++I[je],C=m+j,++N}else y[O++]=r[m],++_[r[m]]}}for(m=Math.max(m,C);m<i;++m)y[O++]=r[m],++_[r[m]];u=nr(r,a,f,y,_,I,T,O,R,m-R,u),f||(o.r=u&7|a[u/8|0]<<3,u-=7,o.h=k,o.p=E,o.i=m,o.w=C)}else{for(var m=o.w||0;m<i+f;m+=65535){var Ie=m+65535;Ie>=i&&(a[u/8|0]=f,Ie=i),u=rr(a,u+1,r.subarray(m,Ie))}o.i=i}return de(c,0,n+lt(u)+s)},or=function(){var r=1,e=0;return{p:function(t){for(var n=r,s=e,o=t.length|0,i=0;i!=o;){for(var c=Math.min(i+2655,o);i<c;++i)s+=n+=t[i];n=(n&65535)+15*(n>>16),s=(s&65535)+15*(s>>16)}r=n,e=s},d:function(){return r%=65521,e%=65521,(r&255)<<24|(r&65280)<<8|(e&255)<<8|e>>8}}},ir=function(r,e,t,n,s){if(!s&&(s={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),i=new P(o.length+r.length);i.set(o),i.set(r,o.length),r=i,s.w=o.length}return Jr(r,e.level==null?6:e.level,e.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,n,s)},ar=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},zr=function(r,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;if(r[0]=120,r[1]=n<<6|(e.dictionary&&32),r[1]|=31-(r[0]<<8|r[1])%31,e.dictionary){var s=or();s.p(e.dictionary),ar(r,2,s.d())}},Kr=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&F(6,"invalid zlib data"),(r[1]>>5&1)==+!e&&F(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2},gt=(function(){function r(e,t){if(typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new P(98304),this.o.dictionary){var n=this.o.dictionary.subarray(-32768);this.b.set(n,32768-n.length),this.s.i=32768-n.length}}return r.prototype.p=function(e,t){this.ondata(ir(e,this.o,0,0,this.s),t)},r.prototype.push=function(e,t){this.ondata||F(5),this.s.l&&F(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var s=new P(n&-32768);s.set(this.b.subarray(0,this.s.z)),this.b=s}var o=this.b.length-this.s.z;this.b.set(e.subarray(0,o),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(o),32768),this.s.z=e.length-o+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=t&1,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},r.prototype.flush=function(){this.ondata||F(5),this.s.l&&F(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},r})(),pt=(function(){function r(e,t){typeof e=="function"&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new P(32768),this.p=new P(0),n&&this.o.set(n)}return r.prototype.e=function(e){if(this.ondata||F(5),this.d&&F(4),!this.p.length)this.p=e;else if(e.length){var t=new P(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},r.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=Vr(this.p,this.s,this.o);this.ondata(de(n,t,this.s.b),this.d),this.o=de(n,this.s.b-32768),this.s.b=this.o.length,this.p=de(this.p,this.s.p/8|0),this.s.p&=7},r.prototype.push=function(e,t){this.e(e),this.c(t)},r})(),Yr=(function(){function r(e,t){this.c=or(),this.v=1,gt.call(this,e,t)}return r.prototype.push=function(e,t){this.c.p(e),gt.prototype.push.call(this,e,t)},r.prototype.p=function(e,t){var n=ir(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(zr(n,this.o),this.v=0),t&&ar(n,n.length-4,this.c.d()),this.ondata(n,t)},r.prototype.flush=function(){gt.prototype.flush.call(this)},r})(),Qr=(function(){function r(e,t){pt.call(this,e,t),this.v=e&&e.dictionary?2:1}return r.prototype.push=function(e,t){if(pt.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(Kr(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&F(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),pt.prototype.c.call(this,t)},r})(),cr=typeof TextEncoder<"u"&&new TextEncoder,vt=typeof TextDecoder<"u"&&new TextDecoder,Xr=0;try{vt.decode(sr,{stream:!0}),Xr=1}catch{}var Zr=function(r){for(var e="",t=0;;){var n=r[t++],s=(n>127)+(n>223)+(n>239);if(t+s>r.length)return{s:e,r:de(r,t-1)};s?s==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):s&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function en(r,e){var t;if(cr)return cr.encode(r);for(var n=r.length,s=new P(r.length+(r.length>>1)),o=0,i=function(f){s[o++]=f},t=0;t<n;++t){if(o+5>s.length){var c=new P(o+8+(n-t<<1));c.set(s),s=c}var a=r.charCodeAt(t);a<128||e?i(a):a<2048?(i(192|a>>6),i(128|a&63)):a>55295&&a<57344?(a=65536+(a&1047552)|r.charCodeAt(++t)&1023,i(240|a>>18),i(128|a>>12&63),i(128|a>>6&63),i(128|a&63)):(i(224|a>>12),i(128|a>>6&63),i(128|a&63))}return de(s,0,o)}function tn(r,e){var t;if(vt)return vt.decode(r);var n=Zr(r),s=n.s,t=n.r;return t.length&&F(8),s}const rn=r=>{if(r.length===1)return r[0];const e=new Uint8Array(r.reduce((t,n)=>t+n.length,0));for(let t=0,n=0;t<r.length;++t)e.set(r[t],n),n+=r[t].length;return e};class nn{constructor(){this.reset()}reset(){this.compressor=null,this.decompressor=null}compress(e){this.compressor||(this.compressor=new Yr({mem:4}));const t=[];return this.compressor.ondata=n=>{t.push(n)},this.compressor.push(en(e)),this.compressor.flush(),rn(t)}decompress(e){this.decompressor||(this.decompressor=new Qr);let t;this.decompressor.ondata=n=>{t=n};try{if(this.decompressor.push(e),t===void 0)throw new Error("invalid block type")}catch(n){throw new Error(`Decompression error: ${n.message}, length: ${e.length}, data: [${e.toString()}]`)}return tn(t)}}const sn=()=>H(e=>class extends e{#e;constructor(...t){super(...t),this.#e=new nn,this.hooks.hook("frontgateConnection:reset",()=>{this.#e.reset()}),this.hooks.hook("frontgateConnection:afterSetEncoding",n=>{n.encoding="jsjsonc-v2"}),this.hooks.hook("frontgateConnection:beforeSendMessage",n=>{const s=this.#e.compress(n.msg);n.msg=s}),this.hooks.hook("frontgateConnection:afterReceiveMessage",n=>{const s=this.#e.decompress(new Uint8Array(n.msg));n.msg=s})}},{featureName:"MessageCompressor",featureGroups:["Misc"]}),on=()=>H(e=>class extends e{async request(t,n=this.defaultTimeoutInMs){t.header.setTimeout(n);const s={message:t.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",s);const o=new Promise(c=>{this.hooks.hookOnce(`frontgateConnection:response:${s.callbackId}`,a=>{const f=new fe(a);c(f)})}),i=`Request timeout reached (${n} ms) for ${s.message.Message}`;return Y(n,i,o)}},{featureName:"Request",featureGroups:["Misc"]}),an=r=>H(t=>{const n={...r};return class extends t{#e=new Map;#t=new Map;#r=new Map;async observeEndpoint(s,o,i,c){const a=`${s}:${o}:${JSON.stringify(i)}:${JSON.stringify(c??{})}`;if(this.#r.has(a)){const k=this.#r.get(a);this.log(d.INFO,`Catching inflight subscription for ${a}`);const l=this.#t.get(a)??0;return this.#t.set(a,l+1),k}const f=n.timeout??this.defaultTimeoutInMs,u=n.subscriptionResubscribeTimeout??1e3;if(this.#e.has(a)){const k=this.#e.get(a),l=this.#t.get(a)??0;if(k)return this.#t.set(a,l+1),this.log(d.INFO,`Reusing existing subscription for ${a}`),k}this.log(d.INFO,`Creating new subscription for ${a}`);const h=new ye(s,o,i,{...c,subscribe:!0});h.header.setTimeout(f);const v={message:h.getPtlMessage(),callbackType:"job",callbackId:""},w=new Promise((k,l)=>{this.hooks.callHook("frontgateConnection:sendMessage",v).then(()=>{this.hooks.hookOnce(`frontgateConnection:response:${v.callbackId}`,g=>{if(!g.Message.includes("HighLevelResponse")){this.log(d.ERROR,`Unexpected response: ${g.Message}`),l(new z(JSON.stringify(g)));return}let p;try{p=JSON.parse(g.body.value)}catch(m){this.log(d.ERROR,`Failed to parse response: ${g.body.value}`),this.log(d.ERROR,m),l(m);return}const y=new ur(g.header.id_job,p);let _=this.hooks.hook(`frontgateConnection:response:${v.callbackId}`,m=>{if(!m.Message.includes("HighLevelUpdate")){if(m.Message.includes("SubscriptionLoss")){this.log(d.DEBUG,`Received: ${m.Message}`),setTimeout(()=>{I()},qt(u)),_();return}this.log(d.ERROR,`Unexpected response: ${g.Message}`),y.pushError(new z(JSON.stringify(m))),_();return}let O;try{O=new tt(m)}catch(C){this.log(d.ERROR,`Failed to parse response: ${m.body.value}`),y.pushError(C);return}y.pushPatchData(O.data)});const I=async()=>{_(),this.log(d.INFO,`Resubscribing to ${a} due to reconnect`),await this.hooks.callHook("frontgateConnection:sendMessage",v);const m=new Promise((O,C)=>{this.hooks.hookOnce(`frontgateConnection:response:${v.callbackId}`,R=>{if(!g.Message.includes("HighLevelResponse")){const U=new z(R);this.log(d.ERROR,`Unexpected response: ${R.Message}`),_(),C(U);return}this.log(d.INFO,`Resubscribed to ${a} with ${R.header.id_job}`),y.idJob=R.header.id_job,_=this.hooks.hook(`frontgateConnection:response:${R.header.id_job}`,U=>{if(!U.Message.includes("HighLevelUpdate")){if(U.Message.includes("SubscriptionLoss")){this.log(d.DEBUG,`Received: ${U.Message}`),setTimeout(()=>{I()},qt(u));return}this.log(d.ERROR,`Unexpected response: ${U.Message}`);const $=new z(U);y.pushError($);return}let q;try{q=new tt(U)}catch($){this.log(d.ERROR,`Failed to parse response: ${U.body.value}`),y.pushError($);return}y.unsubscribe=()=>{if(this.#e.get(a)){const j=this.#t.get(a)??0;if(this.#t.set(a,j-1),j-1>0){this.log(d.INFO,`Not unsubscribing from ${a} as there are still ${j} subscribers`);return}this.#e.delete(a),this.#t.delete(a)}this.log(d.INFO,`Unsubscribing from ${a}`);const S={message:new le(y.idJob).getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",S),_(),N()},y.pushPatchData(q.data)}),O()})});try{await Y(f,"Request timeout reached",m)}catch(O){y.pushError(new z({Message:"Reconnect failed",Error:O}))}},N=this.hooks.hook("reconnect:success",I);y.unsubscribe=()=>{if(this.#e.get(a)){const R=this.#t.get(a)??0;if(this.#t.set(a,R-1),R-1>0){this.log(d.INFO,`Not unsubscribing from ${a} as there are still ${R} subscribers`);return}this.#e.delete(a),this.#t.delete(a)}this.log(d.INFO,`Unsubscribing from ${a}`);const C={message:new le(y.idJob).getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",C),_(),N()},this.#e.set(a,y);const T=this.#t.get(a)??0;this.#t.set(a,T+1),this.#r.delete(a),k(y)})}).catch(g=>{l(g)})}),M=`Request timeout reached (${f} ms) for ${v.message.Message}`,E=Y(f,M,w);return this.#r.set(a,E),E}}},{featureName:"EndpointSubscriptions",featureGroups:["Misc"]}),cn=()=>H(e=>class extends e{#e=new Map;async observe(t,n=this.defaultTimeoutInMs){return this.#t(t,"job",void 0,n)}async observeConnectionBased(t,n,s=this.defaultTimeoutInMs){return this.#t(t,"connection",n,s)}async#t(t,n,s,o=this.defaultTimeoutInMs){const i=JSON.stringify(t.getPtlMessage());if(this.#e.has(i)){const h=this.#e.get(i);if(h)return h.count++,this.log(d.INFO,`Reusing existing subscription for ${i}`),h.observer}this.log(d.INFO,`Creating new subscription for ${i}`);const a={message:t.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",a);const f=new Promise((h,v)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,w=>{if(w.Message.includes("Error")||w.Message.includes("PermissionDenied")){this.log(d.ERROR,`Unexpected response: ${w.Message}`),v(new Error(`Unexpected response: ${w.Message}`));return}const M=n==="connection"?`${w.header.id_service}-${t.getPtlMessage().id_notation}`:w.header.id_job,E=typeof s>"u"?new le(w.header.id_job):new s(w.header.id_service,t.getPtlMessage().id_notation),k=new mt(w.header.id_job,w);let l=this.hooks.hook(`frontgateConnection:response:${M}`,p=>{if(p.Message.includes("Error")||p.Message.includes("PermissionDenied")){this.log(d.ERROR,`Unexpected response: ${w.Message}`),k.pushError(new z(JSON.stringify(p)));return}k.pushData(p)});const g=this.hooks.hook("reconnect:success",async()=>{l(),this.log(d.INFO,`Resubscribing to ${i} due to reconnect`),await this.hooks.callHook("frontgateConnection:sendMessage",a);const p=new Promise((y,_)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,I=>{if(I.Message.includes("Error")||I.Message.includes("PermissionDenied")){const m=new z(I);this.log(d.ERROR,`Unexpected resp: ${I.Message}`),_(m);return}const N=n==="connection"?`${I.header.id_service}-${t.getPtlMessage().id_notation}`:I.header.id_job,T=typeof s>"u"?new le(I.header.id_job):new s(I.header.id_service,t.getPtlMessage().id_notation);k.idJob=I.header.id_job,l=this.hooks.hook(`frontgateConnection:response:${N}`,m=>{if(m.Message.includes("Error")||m.Message.includes("PermissionDenied")){this.log(d.ERROR,`Unexpected response: ${m.Message}`);const O=new z(m);k.pushError(O);return}k.unsubscribe=()=>{const O=this.#e.get(i);if(O){if(O.count--,O.count>0){this.log(d.INFO,`Not unsubscribing from ${i} as there are still ${O.count} subscribers`);return}this.#e.delete(i)}this.log(d.INFO,`Unsubscribing from ${i}`);const C={message:T.getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",C),l(),g()},k.pushData(m)}),y()})});try{await Y(o,"Request timeout reached",p)}catch(y){k.pushError(new z({Message:"Reconnect failed",Error:y}))}});k.unsubscribe=()=>{const p=this.#e.get(i);if(p){if(p.count--,p.count>0){this.log(d.INFO,`Not unsubscribing from ${i} as there are still ${p.count} subscribers`);return}this.#e.delete(i)}this.log(d.INFO,`Unsubscribing from ${i}`);const y={message:E.getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",y),l(),g()},this.#e.set(i,{observer:k,count:1}),h(k)})}),u=`Request timeout reached (${o} ms) for ${a.message.Message}`;return Y(o,u,f)}},{featureName:"RawSubscriptions",featureGroups:["Misc"]}),bt=(r,e)=>{const t=e.split("/").slice(1);let n=r;for(let s=0;s<t.length-1;s++){const o=decodeURIComponent(t[s]);if(!(o in n))throw new Error(`Path not found: ${e}`);n=n[o]}return[n,decodeURIComponent(t[t.length-1])]},un=(r,e,t)=>{const[n,s]=bt(r,e);n[s]=t},hn="-",ln=(r,e,t)=>{const[n,s]=bt(r,e);Array.isArray(n)?s===hn?n.push(t):n.splice(parseInt(s,10),0,t):n[s]=t},fn=(r,e)=>{const[t,n]=bt(r,e);Array.isArray(t)?t.splice(parseInt(n,10),1):delete t[n]};function dn(r,e){return e.forEach(t=>{switch(t.op){case"replace":un(r,t.path,t.value);break;case"add":ln(r,t.path,t.value);break;case"remove":fn(r,t.path);break;case"move":case"copy":case"test":default:throw new Error(`Unsupported op: ${t.op}`)}}),r}class mt{#e;#t=[];#r=[];get data(){return this.#e}constructor(e,t){this.#e=t,this.idJob=e}subscribe({next:e,error:t}){e(this.#e),t&&this.#r.push(t),this.#t.push(e)}pushData(e){this.#e=e,this.#t.forEach(t=>{t(e)})}pushError(e){this.#r.forEach(t=>{t(e)})}}class ur extends mt{pushPatchData(e){try{const t=dn(this.data,e);super.pushData(t)}catch(t){super.pushError(new z(t.message))}}}const gn=r=>H(t=>class extends t{constructor(...n){super(...n),this.hooks.hook("frontgateConnection:beforeConnect",o=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be),this.log(d.DEBUG,"Adding mdg2auth subprotocol"),o.subProtocols.push(`mdg2auth-${r}`)});const s=async o=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be);const i={maximum_idle_interval:o.maximumIdleInterval},c={b64:""},f=new qe(c,i.maximum_idle_interval).toJson();this.log(d.INFO,"Sending message",f);const u={message:f,callbackType:"response",callbackId:f.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",u),this.hooks.hookOnce(`frontgateConnection:response:${u.callbackId}`,h=>{this.log(d.INFO,"Received response",h),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hookOnce("frontgateConnection:connected",s)}},{featureName:"CookieTokenAuth",featureGroups:["Auth"],disabledFeatureGroups:["Auth"]}),pn=r=>H(t=>class extends t{#e;constructor(...n){super(...n),this.#e=r??"";const s=async o=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be);const i={maximum_idle_interval:o.maximumIdleInterval},c={b64:this.#e},f=new qe(c,i.maximum_idle_interval).toJson();this.log(d.INFO,"Sending message",f);const u={message:f,callbackType:"response",callbackId:f.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",u),this.hooks.hookOnce(`frontgateConnection:response:${u.callbackId}`,h=>{this.log(d.INFO,"Received response",h),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hook("frontgateConnection:connected",s)}set token(n){this.#e=n}},{featureName:"TokenAuth",featureGroups:["Auth"],disabledFeatureGroups:["Auth"]}),vn=(r,e,t)=>H(s=>class extends Kt({host:"",pathPrefix:"",port:0,tls:!0,maximumIdleIntervalInS:r.maximumIdleIntervalInS})(s){#e="";#t="";#r;#n;constructor(...o){super(...o),this.#r=e,this.#n=t,this.hooks.hook("frontgateConnection:beforeConnect",async c=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be),this.log(d.DEBUG,"Fetching connection configuration");const a=await this.#s();if(this.log(d.DEBUG,"Connection configuration received",a),c.url=a.url,a.authtenticationType==="token"&&a.authenticationToken)this.#e=a.authenticationToken;else if(a.splitAuthenticationTokenSecondFactor)this.#t=a.splitAuthenticationTokenSecondFactor;else throw new Error("Invalid authentication configuration");this.log(d.DEBUG,"Adding mdg2auth subprotocol"),this.#t!==""&&c.subProtocols.push(`mdg2auth-${this.#t}`)});const i=async c=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be);const a={maximum_idle_interval:c.maximumIdleInterval},f={b64:this.#e},h=new qe(f,a.maximum_idle_interval).toJson();this.log(d.INFO,"Sending message",h);const v={message:h,callbackType:"response",callbackId:h.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",v),this.hooks.hookOnce(`frontgateConnection:response:${v.callbackId}`,w=>{this.log(d.INFO,"Received response",w),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hook("frontgateConnection:connected",i)}async#s(){const o=await fetch(this.#r,this.#n);if(!o.ok)throw new Error(`Failed to fetch connection configuration: ${o.status} ${o.statusText}`);const{headers:i}=o,c=i.get("frontgate-host"),a=i.get("frontgate-path-prefix"),f=i.get("frontgate-split-authentication-token-second-factor"),u=i.get("frontgate-authentication-type"),h=i.get("frontgate-authentication-token"),v=i.get("frontgate-websocket-port")??"443",w=`wss://${c}:${v}${a??""}/ws`;if(u==="token"&&!h)throw new Error("Authentication token is required for token authentication");if(u!=="token"&&!f)throw new Error("Split authentication token second factor is required");return{url:w,authtenticationType:u,authenticationToken:h,splitAuthenticationTokenSecondFactor:f}}},{featureName:"FetchAuth",featureGroups:["Auth","Connection"],disabledFeatureGroups:["Auth","Connection"]}),bn=r=>H(t=>class extends t{#e=0;#t;#r;constructor(...n){super(...n),this.#t=r??[1e3,2e3,4e3,8e3,16e3,32e3];const s=o=>{if(o.code!==1e3){this.#r&&(this.log(d.WARN,"Aborting previous reconnect attempt"),clearTimeout(this.#r),this.#e=0);let i=this.#e;this.#e>=this.#t.length&&(i=this.#t.length-1);const c=this.#t[i];this.#r=setTimeout(()=>{this.log(d.INFO,`Reconnecting... Attempt ${this.#e}`);const a=this.hooks.hookOnce("reconnect:failed",s);this.hooks.callHook("reconnect:attempt",o).then(a).catch(()=>{this.log(d.ERROR,"Failed to reconnect")}),this.#r=void 0},c),this.#e++}};this.hooks.hookOnce("frontgateConnection:disconnected",s),this.hooks.hook("reconnect:success",()=>{clearTimeout(this.#r),this.#r=void 0,this.#e=0,this.log(d.INFO,"Reconnected"),this.hooks.hookOnce("frontgateConnection:disconnected",s)})}},{featureName:"Reconnect",featureGroups:["Misc"],disabledFeatures:["TokenAuth","CookieTokenAuth"]});var mn=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},ge="1.9.0",hr=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function yn(r){var e=new Set([r]),t=new Set,n=r.match(hr);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(a){return a===r};function o(c){return t.add(c),!1}function i(c){return e.add(c),!0}return function(a){if(e.has(a))return!0;if(t.has(a))return!1;var f=a.match(hr);if(!f)return o(a);var u={major:+f[1],minor:+f[2],patch:+f[3],prerelease:f[4]};return u.prerelease!=null||s.major!==u.major?o(a):s.major===0?s.minor===u.minor&&s.patch<=u.patch?i(a):o(a):s.minor<=u.minor?i(a):o(a)}}var wn=yn(ge),kn=ge.split(".")[0],Ne=Symbol.for("opentelemetry.js.api."+kn),Se=mn;function Pe(r,e,t,n){var s;n===void 0&&(n=!1);var o=Se[Ne]=(s=Se[Ne])!==null&&s!==void 0?s:{version:ge};if(!n&&o[r]){var i=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+r);return t.error(i.stack||i.message),!1}if(o.version!==ge){var i=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+r+" does not match previously registered API v"+ge);return t.error(i.stack||i.message),!1}return o[r]=e,t.debug("@opentelemetry/api: Registered a global for "+r+" v"+ge+"."),!0}function pe(r){var e,t,n=(e=Se[Ne])===null||e===void 0?void 0:e.version;if(!(!n||!wn(n)))return(t=Se[Ne])===null||t===void 0?void 0:t[r]}function xe(r,e){e.debug("@opentelemetry/api: Unregistering a global for "+r+" v"+ge+".");var t=Se[Ne];t&&delete t[r]}var _n=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},Mn=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},En=(function(){function r(e){this._namespace=e.namespace||"DiagComponentLogger"}return r.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("debug",this._namespace,e)},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("error",this._namespace,e)},r.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("info",this._namespace,e)},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("warn",this._namespace,e)},r.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("verbose",this._namespace,e)},r})();function Fe(r,e,t){var n=pe("diag");if(n)return t.unshift(e),n[r].apply(n,Mn([],_n(t),!1))}var B;(function(r){r[r.NONE=0]="NONE",r[r.ERROR=30]="ERROR",r[r.WARN=50]="WARN",r[r.INFO=60]="INFO",r[r.DEBUG=70]="DEBUG",r[r.VERBOSE=80]="VERBOSE",r[r.ALL=9999]="ALL"})(B||(B={}));function Tn(r,e){r<B.NONE?r=B.NONE:r>B.ALL&&(r=B.ALL),e=e||{};function t(n,s){var o=e[n];return typeof o=="function"&&r>=s?o.bind(e):function(){}}return{error:t("error",B.ERROR),warn:t("warn",B.WARN),info:t("info",B.INFO),debug:t("debug",B.DEBUG),verbose:t("verbose",B.VERBOSE)}}var In=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},On=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},Cn="diag",re=(function(){function r(){function e(s){return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];var c=pe("diag");if(c)return c[s].apply(c,On([],In(o),!1))}}var t=this,n=function(s,o){var i,c,a;if(o===void 0&&(o={logLevel:B.INFO}),s===t){var f=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((i=f.stack)!==null&&i!==void 0?i:f.message),!1}typeof o=="number"&&(o={logLevel:o});var u=pe("diag"),h=Tn((c=o.logLevel)!==null&&c!==void 0?c:B.INFO,s);if(u&&!o.suppressOverrideMessage){var v=(a=new Error().stack)!==null&&a!==void 0?a:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+v),h.warn("Current logger will overwrite one already registered from "+v)}return Pe("diag",h,t,!0)};t.setLogger=n,t.disable=function(){xe(Cn,t)},t.createComponentLogger=function(s){return new En(s)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return r.instance=function(){return this._instance||(this._instance=new r),this._instance},r})(),Rn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},An=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Nn=(function(){function r(e){this._entries=e?new Map(e):new Map}return r.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},r.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=Rn(e,2),n=t[0],s=t[1];return[n,s]})},r.prototype.setEntry=function(e,t){var n=new r(this._entries);return n._entries.set(e,t),n},r.prototype.removeEntry=function(e){var t=new r(this._entries);return t._entries.delete(e),t},r.prototype.removeEntries=function(){for(var e,t,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var o=new r(this._entries);try{for(var i=An(n),c=i.next();!c.done;c=i.next()){var a=c.value;o._entries.delete(a)}}catch(f){e={error:f}}finally{try{c&&!c.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return o},r.prototype.clear=function(){return new r},r})();re.instance();function Sn(r){return r===void 0&&(r={}),new Nn(new Map(Object.entries(r)))}function lr(r){return Symbol.for(r)}var Pn=(function(){function r(e){var t=this;t._currentContext=e?new Map(e):new Map,t.getValue=function(n){return t._currentContext.get(n)},t.setValue=function(n,s){var o=new r(t._currentContext);return o._currentContext.set(n,s),o},t.deleteValue=function(n){var s=new r(t._currentContext);return s._currentContext.delete(n),s}}return r})(),xn=new Pn,ve=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(n[o]=s[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Fn=(function(){function r(){}return r.prototype.createGauge=function(e,t){return Vn},r.prototype.createHistogram=function(e,t){return Wn},r.prototype.createCounter=function(e,t){return Bn},r.prototype.createUpDownCounter=function(e,t){return Jn},r.prototype.createObservableGauge=function(e,t){return Kn},r.prototype.createObservableCounter=function(e,t){return zn},r.prototype.createObservableUpDownCounter=function(e,t){return Yn},r.prototype.addBatchObservableCallback=function(e,t){},r.prototype.removeBatchObservableCallback=function(e){},r})(),Ke=(function(){function r(){}return r})(),$n=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.add=function(t,n){},e})(Ke),Un=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.add=function(t,n){},e})(Ke),Dn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.record=function(t,n){},e})(Ke),jn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.record=function(t,n){},e})(Ke),yt=(function(){function r(){}return r.prototype.addCallback=function(e){},r.prototype.removeCallback=function(e){},r})(),Hn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(yt),Gn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(yt),qn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(yt),Ln=new Fn,Bn=new $n,Vn=new Dn,Wn=new jn,Jn=new Un,zn=new Hn,Kn=new Gn,Yn=new qn,Qn={get:function(r,e){if(r!=null)return r[e]},keys:function(r){return r==null?[]:Object.keys(r)}},Xn={set:function(r,e,t){r!=null&&(r[e]=t)}},Zn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},es=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},ts=(function(){function r(){}return r.prototype.active=function(){return xn},r.prototype.with=function(e,t,n){for(var s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return t.call.apply(t,es([n],Zn(s),!1))},r.prototype.bind=function(e,t){return t},r.prototype.enable=function(){return this},r.prototype.disable=function(){return this},r})(),rs=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},ns=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},wt="context",ss=new ts,Ye=(function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalContextManager=function(e){return Pe(wt,e,re.instance())},r.prototype.active=function(){return this._getContextManager().active()},r.prototype.with=function(e,t,n){for(var s,o=[],i=3;i<arguments.length;i++)o[i-3]=arguments[i];return(s=this._getContextManager()).with.apply(s,ns([e,t,n],rs(o),!1))},r.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},r.prototype._getContextManager=function(){return pe(wt)||ss},r.prototype.disable=function(){this._getContextManager().disable(),xe(wt,re.instance())},r})(),kt;(function(r){r[r.NONE=0]="NONE",r[r.SAMPLED=1]="SAMPLED"})(kt||(kt={}));var fr="0000000000000000",dr="00000000000000000000000000000000",os={traceId:dr,spanId:fr,traceFlags:kt.NONE},$e=(function(){function r(e){e===void 0&&(e=os),this._spanContext=e}return r.prototype.spanContext=function(){return this._spanContext},r.prototype.setAttribute=function(e,t){return this},r.prototype.setAttributes=function(e){return this},r.prototype.addEvent=function(e,t){return this},r.prototype.addLink=function(e){return this},r.prototype.addLinks=function(e){return this},r.prototype.setStatus=function(e){return this},r.prototype.updateName=function(e){return this},r.prototype.end=function(e){},r.prototype.isRecording=function(){return!1},r.prototype.recordException=function(e,t){},r})(),_t=lr("OpenTelemetry Context Key SPAN");function Mt(r){return r.getValue(_t)||void 0}function is(){return Mt(Ye.getInstance().active())}function Et(r,e){return r.setValue(_t,e)}function as(r){return r.deleteValue(_t)}function cs(r,e){return Et(r,new $e(e))}function gr(r){var e;return(e=Mt(r))===null||e===void 0?void 0:e.spanContext()}var us=/^([0-9a-f]{32})$/i,hs=/^[0-9a-f]{16}$/i;function ls(r){return us.test(r)&&r!==dr}function fs(r){return hs.test(r)&&r!==fr}function pr(r){return ls(r.traceId)&&fs(r.spanId)}function ds(r){return new $e(r)}var Tt=Ye.getInstance(),vr=(function(){function r(){}return r.prototype.startSpan=function(e,t,n){n===void 0&&(n=Tt.active());var s=!!t?.root;if(s)return new $e;var o=n&&gr(n);return gs(o)&&pr(o)?new $e(o):new $e},r.prototype.startActiveSpan=function(e,t,n,s){var o,i,c;if(!(arguments.length<2)){arguments.length===2?c=t:arguments.length===3?(o=t,c=n):(o=t,i=n,c=s);var a=i??Tt.active(),f=this.startSpan(e,o,a),u=Et(a,f);return Tt.with(u,c,void 0,f)}},r})();function gs(r){return typeof r=="object"&&typeof r.spanId=="string"&&typeof r.traceId=="string"&&typeof r.traceFlags=="number"}var ps=new vr,vs=(function(){function r(e,t,n,s){this._provider=e,this.name=t,this.version=n,this.options=s}return r.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},r.prototype.startActiveSpan=function(e,t,n,s){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},r.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):ps},r})(),bs=(function(){function r(){}return r.prototype.getTracer=function(e,t,n){return new vr},r})(),ms=new bs,br=(function(){function r(){}return r.prototype.getTracer=function(e,t,n){var s;return(s=this.getDelegateTracer(e,t,n))!==null&&s!==void 0?s:new vs(this,e,t,n)},r.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:ms},r.prototype.setDelegate=function(e){this._delegate=e},r.prototype.getDelegateTracer=function(e,t,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,t,n)},r})();Ye.getInstance(),re.instance();var ys=(function(){function r(){}return r.prototype.getMeter=function(e,t,n){return Ln},r})(),ws=new ys,It="metrics",ks=(function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalMeterProvider=function(e){return Pe(It,e,re.instance())},r.prototype.getMeterProvider=function(){return pe(It)||ws},r.prototype.getMeter=function(e,t,n){return this.getMeterProvider().getMeter(e,t,n)},r.prototype.disable=function(){xe(It,re.instance())},r})();ks.getInstance();var _s=(function(){function r(){}return r.prototype.inject=function(e,t){},r.prototype.extract=function(e,t){return e},r.prototype.fields=function(){return[]},r})(),Ot=lr("OpenTelemetry Baggage Key");function mr(r){return r.getValue(Ot)||void 0}function Ms(){return mr(Ye.getInstance().active())}function Es(r,e){return r.setValue(Ot,e)}function Ts(r){return r.deleteValue(Ot)}var Ct="propagation",Is=new _s,Os=(function(){function r(){this.createBaggage=Sn,this.getBaggage=mr,this.getActiveBaggage=Ms,this.setBaggage=Es,this.deleteBaggage=Ts}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalPropagator=function(e){return Pe(Ct,e,re.instance())},r.prototype.inject=function(e,t,n){return n===void 0&&(n=Xn),this._getGlobalPropagator().inject(e,t,n)},r.prototype.extract=function(e,t,n){return n===void 0&&(n=Qn),this._getGlobalPropagator().extract(e,t,n)},r.prototype.fields=function(){return this._getGlobalPropagator().fields()},r.prototype.disable=function(){xe(Ct,re.instance())},r.prototype._getGlobalPropagator=function(){return pe(Ct)||Is},r})();Os.getInstance();var Rt="trace",Cs=(function(){function r(){this._proxyTracerProvider=new br,this.wrapSpanContext=ds,this.isSpanContextValid=pr,this.deleteSpan=as,this.getSpan=Mt,this.getActiveSpan=is,this.getSpanContext=gr,this.setSpan=Et,this.setSpanContext=cs}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalTracerProvider=function(e){var t=Pe(Rt,this._proxyTracerProvider,re.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},r.prototype.getTracerProvider=function(){return pe(Rt)||this._proxyTracerProvider},r.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},r.prototype.disable=function(){xe(Rt,re.instance()),this._proxyTracerProvider=new br},r})(),Rs=Cs.getInstance();const As=()=>H(e=>class extends e{constructor(...t){super(...t),this.hooks.hook("frontgateConnection:beforeSerializeMessage",n=>{n.header&&Rs.getTracer("frontgate-js-sdk").startActiveSpan("frontgateConnection:sendMessage",s=>{const o=this.#e(s.spanContext());o&&(n.header={...n.header,...o}),s.end()})})}#e(t){if(!/^0+$/.test(t.traceId))return{tracing:{value:{value:yr(t)}}}}},{featureName:"OpenTelemetry",featureGroups:["Misc"]}),yr=r=>{const e=[18,20,9],t=n=>{for(let s=n.length;s>n.length-16;s-=2){let o=parseInt(n.substring(s-2,s),16);o>127&&(o-=256),e.push(o)}};return t(r.traceId),e.push(17),t(r.spanId),e.push(24),e.push(0),e},Ns=()=>H(e=>class extends e{async requestProxyEndpoint(t,n,s,o,i=this.defaultTimeoutInMs){const c=new Be(t,n,o);s&&c.setBody(s),c.header.setTimeout(i);const a={message:c.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",a);const f=new Promise((h,v)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,w=>{try{if(!w.Message.includes("HTTPProxyResponse")){v(JSON.stringify(w));return}const M=new Jt(w);h({response:M,data:M.data})}catch(M){v(M)}})}),u=`Request timeout reached (${i} ms) for ${a.message.Message}`;return Y(i,u,f)}},{featureName:"HTTPProxyRequest",featureGroups:["Misc"]}),Ss=()=>H(e=>class extends e{async ping(t=this.defaultTimeoutInMs){const s={message:new Ve().getPtlMessage(),callbackType:"response",callbackId:"PingResponse"};await this.hooks.callHook("frontgateConnection:sendMessage",s);const o=new Promise(c=>{this.hooks.hookOnce(`frontgateConnection:response:${s.callbackId}`,a=>{const f=new We(a);c(f)})}),i=`Request timeout reached (${t} ms) for ${s.message.Message}`;return Y(t,i,o)}},{featureName:"Pingable",featureGroups:["Misc"]}),Ps=r=>H(t=>class extends t{async logRemotely(n){const o={message:new Bt({Message:"LogMessage",timestamp:{microseconds:Date.now()*1e3},uuid:{id_1:r??0,id_2:0},level:{value:4},area:61,Version:1,message:n}).getPtlMessage(),callbackType:"job",callbackId:""};return this.hooks.callHook("frontgateConnection:sendMessage",o)}},{featureName:"RemoteLogger",featureGroups:["Misc"]}),H=(r,e)=>{const t=r;return t.featureName=e.featureName,t.featureGroups=e.featureGroups,t.disabledFeatures=e.disabledFeatures,t.disabledFeatureGroups=e.disabledFeatureGroups,t};function At(r,e={},t){for(const n in r){const s=r[n],o=t?`${t}:${n}`:n;typeof s=="object"&&s!==null?At(s,e,o):typeof s=="function"&&(e[o]=s)}return e}const xs={run:r=>r()},Fs=()=>xs,wr=typeof console.createTask<"u"?console.createTask:Fs;function $s(r,e){const t=e.shift(),n=wr(t);return r.reduce((s,o)=>s.then(()=>n.run(()=>o(...e))),Promise.resolve())}function Us(r,e){const t=e.shift(),n=wr(t);return Promise.all(r.map(s=>n.run(()=>s(...e))))}function Nt(r,e){for(const t of[...r])t(e)}class Ds{constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(e,t,n={}){if(!e||typeof t!="function")return()=>{};const s=e;let o;for(;this._deprecatedHooks[e];)o=this._deprecatedHooks[e],e=o.to;if(o&&!n.allowDeprecated){let i=o.message;i||(i=`${s} hook has been deprecated`+(o.to?`, please use ${o.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!t.name)try{Object.defineProperty(t,"name",{get:()=>"_"+e.replace(/\W+/g,"_")+"_hook_cb",configurable:!0})}catch{}return this._hooks[e]=this._hooks[e]||[],this._hooks[e].push(t),()=>{t&&(this.removeHook(e,t),t=void 0)}}hookOnce(e,t){let n,s=(...o)=>(typeof n=="function"&&n(),n=void 0,s=void 0,t(...o));return n=this.hook(e,s),n}removeHook(e,t){if(this._hooks[e]){const n=this._hooks[e].indexOf(t);n!==-1&&this._hooks[e].splice(n,1),this._hooks[e].length===0&&delete this._hooks[e]}}deprecateHook(e,t){this._deprecatedHooks[e]=typeof t=="string"?{to:t}:t;const n=this._hooks[e]||[];delete this._hooks[e];for(const s of n)this.hook(e,s)}deprecateHooks(e){Object.assign(this._deprecatedHooks,e);for(const t in e)this.deprecateHook(t,e[t])}addHooks(e){const t=At(e),n=Object.keys(t).map(s=>this.hook(s,t[s]));return()=>{for(const s of n.splice(0,n.length))s()}}removeHooks(e){const t=At(e);for(const n in t)this.removeHook(n,t[n])}removeAllHooks(){for(const e in this._hooks)delete this._hooks[e]}callHook(e,...t){return t.unshift(e),this.callHookWith($s,e,...t)}callHookParallel(e,...t){return t.unshift(e),this.callHookWith(Us,e,...t)}callHookWith(e,t,...n){const s=this._before||this._after?{name:t,args:n,context:{}}:void 0;this._before&&Nt(this._before,s);const o=e(t in this._hooks?[...this._hooks[t]]:[],n);return o instanceof Promise?o.finally(()=>{this._after&&s&&Nt(this._after,s)}):(this._after&&s&&Nt(this._after,s),o)}beforeEach(e){return this._before=this._before||[],this._before.push(e),()=>{if(this._before!==void 0){const t=this._before.indexOf(e);t!==-1&&this._before.splice(t,1)}}}afterEach(e){return this._after=this._after||[],this._after.push(e),()=>{if(this._after!==void 0){const t=this._after.indexOf(e);t!==-1&&this._after.splice(t,1)}}}}function js(){return new Ds}const kr=typeof window<"u";function Hs(r,e={}){const t={inspect:kr,group:kr,filter:()=>!0,...e},n=t.filter,s=typeof n=="string"?u=>u.startsWith(n):n,o=t.tag?`[${t.tag}] `:"",i=u=>o+u.name+"".padEnd(u._id,"\0"),c={},a=r.beforeEach(u=>{s!==void 0&&!s(u.name)||(c[u.name]=c[u.name]||0,u._id=c[u.name]++,console.time(i(u)))}),f=r.afterEach(u=>{s!==void 0&&!s(u.name)||(t.group&&console.groupCollapsed(u.name),t.inspect?console.timeLog(i(u),u.args):console.timeEnd(i(u)),t.group&&console.groupEnd(),c[u.name]--)});return{close:()=>{a(),f()}}}class _r{constructor(e){this.hooks=js(),this.#e=1e4,e?.hookDebug&&Hs(this.hooks,{tag:"hooks"}),e?.defaultRequestTimeout&&(this.#e=e.defaultRequestTimeout)}#e;get defaultTimeoutInMs(){return this.#e}log(e,...t){if(this.hooks.callHook("base:log",t),this.logger)switch(e){case d.TRACE:this.logger.trace(t);break;case d.DEBUG:this.logger.debug(t);break;case d.INFO:this.logger.info(t);break;case d.WARN:this.logger.warn(t);break;case d.ERROR:this.logger.error(t);break;case d.FATAL:this.logger.fatal(t);break}}}class Qe{#e;#t=[];#r=[];#n=[];constructor(e,t=[],n=[],s=[]){this.#e=e,this.#t=t,this.#r=n,this.#n=s}static create(){return new Qe(_r)}#s(e){if(this.#t.includes(e))throw new Error(`Feature "${e}" has already been used.`)}#i(e){for(const t of this.#r)if(t.feature===e)throw new Error(`Feature "${e}" has been disabled by ${t.disabler.join(",")}.`)}#a(e){for(const t of this.#n)if(t.feature===e)throw new Error(`Group "${e}" has been disabled by ${t.disabler.join(",")}.`)}#o(e,t){for(const n of this.#r)if(n.feature===t){n.disabler.push(e);return}this.#r.push({disabler:[e],feature:t})}#c(e,t){for(const n of this.#n)if(n.feature===t){n.disabler.push(e);return}this.#n.push({disabler:[e],feature:t})}with(e){const{featureName:t,disabledFeatures:n,disabledFeatureGroups:s,featureGroups:o}=e;if(!t)throw new Error("Feature name is missing");if(t!=="Custom"){if(this.#s(t),this.#i(t),this.#t.push(t),o&&o.length>0)for(const c of o)this.#a(c);if(n&&n.length>0)for(const c of n)this.#o(t,c);if(s&&s.length>0)for(const c of s)this.#c(t,c)}const i=e(this.#e);return new Qe(i,this.#t,this.#r,this.#n)}build(e){return new this.#e(e)}getClientConstructor(){return this.#e}}b.AbstractLogger=ie,b.AbstractMdg2Request=me,b.AuthenticationByTokenRequest=qe,b.AuthenticationTokenRequest=Le,b.AuthenticationTokenResponse=Vt,b.CancelSubscriptionRequest=le,b.ConnectionState=Ut,b.ConsoleLogger=nt,b.CookieTokenAuthenticationFactors=Ft,b.DEFAULT_TIMEOUT_IN_MS=Lt,b.DefaultHosts=jt,b.DeploymentStage=Dt,b.ErrorResponse=z,b.FLAG_HAS_NEXT_CHUNK=rt,b.FrontgateClient=_r,b.FrontgateClientBuilder=Qe,b.FrontgateClientDataObserver=mt,b.FrontgateClientEndpointDataObserver=ur,b.HTTPProxyRequest=Be,b.HTTPProxyResponse=Jt,b.HighLevelRequest=ye,b.HighLevelResponse=Wt,b.HighLevelUpdate=tt,b.ID_APP_AUTHENTICATED=he,b.ID_USER_AUTHENTICATED=be,b.ID_USER_NONE=$t,b.LogLevel=d,b.LoggerHelper=Pr,b.Mdg2Response=fe,b.NullLogger=st,b.PingRequest=Ve,b.PingResponse=We,b.RawRequest=Bt,b.TimeOptions=Ht,b.TransportLayerClientRequestHeader=Ge,b.WinstonLogger=Fr,b.authTokenRequest=$r,b.cookieTokenAuth=gn,b.createExtendedMixinFactory=H,b.encodeSpanContext=yr,b.endpointRequest=Ur,b.endpointSubscriptions=an,b.fetchAuth=vn,b.getBytesFromBuffer=Cr,b.httpProxyRequest=Ns,b.levels=xr,b.logger=Dr,b.messageCompressor=sn,b.openTelemetry=As,b.pingRequests=Ss,b.rawSubscriptions=cn,b.reconnect=bn,b.remotelogger=Ps,b.requests=on,b.timeToMilliseconds=He,b.tokenAuth=pn,b.useTimeout=Y,b.wsConnection=Kt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(b,Oe){typeof exports=="object"&&typeof module<"u"?Oe(exports):typeof define=="function"&&define.amd?define(["exports"],Oe):(b=typeof globalThis<"u"?globalThis:b||self,Oe(b.fdsg={}))})(this,(function(b){"use strict";function Oe(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var et,Pt;function Mr(){if(Pt)return et;Pt=1;var r=function(g){return e(g)&&!t(g)};function e(l){return!!l&&typeof l=="object"}function t(l){var g=Object.prototype.toString.call(l);return g==="[object RegExp]"||g==="[object Date]"||o(l)}var n=typeof Symbol=="function"&&Symbol.for,s=n?Symbol.for("react.element"):60103;function o(l){return l.$$typeof===s}function i(l){return Array.isArray(l)?[]:{}}function c(l,g){return g.clone!==!1&&g.isMergeableObject(l)?E(i(l),l,g):l}function a(l,g,p){return l.concat(g).map(function(y){return c(y,p)})}function f(l,g){if(!g.customMerge)return E;var p=g.customMerge(l);return typeof p=="function"?p:E}function u(l){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(l).filter(function(g){return Object.propertyIsEnumerable.call(l,g)}):[]}function h(l){return Object.keys(l).concat(u(l))}function v(l,g){try{return g in l}catch{return!1}}function w(l,g){return v(l,g)&&!(Object.hasOwnProperty.call(l,g)&&Object.propertyIsEnumerable.call(l,g))}function M(l,g,p){var y={};return p.isMergeableObject(l)&&h(l).forEach(function(_){y[_]=c(l[_],p)}),h(g).forEach(function(_){w(l,_)||(v(l,_)&&p.isMergeableObject(g[_])?y[_]=f(_,p)(l[_],g[_],p):y[_]=c(g[_],p))}),y}function E(l,g,p){p=p||{},p.arrayMerge=p.arrayMerge||a,p.isMergeableObject=p.isMergeableObject||r,p.cloneUnlessOtherwiseSpecified=c;var y=Array.isArray(g),_=Array.isArray(l),I=y===_;return I?y?p.arrayMerge(l,g,p):M(l,g,p):c(g,p)}E.all=function(g,p){if(!Array.isArray(g))throw new Error("first argument should be an array");return g.reduce(function(y,_){return E(y,_,p)},{})};var k=E;return et=k,et}var Er=Mr();const xt=Oe(Er);function Tr(r){return!!r&&typeof r=="object"}function Ir(...r){const e=r.filter(Tr);return xt.all(e,{arrayMerge:(t,n)=>n})}function Or(r){return r.replace(/[=]/g,"").replace(/\//g,"_").replace(/\+/g,"-")}class Ft{constructor(e){const t=Or(e),n=Math.ceil(t.length/2);this.firstFactor=t.substring(0,n),this.secondFactor=t.substring(n)}getFirstFactor(){return this.firstFactor}getSecondFactor(){return this.secondFactor}}const he=-2,be=-2,$t=-1;function Cr(r){const e=[];if(r)for(let t=0;t<r.length;t++)e.push(r.readInt8(t));return e}var Ut=(r=>(r[r.DISCONNECTED=0]="DISCONNECTED",r[r.CONNECTING=1]="CONNECTING",r[r.AUTHENTICATED=2]="AUTHENTICATED",r[r.RECONNECTING=3]="RECONNECTING",r))(Ut||{}),Dt=(r=>(r[r.production=40]="production",r[r.preproduction=35]="preproduction",r[r.show=30]="show",r[r.testing=20]="testing",r))(Dt||{}),jt=(r=>(r.production="frontgate-eu.factsetdigitalsolutions.com",r.show="frontgate-eu.show.factsetdigitalsolutions.com",r))(jt||{}),Ht=(r=>(r.MAXIMUM_STRING="9223372036854775807",r.MINIMUM_STRING="-9223372036854775807",r))(Ht||{});function He(r){return r.toString().slice(0,-3)}const Gt={version:"7.0.4",package:"@factset/frontgate-js-sdk"};function Rr(){const r=Ar();return{userAgent:r.userAgent??"unknown",platform:"frontgate-js-sdk",version:Gt.version,package:Gt.package,mobile:/Mobi/i.test(r.userAgent??"unknown")}}function Ar(){return typeof navigator<"u"?navigator:typeof process<"u"?{userAgent:`node.js/io.js, ${process.version}`}:{userAgent:"unknown"}}const Nr=r=>{const e=[18,20,9],t=n=>{for(let s=n.length;s>n.length-16;s-=2){let o=parseInt(n.substring(s-2,s),16);o>127&&(o-=256),e.push(o)}};return t(r.traceId),e.push(17),t(r.spanId),e.push(24),e.push(0),e},Sr=async(r,e)=>new Promise((t,n)=>{setTimeout(()=>{n(e)},r)}),Y=async(r,e,t)=>Promise.race([Sr(r,e),t]),qt=r=>r+Math.random()*100,Lt=6e3,X=class X{constructor(){this.headerMembers={dataset:{id_dataset:0},id_job:0,flags_r2:0,resend_counter:0,timeout:Lt,authentication_identifiers:{id_application:0,id_user:0},cache_key:{value:[]},previous_response_hash:{value:[]},tracing:{value:{value:[]}}},this.flags=[]}getPtlMessage(){return this.headerMembers}getQuality(){return Object.keys(X.PRICE_QUALITY).find(t=>X.PRICE_QUALITY[t]===this.headerMembers.dataset.id_dataset)}setQuality(e){this.headerMembers.dataset.id_dataset=X.PRICE_QUALITY[e]}setIdApplication(e,t=!1){(this.headerMembers.authentication_identifiers.id_application===0||t)&&(this.headerMembers.authentication_identifiers.id_application=e)}setIdUser(e,t=!1){(this.headerMembers.authentication_identifiers.id_user===0||t)&&(this.headerMembers.authentication_identifiers.id_user=e)}setFlag(e,t=!0){const n=this.flags.indexOf(e);t&&n===-1&&this.flags.push(e),!t&&n>-1&&this.flags.splice(n,1),this.headerMembers.flags_r2=this.getFlagsValue()}getFlagsValue(){return this.flags.reduce((e,t)=>e+X.FLAG_VALUE[t],0)}isFlagValueSet(e){return this.flags.find(t=>t===e)!==void 0}setJobId(e){this.headerMembers.id_job=e}getJobId(){return this.headerMembers.id_job}countResend(){this.headerMembers.resend_counter++}getResendCounter(){return this.headerMembers.resend_counter}setTimeout(e){if(e>0){this.headerMembers.timeout=e;return}throw new Error(`Attempted to set the timeout to "${e}". The timeout must be greater than 0.`)}getTimeout(){return this.headerMembers.timeout}setTracing(e){/^0+$/.test(e.traceId)||(this.headerMembers.tracing.value.value=Nr(e))}static getDataSet(e){return Object.prototype.hasOwnProperty.call(X.PRICE_QUALITY,e)?X.PRICE_QUALITY[e]:X.PRICE_QUALITY.DLY}};X.PRICE_QUALITY={RLT:129,DLY:0,EOD:130},X.FLAG_VALUE={add_subscription:1,no_merge:2,support_caching:4,permission_denied_response:8,internal_client:16,current_state_refresh:32,subscription_use_pull_permissions:64,allow_chunked_response:128};let Ge=X;class me{constructor(e,t){this.header=new Ge,this.coreMembers={Message:e,Version:t},this.members={}}getPtlMessage(){const e={header:this.header.getPtlMessage()};return Ir(this.coreMembers,e,this.members)}}class qe{constructor(e,t){this.token=e,this.maximumIdleInterval=t}toJson(){const e=Rr();return{Message:"AuthenticationByTokenRequest",Version:1,token:{value:this.token},software:JSON.stringify(e),os:e.platform,feature_flags_wanted:{value:0},maximum_idle_interval:this.maximumIdleInterval,maximum_receivable_message_size:1048576,flags:0,cache_authentication_salt:{value:[]},cache_authentication_encrypted_secret:{encrypted_secret:[]}}}}const Z=class Z extends me{constructor(e,t,n,s,o=!1){super(Z.NAME,Z.VERSION),t&&this.header.setIdUser(t),n&&this.header.setIdApplication(n),s&&this.header.setTimeout(s),this.members.flags=o?Z.FLAG_SINGLE_USAGE:0,this.members.lifetime_seconds_r2=e??Z.LIFETIME_SECONDS_DEFAULT,this.header.setFlag("no_merge")}};Z.NAME="AuthenticationTokenRequest",Z.VERSION=6,Z.LIFETIME_SECONDS_DEFAULT=-1,Z.LIFETIME_SECONDS_MAXIMUM=-2,Z.FLAG_SINGLE_USAGE=1;let Le=Z;const ke=class ke extends me{constructor(e){super(ke.NAME,ke.VERSION),this.members.id_job_subscription=e}};ke.NAME="CancelSubscriptionRequest",ke.VERSION=6;let le=ke;const ee=class ee extends me{constructor(e,t,n={},s){super(ee.NAME,ee.VERSION),this.members.accept="application/json",this.members.content_type="application/json",this.members.body={value:[]},this.members.query="",this.members.path=t,this.setMethod(e),Object.keys(n).length>0&&(e==="POST"?this.setBody(n):this.setQuery(n)),s&&this.setOptions(s)}setOptions(e){Object.hasOwnProperty.call(e,"accept")&&(this.members.accept=e.accept),Object.hasOwnProperty.call(e,"content_type")&&(this.members.content_type=e.content_type),Object.hasOwnProperty.call(e,"subscribe")&&e.subscribe&&this.header.setFlag("add_subscription"),Object.hasOwnProperty.call(e,"no_merge")&&e.no_merge&&this.header.setFlag("no_merge"),Object.hasOwnProperty.call(e,"allowChunkedResponse")&&e.allowChunkedResponse&&this.header.setFlag("allow_chunked_response"),Object.hasOwnProperty.call(e,"idApplication")&&e.idApplication&&this.header.setIdApplication(e.idApplication),Object.hasOwnProperty.call(e,"idUser")&&e.idUser&&this.header.setIdUser(e.idUser)}setMethod(e){const t=e==="POST"?ee.METHOD.POST:ee.METHOD.GET;this.members.method={value:t}}setBody(e={}){e instanceof Array?this.members.body={value:e}:this.members.body={value:JSON.stringify(e)}}getData(){return this.members.method.value===ee.METHOD.POST?ee.ptlToJsonData(this.members.body.value):this.members.query}setQuery(e={}){this.members.query=Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}static ptlToJsonData(e){if(typeof e=="string")return JSON.parse(e);if(e instanceof Array&&e.length>0){let t="";return e.forEach(n=>{t+=String.fromCharCode(n)}),JSON.parse(t)}}};ee.NAME="HighLevelRequest",ee.VERSION=3,ee.METHOD={GET:1,POST:2};let ye=ee;const V=class V extends me{constructor(e,t,n){super(V.NAME,V.VERSION),this.members.request={headers:{values:[{key:"accept",value:"application/json"},{key:"content-type",value:"application/json"}]},protocol:{value:V.PROTOCOL.HTTPS},host:"",port:0,path:t,query:"",body:{value:[]}},this.setQuery(),this.setMethod(e),n&&this.setOptions(n)}setOptions(e){e.no_merge&&this.header.setFlag("no_merge"),e.idApplication&&this.header.setIdApplication(e.idApplication),e.idUser&&this.header.setIdUser(e.idUser),e.protocol&&(this.members.request.protocol=e.protocol.toUpperCase()==="HTTP"?{value:V.PROTOCOL.HTTP}:{value:V.PROTOCOL.HTTPS}),e.method&&(this.members.request.method={value:V.METHOD[e.method]}),e.host&&(this.members.request.host=e.host),e.port&&(this.members.request.port=e.port),e.path&&(this.members.request.path=e.path),e.query&&(this.members.request.query=typeof e.query=="string"?e.query:Object.keys(e.query).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e.query[t])}`).join("&")),e.body&&this.setBody(e.body),e.headers&&this.setHeaders(e.headers)}setHeaders(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const n=e[t],s=this.members.request.headers.values.findIndex(i=>i.key===t);s!==-1&&this.members.request.headers.values.splice(s,1),this.members.request.headers.values.push({key:t,value:n})}}setQuery(){if(this.members.request.path.includes("?")){const e=this.members.request.path.split("?");this.members.request.path=e[0],this.members.request.query=e[1]}}setMethod(e){this.members.request.method={value:V.METHOD[e]}}setBody(e={}){return e instanceof Array||typeof e=="string"?this.members.request.body={value:e}:this.members.request.body={value:JSON.stringify(e)},this}getData(){if(this.members.request.body?.value)return ye.ptlToJsonData(this.members.request.body.value)}};V.NAME="HTTPProxyRequest",V.VERSION=2,V.PROTOCOL={HTTP:1,HTTPS:2},V.METHOD={GET:1,POST:2,OPTIONS:3,HEAD:4,PUT:5,DELETE:6,TRACE:7,CONNECT:8};let Be=V;const _e=class _e{constructor(){this._timeAtSender=Date.now()}getPtlMessage(){return{Message:_e.NAME,Version:_e.VERSION,time_at_sender:{microseconds:this._timeAtSender*1e3}}}resetTimeAtSender(){this._timeAtSender=Date.now()}get timeAtSender(){return this._timeAtSender}};_e.NAME="PingRequest",_e.VERSION=3;let Ve=_e;class Bt extends me{constructor(e){super(e.Message,e.version?e.version:e.Version),this._extractRequestAttributes(e)}_extractRequestAttributes(e){for(const t of Object.keys(this.coreMembers))delete e[t];this.members=xt(this.members,e)}}class fe{constructor(e){this.raw=e}get msg(){return this.raw}get name(){return this.raw.Message}get jobId(){return this.raw.header.id_job}get serviceId(){return this.raw.header.id_service}isUpdateMessage(){return Object.hasOwnProperty.call(this.raw,"header")?(Object.hasOwnProperty.call(this.raw.header,"id_service")||Object.hasOwnProperty.call(this.raw.header,"id_job"))&&this.raw.Message.endsWith("Update"):!1}isLossMessage(){return Object.hasOwnProperty.call(this.raw,"header")?(Object.hasOwnProperty.call(this.raw.header,"id_service")||Object.hasOwnProperty.call(this.raw.header,"id_job"))&&(this.raw.Message.endsWith("LossMessage")||this.raw.Message.endsWith("Loss")):!1}}class Vt extends fe{constructor(e){if(super(e),!this.raw.token.value.b64)throw new Error("Token not set in AuthenticationTokenResponse");if(!this.raw.expiry.microseconds)throw new Error("Expiry not set in AuthenticationTokenResponse");this.token=this.raw.token.value.b64,this.expiry=parseInt(He(this.raw.expiry.microseconds),10)}getToken(){return this.token}getExpiry(){return this.expiry}}class z extends fe{get reason(){return this.raw.details}get jobId(){return this.raw.id_job}}class Wt extends fe{constructor(e){super(e);try{this.responseData=JSON.parse(this.raw.body.value)}catch(t){throw new Error(`Could not parse HighLevelResponse: ${t.message}`)}}get data(){return this.responseData.data}get meta(){return this.responseData.meta}get status(){return this.meta.status}get statusCode(){return this.status.code}}class Jt extends fe{constructor(e){super(e);try{const t=this.raw.response.body.value,n=t.substr(0,1)==="{";this.responseData=n?JSON.parse(t):t}catch(t){throw new Error(`Could not parse HTTPProxyResponse: ${t}`)}this.responseInfo=this.raw.info,this.statusReason=this.raw.response.status_reason,this.statusCode=this.raw.response.status_code.value}get data(){return this.responseData}get meta(){return this.responseData.meta}get status(){return{code:this.statusCode,reason:this.statusReason}}}const Me=class Me{constructor(e){if(e.Message!==Me.NAME)throw new Error(`Unsupported message=${e.Message}`);if(e.Version!==Me.VERSION)throw new Error(`Unsupported version=${e.Version} for message=${e.Message}`);this._timeReceivedResponse=Date.now(),this._timeAtSender=Number(He(e.time_at_sender.microseconds)),this._timeFromRequest=Number(He(e.time_from_request.microseconds))}get timeAtPeer(){return this._timeAtSender}get timeOfRequest(){return this._timeFromRequest}get timeOfResponse(){return this._timeReceivedResponse}get latencyTotal(){return this._timeReceivedResponse-this._timeFromRequest}get latencyAtPeer(){return this._timeAtSender-this._timeFromRequest}};Me.NAME="Foundation::PingResponse",Me.VERSION=2;let We=Me;class tt extends fe{constructor(e){if(super(e),typeof this.raw.body.value!="string")throw new Error("Incorrect response type in HighLevelUpdate");try{this.responseData=JSON.parse(this.raw.body.value)}catch(t){throw new Error(`Could not parse HighLevelUpdate: ${t.message}`)}}get data(){return this.responseData}}const rt=8;var d=(r=>(r[r.TRACE=10]="TRACE",r[r.DEBUG=20]="DEBUG",r[r.INFO=30]="INFO",r[r.WARN=40]="WARN",r[r.ERROR=50]="ERROR",r[r.FATAL=60]="FATAL",r[r.SILENT=100]="SILENT",r))(d||{});const ue=class ue{constructor(e=""){this.defaultLevel=40,this.noop=()=>null,this.name=e,this.setDefaultLevelFromLocalStorage(),Object.assign(ue.loggers,{[e]:this})}getName(){return this.name}setLevel(e){this.level=e}getLevel(){return typeof this.level=="number"&&isFinite(this.level)&&Math.floor(this.level)===this.level?this.level:this.defaultLevel}shouldLog(e){switch(this.getLevel()){case 100:return!1;case 60:return e==="fatal";case 50:return e==="fatal"||e==="error";case 40:return e==="fatal"||e==="error"||e==="warn";case 30:return e==="fatal"||e==="error"||e==="warn"||e==="info";case 20:return e==="fatal"||e==="error"||e==="warn"||e==="info"||e==="debug";case 10:default:return!0}}setDefaultLevelFromLocalStorage(){let e;try{if(!(typeof localStorage=="object"))return;const n=localStorage.getItem("loglevel");if(!n)return;e=n}catch{return}e&&this.setLevel(ue.getLogLevel(e))}static getLogLevel(e){const t=e.toLowerCase();switch(t){case"silent":return 100;case"fatal":return 60;case"error":return 50;case"warn":return 40;case"info":return 30;case"debug":return 20;case"trace":return 10;default:throw new Error(`Invalid log level: ${t}`)}}static getLogger(e,t){if(Object.prototype.hasOwnProperty.call(ue.loggers,e))return ue.loggers[e];const n=new t(e);return ue.loggers[e]=n,n}};ue.loggers={};let ie=ue;class Pr{static getLogLevel(e){const t=e.toLowerCase();switch(t){case"silent":return d.SILENT;case"fatal":return d.FATAL;case"error":return d.ERROR;case"warn":return d.WARN;case"info":return d.INFO;case"debug":return d.DEBUG;case"trace":return d.TRACE;default:throw new Error(`Invalid log level: ${t}`)}}}class nt extends ie{constructor(){super(...arguments),this.trace=this.getLogMethod("trace"),this.debug=this.getLogMethod("debug"),this.info=this.getLogMethod("info"),this.warn=this.getLogMethod("warn"),this.error=this.getLogMethod("error"),this.fatal=this.getLogMethod("fatal")}setLevel(e){this.level=e,this.trace=this.getLogMethod("trace"),this.debug=this.getLogMethod("debug"),this.info=this.getLogMethod("info"),this.warn=this.getLogMethod("warn"),this.error=this.getLogMethod("error"),this.fatal=this.getLogMethod("fatal")}getLogMethod(e){if(this.shouldLog(e)){const t=e==="debug"||e==="fatal"?"log":e,n=this.name?`${this.name}: [${e.toUpperCase()}] `:`-----> [${e.toUpperCase()}] `;return Function.prototype.bind.call(console[t],console,n)}return this.noop}static getLogger(e=""){return super.getLogger(e,nt)}}const xr={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};class Fr extends ie{constructor(e,t=""){super(t),this.name=t,this.logger=e,this.trace=Function.prototype.bind.call(e.trace,e),this.debug=Function.prototype.bind.call(e.debug,e),this.info=Function.prototype.bind.call(e.info,e),this.warn=Function.prototype.bind.call(e.warn,e),this.error=Function.prototype.bind.call(e.error,e),this.fatal=Function.prototype.bind.call(e.error,e)}setLevel(e){this.level=e,this.logger&&(this.logger.level=d[e].toLowerCase())}static getLogger(e=""){return Object.prototype.hasOwnProperty.call(ie.loggers,e)?ie.loggers[e]:null}}class st extends ie{constructor(){super(...arguments),this.trace=this.noop,this.debug=this.noop,this.info=this.noop,this.warn=this.noop,this.error=this.noop}static getLogger(e=""){return super.getLogger(e,st)}}const $r=()=>H(e=>class extends e{async requestAuthenticationToken(t=30,n=0,s=0,o=this.defaultTimeoutInMs){const c={message:new Le(t,n,s,o).getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",c);const a=new Promise((u,h)=>{this.hooks.hookOnce(`frontgateConnection:response:${c.callbackId}`,v=>{if(!v.Message.includes("AuthenticationTokenResponse")){h(JSON.stringify(v));return}const w=new Vt(v);u({token:w.getToken(),expiry:w.getExpiry()})})}),f=`Request timeout reached (${o} ms) for ${c.message.Message}`;return Y(o,f,a)}async requestAuthenticationTokenForCookieTokenAuthentication(t=30,n=0,s=0,o=this.defaultTimeoutInMs){const i=await this.requestAuthenticationToken(t,n,s,o);return new Ft(i.token)}},{featureName:"AuthTokenRequest",featureGroups:["Misc"]}),Ur=r=>H(t=>class extends t{async requestEndpoint(n,s,o,i,c=this.defaultTimeoutInMs){const a=new ye(n,s,o,{...i,allowChunkedResponse:!r?.disableChunkedResponse});a.header.setTimeout(c),r?.allowPermissionDeniedResponse&&a.header.setFlag("permission_denied_response");const f={message:a.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",f);const u=new Promise((v,w)=>{const M=[],E=()=>{this.hooks.hookOnce(`frontgateConnection:response:${f.callbackId}`,k=>{try{if(!k.Message.includes("HighLevelResponse")){w(JSON.stringify(k));return}if(this.#e(k))M.push({body:k.body?.value??"",processingTime:k.header?.processingTime??0}),E();else{M.push({body:k.body?.value??"",processingTime:k.header?.processingTime??0});const l=new Wt({...k,body:{value:M.map(g=>g.body).join("")},header:{...k.header,processingTime:M.reduce((g,p)=>g+p.processingTime,0)}});v({response:l,data:l.data})}}catch(l){w(l)}})};E()}),h=`Request timeout reached (${c} ms) for ${f.message.Message}`;return Y(c,h,u)}#e(n){return((n.header?.flags??0)&rt)===rt}},{featureName:"EndpointRequest",featureGroups:["Misc"]});var we=null;typeof WebSocket<"u"?we=WebSocket:typeof MozWebSocket<"u"?we=MozWebSocket:typeof global<"u"?we=global.WebSocket||global.MozWebSocket:typeof window<"u"?we=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(we=self.WebSocket||self.MozWebSocket);const zt=we,Kt=r=>H(t=>class extends t{#e;#t;#r="disconnected";#n;#s=0;#i;#a;get#o(){return this.#e&&this.#e.readyState<2?this.#r:"disconnected"}#c;#u=[];set conf(n){const s=this.#b(n);this.#c=s.messageBufferSize,this.#t=s}constructor(...n){super(...n),this.#i=he,this.#a=$t,r&&(this.conf=r),this.hooks.hook("frontgateConnection:setIdApp",s=>{this.#i=s}),this.hooks.hook("frontgateConnection:setIdUser",s=>{this.#a=s}),this.hooks.hook("frontgateConnection:sendMessage",s=>{if(s.callbackType==="job"){const o=this.#p(s.message);s.callbackId=`${o}`,this.#f(s.message)}if(this.#o==="connected"&&s.callbackType==="response")this.#h(s.message);else if(this.#o==="authenticated")this.#h(s.message);else{if(this.#u.length>=this.#c)throw new Error("Message buffer is full");this.#u.push(s)}}),this.hooks.hook("frontgateConnection:authenticated",()=>{if(!this.#t)throw new Error("No connection configuration set");for(this.log(d.DEBUG,"Draining message buffer");this.#u.length>0;){const s=this.#u.shift();s&&(this.#f(s.message),this.#h(s.message))}this.#n=setInterval(()=>{this.log(d.DEBUG,"Sending keepalive"),this.hooks.callHook("frontgateConnection:sendMessage",{message:this.#g(),callbackType:"response",callbackId:"KeepAliveMessage"})},this.#t.maximumIdleIntervalInS/2*1e3)}),this.hooks.hook("reconnect:attempt",async()=>{clearInterval(this.#n),this.log(d.DEBUG,"Reconnecting"),await this.hooks.callHook("frontgateConnection:reset");try{await this.connect(),await this.hooks.callHook("reconnect:success")}catch(s){this.log(d.ERROR,"Reconnect failed",s),await this.hooks.callHook("reconnect:failed",s)}})}async connect(){if(!this.#t)throw new Error("No connection configuration set");if(this.#o!=="disconnected")throw new Error("Client is already connected or is connecting right now");const{host:n,port:s,tls:o,pathPrefix:i}=this.#t;this.#r="connecting";const a=`${o?"wss":"ws"}://${n}:${s}${i??""}/ws`,f={encoding:"jsjson-v2"};await this.hooks.callHook("frontgateConnection:afterSetEncoding",f);const[u,h]=f.encoding.split("-"),w=[`${h?`${h}.`:""}ws-${u}.mdgms.com`],M={url:a,subProtocols:w};try{await this.hooks.callHook("frontgateConnection:beforeConnect",M)}catch(l){throw this.#r="disconnected",l}this.log(d.DEBUG,`Connecting to ${M.url} with subprotocols ${M.subProtocols}`);const E=new Promise((l,g)=>{if(!this.#t)throw new Error("No connection configuration set");this.#t.wsClientOptions&&typeof window>"u"?this.#e=new zt(M.url,M.subProtocols,this.#t.wsClientOptions):this.#e=new zt(M.url,M.subProtocols),this.#e.binaryType="arraybuffer";let p;this.#e.onopen=()=>{this.#r="connected",this.log(d.DEBUG,"Connected"),this.hooks.callHook("frontgateConnection:connected",this.#t).catch(g),p=this.hooks.hookOnce("frontgateConnection:authenticated",()=>{this.#r="authenticated",this.log(d.DEBUG,"Authenticated"),l()})},this.#e.onclose=y=>{p?.(),this.log(d.DEBUG,"Disconnected",y),this.#r==="connecting"||this.#r==="connected"?g(JSON.stringify(y)):this.hooks.callHook("frontgateConnection:disconnected",y),clearInterval(this.#n),this.#r="disconnected"},this.#e.onerror=y=>{p?.(),this.log(d.ERROR,"Error:",y),this.hooks.callHook("frontgateConnection:error",y),(this.#r==="connecting"||this.#r==="connected")&&g(new Error("Websocket error")),clearInterval(this.#n),this.#r="disconnected"},this.#e.onmessage=y=>{const{data:_}=y;this.log(d.DEBUG,"Received data:",_);const I={msg:_};this.hooks.callHook("frontgateConnection:afterReceiveMessage",I).then(()=>{this.log(d.DEBUG,"Received message",I.msg);const N=I.msg.toString("utf-8"),T=JSON.parse(N);if(this.hooks.callHook("frontgateConnection:message",T),T.Message==="Foundation::DisconnectionMessage"){this.#e?.close(),this.hooks.callHook("frontgateConnection:disconnected",T);return}this.#l(T)})}}),k=`Timeout reached (${this.defaultTimeoutInMs} ms) for connection to ${a}`;return Y(this.defaultTimeoutInMs,k,E)}async disconnect(){return new Promise(n=>{this.#h(this.#d()),this.hooks.hookOnce("frontgateConnection:disconnected",()=>{this.#e?.close(),n()})})}#d(){return{Message:"Foundation::DisconnectionMessage",Version:3,reason:{value:64},details:"client shutdown"}}#g(){return{Message:"KeepAliveMessage",Version:2}}async#h(n){await this.hooks.callHook("frontgateConnection:beforeSerializeMessage",n);const s={msg:JSON.stringify(n)};await this.hooks.callHook("frontgateConnection:beforeSendMessage",s),this.log(d.DEBUG,"Sending message:",n),this.log(d.TRACE,"Sending data:",s.msg);try{this.#e?.send(s.msg)}catch(o){const i=this.#v(o,n);this.#l(i.msg)}}#l(n){if(typeof n.header?.id_job<"u"){this.hooks.callHook(`frontgateConnection:response:${n.header.id_job}`,n);return}if(typeof n.header?.id_service<"u"&&typeof n.id_notation<"u"){this.hooks.callHook(`frontgateConnection:response:${n.header.id_service}-${n.id_notation}`,n);return}if(typeof n.id_job<"u"){this.hooks.callHook(`frontgateConnection:response:${n.id_job}`,n);return}typeof n.Message=="string"&&this.hooks.callHook(`frontgateConnection:response:${n.Message.replace("Foundation::","")}`,n)}#p(n){this.#s+=1;const s=this.#s;return n.header={...n.header,id_job:s},this.#s}#f(n){n.header||(n.header={authentication_identifiers:{id_application:void 0,id_user:void 0}}),n.header.authentication_identifiers||(n.header={...n.header,authentication_identifiers:{id_application:void 0,id_user:void 0}}),n.header.authentication_identifiers.id_application||=this.#i,n.header.authentication_identifiers.id_user||=this.#a}#v(n,s){return new z({Message:"Foundation::ErrorResponse",Version:1,id_job:s.header?.id_job,reason:8,details:n})}#b(n){const s=n.maximumIdleIntervalInS??60,o=n.maximumIdleInterval??s*1e6;return{...n,payloadContent:n.payloadContent??"foundation",maximumIdleIntervalInS:s,maximumIdleInterval:o,tls:n.tls??!0,messageBufferSize:n.messageBufferSize??512}}isConnected(){return this.#o==="authenticated"}isDisconnected(){return this.#r!=="authenticated"}isReadyToConnect(){return this.#o==="disconnected"}},{featureName:"WSConnection",disabledFeatureGroups:["Connection"]}),Dr=(r,e)=>(e&&r.setLevel(e),H(n=>class extends n{constructor(...s){super(...s),this.logger=r}},{featureName:"Logger",featureGroups:["Misc"]}));var P=Uint8Array,L=Uint16Array,ot=Int32Array,Je=new P([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ze=new P([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),it=new P([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yt=function(r,e){for(var t=new L(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var s=new ot(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)s[o]=o-t[n]<<5|n;return{b:t,r:s}},Qt=Yt(Je,2),Xt=Qt.b,at=Qt.r;Xt[28]=258,at[258]=28;for(var Zt=Yt(ze,0),jr=Zt.b,er=Zt.r,ct=new L(32768),A=0;A<32768;++A){var ae=(A&43690)>>1|(A&21845)<<1;ae=(ae&52428)>>2|(ae&13107)<<2,ae=(ae&61680)>>4|(ae&3855)<<4,ct[A]=((ae&65280)>>8|(ae&255)<<8)>>1}for(var te=(function(r,e,t){for(var n=r.length,s=0,o=new L(e);s<n;++s)r[s]&&++o[r[s]-1];var i=new L(e);for(s=1;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;var c;if(t){c=new L(1<<e);var a=15-e;for(s=0;s<n;++s)if(r[s])for(var f=s<<4|r[s],u=e-r[s],h=i[r[s]-1]++<<u,v=h|(1<<u)-1;h<=v;++h)c[ct[h]>>a]=f}else for(c=new L(n),s=0;s<n;++s)r[s]&&(c[s]=ct[i[r[s]-1]++]>>15-r[s]);return c}),ce=new P(288),A=0;A<144;++A)ce[A]=8;for(var A=144;A<256;++A)ce[A]=9;for(var A=256;A<280;++A)ce[A]=7;for(var A=280;A<288;++A)ce[A]=8;for(var Ce=new P(32),A=0;A<32;++A)Ce[A]=5;var Hr=te(ce,9,0),Gr=te(ce,9,1),qr=te(Ce,5,0),Lr=te(Ce,5,1),ut=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},Q=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},ht=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},lt=function(r){return(r+7)/8|0},de=function(r,e,t){return(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new P(r.subarray(e,t))},Br=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],F=function(r,e,t){var n=new Error(e||Br[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,F),!t)throw n;return n},Vr=function(r,e,t,n){var s=r.length,o=0;if(!s||e.f&&!e.l)return t||new P(0);var i=!t,c=i||e.i!=2,a=e.i;i&&(t=new P(s*3));var f=function(De){var je=t.length;if(De>je){var Ie=new P(Math.max(je*2,De));Ie.set(t),t=Ie}},u=e.f||0,h=e.p||0,v=e.b||0,w=e.l,M=e.d,E=e.m,k=e.n,l=s*8;do{if(!w){u=Q(r,h,1);var g=Q(r,h+1,3);if(h+=3,g)if(g==1)w=Gr,M=Lr,E=9,k=5;else if(g==2){var I=Q(r,h,31)+257,N=Q(r,h+10,15)+4,T=I+Q(r,h+5,31)+1;h+=14;for(var m=new P(T),O=new P(19),C=0;C<N;++C)O[it[C]]=Q(r,h+C*3,7);h+=N*3;for(var R=ut(O),U=(1<<R)-1,q=te(O,R,1),C=0;C<T;){var $=q[Q(r,h,U)];h+=$&15;var p=$>>4;if(p<16)m[C++]=p;else{var D=0,S=0;for(p==16?(S=3+Q(r,h,3),h+=2,D=m[C-1]):p==17?(S=3+Q(r,h,7),h+=3):p==18&&(S=11+Q(r,h,127),h+=7);S--;)m[C++]=D}}var j=m.subarray(0,I),G=m.subarray(I);E=ut(j),k=ut(G),w=te(j,E,1),M=te(G,k,1)}else F(1);else{var p=lt(h)+4,y=r[p-4]|r[p-3]<<8,_=p+y;if(_>s){a&&F(0);break}c&&f(v+y),t.set(r.subarray(p,_),v),e.b=v+=y,e.p=h=_*8,e.f=u;continue}if(h>l){a&&F(0);break}}c&&f(v+131072);for(var Ue=(1<<E)-1,K=(1<<k)-1,oe=h;;oe=h){var D=w[ht(r,h)&Ue],W=D>>4;if(h+=D&15,h>l){a&&F(0);break}if(D||F(2),W<256)t[v++]=W;else if(W==256){oe=h,w=null;break}else{var J=W-254;if(W>264){var C=W-257,x=Je[C];J=Q(r,h,(1<<x)-1)+Xt[C],h+=x}var ne=M[ht(r,h)&K],Ee=ne>>4;ne||F(3),h+=ne&15;var G=jr[Ee];if(Ee>3){var x=ze[Ee];G+=ht(r,h)&(1<<x)-1,h+=x}if(h>l){a&&F(0);break}c&&f(v+131072);var Te=v+J;if(v<G){var Xe=o-G,Ze=Math.min(G,Te);for(Xe+v<0&&F(3);v<Ze;++v)t[v]=n[Xe+v]}for(;v<Te;++v)t[v]=t[v-G]}}e.l=w,e.p=oe,e.b=v,e.f=u,w&&(u=1,e.m=E,e.d=M,e.n=k)}while(!u);return v!=t.length&&i?de(t,0,v):t.subarray(0,v)},se=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8},Re=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},ft=function(r,e){for(var t=[],n=0;n<r.length;++n)r[n]&&t.push({s:n,f:r[n]});var s=t.length,o=t.slice();if(!s)return{t:sr,l:0};if(s==1){var i=new P(t[0].s+1);return i[t[0].s]=1,{t:i,l:1}}t.sort(function(_,I){return _.f-I.f}),t.push({s:-1,f:25001});var c=t[0],a=t[1],f=0,u=1,h=2;for(t[0]={s:-1,f:c.f+a.f,l:c,r:a};u!=s-1;)c=t[t[f].f<t[h].f?f++:h++],a=t[f!=u&&t[f].f<t[h].f?f++:h++],t[u++]={s:-1,f:c.f+a.f,l:c,r:a};for(var v=o[0].s,n=1;n<s;++n)o[n].s>v&&(v=o[n].s);var w=new L(v+1),M=dt(t[u-1],w,0);if(M>e){var n=0,E=0,k=M-e,l=1<<k;for(o.sort(function(I,N){return w[N.s]-w[I.s]||I.f-N.f});n<s;++n){var g=o[n].s;if(w[g]>e)E+=l-(1<<M-w[g]),w[g]=e;else break}for(E>>=k;E>0;){var p=o[n].s;w[p]<e?E-=1<<e-w[p]++-1:++n}for(;n>=0&&E;--n){var y=o[n].s;w[y]==e&&(--w[y],++E)}M=e}return{t:new P(w),l:M}},dt=function(r,e,t){return r.s==-1?Math.max(dt(r.l,e,t+1),dt(r.r,e,t+1)):e[r.s]=t},tr=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new L(++e),n=0,s=r[0],o=1,i=function(a){t[n++]=a},c=1;c<=e;++c)if(r[c]==s&&c!=e)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=r[c]}return{c:t.subarray(0,n),n:e}},Ae=function(r,e){for(var t=0,n=0;n<e.length;++n)t+=r[n]*e[n];return t},rr=function(r,e,t){var n=t.length,s=lt(e+2);r[s]=n&255,r[s+1]=n>>8,r[s+2]=r[s]^255,r[s+3]=r[s+1]^255;for(var o=0;o<n;++o)r[s+o+4]=t[o];return(s+4+n)*8},nr=function(r,e,t,n,s,o,i,c,a,f,u){se(e,u++,t),++s[256];for(var h=ft(s,15),v=h.t,w=h.l,M=ft(o,15),E=M.t,k=M.l,l=tr(v),g=l.c,p=l.n,y=tr(E),_=y.c,I=y.n,N=new L(19),T=0;T<g.length;++T)++N[g[T]&31];for(var T=0;T<_.length;++T)++N[_[T]&31];for(var m=ft(N,7),O=m.t,C=m.l,R=19;R>4&&!O[it[R-1]];--R);var U=f+5<<3,q=Ae(s,ce)+Ae(o,Ce)+i,$=Ae(s,v)+Ae(o,E)+i+14+3*R+Ae(N,O)+2*N[16]+3*N[17]+7*N[18];if(a>=0&&U<=q&&U<=$)return rr(e,u,r.subarray(a,a+f));var D,S,j,G;if(se(e,u,1+($<q)),u+=2,$<q){D=te(v,w,0),S=v,j=te(E,k,0),G=E;var Ue=te(O,C,0);se(e,u,p-257),se(e,u+5,I-1),se(e,u+10,R-4),u+=14;for(var T=0;T<R;++T)se(e,u+3*T,O[it[T]]);u+=3*R;for(var K=[g,_],oe=0;oe<2;++oe)for(var W=K[oe],T=0;T<W.length;++T){var J=W[T]&31;se(e,u,Ue[J]),u+=O[J],J>15&&(se(e,u,W[T]>>5&127),u+=W[T]>>12)}}else D=Hr,S=ce,j=qr,G=Ce;for(var T=0;T<c;++T){var x=n[T];if(x>255){var J=x>>18&31;Re(e,u,D[J+257]),u+=S[J+257],J>7&&(se(e,u,x>>23&31),u+=Je[J]);var ne=x&31;Re(e,u,j[ne]),u+=G[ne],ne>3&&(Re(e,u,x>>5&8191),u+=ze[ne])}else Re(e,u,D[x]),u+=S[x]}return Re(e,u,D[256]),u+S[256]},Wr=new ot([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),sr=new P(0),Jr=function(r,e,t,n,s,o){var i=o.z||r.length,c=new P(n+i+5*(1+Math.ceil(i/7e3))+s),a=c.subarray(n,c.length-s),f=o.l,u=(o.r||0)&7;if(e){u&&(a[0]=o.r>>3);for(var h=Wr[e-1],v=h>>13,w=h&8191,M=(1<<t)-1,E=o.p||new L(32768),k=o.h||new L(M+1),l=Math.ceil(t/3),g=2*l,p=function(St){return(r[St]^r[St+1]<<l^r[St+2]<<g)&M},y=new ot(25e3),_=new L(288),I=new L(32),N=0,T=0,m=o.i||0,O=0,C=o.w||0,R=0;m+2<i;++m){var U=p(m),q=m&32767,$=k[U];if(E[q]=$,k[U]=q,C<=m){var D=i-m;if((N>7e3||O>24576)&&(D>423||!f)){u=nr(r,a,0,y,_,I,T,O,R,m-R,u),O=N=T=0,R=m;for(var S=0;S<286;++S)_[S]=0;for(var S=0;S<30;++S)I[S]=0}var j=2,G=0,Ue=w,K=q-$&32767;if(D>2&&U==p(m-K))for(var oe=Math.min(v,D)-1,W=Math.min(32767,m),J=Math.min(258,D);K<=W&&--Ue&&q!=$;){if(r[m+j]==r[m+j-K]){for(var x=0;x<J&&r[m+x]==r[m+x-K];++x);if(x>j){if(j=x,G=K,x>oe)break;for(var ne=Math.min(K,x-2),Ee=0,S=0;S<ne;++S){var Te=m-K+S&32767,Xe=E[Te],Ze=Te-Xe&32767;Ze>Ee&&(Ee=Ze,$=Te)}}}q=$,$=E[q],K+=q-$&32767}if(G){y[O++]=268435456|at[j]<<18|er[G];var De=at[j]&31,je=er[G]&31;T+=Je[De]+ze[je],++_[257+De],++I[je],C=m+j,++N}else y[O++]=r[m],++_[r[m]]}}for(m=Math.max(m,C);m<i;++m)y[O++]=r[m],++_[r[m]];u=nr(r,a,f,y,_,I,T,O,R,m-R,u),f||(o.r=u&7|a[u/8|0]<<3,u-=7,o.h=k,o.p=E,o.i=m,o.w=C)}else{for(var m=o.w||0;m<i+f;m+=65535){var Ie=m+65535;Ie>=i&&(a[u/8|0]=f,Ie=i),u=rr(a,u+1,r.subarray(m,Ie))}o.i=i}return de(c,0,n+lt(u)+s)},or=function(){var r=1,e=0;return{p:function(t){for(var n=r,s=e,o=t.length|0,i=0;i!=o;){for(var c=Math.min(i+2655,o);i<c;++i)s+=n+=t[i];n=(n&65535)+15*(n>>16),s=(s&65535)+15*(s>>16)}r=n,e=s},d:function(){return r%=65521,e%=65521,(r&255)<<24|(r&65280)<<8|(e&255)<<8|e>>8}}},ir=function(r,e,t,n,s){if(!s&&(s={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),i=new P(o.length+r.length);i.set(o),i.set(r,o.length),r=i,s.w=o.length}return Jr(r,e.level==null?6:e.level,e.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,n,s)},ar=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},zr=function(r,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;if(r[0]=120,r[1]=n<<6|(e.dictionary&&32),r[1]|=31-(r[0]<<8|r[1])%31,e.dictionary){var s=or();s.p(e.dictionary),ar(r,2,s.d())}},Kr=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&F(6,"invalid zlib data"),(r[1]>>5&1)==+!e&&F(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2},gt=(function(){function r(e,t){if(typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new P(98304),this.o.dictionary){var n=this.o.dictionary.subarray(-32768);this.b.set(n,32768-n.length),this.s.i=32768-n.length}}return r.prototype.p=function(e,t){this.ondata(ir(e,this.o,0,0,this.s),t)},r.prototype.push=function(e,t){this.ondata||F(5),this.s.l&&F(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var s=new P(n&-32768);s.set(this.b.subarray(0,this.s.z)),this.b=s}var o=this.b.length-this.s.z;this.b.set(e.subarray(0,o),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(o),32768),this.s.z=e.length-o+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=t&1,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},r.prototype.flush=function(){this.ondata||F(5),this.s.l&&F(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},r})(),pt=(function(){function r(e,t){typeof e=="function"&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new P(32768),this.p=new P(0),n&&this.o.set(n)}return r.prototype.e=function(e){if(this.ondata||F(5),this.d&&F(4),!this.p.length)this.p=e;else if(e.length){var t=new P(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},r.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=Vr(this.p,this.s,this.o);this.ondata(de(n,t,this.s.b),this.d),this.o=de(n,this.s.b-32768),this.s.b=this.o.length,this.p=de(this.p,this.s.p/8|0),this.s.p&=7},r.prototype.push=function(e,t){this.e(e),this.c(t)},r})(),Yr=(function(){function r(e,t){this.c=or(),this.v=1,gt.call(this,e,t)}return r.prototype.push=function(e,t){this.c.p(e),gt.prototype.push.call(this,e,t)},r.prototype.p=function(e,t){var n=ir(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(zr(n,this.o),this.v=0),t&&ar(n,n.length-4,this.c.d()),this.ondata(n,t)},r.prototype.flush=function(){gt.prototype.flush.call(this)},r})(),Qr=(function(){function r(e,t){pt.call(this,e,t),this.v=e&&e.dictionary?2:1}return r.prototype.push=function(e,t){if(pt.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(Kr(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&F(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),pt.prototype.c.call(this,t)},r})(),cr=typeof TextEncoder<"u"&&new TextEncoder,vt=typeof TextDecoder<"u"&&new TextDecoder,Xr=0;try{vt.decode(sr,{stream:!0}),Xr=1}catch{}var Zr=function(r){for(var e="",t=0;;){var n=r[t++],s=(n>127)+(n>223)+(n>239);if(t+s>r.length)return{s:e,r:de(r,t-1)};s?s==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):s&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function en(r,e){var t;if(cr)return cr.encode(r);for(var n=r.length,s=new P(r.length+(r.length>>1)),o=0,i=function(f){s[o++]=f},t=0;t<n;++t){if(o+5>s.length){var c=new P(o+8+(n-t<<1));c.set(s),s=c}var a=r.charCodeAt(t);a<128||e?i(a):a<2048?(i(192|a>>6),i(128|a&63)):a>55295&&a<57344?(a=65536+(a&1047552)|r.charCodeAt(++t)&1023,i(240|a>>18),i(128|a>>12&63),i(128|a>>6&63),i(128|a&63)):(i(224|a>>12),i(128|a>>6&63),i(128|a&63))}return de(s,0,o)}function tn(r,e){var t;if(vt)return vt.decode(r);var n=Zr(r),s=n.s,t=n.r;return t.length&&F(8),s}const rn=r=>{if(r.length===1)return r[0];const e=new Uint8Array(r.reduce((t,n)=>t+n.length,0));for(let t=0,n=0;t<r.length;++t)e.set(r[t],n),n+=r[t].length;return e};class nn{constructor(){this.reset()}reset(){this.compressor=null,this.decompressor=null}compress(e){this.compressor||(this.compressor=new Yr({mem:4}));const t=[];return this.compressor.ondata=n=>{t.push(n)},this.compressor.push(en(e)),this.compressor.flush(),rn(t)}decompress(e){this.decompressor||(this.decompressor=new Qr);let t;this.decompressor.ondata=n=>{t=n};try{if(this.decompressor.push(e),t===void 0)throw new Error("invalid block type")}catch(n){throw new Error(`Decompression error: ${n.message}, length: ${e.length}, data: [${e.toString()}]`)}return tn(t)}}const sn=()=>H(e=>class extends e{#e;constructor(...t){super(...t),this.#e=new nn,this.hooks.hook("frontgateConnection:reset",()=>{this.#e.reset()}),this.hooks.hook("frontgateConnection:afterSetEncoding",n=>{n.encoding="jsjsonc-v2"}),this.hooks.hook("frontgateConnection:beforeSendMessage",n=>{const s=this.#e.compress(n.msg);n.msg=s}),this.hooks.hook("frontgateConnection:afterReceiveMessage",n=>{const s=this.#e.decompress(new Uint8Array(n.msg));n.msg=s})}},{featureName:"MessageCompressor",featureGroups:["Misc"]}),on=()=>H(e=>class extends e{async request(t,n=this.defaultTimeoutInMs){t.header.setTimeout(n);const s={message:t.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",s);const o=new Promise(c=>{this.hooks.hookOnce(`frontgateConnection:response:${s.callbackId}`,a=>{const f=new fe(a);c(f)})}),i=`Request timeout reached (${n} ms) for ${s.message.Message}`;return Y(n,i,o)}},{featureName:"Request",featureGroups:["Misc"]}),an=r=>H(t=>{const n={...r};return class extends t{#e=new Map;#t=new Map;#r=new Map;async observeEndpoint(s,o,i,c){const a=`${s}:${o}:${JSON.stringify(i)}:${JSON.stringify(c??{})}`;if(this.#r.has(a)){const k=this.#r.get(a);this.log(d.INFO,`Catching inflight subscription for ${a}`);const l=this.#t.get(a)??0;return this.#t.set(a,l+1),k}const f=n.timeout??this.defaultTimeoutInMs,u=n.subscriptionResubscribeTimeout??1e3;if(this.#e.has(a)){const k=this.#e.get(a),l=this.#t.get(a)??0;if(k)return this.#t.set(a,l+1),this.log(d.INFO,`Reusing existing subscription for ${a}`),k}this.log(d.INFO,`Creating new subscription for ${a}`);const h=new ye(s,o,i,{...c,subscribe:!0});h.header.setTimeout(f);const v={message:h.getPtlMessage(),callbackType:"job",callbackId:""},w=new Promise((k,l)=>{this.hooks.callHook("frontgateConnection:sendMessage",v).then(()=>{this.hooks.hookOnce(`frontgateConnection:response:${v.callbackId}`,g=>{if(!g.Message.includes("HighLevelResponse")){this.log(d.ERROR,`Unexpected response: ${g.Message}`),l(new z(JSON.stringify(g)));return}let p;try{p=JSON.parse(g.body.value)}catch(m){this.log(d.ERROR,`Failed to parse response: ${g.body.value}`),this.log(d.ERROR,m),l(m);return}const y=new ur(g.header.id_job,p);let _=this.hooks.hook(`frontgateConnection:response:${v.callbackId}`,m=>{if(!m.Message.includes("HighLevelUpdate")){if(m.Message.includes("SubscriptionLoss")){this.log(d.DEBUG,`Received: ${m.Message}`),setTimeout(()=>{I()},qt(u)),_();return}this.log(d.ERROR,`Unexpected response: ${g.Message}`),y.pushError(new z(JSON.stringify(m))),_();return}let O;try{O=new tt(m)}catch(C){this.log(d.ERROR,`Failed to parse response: ${m.body.value}`),y.pushError(C);return}y.pushPatchData(O.data)});const I=async()=>{_(),this.log(d.INFO,`Resubscribing to ${a} due to reconnect`),await this.hooks.callHook("frontgateConnection:sendMessage",v);const m=new Promise((O,C)=>{this.hooks.hookOnce(`frontgateConnection:response:${v.callbackId}`,R=>{if(!g.Message.includes("HighLevelResponse")){const U=new z(R);this.log(d.ERROR,`Unexpected response: ${R.Message}`),_(),C(U);return}this.log(d.INFO,`Resubscribed to ${a} with ${R.header.id_job}`),y.idJob=R.header.id_job,_=this.hooks.hook(`frontgateConnection:response:${R.header.id_job}`,U=>{if(!U.Message.includes("HighLevelUpdate")){if(U.Message.includes("SubscriptionLoss")){this.log(d.DEBUG,`Received: ${U.Message}`),setTimeout(()=>{I()},qt(u));return}this.log(d.ERROR,`Unexpected response: ${U.Message}`);const $=new z(U);y.pushError($);return}let q;try{q=new tt(U)}catch($){this.log(d.ERROR,`Failed to parse response: ${U.body.value}`),y.pushError($);return}y.unsubscribe=()=>{if(this.#e.get(a)){const j=this.#t.get(a)??0;if(this.#t.set(a,j-1),j-1>0){this.log(d.INFO,`Not unsubscribing from ${a} as there are still ${j} subscribers`);return}this.#e.delete(a),this.#t.delete(a)}this.log(d.INFO,`Unsubscribing from ${a}`);const S={message:new le(y.idJob).getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",S),_(),N()},y.pushPatchData(q.data)}),O()})});try{await Y(f,"Request timeout reached",m)}catch(O){y.pushError(new z({Message:"Reconnect failed",Error:O}))}},N=this.hooks.hook("reconnect:success",I);y.unsubscribe=()=>{if(this.#e.get(a)){const R=this.#t.get(a)??0;if(this.#t.set(a,R-1),R-1>0){this.log(d.INFO,`Not unsubscribing from ${a} as there are still ${R} subscribers`);return}this.#e.delete(a),this.#t.delete(a)}this.log(d.INFO,`Unsubscribing from ${a}`);const C={message:new le(y.idJob).getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",C),_(),N()},this.#e.set(a,y);const T=this.#t.get(a)??0;this.#t.set(a,T+1),k(y)})}).catch(g=>{l(g)})}),M=`Request timeout reached (${f} ms) for ${v.message.Message}`,E=Y(f,M,w).finally(()=>{this.#r.delete(a)});return this.#r.set(a,E),E}}},{featureName:"EndpointSubscriptions",featureGroups:["Misc"]}),cn=()=>H(e=>class extends e{#e=new Map;async observe(t,n=this.defaultTimeoutInMs){return this.#t(t,"job",void 0,n)}async observeConnectionBased(t,n,s=this.defaultTimeoutInMs){return this.#t(t,"connection",n,s)}async#t(t,n,s,o=this.defaultTimeoutInMs){const i=JSON.stringify(t.getPtlMessage());if(this.#e.has(i)){const h=this.#e.get(i);if(h)return h.count++,this.log(d.INFO,`Reusing existing subscription for ${i}`),h.observer}this.log(d.INFO,`Creating new subscription for ${i}`);const a={message:t.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",a);const f=new Promise((h,v)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,w=>{if(w.Message.includes("Error")||w.Message.includes("PermissionDenied")){this.log(d.ERROR,`Unexpected response: ${w.Message}`),v(new Error(`Unexpected response: ${w.Message}`));return}const M=n==="connection"?`${w.header.id_service}-${t.getPtlMessage().id_notation}`:w.header.id_job,E=typeof s>"u"?new le(w.header.id_job):new s(w.header.id_service,t.getPtlMessage().id_notation),k=new mt(w.header.id_job,w);let l=this.hooks.hook(`frontgateConnection:response:${M}`,p=>{if(p.Message.includes("Error")||p.Message.includes("PermissionDenied")){this.log(d.ERROR,`Unexpected response: ${w.Message}`),k.pushError(new z(JSON.stringify(p)));return}k.pushData(p)});const g=this.hooks.hook("reconnect:success",async()=>{l(),this.log(d.INFO,`Resubscribing to ${i} due to reconnect`),await this.hooks.callHook("frontgateConnection:sendMessage",a);const p=new Promise((y,_)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,I=>{if(I.Message.includes("Error")||I.Message.includes("PermissionDenied")){const m=new z(I);this.log(d.ERROR,`Unexpected resp: ${I.Message}`),_(m);return}const N=n==="connection"?`${I.header.id_service}-${t.getPtlMessage().id_notation}`:I.header.id_job,T=typeof s>"u"?new le(I.header.id_job):new s(I.header.id_service,t.getPtlMessage().id_notation);k.idJob=I.header.id_job,l=this.hooks.hook(`frontgateConnection:response:${N}`,m=>{if(m.Message.includes("Error")||m.Message.includes("PermissionDenied")){this.log(d.ERROR,`Unexpected response: ${m.Message}`);const O=new z(m);k.pushError(O);return}k.unsubscribe=()=>{const O=this.#e.get(i);if(O){if(O.count--,O.count>0){this.log(d.INFO,`Not unsubscribing from ${i} as there are still ${O.count} subscribers`);return}this.#e.delete(i)}this.log(d.INFO,`Unsubscribing from ${i}`);const C={message:T.getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",C),l(),g()},k.pushData(m)}),y()})});try{await Y(o,"Request timeout reached",p)}catch(y){k.pushError(new z({Message:"Reconnect failed",Error:y}))}});k.unsubscribe=()=>{const p=this.#e.get(i);if(p){if(p.count--,p.count>0){this.log(d.INFO,`Not unsubscribing from ${i} as there are still ${p.count} subscribers`);return}this.#e.delete(i)}this.log(d.INFO,`Unsubscribing from ${i}`);const y={message:E.getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",y),l(),g()},this.#e.set(i,{observer:k,count:1}),h(k)})}),u=`Request timeout reached (${o} ms) for ${a.message.Message}`;return Y(o,u,f)}},{featureName:"RawSubscriptions",featureGroups:["Misc"]}),bt=(r,e)=>{const t=e.split("/").slice(1);let n=r;for(let s=0;s<t.length-1;s++){const o=decodeURIComponent(t[s]);if(!(o in n))throw new Error(`Path not found: ${e}`);n=n[o]}return[n,decodeURIComponent(t[t.length-1])]},un=(r,e,t)=>{const[n,s]=bt(r,e);n[s]=t},hn="-",ln=(r,e,t)=>{const[n,s]=bt(r,e);Array.isArray(n)?s===hn?n.push(t):n.splice(parseInt(s,10),0,t):n[s]=t},fn=(r,e)=>{const[t,n]=bt(r,e);Array.isArray(t)?t.splice(parseInt(n,10),1):delete t[n]};function dn(r,e){return e.forEach(t=>{switch(t.op){case"replace":un(r,t.path,t.value);break;case"add":ln(r,t.path,t.value);break;case"remove":fn(r,t.path);break;case"move":case"copy":case"test":default:throw new Error(`Unsupported op: ${t.op}`)}}),r}class mt{#e;#t=[];#r=[];get data(){return this.#e}constructor(e,t){this.#e=t,this.idJob=e}subscribe({next:e,error:t}){e(this.#e),t&&this.#r.push(t),this.#t.push(e)}pushData(e){this.#e=e,this.#t.forEach(t=>{t(e)})}pushError(e){this.#r.forEach(t=>{t(e)})}}class ur extends mt{pushPatchData(e){try{const t=dn(this.data,e);super.pushData(t)}catch(t){super.pushError(new z(t.message))}}}const gn=r=>H(t=>class extends t{constructor(...n){super(...n),this.hooks.hook("frontgateConnection:beforeConnect",o=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be),this.log(d.DEBUG,"Adding mdg2auth subprotocol"),o.subProtocols.push(`mdg2auth-${r}`)});const s=async o=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be);const i={maximum_idle_interval:o.maximumIdleInterval},c={b64:""},f=new qe(c,i.maximum_idle_interval).toJson();this.log(d.INFO,"Sending message",f);const u={message:f,callbackType:"response",callbackId:f.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",u),this.hooks.hookOnce(`frontgateConnection:response:${u.callbackId}`,h=>{this.log(d.INFO,"Received response",h),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hookOnce("frontgateConnection:connected",s)}},{featureName:"CookieTokenAuth",featureGroups:["Auth"],disabledFeatureGroups:["Auth"]}),pn=r=>H(t=>class extends t{#e;constructor(...n){super(...n),this.#e=r??"";const s=async o=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be);const i={maximum_idle_interval:o.maximumIdleInterval},c={b64:this.#e},f=new qe(c,i.maximum_idle_interval).toJson();this.log(d.INFO,"Sending message",f);const u={message:f,callbackType:"response",callbackId:f.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",u),this.hooks.hookOnce(`frontgateConnection:response:${u.callbackId}`,h=>{this.log(d.INFO,"Received response",h),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hook("frontgateConnection:connected",s)}set token(n){this.#e=n}},{featureName:"TokenAuth",featureGroups:["Auth"],disabledFeatureGroups:["Auth"]}),vn=(r,e,t)=>H(s=>class extends Kt({host:"",pathPrefix:"",port:0,tls:!0,maximumIdleIntervalInS:r.maximumIdleIntervalInS})(s){#e="";#t="";#r;#n;constructor(...o){super(...o),this.#r=e,this.#n=t,this.hooks.hook("frontgateConnection:beforeConnect",async c=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be),this.log(d.DEBUG,"Fetching connection configuration");const a=await this.#s();if(this.log(d.DEBUG,"Connection configuration received",a),c.url=a.url,a.authtenticationType==="token"&&a.authenticationToken)this.#e=a.authenticationToken;else if(a.splitAuthenticationTokenSecondFactor)this.#t=a.splitAuthenticationTokenSecondFactor;else throw new Error("Invalid authentication configuration");this.log(d.DEBUG,"Adding mdg2auth subprotocol"),this.#t!==""&&c.subProtocols.push(`mdg2auth-${this.#t}`)});const i=async c=>{this.hooks.callHook("frontgateConnection:setIdApp",he),this.hooks.callHook("frontgateConnection:setIdUser",be);const a={maximum_idle_interval:c.maximumIdleInterval},f={b64:this.#e},h=new qe(f,a.maximum_idle_interval).toJson();this.log(d.INFO,"Sending message",h);const v={message:h,callbackType:"response",callbackId:h.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",v),this.hooks.hookOnce(`frontgateConnection:response:${v.callbackId}`,w=>{this.log(d.INFO,"Received response",w),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hook("frontgateConnection:connected",i)}async#s(){const o=await fetch(this.#r,this.#n);if(!o.ok)throw new Error(`Failed to fetch connection configuration: ${o.status} ${o.statusText}`);const{headers:i}=o,c=i.get("frontgate-host"),a=i.get("frontgate-path-prefix"),f=i.get("frontgate-split-authentication-token-second-factor"),u=i.get("frontgate-authentication-type"),h=i.get("frontgate-authentication-token"),v=i.get("frontgate-websocket-port")??"443",w=`wss://${c}:${v}${a??""}/ws`;if(u==="token"&&!h)throw new Error("Authentication token is required for token authentication");if(u!=="token"&&!f)throw new Error("Split authentication token second factor is required");return{url:w,authtenticationType:u,authenticationToken:h,splitAuthenticationTokenSecondFactor:f}}},{featureName:"FetchAuth",featureGroups:["Auth","Connection"],disabledFeatureGroups:["Auth","Connection"]}),bn=r=>H(t=>class extends t{#e=0;#t;#r;constructor(...n){super(...n),this.#t=r??[1e3,2e3,4e3,8e3,16e3,32e3];const s=o=>{if(o.code!==1e3){this.#r&&(this.log(d.WARN,"Aborting previous reconnect attempt"),clearTimeout(this.#r),this.#e=0);let i=this.#e;this.#e>=this.#t.length&&(i=this.#t.length-1);const c=this.#t[i];this.#r=setTimeout(()=>{this.log(d.INFO,`Reconnecting... Attempt ${this.#e}`);const a=this.hooks.hookOnce("reconnect:failed",s);this.hooks.callHook("reconnect:attempt",o).then(a).catch(()=>{this.log(d.ERROR,"Failed to reconnect")}),this.#r=void 0},c),this.#e++}};this.hooks.hookOnce("frontgateConnection:disconnected",s),this.hooks.hook("reconnect:success",()=>{clearTimeout(this.#r),this.#r=void 0,this.#e=0,this.log(d.INFO,"Reconnected"),this.hooks.hookOnce("frontgateConnection:disconnected",s)})}},{featureName:"Reconnect",featureGroups:["Misc"],disabledFeatures:["TokenAuth","CookieTokenAuth"]});var mn=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},ge="1.9.0",hr=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function yn(r){var e=new Set([r]),t=new Set,n=r.match(hr);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(a){return a===r};function o(c){return t.add(c),!1}function i(c){return e.add(c),!0}return function(a){if(e.has(a))return!0;if(t.has(a))return!1;var f=a.match(hr);if(!f)return o(a);var u={major:+f[1],minor:+f[2],patch:+f[3],prerelease:f[4]};return u.prerelease!=null||s.major!==u.major?o(a):s.major===0?s.minor===u.minor&&s.patch<=u.patch?i(a):o(a):s.minor<=u.minor?i(a):o(a)}}var wn=yn(ge),kn=ge.split(".")[0],Ne=Symbol.for("opentelemetry.js.api."+kn),Se=mn;function Pe(r,e,t,n){var s;n===void 0&&(n=!1);var o=Se[Ne]=(s=Se[Ne])!==null&&s!==void 0?s:{version:ge};if(!n&&o[r]){var i=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+r);return t.error(i.stack||i.message),!1}if(o.version!==ge){var i=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+r+" does not match previously registered API v"+ge);return t.error(i.stack||i.message),!1}return o[r]=e,t.debug("@opentelemetry/api: Registered a global for "+r+" v"+ge+"."),!0}function pe(r){var e,t,n=(e=Se[Ne])===null||e===void 0?void 0:e.version;if(!(!n||!wn(n)))return(t=Se[Ne])===null||t===void 0?void 0:t[r]}function xe(r,e){e.debug("@opentelemetry/api: Unregistering a global for "+r+" v"+ge+".");var t=Se[Ne];t&&delete t[r]}var _n=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},Mn=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},En=(function(){function r(e){this._namespace=e.namespace||"DiagComponentLogger"}return r.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("debug",this._namespace,e)},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("error",this._namespace,e)},r.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("info",this._namespace,e)},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("warn",this._namespace,e)},r.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Fe("verbose",this._namespace,e)},r})();function Fe(r,e,t){var n=pe("diag");if(n)return t.unshift(e),n[r].apply(n,Mn([],_n(t),!1))}var B;(function(r){r[r.NONE=0]="NONE",r[r.ERROR=30]="ERROR",r[r.WARN=50]="WARN",r[r.INFO=60]="INFO",r[r.DEBUG=70]="DEBUG",r[r.VERBOSE=80]="VERBOSE",r[r.ALL=9999]="ALL"})(B||(B={}));function Tn(r,e){r<B.NONE?r=B.NONE:r>B.ALL&&(r=B.ALL),e=e||{};function t(n,s){var o=e[n];return typeof o=="function"&&r>=s?o.bind(e):function(){}}return{error:t("error",B.ERROR),warn:t("warn",B.WARN),info:t("info",B.INFO),debug:t("debug",B.DEBUG),verbose:t("verbose",B.VERBOSE)}}var In=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},On=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},Cn="diag",re=(function(){function r(){function e(s){return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];var c=pe("diag");if(c)return c[s].apply(c,On([],In(o),!1))}}var t=this,n=function(s,o){var i,c,a;if(o===void 0&&(o={logLevel:B.INFO}),s===t){var f=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((i=f.stack)!==null&&i!==void 0?i:f.message),!1}typeof o=="number"&&(o={logLevel:o});var u=pe("diag"),h=Tn((c=o.logLevel)!==null&&c!==void 0?c:B.INFO,s);if(u&&!o.suppressOverrideMessage){var v=(a=new Error().stack)!==null&&a!==void 0?a:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+v),h.warn("Current logger will overwrite one already registered from "+v)}return Pe("diag",h,t,!0)};t.setLogger=n,t.disable=function(){xe(Cn,t)},t.createComponentLogger=function(s){return new En(s)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return r.instance=function(){return this._instance||(this._instance=new r),this._instance},r})(),Rn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},An=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Nn=(function(){function r(e){this._entries=e?new Map(e):new Map}return r.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},r.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=Rn(e,2),n=t[0],s=t[1];return[n,s]})},r.prototype.setEntry=function(e,t){var n=new r(this._entries);return n._entries.set(e,t),n},r.prototype.removeEntry=function(e){var t=new r(this._entries);return t._entries.delete(e),t},r.prototype.removeEntries=function(){for(var e,t,n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];var o=new r(this._entries);try{for(var i=An(n),c=i.next();!c.done;c=i.next()){var a=c.value;o._entries.delete(a)}}catch(f){e={error:f}}finally{try{c&&!c.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return o},r.prototype.clear=function(){return new r},r})();re.instance();function Sn(r){return r===void 0&&(r={}),new Nn(new Map(Object.entries(r)))}function lr(r){return Symbol.for(r)}var Pn=(function(){function r(e){var t=this;t._currentContext=e?new Map(e):new Map,t.getValue=function(n){return t._currentContext.get(n)},t.setValue=function(n,s){var o=new r(t._currentContext);return o._currentContext.set(n,s),o},t.deleteValue=function(n){var s=new r(t._currentContext);return s._currentContext.delete(n),s}}return r})(),xn=new Pn,ve=(function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(n[o]=s[o])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}})(),Fn=(function(){function r(){}return r.prototype.createGauge=function(e,t){return Vn},r.prototype.createHistogram=function(e,t){return Wn},r.prototype.createCounter=function(e,t){return Bn},r.prototype.createUpDownCounter=function(e,t){return Jn},r.prototype.createObservableGauge=function(e,t){return Kn},r.prototype.createObservableCounter=function(e,t){return zn},r.prototype.createObservableUpDownCounter=function(e,t){return Yn},r.prototype.addBatchObservableCallback=function(e,t){},r.prototype.removeBatchObservableCallback=function(e){},r})(),Ke=(function(){function r(){}return r})(),$n=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.add=function(t,n){},e})(Ke),Un=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.add=function(t,n){},e})(Ke),Dn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.record=function(t,n){},e})(Ke),jn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e.prototype.record=function(t,n){},e})(Ke),yt=(function(){function r(){}return r.prototype.addCallback=function(e){},r.prototype.removeCallback=function(e){},r})(),Hn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(yt),Gn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(yt),qn=(function(r){ve(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(yt),Ln=new Fn,Bn=new $n,Vn=new Dn,Wn=new jn,Jn=new Un,zn=new Hn,Kn=new Gn,Yn=new qn,Qn={get:function(r,e){if(r!=null)return r[e]},keys:function(r){return r==null?[]:Object.keys(r)}},Xn={set:function(r,e,t){r!=null&&(r[e]=t)}},Zn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},es=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},ts=(function(){function r(){}return r.prototype.active=function(){return xn},r.prototype.with=function(e,t,n){for(var s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return t.call.apply(t,es([n],Zn(s),!1))},r.prototype.bind=function(e,t){return t},r.prototype.enable=function(){return this},r.prototype.disable=function(){return this},r})(),rs=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(c){i={error:c}}finally{try{s&&!s.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},ns=function(r,e,t){if(t||arguments.length===2)for(var n=0,s=e.length,o;n<s;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},wt="context",ss=new ts,Ye=(function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalContextManager=function(e){return Pe(wt,e,re.instance())},r.prototype.active=function(){return this._getContextManager().active()},r.prototype.with=function(e,t,n){for(var s,o=[],i=3;i<arguments.length;i++)o[i-3]=arguments[i];return(s=this._getContextManager()).with.apply(s,ns([e,t,n],rs(o),!1))},r.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},r.prototype._getContextManager=function(){return pe(wt)||ss},r.prototype.disable=function(){this._getContextManager().disable(),xe(wt,re.instance())},r})(),kt;(function(r){r[r.NONE=0]="NONE",r[r.SAMPLED=1]="SAMPLED"})(kt||(kt={}));var fr="0000000000000000",dr="00000000000000000000000000000000",os={traceId:dr,spanId:fr,traceFlags:kt.NONE},$e=(function(){function r(e){e===void 0&&(e=os),this._spanContext=e}return r.prototype.spanContext=function(){return this._spanContext},r.prototype.setAttribute=function(e,t){return this},r.prototype.setAttributes=function(e){return this},r.prototype.addEvent=function(e,t){return this},r.prototype.addLink=function(e){return this},r.prototype.addLinks=function(e){return this},r.prototype.setStatus=function(e){return this},r.prototype.updateName=function(e){return this},r.prototype.end=function(e){},r.prototype.isRecording=function(){return!1},r.prototype.recordException=function(e,t){},r})(),_t=lr("OpenTelemetry Context Key SPAN");function Mt(r){return r.getValue(_t)||void 0}function is(){return Mt(Ye.getInstance().active())}function Et(r,e){return r.setValue(_t,e)}function as(r){return r.deleteValue(_t)}function cs(r,e){return Et(r,new $e(e))}function gr(r){var e;return(e=Mt(r))===null||e===void 0?void 0:e.spanContext()}var us=/^([0-9a-f]{32})$/i,hs=/^[0-9a-f]{16}$/i;function ls(r){return us.test(r)&&r!==dr}function fs(r){return hs.test(r)&&r!==fr}function pr(r){return ls(r.traceId)&&fs(r.spanId)}function ds(r){return new $e(r)}var Tt=Ye.getInstance(),vr=(function(){function r(){}return r.prototype.startSpan=function(e,t,n){n===void 0&&(n=Tt.active());var s=!!t?.root;if(s)return new $e;var o=n&&gr(n);return gs(o)&&pr(o)?new $e(o):new $e},r.prototype.startActiveSpan=function(e,t,n,s){var o,i,c;if(!(arguments.length<2)){arguments.length===2?c=t:arguments.length===3?(o=t,c=n):(o=t,i=n,c=s);var a=i??Tt.active(),f=this.startSpan(e,o,a),u=Et(a,f);return Tt.with(u,c,void 0,f)}},r})();function gs(r){return typeof r=="object"&&typeof r.spanId=="string"&&typeof r.traceId=="string"&&typeof r.traceFlags=="number"}var ps=new vr,vs=(function(){function r(e,t,n,s){this._provider=e,this.name=t,this.version=n,this.options=s}return r.prototype.startSpan=function(e,t,n){return this._getTracer().startSpan(e,t,n)},r.prototype.startActiveSpan=function(e,t,n,s){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},r.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):ps},r})(),bs=(function(){function r(){}return r.prototype.getTracer=function(e,t,n){return new vr},r})(),ms=new bs,br=(function(){function r(){}return r.prototype.getTracer=function(e,t,n){var s;return(s=this.getDelegateTracer(e,t,n))!==null&&s!==void 0?s:new vs(this,e,t,n)},r.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:ms},r.prototype.setDelegate=function(e){this._delegate=e},r.prototype.getDelegateTracer=function(e,t,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,t,n)},r})();Ye.getInstance(),re.instance();var ys=(function(){function r(){}return r.prototype.getMeter=function(e,t,n){return Ln},r})(),ws=new ys,It="metrics",ks=(function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalMeterProvider=function(e){return Pe(It,e,re.instance())},r.prototype.getMeterProvider=function(){return pe(It)||ws},r.prototype.getMeter=function(e,t,n){return this.getMeterProvider().getMeter(e,t,n)},r.prototype.disable=function(){xe(It,re.instance())},r})();ks.getInstance();var _s=(function(){function r(){}return r.prototype.inject=function(e,t){},r.prototype.extract=function(e,t){return e},r.prototype.fields=function(){return[]},r})(),Ot=lr("OpenTelemetry Baggage Key");function mr(r){return r.getValue(Ot)||void 0}function Ms(){return mr(Ye.getInstance().active())}function Es(r,e){return r.setValue(Ot,e)}function Ts(r){return r.deleteValue(Ot)}var Ct="propagation",Is=new _s,Os=(function(){function r(){this.createBaggage=Sn,this.getBaggage=mr,this.getActiveBaggage=Ms,this.setBaggage=Es,this.deleteBaggage=Ts}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalPropagator=function(e){return Pe(Ct,e,re.instance())},r.prototype.inject=function(e,t,n){return n===void 0&&(n=Xn),this._getGlobalPropagator().inject(e,t,n)},r.prototype.extract=function(e,t,n){return n===void 0&&(n=Qn),this._getGlobalPropagator().extract(e,t,n)},r.prototype.fields=function(){return this._getGlobalPropagator().fields()},r.prototype.disable=function(){xe(Ct,re.instance())},r.prototype._getGlobalPropagator=function(){return pe(Ct)||Is},r})();Os.getInstance();var Rt="trace",Cs=(function(){function r(){this._proxyTracerProvider=new br,this.wrapSpanContext=ds,this.isSpanContextValid=pr,this.deleteSpan=as,this.getSpan=Mt,this.getActiveSpan=is,this.getSpanContext=gr,this.setSpan=Et,this.setSpanContext=cs}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalTracerProvider=function(e){var t=Pe(Rt,this._proxyTracerProvider,re.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},r.prototype.getTracerProvider=function(){return pe(Rt)||this._proxyTracerProvider},r.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},r.prototype.disable=function(){xe(Rt,re.instance()),this._proxyTracerProvider=new br},r})(),Rs=Cs.getInstance();const As=()=>H(e=>class extends e{constructor(...t){super(...t),this.hooks.hook("frontgateConnection:beforeSerializeMessage",n=>{n.header&&Rs.getTracer("frontgate-js-sdk").startActiveSpan("frontgateConnection:sendMessage",s=>{const o=this.#e(s.spanContext());o&&(n.header={...n.header,...o}),s.end()})})}#e(t){if(!/^0+$/.test(t.traceId))return{tracing:{value:{value:yr(t)}}}}},{featureName:"OpenTelemetry",featureGroups:["Misc"]}),yr=r=>{const e=[18,20,9],t=n=>{for(let s=n.length;s>n.length-16;s-=2){let o=parseInt(n.substring(s-2,s),16);o>127&&(o-=256),e.push(o)}};return t(r.traceId),e.push(17),t(r.spanId),e.push(24),e.push(0),e},Ns=()=>H(e=>class extends e{async requestProxyEndpoint(t,n,s,o,i=this.defaultTimeoutInMs){const c=new Be(t,n,o);s&&c.setBody(s),c.header.setTimeout(i);const a={message:c.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",a);const f=new Promise((h,v)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,w=>{try{if(!w.Message.includes("HTTPProxyResponse")){v(JSON.stringify(w));return}const M=new Jt(w);h({response:M,data:M.data})}catch(M){v(M)}})}),u=`Request timeout reached (${i} ms) for ${a.message.Message}`;return Y(i,u,f)}},{featureName:"HTTPProxyRequest",featureGroups:["Misc"]}),Ss=()=>H(e=>class extends e{async ping(t=this.defaultTimeoutInMs){const s={message:new Ve().getPtlMessage(),callbackType:"response",callbackId:"PingResponse"};await this.hooks.callHook("frontgateConnection:sendMessage",s);const o=new Promise(c=>{this.hooks.hookOnce(`frontgateConnection:response:${s.callbackId}`,a=>{const f=new We(a);c(f)})}),i=`Request timeout reached (${t} ms) for ${s.message.Message}`;return Y(t,i,o)}},{featureName:"Pingable",featureGroups:["Misc"]}),Ps=r=>H(t=>class extends t{async logRemotely(n){const o={message:new Bt({Message:"LogMessage",timestamp:{microseconds:Date.now()*1e3},uuid:{id_1:r??0,id_2:0},level:{value:4},area:61,Version:1,message:n}).getPtlMessage(),callbackType:"job",callbackId:""};return this.hooks.callHook("frontgateConnection:sendMessage",o)}},{featureName:"RemoteLogger",featureGroups:["Misc"]}),H=(r,e)=>{const t=r;return t.featureName=e.featureName,t.featureGroups=e.featureGroups,t.disabledFeatures=e.disabledFeatures,t.disabledFeatureGroups=e.disabledFeatureGroups,t};function At(r,e={},t){for(const n in r){const s=r[n],o=t?`${t}:${n}`:n;typeof s=="object"&&s!==null?At(s,e,o):typeof s=="function"&&(e[o]=s)}return e}const xs={run:r=>r()},Fs=()=>xs,wr=typeof console.createTask<"u"?console.createTask:Fs;function $s(r,e){const t=e.shift(),n=wr(t);return r.reduce((s,o)=>s.then(()=>n.run(()=>o(...e))),Promise.resolve())}function Us(r,e){const t=e.shift(),n=wr(t);return Promise.all(r.map(s=>n.run(()=>s(...e))))}function Nt(r,e){for(const t of[...r])t(e)}class Ds{constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(e,t,n={}){if(!e||typeof t!="function")return()=>{};const s=e;let o;for(;this._deprecatedHooks[e];)o=this._deprecatedHooks[e],e=o.to;if(o&&!n.allowDeprecated){let i=o.message;i||(i=`${s} hook has been deprecated`+(o.to?`, please use ${o.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!t.name)try{Object.defineProperty(t,"name",{get:()=>"_"+e.replace(/\W+/g,"_")+"_hook_cb",configurable:!0})}catch{}return this._hooks[e]=this._hooks[e]||[],this._hooks[e].push(t),()=>{t&&(this.removeHook(e,t),t=void 0)}}hookOnce(e,t){let n,s=(...o)=>(typeof n=="function"&&n(),n=void 0,s=void 0,t(...o));return n=this.hook(e,s),n}removeHook(e,t){if(this._hooks[e]){const n=this._hooks[e].indexOf(t);n!==-1&&this._hooks[e].splice(n,1),this._hooks[e].length===0&&delete this._hooks[e]}}deprecateHook(e,t){this._deprecatedHooks[e]=typeof t=="string"?{to:t}:t;const n=this._hooks[e]||[];delete this._hooks[e];for(const s of n)this.hook(e,s)}deprecateHooks(e){Object.assign(this._deprecatedHooks,e);for(const t in e)this.deprecateHook(t,e[t])}addHooks(e){const t=At(e),n=Object.keys(t).map(s=>this.hook(s,t[s]));return()=>{for(const s of n.splice(0,n.length))s()}}removeHooks(e){const t=At(e);for(const n in t)this.removeHook(n,t[n])}removeAllHooks(){for(const e in this._hooks)delete this._hooks[e]}callHook(e,...t){return t.unshift(e),this.callHookWith($s,e,...t)}callHookParallel(e,...t){return t.unshift(e),this.callHookWith(Us,e,...t)}callHookWith(e,t,...n){const s=this._before||this._after?{name:t,args:n,context:{}}:void 0;this._before&&Nt(this._before,s);const o=e(t in this._hooks?[...this._hooks[t]]:[],n);return o instanceof Promise?o.finally(()=>{this._after&&s&&Nt(this._after,s)}):(this._after&&s&&Nt(this._after,s),o)}beforeEach(e){return this._before=this._before||[],this._before.push(e),()=>{if(this._before!==void 0){const t=this._before.indexOf(e);t!==-1&&this._before.splice(t,1)}}}afterEach(e){return this._after=this._after||[],this._after.push(e),()=>{if(this._after!==void 0){const t=this._after.indexOf(e);t!==-1&&this._after.splice(t,1)}}}}function js(){return new Ds}const kr=typeof window<"u";function Hs(r,e={}){const t={inspect:kr,group:kr,filter:()=>!0,...e},n=t.filter,s=typeof n=="string"?u=>u.startsWith(n):n,o=t.tag?`[${t.tag}] `:"",i=u=>o+u.name+"".padEnd(u._id,"\0"),c={},a=r.beforeEach(u=>{s!==void 0&&!s(u.name)||(c[u.name]=c[u.name]||0,u._id=c[u.name]++,console.time(i(u)))}),f=r.afterEach(u=>{s!==void 0&&!s(u.name)||(t.group&&console.groupCollapsed(u.name),t.inspect?console.timeLog(i(u),u.args):console.timeEnd(i(u)),t.group&&console.groupEnd(),c[u.name]--)});return{close:()=>{a(),f()}}}class _r{constructor(e){this.hooks=js(),this.#e=1e4,e?.hookDebug&&Hs(this.hooks,{tag:"hooks"}),e?.defaultRequestTimeout&&(this.#e=e.defaultRequestTimeout)}#e;get defaultTimeoutInMs(){return this.#e}log(e,...t){if(this.hooks.callHook("base:log",t),this.logger)switch(e){case d.TRACE:this.logger.trace(t);break;case d.DEBUG:this.logger.debug(t);break;case d.INFO:this.logger.info(t);break;case d.WARN:this.logger.warn(t);break;case d.ERROR:this.logger.error(t);break;case d.FATAL:this.logger.fatal(t);break}}}class Qe{#e;#t=[];#r=[];#n=[];constructor(e,t=[],n=[],s=[]){this.#e=e,this.#t=t,this.#r=n,this.#n=s}static create(){return new Qe(_r)}#s(e){if(this.#t.includes(e))throw new Error(`Feature "${e}" has already been used.`)}#i(e){for(const t of this.#r)if(t.feature===e)throw new Error(`Feature "${e}" has been disabled by ${t.disabler.join(",")}.`)}#a(e){for(const t of this.#n)if(t.feature===e)throw new Error(`Group "${e}" has been disabled by ${t.disabler.join(",")}.`)}#o(e,t){for(const n of this.#r)if(n.feature===t){n.disabler.push(e);return}this.#r.push({disabler:[e],feature:t})}#c(e,t){for(const n of this.#n)if(n.feature===t){n.disabler.push(e);return}this.#n.push({disabler:[e],feature:t})}with(e){const{featureName:t,disabledFeatures:n,disabledFeatureGroups:s,featureGroups:o}=e;if(!t)throw new Error("Feature name is missing");if(t!=="Custom"){if(this.#s(t),this.#i(t),this.#t.push(t),o&&o.length>0)for(const c of o)this.#a(c);if(n&&n.length>0)for(const c of n)this.#o(t,c);if(s&&s.length>0)for(const c of s)this.#c(t,c)}const i=e(this.#e);return new Qe(i,this.#t,this.#r,this.#n)}build(e){return new this.#e(e)}getClientConstructor(){return this.#e}}b.AbstractLogger=ie,b.AbstractMdg2Request=me,b.AuthenticationByTokenRequest=qe,b.AuthenticationTokenRequest=Le,b.AuthenticationTokenResponse=Vt,b.CancelSubscriptionRequest=le,b.ConnectionState=Ut,b.ConsoleLogger=nt,b.CookieTokenAuthenticationFactors=Ft,b.DEFAULT_TIMEOUT_IN_MS=Lt,b.DefaultHosts=jt,b.DeploymentStage=Dt,b.ErrorResponse=z,b.FLAG_HAS_NEXT_CHUNK=rt,b.FrontgateClient=_r,b.FrontgateClientBuilder=Qe,b.FrontgateClientDataObserver=mt,b.FrontgateClientEndpointDataObserver=ur,b.HTTPProxyRequest=Be,b.HTTPProxyResponse=Jt,b.HighLevelRequest=ye,b.HighLevelResponse=Wt,b.HighLevelUpdate=tt,b.ID_APP_AUTHENTICATED=he,b.ID_USER_AUTHENTICATED=be,b.ID_USER_NONE=$t,b.LogLevel=d,b.LoggerHelper=Pr,b.Mdg2Response=fe,b.NullLogger=st,b.PingRequest=Ve,b.PingResponse=We,b.RawRequest=Bt,b.TimeOptions=Ht,b.TransportLayerClientRequestHeader=Ge,b.WinstonLogger=Fr,b.authTokenRequest=$r,b.cookieTokenAuth=gn,b.createExtendedMixinFactory=H,b.encodeSpanContext=yr,b.endpointRequest=Ur,b.endpointSubscriptions=an,b.fetchAuth=vn,b.getBytesFromBuffer=Cr,b.httpProxyRequest=Ns,b.levels=xr,b.logger=Dr,b.messageCompressor=sn,b.openTelemetry=As,b.pingRequests=Ss,b.rawSubscriptions=cn,b.reconnect=bn,b.remotelogger=Ps,b.requests=on,b.timeToMilliseconds=He,b.tokenAuth=pn,b.useTimeout=Y,b.wsConnection=Kt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
@@ -175,7 +175,7 @@
175
175
  function timeToMilliseconds(time) {
176
176
  return time.toString().slice(0, -3);
177
177
  }
178
- const PACKAGE_JSON = { version: "7.0.2", package: "@factset/frontgate-js-sdk" };
178
+ const PACKAGE_JSON = { version: "7.0.4", package: "@factset/frontgate-js-sdk" };
179
179
  function getClientInformation() {
180
180
  const navigator2 = getNavigator();
181
181
  return {
@@ -680,10 +680,16 @@
680
680
  return this.raw.header.id_service;
681
681
  }
682
682
  isUpdateMessage() {
683
- return Object.hasOwnProperty.call(this.raw, "header") && (Object.hasOwnProperty.call(this.raw.header, "id_service") || Object.hasOwnProperty.call(this.raw.header, "id_job")) && this.raw.Message.endsWith("Update");
683
+ if (!Object.hasOwnProperty.call(this.raw, "header")) {
684
+ return false;
685
+ }
686
+ return (Object.hasOwnProperty.call(this.raw.header, "id_service") || Object.hasOwnProperty.call(this.raw.header, "id_job")) && this.raw.Message.endsWith("Update");
684
687
  }
685
688
  isLossMessage() {
686
- return Object.hasOwnProperty.call(this.raw, "header") && (Object.hasOwnProperty.call(this.raw.header, "id_service") || Object.hasOwnProperty.call(this.raw.header, "id_job")) && (this.raw.Message.endsWith("LossMessage") || this.raw.Message.endsWith("Loss"));
689
+ if (!Object.hasOwnProperty.call(this.raw, "header")) {
690
+ return false;
691
+ }
692
+ return (Object.hasOwnProperty.call(this.raw.header, "id_service") || Object.hasOwnProperty.call(this.raw.header, "id_job")) && (this.raw.Message.endsWith("LossMessage") || this.raw.Message.endsWith("Loss"));
687
693
  }
688
694
  }
689
695
  class AuthenticationTokenResponse extends Mdg2Response {
@@ -2642,7 +2648,6 @@
2642
2648
  this.#subscriptions.set(key, observer);
2643
2649
  const currentSubscounts = this.#subscriptionCounts.get(key) ?? 0;
2644
2650
  this.#subscriptionCounts.set(key, currentSubscounts + 1);
2645
- this.#inFlights.delete(key);
2646
2651
  resolve(observer);
2647
2652
  });
2648
2653
  }).catch((e) => {
@@ -2650,7 +2655,9 @@
2650
2655
  });
2651
2656
  });
2652
2657
  const rejectReason = `Request timeout reached (${timeOutInMs} ms) for ${subscriptionMsg.message.Message}`;
2653
- const wrappedTimeoutPromise = useTimeout(timeOutInMs, rejectReason, promise);
2658
+ const wrappedTimeoutPromise = useTimeout(timeOutInMs, rejectReason, promise).finally(() => {
2659
+ this.#inFlights.delete(key);
2660
+ });
2654
2661
  this.#inFlights.set(key, wrappedTimeoutPromise);
2655
2662
  return wrappedTimeoutPromise;
2656
2663
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@factset/frontgate-js-sdk",
3
3
  "author": "Factset GmbH",
4
- "version": "7.0.2",
4
+ "version": "7.0.4",
5
5
  "description": "Typescript based client to request and subscribe values from mdg2 (frontgate)",
6
6
  "license": "Apache-2.0",
7
7
  "main": "./dist/lib/node/index.js",
@@ -69,22 +69,22 @@
69
69
  "devDependencies": {
70
70
  "@types/ws": "^8.18.1",
71
71
  "@typescript-eslint/eslint-plugin": "^8.38.0",
72
- "@vitest/coverage-v8": "^3.2.4",
72
+ "@vitest/coverage-v8": "^4.0.0",
73
73
  "concurrently": "^9.2.0",
74
74
  "conventional-changelog": "^7.1.1",
75
75
  "cross-env": "^10.0.0",
76
76
  "eslint": "^9.31.0",
77
77
  "eslint-config-prettier": "^10.1.8",
78
78
  "globals": "^16.3.0",
79
- "happy-dom": "^19.0.0",
79
+ "happy-dom": "^20.0.2",
80
80
  "mock-socket": "^9.3.1",
81
81
  "prettier": "^3.6.2",
82
82
  "replace": "^1.2.2",
83
83
  "rimraf": "^6.0.1",
84
84
  "typedoc": "^0.28.7",
85
85
  "typescript": "^5.8.3",
86
- "vite": "^7.1.5",
87
- "vitest": "^3.2.4"
86
+ "vite": "^7.1.11",
87
+ "vitest": "^4.0.0"
88
88
  },
89
89
  "packageManager": "yarn@4.10.3"
90
90
  }