(function(s,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.dasf={}))})(this,function(s){"use strict";var K=Object.defineProperty;var x=(s,d,y)=>d in s?K(s,d,{enumerable:!0,configurable:!0,writable:!0,value:y}):s[d]=y;var a=(s,d,y)=>x(s,typeof d!="symbol"?d+"":d,y);var d={},y={},I={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE",e[e.LOGGING=2]="LOGGING"}(o.OperationMode||(o.OperationMode={})),function(e){e[e.CASE_STRICT=1]="CASE_STRICT",e[e.CASE_INSENSITIVE=2]="CASE_INSENSITIVE"}(o.PropertyMatchingRule||(o.PropertyMatchingRule={})),function(e){e[e.ALLOW_NULL=1]="ALLOW_NULL",e[e.ALLOW_OBJECT_NULL=2]="ALLOW_OBJECT_NULL",e[e.DISALLOW_NULL=3]="DISALLOW_NULL"}(o.ValueCheckingMode||(o.ValueCheckingMode={}))})(I);var R={};Object.defineProperty(R,"__esModule",{value:!0});var N=function(){function o(){}return o.MAPPING_PROPERTY="__jsonconvert__mapping__",o.MAPPER_PROPERTY="__jsonconvert__mapper__",o.CLASS_IDENTIFIER="__jsonconvert__class_identifier__",o}();R.Settings=N;var k=function(){function o(){this.classPropertyName="",this.jsonPropertyName="",this.expectedJsonType=void 0,this.isOptional=!1,this.customConverter=null}return o}();R.MappingOptions=k;var O={};Object.defineProperty(O,"__esModule",{value:!0});var J=function(){function o(){}return o}();O.Any=J,Object.defineProperty(y,"__esModule",{value:!0});var l=I,v=R,F=O,q=function(){function o(e,t,r,n){this._operationMode=l.OperationMode.ENABLE,this._valueCheckingMode=l.ValueCheckingMode.ALLOW_OBJECT_NULL,this._ignorePrimitiveChecks=!1,this._propertyMatchingRule=l.PropertyMatchingRule.CASE_STRICT,this._ignoreRequiredCheck=!1,e!==void 0&&e in l.OperationMode&&(this.operationMode=e),t!==void 0&&t in l.ValueCheckingMode&&(this.valueCheckingMode=t),r!==void 0&&(this.ignorePrimitiveChecks=r),n!==void 0&&(this.propertyMatchingRule=n)}return Object.defineProperty(o.prototype,"operationMode",{get:function(){return this._operationMode},set:function(e){e in l.OperationMode&&(this._operationMode=e)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"valueCheckingMode",{get:function(){return this._valueCheckingMode},set:function(e){e in l.ValueCheckingMode&&(this._valueCheckingMode=e)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"ignorePrimitiveChecks",{get:function(){return this._ignorePrimitiveChecks},set:function(e){this._ignorePrimitiveChecks=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"propertyMatchingRule",{get:function(){return this._propertyMatchingRule},set:function(e){e in l.PropertyMatchingRule&&(this._propertyMatchingRule=e)},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"ignoreRequiredCheck",{get:function(){return this._ignoreRequiredCheck},set:function(e){this._ignoreRequiredCheck=e},enumerable:!0,configurable:!0}),o.prototype.serialize=function(e,t){if(this.operationMode===l.OperationMode.DISABLE)return e;if(e instanceof Array)return this.serializeArray(e,t);if(typeof e=="object")return this.serializeObject(e,t);throw new Error(`Fatal error in JsonConvert. Passed parameter data in JsonConvert.serialize() is not in valid format (object or array). `)},o.prototype.serializeObject=function(e,t){if(this.operationMode===l.OperationMode.DISABLE)return e;if(e===void 0)throw new Error(`Fatal error in JsonConvert. Passed parameter instance in JsonConvert.serializeObject() is undefined. This is not a valid JSON format. `);if(e===null){if(this.valueCheckingMode===l.ValueCheckingMode.DISALLOW_NULL)throw new Error(`Fatal error in JsonConvert. Passed parameter instance in JsonConvert.serializeObject() is undefined. You have specified to disallow null values. `);return e}else if(typeof e!="object"||e instanceof Array)throw new Error(`Fatal error in JsonConvert. Passed parameter instance in JsonConvert.serializeObject() is not of type object. `);this.operationMode===l.OperationMode.LOGGING&&(console.log("----------"),console.log("Receiving JavaScript instance:"),console.log(e));var r={},n;t?n=new t:n=e;for(var i=0,c=Object.keys(n);i"u"){if(C||this._ignoreRequiredCheck)return;throw new Error('Fatal error in JsonConvert. Failed to map the JavaScript instance of class "'+t[v.Settings.CLASS_IDENTIFIER]+'" to JSON because the defined class property "'+r+`" does not exist or is not defined: Class property: `+r+` JSON property: `+c+` `)}if(!(C&&S===null))try{n[c]=h!==null?h.serialize(S):this.verifyProperty(u,S,!0)}catch(Z){throw new Error('Fatal error in JsonConvert. Failed to map the JavaScript instance of class "'+t[v.Settings.CLASS_IDENTIFIER]+`" to JSON because of a type error. Class property: `+r+` Class property value: `+S+` Expected type: `+this.getExpectedType(u)+` Runtime type: `+this.getTrueType(S)+` JSON property: `+c+` `+Z.message+` `)}}},o.prototype.deserializeObject_loopProperty=function(e,t,r){var n=this.getClassPropertyMappingOptions(e,t);if(n!==null){var i=n.jsonPropertyName,c=n.expectedJsonType,u=n.isOptional,C=n.customConverter,h=void 0;try{h=this.getObjectValue(r,i)}catch{}if(typeof h>"u"){if(u||this._ignoreRequiredCheck)return;throw new Error('Fatal error in JsonConvert. Failed to map the JSON object to the class "'+e[v.Settings.CLASS_IDENTIFIER]+'" because the defined JSON property "'+i+`" does not exist: Class property: `+t+` JSON property: `+i+` `)}if(!(u&&h===null))try{e[t]=C!==null?C.deserialize(h):this.verifyProperty(c,h)}catch(S){throw new Error('Fatal error in JsonConvert. Failed to map the JSON object to the class "'+e[v.Settings.CLASS_IDENTIFIER]+`" because of a type error. Class property: `+t+` Expected type: `+this.getExpectedType(c)+` JSON property: `+i+` JSON type: `+this.getJsonType(h)+` JSON value: `+JSON.stringify(h)+` `+S.message+` `)}}},o.prototype.getClassPropertyMappingOptions=function(e,t){var r=e[v.Settings.MAPPING_PROPERTY];if(typeof r>"u")return null;for(var n=Object.getPrototypeOf(e);n!=null;){var i=n[v.Settings.CLASS_IDENTIFIER];if(i){var c=i+"."+t;if(typeof r[c]<"u")return r[c]}n=Object.getPrototypeOf(n)}return null},o.prototype.verifyProperty=function(e,t,r){if(e===F.Any||e===null||e===Object)return t;if(!(e instanceof Array)&&!(t instanceof Array))if(typeof e<"u"&&e.prototype.hasOwnProperty(v.Settings.CLASS_IDENTIFIER)){if(t===null){if(this.valueCheckingMode!==l.ValueCheckingMode.DISALLOW_NULL)return null;throw new Error(" Reason: Given value is null.")}return r?this.serializeObject(t,e):this.deserializeObject(t,e)}else if(e===F.Any||e===null||e===Object){if(t===null){if(this.valueCheckingMode!==l.ValueCheckingMode.DISALLOW_NULL)return null;throw new Error(" Reason: Given value is null.")}return t}else if(e===String||e===Number||e===Boolean){if(t===null){if(this.valueCheckingMode===l.ValueCheckingMode.ALLOW_NULL)return null;throw new Error(" Reason: Given value is null.")}if(e===String&&typeof t=="string"||e===Number&&typeof t=="number"||e===Boolean&&typeof t=="boolean")return t;if(this.ignorePrimitiveChecks)return t;throw new Error(" Reason: Given object does not match the expected primitive type.")}else throw new Error(` Reason: Expected type is unknown. There might be multiple reasons for this: - You are missing the decorator @JsonObject (for object mapping) - You are missing the decorator @JsonConverter (for custom mapping) before your class definition - Your given class is undefined in the decorator because of circular dependencies`);if(e instanceof Array&&t instanceof Array){var n=[];if(t.length===0)return n;if(e.length===0)return t;for(var i=e.length=e.length&&(e[c]=e[c-1]),n[c]=this.verifyProperty(e[c],t[c],r);return n}if(e instanceof Array&&t instanceof Object){var n=[];if(t.length===0)return n;if(e.length===0)return t;var i=e.length=e.length&&(e[c]=e[c-1]),n[u]=this.verifyProperty(e[c],t[u]),c++;return n}if(e instanceof Array){if(t===null){if(this.valueCheckingMode!==l.ValueCheckingMode.DISALLOW_NULL)return null;throw new Error(" Reason: Given value is null.")}throw new Error(" Reason: Expected type is array, but given value is non-array.")}throw t instanceof Array?new Error(" Reason: Given value is array, but expected a non-array type."):new Error(" Reason: Mapping failed because of an unknown error.")},o.prototype.getObjectValue=function(e,t){if(this.propertyMatchingRule===l.PropertyMatchingRule.CASE_INSENSITIVE){var r=Object.keys(e).reduce(function(n,i){return n[i.toLowerCase()]=i,n},{});t=r[t.toLowerCase()]}if(!(t in e))throw new Error;return e[t]},o.prototype.getExpectedType=function(e){var t="";if(e instanceof Array){t="[";for(var r=0;r0&&(t+=","),t+=this.getExpectedType(e[r]);return t+="]",t}else return e===F.Any||e===null||e===Object?"any":e===String||e===Boolean||e===Number?new e().constructor.name.toLowerCase():typeof e=="function"?new e().constructor.name:e===void 0?"undefined":"?????"},o.prototype.getJsonType=function(e){if(e===null)return"null";var t="";if(e instanceof Array){t="[";for(var r=0;r0&&(t+=","),t+=this.getJsonType(e[r]);return t+="]",t}else return typeof e},o.prototype.getTrueType=function(e){return typeof e},o}();y.JsonConvert=q;var A={};Object.defineProperty(A,"__esModule",{value:!0});var g=R,T=O;function G(o){o[g.Settings.MAPPER_PROPERTY]=""}A.JsonConverter=G;function z(o){var e="",t=function(n){n.prototype[g.Settings.CLASS_IDENTIFIER]=e.length>0?e:n.name;var i=n.prototype[g.Settings.MAPPING_PROPERTY];if(i)for(var c=Object.keys(i).filter(function(S){return S.indexOf(g.Settings.CLASS_IDENTIFIER+".")===0}),u=0,C=c;u"u"&&(t[g.Settings.MAPPING_PROPERTY]=[]);var u=new g.MappingOptions;if(u.classPropertyName=r,u.jsonPropertyName=n,u.isOptional=c||!1,typeof i<"u"&&i!==null&&typeof i[g.Settings.MAPPER_PROPERTY]<"u"?u.customConverter=new i:u.expectedJsonType=i,typeof t[g.Settings.MAPPING_PROPERTY][g.Settings.CLASS_IDENTIFIER+"."+r]>"u")t[g.Settings.MAPPING_PROPERTY][g.Settings.CLASS_IDENTIFIER+"."+r]=u;else throw new Error(`Fatal error in JsonConvert. It is not allowed to add multiple decorators for the same property. Class property: `+r+` `)}}A.JsonProperty=U,Object.defineProperty(d,"__esModule",{value:!0});var W=y,Y=d.JsonConvert=W.JsonConvert,D=I;d.ValueCheckingMode=D.ValueCheckingMode,d.OperationMode=D.OperationMode;var L=A,b=d.JsonObject=L.JsonObject,f=d.JsonProperty=L.JsonProperty;d.JsonConverter=L.JsonConverter;var B=O,V=d.Any=B.Any,$=Object.defineProperty,H=Object.getOwnPropertyDescriptor,p=(o,e,t,r)=>{for(var n=r>1?void 0:r?H(e,t):e,i=o.length-1,c;i>=0;i--)(c=o[i])&&(n=(r?c(e,t,n):c(n))||n);return r&&n&&$(e,t,n),n},w=(o=>(o.Ping="ping",o.Pong="pong",o.Info="info",o.ApiInfo="api_info",o.Request="request",o.Response="response",o.Log="log",o.Progress="progress",o))(w||{}),M=(o=>(o.ResponseTopic="response_topic",o.RequestContext="requestContext",o.RequestMessageId="requestMessageId",o.MessageType="messageType",o))(M||{}),j=(o=>(o.Success="success",o.Error="error",o.Running="running",o))(j||{});s.DASFModuleRequest=class{constructor(){a(this,"payload","");a(this,"context","");a(this,"properties")}static createMessage(e){const t=new s.DASFModuleRequest;return t.properties={},t.properties.messageType=e,t}static createRequestMessage(){return s.DASFModuleRequest.createMessage("request")}static createPingMessage(){return s.DASFModuleRequest.createMessage("ping")}static createPongMessage(){return s.DASFModuleRequest.createMessage("pong")}static createInfoMessage(){return s.DASFModuleRequest.createMessage("info")}static createApiInfoMessage(){return s.DASFModuleRequest.createMessage("api_info")}getMessageType(){if(this.properties)return this.properties.messageType;throw new Error("Missing or empty message type property")}},p([f("payload",String)],s.DASFModuleRequest.prototype,"payload",2),p([f("properties",V)],s.DASFModuleRequest.prototype,"properties",2),s.DASFModuleRequest=p([b("DASFModuleRequest")],s.DASFModuleRequest),s.DASFModuleRequestReceipt=class{constructor(){a(this,"result","");a(this,"messageId","");a(this,"errorMsg","");a(this,"context","")}isOk(){return this.result=="ok"}},p([f("result",String)],s.DASFModuleRequestReceipt.prototype,"result",2),p([f("messageId",String,!0)],s.DASFModuleRequestReceipt.prototype,"messageId",2),p([f("errorMsg",String,!0)],s.DASFModuleRequestReceipt.prototype,"errorMsg",2),p([f("context",String,!0)],s.DASFModuleRequestReceipt.prototype,"context",2),s.DASFModuleRequestReceipt=p([b("DASFModuleRequestReceipt")],s.DASFModuleRequestReceipt),s.DASFAcknowledgment=class{constructor(e){a(this,"messageId","");e&&(this.messageId=e)}},p([f("messageId",String)],s.DASFAcknowledgment.prototype,"messageId",2),s.DASFAcknowledgment=p([b("DASFAcknowledgment")],s.DASFAcknowledgment),s.DASFModuleResponse=class{constructor(){a(this,"messageId","");a(this,"payload","");a(this,"publishTime","");a(this,"properties")}getMessageType(){if(this.properties){const e=this.properties.messageType;if(e&&e.trim().length>0)return e}throw new Error("Missing or empty message type property")}getRequestContext(){if(this.properties){const e=this.properties.requestContext;if(e)return e}throw new Error("Missing or empty request context property")}getRequestMessageId(){if(this.properties){const e=this.properties.requestMessageId;if(e)return e}throw new Error("Missing or empty request messageId property")}isFragmented(){return this.properties!=null&&this.properties.hasOwnProperty("num_fragments")&&this.properties.hasOwnProperty("fragment")}getFragmentId(){if(this.properties&&this.isFragmented())return this.properties.fragment;throw new Error("Unable to request fragment id from unfragmented response.")}getNumberOfFragments(){if(this.properties&&this.isFragmented())return this.properties.num_fragments;throw new Error("Unable to request number of fragments from unfragmented response.")}},p([f("messageId",String)],s.DASFModuleResponse.prototype,"messageId",2),p([f("payload",String)],s.DASFModuleResponse.prototype,"payload",2),p([f("publishTime",String)],s.DASFModuleResponse.prototype,"publishTime",2),p([f("properties")],s.DASFModuleResponse.prototype,"properties",2),s.DASFModuleResponse=p([b("DASFModuleResponse")],s.DASFModuleResponse),s.DASFProgressReport=class{constructor(){a(this,"report_type","");a(this,"report_id","");a(this,"step_message","");a(this,"steps",0);a(this,"status","");a(this,"children")}hasError(){return this.status=="error"}hasSuccess(){return this.status=="success"}isRunning(){return this.status=="running"}isComplete(){return!this.isRunning()}},p([f("report_type",String)],s.DASFProgressReport.prototype,"report_type",2),p([f("report_id",String)],s.DASFProgressReport.prototype,"report_id",2),p([f("step_message",String)],s.DASFProgressReport.prototype,"step_message",2),p([f("steps",Number)],s.DASFProgressReport.prototype,"steps",2),p([f("status",String)],s.DASFProgressReport.prototype,"status",2),p([f("children",[s.DASFProgressReport])],s.DASFProgressReport.prototype,"children",2),s.DASFProgressReport=p([b("DASFProgressReport")],s.DASFProgressReport);class Q{constructor(e,t){a(this,"outgoingChannel");a(this,"incomingChannel");a(this,"DASFProducerURL");a(this,"DASFConsumerURL");a(this,"topic");a(this,"consumeTopic");a(this,"jsonCoder");a(this,"contextCounter",0);a(this,"responseCallbacks",new Map);a(this,"progressCallbacks",new Map);a(this,"errorCallbacks",new Map);a(this,"finishedContexts",new Set);a(this,"contextResponseFragments",new Map);a(this,"pendingRequests",[]);a(this,"waitingForPong",!1);a(this,"connectionTimeout",1e4);a(this,"backendConsumerConnected",!1);a(this,"connectionError","");a(this,"onConnectionError");a(this,"startedReconnectOutgoing",!0);a(this,"startedReconnectIncoming",!0);this.onConnectionError=t,this.topic=e.topic,this.consumeTopic=e.consumeTopic,this.DASFProducerURL=e.DASFProducerURL,this.DASFConsumerURL=e.DASFConsumerURL,this.jsonCoder=new Y,this.connect(),setInterval(()=>this.checkConnection(),this.connectionTimeout)}connect(){this.startedReconnectIncoming=!0,this.startedReconnectOutgoing=!0,this.outgoingChannel=new WebSocket(this.DASFProducerURL),this.incomingChannel=new WebSocket(this.DASFConsumerURL),this.registerListener(),this.getInitialModuleInfo()}isConnected(){return this.outgoingChannel&&this.incomingChannel&&this.outgoingChannel.readyState==WebSocket.OPEN&&this.incomingChannel.readyState==WebSocket.OPEN}isConnecting(){return this.outgoingChannel&&this.incomingChannel&&this.outgoingChannel.readyState!=WebSocket.OPEN&&this.incomingChannel.readyState!=WebSocket.OPEN}assureConnected(){return this.isConnected()?!0:(this.startedReconnectIncoming||this.startedReconnectOutgoing||this.isConnecting()||this.connect(),!1)}hasPendingRequests(){return this.pendingRequests.length>0}sendPendingRequests(){if(this.hasPendingRequests()){const e=this.pendingRequests.shift();this.outgoingChannel.send(JSON.stringify(e)),setTimeout(()=>this.sendPendingRequests(),200)}}registerListener(){const e=t=>{this.startedReconnectOutgoing=!1,this.startedReconnectIncoming=!1,!this.hasConnectionError()&&this.isConnecting()&&(this.connectionError="Connection to "+t.target.url+" failed.",this.onConnectionError&&this.onConnectionError(this.connectionError))};this.outgoingChannel.addEventListener("error",e),this.incomingChannel.addEventListener("error",e),this.outgoingChannel.addEventListener("open",()=>{this.startedReconnectOutgoing=!1,this.connectionError="",this.outgoingChannel.addEventListener("message",t=>{const r=this.jsonCoder.deserializeObject(JSON.parse(t.data),s.DASFModuleRequestReceipt);if(r.isOk())this.errorCallbacks.delete(r.context);else{console.error(r),this.responseCallbacks.delete(r.context);const n=this.errorCallbacks.get(r.context);n?(this.errorCallbacks.delete(r.context),n(r)):console.error("received error receipt for an unknwon context: "+r.context)}})}),this.incomingChannel.addEventListener("open",()=>{this.startedReconnectIncoming=!1,this.connectionError="",this.incomingChannel.addEventListener("message",t=>{try{const r=JSON.parse(t.data),n=this.jsonCoder.deserializeObject(r,s.DASFModuleResponse);this.acknowledgeMessage(n);const i=n.getRequestContext();if(this.finishedContexts.has(i))return;if(n.getMessageType()==w.Progress){const c=this.jsonCoder.deserializeObject(JSON.parse(atob(r.payload)),s.DASFProgressReport),u=this.progressCallbacks.get(i);u&&u(c,n.properties)}else{if(n.isFragmented())if(this.contextResponseFragments.has(i)){let u=this.contextResponseFragments.get(i);if(u)if(u.push(n),u.length==n.getNumberOfFragments()){u=u.sort((h,S)=>h.getFragmentId()-S.getFragmentId());let C="";for(const h of u)C+=h.payload;n.payload=C,this.contextResponseFragments.delete(i)}else return}else{this.contextResponseFragments.set(i,[n]);return}const c=this.responseCallbacks.get(i);c?(this.responseCallbacks.delete(i),this.progressCallbacks.delete(i),this.errorCallbacks.delete(i),this.finishedContexts.add(i),c(n)):console.warn("received a response for an unknown context: "+i,n)}}catch(r){console.error(r)}})})}checkConnection(){if(this.waitingForPong&&(this.backendConsumerConnected=!1,console.warn("Ping to backend module timed out.")),this.startedReconnectOutgoing||this.startedReconnectIncoming)return;this.waitingForPong=!0;const e=s.DASFModuleRequest.createPingMessage();this.sendRequest(e,()=>{this.waitingForPong=!1,this.backendConsumerConnected=!0,this.sendPendingRequests()},void 0,t=>{console.warn(t.errorMsg)})}sendRequest(e,t,r,n){if(e.context=String(++this.contextCounter),!e.properties)throw new Error("missing request properties");if(e.properties[M.ResponseTopic]=this.consumeTopic,e.properties[M.RequestContext]=e.context,this.responseCallbacks.set(e.context,t),this.progressCallbacks.set(e.context,r),this.errorCallbacks.set(e.context,n),(e.getMessageType()==w.Request||e.getMessageType()==w.Info)&&!this.backendConsumerConnected){if(this.hasConnectionError()&&n!=null){const i=new s.DASFModuleRequestReceipt;i.context=e.context,i.errorMsg=this.connectionError,this.responseCallbacks.delete(e.context),this.progressCallbacks.delete(e.context),this.errorCallbacks.delete(e.context),n(i)}this.pendingRequests.push(e);return}if(this.assureConnected()){const i=JSON.stringify(e);this.outgoingChannel.send(i)}}acknowledgeMessage(e){const t=this.jsonCoder.serializeObject(new s.DASFAcknowledgment(e.messageId));this.incomingChannel.send(JSON.stringify(t))}close(){this.outgoingChannel.close(),this.incomingChannel.close()}getInitialModuleInfo(){this.backendConsumerConnected?this.getModuleInfo(e=>{console.info("module for topic "+this.topic+" provided the following module info: ",e)}):setTimeout(()=>this.getInitialModuleInfo(),1e3)}getModuleInfo(e){this.sendRequest(s.DASFModuleRequest.createInfoMessage(),t=>{if(t.properties)try{e(JSON.parse(t.properties.info))}catch{console.warn("Unable to retrieve backend module capabilities, got: ",t.properties.info)}},()=>{try{console.info("getModuleInfo success")}catch{console.warn("getModuleInfo failure")}},t=>{throw new Error(t.errorMsg)})}isBackendConnected(){return this.backendConsumerConnected}hasConnectionError(){return this.connectionError.length>0}getConnectionErrorMessage(){return this.connectionError}}class X{constructor(e,t,r="",n=""){a(this,"topic");a(this,"consumeTopic");a(this,"DASFConsumerURL");a(this,"DASFProducerURL");this.topic=t,this.consumeTopic=this.generateConsumeTopic(t),this.DASFConsumerURL=(n||this.buildUrl(e,this.consumeTopic))+"/"+this.generateSubscriptionPrefix(),this.DASFProducerURL=r||this.buildUrl(e,this.topic)}buildUrl(e,t){return e+"/"+t}generateConsumeTopic(e){return e+"_"+this.generateRequestToken()}generateSubscriptionPrefix(){return"web-frontend-"+new Date().toISOString()}generateRequestToken(){return Math.random().toString(16).slice(2)}}const P=class P{constructor(e,t,r,n){a(this,"topic");a(this,"consumeTopic");a(this,"DASFConsumerURL");a(this,"DASFProducerURL");this.topic=n,this.consumeTopic=this.generateConsumeTopic(n),this.DASFConsumerURL=this.buildUrl(e,t,r,"consumer",this.consumeTopic),this.DASFProducerURL=this.buildUrl(e,t,r,"producer",this.topic)}buildUrl(e,t,r,n,i){let c=P.BASE_DASF_URL.replace("%host%",e).replace("%port%",t).replace("%namespace%",r).replace("%type%",n).replace("%topic%",i);return n=="consumer"&&(c+=this.generateSubscriptionPrefix()+"?subscriptionType=Exclusive"),c}generateConsumeTopic(e){return e+"_"+this.generateRequestToken()}generateSubscriptionPrefix(){return"web-frontend-"+new Date().toISOString()}generateRequestToken(){return Math.random().toString(16).slice(2)}};a(P,"BASE_DASF_URL","ws://%host%:%port%/ws/v2/%type%/non-persistent/public/%namespace%/%topic%/");let E=P;const m=class m extends E{constructor(e){super(m.HOST,m.PORT,m.NAMESPACE,e)}};a(m,"HOST","rz-vm154.gfz-potsdam.de"),a(m,"PORT","8082"),a(m,"NAMESPACE","digital-earth");let _=m;s.DASFConnection=Q,s.DefaultDASFUrlBuilder=E,s.DigitalEarthUrlBuilder=_,s.MessageType=w,s.PropertyKeys=M,s.Status=j,s.WebsocketUrlBuilder=X,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});