@signalk/freeboard-sk 3.1.0 → 3.2.0-beta.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.
@@ -9,4 +9,4 @@ Actual: `+s.attribValue);else if(b==="xmlns"&&s.attribValue!==T)B(s,"xmlns: pref
9
9
  Actual: `+s.attribValue);else{var j=s.tag,W=s.tags[s.tags.length-1]||s;j.ns===W.ns&&(j.ns=Object.create(W.ns)),j.ns[b]=s.attribValue}s.attribList.push([s.attribName,s.attribValue])}else s.tag.attributes[s.attribName]=s.attribValue,S(s,"onattribute",{name:s.attribName,value:s.attribValue});s.attribName=s.attribValue=""}function at(s,e){if(s.opt.xmlns){var L=s.tag,b=Ft(s.tagName);L.prefix=b.prefix,L.local=b.local,L.uri=L.ns[b.prefix]||"",L.prefix&&!L.uri&&(B(s,"Unbound namespace prefix: "+JSON.stringify(s.tagName)),L.uri=b.prefix);var j=s.tags[s.tags.length-1]||s;L.ns&&j.ns!==L.ns&&Object.keys(L.ns).forEach(function(ne){S(s,"onopennamespace",{prefix:ne,uri:L.ns[ne]})});for(var W=0,G=s.attribList.length;W<G;W++){var z=s.attribList[W],H=z[0],et=z[1],Y=Ft(H,!0),rt=Y.prefix,en=Y.local,re=rt===""?"":L.ns[rt]||"",jt={name:H,value:et,prefix:rt,local:en,uri:re};rt&&rt!=="xmlns"&&!re&&(B(s,"Unbound namespace prefix: "+JSON.stringify(rt)),jt.uri=rt),s.tag.attributes[H]=jt,S(s,"onattribute",jt)}s.attribList.length=0}s.tag.isSelfClosing=!!e,s.sawRoot=!0,s.tags.push(s.tag),S(s,"onopentag",s.tag),e||(!s.noscript&&s.tagName.toLowerCase()==="script"?s.state=a.SCRIPT:s.state=a.TEXT,s.tag=null,s.tagName=""),s.attribName=s.attribValue="",s.attribList.length=0}function Xt(s){if(!s.tagName){B(s,"Weird empty close tag."),s.textNode+="</>",s.state=a.TEXT;return}if(s.script){if(s.tagName!=="script"){s.script+="</"+s.tagName+">",s.tagName="",s.state=a.SCRIPT;return}S(s,"onscript",s.script),s.script=""}var e=s.tags.length,L=s.tagName;s.strict||(L=L[s.looseCase]());for(var b=L;e--;){var j=s.tags[e];if(j.name!==b)B(s,"Unexpected close tag");else break}if(e<0){B(s,"Unmatched closing tag: "+s.tagName),s.textNode+="</"+s.tagName+">",s.state=a.TEXT;return}s.tagName=L;for(var W=s.tags.length;W-- >e;){var G=s.tag=s.tags.pop();s.tagName=s.tag.name,S(s,"onclosetag",s.tagName);var z={};for(var H in G.ns)z[H]=G.ns[H];var et=s.tags[s.tags.length-1]||s;s.opt.xmlns&&G.ns!==et.ns&&Object.keys(G.ns).forEach(function(Y){var rt=G.ns[Y];S(s,"onclosenamespace",{prefix:Y,uri:rt})})}e===0&&(s.closedRoot=!0),s.tagName=s.attribValue=s.attribName="",s.attribList.length=0,s.state=a.TEXT}function Jr(s){var e=s.entity,L=e.toLowerCase(),b,j="";return s.ENTITIES[e]?s.ENTITIES[e]:s.ENTITIES[L]?s.ENTITIES[L]:(e=L,e.charAt(0)==="#"&&(e.charAt(1)==="x"?(e=e.slice(2),b=parseInt(e,16),j=b.toString(16)):(e=e.slice(1),b=parseInt(e,10),j=b.toString(10))),e=e.replace(/^0+/,""),isNaN(b)||j.toLowerCase()!==e||b<0||b>1114111?(B(s,"Invalid character entity"),"&"+s.entity+";"):String.fromCodePoint(b))}function ee(s,e){e==="<"?(s.state=a.OPEN_WAKA,s.startTagPosition=s.position):o(e)||(B(s,"Non-whitespace before first tag."),s.textNode=e,s.state=a.TEXT)}function Rt(s,e){var L="";return e<s.length&&(L=s.charAt(e)),L}function tn(s){var e=this;if(this.error)throw this.error;if(e.closed)return J(e,"Cannot write after close. Assign an onready handler.");if(s===null)return ht(e);typeof s=="object"&&(s=s.toString());for(var L=0,b="";b=Rt(s,L++),e.c=b,!!b;)switch(e.trackPosition&&(e.position++,b===`
10
10
  `?(e.line++,e.column=0):e.column++),e.state){case a.BEGIN:if(e.state=a.BEGIN_WHITESPACE,b==="\uFEFF")continue;ee(e,b);continue;case a.BEGIN_WHITESPACE:ee(e,b);continue;case a.TEXT:if(e.sawRoot&&!e.closedRoot){for(var W=L-1;b&&b!=="<"&&b!=="&";)b=Rt(s,L++),b&&e.trackPosition&&(e.position++,b===`
11
11
  `?(e.line++,e.column=0):e.column++);e.textNode+=s.substring(W,L-1)}b==="<"&&!(e.sawRoot&&e.closedRoot&&!e.strict)?(e.state=a.OPEN_WAKA,e.startTagPosition=e.position):(!o(b)&&(!e.sawRoot||e.closedRoot)&&B(e,"Text data outside of root node."),b==="&"?e.state=a.TEXT_ENTITY:e.textNode+=b);continue;case a.SCRIPT:b==="<"?e.state=a.SCRIPT_ENDING:e.script+=b;continue;case a.SCRIPT_ENDING:b==="/"?e.state=a.CLOSE_TAG:(e.script+="<"+b,e.state=a.SCRIPT);continue;case a.OPEN_WAKA:if(b==="!")e.state=a.SGML_DECL,e.sgmlDecl="";else if(!o(b))if(C(A,b))e.state=a.OPEN_TAG,e.tagName=b;else if(b==="/")e.state=a.CLOSE_TAG,e.tagName="";else if(b==="?")e.state=a.PROC_INST,e.procInstName=e.procInstBody="";else{if(B(e,"Unencoded <"),e.startTagPosition+1<e.position){var j=e.position-e.startTagPosition;b=new Array(j).join(" ")+b}e.textNode+="<"+b,e.state=a.TEXT}continue;case a.SGML_DECL:if(e.sgmlDecl+b==="--"){e.state=a.COMMENT,e.comment="",e.sgmlDecl="";continue}e.doctype&&e.doctype!==!0&&e.sgmlDecl?(e.state=a.DOCTYPE_DTD,e.doctype+="<!"+e.sgmlDecl+b,e.sgmlDecl=""):(e.sgmlDecl+b).toUpperCase()===O?(S(e,"onopencdata"),e.state=a.CDATA,e.sgmlDecl="",e.cdata=""):(e.sgmlDecl+b).toUpperCase()===D?(e.state=a.DOCTYPE,(e.doctype||e.sawRoot)&&B(e,"Inappropriately located doctype declaration"),e.doctype="",e.sgmlDecl=""):b===">"?(S(e,"onsgmldeclaration",e.sgmlDecl),e.sgmlDecl="",e.state=a.TEXT):(n(b)&&(e.state=a.SGML_DECL_QUOTED),e.sgmlDecl+=b);continue;case a.SGML_DECL_QUOTED:b===e.q&&(e.state=a.SGML_DECL,e.q=""),e.sgmlDecl+=b;continue;case a.DOCTYPE:b===">"?(e.state=a.TEXT,S(e,"ondoctype",e.doctype),e.doctype=!0):(e.doctype+=b,b==="["?e.state=a.DOCTYPE_DTD:n(b)&&(e.state=a.DOCTYPE_QUOTED,e.q=b));continue;case a.DOCTYPE_QUOTED:e.doctype+=b,b===e.q&&(e.q="",e.state=a.DOCTYPE);continue;case a.DOCTYPE_DTD:b==="]"?(e.doctype+=b,e.state=a.DOCTYPE):b==="<"?(e.state=a.OPEN_WAKA,e.startTagPosition=e.position):n(b)?(e.doctype+=b,e.state=a.DOCTYPE_DTD_QUOTED,e.q=b):e.doctype+=b;continue;case a.DOCTYPE_DTD_QUOTED:e.doctype+=b,b===e.q&&(e.state=a.DOCTYPE_DTD,e.q="");continue;case a.COMMENT:b==="-"?e.state=a.COMMENT_ENDING:e.comment+=b;continue;case a.COMMENT_ENDING:b==="-"?(e.state=a.COMMENT_ENDED,e.comment=R(e.opt,e.comment),e.comment&&S(e,"oncomment",e.comment),e.comment=""):(e.comment+="-"+b,e.state=a.COMMENT);continue;case a.COMMENT_ENDED:b!==">"?(B(e,"Malformed comment"),e.comment+="--"+b,e.state=a.COMMENT):e.doctype&&e.doctype!==!0?e.state=a.DOCTYPE_DTD:e.state=a.TEXT;continue;case a.CDATA:for(var W=L-1;b&&b!=="]";)b=Rt(s,L++),b&&e.trackPosition&&(e.position++,b===`
12
- `?(e.line++,e.column=0):e.column++);e.cdata+=s.substring(W,L-1),b==="]"&&(e.state=a.CDATA_ENDING);continue;case a.CDATA_ENDING:b==="]"?e.state=a.CDATA_ENDING_2:(e.cdata+="]"+b,e.state=a.CDATA);continue;case a.CDATA_ENDING_2:b===">"?(e.cdata&&S(e,"oncdata",e.cdata),S(e,"onclosecdata"),e.cdata="",e.state=a.TEXT):b==="]"?e.cdata+="]":(e.cdata+="]]"+b,e.state=a.CDATA);continue;case a.PROC_INST:b==="?"?e.state=a.PROC_INST_ENDING:o(b)?e.state=a.PROC_INST_BODY:e.procInstName+=b;continue;case a.PROC_INST_BODY:if(!e.procInstBody&&o(b))continue;b==="?"?e.state=a.PROC_INST_ENDING:e.procInstBody+=b;continue;case a.PROC_INST_ENDING:if(b===">"){let et={name:e.procInstName,body:e.procInstBody};X(e,et),S(e,"onprocessinginstruction",et),e.procInstName=e.procInstBody="",e.state=a.TEXT}else e.procInstBody+="?"+b,e.state=a.PROC_INST_BODY;continue;case a.OPEN_TAG:C(M,b)?e.tagName+=b:(Zr(e),b===">"?at(e):b==="/"?e.state=a.OPEN_TAG_SLASH:(o(b)||B(e,"Invalid character in tag name"),e.state=a.ATTRIB));continue;case a.OPEN_TAG_SLASH:b===">"?(at(e,!0),Xt(e)):(B(e,"Forward-slash in opening tag not followed by >"),e.state=a.ATTRIB);continue;case a.ATTRIB:if(o(b))continue;b===">"?at(e):b==="/"?e.state=a.OPEN_TAG_SLASH:C(A,b)?(e.attribName=b,e.attribValue="",e.state=a.ATTRIB_NAME):B(e,"Invalid attribute name");continue;case a.ATTRIB_NAME:b==="="?e.state=a.ATTRIB_VALUE:b===">"?(B(e,"Attribute without value"),e.attribValue=e.attribName,qt(e),at(e)):o(b)?e.state=a.ATTRIB_NAME_SAW_WHITE:C(M,b)?e.attribName+=b:B(e,"Invalid attribute name");continue;case a.ATTRIB_NAME_SAW_WHITE:if(b==="=")e.state=a.ATTRIB_VALUE;else{if(o(b))continue;B(e,"Attribute without value"),e.tag.attributes[e.attribName]="",e.attribValue="",S(e,"onattribute",{name:e.attribName,value:""}),e.attribName="",b===">"?at(e):C(A,b)?(e.attribName=b,e.state=a.ATTRIB_NAME):(B(e,"Invalid attribute name"),e.state=a.ATTRIB)}continue;case a.ATTRIB_VALUE:if(o(b))continue;n(b)?(e.q=b,e.state=a.ATTRIB_VALUE_QUOTED):(e.opt.unquotedAttributeValues||J(e,"Unquoted attribute value"),e.state=a.ATTRIB_VALUE_UNQUOTED,e.attribValue=b);continue;case a.ATTRIB_VALUE_QUOTED:if(b!==e.q){b==="&"?e.state=a.ATTRIB_VALUE_ENTITY_Q:e.attribValue+=b;continue}qt(e),e.q="",e.state=a.ATTRIB_VALUE_CLOSED;continue;case a.ATTRIB_VALUE_CLOSED:o(b)?e.state=a.ATTRIB:b===">"?at(e):b==="/"?e.state=a.OPEN_TAG_SLASH:C(A,b)?(B(e,"No whitespace between attributes"),e.attribName=b,e.attribValue="",e.state=a.ATTRIB_NAME):B(e,"Invalid attribute name");continue;case a.ATTRIB_VALUE_UNQUOTED:if(!h(b)){b==="&"?e.state=a.ATTRIB_VALUE_ENTITY_U:e.attribValue+=b;continue}qt(e),b===">"?at(e):e.state=a.ATTRIB;continue;case a.CLOSE_TAG:if(e.tagName)b===">"?Xt(e):C(M,b)?e.tagName+=b:e.script?(e.script+="</"+e.tagName+b,e.tagName="",e.state=a.SCRIPT):(o(b)||B(e,"Invalid tagname in closing tag"),e.state=a.CLOSE_TAG_SAW_WHITE);else{if(o(b))continue;I(A,b)?e.script?(e.script+="</"+b,e.state=a.SCRIPT):B(e,"Invalid tagname in closing tag."):e.tagName=b}continue;case a.CLOSE_TAG_SAW_WHITE:if(o(b))continue;b===">"?Xt(e):B(e,"Invalid characters in closing tag");continue;case a.TEXT_ENTITY:case a.ATTRIB_VALUE_ENTITY_Q:case a.ATTRIB_VALUE_ENTITY_U:var G,z;switch(e.state){case a.TEXT_ENTITY:G=a.TEXT,z="textNode";break;case a.ATTRIB_VALUE_ENTITY_Q:G=a.ATTRIB_VALUE_QUOTED,z="attribValue";break;case a.ATTRIB_VALUE_ENTITY_U:G=a.ATTRIB_VALUE_UNQUOTED,z="attribValue";break}if(b===";"){var H=Jr(e);e.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(H)?((e.entityCount+=1)>e.opt.maxEntityCount&&J(e,"Parsed entity count exceeds max entity count"),(e.entityDepth+=1)>e.opt.maxEntityDepth&&J(e,"Parsed entity depth exceeds max entity depth"),e.entity="",e.state=G,e.write(H),e.entityDepth-=1):(e[z]+=H,e.entity="",e.state=G)}else C(e.entity.length?d:_,b)?e.entity+=b:(B(e,"Invalid character in entity name"),e[z]+="&"+e.entity+b,e.entity="",e.state=G);continue;default:throw new Error(e,"Unknown state: "+e.state)}return e.position>=e.bufferCheckPosition&&y(e),e}String.fromCodePoint||(function(){var s=String.fromCharCode,e=Math.floor,L=function(){var b=16384,j=[],W,G,z=-1,H=arguments.length;if(!H)return"";for(var et="";++z<H;){var Y=Number(arguments[z]);if(!isFinite(Y)||Y<0||Y>1114111||e(Y)!==Y)throw RangeError("Invalid code point: "+Y);Y<=65535?j.push(Y):(Y-=65536,W=(Y>>10)+55296,G=Y%1024+56320,j.push(W,G)),(z+1===H||j.length>b)&&(et+=s.apply(null,j),j.length=0)}return et};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:L,configurable:!0,writable:!0}):String.fromCodePoint=L})()})(typeof Pt>"u"?Pt.sax={}:Pt)});var jr=F((xn,Ht)=>{"use strict";var pt=typeof Reflect=="object"?Reflect:null,vr=pt&&typeof pt.apply=="function"?pt.apply:function(r,c,y){return Function.prototype.apply.call(r,c,y)},xt;pt&&typeof pt.ownKeys=="function"?xt=pt.ownKeys:Object.getOwnPropertySymbols?xt=function(r){return Object.getOwnPropertyNames(r).concat(Object.getOwnPropertySymbols(r))}:xt=function(r){return Object.getOwnPropertyNames(r)};function fn(t){console&&console.warn&&console.warn(t)}var Ar=Number.isNaN||function(r){return r!==r};function U(){U.init.call(this)}Ht.exports=U;Ht.exports.once=mn;U.EventEmitter=U;U.prototype._events=void 0;U.prototype._eventsCount=0;U.prototype._maxListeners=void 0;var Mr=10;function St(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(U,"defaultMaxListeners",{enumerable:!0,get:function(){return Mr},set:function(t){if(typeof t!="number"||t<0||Ar(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Mr=t}});U.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};U.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||Ar(r))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+r+".");return this._maxListeners=r,this};function Pr(t){return t._maxListeners===void 0?U.defaultMaxListeners:t._maxListeners}U.prototype.getMaxListeners=function(){return Pr(this)};U.prototype.emit=function(r){for(var c=[],y=1;y<arguments.length;y++)c.push(arguments[y]);var i=r==="error",f=this._events;if(f!==void 0)i=i&&f.error===void 0;else if(!i)return!1;if(i){var u;if(c.length>0&&(u=c[0]),u instanceof Error)throw u;var l=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw l.context=u,l}var m=f[r];if(m===void 0)return!1;if(typeof m=="function")vr(m,this,c);else for(var g=m.length,N=Xr(m,g),y=0;y<g;++y)vr(N[y],this,c);return!0};function xr(t,r,c,y){var i,f,u;if(St(c),f=t._events,f===void 0?(f=t._events=Object.create(null),t._eventsCount=0):(f.newListener!==void 0&&(t.emit("newListener",r,c.listener?c.listener:c),f=t._events),u=f[r]),u===void 0)u=f[r]=c,++t._eventsCount;else if(typeof u=="function"?u=f[r]=y?[c,u]:[u,c]:y?u.unshift(c):u.push(c),i=Pr(t),i>0&&u.length>i&&!u.warned){u.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(r)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=r,l.count=u.length,fn(l)}return t}U.prototype.addListener=function(r,c){return xr(this,r,c,!1)};U.prototype.on=U.prototype.addListener;U.prototype.prependListener=function(r,c){return xr(this,r,c,!0)};function hn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Sr(t,r,c){var y={fired:!1,wrapFn:void 0,target:t,type:r,listener:c},i=hn.bind(y);return i.listener=c,y.wrapFn=i,i}U.prototype.once=function(r,c){return St(c),this.on(r,Sr(this,r,c)),this};U.prototype.prependOnceListener=function(r,c){return St(c),this.prependListener(r,Sr(this,r,c)),this};U.prototype.removeListener=function(r,c){var y,i,f,u,l;if(St(c),i=this._events,i===void 0)return this;if(y=i[r],y===void 0)return this;if(y===c||y.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete i[r],i.removeListener&&this.emit("removeListener",r,y.listener||c));else if(typeof y!="function"){for(f=-1,u=y.length-1;u>=0;u--)if(y[u]===c||y[u].listener===c){l=y[u].listener,f=u;break}if(f<0)return this;f===0?y.shift():pn(y,f),y.length===1&&(i[r]=y[0]),i.removeListener!==void 0&&this.emit("removeListener",r,l||c)}return this};U.prototype.off=U.prototype.removeListener;U.prototype.removeAllListeners=function(r){var c,y,i;if(y=this._events,y===void 0)return this;if(y.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):y[r]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete y[r]),this;if(arguments.length===0){var f=Object.keys(y),u;for(i=0;i<f.length;++i)u=f[i],u!=="removeListener"&&this.removeAllListeners(u);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(c=y[r],typeof c=="function")this.removeListener(r,c);else if(c!==void 0)for(i=c.length-1;i>=0;i--)this.removeListener(r,c[i]);return this};function Fr(t,r,c){var y=t._events;if(y===void 0)return[];var i=y[r];return i===void 0?[]:typeof i=="function"?c?[i.listener||i]:[i]:c?dn(i):Xr(i,i.length)}U.prototype.listeners=function(r){return Fr(this,r,!0)};U.prototype.rawListeners=function(r){return Fr(this,r,!1)};U.listenerCount=function(t,r){return typeof t.listenerCount=="function"?t.listenerCount(r):qr.call(t,r)};U.prototype.listenerCount=qr;function qr(t){var r=this._events;if(r!==void 0){var c=r[t];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}U.prototype.eventNames=function(){return this._eventsCount>0?xt(this._events):[]};function Xr(t,r){for(var c=new Array(r),y=0;y<r;++y)c[y]=t[y];return c}function pn(t,r){for(;r+1<t.length;r++)t[r]=t[r+1];t.pop()}function dn(t){for(var r=new Array(t.length),c=0;c<r.length;++c)r[c]=t[c].listener||t[c];return r}function mn(t,r){return new Promise(function(c,y){function i(u){t.removeListener(r,f),y(u)}function f(){typeof t.removeListener=="function"&&t.removeListener("error",i),c([].slice.call(arguments))}Rr(t,r,f,{once:!0}),r!=="error"&&yn(t,i,{once:!0})})}function yn(t,r,c){typeof t.on=="function"&&Rr(t,"error",r,c)}function Rr(t,r,c,y){if(typeof t.on=="function")y.once?t.once(r,c):t.on(r,c);else if(typeof t.addEventListener=="function")t.addEventListener(r,function i(f){y.once&&t.removeEventListener(r,i),c(f)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var Br=F($t=>{(function(){"use strict";$t.stripBOM=function(t){return t[0]==="\uFEFF"?t.substring(1):t}}).call($t)});var Qt=F(ct=>{(function(){"use strict";var t;t=new RegExp(/(?!xmlns)^.*:/),ct.normalize=function(r){return r.toLowerCase()},ct.firstCharLowerCase=function(r){return r.charAt(0).toLowerCase()+r.slice(1)},ct.stripPrefix=function(r){return r.replace(t,"")},ct.parseNumbers=function(r){return isNaN(r)||(r=r%1===0?parseInt(r,10):parseFloat(r)),r},ct.parseBooleans=function(r){return/^(?:true|false)$/i.test(r)&&(r=r.toLowerCase()==="true"),r}}).call(ct)});var Vr=F(Ur=>{Ur.every=function(t){return new Zt(t)};var nt={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5};for(lt in nt)lt==="millisecond"?nt.ms=nt[lt]:nt[lt.charAt(0)]=nt[lt],nt[lt+"s"]=nt[lt];var lt;function Zt(t){this.count=0;var r=wn(t);r&&(this.time=Number(r[0])*nt[r[1]],this.type=r[1])}Zt.prototype.do=function(t){this.time&&(this.interval=setInterval(c,this.time));var r=this;function c(){r.count++,t.call(r)}return this};Zt.prototype.stop=function(){return this.interval&&(clearInterval(this.interval),delete this.interval),this};var gn=/^\s*(\d+(?:\.\d+)?)\s*([a-z]+)\s*$/;function wn(t){var r=t.match(gn);return r&&nt[r[2]]?r.slice(1):null}});var Wr=F(it=>{(function(){"use strict";var t,r,c,y,i,f,u,l,m,g=function(D,p){return function(){return D.apply(p,arguments)}},N=function(D,p){for(var T in p)O.call(p,T)&&(D[T]=p[T]);function E(){this.constructor=D}return E.prototype=p.prototype,D.prototype=new E,D.__super__=p.prototype,D},O={}.hasOwnProperty;l=Lr(),y=jr(),t=Br(),u=Qt(),m=Vr().setImmediate,r=gt().defaults,i=function(D){return typeof D=="object"&&D!=null&&Object.keys(D).length===0},f=function(D,p,T){var E,A,M;for(E=0,A=D.length;E<A;E++)M=D[E],p=M(p,T);return p},c=function(D,p,T){var E;return E=Object.create(null),E.value=T,E.writable=!0,E.enumerable=!0,E.configurable=!0,Object.defineProperty(D,p,E)},it.Parser=(function(D){N(p,D);function p(T){this.parseStringPromise=g(this.parseStringPromise,this),this.parseString=g(this.parseString,this),this.reset=g(this.reset,this),this.assignOrPush=g(this.assignOrPush,this),this.processAsync=g(this.processAsync,this);var E,A,M;if(!(this instanceof it.Parser))return new it.Parser(T);this.options={},A=r["0.2"];for(E in A)O.call(A,E)&&(M=A[E],this.options[E]=M);for(E in T)O.call(T,E)&&(M=T[E],this.options[E]=M);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(u.normalize)),this.reset()}return p.prototype.processAsync=function(){var T,E;try{return this.remaining.length<=this.options.chunkSize?(T=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(T),this.saxParser.close()):(T=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(T),m(this.processAsync))}catch(A){if(E=A,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(E)}},p.prototype.assignOrPush=function(T,E,A){return E in T?(T[E]instanceof Array||c(T,E,[T[E]]),T[E].push(A)):this.options.explicitArray?c(T,E,[A]):c(T,E,A)},p.prototype.reset=function(){var T,E,A,M;return this.removeAllListeners(),this.saxParser=l.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=(function(_){return function(d){if(_.saxParser.resume(),!_.saxParser.errThrown)return _.saxParser.errThrown=!0,_.emit("error",d)}})(this),this.saxParser.onend=(function(_){return function(){if(!_.saxParser.ended)return _.saxParser.ended=!0,_.emit("end",_.resultObject)}})(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,M=[],T=this.options.attrkey,E=this.options.charkey,this.saxParser.onopentag=(function(_){return function(d){var o,n,h,C,I;if(h={},h[E]="",!_.options.ignoreAttrs){I=d.attributes;for(o in I)O.call(I,o)&&(!(T in h)&&!_.options.mergeAttrs&&(h[T]={}),n=_.options.attrValueProcessors?f(_.options.attrValueProcessors,d.attributes[o],o):d.attributes[o],C=_.options.attrNameProcessors?f(_.options.attrNameProcessors,o):o,_.options.mergeAttrs?_.assignOrPush(h,C,n):c(h[T],C,n))}return h["#name"]=_.options.tagNameProcessors?f(_.options.tagNameProcessors,d.name):d.name,_.options.xmlns&&(h[_.options.xmlnskey]={uri:d.uri,local:d.local}),M.push(h)}})(this),this.saxParser.onclosetag=(function(_){return function(){var d,o,n,h,C,I,a,w,v,P;if(I=M.pop(),C=I["#name"],(!_.options.explicitChildren||!_.options.preserveChildrenOrder)&&delete I["#name"],I.cdata===!0&&(d=I.cdata,delete I.cdata),v=M[M.length-1],I[E].match(/^\s*$/)&&!d?(o=I[E],delete I[E]):(_.options.trim&&(I[E]=I[E].trim()),_.options.normalize&&(I[E]=I[E].replace(/\s{2,}/g," ").trim()),I[E]=_.options.valueProcessors?f(_.options.valueProcessors,I[E],C):I[E],Object.keys(I).length===1&&E in I&&!_.EXPLICIT_CHARKEY&&(I=I[E])),i(I)&&(typeof _.options.emptyTag=="function"?I=_.options.emptyTag():I=_.options.emptyTag!==""?_.options.emptyTag:o),_.options.validator!=null&&(P="/"+(function(){var x,q,X;for(X=[],x=0,q=M.length;x<q;x++)h=M[x],X.push(h["#name"]);return X})().concat(C).join("/"),(function(){var x;try{return I=_.options.validator(P,v&&v[C],I)}catch(q){return x=q,_.emit("error",x)}})()),_.options.explicitChildren&&!_.options.mergeAttrs&&typeof I=="object"){if(!_.options.preserveChildrenOrder)h={},_.options.attrkey in I&&(h[_.options.attrkey]=I[_.options.attrkey],delete I[_.options.attrkey]),!_.options.charsAsChildren&&_.options.charkey in I&&(h[_.options.charkey]=I[_.options.charkey],delete I[_.options.charkey]),Object.getOwnPropertyNames(I).length>0&&(h[_.options.childkey]=I),I=h;else if(v){v[_.options.childkey]=v[_.options.childkey]||[],a={};for(n in I)O.call(I,n)&&c(a,n,I[n]);v[_.options.childkey].push(a),delete I["#name"],Object.keys(I).length===1&&E in I&&!_.EXPLICIT_CHARKEY&&(I=I[E])}}return M.length>0?_.assignOrPush(v,C,I):(_.options.explicitRoot&&(w=I,I={},c(I,C,w)),_.resultObject=I,_.saxParser.ended=!0,_.emit("end",_.resultObject))}})(this),A=(function(_){return function(d){var o,n;if(n=M[M.length-1],n)return n[E]+=d,_.options.explicitChildren&&_.options.preserveChildrenOrder&&_.options.charsAsChildren&&(_.options.includeWhiteChars||d.replace(/\\n/g,"").trim()!=="")&&(n[_.options.childkey]=n[_.options.childkey]||[],o={"#name":"__text__"},o[E]=d,_.options.normalize&&(o[E]=o[E].replace(/\s{2,}/g," ").trim()),n[_.options.childkey].push(o)),n}})(this),this.saxParser.ontext=A,this.saxParser.oncdata=(function(_){return function(d){var o;if(o=A(d),o)return o.cdata=!0}})(this)},p.prototype.parseString=function(T,E){var A;E!=null&&typeof E=="function"&&(this.on("end",function(M){return this.reset(),E(null,M)}),this.on("error",function(M){return this.reset(),E(M)}));try{return T=T.toString(),T.trim()===""?(this.emit("end",null),!0):(T=t.stripBOM(T),this.options.async?(this.remaining=T,m(this.processAsync),this.saxParser):this.saxParser.write(T).close())}catch(M){if(A=M,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw A}else return this.emit("error",A),this.saxParser.errThrown=!0}},p.prototype.parseStringPromise=function(T){return new Promise((function(E){return function(A,M){return E.parseString(T,function(_,d){return _?M(_):A(d)})}})(this))},p})(y),it.parseString=function(D,p,T){var E,A,M;return T!=null?(typeof T=="function"&&(E=T),typeof p=="object"&&(A=p)):(typeof p=="function"&&(E=p),A={}),M=new it.Parser(A),M.parseString(D,E)},it.parseStringPromise=function(D,p){var T,E;return typeof p=="object"&&(T=p),E=new it.Parser(T),E.parseStringPromise(D)}}).call(it)});var kr=F(ot=>{(function(){"use strict";var t,r,c,y,i=function(u,l){for(var m in l)f.call(l,m)&&(u[m]=l[m]);function g(){this.constructor=u}return g.prototype=l.prototype,u.prototype=new g,u.__super__=l.prototype,u},f={}.hasOwnProperty;r=gt(),t=Nr(),c=Wr(),y=Qt(),ot.defaults=r.defaults,ot.processors=y,ot.ValidationError=(function(u){i(l,u);function l(m){this.message=m}return l})(Error),ot.Builder=t.Builder,ot.Parser=c.Parser,ot.parseString=c.parseString,ot.parseStringPromise=c.parseStringPromise}).call(ot)});var te=cn(kr()),$r=8e3;self.onmessage=async t=>{let{sourceType:r}=t.data;try{let c;if(r==="wms"){let{url:y,options:i}=t.data;c=await Tn(y,i)}else if(r==="wmts"){let{url:y,options:i}=t.data;c=await bn(y,i)}else c=null;self.postMessage(c)}catch{self.postMessage(null)}};var Tn=async(t,r)=>{let c=t+"?request=getcapabilities&service=wms",y=new AbortController,i=setTimeout(()=>y.abort(),$r);try{let f=await fetch(c,{signal:y.signal});if(clearTimeout(i),!f.ok)throw new Error(`(${f.status}) Error fetching capabilities.. ${f.statusText}`);let u=await f.text();return await Dn(u,c,r)}catch(f){throw f}},Dn=async(t,r,c)=>{let y=0,i=(g,N,O=null,D=0)=>{if(y>=c.maxNodes||D>c.maxDepth)return;y+=1;let p={name:g.Name?$(g.Name[0]):"",description:g.Abstract?$(g.Abstract[0]):"",selected:!1,parent:O,time:null};if(g.Title&&(p.title=$(g.Title[0])),Array.isArray(g.Dimension)){for(let T of g.Dimension)if(T.$?.name.toLowerCase()==="time"&&T.$?.units==="ISO8601"){p.time=Object.assign({current:T.$?.default??null},Qr(T._,T.$?.default));break}}g.Layer&&(p.children=[],g.Layer.forEach(T=>i(T,p.children,p,D+1))),N.push(p)};if(t.indexOf("<Capability")===-1)throw new Error("Error: Invalid response received!");let f=await(0,te.parseStringPromise)(t);if(!f.WMS_Capabilities&&!f.WMT_MS_Capabilities)throw new Error("Error: No Capabilities found!");let u=f.WMS_Capabilities?f.WMS_Capabilities:f.WMT_MS_Capabilities?f.WMT_MS_Capabilities:void 0;if(!u?.Capability[0].Layer)throw new Error("Error: No layer information found!");let l={name:"",description:"",type:"WMS",url:r,layers:[]};if(Z(u?.Service)){let g=u?.Service[0];l.name=Z(g.Title)?$(g.Title[0]):Z(g.Name)?$(g.Name[0]):"WMS",l.description=Z(g.Abstract)?$(g.Abstract[0]):""}let m=[];return u.Capability[0].Layer.forEach(g=>{i(g,m)}),m.sort((g,N)=>g.name<N.name?-1:1),l.layers=m,l},bn=async(t,r)=>{let c=t+"?request=GetCapabilities&service=wmts",y=new AbortController,i=setTimeout(()=>y.abort(),$r);try{let f=await fetch(c,{signal:y.signal});if(clearTimeout(i),!f.ok)throw new Error(`(${f.status}) Error fetching capabilities.. ${f.statusText}`);let u=await f.text();return await En(u,c,r)}catch(f){throw f}},En=async(t,r,c)=>{let y=l=>{if(!Z(l["ows:Identifier"]))return null;let m={name:Z(l["ows:Title"])?$(l["ows:Title"][0]):"",description:Z(l["ows:Abstract"])?$(l["ows:Abstract"][0]):"",id:$(l["ows:Identifier"][0])};if(Z(l["ows:WGS84BoundingBox"])&&(m.bounds=[Number(l["ows:WGS84BoundingBox"][0]["ows:LowerCorner"][0].split(" ")[0]),Number(l["ows:WGS84BoundingBox"][0]["ows:LowerCorner"][0].split(" ")[1]),Number(l["ows:WGS84BoundingBox"][0]["ows:UpperCorner"][0].split(" ")[0]),Number(l["ows:WGS84BoundingBox"][0]["ows:UpperCorner"][0].split(" ")[1])]),Z(l.Format)){let g=$(l.Format[0]);m.format=g.indexOf("jpg")!==-1?"jpg":"png"}else m.format="png";return Z(l.Dimension)&&l.Dimension.forEach(g=>{$(g["ows:Identifier"][0]).toLowerCase()==="time"&&(m.time=Object.assign({current:ft($(g.Default[0]))??null},Qr($(g.Value),$(g.Default[0]))))}),m};if(t.indexOf("<Capabilities")===-1)throw new Error("Error: Invalid response received!");let i=await(0,te.parseStringPromise)(t);if(!Z(i.Capabilities?.Contents))throw new Error("Error: No Capabilities found!");if(!Z(i.Capabilities.Contents[0].Layer))throw new Error("Error: No layer information found!");let f={name:"",description:"",type:"WMTS",url:r,layers:[]},u=0;for(let l of i.Capabilities.Contents[0].Layer){if(u>=c.maxNodes)break;let m=y(l);m&&f.layers.push(m),u++}return f.layers.sort((l,m)=>l.name<m.name?-1:1),f},Z=t=>Array.isArray(t)&&t.length!==0,$=t=>t._??t,Jt=t=>{let r=/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/,c=t.match(r);return c?{years:parseInt(c[1]??"0"),months:parseInt(c[2]??"0"),weeks:parseInt(c[3]??"0"),days:parseInt(c[4]??"0"),hours:parseInt(c[5]??"0"),minutes:parseInt(c[6]??"0"),seconds:parseFloat(c[7]??"0")}:{years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0}},Nn=t=>{let r=Jt(t);return r.weeks*(3600*1e3*24*7)+r.days*(3600*1e3*24)+r.hours*(3600*1e3)+r.minutes*(60*1e3)+r.seconds*1e3},Gr=(t,r,c)=>{let y={y:new Date(t).getFullYear(),m:new Date(t).getMonth(),d:new Date(t).getDate()},i={y:c?y.y+r.years:y.y-r.years,m:c?y.m+r.months:y.m-r.months,d:c?y.d+r.days:y.d-r.days};if(r.weeks){let l=r.weeks*7;i.d=c?i.d+l:i.d-l}let f=new Date(t);f.setFullYear(i.y,i.m,i.d);let u=r.hours*(1e3*3600)+r.minutes*(1e3*60)+r.seconds*1e3;return u=c?u:0-u,f.setTime(f.getTime()+u),f.toISOString()},Yr=t=>t.startsWith("P"),Kr=t=>!t.includes("-")&&!t.includes(":"),zr=t=>t.split("-").length===2&&!t.includes("T"),On=t=>t.split("-").length===3&&!t.includes("T"),In=t=>t.length===8&&!t.startsWith("P"),Cn=t=>t.includes("T")&&!t.includes(":"),Hr=t=>t.includes("/"),ft=t=>{try{return t.toLocaleLowerCase()==="current"||t.toLocaleLowerCase()==="present"?new Date().toISOString():(In(t)?t=`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6)}`:Cn(t)&&(t+=":00:00.000Z"),new Date(t).toISOString())}catch{throw new Error(`Unhandled Date format (${t})`)}},Qr=(t,r)=>{let c=i=>{if(Kr(i))return`${i}-12-31T23:59:59.999Z`;if(zr(i)){let f=i.split("-").map(l=>parseInt(l)),u=new Date(f[0],f[1],0).getDate();return`${i}-${u}T23:59:59.999Z`}else return On(i)?`${i}T23:59:59.999Z`:ft(i)},y=i=>{let f={from:null,to:null};if((i[0].toLocaleLowerCase()==="present"||i[0].toLocaleLowerCase()==="current")&&(i[0]=new Date().toISOString()),(i[1].toLocaleLowerCase()==="present"||i[1].toLocaleLowerCase()==="current")&&(i[1]=new Date().toISOString()),Yr(i[0])?f.from=Gr(i[1],Jt(i[0]),!1):f.from=ft(i[0]),Yr(i[1])?f.to=Gr(i[0],Jt(i[1]),!0):f.to=c(i[1]),i.length===3){let u=Nn(i[2]);u&&(f.interval=u)}return f};try{if(Array.isArray(t)){let i=[];if(t.forEach(u=>{if(Hr(u)){let l=y(u.split("/"));l&&i.push(l)}}),i.length){let u=new Date(r).valueOf();for(let l=0;l<i.length;l++)if(u>=new Date(i[l].from).valueOf()&&u<=new Date(i[l].to).valueOf())return i[l];return i[i.length-1]}let f=t.map(u=>ft(u));if(f.length>1)return{from:f[0]??null,to:f[f.length-1]??null,values:f};t=f[0]}if(t.includes(",")){let i=t.split(",").map(f=>ft(f));return{from:i[0]??null,to:i[i.length-1]??null,values:i}}else if(typeof t=="string"){if(Hr(t))return y(t.split("/"));if(Kr(t)){let i=new Date(t),f=i.getFullYear();return i.setFullYear(f+1),{from:ft(t),to:i.toISOString()}}else if(zr(t)){let i=new Date(t),f=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setFullYear(i.getFullYear(),i.getMonth(),f),i.setUTCHours(23),i.setUTCMinutes(59),i.setUTCSeconds(59,999),{from:ft(t),to:i.toISOString()}}else return{from:null,to:null}}}catch{return{from:null,to:null}}};
12
+ `?(e.line++,e.column=0):e.column++);e.cdata+=s.substring(W,L-1),b==="]"&&(e.state=a.CDATA_ENDING);continue;case a.CDATA_ENDING:b==="]"?e.state=a.CDATA_ENDING_2:(e.cdata+="]"+b,e.state=a.CDATA);continue;case a.CDATA_ENDING_2:b===">"?(e.cdata&&S(e,"oncdata",e.cdata),S(e,"onclosecdata"),e.cdata="",e.state=a.TEXT):b==="]"?e.cdata+="]":(e.cdata+="]]"+b,e.state=a.CDATA);continue;case a.PROC_INST:b==="?"?e.state=a.PROC_INST_ENDING:o(b)?e.state=a.PROC_INST_BODY:e.procInstName+=b;continue;case a.PROC_INST_BODY:if(!e.procInstBody&&o(b))continue;b==="?"?e.state=a.PROC_INST_ENDING:e.procInstBody+=b;continue;case a.PROC_INST_ENDING:if(b===">"){let et={name:e.procInstName,body:e.procInstBody};X(e,et),S(e,"onprocessinginstruction",et),e.procInstName=e.procInstBody="",e.state=a.TEXT}else e.procInstBody+="?"+b,e.state=a.PROC_INST_BODY;continue;case a.OPEN_TAG:C(M,b)?e.tagName+=b:(Zr(e),b===">"?at(e):b==="/"?e.state=a.OPEN_TAG_SLASH:(o(b)||B(e,"Invalid character in tag name"),e.state=a.ATTRIB));continue;case a.OPEN_TAG_SLASH:b===">"?(at(e,!0),Xt(e)):(B(e,"Forward-slash in opening tag not followed by >"),e.state=a.ATTRIB);continue;case a.ATTRIB:if(o(b))continue;b===">"?at(e):b==="/"?e.state=a.OPEN_TAG_SLASH:C(A,b)?(e.attribName=b,e.attribValue="",e.state=a.ATTRIB_NAME):B(e,"Invalid attribute name");continue;case a.ATTRIB_NAME:b==="="?e.state=a.ATTRIB_VALUE:b===">"?(B(e,"Attribute without value"),e.attribValue=e.attribName,qt(e),at(e)):o(b)?e.state=a.ATTRIB_NAME_SAW_WHITE:C(M,b)?e.attribName+=b:B(e,"Invalid attribute name");continue;case a.ATTRIB_NAME_SAW_WHITE:if(b==="=")e.state=a.ATTRIB_VALUE;else{if(o(b))continue;B(e,"Attribute without value"),e.tag.attributes[e.attribName]="",e.attribValue="",S(e,"onattribute",{name:e.attribName,value:""}),e.attribName="",b===">"?at(e):C(A,b)?(e.attribName=b,e.state=a.ATTRIB_NAME):(B(e,"Invalid attribute name"),e.state=a.ATTRIB)}continue;case a.ATTRIB_VALUE:if(o(b))continue;n(b)?(e.q=b,e.state=a.ATTRIB_VALUE_QUOTED):(e.opt.unquotedAttributeValues||J(e,"Unquoted attribute value"),e.state=a.ATTRIB_VALUE_UNQUOTED,e.attribValue=b);continue;case a.ATTRIB_VALUE_QUOTED:if(b!==e.q){b==="&"?e.state=a.ATTRIB_VALUE_ENTITY_Q:e.attribValue+=b;continue}qt(e),e.q="",e.state=a.ATTRIB_VALUE_CLOSED;continue;case a.ATTRIB_VALUE_CLOSED:o(b)?e.state=a.ATTRIB:b===">"?at(e):b==="/"?e.state=a.OPEN_TAG_SLASH:C(A,b)?(B(e,"No whitespace between attributes"),e.attribName=b,e.attribValue="",e.state=a.ATTRIB_NAME):B(e,"Invalid attribute name");continue;case a.ATTRIB_VALUE_UNQUOTED:if(!h(b)){b==="&"?e.state=a.ATTRIB_VALUE_ENTITY_U:e.attribValue+=b;continue}qt(e),b===">"?at(e):e.state=a.ATTRIB;continue;case a.CLOSE_TAG:if(e.tagName)b===">"?Xt(e):C(M,b)?e.tagName+=b:e.script?(e.script+="</"+e.tagName+b,e.tagName="",e.state=a.SCRIPT):(o(b)||B(e,"Invalid tagname in closing tag"),e.state=a.CLOSE_TAG_SAW_WHITE);else{if(o(b))continue;I(A,b)?e.script?(e.script+="</"+b,e.state=a.SCRIPT):B(e,"Invalid tagname in closing tag."):e.tagName=b}continue;case a.CLOSE_TAG_SAW_WHITE:if(o(b))continue;b===">"?Xt(e):B(e,"Invalid characters in closing tag");continue;case a.TEXT_ENTITY:case a.ATTRIB_VALUE_ENTITY_Q:case a.ATTRIB_VALUE_ENTITY_U:var G,z;switch(e.state){case a.TEXT_ENTITY:G=a.TEXT,z="textNode";break;case a.ATTRIB_VALUE_ENTITY_Q:G=a.ATTRIB_VALUE_QUOTED,z="attribValue";break;case a.ATTRIB_VALUE_ENTITY_U:G=a.ATTRIB_VALUE_UNQUOTED,z="attribValue";break}if(b===";"){var H=Jr(e);e.opt.unparsedEntities&&!Object.values(t.XML_ENTITIES).includes(H)?((e.entityCount+=1)>e.opt.maxEntityCount&&J(e,"Parsed entity count exceeds max entity count"),(e.entityDepth+=1)>e.opt.maxEntityDepth&&J(e,"Parsed entity depth exceeds max entity depth"),e.entity="",e.state=G,e.write(H),e.entityDepth-=1):(e[z]+=H,e.entity="",e.state=G)}else C(e.entity.length?d:_,b)?e.entity+=b:(B(e,"Invalid character in entity name"),e[z]+="&"+e.entity+b,e.entity="",e.state=G);continue;default:throw new Error(e,"Unknown state: "+e.state)}return e.position>=e.bufferCheckPosition&&y(e),e}String.fromCodePoint||(function(){var s=String.fromCharCode,e=Math.floor,L=function(){var b=16384,j=[],W,G,z=-1,H=arguments.length;if(!H)return"";for(var et="";++z<H;){var Y=Number(arguments[z]);if(!isFinite(Y)||Y<0||Y>1114111||e(Y)!==Y)throw RangeError("Invalid code point: "+Y);Y<=65535?j.push(Y):(Y-=65536,W=(Y>>10)+55296,G=Y%1024+56320,j.push(W,G)),(z+1===H||j.length>b)&&(et+=s.apply(null,j),j.length=0)}return et};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:L,configurable:!0,writable:!0}):String.fromCodePoint=L})()})(typeof Pt>"u"?Pt.sax={}:Pt)});var jr=F((xn,Ht)=>{"use strict";var pt=typeof Reflect=="object"?Reflect:null,vr=pt&&typeof pt.apply=="function"?pt.apply:function(r,c,y){return Function.prototype.apply.call(r,c,y)},xt;pt&&typeof pt.ownKeys=="function"?xt=pt.ownKeys:Object.getOwnPropertySymbols?xt=function(r){return Object.getOwnPropertyNames(r).concat(Object.getOwnPropertySymbols(r))}:xt=function(r){return Object.getOwnPropertyNames(r)};function fn(t){console&&console.warn&&console.warn(t)}var Ar=Number.isNaN||function(r){return r!==r};function U(){U.init.call(this)}Ht.exports=U;Ht.exports.once=mn;U.EventEmitter=U;U.prototype._events=void 0;U.prototype._eventsCount=0;U.prototype._maxListeners=void 0;var Mr=10;function St(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(U,"defaultMaxListeners",{enumerable:!0,get:function(){return Mr},set:function(t){if(typeof t!="number"||t<0||Ar(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Mr=t}});U.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};U.prototype.setMaxListeners=function(r){if(typeof r!="number"||r<0||Ar(r))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+r+".");return this._maxListeners=r,this};function Pr(t){return t._maxListeners===void 0?U.defaultMaxListeners:t._maxListeners}U.prototype.getMaxListeners=function(){return Pr(this)};U.prototype.emit=function(r){for(var c=[],y=1;y<arguments.length;y++)c.push(arguments[y]);var i=r==="error",f=this._events;if(f!==void 0)i=i&&f.error===void 0;else if(!i)return!1;if(i){var u;if(c.length>0&&(u=c[0]),u instanceof Error)throw u;var l=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw l.context=u,l}var m=f[r];if(m===void 0)return!1;if(typeof m=="function")vr(m,this,c);else for(var g=m.length,N=Xr(m,g),y=0;y<g;++y)vr(N[y],this,c);return!0};function xr(t,r,c,y){var i,f,u;if(St(c),f=t._events,f===void 0?(f=t._events=Object.create(null),t._eventsCount=0):(f.newListener!==void 0&&(t.emit("newListener",r,c.listener?c.listener:c),f=t._events),u=f[r]),u===void 0)u=f[r]=c,++t._eventsCount;else if(typeof u=="function"?u=f[r]=y?[c,u]:[u,c]:y?u.unshift(c):u.push(c),i=Pr(t),i>0&&u.length>i&&!u.warned){u.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+String(r)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=r,l.count=u.length,fn(l)}return t}U.prototype.addListener=function(r,c){return xr(this,r,c,!1)};U.prototype.on=U.prototype.addListener;U.prototype.prependListener=function(r,c){return xr(this,r,c,!0)};function hn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Sr(t,r,c){var y={fired:!1,wrapFn:void 0,target:t,type:r,listener:c},i=hn.bind(y);return i.listener=c,y.wrapFn=i,i}U.prototype.once=function(r,c){return St(c),this.on(r,Sr(this,r,c)),this};U.prototype.prependOnceListener=function(r,c){return St(c),this.prependListener(r,Sr(this,r,c)),this};U.prototype.removeListener=function(r,c){var y,i,f,u,l;if(St(c),i=this._events,i===void 0)return this;if(y=i[r],y===void 0)return this;if(y===c||y.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete i[r],i.removeListener&&this.emit("removeListener",r,y.listener||c));else if(typeof y!="function"){for(f=-1,u=y.length-1;u>=0;u--)if(y[u]===c||y[u].listener===c){l=y[u].listener,f=u;break}if(f<0)return this;f===0?y.shift():pn(y,f),y.length===1&&(i[r]=y[0]),i.removeListener!==void 0&&this.emit("removeListener",r,l||c)}return this};U.prototype.off=U.prototype.removeListener;U.prototype.removeAllListeners=function(r){var c,y,i;if(y=this._events,y===void 0)return this;if(y.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):y[r]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete y[r]),this;if(arguments.length===0){var f=Object.keys(y),u;for(i=0;i<f.length;++i)u=f[i],u!=="removeListener"&&this.removeAllListeners(u);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(c=y[r],typeof c=="function")this.removeListener(r,c);else if(c!==void 0)for(i=c.length-1;i>=0;i--)this.removeListener(r,c[i]);return this};function Fr(t,r,c){var y=t._events;if(y===void 0)return[];var i=y[r];return i===void 0?[]:typeof i=="function"?c?[i.listener||i]:[i]:c?dn(i):Xr(i,i.length)}U.prototype.listeners=function(r){return Fr(this,r,!0)};U.prototype.rawListeners=function(r){return Fr(this,r,!1)};U.listenerCount=function(t,r){return typeof t.listenerCount=="function"?t.listenerCount(r):qr.call(t,r)};U.prototype.listenerCount=qr;function qr(t){var r=this._events;if(r!==void 0){var c=r[t];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}U.prototype.eventNames=function(){return this._eventsCount>0?xt(this._events):[]};function Xr(t,r){for(var c=new Array(r),y=0;y<r;++y)c[y]=t[y];return c}function pn(t,r){for(;r+1<t.length;r++)t[r]=t[r+1];t.pop()}function dn(t){for(var r=new Array(t.length),c=0;c<r.length;++c)r[c]=t[c].listener||t[c];return r}function mn(t,r){return new Promise(function(c,y){function i(u){t.removeListener(r,f),y(u)}function f(){typeof t.removeListener=="function"&&t.removeListener("error",i),c([].slice.call(arguments))}Rr(t,r,f,{once:!0}),r!=="error"&&yn(t,i,{once:!0})})}function yn(t,r,c){typeof t.on=="function"&&Rr(t,"error",r,c)}function Rr(t,r,c,y){if(typeof t.on=="function")y.once?t.once(r,c):t.on(r,c);else if(typeof t.addEventListener=="function")t.addEventListener(r,function i(f){y.once&&t.removeEventListener(r,i),c(f)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var Br=F($t=>{(function(){"use strict";$t.stripBOM=function(t){return t[0]==="\uFEFF"?t.substring(1):t}}).call($t)});var Qt=F(ct=>{(function(){"use strict";var t;t=new RegExp(/(?!xmlns)^.*:/),ct.normalize=function(r){return r.toLowerCase()},ct.firstCharLowerCase=function(r){return r.charAt(0).toLowerCase()+r.slice(1)},ct.stripPrefix=function(r){return r.replace(t,"")},ct.parseNumbers=function(r){return isNaN(r)||(r=r%1===0?parseInt(r,10):parseFloat(r)),r},ct.parseBooleans=function(r){return/^(?:true|false)$/i.test(r)&&(r=r.toLowerCase()==="true"),r}}).call(ct)});var Vr=F(Ur=>{Ur.every=function(t){return new Zt(t)};var nt={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5};for(lt in nt)lt==="millisecond"?nt.ms=nt[lt]:nt[lt.charAt(0)]=nt[lt],nt[lt+"s"]=nt[lt];var lt;function Zt(t){this.count=0;var r=wn(t);r&&(this.time=Number(r[0])*nt[r[1]],this.type=r[1])}Zt.prototype.do=function(t){this.time&&(this.interval=setInterval(c,this.time));var r=this;function c(){r.count++,t.call(r)}return this};Zt.prototype.stop=function(){return this.interval&&(clearInterval(this.interval),delete this.interval),this};var gn=/^\s*(\d+(?:\.\d+)?)\s*([a-z]+)\s*$/;function wn(t){var r=t.match(gn);return r&&nt[r[2]]?r.slice(1):null}});var Wr=F(it=>{(function(){"use strict";var t,r,c,y,i,f,u,l,m,g=function(D,p){return function(){return D.apply(p,arguments)}},N=function(D,p){for(var T in p)O.call(p,T)&&(D[T]=p[T]);function E(){this.constructor=D}return E.prototype=p.prototype,D.prototype=new E,D.__super__=p.prototype,D},O={}.hasOwnProperty;l=Lr(),y=jr(),t=Br(),u=Qt(),m=Vr().setImmediate,r=gt().defaults,i=function(D){return typeof D=="object"&&D!=null&&Object.keys(D).length===0},f=function(D,p,T){var E,A,M;for(E=0,A=D.length;E<A;E++)M=D[E],p=M(p,T);return p},c=function(D,p,T){var E;return E=Object.create(null),E.value=T,E.writable=!0,E.enumerable=!0,E.configurable=!0,Object.defineProperty(D,p,E)},it.Parser=(function(D){N(p,D);function p(T){this.parseStringPromise=g(this.parseStringPromise,this),this.parseString=g(this.parseString,this),this.reset=g(this.reset,this),this.assignOrPush=g(this.assignOrPush,this),this.processAsync=g(this.processAsync,this);var E,A,M;if(!(this instanceof it.Parser))return new it.Parser(T);this.options={},A=r["0.2"];for(E in A)O.call(A,E)&&(M=A[E],this.options[E]=M);for(E in T)O.call(T,E)&&(M=T[E],this.options[E]=M);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(u.normalize)),this.reset()}return p.prototype.processAsync=function(){var T,E;try{return this.remaining.length<=this.options.chunkSize?(T=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(T),this.saxParser.close()):(T=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(T),m(this.processAsync))}catch(A){if(E=A,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(E)}},p.prototype.assignOrPush=function(T,E,A){return E in T?(T[E]instanceof Array||c(T,E,[T[E]]),T[E].push(A)):this.options.explicitArray?c(T,E,[A]):c(T,E,A)},p.prototype.reset=function(){var T,E,A,M;return this.removeAllListeners(),this.saxParser=l.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=(function(_){return function(d){if(_.saxParser.resume(),!_.saxParser.errThrown)return _.saxParser.errThrown=!0,_.emit("error",d)}})(this),this.saxParser.onend=(function(_){return function(){if(!_.saxParser.ended)return _.saxParser.ended=!0,_.emit("end",_.resultObject)}})(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,M=[],T=this.options.attrkey,E=this.options.charkey,this.saxParser.onopentag=(function(_){return function(d){var o,n,h,C,I;if(h={},h[E]="",!_.options.ignoreAttrs){I=d.attributes;for(o in I)O.call(I,o)&&(!(T in h)&&!_.options.mergeAttrs&&(h[T]={}),n=_.options.attrValueProcessors?f(_.options.attrValueProcessors,d.attributes[o],o):d.attributes[o],C=_.options.attrNameProcessors?f(_.options.attrNameProcessors,o):o,_.options.mergeAttrs?_.assignOrPush(h,C,n):c(h[T],C,n))}return h["#name"]=_.options.tagNameProcessors?f(_.options.tagNameProcessors,d.name):d.name,_.options.xmlns&&(h[_.options.xmlnskey]={uri:d.uri,local:d.local}),M.push(h)}})(this),this.saxParser.onclosetag=(function(_){return function(){var d,o,n,h,C,I,a,w,v,P;if(I=M.pop(),C=I["#name"],(!_.options.explicitChildren||!_.options.preserveChildrenOrder)&&delete I["#name"],I.cdata===!0&&(d=I.cdata,delete I.cdata),v=M[M.length-1],I[E].match(/^\s*$/)&&!d?(o=I[E],delete I[E]):(_.options.trim&&(I[E]=I[E].trim()),_.options.normalize&&(I[E]=I[E].replace(/\s{2,}/g," ").trim()),I[E]=_.options.valueProcessors?f(_.options.valueProcessors,I[E],C):I[E],Object.keys(I).length===1&&E in I&&!_.EXPLICIT_CHARKEY&&(I=I[E])),i(I)&&(typeof _.options.emptyTag=="function"?I=_.options.emptyTag():I=_.options.emptyTag!==""?_.options.emptyTag:o),_.options.validator!=null&&(P="/"+(function(){var x,q,X;for(X=[],x=0,q=M.length;x<q;x++)h=M[x],X.push(h["#name"]);return X})().concat(C).join("/"),(function(){var x;try{return I=_.options.validator(P,v&&v[C],I)}catch(q){return x=q,_.emit("error",x)}})()),_.options.explicitChildren&&!_.options.mergeAttrs&&typeof I=="object"){if(!_.options.preserveChildrenOrder)h={},_.options.attrkey in I&&(h[_.options.attrkey]=I[_.options.attrkey],delete I[_.options.attrkey]),!_.options.charsAsChildren&&_.options.charkey in I&&(h[_.options.charkey]=I[_.options.charkey],delete I[_.options.charkey]),Object.getOwnPropertyNames(I).length>0&&(h[_.options.childkey]=I),I=h;else if(v){v[_.options.childkey]=v[_.options.childkey]||[],a={};for(n in I)O.call(I,n)&&c(a,n,I[n]);v[_.options.childkey].push(a),delete I["#name"],Object.keys(I).length===1&&E in I&&!_.EXPLICIT_CHARKEY&&(I=I[E])}}return M.length>0?_.assignOrPush(v,C,I):(_.options.explicitRoot&&(w=I,I={},c(I,C,w)),_.resultObject=I,_.saxParser.ended=!0,_.emit("end",_.resultObject))}})(this),A=(function(_){return function(d){var o,n;if(n=M[M.length-1],n)return n[E]+=d,_.options.explicitChildren&&_.options.preserveChildrenOrder&&_.options.charsAsChildren&&(_.options.includeWhiteChars||d.replace(/\\n/g,"").trim()!=="")&&(n[_.options.childkey]=n[_.options.childkey]||[],o={"#name":"__text__"},o[E]=d,_.options.normalize&&(o[E]=o[E].replace(/\s{2,}/g," ").trim()),n[_.options.childkey].push(o)),n}})(this),this.saxParser.ontext=A,this.saxParser.oncdata=(function(_){return function(d){var o;if(o=A(d),o)return o.cdata=!0}})(this)},p.prototype.parseString=function(T,E){var A;E!=null&&typeof E=="function"&&(this.on("end",function(M){return this.reset(),E(null,M)}),this.on("error",function(M){return this.reset(),E(M)}));try{return T=T.toString(),T.trim()===""?(this.emit("end",null),!0):(T=t.stripBOM(T),this.options.async?(this.remaining=T,m(this.processAsync),this.saxParser):this.saxParser.write(T).close())}catch(M){if(A=M,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw A}else return this.emit("error",A),this.saxParser.errThrown=!0}},p.prototype.parseStringPromise=function(T){return new Promise((function(E){return function(A,M){return E.parseString(T,function(_,d){return _?M(_):A(d)})}})(this))},p})(y),it.parseString=function(D,p,T){var E,A,M;return T!=null?(typeof T=="function"&&(E=T),typeof p=="object"&&(A=p)):(typeof p=="function"&&(E=p),A={}),M=new it.Parser(A),M.parseString(D,E)},it.parseStringPromise=function(D,p){var T,E;return typeof p=="object"&&(T=p),E=new it.Parser(T),E.parseStringPromise(D)}}).call(it)});var kr=F(ot=>{(function(){"use strict";var t,r,c,y,i=function(u,l){for(var m in l)f.call(l,m)&&(u[m]=l[m]);function g(){this.constructor=u}return g.prototype=l.prototype,u.prototype=new g,u.__super__=l.prototype,u},f={}.hasOwnProperty;r=gt(),t=Nr(),c=Wr(),y=Qt(),ot.defaults=r.defaults,ot.processors=y,ot.ValidationError=(function(u){i(l,u);function l(m){this.message=m}return l})(Error),ot.Builder=t.Builder,ot.Parser=c.Parser,ot.parseString=c.parseString,ot.parseStringPromise=c.parseStringPromise}).call(ot)});var te=cn(kr()),$r=8e3;self.onmessage=async t=>{let{sourceType:r}=t.data;try{let c;if(r==="wms"){let{url:y,options:i}=t.data;c=await Tn(y,i)}else if(r==="wmts"){let{url:y,options:i}=t.data;c=await bn(y,i)}else c=null;self.postMessage(c)}catch{self.postMessage(null)}};var Tn=async(t,r)=>{let c=t+"?request=getcapabilities&service=wms",y=new AbortController,i=setTimeout(()=>y.abort(),$r);try{let f=await fetch(c,{signal:y.signal});if(clearTimeout(i),!f.ok)throw new Error(`(${f.status}) Error fetching capabilities.. ${f.statusText}`);let u=await f.text();return await Dn(u,c,r)}catch(f){throw f}},Dn=async(t,r,c)=>{let y=0,i=(g,N,O=null,D=0)=>{if(y>=c.maxNodes||D>c.maxDepth)return;y+=1;let p={name:g.Name?$(g.Name[0]):"",description:g.Abstract?$(g.Abstract[0]):"",selected:!1,parent:O,time:null};if(g.Title&&(p.title=$(g.Title[0])),Array.isArray(g.Dimension)){for(let T of g.Dimension)if(T.$?.name.toLowerCase()==="time"&&T.$?.units==="ISO8601"){p.time=Object.assign({current:T.$?.default??null},Qr(T._,T.$?.default));break}}g.Layer&&(p.children=[],g.Layer.forEach(T=>i(T,p.children,p,D+1))),N.push(p)};if(t.indexOf("<Capability")===-1)throw new Error("Error: Invalid response received!");let f=await(0,te.parseStringPromise)(t);if(!f.WMS_Capabilities&&!f.WMT_MS_Capabilities)throw new Error("Error: No Capabilities found!");let u=f.WMS_Capabilities?f.WMS_Capabilities:f.WMT_MS_Capabilities?f.WMT_MS_Capabilities:void 0;if(!u?.Capability[0].Layer)throw new Error("Error: No layer information found!");let l={name:"",description:"",type:"WMS",url:r,layers:[]};if(Z(u?.Service)){let g=u?.Service[0];l.name=Z(g.Title)?$(g.Title[0]):Z(g.Name)?$(g.Name[0]):"WMS",l.description=Z(g.Abstract)?$(g.Abstract[0]):""}let m=[];return u.Capability[0].Layer.forEach(g=>{i(g,m)}),m.sort((g,N)=>g.name<N.name?-1:1),l.layers=m,l},bn=async(t,r)=>{let c=t+"?request=GetCapabilities&service=wmts",y=new AbortController,i=setTimeout(()=>y.abort(),$r);try{let f=await fetch(c,{signal:y.signal});if(clearTimeout(i),!f.ok)throw new Error(`(${f.status}) Error fetching capabilities.. ${f.statusText}`);let u=await f.text();return await En(u,c,r)}catch(f){throw f}},En=async(t,r,c)=>{let y=l=>{if(!Z(l["ows:Identifier"]))return null;let m={name:Z(l["ows:Title"])?$(l["ows:Title"][0]):"",description:Z(l["ows:Abstract"])?$(l["ows:Abstract"][0]):"",id:$(l["ows:Identifier"][0])};if(Z(l["ows:WGS84BoundingBox"])&&(m.bounds=[Number(l["ows:WGS84BoundingBox"][0]["ows:LowerCorner"][0].split(" ")[0]),Number(l["ows:WGS84BoundingBox"][0]["ows:LowerCorner"][0].split(" ")[1]),Number(l["ows:WGS84BoundingBox"][0]["ows:UpperCorner"][0].split(" ")[0]),Number(l["ows:WGS84BoundingBox"][0]["ows:UpperCorner"][0].split(" ")[1])]),Z(l.Format)){let g=$(l.Format[0]);m.format=g.indexOf("jpg")!==-1?"jpg":"png"}else m.format="png";return Z(l.Dimension)&&l.Dimension.forEach(g=>{$(g["ows:Identifier"][0]).toLowerCase()==="time"&&(m.time=Object.assign({current:ft($(g.Default[0]))??null},Qr($(g.Value),$(g.Default[0]))))}),m};if(t.indexOf("<Capabilities")===-1)throw new Error("Error: Invalid response received!");let i=await(0,te.parseStringPromise)(t);if(!Z(i.Capabilities?.Contents))throw new Error("Error: No Capabilities found!");if(!Z(i.Capabilities.Contents[0].Layer))throw new Error("Error: No layer information found!");let f={name:"",description:"",type:"WMTS",url:r,layers:[]},u=0;for(let l of i.Capabilities.Contents[0].Layer){if(u>=c.maxNodes)break;let m=y(l);m&&f.layers.push(m),u++}return f.layers.sort((l,m)=>l.name<m.name?-1:1),f},Z=t=>Array.isArray(t)&&t.length!==0,$=t=>t._??t,Jt=t=>{let r=/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/,c=t.match(r);return c?{years:parseInt(c[1]??"0"),months:parseInt(c[2]??"0"),weeks:parseInt(c[3]??"0"),days:parseInt(c[4]??"0"),hours:parseInt(c[5]??"0"),minutes:parseInt(c[6]??"0"),seconds:parseFloat(c[7]??"0")}:{years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0}},Nn=t=>{let r=Jt(t);return r.weeks*(3600*1e3*24*7)+r.days*(3600*1e3*24)+r.hours*(3600*1e3)+r.minutes*(60*1e3)+r.seconds*1e3},Gr=(t,r,c)=>{let y={y:new Date(t).getFullYear(),m:new Date(t).getMonth(),d:new Date(t).getDate()},i={y:c?y.y+r.years:y.y-r.years,m:c?y.m+r.months:y.m-r.months,d:c?y.d+r.days:y.d-r.days};if(r.weeks){let l=r.weeks*7;i.d=c?i.d+l:i.d-l}let f=new Date(t);f.setFullYear(i.y,i.m,i.d);let u=r.hours*(1e3*3600)+r.minutes*(1e3*60)+r.seconds*1e3;return u=c?u:0-u,f.setTime(f.getTime()+u),f.toISOString()},Yr=t=>t.startsWith("P"),Kr=t=>!t.includes("-")&&!t.includes(":"),zr=t=>t.split("-").length===2&&!t.includes("T"),On=t=>t.split("-").length===3&&!t.includes("T"),In=t=>t.length===8&&!t.startsWith("P"),Cn=t=>t.includes("T")&&!t.includes(":"),Hr=t=>t.includes("/"),ft=t=>{try{return t.toLocaleLowerCase()==="current"||t.toLocaleLowerCase()==="present"?new Date().toISOString():(In(t)?t=`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6)}`:Cn(t)&&(t+=":00:00.000Z"),new Date(t).toISOString())}catch(r){throw new Error(`Unhandled Date format (${t})`,{cause:r})}},Qr=(t,r)=>{let c=i=>{if(Kr(i))return`${i}-12-31T23:59:59.999Z`;if(zr(i)){let f=i.split("-").map(l=>parseInt(l)),u=new Date(f[0],f[1],0).getDate();return`${i}-${u}T23:59:59.999Z`}else return On(i)?`${i}T23:59:59.999Z`:ft(i)},y=i=>{let f={from:null,to:null};if((i[0].toLocaleLowerCase()==="present"||i[0].toLocaleLowerCase()==="current")&&(i[0]=new Date().toISOString()),(i[1].toLocaleLowerCase()==="present"||i[1].toLocaleLowerCase()==="current")&&(i[1]=new Date().toISOString()),Yr(i[0])?f.from=Gr(i[1],Jt(i[0]),!1):f.from=ft(i[0]),Yr(i[1])?f.to=Gr(i[0],Jt(i[1]),!0):f.to=c(i[1]),i.length===3){let u=Nn(i[2]);u&&(f.interval=u)}return f};try{if(Array.isArray(t)){let i=[];if(t.forEach(u=>{if(Hr(u)){let l=y(u.split("/"));l&&i.push(l)}}),i.length){let u=new Date(r).valueOf();for(let l=0;l<i.length;l++)if(u>=new Date(i[l].from).valueOf()&&u<=new Date(i[l].to).valueOf())return i[l];return i[i.length-1]}let f=t.map(u=>ft(u));if(f.length>1)return{from:f[0]??null,to:f[f.length-1]??null,values:f};t=f[0]}if(t.includes(",")){let i=t.split(",").map(f=>ft(f));return{from:i[0]??null,to:i[i.length-1]??null,values:i}}else if(typeof t=="string"){if(Hr(t))return y(t.split("/"));if(Kr(t)){let i=new Date(t),f=i.getFullYear();return i.setFullYear(f+1),{from:ft(t),to:i.toISOString()}}else if(zr(t)){let i=new Date(t),f=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setFullYear(i.getFullYear(),i.getMonth(),f),i.setUTCHours(23),i.setUTCMinutes(59),i.setUTCSeconds(59,999),{from:ft(t),to:i.toISOString()}}else return{from:null,to:null}}}catch{return{from:null,to:null}}};