@factset/frontgate-js-sdk 6.9.0
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 +1112 -0
- package/LICENSE +201 -0
- package/README.md +44 -0
- package/dist/lib/esnext/FrontgateClient.js +142 -0
- package/dist/lib/esnext/FrontgateClient.js.map +1 -0
- package/dist/lib/esnext/Mdg2Client.js +186 -0
- package/dist/lib/esnext/Mdg2Client.js.map +1 -0
- package/dist/lib/esnext/authentication/AbstractAuthentication.js +50 -0
- package/dist/lib/esnext/authentication/AbstractAuthentication.js.map +1 -0
- package/dist/lib/esnext/authentication/AppAuthentication.js +71 -0
- package/dist/lib/esnext/authentication/AppAuthentication.js.map +1 -0
- package/dist/lib/esnext/authentication/AuthenticationInterface.js +2 -0
- package/dist/lib/esnext/authentication/AuthenticationInterface.js.map +1 -0
- package/dist/lib/esnext/authentication/CookieTokenAuthentication.js +19 -0
- package/dist/lib/esnext/authentication/CookieTokenAuthentication.js.map +1 -0
- package/dist/lib/esnext/authentication/CookieTokenAuthenticationFactors.js +16 -0
- package/dist/lib/esnext/authentication/CookieTokenAuthenticationFactors.js.map +1 -0
- package/dist/lib/esnext/authentication/TokenAuthentication.js +43 -0
- package/dist/lib/esnext/authentication/TokenAuthentication.js.map +1 -0
- package/dist/lib/esnext/authentication/UserCredentialAuthentication.js +74 -0
- package/dist/lib/esnext/authentication/UserCredentialAuthentication.js.map +1 -0
- package/dist/lib/esnext/authentication/UserPasswordAuthentication.js +72 -0
- package/dist/lib/esnext/authentication/UserPasswordAuthentication.js.map +1 -0
- package/dist/lib/esnext/authentication/index.js +6 -0
- package/dist/lib/esnext/authentication/index.js.map +1 -0
- package/dist/lib/esnext/authentication/util/ChallengeResolver.js +33 -0
- package/dist/lib/esnext/authentication/util/ChallengeResolver.js.map +1 -0
- package/dist/lib/esnext/authentication/util/SecretGenerator.js +63 -0
- package/dist/lib/esnext/authentication/util/SecretGenerator.js.map +1 -0
- package/dist/lib/esnext/authentication/util/index.js +3 -0
- package/dist/lib/esnext/authentication/util/index.js.map +1 -0
- package/dist/lib/esnext/common/Mdg2ClientOptions.js +2 -0
- package/dist/lib/esnext/common/Mdg2ClientOptions.js.map +1 -0
- package/dist/lib/esnext/common/constants.js +11 -0
- package/dist/lib/esnext/common/constants.js.map +1 -0
- package/dist/lib/esnext/common/errors.js +43 -0
- package/dist/lib/esnext/common/errors.js.map +1 -0
- package/dist/lib/esnext/common/functions.js +98 -0
- package/dist/lib/esnext/common/functions.js.map +1 -0
- package/dist/lib/esnext/common/interfaces/PtlMessage.js +2 -0
- package/dist/lib/esnext/common/interfaces/PtlMessage.js.map +1 -0
- package/dist/lib/esnext/common/interfaces/index.js +5 -0
- package/dist/lib/esnext/common/interfaces/index.js.map +1 -0
- package/dist/lib/esnext/common/interfaces/observe/ObserveOptions.js +2 -0
- package/dist/lib/esnext/common/interfaces/observe/ObserveOptions.js.map +1 -0
- package/dist/lib/esnext/common/interfaces/result/HTTPProxyRequestResult.js +2 -0
- package/dist/lib/esnext/common/interfaces/result/HTTPProxyRequestResult.js.map +1 -0
- package/dist/lib/esnext/common/interfaces/result/HighLevelRequestResult.js +2 -0
- package/dist/lib/esnext/common/interfaces/result/HighLevelRequestResult.js.map +1 -0
- package/dist/lib/esnext/common/interfaces/result/RequestResult.js +2 -0
- package/dist/lib/esnext/common/interfaces/result/RequestResult.js.map +1 -0
- package/dist/lib/esnext/common/types/Quality.js +2 -0
- package/dist/lib/esnext/common/types/Quality.js.map +1 -0
- package/dist/lib/esnext/common/types/RequestQuality.js +2 -0
- package/dist/lib/esnext/common/types/RequestQuality.js.map +1 -0
- package/dist/lib/esnext/common/types/index.js +3 -0
- package/dist/lib/esnext/common/types/index.js.map +1 -0
- package/dist/lib/esnext/compat/index.js +11 -0
- package/dist/lib/esnext/compat/index.js.map +1 -0
- package/dist/lib/esnext/connection/AbstractFrontgateConnection.js +325 -0
- package/dist/lib/esnext/connection/AbstractFrontgateConnection.js.map +1 -0
- package/dist/lib/esnext/connection/ConnectionInterface.js +2 -0
- package/dist/lib/esnext/connection/ConnectionInterface.js.map +1 -0
- package/dist/lib/esnext/connection/FrontgateWSConnection.js +282 -0
- package/dist/lib/esnext/connection/FrontgateWSConnection.js.map +1 -0
- package/dist/lib/esnext/connection/JobPromise.js +3 -0
- package/dist/lib/esnext/connection/JobPromise.js.map +1 -0
- package/dist/lib/esnext/connection/LatencyHandler.js +2 -0
- package/dist/lib/esnext/connection/LatencyHandler.js.map +1 -0
- package/dist/lib/esnext/connection/LatencyTracker.js +48 -0
- package/dist/lib/esnext/connection/LatencyTracker.js.map +1 -0
- package/dist/lib/esnext/connection/MessageProcessor.js +2 -0
- package/dist/lib/esnext/connection/MessageProcessor.js.map +1 -0
- package/dist/lib/esnext/connection/index.js +8 -0
- package/dist/lib/esnext/connection/index.js.map +1 -0
- package/dist/lib/esnext/connection/util/Compressor.js +52 -0
- package/dist/lib/esnext/connection/util/Compressor.js.map +1 -0
- package/dist/lib/esnext/connection/util/Encoding.js +15 -0
- package/dist/lib/esnext/connection/util/Encoding.js.map +1 -0
- package/dist/lib/esnext/connection/util/functions.js +66 -0
- package/dist/lib/esnext/connection/util/functions.js.map +1 -0
- package/dist/lib/esnext/core/RequestModule.js +350 -0
- package/dist/lib/esnext/core/RequestModule.js.map +1 -0
- package/dist/lib/esnext/core/SubscriptionModule.js +105 -0
- package/dist/lib/esnext/core/SubscriptionModule.js.map +1 -0
- package/dist/lib/esnext/core/subscription/EndpointHandler.js +122 -0
- package/dist/lib/esnext/core/subscription/EndpointHandler.js.map +1 -0
- package/dist/lib/esnext/core/subscription/SubjectManager.js +40 -0
- package/dist/lib/esnext/core/subscription/SubjectManager.js.map +1 -0
- package/dist/lib/esnext/index.js +11 -0
- package/dist/lib/esnext/index.js.map +1 -0
- package/dist/lib/esnext/logger/AbstractLogger.js +99 -0
- package/dist/lib/esnext/logger/AbstractLogger.js.map +1 -0
- package/dist/lib/esnext/logger/ConsoleLogger.js +33 -0
- package/dist/lib/esnext/logger/ConsoleLogger.js.map +1 -0
- package/dist/lib/esnext/logger/LoggerHelper.js +25 -0
- package/dist/lib/esnext/logger/LoggerHelper.js.map +1 -0
- package/dist/lib/esnext/logger/LoggerInterface.js +2 -0
- package/dist/lib/esnext/logger/LoggerInterface.js.map +1 -0
- package/dist/lib/esnext/logger/NullLogger.js +15 -0
- package/dist/lib/esnext/logger/NullLogger.js.map +1 -0
- package/dist/lib/esnext/logger/WinstonLogger.js +34 -0
- package/dist/lib/esnext/logger/WinstonLogger.js.map +1 -0
- package/dist/lib/esnext/logger/index.js +7 -0
- package/dist/lib/esnext/logger/index.js.map +1 -0
- package/dist/lib/esnext/message/MessageFactory.js +37 -0
- package/dist/lib/esnext/message/MessageFactory.js.map +1 -0
- package/dist/lib/esnext/message/guards.js +22 -0
- package/dist/lib/esnext/message/guards.js.map +1 -0
- package/dist/lib/esnext/message/index.js +7 -0
- package/dist/lib/esnext/message/index.js.map +1 -0
- package/dist/lib/esnext/message/interfaces/HTTPProxyRequestOptions.js +2 -0
- package/dist/lib/esnext/message/interfaces/HTTPProxyRequestOptions.js.map +1 -0
- package/dist/lib/esnext/message/interfaces/HighLevelRequestMethod.js +2 -0
- package/dist/lib/esnext/message/interfaces/HighLevelRequestMethod.js.map +1 -0
- package/dist/lib/esnext/message/interfaces/HighLevelRequestOptions.js +2 -0
- package/dist/lib/esnext/message/interfaces/HighLevelRequestOptions.js.map +1 -0
- package/dist/lib/esnext/message/interfaces/JobObservable.js +2 -0
- package/dist/lib/esnext/message/interfaces/JobObservable.js.map +1 -0
- package/dist/lib/esnext/message/interfaces/index.js +5 -0
- package/dist/lib/esnext/message/interfaces/index.js.map +1 -0
- package/dist/lib/esnext/message/request/AbstractMdg2Request.js +17 -0
- package/dist/lib/esnext/message/request/AbstractMdg2Request.js.map +1 -0
- package/dist/lib/esnext/message/request/AuthenticationByTokenRequest.js +32 -0
- package/dist/lib/esnext/message/request/AuthenticationByTokenRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/AuthenticationRequest.js +30 -0
- package/dist/lib/esnext/message/request/AuthenticationRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/AuthenticationTokenRequest.js +24 -0
- package/dist/lib/esnext/message/request/AuthenticationTokenRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/CancelSubscriptionRequest.js +10 -0
- package/dist/lib/esnext/message/request/CancelSubscriptionRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/ConfigurationRequest.js +76 -0
- package/dist/lib/esnext/message/request/ConfigurationRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/HTTPProxyRequest.js +121 -0
- package/dist/lib/esnext/message/request/HTTPProxyRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/HighLevelRequest.js +89 -0
- package/dist/lib/esnext/message/request/HighLevelRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/PingRequest.js +23 -0
- package/dist/lib/esnext/message/request/PingRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/TransportLayerClientRequestHeader.js +109 -0
- package/dist/lib/esnext/message/request/TransportLayerClientRequestHeader.js.map +1 -0
- package/dist/lib/esnext/message/request/index.js +10 -0
- package/dist/lib/esnext/message/request/index.js.map +1 -0
- package/dist/lib/esnext/message/request/raw/RawRequest.js +15 -0
- package/dist/lib/esnext/message/request/raw/RawRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/raw/RawRequestFactory.js +19 -0
- package/dist/lib/esnext/message/request/raw/RawRequestFactory.js.map +1 -0
- package/dist/lib/esnext/message/request/raw/example/CreateNotationSearchRequest.js +568 -0
- package/dist/lib/esnext/message/request/raw/example/CreateNotationSearchRequest.js.map +1 -0
- package/dist/lib/esnext/message/request/raw/index.js +3 -0
- package/dist/lib/esnext/message/request/raw/index.js.map +1 -0
- package/dist/lib/esnext/message/response/AuthenticationByTokenResponse.js +2 -0
- package/dist/lib/esnext/message/response/AuthenticationByTokenResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/AuthenticationResponse.js +2 -0
- package/dist/lib/esnext/message/response/AuthenticationResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/AuthenticationTokenResponse.js +22 -0
- package/dist/lib/esnext/message/response/AuthenticationTokenResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/CancelSubscriptionResponse.js +4 -0
- package/dist/lib/esnext/message/response/CancelSubscriptionResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/ConfigurationResponse.js +2 -0
- package/dist/lib/esnext/message/response/ConfigurationResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/DisconnectionMessage.js +2 -0
- package/dist/lib/esnext/message/response/DisconnectionMessage.js.map +1 -0
- package/dist/lib/esnext/message/response/ErrorResponse.js +10 -0
- package/dist/lib/esnext/message/response/ErrorResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/HTTPProxyResponse.js +30 -0
- package/dist/lib/esnext/message/response/HTTPProxyResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/HighLevelResponse.js +25 -0
- package/dist/lib/esnext/message/response/HighLevelResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/LoadNotificationMessage.js +2 -0
- package/dist/lib/esnext/message/response/LoadNotificationMessage.js.map +1 -0
- package/dist/lib/esnext/message/response/Mdg2Response.js +28 -0
- package/dist/lib/esnext/message/response/Mdg2Response.js.map +1 -0
- package/dist/lib/esnext/message/response/PermissionDeniedResponse.js +7 -0
- package/dist/lib/esnext/message/response/PermissionDeniedResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/PingResponse.js +32 -0
- package/dist/lib/esnext/message/response/PingResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/RejectResponse.js +10 -0
- package/dist/lib/esnext/message/response/RejectResponse.js.map +1 -0
- package/dist/lib/esnext/message/response/index.js +14 -0
- package/dist/lib/esnext/message/response/index.js.map +1 -0
- package/dist/lib/esnext/message/types/Time.js +9 -0
- package/dist/lib/esnext/message/types/Time.js.map +1 -0
- package/dist/lib/esnext/message/types/TransportLayerClientRequestHeaderFlag.js +2 -0
- package/dist/lib/esnext/message/types/TransportLayerClientRequestHeaderFlag.js.map +1 -0
- package/dist/lib/esnext/message/types/index.js +3 -0
- package/dist/lib/esnext/message/types/index.js.map +1 -0
- package/dist/lib/esnext/message/update/HighLevelUpdate.js +19 -0
- package/dist/lib/esnext/message/update/HighLevelUpdate.js.map +1 -0
- package/dist/lib/esnext/message/update/SubscriptionLossMessage.js +11 -0
- package/dist/lib/esnext/message/update/SubscriptionLossMessage.js.map +1 -0
- package/dist/lib/esnext/message/update/index.js +3 -0
- package/dist/lib/esnext/message/update/index.js.map +1 -0
- package/dist/lib/esnext/mixins/AuthTokenRequestMixin.js +38 -0
- package/dist/lib/esnext/mixins/AuthTokenRequestMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/EndpointRequestMixin.js +87 -0
- package/dist/lib/esnext/mixins/EndpointRequestMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/HTTPProxyRequestMixin.js +47 -0
- package/dist/lib/esnext/mixins/HTTPProxyRequestMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/LoggerMixin.js +19 -0
- package/dist/lib/esnext/mixins/LoggerMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/MessageCompressorMixin.js +46 -0
- package/dist/lib/esnext/mixins/MessageCompressorMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/OpenTelemetryMixin.js +65 -0
- package/dist/lib/esnext/mixins/OpenTelemetryMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/ReconnectMixin.js +71 -0
- package/dist/lib/esnext/mixins/ReconnectMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/RequestMixin.js +31 -0
- package/dist/lib/esnext/mixins/RequestMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/AppAuthMixin.js +43 -0
- package/dist/lib/esnext/mixins/auth/AppAuthMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/CookieTokenAuthMixin.js +47 -0
- package/dist/lib/esnext/mixins/auth/CookieTokenAuthMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/FetchAuthenticationMixin.js +128 -0
- package/dist/lib/esnext/mixins/auth/FetchAuthenticationMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/SessionAuthMixin.js +181 -0
- package/dist/lib/esnext/mixins/auth/SessionAuthMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/TokenAuthMixin.js +60 -0
- package/dist/lib/esnext/mixins/auth/TokenAuthMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/UserCredentialAuthMixin.js +44 -0
- package/dist/lib/esnext/mixins/auth/UserCredentialAuthMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/UserPasswordAuthMixin.js +44 -0
- package/dist/lib/esnext/mixins/auth/UserPasswordAuthMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/auth/index.js +34 -0
- package/dist/lib/esnext/mixins/auth/index.js.map +1 -0
- package/dist/lib/esnext/mixins/connection/FrontgateWSMixin.js +326 -0
- package/dist/lib/esnext/mixins/connection/FrontgateWSMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/connection/index.js +2 -0
- package/dist/lib/esnext/mixins/connection/index.js.map +1 -0
- package/dist/lib/esnext/mixins/index.js +20 -0
- package/dist/lib/esnext/mixins/index.js.map +1 -0
- package/dist/lib/esnext/mixins/subscription/DataObserver.js +117 -0
- package/dist/lib/esnext/mixins/subscription/DataObserver.js.map +1 -0
- package/dist/lib/esnext/mixins/subscription/EndpointSubscriptionMixin.js +193 -0
- package/dist/lib/esnext/mixins/subscription/EndpointSubscriptionMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/subscription/RawSubscriptionMixin.js +156 -0
- package/dist/lib/esnext/mixins/subscription/RawSubscriptionMixin.js.map +1 -0
- package/dist/lib/esnext/mixins/subscription/index.js +4 -0
- package/dist/lib/esnext/mixins/subscription/index.js.map +1 -0
- package/dist/lib/esnext/util/TimeOutWrapper.js +52 -0
- package/dist/lib/esnext/util/TimeOutWrapper.js.map +1 -0
- package/dist/lib/esnext/util/functions.js +64 -0
- package/dist/lib/esnext/util/functions.js.map +1 -0
- package/dist/lib/esnext/version.js +2 -0
- package/dist/lib/esnext/version.js.map +1 -0
- package/dist/lib/node/FrontgateClient.js +147 -0
- package/dist/lib/node/FrontgateClient.js.map +1 -0
- package/dist/lib/node/Mdg2Client.js +190 -0
- package/dist/lib/node/Mdg2Client.js.map +1 -0
- package/dist/lib/node/authentication/AbstractAuthentication.js +54 -0
- package/dist/lib/node/authentication/AbstractAuthentication.js.map +1 -0
- package/dist/lib/node/authentication/AppAuthentication.js +75 -0
- package/dist/lib/node/authentication/AppAuthentication.js.map +1 -0
- package/dist/lib/node/authentication/AuthenticationInterface.js +3 -0
- package/dist/lib/node/authentication/AuthenticationInterface.js.map +1 -0
- package/dist/lib/node/authentication/CookieTokenAuthentication.js +23 -0
- package/dist/lib/node/authentication/CookieTokenAuthentication.js.map +1 -0
- package/dist/lib/node/authentication/CookieTokenAuthenticationFactors.js +20 -0
- package/dist/lib/node/authentication/CookieTokenAuthenticationFactors.js.map +1 -0
- package/dist/lib/node/authentication/TokenAuthentication.js +47 -0
- package/dist/lib/node/authentication/TokenAuthentication.js.map +1 -0
- package/dist/lib/node/authentication/UserCredentialAuthentication.js +78 -0
- package/dist/lib/node/authentication/UserCredentialAuthentication.js.map +1 -0
- package/dist/lib/node/authentication/UserPasswordAuthentication.js +76 -0
- package/dist/lib/node/authentication/UserPasswordAuthentication.js.map +1 -0
- package/dist/lib/node/authentication/index.js +22 -0
- package/dist/lib/node/authentication/index.js.map +1 -0
- package/dist/lib/node/authentication/util/ChallengeResolver.js +40 -0
- package/dist/lib/node/authentication/util/ChallengeResolver.js.map +1 -0
- package/dist/lib/node/authentication/util/SecretGenerator.js +67 -0
- package/dist/lib/node/authentication/util/SecretGenerator.js.map +1 -0
- package/dist/lib/node/authentication/util/index.js +19 -0
- package/dist/lib/node/authentication/util/index.js.map +1 -0
- package/dist/lib/node/common/Mdg2ClientOptions.js +3 -0
- package/dist/lib/node/common/Mdg2ClientOptions.js.map +1 -0
- package/dist/lib/node/common/constants.js +14 -0
- package/dist/lib/node/common/constants.js.map +1 -0
- package/dist/lib/node/common/errors.js +52 -0
- package/dist/lib/node/common/errors.js.map +1 -0
- package/dist/lib/node/common/functions.js +114 -0
- package/dist/lib/node/common/functions.js.map +1 -0
- package/dist/lib/node/common/interfaces/PtlMessage.js +3 -0
- package/dist/lib/node/common/interfaces/PtlMessage.js.map +1 -0
- package/dist/lib/node/common/interfaces/index.js +21 -0
- package/dist/lib/node/common/interfaces/index.js.map +1 -0
- package/dist/lib/node/common/interfaces/observe/ObserveOptions.js +3 -0
- package/dist/lib/node/common/interfaces/observe/ObserveOptions.js.map +1 -0
- package/dist/lib/node/common/interfaces/result/HTTPProxyRequestResult.js +3 -0
- package/dist/lib/node/common/interfaces/result/HTTPProxyRequestResult.js.map +1 -0
- package/dist/lib/node/common/interfaces/result/HighLevelRequestResult.js +3 -0
- package/dist/lib/node/common/interfaces/result/HighLevelRequestResult.js.map +1 -0
- package/dist/lib/node/common/interfaces/result/RequestResult.js +3 -0
- package/dist/lib/node/common/interfaces/result/RequestResult.js.map +1 -0
- package/dist/lib/node/common/types/Quality.js +3 -0
- package/dist/lib/node/common/types/Quality.js.map +1 -0
- package/dist/lib/node/common/types/RequestQuality.js +3 -0
- package/dist/lib/node/common/types/RequestQuality.js.map +1 -0
- package/dist/lib/node/common/types/index.js +19 -0
- package/dist/lib/node/common/types/index.js.map +1 -0
- package/dist/lib/node/compat/index.js +27 -0
- package/dist/lib/node/compat/index.js.map +1 -0
- package/dist/lib/node/connection/AbstractFrontgateConnection.js +329 -0
- package/dist/lib/node/connection/AbstractFrontgateConnection.js.map +1 -0
- package/dist/lib/node/connection/ConnectionInterface.js +3 -0
- package/dist/lib/node/connection/ConnectionInterface.js.map +1 -0
- package/dist/lib/node/connection/FrontgateWSConnection.js +289 -0
- package/dist/lib/node/connection/FrontgateWSConnection.js.map +1 -0
- package/dist/lib/node/connection/JobPromise.js +7 -0
- package/dist/lib/node/connection/JobPromise.js.map +1 -0
- package/dist/lib/node/connection/LatencyHandler.js +3 -0
- package/dist/lib/node/connection/LatencyHandler.js.map +1 -0
- package/dist/lib/node/connection/LatencyTracker.js +52 -0
- package/dist/lib/node/connection/LatencyTracker.js.map +1 -0
- package/dist/lib/node/connection/MessageProcessor.js +3 -0
- package/dist/lib/node/connection/MessageProcessor.js.map +1 -0
- package/dist/lib/node/connection/index.js +24 -0
- package/dist/lib/node/connection/index.js.map +1 -0
- package/dist/lib/node/connection/util/Compressor.js +56 -0
- package/dist/lib/node/connection/util/Compressor.js.map +1 -0
- package/dist/lib/node/connection/util/Encoding.js +19 -0
- package/dist/lib/node/connection/util/Encoding.js.map +1 -0
- package/dist/lib/node/connection/util/functions.js +76 -0
- package/dist/lib/node/connection/util/functions.js.map +1 -0
- package/dist/lib/node/core/RequestModule.js +354 -0
- package/dist/lib/node/core/RequestModule.js.map +1 -0
- package/dist/lib/node/core/SubscriptionModule.js +109 -0
- package/dist/lib/node/core/SubscriptionModule.js.map +1 -0
- package/dist/lib/node/core/subscription/EndpointHandler.js +126 -0
- package/dist/lib/node/core/subscription/EndpointHandler.js.map +1 -0
- package/dist/lib/node/core/subscription/SubjectManager.js +44 -0
- package/dist/lib/node/core/subscription/SubjectManager.js.map +1 -0
- package/dist/lib/node/index.js +32 -0
- package/dist/lib/node/index.js.map +1 -0
- package/dist/lib/node/logger/AbstractLogger.js +103 -0
- package/dist/lib/node/logger/AbstractLogger.js.map +1 -0
- package/dist/lib/node/logger/ConsoleLogger.js +37 -0
- package/dist/lib/node/logger/ConsoleLogger.js.map +1 -0
- package/dist/lib/node/logger/LoggerHelper.js +29 -0
- package/dist/lib/node/logger/LoggerHelper.js.map +1 -0
- package/dist/lib/node/logger/LoggerInterface.js +3 -0
- package/dist/lib/node/logger/LoggerInterface.js.map +1 -0
- package/dist/lib/node/logger/NullLogger.js +19 -0
- package/dist/lib/node/logger/NullLogger.js.map +1 -0
- package/dist/lib/node/logger/WinstonLogger.js +38 -0
- package/dist/lib/node/logger/WinstonLogger.js.map +1 -0
- package/dist/lib/node/logger/index.js +23 -0
- package/dist/lib/node/logger/index.js.map +1 -0
- package/dist/lib/node/message/MessageFactory.js +74 -0
- package/dist/lib/node/message/MessageFactory.js.map +1 -0
- package/dist/lib/node/message/guards.js +31 -0
- package/dist/lib/node/message/guards.js.map +1 -0
- package/dist/lib/node/message/index.js +23 -0
- package/dist/lib/node/message/index.js.map +1 -0
- package/dist/lib/node/message/interfaces/HTTPProxyRequestOptions.js +3 -0
- package/dist/lib/node/message/interfaces/HTTPProxyRequestOptions.js.map +1 -0
- package/dist/lib/node/message/interfaces/HighLevelRequestMethod.js +3 -0
- package/dist/lib/node/message/interfaces/HighLevelRequestMethod.js.map +1 -0
- package/dist/lib/node/message/interfaces/HighLevelRequestOptions.js +3 -0
- package/dist/lib/node/message/interfaces/HighLevelRequestOptions.js.map +1 -0
- package/dist/lib/node/message/interfaces/JobObservable.js +3 -0
- package/dist/lib/node/message/interfaces/JobObservable.js.map +1 -0
- package/dist/lib/node/message/interfaces/index.js +21 -0
- package/dist/lib/node/message/interfaces/index.js.map +1 -0
- package/dist/lib/node/message/request/AbstractMdg2Request.js +21 -0
- package/dist/lib/node/message/request/AbstractMdg2Request.js.map +1 -0
- package/dist/lib/node/message/request/AuthenticationByTokenRequest.js +36 -0
- package/dist/lib/node/message/request/AuthenticationByTokenRequest.js.map +1 -0
- package/dist/lib/node/message/request/AuthenticationRequest.js +34 -0
- package/dist/lib/node/message/request/AuthenticationRequest.js.map +1 -0
- package/dist/lib/node/message/request/AuthenticationTokenRequest.js +28 -0
- package/dist/lib/node/message/request/AuthenticationTokenRequest.js.map +1 -0
- package/dist/lib/node/message/request/CancelSubscriptionRequest.js +14 -0
- package/dist/lib/node/message/request/CancelSubscriptionRequest.js.map +1 -0
- package/dist/lib/node/message/request/ConfigurationRequest.js +80 -0
- package/dist/lib/node/message/request/ConfigurationRequest.js.map +1 -0
- package/dist/lib/node/message/request/HTTPProxyRequest.js +125 -0
- package/dist/lib/node/message/request/HTTPProxyRequest.js.map +1 -0
- package/dist/lib/node/message/request/HighLevelRequest.js +93 -0
- package/dist/lib/node/message/request/HighLevelRequest.js.map +1 -0
- package/dist/lib/node/message/request/PingRequest.js +27 -0
- package/dist/lib/node/message/request/PingRequest.js.map +1 -0
- package/dist/lib/node/message/request/TransportLayerClientRequestHeader.js +113 -0
- package/dist/lib/node/message/request/TransportLayerClientRequestHeader.js.map +1 -0
- package/dist/lib/node/message/request/index.js +26 -0
- package/dist/lib/node/message/request/index.js.map +1 -0
- package/dist/lib/node/message/request/raw/RawRequest.js +22 -0
- package/dist/lib/node/message/request/raw/RawRequest.js.map +1 -0
- package/dist/lib/node/message/request/raw/RawRequestFactory.js +23 -0
- package/dist/lib/node/message/request/raw/RawRequestFactory.js.map +1 -0
- package/dist/lib/node/message/request/raw/example/CreateNotationSearchRequest.js +572 -0
- package/dist/lib/node/message/request/raw/example/CreateNotationSearchRequest.js.map +1 -0
- package/dist/lib/node/message/request/raw/index.js +19 -0
- package/dist/lib/node/message/request/raw/index.js.map +1 -0
- package/dist/lib/node/message/response/AuthenticationByTokenResponse.js +3 -0
- package/dist/lib/node/message/response/AuthenticationByTokenResponse.js.map +1 -0
- package/dist/lib/node/message/response/AuthenticationResponse.js +3 -0
- package/dist/lib/node/message/response/AuthenticationResponse.js.map +1 -0
- package/dist/lib/node/message/response/AuthenticationTokenResponse.js +26 -0
- package/dist/lib/node/message/response/AuthenticationTokenResponse.js.map +1 -0
- package/dist/lib/node/message/response/CancelSubscriptionResponse.js +8 -0
- package/dist/lib/node/message/response/CancelSubscriptionResponse.js.map +1 -0
- package/dist/lib/node/message/response/ConfigurationResponse.js +3 -0
- package/dist/lib/node/message/response/ConfigurationResponse.js.map +1 -0
- package/dist/lib/node/message/response/DisconnectionMessage.js +3 -0
- package/dist/lib/node/message/response/DisconnectionMessage.js.map +1 -0
- package/dist/lib/node/message/response/ErrorResponse.js +14 -0
- package/dist/lib/node/message/response/ErrorResponse.js.map +1 -0
- package/dist/lib/node/message/response/HTTPProxyResponse.js +34 -0
- package/dist/lib/node/message/response/HTTPProxyResponse.js.map +1 -0
- package/dist/lib/node/message/response/HighLevelResponse.js +29 -0
- package/dist/lib/node/message/response/HighLevelResponse.js.map +1 -0
- package/dist/lib/node/message/response/LoadNotificationMessage.js +3 -0
- package/dist/lib/node/message/response/LoadNotificationMessage.js.map +1 -0
- package/dist/lib/node/message/response/Mdg2Response.js +32 -0
- package/dist/lib/node/message/response/Mdg2Response.js.map +1 -0
- package/dist/lib/node/message/response/PermissionDeniedResponse.js +11 -0
- package/dist/lib/node/message/response/PermissionDeniedResponse.js.map +1 -0
- package/dist/lib/node/message/response/PingResponse.js +36 -0
- package/dist/lib/node/message/response/PingResponse.js.map +1 -0
- package/dist/lib/node/message/response/RejectResponse.js +14 -0
- package/dist/lib/node/message/response/RejectResponse.js.map +1 -0
- package/dist/lib/node/message/response/index.js +30 -0
- package/dist/lib/node/message/response/index.js.map +1 -0
- package/dist/lib/node/message/types/Time.js +13 -0
- package/dist/lib/node/message/types/Time.js.map +1 -0
- package/dist/lib/node/message/types/TransportLayerClientRequestHeaderFlag.js +3 -0
- package/dist/lib/node/message/types/TransportLayerClientRequestHeaderFlag.js.map +1 -0
- package/dist/lib/node/message/types/index.js +19 -0
- package/dist/lib/node/message/types/index.js.map +1 -0
- package/dist/lib/node/message/update/HighLevelUpdate.js +23 -0
- package/dist/lib/node/message/update/HighLevelUpdate.js.map +1 -0
- package/dist/lib/node/message/update/SubscriptionLossMessage.js +15 -0
- package/dist/lib/node/message/update/SubscriptionLossMessage.js.map +1 -0
- package/dist/lib/node/message/update/index.js +19 -0
- package/dist/lib/node/message/update/index.js.map +1 -0
- package/dist/lib/node/mixins/AuthTokenRequestMixin.js +42 -0
- package/dist/lib/node/mixins/AuthTokenRequestMixin.js.map +1 -0
- package/dist/lib/node/mixins/EndpointRequestMixin.js +91 -0
- package/dist/lib/node/mixins/EndpointRequestMixin.js.map +1 -0
- package/dist/lib/node/mixins/HTTPProxyRequestMixin.js +51 -0
- package/dist/lib/node/mixins/HTTPProxyRequestMixin.js.map +1 -0
- package/dist/lib/node/mixins/LoggerMixin.js +23 -0
- package/dist/lib/node/mixins/LoggerMixin.js.map +1 -0
- package/dist/lib/node/mixins/MessageCompressorMixin.js +50 -0
- package/dist/lib/node/mixins/MessageCompressorMixin.js.map +1 -0
- package/dist/lib/node/mixins/OpenTelemetryMixin.js +70 -0
- package/dist/lib/node/mixins/OpenTelemetryMixin.js.map +1 -0
- package/dist/lib/node/mixins/ReconnectMixin.js +75 -0
- package/dist/lib/node/mixins/ReconnectMixin.js.map +1 -0
- package/dist/lib/node/mixins/RequestMixin.js +35 -0
- package/dist/lib/node/mixins/RequestMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/AppAuthMixin.js +47 -0
- package/dist/lib/node/mixins/auth/AppAuthMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/CookieTokenAuthMixin.js +51 -0
- package/dist/lib/node/mixins/auth/CookieTokenAuthMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/FetchAuthenticationMixin.js +132 -0
- package/dist/lib/node/mixins/auth/FetchAuthenticationMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/SessionAuthMixin.js +185 -0
- package/dist/lib/node/mixins/auth/SessionAuthMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/TokenAuthMixin.js +64 -0
- package/dist/lib/node/mixins/auth/TokenAuthMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/UserCredentialAuthMixin.js +48 -0
- package/dist/lib/node/mixins/auth/UserCredentialAuthMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/UserPasswordAuthMixin.js +48 -0
- package/dist/lib/node/mixins/auth/UserPasswordAuthMixin.js.map +1 -0
- package/dist/lib/node/mixins/auth/index.js +52 -0
- package/dist/lib/node/mixins/auth/index.js.map +1 -0
- package/dist/lib/node/mixins/connection/FrontgateWSMixin.js +333 -0
- package/dist/lib/node/mixins/connection/FrontgateWSMixin.js.map +1 -0
- package/dist/lib/node/mixins/connection/index.js +18 -0
- package/dist/lib/node/mixins/connection/index.js.map +1 -0
- package/dist/lib/node/mixins/index.js +38 -0
- package/dist/lib/node/mixins/index.js.map +1 -0
- package/dist/lib/node/mixins/subscription/DataObserver.js +122 -0
- package/dist/lib/node/mixins/subscription/DataObserver.js.map +1 -0
- package/dist/lib/node/mixins/subscription/EndpointSubscriptionMixin.js +197 -0
- package/dist/lib/node/mixins/subscription/EndpointSubscriptionMixin.js.map +1 -0
- package/dist/lib/node/mixins/subscription/RawSubscriptionMixin.js +160 -0
- package/dist/lib/node/mixins/subscription/RawSubscriptionMixin.js.map +1 -0
- package/dist/lib/node/mixins/subscription/index.js +20 -0
- package/dist/lib/node/mixins/subscription/index.js.map +1 -0
- package/dist/lib/node/util/TimeOutWrapper.js +56 -0
- package/dist/lib/node/util/TimeOutWrapper.js.map +1 -0
- package/dist/lib/node/util/functions.js +75 -0
- package/dist/lib/node/util/functions.js.map +1 -0
- package/dist/lib/node/version.js +5 -0
- package/dist/lib/node/version.js.map +1 -0
- package/dist/lib/types/FrontgateClient.d.ts +39 -0
- package/dist/lib/types/Mdg2Client.d.ts +52 -0
- package/dist/lib/types/authentication/AbstractAuthentication.d.ts +17 -0
- package/dist/lib/types/authentication/AppAuthentication.d.ts +12 -0
- package/dist/lib/types/authentication/AuthenticationInterface.d.ts +9 -0
- package/dist/lib/types/authentication/CookieTokenAuthentication.d.ts +6 -0
- package/dist/lib/types/authentication/CookieTokenAuthenticationFactors.d.ts +7 -0
- package/dist/lib/types/authentication/TokenAuthentication.d.ts +14 -0
- package/dist/lib/types/authentication/UserCredentialAuthentication.d.ts +13 -0
- package/dist/lib/types/authentication/UserPasswordAuthentication.d.ts +14 -0
- package/dist/lib/types/authentication/index.d.ts +5 -0
- package/dist/lib/types/authentication/util/ChallengeResolver.d.ts +15 -0
- package/dist/lib/types/authentication/util/SecretGenerator.d.ts +14 -0
- package/dist/lib/types/authentication/util/index.d.ts +2 -0
- package/dist/lib/types/common/Mdg2ClientOptions.d.ts +12 -0
- package/dist/lib/types/common/constants.d.ts +11 -0
- package/dist/lib/types/common/errors.d.ts +30 -0
- package/dist/lib/types/common/functions.d.ts +11 -0
- package/dist/lib/types/common/interfaces/PtlMessage.d.ts +5 -0
- package/dist/lib/types/common/interfaces/index.d.ts +5 -0
- package/dist/lib/types/common/interfaces/observe/ObserveOptions.d.ts +5 -0
- package/dist/lib/types/common/interfaces/result/HTTPProxyRequestResult.d.ts +6 -0
- package/dist/lib/types/common/interfaces/result/HighLevelRequestResult.d.ts +6 -0
- package/dist/lib/types/common/interfaces/result/RequestResult.d.ts +5 -0
- package/dist/lib/types/common/types/Quality.d.ts +1 -0
- package/dist/lib/types/common/types/RequestQuality.d.ts +2 -0
- package/dist/lib/types/common/types/index.d.ts +2 -0
- package/dist/lib/types/compat/index.d.ts +10 -0
- package/dist/lib/types/connection/AbstractFrontgateConnection.d.ts +116 -0
- package/dist/lib/types/connection/ConnectionInterface.d.ts +53 -0
- package/dist/lib/types/connection/FrontgateWSConnection.d.ts +23 -0
- package/dist/lib/types/connection/JobPromise.d.ts +3 -0
- package/dist/lib/types/connection/LatencyHandler.d.ts +1 -0
- package/dist/lib/types/connection/LatencyTracker.d.ts +13 -0
- package/dist/lib/types/connection/MessageProcessor.d.ts +2 -0
- package/dist/lib/types/connection/index.d.ts +7 -0
- package/dist/lib/types/connection/util/Compressor.d.ts +8 -0
- package/dist/lib/types/connection/util/Encoding.d.ts +9 -0
- package/dist/lib/types/connection/util/functions.d.ts +19 -0
- package/dist/lib/types/core/RequestModule.d.ts +78 -0
- package/dist/lib/types/core/SubscriptionModule.d.ts +24 -0
- package/dist/lib/types/core/subscription/EndpointHandler.d.ts +37 -0
- package/dist/lib/types/core/subscription/SubjectManager.d.ts +21 -0
- package/dist/lib/types/index.d.ts +10 -0
- package/dist/lib/types/logger/AbstractLogger.d.ts +32 -0
- package/dist/lib/types/logger/ConsoleLogger.d.ts +14 -0
- package/dist/lib/types/logger/LoggerHelper.d.ts +4 -0
- package/dist/lib/types/logger/LoggerInterface.d.ts +12 -0
- package/dist/lib/types/logger/NullLogger.d.ts +10 -0
- package/dist/lib/types/logger/WinstonLogger.d.ts +22 -0
- package/dist/lib/types/logger/index.d.ts +6 -0
- package/dist/lib/types/message/MessageFactory.d.ts +29 -0
- package/dist/lib/types/message/guards.d.ts +11 -0
- package/dist/lib/types/message/index.d.ts +6 -0
- package/dist/lib/types/message/interfaces/HTTPProxyRequestOptions.d.ts +15 -0
- package/dist/lib/types/message/interfaces/HighLevelRequestMethod.d.ts +1 -0
- package/dist/lib/types/message/interfaces/HighLevelRequestOptions.d.ts +9 -0
- package/dist/lib/types/message/interfaces/JobObservable.d.ts +4 -0
- package/dist/lib/types/message/interfaces/index.d.ts +4 -0
- package/dist/lib/types/message/request/AbstractMdg2Request.d.ts +12 -0
- package/dist/lib/types/message/request/AuthenticationByTokenRequest.d.ts +6 -0
- package/dist/lib/types/message/request/AuthenticationRequest.d.ts +17 -0
- package/dist/lib/types/message/request/AuthenticationTokenRequest.d.ts +9 -0
- package/dist/lib/types/message/request/CancelSubscriptionRequest.d.ts +6 -0
- package/dist/lib/types/message/request/ConfigurationRequest.d.ts +14 -0
- package/dist/lib/types/message/request/HTTPProxyRequest.d.ts +28 -0
- package/dist/lib/types/message/request/HighLevelRequest.d.ts +17 -0
- package/dist/lib/types/message/request/PingRequest.d.ts +16 -0
- package/dist/lib/types/message/request/TransportLayerClientRequestHeader.d.ts +53 -0
- package/dist/lib/types/message/request/index.d.ts +9 -0
- package/dist/lib/types/message/request/raw/RawRequest.d.ts +5 -0
- package/dist/lib/types/message/request/raw/RawRequestFactory.d.ts +4 -0
- package/dist/lib/types/message/request/raw/example/CreateNotationSearchRequest.d.ts +146 -0
- package/dist/lib/types/message/request/raw/index.d.ts +2 -0
- package/dist/lib/types/message/response/AuthenticationByTokenResponse.d.ts +20 -0
- package/dist/lib/types/message/response/AuthenticationResponse.d.ts +37 -0
- package/dist/lib/types/message/response/AuthenticationTokenResponse.d.ts +8 -0
- package/dist/lib/types/message/response/CancelSubscriptionResponse.d.ts +3 -0
- package/dist/lib/types/message/response/ConfigurationResponse.d.ts +44 -0
- package/dist/lib/types/message/response/DisconnectionMessage.d.ts +7 -0
- package/dist/lib/types/message/response/ErrorResponse.d.ts +5 -0
- package/dist/lib/types/message/response/HTTPProxyResponse.d.ts +30 -0
- package/dist/lib/types/message/response/HighLevelResponse.d.ts +25 -0
- package/dist/lib/types/message/response/LoadNotificationMessage.d.ts +8 -0
- package/dist/lib/types/message/response/Mdg2Response.d.ts +11 -0
- package/dist/lib/types/message/response/PermissionDeniedResponse.d.ts +4 -0
- package/dist/lib/types/message/response/PingResponse.d.ts +13 -0
- package/dist/lib/types/message/response/RejectResponse.d.ts +5 -0
- package/dist/lib/types/message/response/index.d.ts +13 -0
- package/dist/lib/types/message/types/Time.d.ts +6 -0
- package/dist/lib/types/message/types/TransportLayerClientRequestHeaderFlag.d.ts +1 -0
- package/dist/lib/types/message/types/index.d.ts +2 -0
- package/dist/lib/types/message/update/HighLevelUpdate.d.ts +6 -0
- package/dist/lib/types/message/update/SubscriptionLossMessage.d.ts +17 -0
- package/dist/lib/types/message/update/index.d.ts +2 -0
- package/dist/lib/types/mixins/AuthTokenRequestMixin.d.ts +22 -0
- package/dist/lib/types/mixins/EndpointRequestMixin.d.ts +23 -0
- package/dist/lib/types/mixins/HTTPProxyRequestMixin.d.ts +21 -0
- package/dist/lib/types/mixins/LoggerMixin.d.ts +12 -0
- package/dist/lib/types/mixins/MessageCompressorMixin.d.ts +14 -0
- package/dist/lib/types/mixins/OpenTelemetryMixin.d.ts +20 -0
- package/dist/lib/types/mixins/ReconnectMixin.d.ts +22 -0
- package/dist/lib/types/mixins/RequestMixin.d.ts +17 -0
- package/dist/lib/types/mixins/auth/AppAuthMixin.d.ts +15 -0
- package/dist/lib/types/mixins/auth/CookieTokenAuthMixin.d.ts +13 -0
- package/dist/lib/types/mixins/auth/FetchAuthenticationMixin.d.ts +54 -0
- package/dist/lib/types/mixins/auth/SessionAuthMixin.d.ts +58 -0
- package/dist/lib/types/mixins/auth/TokenAuthMixin.d.ts +18 -0
- package/dist/lib/types/mixins/auth/UserCredentialAuthMixin.d.ts +15 -0
- package/dist/lib/types/mixins/auth/UserPasswordAuthMixin.d.ts +15 -0
- package/dist/lib/types/mixins/auth/index.d.ts +16 -0
- package/dist/lib/types/mixins/connection/FrontgateWSMixin.d.ts +67 -0
- package/dist/lib/types/mixins/connection/index.d.ts +45 -0
- package/dist/lib/types/mixins/index.d.ts +28 -0
- package/dist/lib/types/mixins/subscription/DataObserver.d.ts +43 -0
- package/dist/lib/types/mixins/subscription/EndpointSubscriptionMixin.d.ts +26 -0
- package/dist/lib/types/mixins/subscription/RawSubscriptionMixin.d.ts +27 -0
- package/dist/lib/types/mixins/subscription/index.d.ts +8 -0
- package/dist/lib/types/util/TimeOutWrapper.d.ts +12 -0
- package/dist/lib/types/util/functions.d.ts +20 -0
- package/dist/lib/types/version.d.ts +4 -0
- package/dist/lib/umd/mdg2.client.min.umd.js +12 -0
- package/dist/lib/umd/mdg2.client.umd.js +8852 -0
- package/package.json +92 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function(d,G){typeof exports=="object"&&typeof module<"u"?G(exports):typeof define=="function"&&define.amd?define(["exports"],G):(d=typeof globalThis<"u"?globalThis:d||self,G(d.fdsg={}))})(this,function(d){"use strict";var Ls=d=>{throw TypeError(d)};var lr=(d,G,Q)=>G.has(d)||Ls("Cannot "+Q);var v=(d,G,Q)=>(lr(d,G,"read from private field"),Q?Q.call(d):G.get(d)),O=(d,G,Q)=>G.has(d)?Ls("Cannot add the same private member more than once"):G instanceof WeakSet?G.add(d):G.set(d,Q),C=(d,G,Q,it)=>(lr(d,G,"write to private field"),it?it.call(d,Q):G.set(d,Q),Q),H=(d,G,Q)=>(lr(d,G,"access private method"),Q);var Hs=(d,G,Q,it)=>({set _(Pt){C(d,G,Pt,Q)},get _(){return v(d,G,it)}});var Le,It,At,He,qe,Ge,Oe,ke,ae,Ks,Qs,Xs,Zs,eo;class Pt{constructor(e,t=-1){if(!Number.isInteger(e))throw new TypeError(`idApplication is not an integer number. Given: ${e} (${typeof e})`);if(this.idApplication=e,!Number.isInteger(t))throw new TypeError(`idUser is not an integer number. Given: ${t} (${typeof t})`);this.idUser=t}peerInfoFromMessage(e){if(e.Message==="Foundation::DisconnectionMessage"){const t=e;throw new Error(`Disconnection Message: ${t.details}`)}if(e.Message==="Foundation::AuthenticationByTokenResponse"||e.Message==="Foundation::ConfigurationResponse"){const t=e;return this.serverInfo=this.parseServerInfo(t),{uuid:t.server_info.uuid,description:t.server_info.description,software:t.server_info.software,os:t.server_info.os,maximumIdleInterval:parseInt(t.maximum_idle_interval,10),maximumReceivableMessageSize:t.maximum_receivable_message_size}}throw new Error("Could not extract server_info from unknown message type.")}parseServerInfo(e){const t=e,r=Number(BigInt(t.time_at_server.microseconds))/1e3,s=Math.ceil(Date.now()-r);return{description:t.server_info.description,software:t.server_info.software,os:t.server_info.os,time:new Date(r),offsetInMs:s}}getServerInfo(){return this.serverInfo}}var m=(n=>(n[n.TRACE=10]="TRACE",n[n.DEBUG=20]="DEBUG",n[n.INFO=30]="INFO",n[n.WARN=40]="WARN",n[n.ERROR=50]="ERROR",n[n.FATAL=60]="FATAL",n[n.SILENT=100]="SILENT",n))(m||{});const Ce=class Ce{constructor(e=""){this.defaultLevel=40,this.noop=()=>null,this.name=e,this.setDefaultLevelFromLocalStorage(),Object.assign(Ce.loggers,{[e]:this})}getName(){return this.name}setLevel(e){this.level=e}getLevel(){return typeof this.level=="number"&&isFinite(this.level)&&Math.floor(this.level)===this.level?this.level:this.defaultLevel}shouldLog(e){switch(this.getLevel()){case 100:return!1;case 60:return e==="fatal";case 50:return e==="fatal"||e==="error";case 40:return e==="fatal"||e==="error"||e==="warn";case 30:return e==="fatal"||e==="error"||e==="warn"||e==="info";case 20:return e==="fatal"||e==="error"||e==="warn"||e==="info"||e==="debug";case 10:default:return!0}}setDefaultLevelFromLocalStorage(){let e;try{if(!(typeof localStorage=="object"))return;const r=localStorage.getItem("loglevel");if(!r)return;e=r}catch{return}e&&this.setLevel(Ce.getLogLevel(e))}static getLogLevel(e){const t=e.toLowerCase();switch(t){case"silent":return 100;case"fatal":return 60;case"error":return 50;case"warn":return 40;case"info":return 30;case"debug":return 20;case"trace":return 10;default:throw new Error(`Invalid log level: ${t}`)}}static getLogger(e,t){if(Object.prototype.hasOwnProperty.call(Ce.loggers,e))return Ce.loggers[e];const r=new t(e);return Ce.loggers[e]=r,r}};Ce.loggers={};let Ee=Ce;class to{static getLogLevel(e){const t=e.toLowerCase();switch(t){case"silent":return m.SILENT;case"fatal":return m.FATAL;case"error":return m.ERROR;case"warn":return m.WARN;case"info":return m.INFO;case"debug":return m.DEBUG;case"trace":return m.TRACE;default:throw new Error(`Invalid log level: ${t}`)}}}class un extends Ee{constructor(){super(...arguments),this.trace=this.getLogMethod("trace"),this.debug=this.getLogMethod("debug"),this.info=this.getLogMethod("info"),this.warn=this.getLogMethod("warn"),this.error=this.getLogMethod("error"),this.fatal=this.getLogMethod("fatal")}setLevel(e){this.level=e,this.trace=this.getLogMethod("trace"),this.debug=this.getLogMethod("debug"),this.info=this.getLogMethod("info"),this.warn=this.getLogMethod("warn"),this.error=this.getLogMethod("error"),this.fatal=this.getLogMethod("fatal")}getLogMethod(e){if(this.shouldLog(e)){const t=e==="debug"||e==="fatal"?"log":e,r=this.name?`${this.name}: [${e.toUpperCase()}] `:`-----> [${e.toUpperCase()}] `;return Function.prototype.bind.call(console[t],console,r)}return this.noop}static getLogger(e=""){return super.getLogger(e,un)}}const no={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};class ro extends Ee{constructor(e,t=""){super(t),this.name=t,this.logger=e,this.trace=Function.prototype.bind.call(e.trace,e),this.debug=Function.prototype.bind.call(e.debug,e),this.info=Function.prototype.bind.call(e.info,e),this.warn=Function.prototype.bind.call(e.warn,e),this.error=Function.prototype.bind.call(e.error,e),this.fatal=Function.prototype.bind.call(e.error,e)}setLevel(e){this.level=e,this.logger&&(this.logger.level=m[e].toLowerCase())}static getLogger(e=""){return Object.prototype.hasOwnProperty.call(Ee.loggers,e)?Ee.loggers[e]:null}}class at extends Ee{constructor(){super(...arguments),this.trace=this.noop,this.debug=this.noop,this.info=this.noop,this.warn=this.noop,this.error=this.noop}static getLogger(e=""){return super.getLogger(e,at)}}var q=Uint8Array,te=Uint16Array,hn=Int32Array,Nt=new q([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]),jt=new q([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]),ln=new q([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gr=function(n,e){for(var t=new te(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];for(var s=new hn(t[30]),r=1;r<30;++r)for(var o=t[r];o<t[r+1];++o)s[o]=o-t[r]<<5|r;return{b:t,r:s}},vr=gr(Nt,2),br=vr.b,fn=vr.r;br[28]=258,fn[258]=28;for(var mr=gr(jt,0),so=mr.b,yr=mr.r,dn=new te(32768),U=0;U<32768;++U){var Te=(U&43690)>>1|(U&21845)<<1;Te=(Te&52428)>>2|(Te&13107)<<2,Te=(Te&61680)>>4|(Te&3855)<<4,dn[U]=((Te&65280)>>8|(Te&255)<<8)>>1}for(var de=function(n,e,t){for(var r=n.length,s=0,o=new te(e);s<r;++s)n[s]&&++o[n[s]-1];var i=new te(e);for(s=1;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;var a;if(t){a=new te(1<<e);var c=15-e;for(s=0;s<r;++s)if(n[s])for(var h=s<<4|n[s],u=e-n[s],l=i[n[s]-1]++<<u,b=l|(1<<u)-1;l<=b;++l)a[dn[l]>>c]=h}else for(a=new te(r),s=0;s<r;++s)n[s]&&(a[s]=dn[i[n[s]-1]++]>>15-n[s]);return a},Me=new q(288),U=0;U<144;++U)Me[U]=8;for(var U=144;U<256;++U)Me[U]=9;for(var U=256;U<280;++U)Me[U]=7;for(var U=280;U<288;++U)Me[U]=8;for(var ct=new q(32),U=0;U<32;++U)ct[U]=5;var oo=de(Me,9,0),io=de(Me,9,1),ao=de(ct,5,0),co=de(ct,5,1),pn=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},ce=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(e&7)&t},gn=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},vn=function(n){return(n+7)/8|0},Ne=function(n,e,t){return(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length),new q(n.subarray(e,t))},uo=["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"],W=function(n,e,t){var r=new Error(e||uo[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,W),!t)throw r;return r},ho=function(n,e,t,r){var s=n.length,o=0;if(!s||e.f&&!e.l)return t||new q(0);var i=!t,a=i||e.i!=2,c=e.i;i&&(t=new q(s*3));var h=function(Ct){var Ot=t.length;if(Ct>Ot){var ot=new q(Math.max(Ot*2,Ct));ot.set(t),t=ot}},u=e.f||0,l=e.p||0,b=e.b||0,f=e.l,w=e.d,y=e.m,M=e.n,D=s*8;do{if(!f){u=ce(n,l,1);var E=ce(n,l+1,3);if(l+=3,E)if(E==1)f=io,w=co,y=9,M=5;else if(E==2){var S=ce(n,l,31)+257,P=ce(n,l+10,15)+4,g=S+ce(n,l+5,31)+1;l+=14;for(var p=new q(g),_=new q(19),I=0;I<P;++I)_[ln[I]]=ce(n,l+I*3,7);l+=P*3;for(var x=pn(_),z=(1<<x)-1,k=de(_,x,1),I=0;I<g;){var F=k[ce(n,l,z)];l+=F&15;var A=F>>4;if(A<16)p[I++]=A;else{var N=0,L=0;for(A==16?(L=3+ce(n,l,3),l+=2,N=p[I-1]):A==17?(L=3+ce(n,l,7),l+=3):A==18&&(L=11+ce(n,l,127),l+=7);L--;)p[I++]=N}}var V=p.subarray(0,S),$=p.subarray(S);y=pn(V),M=pn($),f=de(V,y,1),w=de($,M,1)}else W(1);else{var A=vn(l)+4,T=n[A-4]|n[A-3]<<8,R=A+T;if(R>s){c&&W(0);break}a&&h(b+T),t.set(n.subarray(A,R),b),e.b=b+=T,e.p=l=R*8,e.f=u;continue}if(l>D){c&&W(0);break}}a&&h(b+131072);for(var Be=(1<<y)-1,ee=(1<<M)-1,fe=l;;fe=l){var N=f[gn(n,l)&Be],Y=N>>4;if(l+=N&15,l>D){c&&W(0);break}if(N||W(2),Y<256)t[b++]=Y;else if(Y==256){fe=l,f=null;break}else{var J=Y-254;if(Y>264){var I=Y-257,j=Nt[I];J=ce(n,l,(1<<j)-1)+br[I],l+=j}var ie=w[gn(n,l)&ee],me=ie>>4;ie||W(3),l+=ie&15;var $=so[me];if(me>3){var j=jt[me];$+=gn(n,l)&(1<<j)-1,l+=j}if(l>D){c&&W(0);break}a&&h(b+131072);var Pe=b+J;if(b<$){var _e=o-$,Je=Math.min($,Pe);for(_e+b<0&&W(3);b<Je;++b)t[b]=r[_e+b]}for(;b<Pe;++b)t[b]=t[b-$]}}e.l=f,e.p=fe,e.b=b,e.f=u,f&&(u=1,e.m=y,e.d=w,e.n=M)}while(!u);return b!=t.length&&i?Ne(t,0,b):t.subarray(0,b)},ye=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8},ut=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8,n[r+2]|=t>>16},bn=function(n,e){for(var t=[],r=0;r<n.length;++r)n[r]&&t.push({s:r,f:n[r]});var s=t.length,o=t.slice();if(!s)return{t:Tr,l:0};if(s==1){var i=new q(t[0].s+1);return i[t[0].s]=1,{t:i,l:1}}t.sort(function(R,S){return R.f-S.f}),t.push({s:-1,f:25001});var a=t[0],c=t[1],h=0,u=1,l=2;for(t[0]={s:-1,f:a.f+c.f,l:a,r:c};u!=s-1;)a=t[t[h].f<t[l].f?h++:l++],c=t[h!=u&&t[h].f<t[l].f?h++:l++],t[u++]={s:-1,f:a.f+c.f,l:a,r:c};for(var b=o[0].s,r=1;r<s;++r)o[r].s>b&&(b=o[r].s);var f=new te(b+1),w=mn(t[u-1],f,0);if(w>e){var r=0,y=0,M=w-e,D=1<<M;for(o.sort(function(S,P){return f[P.s]-f[S.s]||S.f-P.f});r<s;++r){var E=o[r].s;if(f[E]>e)y+=D-(1<<w-f[E]),f[E]=e;else break}for(y>>=M;y>0;){var A=o[r].s;f[A]<e?y-=1<<e-f[A]++-1:++r}for(;r>=0&&y;--r){var T=o[r].s;f[T]==e&&(--f[T],++y)}w=e}return{t:new q(f),l:w}},mn=function(n,e,t){return n.s==-1?Math.max(mn(n.l,e,t+1),mn(n.r,e,t+1)):e[n.s]=t},wr=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new te(++e),r=0,s=n[0],o=1,i=function(c){t[r++]=c},a=1;a<=e;++a)if(n[a]==s&&a!=e)++o;else{if(!s&&o>2){for(;o>138;o-=138)i(32754);o>2&&(i(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(i(s),--o;o>6;o-=6)i(8304);o>2&&(i(o-3<<5|8208),o=0)}for(;o--;)i(s);o=1,s=n[a]}return{c:t.subarray(0,r),n:e}},ht=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},_r=function(n,e,t){var r=t.length,s=vn(e+2);n[s]=r&255,n[s+1]=r>>8,n[s+2]=n[s]^255,n[s+3]=n[s+1]^255;for(var o=0;o<r;++o)n[s+o+4]=t[o];return(s+4+r)*8},Er=function(n,e,t,r,s,o,i,a,c,h,u){ye(e,u++,t),++s[256];for(var l=bn(s,15),b=l.t,f=l.l,w=bn(o,15),y=w.t,M=w.l,D=wr(b),E=D.c,A=D.n,T=wr(y),R=T.c,S=T.n,P=new te(19),g=0;g<E.length;++g)++P[E[g]&31];for(var g=0;g<R.length;++g)++P[R[g]&31];for(var p=bn(P,7),_=p.t,I=p.l,x=19;x>4&&!_[ln[x-1]];--x);var z=h+5<<3,k=ht(s,Me)+ht(o,ct)+i,F=ht(s,b)+ht(o,y)+i+14+3*x+ht(P,_)+2*P[16]+3*P[17]+7*P[18];if(c>=0&&z<=k&&z<=F)return _r(e,u,n.subarray(c,c+h));var N,L,V,$;if(ye(e,u,1+(F<k)),u+=2,F<k){N=de(b,f,0),L=b,V=de(y,M,0),$=y;var Be=de(_,I,0);ye(e,u,A-257),ye(e,u+5,S-1),ye(e,u+10,x-4),u+=14;for(var g=0;g<x;++g)ye(e,u+3*g,_[ln[g]]);u+=3*x;for(var ee=[E,R],fe=0;fe<2;++fe)for(var Y=ee[fe],g=0;g<Y.length;++g){var J=Y[g]&31;ye(e,u,Be[J]),u+=_[J],J>15&&(ye(e,u,Y[g]>>5&127),u+=Y[g]>>12)}}else N=oo,L=Me,V=ao,$=ct;for(var g=0;g<a;++g){var j=r[g];if(j>255){var J=j>>18&31;ut(e,u,N[J+257]),u+=L[J+257],J>7&&(ye(e,u,j>>23&31),u+=Nt[J]);var ie=j&31;ut(e,u,V[ie]),u+=$[ie],ie>3&&(ut(e,u,j>>5&8191),u+=jt[ie])}else ut(e,u,N[j]),u+=L[j]}return ut(e,u,N[256]),u+L[256]},lo=new hn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Tr=new q(0),fo=function(n,e,t,r,s,o){var i=o.z||n.length,a=new q(r+i+5*(1+Math.ceil(i/7e3))+s),c=a.subarray(r,a.length-s),h=o.l,u=(o.r||0)&7;if(e){u&&(c[0]=o.r>>3);for(var l=lo[e-1],b=l>>13,f=l&8191,w=(1<<t)-1,y=o.p||new te(32768),M=o.h||new te(w+1),D=Math.ceil(t/3),E=2*D,A=function(hr){return(n[hr]^n[hr+1]<<D^n[hr+2]<<E)&w},T=new hn(25e3),R=new te(288),S=new te(32),P=0,g=0,p=o.i||0,_=0,I=o.w||0,x=0;p+2<i;++p){var z=A(p),k=p&32767,F=M[z];if(y[k]=F,M[z]=k,I<=p){var N=i-p;if((P>7e3||_>24576)&&(N>423||!h)){u=Er(n,c,0,T,R,S,g,_,x,p-x,u),_=P=g=0,x=p;for(var L=0;L<286;++L)R[L]=0;for(var L=0;L<30;++L)S[L]=0}var V=2,$=0,Be=f,ee=k-F&32767;if(N>2&&z==A(p-ee))for(var fe=Math.min(b,N)-1,Y=Math.min(32767,p),J=Math.min(258,N);ee<=Y&&--Be&&k!=F;){if(n[p+V]==n[p+V-ee]){for(var j=0;j<J&&n[p+j]==n[p+j-ee];++j);if(j>V){if(V=j,$=ee,j>fe)break;for(var ie=Math.min(ee,j-2),me=0,L=0;L<ie;++L){var Pe=p-ee+L&32767,_e=y[Pe],Je=Pe-_e&32767;Je>me&&(me=Je,F=Pe)}}}k=F,F=y[k],ee+=k-F&32767}if($){T[_++]=268435456|fn[V]<<18|yr[$];var Ct=fn[V]&31,Ot=yr[$]&31;g+=Nt[Ct]+jt[Ot],++R[257+Ct],++S[Ot],I=p+V,++P}else T[_++]=n[p],++R[n[p]]}}for(p=Math.max(p,I);p<i;++p)T[_++]=n[p],++R[n[p]];u=Er(n,c,h,T,R,S,g,_,x,p-x,u),h||(o.r=u&7|c[u/8|0]<<3,u-=7,o.h=M,o.p=y,o.i=p,o.w=I)}else{for(var p=o.w||0;p<i+h;p+=65535){var ot=p+65535;ot>=i&&(c[u/8|0]=h,ot=i),u=_r(c,u+1,n.subarray(p,ot))}o.i=i}return Ne(a,0,r+vn(u)+s)},Mr=function(){var n=1,e=0;return{p:function(t){for(var r=n,s=e,o=t.length|0,i=0;i!=o;){for(var a=Math.min(i+2655,o);i<a;++i)s+=r+=t[i];r=(r&65535)+15*(r>>16),s=(s&65535)+15*(s>>16)}n=r,e=s},d:function(){return n%=65521,e%=65521,(n&255)<<24|(n&65280)<<8|(e&255)<<8|e>>8}}},Sr=function(n,e,t,r,s){if(!s&&(s={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),i=new q(o.length+n.length);i.set(o),i.set(n,o.length),n=i,s.w=o.length}return fo(n,e.level==null?6:e.level,e.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+e.mem,t,r,s)},Ir=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},po=function(n,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(n[0]=120,n[1]=r<<6|(e.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,e.dictionary){var s=Mr();s.p(e.dictionary),Ir(n,2,s.d())}},go=function(n,e){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&W(6,"invalid zlib data"),(n[1]>>5&1)==+!e&&W(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2},yn=function(){function n(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 q(98304),this.o.dictionary){var r=this.o.dictionary.subarray(-32768);this.b.set(r,32768-r.length),this.s.i=32768-r.length}}return n.prototype.p=function(e,t){this.ondata(Sr(e,this.o,0,0,this.s),t)},n.prototype.push=function(e,t){this.ondata||W(5),this.s.l&&W(4);var r=e.length+this.s.z;if(r>this.b.length){if(r>2*this.b.length-32768){var s=new q(r&-32768);s.set(this.b.subarray(0,this.s.z)),this.b=s}var o=this.b.length-this.s.z;this.b.set(e.subarray(0,o),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(o),32768),this.s.z=e.length-o+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=t&1,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},n.prototype.flush=function(){this.ondata||W(5),this.s.l&&W(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},n}(),wn=function(){function n(e,t){typeof e=="function"&&(t=e,e={}),this.ondata=t;var r=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new q(32768),this.p=new q(0),r&&this.o.set(r)}return n.prototype.e=function(e){if(this.ondata||W(5),this.d&&W(4),!this.p.length)this.p=e;else if(e.length){var t=new q(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},n.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,r=ho(this.p,this.s,this.o);this.ondata(Ne(r,t,this.s.b),this.d),this.o=Ne(r,this.s.b-32768),this.s.b=this.o.length,this.p=Ne(this.p,this.s.p/8|0),this.s.p&=7},n.prototype.push=function(e,t){this.e(e),this.c(t)},n}(),vo=function(){function n(e,t){this.c=Mr(),this.v=1,yn.call(this,e,t)}return n.prototype.push=function(e,t){this.c.p(e),yn.prototype.push.call(this,e,t)},n.prototype.p=function(e,t){var r=Sr(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(po(r,this.o),this.v=0),t&&Ir(r,r.length-4,this.c.d()),this.ondata(r,t)},n.prototype.flush=function(){yn.prototype.flush.call(this)},n}(),bo=function(){function n(e,t){wn.call(this,e,t),this.v=e&&e.dictionary?2:1}return n.prototype.push=function(e,t){if(wn.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(go(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&W(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),wn.prototype.c.call(this,t)},n}(),Ar=typeof TextEncoder<"u"&&new TextEncoder,_n=typeof TextDecoder<"u"&&new TextDecoder,mo=0;try{_n.decode(Tr,{stream:!0}),mo=1}catch{}var yo=function(n){for(var e="",t=0;;){var r=n[t++],s=(r>127)+(r>223)+(r>239);if(t+s>n.length)return{s:e,r:Ne(n,t-1)};s?s==3?(r=((r&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):s&1?e+=String.fromCharCode((r&31)<<6|n[t++]&63):e+=String.fromCharCode((r&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(r)}};function wo(n,e){var t;if(Ar)return Ar.encode(n);for(var r=n.length,s=new q(n.length+(n.length>>1)),o=0,i=function(h){s[o++]=h},t=0;t<r;++t){if(o+5>s.length){var a=new q(o+8+(r-t<<1));a.set(s),s=a}var c=n.charCodeAt(t);c<128||e?i(c):c<2048?(i(192|c>>6),i(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|n.charCodeAt(++t)&1023,i(240|c>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|c&63)):(i(224|c>>12),i(128|c>>6&63),i(128|c&63))}return Ne(s,0,o)}function _o(n,e){var t;if(_n)return _n.decode(n);var r=yo(n),s=r.s,t=r.r;return t.length&&W(8),s}const Eo=n=>{if(n.length===1)return n[0];const e=new Uint8Array(n.reduce((t,r)=>t+r.length,0));for(let t=0,r=0;t<n.length;++t)e.set(n[t],r),r+=n[t].length;return e};class Rr{constructor(){this.reset()}reset(){this.compressor=null,this.decompressor=null}compress(e){this.compressor||(this.compressor=new vo({mem:4}));const t=[];return this.compressor.ondata=r=>{t.push(r)},this.compressor.push(wo(e)),this.compressor.flush(),Eo(t)}decompress(e){this.decompressor||(this.decompressor=new bo);let t;this.decompressor.ondata=r=>{t=r};try{if(this.decompressor.push(e),t===void 0)throw new Error("invalid block type")}catch(r){throw new Error(`Decompression error: ${r.message}, length: ${e.length}, data: [${e.toString()}]`)}return _o(t)}}const we=class we{static isSupportedEncoding(e){return we.SUPPORTED_ENCODINGS.includes(e)}static isPlainJson(e){return we.PLAIN_JSON_ENCODINGS.includes(e)}static isCompressedJson(e){return we.COMPRESSED_ENCODINGS.includes(e)}};we.SUPPORTED_ENCODINGS=["jsjson-v2","jsjsonc-v2"],we.PLAIN_JSON_ENCODINGS=["jsjson-v2"],we.COMPRESSED_ENCODINGS=we.SUPPORTED_ENCODINGS.filter(e=>e.includes("jsonc"));let Se=we;const To="Mdg2Client",Cr="BST",En=6e3,Or=3e3,Mo=9e3,kr=3,So=!1,Io=9e3,Pr=!1,Nr=512;function Ao(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ro=function(e){return Co(e)&&!Oo(e)};function Co(n){return!!n&&typeof n=="object"}function Oo(n){var e=Object.prototype.toString.call(n);return e==="[object RegExp]"||e==="[object Date]"||No(n)}var ko=typeof Symbol=="function"&&Symbol.for,Po=ko?Symbol.for("react.element"):60103;function No(n){return n.$$typeof===Po}function jo(n){return Array.isArray(n)?[]:{}}function lt(n,e){return e.clone!==!1&&e.isMergeableObject(n)?We(jo(n),n,e):n}function Do(n,e,t){return n.concat(e).map(function(r){return lt(r,t)})}function xo(n,e){if(!e.customMerge)return We;var t=e.customMerge(n);return typeof t=="function"?t:We}function Fo(n){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(n).filter(function(e){return Object.propertyIsEnumerable.call(n,e)}):[]}function jr(n){return Object.keys(n).concat(Fo(n))}function Dr(n,e){try{return e in n}catch{return!1}}function Uo(n,e){return Dr(n,e)&&!(Object.hasOwnProperty.call(n,e)&&Object.propertyIsEnumerable.call(n,e))}function $o(n,e,t){var r={};return t.isMergeableObject(n)&&jr(n).forEach(function(s){r[s]=lt(n[s],t)}),jr(e).forEach(function(s){Uo(n,s)||(Dr(n,s)&&t.isMergeableObject(e[s])?r[s]=xo(s,t)(n[s],e[s],t):r[s]=lt(e[s],t))}),r}function We(n,e,t){t=t||{},t.arrayMerge=t.arrayMerge||Do,t.isMergeableObject=t.isMergeableObject||Ro,t.cloneUnlessOtherwiseSpecified=lt;var r=Array.isArray(e),s=Array.isArray(n),o=r===s;return o?r?t.arrayMerge(n,e,t):$o(n,e,t):lt(e,t)}We.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,s){return We(r,s,t)},{})};var Lo=We,Ho=Lo;const xr=Ao(Ho);class qo extends Error{constructor(e="Service Unavailable",t){super(e,{cause:t}),this.name="ServiceUnavailableError",this.code=503}}class Go extends Error{constructor(e="Internal Server Error",t){super(e,{cause:t}),this.name="InternalServerError",this.code=500}}class Fr extends Error{constructor(e="Timeout",t){super(e,{cause:t}),this.name="TimeoutError",this.code=408}}class Bo extends Error{constructor(e="Unauthorized",t){super(e,{cause:t}),this.name="UnauthorizedError",this.code=401}}class Jo extends Error{constructor(e="Bad Request",t){super(e,{cause:t}),this.name="BadRequestError",this.code=400}}class Wo extends Error{constructor(e,t){super(e,{cause:t}),this.name="ResponseError",this.response=t}}function zo(n){return!!n&&typeof n=="object"}function Vo(...n){const e=n.filter(zo);return xr.all(e,{arrayMerge:(t,r)=>r})}function Tn(n){return n.replace(/[=]/g,"").replace(/\//g,"_").replace(/\+/g,"-")}function Yo(n){return/^[A-Za-z0-9_-]*$/.test(n)}function Ko(n){let e=n.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";switch(e.length%4){case 0:break;case 1:e+="===";break;case 2:e+="==";break;case 3:e+="=";break}return e}const Mn=n=>{var r,s,o,i;let e="Unknown",t=500;if(n.name==="Foundation::PermissionDeniedResponse")t=403,e=`Permission Denied. Job ID: ${n.jobId} failed with status code ${t} `;else if(n.name==="Foundation::ErrorResponse"&&n.reason){const a=n.reason.startsWith("{"),c=a?JSON.parse(n.reason)||{}:n.reason;a&&((r=c.errors)!=null&&r[0].details)?e=c.errors[0].details:typeof c=="string"&&(e=c),t=parseInt(((o=(s=c==null?void 0:c.meta)==null?void 0:s.status)==null?void 0:o.code)??((i=n.msg.reason)==null?void 0:i.value)??500,10)}return new Wo(`${e} (${t})`,n)},Qo=async n=>new Promise(e=>{setTimeout(e,n)}),Xo=()=>typeof window>"u",tt=class tt{constructor(){this._timeAtSender=Date.now()}getPtlMessage(){return{Message:tt.NAME,Version:tt.VERSION,time_at_sender:{microseconds:this._timeAtSender*1e3}}}resetTimeAtSender(){this._timeAtSender=Date.now()}get timeAtSender(){return this._timeAtSender}};tt.NAME="PingRequest",tt.VERSION=3;let ft=tt;var Ur=(n=>(n.MAXIMUM_STRING="9223372036854775807",n.MINIMUM_STRING="-9223372036854775807",n))(Ur||{});function Dt(n){return n.toString().slice(0,-3)}const nt=class nt{constructor(e){if(e.Message!==nt.NAME)throw new Error(`Unsupported message=${e.Message}`);if(e.Version!==nt.VERSION)throw new Error(`Unsupported version=${e.Version} for message=${e.Message}`);this._timeReceivedResponse=Date.now(),this._timeAtSender=Number(Dt(e.time_at_sender.microseconds)),this._timeFromRequest=Number(Dt(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}};nt.NAME="Foundation::PingResponse",nt.VERSION=2;let ze=nt;var Ie=(n=>(n[n.DISCONNECTED=0]="DISCONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.AUTHENTICATED=2]="AUTHENTICATED",n[n.RECONNECTING=3]="RECONNECTING",n))(Ie||{}),$r=(n=>(n[n.production=40]="production",n[n.preproduction=35]="preproduction",n[n.show=30]="show",n[n.testing=20]="testing",n))($r||{}),Lr=(n=>(n.production="frontgate-eu.factsetdigitalsolutions.com",n.show="frontgate-eu.show.factsetdigitalsolutions.com",n))(Lr||{});const sn=class sn{constructor(e,t){if(this.reconnectDelays=[1e3,2e3,4e3,8e3,16e3,32e3],this.reconnectCounter=0,this.connectionCounter=0,this.onConnect=null,this.onMessage=null,this.onClose=null,this.onError=null,this.onAuthentication=null,this.onCleanupRequests=null,this.onCleanupSubscriptions=null,this.onClearPendingSubscription=null,this.onReceiveTimeout=null,this.restartSubscriptions=null,this.options={...sn.DEFAULT_OPTIONS,...t},this.auth=e,this.state=0,this.options.logger&&(this.logger=this.options.logger),this.timestampOfLastMessageSent=0,this.jobId=0,this.peerInfo=null,this.compressor=new Rr,this.keepAliveIntervalHandle=null,this.hasActiveSession=!1,this.options.loglevel&&this.logger.setLevel(this.options.loglevel),!Se.isSupportedEncoding(this.options.encoding))throw new Error(`Unknown or unsupported encoding: ${this.options.encoding}`);this.messageProcessors={},this.setMessageProcessor("Foundation::LoadNotificationMessage",this.handleLoadNotificationMessage.bind(this)),this.setMessageProcessor("Foundation::KeepAliveMessage",this.handleKeepAliveMessage.bind(this)),this.setMessageProcessor("Foundation::PingResponse",this.handlePingResponseMessage.bind(this)),this.setMessageProcessor("Foundation::DisconnectionMessage",this.handleDisconnectionMessage.bind(this))}setMessageProcessor(e,t){this.messageProcessors[e]=t}removeMessageProcessor(e){this.messageProcessors[e]!==void 0&&(this.messageProcessors[e]=void 0)}async close(){if(!this.isAuthenticated()){this.logger.warn("Cannot close gracefully. Connection not open. Proceeding to handleClose."),await this.handleClose("Unauthenticated connection");return}try{await this.sendDisconnectionMessage()}catch(e){await this.handleClose(e.message)}}setPeerInfo(e){this.peerInfo={...this.peerInfo,...e}}isAuthenticated(){return this.state===2}isConnecting(){return this.state===1}clearPendingConnection(){this.pendingConnection=null}isPendingConnection(){return this.pendingConnection instanceof Promise}handleLoadNotificationMessage(e){return this.peerInfo&&(this.peerInfo.loadStatus=e.load),!1}handleKeepAliveMessage(){return!1}handlePingResponseMessage(e){const t=new ze(e);return this.logger.debug(`Time in ms: Request=${t.timeOfRequest} Peer=${t.timeAtPeer} Response=${t.timeOfResponse}`),this.logger.debug(`Latency in ms: Total=${t.latencyTotal} Peer=${t.latencyAtPeer}`),!1}async handleDisconnectionMessage(e){await this.handleClose(`DisconnectionMessage received: '${e.details}`),this.onClose&&this.onClose(e.details)}handleAuthentication(){this.state=2;const e=1e3;this.keepAliveIntervalHandle=setInterval(()=>{this.sendKeepAliveMessage()},e),this.onAuthentication&&this.onAuthentication()}handleReceiveTimeout(){this.messageReceiveTimeout&&clearTimeout(this.messageReceiveTimeout),this.onReceiveTimeout&&this.onReceiveTimeout()}resetReceiveTimeout(){var t;if(!((t=this.peerInfo)!=null&&t.maximumIdleInterval))return;const e=this.peerInfo.maximumIdleInterval/1e3*2;this.messageReceiveTimeout&&clearTimeout(this.messageReceiveTimeout),this.messageReceiveTimeout=setTimeout(()=>{this.handleReceiveTimeout()},e)}handleStandardMessage(e){return this.onMessage&&this.onMessage(e),!0}handleMessage(e){if(!e.Message)return;this.resetReceiveTimeout();const t=this.messageProcessors[e.Message];if(t!==void 0){if(!t(e))return}else this.handleStandardMessage(e);return e}async handleClose(e){if(typeof e=="string")this.logger.warn(`Handling connection close event. Reason: ${e}`);else{const{code:s,reason:o,wasClean:i,type:a}=e;this.logger.warn("Handling connection close event.",{code:s,reason:o,wasClean:i,type:a})}this.onCleanupRequests&&this.onCleanupRequests(),!this.shouldRestartSubscriptions&&this.onCleanupSubscriptions&&this.onCleanupSubscriptions(),this.keepAliveIntervalHandle&&(clearInterval(this.keepAliveIntervalHandle),this.keepAliveIntervalHandle=null),this.state=0,this.compressor.reset(),this.peerInfo=null,this.messageReceiveTimeout&&(clearTimeout(this.messageReceiveTimeout),this.messageReceiveTimeout=null),typeof e=="string"&&e.includes("DisconnectionMessage")&&(this.logger.debug("Disconnect message received. Preventing reconnect. Potential authentication failure."),this.options.shouldReconnectOnConnectionLoss=!1),this.auth.reconnectable&&this.options.shouldReconnectOnConnectionLoss?(this.onMessage=null,await this.reconnect()):(this.onClose&&this.onClose(e),this.onMessage=null,this.onClose=null,this.onError=null)}async reconnect(){for(;!this.isAuthenticated();){this.compressor.reset(),this.peerInfo=null,this.state=3;try{const e=this.reconnectDelays.length-1;let t=this.reconnectDelays[this.reconnectCounter]??this.reconnectDelays[e];t+=Math.floor(Math.random()*50);const r=this.reconnectCounter?`(${this.reconnectCounter} attempts)`:"";this.logger.warn(`Trying to reconnect. Waiting ${t} ms ${r}`),this.reconnectCounter++,await this.open(t),this.shouldRestartSubscriptions&&this.restartSubscriptions&&this.restartSubscriptions()}catch(e){this.logger.error("Failed to reconnect",e)}}this.reconnectCounter=0}handleWsError(e){this.close().then(()=>{this.logger.error("Connection closed due to WebSocket error")}),this.logger.error("WebSocket error: ",e),this.onError&&this.onError(e)}preSubmit(e){if(e.Message){const t=this.returnAndAssignJobIdToMessage(e);return this.logger.trace("PreSubmit",{message:e.Message,jobId:t}),t}throw new TypeError("Expected message type. Must be JSON message object or Array of JSON message objects")}async sendKeepAliveMessage(){const e=Date.now()-this.timestampOfLastMessageSent,t=this.options.maximum_idle_interval/1e3/2;if(!(this.timestampOfLastMessageSent>0&&e>t))return;const s=this.options.enablePingPongKeepalive??Xo()?new ft().getPtlMessage():{Message:"KeepAliveMessage",Version:2};await this.submit(s)}async sendDisconnectionMessage(e="client shutdown",t=64){const r={Message:"Foundation::DisconnectionMessage",Version:3,reason:{value:t},details:e};await this.submit(r),await this.handleClose("Disconnected by User.")}returnAndAssignJobIdToMessage(e){if(typeof e!="object")throw new TypeError(`expected object, not ${typeof e}`);if(typeof e.Message>"u")throw new TypeError("expected object to have a 'Message' member");return!/Request$/.exec(e.Message)||typeof e.header>"u"?null:(e.header.id_job||(this.jobId=this.jobId>=Number.MAX_SAFE_INTEGER?1:this.jobId+1,e.header.id_job=this.jobId),e.header.id_job)}setLogger(e){this.logger=e}};sn.DEFAULT_OPTIONS={payload_content:"foundation",deployment_stage:30,logger:at.getLogger(To),loglevel:m.WARN,maximum_idle_interval:45e6,host:"frontgate-eu.show.factsetdigitalsolutions.com",port:443,tls:!0,path_prefix:"",encoding:"jsjsonc-v2",split_authentication_token_second_factor:void 0,shouldReconnectOnConnectionLoss:!0,connectionTimeoutInMs:Mo,sessionHandling:!1};let xt=sn;var pe=null;typeof WebSocket<"u"?pe=WebSocket:typeof MozWebSocket<"u"?pe=MozWebSocket:typeof global<"u"?pe=global.WebSocket||global.MozWebSocket:typeof window<"u"?pe=window.WebSocket||window.MozWebSocket:typeof self<"u"&&(pe=self.WebSocket||self.MozWebSocket);class Ve{constructor(){this.promiseFinally=async(e,t)=>{const r=o=>(t(),o),s=async o=>(t(),Promise.reject(o));return Promise.resolve(e).then(r,s)},this._id=null,this._delay=null}static async wrap(e,t,r=""){return new Ve().wrap(e,t,r)}get id(){return this._id}get delay(){return this._delay}async set(e,t=""){return new Promise((r,s)=>{this.clear();const o=t?()=>{s(new Fr(t))}:r;this._id=setTimeout(o,e),this._delay=e})}async wrap(e,t,r=""){const s=this.promiseFinally(e,()=>{this.clear()}),o=this.set(t,r);return Promise.race([s,o])}clear(){this._id&&clearTimeout(this._id)}}class dt extends xt{constructor(e,t){if(typeof pe>"u")throw new Go("WebSocketClient not supported, WebSocket() missing in JavaScript environment");super(e,dt.sanitizeOptions(t)),this.ws=null;const{encoding:r}=this.options;if(!Se.isSupportedEncoding(r))throw new Jo(`Unknown or unsupported encoding: ${r}`);this.onReceiveTimeout=()=>{this.logger.debug("onReceiveTimeout: Closing connection"),super.close().then(()=>{var s;(s=this.ws)==null||s.close()})}}async openConnection(){this.state===Ie.RECONNECTING&&this.auth.onReconnect&&await this.auth.onReconnect(),this.logger.info("Opening new connection",{host:this.options.host});try{await this.openWebSocket()}catch(e){throw this.logger.error("Problem opening connection",e),new qo(e.message,e)}this.logger.info(`Performing ${this.auth.constructor.name}`);try{await this.performAuthentication(),this.logger.debug("WebSocket authenticated")}catch(e){throw this.logger.error("Authentication problem occurred:",e),new Bo(e.message,e)}this.ws&&(this.ws.onclose=this.handleClose.bind(this),this.ws.onerror=this.handleWsError.bind(this))}async performAuthentication(){await new Promise((e,t)=>{this.ws?(this.ws.onclose=()=>{this.state=Ie.DISCONNECTED,t(new Error("Connection closed by server. Check credentials."))},this.ws.onerror=r=>{this.close(),t(new Error(`WebSocket error during authentication: ${r.message}`))},this.auth.authenticate(this).then(e).catch(t)):t(new Error("WebSocket not initialized"))}),this.handleAuthentication()}async open(e){this.onConnect&&(this.logger.trace("onConnect()"),this.onConnect());const t=this.options.connectionTimeoutInMs,r=`Connection timeout after ${t} ms`,s=async o=>o instanceof Fr&&!this.pendingConnection?Promise.resolve():Promise.reject(o);if(this.isPendingConnection()&&this.pendingConnection){this.connectionCounter++;const o=Date.now();return this.logger.warn(`Waiting for pending connection (${this.connectionCounter}) with a timeout of ${t} ms`),Ve.wrap(this.pendingConnection,t,r).catch(s).then(()=>{const i=Date.now()-o;this.logger.warn(`Pending connection (${this.connectionCounter}) resolved after ${i} ms`)})}return e?(this.logger.debug(`Opening ${e} ms delayed connection with a timeout of ${t} ms`),this.pendingConnection=Qo(e).then(async()=>Ve.wrap(this.openConnection(),t,r)).catch(s).finally(()=>{this.clearPendingConnection()}),this.pendingConnection):(this.logger.debug(`Opening connection with a timeout of ${t} ms `),this.pendingConnection=Ve.wrap(this.openConnection(),t,r).catch(s).finally(()=>{this.clearPendingConnection()}),this.pendingConnection)}async close(e=!1,t=!1){this.logger.info("Closing connection explicitly"),this.options.shouldReconnectOnConnectionLoss=e,await super.close(),this.ws&&(this.clearPendingConnection(),this.ws.onclose=this.handleClose.bind(this),this.ws.close(),this.state=Ie.DISCONNECTED),t&&!e&&this.options.sessionHandling&&this.hasActiveSession&&(this.logger.info("Session logout"),await this.openWebSocket(!0))}send(e){const t=this.preSubmit(e),r=this.submit(e);return r.idJob=t,r}async submit(e){this.timestampOfLastMessageSent=Date.now();const t=new Promise(r=>{switch(this.logger.debug(`Sending ${e.Message}`,{...e}),this.sendMessage(e),this.resolveOnMessage=r,e.Message){case"Foundation::DisconnectionMessage":case"Foundation::KeepAliveMessage":case"Foundation::PingRequest":r({Message:"This message does not have a response",Version:1});break}});return t.catch(r=>{const s=new Date(this.timestampOfLastMessageSent);this.logger.error(`Failed sending ${e.Message}`,r,{request:e,lastMsgDate:s})}),t}sendMessage(e){var r;let t=JSON.stringify(e);Se.isCompressedJson(this.options.encoding)&&(t=this.compressor.compress(t)),(r=this.ws)==null||r.send(t)}async openWebSocket(e=!1){return this.logger.debug("Open WebSocket"),new Promise((t,r)=>{const{encoding:s,tls:o,host:i,port:a,path_prefix:c,frontgateSplitAuthenticationTokenSecondFactor:h,webSocketClientOptions:u,sessionHandling:l,frontgateAuthenticationToken:b}=this.options,w=`${o?"wss":"ws"}://${i}:${a}${c}/ws`,[y,M]=s.split("-"),E=[`${M?`${M}.`:""}ws-${y}.mdgms.com`];h?(E.push(`mdg2auth-${h}`),this.options.frontgateSplitAuthenticationTokenSecondFactor=null):l&&(e?E.push("mdg2wstoken-0"):this.clientOptions.otpToken?(E.push(`mdg2wstoken-${Tn(this.clientOptions.otpToken)}`),this.clientOptions.otpToken=""):b?typeof window<"u"&&E.push(`mdg2wstoken-${Tn(b)}`):E.push("mdg2wstoken-1")),this.state=Ie.CONNECTING,u?this.ws=new pe(w,E,u):this.ws=new pe(w,E),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{this.logger.info("WebSocket connected",{wsUrl:w,subProtocols:E}),e&&(this.logger.info("User logged out"),this.ws&&this.ws.close()),this.hasActiveSession=!e&&l,t()},this.ws.onclose=A=>{this.state=Ie.DISCONNECTED;const T=A.reason?`: ${A.reason}`:"";r(new Error(`Connection closed while trying to connect${T}`))},this.ws.onerror=this.handleWsError.bind(this),this.ws.onmessage=this.onWebSocketMessage.bind(this)})}onWebSocketMessage(e){if(this.state===Ie.DISCONNECTED){this.logger.warn("onWebSocketMessage while state is disconnected",{data:e.data});return}const t=this.decodeMessage(e.data),r=this.handleMessage(t);this.logger.debug(`Received ${t.Message}`,t),r&&this.resolveOnMessage(r)}decodeMessage(e){const{encoding:t}=this.options;try{if(e instanceof ArrayBuffer&&Se.isCompressedJson(t)){const r=this.compressor.decompress(new Uint8Array(e));return JSON.parse(r)}if(typeof e=="string"&&Se.isPlainJson(t))return JSON.parse(e)}catch(r){this.logger.error("Decoding message failed",r)}return String(e.constructor.name)==="Buffer"?e:(this.logger.error(`Could not decode Message of type "${typeof e}" with encoding "${t}".`),{Message:`Invalid Message Type ${typeof e}`,Version:1})}static sanitizeOptions(e={}){return e.frontgateHost&&(e.host=e.frontgateHost),e.frontgatePathPrefix&&(e.path_prefix=e.frontgatePathPrefix),e.frontgateSplitAuthenticationTokenSecondFactor&&(e.split_authentication_token_second_factor=e.frontgateSplitAuthenticationTokenSecondFactor),e.frontgateWebsocketProtocol&&(e.encoding=e.frontgateWebsocketProtocol),e.deploymentStage&&(e.deployment_stage=e.deploymentStage),e}handleWsError(e){typeof process<"u"&&this.close(this.options.shouldReconnectOnConnectionLoss).then(()=>{this.logger.error("Connection closed due to WebSocket error")}),this.logger.error("WebSocket error: ",e),this.onError&&this.onError(e)}}var Hr=(n=>(n.FRONTGATE_HOST="frontgate-host",n.FRONTGATE_PATH_PREFIX="frontgate-path-prefix",n.FRONTGATE_SPLIT_AUTHENTICATION_TOKEN_SECOND_FACTOR="frontgate-split-authentication-token-second-factor",n.FRONTGATE_AUTHENTICATION_TYPE="frontgate-authentication-type",n.FRONTGATE_AUTHENTICATION_TOKEN="frontgate-authentication-token",n.FRONTGATE_WEBSOCKET_PROTOCOL="frontgate-websocket-protocol",n))(Hr||{});function Zo(n){const e=[];if(n)for(let t=0;t<n.length;t++)e.push(n.readInt8(t));return e}function qr(n){const e={},t=Object.keys(n);return["frontgate-host","frontgate-path-prefix","frontgate-split-authentication-token-second-factor","frontgate-authentication-type","frontgate-authentication-token","frontgate-websocket-protocol"].forEach(r=>{t.includes(r)&&(e[r.replace(/-([a-z])/g,s=>s[1].toUpperCase())]=n[r])}),e}function Gr(n){const e={};return n.forEach((t,r)=>{e[r]=t}),e}async function Ft(n,e){const t=await fetch(n,e),r=Gr(t.headers);return{config:qr(r),response:t}}function Br(n={},e,t){const r=n.frontgateAuthenticationType==="token"?new Cn(n.frontgateAuthenticationToken):new On;return r.setFetchConfiguration(e,t),new dt(r,n)}function Jr({frontgateHost:n,frontgateWebsocketProtocol:e}){localStorage.setItem("mdg2config",JSON.stringify({frontgateHost:n,frontgateWebsocketProtocol:e}))}function Wr(){const n=localStorage.getItem("mdg2config");return n?JSON.parse(n):null}function zr(n){return n.name==="Foundation::ErrorResponse"}function Vr(n){return n.name==="Foundation::PermissionDeniedResponse"}function Yr(n){return n.name==="Foundation::HighLevelResponse"}function Kr(n){return n.Message==="Foundation::HighLevelResponse"}function Qr(n){return n.name==="Foundation::RejectResponse"}function Ut(n){return n.name==="Foundation::HighLevelUpdate"}function Xr(n){return n.name==="Foundation::SubscriptionLossMessage"}const Zr={version:"INSERT_FRONTGATE_VERSION_HERE",package:"@factset/frontgate-js-sdk"};function ei(){const n=ti();return{userAgent:n.userAgent,platform:n.platform,version:Zr.version,package:Zr.package,mobile:/Mobi/i.test(n.userAgent)}}function ti(){return typeof navigator<"u"?navigator:typeof process<"u"?{userAgent:`node.js/io.js, ${process.version}`,platform:`${process.platform}_${process.arch}`}:{userAgent:"unknown",platform:"unknown"}}const ni=n=>{const e=[18,20,9],t=r=>{for(let s=r.length;s>r.length-16;s-=2){let o=parseInt(r.substring(s-2,s),16);o>127&&(o-=256),e.push(o)}};return t(n.traceId),e.push(17),t(n.spanId),e.push(24),e.push(0),e},ri=async(n,e)=>new Promise((t,r)=>{setTimeout(()=>{r(e)},n)}),ge=async(n,e,t)=>Promise.race([ri(n,e),t]),es=n=>n+Math.random()*100,ue=class ue{constructor(){this.headerMembers={dataset:{id_dataset:0},id_job:0,flags_r2:0,resend_counter:0,timeout:En,authentication_identifiers:{id_application:0,id_user:0},cache_key:{value:[]},previous_response_hash:{value:[]},tracing:{value:{value:[]}}},this.flags=[]}getPtlMessage(){return this.headerMembers}getQuality(){return Object.keys(ue.PRICE_QUALITY).find(t=>ue.PRICE_QUALITY[t]===this.headerMembers.dataset.id_dataset)}setQuality(e){this.headerMembers.dataset.id_dataset=ue.PRICE_QUALITY[e]}setIdApplication(e,t=!1){(this.headerMembers.authentication_identifiers.id_application===0||t)&&(this.headerMembers.authentication_identifiers.id_application=e)}setIdUser(e,t=!1){(this.headerMembers.authentication_identifiers.id_user===0||t)&&(this.headerMembers.authentication_identifiers.id_user=e)}setFlag(e,t=!0){const r=this.flags.indexOf(e);t&&r===-1&&this.flags.push(e),!t&&r>-1&&this.flags.splice(r,1),this.headerMembers.flags_r2=this.getFlagsValue()}getFlagsValue(){return this.flags.reduce((e,t)=>e+ue.FLAG_VALUE[t],0)}isFlagValueSet(e){return this.flags.find(t=>t===e)!==void 0}setJobId(e){this.headerMembers.id_job=e}getJobId(){return this.headerMembers.id_job}countResend(){this.headerMembers.resend_counter++}getResendCounter(){return this.headerMembers.resend_counter}setTimeout(e){if(e>0){this.headerMembers.timeout=e;return}throw new Error(`Attempted to set the timeout to "${e}". The timeout must be greater than 0.`)}getTimeout(){return this.headerMembers.timeout}setTracing(e){/^0+$/.test(e.traceId)||(this.headerMembers.tracing.value.value=ni(e))}static getDataSet(e){return Object.prototype.hasOwnProperty.call(ue.PRICE_QUALITY,e)?ue.PRICE_QUALITY[e]:ue.PRICE_QUALITY.DLY}};ue.PRICE_QUALITY={RLT:129,DLY:0,EOD:130},ue.FLAG_VALUE={add_subscription:1,no_merge:2,support_caching:4,permission_denied_response:8,internal_client:16,current_state_refresh:32,subscription_use_pull_permissions:64,allow_chunked_response:128};let pt=ue;class Ye{constructor(e,t){this.header=new pt,this.coreMembers={Message:e,Version:t},this.members={}}getPtlMessage(){const e={header:this.header.getPtlMessage()};return Vo(this.coreMembers,e,this.members)}}class gt{constructor(e,t){this.token=e,this.maximumIdleInterval=t}toJson(){const e=ei();return{Message:"AuthenticationByTokenRequest",Version:1,token:{value:this.token},software:JSON.stringify(e),os:e.platform,feature_flags_wanted:{value:0},maximum_idle_interval:this.maximumIdleInterval,maximum_receivable_message_size:1048576,flags:0,cache_authentication_salt:{value:[]},cache_authentication_encrypted_secret:{encrypted_secret:[]}}}}const he=class he extends Ye{constructor(e,t,r,s,o=!1){super(he.NAME,he.VERSION),t&&this.header.setIdUser(t),r&&this.header.setIdApplication(r),s&&this.header.setTimeout(s),this.members.flags=o?he.FLAG_SINGLE_USAGE:0,this.members.lifetime_seconds_r2=e??he.LIFETIME_SECONDS_DEFAULT,this.header.setFlag("no_merge")}};he.NAME="AuthenticationTokenRequest",he.VERSION=6,he.LIFETIME_SECONDS_DEFAULT=-1,he.LIFETIME_SECONDS_MAXIMUM=-2,he.FLAG_SINGLE_USAGE=1;let je=he;const rt=class rt extends Ye{constructor(e){super(rt.NAME,rt.VERSION),this.members.id_job_subscription=e}};rt.NAME="CancelSubscriptionRequest",rt.VERSION=6;let Ae=rt;const le=class le extends Ye{constructor(e,t,r={},s){super(le.NAME,le.VERSION),this.members.accept="application/json",this.members.content_type="application/json",this.members.body={value:[]},this.members.query="",this.members.path=t,this.setMethod(e),Object.keys(r).length>0&&(e==="POST"?this.setBody(r):this.setQuery(r)),s&&this.setOptions(s)}setOptions(e){Object.hasOwnProperty.call(e,"accept")&&(this.members.accept=e.accept),Object.hasOwnProperty.call(e,"content_type")&&(this.members.content_type=e.content_type),Object.hasOwnProperty.call(e,"subscribe")&&e.subscribe&&this.header.setFlag("add_subscription"),Object.hasOwnProperty.call(e,"no_merge")&&e.no_merge&&this.header.setFlag("no_merge"),Object.hasOwnProperty.call(e,"allowChunkedResponse")&&e.allowChunkedResponse&&this.header.setFlag("allow_chunked_response"),Object.hasOwnProperty.call(e,"idApplication")&&e.idApplication&&this.header.setIdApplication(e.idApplication),Object.hasOwnProperty.call(e,"idUser")&&e.idUser&&this.header.setIdUser(e.idUser)}setMethod(e){const t=e==="POST"?le.METHOD.POST:le.METHOD.GET;this.members.method={value:t}}setBody(e={}){e instanceof Array?this.members.body={value:e}:this.members.body={value:JSON.stringify(e)}}getData(){return this.members.method.value===le.METHOD.POST?le.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(r=>{t+=String.fromCharCode(r)}),JSON.parse(t)}}};le.NAME="HighLevelRequest",le.VERSION=3,le.METHOD={GET:1,POST:2};let ve=le;const oe=class oe extends Ye{constructor(e,t,r){super(oe.NAME,oe.VERSION),this.members.request={headers:{values:[{key:"accept",value:"application/json"},{key:"content-type",value:"application/json"}]},protocol:{value:oe.PROTOCOL.HTTPS},host:"",port:0,path:t,query:"",body:{value:[]}},this.setQuery(),this.setMethod(e),r&&this.setOptions(r)}setOptions(e){e.no_merge&&this.header.setFlag("no_merge"),e.idApplication&&this.header.setIdApplication(e.idApplication),e.idUser&&this.header.setIdUser(e.idUser),e.protocol&&(this.members.request.protocol=e.protocol.toUpperCase()==="HTTP"?{value:oe.PROTOCOL.HTTP}:{value:oe.PROTOCOL.HTTPS}),e.method&&(this.members.request.method={value:oe.METHOD[e.method]}),e.host&&(this.members.request.host=e.host),e.port&&(this.members.request.port=e.port),e.path&&(this.members.request.path=e.path),e.query&&(this.members.request.query=typeof e.query=="string"?e.query:Object.keys(e.query).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e.query[t])}`).join("&")),e.body&&this.setBody(e.body),e.headers&&this.setHeaders(e.headers)}setHeaders(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t],s=this.members.request.headers.values.findIndex(i=>i.key===t);s!==-1&&this.members.request.headers.values.splice(s,1),this.members.request.headers.values.push({key:t,value:r})}}setQuery(){if(this.members.request.path.includes("?")){const e=this.members.request.path.split("?");this.members.request.path=e[0],this.members.request.query=e[1]}}setMethod(e){this.members.request.method={value:oe.METHOD[e]}}setBody(e={}){return e instanceof Array||typeof e=="string"?this.members.request.body={value:e}:this.members.request.body={value:JSON.stringify(e)},this}getData(){var e;if((e=this.members.request.body)!=null&&e.value)return ve.ptlToJsonData(this.members.request.body.value)}};oe.NAME="HTTPProxyRequest",oe.VERSION=2,oe.PROTOCOL={HTTP:1,HTTPS:2},oe.METHOD={GET:1,POST:2,OPTIONS:3,HEAD:4,PUT:5,DELETE:6,TRACE:7,CONNECT:8};let Ke=oe;class ts extends Ye{constructor(e){super(e.Message,e.version?e.version:e.Version),this._extractRequestAttributes(e)}_extractRequestAttributes(e){for(const t of Object.keys(this.coreMembers))delete e[t];this.members=xr(this.members,e)}}class Sn{static createFromString(e){return Sn.createFromObject(JSON.parse(e))}static createFromObject(e){const{header:t}=e;return t&&(t.id_job&&delete t.id_job,t.resend_counter&&delete t.resend_counter),new ts(e)}}class ne{constructor(e){this.raw=e}get msg(){return this.raw}get name(){return this.raw.Message}get jobId(){return this.raw.header.id_job}get serviceId(){return this.raw.header.id_service}isUpdateMessage(){return Object.hasOwnProperty.call(this.raw,"header")&&(Object.hasOwnProperty.call(this.raw.header,"id_service")||Object.hasOwnProperty.call(this.raw.header,"id_job"))&&this.raw.Message.endsWith("Update")}isLossMessage(){return Object.hasOwnProperty.call(this.raw,"header")&&(Object.hasOwnProperty.call(this.raw.header,"id_service")||Object.hasOwnProperty.call(this.raw.header,"id_job"))&&(this.raw.Message.endsWith("LossMessage")||this.raw.Message.endsWith("Loss"))}}class In extends ne{constructor(e){if(super(e),!this.raw.token.value.b64)throw new Error("Token not set in AuthenticationTokenResponse");if(!this.raw.expiry.microseconds)throw new Error("Expiry not set in AuthenticationTokenResponse");this.token=this.raw.token.value.b64,this.expiry=parseInt(Dt(this.raw.expiry.microseconds),10)}getToken(){return this.token}getExpiry(){return this.expiry}}class ns extends ne{}class X extends ne{get reason(){return this.raw.details}get jobId(){return this.raw.id_job}}class An extends ne{constructor(e){super(e);try{this.responseData=JSON.parse(this.raw.body.value)}catch(t){throw new Error(`Could not parse HighLevelResponse: ${t.message}`)}}get data(){return this.responseData.data}get meta(){return this.responseData.meta}get status(){return this.meta.status}get statusCode(){return this.status.code}}class Rn extends ne{constructor(e){super(e);try{const t=this.raw.response.body.value,r=t.substr(0,1)==="{";this.responseData=r?JSON.parse(t):t}catch(t){throw new Error(`Could not parse HTTPProxyResponse: ${t}`)}this.responseInfo=this.raw.info,this.statusReason=this.raw.response.status_reason,this.statusCode=this.raw.response.status_code.value}get data(){return this.responseData}get meta(){return this.responseData.meta}get status(){return{code:this.statusCode,reason:this.statusReason}}}class rs extends ne{get reason(){return this.raw.details}}class ss extends ne{get reason(){return this.raw.details}get jobId(){return this.raw.id_job}}const si=Object.freeze(Object.defineProperty({__proto__:null,AuthenticationTokenResponse:In,CancelSubscriptionResponse:ns,ErrorResponse:X,HTTPProxyResponse:Rn,HighLevelResponse:An,Mdg2Response:ne,PermissionDeniedResponse:rs,PingResponse:ze,RejectResponse:ss},Symbol.toStringTag,{value:"Module"}));class $t extends ne{constructor(e){if(super(e),typeof this.raw.body.value!="string")throw new Error("Incorrect response type in HighLevelUpdate");try{this.responseData=JSON.parse(this.raw.body.value)}catch(t){throw new Error(`Could not parse HighLevelUpdate: ${t.message}`)}}get data(){return this.responseData}}class Lt extends ne{constructor(e){super(e),this.reason=e.reason}get reasonValue(){return this.reason.value}}const oi=Object.freeze(Object.defineProperty({__proto__:null,HighLevelUpdate:$t,SubscriptionLossMessage:Lt},Symbol.toStringTag,{value:"Module"}));class Cn extends Pt{constructor(e,t=!0){if(super(-2,-2),t&&(!e||e.length<80))throw new Error("Invalid token passed to TokenAuthentication");this.setToken(e)}setToken(e){this.token=Yo(e)?Ko(e):e}setFetchConfiguration(e,t){this.fetchConfigurationInput=e,this.fetchConfigurationConfig=t}async authenticate(e){this.connection=e;const t=await this.sendAuthenticationByTokenRequest(),r=this.peerInfoFromMessage(t);this.connection.setPeerInfo(r)}async sendAuthenticationByTokenRequest(){const e={b64:this.token},t=new gt(e,this.connection.options.maximum_idle_interval);return await this.connection.submit(t.toJson())}get reconnectable(){return!!this.fetchConfigurationInput}async onReconnect(){if(this.fetchConfigurationInput){const{config:e}=await Ft(this.fetchConfigurationInput,this.fetchConfigurationConfig);e.frontgateAuthenticationType==="token"&&e.frontgateAuthenticationToken&&this.setToken(e.frontgateAuthenticationToken)}}}class On extends Cn{constructor(){super("",!1)}getEncodedToken(){return[]}async onReconnect(){if(this.fetchConfigurationInput){const{config:e}=await Ft(this.fetchConfigurationInput,this.fetchConfigurationConfig);e.frontgateSplitAuthenticationTokenSecondFactor&&(this.connection.options.frontgateSplitAuthenticationTokenSecondFactor=e.frontgateSplitAuthenticationTokenSecondFactor)}}}class os{constructor(e){const t=Tn(e),r=Math.ceil(t.length/2);this.firstFactor=t.substring(0,r),this.secondFactor=t.substring(r)}getFirstFactor(){return this.firstFactor}getSecondFactor(){return this.secondFactor}}const on=class on{constructor(e,t){this.cb=e,this.conn=t,this.isRequestPending=!1,this.request=new ft}start(e){if(this.timeout!==void 0)throw new Error("LatencyTracker already running!");this.conn.setMessageProcessor("Foundation::PingResponse",this.handlePingResponse.bind(this)),this.timeout=setInterval(()=>{if(!this.conn.isAuthenticated()){this.cb(void 0,void 0,void 0,"Skipping ping request, connection not authenticated!");return}if(this.isRequestPending){if(Date.now()-this.request.timeAtSender<on.MAX_RESPONSE_LATENCY_MS){this.cb(this.request.timeAtSender,void 0,void 0,"Skipping ping request, previous request pending!");return}this.cb(this.request.timeAtSender,void 0,void 0,"Clearing ping request, previous request exceeded timeout!")}this.isRequestPending=!0,this.request.resetTimeAtSender(),this.conn.send(this.request.getPtlMessage())},e),typeof window>"u"&&this.timeout.unref()}stop(){clearInterval(this.timeout),this.timeout=void 0,this.isRequestPending=!1,this.conn.removeMessageProcessor("Foundation::PingResponse")}handlePingResponse(e){const t=new ze(e);return this.cb(t.timeOfRequest,t.latencyTotal,t.latencyAtPeer,void 0),this.isRequestPending=!1,!1}};on.MAX_RESPONSE_LATENCY_MS=60*1e3;let kn=on;const ii=()=>Z(e=>class extends e{async requestAuthenticationToken(t=30,r=0,s=0,o=this.defaultTimeoutInMs){const a={message:new je(t,r,s,o).getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",a);const c=new Promise((u,l)=>{this.hooks.hookOnce(`frontgateConnection:response:${a.callbackId}`,b=>{if(!b.Message.includes("AuthenticationTokenResponse")){l(JSON.stringify(b));return}const f=new In(b);u({token:f.getToken(),expiry:f.getExpiry()})})}),h=`Request timeout reached (${o} ms) for ${a.message.Message}`;return ge(o,h,c)}},{featureName:"AuthTokenRequest",featureGroups:["Misc"]}),Ht=8,is={...si,...oi},st=class st{static createMessage(e){if(!e)throw new Error(`Could not create message because msg is "${e}"`);if(!e.Message||typeof e.Message!="string")throw new Error(`Could not create message because msg.Message is "${e.Message}"`);const t=e.Message.indexOf(st.msgNameSeparator);if(t===-1)throw new Error(`Could not create message for invalid msg.Message "${e.Message}"`);if(!(e!=null&&e.header))throw new Error("Could not create message because the header is missing in the msg");try{const r=e.Message.substring(t+st.msgNameSeparatorLength);return is[r]?new is[r](e):new ne(e)}catch(r){throw new Error(`Could not create message "${e.Message}": ${r.message}`)}}static hasNextChunk(e){var t;return((((t=e.header)==null?void 0:t.flags)??0)&Ht)===Ht}};st.msgNameSeparator="::",st.msgNameSeparatorLength=2;let qt=st;const ai=n=>Z(t=>{var r,qs,o;return o=class extends t{constructor(){super(...arguments);O(this,r)}async requestEndpoint(a,c,h,u,l=this.defaultTimeoutInMs){const b=new ve(a,c,h,{...u,allowChunkedResponse:!(n!=null&&n.disableChunkedResponse)});b.header.setTimeout(l),n!=null&&n.allowPermissionDeniedResponse&&b.header.setFlag("permission_denied_response");const f={message:b.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",f);const w=new Promise((M,D)=>{const E=[],A=()=>{this.hooks.hookOnce(`frontgateConnection:response:${f.callbackId}`,T=>{var R,S,P,g;try{if(!T.Message.includes("HighLevelResponse")){D(JSON.stringify(T));return}if(H(this,r,qs).call(this,T))E.push({body:((P=T.body)==null?void 0:P.value)??"",processingTime:((g=T.header)==null?void 0:g.processingTime)??0}),A();else{E.push({body:((R=T.body)==null?void 0:R.value)??"",processingTime:((S=T.header)==null?void 0:S.processingTime)??0});const p=new An({...T,body:{value:E.map(_=>_.body).join("")},header:{...T.header,processingTime:E.reduce((_,I)=>_+I.processingTime,0)}});M({response:p,data:p.data})}}catch(p){D(p)}})};A()}),y=`Request timeout reached (${l} ms) for ${f.message.Message}`;return ge(l,y,w)}},r=new WeakSet,qs=function(a){var c;return((((c=a.header)==null?void 0:c.flags)??0)&Ht)===Ht},o},{featureName:"EndpointRequest",featureGroups:["Misc"]}),as=n=>Z(t=>{var r,s,o,i,a,c,h,u,cn,b,f,Gs,Bs,kt,fr,Js,dr,Ws,zs,S;return S=class extends t{constructor(...g){super(...g);O(this,u);O(this,r);O(this,s);O(this,o,"disconnected");O(this,i);O(this,a,0);O(this,c);O(this,h);O(this,b);O(this,f,[]);C(this,c,-2),C(this,h,-1),n&&(this.conf=n),this.hooks.hook("frontgateConnection:setIdApp",p=>{C(this,c,p)}),this.hooks.hook("frontgateConnection:setIdUser",p=>{C(this,h,p)}),this.hooks.hook("frontgateConnection:sendMessage",p=>{if(p.callbackType==="job"){const _=H(this,u,Js).call(this,p.message);p.callbackId=`${_}`,H(this,u,dr).call(this,p.message)}if(v(this,u,cn)==="connected"&&p.callbackType==="response")H(this,u,kt).call(this,p.message);else if(v(this,u,cn)==="authenticated")H(this,u,kt).call(this,p.message);else{if(v(this,f).length>=v(this,b))throw new Error("Message buffer is full");v(this,f).push(p)}}),this.hooks.hook("frontgateConnection:authenticated",()=>{if(!v(this,s))throw new Error("No connection configuration set");for(this.log(m.DEBUG,"Draining message buffer");v(this,f).length>0;){const p=v(this,f).shift();p&&(H(this,u,dr).call(this,p.message),H(this,u,kt).call(this,p.message))}C(this,i,setInterval(()=>{this.log(m.DEBUG,"Sending keepalive"),this.hooks.callHook("frontgateConnection:sendMessage",{message:H(this,u,Bs).call(this),callbackType:"response",callbackId:"KeepAliveMessage"})},v(this,s).maximumIdleIntervalInS/2*1e3))}),this.hooks.hook("reconnect:attempt",async()=>{clearInterval(v(this,i)),this.log(m.DEBUG,"Reconnecting"),await this.hooks.callHook("frontgateConnection:reset");try{await this.connect(),await this.hooks.callHook("reconnect:success")}catch(p){this.log(m.ERROR,"Reconnect failed",p),await this.hooks.callHook("reconnect:failed",p)}})}set conf(g){const p=H(this,u,zs).call(this,g);C(this,b,p.messageBufferSize),C(this,s,p)}async connect(){if(!v(this,s))throw new Error("No connection configuration set");if(v(this,u,cn)!=="disconnected")throw new Error("Client is already connected or is connecting right now");const{host:g,port:p,tls:_,pathPrefix:I}=v(this,s);C(this,o,"connecting");const z=`${_?"wss":"ws"}://${g}:${p}${I??""}/ws`,k={encoding:"jsjson-v2"};await this.hooks.callHook("frontgateConnection:afterSetEncoding",k);const[F,N]=k.encoding.split("-"),V=[`${N?`${N}.`:""}ws-${F}.mdgms.com`],$={url:z,subProtocols:V};await this.hooks.callHook("frontgateConnection:beforeConnect",$),this.log(m.DEBUG,`Connecting to ${$.url} with subprotocols ${$.subProtocols}`);const Be=new Promise((fe,Y)=>{if(!v(this,s))throw new Error("No connection configuration set");v(this,s).wsClientOptions&&typeof window>"u"?C(this,r,new pe($.url,$.subProtocols,v(this,s).wsClientOptions)):C(this,r,new pe($.url,$.subProtocols)),v(this,r).binaryType="arraybuffer";let J;v(this,r).onopen=()=>{C(this,o,"connected"),this.log(m.DEBUG,"Connected"),this.hooks.callHook("frontgateConnection:connected",v(this,s)).catch(Y),J=this.hooks.hookOnce("frontgateConnection:authenticated",()=>{C(this,o,"authenticated"),this.log(m.DEBUG,"Authenticated"),fe()})},v(this,r).onclose=j=>{J==null||J(),this.log(m.DEBUG,"Disconnected",j),this.hooks.callHook("frontgateConnection:disconnected",j),(v(this,o)==="connecting"||v(this,o)==="connected")&&Y(JSON.stringify(j)),clearInterval(v(this,i)),C(this,o,"disconnected")},v(this,r).onerror=j=>{J==null||J(),this.log(m.ERROR,"Error:",j),this.hooks.callHook("frontgateConnection:error",j),(v(this,o)==="connecting"||v(this,o)==="connected")&&Y(new Error("Websocket error")),clearInterval(v(this,i)),C(this,o,"disconnected")},v(this,r).onmessage=j=>{const{data:ie}=j;this.log(m.DEBUG,"Received data:",ie);const me={msg:ie};this.hooks.callHook("frontgateConnection:afterReceiveMessage",me).then(()=>{var Je;this.log(m.DEBUG,"Received message",me.msg);const Pe=me.msg.toString("utf-8"),_e=JSON.parse(Pe);if(this.hooks.callHook("frontgateConnection:message",_e),_e.Message==="Foundation::DisconnectionMessage"){(Je=v(this,r))==null||Je.close(),this.hooks.callHook("frontgateConnection:disconnected",_e);return}H(this,u,fr).call(this,_e)})}}),ee=`Timeout reached (${this.defaultTimeoutInMs} ms) for connection to ${z}`;return ge(this.defaultTimeoutInMs,ee,Be)}async disconnect(){return new Promise(g=>{H(this,u,kt).call(this,H(this,u,Gs).call(this)),this.hooks.hookOnce("frontgateConnection:disconnected",()=>{var p;(p=v(this,r))==null||p.close(),g()})})}isConnected(){return v(this,o)==="authenticated"}isDisconnected(){return v(this,o)!=="authenticated"}isReadyToConnect(){return v(this,o)==="disconnected"}},r=new WeakMap,s=new WeakMap,o=new WeakMap,i=new WeakMap,a=new WeakMap,c=new WeakMap,h=new WeakMap,u=new WeakSet,cn=function(){return v(this,r)&&v(this,r).readyState<2?v(this,o):"disconnected"},b=new WeakMap,f=new WeakMap,Gs=function(){return{Message:"Foundation::DisconnectionMessage",Version:3,reason:{value:64},details:"client shutdown"}},Bs=function(){return{Message:"KeepAliveMessage",Version:2}},kt=async function(g){var _;await this.hooks.callHook("frontgateConnection:beforeSerializeMessage",g);const p={msg:JSON.stringify(g)};await this.hooks.callHook("frontgateConnection:beforeSendMessage",p),this.log(m.DEBUG,"Sending message:",g),this.log(m.TRACE,"Sending data:",p.msg);try{(_=v(this,r))==null||_.send(p.msg)}catch(I){const x=H(this,u,Ws).call(this,I,g);H(this,u,fr).call(this,x.msg)}},fr=function(g){var p,_;if(typeof((p=g.header)==null?void 0:p.id_job)<"u"){this.hooks.callHook(`frontgateConnection:response:${g.header.id_job}`,g);return}if(typeof((_=g.header)==null?void 0:_.id_service)<"u"&&typeof g.id_notation<"u"){this.hooks.callHook(`frontgateConnection:response:${g.header.id_service}-${g.id_notation}`,g);return}if(typeof g.id_job<"u"){this.hooks.callHook(`frontgateConnection:response:${g.id_job}`,g);return}typeof g.Message=="string"&&this.hooks.callHook(`frontgateConnection:response:${g.Message.replace("Foundation::","")}`,g)},Js=function(g){C(this,a,v(this,a)+1);const p=v(this,a);return g.header={...g.header,id_job:p},v(this,a)},dr=function(g){var p,_;g.header||(g.header={authentication_identifiers:{id_application:void 0,id_user:void 0}}),g.header.authentication_identifiers||(g.header={...g.header,authentication_identifiers:{id_application:void 0,id_user:void 0}}),(p=g.header.authentication_identifiers).id_application||(p.id_application=v(this,c)),(_=g.header.authentication_identifiers).id_user||(_.id_user=v(this,h))},Ws=function(g,p){var _;return new X({Message:"Foundation::ErrorResponse",Version:1,id_job:(_=p.header)==null?void 0:_.id_job,reason:8,details:g})},zs=function(g){const p=g.maximumIdleIntervalInS??60,_=g.maximumIdleInterval??p*1e6;return{...g,payloadContent:g.payloadContent??"foundation",maximumIdleIntervalInS:p,maximumIdleInterval:_,tls:g.tls??!0,messageBufferSize:g.messageBufferSize??512}},S},{featureName:"WSConnection",disabledFeatureGroups:["Connection"]}),ci=(n,e)=>(e&&n.setLevel(e),Z(r=>class extends r{constructor(...s){super(...s),this.logger=n}},{featureName:"Logger",featureGroups:["Misc"]})),ui=()=>Z(e=>{var t,r;return r=class extends e{constructor(...o){super(...o);O(this,t);C(this,t,new Rr),this.hooks.hook("frontgateConnection:reset",()=>{v(this,t).reset()}),this.hooks.hook("frontgateConnection:afterSetEncoding",i=>{i.encoding="jsjsonc-v2"}),this.hooks.hook("frontgateConnection:beforeSendMessage",i=>{const a=v(this,t).compress(i.msg);i.msg=a}),this.hooks.hook("frontgateConnection:afterReceiveMessage",i=>{const a=v(this,t).decompress(new Uint8Array(i.msg));i.msg=a})}},t=new WeakMap,r},{featureName:"MessageCompressor",featureGroups:["Misc"]}),hi=()=>Z(e=>class extends e{async request(t,r=this.defaultTimeoutInMs){t.header.setTimeout(r);const s={message:t.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",s);const o=new Promise(a=>{this.hooks.hookOnce(`frontgateConnection:response:${s.callbackId}`,c=>{const h=new ne(c);a(h)})}),i=`Request timeout reached (${r} ms) for ${s.message.Message}`;return ge(r,i,o)}},{featureName:"Request",featureGroups:["Misc"]}),li=n=>Z(t=>{var s,o;const r={...n};return o=class extends t{constructor(){super(...arguments);O(this,s,new Map)}async observeEndpoint(a,c,h,u){const l=`${a}:${c}:${JSON.stringify(h)}:${JSON.stringify(u??{})}`,b=r.timeout??this.defaultTimeoutInMs,f=r.subscriptionResubscribeTimeout??1e3;if(v(this,s).has(l)){const E=v(this,s).get(l);if(E)return E.count++,this.log(m.INFO,`Reusing existing subscription for ${l}`),E.observer}this.log(m.INFO,`Creating new subscription for ${l}`);const w=new ve(a,c,h,{...u,subscribe:!0});w.header.setTimeout(b);const y={message:w.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",y);const M=new Promise((E,A)=>{this.hooks.hookOnce(`frontgateConnection:response:${y.callbackId}`,T=>{if(!T.Message.includes("HighLevelResponse")){this.log(m.ERROR,`Unexpected response: ${T.Message}`),A(new X(JSON.stringify(T)));return}let R;try{R=JSON.parse(T.body.value)}catch(_){this.log(m.ERROR,`Failed to parse response: ${T.body.value}`),this.log(m.ERROR,_),A(_);return}const S=new cs(T.header.id_job,R);let P=this.hooks.hook(`frontgateConnection:response:${y.callbackId}`,_=>{if(!_.Message.includes("HighLevelUpdate")){if(_.Message.includes("SubscriptionLoss")){this.log(m.DEBUG,`Received: ${_.Message}`),setTimeout(()=>{g()},es(f)),P();return}this.log(m.ERROR,`Unexpected response: ${T.Message}`),S.pushError(new X(JSON.stringify(_))),P();return}let I;try{I=new $t(_)}catch(x){this.log(m.ERROR,`Failed to parse response: ${_.body.value}`),S.pushError(x);return}S.pushPatchData(I.data)});const g=async()=>{P(),this.log(m.INFO,`Resubscribing to ${l} due to reconnect`),await this.hooks.callHook("frontgateConnection:sendMessage",y);const _=new Promise((I,x)=>{this.hooks.hookOnce(`frontgateConnection:response:${y.callbackId}`,z=>{if(!T.Message.includes("HighLevelResponse")){const k=new X(z);this.log(m.ERROR,`Unexpected response: ${z.Message}`),P(),x(k);return}this.log(m.INFO,`Resubscribed to ${l} with ${z.header.id_job}`),S.idJob=z.header.id_job,P=this.hooks.hook(`frontgateConnection:response:${z.header.id_job}`,k=>{if(!k.Message.includes("HighLevelUpdate")){if(k.Message.includes("SubscriptionLoss")){this.log(m.DEBUG,`Received: ${k.Message}`),setTimeout(()=>{g()},es(f));return}this.log(m.ERROR,`Unexpected response: ${k.Message}`);const N=new X(k);S.pushError(N);return}let F;try{F=new $t(k)}catch(N){this.log(m.ERROR,`Failed to parse response: ${k.body.value}`),S.pushError(N);return}S.unsubscribe=()=>{const N=v(this,s).get(l);if(N){if(N.count--,N.count>0){this.log(m.INFO,`Not unsubscribing from ${l} as there are still ${N.count} subscribers`);return}v(this,s).delete(l)}this.log(m.INFO,`Unsubscribing from ${l}`);const V={message:new Ae(T.header.id_job).getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",V),P(),p()},S.pushPatchData(F.data)}),I()})});try{await ge(b,"Request timeout reached",_)}catch(I){S.pushError(new X({Message:"Reconnect failed",Error:I}))}},p=this.hooks.hook("reconnect:success",g);S.unsubscribe=()=>{const _=v(this,s).get(l);if(_){if(_.count--,_.count>0){this.log(m.INFO,`Not unsubscribing from ${l} as there are still ${_.count} subscribers`);return}v(this,s).delete(l)}this.log(m.INFO,`Unsubscribing from ${l}`);const x={message:new Ae(T.header.id_job).getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",x),P(),p()},v(this,s).set(l,{observer:S,count:1}),E(S)})}),D=`Request timeout reached (${b} ms) for ${y.message.Message}`;return ge(b,D,M)}},s=new WeakMap,o},{featureName:"EndpointSubscriptions",featureGroups:["Misc"]}),fi=()=>Z(e=>{var t,r,pr,o;return o=class extends e{constructor(){super(...arguments);O(this,r);O(this,t,new Map)}async observe(a,c=this.defaultTimeoutInMs){return H(this,r,pr).call(this,a,"job",void 0,c)}async observeConnectionBased(a,c,h=this.defaultTimeoutInMs){return H(this,r,pr).call(this,a,"connection",c,h)}},t=new WeakMap,r=new WeakSet,pr=async function(a,c,h,u=this.defaultTimeoutInMs){const l=JSON.stringify(a.getPtlMessage());if(v(this,t).has(l)){const M=v(this,t).get(l);if(M)return M.count++,this.log(m.INFO,`Reusing existing subscription for ${l}`),M.observer}this.log(m.INFO,`Creating new subscription for ${l}`);const f={message:a.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",f);const w=new Promise((M,D)=>{this.hooks.hookOnce(`frontgateConnection:response:${f.callbackId}`,E=>{if(E.Message.includes("Error")||E.Message.includes("PermissionDenied")){this.log(m.ERROR,`Unexpected response: ${E.Message}`),D(new Error(`Unexpected response: ${E.Message}`));return}const A=c==="connection"?`${E.header.id_service}-${a.getPtlMessage().id_notation}`:E.header.id_job,T=typeof h>"u"?new Ae(E.header.id_job):new h(E.header.id_service,a.getPtlMessage().id_notation),R=new Nn(E.header.id_job,E);let S=this.hooks.hook(`frontgateConnection:response:${A}`,g=>{if(g.Message.includes("Error")||g.Message.includes("PermissionDenied")){this.log(m.ERROR,`Unexpected response: ${E.Message}`),R.pushError(new X(JSON.stringify(g)));return}R.pushData(g)});const P=this.hooks.hook("reconnect:success",async()=>{S(),this.log(m.INFO,`Resubscribing to ${l} due to reconnect`),await this.hooks.callHook("frontgateConnection:sendMessage",f);const g=new Promise((p,_)=>{this.hooks.hookOnce(`frontgateConnection:response:${f.callbackId}`,I=>{if(I.Message.includes("Error")||I.Message.includes("PermissionDenied")){const k=new X(I);this.log(m.ERROR,`Unexpected resp: ${I.Message}`),_(k);return}const x=c==="connection"?`${I.header.id_service}-${a.getPtlMessage().id_notation}`:I.header.id_job,z=typeof h>"u"?new Ae(I.header.id_job):new h(I.header.id_service,a.getPtlMessage().id_notation);R.idJob=I.header.id_job,S=this.hooks.hook(`frontgateConnection:response:${x}`,k=>{if(k.Message.includes("Error")||k.Message.includes("PermissionDenied")){this.log(m.ERROR,`Unexpected response: ${k.Message}`);const F=new X(k);R.pushError(F);return}R.unsubscribe=()=>{const F=v(this,t).get(l);if(F){if(F.count--,F.count>0){this.log(m.INFO,`Not unsubscribing from ${l} as there are still ${F.count} subscribers`);return}v(this,t).delete(l)}this.log(m.INFO,`Unsubscribing from ${l}`);const N={message:z.getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",N),S(),P()},R.pushData(k)}),p()})});try{await ge(u,"Request timeout reached",g)}catch(p){R.pushError(new X({Message:"Reconnect failed",Error:p}))}});R.unsubscribe=()=>{const g=v(this,t).get(l);if(g){if(g.count--,g.count>0){this.log(m.INFO,`Not unsubscribing from ${l} as there are still ${g.count} subscribers`);return}v(this,t).delete(l)}this.log(m.INFO,`Unsubscribing from ${l}`);const p={message:T.getPtlMessage(),callbackType:"job",callbackId:""};this.hooks.callHook("frontgateConnection:sendMessage",p),S(),P()},v(this,t).set(l,{observer:R,count:1}),M(R)})}),y=`Request timeout reached (${u} ms) for ${f.message.Message}`;return ge(u,y,w)},o},{featureName:"RawSubscriptions",featureGroups:["Misc"]}),Pn=(n,e)=>{const t=e.split("/").slice(1);let r=n;for(let s=0;s<t.length-1;s++){const o=decodeURIComponent(t[s]);if(!(o in r))throw new Error(`Path not found: ${e}`);r=r[o]}return[r,decodeURIComponent(t[t.length-1])]},di=(n,e,t)=>{const[r,s]=Pn(n,e);r[s]=t},pi="-",gi=(n,e,t)=>{const[r,s]=Pn(n,e);Array.isArray(r)?s===pi?r.push(t):r.splice(parseInt(s,10),0,t):r[s]=t},vi=(n,e)=>{const[t,r]=Pn(n,e);Array.isArray(t)?t.splice(parseInt(r,10),1):delete t[r]};function bi(n,e){return e.forEach(t=>{switch(t.op){case"replace":di(n,t.path,t.value);break;case"add":gi(n,t.path,t.value);break;case"remove":vi(n,t.path);break;case"move":case"copy":case"test":default:throw new Error(`Unsupported op: ${t.op}`)}}),n}class Nn{constructor(e,t){O(this,Le);O(this,It,[]);O(this,At,[]);C(this,Le,t),this.idJob=e}get data(){return v(this,Le)}subscribe({next:e,error:t}){e(v(this,Le)),t&&v(this,At).push(t),v(this,It).push(e)}pushData(e){C(this,Le,e),v(this,It).forEach(t=>{t(e)})}pushError(e){v(this,At).forEach(t=>{t(e)})}}Le=new WeakMap,It=new WeakMap,At=new WeakMap;class cs extends Nn{pushPatchData(e){try{const t=bi(this.data,e);super.pushData(t)}catch(t){super.pushError(new X(t.message))}}}const mi=n=>Z(t=>class extends t{constructor(...r){super(...r),this.hooks.hook("frontgateConnection:beforeConnect",o=>{this.hooks.callHook("frontgateConnection:setIdApp",-2),this.hooks.callHook("frontgateConnection:setIdUser",-2),this.log(m.DEBUG,"Adding mdg2auth subprotocol"),o.subProtocols.push(`mdg2auth-${n}`)});const s=async o=>{this.hooks.callHook("frontgateConnection:setIdApp",-2),this.hooks.callHook("frontgateConnection:setIdUser",-2);const i={maximum_idle_interval:o.maximumIdleInterval},a={b64:""},h=new gt(a,i.maximum_idle_interval).toJson();this.log(m.INFO,"Sending message",h);const u={message:h,callbackType:"response",callbackId:h.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",u),this.hooks.hookOnce(`frontgateConnection:response:${u.callbackId}`,l=>{this.log(m.INFO,"Received response",l),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hookOnce("frontgateConnection:connected",s)}},{featureName:"CookieTokenAuth",featureGroups:["Auth"],disabledFeatureGroups:["Auth"]}),yi=n=>Z(t=>{var r,s;return s=class extends t{constructor(...i){super(...i);O(this,r);C(this,r,n??"");const a=async c=>{this.hooks.callHook("frontgateConnection:setIdApp",-2),this.hooks.callHook("frontgateConnection:setIdUser",-2);const h={maximum_idle_interval:c.maximumIdleInterval},u={b64:v(this,r)},b=new gt(u,h.maximum_idle_interval).toJson();this.log(m.INFO,"Sending message",b);const f={message:b,callbackType:"response",callbackId:b.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",f),this.hooks.hookOnce(`frontgateConnection:response:${f.callbackId}`,w=>{this.log(m.INFO,"Received response",w),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hook("frontgateConnection:connected",a)}set token(i){C(this,r,i)}},r=new WeakMap,s},{featureName:"TokenAuth",featureGroups:["Auth"],disabledFeatureGroups:["Auth"]}),wi=(n,e,t)=>Z(s=>{var o,i,a,c,h,Vs,l;return l=class extends as({host:"",pathPrefix:"",port:0,tls:!0,maximumIdleIntervalInS:n.maximumIdleIntervalInS})(s){constructor(...f){super(...f);O(this,h);O(this,o,"");O(this,i,"");O(this,a);O(this,c);C(this,a,e),C(this,c,t),this.hooks.hook("frontgateConnection:beforeConnect",async y=>{this.hooks.callHook("frontgateConnection:setIdApp",-2),this.hooks.callHook("frontgateConnection:setIdUser",-2),this.log(m.DEBUG,"Fetching connection configuration");const M=await H(this,h,Vs).call(this);if(this.log(m.DEBUG,"Connection configuration received",n),y.url=M.url,M.authtenticationType==="token"&&M.authenticationToken)C(this,o,M.authenticationToken);else if(M.splitAuthenticationTokenSecondFactor)C(this,i,M.splitAuthenticationTokenSecondFactor);else throw new Error("Invalid authentication configuration");this.log(m.DEBUG,"Adding mdg2auth subprotocol"),v(this,i)!==""&&y.subProtocols.push(`mdg2auth-${v(this,i)}`)});const w=async y=>{this.hooks.callHook("frontgateConnection:setIdApp",-2),this.hooks.callHook("frontgateConnection:setIdUser",-2);const M={maximum_idle_interval:y.maximumIdleInterval},D={b64:v(this,o)},A=new gt(D,M.maximum_idle_interval).toJson();this.log(m.INFO,"Sending message",A);const T={message:A,callbackType:"response",callbackId:A.Message.replace("Request","Response")};await this.hooks.callHook("frontgateConnection:sendMessage",T),this.hooks.hookOnce(`frontgateConnection:response:${T.callbackId}`,R=>{this.log(m.INFO,"Received response",R),this.hooks.callHook("frontgateConnection:authenticated")})};this.hooks.hook("frontgateConnection:connected",w)}},o=new WeakMap,i=new WeakMap,a=new WeakMap,c=new WeakMap,h=new WeakSet,Vs=async function(){const f=await fetch(v(this,a),v(this,c));if(!f.ok)throw new Error(`Failed to fetch connection configuration: ${f.status} ${f.statusText}`);const{headers:w}=f,y=w.get("frontgate-host"),M=w.get("frontgate-path-prefix"),D=w.get("frontgate-split-authentication-token-second-factor"),E=w.get("frontgate-authentication-type"),A=w.get("frontgate-authentication-token"),T=w.get("frontgate-websocket-port")??"443",R=`wss://${y}:${T}${M??""}/ws`;if(E==="token"&&!A)throw new Error("Authentication token is required for token authentication");if(E!=="token"&&!D)throw new Error("Split authentication token second factor is required");return{url:R,authtenticationType:E,authenticationToken:A,splitAuthenticationTokenSecondFactor:D}},l},{featureName:"FetchAuth",featureGroups:["Auth","Connection"],disabledFeatureGroups:["Auth","Connection"]}),_i=(n,e)=>({options:n,submit:async t=>{e.log(m.INFO,"Sending message",t);const r={message:t,callbackType:"response",callbackId:t.Message.replace("Request","Response")};await e.hooks.callHook("frontgateConnection:sendMessage",r);let s;return new Promise((o,i)=>{const a=e.hooks.hookOnce(`frontgateConnection:response:${r.callbackId}`,c=>{clearTimeout(s),e.log(m.INFO,"Received response",c),o(c)});s=setTimeout(()=>{a(),i(new Error("Authentication message timeout"))},3e3)})},setPeerInfo:t=>{e.log(m.INFO,"Peer info:",t)}}),Ei=()=>Z(e=>{var t,r,s,o;return o=class extends e{constructor(...a){super(...a);O(this,t,0);O(this,r,[1e3,2e3,4e3,8e3,16e3,32e3]);O(this,s);const c=h=>{if(h.code!==1e3){v(this,s)&&(this.log(m.WARN,"Aborting previous reconnect attempt"),clearTimeout(v(this,s)),C(this,t,0));let u=v(this,t);v(this,t)>v(this,r).length&&(u=v(this,r).length-1);const l=v(this,r)[u];C(this,s,setTimeout(()=>{this.log(m.INFO,`Reconnecting... Attempt ${v(this,t)}`);const b=this.hooks.hookOnce("reconnect:failed",c);this.hooks.callHook("reconnect:attempt",h).then(b).catch(()=>{this.log(m.ERROR,"Failed to reconnect")}),C(this,s,void 0)},l)),Hs(this,t)._++}};this.hooks.hookOnce("frontgateConnection:disconnected",c),this.hooks.hook("reconnect:success",()=>{clearTimeout(v(this,s)),C(this,s,void 0),C(this,t,0),this.log(m.INFO,"Reconnected"),this.hooks.hookOnce("frontgateConnection:disconnected",c)})}},t=new WeakMap,r=new WeakMap,s=new WeakMap,o},{featureName:"Reconnect",featureGroups:["Misc"],disabledFeatures:["TokenAuth","CookieTokenAuth"]});var Ti=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},De="1.9.0",us=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Mi(n){var e=new Set([n]),t=new Set,r=n.match(us);if(!r)return function(){return!1};var s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(s.prerelease!=null)return function(c){return c===n};function o(a){return t.add(a),!1}function i(a){return e.add(a),!0}return function(c){if(e.has(c))return!0;if(t.has(c))return!1;var h=c.match(us);if(!h)return o(c);var u={major:+h[1],minor:+h[2],patch:+h[3],prerelease:h[4]};return u.prerelease!=null||s.major!==u.major?o(c):s.major===0?s.minor===u.minor&&s.patch<=u.patch?i(c):o(c):s.minor<=u.minor?i(c):o(c)}}var Si=Mi(De),Ii=De.split(".")[0],vt=Symbol.for("opentelemetry.js.api."+Ii),bt=Ti;function mt(n,e,t,r){var s;r===void 0&&(r=!1);var o=bt[vt]=(s=bt[vt])!==null&&s!==void 0?s:{version:De};if(!r&&o[n]){var i=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+n);return t.error(i.stack||i.message),!1}if(o.version!==De){var i=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+n+" does not match previously registered API v"+De);return t.error(i.stack||i.message),!1}return o[n]=e,t.debug("@opentelemetry/api: Registered a global for "+n+" v"+De+"."),!0}function xe(n){var e,t,r=(e=bt[vt])===null||e===void 0?void 0:e.version;if(!(!r||!Si(r)))return(t=bt[vt])===null||t===void 0?void 0:t[n]}function yt(n,e){e.debug("@opentelemetry/api: Unregistering a global for "+n+" v"+De+".");var t=bt[vt];t&&delete t[n]}var Ai=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o},Ri=function(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return n.concat(o||Array.prototype.slice.call(e))},Ci=function(){function n(e){this._namespace=e.namespace||"DiagComponentLogger"}return n.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return wt("debug",this._namespace,e)},n.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return wt("error",this._namespace,e)},n.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return wt("info",this._namespace,e)},n.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return wt("warn",this._namespace,e)},n.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return wt("verbose",this._namespace,e)},n}();function wt(n,e,t){var r=xe("diag");if(r)return t.unshift(e),r[n].apply(r,Ri([],Ai(t),!1))}var re;(function(n){n[n.NONE=0]="NONE",n[n.ERROR=30]="ERROR",n[n.WARN=50]="WARN",n[n.INFO=60]="INFO",n[n.DEBUG=70]="DEBUG",n[n.VERBOSE=80]="VERBOSE",n[n.ALL=9999]="ALL"})(re||(re={}));function Oi(n,e){n<re.NONE?n=re.NONE:n>re.ALL&&(n=re.ALL),e=e||{};function t(r,s){var o=e[r];return typeof o=="function"&&n>=s?o.bind(e):function(){}}return{error:t("error",re.ERROR),warn:t("warn",re.WARN),info:t("info",re.INFO),debug:t("debug",re.DEBUG),verbose:t("verbose",re.VERBOSE)}}var ki=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o},Pi=function(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return n.concat(o||Array.prototype.slice.call(e))},Ni="diag",be=function(){function n(){function e(s){return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];var a=xe("diag");if(a)return a[s].apply(a,Pi([],ki(o),!1))}}var t=this,r=function(s,o){var i,a,c;if(o===void 0&&(o={logLevel:re.INFO}),s===t){var h=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((i=h.stack)!==null&&i!==void 0?i:h.message),!1}typeof o=="number"&&(o={logLevel:o});var u=xe("diag"),l=Oi((a=o.logLevel)!==null&&a!==void 0?a:re.INFO,s);if(u&&!o.suppressOverrideMessage){var b=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+b),l.warn("Current logger will overwrite one already registered from "+b)}return mt("diag",l,t,!0)};t.setLogger=r,t.disable=function(){yt(Ni,t)},t.createComponentLogger=function(s){return new Ci(s)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return n.instance=function(){return this._instance||(this._instance=new n),this._instance},n}(),ji=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o},Di=function(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},xi=function(){function n(e){this._entries=e?new Map(e):new Map}return n.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},n.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=ji(e,2),r=t[0],s=t[1];return[r,s]})},n.prototype.setEntry=function(e,t){var r=new n(this._entries);return r._entries.set(e,t),r},n.prototype.removeEntry=function(e){var t=new n(this._entries);return t._entries.delete(e),t},n.prototype.removeEntries=function(){for(var e,t,r=[],s=0;s<arguments.length;s++)r[s]=arguments[s];var o=new n(this._entries);try{for(var i=Di(r),a=i.next();!a.done;a=i.next()){var c=a.value;o._entries.delete(c)}}catch(h){e={error:h}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return o},n.prototype.clear=function(){return new n},n}();be.instance();function Fi(n){return n===void 0&&(n={}),new xi(new Map(Object.entries(n)))}function hs(n){return Symbol.for(n)}var Ui=function(){function n(e){var t=this;t._currentContext=e?new Map(e):new Map,t.getValue=function(r){return t._currentContext.get(r)},t.setValue=function(r,s){var o=new n(t._currentContext);return o._currentContext.set(r,s),o},t.deleteValue=function(r){var s=new n(t._currentContext);return s._currentContext.delete(r),s}}return n}(),$i=new Ui,Fe=function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},n(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Li=function(){function n(){}return n.prototype.createGauge=function(e,t){return Ki},n.prototype.createHistogram=function(e,t){return Qi},n.prototype.createCounter=function(e,t){return Yi},n.prototype.createUpDownCounter=function(e,t){return Xi},n.prototype.createObservableGauge=function(e,t){return ea},n.prototype.createObservableCounter=function(e,t){return Zi},n.prototype.createObservableUpDownCounter=function(e,t){return ta},n.prototype.addBatchObservableCallback=function(e,t){},n.prototype.removeBatchObservableCallback=function(e){},n}(),Gt=function(){function n(){}return n}(),Hi=function(n){Fe(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.prototype.add=function(t,r){},e}(Gt),qi=function(n){Fe(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.prototype.add=function(t,r){},e}(Gt),Gi=function(n){Fe(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.prototype.record=function(t,r){},e}(Gt),Bi=function(n){Fe(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.prototype.record=function(t,r){},e}(Gt),jn=function(){function n(){}return n.prototype.addCallback=function(e){},n.prototype.removeCallback=function(e){},n}(),Ji=function(n){Fe(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e}(jn),Wi=function(n){Fe(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e}(jn),zi=function(n){Fe(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e}(jn),Vi=new Li,Yi=new Hi,Ki=new Gi,Qi=new Bi,Xi=new qi,Zi=new Ji,ea=new Wi,ta=new zi,na={get:function(n,e){if(n!=null)return n[e]},keys:function(n){return n==null?[]:Object.keys(n)}},ra={set:function(n,e,t){n!=null&&(n[e]=t)}},sa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o},oa=function(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return n.concat(o||Array.prototype.slice.call(e))},ia=function(){function n(){}return n.prototype.active=function(){return $i},n.prototype.with=function(e,t,r){for(var s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return t.call.apply(t,oa([r],sa(s),!1))},n.prototype.bind=function(e,t){return t},n.prototype.enable=function(){return this},n.prototype.disable=function(){return this},n}(),aa=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o},ca=function(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return n.concat(o||Array.prototype.slice.call(e))},Dn="context",ua=new ia,Bt=function(){function n(){}return n.getInstance=function(){return this._instance||(this._instance=new n),this._instance},n.prototype.setGlobalContextManager=function(e){return mt(Dn,e,be.instance())},n.prototype.active=function(){return this._getContextManager().active()},n.prototype.with=function(e,t,r){for(var s,o=[],i=3;i<arguments.length;i++)o[i-3]=arguments[i];return(s=this._getContextManager()).with.apply(s,ca([e,t,r],aa(o),!1))},n.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},n.prototype._getContextManager=function(){return xe(Dn)||ua},n.prototype.disable=function(){this._getContextManager().disable(),yt(Dn,be.instance())},n}(),xn;(function(n){n[n.NONE=0]="NONE",n[n.SAMPLED=1]="SAMPLED"})(xn||(xn={}));var ls="0000000000000000",fs="00000000000000000000000000000000",ha={traceId:fs,spanId:ls,traceFlags:xn.NONE},_t=function(){function n(e){e===void 0&&(e=ha),this._spanContext=e}return n.prototype.spanContext=function(){return this._spanContext},n.prototype.setAttribute=function(e,t){return this},n.prototype.setAttributes=function(e){return this},n.prototype.addEvent=function(e,t){return this},n.prototype.addLink=function(e){return this},n.prototype.addLinks=function(e){return this},n.prototype.setStatus=function(e){return this},n.prototype.updateName=function(e){return this},n.prototype.end=function(e){},n.prototype.isRecording=function(){return!1},n.prototype.recordException=function(e,t){},n}(),Fn=hs("OpenTelemetry Context Key SPAN");function Un(n){return n.getValue(Fn)||void 0}function la(){return Un(Bt.getInstance().active())}function $n(n,e){return n.setValue(Fn,e)}function fa(n){return n.deleteValue(Fn)}function da(n,e){return $n(n,new _t(e))}function ds(n){var e;return(e=Un(n))===null||e===void 0?void 0:e.spanContext()}var pa=/^([0-9a-f]{32})$/i,ga=/^[0-9a-f]{16}$/i;function va(n){return pa.test(n)&&n!==fs}function ba(n){return ga.test(n)&&n!==ls}function ps(n){return va(n.traceId)&&ba(n.spanId)}function ma(n){return new _t(n)}var Ln=Bt.getInstance(),gs=function(){function n(){}return n.prototype.startSpan=function(e,t,r){r===void 0&&(r=Ln.active());var s=!!(t!=null&&t.root);if(s)return new _t;var o=r&&ds(r);return ya(o)&&ps(o)?new _t(o):new _t},n.prototype.startActiveSpan=function(e,t,r,s){var o,i,a;if(!(arguments.length<2)){arguments.length===2?a=t:arguments.length===3?(o=t,a=r):(o=t,i=r,a=s);var c=i??Ln.active(),h=this.startSpan(e,o,c),u=$n(c,h);return Ln.with(u,a,void 0,h)}},n}();function ya(n){return typeof n=="object"&&typeof n.spanId=="string"&&typeof n.traceId=="string"&&typeof n.traceFlags=="number"}var wa=new gs,_a=function(){function n(e,t,r,s){this._provider=e,this.name=t,this.version=r,this.options=s}return n.prototype.startSpan=function(e,t,r){return this._getTracer().startSpan(e,t,r)},n.prototype.startActiveSpan=function(e,t,r,s){var o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)},n.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):wa},n}(),Ea=function(){function n(){}return n.prototype.getTracer=function(e,t,r){return new gs},n}(),Ta=new Ea,vs=function(){function n(){}return n.prototype.getTracer=function(e,t,r){var s;return(s=this.getDelegateTracer(e,t,r))!==null&&s!==void 0?s:new _a(this,e,t,r)},n.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Ta},n.prototype.setDelegate=function(e){this._delegate=e},n.prototype.getDelegateTracer=function(e,t,r){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,t,r)},n}();Bt.getInstance(),be.instance();var Ma=function(){function n(){}return n.prototype.getMeter=function(e,t,r){return Vi},n}(),Sa=new Ma,Hn="metrics",Ia=function(){function n(){}return n.getInstance=function(){return this._instance||(this._instance=new n),this._instance},n.prototype.setGlobalMeterProvider=function(e){return mt(Hn,e,be.instance())},n.prototype.getMeterProvider=function(){return xe(Hn)||Sa},n.prototype.getMeter=function(e,t,r){return this.getMeterProvider().getMeter(e,t,r)},n.prototype.disable=function(){yt(Hn,be.instance())},n}();Ia.getInstance();var Aa=function(){function n(){}return n.prototype.inject=function(e,t){},n.prototype.extract=function(e,t){return e},n.prototype.fields=function(){return[]},n}(),qn=hs("OpenTelemetry Baggage Key");function bs(n){return n.getValue(qn)||void 0}function Ra(){return bs(Bt.getInstance().active())}function Ca(n,e){return n.setValue(qn,e)}function Oa(n){return n.deleteValue(qn)}var Gn="propagation",ka=new Aa,Pa=function(){function n(){this.createBaggage=Fi,this.getBaggage=bs,this.getActiveBaggage=Ra,this.setBaggage=Ca,this.deleteBaggage=Oa}return n.getInstance=function(){return this._instance||(this._instance=new n),this._instance},n.prototype.setGlobalPropagator=function(e){return mt(Gn,e,be.instance())},n.prototype.inject=function(e,t,r){return r===void 0&&(r=ra),this._getGlobalPropagator().inject(e,t,r)},n.prototype.extract=function(e,t,r){return r===void 0&&(r=na),this._getGlobalPropagator().extract(e,t,r)},n.prototype.fields=function(){return this._getGlobalPropagator().fields()},n.prototype.disable=function(){yt(Gn,be.instance())},n.prototype._getGlobalPropagator=function(){return xe(Gn)||ka},n}();Pa.getInstance();var Bn="trace",Na=function(){function n(){this._proxyTracerProvider=new vs,this.wrapSpanContext=ma,this.isSpanContextValid=ps,this.deleteSpan=fa,this.getSpan=Un,this.getActiveSpan=la,this.getSpanContext=ds,this.setSpan=$n,this.setSpanContext=da}return n.getInstance=function(){return this._instance||(this._instance=new n),this._instance},n.prototype.setGlobalTracerProvider=function(e){var t=mt(Bn,this._proxyTracerProvider,be.instance());return t&&this._proxyTracerProvider.setDelegate(e),t},n.prototype.getTracerProvider=function(){return xe(Bn)||this._proxyTracerProvider},n.prototype.getTracer=function(e,t){return this.getTracerProvider().getTracer(e,t)},n.prototype.disable=function(){yt(Bn,be.instance()),this._proxyTracerProvider=new vs},n}(),ms=Na.getInstance();const ja=()=>Z(e=>{var t,Ys,s;return s=class extends e{constructor(...i){super(...i);O(this,t);this.hooks.hook("frontgateConnection:beforeSerializeMessage",a=>{a.header&&ms.getTracer("frontgate-js-sdk").startActiveSpan("frontgateConnection:sendMessage",c=>{const h=H(this,t,Ys).call(this,c.spanContext());h&&(a.header={...a.header,...h}),c.end()})})}},t=new WeakSet,Ys=function(i){if(!/^0+$/.test(i.traceId))return{tracing:{value:{value:ys(i)}}}},s},{featureName:"OpenTelemetry",featureGroups:["Misc"]}),ys=n=>{const e=[18,20,9],t=r=>{for(let s=r.length;s>r.length-16;s-=2){let o=parseInt(r.substring(s-2,s),16);o>127&&(o-=256),e.push(o)}};return t(n.traceId),e.push(17),t(n.spanId),e.push(24),e.push(0),e},Da=()=>Z(e=>class extends e{async requestProxyEndpoint(t,r,s,o,i=this.defaultTimeoutInMs){const a=new Ke(t,r,o);s&&a.setBody(s),a.header.setTimeout(i);const c={message:a.getPtlMessage(),callbackType:"job",callbackId:""};await this.hooks.callHook("frontgateConnection:sendMessage",c);const h=new Promise((l,b)=>{this.hooks.hookOnce(`frontgateConnection:response:${c.callbackId}`,f=>{try{if(!f.Message.includes("HTTPProxyResponse")){b(JSON.stringify(f));return}const w=new Rn(f);l({response:w,data:w.data})}catch(w){b(w)}})}),u=`Request timeout reached (${i} ms) for ${c.message.Message}`;return ge(i,u,h)}},{featureName:"HTTPProxyRequest",featureGroups:["Misc"]}),Z=(n,e)=>{const t=n;return t.featureName=e.featureName,t.featureGroups=e.featureGroups,t.disabledFeatures=e.disabledFeatures,t.disabledFeatureGroups=e.disabledFeatureGroups,t};var Jn=function(n,e){return Jn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])},Jn(n,e)};function Qe(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Jn(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function xa(n,e,t,r){function s(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{h(r.next(u))}catch(l){i(l)}}function c(u){try{h(r.throw(u))}catch(l){i(l)}}function h(u){u.done?o(u.value):s(u.value).then(a,c)}h((r=r.apply(n,e||[])).next())})}function ws(n,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,s,o,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(h){return function(u){return c([h,u])}}function c(h){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,h[0]&&(t=0)),t;)try{if(r=1,s&&(o=h[0]&2?s.return:h[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,h[1])).done)return o;switch(s=0,o&&(h=[h[0]&2,o.value]),h[0]){case 0:case 1:o=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,s=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!o||h[1]>o[0]&&h[1]<o[3])){t.label=h[1];break}if(h[0]===6&&t.label<o[1]){t.label=o[1],o=h;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(h);break}o[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(n,t)}catch(u){h=[6,u],s=0}finally{r=o=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Xe(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Jt(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],i;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o}function Wt(n,e,t){if(t||arguments.length===2)for(var r=0,s=e.length,o;r<s;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return n.concat(o||Array.prototype.slice.call(e))}function Ze(n){return this instanceof Ze?(this.v=n,this):new Ze(n)}function Fa(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t.apply(n,e||[]),s,o=[];return s=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),s[Symbol.asyncIterator]=function(){return this},s;function i(f){return function(w){return Promise.resolve(w).then(f,l)}}function a(f,w){r[f]&&(s[f]=function(y){return new Promise(function(M,D){o.push([f,y,M,D])>1||c(f,y)})},w&&(s[f]=w(s[f])))}function c(f,w){try{h(r[f](w))}catch(y){b(o[0][3],y)}}function h(f){f.value instanceof Ze?Promise.resolve(f.value.v).then(u,l):b(o[0][2],f)}function u(f){c("next",f)}function l(f){c("throw",f)}function b(f,w){f(w),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Ua(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof Xe=="function"?Xe(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=n[o]&&function(i){return new Promise(function(a,c){i=n[o](i),s(a,c,i.done,i.value)})}}function s(o,i,a,c){Promise.resolve(c).then(function(h){o({value:h,done:a})},i)}}typeof SuppressedError=="function"&&SuppressedError;function K(n){return typeof n=="function"}function _s(n){var e=function(r){Error.call(r),r.stack=new Error().stack},t=n(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var Wn=_s(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
2
|
+
`+t.map(function(r,s){return s+1+") "+r.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=t}});function zn(n,e){if(n){var t=n.indexOf(e);0<=t&&n.splice(t,1)}}var Et=function(){function n(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var e,t,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=Xe(i),c=a.next();!c.done;c=a.next()){var h=c.value;h.remove(this)}}catch(y){e={error:y}}finally{try{c&&!c.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else i.remove(this);var u=this.initialTeardown;if(K(u))try{u()}catch(y){o=y instanceof Wn?y.errors:[y]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var b=Xe(l),f=b.next();!f.done;f=b.next()){var w=f.value;try{Ms(w)}catch(y){o=o??[],y instanceof Wn?o=Wt(Wt([],Jt(o)),Jt(y.errors)):o.push(y)}}}catch(y){r={error:y}}finally{try{f&&!f.done&&(s=b.return)&&s.call(b)}finally{if(r)throw r.error}}}if(o)throw new Wn(o)}},n.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Ms(e);else{if(e instanceof n){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},n.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},n.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},n.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&zn(t,e)},n.prototype.remove=function(e){var t=this._finalizers;t&&zn(t,e),e instanceof n&&e._removeParent(this)},n.EMPTY=function(){var e=new n;return e.closed=!0,e}(),n}(),Es=Et.EMPTY;function Ts(n){return n instanceof Et||n&&"closed"in n&&K(n.remove)&&K(n.add)&&K(n.unsubscribe)}function Ms(n){K(n)?n():n.unsubscribe()}var $a={Promise:void 0},La={setTimeout:function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];return setTimeout.apply(void 0,Wt([n,e],Jt(t)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function Ss(n){La.setTimeout(function(){throw n})}function Is(){}function zt(n){n()}var Vn=function(n){Qe(e,n);function e(t){var r=n.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Ts(t)&&t.add(r)):r.destination=Ga,r}return e.create=function(t,r,s){return new Tt(t,r,s)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Et),Ha=function(){function n(e){this.partialObserver=e}return n.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(r){Vt(r)}},n.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(r){Vt(r)}else Vt(e)},n.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Vt(t)}},n}(),Tt=function(n){Qe(e,n);function e(t,r,s){var o=n.call(this)||this,i;return K(t)||!t?i={next:t??void 0,error:r??void 0,complete:s??void 0}:i=t,o.destination=new Ha(i),o}return e}(Vn);function Vt(n){Ss(n)}function qa(n){throw n}var Ga={closed:!0,next:Is,error:qa,complete:Is},Yn=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function As(n){return n}function Ba(n){return n.length===0?As:n.length===1?n[0]:function(t){return n.reduce(function(r,s){return s(r)},t)}}var Re=function(){function n(e){e&&(this._subscribe=e)}return n.prototype.lift=function(e){var t=new n;return t.source=this,t.operator=e,t},n.prototype.subscribe=function(e,t,r){var s=this,o=Wa(e)?e:new Tt(e,t,r);return zt(function(){var i=s,a=i.operator,c=i.source;o.add(a?a.call(o,c):c?s._subscribe(o):s._trySubscribe(o))}),o},n.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},n.prototype.forEach=function(e,t){var r=this;return t=Rs(t),new t(function(s,o){var i=new Tt({next:function(a){try{e(a)}catch(c){o(c),i.unsubscribe()}},error:o,complete:s});r.subscribe(i)})},n.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},n.prototype[Yn]=function(){return this},n.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ba(e)(this)},n.prototype.toPromise=function(e){var t=this;return e=Rs(e),new e(function(r,s){var o;t.subscribe(function(i){return o=i},function(i){return s(i)},function(){return r(o)})})},n.create=function(e){return new n(e)},n}();function Rs(n){var e;return(e=n??$a.Promise)!==null&&e!==void 0?e:Promise}function Ja(n){return n&&K(n.next)&&K(n.error)&&K(n.complete)}function Wa(n){return n&&n instanceof Vn||Ja(n)&&Ts(n)}function za(n){return K(n==null?void 0:n.lift)}function Yt(n){return function(e){if(za(e))return e.lift(function(t){try{return n(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Kt(n,e,t,r,s){return new Va(n,e,t,r,s)}var Va=function(n){Qe(e,n);function e(t,r,s,o,i,a){var c=n.call(this,t)||this;return c.onFinalize=i,c.shouldUnsubscribe=a,c._next=r?function(h){try{r(h)}catch(u){t.error(u)}}:n.prototype._next,c._error=o?function(h){try{o(h)}catch(u){t.error(u)}finally{this.unsubscribe()}}:n.prototype._error,c._complete=s?function(){try{s()}catch(h){t.error(h)}finally{this.unsubscribe()}}:n.prototype._complete,c}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(Vn),Ya=_s(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Mt=function(n){Qe(e,n);function e(){var t=n.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var r=new Cs(this,this);return r.operator=t,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new Ya},e.prototype.next=function(t){var r=this;zt(function(){var s,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=Xe(r.currentObservers),a=i.next();!a.done;a=i.next()){var c=a.value;c.next(t)}}catch(h){s={error:h}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(s)throw s.error}}}})},e.prototype.error=function(t){var r=this;zt(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=t;for(var s=r.observers;s.length;)s.shift().error(t)}})},e.prototype.complete=function(){var t=this;zt(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var r=t.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var r=this,s=this,o=s.hasError,i=s.isStopped,a=s.observers;return o||i?Es:(this.currentObservers=null,a.push(t),new Et(function(){r.currentObservers=null,zn(a,t)}))},e.prototype._checkFinalizedStatuses=function(t){var r=this,s=r.hasError,o=r.thrownError,i=r.isStopped;s?t.error(o):i&&t.complete()},e.prototype.asObservable=function(){var t=new Re;return t.source=this,t},e.create=function(t,r){return new Cs(t,r)},e}(Re),Cs=function(n){Qe(e,n);function e(t,r){var s=n.call(this)||this;return s.destination=t,s.source=r,s}return e.prototype.next=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,t)},e.prototype.error=function(t){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.call(r,t)},e.prototype.complete=function(){var t,r;(r=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||r===void 0||r.call(t)},e.prototype._subscribe=function(t){var r,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(t))!==null&&s!==void 0?s:Es},e}(Mt),Os={now:function(){return(Os.delegate||Date).now()},delegate:void 0},Qt=function(n){Qe(e,n);function e(t,r,s){t===void 0&&(t=1/0),r===void 0&&(r=1/0),s===void 0&&(s=Os);var o=n.call(this)||this;return o._bufferSize=t,o._windowTime=r,o._timestampProvider=s,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,r),o}return e.prototype.next=function(t){var r=this,s=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,a=r._timestampProvider,c=r._windowTime;s||(o.push(t),!i&&o.push(a.now()+c)),this._trimBuffer(),n.prototype.next.call(this,t)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(t),s=this,o=s._infiniteTimeWindow,i=s._buffer,a=i.slice(),c=0;c<a.length&&!t.closed;c+=o?1:2)t.next(a[c]);return this._checkFinalizedStatuses(t),r},e.prototype._trimBuffer=function(){var t=this,r=t._bufferSize,s=t._timestampProvider,o=t._buffer,i=t._infiniteTimeWindow,a=(i?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!i){for(var c=s.now(),h=0,u=1;u<o.length&&o[u]<=c;u+=2)h=u;h&&o.splice(0,h+1)}},e}(Mt),Ka=function(n){return n&&typeof n.length=="number"&&typeof n!="function"};function Qa(n){return K(n==null?void 0:n.then)}function Xa(n){return K(n[Yn])}function Za(n){return Symbol.asyncIterator&&K(n==null?void 0:n[Symbol.asyncIterator])}function ec(n){return new TypeError("You provided "+(n!==null&&typeof n=="object"?"an invalid object":"'"+n+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function tc(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var nc=tc();function rc(n){return K(n==null?void 0:n[nc])}function sc(n){return Fa(this,arguments,function(){var t,r,s,o;return ws(this,function(i){switch(i.label){case 0:t=n.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,Ze(t.read())];case 3:return r=i.sent(),s=r.value,o=r.done,o?[4,Ze(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,Ze(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function oc(n){return K(n==null?void 0:n.getReader)}function Kn(n){if(n instanceof Re)return n;if(n!=null){if(Xa(n))return ic(n);if(Ka(n))return ac(n);if(Qa(n))return cc(n);if(Za(n))return ks(n);if(rc(n))return uc(n);if(oc(n))return hc(n)}throw ec(n)}function ic(n){return new Re(function(e){var t=n[Yn]();if(K(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ac(n){return new Re(function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()})}function cc(n){return new Re(function(e){n.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,Ss)})}function uc(n){return new Re(function(e){var t,r;try{for(var s=Xe(n),o=s.next();!o.done;o=s.next()){var i=o.value;if(e.next(i),e.closed)return}}catch(a){t={error:a}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.complete()})}function ks(n){return new Re(function(e){lc(n,e).catch(function(t){return e.error(t)})})}function hc(n){return ks(sc(n))}function lc(n,e){var t,r,s,o;return xa(this,void 0,void 0,function(){var i,a;return ws(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),t=Ua(n),c.label=1;case 1:return[4,t.next()];case 2:if(r=c.sent(),!!r.done)return[3,4];if(i=r.value,e.next(i),e.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),s={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(o=t.return)?[4,o.call(t)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function fc(n,e){return Yt(function(t,r){var s=0;t.subscribe(Kt(r,function(o){r.next(n.call(e,o,s++))}))})}function dc(n,e){return Yt(function(t,r){var s=0;t.subscribe(Kt(r,function(o){return n.call(e,o,s++)&&r.next(o)}))})}function pc(n){n===void 0&&(n={});var e=n.connector,t=e===void 0?function(){return new Mt}:e,r=n.resetOnError,s=r===void 0?!0:r,o=n.resetOnComplete,i=o===void 0?!0:o,a=n.resetOnRefCountZero,c=a===void 0?!0:a;return function(h){var u,l,b,f=0,w=!1,y=!1,M=function(){l==null||l.unsubscribe(),l=void 0},D=function(){M(),u=b=void 0,w=y=!1},E=function(){var A=u;D(),A==null||A.unsubscribe()};return Yt(function(A,T){f++,!y&&!w&&M();var R=b=b??t();T.add(function(){f--,f===0&&!y&&!w&&(l=Qn(E,c))}),R.subscribe(T),!u&&f>0&&(u=new Tt({next:function(S){return R.next(S)},error:function(S){y=!0,M(),l=Qn(D,s,S),R.error(S)},complete:function(){w=!0,M(),l=Qn(D,i),R.complete()}}),Kn(A).subscribe(u))})(h)}}function Qn(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=arguments[r];if(e===!0){n();return}if(e!==!1){var s=new Tt({next:function(){s.unsubscribe(),n()}});return Kn(e.apply(void 0,Wt([],Jt(t)))).subscribe(s)}}function Ps(n,e,t){var r,s=!1;return r=n,pc({connector:function(){return new Qt(r,e,t)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:s})}function gc(n,e){return Yt(function(t,r){var s=null,o=0,i=!1,a=function(){return i&&!s&&r.complete()};t.subscribe(Kt(r,function(c){s==null||s.unsubscribe();var h=0,u=o++;Kn(n(c,u)).subscribe(s=Kt(r,function(l){return r.next(e?e(c,l,u,h++):l)},function(){s=null,a()}))},function(){i=!0,a()}))})}function vc(){return gc(As)}const bc={defaultTimeoutInMs:En,defaultTimeoutTokenInMs:Or,maxTimeoutsBeforeReconnect:kr,flagPermissionDenied:Pr,replaySubjectBufferSize:Nr};class Xt{constructor(e,t,r=bc){this.getConnection=e,this.logger=t,this.options=r,this.rejectResponsesTimeout=[50,100,200,400,800,1600,3200],this.timeoutCounter=0,this.subscription=Et.EMPTY,this.chunks=new Map,this.replaySubjectBufferSize=r.replaySubjectBufferSize,this.requestSubject=new Qt(this.replaySubjectBufferSize),this.jobs=new Map}setLogger(e){this.logger=e}reset(){this.logger.trace("requestModule.reset()"),this.requestSubject.complete(),this.requestSubject=new Qt(this.replaySubjectBufferSize),this.chunks.clear()}async requestWithQuality(e,t,r=this.options.defaultTimeoutInMs){return t==="BST"?this.requestBestQuality(e,r):(t&&Object.keys(pt.PRICE_QUALITY).includes(t)&&e.header.setQuality(t),this.request(e,r))}async requestEndpoint(e,t,r,s,o=this.options.defaultTimeoutInMs){const i=new ve(e,t,r,s);try{const a=await this.request(i,o);return this.logger.info(`Endpoint Response: [${e}] ${t}`,{request:r,response:a.data}),{response:a,data:a.data}}catch(a){const c=Mn(a);throw this.logger.warn(`Endpoint Request Failed. ${c.message}`,a),c}}async requestProxyEndpoint(e,t,r,s,o=this.options.defaultTimeoutInMs){const i=new Ke(e,t,s);r&&i.setBody(r);try{const a=await this.request(i,o);return this.logger.info(`Proxy Endpoint Response: [${e}] ${t}`,{request:r,response:a.data}),{response:a,data:a.data}}catch(a){const c=Mn(a);throw this.logger.warn(`Proxy Endpoint Request Failed. ${c.message}`,a),c}}async requestAuthenticationToken(e,t,r,s=this.options.defaultTimeoutTokenInMs){const o=new je(e,t,r,s);return(await this.request(o,s)).getToken()}async requestAuthenticationTokenExpiry(e,t,r,s=this.options.defaultTimeoutTokenInMs,o=!1){const i=new je(e,t,r,s,o),a=await this.request(i,s),c=a.getToken(),h=a.getExpiry();return{token:c,expiry:h}}async requestAuthenticationTokenFactorsForCookieAuthentication(e,t,r,s=this.options.defaultTimeoutTokenInMs){const o=await this.requestAuthenticationToken(e,t,r,s);return new os(o)}onConnection(){const e=this.getConnection();if(!e)throw new Error("Runtime error: Please assign a connection to the client instance.");this.subscription.closed&&(e.onMessage=this.handleMessage.bind(this),this.subscription=this.requestSubject.subscribe(this.sendRequest.bind(this)),this.logger.trace("onConnection"))}setUpdateMessageHandler(e){this.updateMessageHandler=e}setLossMessageHandler(e){this.lossMessageHandler=e}async request(e,t=this.options.defaultTimeoutInMs){const r=this.getConnection();if(!r)throw new Error("Runtime error: Please assign a connection to the client instance.");return Xt.supportedPermissionDeniedResponseMessages(e)&&this.options.flagPermissionDenied&&e.header.setFlag("permission_denied_response"),Xt.supportsChunkedResponse(e)&&e.header.setFlag("allow_chunked_response"),e.header.setTimeout(t),ms.getTracer("MDG2Client").startActiveSpan("RequestModule.request",async s=>{e.header.setTracing(s.spanContext());const o=`Request timeout reached (${t} ms) for ${e.getPtlMessage().Message}`,i=new Promise((a,c)=>{this.requestSubject.next({msg:e,insertedAt:Date.now(),resolve:a,reject:c})});return Ve.wrap(i,t,o).then(a=>(this.logger.trace("Reset timeout counter"),this.timeoutCounter=0,a)).catch(a=>{if(a.code===408){this.timeoutCounter++,this.logger.trace(`Increment timeout counter to ${this.timeoutCounter}`);const c=this.options.maxTimeoutsBeforeReconnect;this.timeoutCounter===c&&(this.logger.warn(`Closing connection due to max number of timeouts reached (${c})`),r.close(!0).catch(h=>{this.logger.error("Error while closing connection",h)}),this.timeoutCounter=0)}else{const c=Mn(a);this.logger.trace(`Endpoint Request Failed. ${c.message}`)}throw a}).finally(()=>{s.end()})})}reRequest(e){this.requestSubject.next({msg:e.msg,resolve:e.resolve,reject:e.reject})}async requestBestQuality(e,t=this.options.defaultTimeoutInMs){const r=["RLT","DLY","EOD"];for(let s=0;s<r.length;s++){e.header.setQuality(r[s]);const o=this.request(e,t);try{return await o}catch(i){this.logger.debug(`Failed to perform request in "${r[s]}" quality.`,i,e)}if(s===r.length-1)return o}return{Message:"Should never happen",Version:1}}prependCollectedChunks(e){const t=this.chunks.get(e.header.id_job);if(t===void 0)return;this.logger.trace("Prepending previous chunks to message",e);let r="";t.forEach(s=>{this.logger.trace("Prepending previous chunk to message",s),r+=s.body.value,e.header.processingTime+=s.header.processingTime}),r+=e.body.value,e.body.value=r,this.chunks.delete(e.header.id_job)}collectChunk(e){var t;this.chunks.has(e.header.id_job)?(t=this.chunks.get(e.header.id_job))==null||t.push(e):this.chunks.set(e.header.id_job,[e])}handleMessage(e){let t;if(Kr(e)){if(qt.hasNextChunk(e)){this.logger.trace("Received message chunk",e),this.collectChunk(e);return}this.prependCollectedChunks(e)}try{t=qt.createMessage(e)}catch(o){this.logger.error("Problem while creating message",o,e);return}const{jobId:r}=t,s=this.jobs.get(r);if(t.isUpdateMessage()&&this.updateMessageHandler){this.updateMessageHandler(t,r);return}if(t.isLossMessage()&&this.lossMessageHandler){this.lossMessageHandler(t,r),this.jobs.delete(r);return}if(!s){this.logger.error(`Could not find idJob ${r}`,e);return}if(Qr(t)){this.logger.debug(`RejectResponse received for idJob ${r}`,e),this.rejectResponseHandler(s);return}if(zr(t)||Vr(t)){const o={request:s.request,response:t};this.logger.warn(`Received ${t.name} with idJob: ${r}`,o),s.reject(t),this.jobs.delete(r);return}this.logger.trace(`Received ${t.name} with idJob: ${r}`,t),this.jobs.delete(r),s.resolve(t)}rejectResponseHandler(e){const t=this.getRejectResponseTimeout(e.msg.header.getResendCounter()),r=e.expirationTime-Date.now()-t;if(r<1){const s=`Timeout for idJob ${e.msg.header.getJobId()}`;this.logger.error(s),e.reject(new X({Message:"Foundation::ErrorResponse",Version:1,id_job:e.msg.header.getJobId(),reason:8,details:s}))}this.logger.debug(`Retry request after ${t}ms for idJob ${e.msg.header.getJobId()}`),setTimeout(()=>{e.msg.header.setTimeout(r),e.msg.header.countResend(),this.reRequest(e)},t)}getRejectResponseTimeout(e=0){const t=this.rejectResponsesTimeout.length-1;return this.rejectResponsesTimeout[e]??this.rejectResponsesTimeout[t]}async sendRequest(e){const t=this.getConnection();if(!t){e.reject("Runtime error: Please assign a connection to the client instance.");return}for(;!t.isAuthenticated();){if(e.insertedAt&&e.insertedAt+e.msg.header.getTimeout()<Date.now()){e.reject("sendRequest timeout reached");return}await new Promise(a=>{setTimeout(()=>{a("Timeout reached")},1e3)})}e.msg.header.setIdApplication(t.auth.idApplication),e.msg.header.setIdUser(t.auth.idUser);const r=e.msg.getPtlMessage(),s=t.send(r).idJob;e.msg.header.setJobId(s);const o={json:r};(r.Message===ve.NAME||r.Message===Ke.NAME)&&typeof e.msg.getData=="function"&&(o.data=e.msg.getData());const i={msg:e.msg,expirationTime:Date.now()+e.msg.header.getTimeout(),resolve:e.resolve,reject:e.reject,request:o};this.jobs.set(s,i),this.logger.trace(`Sending ${r.Message} with idJob: ${s}`,o)}clearPendingRequests(){this.jobs.forEach((e,t)=>{const r=new X({Message:"Foundation::ErrorResponse",header:{id_job:t,id_service:"0"},reason:{value:1001}});e.reject(r)}),this.jobs.clear(),this.reset()}static supportedPermissionDeniedResponseMessages(e){const t=[ve];for(const r of t)if(e instanceof r)return!0;return!1}static supportsChunkedResponse(e){return e instanceof ve&&!e.header.isFlagValueSet("add_subscription")}}/*!
|
|
4
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
5
|
+
* (c) 2017-2022 Joachim Wester
|
|
6
|
+
* MIT licensed
|
|
7
|
+
*/var mc=function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)s.hasOwnProperty(o)&&(r[o]=s[o])},n(e,t)};return function(e,t){n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),yc=Object.prototype.hasOwnProperty;function Xn(n,e){return yc.call(n,e)}function Zn(n){if(Array.isArray(n)){for(var e=new Array(n.length),t=0;t<e.length;t++)e[t]=""+t;return e}if(Object.keys)return Object.keys(n);var r=[];for(var s in n)Xn(n,s)&&r.push(s);return r}function se(n){switch(typeof n){case"object":return JSON.parse(JSON.stringify(n));case"undefined":return null;default:return n}}function er(n){for(var e=0,t=n.length,r;e<t;){if(r=n.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}function Ue(n){return n.indexOf("/")===-1&&n.indexOf("~")===-1?n:n.replace(/~/g,"~0").replace(/\//g,"~1")}function Ns(n){return n.replace(/~1/g,"/").replace(/~0/g,"~")}function tr(n){if(n===void 0)return!0;if(n){if(Array.isArray(n)){for(var e=0,t=n.length;e<t;e++)if(tr(n[e]))return!0}else if(typeof n=="object"){for(var r=Zn(n),s=r.length,o=0;o<s;o++)if(tr(n[r[o]]))return!0}}return!1}function js(n,e){var t=[n];for(var r in e){var s=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof s<"u"&&t.push(r+": "+s)}return t.join(`
|
|
8
|
+
`)}var Ds=function(n){mc(e,n);function e(t,r,s,o,i){var a=this.constructor,c=n.call(this,js(t,{name:r,index:s,operation:o,tree:i}))||this;return c.name=r,c.index=s,c.operation=o,c.tree=i,Object.setPrototypeOf(c,a.prototype),c.message=js(t,{name:r,index:s,operation:o,tree:i}),c}return e}(Error),B=Ds,wc=se,et={add:function(n,e,t){return n[e]=this.value,{newDocument:t}},remove:function(n,e,t){var r=n[e];return delete n[e],{newDocument:t,removed:r}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:function(n,e,t){var r=Zt(t,this.path);r&&(r=se(r));var s=$e(t,{op:"remove",path:this.from}).removed;return $e(t,{op:"add",path:this.path,value:s}),{newDocument:t,removed:r}},copy:function(n,e,t){var r=Zt(t,this.from);return $e(t,{op:"add",path:this.path,value:se(r)}),{newDocument:t}},test:function(n,e,t){return{newDocument:t,test:St(n[e],this.value)}},_get:function(n,e,t){return this.value=n[e],{newDocument:t}}},_c={add:function(n,e,t){return er(e)?n.splice(e,0,this.value):n[e]=this.value,{newDocument:t,index:e}},remove:function(n,e,t){var r=n.splice(e,1);return{newDocument:t,removed:r[0]}},replace:function(n,e,t){var r=n[e];return n[e]=this.value,{newDocument:t,removed:r}},move:et.move,copy:et.copy,test:et.test,_get:et._get};function Zt(n,e){if(e=="")return n;var t={op:"_get",path:e};return $e(n,t),t.value}function $e(n,e,t,r,s,o){if(t===void 0&&(t=!1),r===void 0&&(r=!0),s===void 0&&(s=!0),o===void 0&&(o=0),t&&(typeof t=="function"?t(e,0,n,e.path):tn(e,0)),e.path===""){var i={newDocument:n};if(e.op==="add")return i.newDocument=e.value,i;if(e.op==="replace")return i.newDocument=e.value,i.removed=n,i;if(e.op==="move"||e.op==="copy")return i.newDocument=Zt(n,e.from),e.op==="move"&&(i.removed=n),i;if(e.op==="test"){if(i.test=St(n,e.value),i.test===!1)throw new B("Test operation failed","TEST_OPERATION_FAILED",o,e,n);return i.newDocument=n,i}else{if(e.op==="remove")return i.removed=n,i.newDocument=null,i;if(e.op==="_get")return e.value=n,i;if(t)throw new B("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,e,n);return i}}else{r||(n=se(n));var a=e.path||"",c=a.split("/"),h=n,u=1,l=c.length,b=void 0,f=void 0,w=void 0;for(typeof t=="function"?w=t:w=tn;;){if(f=c[u],f&&f.indexOf("~")!=-1&&(f=Ns(f)),s&&(f=="__proto__"||f=="prototype"&&u>0&&c[u-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(t&&b===void 0&&(h[f]===void 0?b=c.slice(0,u).join("/"):u==l-1&&(b=e.path),b!==void 0&&w(e,0,n,b)),u++,Array.isArray(h)){if(f==="-")f=h.length;else{if(t&&!er(f))throw new B("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,e,n);er(f)&&(f=~~f)}if(u>=l){if(t&&e.op==="add"&&f>h.length)throw new B("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,e,n);var i=_c[e.op].call(e,h,f,n);if(i.test===!1)throw new B("Test operation failed","TEST_OPERATION_FAILED",o,e,n);return i}}else if(u>=l){var i=et[e.op].call(e,h,f,n);if(i.test===!1)throw new B("Test operation failed","TEST_OPERATION_FAILED",o,e,n);return i}if(h=h[f],t&&u<l&&(!h||typeof h!="object"))throw new B("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,e,n)}}}function en(n,e,t,r,s){if(r===void 0&&(r=!0),s===void 0&&(s=!0),t&&!Array.isArray(e))throw new B("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(n=se(n));for(var o=new Array(e.length),i=0,a=e.length;i<a;i++)o[i]=$e(n,e[i],t,!0,s,i),n=o[i].newDocument;return o.newDocument=n,o}function Ec(n,e,t){var r=$e(n,e);if(r.test===!1)throw new B("Test operation failed","TEST_OPERATION_FAILED",t,e,n);return r.newDocument}function tn(n,e,t,r){if(typeof n!="object"||n===null||Array.isArray(n))throw new B("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,n,t);if(et[n.op]){if(typeof n.path!="string")throw new B("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,n,t);if(n.path.indexOf("/")!==0&&n.path.length>0)throw new B('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,n,t);if((n.op==="move"||n.op==="copy")&&typeof n.from!="string")throw new B("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&n.value===void 0)throw new B("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,n,t);if((n.op==="add"||n.op==="replace"||n.op==="test")&&tr(n.value))throw new B("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,n,t);if(t){if(n.op=="add"){var s=n.path.split("/").length,o=r.split("/").length;if(s!==o+1&&s!==o)throw new B("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,n,t)}else if(n.op==="replace"||n.op==="remove"||n.op==="_get"){if(n.path!==r)throw new B("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,n,t)}else if(n.op==="move"||n.op==="copy"){var i={op:"_get",path:n.from,value:void 0},a=xs([i],t);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new B("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,n,t)}}}else throw new B("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,n,t)}function xs(n,e,t){try{if(!Array.isArray(n))throw new B("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)en(se(e),se(n),t||!0);else{t=t||tn;for(var r=0;r<n.length;r++)t(n[r],r,e,void 0)}}catch(s){if(s instanceof B)return s;throw s}}function St(n,e){if(n===e)return!0;if(n&&e&&typeof n=="object"&&typeof e=="object"){var t=Array.isArray(n),r=Array.isArray(e),s,o,i;if(t&&r){if(o=n.length,o!=e.length)return!1;for(s=o;s--!==0;)if(!St(n[s],e[s]))return!1;return!0}if(t!=r)return!1;var a=Object.keys(n);if(o=a.length,o!==Object.keys(e).length)return!1;for(s=o;s--!==0;)if(!e.hasOwnProperty(a[s]))return!1;for(s=o;s--!==0;)if(i=a[s],!St(n[i],e[i]))return!1;return!0}return n!==n&&e!==e}const Tc=Object.freeze(Object.defineProperty({__proto__:null,JsonPatchError:B,_areEquals:St,applyOperation:$e,applyPatch:en,applyReducer:Ec,deepClone:wc,getValueByPointer:Zt,validate:xs,validator:tn},Symbol.toStringTag,{value:"Module"}));/*!
|
|
9
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
10
|
+
* (c) 2017-2021 Joachim Wester
|
|
11
|
+
* MIT license
|
|
12
|
+
*/var nr=new WeakMap,Mc=function(){function n(e){this.observers=new Map,this.obj=e}return n}(),Sc=function(){function n(e,t){this.callback=e,this.observer=t}return n}();function Ic(n){return nr.get(n)}function Ac(n,e){return n.observers.get(e)}function Rc(n,e){n.observers.delete(e.callback)}function Cc(n,e){e.unobserve()}function Oc(n,e){var t=[],r,s=Ic(n);if(!s)s=new Mc(n),nr.set(n,s);else{var o=Ac(s,e);r=o&&o.observer}if(r)return r;if(r={},s.value=se(n),e){r.callback=e,r.next=null;var i=function(){rr(r)},a=function(){clearTimeout(r.next),r.next=setTimeout(i)};typeof window<"u"&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a))}return r.patches=t,r.object=n,r.unobserve=function(){rr(r),clearTimeout(r.next),Rc(s,r),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},s.observers.set(e,new Sc(e,r)),r}function rr(n,e){e===void 0&&(e=!1);var t=nr.get(n.object);sr(t.value,n.object,n.patches,"",e),n.patches.length&&en(t.value,n.patches);var r=n.patches;return r.length>0&&(n.patches=[],n.callback&&n.callback(r)),r}function sr(n,e,t,r,s){if(e!==n){typeof e.toJSON=="function"&&(e=e.toJSON());for(var o=Zn(e),i=Zn(n),a=!1,c=i.length-1;c>=0;c--){var h=i[c],u=n[h];if(Xn(e,h)&&!(e[h]===void 0&&u!==void 0&&Array.isArray(e)===!1)){var l=e[h];typeof u=="object"&&u!=null&&typeof l=="object"&&l!=null&&Array.isArray(u)===Array.isArray(l)?sr(u,l,t,r+"/"+Ue(h),s):u!==l&&(s&&t.push({op:"test",path:r+"/"+Ue(h),value:se(u)}),t.push({op:"replace",path:r+"/"+Ue(h),value:se(l)}))}else Array.isArray(n)===Array.isArray(e)?(s&&t.push({op:"test",path:r+"/"+Ue(h),value:se(u)}),t.push({op:"remove",path:r+"/"+Ue(h)}),a=!0):(s&&t.push({op:"test",path:r,value:n}),t.push({op:"replace",path:r,value:e}))}if(!(!a&&o.length==i.length))for(var c=0;c<o.length;c++){var h=o[c];!Xn(n,h)&&e[h]!==void 0&&t.push({op:"add",path:r+"/"+Ue(h),value:se(e[h])})}}}function kc(n,e,t){t===void 0&&(t=!1);var r=[];return sr(n,e,r,"",t),r}Object.assign({},Tc,Object.freeze(Object.defineProperty({__proto__:null,compare:kc,generate:rr,observe:Oc,unobserve:Cc},Symbol.toStringTag,{value:"Module"})),{JsonPatchError:Ds,deepClone:se,escapePathComponent:Ue,unescapePathComponent:Ns});const Rt=class Rt{constructor(e,t,r){this.resultMapper=fc(s=>{if(Ut(s)){const o=this.applyEndpointJsonPatchUpdate(s.jobId,s.data);return{response:o,data:o.data}}return{response:s,data:s.data}}),this.requestToJobMapper=new Map,this.requestModule=e,this.subjectManager=t,this.responses={},this.logger=r}setLogger(e){this.logger=e}observe(e,t,r,s,o){this.validateOptions(s);const i=new Mt,a=new Qt(1),c=a.pipe(vc()),h=i.asObservable().pipe(Rt.highLevelResponseFilter,this.resultMapper.bind(this));return this.requestModule.requestEndpoint(e,t,r,{...o,subscribe:!0}).then(u=>{this.subjectManager.registerJobSubject(u.response.jobId,i),this.registerEndpointRequest(u.response.jobId,a,c,e,t,r,s),this.registerEndpointResponse(u.response.jobId,u.response),h.idJob=u.response.jobId,a.next(h.pipe(Ps(1))),c.idJob=u.response.jobId,i.next(u.response)}).catch(u=>{this.logger.warn("Subscription request failed.",u),a.error(u)}),c}async unobserve(e){if(!this.subjectManager.hasJobSubject(e)){this.logger.warn(`Could not find subscription for idJob "${e}".`);return}await this.requestModule.request(new Ae(e)),this.requestToJobMapper.delete(e.toString()),this.subjectManager.removeJobSubject(e)}findSubject(e){return this.subjectManager.getJobSubject(e)}registerEndpointResponse(e,t){this.responses[e]=t}registerEndpointRequest(e,t,r,s,o,i,a,c){this.requestToJobMapper.set(e.toString(),{path:o,subject:t,observable:r,data:i,method:s,options:a,requestOptions:c})}applyEndpointJsonPatchUpdate(e,t){const r=this.responses[e],s=en(r,t).newDocument;return this.responses[e]=s,s}restartSubscriptions(){const e=Array.from(this.subjectManager.jobs.keys()),t=new Map(this.requestToJobMapper);this.requestToJobMapper.clear(),this.subjectManager.jobs.clear(),e.forEach(r=>{const s=t.get(r);s&&this.resubscribe(s)})}restartSubscription(e){const t=new Map(this.requestToJobMapper);if(this.requestToJobMapper.clear(),e){const r=t.get(e.toString());r&&setTimeout(()=>{this.resubscribe(r)},Io)}}resubscribe(e){this.validateOptions(e.options);const t=new Mt,r=t.asObservable().pipe(Rt.highLevelResponseFilter,this.resultMapper.bind(this));this.requestModule.requestEndpoint(e.method,e.path,e.data,{...e.requestOptions,subscribe:!0}).then(s=>{this.subjectManager.registerJobSubject(s.response.jobId,t),this.registerEndpointResponse(s.response.jobId,s.response),e.observable.idJob=s.response.jobId,e.subject.next(r.pipe(Ps(1))),t.next(s.response),this.registerEndpointRequest(s.response.jobId,e.subject,e.observable,e.method,e.path,e.data,e.options,e.requestOptions)}).catch(s=>{this.logger.warn("Request failed during initial request for restarting endpoint subscription",s)})}validateOptions(e){({...nn.defaultObserveOptions,...e}).minInterval&&this.logger.warn("Option `minInterval` is deprecated. Use _subscriptionMinimumInterval (GET) or meta.subscription.minimumInterval (POST) for server side throttling.")}};Rt.highLevelResponseFilter=dc(e=>Yr(e)||Ut(e));let or=Rt;class Pc{constructor(e){this.job=new Map,this.logger=e}hasJobSubject(e){return this.job.has(String(e))}registerJobSubject(e,t){const r=String(e);this.job.set(r,t)}findJobSubject(e){const t=String(e);if(!this.job.has(t))throw new Error(`could not find job subject for id=${e}`);return this.job.get(t)}removeJobSubject(e){const t=String(e);if(!this.job.has(t)){this.logger.warn(`No subject found for idJob ${t}`);return}this.job.delete(t)}getJobSubject(e){const t=String(e);if(!this.job.has(t)){this.logger.warn(`No subject found for idJob ${t}`);return}return this.job.get(t)}get jobs(){return this.job}}const Nc={shouldRestartSubscriptions:!1},ur=class ur{constructor(e,t,r=Nc){this.logger=t,this.options=r,this.subjectManager=new Pc(this.logger),this.handler={endpoint:new or(e,this.subjectManager,this.logger)},e.setUpdateMessageHandler(this.updateHandler.bind(this)),e.setLossMessageHandler(this.lossHandler.bind(this))}setLogger(e){this.logger=e,this.handler.endpoint.setLogger(e)}observeEndpoint(e,t,r,s,o){return this.handler.endpoint.observe(e,t,r,s,o)}async unobserveEndpoint(e){return this.handler.endpoint.unobserve(e)}restartSubscriptions(){this.handler.endpoint.restartSubscriptions()}clearPendingSubscriptions(){this.subjectManager.jobs.forEach((e,t)=>{const r=new Lt({Message:"Foundation::SubscriptionLossMessage",Version:2,header:{id_job:parseInt(t,10),id_service:0},reason:{value:1}});e.error(r)}),this.subjectManager.jobs.clear()}clearPendingSubscription(e){this.subjectManager.jobs.forEach((t,r)=>{if(e===Number(r)){const s=new Lt({Message:"Foundation::SubscriptionLossMessage",Version:2,header:{id_job:parseInt(r,10),id_service:0},reason:{value:1}});t.error(s)}}),this.subjectManager.jobs.delete(e.toString())}lossHandler(e){try{const t=this.findSubject(e),{jobId:r}=e;this.logger.debug(`Received Loss Message ${e.name}`,e),t.error(`Subscription lost: ${JSON.stringify(e)}`),this.options.shouldRestartSubscriptions&&this.handler.endpoint.restartSubscription(r)}catch{this.logger.warn("Received Loss Message but could not find corresponding subject",e)}}updateHandler(e){try{const t=this.findSubject(e);this.logger.debug(`Received Update Message ${e.name}`,e),t.next(e)}catch{this.logger.warn("Received Update Message but could not find corresponding subject",e)}}findSubject(e){if(Ut(e)||Xr(e)){const t=this.subjectManager.findJobSubject(e.jobId);if(t)return t}throw new Error(`Received unknown message: ${e.name}`)}};ur.defaultObserveOptions={quality:Cr};let nn=ur;class rn{constructor(e,t={}){this.options=t,this.flagPermissionDenied=t.flagPermissionDenied??Pr,this.shouldRestartSubscriptions=t.shouldRestartSubscriptions??!0,this.defaultTimeoutInMs=t.defaultTimeoutInMs??En,this.defaultTimeoutTokenInMs=t.defaultTimeoutTokenInMs??Or,this.maxTimeoutsBeforeReconnect=t.maxTimeoutsBeforeReconnect??kr,this.enableSessionHandling=t.enableSessionHandling??So,this.replaySubjectBufferSize=t.replaySubjectBufferSize??Nr,this.requestModule=new Xt(this.getConnection.bind(this),this.logger,{defaultTimeoutInMs:this.defaultTimeoutInMs,defaultTimeoutTokenInMs:this.defaultTimeoutTokenInMs,flagPermissionDenied:this.flagPermissionDenied,maxTimeoutsBeforeReconnect:this.maxTimeoutsBeforeReconnect,replaySubjectBufferSize:this.replaySubjectBufferSize}),this.subscriptionModule=new nn(this.requestModule,this.logger,{shouldRestartSubscriptions:this.shouldRestartSubscriptions}),this.sessionConnect=!1,t.onConnectCallback&&(this.onConnectCallback=t.onConnectCallback),e?this.setConnection(e):this.logger=new at}async connect(){if(!this.connection)throw new Error("No connection defined. please set a connection before trying to connect.");return this.sessionConnect?Promise.resolve():this.connection.open()}async connectSession(e=!1){if(!this.connection)throw new Error("No connection defined. please set a connection before trying to connect.");const{connection:t}=this,r=new On,s=new dt(r,{...this.connection.options,sessionHandling:!0});this.setConnection(s);try{await this.connection.open()}catch(o){if(this.setConnection(t),e)throw o;return!1}return!0}async disconnect(e=!1){if(!this.connection)throw new Error("No connection defined. please set a connection before trying to disconnect.");await this.connection.close(!1,e)}async request(e,t=this.defaultTimeoutInMs){return this.requestModule.request(e,t)}restartSubscriptions(){this.subscriptionModule.restartSubscriptions()}async requestWithQuality(e,t=Cr,r=this.defaultTimeoutInMs){return this.requestModule.requestWithQuality(e,t,r)}async requestEndpoint(e,t,r,s,o=this.defaultTimeoutInMs){return this.requestModule.requestEndpoint(e,t,r,s,o)}async requestProxyEndpoint(e,t,r,s,o=this.defaultTimeoutInMs){return this.requestModule.requestProxyEndpoint(e,t,r,s,o)}async requestAuthenticationToken(e,t,r,s=this.defaultTimeoutTokenInMs){return this.requestModule.requestAuthenticationToken(e,t,r,s)}async requestAuthenticationTokenExpiry(e,t,r,s=this.defaultTimeoutTokenInMs,o=!1){return this.requestModule.requestAuthenticationTokenExpiry(e,t,r,s,o)}async requestOtpAuthenticationTokenForSessionHandling(e=je.LIFETIME_SECONDS_MAXIMUM,t=-2,r=-2,s=this.defaultTimeoutTokenInMs){const{token:o,expiry:i}=await this.requestModule.requestAuthenticationTokenExpiry(e,t,r,s,!0);this.options.otpToken=o,this.options.otpTokenExpiry=i}async requestAuthenticationTokenForCookieTokenAuthentication(e,t,r,s=this.defaultTimeoutTokenInMs){return this.requestModule.requestAuthenticationTokenFactorsForCookieAuthentication(e,t,r,s)}observeEndpoint(e,t,r,s,o){return this.subscriptionModule.observeEndpoint(e,t,r,s,o)}async unobserveEndpoint(e){return this.subscriptionModule.unobserveEndpoint(e)}setConnection(e){e.options.logger&&this.setLogger(e.options.logger),this.isConnected&&this.logger.warn("Cannot modify an open connection. Disconnect first, before trying to set the connection."),this.connection=e,this.connection.clientOptions=this.options,this.connection.shouldRestartSubscriptions=this.shouldRestartSubscriptions,this.connection.onAuthentication=this.requestModule.onConnection.bind(this.requestModule),this.connection.onCleanupRequests=this.requestModule.clearPendingRequests.bind(this.requestModule),this.connection.onCleanupSubscriptions=this.subscriptionModule.clearPendingSubscriptions.bind(this.subscriptionModule),this.connection.onClearPendingSubscription=t=>{this.subscriptionModule.clearPendingSubscription(t)},this.connection.restartSubscriptions=this.subscriptionModule.restartSubscriptions.bind(this.subscriptionModule),this.connection.onConnect=this.onConnectCallback}getConnection(){return this.connection}async setConnectionFromFetchConfiguration(e,t,r){if(this.enableSessionHandling&&this.setConnectionFromSavedConfig()&&await this.connectSession())return this.sessionConnect=!0,Promise.resolve();const{config:s,response:o}=await Ft(e,t);return this.enableSessionHandling&&Jr(s),this.setConnection(rn.createConnection({...s,logger:this.logger,loglevel:this.logger.getLevel(),shouldReconnectOnConnectionLoss:r},e,t)),o}static createConnection(e,t,r){return Br(e,t,r)}setLogger(e){this.logger=e,this.requestModule.setLogger(e),this.subscriptionModule.setLogger(e),this.connection&&this.connection.setLogger(e)}getLogger(){return this.logger}get isConnected(){var e;return((e=this.connection)==null?void 0:e.isAuthenticated())??!1}get isConnecting(){var e;return((e=this.connection)==null?void 0:e.isConnecting())??!1}getServerInfo(){var e;return(e=this.connection)==null?void 0:e.auth.getServerInfo()}setConnectionFromSavedConfig(){const e=Wr();return e?(this.setConnection(rn.createConnection({...e,logger:this.logger,loglevel:this.logger.getLevel()})),!0):!1}}function ir(n,e={},t){for(const r in n){const s=n[r],o=t?`${t}:${r}`:r;typeof s=="object"&&s!==null?ir(s,e,o):typeof s=="function"&&(e[o]=s)}return e}const jc={run:n=>n()},Dc=()=>jc,Fs=typeof console.createTask<"u"?console.createTask:Dc;function xc(n,e){const t=e.shift(),r=Fs(t);return n.reduce((s,o)=>s.then(()=>r.run(()=>o(...e))),Promise.resolve())}function Fc(n,e){const t=e.shift(),r=Fs(t);return Promise.all(n.map(s=>r.run(()=>s(...e))))}function ar(n,e){for(const t of[...n])t(e)}class Uc{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,r={}){if(!e||typeof t!="function")return()=>{};const s=e;let o;for(;this._deprecatedHooks[e];)o=this._deprecatedHooks[e],e=o.to;if(o&&!r.allowDeprecated){let i=o.message;i||(i=`${s} hook has been deprecated`+(o.to?`, please use ${o.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!t.name)try{Object.defineProperty(t,"name",{get:()=>"_"+e.replace(/\W+/g,"_")+"_hook_cb",configurable:!0})}catch{}return this._hooks[e]=this._hooks[e]||[],this._hooks[e].push(t),()=>{t&&(this.removeHook(e,t),t=void 0)}}hookOnce(e,t){let r,s=(...o)=>(typeof r=="function"&&r(),r=void 0,s=void 0,t(...o));return r=this.hook(e,s),r}removeHook(e,t){if(this._hooks[e]){const r=this._hooks[e].indexOf(t);r!==-1&&this._hooks[e].splice(r,1),this._hooks[e].length===0&&delete this._hooks[e]}}deprecateHook(e,t){this._deprecatedHooks[e]=typeof t=="string"?{to:t}:t;const r=this._hooks[e]||[];delete this._hooks[e];for(const s of r)this.hook(e,s)}deprecateHooks(e){Object.assign(this._deprecatedHooks,e);for(const t in e)this.deprecateHook(t,e[t])}addHooks(e){const t=ir(e),r=Object.keys(t).map(s=>this.hook(s,t[s]));return()=>{for(const s of r.splice(0,r.length))s()}}removeHooks(e){const t=ir(e);for(const r in t)this.removeHook(r,t[r])}removeAllHooks(){for(const e in this._hooks)delete this._hooks[e]}callHook(e,...t){return t.unshift(e),this.callHookWith(xc,e,...t)}callHookParallel(e,...t){return t.unshift(e),this.callHookWith(Fc,e,...t)}callHookWith(e,t,...r){const s=this._before||this._after?{name:t,args:r,context:{}}:void 0;this._before&&ar(this._before,s);const o=e(t in this._hooks?[...this._hooks[t]]:[],r);return o instanceof Promise?o.finally(()=>{this._after&&s&&ar(this._after,s)}):(this._after&&s&&ar(this._after,s),o)}beforeEach(e){return this._before=this._before||[],this._before.push(e),()=>{if(this._before!==void 0){const t=this._before.indexOf(e);t!==-1&&this._before.splice(t,1)}}}afterEach(e){return this._after=this._after||[],this._after.push(e),()=>{if(this._after!==void 0){const t=this._after.indexOf(e);t!==-1&&this._after.splice(t,1)}}}}function $c(){return new Uc}const Us=typeof window<"u";function Lc(n,e={}){const t={inspect:Us,group:Us,filter:()=>!0,...e},r=t.filter,s=typeof r=="string"?u=>u.startsWith(r):r,o=t.tag?`[${t.tag}] `:"",i=u=>o+u.name+"".padEnd(u._id,"\0"),a={},c=n.beforeEach(u=>{s!==void 0&&!s(u.name)||(a[u.name]=a[u.name]||0,u._id=a[u.name]++,console.time(i(u)))}),h=n.afterEach(u=>{s!==void 0&&!s(u.name)||(t.group&&console.groupCollapsed(u.name),t.inspect?console.timeLog(i(u),u.args):console.timeEnd(i(u)),t.group&&console.groupEnd(),a[u.name]--)});return{close:()=>{c(),h()}}}class $s{constructor(e){O(this,He);this.hooks=$c(),C(this,He,1e4),e!=null&&e.hookDebug&&Lc(this.hooks,{tag:"hooks"}),e!=null&&e.defaultRequestTimeout&&C(this,He,e.defaultRequestTimeout)}get defaultTimeoutInMs(){return v(this,He)}set defaultTimeoutInMs(e){C(this,He,e)}log(e,...t){if(this.hooks.callHook("base:log",t),this.logger)switch(e){case m.TRACE:this.logger.trace(t);break;case m.DEBUG:this.logger.debug(t);break;case m.INFO:this.logger.info(t);break;case m.WARN:this.logger.warn(t);break;case m.ERROR:this.logger.error(t);break;case m.FATAL:this.logger.fatal(t);break}}}He=new WeakMap;const an=class an{constructor(e,t=[],r=[],s=[]){O(this,ae);O(this,qe);O(this,Ge,[]);O(this,Oe,[]);O(this,ke,[]);C(this,qe,e),C(this,Ge,t),C(this,Oe,r),C(this,ke,s)}static create(){return new an($s)}with(e){const{featureName:t,disabledFeatures:r,disabledFeatureGroups:s,featureGroups:o}=e;if(!t)throw new Error("Feature name is missing");if(H(this,ae,Ks).call(this,t),H(this,ae,Qs).call(this,t),v(this,Ge).push(t),o&&o.length>0)for(const a of o)H(this,ae,Xs).call(this,a);if(r&&r.length>0)for(const a of r)H(this,ae,Zs).call(this,t,a);if(s&&s.length>0)for(const a of s)H(this,ae,eo).call(this,t,a);const i=e(v(this,qe));return new an(i,v(this,Ge),v(this,Oe),v(this,ke))}build(e){return new(v(this,qe))(e)}getClientConstructor(){return v(this,qe)}};qe=new WeakMap,Ge=new WeakMap,Oe=new WeakMap,ke=new WeakMap,ae=new WeakSet,Ks=function(e){if(v(this,Ge).includes(e))throw new Error(`Feature "${e}" has already been used.`)},Qs=function(e){for(const t of v(this,Oe))if(t.feature===e)throw new Error(`Feature "${e}" has been disabled by ${t.disabler.join(",")}.`)},Xs=function(e){for(const t of v(this,ke))if(t.feature===e)throw new Error(`Group "${e}" has been disabled by ${t.disabler.join(",")}.`)},Zs=function(e,t){for(const r of v(this,Oe))if(r.feature===t){r.disabler.push(e);return}v(this,Oe).push({disabler:[e],feature:t})},eo=function(e,t){for(const r of v(this,ke))if(r.feature===t){r.disabler.push(e);return}v(this,ke).push({disabler:[e],feature:t})};let cr=an;d.AbstractAuthentication=Pt,d.AbstractFrontgateConnection=xt,d.AbstractLogger=Ee,d.AbstractMdg2Request=Ye,d.AuthenticationByTokenRequest=gt,d.AuthenticationTokenRequest=je,d.AuthenticationTokenResponse=In,d.CancelSubscriptionRequest=Ae,d.CancelSubscriptionResponse=ns,d.ConnectionState=Ie,d.ConsoleLogger=un,d.CookieTokenAuthentication=On,d.CookieTokenAuthenticationFactors=os,d.DefaultHosts=Lr,d.DeploymentStage=$r,d.Encoding=Se,d.ErrorResponse=X,d.FetchConnectionConfigurationResponseHeaders=Hr,d.FrontgateClient=$s,d.FrontgateClientBuilder=cr,d.FrontgateClientDataObserver=Nn,d.FrontgateClientEndpointDataObserver=cs,d.FrontgateWSConnection=dt,d.HTTPProxyRequest=Ke,d.HTTPProxyResponse=Rn,d.HighLevelRequest=ve,d.HighLevelResponse=An,d.HighLevelUpdate=$t,d.ID_APP_AUTHENTICATED=-2,d.ID_USER_AUTHENTICATED=-2,d.ID_USER_NONE=-1,d.LatencyTracker=kn,d.LogLevel=m,d.LoggerHelper=to,d.Mdg2Client=rn,d.Mdg2Response=ne,d.NullLogger=at,d.PermissionDeniedResponse=rs,d.PingRequest=ft,d.PingResponse=ze,d.RawRequest=ts,d.RawRequestFactory=Sn,d.RejectResponse=ss,d.SubscriptionLossMessage=Lt,d.TimeOptions=Ur,d.TokenAuthentication=Cn,d.TransportLayerClientRequestHeader=pt,d.WinstonLogger=ro,d.authTokenRequest=ii,d.cookieTokenAuth=mi,d.createConnection=Br,d.createConnectionInterface=_i,d.createExtendedMixinFactory=Z,d.encodeSpanContext=ys,d.endpointRequest=ai,d.endpointSubscriptions=li,d.fetchAuth=wi,d.fetchConnectionConfiguration=Ft,d.getBytesFromBuffer=Zo,d.getConnectionConfiguration=Wr,d.httpProxyRequest=Da,d.isErrorResponse=zr,d.isHighLevelResponse=Yr,d.isHighLevelResponseMessage=Kr,d.isHighLevelUpdate=Ut,d.isPermissionDeniedResponse=Vr,d.isRejectResponse=Qr,d.isSubscriptionLossMessage=Xr,d.levels=no,d.logger=ci,d.messageCompressor=ui,d.objectFromFetchHeaders=Gr,d.openTelemetry=ja,d.parseConnectionConfiguration=qr,d.rawSubscriptions=fi,d.reconnect=Ei,d.requests=hi,d.setConnectionConfiguration=Jr,d.timeToMilliseconds=Dt,d.tokenAuth=yi,d.useTimeout=ge,d.wsConnection=as,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|