@factset/frontgate-js-sdk 7.1.6 → 7.1.7
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 +8 -0
- package/dist/lib/esnext/mixins/connection/FrontgateWSMixin.js +2 -2
- package/dist/lib/esnext/version.js +1 -1
- package/dist/lib/node/mixins/connection/FrontgateWSMixin.js +2 -2
- package/dist/lib/node/version.js +1 -1
- package/dist/lib/umd/mdg2.client.min.umd.js +1 -1
- package/dist/lib/umd/mdg2.client.umd.js +16 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
## <small>7.1.7 (2026-07-13)</small>
|
|
2
|
+
|
|
3
|
+
* fix(connection): emit full close event on error [ecb02ad]
|
|
4
|
+
* fix(connection): reset connection on connect [ebe25bd]
|
|
5
|
+
* chore(deps): lock file maintenance [e292741]
|
|
6
|
+
* chore(deps): update yarn to v4.17.1 [4228a96]
|
|
7
|
+
|
|
1
8
|
## <small>7.1.6 (2026-07-07)</small>
|
|
2
9
|
|
|
10
|
+
* chore(release): update changelog for v7.1.6 [d15d276]
|
|
3
11
|
* fix(http-proxy-response): restore meta property [171fb76]
|
|
4
12
|
|
|
5
13
|
## <small>7.1.5 (2026-07-06)</small>
|
|
@@ -69,7 +69,6 @@ export const wsConnection = (conf) => {
|
|
|
69
69
|
this.hooks.hook('reconnect:attempt', async () => {
|
|
70
70
|
clearInterval(__classPrivateFieldGet(this, _keepAliveTimer, "f"));
|
|
71
71
|
this.log(LogLevel.DEBUG, 'Reconnecting');
|
|
72
|
-
await this.hooks.callHook('frontgateConnection:reset');
|
|
73
72
|
try {
|
|
74
73
|
await this.connect();
|
|
75
74
|
await this.hooks.callHook('reconnect:success');
|
|
@@ -81,6 +80,7 @@ export const wsConnection = (conf) => {
|
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
async connect() {
|
|
83
|
+
await this.hooks.callHook('frontgateConnection:reset');
|
|
84
84
|
if (!__classPrivateFieldGet(this, _wsConf, "f")) {
|
|
85
85
|
throw new Error('No connection configuration set');
|
|
86
86
|
}
|
|
@@ -158,7 +158,7 @@ export const wsConnection = (conf) => {
|
|
|
158
158
|
unhookOnFrontgateConnectionAuthenticated?.();
|
|
159
159
|
this.log(LogLevel.DEBUG, 'Disconnected', closeEvent);
|
|
160
160
|
if (__classPrivateFieldGet(this, _wsStateInternal, "f") === 'connecting' || __classPrivateFieldGet(this, _wsStateInternal, "f") === 'connected') {
|
|
161
|
-
reject(
|
|
161
|
+
reject(closeEvent);
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
164
|
void this.hooks.callHook('frontgateConnection:disconnected', closeEvent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_JSON = { version: '7.1.
|
|
1
|
+
export const PACKAGE_JSON = { version: '7.1.7', package: '@factset/frontgate-js-sdk' };
|
|
@@ -75,7 +75,6 @@ const wsConnection = (conf) => {
|
|
|
75
75
|
this.hooks.hook('reconnect:attempt', async () => {
|
|
76
76
|
clearInterval(__classPrivateFieldGet(this, _keepAliveTimer, "f"));
|
|
77
77
|
this.log(logger_1.LogLevel.DEBUG, 'Reconnecting');
|
|
78
|
-
await this.hooks.callHook('frontgateConnection:reset');
|
|
79
78
|
try {
|
|
80
79
|
await this.connect();
|
|
81
80
|
await this.hooks.callHook('reconnect:success');
|
|
@@ -87,6 +86,7 @@ const wsConnection = (conf) => {
|
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
88
|
async connect() {
|
|
89
|
+
await this.hooks.callHook('frontgateConnection:reset');
|
|
90
90
|
if (!__classPrivateFieldGet(this, _wsConf, "f")) {
|
|
91
91
|
throw new Error('No connection configuration set');
|
|
92
92
|
}
|
|
@@ -164,7 +164,7 @@ const wsConnection = (conf) => {
|
|
|
164
164
|
unhookOnFrontgateConnectionAuthenticated?.();
|
|
165
165
|
this.log(logger_1.LogLevel.DEBUG, 'Disconnected', closeEvent);
|
|
166
166
|
if (__classPrivateFieldGet(this, _wsStateInternal, "f") === 'connecting' || __classPrivateFieldGet(this, _wsStateInternal, "f") === 'connected') {
|
|
167
|
-
reject(
|
|
167
|
+
reject(closeEvent);
|
|
168
168
|
}
|
|
169
169
|
else {
|
|
170
170
|
void this.hooks.callHook('frontgateConnection:disconnected', closeEvent);
|
package/dist/lib/node/version.js
CHANGED
|
@@ -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.1.
|
|
4
|
+
exports.PACKAGE_JSON = { version: '7.1.7', package: '@factset/frontgate-js-sdk' };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.fdsg={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=((e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)))(s(((e,t)=>{var n=function(e){return r(e)&&!i(e)};function r(e){return!!e&&typeof e==`object`}function i(e){var t=Object.prototype.toString.call(e);return t===`[object RegExp]`||t===`[object Date]`||o(e)}var a=typeof Symbol==`function`&&Symbol.for?Symbol.for(`react.element`):60103;function o(e){return e.$$typeof===a}function s(e){return Array.isArray(e)?[]:{}}function c(e,t){return t.clone!==!1&&t.isMergeableObject(e)?g(s(e),e,t):e}function l(e,t,n){return e.concat(t).map(function(e){return c(e,n)})}function u(e,t){if(!t.customMerge)return g;var n=t.customMerge(e);return typeof n==`function`?n:g}function d(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function f(e){return Object.keys(e).concat(d(e))}function p(e,t){try{return t in e}catch{return!1}}function m(e,t){return p(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function h(e,t,n){var r={};return n.isMergeableObject(e)&&f(e).forEach(function(t){r[t]=c(e[t],n)}),f(t).forEach(function(i){m(e,i)||(p(e,i)&&n.isMergeableObject(t[i])?r[i]=u(i,n)(e[i],t[i],n):r[i]=c(t[i],n))}),r}function g(e,t,r){r||={},r.arrayMerge=r.arrayMerge||l,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=c;var i=Array.isArray(t);return i===Array.isArray(e)?i?r.arrayMerge(e,t,r):h(e,t,r):c(t,r)}g.all=function(e,t){if(!Array.isArray(e))throw Error(`first argument should be an array`);return e.reduce(function(e,n){return g(e,n,t)},{})},t.exports=g}))());function u(e){return!!e&&typeof e==`object`}function d(...e){let t=e.filter(u);return l.default.all(t,{arrayMerge:(e,t)=>t})}function f(e){return e.replace(/[=]/g,``).replace(/\//g,`_`).replace(/\+/g,`-`)}var p=class{constructor(e){let t=f(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}},m=-2,h=-2,g=-1;function _(e){let t=[];if(e)for(let n=0;n<e.length;n++)t.push(e.readInt8(n));return t}var v=function(e){return e[e.DISCONNECTED=0]=`DISCONNECTED`,e[e.CONNECTING=1]=`CONNECTING`,e[e.AUTHENTICATED=2]=`AUTHENTICATED`,e[e.RECONNECTING=3]=`RECONNECTING`,e}({}),y=function(e){return e[e.production=40]=`production`,e[e.preproduction=35]=`preproduction`,e[e.show=30]=`show`,e[e.testing=20]=`testing`,e}({}),b=function(e){return e.production=`frontgate-eu.factsetdigitalsolutions.com`,e.show=`frontgate-eu.show.factsetdigitalsolutions.com`,e}({}),x=function(e){return e.MAXIMUM_STRING=`9223372036854775807`,e.MINIMUM_STRING=`-9223372036854775807`,e}({});function S(e){return e.toString().slice(0,-3)}var C=e=>e.id_job!==void 0,w=e=>e.header?.id_job!==void 0,T=e=>e.header?.id_service!==void 0&&e.id_notation!==void 0,E=e=>e.header!==void 0,D={version:`7.1.6`,package:`@factset/frontgate-js-sdk`};function O(){let e=ee();return{userAgent:e.userAgent??`unknown`,platform:`frontgate-js-sdk`,version:D.version,package:D.package,mobile:/Mobi/i.test(e.userAgent??`unknown`)}}function ee(){return typeof navigator<`u`?navigator:typeof process<`u`?{userAgent:`node.js/io.js, ${process.version}`}:{userAgent:`unknown`}}var k=e=>{let t=[18,20,9],n=e=>{for(let n=e.length;n>e.length-16;n-=2){let r=parseInt(e.substring(n-2,n),16);r>127&&(r-=256),t.push(r)}};return n(e.traceId),t.push(17),n(e.spanId),t.push(24),t.push(0),t},A=async(e,t)=>new Promise((n,r)=>{setTimeout(()=>{r(t)},e)}),j=async(e,t,n)=>Promise.race([A(e,t),n]),M=e=>e+Math.random()*100,N=6e3,P=class e{constructor(){this.headerMembers={dataset:{id_dataset:0},id_job:0,flags_r2:0,resend_counter:0,timeout:N,authentication_identifiers:{id_application:0,id_user:0},cache_key:{value:[]},previous_response_hash:{value:[]},tracing:{value:{value:[]}}},this.flags=[]}static{this.PRICE_QUALITY={RLT:129,DLY:0,EOD:130}}static{this.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}}getPtlMessage(){return this.headerMembers}getQuality(){return Object.keys(e.PRICE_QUALITY).find(t=>e.PRICE_QUALITY[t]===this.headerMembers.dataset.id_dataset)}setQuality(t){this.headerMembers.dataset.id_dataset=e.PRICE_QUALITY[t]}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){let 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((t,n)=>t+e.FLAG_VALUE[n],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 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=k(e))}static getDataSet(t){return Object.prototype.hasOwnProperty.call(e.PRICE_QUALITY,t)?e.PRICE_QUALITY[t]:e.PRICE_QUALITY.DLY}},F=class{constructor(e,t){this.header=new P,this.coreMembers={Message:e,Version:t},this.members={}}getPtlMessage(){let e={header:this.header.getPtlMessage()};return d(this.coreMembers,e,this.members)}},I=class{constructor(e,t){this.token=e,this.maximumIdleInterval=t}toJson(){let e=O();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:{b64:``}},cache_authentication_encrypted_secret:{encrypted_secret:{b64:``}}}}},L=class e extends F{static{this.NAME=`AuthenticationTokenRequest`}static{this.VERSION=6}static{this.LIFETIME_SECONDS_DEFAULT=-1}static{this.LIFETIME_SECONDS_MAXIMUM=-2}static{this.FLAG_SINGLE_USAGE=1}constructor(t,n,r,i,a=!1){super(e.NAME,e.VERSION),n&&this.header.setIdUser(n),r&&this.header.setIdApplication(r),i&&this.header.setTimeout(i),this.members.flags=a?e.FLAG_SINGLE_USAGE:0,this.members.lifetime_seconds_r2=t??e.LIFETIME_SECONDS_DEFAULT,this.header.setFlag(`no_merge`)}},R=class e extends F{static{this.NAME=`CancelSubscriptionRequest`}static{this.VERSION=6}constructor(t){super(e.NAME,e.VERSION),this.members.id_job_subscription=t}},z=class e extends F{static{this.NAME=`HighLevelRequest`}static{this.VERSION=3}static{this.METHOD={GET:1,POST:2}}constructor(t,n,r={},i){super(e.NAME,e.VERSION),this.members.accept=`application/json`,this.members.content_type=`application/json`,this.members.body={value:[]},this.members.query=``,this.members.path=n,this.setMethod(t),Object.keys(r).length>0&&(t===`POST`?this.setBody(r):this.setQuery(r)),i&&this.setOptions(i)}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(t){let n=t===`POST`?e.METHOD.POST:e.METHOD.GET;this.members.method={value:n}}setBody(e={}){e instanceof Array?this.members.body={value:e}:this.members.body={value:JSON.stringify(e)}}getData(){return this.members.method.value===e.METHOD.POST?e.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(e=>{t+=String.fromCharCode(e)}),JSON.parse(t)}}},B=class e extends F{static{this.NAME=`HTTPProxyRequest`}static{this.VERSION=2}static{this.PROTOCOL={HTTP:1,HTTPS:2}}static{this.METHOD={GET:1,POST:2,OPTIONS:3,HEAD:4,PUT:5,DELETE:6,TRACE:7,CONNECT:8}}constructor(t,n,r){super(e.NAME,e.VERSION),this.members.request={headers:{values:[{key:`accept`,value:`application/json`},{key:`content-type`,value:`application/json`}]},protocol:{value:e.PROTOCOL.HTTPS},host:``,port:0,path:n,query:``,body:{value:[]}},this.setQuery(),this.setMethod(t),r&&this.setOptions(r)}setOptions(t){t.no_merge&&this.header.setFlag(`no_merge`),t.idApplication&&this.header.setIdApplication(t.idApplication),t.idUser&&this.header.setIdUser(t.idUser),t.protocol&&(this.members.request.protocol=t.protocol.toUpperCase()===`HTTP`?{value:e.PROTOCOL.HTTP}:{value:e.PROTOCOL.HTTPS}),t.method&&(this.members.request.method={value:e.METHOD[t.method]}),t.host&&(this.members.request.host=t.host),t.port&&(this.members.request.port=t.port),t.path&&(this.members.request.path=t.path),t.query&&(this.members.request.query=typeof t.query==`string`?t.query:Object.keys(t.query).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t.query[e])}`).join(`&`)),t.body&&this.setBody(t.body),t.headers&&this.setHeaders(t.headers)}setHeaders(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t],r=this.members.request.headers.values.findIndex(e=>e.key===t);r!==-1&&this.members.request.headers.values.splice(r,1),this.members.request.headers.values.push({key:t,value:n})}}setQuery(){if(this.members.request.path.includes(`?`)){let e=this.members.request.path.split(`?`);this.members.request.path=e[0],this.members.request.query=e[1]}}setMethod(t){this.members.request.method={value:e.METHOD[t]}}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 z.ptlToJsonData(this.members.request.body.value)}},V=class e{static{this.NAME=`PingRequest`}static{this.VERSION=3}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}},te=class extends F{constructor(e){super(e.Message,e.version?e.version:e.Version),this._extractRequestAttributes(e)}_extractRequestAttributes(e){for(let t of Object.keys(this.coreMembers))delete e[t];this.members=(0,l.default)(this.members,e)}},ne=class{constructor(e){this.token=e.token.value.b64,this.expiry=parseInt(S(e.expiry.microseconds),10)}getToken(){return this.token}getExpiry(){return this.expiry}},H=class{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(){if(this.raw.Message===`Foundation::HTTPProxyResponse`||this.raw.Message===`Foundation::HighLevelResponse`)return this.raw.header.id_service;throw Error(`Invalid message type`)}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}},re=class extends H{constructor(e){super(e);try{this.responseData=JSON.parse(this.raw.body.value)}catch(e){throw Error(`Could not parse HighLevelResponse: ${e.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}},ie=class extends H{constructor(e){super(e);try{let e=this.raw.response.body.value,t=e.substr(0,1)===`{`;this.responseData=t?JSON.parse(e):e}catch(e){throw Error(`Could not parse HTTPProxyResponse: ${e}`)}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 info(){return this.responseInfo}get status(){return{code:this.statusCode,reason:this.statusReason}}},ae=class{static{this.NAME=`Foundation::PingResponse`}static{this.VERSION=2}constructor(e){this._timeReceivedResponse=Date.now(),this._timeAtSender=Number(S(e.time_at_sender.microseconds)),this._timeFromRequest=Number(S(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}},oe=class extends H{constructor(e){if(super(e),typeof this.raw.body.value!=`string`)throw Error(`Incorrect response type in HighLevelUpdate`);try{this.responseData=JSON.parse(this.raw.body.value)}catch(e){throw Error(`Could not parse HighLevelUpdate: ${e.message}`)}}get data(){return this.responseData}},se=8,U=function(e){return e[e.TRACE=10]=`TRACE`,e[e.DEBUG=20]=`DEBUG`,e[e.INFO=30]=`INFO`,e[e.WARN=40]=`WARN`,e[e.ERROR=50]=`ERROR`,e[e.FATAL=60]=`FATAL`,e[e.SILENT=100]=`SILENT`,e}({}),ce=class e{static{this.loggers={}}constructor(t=``){this.defaultLevel=40,this.noop=()=>null,this.name=t,this.level=this.defaultLevel,this.setDefaultLevelFromLocalStorage(),Object.assign(e.loggers,{[t]: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`;default:return!0}}setDefaultLevelFromLocalStorage(){let t;try{if(typeof localStorage!=`object`)return;let e=localStorage.getItem(`loglevel`);if(!e)return;t=e}catch{return}t&&this.setLevel(e.getLogLevel(t))}static getLogLevel(e){let 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 Error(`Invalid log level: ${t}`)}}static getLogger(t,n){if(Object.prototype.hasOwnProperty.call(e.loggers,t))return e.loggers[t];let r=new n(t);return e.loggers[t]=r,r}},le=class{static getLogLevel(e){let t=e.toLowerCase();switch(t){case`silent`:return U.SILENT;case`fatal`:return U.FATAL;case`error`:return U.ERROR;case`warn`:return U.WARN;case`info`:return U.INFO;case`debug`:return U.DEBUG;case`trace`:return U.TRACE;default:throw Error(`Invalid log level: ${t}`)}}},ue=class e extends ce{constructor(...e){super(...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`)}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)){let 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(t=``){return super.getLogger(t,e)}},de={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6},fe=class extends ce{constructor(e,t=``){super(t),this.name=t,this.logger=e,e.trace&&(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=U[e].toLowerCase())}static getLogger(e=``){return Object.prototype.hasOwnProperty.call(ce.loggers,e)?ce.loggers[e]:null}},pe=class e extends ce{constructor(...e){super(...e),this.trace=this.noop,this.debug=this.noop,this.info=this.noop,this.warn=this.noop,this.error=this.noop}static getLogger(t=``){return super.getLogger(t,e)}},me=()=>$(e=>class extends e{async requestAuthenticationToken(e=30,t=0,n=0,r=this.defaultTimeoutInMs){let i={message:new L(e,t,n,r).getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,i);let a=new Promise((e,t)=>{this.hooks.hookOnce(`frontgateConnection:response:${i.callbackId}`,n=>{if(n.Message!==`Foundation::AuthenticationTokenResponse`){t(JSON.stringify(n));return}let r=new ne(n);e({token:r.getToken(),expiry:r.getExpiry()})})});return j(r,`Request timeout reached (${r} ms) for ${i.message.Message}`,a)}async requestAuthenticationTokenForCookieTokenAuthentication(e=30,t=0,n=0,r=this.defaultTimeoutInMs){return new p((await this.requestAuthenticationToken(e,t,n,r)).token)}},{featureName:`AuthTokenRequest`,featureGroups:[`Misc`]}),he=e=>$(t=>class extends t{async requestEndpoint(t,n,r,i,a=this.defaultTimeoutInMs){let o=new z(t,n,r,{...i,allowChunkedResponse:!e?.disableChunkedResponse});o.header.setTimeout(a),e?.allowPermissionDeniedResponse&&o.header.setFlag(`permission_denied_response`);let s={message:o.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,s);let c=new Promise((e,t)=>{let n=[],r=()=>{this.hooks.hookOnce(`frontgateConnection:response:${s.callbackId}`,i=>{try{if(i.Message!==`Foundation::HighLevelResponse`&&i.Message!==`HighLevelResponse`){t(JSON.stringify(i));return}if(this.#e(i))n.push({body:i.body.value,processingTime:i.header.processing_time}),r();else{n.push({body:i.body.value,processingTime:i.header.processing_time});let t=new re({...i,body:{value:n.map(e=>e.body).join(``)},header:{...i.header,processing_time:n.reduce((e,t)=>e+t.processingTime,0)}});e({response:t,data:t.data})}}catch(e){t(e)}})};r()});return j(a,`Request timeout reached (${a} ms) for ${s.message.Message}`,c)}#e(e){return(e.header.flags&8)==8}},{featureName:`EndpointRequest`,featureGroups:[`Misc`]}),ge=null;typeof WebSocket<`u`?ge=WebSocket:typeof MozWebSocket<`u`?ge=MozWebSocket:typeof global<`u`?ge=global.WebSocket||global.MozWebSocket:typeof window<`u`?ge=window.WebSocket||window.MozWebSocket:typeof self<`u`&&(ge=self.WebSocket||self.MozWebSocket);var _e=ge,ve=e=>$(t=>class extends t{#e;#t;#n=`disconnected`;#r;#i=0;#a;#o;get#s(){return this.#e&&this.#e.readyState<2?this.#n:`disconnected`}#c=0;#l=[];set conf(e){let t=this.#_(e);this.#c=t.messageBufferSize,this.#t=t}constructor(...t){super(...t),this.#a=-2,this.#o=-1,e&&(this.conf=e),this.hooks.hook(`frontgateConnection:setIdApp`,e=>{this.#a=e}),this.hooks.hook(`frontgateConnection:setIdUser`,e=>{this.#o=e}),this.hooks.hook(`frontgateConnection:sendMessage`,e=>{if(e.callbackType===`job`&&(e.callbackId=`${this.#m(e.message)}`),this.#s===`connected`&&e.callbackType===`response`)this.#f(e.message);else if(this.#s===`authenticated`)this.#h(e.message),this.#f(e.message);else{if(this.#l.length>=this.#c)throw Error(`Message buffer is full`);this.#l.push(e)}}),this.hooks.hook(`reconnect:attempt`,async()=>{clearInterval(this.#r),this.log(U.DEBUG,`Reconnecting`),await this.hooks.callHook(`frontgateConnection:reset`);try{await this.connect(),await this.hooks.callHook(`reconnect:success`)}catch(e){this.log(U.ERROR,`Reconnect failed`,e),await this.hooks.callHook(`reconnect:failed`,e)}})}async connect(){if(!this.#t)throw Error(`No connection configuration set`);if(this.#s!==`disconnected`)throw Error(`Client is already connected or is connecting right now`);let{host:e,port:t,tls:n,pathPrefix:r}=this.#t;this.#n=`connecting`;let i=`${n?`wss`:`ws`}://${e}:${t}${r??``}/ws`,a={encoding:`jsjson-v2`};await this.hooks.callHook(`frontgateConnection:afterSetEncoding`,a);let[o,s]=a.encoding.split(`-`),c={url:i,subProtocols:[`${s?`${s}.`:``}ws-${o}.mdgms.com`]};try{await this.hooks.callHook(`frontgateConnection:beforeConnect`,c)}catch(e){throw this.#n=`disconnected`,e}this.log(U.DEBUG,`Connecting to ${c.url} with subprotocols ${c.subProtocols}`);let l=new Promise((e,t)=>{if(!this.#t)throw Error(`No connection configuration set`);this.#t.wsClientOptions&&typeof window>`u`?this.#e=new _e(c.url,c.subProtocols,this.#t.wsClientOptions):this.#e=new _e(c.url,c.subProtocols),this.#e.binaryType=`arraybuffer`;let n;this.#e.onopen=()=>{let r=()=>{for(this.log(U.DEBUG,`Draining message buffer`);this.#l.length>0;){let e=this.#l.shift();e&&(this.#h(e.message),this.#f(e.message))}},i=()=>{if(!this.#t)throw Error(`No connection configuration set`);this.#r=setInterval(()=>{this.log(U.DEBUG,`Sending keepalive`),this.hooks.callHook(`frontgateConnection:sendMessage`,{message:this.#d(),callbackType:`response`,callbackId:`KeepAliveMessage`})},this.#t.maximumIdleIntervalInS/2*1e3)};this.#n=`connected`,this.log(U.DEBUG,`Connected`),this.hooks.callHook(`frontgateConnection:connected`,this.#t).catch(t),n=this.hooks.hookOnce(`frontgateConnection:authenticated`,()=>{this.#n=`authenticated`,this.log(U.DEBUG,`Authenticated`),r(),i(),e()})},this.#e.onclose=e=>{n?.(),this.log(U.DEBUG,`Disconnected`,e),this.#n===`connecting`||this.#n===`connected`?t(JSON.stringify(e)):this.hooks.callHook(`frontgateConnection:disconnected`,e),clearInterval(this.#r),this.#n=`disconnected`},this.#e.onerror=e=>{n?.(),this.log(U.ERROR,`Error:`,e),this.hooks.callHook(`frontgateConnection:error`,e),(this.#n===`connecting`||this.#n===`connected`)&&t(Error(`Websocket error`)),clearInterval(this.#r),this.#n=`disconnected`},this.#e.onmessage=e=>{let{data:t}=e;this.log(U.DEBUG,`Received data:`,t);let n={msg:t};this.hooks.callHook(`frontgateConnection:afterReceiveMessage`,n).then(()=>{this.log(U.DEBUG,`Received message`,n.msg);let e=n.msg.toString(`utf-8`),t=JSON.parse(e);if(this.hooks.callHook(`frontgateConnection:message`,t),t.Message===`Foundation::DisconnectionMessage`){this.#e?.close(),this.hooks.callHook(`frontgateConnection:disconnected`,t);return}this.#p(t)})}}),u=`Timeout reached (${this.defaultTimeoutInMs} ms) for connection to ${i}`;return j(this.defaultTimeoutInMs,u,l)}async disconnect(){return new Promise(e=>{this.#f(this.#u()),this.hooks.hookOnce(`frontgateConnection:disconnected`,()=>{this.#e?.close(),e()})})}#u(){return{Message:`Foundation::DisconnectionMessage`,Version:3,reason:{value:64},details:`client shutdown`}}#d(){return{Message:`KeepAliveMessage`,Version:2}}async#f(e){await this.hooks.callHook(`frontgateConnection:beforeSerializeMessage`,e);let t={msg:JSON.stringify(e)};await this.hooks.callHook(`frontgateConnection:beforeSendMessage`,t),this.log(U.DEBUG,`Sending message:`,e),this.log(U.TRACE,`Sending data:`,t.msg);try{this.#e?.send(t.msg)}catch(t){let n=this.#g(t,e);this.#p(n)}}#p(e){if(w(e)){this.hooks.callHook(`frontgateConnection:response:${e.header.id_job}`,e);return}if(T(e)){this.hooks.callHook(`frontgateConnection:response:${e.header.id_service}-${e.id_notation}`,e);return}if(C(e)){this.hooks.callHook(`frontgateConnection:response:${e.id_job}`,e);return}typeof e.Message==`string`&&this.hooks.callHook(`frontgateConnection:response:${e.Message.replace(`Foundation::`,``)}`,e)}#m(e){this.#i+=1;let t=this.#i;return e.header={...e.header,id_job:t},this.#i}#h(e){e.header||={authentication_identifiers:{id_application:void 0,id_user:void 0}},e.header.authentication_identifiers||(e.header={...e.header,authentication_identifiers:{id_application:void 0,id_user:void 0}}),e.header.authentication_identifiers.id_application||=this.#a,e.header.authentication_identifiers.id_user||=this.#o}#g(e,t){return{Message:`Foundation::ErrorResponse`,Version:1,header:{},id_job:t.header?.id_job??-1,processing_time:0,reason:{value:8},details:e}}#_(e){let t=e.maximumIdleIntervalInS??60,n=e.maximumIdleInterval??t*1e6;return{...e,payloadContent:e.payloadContent??`foundation`,maximumIdleIntervalInS:t,maximumIdleInterval:n,tls:e.tls??!0,messageBufferSize:e.messageBufferSize??512}}isConnected(){return this.#s===`authenticated`}isDisconnected(){return this.#n!==`authenticated`}isReadyToConnect(){return this.#s===`disconnected`}},{featureName:`WSConnection`,disabledFeatureGroups:[`Connection`]}),ye=(e,t)=>(t&&e.setLevel(t),$(t=>class extends t{constructor(...t){super(...t),this.logger=e}},{featureName:`Logger`,featureGroups:[`Misc`]})),W=Uint8Array,G=Uint16Array,be=Int32Array,xe=new W([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]),Se=new W([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]),Ce=new W([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),we=function(e,t){for(var n=new G(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new be(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},Te=we(xe,2),Ee=Te.b,De=Te.r;Ee[28]=258,De[258]=28;for(var Oe=we(Se,0),ke=Oe.b,Ae=Oe.r,je=new G(32768),K=0;K<32768;++K){var Me=(K&43690)>>1|(K&21845)<<1;Me=(Me&52428)>>2|(Me&13107)<<2,Me=(Me&61680)>>4|(Me&3855)<<4,je[K]=((Me&65280)>>8|(Me&255)<<8)>>1}for(var q=(function(e,t,n){for(var r=e.length,i=0,a=new G(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new G(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new G(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[je[d]>>c]=l}else for(s=new G(r),i=0;i<r;++i)e[i]&&(s[i]=je[o[e[i]-1]++]>>15-e[i]);return s}),Ne=new W(288),K=0;K<144;++K)Ne[K]=8;for(var K=144;K<256;++K)Ne[K]=9;for(var K=256;K<280;++K)Ne[K]=7;for(var K=280;K<288;++K)Ne[K]=8;for(var Pe=new W(32),K=0;K<32;++K)Pe[K]=5;var Fe=q(Ne,9,0),Ie=q(Ne,9,1),Le=q(Pe,5,0),Re=q(Pe,5,1),ze=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},J=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Be=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ve=function(e){return(e+7)/8|0},He=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new W(e.subarray(t,n))},Ue=[`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`],Y=function(e,t,n){var r=Error(t||Ue[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Y),!n)throw r;return r},We=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new W(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new W(i*3));var l=function(e){var t=n.length;if(e>t){var r=new W(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=J(e,d,1);var v=J(e,d+1,3);if(d+=3,!v){var y=Ve(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&Y(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=Ie,m=Re,h=9,g=5;else if(v==2){var S=J(e,d,31)+257,C=J(e,d+10,15)+4,w=S+J(e,d+5,31)+1;d+=14;for(var T=new W(w),E=new W(19),D=0;D<C;++D)E[Ce[D]]=J(e,d+D*3,7);d+=C*3;for(var O=ze(E),ee=(1<<O)-1,k=q(E,O,1),D=0;D<w;){var A=k[J(e,d,ee)];d+=A&15;var y=A>>4;if(y<16)T[D++]=y;else{var j=0,M=0;for(y==16?(M=3+J(e,d,3),d+=2,j=T[D-1]):y==17?(M=3+J(e,d,7),d+=3):y==18&&(M=11+J(e,d,127),d+=7);M--;)T[D++]=j}}var N=T.subarray(0,S),P=T.subarray(S);h=ze(N),g=ze(P),p=q(N,h,1),m=q(P,g,1)}else Y(1);if(d>_){c&&Y(0);break}}s&&l(f+131072);for(var F=(1<<h)-1,I=(1<<g)-1,L=d;;L=d){var j=p[Be(e,d)&F],R=j>>4;if(d+=j&15,d>_){c&&Y(0);break}if(j||Y(2),R<256)n[f++]=R;else if(R==256){L=d,p=null;break}else{var z=R-254;if(R>264){var D=R-257,B=xe[D];z=J(e,d,(1<<B)-1)+Ee[D],d+=B}var V=m[Be(e,d)&I],te=V>>4;V||Y(3),d+=V&15;var P=ke[te];if(te>3){var B=Se[te];P+=Be(e,d)&(1<<B)-1,d+=B}if(d>_){c&&Y(0);break}s&&l(f+131072);var ne=f+z;if(f<P){var H=a-P,re=Math.min(P,ne);for(H+f<0&&Y(3);f<re;++f)n[f]=r[H+f]}for(;f<ne;++f)n[f]=n[f-P]}}t.l=p,t.p=L,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?He(n,0,f):n.subarray(0,f)},X=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Ge=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Ke=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:$e,l:0};if(i==1){var o=new W(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new G(f+1),m=qe(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new W(p),l:m}},qe=function(e,t,n){return e.s==-1?Math.max(qe(e.l,t,n+1),qe(e.r,t,n+1)):t[e.s]=n},Je=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new G(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},Ye=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Xe=function(e,t,n){var r=n.length,i=Ve(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},Ze=function(e,t,n,r,i,a,o,s,c,l,u){X(t,u++,n),++i[256];for(var d=Ke(i,15),f=d.t,p=d.l,m=Ke(a,15),h=m.t,g=m.l,_=Je(f),v=_.c,y=_.n,b=Je(h),x=b.c,S=b.n,C=new G(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=Ke(C,7),E=T.t,D=T.l,O=19;O>4&&!E[Ce[O-1]];--O);var ee=l+5<<3,k=Ye(i,Ne)+Ye(a,Pe)+o,A=Ye(i,f)+Ye(a,h)+o+14+3*O+Ye(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&ee<=k&&ee<=A)return Xe(t,u,e.subarray(c,c+l));var j,M,N,P;if(X(t,u,1+(A<k)),u+=2,A<k){j=q(f,p,0),M=f,N=q(h,g,0),P=h;var F=q(E,D,0);X(t,u,y-257),X(t,u+5,S-1),X(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)X(t,u+3*w,E[Ce[w]]);u+=3*O;for(var I=[v,x],L=0;L<2;++L)for(var R=I[L],w=0;w<R.length;++w){var z=R[w]&31;X(t,u,F[z]),u+=E[z],z>15&&(X(t,u,R[w]>>5&127),u+=R[w]>>12)}}else j=Fe,M=Ne,N=Le,P=Pe;for(var w=0;w<s;++w){var B=r[w];if(B>255){var z=B>>18&31;Ge(t,u,j[z+257]),u+=M[z+257],z>7&&(X(t,u,B>>23&31),u+=xe[z]);var V=B&31;Ge(t,u,N[V]),u+=P[V],V>3&&(Ge(t,u,B>>5&8191),u+=Se[V])}else Ge(t,u,j[B]),u+=M[B]}return Ge(t,u,j[256]),u+M[256]},Qe=new be([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$e=new W(0),et=function(e,t,n,r,i,a){var o=a.z||e.length,s=new W(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=Qe[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new G(32768),g=a.h||new G(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new be(25e3),x=new G(288),S=new G(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var ee=y(T),k=T&32767,A=g[ee];if(h[k]=A,g[ee]=k,D<=T){var j=o-T;if((C>7e3||E>24576)&&(j>423||!l)){u=Ze(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var M=0;M<286;++M)x[M]=0;for(var M=0;M<30;++M)S[M]=0}var N=2,P=0,F=p,I=k-A&32767;if(j>2&&ee==y(T-I))for(var L=Math.min(f,j)-1,R=Math.min(32767,T),z=Math.min(258,j);I<=R&&--F&&k!=A;){if(e[T+N]==e[T+N-I]){for(var B=0;B<z&&e[T+B]==e[T+B-I];++B);if(B>N){if(N=B,P=I,B>L)break;for(var V=Math.min(I,B-2),te=0,M=0;M<V;++M){var ne=T-I+M&32767,H=ne-h[ne]&32767;H>te&&(te=H,A=ne)}}}k=A,A=h[k],I+=k-A&32767}if(P){b[E++]=268435456|De[N]<<18|Ae[P];var re=De[N]&31,ie=Ae[P]&31;w+=xe[re]+Se[ie],++x[257+re],++S[ie],D=T+N,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=Ze(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var ae=T+65535;ae>=o&&(c[u/8|0]=l,ae=o),u=Xe(c,u+1,e.subarray(T,ae))}a.i=o}return He(s,0,r+Ve(u)+i)},tt=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},nt=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new W(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return et(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},rt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},it=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=tt();i.p(t.dictionary),rt(e,2,i.d())}},at=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Y(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&Y(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2},ot=function(){function e(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 W(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 e.prototype.p=function(e,t){this.ondata(nt(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||Y(5),this.s.l&&Y(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var r=new W(n&-32768);r.set(this.b.subarray(0,this.s.z)),this.b=r}var i=this.b.length-this.s.z;this.b.set(e.subarray(0,i),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(i),32768),this.s.z=e.length-i+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),t&&(this.s=this.o={},this.b=$e)},e.prototype.flush=function(e){if(this.ondata||Y(5),this.s.l&&Y(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2,e){var t=new W(6);t[0]=this.s.r>>3;var n=Xe(t,this.s.r,$e);this.s.r=0,this.ondata(t.subarray(0,n>>3),!1)}},e}(),st=function(){function e(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 W(32768),this.p=new W(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||Y(5),this.d&&Y(4),!this.p.length)this.p=e;else if(e.length){var t=new W(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=We(this.p,this.s,this.o);this.ondata(He(n,t,this.s.b),this.d),this.o=He(n,this.s.b-32768),this.s.b=this.o.length,this.p=He(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),ct=function(){function e(e,t){this.c=tt(),this.v=1,ot.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),ot.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=nt(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&=(it(n,this.o),0),t&&rt(n,n.length-4,this.c.d()),this.ondata(n,t)},e.prototype.flush=function(e){ot.prototype.flush.call(this,e)},e}(),lt=function(){function e(e,t){st.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(st.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(at(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&Y(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),st.prototype.c.call(this,t)},e}(),ut=typeof TextEncoder<`u`&&new TextEncoder,dt=typeof TextDecoder<`u`&&new TextDecoder;try{dt.decode($e,{stream:!0})}catch{}var ft=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:He(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function pt(e,t){if(t){for(var n=new W(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(ut)return ut.encode(e);for(var i=e.length,a=new W(e.length+(e.length>>1)),o=0,s=function(e){a[o++]=e},r=0;r<i;++r){if(o+5>a.length){var c=new W(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return He(a,0,o)}function mt(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else if(dt)return dt.decode(e);else{var i=ft(e),a=i.s,n=i.r;return n.length&&Y(8),a}}var ht=e=>{if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));for(let n=0,r=0;n<e.length;++n)t.set(e[n],r),r+=e[n].length;return t},gt=class{constructor(){this.compressor=null,this.decompressor=null,this.reset()}reset(){this.compressor=null,this.decompressor=null}compress(e){this.compressor||=new ct({mem:4});let t=[];return this.compressor.ondata=e=>{t.push(e)},this.compressor.push(pt(e)),this.compressor.flush(),ht(t)}decompress(e){this.decompressor||=new lt;let t;this.decompressor.ondata=e=>{t=e};try{if(this.decompressor.push(e),t===void 0)throw Error(`invalid block type`)}catch(t){throw Error(`Decompression error: ${t.message}, length: ${e.length}, data: [${e.toString()}]`)}return mt(t)}},_t=()=>$(e=>class extends e{#e;constructor(...e){super(...e),this.#e=new gt,this.hooks.hook(`frontgateConnection:reset`,()=>{this.#e.reset()}),this.hooks.hook(`frontgateConnection:afterSetEncoding`,e=>{e.encoding=`jsjsonc-v2`}),this.hooks.hook(`frontgateConnection:beforeSendMessage`,e=>{e.msg=this.#e.compress(e.msg)}),this.hooks.hook(`frontgateConnection:afterReceiveMessage`,e=>{e.msg=this.#e.decompress(new Uint8Array(e.msg))})}},{featureName:`MessageCompressor`,featureGroups:[`Compression`]}),Z=class extends Error{constructor(e){super(`Unexpected response: ${e.Message}`),this.response=e}},vt=()=>$(e=>class extends e{async request(e,t=this.defaultTimeoutInMs){e.header.setTimeout(t);let n={message:e.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,n);let r=new Promise((e,t)=>{this.hooks.hookOnce(`frontgateConnection:response:${n.callbackId}`,n=>{if(n.Message!==`Foundation::HighLevelResponse`&&n.Message!==`HighLevelResponse`){t(new Z(n));return}e(new H(n))})});return j(t,`Request timeout reached (${t} ms) for ${n.message.Message}`,r)}},{featureName:`Request`,featureGroups:[`Misc`]}),yt=e=>$(t=>{let n={...e};return class extends t{#e=new Map;#t=new Map;#n=new Map;async observeEndpoint(e,t,r,i){let a=`${e}:${t}:${JSON.stringify(r)}:${JSON.stringify(i??{})}`;if(this.#n.has(a)){let e=this.#n.get(a);this.log(U.INFO,`Catching inflight subscription for ${a}`);let t=this.#t.get(a)??0;return this.#t.set(a,t+1),e}let o=n.timeout??this.defaultTimeoutInMs,s=n.subscriptionResubscribeTimeout??1e3;if(this.#e.has(a)){let e=this.#e.get(a),t=this.#t.get(a)??0;if(e)return this.#t.set(a,t+1),this.log(U.INFO,`Reusing existing subscription for ${a}`),e}this.log(U.INFO,`Creating new subscription for ${a}`);let c=new z(e,t,r,{...i,subscribe:!0});c.header.setTimeout(o);let l={message:c.getPtlMessage(),callbackType:`job`,callbackId:``},u=!1,d=new Promise((e,t)=>{this.hooks.callHook(`frontgateConnection:sendMessage`,l).then(()=>{this.hooks.hookOnce(`frontgateConnection:response:${l.callbackId}`,n=>{if(n.Message!==`Foundation::HighLevelResponse`&&n.Message!==`HighLevelResponse`){this.log(U.ERROR,`Unexpected response: ${n.Message}`),t(new Z(n));return}let r;try{r=JSON.parse(n.body.value)}catch(e){this.log(U.ERROR,`Failed to parse response: ${n.body.value}`),this.log(U.ERROR,e),t(e);return}let i=new Ot(n.header.id_job,r);if(u){this.log(U.WARN,`Zombie subscription detected for ${a}. Cancelling stale subscription on server.`);let e=new R(i.idJob);this.hooks.callHook(`frontgateConnection:sendMessage`,{message:e.getPtlMessage(),callbackType:`job`,callbackId:``});return}let c=this.hooks.hook(`frontgateConnection:response:${l.callbackId}`,e=>{if(e.Message!==`Foundation::HighLevelUpdate`&&e.Message!==`HighLevelUpdate`){if(e.Message.includes(`SubscriptionLoss`)){this.log(U.DEBUG,`Received: ${e.Message}`),setTimeout(()=>{d()},M(s)),c();return}this.log(U.ERROR,`Unexpected response: ${n.Message}`),i.pushError(new Z(e)),c();return}let t;try{t=new oe(e)}catch(t){this.log(U.ERROR,`Failed to parse response: ${e.body.value}`),i.pushError(Error(`Failed to parse response`,{cause:t}));return}i.pushPatchData(t.data)}),d=async()=>{c(),this.log(U.INFO,`Resubscribing to ${a} due to reconnect`),await this.hooks.callHook(`frontgateConnection:sendMessage`,l);let e,t=new Promise((t,n)=>{e=this.hooks.hookOnce(`frontgateConnection:response:${l.callbackId}`,e=>{if(e.Message!==`Foundation::HighLevelResponse`&&e.Message!==`HighLevelResponse`){let t=new Z(e);this.log(U.ERROR,`Unexpected response: ${e.Message}`),c(),n(t);return}if(this.log(U.INFO,`Resubscribed to ${a} with ${e.header.id_job}`),i.idJob=e.header.id_job,u){this.log(U.WARN,`Zombie subscription detected for ${a}. Initiating unsubscribe.`),i.unsubscribe?.(),t();return}try{i.pushData(JSON.parse(e.body.value))}catch(t){this.log(U.ERROR,`Failed to parse response: ${e.body.value}`),this.log(U.ERROR,t),n(t);return}c=this.hooks.hook(`frontgateConnection:response:${e.header.id_job}`,e=>{if(e.Message!==`Foundation::HighLevelUpdate`&&e.Message!==`HighLevelUpdate`){if(e.Message.includes(`SubscriptionLoss`)){this.log(U.DEBUG,`Received: ${e.Message}`),setTimeout(()=>{d()},M(s));return}this.log(U.ERROR,`Unexpected response: ${e.Message}`);let t=new Z(e);i.pushError(t);return}let t;try{t=new oe(e)}catch(t){this.log(U.ERROR,`Failed to parse response: ${e.body.value}`),i.pushError(Error(`Failed to parse response`,{cause:t}));return}i.pushPatchData(t.data)}),t()})});try{await j(o,`Request timeout reached`,t)}catch(t){e?.(),u=!0,i.pushError(Error(`Resubscribe failed`,{cause:t}))}},f=this.hooks.hook(`reconnect:success`,d);i.unsubscribe=()=>{if(this.#e.get(a)){let e=this.#t.get(a)??0;if(this.#t.set(a,e-1),e-1>0){this.log(U.INFO,`Not unsubscribing from ${a} as there are still ${e} subscribers`);return}this.#e.delete(a),this.#t.delete(a),u=!0}this.log(U.INFO,`Unsubscribing from ${a}`);let e={message:new R(i.idJob).getPtlMessage(),callbackType:`job`,callbackId:``};this.hooks.callHook(`frontgateConnection:sendMessage`,e),c(),f()},this.#e.set(a,i);let p=this.#t.get(a)??0;this.#t.set(a,p+1),e(i)})}).catch(e=>{t(e)})}),f=j(o,`Request timeout reached (${o} ms) for ${l.message.Message}`,d).catch(e=>{throw u=!0,this.#t.delete(a),this.#e.delete(a),e}).finally(()=>{this.#n.delete(a)});return this.#n.set(a,f),f}}},{featureName:`EndpointSubscriptions`,featureGroups:[`Misc`]}),bt=()=>$(e=>class extends e{#e=new Map;async observe(e,t=this.defaultTimeoutInMs){return this.#t(e,`job`,void 0,t)}async observeConnectionBased(e,t,n=this.defaultTimeoutInMs){return this.#t(e,`connection`,t,n)}async#t(e,t,n,r=this.defaultTimeoutInMs){let i=JSON.stringify(e.getPtlMessage());if(this.#e.has(i)){let e=this.#e.get(i);if(e)return e.count++,this.log(U.INFO,`Reusing existing subscription for ${i}`),e.observer}this.log(U.INFO,`Creating new subscription for ${i}`);let a={message:e.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,a);let o=new Promise((e,o)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,s=>{if(s.Message.includes(`Error`)||s.Message.includes(`PermissionDenied`)||!w(s)){this.log(U.ERROR,`Unexpected response: ${s.Message}`),o(new Z(s));return}let c=s.header.id_job.toString(),l=-1,u=-1;t===`connection`&&T(s)&&(l=s.header.id_service,u=s.id_notation,c=`${l}-${u}`);let d=n===void 0?new R(s.header.id_job):new n(l,u),f=new Dt(s.header.id_job,s),p=this.hooks.hook(`frontgateConnection:response:${c}`,e=>{if(e.Message===`Foundation::ErrorResponse`){this.log(U.ERROR,`Unexpected response: ${s.Message}`),f.pushError(new Z(e));return}f.pushData(e)}),m=this.hooks.hook(`reconnect:success`,async()=>{p(),this.log(U.INFO,`Resubscribing to ${i} due to reconnect`),await this.hooks.callHook(`frontgateConnection:sendMessage`,a);let e=new Promise((e,r)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,a=>{if(a.Message===`Foundation::ErrorResponse`||!w(a)){let e=new Z(a);this.log(U.ERROR,`Unexpected resp: ${a.Message}`),r(e);return}let o=s.header.id_job.toString();t===`connection`&&T(a)&&(l=a.header.id_service,u=a.id_notation,o=`${l}-${u}`);let c=n===void 0?new R(a.header.id_job):new n(l,u);f.idJob=a.header.id_job,p=this.hooks.hook(`frontgateConnection:response:${o}`,e=>{if(e.Message===`Foundation::ErrorResponse`){this.log(U.ERROR,`Unexpected response: ${e.Message}`),f.pushError(new Z(e));return}f.unsubscribe=()=>{let e=this.#e.get(i);if(e){if(e.count--,e.count>0){this.log(U.INFO,`Not unsubscribing from ${i} as there are still ${e.count} subscribers`);return}this.#e.delete(i)}this.log(U.INFO,`Unsubscribing from ${i}`);let t={message:c.getPtlMessage(),callbackType:`job`,callbackId:``};this.hooks.callHook(`frontgateConnection:sendMessage`,t),p(),m()},f.pushData(e)}),e()})});try{await j(r,`Request timeout reached`,e)}catch(e){f.pushError(Error(`Reconnect Failed`,{cause:e}))}});f.unsubscribe=()=>{let e=this.#e.get(i);if(e){if(e.count--,e.count>0){this.log(U.INFO,`Not unsubscribing from ${i} as there are still ${e.count} subscribers`);return}this.#e.delete(i)}this.log(U.INFO,`Unsubscribing from ${i}`);let t={message:d.getPtlMessage(),callbackType:`job`,callbackId:``};this.hooks.callHook(`frontgateConnection:sendMessage`,t),p(),m()},this.#e.set(i,{observer:f,count:1}),e(f)})});return j(r,`Request timeout reached (${r} ms) for ${a.message.Message}`,o)}},{featureName:`RawSubscriptions`,featureGroups:[`Misc`]}),xt=(e,t)=>{let n=t.split(`/`).slice(1),r=e;for(let e=0;e<n.length-1;e++){let i=decodeURIComponent(n[e]);if(!(i in r))throw Error(`Path not found: ${t}`);r=r[i]}return[r,decodeURIComponent(n[n.length-1])]},St=(e,t,n)=>{let[r,i]=xt(e,t);r[i]=n},Ct=`-`,wt=(e,t,n)=>{let[r,i]=xt(e,t);Array.isArray(r)?i===Ct?r.push(n):r.splice(parseInt(i,10),0,n):r[i]=n},Tt=(e,t)=>{let[n,r]=xt(e,t);Array.isArray(n)?n.splice(parseInt(r,10),1):delete n[r]};function Et(e,t){return t.forEach(t=>{switch(t.op){case`replace`:St(e,t.path,t.value);break;case`add`:wt(e,t.path,t.value);break;case`remove`:Tt(e,t.path);break;default:throw Error(`Unsupported op: ${t.op}`)}}),e}var Dt=class{#e;#t=[];#n=[];get data(){return this.#e}constructor(e,t){this.#e=t,this.idJob=e}subscribe({next:e,error:t}){e(this.#e),t&&this.#n.push(t),this.#t.push(e)}pushData(e){this.#e=e,this.#t.forEach(t=>{t(e)})}pushError(e){this.#n.forEach(t=>{t(e)})}},Ot=class extends Dt{pushPatchData(e){try{let t=Et(this.data,e);super.pushData(t)}catch(e){super.pushError(Error(`Failed to apply patch`,{cause:e}))}}},kt=e=>$(t=>class extends t{constructor(...t){super(...t),this.hooks.hook(`frontgateConnection:beforeConnect`,t=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2),this.log(U.DEBUG,`Adding mdg2auth subprotocol`),t.subProtocols.push(`mdg2auth-${e}`)}),this.hooks.hookOnce(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t=new I({b64:``},{maximum_idle_interval:e.maximumIdleInterval}.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,t);let n={message:t,callbackType:`response`,callbackId:t.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,n),this.hooks.hookOnce(`frontgateConnection:response:${n.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}},{featureName:`CookieTokenAuth`,featureGroups:[`Auth`],disabledFeatureGroups:[`Auth`]}),At=e=>$(t=>class extends t{#e;constructor(...t){super(...t),this.#e=e??``,this.hooks.hook(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t={maximum_idle_interval:e.maximumIdleInterval},n=new I({b64:this.#e},t.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,n);let r={message:n,callbackType:`response`,callbackId:n.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,r),this.hooks.hookOnce(`frontgateConnection:response:${r.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}set token(e){this.#e=e}},{featureName:`TokenAuth`,featureGroups:[`Auth`],disabledFeatureGroups:[`Auth`]}),jt=(e,t,n)=>$(r=>class extends ve({host:``,pathPrefix:``,port:0,tls:!0,maximumIdleIntervalInS:e.maximumIdleIntervalInS})(r){#e=``;#t=``;#n;#r;constructor(...e){super(...e),this.#n=t,this.#r=n,this.hooks.hook(`frontgateConnection:beforeConnect`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2),this.log(U.DEBUG,`Fetching connection configuration`);let t=await this.#i();if(this.log(U.DEBUG,`Connection configuration received`,t),e.url=t.url,t.authtenticationType===`token`&&t.authenticationToken)this.#e=t.authenticationToken;else if(t.splitAuthenticationTokenSecondFactor)this.#t=t.splitAuthenticationTokenSecondFactor;else throw Error(`Invalid authentication configuration`);this.log(U.DEBUG,`Adding mdg2auth subprotocol`),this.#t!==``&&e.subProtocols.push(`mdg2auth-${this.#t}`)}),this.hooks.hook(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t={maximum_idle_interval:e.maximumIdleInterval},n=new I({b64:this.#e},t.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,n);let r={message:n,callbackType:`response`,callbackId:n.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,r),this.hooks.hookOnce(`frontgateConnection:response:${r.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}async#i(){let e=await fetch(this.#n,this.#r);if(!e.ok)throw Error(`Failed to fetch connection configuration: ${e.status} ${e.statusText}`);let{headers:t}=e,n=t.get(`frontgate-host`),r=t.get(`frontgate-path-prefix`),i=t.get(`frontgate-split-authentication-token-second-factor`),a=t.get(`frontgate-authentication-type`),o=t.get(`frontgate-authentication-token`),s=`wss://${n}:${t.get(`frontgate-websocket-port`)??`443`}${r??``}/ws`;if(a===`token`&&!o)throw Error(`Authentication token is required for token authentication`);if(a!==`token`&&!i)throw Error(`Split authentication token second factor is required`);return{url:s,authtenticationType:a,authenticationToken:o,splitAuthenticationTokenSecondFactor:i}}},{featureName:`FetchAuth`,featureGroups:[`Auth`,`Connection`],disabledFeatureGroups:[`Auth`,`Connection`]}),Mt=(e,t,n)=>$(r=>class extends ve({host:``,pathPrefix:``,port:0,tls:!0,maximumIdleIntervalInS:e.maximumIdleIntervalInS})(r){#e=``;#t=``;#n=!1;#r;#i;#a;constructor(...e){super(...e),this.#i=t,this.#a=n,this.#r=new gt,this.hooks.hook(`frontgateConnection:reset`,()=>{this.#n&&this.#r.reset()}),this.hooks.hook(`frontgateConnection:beforeSendMessage`,e=>{this.#n&&(e.msg=this.#r.compress(e.msg))}),this.hooks.hook(`frontgateConnection:afterReceiveMessage`,e=>{this.#n&&(e.msg=this.#r.decompress(new Uint8Array(e.msg)))}),this.hooks.hook(`frontgateConnection:beforeConnect`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2),this.log(U.DEBUG,`Fetching connection configuration`);let t=await this.#o();if(this.log(U.DEBUG,`Connection configuration received`,t),e.url=t.url,t.authtenticationType===`token`&&t.authenticationToken)this.#e=t.authenticationToken;else if(t.splitAuthenticationTokenSecondFactor)this.#t=t.splitAuthenticationTokenSecondFactor;else throw Error(`Invalid authentication configuration`);this.log(U.DEBUG,`Adding mdg2auth subprotocol`),this.#t!==``&&e.subProtocols.push(`mdg2auth-${this.#t}`),this.#n&&e.subProtocols.forEach((t,n)=>{t.includes(`jsjson`)&&!t.includes(`jsjsonc`)&&(e.subProtocols[n]=t.replace(`jsjson`,`jsjsonc`))})}),this.hooks.hook(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t={maximum_idle_interval:e.maximumIdleInterval},n=new I({b64:this.#e},t.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,n);let r={message:n,callbackType:`response`,callbackId:n.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,r),this.hooks.hookOnce(`frontgateConnection:response:${r.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}async#o(){let e=await fetch(this.#i,this.#a);if(!e.ok)throw Error(`Failed to fetch connection configuration: ${e.status} ${e.statusText}`);let{headers:t}=e,n=t.get(`frontgate-host`),r=t.get(`frontgate-path-prefix`),i=t.get(`frontgate-split-authentication-token-second-factor`),a=t.get(`frontgate-authentication-type`),o=t.get(`frontgate-authentication-token`),s=`wss://${n}:${t.get(`frontgate-websocket-port`)??`443`}${r??``}/ws`;if(a===`token`&&!o)throw Error(`Authentication token is required for token authentication`);if(a!==`token`&&!i)throw Error(`Split authentication token second factor is required`);return t.get(`frontgate-websocket-protocol`)===`jsjsonc-v2`?this.#n=!0:this.#n=!1,{url:s,authtenticationType:a,authenticationToken:o,splitAuthenticationTokenSecondFactor:i}}},{featureName:`FetchAuthWithOptionalCompressor`,featureGroups:[`Auth`,`Connection`],disabledFeatureGroups:[`Auth`,`Connection`,`Compression`]}),Nt=e=>$(t=>class extends t{#e=0;#t;#n;constructor(...t){super(...t),this.#t=e??[1e3,2e3,4e3,8e3,16e3,32e3];let n=e=>{if(e.code!==1e3){this.#n&&(this.log(U.WARN,`Aborting previous reconnect attempt`),clearTimeout(this.#n),this.#e=0);let t=this.#e;this.#e>=this.#t.length&&(t=this.#t.length-1);let r=this.#t[t];this.#n=setTimeout(()=>{this.log(U.INFO,`Reconnecting... Attempt ${this.#e}`);let t=this.hooks.hookOnce(`reconnect:failed`,n);this.hooks.callHook(`reconnect:attempt`,e).then(t).catch(()=>{this.log(U.ERROR,`Failed to reconnect`)}),this.#n=void 0},r),this.#e++}};this.hooks.hookOnce(`frontgateConnection:disconnected`,n),this.hooks.hook(`reconnect:success`,()=>{clearTimeout(this.#n),this.#n=void 0,this.#e=0,this.log(U.INFO,`Reconnected`),this.hooks.hookOnce(`frontgateConnection:disconnected`,n)})}},{featureName:`Reconnect`,featureGroups:[`Misc`],disabledFeatures:[`TokenAuth`,`CookieTokenAuth`]}),Pt=`1.9.1`,Ft=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function It(e){let t=new Set([e]),n=new Set,r=e.match(Ft);if(!r)return()=>!1;let i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;let r=e.match(Ft);if(!r)return a(e);let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return s.prerelease!=null||i.major!==s.major?a(e):i.major===0?i.minor===s.minor&&i.patch<=s.patch?o(e):a(e):i.minor<=s.minor?o(e):a(e)}}var Lt=It(Pt),Rt=Pt.split(`.`)[0],zt=Symbol.for(`opentelemetry.js.api.${Rt}`),Bt=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{};function Vt(e,t,n,r=!1){let i=Bt[zt]=Bt[zt]??{version:Pt};if(!r&&i[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(t.stack||t.message),!1}if(i.version!==`1.9.1`){let t=Error(`@opentelemetry/api: Registration of version v${i.version} for ${e} does not match previously registered API v${Pt}`);return n.error(t.stack||t.message),!1}return i[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${Pt}.`),!0}function Ht(e){let t=Bt[zt]?.version;if(!(!t||!Lt(t)))return Bt[zt]?.[e]}function Ut(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${Pt}.`);let n=Bt[zt];n&&delete n[e]}var Wt=class{constructor(e){this._namespace=e.namespace||`DiagComponentLogger`}debug(...e){return Gt(`debug`,this._namespace,e)}error(...e){return Gt(`error`,this._namespace,e)}info(...e){return Gt(`info`,this._namespace,e)}warn(...e){return Gt(`warn`,this._namespace,e)}verbose(...e){return Gt(`verbose`,this._namespace,e)}};function Gt(e,t,n){let r=Ht(`diag`);if(r)return r[e](t,...n)}var Q;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(Q||={});function Kt(e,t){e<Q.NONE?e=Q.NONE:e>Q.ALL&&(e=Q.ALL),t||={};function n(n,r){let i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,Q.ERROR),warn:n(`warn`,Q.WARN),info:n(`info`,Q.INFO),debug:n(`debug`,Q.DEBUG),verbose:n(`verbose`,Q.VERBOSE)}}var qt=`diag`,Jt=class e{static instance(){return this._instance||=new e,this._instance}constructor(){function e(e){return function(...t){let n=Ht(`diag`);if(n)return n[e](...t)}}let t=this;t.setLogger=(e,n={logLevel:Q.INFO})=>{if(e===t){let e=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error(e.stack??e.message),!1}typeof n==`number`&&(n={logLevel:n});let r=Ht(`diag`),i=Kt(n.logLevel??Q.INFO,e);if(r&&!n.suppressOverrideMessage){let e=Error().stack??`<failed to generate stacktrace>`;r.warn(`Current logger will be overwritten from ${e}`),i.warn(`Current logger will overwrite one already registered from ${e}`)}return Vt(`diag`,i,t,!0)},t.disable=()=>{Ut(qt,t)},t.createComponentLogger=e=>new Wt(e),t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}};function Yt(e){return Symbol.for(e)}var Xt=new class e{constructor(t){let n=this;n._currentContext=t?new Map(t):new Map,n.getValue=e=>n._currentContext.get(e),n.setValue=(t,r)=>{let i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=t=>{let r=new e(n._currentContext);return r._currentContext.delete(t),r}}},Zt=class{active(){return Xt}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}},Qt=`context`,$t=new Zt,en=class e{constructor(){}static getInstance(){return this._instance||=new e,this._instance}setGlobalContextManager(e){return Vt(Qt,e,Jt.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Ht(Qt)||$t}disable(){this._getContextManager().disable(),Ut(Qt,Jt.instance())}},tn;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(tn||={});var nn={traceId:`00000000000000000000000000000000`,spanId:`0000000000000000`,traceFlags:tn.NONE},rn=class{constructor(e=nn){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}},an=Yt(`OpenTelemetry Context Key SPAN`);function on(e){return e.getValue(an)||void 0}function sn(){return on(en.getInstance().active())}function cn(e,t){return e.setValue(an,t)}function ln(e){return e.deleteValue(an)}function un(e,t){return cn(e,new rn(t))}function dn(e){return on(e)?.spanContext()}var fn=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function pn(e,t){if(typeof e!=`string`||e.length!==t)return!1;let n=0;for(let t=0;t<e.length;t+=4)n+=(fn[e.charCodeAt(t)]|0)+(fn[e.charCodeAt(t+1)]|0)+(fn[e.charCodeAt(t+2)]|0)+(fn[e.charCodeAt(t+3)]|0);return n===t}function mn(e){return pn(e,32)&&e!==`00000000000000000000000000000000`}function hn(e){return pn(e,16)&&e!==`0000000000000000`}function gn(e){return mn(e.traceId)&&hn(e.spanId)}function _n(e){return new rn(e)}var vn=en.getInstance(),yn=class{startSpan(e,t,n=vn.active()){if(t?.root)return new rn;let r=n&&dn(n);return bn(r)&&gn(r)?new rn(r):new rn}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??vn.active(),c=this.startSpan(e,i,s),l=cn(s,c);return vn.with(l,o,void 0,c)}};function bn(e){return typeof e==`object`&&!!e&&`spanId`in e&&typeof e.spanId==`string`&&`traceId`in e&&typeof e.traceId==`string`&&`traceFlags`in e&&typeof e.traceFlags==`number`}var xn=new yn,Sn=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}startSpan(e,t,n){return this._getTracer().startSpan(e,t,n)}startActiveSpan(e,t,n,r){let i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):xn}},Cn=new class{getTracer(e,t,n){return new yn}},wn=class{getTracer(e,t,n){return this.getDelegateTracer(e,t,n)??new Sn(this,e,t,n)}getDelegate(){return this._delegate??Cn}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,n){return this._delegate?.getTracer(e,t,n)}},Tn=`trace`,En=class e{constructor(){this._proxyTracerProvider=new wn,this.wrapSpanContext=_n,this.isSpanContextValid=gn,this.deleteSpan=ln,this.getSpan=on,this.getActiveSpan=sn,this.getSpanContext=dn,this.setSpan=cn,this.setSpanContext=un}static getInstance(){return this._instance||=new e,this._instance}setGlobalTracerProvider(e){let t=Vt(Tn,this._proxyTracerProvider,Jt.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return Ht(Tn)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){Ut(Tn,Jt.instance()),this._proxyTracerProvider=new wn}}.getInstance(),Dn=()=>$(e=>class extends e{constructor(...e){super(...e),this.hooks.hook(`frontgateConnection:beforeSerializeMessage`,e=>{E(e)&&En.getTracer(`frontgate-js-sdk`).startActiveSpan(`frontgateConnection:sendMessage`,t=>{let n=this.#e(t.spanContext());n&&(e.header={...e.header,...n}),t.end()})})}#e(e){if(!/^0+$/.test(e.traceId))return{tracing:{value:{value:On(e)}}}}},{featureName:`OpenTelemetry`,featureGroups:[`Misc`]}),On=e=>{let t=[18,20,9],n=e=>{for(let n=e.length;n>e.length-16;n-=2){let r=parseInt(e.substring(n-2,n),16);r>127&&(r-=256),t.push(r)}};return n(e.traceId),t.push(17),n(e.spanId),t.push(24),t.push(0),t},kn=()=>$(e=>class extends e{async requestProxyEndpoint(e,t,n,r,i=this.defaultTimeoutInMs){let a=new B(e,t,r);n&&a.setBody(n),a.header.setTimeout(i);let o={message:a.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,o);let s=new Promise((e,t)=>{this.hooks.hookOnce(`frontgateConnection:response:${o.callbackId}`,n=>{try{if(n.Message!==`Foundation::HTTPProxyResponse`){t(JSON.stringify(n));return}let r=new ie(n);e({response:r,data:r.data})}catch(e){t(e)}})});return j(i,`Request timeout reached (${i} ms) for ${o.message.Message}`,s)}},{featureName:`HTTPProxyRequest`,featureGroups:[`Misc`]}),An=()=>$(e=>class extends e{async ping(e=this.defaultTimeoutInMs){let t={message:new V().getPtlMessage(),callbackType:`response`,callbackId:`PingResponse`};await this.hooks.callHook(`frontgateConnection:sendMessage`,t);let n=new Promise((e,n)=>{this.hooks.hookOnce(`frontgateConnection:response:${t.callbackId}`,t=>{if(t.Message!==`Foundation::PingResponse`){n(JSON.stringify(t));return}e(new ae(t))})});return j(e,`Request timeout reached (${e} ms) for ${t.message.Message}`,n)}},{featureName:`Pingable`,featureGroups:[`Misc`]}),jn=e=>$(t=>class extends t{async logRemotely(t){let n={message:new te({Message:`LogMessage`,timestamp:{microseconds:Date.now()*1e3},uuid:{id_1:e??0,id_2:0},level:{value:4},area:61,Version:1,message:t}).getPtlMessage(),callbackType:`job`,callbackId:``};return this.hooks.callHook(`frontgateConnection:sendMessage`,n)}},{featureName:`RemoteLogger`,featureGroups:[`Misc`]}),$=(e,t)=>{let n=e;return n.featureName=t.featureName,n.featureGroups=t.featureGroups,n.disabledFeatures=t.disabledFeatures,n.disabledFeatureGroups=t.disabledFeatureGroups,n};function Mn(e,t={},n){for(let r in e){let i=e[r],a=n?`${n}:${r}`:r;typeof i==`object`&&i?Mn(i,t,a):typeof i==`function`&&(t[a]=i)}return t}var Nn={run:e=>e()},Pn=console.createTask===void 0?()=>Nn:console.createTask;function Fn(e,t){let n=Pn(t.shift());return e.reduce((e,r)=>e.then(()=>n.run(()=>r(...t))),Promise.resolve())}function In(e,t){let n=Pn(t.shift());return Promise.all(e.map(e=>n.run(()=>e(...t))))}function Ln(e,t){for(let n of[...e])n(t)}var Rn=class{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()=>{};let r=e,i;for(;this._deprecatedHooks[e];)i=this._deprecatedHooks[e],e=i.to;if(i&&!n.allowDeprecated){let e=i.message;e||=`${r} hook has been deprecated`+(i.to?`, please use ${i.to}`:``),this._deprecatedMessages||=new Set,this._deprecatedMessages.has(e)||(console.warn(e),this._deprecatedMessages.add(e))}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),void 0)}}hookOnce(e,t){let n,r=(...e)=>(typeof n==`function`&&n(),n=void 0,r=void 0,t(...e));return n=this.hook(e,r),n}removeHook(e,t){if(this._hooks[e]){let 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;let n=this._hooks[e]||[];delete this._hooks[e];for(let t of n)this.hook(e,t)}deprecateHooks(e){Object.assign(this._deprecatedHooks,e);for(let t in e)this.deprecateHook(t,e[t])}addHooks(e){let t=Mn(e),n=Object.keys(t).map(e=>this.hook(e,t[e]));return()=>{for(let e of n.splice(0,n.length))e()}}removeHooks(e){let t=Mn(e);for(let e in t)this.removeHook(e,t[e])}removeAllHooks(){for(let e in this._hooks)delete this._hooks[e]}callHook(e,...t){return t.unshift(e),this.callHookWith(Fn,e,...t)}callHookParallel(e,...t){return t.unshift(e),this.callHookWith(In,e,...t)}callHookWith(e,t,...n){let r=this._before||this._after?{name:t,args:n,context:{}}:void 0;this._before&&Ln(this._before,r);let i=e(t in this._hooks?[...this._hooks[t]]:[],n);return i instanceof Promise?i.finally(()=>{this._after&&r&&Ln(this._after,r)}):(this._after&&r&&Ln(this._after,r),i)}beforeEach(e){return this._before=this._before||[],this._before.push(e),()=>{if(this._before!==void 0){let 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){let t=this._after.indexOf(e);t!==-1&&this._after.splice(t,1)}}}};function zn(){return new Rn}var Bn=typeof window<`u`;function Vn(e,t={}){let n={inspect:Bn,group:Bn,filter:()=>!0,...t},r=n.filter,i=typeof r==`string`?e=>e.startsWith(r):r,a=n.tag?`[${n.tag}] `:``,o=e=>a+e.name+``.padEnd(e._id,`\0`),s={},c=e.beforeEach(e=>{i!==void 0&&!i(e.name)||(s[e.name]=s[e.name]||0,e._id=s[e.name]++,console.time(o(e)))}),l=e.afterEach(e=>{i!==void 0&&!i(e.name)||(n.group&&console.groupCollapsed(e.name),n.inspect?console.timeLog(o(e),e.args):console.timeEnd(o(e)),n.group&&console.groupEnd(),s[e.name]--)});return{close:()=>{c(),l()}}}var Hn=class{#e;get defaultTimeoutInMs(){return this.#e}constructor(e){this.hooks=zn(),this.#e=1e4,e?.hookDebug&&Vn(this.hooks,{tag:`hooks`}),e?.defaultRequestTimeout&&(this.#e=e.defaultRequestTimeout)}log(e,...t){if(this.hooks.callHook(`base:log`,t),this.logger)switch(e){case U.TRACE:this.logger.trace(t);break;case U.DEBUG:this.logger.debug(t);break;case U.INFO:this.logger.info(t);break;case U.WARN:this.logger.warn(t);break;case U.ERROR:this.logger.error(t);break;case U.FATAL:this.logger.fatal(t);break;default:break}}},Un=class e{#e;#t=[];#n=[];#r=[];constructor(e,t=[],n=[],r=[]){this.#e=e,this.#t=t,this.#n=n,this.#r=r}static create(){return new e(Hn)}#i(e){if(this.#t.includes(e))throw Error(`Feature "${e}" has already been used.`)}#a(e){for(let t of this.#n)if(t.feature===e)throw Error(`Feature "${e}" has been disabled by ${t.disabler.join(`,`)}.`)}#o(e){for(let t of this.#r)if(t.feature===e)throw Error(`Group "${e}" has been disabled by ${t.disabler.join(`,`)}.`)}#s(e,t){for(let n of this.#n)if(n.feature===t){n.disabler.push(e);return}this.#n.push({disabler:[e],feature:t})}#c(e,t){for(let n of this.#r)if(n.feature===t){n.disabler.push(e);return}this.#r.push({disabler:[e],feature:t})}with(t){let{featureName:n,disabledFeatures:r,disabledFeatureGroups:i,featureGroups:a}=t;if(!n)throw Error(`Feature name is missing`);if(n!==`Custom`){if(this.#i(n),this.#a(n),this.#t.push(n),a&&a.length>0)for(let e of a)this.#o(e);if(r&&r.length>0)for(let e of r)this.#s(n,e);if(i&&i.length>0)for(let e of i)this.#c(n,e)}let o=t(this.#e);return new e(o,this.#t,this.#n,this.#r)}build(e){return new this.#e(e)}getClientConstructor(){return this.#e}};e.AbstractLogger=ce,e.AbstractMdg2Request=F,e.AuthenticationByTokenRequest=I,e.AuthenticationTokenRequest=L,e.AuthenticationTokenResponse=ne,e.CancelSubscriptionRequest=R,e.ConnectionState=v,e.ConsoleLogger=ue,e.CookieTokenAuthenticationFactors=p,e.DEFAULT_TIMEOUT_IN_MS=N,e.DefaultHosts=b,e.DeploymentStage=y,e.FLAG_HAS_NEXT_CHUNK=se,e.FrontgateClient=Hn,e.FrontgateClientBuilder=Un,e.FrontgateClientDataObserver=Dt,e.FrontgateClientEndpointDataObserver=Ot,e.HTTPProxyRequest=B,e.HTTPProxyResponse=ie,e.HighLevelRequest=z,e.HighLevelResponse=re,e.HighLevelUpdate=oe,e.ID_APP_AUTHENTICATED=m,e.ID_USER_AUTHENTICATED=h,e.ID_USER_NONE=g,e.LogLevel=U,e.LoggerHelper=le,e.Mdg2Response=H,e.NullLogger=pe,e.PingRequest=V,e.PingResponse=ae,e.RawRequest=te,e.TimeOptions=x,e.TransportLayerClientRequestHeader=P,e.WinstonLogger=fe,e.authTokenRequest=me,e.cookieTokenAuth=kt,e.createExtendedMixinFactory=$,e.encodeSpanContext=On,e.endpointRequest=he,e.endpointSubscriptions=yt,e.fetchAuth=jt,e.fetchAuthWithOptionalCompressor=Mt,e.getBytesFromBuffer=_,e.hasJobIdInHeader=w,e.hasJobIdInRoot=C,e.httpProxyRequest=kn,e.isPtlMessageWithHeader=E,e.isServiceAndNotationBased=T,e.levels=de,e.logger=ye,e.messageCompressor=_t,e.openTelemetry=Dn,e.pingRequests=An,e.rawSubscriptions=bt,e.reconnect=Nt,e.remotelogger=jn,e.requests=vt,e.timeToMilliseconds=S,e.tokenAuth=At,e.useTimeout=j,e.wsConnection=ve});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.fdsg={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=((e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)))(s(((e,t)=>{var n=function(e){return r(e)&&!i(e)};function r(e){return!!e&&typeof e==`object`}function i(e){var t=Object.prototype.toString.call(e);return t===`[object RegExp]`||t===`[object Date]`||o(e)}var a=typeof Symbol==`function`&&Symbol.for?Symbol.for(`react.element`):60103;function o(e){return e.$$typeof===a}function s(e){return Array.isArray(e)?[]:{}}function c(e,t){return t.clone!==!1&&t.isMergeableObject(e)?g(s(e),e,t):e}function l(e,t,n){return e.concat(t).map(function(e){return c(e,n)})}function u(e,t){if(!t.customMerge)return g;var n=t.customMerge(e);return typeof n==`function`?n:g}function d(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function f(e){return Object.keys(e).concat(d(e))}function p(e,t){try{return t in e}catch{return!1}}function m(e,t){return p(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function h(e,t,n){var r={};return n.isMergeableObject(e)&&f(e).forEach(function(t){r[t]=c(e[t],n)}),f(t).forEach(function(i){m(e,i)||(p(e,i)&&n.isMergeableObject(t[i])?r[i]=u(i,n)(e[i],t[i],n):r[i]=c(t[i],n))}),r}function g(e,t,r){r||={},r.arrayMerge=r.arrayMerge||l,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=c;var i=Array.isArray(t);return i===Array.isArray(e)?i?r.arrayMerge(e,t,r):h(e,t,r):c(t,r)}g.all=function(e,t){if(!Array.isArray(e))throw Error(`first argument should be an array`);return e.reduce(function(e,n){return g(e,n,t)},{})},t.exports=g}))());function u(e){return!!e&&typeof e==`object`}function d(...e){let t=e.filter(u);return l.default.all(t,{arrayMerge:(e,t)=>t})}function f(e){return e.replace(/[=]/g,``).replace(/\//g,`_`).replace(/\+/g,`-`)}var p=class{constructor(e){let t=f(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}},m=-2,h=-2,g=-1;function _(e){let t=[];if(e)for(let n=0;n<e.length;n++)t.push(e.readInt8(n));return t}var v=function(e){return e[e.DISCONNECTED=0]=`DISCONNECTED`,e[e.CONNECTING=1]=`CONNECTING`,e[e.AUTHENTICATED=2]=`AUTHENTICATED`,e[e.RECONNECTING=3]=`RECONNECTING`,e}({}),y=function(e){return e[e.production=40]=`production`,e[e.preproduction=35]=`preproduction`,e[e.show=30]=`show`,e[e.testing=20]=`testing`,e}({}),b=function(e){return e.production=`frontgate-eu.factsetdigitalsolutions.com`,e.show=`frontgate-eu.show.factsetdigitalsolutions.com`,e}({}),x=function(e){return e.MAXIMUM_STRING=`9223372036854775807`,e.MINIMUM_STRING=`-9223372036854775807`,e}({});function S(e){return e.toString().slice(0,-3)}var C=e=>e.id_job!==void 0,w=e=>e.header?.id_job!==void 0,T=e=>e.header?.id_service!==void 0&&e.id_notation!==void 0,E=e=>e.header!==void 0,D={version:`7.1.7`,package:`@factset/frontgate-js-sdk`};function O(){let e=ee();return{userAgent:e.userAgent??`unknown`,platform:`frontgate-js-sdk`,version:D.version,package:D.package,mobile:/Mobi/i.test(e.userAgent??`unknown`)}}function ee(){return typeof navigator<`u`?navigator:typeof process<`u`?{userAgent:`node.js/io.js, ${process.version}`}:{userAgent:`unknown`}}var k=e=>{let t=[18,20,9],n=e=>{for(let n=e.length;n>e.length-16;n-=2){let r=parseInt(e.substring(n-2,n),16);r>127&&(r-=256),t.push(r)}};return n(e.traceId),t.push(17),n(e.spanId),t.push(24),t.push(0),t},A=async(e,t)=>new Promise((n,r)=>{setTimeout(()=>{r(t)},e)}),j=async(e,t,n)=>Promise.race([A(e,t),n]),M=e=>e+Math.random()*100,N=6e3,P=class e{constructor(){this.headerMembers={dataset:{id_dataset:0},id_job:0,flags_r2:0,resend_counter:0,timeout:N,authentication_identifiers:{id_application:0,id_user:0},cache_key:{value:[]},previous_response_hash:{value:[]},tracing:{value:{value:[]}}},this.flags=[]}static{this.PRICE_QUALITY={RLT:129,DLY:0,EOD:130}}static{this.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}}getPtlMessage(){return this.headerMembers}getQuality(){return Object.keys(e.PRICE_QUALITY).find(t=>e.PRICE_QUALITY[t]===this.headerMembers.dataset.id_dataset)}setQuality(t){this.headerMembers.dataset.id_dataset=e.PRICE_QUALITY[t]}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){let 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((t,n)=>t+e.FLAG_VALUE[n],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 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=k(e))}static getDataSet(t){return Object.prototype.hasOwnProperty.call(e.PRICE_QUALITY,t)?e.PRICE_QUALITY[t]:e.PRICE_QUALITY.DLY}},F=class{constructor(e,t){this.header=new P,this.coreMembers={Message:e,Version:t},this.members={}}getPtlMessage(){let e={header:this.header.getPtlMessage()};return d(this.coreMembers,e,this.members)}},I=class{constructor(e,t){this.token=e,this.maximumIdleInterval=t}toJson(){let e=O();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:{b64:``}},cache_authentication_encrypted_secret:{encrypted_secret:{b64:``}}}}},L=class e extends F{static{this.NAME=`AuthenticationTokenRequest`}static{this.VERSION=6}static{this.LIFETIME_SECONDS_DEFAULT=-1}static{this.LIFETIME_SECONDS_MAXIMUM=-2}static{this.FLAG_SINGLE_USAGE=1}constructor(t,n,r,i,a=!1){super(e.NAME,e.VERSION),n&&this.header.setIdUser(n),r&&this.header.setIdApplication(r),i&&this.header.setTimeout(i),this.members.flags=a?e.FLAG_SINGLE_USAGE:0,this.members.lifetime_seconds_r2=t??e.LIFETIME_SECONDS_DEFAULT,this.header.setFlag(`no_merge`)}},R=class e extends F{static{this.NAME=`CancelSubscriptionRequest`}static{this.VERSION=6}constructor(t){super(e.NAME,e.VERSION),this.members.id_job_subscription=t}},z=class e extends F{static{this.NAME=`HighLevelRequest`}static{this.VERSION=3}static{this.METHOD={GET:1,POST:2}}constructor(t,n,r={},i){super(e.NAME,e.VERSION),this.members.accept=`application/json`,this.members.content_type=`application/json`,this.members.body={value:[]},this.members.query=``,this.members.path=n,this.setMethod(t),Object.keys(r).length>0&&(t===`POST`?this.setBody(r):this.setQuery(r)),i&&this.setOptions(i)}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(t){let n=t===`POST`?e.METHOD.POST:e.METHOD.GET;this.members.method={value:n}}setBody(e={}){e instanceof Array?this.members.body={value:e}:this.members.body={value:JSON.stringify(e)}}getData(){return this.members.method.value===e.METHOD.POST?e.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(e=>{t+=String.fromCharCode(e)}),JSON.parse(t)}}},B=class e extends F{static{this.NAME=`HTTPProxyRequest`}static{this.VERSION=2}static{this.PROTOCOL={HTTP:1,HTTPS:2}}static{this.METHOD={GET:1,POST:2,OPTIONS:3,HEAD:4,PUT:5,DELETE:6,TRACE:7,CONNECT:8}}constructor(t,n,r){super(e.NAME,e.VERSION),this.members.request={headers:{values:[{key:`accept`,value:`application/json`},{key:`content-type`,value:`application/json`}]},protocol:{value:e.PROTOCOL.HTTPS},host:``,port:0,path:n,query:``,body:{value:[]}},this.setQuery(),this.setMethod(t),r&&this.setOptions(r)}setOptions(t){t.no_merge&&this.header.setFlag(`no_merge`),t.idApplication&&this.header.setIdApplication(t.idApplication),t.idUser&&this.header.setIdUser(t.idUser),t.protocol&&(this.members.request.protocol=t.protocol.toUpperCase()===`HTTP`?{value:e.PROTOCOL.HTTP}:{value:e.PROTOCOL.HTTPS}),t.method&&(this.members.request.method={value:e.METHOD[t.method]}),t.host&&(this.members.request.host=t.host),t.port&&(this.members.request.port=t.port),t.path&&(this.members.request.path=t.path),t.query&&(this.members.request.query=typeof t.query==`string`?t.query:Object.keys(t.query).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t.query[e])}`).join(`&`)),t.body&&this.setBody(t.body),t.headers&&this.setHeaders(t.headers)}setHeaders(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t],r=this.members.request.headers.values.findIndex(e=>e.key===t);r!==-1&&this.members.request.headers.values.splice(r,1),this.members.request.headers.values.push({key:t,value:n})}}setQuery(){if(this.members.request.path.includes(`?`)){let e=this.members.request.path.split(`?`);this.members.request.path=e[0],this.members.request.query=e[1]}}setMethod(t){this.members.request.method={value:e.METHOD[t]}}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 z.ptlToJsonData(this.members.request.body.value)}},V=class e{static{this.NAME=`PingRequest`}static{this.VERSION=3}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}},te=class extends F{constructor(e){super(e.Message,e.version?e.version:e.Version),this._extractRequestAttributes(e)}_extractRequestAttributes(e){for(let t of Object.keys(this.coreMembers))delete e[t];this.members=(0,l.default)(this.members,e)}},ne=class{constructor(e){this.token=e.token.value.b64,this.expiry=parseInt(S(e.expiry.microseconds),10)}getToken(){return this.token}getExpiry(){return this.expiry}},H=class{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(){if(this.raw.Message===`Foundation::HTTPProxyResponse`||this.raw.Message===`Foundation::HighLevelResponse`)return this.raw.header.id_service;throw Error(`Invalid message type`)}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}},re=class extends H{constructor(e){super(e);try{this.responseData=JSON.parse(this.raw.body.value)}catch(e){throw Error(`Could not parse HighLevelResponse: ${e.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}},ie=class extends H{constructor(e){super(e);try{let e=this.raw.response.body.value,t=e.substr(0,1)===`{`;this.responseData=t?JSON.parse(e):e}catch(e){throw Error(`Could not parse HTTPProxyResponse: ${e}`)}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 info(){return this.responseInfo}get status(){return{code:this.statusCode,reason:this.statusReason}}},ae=class{static{this.NAME=`Foundation::PingResponse`}static{this.VERSION=2}constructor(e){this._timeReceivedResponse=Date.now(),this._timeAtSender=Number(S(e.time_at_sender.microseconds)),this._timeFromRequest=Number(S(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}},oe=class extends H{constructor(e){if(super(e),typeof this.raw.body.value!=`string`)throw Error(`Incorrect response type in HighLevelUpdate`);try{this.responseData=JSON.parse(this.raw.body.value)}catch(e){throw Error(`Could not parse HighLevelUpdate: ${e.message}`)}}get data(){return this.responseData}},se=8,U=function(e){return e[e.TRACE=10]=`TRACE`,e[e.DEBUG=20]=`DEBUG`,e[e.INFO=30]=`INFO`,e[e.WARN=40]=`WARN`,e[e.ERROR=50]=`ERROR`,e[e.FATAL=60]=`FATAL`,e[e.SILENT=100]=`SILENT`,e}({}),ce=class e{static{this.loggers={}}constructor(t=``){this.defaultLevel=40,this.noop=()=>null,this.name=t,this.level=this.defaultLevel,this.setDefaultLevelFromLocalStorage(),Object.assign(e.loggers,{[t]: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`;default:return!0}}setDefaultLevelFromLocalStorage(){let t;try{if(typeof localStorage!=`object`)return;let e=localStorage.getItem(`loglevel`);if(!e)return;t=e}catch{return}t&&this.setLevel(e.getLogLevel(t))}static getLogLevel(e){let 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 Error(`Invalid log level: ${t}`)}}static getLogger(t,n){if(Object.prototype.hasOwnProperty.call(e.loggers,t))return e.loggers[t];let r=new n(t);return e.loggers[t]=r,r}},le=class{static getLogLevel(e){let t=e.toLowerCase();switch(t){case`silent`:return U.SILENT;case`fatal`:return U.FATAL;case`error`:return U.ERROR;case`warn`:return U.WARN;case`info`:return U.INFO;case`debug`:return U.DEBUG;case`trace`:return U.TRACE;default:throw Error(`Invalid log level: ${t}`)}}},ue=class e extends ce{constructor(...e){super(...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`)}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)){let 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(t=``){return super.getLogger(t,e)}},de={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6},fe=class extends ce{constructor(e,t=``){super(t),this.name=t,this.logger=e,e.trace&&(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=U[e].toLowerCase())}static getLogger(e=``){return Object.prototype.hasOwnProperty.call(ce.loggers,e)?ce.loggers[e]:null}},pe=class e extends ce{constructor(...e){super(...e),this.trace=this.noop,this.debug=this.noop,this.info=this.noop,this.warn=this.noop,this.error=this.noop}static getLogger(t=``){return super.getLogger(t,e)}},me=()=>$(e=>class extends e{async requestAuthenticationToken(e=30,t=0,n=0,r=this.defaultTimeoutInMs){let i={message:new L(e,t,n,r).getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,i);let a=new Promise((e,t)=>{this.hooks.hookOnce(`frontgateConnection:response:${i.callbackId}`,n=>{if(n.Message!==`Foundation::AuthenticationTokenResponse`){t(JSON.stringify(n));return}let r=new ne(n);e({token:r.getToken(),expiry:r.getExpiry()})})});return j(r,`Request timeout reached (${r} ms) for ${i.message.Message}`,a)}async requestAuthenticationTokenForCookieTokenAuthentication(e=30,t=0,n=0,r=this.defaultTimeoutInMs){return new p((await this.requestAuthenticationToken(e,t,n,r)).token)}},{featureName:`AuthTokenRequest`,featureGroups:[`Misc`]}),he=e=>$(t=>class extends t{async requestEndpoint(t,n,r,i,a=this.defaultTimeoutInMs){let o=new z(t,n,r,{...i,allowChunkedResponse:!e?.disableChunkedResponse});o.header.setTimeout(a),e?.allowPermissionDeniedResponse&&o.header.setFlag(`permission_denied_response`);let s={message:o.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,s);let c=new Promise((e,t)=>{let n=[],r=()=>{this.hooks.hookOnce(`frontgateConnection:response:${s.callbackId}`,i=>{try{if(i.Message!==`Foundation::HighLevelResponse`&&i.Message!==`HighLevelResponse`){t(JSON.stringify(i));return}if(this.#e(i))n.push({body:i.body.value,processingTime:i.header.processing_time}),r();else{n.push({body:i.body.value,processingTime:i.header.processing_time});let t=new re({...i,body:{value:n.map(e=>e.body).join(``)},header:{...i.header,processing_time:n.reduce((e,t)=>e+t.processingTime,0)}});e({response:t,data:t.data})}}catch(e){t(e)}})};r()});return j(a,`Request timeout reached (${a} ms) for ${s.message.Message}`,c)}#e(e){return(e.header.flags&8)==8}},{featureName:`EndpointRequest`,featureGroups:[`Misc`]}),ge=null;typeof WebSocket<`u`?ge=WebSocket:typeof MozWebSocket<`u`?ge=MozWebSocket:typeof global<`u`?ge=global.WebSocket||global.MozWebSocket:typeof window<`u`?ge=window.WebSocket||window.MozWebSocket:typeof self<`u`&&(ge=self.WebSocket||self.MozWebSocket);var _e=ge,ve=e=>$(t=>class extends t{#e;#t;#n=`disconnected`;#r;#i=0;#a;#o;get#s(){return this.#e&&this.#e.readyState<2?this.#n:`disconnected`}#c=0;#l=[];set conf(e){let t=this.#_(e);this.#c=t.messageBufferSize,this.#t=t}constructor(...t){super(...t),this.#a=-2,this.#o=-1,e&&(this.conf=e),this.hooks.hook(`frontgateConnection:setIdApp`,e=>{this.#a=e}),this.hooks.hook(`frontgateConnection:setIdUser`,e=>{this.#o=e}),this.hooks.hook(`frontgateConnection:sendMessage`,e=>{if(e.callbackType===`job`&&(e.callbackId=`${this.#m(e.message)}`),this.#s===`connected`&&e.callbackType===`response`)this.#f(e.message);else if(this.#s===`authenticated`)this.#h(e.message),this.#f(e.message);else{if(this.#l.length>=this.#c)throw Error(`Message buffer is full`);this.#l.push(e)}}),this.hooks.hook(`reconnect:attempt`,async()=>{clearInterval(this.#r),this.log(U.DEBUG,`Reconnecting`);try{await this.connect(),await this.hooks.callHook(`reconnect:success`)}catch(e){this.log(U.ERROR,`Reconnect failed`,e),await this.hooks.callHook(`reconnect:failed`,e)}})}async connect(){if(await this.hooks.callHook(`frontgateConnection:reset`),!this.#t)throw Error(`No connection configuration set`);if(this.#s!==`disconnected`)throw Error(`Client is already connected or is connecting right now`);let{host:e,port:t,tls:n,pathPrefix:r}=this.#t;this.#n=`connecting`;let i=`${n?`wss`:`ws`}://${e}:${t}${r??``}/ws`,a={encoding:`jsjson-v2`};await this.hooks.callHook(`frontgateConnection:afterSetEncoding`,a);let[o,s]=a.encoding.split(`-`),c={url:i,subProtocols:[`${s?`${s}.`:``}ws-${o}.mdgms.com`]};try{await this.hooks.callHook(`frontgateConnection:beforeConnect`,c)}catch(e){throw this.#n=`disconnected`,e}this.log(U.DEBUG,`Connecting to ${c.url} with subprotocols ${c.subProtocols}`);let l=new Promise((e,t)=>{if(!this.#t)throw Error(`No connection configuration set`);this.#t.wsClientOptions&&typeof window>`u`?this.#e=new _e(c.url,c.subProtocols,this.#t.wsClientOptions):this.#e=new _e(c.url,c.subProtocols),this.#e.binaryType=`arraybuffer`;let n;this.#e.onopen=()=>{let r=()=>{for(this.log(U.DEBUG,`Draining message buffer`);this.#l.length>0;){let e=this.#l.shift();e&&(this.#h(e.message),this.#f(e.message))}},i=()=>{if(!this.#t)throw Error(`No connection configuration set`);this.#r=setInterval(()=>{this.log(U.DEBUG,`Sending keepalive`),this.hooks.callHook(`frontgateConnection:sendMessage`,{message:this.#d(),callbackType:`response`,callbackId:`KeepAliveMessage`})},this.#t.maximumIdleIntervalInS/2*1e3)};this.#n=`connected`,this.log(U.DEBUG,`Connected`),this.hooks.callHook(`frontgateConnection:connected`,this.#t).catch(t),n=this.hooks.hookOnce(`frontgateConnection:authenticated`,()=>{this.#n=`authenticated`,this.log(U.DEBUG,`Authenticated`),r(),i(),e()})},this.#e.onclose=e=>{n?.(),this.log(U.DEBUG,`Disconnected`,e),this.#n===`connecting`||this.#n===`connected`?t(e):this.hooks.callHook(`frontgateConnection:disconnected`,e),clearInterval(this.#r),this.#n=`disconnected`},this.#e.onerror=e=>{n?.(),this.log(U.ERROR,`Error:`,e),this.hooks.callHook(`frontgateConnection:error`,e),(this.#n===`connecting`||this.#n===`connected`)&&t(Error(`Websocket error`)),clearInterval(this.#r),this.#n=`disconnected`},this.#e.onmessage=e=>{let{data:t}=e;this.log(U.DEBUG,`Received data:`,t);let n={msg:t};this.hooks.callHook(`frontgateConnection:afterReceiveMessage`,n).then(()=>{this.log(U.DEBUG,`Received message`,n.msg);let e=n.msg.toString(`utf-8`),t=JSON.parse(e);if(this.hooks.callHook(`frontgateConnection:message`,t),t.Message===`Foundation::DisconnectionMessage`){this.#e?.close(),this.hooks.callHook(`frontgateConnection:disconnected`,t);return}this.#p(t)})}}),u=`Timeout reached (${this.defaultTimeoutInMs} ms) for connection to ${i}`;return j(this.defaultTimeoutInMs,u,l)}async disconnect(){return new Promise(e=>{this.#f(this.#u()),this.hooks.hookOnce(`frontgateConnection:disconnected`,()=>{this.#e?.close(),e()})})}#u(){return{Message:`Foundation::DisconnectionMessage`,Version:3,reason:{value:64},details:`client shutdown`}}#d(){return{Message:`KeepAliveMessage`,Version:2}}async#f(e){await this.hooks.callHook(`frontgateConnection:beforeSerializeMessage`,e);let t={msg:JSON.stringify(e)};await this.hooks.callHook(`frontgateConnection:beforeSendMessage`,t),this.log(U.DEBUG,`Sending message:`,e),this.log(U.TRACE,`Sending data:`,t.msg);try{this.#e?.send(t.msg)}catch(t){let n=this.#g(t,e);this.#p(n)}}#p(e){if(w(e)){this.hooks.callHook(`frontgateConnection:response:${e.header.id_job}`,e);return}if(T(e)){this.hooks.callHook(`frontgateConnection:response:${e.header.id_service}-${e.id_notation}`,e);return}if(C(e)){this.hooks.callHook(`frontgateConnection:response:${e.id_job}`,e);return}typeof e.Message==`string`&&this.hooks.callHook(`frontgateConnection:response:${e.Message.replace(`Foundation::`,``)}`,e)}#m(e){this.#i+=1;let t=this.#i;return e.header={...e.header,id_job:t},this.#i}#h(e){e.header||={authentication_identifiers:{id_application:void 0,id_user:void 0}},e.header.authentication_identifiers||(e.header={...e.header,authentication_identifiers:{id_application:void 0,id_user:void 0}}),e.header.authentication_identifiers.id_application||=this.#a,e.header.authentication_identifiers.id_user||=this.#o}#g(e,t){return{Message:`Foundation::ErrorResponse`,Version:1,header:{},id_job:t.header?.id_job??-1,processing_time:0,reason:{value:8},details:e}}#_(e){let t=e.maximumIdleIntervalInS??60,n=e.maximumIdleInterval??t*1e6;return{...e,payloadContent:e.payloadContent??`foundation`,maximumIdleIntervalInS:t,maximumIdleInterval:n,tls:e.tls??!0,messageBufferSize:e.messageBufferSize??512}}isConnected(){return this.#s===`authenticated`}isDisconnected(){return this.#n!==`authenticated`}isReadyToConnect(){return this.#s===`disconnected`}},{featureName:`WSConnection`,disabledFeatureGroups:[`Connection`]}),ye=(e,t)=>(t&&e.setLevel(t),$(t=>class extends t{constructor(...t){super(...t),this.logger=e}},{featureName:`Logger`,featureGroups:[`Misc`]})),W=Uint8Array,G=Uint16Array,be=Int32Array,xe=new W([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]),Se=new W([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]),Ce=new W([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),we=function(e,t){for(var n=new G(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new be(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},Te=we(xe,2),Ee=Te.b,De=Te.r;Ee[28]=258,De[258]=28;for(var Oe=we(Se,0),ke=Oe.b,Ae=Oe.r,je=new G(32768),K=0;K<32768;++K){var Me=(K&43690)>>1|(K&21845)<<1;Me=(Me&52428)>>2|(Me&13107)<<2,Me=(Me&61680)>>4|(Me&3855)<<4,je[K]=((Me&65280)>>8|(Me&255)<<8)>>1}for(var q=(function(e,t,n){for(var r=e.length,i=0,a=new G(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new G(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new G(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[je[d]>>c]=l}else for(s=new G(r),i=0;i<r;++i)e[i]&&(s[i]=je[o[e[i]-1]++]>>15-e[i]);return s}),Ne=new W(288),K=0;K<144;++K)Ne[K]=8;for(var K=144;K<256;++K)Ne[K]=9;for(var K=256;K<280;++K)Ne[K]=7;for(var K=280;K<288;++K)Ne[K]=8;for(var Pe=new W(32),K=0;K<32;++K)Pe[K]=5;var Fe=q(Ne,9,0),Ie=q(Ne,9,1),Le=q(Pe,5,0),Re=q(Pe,5,1),ze=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},J=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Be=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ve=function(e){return(e+7)/8|0},He=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new W(e.subarray(t,n))},Ue=[`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`],Y=function(e,t,n){var r=Error(t||Ue[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Y),!n)throw r;return r},We=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new W(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new W(i*3));var l=function(e){var t=n.length;if(e>t){var r=new W(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=J(e,d,1);var v=J(e,d+1,3);if(d+=3,!v){var y=Ve(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&Y(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}else if(v==1)p=Ie,m=Re,h=9,g=5;else if(v==2){var S=J(e,d,31)+257,C=J(e,d+10,15)+4,w=S+J(e,d+5,31)+1;d+=14;for(var T=new W(w),E=new W(19),D=0;D<C;++D)E[Ce[D]]=J(e,d+D*3,7);d+=C*3;for(var O=ze(E),ee=(1<<O)-1,k=q(E,O,1),D=0;D<w;){var A=k[J(e,d,ee)];d+=A&15;var y=A>>4;if(y<16)T[D++]=y;else{var j=0,M=0;for(y==16?(M=3+J(e,d,3),d+=2,j=T[D-1]):y==17?(M=3+J(e,d,7),d+=3):y==18&&(M=11+J(e,d,127),d+=7);M--;)T[D++]=j}}var N=T.subarray(0,S),P=T.subarray(S);h=ze(N),g=ze(P),p=q(N,h,1),m=q(P,g,1)}else Y(1);if(d>_){c&&Y(0);break}}s&&l(f+131072);for(var F=(1<<h)-1,I=(1<<g)-1,L=d;;L=d){var j=p[Be(e,d)&F],R=j>>4;if(d+=j&15,d>_){c&&Y(0);break}if(j||Y(2),R<256)n[f++]=R;else if(R==256){L=d,p=null;break}else{var z=R-254;if(R>264){var D=R-257,B=xe[D];z=J(e,d,(1<<B)-1)+Ee[D],d+=B}var V=m[Be(e,d)&I],te=V>>4;V||Y(3),d+=V&15;var P=ke[te];if(te>3){var B=Se[te];P+=Be(e,d)&(1<<B)-1,d+=B}if(d>_){c&&Y(0);break}s&&l(f+131072);var ne=f+z;if(f<P){var H=a-P,re=Math.min(P,ne);for(H+f<0&&Y(3);f<re;++f)n[f]=r[H+f]}for(;f<ne;++f)n[f]=n[f-P]}}t.l=p,t.p=L,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?He(n,0,f):n.subarray(0,f)},X=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Ge=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},Ke=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:$e,l:0};if(i==1){var o=new W(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new G(f+1),m=qe(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new W(p),l:m}},qe=function(e,t,n){return e.s==-1?Math.max(qe(e.l,t,n+1),qe(e.r,t,n+1)):t[e.s]=n},Je=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new G(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},Ye=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Xe=function(e,t,n){var r=n.length,i=Ve(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},Ze=function(e,t,n,r,i,a,o,s,c,l,u){X(t,u++,n),++i[256];for(var d=Ke(i,15),f=d.t,p=d.l,m=Ke(a,15),h=m.t,g=m.l,_=Je(f),v=_.c,y=_.n,b=Je(h),x=b.c,S=b.n,C=new G(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=Ke(C,7),E=T.t,D=T.l,O=19;O>4&&!E[Ce[O-1]];--O);var ee=l+5<<3,k=Ye(i,Ne)+Ye(a,Pe)+o,A=Ye(i,f)+Ye(a,h)+o+14+3*O+Ye(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&ee<=k&&ee<=A)return Xe(t,u,e.subarray(c,c+l));var j,M,N,P;if(X(t,u,1+(A<k)),u+=2,A<k){j=q(f,p,0),M=f,N=q(h,g,0),P=h;var F=q(E,D,0);X(t,u,y-257),X(t,u+5,S-1),X(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)X(t,u+3*w,E[Ce[w]]);u+=3*O;for(var I=[v,x],L=0;L<2;++L)for(var R=I[L],w=0;w<R.length;++w){var z=R[w]&31;X(t,u,F[z]),u+=E[z],z>15&&(X(t,u,R[w]>>5&127),u+=R[w]>>12)}}else j=Fe,M=Ne,N=Le,P=Pe;for(var w=0;w<s;++w){var B=r[w];if(B>255){var z=B>>18&31;Ge(t,u,j[z+257]),u+=M[z+257],z>7&&(X(t,u,B>>23&31),u+=xe[z]);var V=B&31;Ge(t,u,N[V]),u+=P[V],V>3&&(Ge(t,u,B>>5&8191),u+=Se[V])}else Ge(t,u,j[B]),u+=M[B]}return Ge(t,u,j[256]),u+M[256]},Qe=new be([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$e=new W(0),et=function(e,t,n,r,i,a){var o=a.z||e.length,s=new W(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=Qe[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new G(32768),g=a.h||new G(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new be(25e3),x=new G(288),S=new G(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var ee=y(T),k=T&32767,A=g[ee];if(h[k]=A,g[ee]=k,D<=T){var j=o-T;if((C>7e3||E>24576)&&(j>423||!l)){u=Ze(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var M=0;M<286;++M)x[M]=0;for(var M=0;M<30;++M)S[M]=0}var N=2,P=0,F=p,I=k-A&32767;if(j>2&&ee==y(T-I))for(var L=Math.min(f,j)-1,R=Math.min(32767,T),z=Math.min(258,j);I<=R&&--F&&k!=A;){if(e[T+N]==e[T+N-I]){for(var B=0;B<z&&e[T+B]==e[T+B-I];++B);if(B>N){if(N=B,P=I,B>L)break;for(var V=Math.min(I,B-2),te=0,M=0;M<V;++M){var ne=T-I+M&32767,H=ne-h[ne]&32767;H>te&&(te=H,A=ne)}}}k=A,A=h[k],I+=k-A&32767}if(P){b[E++]=268435456|De[N]<<18|Ae[P];var re=De[N]&31,ie=Ae[P]&31;w+=xe[re]+Se[ie],++x[257+re],++S[ie],D=T+N,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=Ze(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var ae=T+65535;ae>=o&&(c[u/8|0]=l,ae=o),u=Xe(c,u+1,e.subarray(T,ae))}a.i=o}return He(s,0,r+Ve(u)+i)},tt=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},nt=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new W(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return et(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},rt=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},it=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=tt();i.p(t.dictionary),rt(e,2,i.d())}},at=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Y(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&Y(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2},ot=function(){function e(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 W(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 e.prototype.p=function(e,t){this.ondata(nt(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||Y(5),this.s.l&&Y(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var r=new W(n&-32768);r.set(this.b.subarray(0,this.s.z)),this.b=r}var i=this.b.length-this.s.z;this.b.set(e.subarray(0,i),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(i),32768),this.s.z=e.length-i+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),t&&(this.s=this.o={},this.b=$e)},e.prototype.flush=function(e){if(this.ondata||Y(5),this.s.l&&Y(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2,e){var t=new W(6);t[0]=this.s.r>>3;var n=Xe(t,this.s.r,$e);this.s.r=0,this.ondata(t.subarray(0,n>>3),!1)}},e}(),st=function(){function e(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 W(32768),this.p=new W(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||Y(5),this.d&&Y(4),!this.p.length)this.p=e;else if(e.length){var t=new W(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=We(this.p,this.s,this.o);this.ondata(He(n,t,this.s.b),this.d),this.o=He(n,this.s.b-32768),this.s.b=this.o.length,this.p=He(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),ct=function(){function e(e,t){this.c=tt(),this.v=1,ot.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),ot.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=nt(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&=(it(n,this.o),0),t&&rt(n,n.length-4,this.c.d()),this.ondata(n,t)},e.prototype.flush=function(e){ot.prototype.flush.call(this,e)},e}(),lt=function(){function e(e,t){st.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(st.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(at(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&Y(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),st.prototype.c.call(this,t)},e}(),ut=typeof TextEncoder<`u`&&new TextEncoder,dt=typeof TextDecoder<`u`&&new TextDecoder;try{dt.decode($e,{stream:!0})}catch{}var ft=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:He(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function pt(e,t){if(t){for(var n=new W(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(ut)return ut.encode(e);for(var i=e.length,a=new W(e.length+(e.length>>1)),o=0,s=function(e){a[o++]=e},r=0;r<i;++r){if(o+5>a.length){var c=new W(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return He(a,0,o)}function mt(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else if(dt)return dt.decode(e);else{var i=ft(e),a=i.s,n=i.r;return n.length&&Y(8),a}}var ht=e=>{if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));for(let n=0,r=0;n<e.length;++n)t.set(e[n],r),r+=e[n].length;return t},gt=class{constructor(){this.compressor=null,this.decompressor=null,this.reset()}reset(){this.compressor=null,this.decompressor=null}compress(e){this.compressor||=new ct({mem:4});let t=[];return this.compressor.ondata=e=>{t.push(e)},this.compressor.push(pt(e)),this.compressor.flush(),ht(t)}decompress(e){this.decompressor||=new lt;let t;this.decompressor.ondata=e=>{t=e};try{if(this.decompressor.push(e),t===void 0)throw Error(`invalid block type`)}catch(t){throw Error(`Decompression error: ${t.message}, length: ${e.length}, data: [${e.toString()}]`)}return mt(t)}},_t=()=>$(e=>class extends e{#e;constructor(...e){super(...e),this.#e=new gt,this.hooks.hook(`frontgateConnection:reset`,()=>{this.#e.reset()}),this.hooks.hook(`frontgateConnection:afterSetEncoding`,e=>{e.encoding=`jsjsonc-v2`}),this.hooks.hook(`frontgateConnection:beforeSendMessage`,e=>{e.msg=this.#e.compress(e.msg)}),this.hooks.hook(`frontgateConnection:afterReceiveMessage`,e=>{e.msg=this.#e.decompress(new Uint8Array(e.msg))})}},{featureName:`MessageCompressor`,featureGroups:[`Compression`]}),Z=class extends Error{constructor(e){super(`Unexpected response: ${e.Message}`),this.response=e}},vt=()=>$(e=>class extends e{async request(e,t=this.defaultTimeoutInMs){e.header.setTimeout(t);let n={message:e.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,n);let r=new Promise((e,t)=>{this.hooks.hookOnce(`frontgateConnection:response:${n.callbackId}`,n=>{if(n.Message!==`Foundation::HighLevelResponse`&&n.Message!==`HighLevelResponse`){t(new Z(n));return}e(new H(n))})});return j(t,`Request timeout reached (${t} ms) for ${n.message.Message}`,r)}},{featureName:`Request`,featureGroups:[`Misc`]}),yt=e=>$(t=>{let n={...e};return class extends t{#e=new Map;#t=new Map;#n=new Map;async observeEndpoint(e,t,r,i){let a=`${e}:${t}:${JSON.stringify(r)}:${JSON.stringify(i??{})}`;if(this.#n.has(a)){let e=this.#n.get(a);this.log(U.INFO,`Catching inflight subscription for ${a}`);let t=this.#t.get(a)??0;return this.#t.set(a,t+1),e}let o=n.timeout??this.defaultTimeoutInMs,s=n.subscriptionResubscribeTimeout??1e3;if(this.#e.has(a)){let e=this.#e.get(a),t=this.#t.get(a)??0;if(e)return this.#t.set(a,t+1),this.log(U.INFO,`Reusing existing subscription for ${a}`),e}this.log(U.INFO,`Creating new subscription for ${a}`);let c=new z(e,t,r,{...i,subscribe:!0});c.header.setTimeout(o);let l={message:c.getPtlMessage(),callbackType:`job`,callbackId:``},u=!1,d=new Promise((e,t)=>{this.hooks.callHook(`frontgateConnection:sendMessage`,l).then(()=>{this.hooks.hookOnce(`frontgateConnection:response:${l.callbackId}`,n=>{if(n.Message!==`Foundation::HighLevelResponse`&&n.Message!==`HighLevelResponse`){this.log(U.ERROR,`Unexpected response: ${n.Message}`),t(new Z(n));return}let r;try{r=JSON.parse(n.body.value)}catch(e){this.log(U.ERROR,`Failed to parse response: ${n.body.value}`),this.log(U.ERROR,e),t(e);return}let i=new Ot(n.header.id_job,r);if(u){this.log(U.WARN,`Zombie subscription detected for ${a}. Cancelling stale subscription on server.`);let e=new R(i.idJob);this.hooks.callHook(`frontgateConnection:sendMessage`,{message:e.getPtlMessage(),callbackType:`job`,callbackId:``});return}let c=this.hooks.hook(`frontgateConnection:response:${l.callbackId}`,e=>{if(e.Message!==`Foundation::HighLevelUpdate`&&e.Message!==`HighLevelUpdate`){if(e.Message.includes(`SubscriptionLoss`)){this.log(U.DEBUG,`Received: ${e.Message}`),setTimeout(()=>{d()},M(s)),c();return}this.log(U.ERROR,`Unexpected response: ${n.Message}`),i.pushError(new Z(e)),c();return}let t;try{t=new oe(e)}catch(t){this.log(U.ERROR,`Failed to parse response: ${e.body.value}`),i.pushError(Error(`Failed to parse response`,{cause:t}));return}i.pushPatchData(t.data)}),d=async()=>{c(),this.log(U.INFO,`Resubscribing to ${a} due to reconnect`),await this.hooks.callHook(`frontgateConnection:sendMessage`,l);let e,t=new Promise((t,n)=>{e=this.hooks.hookOnce(`frontgateConnection:response:${l.callbackId}`,e=>{if(e.Message!==`Foundation::HighLevelResponse`&&e.Message!==`HighLevelResponse`){let t=new Z(e);this.log(U.ERROR,`Unexpected response: ${e.Message}`),c(),n(t);return}if(this.log(U.INFO,`Resubscribed to ${a} with ${e.header.id_job}`),i.idJob=e.header.id_job,u){this.log(U.WARN,`Zombie subscription detected for ${a}. Initiating unsubscribe.`),i.unsubscribe?.(),t();return}try{i.pushData(JSON.parse(e.body.value))}catch(t){this.log(U.ERROR,`Failed to parse response: ${e.body.value}`),this.log(U.ERROR,t),n(t);return}c=this.hooks.hook(`frontgateConnection:response:${e.header.id_job}`,e=>{if(e.Message!==`Foundation::HighLevelUpdate`&&e.Message!==`HighLevelUpdate`){if(e.Message.includes(`SubscriptionLoss`)){this.log(U.DEBUG,`Received: ${e.Message}`),setTimeout(()=>{d()},M(s));return}this.log(U.ERROR,`Unexpected response: ${e.Message}`);let t=new Z(e);i.pushError(t);return}let t;try{t=new oe(e)}catch(t){this.log(U.ERROR,`Failed to parse response: ${e.body.value}`),i.pushError(Error(`Failed to parse response`,{cause:t}));return}i.pushPatchData(t.data)}),t()})});try{await j(o,`Request timeout reached`,t)}catch(t){e?.(),u=!0,i.pushError(Error(`Resubscribe failed`,{cause:t}))}},f=this.hooks.hook(`reconnect:success`,d);i.unsubscribe=()=>{if(this.#e.get(a)){let e=this.#t.get(a)??0;if(this.#t.set(a,e-1),e-1>0){this.log(U.INFO,`Not unsubscribing from ${a} as there are still ${e} subscribers`);return}this.#e.delete(a),this.#t.delete(a),u=!0}this.log(U.INFO,`Unsubscribing from ${a}`);let e={message:new R(i.idJob).getPtlMessage(),callbackType:`job`,callbackId:``};this.hooks.callHook(`frontgateConnection:sendMessage`,e),c(),f()},this.#e.set(a,i);let p=this.#t.get(a)??0;this.#t.set(a,p+1),e(i)})}).catch(e=>{t(e)})}),f=j(o,`Request timeout reached (${o} ms) for ${l.message.Message}`,d).catch(e=>{throw u=!0,this.#t.delete(a),this.#e.delete(a),e}).finally(()=>{this.#n.delete(a)});return this.#n.set(a,f),f}}},{featureName:`EndpointSubscriptions`,featureGroups:[`Misc`]}),bt=()=>$(e=>class extends e{#e=new Map;async observe(e,t=this.defaultTimeoutInMs){return this.#t(e,`job`,void 0,t)}async observeConnectionBased(e,t,n=this.defaultTimeoutInMs){return this.#t(e,`connection`,t,n)}async#t(e,t,n,r=this.defaultTimeoutInMs){let i=JSON.stringify(e.getPtlMessage());if(this.#e.has(i)){let e=this.#e.get(i);if(e)return e.count++,this.log(U.INFO,`Reusing existing subscription for ${i}`),e.observer}this.log(U.INFO,`Creating new subscription for ${i}`);let a={message:e.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,a);let o=new Promise((e,o)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,s=>{if(s.Message.includes(`Error`)||s.Message.includes(`PermissionDenied`)||!w(s)){this.log(U.ERROR,`Unexpected response: ${s.Message}`),o(new Z(s));return}let c=s.header.id_job.toString(),l=-1,u=-1;t===`connection`&&T(s)&&(l=s.header.id_service,u=s.id_notation,c=`${l}-${u}`);let d=n===void 0?new R(s.header.id_job):new n(l,u),f=new Dt(s.header.id_job,s),p=this.hooks.hook(`frontgateConnection:response:${c}`,e=>{if(e.Message===`Foundation::ErrorResponse`){this.log(U.ERROR,`Unexpected response: ${s.Message}`),f.pushError(new Z(e));return}f.pushData(e)}),m=this.hooks.hook(`reconnect:success`,async()=>{p(),this.log(U.INFO,`Resubscribing to ${i} due to reconnect`),await this.hooks.callHook(`frontgateConnection:sendMessage`,a);let e=new Promise((e,r)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,a=>{if(a.Message===`Foundation::ErrorResponse`||!w(a)){let e=new Z(a);this.log(U.ERROR,`Unexpected resp: ${a.Message}`),r(e);return}let o=s.header.id_job.toString();t===`connection`&&T(a)&&(l=a.header.id_service,u=a.id_notation,o=`${l}-${u}`);let c=n===void 0?new R(a.header.id_job):new n(l,u);f.idJob=a.header.id_job,p=this.hooks.hook(`frontgateConnection:response:${o}`,e=>{if(e.Message===`Foundation::ErrorResponse`){this.log(U.ERROR,`Unexpected response: ${e.Message}`),f.pushError(new Z(e));return}f.unsubscribe=()=>{let e=this.#e.get(i);if(e){if(e.count--,e.count>0){this.log(U.INFO,`Not unsubscribing from ${i} as there are still ${e.count} subscribers`);return}this.#e.delete(i)}this.log(U.INFO,`Unsubscribing from ${i}`);let t={message:c.getPtlMessage(),callbackType:`job`,callbackId:``};this.hooks.callHook(`frontgateConnection:sendMessage`,t),p(),m()},f.pushData(e)}),e()})});try{await j(r,`Request timeout reached`,e)}catch(e){f.pushError(Error(`Reconnect Failed`,{cause:e}))}});f.unsubscribe=()=>{let e=this.#e.get(i);if(e){if(e.count--,e.count>0){this.log(U.INFO,`Not unsubscribing from ${i} as there are still ${e.count} subscribers`);return}this.#e.delete(i)}this.log(U.INFO,`Unsubscribing from ${i}`);let t={message:d.getPtlMessage(),callbackType:`job`,callbackId:``};this.hooks.callHook(`frontgateConnection:sendMessage`,t),p(),m()},this.#e.set(i,{observer:f,count:1}),e(f)})});return j(r,`Request timeout reached (${r} ms) for ${a.message.Message}`,o)}},{featureName:`RawSubscriptions`,featureGroups:[`Misc`]}),xt=(e,t)=>{let n=t.split(`/`).slice(1),r=e;for(let e=0;e<n.length-1;e++){let i=decodeURIComponent(n[e]);if(!(i in r))throw Error(`Path not found: ${t}`);r=r[i]}return[r,decodeURIComponent(n[n.length-1])]},St=(e,t,n)=>{let[r,i]=xt(e,t);r[i]=n},Ct=`-`,wt=(e,t,n)=>{let[r,i]=xt(e,t);Array.isArray(r)?i===Ct?r.push(n):r.splice(parseInt(i,10),0,n):r[i]=n},Tt=(e,t)=>{let[n,r]=xt(e,t);Array.isArray(n)?n.splice(parseInt(r,10),1):delete n[r]};function Et(e,t){return t.forEach(t=>{switch(t.op){case`replace`:St(e,t.path,t.value);break;case`add`:wt(e,t.path,t.value);break;case`remove`:Tt(e,t.path);break;default:throw Error(`Unsupported op: ${t.op}`)}}),e}var Dt=class{#e;#t=[];#n=[];get data(){return this.#e}constructor(e,t){this.#e=t,this.idJob=e}subscribe({next:e,error:t}){e(this.#e),t&&this.#n.push(t),this.#t.push(e)}pushData(e){this.#e=e,this.#t.forEach(t=>{t(e)})}pushError(e){this.#n.forEach(t=>{t(e)})}},Ot=class extends Dt{pushPatchData(e){try{let t=Et(this.data,e);super.pushData(t)}catch(e){super.pushError(Error(`Failed to apply patch`,{cause:e}))}}},kt=e=>$(t=>class extends t{constructor(...t){super(...t),this.hooks.hook(`frontgateConnection:beforeConnect`,t=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2),this.log(U.DEBUG,`Adding mdg2auth subprotocol`),t.subProtocols.push(`mdg2auth-${e}`)}),this.hooks.hookOnce(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t=new I({b64:``},{maximum_idle_interval:e.maximumIdleInterval}.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,t);let n={message:t,callbackType:`response`,callbackId:t.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,n),this.hooks.hookOnce(`frontgateConnection:response:${n.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}},{featureName:`CookieTokenAuth`,featureGroups:[`Auth`],disabledFeatureGroups:[`Auth`]}),At=e=>$(t=>class extends t{#e;constructor(...t){super(...t),this.#e=e??``,this.hooks.hook(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t={maximum_idle_interval:e.maximumIdleInterval},n=new I({b64:this.#e},t.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,n);let r={message:n,callbackType:`response`,callbackId:n.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,r),this.hooks.hookOnce(`frontgateConnection:response:${r.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}set token(e){this.#e=e}},{featureName:`TokenAuth`,featureGroups:[`Auth`],disabledFeatureGroups:[`Auth`]}),jt=(e,t,n)=>$(r=>class extends ve({host:``,pathPrefix:``,port:0,tls:!0,maximumIdleIntervalInS:e.maximumIdleIntervalInS})(r){#e=``;#t=``;#n;#r;constructor(...e){super(...e),this.#n=t,this.#r=n,this.hooks.hook(`frontgateConnection:beforeConnect`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2),this.log(U.DEBUG,`Fetching connection configuration`);let t=await this.#i();if(this.log(U.DEBUG,`Connection configuration received`,t),e.url=t.url,t.authtenticationType===`token`&&t.authenticationToken)this.#e=t.authenticationToken;else if(t.splitAuthenticationTokenSecondFactor)this.#t=t.splitAuthenticationTokenSecondFactor;else throw Error(`Invalid authentication configuration`);this.log(U.DEBUG,`Adding mdg2auth subprotocol`),this.#t!==``&&e.subProtocols.push(`mdg2auth-${this.#t}`)}),this.hooks.hook(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t={maximum_idle_interval:e.maximumIdleInterval},n=new I({b64:this.#e},t.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,n);let r={message:n,callbackType:`response`,callbackId:n.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,r),this.hooks.hookOnce(`frontgateConnection:response:${r.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}async#i(){let e=await fetch(this.#n,this.#r);if(!e.ok)throw Error(`Failed to fetch connection configuration: ${e.status} ${e.statusText}`);let{headers:t}=e,n=t.get(`frontgate-host`),r=t.get(`frontgate-path-prefix`),i=t.get(`frontgate-split-authentication-token-second-factor`),a=t.get(`frontgate-authentication-type`),o=t.get(`frontgate-authentication-token`),s=`wss://${n}:${t.get(`frontgate-websocket-port`)??`443`}${r??``}/ws`;if(a===`token`&&!o)throw Error(`Authentication token is required for token authentication`);if(a!==`token`&&!i)throw Error(`Split authentication token second factor is required`);return{url:s,authtenticationType:a,authenticationToken:o,splitAuthenticationTokenSecondFactor:i}}},{featureName:`FetchAuth`,featureGroups:[`Auth`,`Connection`],disabledFeatureGroups:[`Auth`,`Connection`]}),Mt=(e,t,n)=>$(r=>class extends ve({host:``,pathPrefix:``,port:0,tls:!0,maximumIdleIntervalInS:e.maximumIdleIntervalInS})(r){#e=``;#t=``;#n=!1;#r;#i;#a;constructor(...e){super(...e),this.#i=t,this.#a=n,this.#r=new gt,this.hooks.hook(`frontgateConnection:reset`,()=>{this.#n&&this.#r.reset()}),this.hooks.hook(`frontgateConnection:beforeSendMessage`,e=>{this.#n&&(e.msg=this.#r.compress(e.msg))}),this.hooks.hook(`frontgateConnection:afterReceiveMessage`,e=>{this.#n&&(e.msg=this.#r.decompress(new Uint8Array(e.msg)))}),this.hooks.hook(`frontgateConnection:beforeConnect`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2),this.log(U.DEBUG,`Fetching connection configuration`);let t=await this.#o();if(this.log(U.DEBUG,`Connection configuration received`,t),e.url=t.url,t.authtenticationType===`token`&&t.authenticationToken)this.#e=t.authenticationToken;else if(t.splitAuthenticationTokenSecondFactor)this.#t=t.splitAuthenticationTokenSecondFactor;else throw Error(`Invalid authentication configuration`);this.log(U.DEBUG,`Adding mdg2auth subprotocol`),this.#t!==``&&e.subProtocols.push(`mdg2auth-${this.#t}`),this.#n&&e.subProtocols.forEach((t,n)=>{t.includes(`jsjson`)&&!t.includes(`jsjsonc`)&&(e.subProtocols[n]=t.replace(`jsjson`,`jsjsonc`))})}),this.hooks.hook(`frontgateConnection:connected`,async e=>{this.hooks.callHook(`frontgateConnection:setIdApp`,-2),this.hooks.callHook(`frontgateConnection:setIdUser`,-2);let t={maximum_idle_interval:e.maximumIdleInterval},n=new I({b64:this.#e},t.maximum_idle_interval).toJson();this.log(U.INFO,`Sending message`,n);let r={message:n,callbackType:`response`,callbackId:n.Message.replace(`Request`,`Response`)};await this.hooks.callHook(`frontgateConnection:sendMessage`,r),this.hooks.hookOnce(`frontgateConnection:response:${r.callbackId}`,e=>{this.log(U.INFO,`Received response`,e),this.hooks.callHook(`frontgateConnection:authenticated`)})})}async#o(){let e=await fetch(this.#i,this.#a);if(!e.ok)throw Error(`Failed to fetch connection configuration: ${e.status} ${e.statusText}`);let{headers:t}=e,n=t.get(`frontgate-host`),r=t.get(`frontgate-path-prefix`),i=t.get(`frontgate-split-authentication-token-second-factor`),a=t.get(`frontgate-authentication-type`),o=t.get(`frontgate-authentication-token`),s=`wss://${n}:${t.get(`frontgate-websocket-port`)??`443`}${r??``}/ws`;if(a===`token`&&!o)throw Error(`Authentication token is required for token authentication`);if(a!==`token`&&!i)throw Error(`Split authentication token second factor is required`);return t.get(`frontgate-websocket-protocol`)===`jsjsonc-v2`?this.#n=!0:this.#n=!1,{url:s,authtenticationType:a,authenticationToken:o,splitAuthenticationTokenSecondFactor:i}}},{featureName:`FetchAuthWithOptionalCompressor`,featureGroups:[`Auth`,`Connection`],disabledFeatureGroups:[`Auth`,`Connection`,`Compression`]}),Nt=e=>$(t=>class extends t{#e=0;#t;#n;constructor(...t){super(...t),this.#t=e??[1e3,2e3,4e3,8e3,16e3,32e3];let n=e=>{if(e.code!==1e3){this.#n&&(this.log(U.WARN,`Aborting previous reconnect attempt`),clearTimeout(this.#n),this.#e=0);let t=this.#e;this.#e>=this.#t.length&&(t=this.#t.length-1);let r=this.#t[t];this.#n=setTimeout(()=>{this.log(U.INFO,`Reconnecting... Attempt ${this.#e}`);let t=this.hooks.hookOnce(`reconnect:failed`,n);this.hooks.callHook(`reconnect:attempt`,e).then(t).catch(()=>{this.log(U.ERROR,`Failed to reconnect`)}),this.#n=void 0},r),this.#e++}};this.hooks.hookOnce(`frontgateConnection:disconnected`,n),this.hooks.hook(`reconnect:success`,()=>{clearTimeout(this.#n),this.#n=void 0,this.#e=0,this.log(U.INFO,`Reconnected`),this.hooks.hookOnce(`frontgateConnection:disconnected`,n)})}},{featureName:`Reconnect`,featureGroups:[`Misc`],disabledFeatures:[`TokenAuth`,`CookieTokenAuth`]}),Pt=`1.9.1`,Ft=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function It(e){let t=new Set([e]),n=new Set,r=e.match(Ft);if(!r)return()=>!1;let i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;let r=e.match(Ft);if(!r)return a(e);let s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return s.prerelease!=null||i.major!==s.major?a(e):i.major===0?i.minor===s.minor&&i.patch<=s.patch?o(e):a(e):i.minor<=s.minor?o(e):a(e)}}var Lt=It(Pt),Rt=Pt.split(`.`)[0],zt=Symbol.for(`opentelemetry.js.api.${Rt}`),Bt=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{};function Vt(e,t,n,r=!1){let i=Bt[zt]=Bt[zt]??{version:Pt};if(!r&&i[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(t.stack||t.message),!1}if(i.version!==`1.9.1`){let t=Error(`@opentelemetry/api: Registration of version v${i.version} for ${e} does not match previously registered API v${Pt}`);return n.error(t.stack||t.message),!1}return i[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${Pt}.`),!0}function Ht(e){let t=Bt[zt]?.version;if(!(!t||!Lt(t)))return Bt[zt]?.[e]}function Ut(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${Pt}.`);let n=Bt[zt];n&&delete n[e]}var Wt=class{constructor(e){this._namespace=e.namespace||`DiagComponentLogger`}debug(...e){return Gt(`debug`,this._namespace,e)}error(...e){return Gt(`error`,this._namespace,e)}info(...e){return Gt(`info`,this._namespace,e)}warn(...e){return Gt(`warn`,this._namespace,e)}verbose(...e){return Gt(`verbose`,this._namespace,e)}};function Gt(e,t,n){let r=Ht(`diag`);if(r)return r[e](t,...n)}var Q;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(Q||={});function Kt(e,t){e<Q.NONE?e=Q.NONE:e>Q.ALL&&(e=Q.ALL),t||={};function n(n,r){let i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,Q.ERROR),warn:n(`warn`,Q.WARN),info:n(`info`,Q.INFO),debug:n(`debug`,Q.DEBUG),verbose:n(`verbose`,Q.VERBOSE)}}var qt=`diag`,Jt=class e{static instance(){return this._instance||=new e,this._instance}constructor(){function e(e){return function(...t){let n=Ht(`diag`);if(n)return n[e](...t)}}let t=this;t.setLogger=(e,n={logLevel:Q.INFO})=>{if(e===t){let e=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error(e.stack??e.message),!1}typeof n==`number`&&(n={logLevel:n});let r=Ht(`diag`),i=Kt(n.logLevel??Q.INFO,e);if(r&&!n.suppressOverrideMessage){let e=Error().stack??`<failed to generate stacktrace>`;r.warn(`Current logger will be overwritten from ${e}`),i.warn(`Current logger will overwrite one already registered from ${e}`)}return Vt(`diag`,i,t,!0)},t.disable=()=>{Ut(qt,t)},t.createComponentLogger=e=>new Wt(e),t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}};function Yt(e){return Symbol.for(e)}var Xt=new class e{constructor(t){let n=this;n._currentContext=t?new Map(t):new Map,n.getValue=e=>n._currentContext.get(e),n.setValue=(t,r)=>{let i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=t=>{let r=new e(n._currentContext);return r._currentContext.delete(t),r}}},Zt=class{active(){return Xt}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}},Qt=`context`,$t=new Zt,en=class e{constructor(){}static getInstance(){return this._instance||=new e,this._instance}setGlobalContextManager(e){return Vt(Qt,e,Jt.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Ht(Qt)||$t}disable(){this._getContextManager().disable(),Ut(Qt,Jt.instance())}},tn;(function(e){e[e.NONE=0]=`NONE`,e[e.SAMPLED=1]=`SAMPLED`})(tn||={});var nn={traceId:`00000000000000000000000000000000`,spanId:`0000000000000000`,traceFlags:tn.NONE},rn=class{constructor(e=nn){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}},an=Yt(`OpenTelemetry Context Key SPAN`);function on(e){return e.getValue(an)||void 0}function sn(){return on(en.getInstance().active())}function cn(e,t){return e.setValue(an,t)}function ln(e){return e.deleteValue(an)}function un(e,t){return cn(e,new rn(t))}function dn(e){return on(e)?.spanContext()}var fn=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function pn(e,t){if(typeof e!=`string`||e.length!==t)return!1;let n=0;for(let t=0;t<e.length;t+=4)n+=(fn[e.charCodeAt(t)]|0)+(fn[e.charCodeAt(t+1)]|0)+(fn[e.charCodeAt(t+2)]|0)+(fn[e.charCodeAt(t+3)]|0);return n===t}function mn(e){return pn(e,32)&&e!==`00000000000000000000000000000000`}function hn(e){return pn(e,16)&&e!==`0000000000000000`}function gn(e){return mn(e.traceId)&&hn(e.spanId)}function _n(e){return new rn(e)}var vn=en.getInstance(),yn=class{startSpan(e,t,n=vn.active()){if(t?.root)return new rn;let r=n&&dn(n);return bn(r)&&gn(r)?new rn(r):new rn}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??vn.active(),c=this.startSpan(e,i,s),l=cn(s,c);return vn.with(l,o,void 0,c)}};function bn(e){return typeof e==`object`&&!!e&&`spanId`in e&&typeof e.spanId==`string`&&`traceId`in e&&typeof e.traceId==`string`&&`traceFlags`in e&&typeof e.traceFlags==`number`}var xn=new yn,Sn=class{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}startSpan(e,t,n){return this._getTracer().startSpan(e,t,n)}startActiveSpan(e,t,n,r){let i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):xn}},Cn=new class{getTracer(e,t,n){return new yn}},wn=class{getTracer(e,t,n){return this.getDelegateTracer(e,t,n)??new Sn(this,e,t,n)}getDelegate(){return this._delegate??Cn}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,n){return this._delegate?.getTracer(e,t,n)}},Tn=`trace`,En=class e{constructor(){this._proxyTracerProvider=new wn,this.wrapSpanContext=_n,this.isSpanContextValid=gn,this.deleteSpan=ln,this.getSpan=on,this.getActiveSpan=sn,this.getSpanContext=dn,this.setSpan=cn,this.setSpanContext=un}static getInstance(){return this._instance||=new e,this._instance}setGlobalTracerProvider(e){let t=Vt(Tn,this._proxyTracerProvider,Jt.instance());return t&&this._proxyTracerProvider.setDelegate(e),t}getTracerProvider(){return Ht(Tn)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){Ut(Tn,Jt.instance()),this._proxyTracerProvider=new wn}}.getInstance(),Dn=()=>$(e=>class extends e{constructor(...e){super(...e),this.hooks.hook(`frontgateConnection:beforeSerializeMessage`,e=>{E(e)&&En.getTracer(`frontgate-js-sdk`).startActiveSpan(`frontgateConnection:sendMessage`,t=>{let n=this.#e(t.spanContext());n&&(e.header={...e.header,...n}),t.end()})})}#e(e){if(!/^0+$/.test(e.traceId))return{tracing:{value:{value:On(e)}}}}},{featureName:`OpenTelemetry`,featureGroups:[`Misc`]}),On=e=>{let t=[18,20,9],n=e=>{for(let n=e.length;n>e.length-16;n-=2){let r=parseInt(e.substring(n-2,n),16);r>127&&(r-=256),t.push(r)}};return n(e.traceId),t.push(17),n(e.spanId),t.push(24),t.push(0),t},kn=()=>$(e=>class extends e{async requestProxyEndpoint(e,t,n,r,i=this.defaultTimeoutInMs){let a=new B(e,t,r);n&&a.setBody(n),a.header.setTimeout(i);let o={message:a.getPtlMessage(),callbackType:`job`,callbackId:``};await this.hooks.callHook(`frontgateConnection:sendMessage`,o);let s=new Promise((e,t)=>{this.hooks.hookOnce(`frontgateConnection:response:${o.callbackId}`,n=>{try{if(n.Message!==`Foundation::HTTPProxyResponse`){t(JSON.stringify(n));return}let r=new ie(n);e({response:r,data:r.data})}catch(e){t(e)}})});return j(i,`Request timeout reached (${i} ms) for ${o.message.Message}`,s)}},{featureName:`HTTPProxyRequest`,featureGroups:[`Misc`]}),An=()=>$(e=>class extends e{async ping(e=this.defaultTimeoutInMs){let t={message:new V().getPtlMessage(),callbackType:`response`,callbackId:`PingResponse`};await this.hooks.callHook(`frontgateConnection:sendMessage`,t);let n=new Promise((e,n)=>{this.hooks.hookOnce(`frontgateConnection:response:${t.callbackId}`,t=>{if(t.Message!==`Foundation::PingResponse`){n(JSON.stringify(t));return}e(new ae(t))})});return j(e,`Request timeout reached (${e} ms) for ${t.message.Message}`,n)}},{featureName:`Pingable`,featureGroups:[`Misc`]}),jn=e=>$(t=>class extends t{async logRemotely(t){let n={message:new te({Message:`LogMessage`,timestamp:{microseconds:Date.now()*1e3},uuid:{id_1:e??0,id_2:0},level:{value:4},area:61,Version:1,message:t}).getPtlMessage(),callbackType:`job`,callbackId:``};return this.hooks.callHook(`frontgateConnection:sendMessage`,n)}},{featureName:`RemoteLogger`,featureGroups:[`Misc`]}),$=(e,t)=>{let n=e;return n.featureName=t.featureName,n.featureGroups=t.featureGroups,n.disabledFeatures=t.disabledFeatures,n.disabledFeatureGroups=t.disabledFeatureGroups,n};function Mn(e,t={},n){for(let r in e){let i=e[r],a=n?`${n}:${r}`:r;typeof i==`object`&&i?Mn(i,t,a):typeof i==`function`&&(t[a]=i)}return t}var Nn={run:e=>e()},Pn=console.createTask===void 0?()=>Nn:console.createTask;function Fn(e,t){let n=Pn(t.shift());return e.reduce((e,r)=>e.then(()=>n.run(()=>r(...t))),Promise.resolve())}function In(e,t){let n=Pn(t.shift());return Promise.all(e.map(e=>n.run(()=>e(...t))))}function Ln(e,t){for(let n of[...e])n(t)}var Rn=class{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()=>{};let r=e,i;for(;this._deprecatedHooks[e];)i=this._deprecatedHooks[e],e=i.to;if(i&&!n.allowDeprecated){let e=i.message;e||=`${r} hook has been deprecated`+(i.to?`, please use ${i.to}`:``),this._deprecatedMessages||=new Set,this._deprecatedMessages.has(e)||(console.warn(e),this._deprecatedMessages.add(e))}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),void 0)}}hookOnce(e,t){let n,r=(...e)=>(typeof n==`function`&&n(),n=void 0,r=void 0,t(...e));return n=this.hook(e,r),n}removeHook(e,t){if(this._hooks[e]){let 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;let n=this._hooks[e]||[];delete this._hooks[e];for(let t of n)this.hook(e,t)}deprecateHooks(e){Object.assign(this._deprecatedHooks,e);for(let t in e)this.deprecateHook(t,e[t])}addHooks(e){let t=Mn(e),n=Object.keys(t).map(e=>this.hook(e,t[e]));return()=>{for(let e of n.splice(0,n.length))e()}}removeHooks(e){let t=Mn(e);for(let e in t)this.removeHook(e,t[e])}removeAllHooks(){for(let e in this._hooks)delete this._hooks[e]}callHook(e,...t){return t.unshift(e),this.callHookWith(Fn,e,...t)}callHookParallel(e,...t){return t.unshift(e),this.callHookWith(In,e,...t)}callHookWith(e,t,...n){let r=this._before||this._after?{name:t,args:n,context:{}}:void 0;this._before&&Ln(this._before,r);let i=e(t in this._hooks?[...this._hooks[t]]:[],n);return i instanceof Promise?i.finally(()=>{this._after&&r&&Ln(this._after,r)}):(this._after&&r&&Ln(this._after,r),i)}beforeEach(e){return this._before=this._before||[],this._before.push(e),()=>{if(this._before!==void 0){let 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){let t=this._after.indexOf(e);t!==-1&&this._after.splice(t,1)}}}};function zn(){return new Rn}var Bn=typeof window<`u`;function Vn(e,t={}){let n={inspect:Bn,group:Bn,filter:()=>!0,...t},r=n.filter,i=typeof r==`string`?e=>e.startsWith(r):r,a=n.tag?`[${n.tag}] `:``,o=e=>a+e.name+``.padEnd(e._id,`\0`),s={},c=e.beforeEach(e=>{i!==void 0&&!i(e.name)||(s[e.name]=s[e.name]||0,e._id=s[e.name]++,console.time(o(e)))}),l=e.afterEach(e=>{i!==void 0&&!i(e.name)||(n.group&&console.groupCollapsed(e.name),n.inspect?console.timeLog(o(e),e.args):console.timeEnd(o(e)),n.group&&console.groupEnd(),s[e.name]--)});return{close:()=>{c(),l()}}}var Hn=class{#e;get defaultTimeoutInMs(){return this.#e}constructor(e){this.hooks=zn(),this.#e=1e4,e?.hookDebug&&Vn(this.hooks,{tag:`hooks`}),e?.defaultRequestTimeout&&(this.#e=e.defaultRequestTimeout)}log(e,...t){if(this.hooks.callHook(`base:log`,t),this.logger)switch(e){case U.TRACE:this.logger.trace(t);break;case U.DEBUG:this.logger.debug(t);break;case U.INFO:this.logger.info(t);break;case U.WARN:this.logger.warn(t);break;case U.ERROR:this.logger.error(t);break;case U.FATAL:this.logger.fatal(t);break;default:break}}},Un=class e{#e;#t=[];#n=[];#r=[];constructor(e,t=[],n=[],r=[]){this.#e=e,this.#t=t,this.#n=n,this.#r=r}static create(){return new e(Hn)}#i(e){if(this.#t.includes(e))throw Error(`Feature "${e}" has already been used.`)}#a(e){for(let t of this.#n)if(t.feature===e)throw Error(`Feature "${e}" has been disabled by ${t.disabler.join(`,`)}.`)}#o(e){for(let t of this.#r)if(t.feature===e)throw Error(`Group "${e}" has been disabled by ${t.disabler.join(`,`)}.`)}#s(e,t){for(let n of this.#n)if(n.feature===t){n.disabler.push(e);return}this.#n.push({disabler:[e],feature:t})}#c(e,t){for(let n of this.#r)if(n.feature===t){n.disabler.push(e);return}this.#r.push({disabler:[e],feature:t})}with(t){let{featureName:n,disabledFeatures:r,disabledFeatureGroups:i,featureGroups:a}=t;if(!n)throw Error(`Feature name is missing`);if(n!==`Custom`){if(this.#i(n),this.#a(n),this.#t.push(n),a&&a.length>0)for(let e of a)this.#o(e);if(r&&r.length>0)for(let e of r)this.#s(n,e);if(i&&i.length>0)for(let e of i)this.#c(n,e)}let o=t(this.#e);return new e(o,this.#t,this.#n,this.#r)}build(e){return new this.#e(e)}getClientConstructor(){return this.#e}};e.AbstractLogger=ce,e.AbstractMdg2Request=F,e.AuthenticationByTokenRequest=I,e.AuthenticationTokenRequest=L,e.AuthenticationTokenResponse=ne,e.CancelSubscriptionRequest=R,e.ConnectionState=v,e.ConsoleLogger=ue,e.CookieTokenAuthenticationFactors=p,e.DEFAULT_TIMEOUT_IN_MS=N,e.DefaultHosts=b,e.DeploymentStage=y,e.FLAG_HAS_NEXT_CHUNK=se,e.FrontgateClient=Hn,e.FrontgateClientBuilder=Un,e.FrontgateClientDataObserver=Dt,e.FrontgateClientEndpointDataObserver=Ot,e.HTTPProxyRequest=B,e.HTTPProxyResponse=ie,e.HighLevelRequest=z,e.HighLevelResponse=re,e.HighLevelUpdate=oe,e.ID_APP_AUTHENTICATED=m,e.ID_USER_AUTHENTICATED=h,e.ID_USER_NONE=g,e.LogLevel=U,e.LoggerHelper=le,e.Mdg2Response=H,e.NullLogger=pe,e.PingRequest=V,e.PingResponse=ae,e.RawRequest=te,e.TimeOptions=x,e.TransportLayerClientRequestHeader=P,e.WinstonLogger=fe,e.authTokenRequest=me,e.cookieTokenAuth=kt,e.createExtendedMixinFactory=$,e.encodeSpanContext=On,e.endpointRequest=he,e.endpointSubscriptions=yt,e.fetchAuth=jt,e.fetchAuthWithOptionalCompressor=Mt,e.getBytesFromBuffer=_,e.hasJobIdInHeader=w,e.hasJobIdInRoot=C,e.httpProxyRequest=kn,e.isPtlMessageWithHeader=E,e.isServiceAndNotationBased=T,e.levels=de,e.logger=ye,e.messageCompressor=_t,e.openTelemetry=Dn,e.pingRequests=An,e.rawSubscriptions=bt,e.reconnect=Nt,e.remotelogger=jn,e.requests=vt,e.timeToMilliseconds=S,e.tokenAuth=At,e.useTimeout=j,e.wsConnection=ve});
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
//#endregion
|
|
211
211
|
//#region src/version.ts
|
|
212
212
|
var PACKAGE_JSON = {
|
|
213
|
-
version: "7.1.
|
|
213
|
+
version: "7.1.7",
|
|
214
214
|
package: "@factset/frontgate-js-sdk"
|
|
215
215
|
};
|
|
216
216
|
//#endregion
|
|
@@ -1188,7 +1188,6 @@
|
|
|
1188
1188
|
this.hooks.hook("reconnect:attempt", async () => {
|
|
1189
1189
|
clearInterval(this.#keepAliveTimer);
|
|
1190
1190
|
this.log(LogLevel.DEBUG, "Reconnecting");
|
|
1191
|
-
await this.hooks.callHook("frontgateConnection:reset");
|
|
1192
1191
|
try {
|
|
1193
1192
|
await this.connect();
|
|
1194
1193
|
await this.hooks.callHook("reconnect:success");
|
|
@@ -1199,6 +1198,7 @@
|
|
|
1199
1198
|
});
|
|
1200
1199
|
}
|
|
1201
1200
|
async connect() {
|
|
1201
|
+
await this.hooks.callHook("frontgateConnection:reset");
|
|
1202
1202
|
if (!this.#wsConf) throw new Error("No connection configuration set");
|
|
1203
1203
|
if (this.#wsState !== "disconnected") throw new Error("Client is already connected or is connecting right now");
|
|
1204
1204
|
const { host, port, tls, pathPrefix } = this.#wsConf;
|
|
@@ -1260,7 +1260,7 @@
|
|
|
1260
1260
|
this.#ws.onclose = (closeEvent) => {
|
|
1261
1261
|
unhookOnFrontgateConnectionAuthenticated?.();
|
|
1262
1262
|
this.log(LogLevel.DEBUG, "Disconnected", closeEvent);
|
|
1263
|
-
if (this.#wsStateInternal === "connecting" || this.#wsStateInternal === "connected") reject(
|
|
1263
|
+
if (this.#wsStateInternal === "connecting" || this.#wsStateInternal === "connected") reject(closeEvent);
|
|
1264
1264
|
else this.hooks.callHook("frontgateConnection:disconnected", closeEvent);
|
|
1265
1265
|
clearInterval(this.#keepAliveTimer);
|
|
1266
1266
|
this.#wsStateInternal = "disconnected";
|
|
@@ -1427,7 +1427,9 @@
|
|
|
1427
1427
|
};
|
|
1428
1428
|
//#endregion
|
|
1429
1429
|
//#region node_modules/fflate/esm/browser.js
|
|
1430
|
-
var u8 = Uint8Array
|
|
1430
|
+
var u8 = Uint8Array;
|
|
1431
|
+
var u16 = Uint16Array;
|
|
1432
|
+
var i32 = Int32Array;
|
|
1431
1433
|
var fleb = new u8([
|
|
1432
1434
|
0,
|
|
1433
1435
|
0,
|
|
@@ -1527,9 +1529,13 @@
|
|
|
1527
1529
|
r
|
|
1528
1530
|
};
|
|
1529
1531
|
};
|
|
1530
|
-
var _a = freb(fleb, 2)
|
|
1532
|
+
var _a = freb(fleb, 2);
|
|
1533
|
+
var fl = _a.b;
|
|
1534
|
+
var revfl = _a.r;
|
|
1531
1535
|
fl[28] = 258, revfl[258] = 28;
|
|
1532
|
-
var _b = freb(fdeb, 0)
|
|
1536
|
+
var _b = freb(fdeb, 0);
|
|
1537
|
+
var fd = _b.b;
|
|
1538
|
+
var revfd = _b.r;
|
|
1533
1539
|
var rev = new u16(32768);
|
|
1534
1540
|
for (var i = 0; i < 32768; ++i) {
|
|
1535
1541
|
var x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
@@ -1567,8 +1573,10 @@
|
|
|
1567
1573
|
for (var i = 280; i < 288; ++i) flt[i] = 8;
|
|
1568
1574
|
var fdt = new u8(32);
|
|
1569
1575
|
for (var i = 0; i < 32; ++i) fdt[i] = 5;
|
|
1570
|
-
var flm = /*#__PURE__*/ hMap(flt, 9, 0)
|
|
1571
|
-
var
|
|
1576
|
+
var flm = /*#__PURE__*/ hMap(flt, 9, 0);
|
|
1577
|
+
var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
|
|
1578
|
+
var fdm = /*#__PURE__*/ hMap(fdt, 5, 0);
|
|
1579
|
+
var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
|
|
1572
1580
|
var max = function(a) {
|
|
1573
1581
|
var m = a[0];
|
|
1574
1582
|
for (var i = 1; i < a.length; ++i) if (a[i] > m) m = a[i];
|
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.1.
|
|
4
|
+
"version": "7.1.7",
|
|
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",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"vite": "^8.0.0",
|
|
87
87
|
"vitest": "^4.0.0"
|
|
88
88
|
},
|
|
89
|
-
"packageManager": "yarn@4.17.
|
|
89
|
+
"packageManager": "yarn@4.17.1"
|
|
90
90
|
}
|