diff --git a/package.json b/package.json index 76b34a5..2210d05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "marco", - "version": "1.27.0", + "version": "1.27.1", "private": true, "description": "Unhosted maps app", "repository": { diff --git a/release/assets/main-D3dQ-CGf.js b/release/assets/main-D3dQ-CGf.js new file mode 100644 index 0000000..9be86f6 --- /dev/null +++ b/release/assets/main-D3dQ-CGf.js @@ -0,0 +1 @@ +var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:"Module"}),r},l=(o,a,l)=>(l=null!=o?t(i(o)):{},((t,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;ui[t]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return t})(!a&&o&&o.__esModule&&s.call(o,"default")?l:e(l,"default",{value:o,enumerable:!0}),o)),c=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,e)=>("undefined"!=typeof require?require:t)[e]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Calling `require` for "'+t+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});!function(){const t=document.createElement("link").relList;if(!(t&&t.supports&&t.supports("modulepreload"))){for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const n of t)if("childList"===n.type)for(const t of n.addedNodes)"LINK"===t.tagName&&"modulepreload"===t.rel&&e(t)}).observe(document,{childList:!0,subtree:!0})}function e(t){if(t.ep)return;t.ep=!0;const e=function(t){const e={};return t.integrity&&(e.integrity=t.integrity),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),"use-credentials"===t.crossOrigin?e.credentials="include":"anonymous"===t.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(t);fetch(t.href,e)}}();var u,h=Object.prototype,d=Symbol("undefined"),p=function(t){return t[t.ADD=0]="ADD",t[t.ONCE=1]="ONCE",t[t.REMOVE=2]="REMOVE",t}(p||{}),f=1,g=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(t){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=t,this.proto=void 0===t.constructor?void 0:t.constructor.prototype,this._listeners=void 0}get parent(){let t=this._parent;if(void 0===t){let e=m(this.source);this._parent=t=null===e||e===h?null:w(e)}return t}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(t){return this.proto===this.source&&this.source===t}_getOrCreateOwnMap(t){return this[t]||(this[t]=Object.create(null))}_getOrCreateOwnSet(t){return this[t]||(this[t]=new Set)}_findInheritedMap(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r){let t=r.get(e);if(void 0!==t)return t}n=n.parent}}_hasInInheritedSet(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r&&r.has(e))return!0;n=n.parent}return!1}valueFor(t){let e=this._values;return void 0!==e?e[t]:void 0}setValueFor(t,e){this._getOrCreateOwnMap("_values")[t]=e}revisionFor(t){let e=this._revisions;return void 0!==e?e[t]:void 0}setRevisionFor(t,e){this._getOrCreateOwnMap("_revisions")[t]=e}writableLazyChainsFor(t){let e=this._getOrCreateOwnMap("_lazyChains"),n=e[t];return void 0===n&&(n=e[t]=[]),n}readableLazyChainsFor(t){let e=this._lazyChains;if(void 0!==e)return e[t]}addMixin(t){this._getOrCreateOwnSet("_mixins").add(t)}hasMixin(t){return this._hasInInheritedSet("_mixins",t)}forEachMixins(t){let e,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(e=void 0===e?new Set:e,r.forEach(n=>{e.has(n)||(e.add(n),t(n))})),n=n.parent}}writeDescriptors(t,e){(this._descriptors||(this._descriptors=new Map)).set(t,e)}peekDescriptors(t){let e=this._findInheritedMap("_descriptors",t);return e===d?void 0:e}removeDescriptors(t){this.writeDescriptors(t,d)}forEachDescriptors(t){let e,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(e=void 0===e?new Set:e,r.forEach((n,r)=>{e.has(r)||(e.add(r),n!==d&&t(r,n))})),n=n.parent}}addToListeners(t,e,n,r,i){this.pushListener(t,e,n,r?p.ONCE:p.ADD,i)}removeFromListeners(t,e,n){this.pushListener(t,e,n,p.REMOVE)}pushListener(t,e,n,r,i=!1){let s=this.writableListeners(),o=_(s,t,e,n);if(-1!==o&&o0&&(t.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(let n of e)-1===_(t,n.event,n.target,n.method)&&(t.unshift(n),this._inheritedEnd++)}}this._flattenedVersion=f}return this._listeners}matchingListeners(t){let e,n=this.flattenedListeners();if(void 0!==n)for(let r of n)r.event!==t||r.kind!==p.ADD&&r.kind!==p.ONCE||(void 0===e&&(e=[]),e.push(r.target,r.method,r.kind===p.ONCE));return e}observerEvents(){let t,e=this.flattenedListeners();if(void 0!==e)for(let n of e)n.kind!==p.ADD&&n.kind!==p.ONCE||-1===n.event.indexOf(":change")||(void 0===t&&(t=[]),t.push(n));return t}},m=Object.getPrototypeOf,y=new WeakMap;function v(t,e){y.set(t,e)}function b(t){let e=y.get(t);if(void 0!==e)return e;let n=m(t);for(;null!==n;){if(e=y.get(n),void 0!==e)return e.proto!==n&&(e.proto=n),e;n=m(n)}return null}var w=function(t){let e=b(t);if(null!==e&&e.source===t)return e;let n=new g(t);return v(t,n),n};function _(t,e,n,r){for(let i=t.length-1;i>=0;i--){let s=t[i];if(s.event===e&&s.target===n&&s.method===r)return i}return-1}function x(t){let[e,n,r]=t;return 3===t.length&&("function"==typeof e||"object"==typeof e&&null!==e)&&"string"==typeof n&&("object"==typeof r&&null!==r||void 0===r)}function C(t){let e=function(){return t};return A(e),e}var S=class{enumerable=!0;configurable=!0;_dependentKeys=void 0;_meta=void 0;setup(t,e,n,r){r.writeDescriptors(e,this)}teardown(t,e,n){n.removeDescriptors(e)}};function k(t,e){return function(){return e.get(this,t)}}function E(t,e){let n=function(n){return e.set(this,t,n)};return R.add(n),n}var R=new WeakSet;function T(t,e){let n=function(e,n,r,i){let s=3===arguments.length?w(e):i;return t.setup(e,n,r,s),{enumerable:t.enumerable,configurable:t.configurable,get:k(n,t),set:E(n,t)}};return A(n,t),Object.setPrototypeOf(n,e.prototype),n}var L=new WeakMap;function I(t,e,n){let r=void 0===n?b(t):n;if(null!==r)return r.peekDescriptors(e)}function P(t){return L.get(t)}function M(t){return"function"==typeof t&&L.has(t)}function A(t,e=!0){L.set(t,e)}var O={ENABLE_OPTIONAL_FEATURES:!1,EXTEND_PROTOTYPES:{Array:!1},LOG_STACKTRACE_ON_DEPRECATION:!0,LOG_VERSION:!0,LOG_INSPECTOR_HINT:!0,RAISE_ON_DEPRECATION:!1,STRUCTURED_PROFILE:!1,_DEBUG_RENDER_TREE:!1,_ALL_DEPRECATIONS_ENABLED:!1,_OVERRIDE_DEPRECATION_VERSION:null,_DEFAULT_ASYNC_OBSERVERS:!1,_RERENDER_LOOP_LIMIT:1e3,FEATURES:{}},N=globalThis.EmberENV;if("object"==typeof N&&null!==N){for(let e in N){if(!Object.prototype.hasOwnProperty.call(N,e)||"EXTEND_PROTOTYPES"===e||"EMBER_LOAD_HOOKS"===e)continue;let t=O[e];O[e]=!0===t?!1!==N[e]:!1===t?!0===N[e]:N[e]}let{FEATURES:t}=N;if("object"==typeof t&&null!==t)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(O.FEATURES[e]=!0===t[e])}function F(){return O}var D,z,j,U,B,$,q,V,W=()=>{},H=new WeakMap,G=Symbol("BrandedArray");function K(t){return Array.isArray(t)&&G in t}function Z(t,e){if(null===t)return e;if(K(t))return t.push(e),t;{const n=[t,e];return n[G]=!0,n}}function Y(t,e){K(t)?t.forEach(e):null!==t&&e(t)}function X(t,e){if(K(t)&&t.length>1){let n=t.indexOf(e),r=t.length-1;return n!==r&&(t[n]=t[r]),t.length=r,t}return null}function J(t){let e=H.get(t);return void 0===e&&(e={parents:null,children:null,eagerDestructors:null,destructors:null,state:0},H.set(t,e)),e}function Q(t,e){let n=J(t),r=J(e);return n.children=Z(n.children,e),r.parents=Z(r.parents,t),e}function tt(t,e,n=!1){let r=J(t),i=n?"eagerDestructors":"destructors";return r[i]=Z(r[i],e),e}function et(t){let e=J(t);if(e.state>=1)return;let{parents:n,children:r,eagerDestructors:i,destructors:s}=e;e.state=1,Y(r,et),Y(i,e=>{e(t)}),Y(s,e=>{D(t,e)}),z(()=>{Y(n,e=>{!function(t,e){let n=J(e);2!==n.state&&(n.children=X(n.children,t))}(t,e)}),e.state=2})}function nt(t){let e=H.get(t);return void 0!==e&&null!==e.children}function rt(t){let e=H.get(t);return void 0!==e&&e.state>=1}function it(t){let e=H.get(t);return void 0!==e&&e.state>=2}var st=1;function ot(){st++}var at=Symbol("TAG_COMPUTE");function lt(t){return t[at]()}function ct(t,e){return e>=t[at]()}var ut=Symbol("TAG_TYPE"),ht=class t{static combine(e){switch(e.length){case 0:return mt;case 1:return e[0];default:{let n=new t(2);return n.subtag=e,n}}}revision=1;lastChecked=1;lastValue=1;isUpdating=!1;subtag=null;subtagBufferCache=null;constructor(t){this[ut]=t}[at](){let{lastChecked:t}=this;if(this.isUpdating)this.lastChecked=++st;else if(t!==st){this.isUpdating=!0,this.lastChecked=st;try{let{subtag:t,revision:e}=this;if(null!==t)if(Array.isArray(t))for(const n of t){let t=n[at]();e=Math.max(t,e)}else{let n=t[at]();n===this.subtagBufferCache?e=Math.max(e,this.lastValue):(this.subtagBufferCache=null,e=Math.max(e,n))}this.lastValue=e}finally{this.isUpdating=!1}}return this.lastValue}static updateTag(t,e){let n=t,r=e;r===mt?n.subtag=null:(n.subtagBufferCache=r[at](),n.subtag=r)}static dirtyTag(t,e){t.revision=++st,W()}},dt=ht.dirtyTag,pt=ht.updateTag;function ft(){return new ht(0)}function gt(){return new ht(1)}var mt=new ht(3);function yt(t){return t===mt}var vt=class{[ut]=100;[at](){return NaN}},bt=new vt,wt=class{[ut]=101;[at](){return st}},_t=new wt,xt=ht.combine,Ct=gt(),St=gt(),kt=gt();lt(Ct),dt(Ct),lt(Ct),pt(Ct,xt([St,kt])),lt(Ct),dt(St),lt(Ct),dt(kt),lt(Ct),pt(Ct,kt),lt(Ct),dt(kt),lt(Ct);var Et=class{tags=new Set;last=null;add(t){t!==mt&&(this.tags.add(t),this.last=t)}combine(){let{tags:t}=this;return 0===t.size?mt:1===t.size?this.last:xt(Array.from(this.tags))}},Rt=null,Tt=[];function Lt(){Tt.push(Rt),Rt=new Et}function It(){let t=Rt;return Rt=Tt.pop()||null,function(t){if(null==t)throw new Error("Expected value to be present");return t}(t).combine()}function Pt(){Tt.push(Rt),Rt=null}function Mt(){Rt=Tt.pop()||null}function At(){for(;Tt.length>0;)Tt.pop();Rt=null}function Ot(){return null!==Rt}function Nt(t){null!==Rt&&Rt.add(t)}var Ft=Symbol("FN"),Dt=Symbol("LAST_VALUE"),zt=Symbol("TAG"),jt=Symbol("SNAPSHOT");function Ut(t){return{[Ft]:t,[Dt]:void 0,[zt]:void 0,[jt]:-1}}function Bt(t){let e=t[Ft],n=t[zt],r=t[jt];if(void 0!==n&&ct(n,r))Nt(n);else{Lt();try{t[Dt]=e()}finally{n=It(),t[zt]=n,t[jt]=lt(n),Nt(n)}}return t[Dt]}function $t(t){return yt(t[zt])}function qt(t){let e;Lt();try{t()}finally{e=It()}return e}function Vt(t){Pt();try{return t()}finally{Mt()}}var Wt=new WeakMap;function Ht(t,e,n){let r=void 0===n?Wt.get(t):n;if(void 0===r)return;let i=r.get(e);void 0!==i&&dt(i,!0)}function Gt(t){let e=Wt.get(t);return void 0===e&&(e=new Map,Wt.set(t,e)),e}function Kt(t,e,n){let r=void 0===n?Gt(t):n,i=r.get(e);return void 0===i&&(i=gt(),r.set(e,i)),i}function Zt(t){return null!==t&&("object"==typeof t||"function"==typeof t)}function Yt(t){return t}function Xt(t){return t}function Jt(t){return!!t&&t.length>0}function Qt(t){return 0===t.length?void 0:t[t.length-1]}function te(t){return 0===t.length?void 0:t[0]}function ee(){return Object.create(null)}function ne(t){return null!=t}function re(t){return"function"==typeof t||"object"==typeof t&&null!==t}var ie=class{stack;current=null;constructor(t=[]){this.stack=t}get size(){return this.stack.length}push(t){this.current=t,this.stack.push(t)}pop(){let t=this.stack.pop();return this.current=Qt(this.stack)??null,void 0===t?null:t}nth(t){let e=this.stack.length;return ewe(t),null,t.debugLabel):t}function me(t){return 3===t[se]}function ye(t){const e=fe(()=>we(t),e=>_e(t,e));return e.debugLabel=t.debugLabel,e[se]=3,e}function ve(t){return t.tag===mt}function be(t){return null!==t.update}function we(t){const e=t;let{tag:n}=e;if(n===mt)return e.lastValue;const{lastRevision:r}=e;let i;if(null!==n&&ct(n,r))i=e.lastValue;else{const{compute:t}=e,r=qt(()=>{i=e.lastValue=t()});n=e.tag=r,e.lastRevision=lt(r)}return Nt(n),i}function _e(t,e){(0,t.update)(e)}function xe(t,e){const n=t,r=n[se];let i,s=n.children;if(null===s)s=n.children=new Map;else{const t=s.get(e);if(t)return t}if(2===r){const t=we(n);i=ne(t)?pe(t[e]):le}else i=fe(()=>{const t=we(n);if(ne(t))return B(t,e)},t=>{const r=we(n);if(ne(r))return $(r,e,t)});return s.set(e,i),i}function Ce(t,e){let n=t;for(const r of e)n=xe(n,r);return n}var Se=new WeakMap;function ke(t){return Se.get(t)}function Ee(t,e){Se.set(t,e)}function Re(t){if("symbol"==typeof t)return null;const e=Number(t);return isNaN(e)?null:e%1==0?e:null}var Te=class{constructor(t){this.named=t}get(t,e){const n=this.named[e];if(void 0!==n)return we(n)}has(t,e){return e in this.named}ownKeys(){return Object.keys(this.named)}isExtensible(){return!1}getOwnPropertyDescriptor(t,e){return{enumerable:!0,configurable:!0}}},Le=class{constructor(t){this.positional=t}get(t,e){let{positional:n}=this;if("length"===e)return n.length;const r=Re(e);return null!==r&&r>=0&&r=0&&n{const{named:e,positional:n}=t,r=new Te(e),i=new Le(n),s=Object.create(null),o=new Proxy(s,r),a=new Proxy([],i);return Ee(o,(t,n)=>function(t,e){return qt(()=>{e in t&&we(t[e])})}(e,n)),Ee(a,(t,e)=>function(t,e){return qt(()=>{"[]"===e&&t.forEach(we);const n=Re(e);null!==n&&n>=0&&n-1?function(t){return Be.test($e.call(t))}:function(){return!0},Ve=new WeakMap,We=Object.freeze(function(){});function He(t){let e=Ve.get(t);return void 0===e&&(e=qe(t),Ve.set(t,e)),e}Ve.set(We,!1);var Ge=class{listeners=void 0;observers=void 0},Ke=new WeakMap;function Ze(t){let e=Ke.get(t);return void 0===e&&(e=new Ge,Ke.set(t,e)),e}function Ye(t){return Ke.get(t)}function Xe(t,e){Ze(t).observers=e}function Je(t,e){Ze(t).listeners=e}var Qe=new WeakSet;function tn(t,e){return He(t)?!Qe.has(e)&&He(e)?en(t,en(e,We)):en(t,e):t}function en(t,e){function n(){let n=this._super;this._super=e;let r=t.apply(this,arguments);return this._super=n,r}Qe.add(n);let r=Ke.get(t);return void 0!==r&&Ke.set(n,r),n}function nn(t,e,n,r,i,s=!0){r||"function"!=typeof n||(r=n,n=null),w(t).addToListeners(e,n,r,!0===i,s)}function rn(t,e,n,r){let i,s;"object"==typeof n?(i=n,s=r):(i=null,s=n),w(t).removeFromListeners(e,i,s)}function sn(t,e,n,r,i){if(void 0===r){let n=void 0===i?b(t):i;r=null!==n?n.matchingListeners(e):void 0}if(void 0===r||0===r.length)return!1;for(let s=r.length-3;s>=0;s-=3){let i=r[s],o=r[s+1],a=r[s+2];if(!o)continue;a&&rn(t,e,i,o),i||(i=t);let l=typeof o;"string"!==l&&"symbol"!==l||(o=i[o]),o.apply(i,n)}return!0}function on(t,e){let n=b(t);if(null===n)return!1;let r=n.matchingListeners(e);return void 0!==r&&r.length>0}function an(...t){let e=t.pop();return Je(e,t),e}function ln(t){return t+":change"}var cn=!O._DEFAULT_ASYNC_OBSERVERS,un=new Map,hn=new Map;function dn(t,e,n,r,i=cn){let s=ln(e);nn(t,s,n,r,!1,i);let o=b(t);null!==o&&(o.isPrototypeMeta(t)||o.isInitializing())||fn(t,s,i)}function pn(t,e,n,r,i=cn){let s=ln(e),o=b(t);null!==o&&(o.isPrototypeMeta(t)||o.isInitializing())||yn(t,s,i),rn(t,s,n,r)}function fn(t,e,n=!1){let r=function(t,e){let n=!0===e?un:hn;return n.has(t)||(n.set(t,new Map),tt(t,()=>function(t){un.size>0&&un.delete(t),hn.size>0&&hn.delete(t)}(t),!0)),n.get(t)}(t,n);if(r.has(e))r.get(e).count++;else{let n=e.substring(0,e.lastIndexOf(":")),i=je(t,n,Gt(t),b(t));r.set(e,{count:1,path:n,tag:i,lastRevision:lt(i),suspended:!1})}}var gn=!1,mn=[];function yn(t,e,n=!1){if(!0===gn)return void mn.push([t,e,n]);let r=!0===n?un:hn,i=r.get(t);if(void 0!==i){let n=i.get(e);n.count--,0===n.count&&(i.delete(e),0===i.size&&r.delete(t))}}function vn(t){hn.has(t)&&hn.get(t).forEach(e=>{e.tag=je(t,e.path,Gt(t),b(t)),e.lastRevision=lt(e.tag)}),un.has(t)&&un.get(t).forEach(e=>{e.tag=je(t,e.path,Gt(t),b(t)),e.lastRevision=lt(e.tag)})}var bn=0;function wn(t){let e=lt(_t);bn!==e&&(bn=e,hn.forEach((e,n)=>{let r=b(n);e.forEach((e,i)=>{if(!ct(e.tag,e.lastRevision)){let s=()=>{try{sn(n,i,[n,e.path],void 0,r)}finally{e.tag=je(n,e.path,Gt(n),b(n)),e.lastRevision=lt(e.tag)}};t?t("actions",s):s()}})}))}function _n(){un.forEach((t,e)=>{let n=b(e);t.forEach((t,r)=>{if(!t.suspended&&!ct(t.tag,t.lastRevision))try{t.suspended=!0,sn(e,r,[e,t.path],void 0,n)}finally{t.tag=je(e,t.path,Gt(e),b(e)),t.lastRevision=lt(t.tag),t.suspended=!1}})})}function xn(t,e,n){let r=un.get(t);if(!r)return;let i=r.get(ln(e));i&&(i.suspended=n)}var Cn=()=>{},{toString:Sn}=Object.prototype,{toString:kn}=Function.prototype,{isArray:En}=Array,{keys:Rn}=Object,{stringify:Tn}=JSON,Ln=100,In=/^[\w$]+$/;function Pn(t){return"number"==typeof t&&2===arguments.length?this:Mn(t,0)}function Mn(t,e,n){let r=!1;switch(typeof t){case"undefined":return"undefined";case"object":if(null===t)return"null";if(En(t)){r=!0;break}if(t.toString===Sn||void 0===t.toString)break;return t.toString();case"function":return t.toString===kn?t.name?`[Function:${t.name}]`:"[Function]":t.toString();case"string":return Tn(t);default:return t.toString()}if(void 0===n)n=new WeakSet;else if(n.has(t))return"[Circular]";return n.add(t),r?function(t,e,n){if(e>4)return"[Array]";let r="[";for(let i=0;i=Ln){r+=`... ${t.length-Ln} more items`;break}r+=Mn(t[i],e,n)}return r+=" ]",r}(t,e+1,n):function(t,e,n){if(e>4)return"[Object]";let r="{",i=Rn(t);for(let s=0;s=Ln){r+=`... ${i.length-Ln} more keys`;break}let o=i[s];Cn(),r+=`${An(String(o))}: ${Mn(t[o],e,n)}`}return r+=" }",r}(t,e+1,n)}function An(t){return In.test(t)?t:Tn(t)}var On=/\.@each$/;function Nn(t,e){let n=t.indexOf("{");n<0?e(t.replace(On,".[]")):Fn("",t,n,e)}function Fn(t,e,n,r){let i,s,o=e.indexOf("}"),a=0,l=e.substring(n+1,o).split(","),c=e.substring(o+1);for(t+=e.substring(0,n),s=l.length;a0&&this._property(...t)}setup(t,e,n,r){if(super.setup(t,e,n,r),!1===this._hasConfig){let{get:t,set:e}=n;void 0!==t&&(this._getter=t),void 0!==e&&(this._setter=function(n,r){let i=e.call(this,r);return void 0!==t&&void 0===i?t.call(this):i})}}_property(...t){let e=[];function n(t){e.push(t)}for(let r of t)Nn(r,n);this._dependentKeys=e}get(t,e){let n,r=w(t),i=Gt(t),s=Kt(t,e,i),o=r.revisionFor(e);if(void 0!==o&&ct(s,o))n=r.valueFor(e);else{let{_getter:o,_dependentKeys:a}=this;Vt(()=>{n=o.call(t,e)}),void 0!==a&&pt(s,ze(t,a,i,r)),r.setValueFor(e,n),r.setRevisionFor(e,lt(s)),De(r,e,n)}return Nt(s),Array.isArray(n)&&Nt(Kt(n,"[]")),n}set(t,e,n){this._readOnly&&this._throwReadOnlyError(t,e);let r,i=w(t);i.isInitializing()&&void 0!==this._dependentKeys&&this._dependentKeys.length>0&&"function"==typeof t[Un]&&t.isComponent&&dn(t,e,()=>{t[Un](e)},void 0,!0);try{qn(),r=this._set(t,e,n,i),De(i,e,r);let s=Gt(t),o=Kt(t,e,s),{_dependentKeys:a}=this;void 0!==a&&pt(o,ze(t,a,s,i)),i.setRevisionFor(e,lt(o))}finally{Vn()}return r}_throwReadOnlyError(t,e){throw new Error(`Cannot set read-only property "${e}" on object: ${Pn(t)}`)}_set(t,e,n,r){let i,s=void 0!==r.revisionFor(e),o=r.valueFor(e),{_setter:a}=this;xn(t,e,!0);try{i=a.call(t,e,n,o)}finally{xn(t,e,!1)}return s&&o===i||(r.setValueFor(e,i),$n(t,e,r,n)),i}teardown(t,e,n){void 0!==n.revisionFor(e)&&(n.setRevisionFor(e,void 0),n.setValueFor(e,void 0)),super.teardown(t,e,n)}},Kn=class extends Gn{get(t,e){let n,r=w(t),i=Gt(t),s=Kt(t,e,i),o=r.revisionFor(e);if(void 0!==o&&ct(s,o))n=r.valueFor(e);else{let{_getter:i}=this,o=qt(()=>{n=i.call(t,e)});pt(s,o),r.setValueFor(e,n),r.setRevisionFor(e,lt(s)),De(r,e,n)}return Nt(s),Array.isArray(n)&&Nt(Kt(n,"[]",i)),n}},Zn=class extends Function{readOnly(){return P(this)._readOnly=!0,this}meta(t){let e=P(this);return 0===arguments.length?e._meta||{}:(e._meta=t,this)}get _getter(){return P(this)._getter}set enumerable(t){P(this).enumerable=t}};function Yn(...t){return x(t)?T(new Gn([]),Zn)(t[0],t[1],t[2]):T(new Gn(t),Zn)}function Xn(...t){return T(new Kn(t),Zn)}function Jn(t,e){return Boolean(I(t,e))}function Qn(t,e){let n=b(t);return n?n.valueFor(e):void 0}var tr=new WeakSet;function er(t){return!!Zt(t)&&tr.has(t)}function nr(t){Zt(t)&&tr.add(t)}var rr=new WeakSet;function ir(t){return rr.has(t)}var sr=class{size=0;misses=0;hits=0;constructor(t,e,n=new Map){this.limit=t,this.func=e,this.store=n}get(t){return this.store.has(t)?(this.hits++,this.store.get(t)):(this.misses++,this.set(t,this.func(t)))}set(t,e){return this.limit>this.size&&(this.size++,this.store.set(t,e)),e}purge(){this.store.clear(),this.size=0,this.hits=0,this.misses=0}},or=new sr(1e3,t=>t.indexOf("."));function ar(t){return"string"==typeof t&&-1!==or.get(t)}var lr=Symbol("PROXY_CONTENT");function cr(t){return"object"==typeof t&&null!==t&&"function"==typeof t.unknownProperty}function ur(t,e){return ar(e)?dr(t,e):hr(t,e)}function hr(t,e){if(null==t)return;let n;return"object"==typeof t||"function"==typeof t?(n=t[e],void 0===n&&"object"==typeof t&&!(e in t)&&cr(t)&&(n=t.unknownProperty(e)),Ot()&&(Nt(Kt(t,e)),(Array.isArray(n)||ir(n))&&Nt(Kt(n,"[]")))):n=t[e],n}function dr(t,e,n){let r="string"==typeof e?e.split("."):e;for(let i of r){if(null==t||t.isDestroyed)return;if(n&&("__proto__"===i||"constructor"===i))return;t=hr(t,i)}return t}hr("foo","a"),hr("foo",1),hr({},"a"),hr({},1),hr({unknownProperty(){}},"a"),hr({unknownProperty(){}},1),ur({},"foo"),ur({},"foo.bar");var pr={};function fr(t,e){let n=t;do{let t=Object.getOwnPropertyDescriptor(n,e);if(void 0!==t)return t;n=Object.getPrototypeOf(n)}while(null!==n);return null}function gr(t,e,n,r){return t.isDestroyed?n:ar(e)?function(t,e,n,r){let i=e.split("."),s=i.pop(),o=dr(t,i,!0);if(null!=o)return gr(o,s,n);if(!r)throw new Error(`Property set failed: object in path "${i.join(".")}" could not be found.`)}(t,e,n,r):mr(t,e,n)}function mr(t,e,n){let r,i=fr(t,e);return null!==i&&R.has(i.set)?(t[e]=n,n):(r=t[e],void 0!==r||"object"!=typeof t||e in t||"function"!=typeof t.setUnknownProperty?(t[e]=n,r!==n&&$n(t,e)):t.setUnknownProperty(e,n),n)}function yr(t,e,n){return gr(t,e,n,!0)}function vr(t){return T(new wr(t),br)}nr(pr),qt(()=>hr({},"a")),qt(()=>hr({},1)),qt(()=>hr({a:[]},"a")),qt(()=>hr({a:pr},"a"));var br=class extends Function{readOnly(){return P(this).readOnly(),this}oneWay(){return P(this).oneWay(),this}meta(t){let e=P(this);if(0===arguments.length)return e._meta||{};e._meta=t}},wr=class extends S{altKey;constructor(t){super(),this.altKey=t}setup(t,e,n,r){super.setup(t,e,n,r),Fe.add(this)}get(t,e){let n,r=w(t),i=Gt(t),s=Kt(t,e,i);Vt(()=>{n=ur(t,this.altKey)});let o=r.revisionFor(e);return void 0!==o&&ct(s,o)||(pt(s,je(t,this.altKey,i,r)),r.setRevisionFor(e,lt(s)),De(r,e,n)),Nt(s),n}set(t,e,n){return gr(t,this.altKey,n)}readOnly(){this.set=_r}oneWay(){this.set=xr}};function _r(t,e){throw new Error(`Cannot set read-only property '${e}' on object: ${Pn(t)}`)}function xr(t,e,n){return Dn(t,e,null),gr(t,e,n)}function Cr(t,e,n,r){return void 0===e?(e=0,n=r=-1):(void 0===n&&(n=-1),void 0===r&&(r=-1)),sn(t,"@array:before",[t,e,n,r]),t}function Sr(t,e,n,r,i=!0){void 0===e?(e=0,n=r=-1):(void 0===n&&(n=-1),void 0===r&&(r=-1));let s=b(t);if(i&&((r<0||n<0||r-n!==0)&&$n(t,"length",s),$n(t,"[]",s)),sn(t,"@array:change",[t,e,n,r]),null!==s){let i=-1===n?0:n,o=t.length-((-1===r?0:r)-i),a=e<0?o+e:e;void 0!==s.revisionFor("firstObject")&&0===a&&$n(t,"firstObject",s),void 0!==s.revisionFor("lastObject")&&o-1Ar}),Ar="7.2.0",Or=class{_registry;_coreLibIndex;constructor(){this._registry=[],this._coreLibIndex=0}_getLibraryByName(t){let e=this._registry;for(let n of e)if(n.name===t)return n}register(t,e,n){let r=this._registry.length;this._getLibraryByName(t)||(n&&(r=this._coreLibIndex++),this._registry.splice(r,0,{name:t,version:e}))}registerCoreLibrary(t,e){this.register(t,e,!0)}deRegister(t){let e,n=this._getLibraryByName(t);n&&(e=this._registry.indexOf(n),this._registry.splice(e,1))}},Nr=new Or;function Fr(t,e){let n,r={},i=1;for(2===arguments.length&&Array.isArray(e)?(i=0,n=arguments[1]):n=Array.from(arguments);i{let n=Object.keys(e);for(let r of n)gr(t,r,e[r])}),e}Nr.registerCoreLibrary("Ember",Ar);var zr=Symbol("OWNER");function jr(t){return t[zr]}function Ur(t){return jr(t)}function Br(t,e){!function(t,e){t[zr]=e}(t,e)}function $r(t,...e){let n,r;x(e)?n=e:"string"==typeof e[0]&&(r=e[0]);let i=Yn({get:function(e){return(Ur(this)||this.container).lookup(`${t}:${r||e}`)},set(t,e){Dn(this,t,null,e)}});return n?i(n[0],n[1],n[2]):i}function qr(t,e){let n=new WeakMap,r="function"==typeof e;return{getter:function(i){let s;return Nt(Kt(i,t)),r&&!n.has(i)?(s=e.call(i),n.set(i,s)):s=n.get(i),s},setter:function(e,r){Ht(e,t),n.set(e,r)}}}function Vr(...t){if(!x(t)){let e=t[0],n=e?e.initializer:void 0,r=e?e.value:void 0,i=function(t,e){return Wr([t,e,{initializer:n||(()=>r)}])};return A(i),i}return Wr(t)}function Wr([t,e,n]){let{getter:r,setter:i}=qr(e,n?n.initializer:void 0);function s(){let t=r(this);return(Array.isArray(t)||ir(t))&&Nt(Kt(t,"[]")),t}function o(t){i(this,t),Ht(this,Me)}let a={enumerable:!0,configurable:!0,isTracked:!0,get:s,set:o};return R.add(o),w(t).writeDescriptors(e,new Hr(s,o)),a}var Hr=class{constructor(t,e){this._get=t,this._set=e,Fe.add(this)}get(t){return this._get.call(t)}set(t,e,n){this._set.call(t,n)}},Gr=(...t)=>{const[e,n,r]=t,i=new WeakMap,s=r.get;r.get=function(){return i.has(this)||i.set(this,Ut(s.bind(this))),Bt(i.get(this))}},Kr=a({ENV:()=>O,context:()=>Xr,getENV:()=>F,getLookup:()=>Jr,setLookup:()=>Qr}),Zr=globalThis,Yr=Zr.Ember,Xr=void 0===Yr?{imports:Zr,exports:Zr,lookup:Zr}:{imports:Yr.imports||Zr,exports:Yr.exports||Zr,lookup:Yr.lookup||Zr};function Jr(){return Xr.lookup}function Qr(t){Xr.lookup=t}var ti=new WeakMap;function ei(t,e){Zt(t)&&ti.set(t,e)}function ni(t){return ti.get(t)}var ri=Object.prototype.hasOwnProperty,ii=!1,si={_set:0,_unprocessedNamespaces:!1,get unprocessedNamespaces(){return this._unprocessedNamespaces},set unprocessedNamespaces(t){this._set++,this._unprocessedNamespaces=t}},oi=!1,ai=[],li=Object.create(null);function ci(t){si.unprocessedNamespaces=!0,ai.push(t)}function ui(t){let e=ni(t);delete li[e],ai.splice(ai.indexOf(t),1),e in Xr.lookup&&t===Xr.lookup[e]&&(Xr.lookup[e]=void 0)}function hi(){if(!si.unprocessedNamespaces)return;let t=Xr.lookup,e=Object.keys(t);for(let n of e){if(!wi(n.charCodeAt(0)))continue;let e=_i(t,n);e&&ei(e,n)}}function di(t){return ii||fi(),li[t]}function pi(t){vi([t.toString()],t,new Set)}function fi(){let t=si.unprocessedNamespaces;if(t&&(hi(),si.unprocessedNamespaces=!1),t||oi){let t=ai;for(let e of t)pi(e);oi=!1}}function gi(){return ii}function mi(t){ii=Boolean(t)}function yi(){oi=!0}function vi(t,e,n){let r=t.length,i=t.join(".");li[i]=e,ei(e,i);for(let s in e){if(!ri.call(e,s))continue;let i=e[s];if(t[r]=s,i&&void 0===ni(i))ei(i,t.join("."));else if(i&&bi(i)){if(n.has(i))continue;n.add(i),vi(t,i,n)}}t.length=r}function bi(t){return null!=t&&"object"==typeof t&&t.isNamespace}function wi(t){return t>=65&&t<=90}function _i(t,e){try{let n=t[e];return(null!==n&&"object"==typeof n||"function"==typeof n)&&n.isNamespace&&n}catch(n){}}var xi=a({ASYNC_OBSERVERS:()=>hn,ComputedDescriptor:()=>S,ComputedProperty:()=>Gn,DEBUG_INJECTION_FUNCTIONS:()=>{},Libraries:()=>Or,NAMESPACES:()=>ai,NAMESPACES_BY_ID:()=>li,PROPERTY_DID_CHANGE:()=>Un,PROXY_CONTENT:()=>lr,SYNC_OBSERVERS:()=>un,TrackedDescriptor:()=>Hr,_getPath:()=>dr,_getProp:()=>hr,_setProp:()=>mr,activateObserver:()=>fn,addArrayObserver:()=>Ir,addListener:()=>nn,addNamespace:()=>ci,addObserver:()=>dn,alias:()=>vr,arrayContentDidChange:()=>Sr,arrayContentWillChange:()=>Cr,autoComputed:()=>Xn,beginPropertyChanges:()=>qn,cached:()=>Gr,changeProperties:()=>Wn,computed:()=>Yn,createCache:()=>Ut,defineDecorator:()=>zn,defineProperty:()=>Dn,defineValue:()=>jn,deprecateProperty:()=>Ci,descriptorForDecorator:()=>P,descriptorForProperty:()=>I,eachProxyArrayDidChange:()=>Ei,eachProxyArrayWillChange:()=>ki,endPropertyChanges:()=>Vn,expandProperties:()=>Nn,findNamespace:()=>di,findNamespaces:()=>hi,flushAsyncObservers:()=>wn,get:()=>ur,getCachedValueFor:()=>Qn,getProperties:()=>Fr,getValue:()=>Bt,hasListeners:()=>on,hasUnknownProperty:()=>cr,inject:()=>$r,isClassicDecorator:()=>M,isComputed:()=>Jn,isConst:()=>$t,isElementDescriptor:()=>x,isNamespaceSearchDisabled:()=>gi,libraries:()=>Nr,makeComputedDecorator:()=>T,markObjectAsDirty:()=>Ne,nativeDescDecorator:()=>C,notifyPropertyChange:()=>$n,objectAt:()=>Pe,on:()=>an,processAllNamespaces:()=>fi,processNamespace:()=>pi,removeArrayObserver:()=>Pr,removeListener:()=>rn,removeNamespace:()=>ui,removeObserver:()=>pn,replace:()=>Er,replaceInNativeArray:()=>Tr,revalidateObservers:()=>vn,sendEvent:()=>sn,set:()=>gr,setClassicDecorator:()=>A,setNamespaceSearchDisabled:()=>mi,setProperties:()=>Dr,setUnprocessedMixins:()=>yi,tagForObject:()=>Oe,tagForProperty:()=>Ae,tracked:()=>Vr,trySet:()=>yr});function Ci(t,e,n){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,set(t){gr(this,n,t)},get(){return ur(this,n)}})}var Si=new WeakMap;function ki(t,e,n,r){let i=Si.get(t);void 0!==i&&i.arrayWillChange(t,e,n,r)}function Ei(t,e,n,r){let i=Si.get(t);void 0!==i&&i.arrayDidChange(t,e,n,r)}var Ri={get onerror(){}},Ti=setTimeout,Li=()=>{};function Ii(t){if("function"==typeof Promise){const e=Promise.resolve();return()=>e.then(t)}if("function"==typeof MutationObserver){let e=0,n=new MutationObserver(t),r=document.createTextNode("");return n.observe(r,{characterData:!0}),()=>(e=++e%2,r.data=""+e,e)}return()=>Ti(t,0)}function Pi(t){let e=Li;return{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),now:()=>Date.now(),next:Ii(t),clearNext:e}}var Mi=/\d+/;function Ai(t){let e=typeof t;return"number"===e&&t==t||"string"===e&&Mi.test(t)}function Oi(t){return t.onError||t.onErrorTarget&&t.onErrorTarget[t.onErrorMethod]}function Ni(t,e,n){let r=-1;for(let i=0,s=n.length;i=e[n]?i=n+6:s=n;return t>=e[i]?i+6:i}var ji=class{constructor(t,e={},n={}){this._queueBeingFlushed=[],this.targetQueues=new Map,this.index=0,this._queue=[],this.name=t,this.options=e,this.globalOptions=n}stackFor(t){if(t0){let t=Oi(this.globalOptions);s=t?this.invokeWithOnError:this.invoke;for(let o=this.index;o0&&this.flush(!0)}hasWork(){return this._queueBeingFlushed.length>0||this._queue.length>0}cancel({target:t,method:e}){let n=this._queue,r=this.targetQueues.get(t);void 0!==r&&r.delete(e);let i=Ni(t,e,n);return i>-1?(n[i+1]=null,!0):(n=this._queueBeingFlushed,i=Ni(t,e,n),i>-1&&(n[i+1]=null,!0))}push(t,e,n,r){return this._queue.push(t,e,n,r),{queue:this,target:t,method:e}}pushUnique(t,e,n,r){let i=this.targetQueues.get(t);void 0===i&&(i=new Map,this.targetQueues.set(t,i));let s=i.get(e);if(void 0===s){let s=this._queue.push(t,e,n,r)-4;i.set(e,s)}else{let t=this._queue;t[s+2]=n,t[s+3]=r}return{queue:this,target:t,method:e}}_getDebugInfo(t){if(t)return Di(this._queue,4)}invoke(t,e,n){void 0===n?e.call(t):e.apply(t,n)}invokeWithOnError(t,e,n,r,i){try{void 0===n?e.call(t):e.apply(t,n)}catch(e6){r(e6,i)}}},Ui=class{constructor(t=[],e){this.queues={},this.queueNameIndex=0,this.queueNames=t,t.reduce(function(t,n){return t[n]=new ji(n,e[n],e),t},this.queues)}schedule(t,e,n,r,i,s){let o=this.queues[t];if(void 0===o)throw new Error(`You attempted to schedule an action in a queue (${t}) that doesn't exist`);if(null==n)throw new Error(`You attempted to schedule an action in a queue (${t}) for a method that doesn't exist`);return this.queueNameIndex=0,i?o.pushUnique(e,n,r,s):o.push(e,n,r,s)}flush(t=!1){let e,n,r=this.queueNames.length;for(;this.queueNameIndexi){let e=r-i;t=new Array(e);for(let n=0;n{us++,!1!==this._autorun&&(this._autorun=!1,this._autorunStack=null,this._end(!0))};let n=this.options._buildPlatform||Pi;this._platform=n(this._boundAutorunEnd)}get counters(){return{begin:Gi,end:Ki,events:{begin:Zi,end:0},autoruns:{created:cs,completed:us},run:Yi,join:Xi,defer:Ji,schedule:Qi,scheduleIterable:ts,deferOnce:es,scheduleOnce:ns,setTimeout:rs,later:is,throttle:ss,debounce:os,cancelTimers:as,cancel:ls,loops:{total:hs,nested:ds}}}get defaultQueue(){return this._defaultQueue}begin(){Gi++;let t,e=this.options,n=this.currentInstance;return!1!==this._autorun?(t=n,this._cancelAutorun()):(null!==n&&(ds++,this.instanceStack.push(n)),hs++,t=this.currentInstance=new Ui(this.queueNames,e),Zi++,this._trigger("begin",t,n)),this._onBegin(t,n),t}end(){Ki++,this._end(!1)}on(t,e){if("function"!=typeof e)throw new TypeError("Callback must be a function");let n=this._eventCallbacks[t];if(void 0===n)throw new TypeError(`Cannot on() event ${t} because it does not exist`);n.push(e)}off(t,e){let n=this._eventCallbacks[t];if(!t||void 0===n)throw new TypeError(`Cannot off() event ${t} because it does not exist`);let r=!1;if(e)for(let i=0;i0&&Ai(n[i-1])&&(r=parseInt(n.pop(),10)),[t,e,n,r]}(...arguments);return this._later(t,e,n,r)}throttle(){ss++;let t,[e,n,r,i,s=!0]=Wi(...arguments),o=Fi(e,n,this._timers);if(-1===o)t=this._later(e,n,s?qi:r,i),s&&this._join(e,n,r);else{t=this._timers[o+1];let e=o+4;this._timers[e]!==qi&&(this._timers[e]=r)}return t}debounce(){os++;let t,[e,n,r,i,s=!1]=Wi(...arguments),o=this._timers,a=Fi(e,n,o);if(-1===a)t=this._later(e,n,s?qi:r,i),s&&this._join(e,n,r);else{let s=this._platform.now()+i,l=a+4;o[l]===qi&&(r=qi),t=o[a+1];let c=zi(s,o);if(a+6===c)o[a]=s,o[l]=r;else{let i=this._timers[a+5];this._timers.splice(c,0,s,t,e,n,r,i),this._timers.splice(a,6)}0===a&&this._reinstallTimerTimeout()}return t}cancelTimers(){as++,this._clearTimerTimeout(),this._timers=[],this._cancelAutorun()}hasTimers(){return this._timers.length>0||this._autorun}cancel(t){if(ls++,null==t)return!1;let e=typeof t;return"number"===e?this._cancelLaterTimer(t):!("object"!==e||!t.queue||!t.method)&&t.queue.cancel(t)}ensureInstance(){this._ensureInstance()}getDebugInfo(){if(this.DEBUG)return{autorun:this._autorunStack,counters:this.counters,timers:Di(this._timers,6,2),instanceStack:[this.currentInstance,...this.instanceStack].map(t=>t&&t._getDebugInfo(this.DEBUG))}}_end(t){let e=this.currentInstance,n=null;if(null===e)throw new Error("end called without begin");let r,i=!1;try{r=e.flush(t)}finally{if(!i)if(i=!0,1===r){const t=this.queueNames[e.queueNameIndex];this._scheduleAutorun(t)}else this.currentInstance=null,this.instanceStack.length>0&&(n=this.instanceStack.pop(),this.currentInstance=n),this._trigger("end",e,n),this._onEnd(e,n)}}_join(t,e,n){return null===this.currentInstance?this._run(t,e,n):void 0===t&&void 0===n?e():e.apply(t,n)}_run(t,e,n){let r=Oi(this.options);if(this.begin(),r)try{return e.apply(t,n)}catch(e6){r(e6)}finally{this.end()}else try{return e.apply(t,n)}finally{this.end()}}_cancelAutorun(){this._autorun&&(this._platform.clearNext(),this._autorun=!1,this._autorunStack=null)}_later(t,e,n,r){let i=this.DEBUG?new Error:void 0,s=this._platform.now()+r,o=Hi++;if(0===this._timers.length)this._timers.push(s,o,t,e,n,i),this._installTimerTimeout();else{let r=zi(s,this._timers);this._timers.splice(r,0,s,o,t,e,n,i),this._reinstallTimerTimeout()}return o}_cancelLaterTimer(t){for(let e=1;e0&&(this.begin(),this._scheduleExpiredTimers(),this.end())}_scheduleExpiredTimers(){let t=this._timers,e=0,n=t.length,r=this._defaultQueue,i=this._platform.now();for(;ei);e+=6){let n=t[e+4];if(n!==qi){let i=t[e+2],s=t[e+3],o=t[e+5];this.currentInstance.schedule(r,i,s,n,!1,o)}}t.splice(0,e),this._installTimerTimeout()}_reinstallTimerTimeout(){this._clearTimerTimeout(),this._installTimerTimeout()}_clearTimerTimeout(){null!==this._timerTimeoutId&&(this._platform.clearTimeout(this._timerTimeoutId),this._timerTimeoutId=null)}_installTimerTimeout(){if(0===this._timers.length)return;let t=this._timers[0],e=this._platform.now(),n=Math.max(0,t-e);this._timerTimeoutId=this._platform.setTimeout(this._boundRunExpiredTimers,n)}_ensureInstance(){let t=this.currentInstance;return null===t&&(this._autorunStack=this.DEBUG?new Error:void 0,t=this.begin(),this._scheduleAutorun(this.queueNames[0])),t}_scheduleAutorun(t){cs++;const e=this._platform.next,n=this.options.flush;n?n(t,e):e(),this._autorun=!0}};ps.Queue=ji,ps.buildPlatform=Pi,ps.buildNext=Ii;var fs=a({_backburner:()=>bs,_cancelTimers:()=>Rs,_getCurrentRunLoop:()=>ms,_hasScheduledTimers:()=>Es,_queues:()=>vs,_rsvpErrorQueue:()=>ys,begin:()=>Cs,bind:()=>xs,cancel:()=>Ms,debounce:()=>As,end:()=>Ss,join:()=>_s,later:()=>Ts,next:()=>Ps,once:()=>Ls,run:()=>ws,schedule:()=>ks,scheduleOnce:()=>Is,throttle:()=>Os}),gs=null;function ms(){return gs}var ys=`${Math.random()}${Date.now()}`.replace(".",""),vs=["actions","routerTransitions","render","afterRender","destroy",ys],bs=new ps(vs,{defaultQueue:"actions",onBegin:function(t){gs=t},onEnd:function(t,e){gs=e,wn(ks)},onErrorTarget:Ri,onErrorMethod:"onerror",flush:function(t,e){"render"!==t&&t!==ys||wn(ks),e()}});function ws(...t){return bs.run(...t)}function _s(t,e,...n){return bs.join(t,e,...n)}function xs(...t){return(...e)=>_s(...t.concat(e))}function Cs(){bs.begin()}function Ss(){bs.end()}function ks(...t){return bs.schedule(...t)}function Es(){return bs.hasTimers()}function Rs(){bs.cancelTimers()}function Ts(...t){return bs.later(...t)}function Ls(...t){return bs.scheduleOnce("actions",...t)}function Is(...t){return bs.scheduleOnce(...t)}function Ps(...t){return bs.later(...t,1)}function Ms(t){return bs.cancel(t)}function As(...t){return bs.debounce(...t)}function Os(...t){return bs.throttle(...t)}var Ns=new Set([Symbol.iterator,"concat","entries","every","filter","find","findIndex","flat","flatMap","forEach","includes","indexOf","join","keys","lastIndexOf","map","reduce","reduceRight","slice","some","values"]),Fs=new Set(["fill","push","unshift"]);function Ds(t){if("symbol"==typeof t)return null;const e=Number(t);return isNaN(e)?null:e%1==0?e:null}var zs=class t{#t;constructor(e,n){this.#t=n;const r=e.slice(),i=this,s=new Map;let o=!1;return new Proxy(r,{get(t,e){const n=Ds(e);if(null!==n)return i.#e(n),Nt(i.#n),t[n];if("length"===e)return o?o=!1:Nt(i.#n),t[e];if(Fs.has(e)&&(o=!0),Ns.has(e)){let n=s.get(e);return void 0===n&&(n=(...n)=>(Nt(i.#n),t[e](...n)),s.set(e,n)),n}return t[e]},set(t,e,n){if(i.#t.equals(t[e],n))return!0;t[e]=n;const r=Ds(e);return null!==r?(i.#r(r),i.#i()):"length"===e&&i.#i(),!0},getPrototypeOf:()=>t.prototype})}#n=gt();#s=new Map;#e(t){let e=this.#s.get(t);void 0===e&&(e=gt(),this.#s.set(t,e)),Nt(e)}#r(t){const e=this.#s.get(t);e&&dt(e)}#i(){dt(this.#n),this.#s.clear()}};function js(t,e){return new zs(t??[],{equals:e?.equals??Object.is,description:e?.description})}Object.setPrototypeOf(zs.prototype,Array.prototype);var Us=class t{#t;#s=new Map;#n=gt();#e(t){let e=this.#s.get(t);void 0===e&&(e=gt(),this.#s.set(t,e)),Nt(e)}#r(t){const e=this.#s.get(t);e&&dt(e)}#i(){dt(this.#n)}constructor(e,n){this.#t=n;const r=Object.getPrototypeOf(e),i=Object.getOwnPropertyDescriptors(e),s=Object.create(r);for(const t in i)Object.defineProperty(s,t,i[t]);const o=this;return new Proxy(s,{get:(t,e)=>(o.#e(e),t[e]),has:(t,e)=>(o.#e(e),e in t),ownKeys:t=>(Nt(o.#n),Reflect.ownKeys(t)),set:(t,e,n)=>(o.#t.equals(t[e],n)||(t[e]=n,o.#r(e),o.#i()),!0),deleteProperty:(t,e)=>(e in t&&(delete t[e],o.#r(e),o.#s.delete(e),o.#i()),!0),getPrototypeOf:()=>t.prototype})}};function Bs(t,e){return new Us(t??{},{equals:e?.equals??Object.is,description:e?.description})}function $s(t,e){const n=e?.equals??Object.is,r=new Set(t??[]),i=gt(),s=new Map;function o(t){const e=s.get(t);e&&dt(e)}const a=new Proxy(r,{get(t,e,r){if("add"===e)return function(e){if(t.has(e)){if(n(e,e))return a}else dt(i);return o(e),t.add(e),a};if("delete"===e)return function(e){return!!t.has(e)&&(o(e),dt(i),s.delete(e),t.delete(e))};if("clear"===e)return function(){0!==t.size&&(s.forEach(t=>dt(t)),dt(i),s.clear(),t.clear())};if("has"===e)return function(e){return Nt(function(t){let e=s.get(t);return void 0===e&&(e=gt(),s.set(t,e)),e}(e)),t.has(e)};if("size"===e)return Nt(i),t.size;const l=Reflect.get(t,e,r);return"function"==typeof l?function(...e){return Nt(i),l.apply(t,e)}:l}});return a}function qs(t,e){const n=e?.equals??Object.is,r=new WeakSet(t??[]),i=new WeakMap;function s(t){const e=i.get(t);e&&dt(e)}const o=new Proxy(r,{get(t,e,r){if("add"===e)return function(e){return t.has(e)&&n(e,e)||(t.add(e),s(e)),o};if("delete"===e)return function(e){return!!t.has(e)&&(s(e),i.delete(e),t.delete(e))};if("has"===e)return function(e){return Nt(function(t){let e=i.get(t);return void 0===e&&(e=gt(),i.set(t,e)),e}(e)),t.has(e)};const a=Reflect.get(t,e,r);return"function"==typeof a?a.bind(t):a}});return o}function Vs(t,e){const n=e?.equals??Object.is,r=t instanceof Map?new Map(t.entries()):new Map(t??[]),i=gt(),s=new Map;function o(t){let e=s.get(t);return void 0===e&&(e=gt(),s.set(t,e)),e}function a(t){const e=s.get(t);e&&dt(e)}const l=new Proxy(r,{get(t,e,r){if("set"===e)return function(e,r){return t.has(e)&&n(t.get(e),r)||(a(e),dt(i),t.set(e,r)),l};if("delete"===e)return function(e){return!!t.has(e)&&(a(e),dt(i),s.delete(e),t.delete(e))};if("clear"===e)return function(){0!==t.size&&(s.forEach(t=>dt(t)),s.clear(),dt(i),t.clear())};if("get"===e)return function(e){return Nt(o(e)),t.get(e)};if("has"===e)return function(e){return Nt(o(e)),t.has(e)};if("size"===e)return Nt(i),t.size;const c=Reflect.get(t,e,r);return"function"==typeof c?function(...e){return Nt(i),c.apply(t,e)}:c}});return l}function Ws(t,e){const n=e?.equals??Object.is,r=t??[],i=r instanceof WeakMap?r:new WeakMap(r),s=new WeakMap;function o(t){let e=s.get(t);return void 0===e&&(e=gt(),s.set(t,e)),e}function a(t){const e=s.get(t);e&&dt(e)}const l=new Proxy(i,{get(t,e,r){if("set"===e)return function(e,r){return t.has(e)&&n(t.get(e),r)||(a(e),t.set(e,r)),l};if("delete"===e)return function(e){return!!t.has(e)&&(a(e),s.delete(e),t.delete(e))};if("get"===e)return function(e){return Nt(o(e)),t.get(e)};if("has"===e)return function(e){return Nt(o(e)),t.has(e)};const i=Reflect.get(t,e,r);return"function"==typeof i?i.bind(t):i}});return l}var Hs=a({ALLOW_CYCLES:()=>{},COMPUTE:()=>at,CONSTANT:()=>0,CONSTANT_TAG:()=>mt,CURRENT_TAG:()=>_t,CurrentTag:()=>wt,INITIAL:()=>1,VOLATILE:()=>NaN,VOLATILE_TAG:()=>bt,VolatileTag:()=>vt,beginTrackFrame:()=>Lt,beginUntrackFrame:()=>Pt,bump:()=>ot,combine:()=>xt,consumeTag:()=>Nt,createCache:()=>Ut,createTag:()=>ft,createUpdatableTag:()=>gt,debug:()=>Gs,dirtyTag:()=>dt,dirtyTagFor:()=>Ht,endTrackFrame:()=>It,endUntrackFrame:()=>Mt,getValue:()=>Bt,isConst:()=>$t,isConstTag:()=>yt,isTracking:()=>Ot,resetTracking:()=>At,tagFor:()=>Kt,tagMetaFor:()=>Gt,track:()=>qt,trackedArray:()=>js,trackedData:()=>qr,trackedMap:()=>Vs,trackedObject:()=>Bs,trackedSet:()=>$s,trackedWeakMap:()=>Ws,trackedWeakSet:()=>qs,untrack:()=>Vt,updateTag:()=>pt,validateTag:()=>ct,valueForTag:()=>lt}),Gs={},Ks=Symbol("GLIMMER_VALIDATOR_REGISTRATION");if(Reflect.has(globalThis,Ks))throw new Error("The `@glimmer/validator` library has been included twice in this application. It could be different versions of the package, or the same version included twice by mistake. `@glimmer/validator` depends on having a single copy of the package in use at any time in an application, even if they are the same version. You must dedupe your build to remove the duplicate packages in order to prevent this error.");Reflect.set(globalThis,Ks,!0);var Zs="@warp-drive/core",Ys=globalThis;Ys.__warpDrive_universalCache=Ys.__warpDrive_universalCache??{},Ys[Zs]=Ys[Zs]??{__version:"5.8.2"};var Xs=Ys[Zs],Js=Xs.__warpDrive_ModuleScopedCaches??{};if(Xs.__warpDrive_hasOtherCopy)throw new Error("Multiple copies of WarpDrive detected, the application will malfunction.");function Qs(t,e){return e}function to(t){return Js[`(transient) ${t}`]??null}function eo(t,e){return e}Xs.__warpDrive_hasOtherCopy=!0,eo(0,Symbol.for("wd:skip-cache")),eo(0,Symbol.for("wd:enable-hydration")),Qs(0,Symbol("IS_FUTURE")),Qs(0,Symbol("DOC")),Qs(0,Symbol("FROZEN")),Qs(0,Symbol.for("Collection"));var no=eo(0,new WeakMap);function ro(t,e){no.set(t,e)}eo(0,new Map),Qs(0,Symbol("IS_CACHE_HANDLER"));var io=Qs(0,Symbol("#[]"));function so(t,e){return to("signalHooks").createSignal(t,e)}Qs(0,Symbol("#{}"));var oo={isInitializer:!0};function ao(t){return"object"==typeof t&&null!==t&&Object.getPrototypeOf(t)===oo}var lo=Qs(0,Symbol("Signals"));function co(t){return t[lo]||function(t){t[lo]=new Map}(t),t[lo]}function uo(t,e,n,r){const i={key:n,context:e,signal:so(e,n),value:ao(r)?r.value.call(e):r,isStale:!1};return t.set(n,i),i}function ho(t,e){return t?.get(e)}function po(t,e){return{enumerable:!0,configurable:!1,get(){const n=function(t,e,n,r){let i=ho(t,n);return i||(i=uo(t,e,n,r)),function(t){to("signalHooks").consumeSignal(t)}(i.signal),i}(co(this),this,t,e);return n.isStale=!1,n.value},set(n){const r=function(t,e,n,r){let i=ho(t,n);return i||(i=uo(t,e,n,r)),i}(co(this),this,t,e);var i;r.value!==n&&(r.value=n,(i=r)&&(i.isStale=!0,function(t){to("signalHooks").notifySignal(t)}(i.signal)))}}}function fo(t,e,n){Object.defineProperty(t,e,po(e,n))}function go(t,e,n){const r=po(e,n);r.enumerable=!1,Object.defineProperty(t,e,r)}function mo(t,e,n){const r=n.get;return n.get=function(){const t=co(this);let n=t.get(e);return n||(n=function(t,e,n,r){{const i=function(t,e,n){return to("signalHooks").createMemo(t,e,n)}(e,n,r);return t.set(n,i),i}}(t,this,e,r.bind(this))),n()},n}var yo=new WeakMap;function vo(t){return t instanceof DOMException&&"AbortError"===t.name}var bo=class{_stream=null;_future;_triggered=!1;_trigger(){if(this._triggered)return;this._triggered=!0;const t=this._future.getStream();t.sizeHint&&(this._sizeHint=t.sizeHint),this.promise=t.then(t=>t?async function(t,e){const n=e,r=t.getReader();let i=0,s=null!==n._stream&&n._stream.readable.locked,o=s,a=n._stream?.writable.getWriter();const l=[];for(n._isPending=!1,n._isStarted=!0,n._startTime=performance.now();;){const{value:t,done:e}=await r.read();if(e)break;if(i+=t.byteLength,n._bytesLoaded=i,n._lastPacketTime=performance.now(),s=s||null!==n._stream&&n._stream.readable.locked,s){if(!o){o=!0,a=n._stream.writable.getWriter();for(const t of l)await a.ready,await a.write(t);l.length=0}await a.ready,await a.write(t)}else l.push(t)}o?(await a.ready,await a.close()):n._stream&&(await n._stream.readable.cancel("The Stream Has Already Ended"),n._stream=null),n._endTime=performance.now(),n._isComplete=!0,n._isStarted=!1}(t,this):(this._isPending=!1,void(this._isComplete=!0)),t=>{this._isPending=!1,this._isStarted=!1,vo(t)&&(this._isCancelled=!0,this._isComplete=!0),this._isErrored=!0,this._error=t})}promise=null;get isPending(){return this._trigger(),this._isPending}get sizeHint(){return this._trigger(),this._sizeHint}get stream(){if(this._trigger(),!this._stream){if(this._isComplete||this._isCancelled||this._isErrored)return null;this._stream=new TransformStream}return this._stream.readable}get isStarted(){return this._trigger(),this._isStarted}get bytesLoaded(){return this._trigger(),this._bytesLoaded}get startTime(){return this._trigger(),this._startTime}get endTime(){return this._trigger(),this._endTime}get lastPacketTime(){return this._trigger(),this._lastPacketTime}get isComplete(){return this._trigger(),this._isComplete}get isCancelled(){return this._trigger(),this._isCancelled}get isErrored(){return this._trigger(),this._isErrored}get error(){return this._trigger(),this._error}get elapsedTime(){return(this.endTime||this.lastPacketTime)-this.startTime}get completedRatio(){return this.sizeHint?this.bytesLoaded/this.sizeHint:0}get remainingRatio(){return 1-this.completedRatio}get duration(){return this.endTime-this.startTime}get speed(){return this.bytesLoaded/(this.elapsedTime/1e3)}constructor(t){this._future=t}abort=()=>{this._future.abort()}};go(bo.prototype,"_isPending",!0),go(bo.prototype,"_isStarted",!1),go(bo.prototype,"_isComplete",!1),go(bo.prototype,"_isCancelled",!1),go(bo.prototype,"_isErrored",!1),go(bo.prototype,"_error",null),go(bo.prototype,"_sizeHint",0),go(bo.prototype,"_bytesLoaded",0),go(bo.prototype,"_startTime",0),go(bo.prototype,"_endTime",0),go(bo.prototype,"_lastPacketTime",0);var wo={};function _o(t,e,n){const r=Object.assign({},e),i=Object.assign({},r.cacheOptions);return n?i.reload=!0:!1===n?(delete i.reload,i.backgroundReload=!0):(delete i.backgroundReload,delete i.reload),r.cacheOptions=i,t.request(r)}function xo(t,e,n){let r={...Object.getOwnPropertyDescriptor(t,e)};for(let i of n)r=i(t,e,r)||r;void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(t):void 0,r.initializer=void 0),Object.defineProperty(t,e,r)}fo(wo,"reason",null),fo(wo,"value",null),fo(wo,"result",null),fo(wo,"error",null),fo(wo,"status","pending"),fo(wo,"isPending",!0),fo(wo,"isLoading",!0),fo(wo,"isSuccess",!1),fo(wo,"isError",!1),fo(wo,"request",null),fo(wo,"response",null),Object.defineProperty(wo,"isCancelled",{get(){return this.isError&&vo(this.reason)}}),Object.defineProperty(wo,"loadingState",{get(){return this._loadingState||(this._loadingState=new bo(this._request)),this._loadingState}});var Co=Symbol.dispose||Symbol.for("dispose"),So=class{_requester;constructor(t,e){this._args=e,this.store=t,this._subscribedTo=null,this._subscription=null,this._intervalStart=null,this._invalidated=!1,this._nextInterval=null,this._requester=null,this.isDestroyed=!1,this[Co]=Eo,this._installListeners(),this._beginPolling()}async _beginPolling(){try{this.isIdle||await this.request}catch{}finally{this.isDestroyed||this._scheduleInterval()}}get isIdle(){const{request:t,query:e}=this._args;return Boolean(!t&&!e)}static{xo(this.prototype,"isIdle",[mo])}get autorefreshTypes(){const{autorefresh:t}=this._args;let e;return e=!0===t?["online","invalid"]:"string"==typeof t?t.split(","):[],new Set(e)}static{xo(this.prototype,"autorefreshTypes",[mo])}async _scheduleInterval(){const{autorefreshThreshold:t}=this._args;if("undefined"!=typeof window&&"number"==typeof t&&t>0&&this.autorefreshTypes.has("interval")&&null===this._intervalStart){if(this._latestRequest){try{await this._latestRequest}catch{}if(this.isDestroyed)return}this._intervalStart=Date.now(),this._nextInterval=setTimeout(()=>{this._maybeUpdate()},t)}}_clearInterval(){this._nextInterval&&(clearTimeout(this._nextInterval),this._intervalStart=null)}_updateSubscriptions(){if(this.isIdle)return;const t=this._request.lid;if(this._subscribedTo===t)return;this._removeSubscriptions();const e=this._getRequester();this._requester=e,t&&ko(e)&&(this._subscribedTo=t,this._subscription=e.notifications.subscribe(t,(n,r)=>{if(!this._isUpdating)switch(r){case"invalidated":this.autorefreshTypes.has("invalid")&&(this._invalidated=!0,this._maybeUpdate());break;case"state":{const n=e.requestManager._deduped.get(t)?.priority,r=this.reqState;n?n.blocking&&!r.isLoading?(this.isRefreshing=!1,this._maybeUpdate("policy",!0)):this.isRefreshing=!0:this.isRefreshing=!1}}}))}_removeSubscriptions(){const t=this._requester;this._subscription&&t&&ko(t)&&(t.notifications.unsubscribe(this._subscription),this._subscribedTo=null,this._subscription=null,this._requester=null)}_installListeners(){"undefined"!=typeof window&&(this.isOnline=window.navigator.onLine,this._unavailableStart=this.isOnline?null:Date.now(),this.isHidden="hidden"===document.visibilityState,this._onlineChanged=t=>{this.isOnline="online"===t.type,"offline"===t.type&&null===this._unavailableStart&&(this._unavailableStart=Date.now()),this._maybeUpdate()},this._backgroundChanged=()=>{const t="hidden"===document.visibilityState;this.isHidden=t,t&&null===this._unavailableStart&&(this._unavailableStart=Date.now()),this._maybeUpdate()},window.addEventListener("online",this._onlineChanged,{passive:!0,capture:!0}),window.addEventListener("offline",this._onlineChanged,{passive:!0,capture:!0}),document.addEventListener("visibilitychange",this._backgroundChanged,{passive:!0,capture:!0}))}_maybeUpdate(t,e){if(this.isIdle)return;const{reqState:n}=this;if(n.isPending)return;if(!Boolean(this.isOnline&&!this.isHidden&&(t||this.autorefreshTypes.size))){if(!e&&t&&"_invalidated"!==t)throw new Error("Reload not available: the network is not online or the tab is hidden");return}const{autorefreshTypes:r}=this;let i=this._invalidated||Boolean(t);if(!i&&r.has("online")){const{_unavailableStart:t}=this,{autorefreshThreshold:e}=this._args,n="number"==typeof e?e:3e4;i=Boolean(t&&Date.now()-t>n)}if(!i&&r.has("interval")){const{_intervalStart:t}=this,{autorefreshThreshold:e}=this._args;t&&"number"==typeof e&&e>0&&(i=Boolean(Date.now()-t>=e))}if(this._unavailableStart=null,this._invalidated=!1,i){this._clearInterval(),this._isUpdating=!0;const e=("_invalidated"===t?null:t)??this._args.autorefreshBehavior??"policy",r=this._getRequester();switch(n._request.requester||(n._request.requester=r),e){case"reload":this._latestRequest=n.reload();break;case"refresh":this._latestRequest=n.refresh();break;case"policy":this._latestRequest=n.refresh(!0)}"refresh"!==e&&(this._localRequest=this._latestRequest),this._scheduleInterval(),this._latestRequest.finally(()=>{this._isUpdating=!1})}}_getRequester(){return this._args.request?.requester?this._args.request.requester:this.store}retry=async()=>{this._maybeUpdate("reload"),await this._localRequest};refresh=async()=>{this._maybeUpdate("refresh"),await this._latestRequest};get errorFeatures(){return{isHidden:this.isHidden,isOnline:this.isOnline,retry:this.retry}}static{xo(this.prototype,"errorFeatures",[mo])}get contentFeatures(){const t={isHidden:this.isHidden,isOnline:this.isOnline,reload:this.retry,refresh:this.refresh,isRefreshing:this.isRefreshing,latestRequest:this._latestRequest};return t.isRefreshing&&(t.abort=()=>{this._latestRequest?.abort()}),t}static{xo(this.prototype,"contentFeatures",[mo])}get _request(){const{request:t,query:e}=this._args,{_localRequest:n,_originalRequest:r,_originalQuery:i}=this;return n&&t===r&&e===i?n:(this._originalQuery=e,this._originalRequest=t,t||this.store.request(e))}static{xo(this.prototype,"_request",[mo])}get request(){{const t=this._request;return this._updateSubscriptions(),t}}static{xo(this.prototype,"request",[mo])}get reqState(){return function(t){let e=yo.get(t);return e||(e=function(t){const e=(n=t,no.get(n));var n;const r=Object.create(wo);return r._request=t,r.reload=()=>_o(t.requester,r.request,!0),r.refresh=(e=!1)=>_o(t.requester,r.request,!0===e&&null),e?e.isError?(r.error=e.result,r.reason=e.result,r.status="rejected",r.isError=!0,r.isPending=!1,r.isLoading=!1,r.request=e.result.request,r.response=e.result.response):(r.result=e.result.content,r.value=e.result.content,r.status="fulfilled",r.isSuccess=!0,r.isPending=!1,r.isLoading=!1,r.request=e.result.request,r.response=e.result.response):t.then(e=>{ro(t,{isError:!1,result:e}),r.result=e.content,r.value=e.content,r.status="fulfilled",r.isSuccess=!0,r.isPending=!1,r.isLoading=!1,r.request=e.request,r.response=e.response},e=>{ro(t,{isError:!0,result:e}),r.error=e,r.reason=e,r.status="rejected",r.isError=!0,r.isPending=!1,r.isLoading=!1,r.request=e.request,r.response=e.response}),r}(t),yo.set(t,e)),e}(this.request)}get result(){return this.reqState.result}};function ko(t){return"requestManager"in t}function Eo(){const t=this;t.isDestroyed=!0,t._removeSubscriptions(),"undefined"!=typeof window&&(t._clearInterval(),window.removeEventListener("online",t._onlineChanged,{passive:!0,capture:!0}),window.removeEventListener("offline",t._onlineChanged,{passive:!0,capture:!0}),document.removeEventListener("visibilitychange",t._backgroundChanged,{passive:!0,capture:!0}))}fo(So.prototype,"isOnline",!0),fo(So.prototype,"isHidden",!1),fo(So.prototype,"isRefreshing",!1),fo(So.prototype,"_localRequest",void 0),fo(So.prototype,"_latestRequest",void 0);var Ro={};fo(Ro,"reason",null),fo(Ro,"value",null),fo(Ro,"result",null),fo(Ro,"error",null),fo(Ro,"status","pending"),fo(Ro,"isPending",!0),fo(Ro,"isLoading",!0),fo(Ro,"isSuccess",!1),fo(Ro,"isError",!1);var To=dt;!function(){const t=function(t){const e=t.wellknown.Array;return{createSignal:(t,n)=>n===e?[Ae(t,n),Ae(t,"length"),Ae(t,"[]")]:Ae(t,n),consumeSignal(t){if(Array.isArray(t))return Nt(t[0]),Nt(t[1]),void Nt(t[2]);Nt(t)},notifySignal(t){if(Array.isArray(t))return To(t[0]),To(t[1]),void To(t[2]);To(t)},createMemo:(t,e,n)=>{{const r=Ae(t,e),i=Ut(n);let s;const o=()=>{s=Bt(i)};return()=>{const t=qt(o);return pt(r,t),Nt(t),s}}},willSyncFlushWatchers:()=>!!bs.currentInstance&&!0!==bs._autorun,waitFor:async t=>t}}({wellknown:{Array:io}});var e;e=t,Js["(transient) signalHooks"]=e}();var Lo=a({getOwner:()=>Io,setOwner:()=>Br}),Io=Ur;function Po(t){let e=Object.create(t);return e._dict=null,delete e._dict,e}var Mo="object"==typeof self&&null!==self&&self.Object===Object&&"undefined"!=typeof Window&&self.constructor===Window&&"object"==typeof document&&null!==document&&self.document===document&&"object"==typeof location&&null!==location&&self.location===location&&"object"==typeof history&&null!==history&&self.history===history&&"object"==typeof navigator&&null!==navigator&&self.navigator===navigator&&"string"==typeof navigator.userAgent;function Ao(t){let e=t._promiseCallbacks;return e||(e=t._promiseCallbacks={}),e}var Oo={mixin(t){return t.on=this.on,t.off=this.off,t.trigger=this.trigger,t._promiseCallbacks=void 0,t},on(t,e){if("function"!=typeof e)throw new TypeError("Callback must be a function");let n=Ao(this),r=n[t];r||(r=n[t]=[]),-1===r.indexOf(e)&&r.push(e)},off(t,e){let n=Ao(this);if(!e)return void(n[t]=[]);let r=n[t],i=r.indexOf(e);-1!==i&&r.splice(i,1)},trigger(t,e,n){let r=Ao(this)[t];if(r){let t;for(let i=0;i{for(let t=0;t{e===n?Go(t,n):Wo(t,n)},e=>Ko(t,e))}(t,e):"function"==typeof n?function(t,e,n){No.async(t=>{let r=!1,i=function(n,i){try{n.call(i,n=>{r||(r=!0,e===n?Go(t,n):Wo(t,n))},e=>{r||(r=!0,Ko(t,e))})}catch(s){return s}}(n,e,t._label);!r&&i&&(r=!0,Ko(t,i))},t)}(t,e,n):Go(t,e)}function Wo(t,e){if(t===e)Go(t,e);else if(function(t){let e=typeof t;return null!==t&&("object"===e||"function"===e)}(e)){let n;try{n=e.then}catch(e6){return void Ko(t,e6)}Vo(t,e,n)}else Go(t,e)}function Ho(t){t._onError&&t._onError(t._result),Yo(t)}function Go(t,e){t._state===Bo&&(t._result=e,t._state=$o,0===t._subscribers.length?No.instrument&&zo("fulfilled",t):No.async(Yo,t))}function Ko(t,e){t._state===Bo&&(t._state=qo,t._result=e,No.async(Ho,t))}function Zo(t,e,n,r){let i=t._subscribers,s=i.length;t._onError=null,i[s]=e,i[s+$o]=n,i[s+qo]=r,0===s&&t._state&&No.async(Yo,t)}function Yo(t){let e=t._subscribers,n=t._state;if(No.instrument&&zo(n===$o?"fulfilled":"rejected",t),0===e.length)return;let r,i,s=t._result;for(let o=0;oXo(i,s,n,o))}return s}var Qo=class{constructor(t,e,n,r){this._instanceConstructor=t,this.promise=new t(Uo,r),this._abortOnReject=n,this._isUsingOwnPromise=t===ra,this._isUsingOwnResolve=t.resolve===jo,this._init(...arguments)}_init(t,e){let n=e.length||0;this.length=n,this._remaining=n,this._result=new Array(n),this._enumerate(e)}_enumerate(t){let e=this.length,n=this.promise;for(let r=0;n._state===Bo&&re(t)),e,n)}else this._willSettleAt(r.resolve(t),e,n)}_eachEntry(t,e,n){null!==t&&"object"==typeof t?this._settleMaybeThenable(t,e,n):this._setResultAt($o,e,t,n)}_settledAt(t,e,n,r){let i=this.promise;i._state===Bo&&(this._abortOnReject&&t===qo?Ko(i,n):(this._setResultAt(t,e,n,r),this._checkFullfillment()))}_setResultAt(t,e,n,r){this._remaining--,this._result[e]=n}_willSettleAt(t,e,n){Zo(t,void 0,t=>this._settledAt($o,e,t,n),t=>this._settledAt(qo,e,t,n))}};function ta(t,e,n){this._remaining--,this._result[e]=t===$o?{state:"fulfilled",value:n}:{state:"rejected",reason:n}}var ea="rsvp_"+Date.now()+"-",na=0,ra=class t{constructor(e,n){this._id=na++,this._label=n,this._state=void 0,this._result=void 0,this._subscribers=[],No.instrument&&zo("created",this),Uo!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(t,e){let n=!1;try{e(e=>{n||(n=!0,Wo(t,e))},e=>{n||(n=!0,Ko(t,e))})}catch(r){Ko(t,r)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}_onError(t){No.after(()=>{this._onError&&No.trigger("error",t,this._label)})}catch(t,e){return this.then(void 0,t,e)}finally(t,e){let n=this,r=n.constructor;return"function"==typeof t?n.then(e=>r.resolve(t()).then(()=>e),e=>r.resolve(t()).then(()=>{throw e})):n.then(t,t)}};function ia(t,e){return{then:(n,r)=>t.call(e,n,r)}}function sa(t,e){let n=function(){let n=arguments.length,r=new Array(n+1),i=!1;for(let t=0;toa(t,e,n,r))}(s,r,t,this):oa(s,r,t,this)};return n.__proto__=t,n}function oa(t,e,n,r){try{n.apply(r,e)}catch(e6){Ko(t,e6)}return t}function aa(t,e){return ra.all(t,e)}ra.cast=jo,ra.all=function(t,e){return Array.isArray(t)?new Qo(this,t,!0,e).promise:this.reject(new TypeError("Promise.all must be called with an array"),e)},ra.race=function(t,e){let n=this,r=new n(Uo,e);if(!Array.isArray(t))return Ko(r,new TypeError("Promise.race must be called with an array")),r;for(let i=0;r._state===Bo&&iWo(r,t),t=>Ko(r,t));return r},ra.resolve=jo,ra.reject=function(t,e){let n=new this(Uo,e);return Ko(n,t),n},ra.prototype._guidKey=ea,ra.prototype.then=Jo;var la=class extends Qo{constructor(t,e,n){super(t,e,!1,n)}};function ca(t,e){return Array.isArray(t)?new la(ra,t,e).promise:ra.reject(new TypeError("Promise.allSettled must be called with an array"),e)}function ua(t,e){return ra.race(t,e)}la.prototype._setResultAt=ta;var ha=class extends Qo{constructor(t,e,n=!0,r){super(t,e,n,r)}_init(t,e){this._result={},this._enumerate(e)}_enumerate(t){let e,n,r=Object.keys(t),i=r.length,s=this.promise;this._remaining=i;for(let o=0;s._state===Bo&&o{throw t}),t}function ma(t){let e={resolve:void 0,reject:void 0};return e.promise=new ra((t,n)=>{e.resolve=t,e.reject=n},t),e}pa.prototype._setResultAt=ta;var ya=class extends Qo{constructor(t,e,n,r){super(t,e,!0,r,n)}_init(t,e,n,r,i){let s=e.length||0;this.length=s,this._remaining=s,this._result=new Array(s),this._mapFn=i,this._enumerate(e)}_setResultAt(t,e,n,r){if(r)try{this._eachEntry(this._mapFn(n,e),e,!1)}catch(e6){this._settledAt(qo,e,e6,!1)}else this._remaining--,this._result[e]=n}};function va(t,e,n){return"function"!=typeof e?ra.reject(new TypeError("map expects a function as a second argument"),n):ra.resolve(t,n).then(function(t){if(!Array.isArray(t))throw new TypeError("map must be called with an array");return new ya(ra,t,e,n).promise})}function ba(t,e){return ra.resolve(t,e)}function wa(t,e){return ra.reject(t,e)}var _a={},xa=class extends ya{_checkFullfillment(){if(0===this._remaining&&null!==this._result){let t=this._result.filter(t=>t!==_a);Go(this.promise,t),this._result=null}}_setResultAt(t,e,n,r){if(r){this._result[e]=n;let t,r=!0;try{t=this._mapFn(n,e)}catch(e6){r=!1,this._settledAt(qo,e,e6,!1)}r&&this._eachEntry(t,e,!1)}else this._remaining--,n||(this._result[e]=_a)}};function Ca(t,e,n){return"function"!=typeof e?ra.reject(new TypeError("filter expects function as a second argument"),n):ra.resolve(t,n).then(function(t){if(!Array.isArray(t))throw new TypeError("filter must be called with an array");return new xa(ra,t,e,n).promise})}var Sa,ka=0;function Ea(t,e){Oa[ka]=t,Oa[ka+1]=e,2===(ka+=2)&&Aa()}var Ra="undefined"!=typeof window?window:void 0,Ta=Ra||{},La=Ta.MutationObserver||Ta.WebKitMutationObserver,Ia="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Pa="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function Ma(){return()=>setTimeout(Na,1)}var Aa,Oa=new Array(1e3);function Na(){for(let t=0;tt(Na)}():La?function(){let t=0,e=new La(Na),n=document.createTextNode("");return e.observe(n,{characterData:!0}),()=>n.data=t=++t%2}():Pa?function(){let t=new MessageChannel;return t.port1.onmessage=Na,()=>t.port2.postMessage(0)}():void 0===Ra&&"function"==typeof window.require?function(){try{const t=Function("return this")().require("vertx");return void 0!==(Sa=t.runOnLoop||t.runOnContext)?function(){Sa(Na)}:Ma()}catch(t){return Ma()}}():Ma(),No.async=Ea,No.after=t=>setTimeout(t,0);var Fa=ba,Da=(t,e)=>No.async(t,e);function za(){No.on(...arguments)}function ja(){No.off(...arguments)}if("undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){let t=window.__PROMISE_INSTRUMENTATION__;Fo("instrument",!0);for(let e in t)t.hasOwnProperty(e)&&za(e,t[e])}var Ua={asap:Ea,cast:Fa,Promise:ra,EventTarget:Oo,all:aa,allSettled:ca,race:ua,hash:da,hashSettled:fa,rethrow:ga,defer:ma,denodeify:sa,configure:Fo,on:za,off:ja,resolve:ba,reject:wa,map:va,async:Da,filter:Ca},Ba=Object.freeze(Object.defineProperty({__proto__:null,EventTarget:Oo,Promise:ra,all:aa,allSettled:ca,asap:Ea,async:Da,cast:Fa,configure:Fo,default:Ua,defer:ma,denodeify:sa,filter:Ca,hash:da,hashSettled:fa,map:va,off:ja,on:za,race:ua,reject:wa,resolve:ba,rethrow:ga},Symbol.toStringTag,{value:"Module"}));function $a(t){let e=function(t){if(!t)return;let e=t;return e.errorThrown?function(t){let e=t.errorThrown;return"string"==typeof e&&(e=new Error(e)),Object.defineProperty(e,"__reason_with_error_thrown__",{value:t,enumerable:!1}),e}(e):"UnrecognizedURLError"!==t.name&&"TransitionAborted"!==t.name?t:void 0}(t);if(e){let t=null;if(!t)throw e;t(e)}}Fo("async",(t,e)=>{bs.schedule("actions",null,t,e)}),Fo("after",t=>{bs.schedule(ys,null,t)}),za("error",$a);var qa=class{static _leakTracking;owner;registry;cache;factoryManagerCache;validationCache;isDestroyed;isDestroying;constructor(t,e={}){this.registry=t,this.owner=e.owner||null,this.cache=Po(e.cache||null),this.factoryManagerCache=Po(e.factoryManagerCache||null),this.isDestroyed=!1,this.isDestroying=!1}lookup(t,e){if(this.isDestroyed)throw new Error(`Cannot call \`.lookup('${t}')\` after the owner has been destroyed`);return function(t,e,n={}){let r=e;if(!0===n.singleton||void 0===n.singleton&&Va(t,e)){let e=t.cache[r];if(void 0!==e)return e}return function(t,e,n,r){let i=Ha(t,e,n);if(void 0!==i){if(function(t,e,{instantiate:n,singleton:r}){return!1!==r&&!1!==n&&(!0===r||Va(t,e))&&Wa(t,e)}(t,n,r)){let n=t.cache[e]=i.create();return t.isDestroying&&"function"==typeof n.destroy&&n.destroy(),n}if(function(t,e,{instantiate:n,singleton:r}){return!1!==n&&(!1===r||!Va(t,e))&&Wa(t,e)}(t,n,r))return i.create();if(function(t,e,{instantiate:n,singleton:r}){return!1!==r&&!n&&Va(t,e)&&!Wa(t,e)}(t,n,r)||function(t,e,{instantiate:n,singleton:r}){return!(!1!==n||!1!==r&&Va(t,e)||Wa(t,e))}(t,n,r))return i.class;throw new Error("Could not create factory")}}(t,r,e,n)}(this,this.registry.normalize(t),e)}destroy(){this.isDestroying=!0,Ga(this)}finalizeDestroy(){Ka(this),this.isDestroyed=!0}reset(t){this.isDestroyed||(void 0===t?(Ga(this),Ka(this)):function(t,e){let n=t.cache[e];delete t.factoryManagerCache[e],n&&(delete t.cache[e],n.destroy&&n.destroy())}(this,this.registry.normalize(t)))}ownerInjection(){let t={};return Br(t,this.owner),t}factoryFor(t){if(this.isDestroyed)throw new Error(`Cannot call \`.factoryFor('${t}')\` after the owner has been destroyed`);return Ha(this,this.registry.normalize(t),t)}};function Va(t,e){return!1!==t.registry.getOption(e,"singleton")}function Wa(t,e){return!1!==t.registry.getOption(e,"instantiate")}function Ha(t,e,n){let r=t.factoryManagerCache[e];if(void 0!==r)return r;let i=t.registry.resolve(e);if(void 0===i)return;let s=new Ja(t,i,n,e);return t.factoryManagerCache[e]=s,s}function Ga(t){let e=t.cache,n=Object.keys(e);for(let r of n){let t=e[r];t.destroy&&t.destroy()}}function Ka(t){t.cache=Po(null),t.factoryManagerCache=Po(null)}var Za=Symbol("INIT_FACTORY");function Ya(t){return t[Za]}function Xa(t,e){t[Za]=e}var Ja=class{container;owner;class;fullName;normalizedName;madeToString;injections;constructor(t,e,n,r){this.container=t,this.owner=t.owner,this.class=e,this.fullName=n,this.normalizedName=r,this.madeToString=void 0,this.injections=void 0}toString(){return void 0===this.madeToString&&(this.madeToString=this.container.registry.makeToString(this.class,this.fullName)),this.madeToString}create(t){let{container:e}=this;if(e.isDestroyed)throw new Error(`Cannot create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`);let n=t?{...t}:{};return Br(n,e.owner),Xa(n,this),this.class.create(n)}};function Qa(t){let e=Object.create(null);e[t]=1;for(let n in e)if(n===t)return n;return t}var tl=0;function el(){return++tl}var nl="ember",rl=new WeakMap,il=new Map,sl=Qa(`__ember${Date.now()}`);function ol(t,e=nl){let n=e+el().toString();return Zt(t)&&rl.set(t,n),n}function al(t){let e;if(Zt(t))e=rl.get(t),void 0===e&&(e=`${nl}${el()}`,rl.set(t,e));else if(e=il.get(t),void 0===e){let n=typeof t;e="string"===n?`st${el()}`:"number"===n?`nu${el()}`:"symbol"===n?`sy${el()}`:`(${t})`,il.set(t,e)}return e}var ll=Array.prototype.concat;function cl(t,e,n,r){let i=n[t]||r[t];return e[t]&&(i=i?ll.call(i,e[t]):e[t]),i}function ul(t,e,n,r){if(!0===n)return e;let i=n._getter;if(void 0===i)return e;let s=r[t],o="function"==typeof s?P(s):s;if(void 0===o||!0===o)return e;let a=o._getter;if(void 0===a)return e;let l,c=tn(i,a),u=n._setter,h=o._setter;if(l=void 0!==h?void 0!==u?tn(u,h):h:u,c!==i||l!==u){let t=n._dependentKeys||[],e=new Gn([...t,{get:c,set:l}]);return e._readOnly=n._readOnly,e._meta=n._meta,e.enumerable=n.enumerable,T(e,Gn)}return e}function hl(t,e,n,r){if(void 0!==r[t])return e;let i=n[t];return"function"==typeof i?tn(e,i):e}function dl(t){return t?Array.isArray(t)?t:[t]:[]}function pl(t,e,n){return dl(n[t]).concat(dl(e))}function fl(t,e,n){let r=n[t];if(!r)return e;let i=Object.assign({},r),s=!1,o=Object.keys(e);for(let a of o){let t=e[a];"function"==typeof t?(s=!0,i[a]=hl(a,t,r,{})):i[a]=t}return s&&(i._super=We),i}function gl(t,e,n,r,i,s,o){let a;for(let l=0;l{let e=s.indexOf(t);-1!==e&&s.splice(e,1)}))}else ml(e,a,n,r,i,s,o)}function ml(t,e,n,r,i,s,o){let a=cl("concatenatedProperties",e,r,i),l=cl("mergedProperties",e,r,i),c=Object.keys(e);for(let u of c){let c=e[u];if(void 0===c)continue;if(-1===s.indexOf(u)){s.push(u);let e=t.peekDescriptors(u);if(void 0===e){if(!M(c)){let t=r[u]=i[u];"function"==typeof t&&yl(i,u,t,!1)}}else n[u]=e,o.push(u),e.teardown(i,u,t)}let h="function"==typeof c;if(h){let t=P(c);if(void 0!==t){n[u]=ul(u,c,t,n),r[u]=void 0;continue}}a&&a.indexOf(u)>=0||"concatenatedProperties"===u||"mergedProperties"===u?c=pl(u,c,r):l&&l.indexOf(u)>-1?c=fl(u,c,r):h&&(c=hl(u,c,r,n)),r[u]=c,n[u]=void 0}}function yl(t,e,n,r){let i=Ye(n);if(void 0===i)return;let{observers:s,listeners:o}=i;if(void 0!==s){let n=r?dn:pn;for(let r of s.paths)n(t,r,null,e,s.sync)}if(void 0!==o){let n=r?nn:rn;for(let r of o)n(t,r,null,e)}}function vl(t,e,n=!1){let r=Object.create(null),i=Object.create(null),s=w(t),o=[],a=[];t._super=We,gl(e,s,r,i,t,o,a);for(let l of o){let e=i[l],o=r[l];void 0!==e?("function"==typeof e&&yl(t,l,e,!0),jn(t,l,e,-1!==a.indexOf(l),!n)):void 0!==o&&zn(t,l,o,s)}return s.isPrototypeMeta(t)||vn(t),t}var bl=new WeakSet,wl=class t{mixins;properties;ownerConstructor;_without;constructor(t,e){bl.add(this),this.properties=function(t){if(void 0!==t)for(let e of Object.keys(t)){let n=Object.getOwnPropertyDescriptor(t,e);void 0===n.get&&void 0===n.set||Object.defineProperty(t,e,{value:C(n)})}return t}(e),this.mixins=_l(t),this.ownerConstructor=void 0,this._without=void 0}static create(...t){return yi(),new this(t,void 0)}static mixins(t){let e=b(t),n=[];return null===e||e.forEachMixins(t=>{t.properties||n.push(t)}),n}reopen(...e){if(0===e.length)return this;if(this.properties){let e=new t(void 0,this.properties);this.properties=void 0,this.mixins=[e]}else this.mixins||(this.mixins=[]);return this.mixins=this.mixins.concat(_l(e)),this}apply(t,e=!1){return vl(t,[this],e)}applyPartial(t){return vl(t,[this])}detect(t){if("object"!=typeof t||null===t)return!1;if(bl.has(t))return xl(t,this);let e=b(t);return null!==e&&e.hasMixin(this)}without(...e){let n=new t([this]);return n._without=e,n}keys(){return Cl(this)}toString(){return"(unknown mixin)"}};function _l(t){let e,n=t&&t.length||0;if(n>0){e=new Array(n);for(let r=0;rxl(t,e,n))}function Cl(t,e=new Set,n=new Set){if(!n.has(t)){if(n.add(t),t.properties){let n=Object.keys(t.properties);for(let t of n)e.add(t)}else t.mixins&&t.mixins.forEach(t=>Cl(t,e,n));return e}}var Sl=wl.create({mergedProperties:["actions"],send(t,...e){if(this.actions&&this.actions[t]&&!0!==this.actions[t].apply(this,e))return;let n=ur(this,"target");n&&n.send(...arguments)}}),{isArray:kl}=Array;function El(t){return null==t?[]:kl(t)?t:[t]}var Rl=a({default:()=>Nl});function Tl(t){return"object"==typeof t&&null!==t&&"function"==typeof t.setUnknownProperty}var Ll=wl.prototype.reopen,Il=new WeakSet,Pl=new WeakMap,Ml=new Set;function Al(t){Ml.has(t)||t.destroy()}function Ol(t,e){let n=w(t);if(void 0!==e){let r=t.concatenatedProperties,i=t.mergedProperties,s=Object.keys(e);for(let o of s){let s=e[o],a=I(t,o,n),l=void 0!==a;if(!l){if(void 0!==r&&r.length>0&&r.includes(o)){let e=t[o];s=e?El(e).concat(s):El(s)}if(void 0!==i&&i.length>0&&i.includes(o)){let e=t[o];s=Object.assign({},e,s)}}l?a.set(t,o,s):Tl(t)&&!(o in t)?t.setUnknownProperty(o,s):t[o]=s}}t.init(e),n.unsetInitializing();let r=n.observerEvents();if(void 0!==r)for(let i=0;in.willDestroy()),w(e).setInitializing()}reopen(...t){return vl(this,t),this}init(t){}get isDestroyed(){return it(this)}set isDestroyed(t){}get isDestroying(){return rt(this)}set isDestroying(t){}destroy(){Ml.add(this);try{et(this)}finally{Ml.delete(this)}return this}willDestroy(){}toString(){let t="object"==typeof this&&null!==this&&"function"==typeof this.toStringExtension?`:${this.toStringExtension()}`:"";return`<${Ya(this)||"(unknown)"}:${al(this)}${t}>`}static extend(...t){let e=class extends(this){};return Ll.apply(e.PrototypeMixin,t),e}static create(...t){let e,n=t[0];return void 0!==n?(e=new this(Ur(n)),Xa(e,Ya(n))):e=new this,t.length<=1?Ol(e,n):Ol(e,Fl.apply(this,t)),e}static reopen(...t){return this.willReopen(),Ll.apply(this.PrototypeMixin,t),this}static willReopen(){let t=this.prototype;Il.has(t)&&(Il.delete(t),Pl.has(this)&&Pl.set(this,wl.create(this.PrototypeMixin)))}static reopenClass(...t){return vl(this,t),this}static detect(t){if("function"!=typeof t)return!1;for(;t;){if(t===this)return!0;t=t.superclass}return!1}static detectInstance(t){return t instanceof this}static metaForProperty(t){return I(this.proto(),t)._meta||{}}static eachComputedProperty(t,e=this){this.proto();let n={};w(this.prototype).forEachDescriptors((r,i)=>{if(i.enumerable){let s=i._meta||n;t.call(e,r,s)}})}static get PrototypeMixin(){let t=Pl.get(this);return void 0===t&&(t=wl.create(),t.ownerConstructor=this,Pl.set(this,t)),t}static get superclass(){let t=Object.getPrototypeOf(this);return t!==Function.prototype?t:void 0}static proto(){let t=this.prototype;if(!Il.has(t)){Il.add(t);let e=this.superclass;e&&e.proto(),Pl.has(this)&&this.PrototypeMixin.apply(t)}return t}static toString(){return`<${Ya(this)||"(unknown)"}:constructor>`}static isClass=!0;static isMethod=!1;static _onLookup;static _lazyInjections};function Fl(...t){let e={};for(let n of t){let t=Object.keys(n);for(let r=0,i=t.length;rzl}),zl=wl.create({get(t){return ur(this,t)},getProperties(...t){return Fr(this,...t)},set(t,e){return gr(this,t,e)},setProperties(t){return Dr(this,t)},beginPropertyChanges(){return qn(),this},endPropertyChanges(){return Vn(),this},notifyPropertyChange(t){return $n(this,t),this},addObserver(t,e,n,r){return dn(this,t,e,n,r),this},removeObserver(t,e,n,r){return pn(this,t,e,n,r),this},hasObserverFor(t){return on(this,`${t}:change`)},incrementProperty(t,e=1){return gr(this,t,(parseFloat(ur(this,t))||0)+e)},decrementProperty(t,e=1){return gr(this,t,(ur(this,t)||0)-e)},toggleProperty(t){return gr(this,t,!ur(this,t))},cacheFor(t){let e=b(this);return null!==e?e.valueFor(t):void 0}}),jl=a({action:()=>ql,computed:()=>Yn,default:()=>Ul,defineProperty:()=>Dn,get:()=>ur,getProperties:()=>Fr,notifyPropertyChange:()=>$n,observer:()=>Vl,set:()=>gr,setProperties:()=>Dr,trySet:()=>yr}),Ul=class extends(Nl.extend(zl)){get _debugContainerKey(){let t=Ya(this);return void 0!==t&&t.fullName}},Bl=new WeakMap;function $l(t,e,n){var r;if(null!=(r=t)&&void 0!==r.constructor&&"function"==typeof r.constructor.proto&&t.constructor.proto(),!Object.prototype.hasOwnProperty.call(t,"actions")){let e=t.actions;t.actions=e?Object.assign({},e):{}}return t.actions[e]=n,{get(){let t=Bl.get(this);void 0===t&&(t=new Map,Bl.set(this,t));let e=t.get(n);return void 0===e&&(e=n.bind(this),t.set(n,e)),e}}}function ql(...t){let e;if(!x(t)){e=t[0];let n=function(t,n){return $l(t,n,e)};return A(n),n}let[n,r,i]=t;return e=i?.value,$l(n,r,e)}function Vl(...t){let e,n,r,i=t.pop();"function"==typeof i?(e=i,n=t,r=!O._DEFAULT_ASYNC_OBSERVERS):(e=i.fn,n=i.dependentKeys,r=i.sync);let s=[];for(let o of n)Nn(o,t=>s.push(t));return Xe(e,{paths:s,sync:r}),e}function Wl(t){if(!(t instanceof MouseEvent))return!1;let e=t.shiftKey||t.metaKey||t.altKey||t.ctrlKey,n=0!==t.button;return!e&&!n}function Hl(t){return'Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see https://deprecations.emberjs.com/v1.x/#toc_binding-style-attributes. Style affected: "'+t+'"'}function Gl(t){let e=t.lookup("-view-registry:main"),n=[];return Object.keys(e).forEach(t=>{let r=e[t];null===r.parentView&&n.push(r)}),n}function Kl(t){return""!==t.tagName&&t.elementId?t.elementId:al(t)}A(ql);var Zl=new WeakMap,Yl=new WeakMap;function Xl(t){return Zl.get(t)||null}function Jl(t){return Yl.get(t)||null}function Ql(t,e){Zl.set(t,e)}function tc(t,e){Yl.set(t,e)}function ec(t){Zl.delete(t)}function nc(t){Yl.delete(t)}var rc=new WeakMap;function ic(t){return function(t,e){let n=[],r=rc.get(t);return void 0!==r&&r.forEach(t=>{let r=e[t];!r||r.isDestroying||r.isDestroyed||n.push(r)}),n}(t,Ur(t).lookup("-view-registry:main"))}function sc(t,e){let n=rc.get(t);void 0===n&&(n=function(t){let e=new Set;return rc.set(t,e),e}(t)),n.add(Kl(e))}function oc(t){return t.renderer.getBounds(t)}function ac(t){let e=oc(t),n=document.createRange();return n.setStartBefore(e.firstNode),n.setEndAfter(e.lastNode),n}function lc(t){return ac(t).getClientRects()}function cc(t){return ac(t).getBoundingClientRect()}var uc="ember-application",hc=class extends Ul{events={touchstart:"touchStart",touchmove:"touchMove",touchend:"touchEnd",touchcancel:"touchCancel",keydown:"keyDown",keyup:"keyUp",keypress:"keyPress",mousedown:"mouseDown",mouseup:"mouseUp",contextmenu:"contextMenu",click:"click",dblclick:"doubleClick",focusin:"focusIn",focusout:"focusOut",submit:"submit",input:"input",change:"change",dragstart:"dragStart",drag:"drag",dragenter:"dragEnter",dragleave:"dragLeave",dragover:"dragOver",drop:"drop",dragend:"dragEnd"};rootElement="body";_eventHandlers=Object.create(null);_didSetup=!1;finalEventNameMapping=null;_sanitizedRootElement=null;lazyEvents=new Map;_reverseEventNameMapping=null;setup(t,e){let n=this.finalEventNameMapping={...ur(this,"events"),...t};this._reverseEventNameMapping=Object.keys(n).reduce((t,e)=>{let r=n[e];return r?{...t,[r]:e}:t},{});let r=this.lazyEvents;null!=e&&gr(this,"rootElement",e);let i=ur(this,"rootElement"),s="string"!=typeof i?i:document.querySelector(i);s.classList.add(uc),this._sanitizedRootElement=s;for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&r.set(o,n[o]??null);this._didSetup=!0}setupHandlerForBrowserEvent(t){this.setupHandler(this._sanitizedRootElement,t,this.finalEventNameMapping[t]??null)}setupHandlerForEmberEvent(t){let e=this._reverseEventNameMapping?.[t];e&&this.setupHandler(this._sanitizedRootElement,e,t)}setupHandler(t,e,n){if(null===n||!this.lazyEvents.has(e))return;let r=(t,e)=>{let r=Xl(t),i=!0;return r&&(i=r.handleEvent(n,e)),i},i=this._eventHandlers[e]=t=>{let e=t.target;do{if(Xl(e)){if(!1===r(e,t)){t.preventDefault(),t.stopPropagation();break}if(!0===t.cancelBubble)break}e=e.parentNode}while(e instanceof Element)};t.addEventListener(e,i),this.lazyEvents.delete(e)}destroy(){if(!1===this._didSetup)return;let t=this._sanitizedRootElement;if(t){for(let e in this._eventHandlers)t.removeEventListener(e,this._eventHandlers[e]);return t.classList.remove(uc),this._super(...arguments)}}toString(){return"(EventDispatcher)"}},dc=/^[^:]+:[^:]+$/,pc=class{_failSet;resolver;fallback;registrations;_normalizeCache;_options;_resolveCache;_typeOptions;constructor(t={}){this.fallback=t.fallback||null,this.resolver=t.resolver||null,this.registrations=Po(t.registrations||null),this._normalizeCache=Po(null),this._resolveCache=Po(null),this._failSet=new Set,this._options=Po(null),this._typeOptions=Po(null)}container(t){return new qa(this,t)}register(t,e,n={}){let r=this.normalize(t);this._failSet.delete(r),this.registrations[r]=e,this._options[r]=n}unregister(t){let e=this.normalize(t);delete this.registrations[e],delete this._resolveCache[e],delete this._options[e],this._failSet.delete(e)}resolve(t){let e=function(t,e){let n,r=e,i=t._resolveCache[r];return void 0!==i?i:t._failSet.has(r)?void 0:(t.resolver&&(n=t.resolver.resolve(r)),void 0===n&&(n=t.registrations[r]),void 0===n?t._failSet.add(r):t._resolveCache[r]=n,n)}(this,this.normalize(t));return void 0===e&&null!==this.fallback&&(e=this.fallback.resolve(t)),e}describe(t){return null!==this.resolver&&this.resolver.lookupDescription?this.resolver.lookupDescription(t):null!==this.fallback?this.fallback.describe(t):t}normalizeFullName(t){return null!==this.resolver&&this.resolver.normalize?this.resolver.normalize(t):null!==this.fallback?this.fallback.normalizeFullName(t):t}normalize(t){return this._normalizeCache[t]||(this._normalizeCache[t]=this.normalizeFullName(t))}makeToString(t,e){return null!==this.resolver&&this.resolver.makeToString?this.resolver.makeToString(t,e):null!==this.fallback?this.fallback.makeToString(t,e):"string"==typeof t?t:t.name??"(unknown class)"}has(t){return!!this.isValidFullName(t)&&function(t,e){return void 0!==t.resolve(e)}(this,this.normalize(t))}optionsForType(t,e){this._typeOptions[t]=e}getOptionsForType(t){let e=this._typeOptions[t];return void 0===e&&null!==this.fallback&&(e=this.fallback.getOptionsForType(t)),e}options(t,e){let n=this.normalize(t);this._options[n]=e}getOptions(t){let e=this.normalize(t),n=this._options[e];return void 0===n&&null!==this.fallback&&(n=this.fallback.getOptions(t)),n}getOption(t,e){let n=this._options[t];if(void 0!==n&&void 0!==n[e])return n[e];let r=t.split(":")[0];return n=this._typeOptions[r],n&&void 0!==n[e]?n[e]:null!==this.fallback?this.fallback.getOption(t,e):void 0}knownForType(t){let e,n,r=Po(null),i=Object.keys(this.registrations);for(let s of i)s.split(":")[0]===t&&(r[s]=!0);return null!==this.fallback&&(e=this.fallback.knownForType(t)),null!==this.resolver&&this.resolver.knownForType&&(n=this.resolver.knownForType(t)),Object.assign({},e,r,n)}isValidFullName(t){return dc.test(t)}},fc=Po(null),gc=`${Math.random()}${Date.now()}`.replace(".","");function mc([t]){let e=fc[t];if(e)return e;let[n,r]=t.split(":");return fc[t]=Qa(`${n}:${r}-${gc}`)}var yc=a({default:()=>vc,on:()=>an}),vc=wl.create({on(t,e,n){return nn(this,t,e,n),this},one(t,e,n){return nn(this,t,e,n,!0),this},trigger(t,...e){sn(this,t,e)},off(t,e,n){return rn(this,t,e,n),this},has(t){return on(this,t)}}),bc=wl.create(),wc=a({default:()=>_c}),_c=wl.create(bc),xc={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object AsyncFunction]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object FileList]":"filelist"},{toString:Cc}=Object.prototype;function Sc(t){if(null===t)return"null";if(void 0===t)return"undefined";let e=xc[Cc.call(t)]||"object";return"function"===e?Nl.detect(t)&&(e="class"):"object"===e&&(t instanceof Error?e="error":t instanceof Nl?e="instance":t instanceof Date&&(e="date")),e}var kc=wl.create({compare:null}),Ec={undefined:0,null:1,boolean:2,number:3,string:4,array:5,object:6,instance:7,function:8,class:9,date:10,regexp:11,filelist:12,error:13};function Rc(t,e){return Math.sign(t-e)}function Tc(t,e){if(t===e)return 0;let n=Sc(t),r=Sc(e);if("instance"===n&&Lc(t)&&t.constructor.compare)return t.constructor.compare(t,e);if("instance"===r&&Lc(e)&&e.constructor.compare)return-1*e.constructor.compare(e,t);let i=Rc(Ec[n],Ec[r]);if(0!==i)return i;switch(n){case"boolean":return Rc(Number(t),Number(e));case"number":return Rc(t,e);case"string":return Rc(t.localeCompare(e),0);case"array":{let n=t.length,r=e.length,i=Math.min(n,r);for(let s=0;sZc,MutableArray:()=>Hc,NativeArray:()=>Gc,default:()=>Wc,isArray:()=>Ic,makeArray:()=>El,removeAt:()=>Bc,uniqBy:()=>Oc}),Mc=Object.freeze([]),Ac=t=>t;function Oc(t,e=Ac){let n=Zc(),r=new Set,i="function"==typeof e?e:t=>ur(t,e);return t.forEach(t=>{let e=i(t);r.has(e)||(r.add(e),n.push(t))}),n}function Nc(...t){let e=2===t.length,[n,r]=t;return e?t=>r===ur(t,n):t=>Boolean(ur(t,n))}function Fc(t,e,n){let r=t.length;for(let i=n;i!r(t,e,n),0)}function Uc(t,e,n=0,r){let i=t.length;return n<0&&(n+=i),Fc(t,r&&e!=e?t=>t!=t:t=>t===e,n)}function Bc(t,e,n){return Er(t,e,n??1,Mc),t}function $c(t,e,n){return Er(t,e,0,[n]),n}function qc(t){let e=Yn(t);return e.enumerable=!1,e}function Vc(t){return this.map(e=>ur(e,t))}var Wc=wl.create(bc,{init(){this._super(...arguments),rr.add(this)},objectsAt(t){return t.map(t=>Pe(this,t))},"[]":qc({get(){return this},set(t,e){return this.replace(0,this.length,e),this}}),firstObject:qc(function(){return Pe(this,0)}).readOnly(),lastObject:qc(function(){return Pe(this,this.length-1)}).readOnly(),slice(t=0,e){let n,r=Zc(),i=this.length;for(t<0&&(t=i+t),n=void 0===e||e>i?i:e<0?i+e:e;t=n)&&(e=n-1),e<0&&(e+=n);for(let r=e;r>=0;r--)if(Pe(this,r)===t)return r;return-1},forEach(t,e=null){let n=this.length;for(let r=0;rgr(n,t,e))},map(t,e=null){let n=Zc();return this.forEach((r,i,s)=>n[i]=t.call(e,r,i,s)),n},mapBy:Vc,filter(t,e=null){let n=Zc();return this.forEach((r,i,s)=>{t.call(e,r,i,s)&&n.push(r)}),n},reject(t,e=null){return this.filter(function(){return!t.apply(e,arguments)})},filterBy(){return this.filter(Nc(...arguments))},rejectBy(){return this.reject(Nc(...arguments))},find(t,e=null){return Dc(this,t,e)},findBy(){return Dc(this,Nc(...arguments))},every(t,e=null){return jc(this,t,e)},isEvery(){return jc(this,Nc(...arguments))},any(t,e=null){return zc(this,t,e)},isAny(){return zc(this,Nc(...arguments))},reduce(t,e){let n=e,r=0;if(!(arguments.length>1)){if(0===this.length)throw new TypeError("Reduce of empty array with no initial value");n=this.objectAt(0),r=1}for(let i=r;in.push(r[t]?.(...e))),n},toArray(){return this.map(t=>t)},compact(){return this.filter(t=>null!=t)},includes(t,e){return-1!==Uc(this,t,e,!0)},sortBy(){let t=arguments;return this.toArray().sort((e,n)=>{for(let r=0;re!==t:t=>t==t;return this.filter(e)}}),Hc=wl.create(Wc,_c,{clear(){let t=this.length;return 0===t||this.replace(0,t,Mc),this},insertAt(t,e){return $c(this,t,e),this},removeAt(t,e){return Bc(this,t,e)},pushObject(t){return $c(this,this.length,t)},pushObjects(t){return this.replace(this.length,0,t),this},popObject(){let t=this.length;if(0===t)return null;let e=Pe(this,t-1);return this.removeAt(t-1,1),e},shiftObject(){if(0===this.length)return null;let t=Pe(this,0);return this.removeAt(0),t},unshiftObject(t){return $c(this,0,t)},unshiftObjects(t){return this.replace(0,0,t),this},reverseObjects(){let t=this.length;if(0===t)return this;let e=this.toArray().reverse();return this.replace(0,t,e),this},setObjects(t){if(0===t.length)return this.clear();let e=this.length;return this.replace(0,e,t),this},removeObject(t){let e=this.length||0;for(;--e>=0;)Pe(this,e)===t&&this.removeAt(e);return this},removeObjects(t){qn();for(let e=t.length-1;e>=0;e--)this.removeObject(t[e]);return Vn(),this},addObject(t){return this.includes(t)||this.pushObject(t),this},addObjects(t){return qn(),t.forEach(t=>this.addObject(t)),Vn(),this}}),Gc=wl.create(Hc,zl,{objectAt(t){return this[t]},replace(t,e,n=Mc){return Tr(this,t,e,n),this}}),Kc=["length"];Gc.keys().forEach(t=>{Array.prototype[t]&&Kc.push(t)}),Gc=Gc.without(...Kc);var Zc=function(t){return ir(t)?t:Gc.apply(t??[])},Yc=class extends Ul{},Xc=a({ControllerMixin:()=>Qc,default:()=>tu,inject:()=>eu}),Jc=Symbol("MODEL"),Qc=wl.create(Sl,{isController:!0,concatenatedProperties:["queryParams"],target:null,store:null,init(){this._super(...arguments);let t=Ur(this);t&&(this.namespace=t.lookup("application:main"),this.target=t.lookup("router:main"))},model:Yn({get(){return this[Jc]},set(t,e){return this[Jc]=e}}),queryParams:null,_qpDelegate:null,_qpChanged(t,e){let n=e.indexOf(".[]"),r=-1===n?e:e.slice(0,n);(0,t._qpDelegate)(r,ur(t,r))}}),tu=class extends(Yc.extend(Qc)){};function eu(...t){return $r("controller",...t)}var nu=!1;function ru(){return nu}function iu(t){nu=Boolean(t)}var su=Symbol("ENGINE_PARENT");function ou(t){return t[su]}var au=wl.create({__container__:null,ownerInjection(){return this.__container__.ownerInjection()},lookup(t,e){return this.__container__.lookup(t,e)},destroy(){let t=this.__container__;t&&_s(()=>{t.destroy(),ks("destroy",t,"finalizeDestroy")}),this._super()},factoryFor(t){return this.__container__.factoryFor(t)}}),lu=wl.create({__registry__:null,resolveRegistration(t){return this.__registry__.resolve(t)},register:cu("register"),unregister:cu("unregister"),hasRegistration:cu("has"),registeredOption:cu("getOption"),registerOptions:cu("options"),registeredOptions:cu("getOptions"),registerOptionsForType:cu("optionsForType"),registeredOptionsForType:cu("getOptionsForType")});function cu(t){return function(...e){return this.__registry__[t](...e)}}var uu=class extends(Ul.extend(lu,au)){static setupRegistry(t,e){}[su];_booted=!1;init(t){super.init(t),al(this),this.base??=this.application;let e=this.__registry__=new pc({fallback:this.base.__registry__});this.__container__=e.container({owner:this}),this._booted=!1}_bootPromise=null;boot(t){return this._bootPromise||(this._bootPromise=new Ba.Promise(e=>{e(this._bootSync(t))})),this._bootPromise}_bootSync(t){return this._booted||(this.cloneParentDependencies(),this.setupRegistry(t),this.base.runInstanceInitializers(this),this._booted=!0),this}setupRegistry(t=this.__container__.lookup("-environment:main")){this.constructor.setupRegistry(this.__registry__,t)}unregister(t){this.__container__.reset(t),this.__registry__.unregister(t)}buildChildEngineInstance(t,e={}){let n=this.lookup(`engine:${t}`);if(!n)throw new Error(`You attempted to mount the engine '${t}', but it is not registered with its parent.`);let r=n.buildInstance(e);return r[su]=this,r}cloneParentDependencies(){const t=ou(this);["route:basic","service:-routing"].forEach(e=>{let n=t.resolveRegistration(e);this.register(e,n)});let e=t.lookup("-environment:main");this.register("-environment:main",e,{instantiate:!1});let n=["router:main",mc`-bucket-cache:main`,"-view-registry:main","renderer:-dom","service:-document"];e.isInteractive&&n.push("event_dispatcher:main"),n.forEach(e=>{let n=t.lookup(e);this.register(e,n,{instantiate:!1})})}},hu=function(t,e,n){let{get:r}=n;return void 0!==r&&(n.get=function(){let t,n=Kt(this,e),i=qt(()=>{t=r.call(this)});return pt(n,i),Nt(i),t}),n};function du(...t){if(x(t)){let[e,n,r]=t;return hu(0,n,r)}{const e=t[0];let n=function(t,n){return hu(0,n,e)};return A(n),n}}A(du);var pu={Empty:0,dynamicLayout:1,dynamicTag:2,prepareArgs:4,createArgs:8,attributeHook:16,elementHook:32,dynamicScope:64,createCaller:128,updateHook:256,createInstance:512,wrapped:1024,willDestroy:2048,hasSubOwner:4096},fu=pu.Empty;function gu(t){return fu|mu(t,"dynamicLayout")|mu(t,"dynamicTag")|mu(t,"prepareArgs")|mu(t,"createArgs")|mu(t,"attributeHook")|mu(t,"elementHook")|mu(t,"dynamicScope")|mu(t,"createCaller")|mu(t,"updateHook")|mu(t,"createInstance")|mu(t,"wrapped")|mu(t,"willDestroy")|mu(t,"hasSubOwner")}function mu(t,e){return t[e]?pu[e]:fu}function yu(t,e,n){return!!(e&n)}function vu(t,e){return!!(t&e)}function bu(t,e={}){return{hasValue:Boolean(e.hasValue),hasDestroyable:Boolean(e.hasDestroyable),hasScheduledEffect:Boolean(e.hasScheduledEffect)}}function wu(t){return t.capabilities.hasValue}function _u(t){return t.capabilities.hasDestroyable}var xu=class{constructor(t){this.factory=t}helperManagerDelegates=new WeakMap;undefinedDelegate=null;getDelegateForOwner(t){let e=this.helperManagerDelegates.get(t);if(void 0===e){let{factory:n}=this;e=n(t),this.helperManagerDelegates.set(t,e)}return e}getDelegateFor(t){if(void 0===t){let{undefinedDelegate:t}=this;if(null===t){let{factory:e}=this;this.undefinedDelegate=t=e(void 0)}return t}return this.getDelegateForOwner(t)}getHelper(t){return(e,n)=>{let r=this.getDelegateFor(n);const i=Ie(e),s=r.createHelper(t,i);if(wu(r)){let t=fe(()=>r.getValue(s),null);return _u(r)&&Q(t,r.getDestroyable(s)),t}if(_u(r)){let t=de(void 0);return Q(t,r.getDestroyable(s)),t}return le}}},Cu=class{capabilities={hasValue:!0,hasDestroyable:!1,hasScheduledEffect:!1};createHelper(t,e){return{fn:t,args:e}}getValue({fn:t,args:e}){return Object.keys(e.named).length>0?t(...e.positional,e.named):t(...e.positional)}getDebugName(t){return t.name?`(helper function ${t.name})`:"(anonymous helper function)"}},Su=new WeakMap,ku=new WeakMap,Eu=new WeakMap,Ru=Object.getPrototypeOf;function Tu(t,e,n){return t.set(n,e),n}function Lu(t,e){let n=e;for(;null!==n;){const e=t.get(n);if(void 0!==e)return e;n=Ru(n)}}function Iu(t,e){return Tu(ku,t,e)}function Pu(t){const e=Lu(ku,t);return void 0===e?null:e}function Mu(t,e){return Tu(Eu,t,e)}var Au=new xu(()=>new Cu);function Ou(t){let e=Lu(Eu,t);return void 0===e&&"function"==typeof t&&(e=Au),e||null}function Nu(t,e){return Tu(Su,t,e)}function Fu(t){const e=Lu(Su,t);return void 0===e?null:e}function Du(t){return void 0!==Lu(Su,t)}function zu(t){return function(t){return"function"==typeof t}(t)||void 0!==Lu(Eu,t)}function ju(t){return void 0!==Lu(ku,t)}var Uu=Object.create;function Bu(){var t=Uu(null);return t.__=void 0,delete t.__,t}var $u=function(t,e,n){this.path=t,this.matcher=e,this.delegate=n};$u.prototype.to=function(t,e){var n=this.delegate;if(n&&n.willAddRoute&&(t=n.willAddRoute(this.matcher.target,t)),this.matcher.add(this.path,t),e){if(0===e.length)throw new Error("You must have an argument in the function passed to `to`");this.matcher.addChild(this.path,t,e,this.delegate)}};var qu=function(t){this.routes=Bu(),this.children=Bu(),this.target=t};function Vu(t,e,n){return function(r,i){var s=t+r;if(!i)return new $u(s,e,n);i(Vu(s,e,n))}}function Wu(t,e,n){for(var r=0,i=0;i0&&47===e.charCodeAt(0)&&(e=e.substr(1));for(var r=e.split("/"),i=void 0,s=void 0,o=0;o2&&"[]"===s.slice(o-2)&&(a=!0,n[s=s.slice(0,o-2)]||(n[s]=[])),l=i[1]?ph(i[1]):""),a?n[s].push(l):n[s]=l}return n},fh.prototype.recognize=function(t){var e,n=[this.rootState],r={},i=!1,s=t.indexOf("#");-1!==s&&(t=t.substr(0,s));var o=t.indexOf("?");if(-1!==o){var a=t.substr(o+1,t.length);t=t.substr(0,o),r=this.parseQueryString(a)}"/"!==t.charAt(0)&&(t="/"+t);var l=t;fh.ENCODE_AND_DECODE_PATH_SEGMENTS?t=Gu(t):(t=decodeURI(t),l=decodeURI(l));var c=t.length;c>1&&"/"===t.charAt(c-1)&&(t=t.substr(0,c-1),l=l.substr(0,l.length-1),i=!0);for(var u=0;u0){let i=t[r-1];if(function(t){if(t&&"object"==typeof t){let e=t;return"queryParams"in e&&Object.keys(e.queryParams).every(t=>"string"==typeof t)}return!1}(i))return n=i.queryParams,e=yh.call(t,0,r-1),[e,n]}return[t,null]}function _h(t){for(let e in t){let n=t[e];if("number"==typeof n)t[e]=String(n);else if(Array.isArray(n))for(let t=0,e=n.length;t{throw this.router.transitionDidError(t,this)},Rh("Handle Abort"))}else this.promise=ra.resolve(this[Th]),this[Lh]={}}then(t,e,n){return this.promise.then(t,e,n)}catch(t,e){return this.promise.catch(t,e)}finally(t,e){return this.promise.finally(t,e)}abort(){this.rollback();let e=new t(this.router,void 0,void 0,void 0);return e.to=this.from,e.from=this.from,e.isAborted=!0,this.router.routeWillChange(e),this.router.routeDidChange(e),this}rollback(){this.isAborted||(xh(this.router,this.sequence,this.targetName+": transition was aborted"),void 0!==this.intent&&null!==this.intent&&(this.intent.preTransitionState=this.router.state),this.isAborted=!0,this.isActive=!1,this.router.activeTransition=void 0)}redirect(t){this[Ph]=t,this.rollback(),this.router.routeWillChange(t)}retry(){this.abort();let t=this.router.transitionByIntent(this.intent,!1);return null!==this.urlMethod&&t.method(this.urlMethod),t}method(t){return this.urlMethod=t,this}send(t=!1,e,n,r,i){this.trigger(t,e,n,r,i)}trigger(t=!1,e,...n){"string"==typeof t&&(e=t,t=!1),this.router.triggerEvent(this[Th].routeInfos.slice(0,this.resolveIndex+1),t,e,n)}followRedirects(){return this.promise.catch(t=>this[Ph]?this[Ph].followRedirects():ra.reject(t))}toString(){return"Transition (sequence "+this.sequence+")"}log(t){xh(this.router,this.sequence,t)}};function Ah(t){return xh(t.router,t.sequence,"detected abort."),gh()}function Oh(t){return"object"==typeof t&&t instanceof Mh&&t.isTransition}var Nh=function(){function t(e){let n=Error.call(this,e);this.name="UnrecognizedURLError",this.message=e||"UnrecognizedURL",Error.captureStackTrace?Error.captureStackTrace(this,t):this.stack=n.stack}return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}();function Fh(t,e){let n=t.factoryFor("controller:basic").class;n=class extends n{toString(){return`(generated ${e} controller)`}};let r=`controller:${e}`;return t.register(r,n),t.factoryFor(r)}function Dh(t,e){Fh(t,e);let n=`controller:${e}`;return t.lookup(n)}var zh=/\./g;function jh(t){let e,n,r=(t=t.slice())[t.length-1];return function(t){if(t&&"object"==typeof t){let e=t.queryParams;if(e&&"object"==typeof e)return Object.keys(e).every(t=>"string"==typeof t)}return!1}(r)?(t.pop(),e=r.queryParams):e={},"string"==typeof t[0]&&(n=t.shift()),{routeName:n,models:t,queryParams:e}}function Uh(t,e){if(e._namesStashed)return;let n,r=e[e.length-1].name,i=t._routerMicrolib.recognizer.handlersFor(r);for(let s=0;s(t[e]=n,t),s)}serializeQueryParamKey(t){return t}serializeQueryParam(t,e,n){return this._router._serializeQueryParam(t,n)}deserializeQueryParam(t,e,n){return this._router._deserializeQueryParam(t,n)}_optionsForQueryParam(t){const e=ur(this,"queryParams");return ur(e,t.urlKey)||ur(e,t.prop)||e[t.urlKey]||e[t.prop]||{}}resetController(t,e,n){return this}exit(t){this.deactivate(t),this.trigger("deactivate",t),this.teardownViews()}_internalReset(t,e){let n=this.controller;n._qpDelegate=ur(this,"_qp").states.inactive,this.resetController(n,t,e)}enter(t){this[Xh]=void 0,this.activate(t),this.trigger("activate",t)}deactivate(t){}activate(t){}intermediateTransitionTo(...t){let[e,...n]=function(t,e){let n,r=Ur(t),i=r.mountPoint;if(r.routable&&"string"==typeof e[0]){if(n=e[0],Vh(n))throw new Error("Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.");n=`${i}.${n}`,e[0]=n}return e}(this,t);this._router.intermediateTransitionTo(e,...n)}refresh(){return this._router._routerMicrolib.refresh(this)}setup(t,e){let n=this.controllerName||this.routeName,r=this.controllerFor(n,!0)??this.generateController(n),i=ur(this,"_qp");if(!this.controller){let t=i.propertyNames;!function(t,e){e.forEach(e=>{if(void 0===I(t,e)){let n=fr(t,e);null===n||"function"!=typeof n.get&&"function"!=typeof n.set||Dn(t,e,du({get:n.get,set:n.set}))}dn(t,`${e}.[]`,t,t._qpChanged,!1)})}(r,t),this.controller=r}if(r._qpDelegate=i.states.allowOverrides,e){Uh(this._router,e[Th].routeInfos);let t=this._bucketCache,n=e[Lh];i.propertyNames.forEach(e=>{let s=i.map[e];s.values=n;let o=$h(s.route.fullRouteName,s.parts,s.values),a=t.lookup(o,e,s.undecoratedDefaultValue);gr(r,e,a)});let s=ed(this,e[Th]);Dr(r,s)}this.setupController(r,t,e),this._environment.options.shouldRender&&this[Yh](),wn(!1)}_qpChanged(t,e,n){if(!n)return;let r=this._bucketCache,i=$h(n.route.fullRouteName,n.parts,n.values);r.stash(i,t,e)}beforeModel(t){}afterModel(t,e){}redirect(t,e){}contextDidChange(){this.currentModel=this.context}model(t,e){let n,r,i=ur(this,"_qp").map;for(let s in t){if("queryParams"===s||i&&s in i)continue;let t=s.match(/^(.*)_id$/);null!==t&&(n=t[1]),r=!0}if(!n){if(r)return Object.assign({},t);if(e.resolveIndex<1)return;return e[Th].routeInfos[e.resolveIndex-1].context}}deserialize(t,e){return this.model(this._paramsFor(this.routeName,t),e)}setupController(t,e,n){t&&void 0!==e&&gr(t,"model",e)}controllerFor(t,e=!1){let n=Ur(this),r=n.lookup(`route:${t}`);return r&&r.controllerName&&(t=r.controllerName),n.lookup(`controller:${t}`)}generateController(t){return Dh(Ur(this),t)}modelFor(t){let e,n=Ur(this),r=this._router&&this._router._routerMicrolib?this._router._routerMicrolib.activeTransition:void 0;e=n.routable&&void 0!==r?rd(n,t):t;let i=n.lookup(`route:${e}`);if(null!=r){let t=i&&i.routeName||e;if(Object.prototype.hasOwnProperty.call(r.resolvedModels,t))return r.resolvedModels[t]}return i?.currentModel}[Xh]=void 0;[Yh](){this[Xh]=function(t){let e,n=Ur(t),r=t.routeName,i=n.lookup(`controller:${t.controllerName||r}`),s=t.currentModel,o=n.lookup(`template:${t.templateName||r}`);return e=o?Du(o)?o:o(n):t._topLevelViewTemplate(n),{owner:n,name:r,controller:i,model:s,template:e}}(this),Ls(this._router,"_setOutlets")}willDestroy(){this.teardownViews()}teardownViews(){this[Xh]&&(this[Xh]=void 0,Ls(this._router,"_setOutlets"))}buildRouteInfoMetadata(){}_paramsFor(t,e){return void 0!==this._router._routerMicrolib.activeTransition?this.paramsFor(t):e}get _store(){const t=Ur(this);return this.routeName,{find(e,n){let r=t.factoryFor(`model:${e}`);if(r)return r=r.class,r.find(n)}}}static{Kh(this.prototype,"_store",[Yn])}get _qp(){let t={},e=this.controllerName||this.routeName,n=Ur(this),r=n.lookup(`controller:${e}`),i=ur(this,"queryParams"),s=Object.keys(i).length>0;r?t=function(t,e){let n={},r={defaultValue:!0,type:!0,scope:!0,as:!0};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]={...t[i],...e[i]},r[i]=!0);for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&!r[i]&&(n[i]={...e[i],...t[i]});return n}(function(t){let e={};for(let n of t)qh(n,e);return e}(ur(r,"queryParams")||[]),i):s&&(r=Dh(n,e),t=i);let o=[],a={},l=[];for(let c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;if("unknownProperty"===c||"_super"===c)continue;let n,i=t[c],s=i.scope||"model";"controller"===s&&(n=[]);let u=i.as||this.serializeQueryParamKey(c),h=ur(r,c);h=nd(h);let d=i.type||Sc(h),p=this.serializeQueryParam(h,u,d),f=`${e}:${c}`,g={undecoratedDefaultValue:ur(r,c),defaultValue:h,serializedDefaultValue:p,serializedValue:p,type:d,urlKey:u,prop:c,scopedPropertyName:f,controllerName:e,route:this,parts:n,values:null,scope:s};a[c]=a[u]=a[f]=g,o.push(g),l.push(c)}return{qps:o,map:a,propertyNames:l,states:{inactive:(t,e)=>{let n=a[t];this._qpChanged(t,e,n)},active:(t,e)=>{let n=a[t];return this._qpChanged(t,e,n),this._activeQPChanged(n,e)},allowOverrides:(t,e)=>{let n=a[t];return this._qpChanged(t,e,n),this._updatingQPChanged(n)}}}}static{Kh(this.prototype,"_qp",[Yn])}};function Qh(t){return t[Xh]}function td(t,e){if(e.fullQueryParams)return e.fullQueryParams;let n=e.routeInfos.every(t=>t.route),r={...e.queryParams};return t._deserializeQueryParams(e.routeInfos,r),n&&(e.fullQueryParams=r),r}function ed(t,e){e.queryParamsFor=e.queryParamsFor||{};let n=t.fullRouteName,r=e.queryParamsFor[n];if(r)return r;let i=td(t._router,e),s=e.queryParamsFor[n]={},o=ur(t,"_qp").qps;for(let a of o){let t=a.prop in i;s[a.prop]=t?i[a.prop]:nd(a.defaultValue)}return s}function nd(t){return Array.isArray(t)?Zc(t.slice()):t}function rd(t,e){if(t.routable){let n=t.mountPoint;return"application"===e?n:`${n}.${e}`}return e}var id=Jh.prototype.serialize;Jh.reopen({mergedProperties:["queryParams"],queryParams:{},templateName:null,controllerName:null,send(...t){if(this._router&&this._router._routerMicrolib||!ru())this._router.send(...t);else{let e=t.shift(),n=this.actions[e];if(n)return n.apply(this,t)}},actions:{queryParamsDidChange(t,e,n){let r=ur(this,"_qp").map,i=Object.keys(t).concat(Object.keys(n));for(let s of i){let t=r[s];if(t&&ur(this._optionsForQueryParam(t),"refreshModel")&&this._router.currentState){this.refresh();break}}return!0},finalizeQueryParamChange(t,e,n){if("application"!==this.fullRouteName)return!0;if(!n)return;let r,i=n[Th].routeInfos,s=this._router,o=s._queryParamsFor(i),a=s._qpUpdates,l=!1;Uh(s,i);for(let c of o.qps){let i,s,o=c.route,u=o.controller,h=c.urlKey in t&&c.urlKey;if(a.has(c.urlKey)?(i=ur(u,c.prop),s=o.serializeQueryParam(i,c.urlKey,c.type)):h?(s=t[h],void 0!==s&&(i=o.deserializeQueryParam(s,c.urlKey,c.type))):(s=c.serializedDefaultValue,i=nd(c.defaultValue)),u._qpDelegate=ur(o,"_qp").states.inactive,s!==c.serializedValue){if(n.queryParamsOnly&&!1!==r){let t=ur(o._optionsForQueryParam(c),"replace");t?r=!0:!1===t&&(r=!1)}gr(u,c.prop,i),l=!0}c.serializedValue=s,c.serializedDefaultValue!==s&&e.push({value:s,visible:!0,key:h||c.urlKey})}!0===l&&wn(!1),r&&n.method("replace"),o.qps.forEach(t=>{let e=ur(t.route,"_qp");t.route.controller._qpDelegate=ur(e,"states.active")}),s._qpUpdates.clear()}}});var sd=0;function od(t){return"function"==typeof t}var ad=class t{parent;matches;enableLoadingSubstates;explicitIndex=!1;options;constructor(t=null,e){this.parent=t,this.enableLoadingSubstates=Boolean(e&&e.enableLoadingSubstates),this.matches=[],this.options=e}route(e,n,r){let i,s=null,o=`/_unused_dummy_error_path_route_${e}/:error`;if(od(n)?(i={},s=n):od(r)?(i=n,s=r):i=n||{},this.enableLoadingSubstates&&(cd(this,`${e}_loading`,{resetNamespace:i.resetNamespace}),cd(this,`${e}_error`,{resetNamespace:i.resetNamespace,path:o})),s){let n=ld(this,e,i.resetNamespace),r=new t(n,this.options);cd(r,"loading"),cd(r,"error",{path:o}),s.call(r),cd(this,e,i,r.generate())}else cd(this,e,i)}push(t,e,n,r){let i=e.split(".");if(this.options.engineInfo){let t=e.slice(this.options.engineInfo.fullName.length+1),n=Object.assign({localFullName:t},this.options.engineInfo);r&&(n.serializeMethod=r),this.options.addRouteForEngine(e,n)}else if(r)throw new Error(`Defining a route serializer on route '${e}' outside an Engine is not allowed.`);""!==t&&"/"!==t&&"index"!==i[i.length-1]||(this.explicitIndex=!0),this.matches.push(t,e,n)}generate(){let t=this.matches;return this.explicitIndex||this.route("index",{path:"/"}),e=>{for(let n=0;n0){let i=Object.assign({},n);return this.emberRouter._prepareQueryParams(t,e,i),Wh(i,r.queryParams)}return!0}},hd=new WeakMap;function dd(t,e={},n={includeAttributes:!1,localizeMapUpdates:!1}){const r=new WeakMap;return t.map((i,s)=>{let{name:o,params:a,paramNames:l,context:c,route:u}=i,h=i;if(hd.has(h)&&n.includeAttributes){let t=hd.get(h);t=function(t,e){let n={get metadata(){return fd(t)}};return!Object.isExtensible(e)||e.hasOwnProperty("metadata")?Object.freeze(Object.assign({},e,n)):Object.assign(e,n)}(u,t);let e=pd(t,c);return r.set(h,t),n.localizeMapUpdates||hd.set(h,e),e}const d=n.localizeMapUpdates?r:hd;let p={find(e,n){let r,i=[];3===e.length&&(i=t.map(t=>d.get(t)));for(let s=0;t.length>s;s++)if(r=d.get(t[s]),e.call(n,r,s,i))return r},get name(){return o},get paramNames(){return l},get metadata(){return fd(i.route)},get parent(){let e=t[s-1];return void 0===e?null:d.get(e)},get child(){let e=t[s+1];return void 0===e?null:d.get(e)},get localName(){let t=this.name.split(".");return t[t.length-1]},get params(){return a},get queryParams(){return e}};return n.includeAttributes&&(p=pd(p,c)),r.set(i,p),n.localizeMapUpdates||hd.set(i,p),p})}function pd(t,e){let n={get attributes(){return e}};return!Object.isExtensible(t)||t.hasOwnProperty("attributes")?Object.freeze(Object.assign({},t,n)):Object.assign(t,n)}function fd(t){return null!=t&&void 0!==t.buildRouteInfoMetadata?t.buildRouteInfoMetadata():null}var gd=class{_routePromise=void 0;_route=null;router;params={};isResolved=!1;constructor(t,e,n,r){this.name=e,this.paramNames=n,this.router=t,r&&this._processRoute(r)}getModel(t){return ra.resolve(this.context)}serialize(t){return this.params||{}}resolve(t){return ra.resolve(this.routePromise).then(e=>(mh(t),e)).then(()=>this.runBeforeModelHook(t)).then(()=>mh(t)).then(()=>this.getModel(t)).then(e=>(mh(t),e)).then(e=>this.runAfterModelHook(t,e)).then(e=>this.becomeResolved(t,e))}becomeResolved(t,e){let n,r=this.serialize(e);t&&(this.stashResolvedModel(t,e),t[Lh]=t[Lh]||{},t[Lh][this.name]=r);let i=e===this.context;!("context"in this)&&i||(n=e);let s=hd.get(this),o=new md(this.router,this.name,this.paramNames,r,this.route,n);return void 0!==s&&hd.set(o,s),o}shouldSupersede(t){if(!t)return!0;let e=t.context===this.context;return t.name!==this.name||"context"in this&&!e||this.hasOwnProperty("params")&&!function(t,e){if(t===e)return!0;if(!t||!e)return!1;for(let n in t)if(t.hasOwnProperty(n)&&t[n]!==e[n])return!1;return!0}(this.params,t.params)}get route(){return null!==this._route?this._route:this.fetchRoute()}set route(t){this._route=t}get routePromise(){return this._routePromise||this.fetchRoute(),this._routePromise}set routePromise(t){this._routePromise=t}log(t,e){t.log&&t.log(this.name+": "+e)}updateRoute(t){return t._internalName=this.name,this.route=t}runBeforeModelHook(t){let e;return t.trigger&&t.trigger(!0,"willResolveModel",t,this.route),this.route&&void 0!==this.route.beforeModel&&(e=this.route.beforeModel(t)),Oh(e)&&(e=null),ra.resolve(e)}runAfterModelHook(t,e){let n,r=this.name;var i;return this.stashResolvedModel(t,e),void 0!==this.route&&void 0!==this.route.afterModel&&(n=this.route.afterModel(e,t)),n=Oh(i=n)?null:i,ra.resolve(n).then(()=>t.resolvedModels[r])}stashResolvedModel(t,e){t.resolvedModels=t.resolvedModels||{},t.resolvedModels[this.name]=e}fetchRoute(){let t=this.router.getRoute(this.name);return this._processRoute(t)}_processRoute(t){return this.routePromise=ra.resolve(t),function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}(t)?(this.routePromise=this.routePromise.then(t=>this.updateRoute(t)),void(this.route=void 0)):t?this.updateRoute(t):void 0}},md=class extends gd{isResolved;context;constructor(t,e,n,r,i,s){super(t,e,n,i),this.params=r,this.isResolved=!0,this.context=s}resolve(t){return t&&t.resolvedModels&&(t.resolvedModels[this.name]=this.context),ra.resolve(this)}},yd=class extends gd{params={};constructor(t,e,n,r,i){super(t,e,n,i),r&&(this.params=r)}getModel(t){let e=this.params;t&&t[Ih]&&(e={},bh(e,this.params),e.queryParams=t[Ih]);let n,r=this.route;return r.deserialize?n=r.deserialize(e,t):r.model&&(n=r.model(e,t)),n&&Oh(n)&&(n=void 0),ra.resolve(n)}},vd=class extends gd{serializer;constructor(t,e,n,r){super(t,e,n),this.context=r,this.serializer=this.router.getSerializer(e)}getModel(t){return void 0!==this.router.log&&this.router.log(this.name+": resolving provided model"),super.getModel(t)}serialize(t){let{paramNames:e,context:n}=this;t||(t=n);let r={};if(Ch(t))return r[e[0]]=t,r;if(this.serializer)return this.serializer.call(null,t,e);if(void 0!==this.route&&this.route.serialize)return this.route.serialize(t,e);if(1!==e.length)return;let i=e[0];return/_id$/.test(i)?r[i]=t.id:r[i]=t,r}},bd=class{data;router;constructor(t,e={}){this.router=t,this.data=e}preTransitionState};function wd(t,e,n){let r=t.routeInfos,i=e.resolveIndex>=r.length?r.length-1:e.resolveIndex,s=e.isAborted;throw new Sd(n,t.routeInfos[i].route,s,t)}function _d(t,e){if(e.resolveIndex===t.routeInfos.length)return;let n=t.routeInfos[e.resolveIndex],r=xd.bind(null,t,e);return n.resolve(e).then(r,null,t.promiseLabel("Proceed"))}function xd(t,e,n){let r=t.routeInfos[e.resolveIndex].isResolved;if(t.routeInfos[e.resolveIndex++]=n,!r){let{route:t}=n;void 0!==t&&t.redirect&&t.redirect(n.context,e)}return mh(e),_d(t,e)}var Cd=class{routeInfos=[];queryParams={};params={};promiseLabel(t){let e="";return Sh(this.routeInfos,function(t){return""!==e&&(e+="."),e+=t.name,!0}),Rh("'"+e+"': "+t)}resolve(t){let e=this.params;Sh(this.routeInfos,t=>(e[t.name]=t.params||{},!0)),t.resolveIndex=0;let n=_d.bind(null,this,t),r=wd.bind(null,this,t);return ra.resolve(null,this.promiseLabel("Start transition")).then(n,null,this.promiseLabel("Resolve route")).catch(r,this.promiseLabel("Handle error")).then(()=>this)}},Sd=class{constructor(t,e,n,r){this.error=t,this.route=e,this.wasAborted=n,this.state=r}},kd=class extends bd{name;pivotHandler;contexts;queryParams;preTransitionState=void 0;constructor(t,e,n,r=[],i={},s){super(t,s),this.name=e,this.pivotHandler=n,this.contexts=r,this.queryParams=i}applyToState(t,e){let n=this.router.recognizer.handlersFor(this.name),r=n[n.length-1].handler;return this.applyToHandlers(t,n,r,e,!1)}applyToHandlers(t,e,n,r,i){let s,o,a=new Cd,l=this.contexts.slice(0),c=e.length;if(this.pivotHandler)for(s=0,o=e.length;s=0;--s){let o=e[s],u=o.handler,h=t.routeInfos[s],d=null;if(d=o.names.length>0?s>=c?this.createParamHandlerInfo(u,o.names,l,h):this.getHandlerInfoForDynamicSegment(u,o.names,l,h,n,s):this.createParamHandlerInfo(u,o.names,l,h),i){d=d.becomeResolved(null,d.context);let t=h&&h.context;o.names.length>0&&void 0!==h.context&&d.context===t&&(d.params=h&&h.params),d.context=t}let p=h;(s>=c||d.shouldSupersede(h))&&(c=Math.min(s,c),p=d),r&&!i&&(p=p.becomeResolved(null,p.context)),a.routeInfos.unshift(p)}if(l.length>0)throw new Error("More context objects were passed than there are dynamic segments for the route: "+n);return r||this.invalidateChildren(a.routeInfos,c),bh(a.queryParams,this.queryParams||{}),r&&t.queryParams&&bh(a.queryParams,t.queryParams),a}invalidateChildren(t,e){for(let n=e,r=t.length;n0){if(o=n[n.length-1],Ch(o))return this.createParamHandlerInfo(t,e,n,r);n.pop()}else{if(r&&r.name===t)return r;if(!this.preTransitionState)return r;o=this.preTransitionState.routeInfos[s]?.context}return new vd(this.router,t,e,o)}createParamHandlerInfo(t,e,n,r){let i={},s=e.length,o=[];for(;s--;){let a=r&&t===r.name&&r.params||{},l=n[n.length-1],c=e[s];Ch(l)?i[c]=String(n.pop()):a.hasOwnProperty(c)?i[c]=a[c]:o.push(c)}if(o.length>0)throw new Error(`You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route ${t}. Missing params: ${o}`);return new yd(this.router,t,e,i)}},Ed=class extends bd{preTransitionState;url;constructor(t,e,n){super(t,n),this.url=e,this.preTransitionState=void 0}applyToState(t){let e,n,r=new Cd,i=this.router.recognizer.recognize(this.url);if(!i)throw new Nh(this.url);let s=!1,o=this.url;function a(t){if(t&&t.inaccessibleByURL)throw new Nh(o);return t}for(e=0,n=i.length;e=0&&r;--n){let i=e[n],s=i.handler;t.add(e,{as:s}),r="/"===i.path||""===i.path||".index"===s.slice(-6)}})}hasRoute(t){return this.recognizer.hasRoute(t)}queryParamsTransition(t,e,n,r){if(this.fireQueryParamDidChange(r,t),!e&&this.activeTransition)return this.activeTransition;{let t=new Mh(this,void 0,void 0);return t.queryParamsOnly=!0,n.queryParams=this.finalizeQueryParamChange(r.routeInfos,r.queryParams,t),t[Ih]=r.queryParams,this.toReadOnlyInfos(t,r),this.routeWillChange(t),t.promise=t.promise.then(e=>(t.isAborted||(this._updateURL(t,n),this.didTransition(this.currentRouteInfos),this.toInfos(t,r.routeInfos,!0),this.routeDidChange(t)),e),null,Rh("Transition complete")),t}}transitionByIntent(t,e){try{return this.getTransitionByIntent(t,e)}catch(n){return new Mh(this,t,void 0,n,void 0)}}recognize(t){let e=new Ed(this,t),n=this.generateNewState(e);if(null===n)return n;let r=dd(n.routeInfos,n.queryParams,{includeAttributes:!1,localizeMapUpdates:!0});return r[r.length-1]}recognizeAndLoad(t){let e=new Ed(this,t),n=this.generateNewState(e);if(null===n)return ra.reject(`URL ${t} was not recognized`);let r=new Mh(this,e,n,void 0);return r.then(()=>{let t=dd(n.routeInfos,r[Ih],{includeAttributes:!0,localizeMapUpdates:!1});return t[t.length-1]})}generateNewState(t){try{return t.applyToState(this.state,!1)}catch(e){return null}}getTransitionByIntent(t,e){let n,r=Boolean(this.activeTransition),i=r?this.activeTransition[Th]:this.state,s=t.applyToState(i,e),o=kh(i.queryParams,s.queryParams);if(Td(s.routeInfos,i.routeInfos)){if(o){let t=this.queryParamsTransition(o,r,i,s);return t.queryParamsOnly=!0,t}return this.activeTransition||new Mh(this,void 0,void 0)}if(e){let t=new Mh(this,void 0,s);return t.isIntermediate=!0,this.toReadOnlyInfos(t,s),this.setupContexts(s,t),this.routeWillChange(t),this.activeTransition}return n=new Mh(this,t,s,void 0,this.activeTransition),function(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;nthis.finalizeTransition(n,t),null,Rh("Settle transition promise when transition is finalized")),r||this.notifyExistingHandlers(s,n),this.fireQueryParamDidChange(s,o),n}doTransition(t,e=[],n=!1){let r,i=e[e.length-1],s={};if(i&&Object.prototype.hasOwnProperty.call(i,"queryParams")&&(s=e.pop().queryParams),void 0===t){xh(this,"Updating query params");let{routeInfos:t}=this.state;r=new kd(this,t[t.length-1].name,void 0,[],s)}else"/"===t.charAt(0)?(xh(this,"Attempting URL transition to "+t),r=new Ed(this,t)):(xh(this,"Attempting transition to "+t),r=new kd(this,t,void 0,e,s));return this.transitionByIntent(r,n)}finalizeTransition(t,e){try{xh(t.router,t.sequence,"Resolved all models on destination route; finalizing transition.");let n=e.routeInfos;return this.setupContexts(e,t),t.isAborted?(this.state.routeInfos=this.currentRouteInfos,ra.reject(Ah(t))):(this._updateURL(t,e),t.isActive=!1,this.activeTransition=void 0,this.triggerEvent(this.currentRouteInfos,!0,"didTransition",[]),this.didTransition(this.currentRouteInfos),this.toInfos(t,e.routeInfos,!0),this.routeDidChange(t),xh(this,t.sequence,"TRANSITION COMPLETE."),n[n.length-1].route)}catch(r){if("object"!=typeof(n=r)||null===n||"TRANSITION_ABORTED"!==n.code){let e=t[Th].routeInfos;t.trigger(!0,"error",r,t,e[e.length-1].route),t.abort()}throw r}var n}setupContexts(t,e){let n,r,i,s=this.partitionRoutes(this.state,t);for(n=0,r=s.exited.length;n=0;--o){let t=r[o];bh(s,t.params),t.route.inaccessibleByURL&&(n=null)}if(n){s.queryParams=t._visibleQueryParams||e.queryParams;let r=this.recognizer.generate(i,s),o=t.isCausedByInitialTransition,a="replace"===n&&!t.isCausedByAbortingTransition,l=t.queryParamsOnly&&"replace"===n,c="replace"===n&&t.isCausedByAbortingReplaceTransition;o||a||l||c?this.replaceURL(r):this.updateURL(r)}}finalizeQueryParamChange(t,e,n){for(let s in e)e.hasOwnProperty(s)&&null===e[s]&&delete e[s];let r=[];this.triggerEvent(t,!0,"finalizeQueryParamChange",[e,r,n]),n&&(n._visibleQueryParams={});let i={};for(let s=0,o=r.length;s0){let n=dd(e,Object.assign({},this._lastQueryParams),{includeAttributes:!0,localizeMapUpdates:!1});t.from=n[n.length-1]||null}}toInfos(t,e,n=!1){if(void 0!==t&&e.length>0){let r=dd(e,Object.assign({},t[Ih]),{includeAttributes:n,localizeMapUpdates:!1});t.to=r[r.length-1]||null}}notifyExistingHandlers(t,e){let n,r,i,s,o=this.state.routeInfos;for(r=o.length,n=0;n{t.setURL(n),gr(e,"currentURL",n)})}didTransition(t){e.didTransition(t)}willTransition(t,n){e.willTransition(t,n)}triggerEvent(t,n,r,i){return zd.bind(e)(t,n,r,i)}routeWillChange(t){e.trigger("routeWillChange",t),e._routerService.trigger("routeWillChange",t),t.isIntermediate&&e.set("currentRoute",t.to)}routeDidChange(t){e.set("currentRoute",t.to),Ls(()=>{e.trigger("routeDidChange",t),e._routerService.trigger("routeDidChange",t)})}transitionDidError(t,n){return t.wasAborted||n.isAborted?Ah(n):(n.trigger(!1,"error",t.error,n,t.route),e._isErrorHandled(t.error)?(n.rollback(),this.routeDidChange(n),t.error):(n.abort(),t.error))}replaceURL(n){t.replaceURL?Ls(()=>{t.replaceURL(n),gr(e,"currentURL",n)}):this.updateURL(n)}},s=this.constructor.dslCallbacks||[Id],o=this._buildDSL();o.route("application",{path:"/",resetNamespace:!0,overrideNameAssertion:!0},function(){for(let t=0;tn.factoryFor(`route-map:${t}`),addRouteForEngine(t,n){e._engineInfoByRoute[t]||(e._engineInfoByRoute[t]=n)}})}_resetQueuedQueryParameterChanges(){this._queuedQPChanges={}}_hasModuleBasedResolver(){let t=ur(Io(this),"application.__registry__.resolver.moduleBasedResolver");return Boolean(t)}startRouting(){if(this.setupRouter()){let t=ur(this,"initialURL");void 0===t&&(t=ur(this,"location").getURL());let e=this.handleURL(t);if(e&&e.error)throw e.error}}setupRouter(){if(this._didSetupRouter)return!1;this._didSetupRouter=!0,this._setupLocation();let t=ur(this,"location");return!ur(t,"cancelRouterSetup")&&(this._initRouterJs(),t.onUpdateURL(t=>{this.handleURL(t)}),!0)}_setOutlets(){if(this.isDestroying||this.isDestroyed)return;let t=this._routerMicrolib.currentRouteInfos;if(!t)return;let e=null,n=null;for(let r of t){let t=Qh(r.route);if(!t)break;{let r={render:t,outlets:{main:void 0}};n?n.outlets.main=r:e=r,n=r}}if(null!==e)if(this._toplevelView)this._toplevelView.setOutletState(e);else{let t=Io(this),n=t.factoryFor("view:-outlet"),r=t.lookup("application:main"),i=t.lookup("-environment:main"),s=t.lookup("template:-outlet");this._toplevelView=n.create({environment:i,template:s,application:r}),this._toplevelView.setOutletState(e),t.lookup("-application-instance:main").didCreateRootView(this._toplevelView)}}handleURL(t){let e=t.split(/#(.+)?/)[0];return this._doURLTransition("handleURL",e)}_doURLTransition(t,e){this._initialTransitionStarted=!0;let n=this._routerMicrolib[t](e||"/");return Bd(n,this),n}transitionTo(...t){if(Vh(t[0]))return this._doURLTransition("transitionTo",t[0]);let{routeName:e,models:n,queryParams:r}=jh(t);return this._doTransition(e,n,r)}intermediateTransitionTo(t,...e){this._routerMicrolib.intermediateTransitionTo(t,...e),Ud(this)}replaceWith(...t){return this.transitionTo(...t).method("replace")}generate(t,...e){let n=this._routerMicrolib.generate(t,...e);return this.location.formatURL(n)}isActive(t){return this._routerMicrolib.isActive(t)}isActiveIntent(t,e,n){return this.currentState.isActiveIntent(t,e,n)}send(t,...e){this._routerMicrolib.trigger(t,...e)}hasRoute(t){return this._routerMicrolib.hasRoute(t)}reset(){this._didSetupRouter=!1,this._initialTransitionStarted=!1,this._routerMicrolib&&this._routerMicrolib.reset()}willDestroy(){this._toplevelView&&(this._toplevelView.destroy(),this._toplevelView=null),super.willDestroy(),this.reset();let t=this._engineInstances;for(let e in t){let n=t[e];for(let t in n)ws(n[t],"destroy")}}_activeQPChanged(t,e){this._queuedQPChanges[t]=e,Ls(this,this._fireQueryParamTransition)}_updatingQPChanged(t){this._qpUpdates.add(t)}_fireQueryParamTransition(){this.transitionTo({queryParams:this._queuedQPChanges}),this._resetQueuedQueryParameterChanges()}_setupLocation(){let t=this.location,e=this.rootURL,n=Io(this);"string"==typeof t&&(t=gr(this,"location",n.lookup(`location:${t}`))),null!==t&&"object"==typeof t&&(e&&gr(t,"rootURL",e),"function"==typeof t.initState&&t.initState())}_serializeQueryParams(t,e){$d(this,t,e,(t,n,r)=>{if(r)delete e[t],e[r.urlKey]=r.route.serializeQueryParam(n,r.urlKey,r.type);else{if(void 0===n)return;e[t]=this._serializeQueryParam(n,Sc(n))}})}_serializeQueryParam(t,e){return null==t?t:"array"===e?JSON.stringify(t):`${t}`}_deserializeQueryParams(t,e){$d(this,t,e,(t,n,r)=>{r&&(delete e[t],e[r.prop]=r.route.deserializeQueryParam(n,r.urlKey,r.type))})}_deserializeQueryParam(t,e){return null==t?t:"boolean"===e?"true"===t:"number"===e?Number(t).valueOf():"array"===e?Zc(JSON.parse(t)):t}_pruneDefaultQueryParamValues(t,e){let n=this._queryParamsFor(t);for(let r in e){let t=n.map[r];t&&t.serializedDefaultValue===e[r]&&delete e[r]}}_doTransition(t,e,n,r){let i=t||function(t){let e=t.activeTransition?t.activeTransition[Th].routeInfos:t.state.routeInfos;return e[e.length-1].name}(this._routerMicrolib);this._initialTransitionStarted=!0;let s={};this._processActiveTransitionQueryParams(i,e,s,n),Object.assign(s,n),this._prepareQueryParams(i,e,s,Boolean(r));let o=this._routerMicrolib.transitionTo(i,...e,{queryParams:s});return Bd(o,this),o}_processActiveTransitionQueryParams(t,e,n,r){if(!this._routerMicrolib.activeTransition)return;let i={},s=this._qpUpdates,o=td(this,this._routerMicrolib.activeTransition[Th]);for(let a in o)s.has(a)||(i[a]=o[a]);this._fullyScopeQueryParams(t,e,r),this._fullyScopeQueryParams(t,e,i),Object.assign(n,i)}_prepareQueryParams(t,e,n,r){let i=jd(this,t,e);this._hydrateUnsuppliedQueryParams(i,n,Boolean(r)),this._serializeQueryParams(i.routeInfos,n),r||this._pruneDefaultQueryParamValues(i.routeInfos,n)}_getQPMeta(t){let e=t.route;return e&&ur(e,"_qp")}_queryParamsFor(t){let e=t[t.length-1].name,n=this._qpCache[e];if(void 0!==n)return n;let r,i=!0,s={},o=[];for(let l of t)if(r=this._getQPMeta(l),r){for(let t of r.qps)o.push(t);Object.assign(s,r.map)}else i=!1;let a={qps:o,map:s};return i&&(this._qpCache[e]=a),a}_fullyScopeQueryParams(t,e,n){let r,i=jd(this,t,e).routeInfos;for(let s of i)if(r=this._getQPMeta(s),r)for(let t of r.qps){let e=t.prop in n&&t.prop||t.scopedPropertyName in n&&t.scopedPropertyName||t.urlKey in n&&t.urlKey;e&&e!==t.scopedPropertyName&&(n[t.scopedPropertyName]=n[e],delete n[e])}}_hydrateUnsuppliedQueryParams(t,e,n){let r,i,s,o=t.routeInfos,a=this._bucketCache;for(let l of o)if(r=this._getQPMeta(l),r)for(let n=0,o=r.qps.length;n=0;--n){let r=t[n],i=r.route;if(void 0!==i&&!0!==e(i,r))return}}var Od={willResolveModel(t,e,n){this._scheduleLoadingEvent(e,n)},error(t,e,n){let r=this,i=t[t.length-1];Ad(t,(t,n)=>{if(n!==i){let n=Fd(t,"error");if(n)return r._markErrorAsHandled(e),r.intermediateTransitionTo(n,e),!1}let s=Nd(t,"error");return!s||(r._markErrorAsHandled(e),r.intermediateTransitionTo(s,e),!1)}),function(t,e){let n,r=[];n=t&&"object"==typeof t&&"object"==typeof t.errorThrown?t.errorThrown:t,e&&r.push(e),n&&(n.message&&r.push(n.message),n.stack&&r.push(n.stack),"string"==typeof n&&r.push(n)),console.error(...r)}(e,`Error while processing route: ${n.targetName}`)},loading(t,e){let n=this,r=t[t.length-1];Ad(t,(t,i)=>{if(i!==r){let e=Fd(t,"loading");if(e)return n.intermediateTransitionTo(e),!1}let s=Nd(t,"loading");return s?(n.intermediateTransitionTo(s),!1):e.pivotHandler!==t})}};function Nd(t,e){let n=Io(t),{routeName:r,fullRouteName:i,_router:s}=t,o=`${i}_${e}`;return Dd(n,s,`${r}_${e}`,o)?o:""}function Fd(t,e){let n=Io(t),{routeName:r,fullRouteName:i,_router:s}=t,o="application"===i?e:`${i}.${e}`;return Dd(n,s,"application"===r?e:`${r}.${e}`,o)?o:""}function Dd(t,e,n,r){let i=e.hasRoute(r),s=t.factoryFor(`template:${n}`)||t.factoryFor(`route:${n}`);return i&&s}function zd(t,e,n,r){if(!t){if(e)return;throw new Error(`Can't trigger action '${n}' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call \`.send()\` on the \`Transition\` object passed to the \`model/beforeModel/afterModel\` hooks.`)}let i,s,o,a=!1;for(let c=t.length-1;c>=0;c--)if(i=t[c],s=i.route,o=s&&s.actions&&s.actions[n],o){if(!0!==o.apply(s,r))return void("error"===n&&s._router._markErrorAsHandled(r[0]));a=!0}let l=Od[n];if(l)l.call(this,t,...r);else if(!a&&!e)throw new Error(`Nothing handled the action '${n}'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.`)}function jd(t,e,n){let r=t._routerMicrolib.applyIntent(e,n),{routeInfos:i,params:s}=r;for(let o of i)o.isResolved?s[o.name]=o.params:s[o.name]=o.serialize(o.context);return r}function Ud(t){let e=t._routerMicrolib.currentRouteInfos;if(0===e.length)return;let n=Md._routePath(e),r=e[e.length-1].name,i=t.location.getURL();gr(t,"currentPath",n),gr(t,"currentRouteName",r),gr(t,"currentURL",i)}function Bd(t,e){let n=new ud(e,e._routerMicrolib,t[Th]);e.currentState||e.set("currentState",n),e.set("targetState",n),t.promise=t.catch(t=>{if(!e._isErrorHandled(t))throw t;e._clearHandledError(t)},"Transition Error")}function $d(t,e,n,r){let i=t._queryParamsFor(e);for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&r(s,n[s],i.map[s])}function qd(t){return void 0!==t.hash?t.hash.substring(0):""}Md.reopen({didTransition:function(){Ud(this),this._cancelSlowTransitionTimer(),this.notifyPropertyChange("url"),this.set("currentState",this.targetState)},willTransition:function(){},rootURL:"/",location:"hash",url:Yn(function(){let t=ur(this,"location");if("string"!=typeof t)return t.getURL()})});var Vd=class extends Ul{_hashchangeHandler;_location;init(){this.location=this._location??window.location,this._hashchangeHandler=void 0}getHash(){return qd(this.location)}getURL(){let t=this.getHash().substring(1),e=t;return"/"!==e[0]&&(e="/",t&&(e+=`#${t}`)),e}setURL(t){this.location.hash=t,this.lastSetURL=t}replaceURL(t){this.location.replace(`#${t}`),this.lastSetURL=t}lastSetURL=null;onUpdateURL(t){this._removeEventListener(),this._hashchangeHandler=xs(this,function(){let e=this.getURL();this.lastSetURL!==e&&(this.lastSetURL=null,t(e))}),window.addEventListener("hashchange",this._hashchangeHandler)}formatURL(t){return`#${t}`}willDestroy(){this._removeEventListener()}_removeEventListener(){this._hashchangeHandler&&window.removeEventListener("hashchange",this._hashchangeHandler)}};function Wd(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let e,n;return e=16*Math.random()|0,n="x"===t?e:3&e|8,n.toString(16)})}var Hd=class extends Ul{history;_popstateHandler;rootURL="/";getHash(){return qd(this.location)}init(){this._super(...arguments);let t=document.querySelector("base"),e="";null!==t&&t.hasAttribute("href")&&(e=t.getAttribute("href")??""),this.baseURL=e,this.location=this.location??window.location,this._popstateHandler=void 0}initState(){let t=this.history??window.history;this.history=t;let{state:e}=t,n=this.formatURL(this.getURL());e&&e.path===n||this.replaceState(n)}getURL(){let{location:t,rootURL:e,baseURL:n}=this,r=t.pathname;e=e.replace(/\/$/,""),n=n.replace(/\/$/,"");let i=r.replace(new RegExp(`^${n}(?=/|$)`),"").replace(new RegExp(`^${e}(?=/|$)`),"").replace(/\/\//g,"/");return i+=(t.search||"")+this.getHash(),i}setURL(t){let{state:e}=this.history;t=this.formatURL(t),e&&e.path===t||this.pushState(t)}replaceURL(t){let{state:e}=this.history;t=this.formatURL(t),e&&e.path===t||this.replaceState(t)}pushState(t){let e={path:t,uuid:Wd()};this.history.pushState(e,"",t)}replaceState(t){let e={path:t,uuid:Wd()};this.history.replaceState(e,"",t)}onUpdateURL(t){this._removeEventListener(),this._popstateHandler=()=>{t(this.getURL())},window.addEventListener("popstate",this._popstateHandler)}formatURL(t){let{rootURL:e,baseURL:n}=this;return""!==t?(e=e.replace(/\/$/,""),n=n.replace(/\/$/,"")):"/"===n[0]&&"/"===e[0]&&(n=n.replace(/\/$/,"")),n+e+t}willDestroy(){this._removeEventListener()}_removeEventListener(){this._popstateHandler&&window.removeEventListener("popstate",this._popstateHandler)}},Gd=class extends Ul{updateCallback;initState(){this._super(...arguments);let{rootURL:t}=this}getURL(){let{path:t,rootURL:e}=this;return e=e.replace(/\/$/,""),t.replace(new RegExp(`^${e}(?=/|$)`),"")}setURL(t){this.path=t}onUpdateURL(t){this.updateCallback=t}handleURL(t){this.path=t,this.updateCallback&&this.updateCallback(t)}formatURL(t){let{rootURL:e}=this;return""!==t&&(e=e.replace(/\/$/,"")),e+t}};function Kd(t,e){return(t,...n)=>{let r=function(t,e){let n=[];function r(t){n.push(t)}for(let i of e)Nn(i,r);return n}(0,[t,...n]);return Yn(...r,function(){let t=r.length-1;for(let n=0;nt),Kd(0,t=>!t);var Yd=/[ _]/g,Xd=new sr(1e3,t=>{return(e=t,rp.get(e)).replace(Yd,"-");var e}),Jd=/^(-|_)+(.)?/,Qd=/(.)(-|_|\.|\s)+(.)?/g,tp=/(^|\/|\.)([a-z])/g,ep=new sr(1e3,t=>{let e=(t,e,n)=>n?`_${n.toUpperCase()}`:"",n=(t,e,n,r)=>e+(r?r.toUpperCase():""),r=t.split("/");for(let i=0;it.toUpperCase())}),np=/([a-z\d])([A-Z])/g,rp=new sr(1e3,t=>t.replace(np,"$1_$2").toLowerCase());function ip(t){return Xd.get(t)}function sp(t){return Object.hasOwnProperty.call(t.since,"enabled")||O._ALL_DEPRECATIONS_ENABLED}var op=parseFloat(O._OVERRIDE_DEPRECATION_VERSION??"7.2.0");function ap(t){return function(t,e=op){let n=t.replace(/(\.0+)/g,"");return e>=parseFloat(n)}(t.until)}function lp(t){return{options:t,test:!sp(t),isEnabled:sp(t)||ap(t),isRemoved:ap(t)}}var cp={DEPRECATE_IMPORT_EMBER:t=>lp({id:`deprecate-import-${ip(t).toLowerCase()}-from-ember`,for:"ember-source",since:{available:"5.10.0",enabled:"6.5.0"},until:"7.0.0",url:`https://deprecations.emberjs.com/id/import-${ip(t).toLowerCase()}-from-ember`}),DEPRECATE_IMPORT_INJECT:lp({for:"ember-source",id:"importing-inject-from-ember-service",since:{available:"6.2.0",enabled:"6.3.0"},until:"7.0.0",url:"https://deprecations.emberjs.com/id/importing-inject-from-ember-service"})},up=a({default:()=>pp,inject:()=>hp,service:()=>dp});function hp(...t){return function(t,e){const{options:n}=e;if(e.isRemoved)throw new Error(`The API deprecated by ${n.id} was removed in ember-source ${n.until}. The message was: Importing \`inject\` from \`@ember/service\` is deprecated. Please import \`service\` instead.. Please see ${n.url} for more details.`)}(0,cp.DEPRECATE_IMPORT_INJECT),$r("service",...t)}function dp(...t){return $r("service",...t)}var pp=class extends Yc{static isServiceFactory=!0},fp=Symbol("ROUTER");function gp(t,e){return"/"===e?t:t.substring(e.length)}var mp=class extends(pp.extend(vc)){[fp];get _router(){let t=this[fp];if(void 0!==t)return t;let e=Ur(this).lookup("router:main");return this[fp]=e}willDestroy(){super.willDestroy(),this[fp]=void 0}transitionTo(...t){if(Vh(t[0]))return this._router._doURLTransition("transitionTo",t[0]);let{routeName:e,models:n,queryParams:r}=jh(t);return this._router._doTransition(e,n,r,!0)}replaceWith(...t){return this.transitionTo(...t).method("replace")}urlFor(t,...e){return this._router.setupRouter(),this._router.generate(t,...e)}isActive(...t){let{routeName:e,models:n,queryParams:r}=jh(t);this._router.setupRouter();let i=this._router._routerMicrolib;if(Nt(Kt(this._router,"currentURL")),!i.isActiveIntent(e,n))return!1;if(Object.keys(r).length>0){let t=e;r=Object.assign({},r),this._router._prepareQueryParams(t,n,r,!0);let s=Object.assign({},i.state.queryParams);return this._router._prepareQueryParams(t,n,s,!0),Wh(r,s)}return!0}recognize(t){this._router.setupRouter();let e=gp(t,this.rootURL);return this._router._routerMicrolib.recognize(e)}recognizeAndLoad(t){this._router.setupRouter();let e=gp(t,this.rootURL);return this._router._routerMicrolib.recognizeAndLoad(e)}refresh(t){if(!t)return this._router._routerMicrolib.refresh();let e=Ur(this).lookup(`route:${t}`);return this._router._routerMicrolib.refresh(e)}static{Gh(this.prototype,"currentRouteName",[Zd("_router.currentRouteName")])}#o=void Zh(this,"currentRouteName");static{Gh(this.prototype,"currentURL",[Zd("_router.currentURL")])}#a=void Zh(this,"currentURL");static{Gh(this.prototype,"location",[Zd("_router.location")])}#l=void Zh(this,"location");static{Gh(this.prototype,"rootURL",[Zd("_router.rootURL")])}#c=void Zh(this,"rootURL");static{Gh(this.prototype,"currentRoute",[Zd("_router.currentRoute")])}#u=void Zh(this,"currentRoute")},yp=class extends pp{[fp];get router(){let t=this[fp];if(void 0!==t)return t;let e=Ur(this).lookup("router:main");return e.setupRouter(),this[fp]=e}hasRoute(t){return this.router.hasRoute(t)}transitionTo(t,e,n,r){let i=this.router._doTransition(t,e,n);return r&&i.method("replace"),i}normalizeQueryParams(t,e,n){this.router._prepareQueryParams(t,e,n)}_generateURL(t,e,n){let r={};return n&&(Object.assign(r,n),this.normalizeQueryParams(t,e,r)),this.router.generate(t,...e,{queryParams:r})}generateURL(t,e,n){if(this.router._initialTransitionStarted)return this._generateURL(t,e,n);try{return this._generateURL(t,e,n)}catch(r){return}}isActiveForRoute(t,e,n,r){let i=this.router._routerMicrolib.recognizer.handlersFor(n),s=i[i.length-1].handler,o=function(t,e){let n=0;for(let r=0;ro&&(n=s),r.isActiveIntent(n,t,e)}};yp.reopen({targetState:Zd("router.targetState"),currentState:Zd("router.currentState"),currentRouteName:Zd("router.currentRouteName"),currentPath:Zd("router.currentPath")});var vp=class{cache;constructor(){this.cache=new Map}has(t){return this.cache.has(t)}stash(t,e,n){let r=this.cache.get(t);void 0===r&&(r=new Map,this.cache.set(t,r)),r.set(e,n)}lookup(t,e,n){if(!this.has(t))return n;let r=this.cache.get(t);return r.has(e)?r.get(e):n}},bp=Mo?self:null,wp=Mo?self.location:null,_p=Mo?self.history:null,xp=Mo?self.navigator.userAgent:"Lynx (textmode)",Cp=!(!Mo||"object"!=typeof chrome||"object"==typeof opera),Sp=!!Mo&&/Firefox|FxiOS/.test(xp),kp=Object.freeze(Object.defineProperty({__proto__:null,hasDOM:Mo,history:_p,isChrome:Cp,isFirefox:Sp,location:wp,userAgent:xp,window:bp},Symbol.toStringTag,{value:"Module"})),Ep=-536870913;function Rp(t){return(t|=0)<0?function(t){return t&Ep}(t):function(t){return~t}(t)}function Tp(t){return(t|=0)>Ep?function(t){return~t}(t):function(t){return 536870912|t}(t)}function Lp(t){if("number"==typeof t)return t;{let e=t.errors[0];throw new Error(`Compile Error: ${e.problem} @ ${e.span.start}..${e.span.end}`)}}function Ip(t){if("error"===t.result)throw new Error(`Compile Error: ${t.problem} @ ${t.span.start}..${t.span.end}`);return t}[1,-1].forEach(t=>Tp(Rp(t)));var Pp=new WeakMap,Mp=Reflect.getPrototypeOf;function Ap(t,e){return Pp.set(e,t),e}function Op(t){let e=t;for(;null!==e;){let t=Pp.get(e);if(void 0!==t)return t;e=Mp(e)}}var Np=Object.assign;function Fp(t){return Object.values(t)}function Dp(t){return Object.entries(t)}function zp(t){return Object.keys(t)}var jp=Object.freeze([]);function Up(){return jp}var Bp=Up(),$p=Up();function qp(t){return t===jp}function*Vp(t){for(let e=t.length-1;e>=0;e--)yield t[e]}function*Wp(t){let e=0;for(const n of t)yield[e++,n]}function*Hp(t,e){for(let n=0;n255)throw new Error(`Opcode type over 8-bits. Got ${t}.`);let r=t|e|arguments.length-2<<8;this.buffer.push(r);for(const i of n)this.buffer.push(i);this.size=this.buffer.length}patch(t,e){if(-1!==this.buffer[t+1])throw new Error("Trying to patch operand in populated slot instead of a reserved slot.");this.buffer[t+1]=e}},Yp=32,Xp=31;function Jp(t){return e=>{if(!function(t){return Array.isArray(t)&&2===t.length}(e))return!1;let n=e[0];return n===Xp||n===Yp||n===t}}var Qp=Jp(39),tf=Jp(38),ef=Jp(37),nf=Jp(35);function rf(t,e,n,r){let{symbols:{upvars:i}}=n,s=i[t[1]],o=e?.lookupBuiltInHelper?.(s)??null;return r.helper(o,s)}var sf=1004,of=1005,af=1010,lf=1e3,cf=1001,uf=1002;function hf(t){return{type:1,value:t}}function df(t){return{type:5,value:t}}function pf(t){return{type:7,value:t}}function ff(t){return{type:8,value:t}}var gf=class{labels=ee();targets=[];label(t,e){this.labels[t]=e}target(t,e){this.targets.push({at:t,target:e})}patch(t){let{targets:e,labels:n}=this;for(const{at:r,target:i}of e){let e=n[i]-r;Kp(t.getbyaddr(r)),t.setbyaddr(r,e)}}};function mf(t,e,n,r){let{program:{constants:i},resolver:s}=e;if(function(t){return t<1e3}(r[0])){let[e,...n]=r;t.push(i,e,...n)}else switch(r[0]){case lf:return t.label(r[1]);case cf:return t.startLabels();case uf:return t.stopLabels();case sf:return function(t,e,n,[,r,i]){if(Qp(r),r[0]===Yp){let{scopeValues:t,owner:s,symbols:{lexical:o}}=n,a=t[r[1]];i(e.component(a,s,!1,o?.at(r[1])))}else{let{symbols:{upvars:s},owner:o}=n,a=s[r[1]],l=t?.lookupComponent?.(a,o)??null;i(e.resolvedComponent(l,a))}}(s,i,n,r);case 1003:return function(t,e,n,[,r,i]){tf(r);let s=r[0];if(s===Yp){let{scopeValues:t,symbols:{lexical:s}}=n,o=t[r[1]];i(e.modifier(o,s?.at(r[1])??void 0))}else if(s===Xp){let{symbols:{upvars:s}}=n,o=s[r[1]],a=t?.lookupBuiltInModifier?.(o)??null;i(e.modifier(a,o))}else{let{symbols:{upvars:s},owner:o}=n,a=s[r[1]],l=t?.lookupModifier?.(a,o)??null;i(e.modifier(l))}}(s,i,n,r);case of:return function(t,e,n,[,r,i]){ef(r);let s=r[0];if(s===Yp){let{scopeValues:t}=n,s=t[r[1]];i(e.helper(s))}else if(s===Xp)i(rf(r,t,n,e));else{let{symbols:{upvars:s},owner:o}=n,a=s[r[1]],l=t?.lookupHelper?.(a,o)??null;i(e.helper(l,a))}}(s,i,n,r);case 1007:return function(t,e,n,[,r,{ifComponent:i,ifHelper:s}]){nf(r);let o=r[0];if(o===Yp){let{scopeValues:t,owner:o,symbols:{lexical:a}}=n,l=t[r[1]],c=e.component(l,o,!0,a?.at(r[1]));if(null!==c)return void i(c);s(e.helper(l,null,!0))}else if(o===Xp)s(rf(r,t,n,e));else{let{symbols:{upvars:o},owner:a}=n,l=o[r[1]],c=t?.lookupComponent?.(l,a)??null;if(null!==c)i(e.resolvedComponent(c,l));else{let n=t?.lookupHelper?.(l,a)??null;s(e.helper(n,l))}}}(s,i,n,r);case 1008:return function(t,e,n,[,r,{ifComponent:i,ifHelper:s,ifValue:o}]){nf(r);let a=r[0];if(a===Yp){let{scopeValues:t,owner:a,symbols:{lexical:l}}=n,c=t[r[1]];if("function"!=typeof c&&("object"!=typeof c||null===c))return void o(e.value(c));let u=e.component(c,a,!0,l?.at(r[1]));if(null!==u)return void i(u);let h=e.helper(c,null,!0);if(null!==h)return void s(h);o(e.value(c))}else if(a===Xp)s(rf(r,t,n,e));else{let{symbols:{upvars:o},owner:a}=n,l=o[r[1]],c=t?.lookupComponent?.(l,a)??null;if(null!==c)return void i(e.resolvedComponent(c,l));let u=t?.lookupHelper?.(l,a)??null;null!==u&&s(e.helper(u,l))}}(s,i,n,r);case af:{let[,t,e]=r;e(n.symbols.upvars[t],n.moduleName);break}case 1011:{let[,t,e]=r,s=n.scopeValues[t];e(i.value(s));break}default:throw new Error(`Unexpected high level opcode ${r[0]}`)}}var yf=class{labelsStack=new ie;encoder=new Zp([]);errors=[];handle;constructor(t,e,n){this.heap=t,this.meta=e,this.stdlib=n,this.handle=t.malloc()}error(t){this.encoder.encode(30,0),this.errors.push(t)}commit(t){let e=this.handle;return this.heap.pushMachine(5),this.heap.finishMalloc(e,t),Jt(this.errors)?{errors:this.errors,handle:e}:e}push(t,e,...n){let{heap:r}=this,i=e|((s=e)>=0&&s<=15?1024:0)|n.length<<8;var s;r.pushRaw(i);for(let o=0;o=-536870912?Rp(n):function(t){return{type:6,value:t}}(n)),t(30,n)}function kf(t,e,n,r){t(0),Af(t,n,r,!1),t(16,e),t(1),t(36,8)}function Ef(t,e,n,r){t(0),Af(t,e,n,!1),t(33,2,1),t(107),r?(t(36,8),r(),t(1),t(34,1)):(t(1),t(34,1),t(36,8))}function Rf(t,e,n,r,i){t(0),Af(t,r,i,!1),t(86),xf(t,n),t(77,e,{type:2,value:void 0}),t(1),t(36,8)}function Tf(t,e,n){Af(t,n,null,!0),t(23,e),t(24),t(61),t(64),t(40),t(1)}function Lf(t,e){!function(t,e){null!==e?t(63,pf({parameters:e})):Sf(t,null)}(t,e&&e[1]),t(62),Mf(t,e)}function If(t,e){t(0),Mf(t,e),t(61),t(2),t(1)}function Pf(t,e,n){let r=e[1],i=r.length,s=Math.min(n,i);if(0!==s){if(t(0),s){t(39);for(let e=0;e{for(let n of e)xf(t,n);t(27,e.length)}),wf.add(28,(t,[,e,n,r])=>{ef(e)?t(of,e,e=>{kf(t,e,n,r)}):(xf(t,e),Ef(t,n,r))}),wf.add(50,(t,[,e,n,r,i])=>{Rf(t,n,e,r,i)}),wf.add(30,(t,[,e,n])=>{t(21,e),_f(t,n)}),wf.add(Yp,(t,[,e,n])=>{t(1011,e,e=>{t(29,e),_f(t,n)})}),wf.add(Xp,(t,e)=>{t(af,e[1],()=>{t(of,e,e=>{kf(t,e,null,null)})})}),wf.add(37,(t,e)=>{t(af,e[1],()=>{t(of,e,e=>{kf(t,e,null,null)})})}),wf.add(27,t=>Cf(t,void 0)),wf.add(48,(t,[,e])=>{xf(t,e),t(25)}),wf.add(49,(t,[,e])=>{xf(t,e),t(24),t(61),t(26)}),wf.add(52,(t,[,e,n,r])=>{xf(t,r),xf(t,n),xf(t,e),t(109)}),wf.add(51,(t,[,e])=>{xf(t,e),t(110)}),wf.add(53,(t,[,e])=>{xf(t,e),t(111)}),wf.add(54,(t,[,e])=>{t(0),Af(t,e,null,!1),t(112),t(1),t(36,8)});var Ff=class t{names;constructor(t){this.blocks=t,this.names=t?Object.keys(t):[]}get(t){return this.blocks&&this.blocks[t]||null}has(t){let{blocks:e}=this;return null!==e&&t in e}with(e,n){let{blocks:r}=this;return new t(r?Np({},r,{[e]:n}):{[e]:n})}get hasAny(){return null!==this.blocks}},Df=new Ff(null);function zf(t){if(null===t)return Df;let e=ee(),[n,r]=t;for(const[i,s]of Wp(n))e[s]=Yt(r[i]);return new Ff(e)}function jf(t,e,n){let r=[],i=0;n(function(t,e){r.push({match:t,callback:e,label:"CLAUSE"+i++})}),t(69,1),e(),t(cf);for(let s of r.slice(0,-1))t(67,hf(s.label),s.match);for(let s=r.length-1;s>=0;s--){let e=Yt(r[s]);t(lf,e.label),t(34,1),e.callback(),0!==s&&t(4,hf("END"))}t(lf,"END"),t(uf),t(70)}function Uf(t,e,n){t(cf),t(0),t(6,hf("ENDINITIAL")),t(69,e()),n(),t(lf,"FINALLY"),t(70),t(5),t(lf,"ENDINITIAL"),t(1),t(uf)}function Bf(t,e,n,r){return Uf(t,e,()=>{t(66,hf("ELSE")),n(),t(4,hf("FINALLY")),t(lf,"ELSE"),void 0!==r&&r()})}var $f="&attrs";function qf(t,e,n,r,i,s){let{compilable:o,capabilities:a,handle:l}=e,c=n?[n,[]]:null,u=zf(s);o?(t(78,l),function(t,{capabilities:e,layout:n,elementBlock:r,positional:i,named:s,blocks:o}){let{symbolTable:a}=n;if(vu(e,pu.prepareArgs))return void Wf(t,{capabilities:e,elementBlock:r,positional:i,named:s,atNames:!0,blocks:o,layout:n});t(36,4),t(33,3,1),t(35,4),t(0);let{symbols:l}=a,c=[],u=[],h=[],d=o.names;if(null!==r){let e=l.indexOf($f);-1!==e&&(Lf(t,r),c.push(e))}for(const p of d){let e=l.indexOf(`&${p}`);-1!==e&&(Lf(t,o.get(p)),c.push(e))}if(vu(e,pu.createArgs)){let e=Of(t,i)<<4;e|=8;let n=Bp;if(null!==s){n=s[0];let e=s[1];for(let r=0;r0?1:0),t(19,0);for(const p of Vp(u))-1===p?t(34,1):t(19,p+1);null!==i&&t(34,i.length);for(const p of Vp(c))t(20,p+1);t(28,ff(n)),t(61),t(2),t(100,4),t(1),t(40),vu(e,pu.dynamicScope)&&t(60),t(98),t(35,4)}(t,{capabilities:a,layout:o,elementBlock:c,positional:r,named:i,blocks:u})):(t(78,l),Wf(t,{capabilities:a,elementBlock:c,positional:r,named:i,atNames:!0,blocks:u}))}function Vf(t,e,n,r,i,s,o,a){let l=n?[n,[]]:null,c=zf(s);Uf(t,()=>(xf(t,e),t(33,3,0),2),()=>{t(66,hf("ELSE")),a?t(81):t(80,{type:2,value:void 0}),t(79),Wf(t,{capabilities:!0,elementBlock:l,positional:r,named:i,atNames:o,blocks:c}),t(lf,"ELSE")})}function Wf(t,{capabilities:e,elementBlock:n,positional:r,named:i,atNames:s,blocks:o,layout:a}){let l=Boolean(o),c=!0===e||vu(e,pu.prepareArgs)||0!==i?.[0].length,u=o.with("attrs",n);t(36,4),t(33,3,1),t(35,4),t(0),function(t,e,n,r,i){let s=r.names;for(const l of s)Lf(t,r.get(l));let o=Of(t,e)<<4;i&&(o|=8),r.hasAny&&(o|=7);let a=jp;if(n){a=n[0];let e=n[1];for(let n=0;n{a?(t(63,pf(a.symbolTable)),t(28,ff(a)),t(61)):t(92,4),t(95,4)}),t(35,4)}function Hf(t,e,n,r,i=null){t(97,4),t(59),t(87,0|e),i&&i(),t(88,4),t(90,4),t(38,4),t(19,0),r&&t(17,4),n&&t(18,4),t(34,1),t(96,4),t(100,4),t(1),t(40),t(60),t(98)}var Gf=new bf,Kf=["class","id","value","name","type","style","href"],Zf=["div","span","p","a"];function Yf(t){return"string"==typeof t?t:Zf[t]}function Xf(t){return"string"==typeof t?t:Kf[t]}function Jf(t){return null===t?null:[t[0].map(t=>`@${t}`),t[1]]}Gf.add(3,(t,e)=>t(42,e[1])),Gf.add(13,t=>t(55)),Gf.add(12,t=>t(54)),Gf.add(4,(t,[,e,n,r])=>{tf(e)?t(1003,e,e=>{t(0),Af(t,n,r,!1),t(57,e),t(1)}):(xf(t,e),t(0),Af(t,n,r,!1),t(33,2,1),t(108),t(1))}),Gf.add(14,(t,[,e,n,r])=>{t(51,Xf(e),n,r??null)}),Gf.add(24,(t,[,e,n,r])=>{t(105,Xf(e),n,r??null)}),Gf.add(15,(t,[,e,n,r])=>{xf(t,n),t(52,Xf(e),!1,r??null)}),Gf.add(22,(t,[,e,n,r])=>{xf(t,n),t(52,Xf(e),!0,r??null)}),Gf.add(16,(t,[,e,n,r])=>{xf(t,n),t(53,Xf(e),!1,r??null)}),Gf.add(23,(t,[,e,n,r])=>{xf(t,n),t(53,Xf(e),!0,r??null)}),Gf.add(10,(t,[,e])=>{t(48,Yf(e))}),Gf.add(11,(t,[,e])=>{t(89),t(48,Yf(e))}),Gf.add(8,(t,[,e,n,r,i])=>{Qp(e)?t(sf,e,e=>{qf(t,e,n,null,r,i)}):Vf(t,e,n,null,r,i,!0,!0)}),Gf.add(18,(t,[,e,n])=>Tf(t,e,n)),Gf.add(17,(t,[,e])=>Tf(t,e,null)),Gf.add(26,(t,[,e,n,r])=>{t(103,function(t,e,n){return{type:3,value:{locals:t,upvars:e,lexical:n}}}(e,n,r))}),Gf.add(1,(t,[,e])=>{if(Array.isArray(e))if(nf(e))t(1008,e,{ifComponent(e){qf(t,e,null,null,null,null)},ifHelper(e){t(0),kf(t,e,null,null),t(3,df("cautious-non-dynamic-append")),t(1)},ifValue(e){t(0),t(29,e),t(3,df("cautious-non-dynamic-append")),t(1)}});else if(28===e[0]){let[,n,r,i]=e;nf(n)?t(1007,n,{ifComponent(e){qf(t,e,null,r,Jf(i),null)},ifHelper(e){t(0),kf(t,e,r,i),t(3,df("cautious-non-dynamic-append")),t(1)}}):jf(t,()=>{xf(t,n),t(106)},e=>{e(0,()=>{t(68),t(81),t(79),Wf(t,{capabilities:!0,elementBlock:null,positional:r,named:i,atNames:!1,blocks:zf(null)})}),e(1,()=>{Ef(t,r,i,()=>{t(3,df("cautious-non-dynamic-append"))})})})}else t(0),xf(t,e),t(3,df("cautious-append")),t(1);else t(41,null==e?"":String(e))}),Gf.add(2,(t,[,e])=>{Array.isArray(e)?(t(0),xf(t,e),t(3,df("trusting-append")),t(1)):t(41,null==e?"":String(e))}),Gf.add(6,(t,[,e,n,r,i])=>{Qp(e)?t(sf,e,e=>{qf(t,e,null,n,Jf(r),i)}):Vf(t,e,null,n,r,i,!1,!1)}),Gf.add(40,(t,[,e,n,r,i])=>{Bf(t,()=>(xf(t,n),void 0===i?Cf(t,void 0):xf(t,i),xf(t,r),t(33,3,0),4),()=>{t(50),If(t,e),t(56)})}),Gf.add(41,(t,[,e,n,r])=>Bf(t,()=>(xf(t,e),t(71),1),()=>{If(t,n)},r?()=>{If(t,r)}:void 0)),Gf.add(42,(t,[,e,n,r,i])=>Uf(t,()=>(n?xf(t,n):Cf(t,null),xf(t,e),2),()=>{t(72,hf("BODY"),hf("ELSE")),t(0),t(33,2,1),t(6,hf("ITER")),t(lf,"ITER"),t(74,hf("BREAK")),t(lf,"BODY"),Pf(t,r,2),t(34,2),t(4,hf("FINALLY")),t(lf,"BREAK"),t(1),t(73),t(4,hf("FINALLY")),t(lf,"ELSE"),i&&If(t,i)})),Gf.add(44,(t,[,e,n])=>{Pf(t,n,Of(t,e))}),Gf.add(45,(t,[,e,n])=>{if(e){let[r,i]=e;Of(t,i),function(t,e,n){t(59),t(58,e),n(),t(60)}(t,r,()=>{If(t,n)})}else If(t,n)}),Gf.add(46,(t,[,e,n,r,i])=>{Qp(e)?t(sf,e,e=>{qf(t,e,null,n,Jf(r),i)}):Vf(t,e,null,n,r,i,!1,!1)});var Qf=class{compiled=new WeakMap;constructor(t,e,n,r="plain block"){this.statements=t,this.meta=e,this.symbolTable=n,this.moduleName=r}compile(t){return function(t,e){if(t.compiled.has(e))return t.compiled.get(e);t.compiled.set(e,-1);let{statements:n,meta:r}=t,i=function(t,e,n){let r=Gf,i=vf(n,e),{encoder:s,evaluation:o}=i;function a(...t){mf(s,o,e,t)}for(const l of t)r.compile(a,l);return i.encoder.commit(e.size)}(n,r,e);return t.compiled.set(e,i),i}(this,t)}},tg=class{symbolTable;compiled=null;attrsBlockNumber;meta;constructor(t,e){this.layout=t,this.moduleName=e;let{block:n}=t,[,r]=n;r=r.slice();let i=r.indexOf($f);this.attrsBlockNumber=-1===i?r.push($f):i+1,this.symbolTable={symbols:r},this.meta=Nf(t)}compile(t){if(null!==this.compiled)return this.compiled;let e=Nf(this.layout),n=vf(t,e),{encoder:r,evaluation:i}=n;var s,o,a;s=function(...t){mf(r,i,e,t)},o=this.layout,a=this.attrsBlockNumber,s(cf),function(t,e,n){t(36,5),n(),t(35,5)}(s,0,()=>{s(91,4),s(31),s(33,3,0)}),s(66,hf("BODY")),s(36,5),s(89),s(49),s(99,4),Tf(s,a,null),s(54),s(lf,"BODY"),If(s,[o.block[0],[]]),s(36,5),s(66,hf("END")),s(55),s(lf,"END"),s(35,5),s(uf);let l=n.encoder.commit(e.size);return"number"!=typeof l||(this.compiled=l),l}},eg=0,ng={cacheHit:0,cacheMiss:0};function rg({id:t,moduleName:e,block:n,scope:r,isStrictMode:i}){let s,o=t||"client-"+eg++,a=null,l=new WeakMap,c=t=>{if(void 0===s&&(s=JSON.parse(n)),void 0===t)return null===a?(ng.cacheMiss++,a=new ig({id:o,block:s,moduleName:e,owner:null,scope:r,isStrictMode:i})):ng.cacheHit++,a;let c=l.get(t);return void 0===c?(ng.cacheMiss++,c=new ig({id:o,block:s,moduleName:e,owner:t,scope:r,isStrictMode:i}),l.set(t,c)):ng.cacheHit++,c};return c.__id=o,c.__meta={moduleName:e},c}var ig=class{result="ok";layout=null;wrappedLayout=null;constructor(t){this.parsedLayout=t}get moduleName(){return this.parsedLayout.moduleName}get id(){return this.parsedLayout.id}get referrer(){return{moduleName:this.parsedLayout.moduleName,owner:this.parsedLayout.owner}}asLayout(){return this.layout?this.layout:this.layout=function(t,e){let[n,r]=t.block;return new Qf(n,Nf(t),{symbols:r},e)}(Np({},this.parsedLayout),this.moduleName)}asWrappedLayout(){return this.wrappedLayout?this.wrappedLayout:this.wrappedLayout=new tg(Np({},this.parsedLayout),this.moduleName)}},sg=class{offset=0;constructor(t){this.heap=t}get size(){return 1+((768&this.heap.getbyaddr(this.offset))>>8)}get isMachine(){return 1024&this.heap.getbyaddr(this.offset)?1:0}get type(){return 255&this.heap.getbyaddr(this.offset)}get op1(){return this.heap.getbyaddr(this.offset+1)}get op2(){return this.heap.getbyaddr(this.offset+2)}get op3(){return this.heap.getbyaddr(this.offset+3)}},og=1048576,ag=class{offset=0;heap;handleTable;handleState;constructor(){this.heap=new Int32Array(og),this.handleTable=[],this.handleState=[]}entries(){return this.offset}pushRaw(t){this.sizeCheck(),this.heap[this.offset++]=t}pushOp(t){this.pushRaw(t)}pushMachine(t){this.pushRaw(1024|t)}sizeCheck(){let{heap:t}=this;if(this.offset===this.heap.length){let e=new Int32Array(t.length+og);e.set(t,0),this.heap=e}}getbyaddr(t){return this.heap[t]}setbyaddr(t,e){this.heap[t]=e}malloc(){return this.handleTable.push(this.offset),this.handleTable.length-1}finishMalloc(t){}size(){return this.offset}getaddr(t){return this.handleTable[t]}sizeof(t){return this.handleTable,-1}free(t){this.handleState[t]=1}compact(){let t=0,{handleTable:e,handleState:n,heap:r}=this;for(let i=0;i[t,e]));helperDefinitionCache=new WeakMap;modifierDefinitionCache=new WeakMap;componentDefinitionCache=new WeakMap;value(t){let e=this.indexMap,n=e.get(t);return void 0===n&&(n=this.values.push(t)-1,e.set(t,n)),n}array(t){if(0===t.length)return dg;let e=new Array(t.length);for(let n=0;nt}helper(t,e=null,n){let r=this.helperDefinitionCache.get(t);if(void 0===r){let e=Ou(t);if(null===e)return this.helperDefinitionCache.set(t,null),null;let n="function"==typeof e?e:e.getHelper(t);r=this.value(n),this.helperDefinitionCache.set(t,r),this.helperDefinitionCount++}return r}modifier(t,e=null,n){let r=this.modifierDefinitionCache.get(t);if(void 0===r){let n=Pu(t);if(null===n)return this.modifierDefinitionCache.set(t,null),null;let i={resolvedName:e,manager:n,state:t};r=this.value(i),this.modifierDefinitionCache.set(t,r),this.modifierDefinitionCount++}return r}component(t,e,n,r){let i=this.componentDefinitionCache.get(t);if(void 0===i){let n=Fu(t);if(null===n)return this.componentDefinitionCache.set(t,null),null;let s,o=gu(n.getCapabilities(t)),a=Op(t),l=null;s=yu(0,o,pu.dynamicLayout)?a?.(e):a?.(e)??this.defaultTemplate,void 0!==s&&(s=Ip(s),l=yu(0,o,pu.wrapped)?s.asWrappedLayout():s.asLayout()),i={resolvedName:null,handle:-1,manager:n,capabilities:o,state:t,compilable:l},i.handle=this.value(i),r&&(i.debugName=r),this.componentDefinitionCache.set(t,i),this.componentDefinitionCount++}return i}resolvedComponent(t,e){let n=this.componentDefinitionCache.get(t);if(void 0===n){let{manager:r,state:i,template:s}=t,o=gu(r.getCapabilities(t)),a=null;yu(0,o,pu.dynamicLayout)||(s=s??this.defaultTemplate),null!==s&&(s=Ip(s),a=yu(0,o,pu.wrapped)?s.asWrappedLayout():s.asLayout()),n={resolvedName:e,handle:-1,manager:r,capabilities:o,state:i,compilable:a},n.handle=this.value(n),this.componentDefinitionCache.set(t,n),this.componentDefinitionCount++}return n}getValue(t){return this.values[t]}getArray(t){let e=this.reifiedArrs,n=e[t];if(void 0===n){let r=this.getValue(t);n=new Array(r.length);for(const[t,e]of Wp(r))n[t]=this.getValue(e);e[t]=n}return n}},fg=class{constructor(t,e){this.element=t,this.nextSibling=e}},gg=class{constructor(t,e,n){this.parentNode=t,this.first=e,this.last=n}parentElement(){return this.parentNode}firstNode(){return this.first}lastNode(){return this.last}};function mg(t,e){let n=t.parentElement(),r=t.firstNode(),i=t.lastNode(),s=r;for(;;){let t=s.nextSibling;if(n.insertBefore(s,e),s===i)return t;s=Xt(t)}}function yg(t){let e=t.parentElement(),n=t.firstNode(),r=t.lastNode(),i=n;for(;;){let t=i.nextSibling;if(e.removeChild(i),i===r)return t;i=Xt(t)}}function vg(t){return bg(t)?"":String(t)}function bg(t){return null==t||"function"!=typeof t.toString}function wg(t){return null!==t&&"object"==typeof t}function _g(t){return wg(t)&&"function"==typeof t.toHTML}function xg(t){return"string"==typeof t}function Cg(t,e){let n,r;if(e in t)r=e,n="prop";else{let i=e.toLowerCase();i in t?(n="prop",r=i):(n="attr",r=e)}return"prop"!==n||"style"!==r.toLowerCase()&&!function(t,e){let n=kg[t.toUpperCase()];return!(!n||!n[e.toLowerCase()])}(t.tagName,r)||(n="attr"),{normalized:r,type:n}}var Sg,kg={INPUT:{form:!0,autocorrect:!0,list:!0},SELECT:{form:!0},OPTION:{form:!0},TEXTAREA:{form:!0},LABEL:{form:!0},FIELDSET:{form:!0},LEGEND:{form:!0},OBJECT:{form:!0},OUTPUT:{form:!0},BUTTON:{form:!0}},Eg="http://www.w3.org/1998/Math/MathML",Rg=["javascript:","vbscript:"],Tg=["A","AREA","BODY","LINK","IMG","IFRAME","BASE","FORM","BUTTON","INPUT"],Lg=["EMBED"],Ig=["IFRAME","OBJECT"],Pg=["href","src","background","action","formaction","xlink:href"],Mg=["src"],Ag=["src","data"];function Og(t,e){return-1!==t.indexOf(e)}function Ng(t,e){return(null===t||Og(Tg,t.toUpperCase()))&&Og(Pg,e)}function Fg(t,e){return null!==t&&Og(Lg,t.toUpperCase())&&Og(Mg,e)}function Dg(t,e){return null!==t&&Og(Ig,t.toUpperCase())&&Og(Ag,e)}function zg(t,e){return Ng(t,e)||Fg(t,e)||Dg(t,e)}function jg(t){return Sg||(Sg=function(){const t=URL;if("object"==typeof t&&null!==t&&"function"==typeof t.parse){let e=t;return t=>{let n=null;return"string"==typeof t&&(n=e.parse(t.replace(/[\t\n\r]/gu,"")).protocol),null===n?":":n}}if("function"==typeof t)return e=>{try{return new t(e).protocol}catch{return":"}};throw new Error('@glimmer/runtime needs a valid "globalThis.URL"')}()),Sg(t)}function Ug(t,e,n){if(null==n)return n;if(_g(n))return n.toHTML();const r=t.tagName;let i=vg(n);if(Ng(r,e)){let t=jg(i);if(Og(Rg,t))return`unsafe:${i}`}if(Dg(r,e)){let t=jg(i);if("data:"===t||Og(Rg,t))return`unsafe:${i}`}return Fg(r,e)?`unsafe:${i}`:i}function Bg(t,e,n){const{tagName:r,namespaceURI:i}=t,s={element:t,name:e,namespace:n};if("http://www.w3.org/2000/svg"===i)return $g(r,e,s);const{type:o,normalized:a}=Cg(t,e);return"attr"===o?$g(r,a,s):function(t,e,n){return zg(t,e)?new Hg(e,n):function(t,e){return("INPUT"===t||"TEXTAREA"===t)&&"value"===e}(t,e)?new Kg(e,n):function(t,e){return"OPTION"===t&&"selected"===e}(t,e)?new Zg(e,n):new Wg(e,n)}(r,a,s)}function $g(t,e,n){return zg(t,e)?new Gg(n):new Vg(n)}var qg=class{constructor(t){this.attribute=t}},Vg=class extends qg{set(t,e,n){const r=Yg(e);if(null!==r){const{name:e,namespace:n}=this.attribute;t.__setAttribute(e,r,n)}}update(t,e){const n=Yg(t),{element:r,name:i}=this.attribute;null===n?r.removeAttribute(i):r.setAttribute(i,n)}},Wg=class extends qg{constructor(t,e){super(e),this.normalizedName=t}value;set(t,e,n){null!=e&&(this.value=e,t.__setProperty(this.normalizedName,e))}update(t,e){const{element:n}=this.attribute;this.value!==t&&(n[this.normalizedName]=this.value=t,null==t&&this.removeAttribute())}removeAttribute(){const{element:t,namespace:e}=this.attribute;e?t.removeAttributeNS(e,this.normalizedName):t.removeAttribute(this.normalizedName)}},Hg=class extends Wg{set(t,e,n){const{element:r,name:i}=this.attribute,s=Ug(r,i,e);super.set(t,s,n)}update(t,e){const{element:n,name:r}=this.attribute,i=Ug(n,r,t);super.update(i,e)}},Gg=class extends Vg{set(t,e,n){const{element:r,name:i}=this.attribute,s=Ug(r,i,e);super.set(t,s,n)}update(t,e){const{element:n,name:r}=this.attribute,i=Ug(n,r,t);super.update(i,e)}},Kg=class extends Wg{set(t,e){const n=vg(e);t.__setProperty("value",n),""===e&&"INPUT"===this.attribute.element.tagName&&t.__setAttribute("value","",null)}update(t){const e=this.attribute.element,n=e.value,r=vg(t);n!==r&&(e.value=r)}},Zg=class extends Wg{set(t,e){null!=e&&!1!==e&&t.__setProperty("selected",!0)}update(t){this.attribute.element.selected=!!t}};function Yg(t){return!1===t||null==t||void 0===t.toString?null:!0===t?"":"function"==typeof t?null:String(t)}var Xg=class{constructor(t){this.node=t}firstNode(){return this.node}},Jg=class{constructor(t){this.node=t}lastNode(){return this.node}},Qg=class{dom;updateOperations;constructing=null;operations=null;env;cursors=new ie;modifierStack=new ie;blockStack=new ie;static forInitialRender(t,e){return new this(t,e.element,e.nextSibling).initialize()}static resume(t,e){let n=new this(t,e.parentElement(),e.reset(t)).initialize();return n.pushBlock(e),n}constructor(t,e,n){this.pushElement(e,n),this.env=t,this.dom=t.getAppendOperations(),this.updateOperations=t.getDOM()}initialize(){return this.pushAppendingBlock(),this}debugBlocks(){return this.blockStack.toArray()}get element(){return this.cursors.current.element}get nextSibling(){return this.cursors.current.nextSibling}get hasBlocks(){return this.blockStack.size>0}block(){return this.blockStack.current}popElement(){this.cursors.pop(),this.cursors.current}pushAppendingBlock(){return this.pushBlock(new tm(this.element))}pushResettableBlock(){return this.pushBlock(new nm(this.element))}pushBlockList(t){return this.pushBlock(new rm(this.element,t))}pushBlock(t,e=!1){let n=this.blockStack.current;return null!==n&&(e||n.didAppendBounds(t)),this.__openBlock(),this.blockStack.push(t),t}popBlock(){return this.block().finalize(this),this.__closeBlock(),this.blockStack.pop()}__openBlock(){}__closeBlock(){}openElement(t){let e=this.__openElement(t);return this.constructing=e,e}__openElement(t){return this.dom.createElement(t,this.element)}flushElement(t){let e=this.element,n=this.constructing;this.__flushElement(e,n),this.constructing=null,this.operations=null,this.pushModifiers(t),this.pushElement(n,null),this.didOpenElement(n)}__flushElement(t,e){this.dom.insertBefore(t,e,this.nextSibling)}closeElement(){return this.willCloseElement(),this.popElement(),this.popModifiers()}pushRemoteElement(t,e,n){return this.__pushRemoteElement(t,e,n)}__pushRemoteElement(t,e,n){if(this.pushElement(t,n),void 0===n)for(;t.lastChild;)t.removeChild(t.lastChild);let r=new em(t);return this.pushBlock(r,!0)}popRemoteElement(){const t=this.popBlock();return this.popElement(),t}pushElement(t,e=null){this.cursors.push(new fg(t,e))}pushModifiers(t){this.modifierStack.push(t)}popModifiers(){return this.modifierStack.pop()}didAppendBounds(t){return this.block().didAppendBounds(t),t}didAppendNode(t){return this.block().didAppendNode(t),t}didOpenElement(t){return this.block().openElement(t),t}willCloseElement(){this.block().closeElement()}appendText(t){return this.didAppendNode(this.__appendText(t))}__appendText(t){let{dom:e,element:n,nextSibling:r}=this,i=e.createTextNode(t);return e.insertBefore(n,i,r),i}__appendNode(t){return this.dom.insertBefore(this.element,t,this.nextSibling),t}__appendFragment(t){let e=t.firstChild;if(e){let n=new gg(this.element,e,t.lastChild);return this.dom.insertBefore(this.element,t,this.nextSibling),n}{const t=this.__appendComment("");return new gg(this.element,t,t)}}__appendHTML(t){return this.dom.insertHTMLBefore(this.element,this.nextSibling,t)}appendDynamicHTML(t){let e=this.trustedContent(t);this.didAppendBounds(e)}appendDynamicText(t){let e=this.untrustedContent(t);return this.didAppendNode(e),e}appendDynamicFragment(t){let e=this.__appendFragment(t);this.didAppendBounds(e)}appendDynamicNode(t){let e=this.__appendNode(t),n=new gg(this.element,e,e);this.didAppendBounds(n)}trustedContent(t){return this.__appendHTML(t)}untrustedContent(t){return this.__appendText(t)}appendComment(t){return this.didAppendNode(this.__appendComment(t))}__appendComment(t){let{dom:e,element:n,nextSibling:r}=this,i=e.createComment(t);return e.insertBefore(n,i,r),i}__setAttribute(t,e,n){this.dom.setAttribute(this.constructing,t,e,n)}__setProperty(t,e){this.constructing[t]=e}setStaticAttribute(t,e,n){this.__setAttribute(t,e,n)}setDynamicAttribute(t,e,n,r){let i=Bg(this.constructing,t,r);return i.set(this,e,this.env),i}},tm=class{first=null;last=null;nesting=0;constructor(t){this.parent=t}parentElement(){return this.parent}firstNode(){return this.first.firstNode()}lastNode(){return this.last.lastNode()}openElement(t){this.didAppendNode(t),this.nesting++}closeElement(){this.nesting--}didAppendNode(t){0===this.nesting&&(this.first||(this.first=new Xg(t)),this.last=new Jg(t))}didAppendBounds(t){0===this.nesting&&(this.first||(this.first=t),this.last=t)}finalize(t){null===this.first&&t.appendComment("")}},em=class extends tm{constructor(t){super(t),tt(this,()=>{this.parentElement()===this.firstNode().parentNode&&yg(this)})}},nm=class extends tm{constructor(t){super(t)}reset(){et(this);let t=yg(this);return this.first=null,this.last=null,this.nesting=0,t}},rm=class{constructor(t,e){this.parent=t,this.boundList=e,this.parent=t,this.boundList=e}parentElement(){return this.parent}firstNode(){return this.boundList[0].firstNode()}lastNode(){let t=this.boundList;return t[t.length-1].lastNode()}openElement(t){}closeElement(){}didAppendNode(t){}didAppendBounds(t){}finalize(t){this.boundList.length}};function im(t,e){return Qg.forInitialRender(t,e)}var sm={foreignObject:1,desc:1,title:1},om=Object.create(null),am=class{constructor(t){this.document=t,this.setupUselessElement()}setupUselessElement(){this.uselessElement=this.document.createElement("div")}createElement(t,e){let n,r,i,s;if(e?(n="http://www.w3.org/2000/svg"===e.namespaceURI||"svg"===t,i=e.namespaceURI===Eg||"math"===t,r=!!sm[e.tagName]):(n="svg"===t,i="math"===t,r=!1),!i&&!n||r)return this.document.createElement(t);if(om[t])throw new Error(`Cannot create a ${t} inside an SVG context`);return s=i?Eg:"http://www.w3.org/2000/svg",this.document.createElementNS(s,t)}insertBefore(t,e,n){t.insertBefore(e,n)}insertHTMLBefore(t,e,n){if(""===n){const n=this.createComment("");return t.insertBefore(n,e),new gg(t,n,n)}const r=e?e.previousSibling:t.lastChild;let i;if(null===e)t.insertAdjacentHTML("beforeend",n),i=t.lastChild;else if(e instanceof HTMLElement)e.insertAdjacentHTML("beforebegin",n),i=e.previousSibling;else{const{uselessElement:r}=this;t.insertBefore(r,e),r.insertAdjacentHTML("beforebegin",n),i=r.previousSibling,t.removeChild(r)}const s=r?r.nextSibling:t.firstChild;return new gg(t,s,i)}createTextNode(t){return this.document.createTextNode(t)}createComment(t){return this.document.createComment(t)}},lm=class extends am{createElementNS(t,e){return this.document.createElementNS(t,e)}setAttribute(t,e,n,r=null){r?t.setAttributeNS(r,e,n):t.setAttribute(e,n)}};function cm(t){return t}function um(t){return"getDebugCustomRenderTree"in t}new class{validate(t){switch(t){case 4:case 5:case 3:case 2:case 1:case 0:case 6:case 7:case 8:return!0;default:return!1}}expected(){return"Register"}};var hm=Symbol("TYPE"),dm=Symbol("INNER"),pm=Symbol("OWNER"),fm=Symbol("ARGS"),gm=Symbol("RESOLVED"),mm=new WeakSet;function ym(t){return mm.has(t)}function vm(t,e){return ym(t)&&t[hm]===e}var bm=class{[hm];[dm];[pm];[fm];[gm];constructor(t,e,n,r,i=!1){mm.add(this),this[hm]=t,this[dm]=e,this[pm]=n,this[fm]=r,this[gm]=i}};function wm(t){let e,n,r,i,s,o=t;for(;;){let{[fm]:t,[dm]:a}=o;if(null!==t){let{named:r,positional:i}=t;i.length>0&&(e=void 0===e?i:i.concat(e)),void 0===n&&(n=[]),n.unshift(r)}if(!ym(a)){r=a,i=o[pm],s=o[gm];break}o=a}return{definition:r,owner:i,resolved:s,positional:e,named:n}}function _m(t,e,n,r,i=!1){return new bm(t,e,n,r,i)}var xm=0,Cm=class{id=xm++;value;constructor(t){this.value=t}get(){return this.value}release(){this.value=null}toString(){let t=`Ref ${this.id}`;if(null===this.value)return`${t} (released)`;try{return`${t}: ${this.value}`}catch{return t}}},Sm=class{stack=new ie;refs=new WeakMap;roots=new Set;nodes=new WeakMap;begin(){this.reset()}create(t,e){let n=Np({},e,{bounds:null,refs:new Set});this.nodes.set(t,n),this.appendChild(n,t),this.enter(t)}update(t){this.enter(t)}didRender(t,e){this.nodeFor(t).bounds=e,this.exit()}willDestroy(t){this.refs.get(t).release()}commit(){this.reset()}capture(){return this.captureRefs(this.roots)}reset(){if(0!==this.stack.size){let t=this.stack.toArray()[0],e=this.refs.get(t);for(void 0!==e&&this.roots.delete(e);!this.stack.isEmpty();)this.stack.pop()}}enter(t){this.stack.push(t)}exit(){this.stack.pop()}nodeFor(t){return this.nodes.get(t)}appendChild(t,e){let n=this.stack.current,r=new Cm(e);if(this.refs.set(e,r),n){let e=this.nodeFor(n);e.refs.add(r),t.parent=e}else this.roots.add(r)}captureRefs(t){let e=[];return t.forEach(n=>{let r=n.get();r?e.push(this.captureNode(`render-node:${n.id}`,r)):t.delete(n)}),e}captureNode(t,e){let n=this.nodeFor(e),{type:r,name:i,args:s,instance:o,refs:a}=n,l=this.captureBounds(n),c=this.captureRefs(a);return{id:t,type:r,name:i,args:iy(s),instance:o,bounds:l,children:c}}captureBounds(t){let e=t.bounds;return{parentElement:e.parentElement(),firstNode:e.firstNode(),lastNode:e.lastNode()}}},km=new class{evaluateOpcode=new Array(113).fill(null);constructor(){}add(t,e,n="syscall"){this.evaluateOpcode[t]={syscall:"machine"!==n,evaluate:e}}evaluate(t,e,n){let r=this.evaluateOpcode[n];r.syscall?(e.isMachine,r.syscall,e.isMachine,e.type,r.evaluate(t,e)):(e.isMachine,r.syscall,e.isMachine,e.type,r.evaluate(t.lowlevel,e))}};km.add(39,t=>t.pushChildScope()),km.add(40,t=>t.popScope()),km.add(59,t=>t.pushDynamicScope()),km.add(60,t=>t.popDynamicScope()),km.add(28,(t,{op1:e})=>{t.stack.push(t.constants.getValue(e))}),km.add(29,(t,{op1:e})=>{t.stack.push(de(t.constants.getValue(e)))}),km.add(30,(t,{op1:e})=>{let n=t.stack;if(e>=0){let r=t.constants.getValue(e);n.push(r)}else n.push(Tp(e))}),km.add(31,t=>{let e,n=t.stack,r=cm(n.pop());e=void 0===r?le:null===r?ce:!0===r?ue:!1===r?he:ae(r),n.push(e)}),km.add(33,(t,{op1:e,op2:n})=>{let r=cm(t.fetchValue(cm(e)))-n;t.stack.dup(r)}),km.add(34,(t,{op1:e})=>{t.stack.pop(e)}),km.add(35,(t,{op1:e})=>{t.load(cm(e))}),km.add(36,(t,{op1:e})=>{t.fetch(cm(e))}),km.add(58,(t,{op1:e})=>{let n=t.constants.getArray(e);t.bindDynamicScope(n)}),km.add(69,(t,{op1:e})=>{t.enter(e)}),km.add(70,t=>{t.exit()}),km.add(63,(t,{op1:e})=>{t.stack.push(t.constants.getValue(e))}),km.add(62,t=>{t.stack.push(t.scope())}),km.add(61,t=>{let e=t.stack,n=e.pop();n?e.push(t.compile(n)):e.push(null)}),km.add(64,t=>{let{stack:e}=t,n=cm(e.pop()),r=cm(e.pop()),i=cm(e.pop()),s=cm(e.pop());if(null===i||null===n)return t.lowlevel.pushFrame(),void t.pushScope(r??t.scope());let o=r;{let t=i.parameters,e=t.length;if(e>0){o=o.child();for(let n=0;n{let n=cm(t.stack.pop()),r=Boolean(we(n));ve(n)?r&&t.lowlevel.goto(e):(r&&t.lowlevel.goto(e),t.updateWith(new Em(n)))}),km.add(66,(t,{op1:e})=>{let n=cm(t.stack.pop()),r=Boolean(we(n));ve(n)?r||t.lowlevel.goto(e):(r||t.lowlevel.goto(e),t.updateWith(new Em(n)))}),km.add(67,(t,{op1:e,op2:n})=>{cm(t.stack.peek())===n&&t.lowlevel.goto(e)}),km.add(68,t=>{let e=cm(t.stack.peek());ve(e)||t.updateWith(new Em(e))}),km.add(71,t=>{let{stack:e}=t,n=cm(e.pop());e.push(fe(()=>U(we(n))))});var Em=class{last;constructor(t){this.ref=t,this.last=we(t)}evaluate(t){let{last:e,ref:n}=this;e!==we(n)&&t.throw()}},Rm=class{last;constructor(t,e){this.ref=t,this.filter=e,this.last=e(we(t))}evaluate(t){let{last:e,ref:n,filter:r}=this;e!==r(we(n))&&t.throw()}},Tm=class{tag=mt;lastRevision=1;target;finalize(t,e){this.target=e,this.didModify(t)}evaluate(t){let{tag:e,target:n,lastRevision:r}=this;!t.alwaysRevalidate&&ct(e,r)&&(Nt(e),t.goto(n))}didModify(t){this.tag=t,this.lastRevision=lt(this.tag),Nt(t)}},Lm=class{constructor(t){this.debugLabel=t}evaluate(){Lt(this.debugLabel)}},Im=class{constructor(t){this.target=t}evaluate(){let t=It();this.target.didModify(t)}};km.add(41,(t,{op1:e})=>{t.tree().appendText(t.constants.getValue(e))}),km.add(42,(t,{op1:e})=>{t.tree().appendComment(t.constants.getValue(e))}),km.add(48,(t,{op1:e})=>{t.tree().openElement(t.constants.getValue(e))}),km.add(49,t=>{let e=cm(we(cm(t.stack.pop())));t.tree().openElement(e)}),km.add(50,t=>{let e=cm(t.stack.pop()),n=cm(t.stack.pop()),r=cm(t.stack.pop()),i=cm(we(e)),s=cm(we(n)),o=we(r);ve(e)||t.updateWith(new Em(e)),void 0===s||ve(n)||t.updateWith(new Em(n));let a=t.tree().pushRemoteElement(i,o,s);if(t.associateDestroyable(a),void 0!==t.env.debugRenderTree){let r=Ym(void 0===s?{}:{insertBefore:n},[e]);t.env.debugRenderTree.create(a,{type:"keyword",name:"in-element",args:r,instance:null}),tt(a,()=>{t.env.debugRenderTree?.willDestroy(a)})}}),km.add(56,t=>{let e=t.tree().popRemoteElement();void 0!==t.env.debugRenderTree&&t.env.debugRenderTree.didRender(e,e)}),km.add(54,t=>{let e=cm(t.fetchValue(6)),n=null;e&&(n=e.flush(t),t.loadValue(6,null)),t.tree().flushElement(n)}),km.add(55,t=>{let e=t.tree().closeElement();null!==e&&e.forEach(e=>{t.env.scheduleInstallModifier(e);const n=e.manager.getDestroyable(e.state);null!==n&&t.associateDestroyable(n)})}),km.add(57,(t,{op1:e})=>{let n=cm(t.stack.pop());if(!t.env.isInteractive)return;let r=t.getOwner(),i=t.constants.getValue(e),{manager:s}=i,{constructing:o}=t.tree(),a=n.capture(),l=s.create(r,o,i.state,a),c={manager:s,state:l,definition:i};cm(t.fetchValue(6)).addModifier(t,c,a);let u=s.getTag(l);return null!==u?(Nt(u),t.updateWith(new Pm(u,c))):void 0}),km.add(108,t=>{let{stack:e}=t,n=cm(e.pop()),r=cm(e.pop());if(!t.env.isInteractive)return;let i=r.capture(),{positional:s,named:o}=i,{constructing:a}=t.tree(),l=t.getOwner(),c=fe(()=>{let t,e,r=we(n);if(!re(r))return;if(vm(r,2)){let{definition:n,owner:a,positional:l,named:c}=wm(r);e=n,t=a,void 0!==l&&(i.positional=l.concat(s)),void 0!==c&&(i.named=Object.assign({},...c,o))}else e=r,t=l;let c=Pu(e);if(null===c)throw new Error("BUG: modifier manager expected");let u={resolvedName:null,manager:c,state:e};return{manager:c,state:c.create(t,a,u.state,i),definition:u}}),u=we(c),h=null;return void 0!==u&&(cm(t.fetchValue(6)).addModifier(t,u,i),h=u.manager.getTag(u.state),null!==h&&Nt(h)),!ve(n)||h?t.updateWith(new Mm(h,u,c)):void 0});var Pm=class{lastUpdated;constructor(t,e){this.tag=t,this.modifier=e,this.lastUpdated=lt(t)}evaluate(t){let{modifier:e,tag:n,lastUpdated:r}=this;Nt(n),ct(n,r)||(t.env.scheduleUpdateModifier(e),this.lastUpdated=lt(n))}},Mm=class{lastUpdated;constructor(t,e,n){this.tag=t,this.instance=e,this.instanceRef=n,this.lastUpdated=lt(t??_t)}evaluate(t){let{tag:e,lastUpdated:n,instance:r,instanceRef:i}=this,s=we(i);if(s!==r){if(void 0!==r){let t=r.manager.getDestroyable(r.state);null!==t&&et(t)}if(void 0!==s){let{manager:n,state:r}=s,i=n.getDestroyable(r);null!==i&&Q(this,i),e=n.getTag(r),null!==e&&(this.lastUpdated=lt(e)),this.tag=e,t.env.scheduleInstallModifier(s)}this.instance=s}else null===e||ct(e,n)||(t.env.scheduleUpdateModifier(r),this.lastUpdated=lt(e));null!==e&&Nt(e)}};km.add(51,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=r?t.constants.getValue(r):null;t.tree().setStaticAttribute(i,s,o)}),km.add(52,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=cm(t.stack.pop()),a=we(o),l=r?t.constants.getValue(r):null,c=t.tree().setDynamicAttribute(i,a,s,l);ve(o)||t.updateWith(new Am(o,c,t.env))});var Am=class{updateRef;constructor(t,e,n){let r=!1;this.updateRef=fe(()=>{let i=we(t);r?e.update(i,n):r=!0}),we(this.updateRef)}evaluate(){we(this.updateRef)}};km.add(78,(t,{op1:e})=>{let n=t.constants.getValue(e),{manager:r,capabilities:i}=n,s={definition:n,manager:r,capabilities:i,state:null,handle:null,table:null,lookup:null};t.stack.push(s)}),km.add(80,(t,{op1:e})=>{let n,r=t.stack,i=cm(we(cm(r.pop()))),s=t.constants,o=t.getOwner();if(s.getValue(e),t.loadValue(7,null),"string"==typeof i){let e=function(t,e,n,r){let i=t?.lookupComponent?.(n,r)??null;return e.resolvedComponent(i,n)}(t.context.resolver,s,i,o);n=e}else n=ym(i)?i:s.component(i,o);r.push(n)}),km.add(81,t=>{let e,n=t.stack,r=we(cm(n.pop())),i=t.constants;e=ym(r)?r:i.component(r,t.getOwner(),!0),n.push(e)}),km.add(79,t=>{let e,n,{stack:r}=t,i=r.pop();ym(i)?n=e=null:(n=i.manager,e=i.capabilities),r.push({definition:i,capabilities:e,manager:n,state:null,handle:null,table:null})}),km.add(82,(t,{op1:e,op2:n,op3:r})=>{let i=t.stack,s=t.constants.getArray(e),o=r>>4,a=8&r,l=7&r?t.constants.getArray(n):Bp;t.args.setup(i,s,l,o,!!a),i.push(t.args)}),km.add(83,t=>{let{stack:e}=t;e.push(t.args.empty(e))}),km.add(86,t=>{let e=t.stack,n=cm(e.pop()).capture();e.push(n)}),km.add(85,(t,{op1:e})=>{let n=t.stack,r=t.fetchValue(cm(e)),i=cm(n.pop()),{definition:s}=r;if(vm(s,0)){s.manager;let e=t.constants,{definition:n,owner:o,resolved:a,positional:l,named:c}=wm(s);if(a)s=n;else if("string"==typeof n){let r=t.context.resolver?.lookupComponent?.(n,o)??null;s=e.resolvedComponent(r,n)}else s=e.component(n,o);void 0!==c&&i.named.merge(Np({},...c)),void 0!==l&&(i.realloc(l.length),i.positional.prepend(l));let{manager:u}=s;r.definition=s,r.manager=u,r.capabilities=s.capabilities,t.loadValue(7,o)}let{manager:o,state:a}=s;if(!yu(0,r.capabilities,pu.prepareArgs))return void n.push(i);let l=i.blocks.values,c=i.blocks.names,u=o.prepareArgs(a,i);if(u){i.clear();for(let i=0;i{let n=cm(t.fetchValue(4)),{definition:r,manager:i,capabilities:s}=n;if(!yu(0,s,pu.createInstance))return;let o=null;yu(0,s,pu.dynamicScope)&&(o=t.dynamicScope());let a=1&e,l=null;yu(0,s,pu.createArgs)&&(l=cm(t.stack.peek()));let c=null;yu(0,s,pu.createCaller)&&(c=t.getSelf());let u=i.create(t.getOwner(),r.state,l,t.env,o,c,!!a);n.state=u,yu(0,s,pu.updateHook)&&t.updateWith(new zm(u,i,o))}),km.add(88,(t,{op1:e})=>{let{manager:n,state:r,capabilities:i}=cm(t.fetchValue(cm(e))),s=n.getDestroyable(r);s&&t.associateDestroyable(s)}),km.add(97,(t,{op1:e})=>{t.beginCacheGroup(void 0),t.tree().pushAppendingBlock()}),km.add(89,t=>{t.loadValue(6,new Om)}),km.add(53,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=cm(t.stack.pop()),a=r?t.constants.getValue(r):null;cm(t.fetchValue(6)).setAttribute(i,o,s,a)}),km.add(105,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=r?t.constants.getValue(r):null;cm(t.fetchValue(6)).setStaticAttribute(i,s,o)});var Om=class{attributes=ee();classes=[];modifiers=[];setAttribute(t,e,n,r){let i={value:e,namespace:r,trusting:n};"class"===t&&this.classes.push(e),this.attributes[t]=i}setStaticAttribute(t,e,n){let r={value:e,namespace:n};"class"===t&&this.classes.push(e),this.attributes[t]=r}addModifier(t,e,n){if(this.modifiers.push(e),void 0!==t.env.debugRenderTree){const{manager:r,definition:i,state:s}=e;if(null===s||"object"!=typeof s&&"function"!=typeof s)return;let{element:o,constructing:a}=t.tree(),l=i.resolvedName??r.getDebugName(i.state),c=r.getDebugInstance(s),u=new gg(o,a,a);t.env.debugRenderTree.create(s,{type:"modifier",name:l,args:n,instance:c}),t.env.debugRenderTree.didRender(s,u),t.associateDestroyable(s),t.updateWith(new Um(s)),t.updateWith(new Bm(s,u)),tt(s,()=>{t.env.debugRenderTree?.willDestroy(s)})}}flush(t){let e,n=this.attributes;for(let r in this.attributes){if("type"===r){e=n[r];continue}let i=Yt(this.attributes[r]);"class"===r?Fm(t,"class",Nm(this.classes),i.namespace,i.trusting):Fm(t,r,i.value,i.namespace,i.trusting)}return void 0!==e&&Fm(t,"type",e.value,e.namespace,e.trusting),this.modifiers}};function Nm(t){return 0===t.length?"":1===t.length?t[0]:function(t){return t.every(t=>"string"==typeof t)}(t)?t.join(" "):(e=t,fe(()=>{let t=[];for(const n of e){let e=vg("string"==typeof n?n:we(n));e&&t.push(e)}return 0===t.length?null:t.join(" ")}));var e}function Fm(t,e,n,r,i=!1){if("string"==typeof n)t.tree().setStaticAttribute(e,n,r);else{let s=t.tree().setDynamicAttribute(e,we(n),i,r);ve(n)||t.updateWith(new Am(n,s,t.env))}}function Dm(t,e,n,r,i){let s=n.table.symbols.indexOf(t),o=r.get(e);-1!==s&&i.scope().bindBlock(s+1,o),n.lookup&&(n.lookup[t]=o)}km.add(99,(t,{op1:e})=>{let{definition:n,state:r}=cm(t.fetchValue(cm(e))),{manager:i}=n,s=cm(t.fetchValue(6));i.didCreateElement(r,t.tree().constructing,s)}),km.add(90,(t,{op1:e,op2:n})=>{let{definition:r,state:i}=cm(t.fetchValue(cm(e))),{manager:s}=r,o=s.getSelf(i);if(void 0!==t.env.debugRenderTree){let r,s=cm(t.fetchValue(cm(e))),{definition:a,manager:l}=s;if(t.stack.peek()===t.args)r=t.args.capture();else{let e=t.constants.getArray(n);t.args.setup(t.stack,e,[],0,!0),r=t.args.capture()}let c=a.compilable;if(null===c){yu(0,s.capabilities,pu.dynamicLayout);let e=t.context.resolver;c=null===e?null:l.getDynamicLayout(i,e)}if(t.associateDestroyable(s),um(l))l.getDebugCustomRenderTree(s.definition.state,s.state,r).forEach(e=>{let{bucket:n}=e;t.env.debugRenderTree.create(n,e),tt(s,()=>{t.env.debugRenderTree?.willDestroy(n)}),t.updateWith(new Um(n))});else{let e=function(t,e=t.manager){return t.resolvedName??t.debugName??e.getDebugName(t.state)}(a,l);t.env.debugRenderTree.create(s,{type:"component",name:e,args:r,instance:we(o)}),tt(s,()=>{t.env.debugRenderTree?.willDestroy(s)}),t.updateWith(new Um(s))}}t.stack.push(o)}),km.add(91,(t,{op1:e})=>{let{definition:n,state:r}=cm(t.fetchValue(cm(e))),{manager:i}=n,s=i.getTagName(r);t.stack.push(s)}),km.add(92,(t,{op1:e})=>{let n=cm(t.fetchValue(cm(e))),{manager:r,definition:i}=n,{stack:s}=t,{compilable:o}=i;if(null===o){let{capabilities:e}=n;yu(0,e,pu.dynamicLayout);let i=t.context.resolver;o=null===i?null:r.getDynamicLayout(n.state,i),null===o&&(o=yu(0,e,pu.wrapped)?Ip(t.constants.defaultTemplate).asWrappedLayout():Ip(t.constants.defaultTemplate).asLayout())}let a=o.compile(t.context);s.push(o.symbolTable),s.push(a)}),km.add(75,(t,{op1:e})=>{let n=cm(t.stack.pop()),r=cm(t.stack.pop()),{manager:i,capabilities:s}=n,o={definition:n,manager:i,capabilities:s,state:null,handle:r.handle,table:r.symbolTable,lookup:null};t.loadValue(cm(e),o)}),km.add(95,(t,{op1:e})=>{let{stack:n}=t,r=cm(n.pop()),i=cm(n.pop()),s=cm(t.fetchValue(cm(e)));s.handle=r,s.table=i}),km.add(38,(t,{op1:e})=>{let n,{table:r,manager:i,capabilities:s,state:o}=cm(t.fetchValue(cm(e)));yu(0,s,pu.hasSubOwner)?(n=i.getOwner(o),t.loadValue(7,null)):(n=t.fetchValue(7),null===n?n=t.getOwner():t.loadValue(7,null)),t.pushRootScope(r.symbols.length+1,n)}),km.add(17,(t,{op1:e})=>{let n=cm(t.fetchValue(cm(e))),r=t.scope(),i=cm(t.stack.peek()),s=i.named.atNames;for(let o=s.length-1;o>=0;o--){let t=Yt(s[o]),e=n.table.symbols.indexOf(t),a=i.named.get(t,!0);-1!==e&&r.bindSymbol(e+1,a),n.lookup&&(n.lookup[t]=a)}}),km.add(18,(t,{op1:e})=>{let n=cm(t.fetchValue(cm(e))),{blocks:r}=cm(t.stack.peek());for(const[i]of Wp(r.names))Dm(Yt(r.symbolNames[i]),Yt(r.names[i]),n,r,t)}),km.add(96,(t,{op1:e})=>{let n=cm(t.fetchValue(cm(e)));t.call(n.handle)}),km.add(100,(t,{op1:e})=>{let n=cm(t.fetchValue(cm(e))),{manager:r,state:i,capabilities:s}=n,o=t.tree().popBlock();void 0!==t.env.debugRenderTree&&(um(r)?r.getDebugCustomRenderTree(n.definition.state,i,ay).reverse().forEach(e=>{let{bucket:n}=e;t.env.debugRenderTree.didRender(n,o),t.updateWith(new Bm(n,o))}):(t.env.debugRenderTree.didRender(n,o),t.updateWith(new Bm(n,o)))),yu(0,s,pu.createInstance)&&(cm(r).didRenderLayout(i,o),t.env.didCreate(n),t.updateWith(new jm(n,o)))}),km.add(98,t=>{t.commitCacheGroup()});var zm=class{constructor(t,e,n){this.component=t,this.manager=e,this.dynamicScope=n}evaluate(t){let{component:e,manager:n,dynamicScope:r}=this;n.update(e,r)}},jm=class{constructor(t,e){this.component=t,this.bounds=e}evaluate(t){let{component:e,bounds:n}=this,{manager:r,state:i}=e;r.didUpdateLayout(i,n),t.env.didUpdate(e)}},Um=class{constructor(t){this.bucket=t}evaluate(t){t.env.debugRenderTree?.update(this.bucket)}},Bm=class{constructor(t,e){this.bucket=t,this.bounds=e}evaluate(t){t.env.debugRenderTree?.didRender(this.bucket,this.bounds)}},$m=(new class{validate(t){return"object"==typeof t&&null!==t&&se in t}expected(){return"Reference"}},class{stack=null;positional=new Vm;named=new Wm;blocks=new Km;constructor(){}empty(t){let e=t.registers[3]+1;return this.named.empty(t,e),this.positional.empty(t,e),this.blocks.empty(t,e),this}setup(t,e,n,r,i){this.stack=t;let s=this.named,o=e.length,a=t.registers[3]-o+1;s.setup(t,a,o,e,i);let l=a-r;this.positional.setup(t,l,r);let c=this.blocks,u=n.length,h=l-3*u;c.setup(t,h,u,n)}get base(){return this.blocks.base}get length(){return this.positional.length+this.named.length+3*this.blocks.length}at(t){return this.positional.at(t)}realloc(t){let{stack:e}=this;if(t>0&&null!==e){let{positional:n,named:r}=this,i=n.base+t;for(let t=n.length+r.length-1;t>=0;t--)e.copy(t+n.base,t+i);n.base+=t,r.base+=t,e.registers[3]+=t}}capture(){let t=0===this.positional.length?oy:this.positional.capture();return{named:0===this.named.length?sy:this.named.capture(),positional:t}}clear(){let{stack:t,length:e}=this;e>0&&null!==t&&t.pop(e)}}),qm=Up(),Vm=class{base=0;length=0;stack=null;_references=null;constructor(){}empty(t,e){this.stack=t,this.base=e,this.length=0,this._references=qm}setup(t,e,n){this.stack=t,this.base=e,this.length=n,this._references=0===n?qm:null}at(t){let{base:e,length:n,stack:r}=this;return t<0||t>=n?le:cm(r.get(t,e))}capture(){return this.references}prepend(t){let e=t.length;if(e>0){let{base:n,length:r,stack:i}=this;this.base=n-=e,this.length=r+e;for(let s=0;s0){let{names:n,length:r,stack:i}=this,s=n.slice();for(const o of e)-1===s.indexOf(o)&&(r=s.push(o),i.push(t[o]));this.length=r,this._references=null,this._names=s,this._atNames=null}}get references(){let t=this._references;if(!t){let{base:e,length:n,stack:r}=this;t=this._references=r.slice(e,e+n)}return t}toSyntheticName(t){return t.slice(1)}toAtName(t){return`@${t}`}};function Hm(t){return`&${t}`}var Gm=Up(),Km=class{internalValues=null;_symbolNames=null;internalTag=null;names=Bp;length=0;base=0;constructor(){}empty(t,e){this.stack=t,this.names=Bp,this.base=e,this.length=0,this._symbolNames=null,this.internalTag=mt,this.internalValues=Gm}setup(t,e,n,r){this.stack=t,this.names=r,this.base=e,this.length=n,this._symbolNames=null,0===n?(this.internalTag=mt,this.internalValues=Gm):(this.internalTag=null,this.internalValues=null)}get values(){let t=this.internalValues;if(!t){let{base:e,length:n,stack:r}=this;t=this.internalValues=r.slice(e,e+3*n)}return t}has(t){return-1!==this.names.indexOf(t)}get(t){let e=this.names.indexOf(t);if(-1===e)return null;let{base:n,stack:r}=this,i=cm(r.get(3*e,n)),s=cm(r.get(3*e+1,n)),o=cm(r.get(3*e+2,n));return null===o?null:[o,s,i]}capture(){return new Zm(this.names,this.values)}get symbolNames(){let t=this._symbolNames;return null===t&&(t=this._symbolNames=this.names.map(Hm)),t}},Zm=class{length;constructor(t,e){this.names=t,this.values=e,this.length=t.length}has(t){return-1!==this.names.indexOf(t)}get(t){let e=this.names.indexOf(t);return-1===e?null:[this.values[3*e+2],this.values[3*e+1],this.values[3*e]]}};function Ym(t,e){return{named:t,positional:e}}function Xm(t){let e=ee();for(const[n,r]of Object.entries(t))e[n]=we(r);return e}function Jm(t){return t.map(we)}function Qm(t){return{named:Xm(t.named),positional:Jm(t.positional)}}var ty=Symbol("ARGUMENT_ERROR");function ey(t){return null!==t&&"object"==typeof t&&t[ty]}function ny(t){return{[ty]:!0,error:t}}function ry(t){let e=ee();for(const[r,i]of Object.entries(t))try{e[r]=we(i)}catch(n){e[r]=ny(n)}return e}function iy(t){return{named:ry(t.named),positional:(e=t.positional,e.map(t=>{try{return we(t)}catch(e){return ny(e)}}))};var e}var sy=Object.freeze(Object.create(null)),oy=qm,ay=Ym(sy,oy),ly=a({FALSE_REFERENCE:()=>he,NULL_REFERENCE:()=>ce,REFERENCE:()=>se,TRUE_REFERENCE:()=>ue,UNDEFINED_REFERENCE:()=>le,childRefFor:()=>xe,childRefFromParts:()=>Ce,createComputeRef:()=>fe,createConstRef:()=>de,createDebugAliasRef:()=>{},createInvokableRef:()=>ye,createIteratorItemRef:()=>yy,createIteratorRef:()=>my,createPrimitiveRef:()=>ae,createReadOnlyRef:()=>ge,createUnboundRef:()=>pe,isConstRef:()=>ve,isInvokableRef:()=>me,isUpdatableRef:()=>be,updateRef:()=>_e,valueForRef:()=>we}),cy={},uy=(t,e)=>e,hy=(t,e)=>String(e),dy=t=>null===t?cy:t,py=class{_weakMap;_primitiveMap;get weakMap(){return void 0===this._weakMap&&(this._weakMap=new WeakMap),this._weakMap}get primitiveMap(){return void 0===this._primitiveMap&&(this._primitiveMap=new Map),this._primitiveMap}set(t,e){re(t)?this.weakMap.set(t,e):this.primitiveMap.set(t,e)}get(t){return re(t)?this.weakMap.get(t):this.primitiveMap.get(t)}},fy=new py;function gy(t){let e=new py;return(n,r)=>{let i=t(n,r),s=e.get(i)||0;return e.set(i,s+1),0===s?i:function(t,e){let n=fy.get(t);void 0===n&&(n=[],fy.set(t,n));let r=n[e];return void 0===r&&(r={value:t,count:e},n[e]=r),r}(i,s)}}function my(t,e){return fe(()=>{let n=we(t),r=function(t){switch(t){case"@key":return gy(uy);case"@index":return gy(hy);case"@identity":return gy(dy);default:return e=t,gy(t=>null==t?t:q(t,e))}var e}(e);if(Array.isArray(n))return new by(n,r);let i=j(n);return null===i?new by(jp,()=>null):new vy(i,r)})}function yy(t){let e=t,n=ft();return fe(()=>(Nt(n),e),t=>{e!==t&&(e=t,dt(n))})}var vy=class{constructor(t,e){this.inner=t,this.keyFor=e}isEmpty(){return this.inner.isEmpty()}next(){let t=this.inner.next();return null!==t&&(t.key=this.keyFor(t.value,t.memo)),t}},by=class{current;pos=0;constructor(t,e){this.iterator=t,this.keyFor=e,0===t.length?this.current={kind:"empty"}:this.current={kind:"first",value:t[this.pos]}}isEmpty(){return"empty"===this.current.kind}next(){let t,e=this.current;if("first"===e.kind)this.current={kind:"progress"},t=e.value;else{if(this.pos>=this.iterator.length-1)return null;t=this.iterator[++this.pos]}let{keyFor:n}=this;return{key:n(t,this.pos),value:t,memo:this.pos}}},wy=class t{bucket;constructor(t){this.bucket=t?Np({},t):{}}get(t){return this.bucket[t]}set(t,e){return this.bucket[t]=e}child(){return new t(this.bucket)}},_y=class t{static root(e,{self:n,size:r=0}){let i=new Array(r+1).fill(le);return new t(e,i,null).init({self:n})}static sized(e,n=0){let r=new Array(n+1).fill(le);return new t(e,r,null)}owner;slots;callerScope;constructor(t,e,n){this.owner=t,this.slots=e,this.callerScope=n}init({self:t}){return this.slots[0]=t,this}snapshot(){return this.slots.slice()}getSelf(){return this.get(0)}getSymbol(t){return this.get(t)}getBlock(t){let e=this.get(t);return e===le?null:e}bind(t,e){this.set(t,e)}bindSelf(t){this.set(0,t)}bindSymbol(t,e){this.set(t,e)}bindBlock(t,e){this.set(t,e)}bindCallerScope(t){this.callerScope=t}getCallerScope(){return this.callerScope}child(){return new t(this.owner,this.slots.slice(),this.callerScope)}get(t){if(t>=this.slots.length)throw new RangeError(`BUG: cannot get $${t} from scope; length=${this.slots.length}`);return this.slots[t]}set(t,e){if(t>=this.slots.length)throw new RangeError(`BUG: cannot get $${t} from scope; length=${this.slots.length}`);this.slots[t]=e}};["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach(t=>om[t]=1);var xy=/[\t\n\v\f\r \xa0\u{1680}\u{180e}\u{2000}-\u{200a}\u{2028}\u{2029}\u{202f}\u{205f}\u{3000}\u{feff}]/u;function Cy(t){return xy.test(t)}var Sy=class extends am{namespace;constructor(t){super(t),this.document=t,this.namespace=null}setAttribute(t,e,n){t.setAttribute(e,n)}removeAttribute(t,e){t.removeAttribute(e)}insertAfter(t,e,n){this.insertBefore(t,e,n.nextSibling)}},ky=Sy,Ey=Symbol("TRANSACTION"),Ry=class{scheduledInstallModifiers=[];scheduledUpdateModifiers=[];createdComponents=[];updatedComponents=[];didCreate(t){this.createdComponents.push(t)}didUpdate(t){this.updatedComponents.push(t)}scheduleInstallModifier(t){this.scheduledInstallModifiers.push(t)}scheduleUpdateModifier(t){this.scheduledUpdateModifiers.push(t)}commit(){let{createdComponents:t,updatedComponents:e}=this;for(const{manager:i,state:s}of t)i.didCreate(s);for(const{manager:i,state:s}of e)i.didUpdate(s);let{scheduledInstallModifiers:n,scheduledUpdateModifiers:r}=this;for(const{manager:i,state:s,definition:o}of n){let t=i.getTag(s);if(null!==t){let e=qt(()=>i.install(s));pt(t,e)}else i.install(s)}for(const{manager:i,state:s,definition:o}of r){let t=i.getTag(s);if(null!==t){let e=qt(()=>i.update(s));pt(t,e)}else i.update(s)}}},Ty=class{[Ey]=null;updateOperations;isInteractive;isArgumentCaptureError;debugRenderTree;constructor(t,e){this.delegate=e,this.isInteractive=e.isInteractive,this.debugRenderTree=this.delegate.enableDebugTooling?new Sm:void 0,this.isArgumentCaptureError=this.delegate.enableDebugTooling?ey:void 0,t.appendOperations?(this.appendOperations=t.appendOperations,this.updateOperations=t.updateOperations):t.document&&(this.appendOperations=new lm(t.document),this.updateOperations=new Sy(t.document))}getAppendOperations(){return this.appendOperations}getDOM(){return this.updateOperations}begin(){this[Ey],this.debugRenderTree?.begin(),this[Ey]=new Ry}get transaction(){return this[Ey]}didCreate(t){this.transaction.didCreate(t)}didUpdate(t){this.transaction.didUpdate(t)}scheduleInstallModifier(t){this.isInteractive&&this.transaction.scheduleInstallModifier(t)}scheduleUpdateModifier(t){this.isInteractive&&this.transaction.scheduleUpdateModifier(t)}commit(){let t=this.transaction;this[Ey]=null,t.commit(),this.debugRenderTree?.commit(),this.delegate.onTransactionCommit()}};function Ly(t,e,n,r){return{env:new Ty(t,e),program:new lg(n.constants,n.heap),resolver:r}}function Iy(t,e){if(t[Ey])e();else{t.begin();try{e()}finally{t.commit()}}}function Py(t){return"string"==typeof t?t:"function"!=typeof t.toString?"":String(t)}function My(t){let e,n=Ou(t);return e=null===n?null:"function"==typeof n?n:n.getHelper(t),e}function Ay(t){return t===le}km.add(77,(t,{op1:e,op2:n})=>{let r=t.stack,i=r.pop(),s=r.pop(),o=t.getOwner();t.context.resolver,t.loadValue(8,function(t,e,n,r){let i,s;return fe(()=>{let o=we(e);return o===i||(s=vm(o,t)?r?_m(t,o,n,r):r:0===t&&"string"==typeof o&&o||re(o)?_m(t,o,n,r):null,i=o),s})}(e,i,o,s))}),km.add(107,t=>{let e,n=t.stack,r=n.pop(),i=n.pop().capture(),s=t.getOwner(),o=fe(()=>{void 0!==e&&et(e);let t=we(r);if(vm(t,1)){let{definition:n,owner:r,positional:s,named:a}=wm(t),l=My(n);void 0!==a&&(i.named=Np({},...a,i.named)),void 0!==s&&(i.positional=s.concat(i.positional)),e=l(i,r),Q(o,e)}else re(t)?(e=My(t)(i,s),nt(e)&&Q(o,e)):e=le}),a=fe(()=>(we(o),we(e)));t.associateDestroyable(o),t.loadValue(8,a)}),km.add(16,(t,{op1:e})=>{let n=t.stack,r=t.constants.getValue(e)(n.pop().capture(),t.getOwner(),t.dynamicScope());nt(r)&&t.associateDestroyable(r),t.loadValue(8,r)}),km.add(21,(t,{op1:e})=>{let n=t.referenceForSymbol(e);t.stack.push(n)}),km.add(19,(t,{op1:e})=>{let n=t.stack.pop();t.scope().bindSymbol(e,n)}),km.add(20,(t,{op1:e})=>{let n=t.stack.pop(),r=t.stack.pop(),i=t.stack.pop();t.scope().bindBlock(e,[n,r,i])}),km.add(37,(t,{op1:e})=>{t.pushRootScope(e,t.getOwner())}),km.add(22,(t,{op1:e})=>{let n=t.constants.getValue(e),r=t.stack.pop();t.stack.push(xe(r,n))}),km.add(23,(t,{op1:e})=>{let{stack:n}=t,r=t.scope().getBlock(e);n.push(r)}),km.add(24,t=>{let{stack:e}=t,n=e.pop();if(n&&!Ay(n)){let[t,r,i]=n;e.push(i),e.push(r),e.push(t)}else e.push(null),e.push(null),e.push(null)}),km.add(25,t=>{let{stack:e}=t,n=e.pop();n&&!Ay(n)?e.push(ue):e.push(he)}),km.add(26,t=>{t.stack.pop(),t.stack.pop();let e=t.stack.pop(),n=e&&e.parameters.length;t.stack.push(n?ue:he)}),km.add(27,(t,{op1:e})=>{let n=new Array(e);for(let i=e;i>0;i--)n[i-1]=cm(t.stack.pop());var r;t.stack.push((r=n,fe(()=>{const t=[];for(const e of r){const n=we(e);null!=n&&t.push(Py(n))}return t.length>0?t.join(""):null})))}),km.add(109,t=>{let e=t.stack.pop(),n=t.stack.pop(),r=t.stack.pop();t.stack.push(fe(()=>U(we(e))?we(n):we(r)))}),km.add(110,t=>{let e=t.stack.pop();t.stack.push(fe(()=>!U(we(e))))}),km.add(111,t=>{let e=t.dynamicScope(),n=t.stack,r=n.pop();n.push(fe(()=>{let t=String(we(r));return we(e.get(t))}))}),km.add(112,t=>{let{positional:e}=t.stack.pop().capture();t.loadValue(8,fe(()=>{console.log(...Jm(e))}))});var Oy=class{constructor(t,e,n){this.node=t,this.reference=e,this.lastValue=n}evaluate(){let t,e=we(this.reference),{lastValue:n}=this;e!==n&&(t=bg(e)?"":xg(e)?e:String(e),t!==n)&&(this.node.nodeValue=this.lastValue=t)}};function Ny(t){return function(t){return xg(t)||bg(t)||"boolean"==typeof t||"number"==typeof t}(t)?2:vm(t,0)||Du(t)?0:vm(t,1)||zu(t)?1:_g(t)?4:function(t){return wg(t)&&11===t.nodeType}(t)?5:function(t){return wg(t)&&"number"==typeof t.nodeType}(t)?6:2}function Fy(t){return re(t)?vm(t,0)||Du(t)?0:1:2}function Dy(t,e){console.info("Use `context`, and `get()` to debug this template."),e("this")}km.add(76,t=>{let e=t.stack.peek();t.stack.push(Ny(we(e))),ve(e)||t.updateWith(new Rm(e,Ny))}),km.add(106,t=>{let e=t.stack.peek();t.stack.push(Fy(we(e))),ve(e)||t.updateWith(new Rm(e,Fy))}),km.add(43,t=>{let e=we(t.stack.pop()),n=bg(e)?"":String(e);t.tree().appendDynamicHTML(n)}),km.add(44,t=>{let e=we(t.stack.pop()).toHTML(),n=bg(e)?"":e;t.tree().appendDynamicHTML(n)}),km.add(47,t=>{let e=t.stack.pop(),n=we(e),r=bg(n)?"":String(n),i=t.tree().appendDynamicText(r);ve(e)||t.updateWith(new Oy(i,e,r))}),km.add(45,t=>{let e=we(t.stack.pop());t.tree().appendDynamicFragment(e)}),km.add(46,t=>{let e=we(t.stack.pop());t.tree().appendDynamicNode(e)});var zy=Dy;function jy(t){zy=t}function Uy(){zy=Dy}var By=class{#h;constructor(t,e){this.scope=t,this.#h=e}get(t){let e,{scope:n}=this,r=this.#h,i=t.split("."),[s,...o]=t.split(".");return"this"===s?e=n.getSelf():r.locals[s]?e=n.getSymbol(r.locals[s]):(e=this.scope.getSelf(),o=i),o.reduce((t,e)=>xe(t,e),e)}};km.add(103,(t,{op1:e})=>{let n=t.constants.getValue(e),r=new By(t.scope(),n);zy(we(t.getSelf()),t=>we(r.get(t)))}),km.add(72,(t,{op1:e,op2:n})=>{let r=t.stack,i=r.pop(),s=we(r.pop()),o=my(i,null===s?"@identity":String(s)),a=we(o);t.updateWith(new Rm(o,t=>t.isEmpty())),a.isEmpty()?t.lowlevel.goto(n+1):(t.enterList(o,e),t.stack.push(a))}),km.add(73,t=>{t.exitList()}),km.add(74,(t,{op1:e})=>{let n=t.stack.peek().next();null!==n?t.registerItem(t.enterItem(n)):t.lowlevel.goto(e)});var $y=class{currentOpSize=0;registers;context;constructor(t,e,n,r){this.stack=t,this.externs=n,this.context=e,this.registers=r}fetchRegister(t){return this.registers[t]}loadRegister(t,e){this.registers[t]=e}setPc(t){this.registers[0]=t}pushFrame(){this.stack.push(this.registers[1]),this.stack.push(this.registers[2]),this.registers[2]=this.registers[3]-1}popFrame(){this.registers[3]=this.registers[2]-1,this.registers[1]=this.stack.get(0),this.registers[2]=this.stack.get(1)}pushSmallFrame(){this.stack.push(this.registers[1])}popSmallFrame(){this.registers[1]=this.stack.pop()}goto(t){this.setPc(this.target(t))}target(t){return this.registers[0]+t-this.currentOpSize}call(t){this.registers[1]=this.registers[0],this.setPc(this.context.program.heap.getaddr(t))}returnTo(t){this.registers[1]=this.target(t)}return(){this.setPc(this.registers[1])}nextStatement(){let{registers:t,context:e}=this,n=t[0];if(-1===n)return null;let r=e.program.opcode(n),i=this.currentOpSize=r.size;return this.registers[0]+=i,r}evaluateOuter(t,e){this.evaluateInner(t,e)}evaluateInner(t,e){t.isMachine?this.evaluateMachine(t,e):this.evaluateSyscall(t,e)}evaluateMachine(t,e){switch(t.type){case 0:return void this.pushFrame();case 1:return void this.popFrame();case 3:return void this.call(t.op1);case 2:return void e.call(this.stack.pop());case 4:return void this.goto(t.op1);case 5:return void e.return();case 6:return void this.returnTo(t.op1)}}evaluateSyscall(t,e){km.evaluate(e,t,t.type)}},qy=class{env;dom;alwaysRevalidate;frameStack=new ie;constructor(t,{alwaysRevalidate:e=!1}){this.env=t,this.dom=t.getDOM(),this.alwaysRevalidate=e}execute(t,e){this._execute(t,e)}_execute(t,e){let{frameStack:n}=this;for(this.try(t,e);!n.isEmpty();){let t=this.frame.nextStatement();void 0!==t?t.evaluate(this):n.pop()}}get frame(){return this.frameStack.current}goto(t){this.frame.goto(t)}try(t,e){this.frameStack.push(new Ky(t,e))}throw(){this.frame.handleException(),this.frameStack.pop()}},Vy=class{children;bounds;constructor(t,e,n,r){this.state=t,this.context=e,this.children=r,this.bounds=n}parentElement(){return this.bounds.parentElement()}firstNode(){return this.bounds.firstNode()}lastNode(){return this.bounds.lastNode()}evaluate(t){t.try(this.children,null)}},Wy=class extends Vy{type="try";evaluate(t){t.try(this.children,this)}handleException(){let{state:t,bounds:e,context:{env:n}}=this;!function(t){let{children:e}=J(t);Y(e,et)}(this);let r=Qg.resume(n,e),i=t.evaluate(r),s=this.children=[],o=i.execute(t=>{t.updateWith(this),t.pushUpdating(s)});Q(this,o.drop)}},Hy=class extends Wy{retained=!1;index=-1;constructor(t,e,n,r,i,s){super(t,e,n,[]),this.key=r,this.memo=i,this.value=s}shouldRemove(){return!this.retained}reset(){this.retained=!1}},Gy=class extends Vy{type="list-block";opcodeMap=new Map;marker=null;lastIterator;constructor(t,e,n,r,i){super(t,e,n,r),this.iterableRef=i,this.lastIterator=we(i)}initializeChild(t){t.index=this.children.length-1,this.opcodeMap.set(t.key,t)}evaluate(t){let e=we(this.iterableRef);if(this.lastIterator!==e){let{bounds:n}=this,{dom:r}=t,i=this.marker=r.createComment("");r.insertAfter(n.parentElement(),i,n.lastNode()),this.sync(e),this.parentElement().removeChild(i),this.marker=null,this.lastIterator=e}super.evaluate(t)}sync(t){let{opcodeMap:e,children:n}=this,r=0,i=0;for(this.children=this.bounds.boundList=[];;){let s=t.next();if(null===s)break;let o=n[r],{key:a}=s;for(;void 0!==o&&o.retained;)o=n[++r];if(void 0!==o&&o.key===a)this.retainItem(o,s),r++;else if(e.has(a)){let t=e.get(a);if(t.index{let r=e.enterItem(t);r.index=s.length,s.push(r),n.set(a,r),Q(this,r)})}moveItem(t,e,n){let r,i,{children:s}=this;_e(t.memo,e.memo),_e(t.value,e.value),t.retained=!0,void 0===n?mg(t,this.marker):(r=t.lastNode().nextSibling,i=n.firstNode(),r!==i&&mg(t,i)),t.index=s.length,s.push(t)}deleteItem(t){et(t),yg(t),this.opcodeMap.delete(t.key)}},Ky=class{current=0;constructor(t,e){this.ops=t,this.exceptionHandler=e}goto(t){this.current=t}nextStatement(){return this.ops[this.current++]}handleException(){this.exceptionHandler&&this.exceptionHandler.handleException()}},Zy=class{constructor(t,e,n,r){this.env=t,this.updating=e,this.bounds=n,this.drop=r,Q(this,r),tt(this,()=>yg(this.bounds))}rerender({alwaysRevalidate:t=!1}={alwaysRevalidate:!1}){let{env:e,updating:n}=this;new qy(e,{alwaysRevalidate:t}).execute(n,this)}parentElement(){return this.bounds.parentElement()}firstNode(){return this.bounds.firstNode()}lastNode(){return this.bounds.lastNode()}handleException(){}},Yy=class{static restore(t,e){const n=new this(t.slice(),function(t){return[0,-1,t,0]}(t.length-1));return n.registers[0]=e,n.registers[3]=t.length-1,n.registers[2]=-1,n}registers;constructor(t=[],e){this.stack=t,this.registers=e}push(t){this.stack[++this.registers[3]]=t}dup(t=this.registers[3]){this.stack[++this.registers[3]]=this.stack[t]}copy(t,e){this.stack[e]=this.stack[t]}pop(t=1){let e=this.stack[this.registers[3]];return this.registers[3]-=t,e}peek(t=0){return this.stack[this.registers[3]-t]}get(t,e=this.registers[2]){return this.stack[e+t]}set(t,e,n=this.registers[2]){this.stack[n+e]=t}slice(t,e){return this.stack.slice(t,e)}capture(t){let e=this.registers[3]+1,n=e-t;return this.stack.slice(n,e)}reset(){this.stack.length=0}},Xy=class{drop={};scope=new ie;dynamicScope=new ie;updating=new ie;cache=new ie;list=new ie;destroyable=new ie;constructor(t,e){this.scope.push(t),this.dynamicScope.push(e),this.destroyable.push(this.drop)}},Jy=class t{#d;args;lowlevel;debug;trace;get stack(){return this.lowlevel.stack}get pc(){return this.lowlevel.fetchRegister(0)}#p=[null,null,null,null,null,null,null,null,null];fetch(t){let e=this.fetchValue(t);this.stack.push(e)}load(t){let e=this.stack.pop();this.loadValue(t,e)}loadValue(t,e){this.#p[t]=e}fetchValue(t){return function(t){return t<=3}(t)?this.lowlevel.fetchRegister(t):this.#p[t]}call(t){null!==t&&this.lowlevel.call(t)}return(){this.lowlevel.return()}#f;context;constructor({scope:t,dynamicScope:e,stack:n,pc:r},i,s){let o=Yy.restore(n,r);this.#f=s,this.context=i,this.#d=new Xy(t,e),this.args=new $m,this.lowlevel=new $y(o,i,void 0,o.registers),this.pushUpdating()}static initial(e,n){let r=_y.root(n.owner,n.scope??{self:le,size:0});const i=function(t,e,n){return{pc:t,scope:e,dynamicScope:n,stack:[]}}(e.program.heap.getaddr(n.handle),r,n.dynamicScope);return new t(i,e,n.tree)}compile(t){return Lp(t.compile(this.context))}get constants(){return this.context.program.constants}get program(){return this.context.program}get env(){return this.context.env}captureClosure(t,e=this.lowlevel.fetchRegister(0)){return{pc:e,scope:this.scope(),dynamicScope:this.dynamicScope(),stack:this.stack.capture(t)}}capture(t,e=this.lowlevel.fetchRegister(0)){return new Qy(this.captureClosure(t,e),this.context)}beginCacheGroup(t){let e=this.updating(),n=new Tm;e.push(n),e.push(new Lm(t)),this.#d.cache.push(n),Lt()}commitCacheGroup(){let t=this.updating(),e=this.#d.cache.pop(),n=It();t.push(new Im(e)),e.finalize(n,t.length)}enter(t){let e=this.capture(t),n=this.tree().pushResettableBlock(),r=new Wy(e,this.context,n,[]);this.didEnter(r)}enterItem({key:t,value:e,memo:n}){let{stack:r}=this,i=yy(e),s=yy(n);r.push(i),r.push(s);let o=this.capture(2),a=this.tree().pushResettableBlock(),l=new Hy(o,this.context,a,t,s,i);return this.didEnter(l),l}registerItem(t){this.listBlock().initializeChild(t)}enterList(t,e){let n=[],r=this.lowlevel.target(e),i=this.capture(0,r),s=this.tree().pushBlockList(n),o=new Gy(i,this.context,s,n,t);this.#d.list.push(o),this.didEnter(o)}didEnter(t){this.associateDestroyable(t),this.#d.destroyable.push(t),this.updateWith(t),this.pushUpdating(t.children)}exit(){this.#d.destroyable.pop(),this.#f.popBlock(),this.popUpdating()}exitList(){this.exit(),this.#d.list.pop()}pushRootScope(t,e){let n=_y.sized(e,t);return this.#d.scope.push(n),n}pushChildScope(){this.#d.scope.push(this.scope().child())}pushScope(t){this.#d.scope.push(t)}popScope(){this.#d.scope.pop()}pushDynamicScope(){let t=this.dynamicScope().child();return this.#d.dynamicScope.push(t),t}bindDynamicScope(t){let e=this.dynamicScope();for(const n of Vp(t))e.set(n,this.stack.pop())}pushUpdating(t=[]){this.#d.updating.push(t)}popUpdating(){return this.#d.updating.pop()}updateWith(t){this.updating().push(t)}listBlock(){return this.#d.list.current}associateDestroyable(t){Q(this.#d.destroyable.current,t)}updating(){return this.#d.updating.current}tree(){return this.#f}scope(){return this.#d.scope.current}dynamicScope(){return this.#d.dynamicScope.current}popDynamicScope(){this.#d.dynamicScope.pop()}getOwner(){return this.scope().owner}getSelf(){return this.scope().getSelf()}referenceForSymbol(t){return this.scope().getSymbol(t)}execute(t){return this._execute(t)}_execute(t){let e;t&&t(this);do{e=this.next()}while(!e.done);return e.value}next(){let t,{env:e}=this,n=this.lowlevel.nextStatement();return null!==n?(this.lowlevel.evaluateOuter(n,this),t={done:!1,value:null}):(this.stack.reset(),t={done:!0,value:new Zy(e,this.popUpdating(),this.#f.popBlock(),this.#d.drop)}),t}},Qy=class{state;context;constructor(t,e){this.state=t,this.context=e}evaluate(t){return new Jy(this.state,this.context,t)}},tv=class{constructor(t){this.vm=t}next(){return this.vm.next()}sync(){return this.vm.execute()}};function ev(t,e){let n;return Iy(t,()=>n=e.sync()),n}function nv(t,e,n,r,i,s=new wy){let o=Lp(i.compile(t)),a=i.symbolTable.symbols.length,l=Jy.initial(t,{scope:{self:n,size:a},dynamicScope:s,tree:r,handle:o,owner:e});return new tv(l)}function rv(t,e,n,r,i={},s=new wy){return function(t,e,n,r,i){const s=Object.keys(i).map(t=>[t,i[t]]),o=["main","else","attrs"],a=s.map(([t])=>`@${t}`);let l=t.constants.component(r,n,void 0,"{ROOT}");t.lowlevel.pushFrame();for(let h=0;h<3*o.length;h++)t.stack.push(null);t.stack.push(null),s.forEach(([,e])=>{t.stack.push(e)}),t.args.setup(t.stack,a,o,0,!0);const c=l.compilable,u={handle:Lp(c.compile(e)),symbolTable:c.symbolTable};return t.stack.push(t.args),t.stack.push(u),t.stack.push(l),new tv(t)}(Jy.initial(t,{tree:e,handle:t.stdlib.main,dynamicScope:s,owner:n}),t,n,r,function(t){const e=de(t);return Object.keys(t).reduce((t,n)=>(t[n]=xe(e,n),t),{})}(i))}var iv=a({_instrumentStart:()=>hv,flaggedInstrument:()=>cv,instrument:()=>lv,reset:()=>fv,subscribe:()=>dv,subscribers:()=>sv,unsubscribe:()=>pv}),sv=[],ov={},av=()=>performance.now();function lv(t,e,n,r){let i,s,o;if(arguments.length<=3&&"function"==typeof e?(s=e,o=n):(i=e,s=n,o=r),0===sv.length)return s.call(o);let a=i||{},l=hv(t,()=>a);return l===uv?s.call(o):function(t,e,n,r){try{return t.call(r)}catch(i){throw n.exception=i,i}finally{e()}}(s,l,a,o)}function cv(t,e,n){return n()}function uv(){}function hv(t,e,n){if(0===sv.length)return uv;let r=ov[t];if(r||(r=function(t){let e=[];for(let n of sv)n.regex.test(t)&&e.push(n.object);return ov[t]=e,e}(t)),0===r.length)return uv;let i,s=e(n),o=O.STRUCTURED_PROFILE;o&&(i=`${t}: ${s.object}`,console.time(i));let a=[],l=av();for(let u of r)a.push(u.before(t,l,s));const c=r;return function(){let e=av();for(let n=0;n-1?yv(e,i.split(".")):xe(e,i);r.setAttribute(s,a,!1,null)}function wv(t,e){let n;return fe(()=>{let r=we(t);return!0===r?n||(n=ip(e)):r||0===r?String(r):null})}function _v(){}var xv=class{classRef=null;rootRef;argsRevision;constructor(t,e,n,r,i,s){this.component=t,this.args=e,this.argsTag=n,this.finalizer=r,this.hasWrappedElement=i,this.isInteractive=s,this.classRef=null,this.argsRevision=null===e?0:lt(n),this.rootRef=de(t),tt(this,()=>this.willDestroy(),!0),tt(this,()=>this.component.destroy())}willDestroy(){let{component:t,isInteractive:e}=this;if(e){Pt(),t.trigger("willDestroyElement"),t.trigger("willClearRender"),Mt();let e=Jl(t);e&&(ec(e),nc(t))}t.renderer.unregister(t)}finalize(){let{finalizer:t}=this;t(),this.finalizer=_v}};function Cv(t){let e=Object.create(null),n=Object.create(null);for(let r in t){let i=t[r],s=we(i);be(i)?e[r]=new kv(i,s):e[r]=s,n[r]=s}return n.attrs=e,n}var Sv=Symbol("REF"),kv=class{value;[gv];[Sv];constructor(t,e){this[gv]=!0,this[Sv]=t,this.value=e}update(t){_e(this[Sv],t)}},Ev=new WeakMap,Rv=Symbol("DIRTY_TAG"),Tv=Symbol("IS_DISPATCHING_ATTRS"),Lv=Symbol("BOUNDS"),Iv=ae("ember-view"),Pv=class{templateFor(t){let e,{layout:n,layoutName:r}=t,i=Ur(t);if(void 0===n){if(void 0===r)return null;e=i.lookup(`template:${r}`)}else{if("function"!=typeof n)return null;e=n}return mv(e(i)).asWrappedLayout()}getDynamicLayout(t){return this.templateFor(t.component)}getTagName(t){let{component:e,hasWrappedElement:n}=t;return n?e&&e.tagName||"div":null}getCapabilities(){return Ov}prepareArgs(t,e){if(e.named.has("__ARGS__")){let{__ARGS__:t,...n}=e.named.capture(),r=we(t);return{positional:r.positional,named:{...n,...r.named}}}const{positionalParams:n}=t.class??t;if(null==n||0===e.positional.length)return null;let r;if("string"==typeof n){let t=e.positional.capture();r={[n]:fe(()=>Jm(t))},Object.assign(r,e.named.capture())}else{if(!(Array.isArray(n)&&n.length>0))return null;{const t=Math.min(n.length,e.positional.length);r={},Object.assign(r,e.named.capture());for(let i=0;i{s.setAttribute("class",ae(t),!1,null)}),l&&l.length&&l.forEach(t=>{!function(t,e,n){let[r,i,s]=e.split(":");if(""===r)n.setAttribute("class",ae(i),!0,null);else{let e,o=r.indexOf(".")>-1,a=o?r.split("."):[],l=o?yv(t,a):xe(t,r);e=void 0===i?wv(l,o?a[a.length-1]:r):function(t,e,n){return fe(()=>we(t)?e:n)}(l,i,s),n.setAttribute("class",e,!1,null)}}(r,t,s)}),s.setAttribute("class",Iv,!1,null),"ariaRole"in t&&s.setAttribute("role",xe(r,"ariaRole"),!1,null),t._transitionTo("hasElement"),n&&(Pt(),t.trigger("willInsertElement"),Mt())}didRenderLayout(t,e){t.component[Lv]=e,t.finalize()}didCreate({component:t,isInteractive:e}){e&&(t._transitionTo("inDOM"),t.trigger("didInsertElement"),t.trigger("didRender"))}update(t){let{component:e,args:n,argsTag:r,argsRevision:i,isInteractive:s}=t;if(t.finalizer=hv("render.component",Av,e),Pt(),null!==n&&!ct(r,i)){Lt();let i=Cv(n);r=t.argsTag=It(),t.argsRevision=lt(r),e[Tv]=!0,e.setProperties(i),e[Tv]=!1,e.trigger("didUpdateAttrs"),e.trigger("didReceiveAttrs")}s&&(e.trigger("willUpdate"),e.trigger("willRender")),Mt(),Nt(r),Nt(e[Rv])}didUpdateLayout(t){t.finalize()}didUpdate({component:t,isInteractive:e}){e&&(t.trigger("didUpdate"),t.trigger("didRender"))}getDestroyable(t){return t}};function Mv(t){return t.instrumentDetails({initialRender:!0})}function Av(t){return t.instrumentDetails({initialRender:!1})}var Ov={dynamicLayout:!0,dynamicTag:!0,prepareArgs:!0,createArgs:!0,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!0,willDestroy:!0,hasSubOwner:!1},Nv=new Pv;function Fv(t){return t===Nv}function Dv(t){let e=ur(t,"content");return pt(Oe(t),Oe(e)),e}function zv(t,e,n){let r=Gt(t),i=Kt(t,e,r);if(e in t)return i;{let s=[i,Kt(t,"content",r)],o=Dv(t);return Zt(o)&&s.push(Ae(o,e,n)),xt(s)}}var jv=wl.create({content:null,init(){this._super(...arguments),nr(this),Oe(this),Ee(this,zv)},willDestroy(){this.set("content",null),this._super(...arguments)},isTruthy:Yn("content",function(){return Boolean(ur(this,"content"))}),unknownProperty(t){let e=Dv(this);return e?ur(e,t):void 0},setUnknownProperty(t,e){let n=w(this);return n.isInitializing()||n.isPrototypeMeta(this)?(Dn(this,t,null,e),e):gr(Dv(this),t,e)}});function Uv(t){return Mu(t,{})}var Bv=class{__string;constructor(t){this.__string=t}toString(){return`${this.__string}`}toHTML(){return this.toString()}},$v=function(t){return null==t?t="":"string"!=typeof t&&(t=String(t)),new Bv(t)};function qv(t){return Mu(t,{})}var Vv=qv(({positional:t})=>fe(()=>Jm(t),null)),Wv=qv(({positional:t})=>{let e=t[0];return fe(()=>(...n)=>{let[r,...i]=Jm(t);if(me(e)){let t=i.length>0?i[0]:n[0];return void _e(e,t)}return r.call(null,...i,...n)},null)}),Hv=qv(({named:t})=>{let e=fe(()=>Xm(t),null),n=new Map;for(let r in t)n.set(r,t[r]);return e.children=n,e}),Gv=t=>(t=>null==t||"function"!=typeof t.toString)(t)?"":String(t),Kv=qv(({positional:t})=>fe(()=>Jm(t).map(Gv).join(""),null)),Zv=qv(({positional:t})=>{let e=t[0]??le,n=t[1]??le;return fe(()=>{let t=we(e);if(ne(t))return q(t,String(we(n)))},t=>{let r=we(e);if(ne(r))return V(r,String(we(n)),t)})}),Yv=class{tag=gt();element;args;listener=null;constructor(t,e){this.element=t,this.args=e,tt(this,()=>{let{element:t,listener:e}=this;if(e){let{eventName:n,callback:r,options:i}=e;Qv(t,n,r,i)}})}updateListener(){let t,e,n,{element:r,args:i,listener:s}=this,o=i.positional[0],a=o?we(o):void 0,l=i.positional[1],c=l?we(l):void 0;{let{once:r,passive:s,capture:o}=i.named;r&&(t=we(r)),s&&(e=we(s)),o&&(n=we(o))}let u,h=!1;if(h=null===s||a!==s.eventName||c!==s.userProvidedCallback||t!==s.once||e!==s.passive||n!==s.capture,h&&(void 0===t&&void 0===e&&void 0===n||(u={once:t,passive:e,capture:n})),h){let i=c;this.listener={eventName:a,callback:i,userProvidedCallback:c,once:t,passive:e,capture:n,options:u},s&&Qv(r,s.eventName,s.callback,s.options),function(t,e,n,r){Xv++,t.addEventListener(e,n,r)}(r,a,i,u)}}},Xv=0,Jv=0;function Qv(t,e,n,r){Jv++,t.removeEventListener(e,n,r)}var tb,eb=Iu(new class{getDebugName(){return"on"}getDebugInstance(){return null}get counters(){return{adds:Xv,removes:Jv}}create(t,e,n,r){return new Yv(e,r)}getTag({tag:t}){return t}install(t){t.updateListener()}update(t){t.updateListener()}getDestroyable(t){return t}},{}),nb={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!1,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!1,updateHook:!1,createInstance:!1,wrapped:!1,willDestroy:!1,hasSubOwner:!1},rb=class{getCapabilities(){return nb}getDebugName({name:t}){return t}getSelf(){return ce}getDestroyable(){return null}},ib=new rb,sb=class{constructor(t="@glimmer/component/template-only",e="(unknown template-only component)"){this.moduleName=t,this.name=e}toString(){return this.moduleName}};function ob(t,e){return new sb(t,e)}Nu(ib,sb.prototype);var ab={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1};function lb(t,e={}){let n=Boolean(e.updateHook);return{asyncLifeCycleCallbacks:Boolean(e.asyncLifecycleCallbacks),destructor:Boolean(e.destructor),updateHook:n}}function cb(t){return t.capabilities.asyncLifeCycleCallbacks}function ub(t){return t.capabilities.updateHook}var hb=class{componentManagerDelegates=new WeakMap;constructor(t){this.factory=t}getDelegateFor(t){let{componentManagerDelegates:e}=this,n=e.get(t);if(void 0===n){let{factory:r}=this;n=r(t),e.set(t,n)}return n}create(t,e,n){let r=this.getDelegateFor(t),i=Ie(n.capture()),s=r.createComponent(e,i);return new db(s,r,i)}getDebugName(t){return"function"==typeof t?t.name:t.toString()}update(t){let{delegate:e}=t;if(ub(e)){let{component:n,args:r}=t;e.updateComponent(n,r)}}didCreate({component:t,delegate:e}){cb(e)&&e.didCreateComponent(t)}didUpdate({component:t,delegate:e}){(function(t){return cb(t)&&ub(t)})(e)&&e.didUpdateComponent(t)}didRenderLayout(){}didUpdateLayout(){}getSelf({component:t,delegate:e}){return de(e.getContext(t))}getDestroyable(t){const{delegate:e}=t;if(function(t){return t.capabilities.destructor}(e)){const{component:n}=t;return tt(t,()=>e.destroyComponent(n)),t}return null}getCapabilities(){return ab}},db=class{constructor(t,e,n){this.component=t,this.delegate=e,this.args=n}};function pb(t,e={}){return{disableAutoTracking:Boolean(e.disableAutoTracking)}}var fb=class{componentManagerDelegates=new WeakMap;constructor(t){this.factory=t}getDelegateFor(t){let{componentManagerDelegates:e}=this,n=e.get(t);if(void 0===n){let{factory:r}=this;n=r(t),e.set(t,n)}return n}create(t,e,n,r){let i,s=this.getDelegateFor(t),o=Ie(r),a=s.createModifier(n,o);return i={tag:gt(),element:e,delegate:s,args:o,modifier:a},tt(i,()=>s.destroyModifier(a,o)),i}getDebugName(t){return"function"==typeof t?t.name||t.toString():""}getDebugInstance({modifier:t}){return t}getTag({tag:t}){return t}install({element:t,args:e,modifier:n,delegate:r}){let{capabilities:i}=r;i.disableAutoTracking?Vt(()=>r.installModifier(n,t,e)):r.installModifier(n,t,e)}update({args:t,modifier:e,delegate:n}){let{capabilities:r}=n;r.disableAutoTracking?Vt(()=>n.updateModifier(e,t)):n.updateModifier(e,t)}getDestroyable(t){return t}};function gb(t,e){return Nu(new hb(t),e)}function mb(t,e){return Iu(new fb(t),e)}function yb(t,e){return Mu(new xu(t),e)}var vb=Symbol("RECOMPUTE_TAG"),bb=Symbol("IS_CLASSIC_HELPER"),wb=class extends Yc{static isHelperFactory=!0;static[bb]=!0;static helper=kb;init(t){super.init(t),this[vb]=ft()}recompute(){_s(()=>dt(this[vb]))}},_b=class{capabilities=bu(0,{hasValue:!0,hasDestroyable:!0});ownerInjection;constructor(t){let e={};Br(e,t),this.ownerInjection=e}createHelper(t,e){return{instance:(n=t,null!=n&&"class"in n?t.create():t.create(this.ownerInjection)),args:e};var n}getDestroyable({instance:t}){return t}getValue({instance:t,args:e}){let{positional:n,named:r}=e,i=t.compute(n,r);return Nt(t[vb]),i}getDebugName(t){return tb((t.class||t).prototype)}};yb(t=>new _b(t),wb);var xb=Ou(wb),Cb=class{isHelperFactory=!0;constructor(t){this.compute=t}create(){return{compute:this.compute}}},Sb=new class{capabilities=bu(0,{hasValue:!0});createHelper(t,e){return()=>t.compute.call(null,e.positional,e.named)}getValue(t){return t()}getDebugName(t){return tb(t.compute)}};function kb(t){return new Cb(t)}yb(()=>Sb,Cb.prototype);var Eb=Uv(()=>de("30000000-1000-4000-2000-100000000000".replace(/[0-3]/g,t=>(4*t^16*Math.random()>>(2&t)).toString(16)))),Rb=class{constructor(t,e,n,r,i){this.main=t,this.trustingGuardedAppend=e,this.cautiousGuardedAppend=n,this.trustingNonDynamicAppend=r,this.cautiousNonDynamicAppend=i}get"trusting-append"(){return this.trustingGuardedAppend}get"cautious-append"(){return this.cautiousGuardedAppend}get"trusting-non-dynamic-append"(){return this.trustingNonDynamicAppend}get"cautious-non-dynamic-append"(){return this.cautiousNonDynamicAppend}getAppend(t){return t?this.trustingGuardedAppend:this.cautiousGuardedAppend}};function Tb(t,e,n){jf(t,()=>t(76),r=>{r(2,()=>{e?(t(68),t(43)):t(47)}),"number"==typeof n?(r(0,()=>{t(68),t(81),t(79),function(t){t(36,4),t(33,3,1),t(35,4),t(0),t(83),t(85,4),Hf(t,!1,!1,!0,()=>{t(92,4),t(95,4)}),t(35,4)}(t)}),r(1,()=>{Ef(t,null,null,()=>{t(3,n)})})):(r(0,()=>{t(47)}),r(1,()=>{t(47)})),r(4,()=>{t(68),t(44)}),r(5,()=>{t(68),t(45)}),r(6,()=>{t(68),t(46)})})}var Lb={symbols:{locals:null,upvars:null},moduleName:"stdlib",scopeValues:null,isStrictMode:!0,owner:null,size:0};function Ib(t,e){let n=new yf(t.program.heap,Lb);e(function(...e){mf(n,t,Lb,e)});let r=n.commit(0);if("number"!=typeof r)throw new Error("Unexpected errors compiling std");return r}var Pb=class{constants;heap;resolver;stdlib;createOp;env;program;constructor({constants:t,heap:e},n,r){this.constants=t,this.heap=e,this.resolver=r.resolver,this.createOp=n,this.env=r.env,this.program=r.program,this.stdlib=function(t){let e=Ib(t,t=>function(t){t(75,4),Hf(t,!1,!1,!0)}(t)),n=Ib(t,t=>Tb(t,!0,null)),r=Ib(t,t=>Tb(t,!1,null)),i=Ib(t,t=>Tb(t,!0,n)),s=Ib(t,t=>Tb(t,!1,r));return new Rb(e,i,s,n,r)}(this)}};function Mb(t){return{object:`${t.name}:main`}}var Ab,Ob={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!1,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!0,updateHook:!1,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1},Nb=gu(Ob),Fb=new class{create(t,e,n,r,i){let s=i.get("outletState"),o=e.ref;i.set("outletState",o);let a={finalize:hv("render.outlet",Mb,e)};if(void 0!==r.debugRenderTree){let t=we(s)?.render?.owner,e=we(o)?.render?.owner;if(t&&t!==e){let t=e,{mountPoint:n}=t;n&&(a.engine={mountPoint:n,instance:t})}}return a}getDebugName({name:t}){return`{{outlet}} for ${t}`}getDebugCustomRenderTree(t,e){let n=[];return n.push({bucket:e,type:"outlet",name:"main",args:ay,instance:void 0}),e.engine&&n.push({bucket:e.engine,type:"engine",name:e.engine.mountPoint,args:ay,instance:e.engine.instance}),n}getCapabilities(){return Ob}getSelf(){return le}didCreate(){}didUpdate(){}didRenderLayout(t){t.finalize()}didUpdateLayout(){}getDestroyable(){return null}},Db=rg({id:null,block:'[[[8,[30,1],null,[["@controller","@model"],[[30,2],[30,3]]],null]],["@Component","@controller","@model"],[]]',moduleName:"(unknown template module)",isStrictMode:!0}),zb=class{handle=-1;resolvedName=null;manager=Fb;capabilities=Nb;compilable;constructor(t,e){this.state=e,this.compilable=mv(Db(t)).asLayout()}},jb=class extends Pv{component;constructor(t){super(),this.component=t}create(t,e,n,{isInteractive:r},i){let s=this.component,o=hv("render.component",Mv,s);i.view=s;let a=""!==s.tagName;a||(r&&s.trigger("willRender"),s._transitionTo("hasElement"),r&&s.trigger("willInsertElement"));let l=new xv(s,null,mt,o,a,r);return Nt(s[Rv]),l}},Ub={dynamicLayout:!0,dynamicTag:!0,prepareArgs:!1,createArgs:!1,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!0,willDestroy:!1,hasSubOwner:!1},Bb=class{handle=-1;resolvedName="-top-level";state;manager;capabilities=gu(Ub);compilable=null;constructor(t){this.manager=new jb(t);let e=Ya(t);this.state=e}},$b=class{constructor(t){this.inner=t}},qb=Uv(({positional:t})=>{const e=t[0];return fe(()=>{let t=we(e);return Nt(Oe(t)),er(t)&&(t=Dv(t)),new $b(t)})}),Vb=class{position=0;constructor(t){this.length=t}isEmpty(){return!1}memoFor(t){return t}next(){let{length:t,position:e}=this;if(e>=t)return null;let n=this.valueFor(e),r=this.memoFor(e);return this.position++,{value:n,memo:r}}},Wb=class extends Vb{static from(t){return t.length>0?new this(t):null}static fromForEachable(t){let e=[];return t.forEach(t=>e.push(t)),this.from(e)}constructor(t){super(t.length),this.array=t}valueFor(t){return this.array[t]}},Hb=class extends Vb{static from(t){return t.length>0?new this(t):null}constructor(t){super(t.length),this.array=t}valueFor(t){return Pe(this.array,t)}},Gb=class extends Vb{static fromIndexable(t){let e=Object.keys(t);if(0===e.length)return null;{let n=[];for(let r of e){let e;e=t[r],Ot()&&(Nt(Kt(t,r)),Array.isArray(e)&&Nt(Kt(e,"[]"))),n.push(e)}return new this(e,n)}}static fromForEachable(t){let e=[],n=[],r=0,i=!1;return t.forEach(function(t,s){i=i||arguments.length>=2,i&&e.push(s),n.push(t),r++}),0===r?null:i?new this(e,n):new Wb(n)}constructor(t,e){super(e.length),this.keys=t,this.values=e}valueFor(t){return this.values[t]}memoFor(t){return this.keys[t]}},Kb=class{static from(t){let e=t[Symbol.iterator](),n=e.next(),{done:r}=n;return r?null:new this(e,n)}position=0;constructor(t,e){this.iterable=t,this.result=e}isEmpty(){return!1}next(){let{iterable:t,result:e,position:n}=this;if(e.done)return null;let r=this.valueFor(e,n),i=this.memoFor(e,n);return this.position++,this.result=t.next(),{value:r,memo:i}}},Zb=class extends Kb{valueFor(t){return t.value}memoFor(t,e){return e}},Yb=class extends Kb{valueFor(t){return t.value[1]}memoFor(t){return t.value[0]}};function Xb(t){return null!=t&&"function"==typeof t.forEach}function Jb(t){return null!=t&&"function"==typeof t[Symbol.iterator]}W=(Ab={scheduleRevalidate(){bs.ensureInstance()},toBool:function(t){return er(t)?(Nt(Ae(t,"content")),Boolean(ur(t,"isTruthy"))):Ic(t)?(Nt(Ae(t,"[]")),0!==t.length):null!==(e=t)&&"object"==typeof e&&"function"==typeof e.toHTML?Boolean(t.toString()):Boolean(t);var e},toIterator:function(t){return t instanceof $b?function(t){return null===(e=t)||"object"!=typeof e&&"function"!=typeof e?null:Array.isArray(t)||ir(t)?Gb.fromIndexable(t):Jb(t)?Yb.from(t):Xb(t)?Gb.fromForEachable(t):Gb.fromIndexable(t);var e}(t.inner):function(t){return Zt(t)?Array.isArray(t)?Wb.from(t):ir(t)?Hb.from(t):Jb(t)?Zb.from(t):Xb(t)?Wb.fromForEachable(t):null:null}(t)},getProp:hr,setProp:mr,getPath:ur,setPath:gr,scheduleDestroy(t,e){ks("actions",null,e,t)},scheduleDestroyed(t){ks("destroy",null,t)},warnIfStyleNotTrusted(t){},assert(t,e,n){},deprecate(t,e,n){}}).scheduleRevalidate,D=Ab.scheduleDestroy,z=Ab.scheduleDestroyed,j=Ab.toIterator,U=Ab.toBool,B=Ab.getProp,$=Ab.setProp,q=Ab.getPath,V=Ab.setPath;var Qb=class{enableDebugTooling=O._DEBUG_RENDER_TREE;constructor(t,e){this.owner=t,this.isInteractive=e}onTransactionCommit(){}},tw=Uv(({positional:t,named:e})=>{const n=t[0];let r=e.type,i=e.loc,s=e.original;return we(r),we(i),we(s),fe(()=>we(n))}),ew=Uv(t=>t.positional[0]),nw=Uv(({positional:t})=>fe(()=>{let e=t[0],n=t[1],r=we(e).split("."),i=r[r.length-1],s=we(n);return!0===s?ip(i):s||0===s?String(s):""})),rw=Uv(({positional:t},e)=>{let n=we(t[0]);return de(e.factoryFor(n)?.class)}),iw=Uv(({positional:t})=>{const e=t[0];return fe(()=>{let t=we(e);return Zt(t)&&Nt(Ae(t,"[]")),t})}),sw=Uv(({positional:t})=>ye(t[0])),ow=Uv(({positional:t})=>ge(t[0])),aw=Uv(({positional:t,named:e})=>pe(we(t[0]))),lw={dynamicLayout:!0,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!0},cw=new class{getDynamicLayout(t){return mv(t.engine.lookup("template:application")(t.engine)).asLayout()}getCapabilities(){return lw}getOwner(t){return t.engine}create(t,{name:e},n,r){let i=t.buildChildEngineInstance(e);i.boot();let s,o,a,l,c=i.factoryFor("controller:application")||Fh(i,"application");if(n.named.has("model")&&(l=n.named.get("model")),void 0===l)s=c.create(),o=de(s),a={engine:i,controller:s,self:o,modelRef:l};else{let t=we(l);s=c.create({model:t}),o=de(s),a={engine:i,controller:s,self:o,modelRef:l}}return r.debugRenderTree&&Q(i,s),a}getDebugName({name:t}){return t}getDebugCustomRenderTree(t,e,n){return[{bucket:e.engine,instance:e.engine,type:"engine",name:t.name,args:n},{bucket:e.controller,instance:e.controller,type:"route-template",name:"application",args:n}]}getSelf({self:t}){return t}getDestroyable(t){return t.engine}didCreate(){}didUpdate(){}didRenderLayout(){}didUpdateLayout(){}update(t){let{controller:e,modelRef:n}=t;void 0!==n&&e.set("model",we(n))}},uw=class{handle=-1;state;manager=cw;compilable=null;capabilities=gu(lw);constructor(t){this.resolvedName=t,this.state={name:t}}},hw=Uv((t,e)=>{let n,r,i,s=t.positional[0];return n=Ym(t.named,oy),fe(()=>{let t=we(s);return"string"==typeof t?(r===t||(r=t,i=_m(0,new uw(t),e,n,!0)),i):(i=null,r=null,null)})}),dw={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!1,updateHook:!1,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1},pw=gu(dw),fw=new class{create(t,e,n){let r=n.named.get("controller");return{self:r,controller:we(r)}}getSelf({self:t}){return t}getDebugName({name:t}){return`route-template (${t})`}getDebugCustomRenderTree({name:t},e,n){return[{bucket:e,type:"route-template",name:t,args:n,instance:e.controller}]}getCapabilities(){return dw}didRenderLayout(){}didUpdateLayout(){}didCreate(){}didUpdate(){}getDestroyable(){return null}},gw=class{handle=-1;resolvedName;state;manager=fw;capabilities=pw;compilable;constructor(t,e){let n=mv(e);this.resolvedName=t,this.state={name:t},this.compilable=n.asLayout()}};function mw(t,e,n){return _m(0,new gw(e,n),t,null,!0)}var yw=Uv((t,e,n)=>{let r=fe(()=>we(n.get("outletState"))?.outlets?.main),i=null,s=null;return fe(()=>{let t=we(r),n=function(t,e){if(void 0===e)return null;let n=e.render;if(void 0===n)return null;let r=n.template;return null==r?null:{ref:t,name:n.name,template:r,controller:n.controller}}(r,t);if(!function(t,e){return null!==t&&null!==e&&t.template===e.template&&t.controller===e.controller}(n,i))if(i=n,null!==n){let o,a=t?.render?.owner??e,l=ee(),c=n.template;o=Du(c)?c:mw(a,n.name,c),l.Component=de(o),l.controller=de(n.controller);let u=Ce(r,["render","model"]),h=we(u);l.model=fe(()=>(i===n&&(h=we(u)),h));let d=Ym(l,oy);s=_m(0,new zb(e,n),a,d,!0)}else s=null;return s})});function vw(t){return{object:`component:${t}`}}var bw={mut:sw,readonly:ow,unbound:aw,"-hash":Hv,"-each-in":qb,"-normalize-class":nw,"-resolve":rw,"-track-array":iw,"-mount":hw,"-outlet":yw,"-in-el-null":ew},ww={...bw,array:Vv,concat:Kv,fn:Wv,get:Zv,hash:Hv,"unique-id":Eb};ww["-disallow-dynamic-resolution"]=tw;var _w={},xw={..._w,on:eb},Cw=class{componentDefinitionCache=new Map;lookupPartial(){return null}lookupHelper(t,e){let n=ww[t];if(void 0!==n)return n;let r=e.factoryFor(`helper:${t}`);if(void 0===r)return null;let i=r.class;return void 0===i?null:"function"==typeof i&&!0===i[bb]?(Mu(xb,r),r):i}lookupBuiltInHelper(t){return bw[t]??null}lookupModifier(t,e){let n=xw[t];if(void 0!==n)return n;let r=e.factoryFor(`modifier:${t}`);return void 0===r?null:r.class||null}lookupBuiltInModifier(t){return _w[t]??null}lookupComponent(t,e){let n=function(t,e){let n=function(t,e){let n=`component:${t}`;return e.factoryFor(n)||null}(e,t);if(null!=(r=n)&&"function"==typeof r.create&&n.class){let t=Op(n.class);if(void 0!==t)return{component:n,layout:t}}var r;return null===n?null:{component:n,layout:null}}(e,t);if(null===n)return null;let r,i=null;r=null===n.component?i=n.layout(e):n.component;let s=this.componentDefinitionCache.get(r);if(void 0!==s)return s;null===i&&null!==n.layout&&(i=n.layout(e));let o=hv("render.getComponentDefinition",vw,t),a=null;if(null===n.component)a={state:ob(void 0,t),manager:ib,template:i};else{let t=n.component,e=t.class,r=Fu(e);a={state:Fv(r)?t:e,manager:r,template:i}}return o(),this.componentDefinitionCache.set(r,a),a}},Sw="-top-level",kw=class t{static extend(e){return class extends t{static create(t){return t?super.create(Object.assign({},e,t)):super.create(e)}}}static reopenClass(t){Object.assign(this,t)}static create(e){let{environment:n,application:r,template:i}=e,s=Ur(e),o=i(s);return new t(n,s,o,r)}ref;state;constructor(t,e,n,r){this._environment=t,this.owner=e,this.template=n,this.namespace=r;let i=ft(),s={outlets:{main:void 0},render:{owner:e,name:Sw,controller:void 0,model:void 0,template:n}},o=this.ref=fe(()=>(Nt(i),s),t=>{dt(i),s.outlets.main=t});this.state={ref:o,name:Sw,template:n,controller:void 0}}appendTo(t){let e;e=this._environment.hasDOM&&"string"==typeof t?document.querySelector(t):t,ks("render",this.owner.lookup("renderer:-dom"),"appendOutletView",this,e)}rerender(){}setOutletState(t){_e(this.ref,t)}destroy(){}},Ew=class t{constructor(t,e){this.view=t,this.outletState=e}child(){return new t(this.view,this.outletState)}get(t){return this.outletState}set(t,e){return this.outletState=e,e}},Rw=()=>{},Tw=class{type="component";#g;#m;constructor(t,e,n){this.#m=()=>{let r=rv(t.context,t.builder(t.env,n.into),t.owner,e,n?.args),i=this.#g=r.sync();Q(this,this.#g),this.#m=()=>{if(!rt(i)&&!it(i))return i.rerender({alwaysRevalidate:!1})}}}isFor(t){return!1}render(){this.#m()}destroy(){et(this)}get destroyed(){return it(this)}get result(){return this.#g}},Lw=class{type="classic";id;result;destroyed;render;env;constructor(t,e,n,r,i,s,o,a){this.root=t,this.id=t instanceof kw?al(t):Kl(t),this.result=void 0,this.destroyed=!1,this.env=e.env,this.render=()=>{let t=mv(r).asLayout(),l=nv(e,n,i,a(e.env,{element:s,nextSibling:null}),t,o),c=this.result=l.sync();Q(this,c),this.render=()=>{if(!rt(c)&&!it(c))return c.rerender({alwaysRevalidate:!1})}}}isFor(t){return this.root===t}destroy(){let{result:t,env:e}=this;this.destroyed=!0,this.root=null,this.result=void 0,this.render=void 0,void 0!==t&&Iy(e,()=>et(t))}},Iw=[];function Pw(t){let e=Iw.indexOf(t);Iw.splice(e,1)}var Mw=null,Aw=0;bs.on("begin",function(){for(let t of Iw)t.rerender()}),bs.on("end",function(){for(let t of Iw)if(!t.isValid()){if(Aw>O._RERENDER_LOOP_LIMIT)throw Aw=0,t.destroy(),new Error("infinite rendering invalidation detected");return Aw++,bs.join(null,Rw)}Aw=0,function(){if(null!==Mw){let t=Mw.resolve;Mw=null,bs.join(null,t)}}()});var Ow=class t{static create(e,n){const r=new t(e,n);return Q(n,r),r}#y;#v=-1;#b=!1;#w=!1;#_=[];#x=[];constructor(t,e){this.#y=t,tt(this,()=>{this.clearAllRoots(e)})}get debug(){return{roots:this.#_,inRenderTransaction:this.#b,isInteractive:this.isInteractive}}get roots(){return this.#_}get owner(){return this.#y.owner}get builder(){return this.#y.builder}get context(){return this.#y.context}get env(){return this.context.env}get isInteractive(){return this.#y.context.env.isInteractive}renderRoot(t,e){let n=this.#_;return n.push(t),Q(this,t),1===n.length&&function(t){Iw.push(t)}(e),this.#C(e),t}#C(t){if(this.#b)return;this.#b=!0;let e=!1;try{this.renderRoots(t),e=!0}finally{e||(this.#v=lt(_t)),this.#b=!1}}renderRoots(t){let e,n=this.#_,r=this.#x;do{e=n.length,Iy(this.context.env,()=>{for(let t=0;t=e||i.render()}this.#v=lt(_t)})}while(n.length>e);for(;r.length;){let t=r.pop(),e=n.indexOf(t);n.splice(e,1)}0===this.#_.length&&Pw(t)}scheduleRevalidate(t){bs.scheduleOnce("render",this,this.revalidate,t)}isValid(){return this.#w||0===this.#_.length||ct(_t,this.#v)}revalidate(t){this.isValid()||this.#C(t)}clearAllRoots(t){let e=this.#_;for(let n of e)et(n);this.#x.length=0,this.#_=[],e.length&&Pw(t)}},Nw=class t{static strict(e,n,r){return new t(e,{hasDOM:Mo,...r},n,new Cw,im)}state;constructor(t,e,n,r,i){let s={constants:new pg,heap:new ag},o=Ly({document:n},new Qb(t,e.isInteractive),s,r),a=new Pb(s,t=>new sg(t),o);this.state=Ow.create({owner:t,context:a,builder:i},this)}get debugRenderTree(){let{debugRenderTree:t}=this.state.env;return t}isValid(){return this.state.isValid()}destroy(){et(this)}render(t,e){const n=new Tw(this.state,t,{args:e.args,into:(r=e.into,"element"in r?r:{element:r,nextSibling:null})});var r;return this.state.renderRoot(n,this)}rerender(){this.state.scheduleRevalidate(this)}},Fw=class extends Nw{static strict(t,e,n){return new Nw(t,{hasDOM:Mo,...n},e,new Cw,im)}_rootTemplate;_viewRegistry;static create(t){let{_viewRegistry:e}=t,n=Ur(t),r=n.lookup("service:-document"),i=n.lookup("-environment:main"),s=n.lookup(mc`template:-root`),o=n.lookup("service:-dom-builder");return new this(n,r,i,s,e,o)}constructor(t,e,n,r,i,s=im,o=new Cw){super(t,n,e,o,s),this._rootTemplate=r(t),this._viewRegistry=i||t.lookup("-view-registry:main")}appendOutletView(t,e){let n=new zb((r=t).owner,r.state);var r;let{name:i,template:s}=t.state,o=ee();o.Component=de(mw(t.owner,i,s)),o.controller=le,o.model=le;let a=Ym(o,oy);this._appendDefinition(t,_m(0,n,t.owner,a,!0),e)}appendTo(t,e){let n=new Bb(t);this._appendDefinition(t,_m(0,n,this.state.owner,null,!0),e)}_appendDefinition(t,e,n){let r=de(e),i=new Ew(null,le),s=new Lw(t,this.state.context,this.state.owner,this._rootTemplate,r,n,i,this.state.builder);this.state.renderRoot(s,this)}cleanupRootFor(t){if(it(this))return;let e=this.state.roots,n=e.length;for(;n--;){let r=e[n];"classic"===r.type&&r.isFor(t)&&(r.destroy(),e.splice(n,1))}}remove(t){t._transitionTo("destroying"),this.cleanupRootFor(t),this.state.isInteractive&&t.trigger("didDestroyElement")}get _roots(){return this.state.debug.roots}get _inRenderTransaction(){return this.state.debug.inRenderTransaction}get _isInteractive(){return this.state.debug.isInteractive}get _context(){return this.state.context}register(t){let e=Kl(t);this._viewRegistry[e]=t}unregister(t){delete this._viewRegistry[Kl(t)]}getElement(t){if(this._isInteractive)return Jl(t);throw new Error("Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).")}getBounds(t){let e=t[Lv];return{parentElement:e.parentElement(),firstNode:e.firstNode(),lastNode:e.lastNode()}}},Dw=class extends uu{rootElement=null;init(t){super.init(t),this.application._watchInstance(this),this.register("-application-instance:main",this,{instantiate:!1})}_bootSync(t){return this._booted||(t=new zw(t),this.setupRegistry(t),t.rootElement?this.rootElement=t.rootElement:this.rootElement=this.application.rootElement,t.location&&gr(this.router,"location",t.location),this.application.runInstanceInitializers(this),t.isInteractive&&this.setupEventDispatcher(),this._booted=!0),this}setupRegistry(t){this.constructor.setupRegistry(this.__registry__,t)}_router;get router(){if(!this._router){let t=this.lookup("router:main");this._router=t}return this._router}didCreateRootView(t){t.appendTo(this.rootElement)}startRouting(){this.router.startRouting()}setupRouter(){this.router.setupRouter()}handleURL(t){return this.setupRouter(),this.router.handleURL(t)}setupEventDispatcher(){let t=this.lookup("event_dispatcher:main"),e=ur(this.application,"customEvents"),n=ur(this,"customEvents"),r=Object.assign({},e,n);return t.setup(r,this.rootElement),t}getURL(){return this.router.url}visit(t){this.setupRouter();let e=this.__container__.lookup("-environment:main"),n=this.router,r=ur(n,"location");return r.setURL(t),n.handleURL(r.getURL()).followRedirects().then(()=>e.options.shouldRender?function(){if(null===Mw){let t;Mw={promise:new Promise(e=>t=e),resolve:t},ms()||bs.schedule("actions",null,Rw)}return Mw.promise}().then(()=>this):this,t=>{throw t.error&&t.error instanceof Error?t.error:"TransitionAborted"===t.name?new Error(t.message):t})}willDestroy(){super.willDestroy(),this.application._unwatchInstance(this)}static setupRegistry(t,e={}){let n=e instanceof zw?e:new zw(e);t.register("-environment:main",n.toEnvironment(),{instantiate:!1}),t.register("service:-document",n.document,{instantiate:!1}),super.setupRegistry(t,n)}},zw=class{isInteractive;_renderMode;isBrowser;location=null;shouldRender;document;rootElement;constructor(t={}){this.isInteractive=Boolean(Mo),this._renderMode=t._renderMode,void 0!==t.isBrowser?this.isBrowser=Boolean(t.isBrowser):this.isBrowser=Boolean(Mo),this.isBrowser||(this.isInteractive=!1,this.location="none"),void 0!==t.shouldRender?this.shouldRender=Boolean(t.shouldRender):this.shouldRender=!0,this.shouldRender||(this.isInteractive=!1),t.document?this.document=t.document:this.document="undefined"!=typeof document?document:null,t.rootElement&&(this.rootElement=t.rootElement),void 0!==t.location&&(this.location=t.location),void 0!==t.isInteractive&&(this.isInteractive=Boolean(t.isInteractive))}toEnvironment(){return{...kp,hasDOM:this.isBrowser,isInteractive:this.isInteractive,_renderMode:this._renderMode,options:this}}},jw=a({default:()=>Uw}),Uw=class extends Ul{static NAMESPACES=ai;static NAMESPACES_BY_ID=li;static processAll=fi;static byName=di;init(t){super.init(t),ci(this)}toString(){let t=ur(this,"name")||ur(this,"modulePrefix");if(t)return t;hi();let e=ni(this);return void 0===e&&(e=al(this),ei(this,e)),e}nameClasses(){pi(this)}destroy(){return ui(this),super.destroy()}};Uw.prototype.isNamespace=!0;var Bw=function(){function t(){this._vertices=new $w}return t.prototype.add=function(t,e,n,r){if(!t)throw new Error("argument `key` is required");var i=this._vertices,s=i.add(t);if(s.val=e,n)if("string"==typeof n)i.addEdge(s,i.add(n));else for(var o=0;o0){var r="cycle detected: "+e;throw this.each(this.path,function(t){r+=" <- "+t}),new Error(r)}}},t.prototype.reset=function(){this.stack.length=0,this.path.length=0,this.result.length=0;for(var t=0,e=this.length;t=0){var a=this[o];if(a.flag)continue;if(a.flag=!0,i.push(o),e===a.key)break;r.push(~o),this.pushIncoming(a)}else i.pop(),s.push(~o)}},t.prototype.pushIncoming=function(t){for(var e=this.stack,n=t.length-1;n>=0;n--){var r=t[n];this[r].flag||e.push(r)}},t.prototype.each=function(t,e){for(var n=0,r=t.length;n{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.test(e)&&"class"===Sc(t[e])&&n.push(ip(e.replace(r,"")))}),n}},Ww=eb;function Hw(){}var Gw=class{static toString(){return"internal component"}constructor(t,e,n){this.owner=t,this.args=e,this.caller=n,Br(this,t)}get id(){return al(this)}get class(){return"ember-view"}validateArguments(){for(let t of Object.keys(this.args.named))this.isSupportedArgument(t)||this.onUnsupportedArgument(t)}named(t){let e=this.args.named[t];return e?we(e):void 0}positional(t){let e=this.args.positional[t];return e?we(e):void 0}listenerFor(t){return this.named(t)||Hw}isSupportedArgument(t){return!1}onUnsupportedArgument(t){}toString(){return`<${this.constructor}:${al(this)}>`}},Kw=new WeakMap;function Zw(t,e){let n={create(){throw void 0},toString:()=>t.toString()};return Kw.set(n,t),Nu(Xw,n),Ap(e,n),n}var Yw={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!0,dynamicScope:!1,updateHook:!1,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1},Xw=new class{getCapabilities(){return Yw}create(t,e,n,r,i,s){let o=new(a=e,Kw.get(a))(t,n.capture(),we(s));var a;return Vt(o.validateArguments.bind(o)),o}didCreate(){}didUpdate(){}didRenderLayout(){}didUpdateLayout(){}getDebugName(t){return t.toString()}getSelf(t){return de(t)}getDestroyable(t){return t}},Jw=rg({id:null,block:'[[[11,"input"],[16,1,[30,0,["id"]]],[16,0,[30,0,["class"]]],[17,1],[16,4,[30,0,["type"]]],[16,"checked",[30,0,["checked"]]],[16,2,[30,0,["value"]]],[4,[32,0],["change",[30,0,["change"]]],null],[4,[32,0],["input",[30,0,["input"]]],null],[4,[32,0],["keyup",[30,0,["keyUp"]]],null],[4,[32,0],["paste",[30,0,["valueDidChange"]]],null],[4,[32,0],["cut",[30,0,["valueDidChange"]]],null],[12],[13]],["&attrs"],[]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/input.hbs",scope:()=>({on:Ww}),isStrictMode:!0}),Qw=Object.freeze({});function t_(t){return function(t){return t.target}(t).value}function e_(t){return void 0===t?new r_(void 0):ve(t)?new r_(we(t)):be(t)?new i_(t):new s_(t)}var n_,r_=class{static{Gh(this.prototype,"value",[Vr])}#S=void Zh(this,"value");constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}},i_=class{constructor(t){this.reference=t}get(){return we(this.reference)}set(t){_e(this.reference,t)}},s_=class{local;upstream;lastUpstreamValue=Qw;constructor(t){this.upstream=new i_(t)}get(){let t=this.upstream.get();return t!==this.lastUpstreamValue&&(this.lastUpstreamValue=t,this.local=new r_(t)),this.local.get()}set(t){this.local.set(t)}},o_=class extends Gw{validateArguments(){super.validateArguments()}_value=e_(this.args.named.value);get value(){return this._value.get()}set value(t){this._value.set(t)}valueDidChange(t){this.value=t_(t)}static{Kh(this.prototype,"valueDidChange",[ql])}change(t){this.valueDidChange(t)}input(t){this.valueDidChange(t)}keyUp(t){switch(t.key){case"Enter":this.listenerFor("enter")(t),this.listenerFor("insert-newline")(t);break;case"Escape":this.listenerFor("escape-press")(t)}}static{Kh(this.prototype,"keyUp",[ql])}listenerFor(t){let e=super.listenerFor(t);return this.isVirtualEventListener(t,e)?function(t){return e=>t(t_(e),e)}(e):e}isVirtualEventListener(t,e){return-1!==["enter","insert-newline","escape-press"].indexOf(t)}};if(Mo){const t=Object.create(null),e=document.createElement("input");t[""]=!1,t.text=!0,t.checkbox=!0,n_=n=>{let r=t[n];if(void 0===r){try{e.type=n,r=e.type===n}catch(i){r=!1}finally{e.type="text"}t[n]=r}return r}}else n_=t=>""!==t;var a_=class extends o_{static toString(){return"Input"}get class(){return this.isCheckbox?"ember-checkbox ember-view":"ember-text-field ember-view"}get type(){let t=this.named("type");return null==t?"text":n_(t)?t:"text"}get isCheckbox(){return"checkbox"===this.named("type")}_checked=e_(this.args.named.checked);get checked(){return this.isCheckbox?this._checked.get():void 0}set checked(t){this._checked.set(t)}change(t){this.isCheckbox?this.checkedDidChange(t):super.change(t)}static{Kh(this.prototype,"change",[ql])}input(t){this.isCheckbox||super.input(t)}static{Kh(this.prototype,"input",[ql])}checkedDidChange(t){let e=t.target;this.checked=e.checked}static{Kh(this.prototype,"checkedDidChange",[ql])}isSupportedArgument(t){return-1!==["type","value","checked","enter","insert-newline","escape-press"].indexOf(t)||super.isSupportedArgument(t)}},l_=Zw(a_,Jw),c_=rg({id:null,block:'[[[11,"textarea"],[16,1,[30,0,["id"]]],[16,0,[30,0,["class"]]],[17,1],[16,2,[30,0,["value"]]],[4,[32,0],["change",[30,0,["change"]]],null],[4,[32,0],["input",[30,0,["input"]]],null],[4,[32,0],["keyup",[30,0,["keyUp"]]],null],[4,[32,0],["paste",[30,0,["valueDidChange"]]],null],[4,[32,0],["cut",[30,0,["valueDidChange"]]],null],[12],[13]],["&attrs"],[]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/textarea.hbs",scope:()=>({on:Ww}),isStrictMode:!0}),u_=class extends o_{static toString(){return"Textarea"}get class(){return"ember-text-area ember-view"}change(t){super.change(t)}static{Kh(this.prototype,"change",[ql])}input(t){super.input(t)}static{Kh(this.prototype,"input",[ql])}isSupportedArgument(t){return-1!==["type","value","enter","insert-newline","escape-press"].indexOf(t)||super.isSupportedArgument(t)}},h_=Zw(u_,c_),d_=rg({id:null,block:'[[[11,3],[16,1,[30,0,["id"]]],[16,0,[30,0,["class"]]],[16,"role",[30,0,["role"]]],[16,"title",[30,0,["title"]]],[16,"rel",[30,0,["rel"]]],[16,"tabindex",[30,0,["tabindex"]]],[16,"target",[30,0,["target"]]],[17,1],[16,6,[30,0,["href"]]],[4,[32,0],["click",[30,0,["click"]]],null],[12],[18,2,null],[13]],["&attrs","&default"],["yield"]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/link-to.hbs",scope:()=>({on:Ww}),isStrictMode:!0}),p_=[],f_={};function g_(t){return null==t}function m_(t){return"object"==typeof t&&null!==t&&!0===t.isQueryParams}var y_=class extends Gw{static toString(){return"LinkTo"}static{Gh(this.prototype,"routing",[dp("-routing")])}#k=void Zh(this,"routing");validateArguments(){super.validateArguments()}get class(){let t="ember-view";return this.isActive?(t+=this.classFor("active"),!1===this.willBeActive&&(t+=" ember-transitioning-out")):this.willBeActive&&(t+=" ember-transitioning-in"),this.isLoading&&(t+=this.classFor("loading")),this.isDisabled&&(t+=this.classFor("disabled")),t}get href(){if(this.isLoading)return"#";let{routing:t,route:e,models:n,query:r}=this;return Nt(Kt(t,"currentState")),t.generateURL(e,n,r)}click(t){if(!Wl(t))return;let e=t.currentTarget,n=e instanceof SVGAElement?e.target.baseVal:e.target;if(""!==n&&"_self"!==n)return;if(this.preventDefault(t),this.isDisabled)return;if(this.isLoading)return;let{routing:r,route:i,models:s,query:o,replace:a}=this,l={transition:void 0};cv(0,0,()=>{l.transition=r.transitionTo(i,s,o,a)})}static{Kh(this.prototype,"click",[ql])}get route(){if("route"in this.args.named){let t=this.named("route");return t&&this.namespaceRoute(t)}return this.currentRoute}currentRouteCache=Ut(()=>(Nt(Kt(this.routing,"currentState")),Vt(()=>this.routing.currentRouteName)));get currentRoute(){return Bt(this.currentRouteCache)}get models(){return"models"in this.args.named?this.named("models"):"model"in this.args.named?[this.named("model")]:p_}get query(){return"query"in this.args.named?{...this.named("query")}:f_}get replace(){return!0===this.named("replace")}get isActive(){return this.isActiveForState(this.routing.currentState)}get willBeActive(){let t=this.routing.currentState,e=this.routing.targetState;return t===e?null:this.isActiveForState(e)}get isLoading(){return g_(this.route)||this.models.some(t=>g_(t))}get isDisabled(){return Boolean(this.named("disabled"))}get isEngine(){return void 0!==ou(this.owner)}get engineMountPoint(){return this.owner.mountPoint}classFor(t){let e=this.named(`${t}Class`);return!0===e||g_(e)?` ${t}`:e?` ${e}`:""}namespaceRoute(t){let{engineMountPoint:e}=this;return void 0===e?t:"application"===t?e:`${e}.${t}`}isActiveForState(t){if(g_(t))return!1;if(this.isLoading)return!1;let e=this.named("current-when");if("boolean"==typeof e)return e;if("string"==typeof e){let{routing:n}=this;return e.split(" ").some(e=>n.isActiveForRoute([],void 0,this.namespaceRoute(e),t))}{let{route:e,models:n,query:r,routing:i}=this;return i.isActiveForRoute(n,r,e,t)}}preventDefault(t){t.preventDefault()}isSupportedArgument(t){return-1!==["route","model","models","query","replace","disabled","current-when","activeClass","loadingClass","disabledClass"].indexOf(t)||super.isSupportedArgument(t)}},{prototype:v_}=y_,b_=(t,e)=>t?Object.getOwnPropertyDescriptor(t,e)||b_(Object.getPrototypeOf(t),e):null;{let t=v_.onUnsupportedArgument;Object.defineProperty(v_,"onUnsupportedArgument",{configurable:!0,enumerable:!1,value:function(e){"href"===e||t.call(this,e)}})}{let t=b_(v_,"models").get;Object.defineProperty(v_,"models",{configurable:!0,enumerable:!1,get:function(){let e=t.call(this);return e.length>0&&!("query"in this.args.named)&&m_(e[e.length-1])&&(e=e.slice(0,-1)),e}});let e=b_(v_,"query").get;Object.defineProperty(v_,"query",{configurable:!0,enumerable:!1,get:function(){if("query"in this.args.named){let t=e.call(this);return m_(t)?t.values??f_:t}{let e=t.call(this);if(e.length>0){let t=e[e.length-1];if(m_(t)&&null!==t.values)return t.values}return f_}}})}{let t=v_.onUnsupportedArgument;Object.defineProperty(v_,"onUnsupportedArgument",{configurable:!0,enumerable:!1,value:function(e){"params"!==e&&t.call(this,e)}})}var w_=Zw(y_,d_),__="%+b:0%";function x_(t){return t.nodeValue===__}var C_=class extends fg{candidate=null;openBlockDepth;injectedOmittedNode=!1;constructor(t,e,n){super(t,e),this.startingBlockDepth=n,this.openBlockDepth=n-1}},S_=class extends Qg{unmatchedAttributes=null;blockDepth=0;startingBlockOffset;constructor(t,e,n){if(super(t,e,n),n)throw new Error("Rehydration with nextSibling not supported");let r=this.currentCursor.element.firstChild;for(;null!==r&&!k_(r);)r=r.nextSibling;this.candidate=r;const i=R_(r);if(0!==i){const t=i-1,e=this.dom.createComment(`%+b:${t}%`);r.parentNode.insertBefore(e,this.candidate);let n=r.nextSibling;for(;null!==n&&(!E_(n)||R_(n)!==i);)n=n.nextSibling;const s=this.dom.createComment(`%-b:${t}%`);r.parentNode.insertBefore(s,n.nextSibling),this.candidate=e,this.startingBlockOffset=t}else this.startingBlockOffset=0}get currentCursor(){return this.cursors.current}get candidate(){return this.currentCursor?this.currentCursor.candidate:null}set candidate(t){this.currentCursor.candidate=t}disableRehydration(t){const e=this.currentCursor;e.candidate=null,e.nextSibling=t}enableRehydration(t){const e=this.currentCursor;e.candidate=t,e.nextSibling=null}pushElement(t,e=null){const n=new C_(t,e,this.blockDepth||0);null!==this.candidate&&(n.candidate=t.firstChild,this.candidate=t.nextSibling),this.cursors.push(n)}clearMismatch(t){let e=t;const n=this.currentCursor;if(null!==n){const t=n.openBlockDepth;if(t>=n.startingBlockDepth)for(;e&&!(E_(e)&&t>=T_(e,this.startingBlockOffset));)e=this.remove(e);else for(;null!==e;)e=this.remove(e);this.disableRehydration(e)}}__openBlock(){const{currentCursor:t}=this;if(null===t)return;const e=this.blockDepth;this.blockDepth++;const{candidate:n}=t;if(null===n)return;const{tagName:r}=t.element;k_(n)&&T_(n,this.startingBlockOffset)===e?(this.candidate=this.remove(n),t.openBlockDepth=e):"TITLE"!==r&&"SCRIPT"!==r&&"STYLE"!==r&&this.clearMismatch(n)}__closeBlock(){const{currentCursor:t}=this;if(null===t)return;const e=t.openBlockDepth;this.blockDepth--;const{candidate:n}=t;let r=!1;if(null!==n)if(r=!0,E_(n)&&T_(n,this.startingBlockOffset)===e){const e=this.remove(n);this.candidate=e,t.openBlockDepth--}else this.clearMismatch(n),r=!1;if(!r){const e=t.nextSibling;if(null!==e&&E_(e)&&T_(e,this.startingBlockOffset)===this.blockDepth){const n=this.remove(e);this.enableRehydration(n),t.openBlockDepth--}}}__appendNode(t){const{candidate:e}=this;return e||super.__appendNode(t)}__appendHTML(t){const e=this.markerBounds();if(e){const t=e.firstNode(),n=e.lastNode(),r=new gg(this.element,t.nextSibling,n.previousSibling),i=this.remove(t);return this.remove(n),null!==i&&P_(i)&&(this.candidate=this.remove(i),null!==this.candidate&&this.clearMismatch(this.candidate)),r}return super.__appendHTML(t)}remove(t){const e=t.parentNode,n=t.nextSibling;return e.removeChild(t),n}markerBounds(){const t=this.candidate;if(t&&I_(t)){const e=t;let n=e.nextSibling;for(;!I_(n);)n=Xt(n.nextSibling);return new gg(this.element,e,n)}return null}__appendText(t){const{candidate:e}=this;return e?3===e.nodeType?(e.nodeValue!==t&&(e.nodeValue=t),this.candidate=e.nextSibling,e):8===(n=e).nodeType&&"%|%"===n.nodeValue||P_(e)&&""===t?(this.candidate=this.remove(e),this.__appendText(t)):(this.clearMismatch(e),super.__appendText(t)):super.__appendText(t);var n}__appendComment(t){const e=this.candidate;return e&&8===e.nodeType?(e.nodeValue!==t&&(e.nodeValue=t),this.candidate=e.nextSibling,e):(e&&this.clearMismatch(e),super.__appendComment(t))}__openElement(t){const e=this.candidate;if(e&&L_(e)&&function(t,e){return"http://www.w3.org/2000/svg"===t.namespaceURI?t.tagName===e:t.tagName===e.toUpperCase()}(e,t))return this.unmatchedAttributes=[].slice.call(e.attributes),e;if(e){if(L_(e)&&"TBODY"===e.tagName)return this.pushElement(e,null),this.currentCursor.injectedOmittedNode=!0,this.__openElement(t);this.clearMismatch(e)}return super.__openElement(t)}__setAttribute(t,e,n){const r=this.unmatchedAttributes;if(r){const n=M_(r,t);if(n)return n.value!==e&&(n.value=e),void r.splice(r.indexOf(n),1)}return super.__setAttribute(t,e,n)}__setProperty(t,e){const n=this.unmatchedAttributes;if(n){const r=M_(n,t);if(r)return r.value!==e&&(r.value=e),void n.splice(n.indexOf(r),1)}return super.__setProperty(t,e)}__flushElement(t,e){const{unmatchedAttributes:n}=this;if(n){for(const t of n)this.constructing.removeAttribute(t.name);this.unmatchedAttributes=null}else super.__flushElement(t,e)}willCloseElement(){const{candidate:t,currentCursor:e}=this;null!==t&&this.clearMismatch(t),e&&e.injectedOmittedNode&&this.popElement(),super.willCloseElement()}getMarker(t,e){const n=t.querySelector(`script[glmr="${e}"]`);return n?(function(t){t.nodeType}(r=n),r):null;var r}__pushRemoteElement(t,e,n){const r=this.getMarker(t,e);if(!r||r.parentNode,void 0===n){for(;null!==t.firstChild&&t.firstChild!==r;)this.remove(t.firstChild);n=null}const i=new C_(t,null,this.blockDepth);this.cursors.push(i),null===r?this.disableRehydration(n):this.candidate=this.remove(r);const s=new em(t);return this.pushBlock(s,!0)}didAppendBounds(t){if(super.didAppendBounds(t),this.candidate){const e=t.lastNode();this.candidate=e.nextSibling}return t}};function k_(t){return 8===t.nodeType&&0===t.nodeValue.lastIndexOf("%+b:",0)}function E_(t){return 8===t.nodeType&&0===t.nodeValue.lastIndexOf("%-b:",0)}function R_(t){return parseInt(t.nodeValue.slice(4),10)}function T_(t,e){return R_(t)-e}function L_(t){return 1===t.nodeType}function I_(t){return 8===t.nodeType&&"%glmr%"===t.nodeValue}function P_(t){return 8===t.nodeType&&"% %"===t.nodeValue}function M_(t,e){for(const n of t)if(n.name===e)return n}function A_(t,e){return S_.forInitialRender(t,e)}var O_=new WeakMap,N_=class extends Qg{serializeBlockDepth=0;__openBlock(){let{tagName:t}=this.element;if("TITLE"!==t&&"SCRIPT"!==t&&"STYLE"!==t){let t=this.serializeBlockDepth++;this.__appendComment(`%+b:${t}%`)}super.__openBlock()}__closeBlock(){let{tagName:t}=this.element;if(super.__closeBlock(),"TITLE"!==t&&"SCRIPT"!==t&&"STYLE"!==t){let t=--this.serializeBlockDepth;this.__appendComment(`%-b:${t}%`)}}__appendHTML(t){let{tagName:e}=this.element;if("TITLE"===e||"SCRIPT"===e||"STYLE"===e)return super.__appendHTML(t);let n=this.__appendComment("%glmr%");if("TABLE"===e){let e=t.indexOf("<");e>-1&&"tr"===t.slice(e+1,e+3)&&(t=`${t}`)}""===t?this.__appendComment("% %"):super.__appendHTML(t);let r=this.__appendComment("%glmr%");return new gg(this.element,n,r)}__appendText(t){let{tagName:e}=this.element,n=function(t){let{element:e,nextSibling:n}=t;return null===n?e.lastChild:n.previousSibling}(this);return"TITLE"===e||"SCRIPT"===e||"STYLE"===e?super.__appendText(t):""===t?this.__appendComment("% %"):(n&&3===n.nodeType&&this.__appendComment("%|%"),super.__appendText(t))}closeElement(){return O_.has(this.element)&&(O_.delete(this.element),super.closeElement()),super.closeElement()}openElement(t){return"tr"===t&&"TBODY"!==this.element.tagName&&"THEAD"!==this.element.tagName&&"TFOOT"!==this.element.tagName&&(this.openElement("tbody"),O_.set(this.constructing,!0),this.flushElement(null)),super.openElement(t)}pushRemoteElement(t,e,n=null){let{dom:r}=this,i=r.createElement("script");return i.setAttribute("glmr",e),r.insertBefore(t,i,n),super.pushRemoteElement(t,e,n)}};function F_(t,e){return N_.forInitialRender(t,e)}var D_=rg({id:null,block:'[[[46,[30,0],null,null,null]],[],["component"]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/root.hbs",isStrictMode:!0}),z_=rg({id:null,block:'[[[46,[28,[32,0],null,null],null,null,null]],[],["component"]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/outlet.hbs",scope:()=>({outletHelper:yw}),isStrictMode:!0});function j_(t){t.register("service:-dom-builder",{create(t){switch(Ur(t).lookup("-environment:main")._renderMode){case"serialize":return F_.bind(null);case"rehydrate":return A_.bind(null);default:return im.bind(null)}}}),t.register(mc`template:-root`,D_),t.register("renderer:-dom",Fw)}var U_=class t{moduleBasedResolver=!0;#E=new Map;original;static create({namespace:e}){return new t(e.modules)}constructor(t){this.addModules(t)}addModules(t){for(let[e,n]of Object.entries(t))this.#E.set(this.#R(e),n)}#R(t){return t.replace(B_,"").replace($_,"")}#T(t){return"config"===t?t:t+"s"}resolve(t){let[e,n]=t.split(":");n=this.#L(e,n);for(let r of[this.#I,this.#P,this.#M,this.#A]){let t=r.call(this,e,n);if(t)return this.#O(t.hit)}}#O(t){return t&&t.default&&(t=t.default),t}normalize(t){let[e,n]=t.split(":");return n=this.#L(e,n),`${e}:${n}`}#L(t,e){return"component"===t||"helper"===t||"modifier"===t||"template"===t&&0===e.indexOf("components/")?e.replace(/_/g,"-"):e.replace(/\./g,"/").replace(q_,"$1_$2").toLowerCase().replace(V_,"-")}#I(t,e){if("resolver"===t&&"current"===e)return{hit:{create:()=>this}}}#P(t,e){if("main"===e){let e=this.#E.get(t);if(e)return{hit:e}}}#M(t,e){let n=`${this.#T(t)}/${e}`,r=this.#E.get(n);if(r)return{hit:r}}#A(t,e){if("component"!==t)return;let n=`${this.#T(t)}/${e}/index`,r=this.#E.get(n);return r?{hit:r}:void 0}},B_=/\.\w{1,4}$/,$_=/^\.\//,q_=/([a-z\d])([A-Z])/g,V_=/[ _]/g,W_=class extends(Uw.extend(lu)){static initializers=Object.create(null);static instanceInitializers=Object.create(null);static initializer=G_("initializers");static instanceInitializer=G_("instanceInitializers");static buildRegistry(t){let e=new pc({resolver:H_(t)});return e.set=gr,e.register("application:main",t,{instantiate:!1}),function(t){t.optionsForType("component",{singleton:!1}),t.optionsForType("view",{singleton:!1}),t.register("controller:basic",tu,{instantiate:!1}),t.register("service:-routing",yp),t.register("resolver-for-debugging:main",t.resolver,{instantiate:!1}),t.register("container-debug-adapter:main",Vw)}(e),function(t){t.optionsForType("template",{instantiate:!1}),t.register("view:-outlet",kw),t.register("template:-outlet",z_),t.optionsForType("helper",{instantiate:!1}),t.register("component:input",l_),t.register("component:link-to",w_),t.register("component:textarea",h_)}(e),e}Resolver=U_;init(t){super.init(t),this.buildRegistry()}_initializersRan=!1;ensureInitializers(){this._initializersRan||(this.runInitializers(),this._initializersRan=!0)}buildInstance(t={}){return this.ensureInitializers(),uu.create({...t,base:this})}buildRegistry(){return this.__registry__=this.constructor.buildRegistry(this)}initializer(t){this.constructor.initializer(t)}instanceInitializer(t){this.constructor.instanceInitializer(t)}runInitializers(){this._runInitializer("initializers",(t,e)=>{e.initialize(this)})}runInstanceInitializers(t){this._runInitializer("instanceInitializers",(e,n)=>{n.initialize(t)})}_runInitializer(t,e){let n,r=ur(this.constructor,t),i=function(t){let e=[];for(let n in t)e.push(n);return e}(r),s=new Bw;for(let o of i)n=r[o],s.add(n.name,n,n.before,n.after);s.topsort(e)}};function H_(t){let e={namespace:t};return t.Resolver.create(e)}function G_(t){return function(e){let n=this.superclass;if(void 0!==n[t]&&n[t]===this[t]){let e={[t]:Object.create(this[t])};this.reopenClass(e)}this[t][e.name]=e}}var K_=a({default:()=>X_,getOwner:()=>Z_,setOwner:()=>Y_}),Z_=Io,Y_=Br,X_=class extends W_{static buildRegistry(t){let e=super.buildRegistry(t);return function(t){t.register("router:main",Md),t.register("-view-registry:main",{create:()=>Po(null)}),t.register("route:basic",Jh),t.register("event_dispatcher:main",hc),t.register("location:hash",Vd),t.register("location:history",Hd),t.register("location:none",Gd),t.register(mc`-bucket-cache:main`,{create:()=>new vp}),t.register("service:router",mp)}(e),j_(e),e}static initializer=G_("initializers");static instanceInitializer=G_("instanceInitializers");init(t){super.init(t),this.rootElement??="body",this._document??=null,this.eventDispatcher??=null,this.customEvents??=null,this.autoboot??=!0,this._document??=Mo?window.document:null,this._readinessDeferrals=1,this._booted=!1,this._applicationInstances=new Set,this.autoboot=Boolean(this.autoboot),this.autoboot&&(this.Router=(this.Router||Md).extend(),this._buildDeprecatedInstance(),this.waitForDOMReady())}buildInstance(t={}){return Dw.create({...t,base:this,application:this})}_watchInstance(t){this._applicationInstances.add(t)}_unwatchInstance(t){return this._applicationInstances.delete(t)}Router;__deprecatedInstance__;__container__;_buildDeprecatedInstance(){let t=this.buildInstance();this.__deprecatedInstance__=t,this.__container__=t.__container__}waitForDOMReady(){const t=this._document;if(null===t||"loading"!==t.readyState)ks("actions",this,this.domReady);else{let e=()=>{t.removeEventListener("DOMContentLoaded",e),ws(this,this.domReady)};t.addEventListener("DOMContentLoaded",e)}}domReady(){this.isDestroying||this.isDestroyed||this._bootSync()}deferReadiness(){this._readinessDeferrals++}advanceReadiness(){this._readinessDeferrals--,0===this._readinessDeferrals&&Ls(this,this.didBecomeReady)}_bootPromise=null;boot(){if(this._bootPromise)return this._bootPromise;try{this._bootSync()}catch(t){}return this._bootPromise}_bootResolver=null;_bootSync(){if(this._booted||this.isDestroying||this.isDestroyed)return;let t=this._bootResolver=Ba.defer();this._bootPromise=t.promise;try{this.runInitializers(),this.advanceReadiness()}catch(e6){throw t.reject(e6),e6}}reset(){let t=this.__deprecatedInstance__;this._readinessDeferrals=1,this._bootPromise=null,this._bootResolver=null,this._booted=!1,_s(this,function(){ws(t,"destroy"),this._buildDeprecatedInstance(),ks("actions",this,"_bootSync")})}didBecomeReady(){if(!this.isDestroying&&!this.isDestroyed)try{if(this.autoboot){let t=this.__deprecatedInstance__;t._bootSync(),this.ready(),t.startRouting()}this._bootResolver.resolve(this),this._booted=!0}catch(e6){throw this._bootResolver.reject(e6),e6}}ready(){return this}willDestroy(){super.willDestroy(),this._applicationInstances.size&&(this._applicationInstances.forEach(t=>t.destroy()),this._applicationInstances.clear())}visit(t,e){return this.boot().then(()=>{let n=this.buildInstance();return n.boot(e).then(()=>n.visit(t)).catch(t=>{throw ws(n,"destroy"),t})})}},J_=Object.assign({},{});function Q_(){return tx.global}var tx=globalThis.__embroider_macros__runtime_config__||={};tx.packages||={},tx.global||={};Object.assign(tx.packages,{}),Object.assign(tx.global,{});var ex="undefined"!=typeof window?window._embroider_macros_runtime_config:void 0;if(ex){let t={config:function(t){return tx.packages[t]},getGlobalConfig:Q_,setConfig(t,e){tx.packages[t]=e},setGlobalConfig(t,e){tx.global[t]=e}};for(let e of ex)e(t)}var nx=a({default:()=>rx,enterTestMode:()=>ix}),rx={modulePrefix:"marco",environment:"production",rootURL:"/",locationType:"history",EmberENV:{},APP:{}};function ix(){rx.locationType="none",rx.APP.rootElement="#ember-testing",rx.APP.autoboot=!1;const t=Q_()["@embroider/macros"];t&&(t.isTesting=!0)}var sx=()=>{},ox=()=>{};function ax(t){let e=t.lookup("renderer:-dom");if(!e)throw new Error("BUG: owner is missing renderer");return e.debugRenderTree.capture()}var lx=a({_warnIfUsingStrippedFeatureFlags:()=>{},assert:()=>Cn,captureRenderTree:()=>ax,debug:()=>dx,debugFreeze:()=>fx,debugSeal:()=>px,deprecate:()=>bx,deprecateFunc:()=>vx,getDebugFunction:()=>yx,info:()=>ux,inspect:()=>Pn,isTesting:()=>ru,registerDeprecationHandler:()=>sx,registerWarnHandler:()=>ox,runInDebug:()=>gx,setDebugFunction:()=>mx,setTesting:()=>iu,warn:()=>hx}),cx=()=>{},ux=cx,hx=cx,dx=cx,px=cx,fx=cx,gx=cx,mx=cx,yx=cx,vx=function(){return arguments[arguments.length-1]};function bx(){}var wx,_x=a({});wx={throwOnUnhandled:!1,workflow:[]},self.deprecationWorkflow=self.deprecationWorkflow||{},self.deprecationWorkflow.deprecationLog={messages:new Set},self.deprecationWorkflow.flushDeprecations=t=>function({handler:t="silence",config:e={}}={}){let n=self.deprecationWorkflow.deprecationLog.messages,r=e.workflow??[],i=n.values().filter(t=>!r.some(e=>e.matchId===t)).map(e=>({handler:t,matchId:e})),s={...e,workflow:[...r,...i]};return`import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';\n\nsetupDeprecationWorkflow(${JSON.stringify(s,void 0,2)});`}({config:wx,...t}),function(){const t="TEST_WAITERS",e="undefined"!=typeof Symbol?Symbol.for(t):t,n=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;throw new Error("unable to locate global object")}();let r=n[e];void 0===r&&(r=n[e]=new Map)}();var xx=class{name;constructor(t){this.name=t}beginAsync(){return this}endAsync(){}waitUntil(){return!0}debugInfo(){return[]}reset(){}};function Cx(t){return new xx(t)}Cx("@ember/test-waiters:promise-waiter"),Cx("@ember/test-waiters:generator-waiter");var Sx,kx=a({assertDestroyablesDestroyed:()=>{},associateDestroyableChild:()=>Q,destroy:()=>et,enableDestroyableTracking:()=>{},isDestroyed:()=>it,isDestroying:()=>rt,registerDestructor:()=>Ex,unregisterDestructor:()=>Rx});function Ex(t,e){return tt(t,e)}function Rx(t,e){return function(t,e,n=!1){let r=J(t),i=n?"eagerDestructors":"destructors";r[i]=X(r[i],e)}(t,e)}(Sx=Lo,Sx?.__esModule?Sx:{default:Sx,...Sx}).getOwner;var Tx=Md,Lx=a({default:()=>Ix}),Ix=class extends Tx{location=rx.locationType;rootURL=rx.rootURL};function Px(t){return 0===t||3===t||1e4<=t&&t<2e4}function Mx(t){return 3e4<=t&&t<4e4}function Ax(t,e){const n=e instanceof Array?e:[e];return function(t){if(!(t instanceof Object))return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.pubkey)return!1;if(!t.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(t.tags))return!1;for(let e=0;e0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Fx(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}Ix.map(function(){this.route("place",{path:"/place/:place_id"}),this.route("place.new",{path:"/place/new"}),this.route("search"),this.route("menu"),this.route("lists",function(){this.route("list",{path:"/:list_id"})}),this.route("contributions"),this.route("oauth",function(){this.route("osm-callback",{path:"/osm/callback"})})});var Dx="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,zx=t=>t instanceof Uint8Array,jx=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ux=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Bx(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!zx(t))throw new Error("expected Uint8Array, got "+typeof t);return t}var $x=class{clone(){return this._cloneInto()}};function qx(t){const e=e=>t().update(Bx(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Vx(t=32){if(Dx&&"function"==typeof Dx.getRandomValues)return Dx.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}var Wx=class extends $x{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=jx(this.buffer)}update(t){Fx(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Bx(t)).length;for(let s=0;sr-s&&(this.process(n,0),s=0);for(let u=s;u>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=jx(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;ut&e^~t&n,Gx=(t,e,n)=>t&e^t&n^e&n,Kx=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Zx=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yx=new Uint32Array(64),Xx=class extends Wx{constructor(){super(64,32,8,!1),this.A=0|Zx[0],this.B=0|Zx[1],this.C=0|Zx[2],this.D=0|Zx[3],this.E=0|Zx[4],this.F=0|Zx[5],this.G=0|Zx[6],this.H=0|Zx[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[t,e,n,r,i,s,o,a]}set(t,e,n,r,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let u=0;u<16;u++,e+=4)Yx[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){const t=Yx[u-15],e=Yx[u-2],n=Ux(t,7)^Ux(t,18)^t>>>3,r=Ux(e,17)^Ux(e,19)^e>>>10;Yx[u]=r+Yx[u-7]+n+Yx[u-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let u=0;u<64;u++){const t=c+(Ux(o,6)^Ux(o,11)^Ux(o,25))+Hx(o,a,l)+Kx[u]+Yx[u]|0,e=(Ux(n,2)^Ux(n,13)^Ux(n,22))+Gx(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){Yx.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Jx=qx(()=>new Xx),Qx=a({bitGet:()=>bC,bitLen:()=>vC,bitMask:()=>_C,bitSet:()=>wC,bytesToHex:()=>sC,bytesToNumberBE:()=>cC,bytesToNumberLE:()=>uC,concatBytes:()=>gC,createHmacDrbg:()=>SC,ensureBytes:()=>fC,equalBytes:()=>mC,hexToBytes:()=>lC,hexToNumber:()=>aC,numberToBytesBE:()=>hC,numberToBytesLE:()=>dC,numberToHexUnpadded:()=>oC,numberToVarBytesBE:()=>pC,utf8ToBytes:()=>yC,validateObject:()=>EC}),tC=BigInt(0),eC=BigInt(1),nC=BigInt(2),rC=t=>t instanceof Uint8Array,iC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function sC(t){if(!rC(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+e.length,0));let n=0;return t.forEach(t=>{if(!rC(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}function mC(t,e){if(t.length!==e.length)return!1;for(let n=0;ntC;t>>=eC,e+=1);return e}function bC(t,e){return t>>BigInt(e)&eC}var wC=(t,e,n)=>t|(n?eC:tC)<(nC<new Uint8Array(t),CC=t=>Uint8Array.from(t);function SC(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=xC(t),i=xC(t),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...t)=>n(i,r,...t),l=(t=xC())=>{i=a(CC([0]),t),r=a(),0!==t.length&&(i=a(CC([1]),t),r=a())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t{let n;for(o(),l(t);!(n=e(c()));)l();return o(),n}}var kC={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function EC(t,e,n={}){const r=(e,n,r)=>{const i=kC[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const s=t[e];if(!(r&&void 0===s||i(s,t)))throw new Error(`Invalid param ${String(e)}=${s} (${typeof s}), expected ${n}`)};for(const[i,s]of Object.entries(e))r(i,s,!1);for(const[i,s]of Object.entries(n))r(i,s,!0);return t}var RC=BigInt(0),TC=BigInt(1),LC=BigInt(2),IC=BigInt(3),PC=BigInt(4),MC=BigInt(5),AC=BigInt(8);function OC(t,e){const n=t%e;return n>=RC?n:e+n}function NC(t,e,n){if(n<=RC||e 0");if(n===TC)return RC;let r=TC;for(;e>RC;)e&TC&&(r=r*t%n),t=t*t%n,e>>=TC;return r}function FC(t,e,n){let r=t;for(;e-- >RC;)r*=r,r%=n;return r}function DC(t,e){if(t===RC||e<=RC)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=OC(t,e),r=e,i=RC,s=TC,o=TC,a=RC;for(;n!==RC;){const t=r/n,e=r%n,l=i-o*t,c=s-a*t;r=n,n=e,i=o,s=a,o=l,a=c}if(r!==TC)throw new Error("invert: does not exist");return OC(i,e)}BigInt(9),BigInt(16);var zC=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function jC(t,e){const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function UC(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function BC(t){const e=UC(t);return e+Math.ceil(e/2)}var $C=BigInt(0),qC=BigInt(1);function VC(t){return function(t){const e=zC.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});EC(t,e)}(t.Fp),EC(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...jC(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var{bytesToNumberBE:WC,hexToBytes:HC}=Qx,GC={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=GC;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:WC(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=GC,n="string"==typeof t?HC(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=GC._parseInt(n.subarray(2)),{d:o,l:a}=GC._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),i=e(n(t.r)),s=r.length/2,o=i.length/2,a=n(s),l=n(o);return`30${n(o+s+4)}02${l}${i}02${a}${r}`}},KC=BigInt(0),ZC=BigInt(1),YC=BigInt(3);var XC=class extends $x{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Ox(t.outputLen),Ox(t.blockLen)}(t);const n=Bx(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let s=0;snew XC(t,e).update(n).digest();function QC(t){return{hash:t,hmac:(e,...n)=>JC(t,e,function(...t){const e=new Uint8Array(t.reduce((t,e)=>t+e.length,0));let n=0;return t.forEach(t=>{if(!zx(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}(...n)),randomBytes:Vx}}JC.create=(t,e)=>new XC(t,e);var tS=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),eS=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),nS=BigInt(1),rS=BigInt(2),iS=(t,e)=>(t+e/rS)/e;function sS(t){const e=tS,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=FC(u,n,e)*u%e,d=FC(h,n,e)*u%e,p=FC(d,rS,e)*c%e,f=FC(p,i,e)*p%e,g=FC(f,s,e)*f%e,m=FC(g,a,e)*g%e,y=FC(m,l,e)*m%e,v=FC(y,a,e)*g%e,b=FC(v,n,e)*u%e,w=FC(b,o,e)*f%e,_=FC(w,r,e)*c%e,x=FC(_,rS,e);if(!oS.eql(oS.sqr(x),t))throw new Error("Cannot find square root");return x}var oS=function(t,e,n=!1,r={}){if(t<=RC)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=jC(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=function(t){if(t%PC===IC){const e=(t+TC)/PC;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}if(t%AC===MC){const e=(t-MC)/AC;return function(t,n){const r=t.mul(n,LC),i=t.pow(r,e),s=t.mul(n,i),o=t.mul(t.mul(s,LC),i),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-TC)/LC;let n,r,i;for(n=t-TC,r=0;n%LC===RC;n/=LC,r++);for(i=LC;iOC(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return RC<=e&&et===RC,isOdd:t=>(t&TC)===TC,neg:e=>OC(-e,t),eql:(t,e)=>t===e,sqr:e=>OC(e*e,t),add:(e,n)=>OC(e+n,t),sub:(e,n)=>OC(e-n,t),mul:(e,n)=>OC(e*n,t),pow:(t,e)=>function(t,e,n){if(n 0");if(n===RC)return t.ONE;if(n===TC)return e;let r=t.ONE,i=e;for(;n>RC;)n&TC&&(r=t.mul(r,i)),i=t.sqr(i),n>>=TC;return r}(a,t,e),div:(e,n)=>OC(e*DC(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>DC(e,t),sqrt:r.sqrt||(t=>o(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),i=t.inv(r);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),i),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?dC(t,s):hC(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return n?uC(t):cC(t)}});return Object.freeze(a)}(tS,void 0,void 0,{sqrt:sS}),aS=function(t,e){const n=e=>function(t){const e=function(t){const e=VC(t);return EC(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,i=n.BYTES+1,s=2*n.BYTES+1;function o(t){return OC(t,r)}function a(t){return DC(t,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=function(t){const e=function(t){const e=VC(t);EC(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:n}=e,r=e.toBytes||((t,e)=>{const r=e.toAffine();return gC(Uint8Array.from([4]),n.toBytes(r.x),n.toBytes(r.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function s(t){const{a:r,b:i}=e,s=n.sqr(t),o=n.mul(s,t);return n.add(n.add(o,n.mul(t,r)),i)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(t){return"bigint"==typeof t&&KCn.eql(t,n.ZERO);return i(e)&&i(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(fC("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(t);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:i}=this,{px:s,py:o,pz:a}=t,l=n.eql(n.mul(e,a),n.mul(s,i)),c=n.eql(n.mul(r,a),n.mul(o,i));return l&&c}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,i=n.mul(r,YC),{px:s,py:o,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,d=n.mul(s,s),p=n.mul(o,o),f=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,a),u=n.add(u,u),l=n.mul(t,u),c=n.mul(i,f),c=n.add(l,c),l=n.sub(p,c),c=n.add(p,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(i,u),f=n.mul(t,f),g=n.sub(d,f),g=n.mul(t,g),g=n.add(g,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,f),d=n.mul(d,g),c=n.add(c,d),f=n.mul(o,a),f=n.add(f,f),d=n.mul(f,g),l=n.sub(l,d),u=n.mul(f,p),u=n.add(u,u),u=n.add(u,u),new h(l,c,u)}add(t){u(t);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:l}=t;let c=n.ZERO,d=n.ZERO,p=n.ZERO;const f=e.a,g=n.mul(e.b,YC);let m=n.mul(r,o),y=n.mul(i,a),v=n.mul(s,l),b=n.add(r,i),w=n.add(o,a);b=n.mul(b,w),w=n.add(m,y),b=n.sub(b,w),w=n.add(r,s);let _=n.add(o,l);return w=n.mul(w,_),_=n.add(m,v),w=n.sub(w,_),_=n.add(i,s),c=n.add(a,l),_=n.mul(_,c),c=n.add(y,v),_=n.sub(_,c),p=n.mul(f,w),c=n.mul(g,v),p=n.add(c,p),c=n.sub(y,p),p=n.add(y,p),d=n.mul(c,p),y=n.add(m,m),y=n.add(y,m),v=n.mul(f,v),w=n.mul(g,w),y=n.add(y,v),v=n.sub(m,v),v=n.mul(f,v),w=n.add(w,v),m=n.mul(y,w),d=n.add(d,m),m=n.mul(_,w),c=n.mul(b,c),c=n.sub(c,m),m=n.mul(b,y),p=n.mul(_,p),p=n.add(p,m),new h(c,d,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,t=>{const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(h.fromAffine)})}multiplyUnsafe(t){const r=h.ZERO;if(t===KC)return r;if(a(t),t===ZC)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:o,k2neg:l,k2:c}=i.splitScalar(t),u=r,d=r,f=this;for(;o>KC||c>KC;)o&ZC&&(u=u.add(f)),c&ZC&&(d=d.add(f)),f=f.double(),o>>=ZC,c>>=ZC;return s&&(u=u.negate()),l&&(d=d.negate()),d=new h(n.mul(d.px,i.beta),d.py,d.pz),u.add(d)}multiply(t){a(t);let r,i,s=t;const{endo:o}=e;if(o){const{k1neg:t,k1:e,k2neg:a,k2:l}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(e),{p:d,f:f}=this.wNAF(l);c=p.constTimeNegate(t,c),d=p.constTimeNegate(a,d),d=new h(n.mul(d.px,o.beta),d.py,d.pz),r=c.add(d),i=u.add(f)}else{const{p:t,f:e}=this.wNAF(s);r=t,i=e}return h.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,i=(t,e)=>e!==KC&&e!==ZC&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,n));return s.is0()?void 0:s}toAffine(t){const{px:e,py:r,pz:i}=this,s=this.is0();null==t&&(t=s?n.ONE:n.inv(i));const o=n.mul(e,t),a=n.mul(r,t),l=n.mul(i,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===ZC)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===ZC?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return sC(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,p=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,i=e;for(;n>$C;)n&qC&&(r=r.add(i)),i=i.double(),n>>=qC;return r},precomputeWindow(t,e){const{windows:n,windowSize:i}=r(e),s=[];let o=t,a=o;for(let r=0;r>=d,r>a&&(r-=h,s+=qC);const o=e,p=e+Math.abs(r)-1,f=t%2!=0,g=r<0;0===r?c=c.add(n(f,i[o])):l=l.add(n(g,i[p]))}return{p:l,f:c}},wNAFCached(t,e,n,r){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,r(s))),this.wNAF(i,s,n)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:o}}({...e,toBytes(t,e,r){const i=e.toAffine(),s=n.toBytes(i.x),o=gC;return r?o(Uint8Array.from([e.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(t){const e=t.length,r=t[0],o=t.subarray(1);if(e!==i||2!==r&&3!==r){if(e===s&&4===r)return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))};throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=cC(o);if(!(KC<(a=t)&&asC(hC(t,e.nByteLength));function p(t){return t>r>>ZC}const f=(t,e,n)=>cC(t.slice(e,n));class g{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=fC("compactSignature",t,2*n),new g(f(t,0,n),f(t,n,2*n))}static fromDER(t){const{r:e,s:n}=GC.toSig(fC("DER",t));return new g(e,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:i,recovery:s}=this,c=b(fC("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+d(u)),f=a(u),g=o(-c*f),m=o(i*f),y=l.BASE.multiplyAndAddUnsafe(p,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return lC(this.toDERHex())}toDERHex(){return GC.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return lC(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(t){try{return c(t),!0}catch(e6){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=BC(e.n);return function(t,e,n=!1){const r=t.length,i=UC(e),s=BC(e);if(r<16||r1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=OC(n?cC(t):uC(t),e-TC)+TC;return n?dC(o,i):hC(o,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=l.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function y(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===i||r===s:n?r===2*i||r===2*s:t instanceof l}const v=e.bits2int||function(t){const n=cC(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},b=e.bits2int_modN||function(t){return o(v(t))},w=_C(e.nBitLength);function _(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(KC<=t&&tt in i))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=e;let{lowS:d,prehash:f,extraEntropy:m}=i;null==d&&(d=!0),t=fC("msgHash",t),f&&(t=fC("prehashed msgHash",s(t)));const y=b(t),w=c(r),C=[_(w),_(y)];if(null!=m){const t=!0===m?u(n.BYTES):m;C.push(fC("extraEntropy",t))}const S=gC(...C),k=y;return{seed:S,k2sig:function(t){const e=v(t);if(!h(e))return;const n=a(e),r=l.BASE.multiply(e).toAffine(),i=o(r.x);if(i===KC)return;const s=o(n*o(k+i*w));if(s===KC)return;let c=(r.x===i?0:2)|Number(r.y&ZC),u=s;return d&&p(s)&&(u=function(t){return p(t)?o(-t):t}(s),c^=1),new g(i,u,c)}}}(t,r,i),d=e;return SC(d.hash.outputLen,d.nByteLength,d.hmac)(s,u)},verify:function(t,n,r,i=C){const s=t;if(n=fC("msgHash",n),r=fC("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=i;let h,d;try{if("string"==typeof s||s instanceof Uint8Array)try{h=g.fromDER(s)}catch(x){if(!(x instanceof GC.Err))throw x;h=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:t,s:e}=s;h=new g(t,e)}}d=l.fromHex(r)}catch(e6){if("PARSE"===e6.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&h.hasHighS())return!1;u&&(n=e.hash(n));const{r:p,s:f}=h,m=b(n),y=a(f),v=o(m*y),w=o(p*y),_=l.BASE.multiplyAndAddUnsafe(d,v,w)?.toAffine();return!!_&&o(_.x)===p},ProjectivePoint:l,Signature:g,utils:m}}({...t,...QC(e)});return Object.freeze({...n(e),create:n})}({a:BigInt(0),b:BigInt(7),Fp:oS,n:eS,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=eS,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-nS*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=iS(s*t,e),l=iS(-r*t,e);let c=OC(t-a*n-l*i,e),u=OC(-a*r-l*s,e);const h=c>o,d=u>o;if(h&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Jx),lS=BigInt(0),cS=t=>"bigint"==typeof t&&lSt.charCodeAt(0)));n=gC(e,e),uS[t]=n}return Jx(gC(n,...e))}var dS=t=>t.toRawBytes(!0).slice(1),pS=t=>hC(t,32),fS=t=>OC(t,tS),gS=t=>OC(t,eS),mS=aS.ProjectivePoint;function yS(t){let e=aS.utils.normPrivateKeyToScalar(t),n=mS.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:gS(-e),bytes:dS(n)}}function vS(t){if(!cS(t))throw new Error("bad x: need 0 < x < p");const e=fS(t*t);let n=sS(fS(e*t+BigInt(7)));n%rS!==lS&&(n=fS(-n));const r=new mS(t,n,nS);return r.assertValidity(),r}function bS(...t){return gS(cC(hS("BIP0340/challenge",...t)))}function wS(t){return yS(t).bytes}function _S(t,e,n=Vx(32)){const r=fC("message",t),{bytes:i,scalar:s}=yS(e),o=fC("auxRand",n,32),a=hS("BIP0340/nonce",pS(s^cC(hS("BIP0340/aux",o))),i,r),l=gS(cC(a));if(l===lS)throw new Error("sign failed: k is zero");const{bytes:c,scalar:u}=yS(l),h=bS(c,i,r),d=new Uint8Array(64);if(d.set(c,0),d.set(pS(gS(u+h*s)),32),!xS(d,r,i))throw new Error("sign: Invalid signature produced");return d}function xS(t,e,n){const r=fC("signature",t,64),i=fC("message",e),s=fC("publicKey",n,32);try{const t=vS(cC(s)),e=cC(r.subarray(0,32));if(!cS(e))return!1;const n=cC(r.subarray(32,64));if(!(t=>"bigint"==typeof t&&lS({getPublicKey:wS,sign:_S,verify:xS,utils:{randomPrivateKey:aS.utils.randomPrivateKey,lift_x:vS,pointToBytes:dS,numberToBytesBE:hC,bytesToNumberBE:cC,taggedHash:hS,mod:OC}}))(),SS="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,kS=t=>t instanceof Uint8Array,ES=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),RS=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");var TS=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function LS(t){if(!kS(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+e.length,0));let n=0;return t.forEach(t=>{if(!kS(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}var AS=class{clone(){return this._cloneInto()}};function OS(t){const e=e=>t().update(PS(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function NS(t=32){if(SS&&"function"==typeof SS.getRandomValues)return SS.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function FS(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function DS(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}var zS={number:FS,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:DS,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");FS(t.outputLen),FS(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},output:function(t,e){DS(t);const n=e.outputLen;if(t.lengthr-s&&(this.process(n,0),s=0);for(let u=s;u>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=ES(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;ut&e^~t&n,BS=(t,e,n)=>t&e^t&n^e&n,$S=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),qS=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),VS=new Uint32Array(64),WS=class extends jS{constructor(){super(64,32,8,!1),this.A=0|qS[0],this.B=0|qS[1],this.C=0|qS[2],this.D=0|qS[3],this.E=0|qS[4],this.F=0|qS[5],this.G=0|qS[6],this.H=0|qS[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[t,e,n,r,i,s,o,a]}set(t,e,n,r,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let u=0;u<16;u++,e+=4)VS[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){const t=VS[u-15],e=VS[u-2],n=RS(t,7)^RS(t,18)^t>>>3,r=RS(e,17)^RS(e,19)^e>>>10;VS[u]=r+VS[u-7]+n+VS[u-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let u=0;u<64;u++){const t=c+(RS(o,6)^RS(o,11)^RS(o,25))+US(o,a,l)+$S[u]+VS[u]|0,e=(RS(n,2)^RS(n,13)^RS(n,22))+BS(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){VS.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},HS=class extends WS{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},GS=OS(()=>new WS);function KS(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function ZS(...t){const e=(t,e)=>n=>t(e(n));return{encode:Array.from(t).reverse().reduce((t,n)=>t?e(t,n.encode):n.encode,void 0),decode:t.reduce((t,n)=>t?e(t,n.decode):n.decode,void 0)}}function YS(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map(e=>{if(KS(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]})},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map(e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const n=t.indexOf(e);if(-1===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n})}}}function XS(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function JS(t,e="="){if(KS(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function QS(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function tk(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const i=[],s=Array.from(t);for(s.forEach(t=>{if(KS(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)});;){let t=0,o=!0;for(let i=r;inew HS);var ek=(t,e)=>e?ek(e,t%e):t,nk=(t,e)=>t+(e-ek(t,e));function rk(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(nk(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${nk(e,n)}`);let i=0,s=0;const o=2**n-1,a=[];for(const l of t){if(KS(l),l>=2**e)throw new Error(`convertRadix2: invalid data word=${l} from=${e}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)a.push((i>>s-n&o)>>>0);i&=2**s-1}if(i=i<=e)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&s>0&&a.push(i>>>0),a}function ik(t,e=!1){if(KS(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(nk(8,t)>32||nk(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return rk(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(rk(n,t,8,e))}}}function sk(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(n){}}}var ok=ZS(ik(4),YS("0123456789ABCDEF"),XS("")),ak=ZS(ik(5),YS("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),JS(5),XS("")),lk=(ZS(ik(5),YS("0123456789ABCDEFGHIJKLMNOPQRSTUV"),JS(5),XS("")),ZS(ik(5),YS("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),XS(""),QS(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),ZS(ik(6),YS("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),JS(6),XS(""))),ck=ZS(ik(6),YS("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),JS(6),XS("")),uk=t=>ZS((KS(58),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return tk(Array.from(t),256,58)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(tk(t,58,256))}}),YS(t),XS("")),hk=uk("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),dk=(uk("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),uk("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),pk={encode(t){let e="";for(let n=0;n>25;let n=(33554431&t)<<5;for(let r=0;r>r&1)&&(n^=gk[r]);return n}function yk(t,e,n=1){const r=t.length;let i=1;for(let s=0;s126)throw new Error(`Invalid prefix (${t})`);i=mk(i)^e>>5}i=mk(i);for(let s=0;sn)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${n})`);const r=t.toLowerCase();if(t!==r&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(t=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const s=t.slice(0,i),o=t.slice(i+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=fk.decode(o).slice(0,-6),l=yk(s,a,e);if(!o.endsWith(l))throw new Error(`Invalid checksum in ${t}: expected "${l}"`);return{prefix:s,words:a}}return{encode:function(t,n,r=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const i=t.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${t=t.toLowerCase()}1${fk.encode(n)}${yk(t,n,e)}`},decode:o,decodeToBytes:function(t){const{prefix:e,words:n}=o(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:sk(o),fromWords:r,fromWordsUnsafe:s,toWords:i}}var bk=vk("bech32"),wk=(vk("bech32m"),{utf8:{encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},hex:ZS(ik(4),YS("0123456789abcdef"),XS(""),QS(t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),base16:ok,base32:ak,base64:lk,base64url:ck,base58:hk,base58xmr:pk});function _k(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function xk(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function Ck(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function Sk(t,...e){if(!Ck(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function kk(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ek(t,e){Sk(t);const n=e.outputLen;if(t.lengthnew Uint8Array(t.buffer,t.byteOffset,t.byteLength),Tk=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Lk=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");var Ik=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Pk(t){Sk(t);let e="";for(let n=0;n=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function Ak(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let i=0,s=0;i(Object.assign(e,t),e);function Dk(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}var zk=16,jk=new Uint8Array(16),Uk=Tk(jk),Bk=(t,e,n,r)=>({s3:n<<31|r>>>1,s2:e<<31|n>>>1,s1:t<<31|e>>>1,s0:t>>>1^225<<24&-(1&r)}),$k=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255,qk=class{constructor(t,e){this.blockLen=zk,this.outputLen=zk,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,Sk(t=Ok(t),16);const n=Lk(t);let r=n.getUint32(0,!1),i=n.getUint32(4,!1),s=n.getUint32(8,!1),o=n.getUint32(12,!1);const a=[];for(let d=0;d<128;d++)a.push({s0:$k(r),s1:$k(i),s2:$k(s),s3:$k(o)}),({s0:r,s1:i,s2:s,s3:o}=Bk(r,i,s,o));const l=(t=>t>65536?8:t>1024?4:2)(e||1024);if(![1,2,4,8].includes(l))throw new Error(`ghash: wrong window size=${l}, should be 2, 4 or 8`);this.W=l;const c=128/l,u=this.windowSize=2**l,h=[];for(let d=0;d>>l-s-1&1))continue;const{s0:o,s1:c,s2:u,s3:h}=a[l*d+s];e^=o,n^=c,r^=u,i^=h}h.push({s0:e,s1:n,s2:r,s3:i})}this.t=h}_updateBlock(t,e,n,r){t^=this.s0,e^=this.s1,n^=this.s2,r^=this.s3;const{W:i,t:s,windowSize:o}=this;let a=0,l=0,c=0,u=0;const h=(1<>>8*t&255;for(let t=8/i-1;t>=0;t--){const n=e>>>i*t&h,{s0:r,s1:p,s2:f,s3:g}=s[d*o+n];a^=r,l^=p,c^=f,u^=g,d+=1}}this.s0=a,this.s1=l,this.s2=c,this.s3=u}update(t){t=Ok(t),kk(this);const e=Tk(t),n=Math.floor(t.length/zk),r=t.length%zk;for(let i=0;i>>1|n,n=(1&e)<<7}return t[0]^=225&-e,t}((t=Ok(t)).slice());super(n,e),n.fill(0)}update(t){t=Ok(t),kk(this);const e=Tk(t),n=t.length%zk,r=Math.floor(t.length/zk);for(let i=0;it(n,e.length).update(Ok(e)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(e,n)=>t(e,n),e}var Hk=Wk((t,e)=>new qk(t,e)),Gk=Wk((t,e)=>new Vk(t,e)),Kk=16,Zk=new Uint8Array(Kk);function Yk(t){return t<<1^283&-(t>>7)}function Xk(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(1&e),t=Yk(t);return n}var Jk=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Yk(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return e})(),Qk=Jk.map((t,e)=>Jk.indexOf(e)),tE=t=>t<<24|t>>>8,eE=t=>t<<8|t>>>24;function nE(t,e){if(256!==t.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>e(t[r])),r=n.map(eE),i=r.map(eE),s=i.map(eE),o=new Uint32Array(65536),a=new Uint32Array(65536),l=new Uint16Array(65536);for(let c=0;c<256;c++)for(let e=0;e<256;e++){const u=256*c+e;o[u]=n[c]^r[e],a[u]=i[c]^s[e],l[u]=t[c]<<8|t[e]}return{sbox:t,sbox2:l,T0:n,T1:r,T2:i,T3:s,T01:o,T23:a}}var rE=nE(Jk,t=>Xk(t,3)<<24|t<<16|t<<8|Xk(t,2)),iE=nE(Qk,t=>Xk(t,11)<<24|Xk(t,13)<<16|Xk(t,9)<<8|Xk(t,14)),sE=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=Yk(n))t[e]=n;return t})();function oE(t){Sk(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=rE,r=Tk(t),i=r.length,s=t=>cE(n,t,t,t,t),o=new Uint32Array(e+28);o.set(r);for(let a=i;a6&&a%i===4&&(t=s(t)),o[a]=o[a-i]^t}return o}function aE(t){const e=oE(t),n=e.slice(),r=e.length,{sbox2:i}=rE,{T0:s,T1:o,T2:a,T3:l}=iE;for(let c=0;c>>8&255]^a[e>>>16&255]^l[e>>>24]}return n}function lE(t,e,n,r,i,s){return t[n<<8&65280|r>>>8&255]^e[i>>>8&65280|s>>>24&255]}function cE(t,e,n,r,i){return t[255&e|65280&n]|t[r>>>16&255|i>>>16&65280]<<16}function uE(t,e,n,r,i){const{sbox2:s,T01:o,T23:a}=rE;let l=0;e^=t[l++],n^=t[l++],r^=t[l++],i^=t[l++];const c=t.length/4-2;for(let u=0;u>>0,a.setUint32(u,d,e),({s0:p,s1:f,s2:g,s3:m}=uE(t,o[0],o[1],o[2],o[3]));const y=Kk*Math.floor(l.length/4);if(y16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const i=t.subarray(0,-r);for(let s=0;s=0;t--)e=e+(255&s[t])|0,s[t]=255&e,e>>>=8;({s0:a,s1:l,s2:c,s3:u}=uE(t,o[0],o[1],o[2],o[3]))}const p=Kk*Math.floor(h.length/4);if(pn(t,e),decrypt:(t,e)=>n(t,e)}}),Fk({blockSize:16},function(t,e={}){Sk(t);const n=!e.disablePadding;return{encrypt:(e,r)=>{Sk(e);const{b:i,o:s,out:o}=gE(e,n,r),a=oE(t);let l=0;for(;l+4<=i.length;){const{s0:t,s1:e,s2:n,s3:r}=uE(a,i[l+0],i[l+1],i[l+2],i[l+3]);s[l++]=t,s[l++]=e,s[l++]=n,s[l++]=r}if(n){const t=yE(e.subarray(4*l)),{s0:n,s1:r,s2:i,s3:o}=uE(a,t[0],t[1],t[2],t[3]);s[l++]=n,s[l++]=r,s[l++]=i,s[l++]=o}return a.fill(0),o},decrypt:(e,r)=>{fE(e);const i=aE(t),s=dE(e.length,r),o=Tk(e),a=Tk(s);for(let t=0;t+4<=o.length;){const{s0:e,s1:n,s2:r,s3:s}=hE(i,o[t+0],o[t+1],o[t+2],o[t+3]);a[t++]=e,a[t++]=n,a[t++]=r,a[t++]=s}return i.fill(0),mE(s,n)}}});var vE=Fk({blockSize:16,nonceLength:16},function(t,e,n={}){Sk(t),Sk(e,16);const r=!n.disablePadding;return{encrypt:(n,i)=>{const s=oE(t),{b:o,o:a,out:l}=gE(n,r,i),c=Tk(e);let u=c[0],h=c[1],d=c[2],p=c[3],f=0;for(;f+4<=o.length;)u^=o[f+0],h^=o[f+1],d^=o[f+2],p^=o[f+3],({s0:u,s1:h,s2:d,s3:p}=uE(s,u,h,d,p)),a[f++]=u,a[f++]=h,a[f++]=d,a[f++]=p;if(r){const t=yE(n.subarray(4*f));u^=t[0],h^=t[1],d^=t[2],p^=t[3],({s0:u,s1:h,s2:d,s3:p}=uE(s,u,h,d,p)),a[f++]=u,a[f++]=h,a[f++]=d,a[f++]=p}return s.fill(0),l},decrypt:(n,i)=>{fE(n);const s=aE(t),o=Tk(e),a=dE(n.length,i),l=Tk(n),c=Tk(a);let u=o[0],h=o[1],d=o[2],p=o[3];for(let t=0;t+4<=l.length;){const e=u,n=h,r=d,i=p;u=l[t+0],h=l[t+1],d=l[t+2],p=l[t+3];const{s0:o,s1:a,s2:f,s3:g}=hE(s,u,h,d,p);c[t++]=o^e,c[t++]=a^n,c[t++]=f^r,c[t++]=g^i}return s.fill(0),mE(a,r)}}});function bE(t,e,n,r,i){const s=t.create(n,r.length+(i?.length||0));i&&s.update(i),s.update(r);const o=new Uint8Array(16),a=Lk(o);return i&&Dk(a,0,BigInt(8*i.length),e),Dk(a,8,BigInt(8*r.length),e),s.update(o),s.digest()}Fk({blockSize:16,nonceLength:16},function(t,e){function n(n,r,i){const s=oE(t),o=n.length;i=dE(o,i);const a=Tk(n),l=Tk(i),c=r?l:a,u=Tk(e);let h=u[0],d=u[1],p=u[2],f=u[3];for(let t=0;t+4<=a.length;){const{s0:e,s1:n,s2:r,s3:i}=uE(s,h,d,p,f);l[t+0]=a[t+0]^e,l[t+1]=a[t+1]^n,l[t+2]=a[t+2]^r,l[t+3]=a[t+3]^i,h=c[t++],d=c[t++],p=c[t++],f=c[t++]}const g=Kk*Math.floor(a.length/4);if(gn(t,!0,e),decrypt:(t,e)=>n(t,!1,e)}}),Fk({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){if(Sk(e),0===e.length)throw new Error("aes/gcm: empty nonce");function r(t,e,r){const i=bE(Hk,!1,t,r,n);for(let n=0;n{Sk(t);const{xk:e,authKey:n,counter:s,tagMask:o}=i(),a=new Uint8Array(t.length+16);pE(e,!1,s,t,a);const l=r(n,o,a.subarray(0,a.length-16));return a.set(l,t.length),e.fill(0),a},decrypt:t=>{if(Sk(t),t.length<16)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:e,authKey:n,counter:s,tagMask:o}=i(),a=t.subarray(0,-16),l=t.subarray(-16);if(!Nk(r(n,o,a),l))throw new Error("aes/gcm: invalid ghash tag");const c=pE(e,!1,s,a);return n.fill(0),o.fill(0),e.fill(0),c}}});var wE=(t,e,n)=>r=>{if(!Number.isSafeInteger(r)||e>r||r>n)throw new Error(`${t}: invalid value=${r}, must be [${e}..${n}]`)},_E=(Fk({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){const r=wE("AAD",0,2**36),i=wE("plaintext",0,2**36),s=wE("nonce",12,12),o=wE("ciphertext",16,2**36+16);function a(){const n=t.length;if(16!==n&&24!==n&&32!==n)throw new Error(`key length must be 16, 24 or 32 bytes, got: ${n} bytes`);const r=oE(t),i=new Uint8Array(n),s=new Uint8Array(16),o=Tk(e);let a=0,l=o[0],c=o[1],u=o[2],h=0;for(const t of[s,i].map(Tk)){const e=Tk(t);for(let t=0;t{Sk(t),i(t.length);const{encKey:e,authKey:n}=a(),r=l(e,n,t),s=new Uint8Array(t.length+16);return s.set(r,t.length),s.set(c(e,r,t)),e.fill(0),n.fill(0),s},decrypt:t=>{Sk(t),o(t.length);const e=t.subarray(-16),{encKey:n,authKey:r}=a(),i=c(n,e,t.subarray(0,-16)),s=l(n,r,i);if(n.fill(0),r.fill(0),!Nk(e,s))throw new Error("invalid polyval tag");return i}}}),(t,e)=>255&t[e++]|(255&t[e++])<<8),xE=class{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Sk(t=Ok(t),32);const e=_E(t,0),n=_E(t,2),r=_E(t,4),i=_E(t,6),s=_E(t,8),o=_E(t,10),a=_E(t,12),l=_E(t,14);this.r[0]=8191&e,this.r[1]=8191&(e>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|i<<9),this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,this.r[6]=8191&(s>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|l<<8),this.r[9]=l>>>5&127;for(let c=0;c<8;c++)this.pad[c]=_E(t,16+2*c)}process(t,e,n=!1){const r=n?0:2048,{h:i,r:s}=this,o=s[0],a=s[1],l=s[2],c=s[3],u=s[4],h=s[5],d=s[6],p=s[7],f=s[8],g=s[9],m=_E(t,e+0),y=_E(t,e+2),v=_E(t,e+4),b=_E(t,e+6),w=_E(t,e+8),_=_E(t,e+10),x=_E(t,e+12),C=_E(t,e+14);let S=i[0]+(8191&m),k=i[1]+(8191&(m>>>13|y<<3)),E=i[2]+(8191&(y>>>10|v<<6)),R=i[3]+(8191&(v>>>7|b<<9)),T=i[4]+(8191&(b>>>4|w<<12)),L=i[5]+(w>>>1&8191),I=i[6]+(8191&(w>>>14|_<<2)),P=i[7]+(8191&(_>>>11|x<<5)),M=i[8]+(8191&(x>>>8|C<<8)),A=i[9]+(C>>>5|r),O=0,N=O+S*o+k*(5*g)+E*(5*f)+R*(5*p)+T*(5*d);O=N>>>13,N&=8191,N+=L*(5*h)+I*(5*u)+P*(5*c)+M*(5*l)+A*(5*a),O+=N>>>13,N&=8191;let F=O+S*a+k*o+E*(5*g)+R*(5*f)+T*(5*p);O=F>>>13,F&=8191,F+=L*(5*d)+I*(5*h)+P*(5*u)+M*(5*c)+A*(5*l),O+=F>>>13,F&=8191;let D=O+S*l+k*a+E*o+R*(5*g)+T*(5*f);O=D>>>13,D&=8191,D+=L*(5*p)+I*(5*d)+P*(5*h)+M*(5*u)+A*(5*c),O+=D>>>13,D&=8191;let z=O+S*c+k*l+E*a+R*o+T*(5*g);O=z>>>13,z&=8191,z+=L*(5*f)+I*(5*p)+P*(5*d)+M*(5*h)+A*(5*u),O+=z>>>13,z&=8191;let j=O+S*u+k*c+E*l+R*a+T*o;O=j>>>13,j&=8191,j+=L*(5*g)+I*(5*f)+P*(5*p)+M*(5*d)+A*(5*h),O+=j>>>13,j&=8191;let U=O+S*h+k*u+E*c+R*l+T*a;O=U>>>13,U&=8191,U+=L*o+I*(5*g)+P*(5*f)+M*(5*p)+A*(5*d),O+=U>>>13,U&=8191;let B=O+S*d+k*h+E*u+R*c+T*l;O=B>>>13,B&=8191,B+=L*a+I*o+P*(5*g)+M*(5*f)+A*(5*p),O+=B>>>13,B&=8191;let $=O+S*p+k*d+E*h+R*u+T*c;O=$>>>13,$&=8191,$+=L*l+I*a+P*o+M*(5*g)+A*(5*f),O+=$>>>13,$&=8191;let q=O+S*f+k*p+E*d+R*h+T*u;O=q>>>13,q&=8191,q+=L*c+I*l+P*a+M*o+A*(5*g),O+=q>>>13,q&=8191;let V=O+S*g+k*f+E*p+R*d+T*h;O=V>>>13,V&=8191,V+=L*u+I*c+P*l+M*a+A*o,O+=V>>>13,V&=8191,O=(O<<2)+O|0,O=O+N|0,N=8191&O,O>>>=13,F+=O,i[0]=N,i[1]=F,i[2]=D,i[3]=z,i[4]=j,i[5]=U,i[6]=B,i[7]=$,i[8]=q,i[9]=V}finalize(){const{h:t,pad:e}=this,n=new Uint16Array(10);let r=t[1]>>>13;t[1]&=8191;for(let o=2;o<10;o++)t[o]+=r,r=t[o]>>>13,t[o]&=8191;t[0]+=5*r,r=t[0]>>>13,t[0]&=8191,t[1]+=r,r=t[1]>>>13,t[1]&=8191,t[2]+=r,n[0]=t[0]+5,r=n[0]>>>13,n[0]&=8191;for(let o=1;o<10;o++)n[o]=t[o]+r,r=n[o]>>>13,n[o]&=8191;n[9]-=8192;let i=(1^r)-1;for(let o=0;o<10;o++)n[o]&=i;i=~i;for(let o=0;o<10;o++)t[o]=t[o]&i|n[o];t[0]=65535&(t[0]|t[1]<<13),t[1]=65535&(t[1]>>>3|t[2]<<10),t[2]=65535&(t[2]>>>6|t[3]<<7),t[3]=65535&(t[3]>>>9|t[4]<<4),t[4]=65535&(t[4]>>>12|t[5]<<1|t[6]<<14),t[5]=65535&(t[6]>>>2|t[7]<<11),t[6]=65535&(t[7]>>>5|t[8]<<8),t[7]=65535&(t[8]>>>8|t[9]<<5);let s=t[0]+e[0];t[0]=65535&s;for(let o=1;o<8;o++)s=(t[o]+e[o]|0)+(s>>>16)|0,t[o]=65535&s}update(t){kk(this);const{buffer:e,blockLen:n}=this,r=(t=Ok(t)).length;for(let i=0;i>>0,t[i++]=n[s]>>>8;return t}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}},CE=function(t){const e=(e,n)=>t(n).update(Ok(e)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e}(t=>new xE(t)),SE=t=>Uint8Array.from(t.split("").map(t=>t.charCodeAt(0))),kE=SE("expand 16-byte k"),EE=SE("expand 32-byte k"),RE=Tk(kE),TE=Tk(EE);function LE(t,e){return t<>>32-e}function IE(t){return t.byteOffset%4==0}TE.slice();var PE=2**32-1,ME=new Uint32Array;function AE(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:s,rounds:o}=function(t,e){if(null==e||"object"!=typeof e)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e)}(0,e);if("function"!=typeof t)throw new Error("core must be a function");return _k(i),_k(o),xk(s),xk(n),(e,a,l,c,u=0)=>{Sk(e),Sk(a),Sk(l);const h=l.length;if(c||(c=new Uint8Array(h)),Sk(c),_k(u),u<0||u>=PE)throw new Error("arx: counter overflow");if(c.length=PE)throw new Error("arx: counter overflow");const g=Math.min(64,l-f);if(h&&64===g){const t=f/4;if(f%4!=0)throw new Error("arx: invalid block position");for(let e,n=0;n<16;n++)e=t+n,p[e]=d[e]^u[n];f+=64;continue}for(let t,e=0;e0;)d.pop().fill(0);return c}}function OE(t,e,n,r,i,s=20){let o=t[0],a=t[1],l=t[2],c=t[3],u=e[0],h=e[1],d=e[2],p=e[3],f=e[4],g=e[5],m=e[6],y=e[7],v=i,b=n[0],w=n[1],_=n[2],x=o,C=a,S=l,k=c,E=u,R=h,T=d,L=p,I=f,P=g,M=m,A=y,O=v,N=b,F=w,D=_;for(let j=0;j{t.update(e);const n=e.length%16;n&&t.update(DE.subarray(n))},jE=new Uint8Array(32);function UE(t,e,n,r,i){const s=t(e,n,jE),o=CE.create(s);i&&zE(o,i),zE(o,r);const a=new Uint8Array(16),l=Lk(a);Dk(l,0,BigInt(i?i.length:0),!0),Dk(l,8,BigInt(r.length),!0),o.update(a);const c=o.digest();return s.fill(0),c}var BE=t=>(e,n,r)=>(Sk(e,32),Sk(n),{encrypt:(i,s)=>{const o=i.length,a=o+16;s?Sk(s,a):s=new Uint8Array(a),t(e,n,i,s,1);const l=UE(t,e,n,s.subarray(0,-16),r);return s.set(l,o),s},decrypt:(i,s)=>{const o=i.length,a=o-16;if(o<16)throw new Error("encrypted data must be at least 16 bytes");s?Sk(s,a):s=new Uint8Array(a);const l=i.subarray(0,-16);if(!Nk(i.subarray(-16),UE(t,e,n,l,r)))throw new Error("invalid tag");return t(e,n,l,s,1),s}}),$E=(BE(NE),BE(FE),class extends AS{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,zS.hash(t);const n=PS(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let s=0;snew $E(t,e).update(n).digest();qE.create=(t,e)=>new $E(t,e);var VE=new Uint8Array([0]),WE=new Uint8Array,HE=Object.defineProperty,GE=(t,e)=>{for(var n in e)HE(t,n,{get:e[n],enumerable:!0})},KE=Symbol("verified");function ZE(t){if(!(t instanceof Object))return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.pubkey)return!1;if(!t.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(t.tags))return!1;for(let e=0;erR,QueueNode:()=>nR,binarySearch:()=>eR,bytesToHex:()=>LS,hexToBytes:()=>IS,insertEventIntoAscendingList:()=>tR,insertEventIntoDescendingList:()=>QE,normalizeURL:()=>JE,utf8Decoder:()=>YE,utf8Encoder:()=>XE});var YE=new TextDecoder("utf-8"),XE=new TextEncoder;function JE(t){try{-1===t.indexOf("://")&&(t="wss://"+t);let e=new URL(t);return"http:"===e.protocol?e.protocol="ws:":"https:"===e.protocol&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),("80"===e.port&&"ws:"===e.protocol||"443"===e.port&&"wss:"===e.protocol)&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch(e){throw new Error(`Invalid URL: ${t}`)}}function QE(t,e){const[n,r]=eR(t,t=>e.id===t.id?0:e.created_at===t.created_at?-1:t.created_at-e.created_at);return r||t.splice(n,0,e),t}function tR(t,e){const[n,r]=eR(t,t=>e.id===t.id?0:e.created_at===t.created_at?-1:e.created_at-t.created_at);return r||t.splice(n,0,e),t}function eR(t,e){let n=0,r=t.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),s=e(t[i]);if(0===s)return[i,!0];s<0?r=i-1:n=i+1}return[n,!1]}var nR=class{value;next=null;prev=null;constructor(t){this.value=t}},rR=class{first;last;constructor(){this.first=null,this.last=null}enqueue(t){const e=new nR(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const t=this.first;return this.first=null,this.last=null,t.value}const t=this.first;return this.first=t.next,this.first&&(this.first.prev=null),t.value}};function iR(t){return LS(GS(XE.encode(function(t){if(!ZE(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}(t))))}var sR=new class{generateSecretKey(){return CS.utils.randomPrivateKey()}getPublicKey(t){return LS(CS.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=LS(CS.getPublicKey(e)),n.id=iR(n),n.sig=LS(CS.sign(iR(n),e)),n[KE]=!0,n}verifyEvent(t){if("boolean"==typeof t[KE])return t[KE];const e=iR(t);if(e!==t.id)return t[KE]=!1,!1;try{const n=CS.verify(t.sig,e,t.pubkey);return t[KE]=n,n}catch(xD){return t[KE]=!1,!1}}},oR=sR.generateSecretKey,aR=sR.getPublicKey,lR=sR.finalizeEvent,cR=sR.verifyEvent,uR={};function hR(t){return t<1e4&&0!==t&&3!==t}function dR(t){return 0===t||3===t||1e4<=t&&t<2e4}function pR(t){return 2e4<=t&&t<3e4}function fR(t){return 3e4<=t&&t<4e4}function gR(t){return hR(t)?"regular":dR(t)?"replaceable":pR(t)?"ephemeral":fR(t)?"parameterized":"unknown"}function mR(t,e){const n=e instanceof Array?e:[e];return ZE(t)&&n.includes(t.kind)||!1}GE(uR,{Application:()=>BT,BadgeAward:()=>kR,BadgeDefinition:()=>OT,BlockedRelaysList:()=>pT,BlossomServerList:()=>wT,BookmarkList:()=>uT,Bookmarksets:()=>PT,Calendar:()=>KT,CalendarEventRSVP:()=>ZT,ChannelCreation:()=>NR,ChannelHideMessage:()=>zR,ChannelMessage:()=>DR,ChannelMetadata:()=>FR,ChannelMuteUser:()=>jR,ChatMessage:()=>ER,ClassifiedListing:()=>VT,ClientAuth:()=>CT,Comment:()=>VR,CommunitiesList:()=>hT,CommunityDefinition:()=>QT,CommunityPostApproval:()=>JR,Contacts:()=>wR,CreateOrUpdateProduct:()=>DT,CreateOrUpdateStall:()=>FT,Curationsets:()=>MT,Date:()=>HT,DirectMessageRelaysList:()=>vT,DraftClassifiedListing:()=>WT,DraftLong:()=>jT,Emojisets:()=>UT,EncryptedDirectMessage:()=>_R,EventDeletion:()=>xR,FavoriteRelays:()=>gT,FileMessage:()=>IR,FileMetadata:()=>qR,FileServerPreference:()=>bT,Followsets:()=>TT,ForumThread:()=>RR,GenericRepost:()=>PR,Genericlists:()=>LT,GiftWrap:()=>BR,GroupMetadata:()=>tL,HTTPAuth:()=>RT,Handlerinformation:()=>JT,Handlerrecommendation:()=>XT,Highlights:()=>sT,InterestsList:()=>mT,Interestsets:()=>NT,JobFeedback:()=>eT,JobRequest:()=>QR,JobResult:()=>tT,Label:()=>XR,LightningPubRPC:()=>xT,LiveChatMessage:()=>WR,LiveEvent:()=>$T,LongFormArticle:()=>zT,Metadata:()=>yR,Mutelist:()=>aT,NWCWalletInfo:()=>_T,NWCWalletRequest:()=>ST,NWCWalletResponse:()=>kT,NormalVideo:()=>AR,NostrConnect:()=>ET,OpenTimestamps:()=>UR,Photo:()=>MR,Pinlist:()=>lT,Poll:()=>$R,PollResponse:()=>oT,PrivateDirectMessage:()=>LR,ProblemTracker:()=>KR,ProfileBadges:()=>AT,PublicChatsList:()=>dT,Reaction:()=>SR,RecommendRelay:()=>bR,RelayList:()=>cT,RelayReview:()=>YT,Relaysets:()=>IT,Report:()=>ZR,Reporting:()=>YR,Repost:()=>CR,Seal:()=>TR,SearchRelaysList:()=>fT,ShortTextNote:()=>vR,ShortVideo:()=>OR,Time:()=>GT,UserEmojiList:()=>yT,UserStatuses:()=>qT,Voice:()=>HR,VoiceComment:()=>GR,Zap:()=>iT,ZapGoal:()=>nT,ZapRequest:()=>rT,classifyKind:()=>gR,isAddressableKind:()=>fR,isEphemeralKind:()=>pR,isKind:()=>mR,isRegularKind:()=>hR,isReplaceableKind:()=>dR});var yR=0,vR=1,bR=2,wR=3,_R=4,xR=5,CR=6,SR=7,kR=8,ER=9,RR=11,TR=13,LR=14,IR=15,PR=16,MR=20,AR=21,OR=22,NR=40,FR=41,DR=42,zR=43,jR=44,UR=1040,BR=1059,$R=1068,qR=1063,VR=1111,WR=1311,HR=1222,GR=1244,KR=1971,ZR=1984,YR=1984,XR=1985,JR=4550,QR=5999,tT=6999,eT=7e3,nT=9041,rT=9734,iT=9735,sT=9802,oT=1018,aT=1e4,lT=10001,cT=10002,uT=10003,hT=10004,dT=10005,pT=10006,fT=10007,gT=10012,mT=10015,yT=10030,vT=10050,bT=10096,wT=10063,_T=13194,xT=21e3,CT=22242,ST=23194,kT=23195,ET=24133,RT=27235,TT=3e4,LT=30001,IT=30002,PT=30003,MT=30004,AT=30008,OT=30009,NT=30015,FT=30017,DT=30018,zT=30023,jT=30024,UT=30030,BT=30078,$T=30311,qT=30315,VT=30402,WT=30403,HT=31922,GT=31923,KT=31924,ZT=31925,YT=31987,XT=31989,JT=31990,QT=34550,tL=39e3;function eL(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,i=t.slice(r).indexOf('"')+r+1;return t.slice(i,i+64)}function nL(t,e){let n=e.length,r=t.indexOf(`"${e}":`)+n+3,i=t.slice(r),s=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,s),10)}function rL(t){let e=t.slice(0,22).indexOf('"EVENT"');if(-1===e)return null;let n=t.slice(e+7+1).indexOf('"');if(-1===n)return null;let r=e+7+1+n,i=t.slice(r+1,80).indexOf('"');if(-1===i)return null;let s=r+1+i;return t.slice(r+1,s)}function iL(t,e){return e===eL(t,"id")}function sL(t,e){return e===eL(t,"pubkey")}function oL(t,e){return e===nL(t,"kind")}function aL(t,e){return{kind:CT,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}GE({},{getHex64:()=>eL,getInt:()=>nL,getSubscriptionId:()=>rL,matchEventId:()=>iL,matchEventKind:()=>oL,matchEventPubkey:()=>sL}),GE({},{makeAuthEvent:()=>aL});try{WebSocket}catch{}try{WebSocket}catch{}GE({},{BECH32_REGEX:()=>uL,Bech32MaxSize:()=>cL,NostrTypeGuard:()=>lL,decode:()=>dL,decodeNostrURI:()=>hL,encodeBytes:()=>vL,naddrEncode:()=>_L,neventEncode:()=>wL,noteEncode:()=>mL,nprofileEncode:()=>bL,npubEncode:()=>gL,nsecEncode:()=>fL});var lL={isNProfile:t=>/^nprofile1[a-z\d]+$/.test(t||""),isNEvent:t=>/^nevent1[a-z\d]+$/.test(t||""),isNAddr:t=>/^naddr1[a-z\d]+$/.test(t||""),isNSec:t=>/^nsec1[a-z\d]{58}$/.test(t||""),isNPub:t=>/^npub1[a-z\d]{58}$/.test(t||""),isNote:t=>/^note1[a-z\d]+$/.test(t||""),isNcryptsec:t=>/^ncryptsec1[a-z\d]+$/.test(t||"")},cL=5e3,uL=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function hL(t){try{return t.startsWith("nostr:")&&(t=t.substring(6)),dL(t)}catch(e){return{type:"invalid",data:null}}}function dL(t){let{prefix:e,words:n}=bk.decode(t,cL),r=new Uint8Array(bk.fromWords(n));switch(e){case"nprofile":{let t=pL(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:LS(t[0][0]),relays:t[1]?t[1].map(t=>YE.decode(t)):[]}}}case"nevent":{let t=pL(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(t[2]&&32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(t[3]&&4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:LS(t[0][0]),relays:t[1]?t[1].map(t=>YE.decode(t)):[],author:t[2]?.[0]?LS(t[2][0]):void 0,kind:t[3]?.[0]?parseInt(LS(t[3][0]),16):void 0}}}case"naddr":{let t=pL(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!t[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!t[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:YE.decode(t[0][0]),pubkey:LS(t[2][0]),kind:parseInt(LS(t[3][0]),16),relays:t[1]?t[1].map(t=>YE.decode(t)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:LS(r)};default:throw new Error(`unknown prefix ${e}`)}}function pL(t){let e={},n=t;for(;n.length>0;){let t=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.lengthXE.encode(t))}))}function wL(t){let e;return void 0!==t.kind&&(e=function(t){const e=new Uint8Array(4);return e[0]=t>>24&255,e[1]=t>>16&255,e[2]=t>>8&255,e[3]=255&t,e}(t.kind)),yL("nevent",xL({0:[IS(t.id)],1:(t.relays||[]).map(t=>XE.encode(t)),2:t.author?[IS(t.author)]:[],3:e?[new Uint8Array(e)]:[]}))}function _L(t){let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,t.kind,!1),yL("naddr",xL({0:[XE.encode(t.identifier)],1:(t.relays||[]).map(t=>XE.encode(t)),2:[IS(t.pubkey)],3:[new Uint8Array(e)]}))}function xL(t){let e=[];return Object.entries(t).reverse().forEach(([t,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(t)],0),r.set([n.length],1),r.set(n,2),e.push(r)})}),MS(...e)}var CL={};function SL(t,e,n){const r=t instanceof Uint8Array?LS(t):t,i=EL(aS.getSharedSecret(r,"02"+e));let s=Uint8Array.from(NS(16)),o=XE.encode(n),a=vE(i,s).encrypt(o);return`${lk.encode(new Uint8Array(a))}?iv=${lk.encode(new Uint8Array(s.buffer))}`}function kL(t,e,n){const r=t instanceof Uint8Array?LS(t):t;let[i,s]=n.split("?iv="),o=EL(aS.getSharedSecret(r,"02"+e)),a=lk.decode(s),l=lk.decode(i),c=vE(o,a).decrypt(l);return YE.decode(c)}function EL(t){return t.slice(1,33)}GE(CL,{decrypt:()=>kL,encrypt:()=>SL}),GE({},{NIP05_REGEX:()=>TL,isNip05:()=>LL,isValid:()=>AL,queryProfile:()=>ML,searchDomain:()=>PL,useFetchImplementation:()=>IL});var RL,TL=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,LL=t=>TL.test(t||"");try{RL=fetch}catch(het){}function IL(t){RL=t}async function PL(t,e=""){try{const n=`https://${t}/.well-known/nostr.json?name=${e}`,r=await RL(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(het){return{}}}async function ML(t){const e=t.match(TL);if(!e)return null;const[,n="_",r]=e;try{const t=`https://${r}/.well-known/nostr.json?name=${n}`,e=await RL(t,{redirect:"manual"});if(200!==e.status)throw Error("Wrong response code");const i=await e.json(),s=i.names[n];return s?{pubkey:s,relays:i.relays?.[s]}:null}catch(i){return null}}async function AL(t,e){const n=await ML(e);return!!n&&n.pubkey===t}function OL(t){const e={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let i=t.tags.length-1;i>=0;i--){const s=t.tags[i];if("e"===s[0]&&s[1]){const[t,i,o,a,l]=s,c={id:i,relays:o?[o]:[],author:l};if("root"===a){e.root=c;continue}if("reply"===a){e.reply=c;continue}if("mention"===a){e.mentions.push(c);continue}n?r=c:n=c,e.mentions.push(c);continue}if("q"===s[0]&&s[1]){const[t,n,r]=s;e.quotes.push({id:n,relays:r?[r]:[]})}"p"===s[0]&&s[1]&&e.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]})}return e.root||(e.root=r||n||e.reply),e.reply||(e.reply=n||e.root),[e.reply,e.root].forEach(t=>{if(!t)return;let n=e.mentions.indexOf(t);if(-1!==n&&e.mentions.splice(n,1),t.author){let n=e.profiles.find(e=>e.pubkey===t.author);n&&n.relays&&(t.relays||(t.relays=[]),n.relays.forEach(e=>{-1===t.relays?.indexOf(e)&&t.relays.push(e)}),n.relays=t.relays)}}),e.mentions.forEach(t=>{if(t.author){let n=e.profiles.find(e=>e.pubkey===t.author);n&&n.relays&&(t.relays||(t.relays=[]),n.relays.forEach(e=>{-1===t.relays.indexOf(e)&&t.relays.push(e)}),n.relays=t.relays)}}),e}function NL(){}async function FL(t){return await(await fetch(t.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function DL(t){let e=0;for(let n=0;n<64;n+=8){const r=parseInt(t.substring(n,n+8),16);if(0!==r){e+=Math.clz32(r);break}e+=32}return e}function zL(t,e){let n=0;const r=t,i=["nonce",n.toString(),e.toString()];for(r.tags.push(i);;){const t=Math.floor((new Date).getTime()/1e3);if(t!==r.created_at&&(n=0,r.created_at=t),i[1]=(++n).toString(),r.id=jL(r),DL(r.id)>=e)break}return r}function jL(t){return LS(GS(XE.encode(JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content]))))}GE({},{parse:()=>OL}),GE({},{fetchRelayInformation:()=>FL,useFetchImplementation:()=>NL}),GE({},{fastEventHash:()=>jL,getPow:()=>DL,minePow:()=>zL}),GE({},{unwrapEvent:()=>uI,unwrapManyEvents:()=>hI,wrapEvent:()=>lI,wrapManyEvents:()=>cI}),GE({},{createRumor:()=>eI,createSeal:()=>nI,createWrap:()=>rI,unwrapEvent:()=>oI,unwrapManyEvents:()=>aI,wrapEvent:()=>iI,wrapManyEvents:()=>sI});var UL={};GE(UL,{decrypt:()=>KL,encrypt:()=>GL,getConversationKey:()=>qL,v2:()=>ZL});var BL=1,$L=65535;function qL(t,e){const n=aS.getSharedSecret(t,"02"+e).subarray(1,33);return r=GS,i=n,s="nip44-v2",zS.hash(r),void 0===s&&(s=new Uint8Array(r.outputLen)),qE(r,PS(s),PS(i));var r,i,s}function VL(t,e){const n=function(t,e,n,r=32){if(zS.hash(t),zS.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);void 0===n&&(n=WE);const s=new Uint8Array(i*t.outputLen),o=qE.create(t,e),a=o._cloneInto(),l=new Uint8Array(o.outputLen);for(let c=0;c$L)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}(n),e,new Uint8Array(WL(n)-n))}(t),a=NE(r,i,o),l=HL(s,a,n);return lk.encode(MS(new Uint8Array([2]),n,a,l))}function KL(t,e){const{nonce:n,ciphertext:r,mac:i}=function(t){if("string"!=typeof t)throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if("#"===t[0])throw new Error("unknown encryption version");let n;try{n=lk.decode(t)}catch(e6){throw new Error("invalid base64: "+e6.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const i=n[0];if(2!==i)throw new Error("unknown encryption version "+i);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(t),{chacha_key:s,chacha_nonce:o,hmac_key:a}=VL(e,n);if(!Nk(HL(a,r,n),i))throw new Error("invalid MAC");return function(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(e$L||n.length!==e||t.length!==2+WL(e))throw new Error("invalid padding");return YE.decode(n)}(NE(s,o,r))}var ZL={utils:{getConversationKey:qL,calcPaddedLen:WL},encrypt:GL,decrypt:KL},YL=()=>Math.round(Date.now()/1e3),XL=()=>Math.round(YL()-172800*Math.random()),JL=(t,e)=>qL(t,e),QL=(t,e,n)=>GL(JSON.stringify(t),JL(e,n)),tI=(t,e)=>JSON.parse(KL(t.content,JL(e,t.pubkey)));function eI(t,e){const n={created_at:YL(),content:"",tags:[],...t,pubkey:aR(e)};return n.id=iR(n),n}function nI(t,e,n){return lR({kind:TR,content:QL(t,e,n),created_at:XL(),tags:[]},e)}function rI(t,e){const n=oR();return lR({kind:BR,content:QL(t,n,e),created_at:XL(),tags:[["p",e]]},n)}function iI(t,e,n){return rI(nI(eI(t,e),e,n),n)}function sI(t,e,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=[iI(t,e,aR(e))];return n.forEach(n=>{r.push(iI(t,e,n))}),r}function oI(t,e){return tI(tI(t,e),e)}function aI(t,e){let n=[];return t.forEach(t=>{n.push(oI(t,e))}),n.sort((t,e)=>t.created_at-e.created_at),n}function lI(t,e,n,r,i){return iI(function(t,e,n,r){const i={created_at:Math.ceil(Date.now()/1e3),kind:LR,tags:[],content:e};return(Array.isArray(t)?t:[t]).forEach(({publicKey:t,relayUrl:e})=>{i.tags.push(e?["p",t,e]:["p",t])}),r&&i.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&i.tags.push(["subject",n]),i}(e,n,r,i),t,e.publicKey)}function cI(t,e,n,r,i){if(!e||0===e.length)throw new Error("At least one recipient is required.");return[{publicKey:aR(t)},...e].map(e=>lI(t,e,n,r,i))}var uI=oI,hI=aI;function dI(t,e,n,r){let i;const s=[...t.tags??[],["e",e.id,n],["p",e.pubkey]];return e.kind===vR?i=CR:(i=PR,s.push(["k",String(e.kind)])),lR({kind:i,tags:s,content:""===t.content||e.tags?.find(t=>"-"===t[0])?"":JSON.stringify(e),created_at:t.created_at},r)}function pI(t){if(![CR,PR].includes(t.kind))return;let e,n;for(let r=t.tags.length-1;r>=0&&(void 0===e||void 0===n);r--){const i=t.tags[r];i.length>=2&&("e"===i[0]&&void 0===e?e=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==e?{id:e[1],relays:[e[2],n?.[2]].filter(t=>"string"==typeof t),author:n?.[1]}:void 0}function fI(t,{skipVerification:e}={}){const n=pI(t);if(void 0===n||""===t.content)return;let r;try{r=JSON.parse(t.content)}catch(e6){return}return r.id===n.id&&(e||cR(r))?r:void 0}GE({},{finishRepostEvent:()=>dI,getRepostedEvent:()=>fI,getRepostedEventPointer:()=>pI}),GE({},{NOSTR_URI_REGEX:()=>gI,parse:()=>yI,test:()=>mI});var gI=new RegExp(`nostr:(${uL.source})`);function mI(t){return"string"==typeof t&&new RegExp(`^${gI.source}$`).test(t)}function yI(t){const e=t.match(new RegExp(`^${gI.source}$`));if(!e)throw new Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:dL(e[1])}}function vI(t,e,n){const r=e.tags.filter(t=>t.length>=2&&("e"===t[0]||"p"===t[0]));return lR({...t,kind:SR,tags:[...t.tags??[],...r,["e",e.id],["p",e.pubkey]],content:t.content??"+"},n)}function bI(t){if(t.kind!==SR)return;let e,n;for(let r=t.tags.length-1;r>=0&&(void 0===e||void 0===n);r--){const i=t.tags[r];i.length>=2&&("e"===i[0]&&void 0===e?e=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==e&&void 0!==n?{id:e[1],relays:[e[2],n[2]].filter(t=>void 0!==t),author:n[1]}:void 0}GE({},{finishReactionEvent:()=>vI,getReactedEventPointer:()=>bI}),GE({},{parse:()=>CI});var wI=/\W/m,_I=/[^\w\/] |[^\w\/]$|$|,| /m,xI=42;function*CI(t){let e=[];if("string"!=typeof t){for(let n=0;n=3&&e.push({type:"emoji",shortcode:r[1],url:r[2]})}t=t.content}const n=t.length;let r=0,i=0;t:for(;i=0&&aSI,channelHideMessageEvent:()=>RI,channelMessageEvent:()=>EI,channelMetadataEvent:()=>kI,channelMuteUserEvent:()=>TI});var SI=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return lR({kind:NR,tags:[...t.tags??[]],content:n,created_at:t.created_at},e)},kI=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return lR({kind:FR,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},EI=(t,e)=>{const n=[["e",t.channel_create_event_id,t.relay_url,"root"]];return t.reply_to_channel_message_event_id&&n.push(["e",t.reply_to_channel_message_event_id,t.relay_url,"reply"]),lR({kind:DR,tags:[...n,...t.tags??[]],content:t.content,created_at:t.created_at},e)},RI=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return lR({kind:zR,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},TI=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return lR({kind:jR,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:n,created_at:t.created_at},e)};GE({},{EMOJI_SHORTCODE_REGEX:()=>PI,matchAll:()=>AI,regex:()=>MI,replaceAll:()=>OI});var LI,II,PI=/:(\w+):/,MI=()=>new RegExp(`\\B${PI.source}\\B`,"g");function*AI(t){const e=t.matchAll(MI());for(const r of e)try{const[t,e]=r;yield{shortcode:t,name:e,start:r.index,end:r.index+t.length}}catch(n){}}function OI(t,e){return t.replaceAll(MI(),(t,n)=>e({shortcode:t,name:n}))}GE({},{useFetchImplementation:()=>NI,validateGithub:()=>FI});try{LI=fetch}catch{}function NI(t){LI=t}async function FI(t,e,n){try{return await(await LI(`https://gist.github.com/${e}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch(het){return!1}}function DI(t){const{host:e,pathname:n,searchParams:r}=new URL(t),i=n||e,s=r.get("relay"),o=r.get("secret");if(!i||!s||!o)throw new Error("invalid connection string");return{pubkey:i,relay:s,secret:o}}async function zI(t,e,n){const r=SL(e,t,JSON.stringify({method:"pay_invoice",params:{invoice:n}}));return lR({kind:ST,created_at:Math.round(Date.now()/1e3),content:r,tags:[["p",t]]},e)}function jI(t){return t=(t=t.trim().toLowerCase()).normalize("NFKC"),Array.from(t).map(t=>/\p{Letter}/u.test(t)||/\p{Number}/u.test(t)?t:"-").join("")}GE({},{makeNwcRequestEvent:()=>zI,parseConnectionString:()=>DI}),GE({},{normalizeIdentifier:()=>jI}),GE({},{getSatoshisAmountFromBolt11:()=>WI,getZapEndpoint:()=>BI,makeZapReceipt:()=>VI,makeZapRequest:()=>$I,useFetchImplementation:()=>UI,validateZapRequest:()=>qI});try{II=fetch}catch{}function UI(t){II=t}async function BI(t){try{let e="",{lud06:n,lud16:r}=JSON.parse(t.content);if(r){let[t,n]=r.split("@");e=new URL(`/.well-known/lnurlp/${t}`,`https://${n}`).toString()}else{if(!n)return null;{let{words:t}=bk.decode(n,1e3),r=bk.fromWords(t);e=YE.decode(r)}}let i=await(await II(e)).json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch(xD){}return null}function $I(t){let e={kind:9734,created_at:Math.round(Date.now()/1e3),content:t.comment||"",tags:[["p","pubkey"in t?t.pubkey:t.event.pubkey],["amount",t.amount.toString()],["relays",...t.relays]]};if("event"in t){if(e.tags.push(["e",t.event.id]),dR(t.event.kind)){const n=["a",`${t.event.kind}:${t.event.pubkey}:`];e.tags.push(n)}else if(fR(t.event.kind)){let n=t.event.tags.find(([t,e])=>"d"===t&&e);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${t.event.kind}:${t.event.pubkey}:${n[1]}`];e.tags.push(r)}e.tags.push(["k",t.event.kind.toString()])}return e}function qI(t){let e;try{e=JSON.parse(t)}catch(xD){return"Invalid zap request JSON."}if(!ZE(e))return"Zap request is not a valid Nostr event.";if(!cR(e))return"Invalid signature on zap request.";let n=e.tags.find(([t,e])=>"p"===t&&e);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=e.tags.find(([t,e])=>"e"===t&&e);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":e.tags.find(([t,e])=>"relays"===t&&e)?null:"Zap request doesn't have a 'relays' tag."}function VI({zapRequest:t,preimage:e,bolt11:n,paidAt:r}){let i=JSON.parse(t),s=i.tags.filter(([t])=>"e"===t||"p"===t||"a"===t),o={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...s,["P",i.pubkey],["bolt11",n],["description",t]]};return e&&o.tags.push(["preimage",e]),o}function WI(t){if(t.length<50)return 0;const e=(t=t.substring(0,50)).lastIndexOf("1");if(-1===e)return 0;const n=t.substring(0,e);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const i=r[r.length-1],s=i.charCodeAt(0)-"0".charCodeAt(0),o=s>=0&&s<=9;let a=r.length-1;if(o&&a++,a<1)return 0;const l=parseInt(r.substring(0,a));switch(i){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}GE({},{Negentropy:()=>QI,NegentropyStorageVector:()=>JI,NegentropySync:()=>nP});var HI=32,GI=class{_raw;length;constructor(t){"number"==typeof t?(this._raw=new Uint8Array(t),this.length=0):t instanceof Uint8Array?(this._raw=new Uint8Array(t),this.length=t.length):(this._raw=new Uint8Array(512),this.length=0)}unwrap(){return this._raw.subarray(0,this.length)}get capacity(){return this._raw.byteLength}extend(t){if(t instanceof GI&&(t=t.unwrap()),"number"!=typeof t.length)throw Error("bad length");const e=t.length+this.length;if(this.capacity>>=7;e.reverse();for(let n=0;n4294967295&&(n=1),r.setUint32(t,4294967295&o,!0),e=n,n=0}}negate(){let t=new DataView(this.buf.buffer);for(let n=0;n<8;n++){let e=4*n;t.setUint32(e,~t.getUint32(e,!0))}let e=new Uint8Array(HI);e[0]=1,this.add(e)}getFingerprint(t){let e=new GI;return e.extend(this.buf),e.extend(ZI(t)),GS(e.unwrap()).subarray(0,16)}},JI=class{items;sealed;constructor(){this.items=[],this.sealed=!1}insert(t,e){if(this.sealed)throw Error("already sealed");const n=Ak(e);if(n.byteLength!==HI)throw Error("bad id size for added item");this.items.push({timestamp:t,id:n})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(eP);for(let t=1;t=this.items.length)throw Error("out of range");return this.items[t]}iterate(t,e,n){this._checkSealed(),this._checkBounds(t,e);for(let r=t;reP(t,n)<0)}fingerprint(t,e){let n=new XI;return n.setToZero(),this.iterate(t,e,t=>(n.add(t.id),!0)),n.getFingerprint(e-t)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(t,e){if(t>e||e>this.items.length)throw Error("bad range")}_binarySearch(t,e,n,r){let i=n-e;for(;i>0;){let n=e,s=Math.floor(i/2);n+=s,r(t[n])?(e=++n,i-=s+1):i=s}return e}},QI=class{storage;frameSizeLimit;lastTimestampIn;lastTimestampOut;constructor(t,e=6e4){if(e<4096)throw Error("frameSizeLimit too small");this.storage=t,this.frameSizeLimit=e,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(t,e){return{timestamp:t,id:e||new Uint8Array(0)}}initiate(){let t=new GI;return t.extend(new Uint8Array([97])),this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),t),Pk(t.unwrap())}reconcile(t,e,n){const r=new GI(Ak(t));this.lastTimestampIn=this.lastTimestampOut=0;let i=new GI;i.extend(new Uint8Array([97]));let s=YI(r,1)[0];if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(97!==s)throw Error("unsupported negentropy protocol version requested: "+(s-96));let o=this.storage.size(),a=this._bound(0),l=0,c=!1;for(;0!==r.length;){let t=new GI,s=()=>{c&&(c=!1,t.extend(this.encodeBound(a)),t.extend(ZI(0)))},u=this.decodeBound(r),h=KI(r),d=l,p=this.storage.findLowerBound(l,o,u);if(0===h)c=!0;else if(1===h)0!==tP(YI(r,16),this.storage.fingerprint(d,p))?(s(),this.splitRange(d,p,u,t)):c=!0;else{if(2!==h)throw Error("unexpected mode");{let t=KI(r),i={};for(let e=0;e{let n=t.id;const r=Pk(n);return i[r]?delete i[Pk(n)]:e?.(r),!0}),n)for(let e of Object.values(i))n(Pk(e))}}if(this.exceededFrameSizeLimit(i.length+t.length)){let t=this.storage.fingerprint(p,o);i.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),i.extend(ZI(1)),i.extend(t);break}i.extend(t),l=p,a=u}return 1===i.length?null:Pk(i.unwrap())}splitRange(t,e,n,r){let i=e-t;if(i<32)r.extend(this.encodeBound(n)),r.extend(ZI(2)),r.extend(ZI(i)),this.storage.iterate(t,e,t=>(r.extend(t.id),!0));else{let s=Math.floor(i/16),o=i%16,a=t;for(let t=0;t<16;t++){let i,l=s+(t(r===a-1?t=n:e=n,!0)),i=this.getMinimalBound(t,e)}r.extend(this.encodeBound(i)),r.extend(ZI(1)),r.extend(c)}}}exceededFrameSizeLimit(t){return t>this.frameSizeLimit-200}decodeTimestampIn(t){let e=KI(t);return e=0===e?Number.MAX_VALUE:e-1,this.lastTimestampIn===Number.MAX_VALUE||e===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(e+=this.lastTimestampIn,this.lastTimestampIn=e,e)}decodeBound(t){let e=this.decodeTimestampIn(t),n=KI(t);if(n>HI)throw Error("bound key too long");return{timestamp:e,id:YI(t,n)}}encodeTimestampOut(t){if(t===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,ZI(0);let e=t;return t-=this.lastTimestampOut,this.lastTimestampOut=e,ZI(t+1)}encodeBound(t){let e=new GI;return e.extend(this.encodeTimestampOut(t.timestamp)),e.extend(ZI(t.id.length)),e.extend(t.id),e}getMinimalBound(t,e){if(e.timestamp!==t.timestamp)return this._bound(e.timestamp);{let n=0,r=e.id,i=t.id;for(let t=0;te[n])return 1}return t.byteLength>e.byteLength?1:t.byteLength{switch(t[0]){case"NEG-MSG":t.length<3&&console.warn(`got invalid NEG-MSG from ${this.relay.url}: ${t}`);try{const e=this.neg.reconcile(t[2],this.onhave,this.onneed);e?this.relay.send(`["NEG-MSG", "${this.subscription.id}", "${e}"]`):(this.close(),r.onclose?.())}catch(e6){console.error("negentropy reconcile error:",e6),r?.onclose?.(`reconcile error: ${e6}`)}break;case"NEG-CLOSE":{const e=t[2];console.warn("negentropy error:",e),r.onclose?.(e);break}case"NEG-ERR":r.onclose?.()}}}async start(){const t=this.neg.initiate();this.relay.send(`["NEG-OPEN","${this.subscription.id}",${JSON.stringify(this.filter)},"${t}"]`)}close(){this.relay.send(`["NEG-CLOSE","${this.subscription.id}"]`),this.subscription.close()}};GE({},{getToken:()=>iP,hashPayload:()=>hP,unpackEventFromToken:()=>oP,validateEvent:()=>pP,validateEventKind:()=>lP,validateEventMethodTag:()=>uP,validateEventPayloadTag:()=>dP,validateEventTimestamp:()=>aP,validateEventUrlTag:()=>cP,validateToken:()=>sP});var rP="Nostr ";async function iP(t,e,n,r=!1,i){const s={kind:RT,tags:[["u",t],["method",e]],created_at:Math.round((new Date).getTime()/1e3),content:""};i&&s.tags.push(["payload",hP(i)]);const o=await n(s);return(r?rP:"")+lk.encode(XE.encode(JSON.stringify(o)))}async function sP(t,e,n){return await pP(await oP(t).catch(t=>{throw t}),e,n).catch(t=>{throw t})}async function oP(t){if(!t)throw new Error("Missing token");t=t.replace(rP,"");const e=YE.decode(lk.decode(t));if(!e||0===e.length||!e.startsWith("{"))throw new Error("Invalid token");return JSON.parse(e)}function aP(t){return!!t.created_at&&Math.round((new Date).getTime()/1e3)-t.created_at<60}function lP(t){return t.kind===RT}function cP(t,e){const n=t.tags.find(t=>"u"===t[0]);return!!n&&n.length>0&&n[1]===e}function uP(t,e){const n=t.tags.find(t=>"method"===t[0]);return!!n&&n.length>0&&n[1].toLowerCase()===e.toLowerCase()}function hP(t){return LS(GS(XE.encode(JSON.stringify(t))))}function dP(t,e){const n=t.tags.find(t=>"payload"===t[0]);if(!n)return!1;const r=hP(e);return n.length>0&&n[1]===r}async function pP(t,e,n,r){if(!cR(t))throw new Error("Invalid nostr event, signature invalid");if(!lP(t))throw new Error("Invalid nostr event, kind invalid");if(!aP(t))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!cP(t,e))throw new Error("Invalid nostr event, url tag invalid");if(!uP(t,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!dP(t,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}var fP=Symbol("verified");new TextDecoder("utf-8");var gP=new TextEncoder;function mP(t){return LS(GS(gP.encode(function(t){if(!function(t){if(!(t instanceof Object))return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.pubkey)return!1;if(!t.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(t.tags))return!1;for(let e=0;ee.id===t.id?0:e.created_at===t.created_at?-1:t.created_at-e.created_at);return r||t.splice(n,0,e),t}function SP(t,e){let n=0,r=t.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),s=e(t[i]);if(0===s)return[i,!0];s<0?r=i-1:n=i+1}return[n,!1]}new TextDecoder("utf-8"),new TextEncoder;var kP=Symbol.for("event-store"),EP=Symbol.for("event-uid"),RP=Symbol.for("replaceable-address"),TP=Symbol.for("from-cache"),LP=Symbol.for("replaceable-identifier");function IP(t){return Px(t)||Mx(t)}function PP(t,e,n){return t+":"+e+":"+(n??"")}function MP(t){return xP(t,LP,()=>t.tags.find(t=>"d"===t[0])?.[1]??"")}var AP=Symbol.for("encrypted-content"),OP={[uR.EncryptedDirectMessage]:"nip04",[uR.Seal]:"nip44",[uR.GiftWrap]:"nip44"};function NP(t,e){return OP[t]=e,t}function FP(t,e,n){const r=n??OP[t];if(!r)throw new Error(`Event kind ${t} does not support encrypted content`);const i=e[r];if(!i)throw new Error(`Signer does not support ${r} encryption`);return i}var DP=new Set([AP]);function zP(t){return t}function jP(...t){return BP(t.filter(t=>!!t),DP)}function UP(...t){return BP(t.filter(t=>!!t))}function BP(t,e){return 0===t.length?zP:async function(n){return t.reduce(async(t,n)=>{const r=await n(await t);if(e&&"object"==typeof r&&null!==r&&"object"==typeof t&&null!==t){const t=Reflect.ownKeys(r).filter(t=>"symbol"==typeof t);for(const n of t)e.has(n)||Reflect.deleteProperty(r,n)}return r},n)}}function $P(){return Math.round(Date.now()/1e3)}var qP=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[t]];return e};function VP(t,e){return void 0!==t[0]&&void 0!==t[1]&&(!e||t[0]===e)}function WP(t){return VP(t,"e")}function HP(t){return VP(t,"p")}function GP(t){return VP(t,"r")}function KP(t){return VP(t,"a")}var ZP=(t,...e)=>e.reduce((t,e)=>{const n=[];for(const r of t)try{const t=e(r);if(void 0===t)continue;n.push(t)}catch(e6){}return n},t),YP=new TextDecoder("utf-8"),XP=(new TextEncoder,5e3);function JP(t){let e={},n=t;for(;n.length>0;){let t=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.length=8&&rM.test(t)}function sM(t){return!!t&&64===t.length&&!!t.toLowerCase().match(/^[0-9a-f]{64}$/)}function oM(t){const e=t[1];if(!e||!sM(e))return null;const n={id:e};return t[2]&&iM(t[2])&&(n.relays=[tM(t[2])]),n}function aM(t){if(!t[1])return null;const e=function(t,e=!1){const n=t.split(":"),r=n[0]?parseInt(n[0]):void 0,i=n[1];if(void 0===r)return null;if(void 0===i||""===i||!sM(i))return null;const s=n.slice(2).join(":");return e&&""===s?null:{kind:r,pubkey:i,identifier:s}}(t[1]);return e?(t[2]&&iM(t[2])&&(e.relays=[tM(t[2])]),e):null}function lM(t){const e=t[1];if(!e||!sM(e))return null;const n={pubkey:e};return t[2]&&iM(t[2])&&(n.relays=[tM(t[2])]),n}function cM(t){return"object"==typeof t&&null!==t&&"id"in t&&"string"==typeof t.id}function uM(t,e){return cM(e)?t.id===e.id&&(!e.author||t.pubkey===e.author):t.kind===e.kind&&t.pubkey===e.pubkey&&MP(t)===(e.identifier??"")}var hM=AP,dM=FP,pM=new Set([NP(uR.DraftLong,"nip04")]);function fM(t,e){return pM.add(NP(t,e)),t}function gM(t){return function(t){return void 0!==OP[t]}(t)&&pM.has(t)}function mM(t){if(gM(t.kind))return hM in t?Reflect.get(t,hM):function(t){return Reflect.get(t,AP)}(t)}function yM(t,e){if(!gM(t.kind))throw new Error("Event kind does not support hidden content");!function(t,e){Reflect.set(t,AP,e),function(t){if(!function(t){return null!=t&&64===t.id?.length&&"string"==typeof t.sig&&"string"==typeof t.pubkey&&64===t.pubkey.length&&"string"==typeof t.content&&Array.isArray(t.tags)&&"number"==typeof t.created_at&&t.created_at>0}(t))return;const e=function(t){return Reflect.get(t,kP)}(t);e&&e.update(t)}(t)}(t,e)}var vM=Symbol.for("hidden-tags"),bM=new Set([fM(uR.BookmarkList,"nip04"),fM(uR.InterestsList,"nip04"),fM(uR.Mutelist,"nip04"),fM(uR.CommunitiesList,"nip04"),fM(uR.PublicChatsList,"nip04"),fM(uR.SearchRelaysList,"nip04"),fM(10009,"nip04"),fM(uR.Bookmarksets,"nip04"),fM(uR.Relaysets,"nip04"),fM(uR.Followsets,"nip04"),fM(uR.Curationsets,"nip04"),fM(uR.Interestsets,"nip04")]);function wM(t){return gM(t)&&bM.has(t)}function _M(t){return wM(t.kind)&&function(t){return gM(t.kind)&&function(t){return t.content.length>0}(t)}(t)}function xM(t){if(!wM(t.kind))return;if(vM in t)return t[vM];const e=mM(t);if(void 0===e)return;const n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Content is not an array of tags");const r=n.filter(t=>Array.isArray(t)).map(t=>t.map(t=>String(t)));return Reflect.set(t,vM,r),r}var CM=Symbol.for("public-contacts"),SM=Symbol.for("hidden-contacts"),kM=function(t,e){return kM=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},kM(t,e)};function EM(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}kM(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var RM=function(){return RM=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function IM(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,s=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e6){i={error:e6}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function PM(t,e,n){if(n||2===arguments.length)for(var r,i=0,s=e.length;i0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,n=this,r=n.hasError,i=n.isStopped,s=n.observers;return r||i?zM:(this.currentObservers=null,s.push(t),new DM(function(){e.currentObservers=null,FM(s,t)}))},e.prototype._checkFinalizedStatuses=function(t){var e=this,n=e.hasError,r=e.thrownError,i=e.isStopped;n?t.error(r):i&&t.complete()},e.prototype.asObservable=function(){var t=new eA;return t.source=this,t},e.create=function(t,e){return new lA(t,e)},e}(eA),lA=function(t){function e(e,n){var r=t.call(this)||this;return r.destination=e,r.source=n,r}return EM(e,t),e.prototype.next=function(t){var e,n;null===(n=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===n||n.call(e,t)},e.prototype.error=function(t){var e,n;null===(n=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===n||n.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,n;return null!==(n=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==n?n:zM},e}(aA),cA=function(t){function e(e){var n=t.call(this)||this;return n._value=e,n}return EM(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return!n.closed&&e.next(this._value),n},e.prototype.getValue=function(){var t=this,e=t.hasError,n=t.thrownError,r=t._value;if(e)throw n;return this._throwIfClosed(),r},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(aA),uA={now:function(){return(uA.delegate||Date).now()},delegate:void 0},hA=function(t){function e(e,n,r){void 0===e&&(e=1/0),void 0===n&&(n=1/0),void 0===r&&(r=uA);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,n),i}return EM(e,t),e.prototype.next=function(e){var n=this,r=n.isStopped,i=n._buffer,s=n._infiniteTimeWindow,o=n._timestampProvider,a=n._windowTime;r||(i.push(e),!s&&i.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),n=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i1||a(t,e)})},e&&(r[t]=e(r[t])))}function a(t,e){try{(n=i[t](e)).value instanceof MM?Promise.resolve(n.value.v).then(l,c):u(s[0][2],n)}catch(r){u(s[0][3],r)}var n}function l(t){a("next",t)}function c(t){a("throw",t)}function u(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}(this,arguments)}function MA(t){return AM(null==t?void 0:t.getReader)}function AA(t){if(t instanceof eA)return t;if(null!=t){if(EA(t))return r=t,new eA(function(t){var e=r[QM]();if(AM(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(SA(t))return function(t){return new eA(function(e){for(var n=0;n0&&h(i)},void 0,void 0,function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),a=null})),!c&&h(null!=r?"number"==typeof r?r:+r-l.now():i)})}function ZA(t){throw new GA(t)}function YA(t,e){return rA(function(n,r){var i=0;n.subscribe(iA(r,function(n){r.next(t.call(e,n,i++))}))})}var XA=Array.isArray,JA=Array.isArray,QA=Object.getPrototypeOf,tO=Object.prototype,eO=Object.keys;function nO(){for(var t=[],e=0;e=0?NA(n,s,c,o,!0):i=!0,c();var u=iA(n,function(t){var e,n,i=r.slice();try{for(var s=LM(i),o=s.next();!o.done;o=s.next()){var c=o.value,u=c.buffer;u.push(t),a<=u.length&&l(c)}}catch(h){e={error:h}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}},function(){for(;null==r?void 0:r.length;)n.next(r.shift().buffer);null==u||u.unsubscribe(),n.complete(),n.unsubscribe()},void 0,function(){return r=null});e.subscribe(u)})}function gO(t){return rA(function(e,n){var r,i=null,s=!1;i=e.subscribe(iA(n,void 0,void 0,function(o){r=AA(t(o,gO(t)(e))),i?(i.unsubscribe(),i=null,r.subscribe(n)):s=!0})),s&&(i.unsubscribe(),i=null,r.subscribe(n))})}function mO(t,e,n,r,i){return function(s,o){var a=n,l=e,c=0;s.subscribe(iA(o,function(e){var n=c++;l=a?t(l,e,n):(a=!0,e),r&&o.next(l)},i&&function(){a&&o.next(l),o.complete()}))}}var yO=function(t,e){return t.push(e),t},vO={connector:function(){return new aA}};function bO(t,e){void 0===e&&(e=vO);var n=e.connector;return rA(function(e,r){var i,s=n();AA(t((i=s,new eA(function(t){return i.subscribe(t)})))).subscribe(r),r.add(e.subscribe(s))})}function wO(t){return t<=0?function(){return bA}:rA(function(e,n){var r=0;e.subscribe(iA(n,function(e){++r<=t&&(n.next(e),t<=r&&n.complete())}))})}function _O(){return rA(function(t,e){t.subscribe(iA(e,qM))})}function xO(t,e){return void 0===e&&(e=tA),t=null!=t?t:CO,rA(function(n,r){var i,s=!0;n.subscribe(iA(r,function(n){var o=e(n);!s&&t(i,o)||(s=!1,i=o,r.next(n))}))})}function CO(t,e){return t===e}function SO(){for(var t=[],e=0;e=2,!0))}function PO(t){void 0===t&&(t={});var e=t.connector,n=void 0===e?function(){return new aA}:e,r=t.resetOnError,i=void 0===r||r,s=t.resetOnComplete,o=void 0===s||s,a=t.resetOnRefCountZero,l=void 0===a||a;return function(t){var e,r,s,a=0,c=!1,u=!1,h=function(){null==r||r.unsubscribe(),r=void 0},d=function(){h(),e=s=void 0,c=u=!1},p=function(){var t=e;d(),null==t||t.unsubscribe()};return rA(function(t,f){a++,u||c||h();var g=s=null!=s?s:n();f.add(function(){0!==--a||u||c||(r=MO(p,l))}),g.subscribe(f),!e&&a>0&&(e=new ZM({next:function(t){return g.next(t)},error:function(t){u=!0,h(),r=MO(d,i,t),g.error(t)},complete:function(){c=!0,h(),r=MO(d,o),g.complete()}}),AA(t).subscribe(e))})(t)}}function MO(t,e){for(var n=[],r=2;r{var n=1e3,r=60*n,i=60*r,s=24*i,o=7*s;function a(t,e,n,r){var i=e>=1.5*n;return Math.round(t/n)+" "+r+(i?"s":"")}e.exports=function(t,e){e=e||{};var l,c,u=typeof t;if("string"===u&&t.length>0)return function(t){if(!((t=String(t)).length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var a=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*s;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(t);if("number"===u&&isFinite(t))return e.long?(l=t,(c=Math.abs(l))>=s?a(l,c,s,"day"):c>=i?a(l,c,i,"hour"):c>=r?a(l,c,r,"minute"):c>=n?a(l,c,n,"second"):l+" ms"):function(t){var e=Math.abs(t);return e>=s?Math.round(t/s)+"d":e>=i?Math.round(t/i)+"h":e>=r?Math.round(t/r)+"m":e>=n?Math.round(t/n)+"s":t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}}),UO=o((t,e)=>{e.exports=function(t){function e(t){let r,i,s,o=null;function a(...t){if(!a.enabled)return;const n=a,i=Number(new Date);n.diff=i-(r||i),n.prev=r,n.curr=i,r=i,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(r,i)=>{if("%%"===r)return"%";s++;const o=e.formatters[i];if("function"==typeof o){const e=t[s];r=o.call(n,e),t.splice(s,1),s--}return r}),e.formatArgs.call(n,t),(n.log||e.log).apply(n,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=n,a.destroy=e.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==e.namespaces&&(i=e.namespaces,s=e.enabled(t)),s),set:t=>{o=t}}),"function"==typeof e.init&&e.init(a),a}function n(t,n){const r=e(this.namespace+(void 0===n?":":n)+t);return r.log=this.log,r}function r(t,e){let n=0,r=0,i=-1,s=0;for(;n"-"+t)].join(",");return e.enable(""),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=("string"==typeof t?t:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const r of n)"-"===r[0]?e.skips.push(r.slice(1)):e.names.push(r)},e.enabled=function(t){for(const n of e.skips)if(r(t,n))return!1;for(const n of e.names)if(r(t,n))return!0;return!1},e.humanize=jO(),e.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(n=>{e[n]=t[n]}),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let n=0;for(let e=0;e{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,t=>{"%%"!==t&&(r++,"%c"===t&&(i=r))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e6){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e6){}return!e&&"undefined"!=typeof process&&"env"in process&&(e={}.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e6){}}(),t.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=UO()(t);var{formatters:n}=e.exports;n.j=function(t){try{return JSON.stringify(t)}catch(e6){return"[UnexpectedJSONParseError]: "+e6.message}}}),$O=l(BO(),1),qO=(0,$O.default)("applesauce"),VO=qO.extend("event-cache"),WO=Symbol("expiration-timestamp");function HO(t){return xP(t,WO,()=>{const e=t.tags.find(t=>"expiration"===t[0])?.[1];return e?parseInt(e):void 0})}var GO=o((t,e)=>{e.exports=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if((r=e.length)!=n.length)return!1;for(i=r;0!==i--;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(s=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(i=r;0!==i--;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;0!==i--;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!=e&&n!=n}}),KO=l(GO(),1),ZO="abcdefghijklmnopqrstuvwxyz",YO=new Set((ZO+ZO.toUpperCase()).split("")),XO=Symbol.for("indexable-tags");function JO(t){let e=Reflect.get(t,XO);if(!e){const n=new Set;for(const e of t.tags)e.length>=2&&1===e[0].length&&YO.has(e[0])&&n.add(e[0]+":"+e[1]);e=n,Reflect.set(t,XO,n)}return e}function QO(t,e){if(t.ids&&-1===t.ids.indexOf(e.id))return!1;if(t.kinds&&-1===t.kinds.indexOf(e.kind))return!1;if(t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;if(t.since&&e.created_att.until)return!1;for(let n in t)if("&"===n[0]){let r=n.slice(1),i=t[n];if(i&&i.length>0){const t=JO(e);for(const e of i)if(!t.has(r+":"+e))return!1}}for(let n in t)if("#"===n[0]){let r=n.slice(1),i=t[n];if(i){const n=t[`&${r}`],s=n?i.filter(t=>!n.includes(t)):i;if(0===s.length)continue;const o=JO(e);if(!1===s.some(t=>o.has(r+":"+t)))return!1}}return!0}function tN(t,e){for(let n=0;n[t,this.get(t)])}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0===--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const n=this.items[t];this.ttl>0&&n.expiry<=Date.now()?this.delete(t):(e=n.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,n=!1,r=this.resetTtl){let i;if(n||this.has(t)){if(i=this.items[t],i.value=e,!1===n&&r&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,n=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==n&&(n.next=e),null!==e&&(e.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1===++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(t=this.keys()){return t.map(t=>this.get(t))}},rN=Symbol.for("mailboxes-inboxes"),iN=Symbol.for("mailboxes-outboxes");function sN(t){return xP(t,rN,()=>{const e=[];for(const n of t.tags)if(GP(n))try{const[,t,r]=n;!t||!iM(t)||e.includes(t)||"read"!==r&&void 0!==r||e.push(tM(t))}catch{}return e})}function oN(t){return xP(t,iN,()=>{const e=[];for(const n of t.tags)if(GP(n))try{const[t,r,i]=n;"r"!==t||!iM(r)||e.includes(r)||"write"!==i&&void 0!==i||e.push(tM(r))}catch{}return e})}var aN=Symbol.for("profile-content");function lN(t){return xP(t,aN,()=>{const e=function(t){try{return JSON.parse(t)}catch(e6){return}}(t.content);if(e)return e.nip05&&"string"!=typeof e.nip05&&(e.nip05=String(e.nip05)),e.website&&e.website?.length>0&&!1===e.website?.startsWith("http")&&(e.website="https://"+e.website),e})}function cN(t){return!(!t||t.kind!==uR.Metadata&&t.kind!==uR.Handlerinformation||!lN(t))}function uN(t,e){return Object.fromEntries(Array.from(Object.entries(t)).map(([t,n])=>[t,{authors:n.map(t=>t.pubkey),...e}]))}function hN(t,e=!0){return n=>function(t,e,n=!0){const r=t.find(t=>t[0]===e[0]);return r?n?t.map(t=>t===r?e:t):t:[...t,e]}(n,t,e)}function dN(t,e=!0){return pN(hN(t,e))}function pN(...t){return async e=>({...e,tags:await UP(...t)(Array.from(e.tags))})}function fN(t,...e){return 0===(e=e.filter(t=>!!t)).length?t=>t:async n=>{if(!t)throw new Error("Missing signer for hidden tags");if(!wM(n.kind))throw new Error("Event kind does not support hidden tags");let r,i;if(_M(n)?(i=xM(n),void 0===i&&(_M(n)?(r=await t.getPublicKey(),i=await async function(t,e,n){if(!wM(t.kind))throw new Error("Event kind does not support hidden tags");if(function(t){if(!wM(t.kind))return!1;try{return vM in t||function(t){return!!gM(t.kind)&&function(t){return!0===Reflect.has(t,AP)}(t)&&!0===Reflect.has(t,hM)}(t)&&void 0!==xM(t)}catch{}return!1}(t))return t[vM];await async function(t,e,n){if(!gM(t.kind))throw new Error("Event kind does not support hidden content");if(hM in t)return Reflect.get(t,hM);const r=await FP(t.kind,e,n).decrypt(t.pubkey,t.content);return yM(t,r),r}(t,e,n);const r=xM(t);if(void 0===r)throw new Error("Failed to unlock hidden tags");return function(t,e){if(!wM(t.kind))throw new Error("Event kind does not support hidden tags");Reflect.set(t,vM,e),yM(t,JSON.stringify(e))}(t,r),r}({...n,pubkey:r},t)):i=[])):i=[],void 0===i)throw new Error("Failed to find hidden tags");const s=await UP(...e)(i),o=function(t,e){return dM(t,e)}(n.kind,t);r||(r=await t.getPublicKey());const a=JSON.stringify(s),l=await o.encrypt(r,a);return{...n,content:l,[AP]:a}}}function gN(t){return dN(["alt",t])}function mN(t){return dN(["expiration",t.toString()],!0)}function yN(t=!0){return pN(t?hN(["-"]):t=>t.filter(t=>!("-"===t[0])))}function vN(t){return async e=>{if(!t)throw new Error("Missing signer");Reflect.deleteProperty(e,"id"),Reflect.deleteProperty(e,"sig");const n=await t.getPublicKey(),r={...e,pubkey:n};return Reflect.has(e,AP)&&Reflect.set(r,AP,Reflect.get(e,AP)),r}}var bN=class t extends Promise{static fromKind(e){return new t(t=>t({kind:e,created_at:$P(),tags:[],content:""}))}static fromEvent(e){return new t(t=>t(function(t){return{kind:t.kind,created_at:$P(),tags:Array.from(t.tags),content:t.content}}(e)))}_signerRef={};get signer(){return this._signerRef.signer}set signer(t){this._signerRef.signer=t}chain(t){const e=new(0,this.constructor)(e=>e(this.then(async e=>{const n=await t(e);for(const t of Reflect.ownKeys(n))"symbol"!=typeof t||DP.has(t)||Reflect.deleteProperty(n,t);return n})));return e._signerRef=this._signerRef,e}as(t){return this._signerRef.signer=t,this}strip(){return new t(t=>t(this.then(t=>({content:t.content,tags:t.tags,created_at:t.created_at,kind:t.kind}))))}stamp(e=this.signer){return new t((t,n)=>{if(!e)return n(new Error("Signer required for stamping"));t(this.then(t=>vN(e)(t)))})}async sign(t=this.signer){if(!t)throw new Error("Missing signer");this.signer||(this.signer=t);const e=await(this),n=await function(t){return async e=>{if(!t)throw new Error("Missing signer");const n=await vN(t)(e),r=await t.signEvent(n);if(Reflect.has(e,"pubkey")&&Reflect.get(e,"pubkey")!==r.pubkey)throw new Error("Signer modified pubkey");if(!Ax(r,e.kind))throw new Error("Signer modified event kind");return Reflect.has(e,AP)&&Reflect.set(r,AP,Reflect.get(e,AP)),r}}(t)(e);if(Reflect.has(e,"pubkey")&&Reflect.get(e,"pubkey")!==n.pubkey)throw new Error("Signer modified pubkey");if(Ax(n,e.kind))return n;throw new Error("Signer modified event kind")}kind(e){return new t(t=>({...t,kind:e}))}content(t){return this.chain(e=>({...e,content:t}))}created(t=$P()){return t instanceof Date&&(t=Math.floor(t.getTime()/1e3)),this.chain(e=>({...e,created_at:t}))}meta(t){return this.chain(function(t){return jP(t?.protected?yN(!0):t=>t,t?.expiration?mN(t.expiration):t=>t,t?.alt?gN(t.alt):t=>t)}(t))}alt(t){return this.chain(gN(t))}expiration(t){return this.chain(mN(t))}contentWarning(t){return this.chain(function(t){return e=>{let n=Array.from(e.tags);return n=n.filter(t=>"content-warning"!==t[0]),"string"==typeof t?n.push(["content-warning",t]):!0===t&&n.push(["content-warning"]),{...e,tags:n}}}(t))}protected(t){return this.chain(yN(t))}modifyTags(...t){let e;return e=this.chain(n=>function(t,e){let n=[],r=[];return void 0===t?n=r=[]:Array.isArray(t)?n=t:"function"==typeof t?n=[t]:("function"==typeof t.public?n=[t.public]:t.public&&(n=t.public),"function"==typeof t.hidden?r=[t.hidden]:t.hidden&&(r=t.hidden)),jP(n.length>0?pN(...n):void 0,r.length>0?fN(e,...r):void 0)}(t[0],e.signer)(n)),e}modifyPublicTags(...t){return this.chain(pN(...t))}modifyHiddenTags(...t){let e;return e=this.chain(n=>fN(e.signer,...t)(n)),e}encryptedContent(t,e,n){let r;return r=this.chain(i=>{const s=r.signer;if(!s)throw new Error("Signer required for encrypted content");return function(t,e,n,r){return async i=>{if(!n)throw new Error("Signer required for encrypted content");const s=await FP(i.kind,n,r).encrypt(t,e);return{...i,content:s,[AP]:e}}}(t,e,s,n)(i)}),r}},wN=o((t,e)=>{function n(t,e){var n,r;if(0===e.length)return t;for(n=0,r=e.length;nnull!==t).map(e=>(e.author=t.pubkey,e))}(t);if(r.length>0){let i=this.deletedIds.get(e);i||(i=new Set,this.deletedIds.set(e,i));for(const e of r){i.add(e.id);const r={pointer:e,until:t.created_at};n.push(r),this.deletedSubject.next(r)}}const i=function(t){return t.tags.filter(KP).map(aM).filter(t=>null!==t).filter(e=>e.pubkey===t.pubkey)}(t);if(i.length>0){let r=this.deletedIdentifiers.get(e);r||(r=new Map,this.deletedIdentifiers.set(e,r));for(const e of i){const i=e.kind+"|"+e.identifier;r.set(i,t.created_at);const s={pointer:e,until:t.created_at};n.push(s),this.deletedSubject.next(s)}}return n}check(t){const e=t.pubkey;if(Px(t.kind)||Mx(t.kind)){const n=this.deletedIdentifiers.get(e);if(!n)return!1;const r=MP(t),i=t.kind+"|"+r,s=n.get(i);return void 0!==s&&s>=t.created_at}{const n=this.deletedIds.get(e);return!!n&&n.has(t.id)}}filter(t){return t.filter(t=>!1===this.check(t))}},CN=class{log=qO.extend("EventMemory");kinds=new Map;authors=new Map;tags=new nN;created_at=[];kindAuthor=new Map;events=new nN;replaceable=new Map;get size(){return this.events.size}hasEvent(t){return this.events.has(t)}getEvent(t){return this.events.get(t)}hasReplaceable(t,e,n){const r=this.replaceable.get(PP(t,e,n));return!!r&&r.length>0}getReplaceable(t,e,n){const r=PP(t,e,n);return this.replaceable.get(r)?.[0]}getReplaceableHistory(t,e,n){const r=PP(t,e,n);return this.replaceable.get(r)}getByFilters(t){return Array.from(this.getEventsForFilters(Array.isArray(t)?t:[t]))}getTimeline(t){const e=[],n=this.getByFilters(t);for(const r of n)CP(e,r);return e}add(t){const e=t.id,n=this.events.get(e);if(n)return n;this.events.set(e,t),this.getKindIndex(t.kind).add(t),this.getAuthorsIndex(t.pubkey).add(t),this.getKindAuthorIndex(t.kind,t.pubkey).add(t);for(const r of JO(t))this.tags.has(r)&&this.getTagIndex(r).add(t);if(CP(this.created_at,t),IP(t.kind)){const e=t.tags.find(t=>"d"===t[0])?.[1],n=PP(t.kind,t.pubkey,e);let r=this.replaceable.get(n);this.replaceable.has(n)||(r=[],this.replaceable.set(n,r)),CP(r,t)}return t}remove(t){let e="string"==typeof t?this.events.get(t):t;if(!e)return!1;const n=e.id;if(!this.events.has(n))return!1;const r=this.authors.get(e.pubkey);r&&(r.delete(e),0===r.size&&this.authors.delete(e.pubkey));const i=this.kinds.get(e.kind);i&&(i.delete(e),0===i.size&&this.kinds.delete(e.kind));const s=`${e.kind}:${e.pubkey}`,o=this.kindAuthor.get(s);o&&(o.delete(e),0===o.size&&this.kindAuthor.delete(s));for(const a of JO(e))if(this.tags.has(a)){const t=this.getTagIndex(a);t.delete(e),0===t.size&&this.tags.delete(a)}if(this.removeFromSortedArray(this.created_at,e),this.events.delete(n),IP(e.kind)){const t=e.tags.find(t=>"d"===t[0])?.[1],n=PP(e.kind,e.pubkey,t),r=this.replaceable.get(n);r&&(this.removeFromSortedArray(r,e),0===r.length&&this.replaceable.delete(n))}return this.claims.delete(e),!0}removeByFilters(t){const e=this.getByFilters(t);let n=0;for(const r of e)this.remove(r)&&n++;return n}update(t){}claims=new WeakMap;touch(t){this.events.has(t.id)&&this.events.set(t.id,t)}claim(t){const e=this.claims.get(t)||0;this.claims.set(t,e+1),this.touch(t)}isClaimed(t){const e=this.claims.get(t);return void 0!==e&&e>0}removeClaim(t){const e=this.claims.get(t);if(void 0!==e&&e>0){const n=e-1;0===n?this.claims.delete(t):this.claims.set(t,n)}}clearClaim(t){this.claims.delete(t)}*unclaimed(){let t=this.events.first;for(;t;){const e=t.value;this.isClaimed(e)||(yield e),t=t.next}return 0}prune(t){let e=0;const n=this.unclaimed();for(const r of n)if(this.remove(r),e++,t&&e>=t)break;return e}getKindIndex(t){return this.kinds.has(t)||this.kinds.set(t,new Set),this.kinds.get(t)}getAuthorsIndex(t){return this.authors.has(t)||this.authors.set(t,new Set),this.authors.get(t)}getKindAuthorIndex(t,e){const n=`${t}:${e}`;return this.kindAuthor.has(n)||this.kindAuthor.set(n,new Set),this.kindAuthor.get(n)}getTagIndex(t){if(!this.tags.has(t)){const e=new Set,n=Date.now();for(const i of this.events.values())JO(i).has(t)&&e.add(i);const r=Date.now()-n;r>100&&this.log(`Built index ${t} took ${r}ms`),this.tags.set(t,e)}return this.tags.get(t)}removeFromSortedArray(t,e){if(0===t.length)return;const n=SP(t,t=>t.created_at-e.created_at);if(n){let r=n[0],i=!1;if(t[r]===e)return void t.splice(r,1);for(let n=r-1;n>=0&&t[n].created_at===e.created_at;n--)if(t[n]===e){t.splice(n,1),i=!0;break}if(i)return;for(let n=r+1;nt.created_at-e):void 0;i&&(n=Math.max(0,Math.min(i[0],this.created_at.length-1)));const s=t?SP(this.created_at,e=>e.created_at-t):void 0;if(s&&(r=Math.max(0,Math.min(s[0],this.created_at.length-1))),!(n>r))for(let o=n;o<=r;o++){const n=this.created_at[o];if(!(void 0!==e&&n.created_at>e)){if(void 0!==t&&n.created_at{const r=t instanceof Set?t:new Set(t);if(e)n=r,e=!1;else for(const e of n)r.has(e)||n.delete(e);return n};t.ids&&r(this.iterateIds(t.ids));let i=null;void 0!==t.since&&(i=Array.from(this.iterateTime(t.since,t.until)),r(i));for(const s of YO){const e=t[`&${s}`];if(e?.length)for(const t of e)r(this.iterateTag(s,[t]))}for(const s of YO){const e=t[`#${s}`];if(e?.length){const n=t[`&${s}`],i=n?e.filter(t=>!n.includes(t)):e;i.length>0&&r(this.iterateTag(s,i))}}if(t.authors&&t.kinds&&t.authors.length*t.kinds.length<=20){const e=new Set;for(const n of t.kinds)for(const r of t.authors){const t=`${n}:${r}`,i=this.kindAuthor.get(t);if(i)for(const n of i)e.add(n)}r(e)}else t.authors&&r(this.iterateAuthors(t.authors)),t.kinds&&r(this.iterateKinds(t.kinds));if(void 0===t.since&&void 0!==t.until&&(i=Array.from(this.iterateTime(t.since,t.until)),r(i)),e)return new Set(this.events.values());if(t.limit&&i){const e=new Set;for(const r of i){if(e.size>=t.limit)break;n.has(r)&&e.add(r)}return e}return n}getEventsForFilters(t){if(0===t.length)return new Set;let e=new Set;for(const n of t){const t=this.getEventsForFilter(n);for(const n of t)e.add(n)}return e}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}};function SN(t){return e=>{const n=new Set;return e.pipe(zO(e=>{if(void 0!==e)if(Array.isArray(e))for(const r of e)n.has(r)||(n.add(r),t.claim(r));else n.has(e)||(n.add(e),t.claim(e))}),kO(()=>{for(const e of n)t.removeClaim(e)}))}}function kN(t){return e=>{let n;return e.pipe(zO(e=>{n!==e&&(n&&t.removeClaim(n),e&&t.claim(e),n=e)}),kO(()=>{n&&t.removeClaim(n)}))}}function EN(t,e){return NO(n=>n?UA(n):t.eventLoader?jA(t.eventLoader(e)).pipe(OO(void 0)):UA(n))}function RN(t){return"string"==typeof t&&(t={id:t}),e=>cO(aO(()=>function(t,e){const n=t.getEvent(e.id);return n instanceof Promise?jA(n):UA(n)}(e,t)).pipe(e.eventLoader?EN(e,t):tA),e.insert$.pipe(pO(e=>e.id===t.id)),e.remove$.pipe(pO(e=>e.id===t.id),wO(1),YA(()=>{}))).pipe(xO((t,e)=>t?.id===e?.id),kN(e))}function TN(t){return e=>{let n;return cO(aO(()=>function(t,e){const n=t.getReplaceable(e.kind,e.pubkey,e.identifier);return n instanceof Promise?jA(n):UA(n)}(e,t)).pipe(e.eventLoader?EN(e,t):tA),e.insert$.pipe(pO(e=>e.pubkey==t.pubkey&&e.kind===t.kind&&(void 0===t.identifier||MP(e)===t.identifier)))).pipe(zO(t=>n=t),RO(e.remove$.pipe(pO(t=>t.id===n?.id),YA(()=>{}))),xO((t,e)=>void 0===t||void 0===e?t===e:e.created_at{const r=new Map,i=t=>e?t.id:function(t){let e=Reflect.get(t,EP);return e||(e=IP(t.kind)?function(t){return IP(t.kind)?xP(t,RP,()=>PP(t.kind,t.pubkey,MP(t))):null}(t)??t.id:t.id,Reflect.set(t,EP,e)),e}(t);return aO(()=>{const e=n.getTimeline(t);return e instanceof Promise?jA(e):UA(e)}).pipe(SN(n),RO(n.insert$.pipe(pO(e=>tN(t,e)),SN(n))),RO(n.remove$.pipe(pO(e=>tN(t,e)),YA(t=>t.id))),IO((t,n)=>{if("string"==typeof n){const e=t.find(t=>t.id===n);if(e){const t=i(e);r.get(t)?.id===n&&r.delete(t)}return t.filter(t=>t.id!==n)}if(Array.isArray(n)){r.clear();for(const t of n)r.set(i(t),t);return[...n]}let s=[...t];const o=i(n),a=r.get(o);if(a&&(!IP(n.kind)||!e&&n.created_atr.clear()))}}function IN(t,e=!1){return t=Array.isArray(t)?t:[t],n=>{const r=e?bA:aO(()=>function(t,e){const n=t.getByFilters(e);return n instanceof Promise?jA(n).pipe(iO(t=>jA(t))):jA(n)}(n,t));return cO(r,n.insert$.pipe(pO(e=>tN(t,e))))}}function PN(t){return"string"==typeof t&&(t={pubkey:t}),e=>{return e.replaceable({kind:uR.Contacts,pubkey:t.pubkey,relays:t.relays}).pipe((n=e,t=>{let e;return cO(t.pipe(zO(t=>e=t)),n.update$.pipe(pO(t=>t.id===e?.id)))}),YA(t=>{return t?function(...t){const e=new Map;for(const n of t)if(Array.isArray(n))for(const t of n)t&&e.set(t.pubkey,t);else n&&e.set(n.pubkey,n);return Array.from(e.values())}(function(t){return xP(t,CM,()=>ZP(t.tags,t=>HP(t)?t:void 0,t=>lM(t)??void 0))}(e=t),function(t){if(SM in t)return t[SM];const e=xM(t);if(!e)return;const n=ZP(e,t=>HP(t)?t:void 0,t=>lM(t)??void 0);return Reflect.set(t,SM,n),n}(e)):[];var e}));var n}}function MN(t){return"string"==typeof t&&(t={pubkey:t}),e=>e.replaceable({kind:uR.RelayList,pubkey:t.pubkey,relays:t.relays}).pipe(YA(t=>t&&{inboxes:sN(t),outboxes:oN(t)}))}function AN(t){return"string"==typeof t&&(t={pubkey:t}),e=>e.replaceable({kind:uR.Metadata,pubkey:t.pubkey,relays:t.relays}).pipe(pO(cN),YA(t=>t&&lN(t)))}var ON=class{models=new Map;modelKeepWarm=6e4;destroy$=new hA(1);model(t,...e){let n=this.models.get(t);n||(n=new Map,this.models.set(t,n));const r=t.getKey?t.getKey(...e):(0,_N.default)(e);let i=n.get(r);if(!i){const s=()=>{n.get(r)===i&&n.delete(r)};i=t(...e)(this).pipe(kO(s),PO({connector:()=>new hA(1),resetOnComplete:()=>cO(lO(this.modelKeepWarm),this.destroy$),resetOnRefCountZero:()=>cO(lO(this.modelKeepWarm),this.destroy$)}),FO(this.destroy$)),n.set(r,i)}return i}filters(t,e=!1){return Array.isArray(t)||(t=[t]),this.model(IN,t,e)}event(t){return"string"==typeof t||cM(t)?this.model(RN,t):this.replaceable(t)}replaceable(...t){let e;if(1===t.length)e=t[0];else if(3===t.length||2===t.length){let[n,r,i]=t;e={kind:n,pubkey:r,identifier:i}}if(!e)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(TN,e)}addressable(t){return this.replaceable(t)}timeline(t,e=!1){return this.model(LN,t,e)}profile(t){return this.model(AN,t)}contacts(t){return"string"==typeof t&&(t={pubkey:t}),this.model(PN,t)}mailboxes(t){return"string"==typeof t&&(t={pubkey:t}),this.model(MN,t)}dispose(){this.destroy$.next(),this.destroy$.complete()}},NN=class{expired$;expiredSubject;expirations=new Map;timer=null;nextCheck=null;constructor(){this.expiredSubject=new aA,this.expired$=this.expiredSubject.asObservable()}track(t){const e=HO(t);if(!e||!Number.isFinite(e))return;const n=$P();if(e<=n)return;if(this.expirations.set(t.id,e),this.timer&&this.nextCheck&&this.nextCheck<=e)return;this.timer&&clearTimeout(this.timer);const r=e-n;r>0&&(this.timer=setTimeout(this.emitNotifications.bind(this),1e3*r+10),this.nextCheck=e)}forget(t){this.expirations.delete(t)}check(t){const e=HO(t);return!!e&&e<=$P()}dispose(){this.timer&&clearTimeout(this.timer),this.timer=null,this.nextCheck=null,this.expirations.clear(),this.expiredSubject.complete()}[Symbol.dispose](){this.dispose()}emitNotifications(){const t=$P();let e=1/0;for(const[n,r]of this.expirations)r<=t?(this.expirations.delete(n),this.expiredSubject.next(n)):r0&&(this.timer=setTimeout(this.emitNotifications.bind(this),1e3*n+10),this.nextCheck=e)}}},FN=class t extends ON{database;memory;deletes;expiration;keepOldVersions=!1;keepExpired=!1;keepDeleted=!1;_verifyEventMethod=_P;get verifyEvent(){return this._verifyEventMethod}set verifyEvent(t){this._verifyEventMethod=t,void 0===t&&console.warn("[applesauce-core] EventStore.verifyEvent is undefined; signature checks are disabled.")}insert$=new aA;update$=new aA;remove$=new aA;eventLoader;internalSubscriptions=new DM;constructor(t){super(),t?.database?(this.database=t.database,this.memory=new CN):this.database=this.memory=new CN,void 0!==t?.keepDeleted&&(this.keepDeleted=t.keepDeleted),void 0!==t?.keepExpired&&(this.keepExpired=t.keepExpired),void 0!==t?.keepOldVersions&&(this.keepOldVersions=t.keepOldVersions),t?.verifyEvent&&(this.verifyEvent=t.verifyEvent),this.deletes=t?.deleteManager??new xN,this.internalSubscriptions.add(this.deletes.deleted$.subscribe(this.handleDeleteNotification.bind(this))),this.expiration=t?.expirationManager??new NN,this.internalSubscriptions.add(this.expiration.expired$.subscribe(this.handleExpiredNotification.bind(this)))}mapToMemory(t){if(void 0!==t)return this.memory?this.memory.add(t):t}handleDeleteNotification({pointer:t,until:e}){if(!this.keepDeleted)if(cM(t)){const n=this.getEvent(t.id);n&&e>=n.created_at&&uM(n,t)&&this.remove(n)}else if(function(t){return"object"==typeof t&&null!==t&&"identifier"in t&&"pubkey"in t&&"kind"in t&&"string"==typeof t.identifier&&"string"==typeof t.pubkey&&"number"==typeof t.kind}(t)){const n=this.getReplaceableHistory(t.kind,t.pubkey,t.identifier);if(n)for(const r of n)e>=r.created_at&&uM(r,t)&&this.remove(r)}}handleExpiredNotification(t){this.keepExpired||this.remove(t)}static copySymbolsToDuplicateEvent(t,e){if(t.kind!==e.kind)throw new Error("Source and destination events must have the same kind");if((n=t.kind)<1e4&&0!==n&&3!==n&&t.id!==e.id)throw new Error("Source and destination events must have the same ID");var n;if(IP(t.kind)&&t.pubkey!==e.pubkey&&MP(t)!==MP(e))throw new Error("Source and destination events must have the same pubkey and replaceable identifier");let r=!1;const i=(s=t,Reflect.get(s,eM));var s;if(i){for(const t of i)nM(e,t);r=!0}const o=[TP,fP,AP];for(const a of o)a in t&&!(a in e)&&(Reflect.set(e,a,Reflect.get(t,a)),r=!0);return r}add(e,n){if(e.kind===uR.EventDeletion)return this.deletes.add(e),e;if(this.deletes.check(e))return e;const r=HO(e);if(!1===this.keepExpired&&r&&r<=$P())return null;n&&nM(e,n);const i=IP(e.kind)?MP(e):void 0;if(!1===this.keepOldVersions&&IP(e.kind)){const n=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(n&&n.length>0){let r=n[0];for(const t of n)(t.created_at>r.created_at||t.created_at===r.created_at&&t.idr.created_at||e.created_at===r.created_at&&e.id0){let e=t[0];for(const r of t)(r.created_at>e.created_at||r.created_at===e.created_at&&r.idt!==e);for(const t of n)this.remove(t);if(n.length>0)return e}}return!1===this.keepExpired&&void 0!==r&&this.expiration.track(o),o}remove(t){const e="string"==typeof t?t:t.id;let n=this.memory.getEvent(e);this.expiration.forget(e),n&&Reflect.deleteProperty(n,kP),this.memory!==this.database&&this.memory.remove(t);const r=this.database.remove(t);return r&&n&&this.remove$.next(n),r}removeByFilters(t){const e=this.getByFilters(t);for(const r of e)this.expiration.forget(r.id);this.memory!==this.database&&this.memory.removeByFilters(t);const n=this.database.removeByFilters(t);for(const r of e)this.remove$.next(r);return n}update(t){return!!this.database.add(t)&&(this.database.update?.(t),this.update$.next(t),!0)}hasEvent(t){return"string"==typeof t?this.memory.hasEvent(t)||this.database.hasEvent(t):cM(t)?this.memory.hasEvent(t.id)||this.database.hasEvent(t.id):this.hasReplaceable(t.kind,t.pubkey,t.identifier)}getEvent(t){return"string"==typeof t?this.memory.getEvent(t)??this.mapToMemory(this.database.getEvent(t)):cM(t)?this.memory.getEvent(t.id)??this.mapToMemory(this.database.getEvent(t.id)):this.getReplaceable(t.kind,t.pubkey,t.identifier)}hasReplaceable(t,e,n){return this.memory.hasReplaceable(t,e,n)||this.database.hasReplaceable(t,e,n)}getReplaceable(t,e,n){return this.memory.getReplaceable(t,e,n)??this.mapToMemory(this.database.getReplaceable(t,e,n))}getReplaceableHistory(t,e,n){return this.memory.getReplaceableHistory(t,e,n)??this.database.getReplaceableHistory(t,e,n)?.map(t=>this.mapToMemory(t)??t)}getByFilters(t){const e=this.database.getByFilters(t);return this.memory?e.map(t=>this.mapToMemory(t)):e}getTimeline(t){const e=this.database.getTimeline(t);return this.memory?e.map(t=>this.mapToMemory(t)):e}touch(t){return this.memory.touch(t)}claim(t){return this.memory.claim(t)}isClaimed(t){return this.memory.isClaimed(t)??!1}removeClaim(t){return this.memory.removeClaim(t)}clearClaim(t){return this.memory.clearClaim(t)}unclaimed(){return this.memory.unclaimed()||function*(){}()}prune(t){return this.memory.prune(t)??0}dispose(){const t=this.eventLoader;t&&"function"==typeof t[Symbol.dispose]&&t[Symbol.dispose](),this.eventLoader=void 0,super.dispose(),this.internalSubscriptions.unsubscribe(),this.expiration.dispose?.(),this.insert$.complete(),this.update$.complete(),this.remove$.complete()}[Symbol.dispose](){this.dispose()}};function DN(t,e=!0){return n=>{const r=n.pipe(PO());return r.pipe(iO(e=>{if("string"==typeof e)return bA;const n=t.add(e);return n instanceof Promise?jA(n):UA(n)}),gO(()=>UA(null)),pO(t=>null!==t),e?rA(function(t,e){var n=new Set;t.subscribe(iA(e,function(t){var r=t;n.has(r)||(n.add(r),e.next(t))}))}):tA,RO(r.pipe(pO(t=>"string"==typeof t))))}}function zN(t){return DN(t,!0)}var jN=class extends Error{};function UN(t,e){return KA({first:t,with:()=>BA(()=>new jN(e??"Timeout"))})}function BN(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name&&"BYTES_PER_ELEMENT"in t&&1===t.BYTES_PER_ELEMENT}var $N=t=>t?`"${t}" `:"";function qN(t,e,n=""){if(BN(t)&&(void 0===e||t.length===e))return t;void 0!==e&&function(t,e=""){if("number"!=typeof t)throw new TypeError($N(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError($N(e)+"expected integer >= 0, got "+t)}(e,"length");const r=BN(t),i=void 0!==e?` of length ${e}`:"",s=r?`length=${t.length}`:"type="+typeof t,o=$N(n)+"expected Uint8Array"+i+", got "+s;if(!r)throw new TypeError(o);throw new RangeError(o)}var VN=(t,e)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(("object"===e?"":`"${e}" `)+"expected object, got type="+typeof t)};function WN(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function HN(...t){for(let e=0;e>>e}function ZN(t,e={}){if("function"!=typeof t)throw new TypeError('"hashCons" expected function, got type='+typeof t);e=function(t,e,n="opts"){return VN(t,"defaults"),void 0!==e&&VN(e,n),Object.assign(t,e)}({},e,"info");const n=(e,n)=>t(n).update(e).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=e=>t(e),Object.assign(n,e),Object.freeze(n)}var YN=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function XN(t,e,n){return t&e^~t&n}function JN(t,e,n){return t&e^t&n^e&n}var QN=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,r){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=GN(this.buffer)}update(t){WN(this),qN(t);const{view:e,buffer:n,blockLen:r}=this,i=t.length;let s=!1;for(let o=0;o=n))throw new RangeError('"output" expected length >= '+n)}(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;e[s++]=128,e.fill(0,s),this.padOffset>r-s&&(this.process(n,0),e.fill(0)),function(t,e,n,r){const i=(t=>t/2**32|0)(n),s=(t=>t>>>0)(n);t.setUint32(e,r?s:i,r),t.setUint32(e+4,r?i:s,r)}(n,r-8,8*this.length,i),this.process(n,0),this.roundClean();const o=t===e?n:GN(t),a=this.outputLen,l=a/4,c=this.get();if(a%4||l>c.length)throw new Error("invalid outputLen");for(let u=0;u>>3,r=KN(e,17)^KN(e,19)^e>>>10;nF[u]=r+nF[u-7]+n+nF[u-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let u=0;u<64;u++){const t=c+(KN(o,6)^KN(o,11)^KN(o,25))+XN(o,a,l)+eF[u]+nF[u]|0,e=(KN(n,2)^KN(n,13)^KN(n,22))+JN(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){HN(nF)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),HN(this.buffer)}},iF=class extends rF{constructor(){super(32,tF)}},sF=ZN(()=>new iF,YN(1)),oF=new WeakMap;function aF(t,e,n,r){let i={configurable:!0,enumerable:!0,writable:!0,initializer:null};r&&(i.initializer=r);for(let s of n)i=s(t,e,i)||i;void 0===i.initializer?Object.defineProperty(t,e,i):function(t,e,n){let r=oF.get(t);r||(r=new Map,oF.set(t,r)),r.set(e,n)}(t,e,i)}function lF(t,e,n){let r={...Object.getOwnPropertyDescriptor(t,e)};for(let i of n)r=i(t,e,r)||r;void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(t):void 0,r.initializer=void 0),Object.defineProperty(t,e,r)}function cF(t,e){let n=function(t,e){var n;let r=t.prototype;for(;r;){let t=null==(n=oF.get(r))?void 0:n.get(e);if(t)return t;r=Object.getPrototypeOf(r)}}(t.constructor,e);n&&Object.defineProperty(t,e,{enumerable:n.enumerable,configurable:n.configurable,writable:n.writable,value:n.initializer?n.initializer.call(t):void 0})}var uF=a({DEFAULT_BLOSSOM_SERVER:()=>hF,default:()=>pF}),hF="https://blossom.nostr.build";function dF(t,e){let n=t||"https://blossom.nostr.build";return n.endsWith("/")&&(n=n.slice(0,-1)),e.startsWith("/")?`${n}${e}`:`${n}/${e}`}var pF=class extends pp{static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");get servers(){const t=this.nostrData.blossomServers,e=t.length?t:[hF];return this.settings.nostrPhotoFallbackUploads?e:[e[0]]}async _getAuthHeader(t,e,n){const r=Math.floor(Date.now()/1e3),i=new URL(n).hostname,s=await bN.fromKind(24242).content("upload"===t?"Upload photo for place":"Delete photo").modifyPublicTags(()=>[["t",t],["x",e],["expiration",String(r+3600)],["server",i]]).created(r).as(this.nostrAuth.signer).sign();return`Nostr ${btoa(JSON.stringify(s)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}async _uploadToServer(t,e,n,r){const i=dF(n,"upload");r&&r("signing");const s=await this._getAuthHeader("upload",e,n);r&&r("uploading");const o=await fetch(i,{method:"PUT",headers:{Authorization:s,"X-SHA-256":e},body:t});if(!o.ok){const t=await o.text();throw new Error(`Upload failed (${o.status}): ${t}`)}return o.json()}async upload(t,e={sequential:!1}){if(!this.nostrAuth.isConnected)throw new Error("Not connected");const n=await t.arrayBuffer();let r;r="undefined"!=typeof crypto&&crypto.subtle&&crypto.subtle.digest?await crypto.subtle.digest("SHA-256",n):sF(new Uint8Array(n));const i=function(t){return Array.from(new Uint8Array(t)).map(t=>t.toString(16).padStart(2,"0")).join("")}(r),s=this.servers,o=s[0],a=s.slice(1),l=[];let c;if(e.sequential){c=await this._uploadToServer(t,i,o,e.onProgress);for(const n of a)try{const r=await this._uploadToServer(t,i,n,e.onProgress);l.push(r.url)}catch(e6){console.warn(`Fallback upload to ${n} failed:`,e6)}}else{const n=this._uploadToServer(t,i,o,e.onProgress),r=a.map(n=>this._uploadToServer(t,i,n,e.onProgress));c=await n;const s=await Promise.allSettled(r);for(let t=0;tthis._deleteFromServer(t,e));await i;const o=await Promise.allSettled(s);for(let a=0;amF,groupPhotoContributions:()=>vF}),gF=3600,mF=class{type="photo";placeIdentifier;osmType;osmId;photos;createdAt;eventCount;static{aF(this.prototype,"placeName",[Vr],function(){return null})}#z=void cF(this,"placeName");static{aF(this.prototype,"placeNameLoading",[Vr],function(){return!0})}#j=void cF(this,"placeNameLoading");constructor({placeIdentifier:t,osmType:e,osmId:n,photos:r,createdAt:i,eventCount:s}){this.placeIdentifier=t,this.osmType=e,this.osmId=n,this.photos=r,this.createdAt=i,this.eventCount=s}};function yF(t){const e=t.tags||[],n=e.filter(t=>"t"===t[0]).map(t=>t[1]).filter(Boolean),r=e.find(t=>"imeta"===t[0]);if(!r)return null;let i=null,s=null,o=null,a=!1,l=16/9,c=null;for(const h of r.slice(1))if(h.startsWith("url "))i=h.substring(4);else if(h.startsWith("thumb "))s=h.substring(6);else if(h.startsWith("blurhash "))o=h.substring(9);else if(h.startsWith("dim ")){const[t,e]=h.substring(4).split("x").map(Number);t&&e&&(l=t/e,t>e&&(a=!0))}else if(h.startsWith("alt ")){const t=h.substring(4).trim();c="A photo of a place"===t?null:t||null}if(!i)return null;const u=e.find(t=>"i"===t[0])?.[1];return{eventId:t.id,pubkey:t.pubkey,createdAt:t.created_at,url:i,thumbUrl:s,blurhash:o,isLandscape:a,aspectRatio:l,placeIdentifier:u,tags:n,alt:c}}function vF(t,e=3){if(!t||0===t.length)return[];const n=function(t){const e=new Set;for(const n of t)if(5===n.kind)for(const t of n.tags||[])"e"===t[0]&&t[1]&&e.add(t[1]);return t.filter(t=>360===t.kind&&!e.has(t.id))}(t);if(0===n.length)return[];const r=new Map;for(const o of n){const t=(o.tags||[]).find(t=>"i"===t[0])?.[1];t&&(r.has(t)||r.set(t,[]),r.get(t).push(o))}const i=e*gF,s=[];for(const[o,a]of r){const t=[...a].sort((t,e)=>e.created_at-t.created_at);let e=[],n=null;for(const r of t)null!==n&&n-r.created_at>i&&(s.push(bF(o,e)),e=[]),e.push(r),n=r.created_at;e.length>0&&s.push(bF(o,e))}return s.filter(t=>t.photos.length>0).sort((t,e)=>e.createdAt-t.createdAt)}function bF(t,e){const n=e.map(yF).filter(Boolean).sort((t,e)=>t.createdAt-e.createdAt),r=e.reduce((t,e)=>e.created_at>t?e.created_at:t,0),[,i,s]=t.split(":");return new mF({placeIdentifier:t,osmType:i,osmId:s,photos:n,createdAt:r,eventCount:e.length})}var wF=a({default:()=>xF}),_F="contributions-name-cache",xF=class extends pp{static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"osm",[dp])}#B=void cF(this,"osm");static{aF(this.prototype,"localForage",[dp])}#$=void cF(this,"localForage");static{aF(this.prototype,"items",[Vr],function(){return[]})}#q=void cF(this,"items");_sub=null;_pendingBatchPromise=null;_lastBatchSignature="";_unresolvable=new Set;async _resolveCachedName(t){const e=this.storage.findPlaceById(t.osmId);return e?.title?e.title:await this.localForage.get(_F,t.placeIdentifier)||(await this.osm.getCachedOsmObject(t.osmType,t.osmId))?.title||null}async _resolveFromCache(t){const e=t.filter(t=>t.placeNameLoading);0!==e.length?(await Promise.all(e.map(async t=>{const e=await this._resolveCachedName(t);e&&(t.placeName=e,t.placeNameLoading=!1)})),this.items=[...this.items],this._maybeBatchFetchNames(this.items)):this._maybeBatchFetchNames(this.items)}async load(t){t?(this._sub=this.nostrData.store.timeline([{kinds:[360,5],authors:[t]}]).subscribe(t=>{this._updateItems(t)}),await this.nostrData.loadMyContributions(t)):this.items=[]}stop(){this._sub&&(this._sub.unsubscribe(),this._sub=null),this.items=[],this._lastBatchSignature="",this._pendingBatchPromise=null,this._unresolvable.clear()}willDestroy(){this.stop(),super.willDestroy(...arguments)}_updateItems(t){const e=vF(t);for(const n of e){const t=this.storage.findPlaceById(n.osmId);t?.title&&(n.placeName=t.title,n.placeNameLoading=!1)}this.items=e,this._resolveFromCache(e)}_isUnresolvable(t){return this._unresolvable.has(t.placeIdentifier)}_maybeBatchFetchNames(t){const e=t.filter(t=>t.placeNameLoading&&!this._isUnresolvable(t));for(const r of t)r.placeNameLoading&&this._isUnresolvable(r)&&(r.placeName=this._fallbackName(r),r.placeNameLoading=!1);if(0===e.length)return void(this.items.some(t=>!t.placeNameLoading)&&(this.items=[...this.items]));const n=e.map(t=>t.placeIdentifier).sort().join("|");n===this._lastBatchSignature&&this._pendingBatchPromise||(this._lastBatchSignature=n,this._pendingBatchPromise=this._batchResolveNames(e).then(t=>{for(const e of this.items)e.placeNameLoading&&(t.has(e.placeIdentifier)?(e.placeName=t.get(e.placeIdentifier),e.placeNameLoading=!1):(this._unresolvable.add(e.placeIdentifier),e.placeName=this._fallbackName(e),e.placeNameLoading=!1));this.items=[...this.items]}).catch(t=>{console.error("[contributions] Batch name resolution failed",t);for(const e of this.items)e.placeNameLoading&&(this._unresolvable.add(e.placeIdentifier),e.placeName=this._fallbackName(e),e.placeNameLoading=!1);this.items=[...this.items]}).finally(()=>{this._pendingBatchPromise=null}))}_fallbackName(t){return`OSM ${t.osmType} ${t.osmId}`}async _batchResolveNames(t){const e=new Map,n=[];for(const s of t){const t=await this._resolveCachedName(s);t?e.set(s.placeIdentifier,t):n.push({osmType:s.osmType,osmId:s.osmId})}if(0===n.length)return e;const r=await this.osm.fetchOsmObjectsBatch(n),i=[];for(const s of t){if(e.has(s.placeIdentifier))continue;const t=`${s.osmType}:${s.osmId}`,n=r.get(t);n?.title&&(e.set(s.placeIdentifier,n.title),i.push(this.localForage.set(_F,s.placeIdentifier,n.title)))}return await Promise.all(i),e}};function CF(t){return new Worker("/assets/image-processor-TE4QOxly.js",{name:t?.name})}var SF=a({default:()=>kF}),kF=class extends pp{_worker=null;_callbacks=new Map;_msgId=0;constructor(){super(...arguments),this._initWorker()}_initWorker(){if(!this._worker&&void 0!==CF)try{this._worker=new CF,this._worker.onmessage=this._handleMessage.bind(this),this._worker.onerror=this._handleError.bind(this)}catch(t){console.warn("Failed to initialize image-processor worker:",t)}}_handleMessage(t){const{id:e,success:n,blob:r,dim:i,blurhash:s,error:o}=t.data,a=this._callbacks.get(e);a&&(this._callbacks.delete(e),n?a.resolve({blob:r,dim:i,blurhash:s}):a.reject(new Error(o)))}_handleError(t){console.error("Image Processor Worker Error:",t);for(const[,e]of this._callbacks.entries())e.reject(new Error("Worker crashed"));this._callbacks.clear(),this._worker.terminate(),this._worker=null,this._initWorker()}_getImageDimensions(t){return new Promise((e,n)=>{const r=new Image,i=URL.createObjectURL(t);r.onload=()=>{const t={width:r.width,height:r.height};URL.revokeObjectURL(i),e(t)},r.onerror=()=>{URL.revokeObjectURL(i),n(new Error("Could not read image dimensions"))},r.src=i})}async process(t,e,n,r=!1){if(!this._worker)throw new Error("Image processor worker is not available.");try{const{width:i,height:s}=await this._getImageDimensions(t);let o=i,a=s;return i>s?i>e&&(a=Math.round(s*(e/i)),o=e):s>e&&(o=Math.round(i*(e/s)),a=e),new Promise((e,i)=>{const s=++this._msgId;this._callbacks.set(s,{resolve:e,reject:i}),this._worker.postMessage({type:"PROCESS_IMAGE",id:s,file:t,targetWidth:o,targetHeight:a,quality:n,computeBlurhash:r})})}catch(i){throw new Error(`Failed to process image: ${i.message}`,{cause:i})}}willDestroy(){super.willDestroy(...arguments),this._worker&&(this._worker.terminate(),this._worker=null),this._callbacks.clear()}},EF=o((t,e)=>{!function(n){"object"==typeof t&&void 0!==e?e.exports=n():"function"==typeof define&&define.amd?define([],n):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).localforage=n()}(function(){return function t(e,n,r){function i(o,a){if(!n[o]){if(!e[o]){var l="function"==typeof c&&c;if(!a&&l)return l(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[o]={exports:{}};e[o][0].call(h.exports,function(t){return i(e[o][1][t]||t)},h,h.exports,t,e,n,r)}return n[o].exports}for(var s="function"==typeof c&&c,o=0;ot.db.version;if(r&&(t.version!==e&&console.warn('The database "'+t.name+"\" can't be downgraded from version "+t.db.version+" to version "+t.version+"."),t.version=t.db.version),i||n){if(n){var s=t.db.version+1;s>t.version&&(t.version=s)}return!0}return!1}function S(t){return i([m(atob(t.data))],{type:t.type})}function k(t){return t&&t.__local_forage_encoded_blob}function E(t){var e=this,n=e._initReady().then(function(){var t=d[e._dbInfo.name];if(t&&t.dbReady)return t.dbReady});return a(n,t,t),n}function R(t,e,n,r){void 0===r&&(r=1);try{n(null,t.db.transaction(t.storeName,e))}catch(xD){if(r>0&&(!t.db||"InvalidStateError"===xD.name||"NotFoundError"===xD.name))return s.resolve().then(function(){if(!t.db||"NotFoundError"===xD.name&&!t.db.objectStoreNames.contains(t.storeName)&&t.version<=t.db.version)return t.db&&(t.version=t.db.version+1),x(t)}).then(function(){return function(t){y(t);for(var e=d[t.name],n=e.forages,r=0;r=43)}}).catch(function(){return!1})}(t).then(function(t){return h=t})}(a.db).then(function(t){return t?e:(n=e,new s(function(t,e){var r=new FileReader;r.onerror=e,r.onloadend=function(e){t({__local_forage_encoded_blob:!0,data:btoa(e.target.result||""),type:n.type})},r.readAsBinaryString(n)}));var n}):e}).then(function(e){R(r._dbInfo,g,function(i,s){if(i)return o(i);try{var a=s.objectStore(r._dbInfo.storeName);null===e&&(e=void 0);var l=a.put(e,t);s.oncomplete=function(){void 0===e&&(e=null),n(e)},s.onabort=s.onerror=function(){o(l.error?l.error:l.transaction.error)}}catch(c){o(c)}})}).catch(o)});return o(a,n),a},removeItem:function(t,e){var n=this;t=l(t);var r=new s(function(e,r){n.ready().then(function(){R(n._dbInfo,g,function(i,s){if(i)return r(i);try{var o=s.objectStore(n._dbInfo.storeName).delete(t);s.oncomplete=function(){e()},s.onerror=function(){r(o.error)},s.onabort=function(){r(o.error?o.error:o.transaction.error)}}catch(a){r(a)}})}).catch(r)});return o(r,e),r},clear:function(t){var e=this,n=new s(function(t,n){e.ready().then(function(){R(e._dbInfo,g,function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).clear();i.oncomplete=function(){t()},i.onabort=i.onerror=function(){n(s.error?s.error:s.transaction.error)}}catch(o){n(o)}})}).catch(n)});return o(n,t),n},length:function(t){var e=this,n=new s(function(t,n){e.ready().then(function(){R(e._dbInfo,f,function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).count();s.onsuccess=function(){t(s.result)},s.onerror=function(){n(s.error)}}catch(o){n(o)}})}).catch(n)});return o(n,t),n},key:function(t,e){var n=this,r=new s(function(e,r){t<0?e(null):n.ready().then(function(){R(n._dbInfo,f,function(i,s){if(i)return r(i);try{var o=s.objectStore(n._dbInfo.storeName),a=!1,l=o.openKeyCursor();l.onsuccess=function(){var n=l.result;n?0===t||a?e(n.key):(a=!0,n.advance(t)):e(null)},l.onerror=function(){r(l.error)}}catch(c){r(c)}})}).catch(r)});return o(r,e),r},keys:function(t){var e=this,n=new s(function(t,n){e.ready().then(function(){R(e._dbInfo,f,function(r,i){if(r)return n(r);try{var s=i.objectStore(e._dbInfo.storeName).openKeyCursor(),o=[];s.onsuccess=function(){var e=s.result;e?(o.push(e.key),e.continue()):t(o)},s.onerror=function(){n(s.error)}}catch(a){n(a)}})}).catch(n)});return o(n,t),n},dropInstance:function(t,e){e=c.apply(this,arguments);var n,i=this.config();if((t="function"!=typeof t&&t||{}).name||(t.name=t.name||i.name,t.storeName=t.storeName||i.storeName),t.name){var a=t.name===i.name&&this._dbInfo.db?s.resolve(this._dbInfo.db):_(t).then(function(e){var n=d[t.name],r=n.forages;n.db=e;for(var i=0;i>4,u[l++]=(15&r)<<4|i>>2,u[l++]=(3&i)<<6|63&s;return c}function W(t){var e,n=new Uint8Array(t),r="";for(e=0;e>2],r+=L[(3&n[e])<<4|n[e+1]>>4],r+=L[(15&n[e+1])<<2|n[e+2]>>6],r+=L[63&n[e+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var H={serialize:function(t,e){var n="";if(t&&(n=q.call(t)),t&&("[object ArrayBuffer]"===n||t.buffer&&"[object ArrayBuffer]"===q.call(t.buffer))){var r,i=P;t instanceof ArrayBuffer?(r=t,i+=M):(r=t.buffer,"[object Int8Array]"===n?i+=O:"[object Uint8Array]"===n?i+=N:"[object Uint8ClampedArray]"===n?i+=F:"[object Int16Array]"===n?i+=D:"[object Uint16Array]"===n?i+=j:"[object Int32Array]"===n?i+=z:"[object Uint32Array]"===n?i+=U:"[object Float32Array]"===n?i+=B:"[object Float64Array]"===n?i+=$:e(new Error("Failed to get type for BinaryArray"))),e(i+W(r))}else if("[object Blob]"===n){var s=new FileReader;s.onload=function(){var n="~~local_forage_type~"+t.type+"~"+W(this.result);e(P+A+n)},s.readAsArrayBuffer(t)}else try{e(JSON.stringify(t))}catch(o){console.error("Couldn't convert value into a JSON string: ",t),e(null,o)}},deserialize:function(t){if(t.substring(0,9)!==P)return JSON.parse(t);var e,n=t.substring(13),r=t.substring(9,13);if(r===A&&I.test(n)){var s=n.match(I);e=s[1],n=n.substring(s[0].length)}var o=V(n);switch(r){case M:return o;case A:return i([o],{type:e});case O:return new Int8Array(o);case N:return new Uint8Array(o);case F:return new Uint8ClampedArray(o);case D:return new Int16Array(o);case j:return new Uint16Array(o);case z:return new Int32Array(o);case U:return new Uint32Array(o);case B:return new Float32Array(o);case $:return new Float64Array(o);default:throw new Error("Unkown type: "+r)}},stringToBuffer:V,bufferToString:W};function G(t,e,n,r){t.executeSql("CREATE TABLE IF NOT EXISTS "+e.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function K(t,e,n,r,i,s){t.executeSql(n,r,i,function(t,o){o.code===o.SYNTAX_ERR?t.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[e.storeName],function(t,a){a.rows.length?s(t,o):G(t,e,function(){t.executeSql(n,r,i,s)},s)},s):s(t,o)},s)}function Z(t,e,n,r){var i=this;t=l(t);var a=new s(function(s,o){i.ready().then(function(){void 0===e&&(e=null);var a=e,l=i._dbInfo;l.serializer.serialize(e,function(e,c){c?o(c):l.db.transaction(function(n){K(n,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[t,e],function(){s(a)},function(t,e){o(e)})},function(e){if(e.code===e.QUOTA_ERR){if(r>0)return void s(Z.apply(i,[t,a,n,r-1]));o(e)}})})}).catch(o)});return o(a,n),a}var Y={_driver:"webSQLStorage",_initStorage:function(t){var e=this,n={db:null};if(t)for(var r in t)n[r]="string"!=typeof t[r]?t[r].toString():t[r];var i=new s(function(t,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(i){return r(i)}n.db.transaction(function(i){G(i,n,function(){e._dbInfo=n,t()},function(t,e){r(e)})},r)});return n.serializer=H,i},_support:"function"==typeof openDatabase,iterate:function(t,e){var n=this,r=new s(function(e,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){K(n,i,"SELECT * FROM "+i.storeName,[],function(n,r){for(var s=r.rows,o=s.length,a=0;a '__WebKitDatabaseInfoTable__'",[],function(n,r){for(var i=[],s=0;s0?(this._dbInfo=e,e.serializer=H,s.resolve()):s.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(t){return!1}}(),iterate:function(t,e){var n=this,r=n.ready().then(function(){for(var e=n._dbInfo,r=e.keyPrefix,i=r.length,s=localStorage.length,o=1,a=0;a=0;n--){var r=localStorage.key(n);0===r.indexOf(t)&&localStorage.removeItem(r)}});return o(n,t),n},length:function(t){var e=this.keys().then(function(t){return t.length});return o(e,t),e},key:function(t,e){var n=this,r=n.ready().then(function(){var e,r=n._dbInfo;try{e=localStorage.key(t)}catch(e6){e=null}return e&&(e=e.substring(r.keyPrefix.length)),e});return o(r,e),r},keys:function(t){var e=this,n=e.ready().then(function(){for(var t=e._dbInfo,n=localStorage.length,r=[],i=0;i=0;e--){var n=localStorage.key(e);0===n.indexOf(t)&&localStorage.removeItem(n)}}):s.reject("Invalid arguments"),o(r,e),r}},Q=function(t,e){return t===e||"number"==typeof t&&"number"==typeof e&&isNaN(t)&&isNaN(e)},tt=function(t,e){for(var n=t.length,r=0;rLF}),TF=l(EF(),1),LF=class extends pp{_instances=new Map;_instance(t){let e=this._instances.get(t);return e||(e=TF.default.createInstance({name:"marco",storeName:t}),this._instances.set(t,e)),e}async get(t,e){return this._instance(t).getItem(e)}async set(t,e,n){return this._instance(t).setItem(e,n)}async remove(t,e){return this._instance(t).removeItem(e)}async keys(t){return this._instance(t).keys()}async clear(t){return this._instance(t).clear()}async iterate(t,e){return this._instance(t).iterate(e)}},IF=a({default:()=>PF}),PF=class extends pp{static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"selectedPlace",[Vr],function(){return null})}#V=void cF(this,"selectedPlace");static{aF(this.prototype,"isSearching",[Vr],function(){return!1})}#W=void cF(this,"isSearching");static{aF(this.prototype,"isCreating",[Vr],function(){return!1})}#H=void cF(this,"isCreating");static{aF(this.prototype,"creationCoordinates",[Vr],function(){return null})}#G=void cF(this,"creationCoordinates");static{aF(this.prototype,"returnToSearch",[Vr],function(){return!1})}#K=void cF(this,"returnToSearch");static{aF(this.prototype,"returnToRoute",[Vr],function(){return null})}#Z=void cF(this,"returnToRoute");static{aF(this.prototype,"currentCenter",[Vr],function(){return null})}#Y=void cF(this,"currentCenter");static{aF(this.prototype,"currentBounds",[Vr],function(){return null})}#X=void cF(this,"currentBounds");static{aF(this.prototype,"currentZoom",[Vr],function(){return null})}#J=void cF(this,"currentZoom");static{aF(this.prototype,"searchBoxHasFocus",[Vr],function(){return!1})}#Q=void cF(this,"searchBoxHasFocus");static{aF(this.prototype,"selectionOptions",[Vr],function(){return{}})}#tt=void cF(this,"selectionOptions");static{aF(this.prototype,"preventNextZoom",[Vr],function(){return!1})}#et=void cF(this,"preventNextZoom");static{aF(this.prototype,"searchResults",[Vr],function(){return[]})}#nt=void cF(this,"searchResults");static{aF(this.prototype,"currentSearch",[Vr],function(){return null})}#rt=void cF(this,"currentSearch");static{aF(this.prototype,"loadingState",[Vr],function(){return null})}#it=void cF(this,"loadingState");static{aF(this.prototype,"isSidebarVisible",[Vr],function(){return!1})}#st=void cF(this,"isSidebarVisible");static{aF(this.prototype,"isSidebarOpening",[Vr],function(){return!1})}#ot=void cF(this,"isSidebarOpening");scrollPositions={};saveScrollPosition(t,e){this.scrollPositions[t]=e}static{lF(this.prototype,"saveScrollPosition",[ql])}getScrollPosition(t){return this.scrollPositions[t]||0}static{lF(this.prototype,"getScrollPosition",[ql])}showSidebar(){this.isSidebarVisible||(this.isSidebarVisible=!0,this.isSidebarOpening=!0,setTimeout(()=>{this.isSidebarOpening=!1},250))}hideSidebar(){this.isSidebarVisible=!1,this.isSidebarOpening=!1}selectPlace(t,e={}){this.selectedPlace=t,this.selectionOptions=e,this.nostrData.loadPhotosForPlace(t)}clearSelection(){this.selectedPlace=null,this.selectionOptions={},this.preventNextZoom=!1,this.nostrData.loadPhotosForPlace(null)}setSearchResults(t){this.searchResults=t||[]}clearSearchResults(){this.searchResults=[],this.currentSearch=null}startSearch(){this.isSearching=!0,this.isCreating=!1,this.preventNextZoom=!1}stopSearch(){this.isSearching=!1}startCreating(){this.isCreating=!0,this.isSearching=!1}stopCreating(){this.isCreating=!1,this.creationCoordinates=null}updateCreationCoordinates(t,e){this.creationCoordinates={lat:t,lon:e}}setSearchBoxFocus(t){this.searchBoxHasFocus=t}updateCenter(t,e){this.currentCenter={lat:t,lon:e}}updateZoom(t){this.currentZoom=t}updateBounds(t){this.currentBounds=t}startLoading(t,e){this.loadingState={type:t,value:e}}stopLoading(t=null,e=null){t||e?this.loadingState&&this.loadingState.type===t&&this.loadingState.value===e&&(this.loadingState=null):this.loadingState=null}};function MF(){let t,e;const n=new Promise((n,r)=>{t=n,e=r});return n.resolve=t,n.reject=e,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var AF=class extends Error{},OF=class{get nip04(){return window.nostr?.nip04}get nip44(){return window.nostr?.nip44}pubkey=void 0;async getPublicKey(){if(!window.nostr)throw new AF("Signer extension missing");if(this.pubkey)return this.pubkey;const t=await window.nostr.getPublicKey();if(!sM(t))throw new Error("Extension returned an invalid public key");return this.pubkey=t,this.pubkey}async signEvent(t){if(!window.nostr)throw new AF("Signer extension missing");const e=await window.nostr.signEvent(t);if(!_P(e))throw new Error("Extension returned an invalid event");return e}};function NF(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name&&"BYTES_PER_ELEMENT"in t&&1===t.BYTES_PER_ELEMENT}function FF(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function DF(t){if("function"!=typeof t)throw new TypeError("function expected");return!0}function zF(t,e){if("string"!=typeof e)throw new TypeError(`${t}: string expected`);return!0}function jF(t){if("number"!=typeof t)throw new TypeError("number expected, got "+typeof t);if(!Number.isSafeInteger(t))throw new RangeError(`invalid integer: ${t}`)}function UF(t){if(!Array.isArray(t))throw new TypeError("array expected")}function BF(t,e){if(!FF(!0,e))throw new TypeError(`${t}: array of strings expected`)}function $F(t,e){if(!FF(!1,e))throw new TypeError(`${t}: array of numbers expected`)}function qF(...t){const e=t=>t,n=(t,e)=>n=>t(e(n));return{encode:t.map(t=>t.encode).reduceRight(n,e),decode:t.map(t=>t.decode).reduce(n,e)}}function VF(t){const e="string"==typeof t?t.split(""):t,n=e.length;BF("alphabet",e);const r=new Map(e.map((t,e)=>[t,e]));return{encode:r=>(UF(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${t}`);return e[r]})),decode:e=>(UF(e),e.map(e=>{zF("alphabet.decode",e);const n=r.get(e);if(void 0===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}function WF(t=""){return zF("join",t),{encode:e=>(BF("join.decode",e),e.join(t)),decode:e=>(zF("join.decode",e),e.split(t))}}function HF(t,e="="){return jF(t),zF("padding",e),{encode(n){for(BF("padding.encode",n);n.length*t%8;)n.push(e);return n},decode(n){BF("padding.decode",n);let r=n.length;if(r*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if((r-1)*t%8==0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function GF(t){return DF(t),{encode:t=>t,decode:e=>t(e)}}var KF=(t,e)=>0===e?t:KF(e,t%e),ZF=(t,e)=>t+(e-KF(t,e)),YF=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function XF(t,e,n,r){if(UF(t),e<=0||e>32)throw new RangeError(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new RangeError(`convertRadix2: wrong to=${n}`);if(ZF(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${ZF(e,n)}`);let i=0,s=0;const o=YF[e],a=YF[n]-1,l=[];for(const c of t){if(jF(c),c>=o)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)l.push((i>>s-n&a)>>>0);const t=YF[s];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<=e)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&s>0&&l.push(i>>>0),l}function JF(t,e=!1){if(jF(t),t<=0||t>32)throw new RangeError("radix2: bits should be in (0..32]");if(ZF(8,t)>32||ZF(t,8)>32)throw new RangeError("radix2: carry overflow");return{encode:n=>{if(!NF(n))throw new TypeError("radix2.encode input should be Uint8Array");return XF(Array.from(n),8,t,!e)},decode:n=>($F("radix2.decode",n),Uint8Array.from(XF(n,t,8,e)))}}function QF(t){return DF(t),function(...e){try{return t.apply(null,e)}catch(n){}}}qF(JF(4),VF("0123456789ABCDEF"),WF("")),qF(JF(5),VF("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),HF(5),WF("")),qF(JF(5),VF("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),WF("")),qF(JF(5),VF("0123456789ABCDEFGHIJKLMNOPQRSTUV"),HF(5),WF("")),qF(JF(5),VF("0123456789ABCDEFGHIJKLMNOPQRSTUV"),WF("")),qF(JF(5),VF("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),WF(""),GF(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));var tD=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)(),eD=(tD||qF(JF(6),VF("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),HF(6),WF("")),qF(JF(6),VF("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),WF("")),tD||qF(JF(6),VF("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),HF(6),WF("")),qF(JF(6),VF("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),WF("")),qF(VF("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),WF(""))),nD=[996825010,642813549,513874426,1027748829,705979059];function rD(t){const e=t>>25;let n=(33554431&t)<<5;for(let r=0;r>r&1)&&(n^=nD[r]);return n}function iD(t,e,n=1){const r=t.length;let i=1;for(let s=0;s126)throw new Error(`Invalid prefix (${t})`);i=rD(i)^e>>5}i=rD(i);for(let s=0;sr)throw new TypeError(`Length ${s} exceeds limit ${r}`);const o=t.toLowerCase(),a=iD(o,n,e);return`${o}1${eD.encode(n)}${a}`}function a(t,n=90){zF("bech32.decode input",t);const r=t.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${t}). Expected (8..${n})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=i.lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const o=i.slice(0,s),a=i.slice(s+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const l=eD.decode(a).slice(0,-6),c=iD(o,l,e);if(!a.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:o,words:l}}return{encode:o,decode:a,encodeFromBytes:function(t,e){return o(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:n}=a(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:QF(a),fromWords:r,fromWordsUnsafe:s,toWords:i}}var oD,aD,lD=Object.freeze(sD("bech32")),cD=(sD("bech32m"),(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()||qF(JF(4),VF("0123456789abcdef"),WF(""),GF(t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),new TextEncoder),uD=new TextDecoder;function hD(t){if(!sM(t.remote))throw new Error("Invalid nbunksec: remote is not a valid hex key");if(!sM(t.clientKey))throw new Error("Invalid nbunksec: clientKey is not a valid hex key");if(0===t.relays.length)throw new Error("Invalid nbunksec: missing relays");return function(t){try{const e=[],n=IS(t.pubkey);e.push(new Uint8Array([0,n.length]),n);const r=IS(t.local_key);e.push(new Uint8Array([1,r.length]),r);for(const a of t.relays){const t=cD.encode(a);e.push(new Uint8Array([2,t.length]),t)}if(t.secret){const n=cD.encode(t.secret);e.push(new Uint8Array([3,n.length]),n)}const i=e.reduce((t,e)=>t+e.length,0),s=new Uint8Array(i);let o=0;for(const t of e)s.set(t,o),o+=t.length;return lD.encode("nbunksec",lD.toWords(s),!1)}catch(e6){throw new Error(`Failed to encode bunker info: ${e6}`)}}({pubkey:t.remote,local_key:t.clientKey,relays:t.relays,secret:t.bunkerSecret??t.secret})}fM(uR.NostrConnect,"nip44"),function(t){t.GetPublicKey="get_public_key",t.SignEvent="sign_event",t.Ping="ping",t.Nip04Encrypt="nip04_encrypt",t.Nip04Decrypt="nip04_decrypt",t.Nip44Encrypt="nip44_encrypt",t.Nip44Decrypt="nip44_decrypt",t.SwitchRelays="switch_relays"}(oD||(oD={})),function(t){t.Connect="connect",t.CreateAccount="create_account",t.GetPublicKey="get_public_key",t.SignEvent="sign_event",t.Ping="ping",t.Nip04Encrypt="nip04_encrypt",t.Nip04Decrypt="nip04_decrypt",t.Nip44Encrypt="nip44_encrypt",t.Nip44Decrypt="nip44_decrypt",t.SwitchRelays="switch_relays",t.Logout="logout"}(aD||(aD={}));var dD=class t{key;constructor(t){this.key=t||vP()}async getPublicKey(){return bP(this.key)}async signEvent(t){return wP(t,this.key)}nip04={encrypt:async(t,e)=>CL.encrypt(this.key,t,e),decrypt:async(t,e)=>CL.decrypt(this.key,t,e)};nip44={encrypt:async(t,e)=>UL.v2.encrypt(e,UL.v2.utils.getConversationKey(this.key,t)),decrypt:async(t,e)=>UL.v2.decrypt(e,UL.v2.utils.getConversationKey(this.key,t))};static fromKey(e){const n=function(t){if(t instanceof Uint8Array)return 32!==t.length?null:t;if(sM(t))return IS(t);try{const e=function(t){let{prefix:e,words:n}=bk.decode(t,5e3),r=new Uint8Array(bk.fromWords(n));switch(e){case"nprofile":{let t=JP(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:LS(t[0][0]),relays:t[1]?t[1].map(t=>YP.decode(t)):[]}}}case"nevent":{let t=JP(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(t[2]&&32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(t[3]&&4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:LS(t[0][0]),relays:t[1]?t[1].map(t=>YP.decode(t)):[],author:t[2]?.[0]?LS(t[2][0]):void 0,kind:t[3]?.[0]?parseInt(LS(t[3][0]),16):void 0}}}case"naddr":{let t=JP(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!t[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!t[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:YP.decode(t[0][0]),pubkey:LS(t[2][0]),kind:parseInt(LS(t[3][0]),16),relays:t[1]?t[1].map(t=>YP.decode(t)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:LS(r)};default:throw new Error(`unknown prefix ${e}`)}}(t);return"nsec"!==e.type?null:e.data}catch{return null}}(e);if(!n)throw new Error("Invalid private key");return new t(n)}};async function pD(t){window.open(t,"auth","width=400,height=600,resizable=no,status=no,location=no,toolbar=no,menubar=no")}var fD=class t{static subscriptionMethod=void 0;static publishMethod=void 0;static pool=void 0;publishMethod;subscriptionMethod;log=qO.extend("NostrConnectSigner");signer;listening=!1;isConnected=!1;pubkey;relays;remote;get clientPubkey(){return bP(this.signer.key)}onAuth=pD;verifyEvent=_P;connectSecret;bunkerSecret;get secret(){return this.connectSecret}set secret(t){this.connectSecret=t}nip04;nip44;constructor(e){this.relays=e.relays,this.pubkey=e.pubkey,this.remote=e.remote,this.connectSecret=e.connectSecret||e.secret||qP(12),this.bunkerSecret=e.bunkerSecret;const{subscriptionMethod:n,publishMethod:r}=function(t,e){const n=t.subscriptionMethod||t.pool?.subscription.bind(t.pool)||e?.subscriptionMethod||e?.pool?.subscription.bind(e.pool);if(!n)throw new Error("Missing subscriptionMethod, either pass a method or set subscriptionMethod globally on the class");const r=t.publishMethod||t.pool?.publish.bind(t.pool)||e?.publishMethod||e?.pool?.publish.bind(e.pool);if(!r)throw new Error("Missing publishMethod, either pass a method or set publishMethod globally on the class");return{subscriptionMethod:n,publishMethod:r}}(e,t);this.subscriptionMethod=(t,e)=>n(t,e),this.publishMethod=(t,e)=>r(t,e),e.onAuth&&(this.onAuth=e.onAuth),this.signer=e?.signer||new dD,this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)},this.nip44={encrypt:this.nip44Encrypt.bind(this),decrypt:this.nip44Decrypt.bind(this)}}req;async open(){if(this.listening)return;this.listening=!0;const t=await this.signer.getPublicKey();this.req=jA(this.subscriptionMethod(this.relays,[{kinds:[uR.NostrConnect],"#p":[t]}])).pipe(TO(),LO(),pO(t=>"string"!=typeof t)).subscribe(this.handleEvent.bind(this)),this.log("Opened",this.relays)}async close(){this.listening=!1,this.isConnected=!1,this.req&&(this.req.unsubscribe(),this.req=void 0),this.waitingPromise&&(this.waitingPromise.reject(new Error("Closed")),this.waitingPromise=null),this.log("Closed")}requests=new Map;auths=new Set;async handleEvent(t){if(this.verifyEvent(t)&&(!this.remote||t.pubkey===this.remote))try{const n=mM(t)??(function(t){const e=t.length;return!(e<28)&&"?"==t[e-28]&&"i"==t[e-27]&&"v"==t[e-26]&&"="==t[e-25]}(t.content)?await this.signer.nip04.decrypt(t.pubkey,t.content):await this.signer.nip44.decrypt(t.pubkey,t.content));if(!n)return;const r=JSON.parse(n);if(!this.remote&&("ack"===r.result||this.connectSecret&&r.result===this.connectSecret))return this.log("Got ack response from",t.pubkey,r.result),this.isConnected=!0,this.remote=t.pubkey,this.waitingPromise?.resolve(),void(this.waitingPromise=null);if(r.id){const t=this.requests.get(r.id);if(!t)return;if(r.error)if(this.log("Got Error",r.id,r.result,r.error),"auth_url"===r.result){if(!this.auths.has(r.id)&&(this.auths.add(r.id),this.onAuth))try{await this.onAuth(r.error)}catch(e){t.reject(e)}}else t.reject(new Error(r.error));else r.result&&(this.log("Got Response",r.id,r.result),t.resolve(r.result))}}catch(e){}}async createRequestEvent(t,e=this.remote,n=uR.NostrConnect){if(!e)throw new Error("Missing target pubkey");return await this.signer.signEvent({kind:n,created_at:$P(),tags:[["p",e]],content:t})}async makeRequest(t,e,n=uR.NostrConnect){if(!this.remote)throw new Error("Missing remote signer pubkey");const r=qP(8),i={id:r,method:t,params:e},s=await this.signer.nip44.encrypt(this.remote,JSON.stringify(i)),o=await this.createRequestEvent(s,this.remote,n);this.log(`Sending ${r} (${t}) ${JSON.stringify(e)}`);const a=MF();this.requests.set(r,a);const l=this.publishMethod?.(this.relays,o);return l instanceof Promise?await l:"subscribe"in l&&await new Promise(t=>l.subscribe({complete:t})),this.log(`Sent ${r} (${t})`),a}async connect(t,e){if(!this.remote&&this.pubkey&&(this.remote=this.pubkey),!this.remote)throw new Error("Missing remote signer pubkey");await this.open();try{void 0!==t&&(this.bunkerSecret=t);const n=await this.makeRequest(aD.Connect,[this.remote,this.bunkerSecret||"",e?.join(",")??""]);return this.isConnected=!0,n}catch(n){throw this.isConnected=!1,this.close(),n}}waitingPromise=null;waitForSigner(t){return this.isConnected?Promise.resolve():(this.open(),this.waitingPromise=MF(),t?.addEventListener("abort",()=>{this.waitingPromise?.reject(new Error("Aborted")),this.waitingPromise=null,this.close()},!0),this.waitingPromise)}async createAccount(t,e,n,r){if(!this.remote)throw new Error("Remote pubkey must be set");await this.open();try{const i=await this.makeRequest(aD.CreateAccount,[t,e,n??"",r?.join(",")??""]);return this.pubkey=i,this.isConnected=!0,i}catch(i){throw this.isConnected=!1,this.close(),i}}async requireConnection(){this.isConnected||await this.connect()}async getPublicKey(){if(this.pubkey)return this.pubkey;await this.requireConnection();const t=await this.makeRequest(aD.GetPublicKey,[]);if(!sM(t))throw new Error("Remote signer returned an invalid public key");return t}async signEvent(t){await this.requireConnection();const e=await this.makeRequest(aD.SignEvent,[JSON.stringify(t)]),n=JSON.parse(e);if(!this.verifyEvent(n))throw new Error("Invalid event");return n}async nip04Encrypt(t,e){return await this.requireConnection(),this.makeRequest(aD.Nip04Encrypt,[t,e])}async nip04Decrypt(t,e){await this.requireConnection();const n=await this.makeRequest(aD.Nip04Decrypt,[t,e]);return n.startsWith('["')&&n.endsWith('"]')?JSON.parse(n)[0]:n}async nip44Encrypt(t,e){return await this.requireConnection(),this.makeRequest(aD.Nip44Encrypt,[t,e])}async nip44Decrypt(t,e){await this.requireConnection();const n=await this.makeRequest(aD.Nip44Decrypt,[t,e]);return n.startsWith('["')&&n.endsWith('"]')?JSON.parse(n)[0]:n}async ping(){return await this.requireConnection(),this.makeRequest(aD.Ping,[])}async switchRelays(){await this.requireConnection();const t=await this.makeRequest(aD.SwitchRelays,[]);return null!==t&&Array.isArray(t)&&t.length>0&&(this.log("Switching relays from",this.relays,"to",t),this.relays=t,this.listening&&(await this.close(),await this.open())),t}async logout(){try{this.isConnected&&this.remote&&await this.makeRequest(aD.Logout,[])}catch(e6){this.log("Failed to send logout request",e6)}finally{this.isConnected=!1,await this.close()}}getNostrConnectURI(t){return function(t){const e=new URLSearchParams,n=t.connectSecret??t.secret;if(!n)throw new Error("Invalid nostrconnect URI: missing secret");e.set("secret",n),t.metadata?.name&&e.set("name",t.metadata.name),t.metadata?.url&&e.set("url",String(t.metadata.url)),t.metadata?.image&&e.set("image",t.metadata.image),t.metadata?.permissions&&e.set("perms",t.metadata.permissions.join(","));for(const r of t.relays)e.append("relay",r);return`nostrconnect://${t.client}?`+e.toString()}({client:bP(this.signer.key),connectSecret:this.connectSecret,relays:this.relays,metadata:t})}getNbunksec(){if(!this.remote)throw new Error("Cant create nbunksec when remote signer is not set");return hD({remote:this.remote,clientKey:LS(this.signer.key),relays:this.relays,bunkerSecret:this.bunkerSecret})}static parseBunkerURI(t){return function(t){const e=new URL(t),n=e.host||e.pathname.replace("//","");if(!sM(n))throw new Error("Invalid bunker URI: remote is not a valid hex key");const r=e.searchParams.getAll("relay");if(0===r.length)throw new Error("Invalid bunker URI: missing relays");const i=e.searchParams.get("secret")??void 0;return{remote:n,relays:r,secret:i,bunkerSecret:i}}(t)}static parseNbunksec(t){return function(t){const e=function(t){try{const{prefix:e,words:n}=lD.decode(t,!1);if("nbunksec"!==e)throw new Error(`Invalid prefix: ${e}`);const r=lD.fromWords(n);let i=0;const s={pubkey:"",local_key:"",relays:[]};for(;i`${oD.SignEvent}:${t}`)]}(t)}static async fromBunkerURI(e,n){const{remote:r,relays:i,bunkerSecret:s}=t.parseBunkerURI(e),o=new t({relays:i,remote:r,bunkerSecret:s,...n});return await o.connect(s,n?.permissions),o}static async fromNbunksec(e,n){const{remote:r,clientKey:i,relays:s,bunkerSecret:o}=t.parseNbunksec(e),a=new t({relays:s,remote:r,signer:new dD(IS(i)),bunkerSecret:o,...n});return await a.connect(o,n?.permissions),a}},gD=Object.freeze({p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,h:1n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n}),{p:mD,n:yD,Gx:vD,Gy:bD,b:wD}=gD,_D={publicKey:33,publicKeyUncompressed:65,signature:64,seed:48},xD=(t="",e=Error)=>{const n=new e(t),{captureStackTrace:r}=Error;throw"function"==typeof r&&r(n,xD),n},CD=(t,e,n="")=>{const r=(i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name&&1===i.BYTES_PER_ELEMENT;var i;const s=t?.length,o=void 0!==e;return!r||o&&s!==e?xD((n&&`"${n}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(r?`length=${s}`:"type="+typeof t),r?RangeError:TypeError):t},SD=t=>new Uint8Array(t),kD=(t,e)=>t.toString(16).padStart(e,"0"),ED=t=>{let e="";for(const n of CD(t))e+=kD(n,2);return e},RD=t=>t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0,TD=t=>{const e="hex invalid";if("string"!=typeof t)return xD(e);const n=t.length,r=n/2;if(n%2)return xD(e);const i=SD(r);for(let s=0,o=0;s{let e=0;for(const i of t)e+=CD(i).length;const n=SD(e);let r=0;for(const i of t)n.set(i,r),r+=i.length;return n},ID=BigInt,PD=(t,e,n,r="bad number: out of range")=>"bigint"!=typeof t?xD(r,TypeError):e<=t&&t{const n=t%e;return n>=0n?n:e+n},AD=t=>t instanceof jD?t:xD("Point expected"),OD=t=>MD(MD(t*t)*t+wD),ND=t=>PD(t,0n,mD),FD=t=>PD(t,1n,mD),DD=t=>!(1n&t),zD=t=>Uint8Array.of(t),jD=class t{static BASE;static ZERO;X;Y;Z;constructor(t,e,n){this.X=ND(t),this.Y=FD(e),this.Z=ND(n),Object.freeze(this)}static CURVE(){return gD}static fromAffine(e){const{x:n,y:r}=e;return 0n===n&&0n===r?BD:new t(n,r,1n)}static fromBytes(e){CD(e);const{publicKey:n,publicKeyUncompressed:r}=_D;let i;const s=e.length,o=e[0],a=e.subarray(1),l=$D(a,0,32);if(s===n&&(2===o||3===o)){let e=(t=>{const e=OD(FD(t));let n=1n;for(let r=e,i=(mD+1n)/4n;i>0n;i>>=1n)1n&i&&(n=n*r%mD),r=r*r%mD;return MD(n*n)!==e&&xD("sqrt invalid"),DD(n)?n:MD(-n)})(l);3===o&&(e=MD(-e)),i=new t(l,e,1n)}return s===r&&4===o&&(i=new t(l,$D(a,32,64),1n)),i?i.assertValidity():xD("bad point: not on curve")}static fromHex(e){return t.fromBytes(TD(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(t){const{X:e,Y:n,Z:r}=this,{X:i,Y:s,Z:o}=AD(t),a=MD(e*o),l=MD(i*r),c=MD(n*o),u=MD(s*r);return a===l&&c===u}is0(){return this.equals(BD)}negate(){return new t(this.X,MD(-this.Y),this.Z)}double(){return this.add(this)}add(e){const{X:n,Y:r,Z:i}=this,{X:s,Y:o,Z:a}=AD(e);let l=0n,c=0n,u=0n;const h=MD(3n*wD);let d=MD(n*s),p=MD(r*o),f=MD(i*a),g=MD(n+r),m=MD(s+o);g=MD(g*m),m=MD(d+p),g=MD(g-m),m=MD(n+i);let y=MD(s+a);return m=MD(m*y),y=MD(d+f),m=MD(m-y),y=MD(r+i),l=MD(o+a),y=MD(y*l),l=MD(p+f),y=MD(y-l),u=MD(0n*m),l=MD(h*f),u=MD(l+u),l=MD(p-u),u=MD(p+u),c=MD(l*u),p=MD(d+d),p=MD(p+d),f=MD(0n*f),m=MD(h*m),p=MD(p+f),f=MD(d-f),f=MD(0n*f),m=MD(m+f),d=MD(p*m),c=MD(c+d),d=MD(y*m),l=MD(g*l),l=MD(l-d),d=MD(g*p),u=MD(y*u),u=MD(u+d),new t(l,c,u)}subtract(t){return this.add(AD(t).negate())}multiply(t,e=!0){if(!e&&0n===t)return BD;if((t=>{PD(t,1n,yD)})(t),1n===t)return this;if(this.equals(UD))return KD(t).p;let n=BD,r=UD;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?n=n.add(i):e&&(r=r.add(i));return n}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:e,Z:n}=this;if(this.equals(BD))return{x:0n,y:0n};if(1n===n)return{x:t,y:e};const r=((t,e)=>{(0n===t||e<=0n)&&xD("no inverse n="+t+" mod="+e);let n=MD(t,e),r=e,i=0n,s=1n,o=1n,a=0n;for(;0n!==n;){const t=r/n,e=r%n,l=i-o*t,c=s-a*t;r=n,n=e,i=o,s=a,o=l,a=c}return 1n===r?MD(i,e):xD("no inverse")})(n,mD);return 1n!==MD(n*r)&&xD("inverse invalid"),{x:MD(t*r),y:MD(e*r)}}assertValidity(){const{x:t,y:e}=this.toAffine();return FD(t),FD(e),MD(e*e)===OD(t)?this:xD("bad point: not on curve")}toBytes(t=!0){const{x:e,y:n}=this.assertValidity().toAffine(),r=VD(e);return t?LD((t=>zD(DD(t)?2:3))(n),r):LD(zD(4),r,VD(n))}toHex(t){return ED(this.toBytes(t))}},UD=new jD(vD,bD,1n),BD=new jD(0n,1n,0n);jD.BASE=UD,jD.ZERO=BD;var $D=(t,e,n)=>(t=>ID("0x"+(ED(t)||"0")))(t.subarray(e,n)),qD=2n**256n,VD=t=>TD(kD(PD(t,0n,qD),64)),WD=Math.ceil(32)+1,HD=void 0,GD=(t,e)=>{const n=e.negate();return t?n:e},KD=t=>{const e=HD||(HD=(()=>{const t=[];let e=UD,n=e;for(let r=0;r>=s,a>128&&(a-=256,t+=1n);const l=128*o,c=l,u=l+Math.abs(a)-1,h=o%2!=0,d=a<0;0===a?r=r.add(GD(h,e[c])):n=n.add(GD(d,e[u]))}return 0n!==t&&xD("invalid wnaf"),{p:n,f:r}};function ZD(t){return jD.fromHex(t).toHex().substring(2)}var YD=new TextDecoder("utf-8"),XD=new TextEncoder;function JD(t){return btoa(String.fromCharCode(...t))}function QD(t){return new Uint8Array(atob(t).split("").map(t=>t.charCodeAt(0)))}(class t{log=qO.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=_P;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,n,r={}){if(!t.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(r),this.lastCommand)throw new Error("Previous command to device still pending!");const i=MF();return this.lastCommand=i,this.sendCommand(e,n),setTimeout(()=>{i.reject(new Error("Device timeout")),this.lastCommand===i&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:n,onError:r,onDone:i}){let s,o=await window.navigator.serial.requestPort();await o.open({baudRate:9600}),await new Promise(t=>setTimeout(t,1e3)),(async()=>{for(;o&&o.readable;){const e=new window.TextDecoderStream;o.readable.pipeTo(e.writable),s=e.readable.getReader();const n=this.readFromSerialPort(s);try{for(;;){const{value:e,done:r}=await n("\n");if(e){const{method:n,data:r}=this.parseResponse(e);if("/ping"===n&&this.log("Pong"),-1===t.PUBLIC_METHODS.indexOf(n))continue;this.log("Received: ",n,r),this.lastCommand&&(this.lastCommand.resolve(r),this.lastCommand=null)}if(r)return this.lastCommand=null,this.writer=null,void(i&&i())}}catch(e6){if(e6 instanceof Error)throw this.writer=null,r&&r(e6),this.lastCommand&&(this.lastCommand.reject(e6),this.lastCommand=null),e6}}})();const a=new window.TextEncoderStream;a.readable.pipeTo(o.writable),this.writer=a.writable.getWriter(),await this.sendCommand(t.METHOD_PING),await this.sendCommand(t.METHOD_PING,[window.location.host]),e&&e(),o.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,n&&n()})}async sendCommand(t,e=[]){if(!this.writer)return;this.log("Send command",t,e);const n=[t].concat(e).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(t){let e,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const i=[];for(e&&(i.push(e),e=void 0);;){const{value:s,done:o}=await t.read();if(s){const t=s.split(r);if(t.length>1)return i.push(t.shift()),e=t.pop(),n=t,{value:i.join("").trim(),done:!1};i.push(s)}if(o)return{value:i.join("").trim(),done:!0}}}}parseResponse(t){const e=t.split(" ")[0];return{method:e,data:t.substring(e.length).trim()}}async nip04Encrypt(e,n){const r=IS(await this.callMethodOnDevice(t.METHOD_SHARED_SECRET,[ZD(e)]));let i=Uint8Array.from(window.crypto.getRandomValues(new Uint8Array(16))),s=XD.encode(n),o=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},o,s);return`${JD(new Uint8Array(a))}?iv=${JD(new Uint8Array(i.buffer))}`}async nip04Decrypt(e,n){let[r,i]=n.split("?iv=");const s=IS(await this.callMethodOnDevice(t.METHOD_SHARED_SECRET,[ZD(e)]));let o=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),a=QD(r),l=QD(i),c=await crypto.subtle.decrypt({name:"AES-CBC",iv:l},o,a);return YD.decode(c)}async getPublicKey(){const e=await this.callMethodOnDevice(t.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(t.METHOD_RESTORE,[LS(e)])}async signEvent(e){const n=e.pubkey||this.pubkey;if(!n)throw new Error("Unknown signer pubkey");const r={...e,id:mP({...e,pubkey:n})},i=await this.callMethodOnDevice(t.METHOD_SIGN_MESSAGE,[r.id]),s={...r,sig:i,pubkey:n};if(!this.verifyEvent(s))throw new Error("Invalid signature");return s}ping(){this.sendCommand(t.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[t.METHOD_PUBLIC_KEY,t.METHOD_SIGN_MESSAGE,t.METHOD_SHARED_SECRET,t.METHOD_RESTORE]});var tz=a({isMobile:()=>ez});function ez(){return"undefined"!=typeof navigator&&/Mobi|Android|iPhone|iPad/i.test(navigator.userAgent)}var nz,rz,iz=a({default:()=>hz}),sz="marco:nostr_pubkey",oz="marco:nostr_signer_type",az="marco:nostr_connect_local_key",lz="marco:nostr_connect_remote_pubkey",cz="marco:nostr_connect_relay",uz="wss://nostr.kosmos.org",hz=class extends pp{static{aF(this.prototype,"nostrRelay",[dp])}#at=void cF(this,"nostrRelay");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"pubkey",[Vr],function(){return null})}#lt=void cF(this,"pubkey");static{aF(this.prototype,"signerType",[Vr],function(){return null})}#ct=void cF(this,"signerType");static{aF(this.prototype,"connectStatus",[Vr],function(){return null})}#ut=void cF(this,"connectStatus");static{aF(this.prototype,"connectUri",[Vr],function(){return null})}#ht=void cF(this,"connectUri");_signerInstance=null;constructor(){super(...arguments),"undefined"!=typeof localStorage&&(localStorage.debug="applesauce:*");const t=localStorage.getItem(sz),e=localStorage.getItem(oz);t&&(this.pubkey=t,this.signerType=e||"extension",this._verifyPubkey())}async _verifyPubkey(){if("extension"===this.signerType){if(void 0===window.nostr)return void this.disconnect();try{const t=await(new OF).getPublicKey();t!==this.pubkey&&(this.pubkey=t,localStorage.setItem(sz,this.pubkey)),this.nostrData.loadProfile(this.pubkey)}catch(t){console.warn("Failed to verify extension nostr pubkey, logging out",t),this.disconnect()}}else if("connect"===this.signerType)try{await this._initConnectSigner()}catch(t){console.warn("Failed to verify connect nostr pubkey, logging out",t),this.disconnect()}}get isMobile(){return ez()}get isConnected(){return!!this.pubkey&&("extension"!==this.signerType||void 0!==window.nostr)}get signer(){return this._signerInstance?this._signerInstance:"extension"===this.signerType&&void 0!==window.nostr?new OF:(this.signerType,null)}async connectWithExtension(){if(void 0===window.nostr)throw new Error("No NIP-07 Nostr extension found (e.g., Alby, nos2x).");try{return this._signerInstance=new OF,this.pubkey=await this._signerInstance.getPublicKey(),this.signerType="extension",localStorage.setItem(sz,this.pubkey),localStorage.setItem(oz,"extension"),this.nostrData.loadProfile(this.pubkey),this.pubkey}catch(e6){throw console.error("Failed to get public key from extension:",e6),e6}}_getLocalSigner(){let t,e=localStorage.getItem(az);return e?t=dD.fromKey(e):(t=new dD,e=Array.from(t.key).map(t=>t.toString(16).padStart(2,"0")).join(""),localStorage.setItem(az,e)),t}async connectWithApp(){this.connectStatus="waiting";try{const e=this._getLocalSigner(),n=uz;localStorage.setItem(cz,n),this._signerInstance=new fD({pool:this.nostrRelay.pool,relays:[n],signer:e,onAuth:async t=>{confirm(`Your signer app requests authentication via a web page. Open it now?\n\nURL: ${t}`)&&window.open(t,"_blank")}}),this.connectUri=this._signerInstance.getNostrConnectURI({name:"Marco",url:window.location.origin,description:"An unhosted maps application.",icons:[]}),this.isMobile&&(console.debug("Mobile detected, triggering deep link intent."),window.location.href=this.connectUri),console.debug("Opening signer connection to relay..."),await this._signerInstance.open(),console.debug("Signer connection opened successfully."),console.debug("Waiting for remote signer to ack via relay...");try{await this._signerInstance.waitForSigner(),console.debug("Remote signer ack received!")}catch(t){throw console.error("Error while waiting for remote signer ack:",t),t}return this.pubkey=await this._signerInstance.getPublicKey(),this.signerType="connect",this.connectStatus="connected",localStorage.setItem(sz,this.pubkey),localStorage.setItem(oz,"connect"),localStorage.setItem(lz,this._signerInstance.remote),this.nostrData.loadProfile(this.pubkey),this.pubkey}catch(e6){throw this.connectStatus=null,console.error("Failed to connect via Nostr Connect:",e6),e6}}async _initConnectSigner(){const t=localStorage.getItem(lz),e=localStorage.getItem(cz)||uz;if(!t)throw new Error("Missing Nostr Connect remote pubkey.");const n=this._getLocalSigner();if(this._signerInstance=new fD({pool:this.nostrRelay.pool,relays:[e],signer:n,remote:t,onAuth:async t=>{confirm(`Your signer app requests authentication via a web page. Open it now?\n\nURL: ${t}`)&&window.open(t,"_blank")}}),await this._signerInstance.open(),await this._signerInstance.getPublicKey()!==this.pubkey)throw new Error("Remote signer pubkey mismatch");this.nostrData.loadProfile(this.pubkey)}async signEvent(t){if(!this.signer)throw new Error("Not connected or extension missing. Please connect Nostr again.");return await this.signer.signEvent(t)}async disconnect(){this.pubkey=null,this.nostrData?.loadProfile(null),this.signerType=null,this.connectStatus=null,this.connectUri=null,this._signerInstance&&"function"==typeof this._signerInstance.close&&await this._signerInstance.close(),this._signerInstance=null,localStorage.removeItem(sz),localStorage.removeItem(oz),localStorage.removeItem(az),localStorage.removeItem(lz),localStorage.removeItem(cz)}},dz=(t,e)=>e.some(e=>t instanceof e),pz=new WeakMap,fz=new WeakMap,gz=new WeakMap,mz={get(t,e,n){if(t instanceof IDBTransaction){if("done"===e)return pz.get(t);if("store"===e)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return vz(t[e])},set:(t,e,n)=>(t[e]=n,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function yz(t){mz=t(mz)}function vz(t){if(t instanceof IDBRequest)return function(t){const e=new Promise((e,n)=>{const r=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{e(vz(t.result)),r()},s=()=>{n(t.error),r()};t.addEventListener("success",i),t.addEventListener("error",s)});return gz.set(e,t),e}(t);if(fz.has(t))return fz.get(t);const e=function(t){return"function"==typeof t?(e=t,(rz||(rz=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(bz(this),t),vz(this.request)}:function(...t){return vz(e.apply(bz(this),t))}):(t instanceof IDBTransaction&&function(t){if(pz.has(t))return;const e=new Promise((e,n)=>{const r=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{e(),r()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)});pz.set(t,e)}(t),dz(t,nz||(nz=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(t,mz):t);var e}(t);return e!==t&&(fz.set(t,e),gz.set(e,t)),e}var bz=t=>gz.get(t),wz=["get","getKey","getAll","getAllKeys","count"],_z=["put","add","delete","clear"],xz=new Map;function Cz(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(xz.get(e))return xz.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,i=_z.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!wz.includes(n))return;const s=async function(t,...e){const s=this.transaction(t,i?"readwrite":"readonly");let o=s.store;return r&&(o=o.index(e.shift())),(await Promise.all([o[n](...e),i&&s.done]))[0]};return xz.set(e,s),s}yz(t=>({...t,get:(e,n,r)=>Cz(e,n)||t.get(e,n,r),has:(e,n)=>!!Cz(e,n)||t.has(e,n)}));var Sz=["continue","continuePrimaryKey","advance"],kz={},Ez=new WeakMap,Rz=new WeakMap,Tz={get(t,e){if(!Sz.includes(e))return t[e];let n=kz[e];return n||(n=kz[e]=function(...t){Ez.set(this,Rz.get(this)[e](...t))}),n}};async function*Lz(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;const n=new Proxy(e,Tz);for(Rz.set(n,e),gz.set(n,bz(e));e;)yield n,e=await(Ez.get(n)||e.continue()),Ez.delete(n)}function Iz(t,e){return e===Symbol.asyncIterator&&dz(t,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===e&&dz(t,[IDBIndex,IDBObjectStore])}function Pz(t){return 0===t||3===t||t>=1e4&&t<2e4}function Mz(t){return t>=3e4&&t<4e4}function Az(t){return t>=2e4&&t<3e4}yz(t=>({...t,get:(e,n,r)=>Iz(e,n)?Lz:t.get(e,n,r),has:(e,n)=>Iz(e,n)||t.has(e,n)}));var Oz=Symbol.for("indexable-tags");function Nz(t,e){if(t.ids&&-1===t.ids.indexOf(e.id))return!1;if(t.kinds&&-1===t.kinds.indexOf(e.kind))return!1;if(t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;if(t.since&&e.created_att.until)return!1;const n=function(t){let e=Reflect.get(t,Oz);if(!e){e=new Set;for(const n of t.tags)n.length>=2&&1===n[0].length&&e.add(n[0]+":"+n[1]);Reflect.set(t,Oz,e)}return e}(e);for(const r in t)if("&"===r[0]){const e=r.slice(1),i=t[r];if(i&&i.length>0)for(const t of i)if(!n.has(e+":"+t))return!1}for(const r in t)if("#"===r[0]){const e=r.slice(1),i=t[r];if(i){const r=t[`&${e}`],s=r?i.filter(t=>!r.includes(t)):i;if(0===s.length)continue;if(!s.some(t=>n.has(e+":"+t)))return!1}}return!0}function Fz(t,e){for(let n=0;nt.length>=2&&1===t[0].length&&zz.includes(t[0])).map(t=>t[0]+t[1])}function Bz(t){if(Reflect.has(t,jz))return Reflect.get(t,jz);let e;if(Pz(t.kind)||Mz(t.kind)){const n=t.tags.find(t=>"d"===t[0])?.[1];e=t.kind+":"+t.pubkey+":"+(n??"")}else e=t.id;return Reflect.set(t,jz,e),e}async function $z(t="nostr-idb",e){return await function(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(t,e),a=vz(o);return r&&o.addEventListener("upgradeneeded",t=>{r(vz(o.result),t.oldVersion,t.newVersion,vz(o.transaction),t)}),n&&o.addEventListener("blocked",t=>n(t.oldVersion,t.newVersion,t)),a.then(t=>{s&&t.addEventListener("close",()=>s()),i&&t.addEventListener("versionchange",t=>i(t.oldVersion,t.newVersion,t))}).catch(()=>{}),a}(t,3,{...e,async upgrade(t,n,r,i,s){if(0===n){const e=t.createObjectStore("events");e.createIndex("id","event.id",{unique:!0}),e.createIndex("pubkey","event.pubkey"),e.createIndex("kind","event.kind"),e.createIndex("created_at","event.created_at"),e.createIndex("tags","tags",{multiEntry:!0}),t.createObjectStore("used",{keyPath:"uid"}).createIndex("date","date")}1===n&&(t.deleteObjectStore("events"),t.deleteObjectStore("used"),t.deleteObjectStore("seen")),n<=2&&await async function(t){const e=t.objectStore("events");let n=await e.openCursor();const r=[];for(;n;){const t=n.primaryKey,e=n.value,i=e.event;if(Pz(i.kind)||Mz(i.kind)){const n=Bz(i);t!==n&&r.push({oldKey:t,newKey:n,value:e})}n=await n.continue()}for(const{oldKey:i,newKey:s,value:o}of r)await e.delete(i),await e.put(o,s)}(i),e?.upgrade&&e.upgrade(t,n,r,i,s)}})}function qz(t,e){return e.created_at-t.created_at}var Vz=a({countEventsForFilters:()=>tj,getEventsForFilters:()=>Qz,getIdsForFilter:()=>Xz,getIdsForFilters:()=>Jz,queryForKinds:()=>Zz,queryForPubkeys:()=>Wz,queryForTag:()=>Hz,queryForTagAnd:()=>Gz,queryForTime:()=>Yz});function Wz(t,e=[],n){const r=[],i=new Set;if(n)for(const l of e){const t=n.getPubkeyIndex(l);if(t){for(const e of t)i.add(e);r.push(l)}}if(r.length===e.length)return Promise.resolve(i);const s=t.transaction("events","readonly"),o=s.objectStore("events").index("pubkey"),a=e.filter(t=>!r.includes(t)).map(t=>o.getAllKeys(t).then(e=>((t,e)=>{for(const n of e)i.add(n);n&&n.setPubkeyIndex(t,new Set(e))})(t,e)));return s.commit(),Promise.all(a).then(()=>i)}function Hz(t,e,n,r){const i=[],s=new Set;if(r)for(const c of n){const t=r.getTagIndex(e+c);if(t){for(const e of t)s.add(e);i.push(c)}}if(i.length===n.length)return Promise.resolve(s);const o=t.transaction("events","readonly"),a=o.objectStore("events").index("tags"),l=n.map(t=>a.getAllKeys(e+t).then(n=>((t,n)=>{for(const e of n)s.add(e);r&&r.setTagIndex(e+t,new Set(n))})(t,n)));return o.commit(),Promise.all(l).then(()=>s)}function Gz(t,e,n,r){if(0===n.length)return Promise.resolve(new Set);if(1===n.length)return Hz(t,e,n,r);const i=[],s=[];if(r)for(const c of n){const t=r.getTagIndex(e+c);t&&(s.push(t),i.push(c))}if(i.length===n.length)return Promise.resolve(Kz(s));const o=t.transaction("events","readonly"),a=o.objectStore("events").index("tags"),l=n.filter(t=>!i.includes(t)).map(t=>a.getAllKeys(e+t).then(n=>((t,n)=>{const i=new Set(n);s.push(i),r&&r.setTagIndex(e+t,i)})(t,n)));return o.commit(),Promise.all(l).then(()=>Kz(s))}function Kz(t){if(0===t.length)return new Set;const e=t.slice().sort((t,e)=>t.size-e.size);let n=e[0];for(let r=1;r!r.includes(t)).map(t=>o.getAllKeys(t).then(e=>((t,e)=>{for(const n of e)i.add(n);n&&n.setKindIndex(t,new Set(e))})(t,e)));return s.commit(),Promise.all(a).then(()=>i)}async function Yz(t,e,n){let r;if(void 0!==e&&void 0!==n)r=IDBKeyRange.bound(e,n);else if(void 0!==e)r=IDBKeyRange.lowerBound(e);else{if(void 0===n)throw new Error("Missing since or until");r=IDBKeyRange.upperBound(n)}return(await t.getAllKeysFromIndex("events","created_at",r)).reverse()}async function Xz(t,e,n){if(e.search)return new Set;if(e.ids)return new Set(e.ids);let r=null;const i=t=>{const e=t instanceof Set?t:new Set(t);if(r)for(const n of r)e.has(n)||r.delete(n);else r=e;return r};let s=null;void 0!==e.since&&(s=await Yz(t,e.since,e.until),i(s));for(const o of zz){const r=e[`&${o}`],s=e[`#${o}`];if(r?.length&&i(await Gz(t,o,r,n)),s?.length){const e=r?.length?s.filter(t=>!r.includes(t)):s;e.length>0&&i(await Hz(t,o,e,n))}}if(e.authors&&i(await Wz(t,e.authors,n)),e.kinds&&i(await Zz(t,e.kinds,n)),void 0===e.since&&void 0!==e.until&&(s=await Yz(t,e.since,e.until),i(s)),e.limit&&s){const t=new Set;for(const n of s){if(t.size>=e.limit)break;r.has(n)&&t.add(n)}return t}if(null===r)throw new Error("Empty filter");return r}async function Jz(t,e,n){if(0===e.length)throw new Error("No Filters");let r=new Set;for(const i of e){const e=await Xz(t,i,n);for(const t of e)r.add(t)}return r}async function Qz(t,e,n,r){const i=await Jz(t,e,n);return await async function(t,e,n,r){const i=[];let s=[];if(r)for(const d of e){const t=r.get(d);t?i.push(t):s.push(d)}else s=e;const o=t.transaction("events","readonly"),a=o.objectStore("events"),l=t=>t&&i.push(t.event),c=Array.from(s).map(t=>a.get(t).then(l));o.commit();const u=await Promise.all(c).then(()=>i.sort(qz));let h=1/0;for(const d of n)d.limit&&d.limith&&(u.length=h),u}(t,Array.from(i),e,r)}async function tj(t,e,n){return(await Jz(t,e,n)).size}var ej=$O.default("nostr-idb"),nj=ej.extend("prune");async function rj(t,e,n){const r=t.transaction("events","readwrite"),i=r.objectStore("events"),s=await i.get(e);if(!s)return await r.commit(),!1;if(await i.delete(e),await r.commit(),n){const t=s.event;n.removeEvent(t)}return!0}var ij=ej.extend("WriteQueue"),sj=class{db;queuedIds=new Set;eventQueue=[];lastUsedQueue=new Set;processEvents=null;constructor(t){this.db=t}addEvent(t){const e=Bz(t);this.queuedIds.has(e)||(this.eventQueue.push(t),this.queuedIds.add(e),this.touch(t))}addEvents(t){const e=t.filter(t=>!this.queuedIds.has(Bz(t)));if(0!==e.length){this.eventQueue.push(...e);for(const t of e)this.queuedIds.add(Bz(t));this.touch(e)}}touch(t){if(Array.isArray(t))for(const e of t)this.lastUsedQueue.add(Bz(e));else this.lastUsedQueue.add(Bz(t))}matchPending(t){return this.eventQueue.filter(e=>Fz(t,e))}async flush(t=1e3){if(this.eventQueue.length>0){let e=[];for(let n=0;nfunction(t){if("object"!=typeof t||null===t)return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.id)return!1;if(!/^[a-f0-9]{64}$/.test(t.id))return!1;if("string"!=typeof t.pubkey)return!1;if(!/^[a-f0-9]{64}$/.test(t.pubkey))return!1;if(!Array.isArray(t.tags))return!1;for(const e of t.tags){if(!Array.isArray(e))return!1;for(const t of e)if("string"!=typeof t)return!1}return!0}(t))).filter(t=>Pz(t.kind)||Mz(t.kind)),r={};if(n.length>0){const e=t.transaction("events","readonly"),i=n.map(t=>{const n=Bz(t);return e.store.get(n).then(t=>t&&(r[n]=t.event.created_at))});e.commit(),await Promise.all(i)}const i=t.transaction("events","readwrite");for(const s of e){const t=Bz(s);(!r[t]||s.created_at>r[t])&&i.objectStore("events").put({event:s,tags:Uz(s)},t)}await i.commit()}(this.db,e),ij(`Wrote ${e.length} to database`),this.eventQueue.length>0&&ij(`${this.eventQueue.length} left`)}this.lastUsedQueue.size>0&&(await async function(t,e){const n=t.transaction("used","readwrite"),r=Math.floor((new Date).valueOf()/1e3);for(const i of e)n.objectStore("used").put({uid:i,date:r});await n.commit()}(this.db,this.lastUsedQueue),this.lastUsedQueue.clear())}clear(){this.eventQueue=[]}},oj=ej.extend("cache:indexes"),aj=class extends Set{type;key;constructor(t,e,n){super(t),this.type=e,this.key=n}},lj=class{kinds=new Map;pubkeys=new Map;tags=new Map;get count(){return this.kinds.size+this.pubkeys.size+this.tags.size}max=1e3;lastUsed=[];useIndex(t){const e=this.lastUsed.indexOf(t);-1!==e&&this.lastUsed.splice(e,e+1),this.lastUsed.push(t)}getKindIndex(t){const e=this.kinds.get(t);return e&&this.useIndex(e),e}setKindIndex(t,e){const n=new aj(e,"kind",t);this.kinds.set(t,n),this.useIndex(n),this.pruneIndexes()}getPubkeyIndex(t){const e=this.pubkeys.get(t);return e&&this.useIndex(e),e}setPubkeyIndex(t,e){const n=new aj(e,"pubkey",t);this.pubkeys.set(t,n),this.useIndex(n),this.pruneIndexes()}getTagIndex(t){const e=this.tags.get(t);return e&&this.useIndex(e),e}setTagIndex(t,e){const n=new aj(e,"tag",t);this.tags.set(t,n),this.useIndex(n),this.pruneIndexes()}addEventToIndexes(t){const e=Bz(t);this.getKindIndex(t.kind)?.add(e),this.getPubkeyIndex(t.pubkey)?.add(e);const n=Uz(t);for(const r of n)this.getTagIndex(r)?.add(e)}removeEvent(t){const e=Bz(t);this.getKindIndex(t.kind)?.delete(e),this.getPubkeyIndex(t.pubkey)?.delete(e);const n=Uz(t);for(const r of n)this.getTagIndex(r)?.delete(e)}clear(){this.kinds.clear(),this.pubkeys.clear(),this.tags.clear(),this.lastUsed=[]}pruneIndexes(){for(;this.lastUsed.length>0&&this.lastUsed.length>this.max;){const t=this.lastUsed.shift();if(!t)return;switch(oj(`Forgetting ${t.type}:${t.key}`),t.type){case"kind":this.kinds.delete(t.key);break;case"pubkey":this.pubkeys.delete(t.key);break;case"tag":this.tags.delete(t.key)}}}},cj={},uj=function(t,e){let n=Promise.resolve();if(e&&e.length>0){const t=document.getElementsByTagName("link"),i=document.querySelector("meta[property=csp-nonce]"),s=i?.nonce||i?.getAttribute("nonce");r=e.map(e=>{var n;if(n=e=function(t){return"/"+t}(e),(e=import.meta.resolve?import.meta.resolve(n):new URL(n,import.meta.url).href)in cj)return;cj[e]=!0;const r=e.endsWith(".css");for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.href===e&&(!r||"stylesheet"===n.rel))return}const i=document.createElement("link");return i.rel=r?"stylesheet":"modulepreload",r||(i.as="script"),i.crossOrigin="",i.href=e,s&&i.setAttribute("nonce",s),document.head.appendChild(i),r?new Promise((t,n)=>{i.addEventListener("load",t),i.addEventListener("error",()=>n(new Error(`Unable to preload CSS for ${e}`)))}):void 0}),n=Promise.all(r.map(t=>Promise.resolve(t).then(t=>({status:"fulfilled",value:t}),t=>({status:"rejected",reason:t}))))}var r;function i(t){const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=t,window.dispatchEvent(e),!e.defaultPrevented)throw t}return n.then(e=>{for(const t of e||[])"rejected"===t.status&&i(t.reason);return t().catch(i)})},hj={batchWrite:1e3,writeInterval:100,cacheIndexes:1e3,pruneInterval:6e4,maxEvents:1e4},dj=ej.extend("nostridb"),pj=class{options;running=!1;writeInterval;pruneInterval;eventMap=new Map;writeQueue=null;indexCache;db=null;baseEoseTimeout=4400;subscriptions=new Map;constructor(t,e={}){this.options={...hj,...e},t&&(this.db=t,this.writeQueue=new sj(t)),this.indexCache=new lj,this.indexCache.max=this.options.cacheIndexes,this.start()}async getDb(){return this.db||(this.db=await $z()),this.db}async getWriteQueue(){if(this.writeQueue)return this.writeQueue;const t=await this.getDb();return this.writeQueue=new sj(t),this.writeQueue}async flush(){await(await this.getWriteQueue()).flush(),this.writeInterval=setTimeout(this.flush.bind(this),this.options.writeInterval)}async start(){if(this.running)return;dj("Starting"),this.running=!0;const t=await this.getDb();await this.flush(),this.pruneInterval=setInterval(()=>{!async function(t,e){const n=await function(t){return t.transaction("events","readonly").store.count()}(t);if(n<=e)return;const r=n-e;if(r<=0)return;nj(`Pruning database to ${e}`);const i=(await t.getAll("used")).sort((t,e)=>t.date-e.date),s=[];let o=r;for(const u of i){if(o<=0)break;const t=u.uid;s.push(t),o--}if(0===s.length)return;const a=t.transaction("events","readwrite"),l=t.transaction("used","readwrite"),c=[];for(const u of s)c.push(a.store.delete(u)),c.push(l.store.delete(u));a.commit(),l.commit(),await Promise.all(c),nj(`Removed ${s.length} old events`)}(t,this.options.maxEvents)},this.options.pruneInterval)}async stop(){this.running&&(this.writeInterval&&(clearTimeout(this.writeInterval),this.writeInterval=void 0),this.pruneInterval&&(clearInterval(this.pruneInterval),this.pruneInterval=void 0),this.running=!1,dj("Stopped"))}async add(t){Az(t.kind)||((await this.getWriteQueue()).addEvent(t),this.indexCache.addEventToIndexes(t));const e=Bz(t);if(!this.eventMap.has(e)){Az(t.kind)||this.eventMap.set(e,t);for(const[e,n]of this.subscriptions)n.event&&Fz(n.filters,t)&&n.event(t)}return!0}async event(t){return(await(await this.getDb()).get("events",t))?.event}async replaceable(t,e,n){return this.event([t,e,n??""].join(":"))}async count(t){const e=Array.isArray(t)?t:[t],n=await this.getDb();return await tj(n,e)}async query(t){const e=Array.isArray(t)?t:[t],n=await this.getDb(),r=(await this.getWriteQueue()).matchPending(e),i=await Qz(n,e,this.indexCache,this.eventMap);this.addToEventMaps(i);const s=new Set(r.map(t=>Bz(t)));return r.length>0?[...i.filter(t=>!s.has(Bz(t))),...r].sort(qz):i}async*subscribe(t){const e=Array.isArray(t)?t:[t],n=[],r=new Set;let i=null,s=!1;const o=this.subscribeInternal(e,{event:t=>{const e=Bz(t);if(!r.has(e)&&(r.add(e),n.push(t),i)){const t=i;i=null,t()}},complete:()=>{if(s=!0,i){const t=i;i=null,t()}}});try{for(;;){for(;n.length>0;)yield n.shift();if(s)break;await new Promise(t=>{i=t})}}finally{o.close()}}async supports(){return[]}async deleteEvent(t){const e=await this.getDb(),n=await rj(e,t,this.indexCache);return this.eventMap.delete(t),n}async deleteReplaceable(t,e,n){const r=await this.getDb(),i=await async function(t,e,n,r,i){if(!Pz(n)&&!Mz(n))throw new Error(`Kind ${n} is not replaceable`);return await rj(t,`${n}:${e}:${r??""}`,i)}(r,t,e,n,this.indexCache);if(i){const r=`${e}:${t}:${n??""}`;this.eventMap.delete(r)}return i}async deleteByFilters(t){const e=Array.isArray(t)?t:[t],n=await this.getDb(),r=await this.getEventIdsForFilters(e),i=await async function(t,e,n){const r=await Jz(t,e,n);return await async function(t,e,n){if(0===e.length)return 0;const r=t.transaction("events","readwrite"),i=r.objectStore("events");let s=0;const o=[];for(const a of e){const t=await i.get(a);t&&(o.push(t.event),await i.delete(a),s++)}if(await r.commit(),n&&o.length>0)for(const a of o)n.removeEvent(a);return s}(t,Array.from(r),n)}(n,e,this.indexCache);if(i>0)for(const s of r)this.eventMap.delete(s);return i}async deleteAllEvents(){const t=await this.getDb();await async function(t,e){const n=t.transaction("events","readwrite");await n.objectStore("events").clear(),await n.commit(),e&&e.clear()}(t,this.indexCache),this.eventMap.clear()}async getEventIdsForFilters(t){const e=await this.getDb(),{getIdsForFilters:n}=await uj(async()=>{const{getIdsForFilters:t}=await Promise.resolve().then(()=>Vz);return{getIdsForFilters:t}},void 0),r=await n(e,t,this.indexCache);return Array.from(r)}addToEventMaps(t){for(const e of t)this.eventMap.set(Bz(e),e)}subscribeInternal(t,e){const n=((t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((t,e)=>t+((e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_"),""))(),r={id:n,filters:t,closed:!1,close:()=>this.unsubscribe(n),...e};return this.subscriptions.set(n,r),this.executeSubscription(r),r}async executeSubscription(t){const e=(new Date).valueOf();dj(`Running ${t.id}`,t.filters);const n=(await this.getWriteQueue()).matchPending(t.filters);return new Promise(async r=>{const i=await this.getDb(),s=setTimeout(()=>{t.eose&&!t.closed&&t.eose(),r()},this.baseEoseTimeout);Qz(i,t.filters,this.indexCache,this.eventMap).then(i=>{if(clearTimeout(s),this.addToEventMaps(i),t.event&&!t.closed){const r=new Set(n.map(t=>Bz(t))),s=n.length>0?[...i.filter(t=>!r.has(Bz(t))),...n].sort(qz):i;for(const e of s)try{t.event(e)}catch(e6){dj("event handler failed with error",e6)}const o=(new Date).valueOf()-e;dj(`Finished ${t.id} took ${o}ms and got ${s.length} events`)}t.eose&&!t.closed&&t.eose(),r()})})}unsubscribe(t){const e=this.subscriptions.get(t);e&&(dj(`Closing ${t}`),e.closed=!0,e.complete?.(),this.subscriptions.delete(t))}},fj=a({excludeRequiredRelays:()=>vj,mergeRequiredRelays:()=>yj,normalizeRelayUrl:()=>gj,parsePlacePhotos:()=>bj,uniqNormalizedRelays:()=>mj});function gj(t){if(!t)return"";let e=t.trim().toLowerCase();if(!e)return"";for(e.startsWith("ws://")||e.startsWith("wss://")||(e="wss://"+e);e.endsWith("/");)e=e.slice(0,-1);return e}function mj(t=[]){return Array.from(new Set(t.map(gj).filter(Boolean)))}function yj(t=[],e=[]){const n=new Set(t.filter(Boolean)),r=[...t.filter(Boolean)];for(const i of mj(e))n.has(i)||r.push(i);return r}function vj(t=[],e=[]){const n=new Set(e.filter(Boolean));return mj(t).filter(t=>!n.has(t))}function bj(t){if(!t||0===t.length)return[];const e=[...t].sort((t,e)=>t.created_at-e.created_at),n=[];for(const i of e){const t=i.tags.filter(t=>"t"===t[0]).map(t=>t[1]).filter(Boolean),e=i.tags.filter(t=>"imeta"===t[0]);for(const r of e){let e=null,s=null,o=null,a=!1,l=16/9,c=null,u=i.tags.find(t=>"i"===t[0])?.[1];for(const t of r.slice(1))if(t.startsWith("url "))e=t.substring(4);else if(t.startsWith("thumb "))s=t.substring(6);else if(t.startsWith("blurhash "))o=t.substring(9);else if(t.startsWith("dim ")){const[e,n]=t.substring(4).split("x").map(Number);e&&n&&(l=e/n,e>n&&(a=!0))}else if(t.startsWith("alt ")){const e=t.substring(4).trim();c="A photo of a place"===e?null:e||null}e&&n.push({eventId:i.id,pubkey:i.pubkey,createdAt:i.created_at,url:e,thumbUrl:s,blurhash:o,isLandscape:a,aspectRatio:l,placeIdentifier:u,tags:t,alt:c})}}if(0===n.length)return[];const r=n.findIndex(t=>t.isLandscape);if(r>0){const[t]=n.splice(r,1);n.unshift(t)}return n}var wj="0123456789bcdefghjkmnpqrstuvwxyz",_j=class t{static encode(e,n,r){if(void 0===r){for(let r=1;r<=12;r++){const i=t.encode(e,n,r),s=t.decode(i);if(s.lat==e&&s.lon==n)return i}r=12}if(e=Number(e),n=Number(n),r=Number(r),isNaN(e)||isNaN(n)||isNaN(r))throw new Error("Invalid geohash");let i=0,s=0,o=!0,a="",l=-90,c=90,u=-180,h=180;for(;a.length=t?(i=2*i+1,u=t):(i*=2,h=t)}else{const t=(l+c)/2;e>=t?(i=2*i+1,l=t):(i*=2,c=t)}o=!o,5==++s&&(a+=wj.charAt(i),s=0,i=0)}return a}static decode(e){const n=t.bounds(e),r=n.sw.lat,i=n.sw.lon,s=n.ne.lat,o=n.ne.lon;let a=(r+s)/2,l=(i+o)/2;return a=a.toFixed(Math.floor(2-Math.log(s-r)/Math.LN10)),l=l.toFixed(Math.floor(2-Math.log(o-i)/Math.LN10)),{lat:Number(a),lon:Number(l)}}static bounds(t){if(0==t.length)throw new Error("Invalid geohash");t=t.toLowerCase();let e=!0,n=-90,r=90,i=-180,s=180;for(let o=0;o=0;t--){const o=l>>t&1;if(e){const t=(i+s)/2;1==o?i=t:s=t}else{const t=(n+r)/2;1==o?n=t:r=t}e=!e}}return{sw:{lat:n,lon:i},ne:{lat:r,lon:s}}}static adjacent(e,n){if(e=e.toLowerCase(),n=n.toLowerCase(),0==e.length)throw new Error("Invalid geohash");if(-1=="nsew".indexOf(n))throw new Error("Invalid direction");const r=e.slice(-1);let i=e.slice(0,-1);const s=e.length%2;return-1!={n:["prxz","bcfguvyz"],s:["028b","0145hjnp"],e:["bcfguvyz","prxz"],w:["0145hjnp","028b"]}[n][s].indexOf(r)&&""!=i&&(i=t.adjacent(i,n)),i+wj.charAt({n:["p0r21436x8zb9dcf5h7kjnmqesgutwvy","bc01fg45238967deuvhjyznpkmstqrwx"],s:["14365h7k9dcfesgujnmqp0r2twvyx8zb","238967debc01fg45kmstqrwxuvhjyznp"],e:["bc01fg45238967deuvhjyznpkmstqrwx","p0r21436x8zb9dcf5h7kjnmqesgutwvy"],w:["238967debc01fg45kmstqrwxuvhjyznp","14365h7k9dcfesgujnmqp0r2twvyx8zb"]}[n][s].indexOf(r))}static neighbours(e){return{n:t.adjacent(e,"n"),ne:t.adjacent(t.adjacent(e,"n"),"e"),e:t.adjacent(e,"e"),se:t.adjacent(t.adjacent(e,"s"),"e"),s:t.adjacent(e,"s"),sw:t.adjacent(t.adjacent(e,"s"),"w"),w:t.adjacent(e,"w"),nw:t.adjacent(t.adjacent(e,"n"),"w")}}},xj=a({getGeohashPrefixesInBbox:()=>Cj});function Cj(t){const{minLat:e,minLon:n,maxLat:r,maxLon:i}=t,s=new Set;if(Math.abs(r-e)>20||Math.abs(i-n)>20)return console.debug("BBox too large for 4-char geohash scanning, aborting fine scan."),[];for(let a=e;a<=r+.1;a+=.1)for(let t=n;t<=i+.1;t+=.1){const e=Math.min(a,r),n=Math.min(t,i);try{const t=_j.encode(e,n,4);s.add(t)}catch(o){}}try{s.add(_j.encode(e,n,4))}catch(o){}try{s.add(_j.encode(r,i,4))}catch(o){}try{s.add(_j.encode(e,i,4))}catch(o){}try{s.add(_j.encode(r,n,4))}catch(o){}return Array.from(s)}var Sj=a({default:()=>Tj}),kj=["wss://purplepag.es","wss://relay.damus.io","wss://nos.lol"],Ej=["wss://nostr.kosmos.org"],Rj=[],Tj=class extends pp{static{aF(this.prototype,"nostrRelay",[dp])}#at=void cF(this,"nostrRelay");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");store=new FN;static{aF(this.prototype,"profile",[Vr],function(){return null})}#dt=void cF(this,"profile");static{aF(this.prototype,"mailboxes",[Vr],function(){return null})}#pt=void cF(this,"mailboxes");static{aF(this.prototype,"blossomServers",[Vr],function(){return[]})}#ft=void cF(this,"blossomServers");static{aF(this.prototype,"placePhotos",[Vr],function(){return[]})}#gt=void cF(this,"placePhotos");static{aF(this.prototype,"myContributionEvents",[Vr],function(){return[]})}#mt=void cF(this,"myContributionEvents");_profileSub=null;_mailboxesSub=null;_blossomSub=null;_photosSub=null;_contributionsSub=null;_requestSub=null;_cachePromise=null;loadedGeohashPrefixes=new Set;constructor(){super(...arguments),this._cachePromise=$z("applesauce-events").then(async t=>{this.cache=new pj(t,{cacheIndexes:1e3,maxEvents:1e4}),await this.cache.start(),this._stopPersisting=function(t,e,n){const r=n?.batchTime??5e3,i=t.insert$.pipe(pO(t=>{return e=t,!(!0===Reflect.get(e,TP));var e}),n?.maxBatchSize?fO(r,void 0,n?.maxBatchSize??100):fO(r),pO(t=>t.length>0)).subscribe(t=>{e(t).then(()=>VO(`Saved ${t.length} events to cache`)).catch(e=>VO(`Failed to save ${t.length} events to cache`,e))});return()=>i.unsubscribe()}(this.store,async t=>{const e=t.filter(t=>0===t.kind||5===t.kind||10002===t.kind||10063===t.kind||360===t.kind);e.length>0&&await Promise.all(e.map(t=>this.cache.add(t)))},{batchTime:1e3,maxBatchSize:100})}),this.nostrRelay.pool.relays$.subscribe(()=>{})}get requiredReadRelays(){return Ej}get requiredWriteRelays(){return Rj}get mailboxReadRelays(){return(this.mailboxes?.inboxes||[]).map(gj).filter(Boolean)}get mailboxWriteRelays(){return(this.mailboxes?.outboxes||[]).map(gj).filter(Boolean)}get configuredReadRelays(){return vj(mj([...this.mailboxReadRelays,...this.settings.nostrReadRelays||[]]),this.settings.nostrReadRelayExclusions||[])}get configuredWriteRelays(){return vj(mj([...this.mailboxWriteRelays,...this.settings.nostrWriteRelays||[]]),this.settings.nostrWriteRelayExclusions||[])}get activeReadRelays(){return yj(this.requiredReadRelays,this.configuredReadRelays)}get activeWriteRelays(){return yj(this.requiredWriteRelays,this.configuredWriteRelays)}async loadPlacesInBounds(t){const e=Cj(t).filter(t=>!this.loadedGeohashPrefixes.has(t));if(0!==e.length){console.debug("[nostr-data] Loading place photos for prefixes:",e);try{await this._cachePromise;const t=await this.cache.query([{kinds:[360],"#g":e}]);if(t&&t.length>0)for(const e of t)this.store.add(e)}catch(n){console.warn("[nostr-data] Failed to read photos from local Nostr IDB cache",n)}this.nostrRelay.pool.request(this.activeReadRelays,[{kinds:[360],"#g":e}]).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("[nostr-data] Error fetching place photos by geohash:",t)}});for(const t of e)this.loadedGeohashPrefixes.add(t)}}async loadPhotosForPlace(t){if(this._photosSub&&(this._photosSub.unsubscribe(),this._photosSub=null),this.placePhotos=[],!t||!t.osmId||!t.osmType)return;const e=`osm:${t.osmType}:${t.osmId}`;this._photosSub=this.store.timeline([{kinds:[360],"#i":[e]}]).subscribe(t=>{this.placePhotos=t});try{await this._cachePromise;const t=await this.cache.query([{kinds:[360,5],"#i":[e]}]);if(t&&t.length>0)for(const e of t)this.store.add(e)}catch(n){console.warn("[nostr-data] Failed to read photos for place from local Nostr IDB cache",n)}this.nostrRelay.pool.request(this.activeReadRelays,[{kinds:[360,5],"#i":[e]}]).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("[nostr-data] Error fetching place photos for place:",t)}})}async loadMyContributions(t){if(!t)return;this.myContributionEvents=[],this._contributionsSub&&(this._contributionsSub.unsubscribe(),this._contributionsSub=null);const e=[{kinds:[360,5],authors:[t]}];this._contributionsSub=this.store.timeline(e).subscribe(t=>{this.myContributionEvents=t});try{await this._cachePromise;const t=await this.cache.query(e);if(t&&t.length>0)for(const e of t)this.store.add(e)}catch(n){console.warn("[nostr-data] Failed to read my contributions from local Nostr IDB cache",n)}this.nostrRelay.pool.request(this.activeReadRelays,e).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("[nostr-data] Error fetching my contribution events:",t)}})}async loadProfile(t){if(!t)return;this.profile=null,this.mailboxes=null,this.blossomServers=[],this._cleanupSubscriptions(),this._profileSub=this.store.model(AN,t).subscribe(t=>{this.profile=t}),this._mailboxesSub=this.store.model(MN,t).subscribe(t=>{this.mailboxes=t}),this._blossomSub=this.store.replaceable(10063,t).subscribe(t=>{t&&t.tags?this.blossomServers=t.tags.filter(t=>"server"===t[0]&&t[1]).map(t=>t[1]):this.blossomServers=[]});try{await this._cachePromise;const e=await this.cache.query([{authors:[t],kinds:[0,10002,10063]}]);if(e&&e.length>0)for(const t of e)this.store.add(t)}catch(n){console.warn("Failed to read from local Nostr IDB cache",n)}const e=Array.from(new Set([...kj,...this.activeWriteRelays]));this._requestSub=this.nostrRelay.pool.request(e,[{authors:[t],kinds:[0,10002,10063]}]).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("Error fetching profile events:",t)}})}get userDisplayName(){if(this.profile){if(this.profile.nip05)return this.profile.nip05;if(this.profile.displayName||this.profile.display_name)return this.profile.displayName||this.profile.display_name;if(this.profile.name)return this.profile.name}if(this.nostrAuth.pubkey)try{const t=function(t,e){return function(t,e){let n=bk.toWords(e);return bk.encode("npub",n,XP)}(0,e)}(0,IS(this.nostrAuth.pubkey));return`${t.slice(0,9)}...${t.slice(-4)}`}catch{return this.nostrAuth.pubkey}return"Not connected"}async clearCache(){await this._cachePromise,this.cache&&await this.cache.deleteAllEvents()}_cleanupSubscriptions(){this._requestSub&&(this._requestSub.unsubscribe(),this._requestSub=null),this._profileSub&&(this._profileSub.unsubscribe(),this._profileSub=null),this._mailboxesSub&&(this._mailboxesSub.unsubscribe(),this._mailboxesSub=null),this._blossomSub&&(this._blossomSub.unsubscribe(),this._blossomSub=null),this._photosSub&&(this._photosSub.unsubscribe(),this._photosSub=null),this._contributionsSub&&(this._contributionsSub.unsubscribe(),this._contributionsSub=null)}willDestroy(){super.willDestroy(...arguments),this._cleanupSubscriptions(),this._stopPersisting&&this._stopPersisting(),this.cache&&this.cache.stop()}};function Lj(t,e=t=>!!t){return bO(n=>{const r=e?n.pipe(t,pO(e),wO(1)):n.pipe(t,wO(1));return n.pipe(FO(r))})}function Ij(t){return gO(e=>UA({ok:!1,from:t.url,message:e?.message||"Unknown error"}))}var Pj,Mj=class t{relays$=new cA([]);status$;get relays(){if(this.relays$ instanceof cA)return this.relays$.value;throw new Error("This group was created with an observable, relays are not available")}constructor(t){this.relays$=Array.isArray(t)?new cA(t):t,this.status$=this.relays$.pipe(NO(t=>0===t.length?UA({}):cO(...t.map(t=>t.status$)).pipe(IO((t,e)=>({...t,[e.url]:e}),{}),OO({}))),AO(1))}get controlled(){return this.relays$ instanceof cA==0}has(t){if(this.controlled)throw new Error("This group was created with an observable, relays are not available");return"string"==typeof t?this.relays.some(e=>e.url===t):this.relays.includes(t)}add(t){this.has(t)||this.relays$.next([...this.relays,t])}remove(t){this.has(t)&&this.relays$.next(this.relays.filter(e=>e!==t))}internalSubscription(t){const e=new WeakMap;return this.relays$.pipe(function(t){return rA((e,n)=>{let r=null,i=!1;const s=()=>{i&&!r&&n.complete()};e.subscribe(iA(n,e=>{const i=r,o=r=iA(n,t=>n.next(t),()=>{r!==o&&null!==r||(r=null,s())});jA(t(e)).subscribe(r),i?.unsubscribe()},()=>{i=!0,s()}))})}(n=>{const r=[];for(const i of n){if(e.has(i)){r.push(e.get(i));continue}const n=t(i).pipe(gO(t=>UA({type:"ERROR",from:i.url,error:t})));r.push(n),e.set(i,n)}return cO(...r)}),PO())}internalPublish(t){const e=new WeakMap;return this.relays$.pipe(wO(1),NO(n=>{const r=[];for(const i of n){if(e.has(i)){r.push(e.get(i));continue}const n=t(i).pipe(Ij(i));r.push(n),e.set(i,n)}return cO(...r)}),PO())}req(t,e){return this.internalSubscription(n=>n.req(t,e))}event(t){return this.internalPublish(e=>e.event(t))}async negentropy(t,e,n,r){const i=(await Promise.all(this.relays.map(async t=>[t,await t.getSupported()]))).filter(([t,e])=>e?.includes(77)).map(([t])=>t);if(0===i.length)throw new Error("No relays support NIP-77 negentropy sync");if(!r?.parallel)throw new Error("Negentropy sync must be parallel (for now)");return await Promise.allSettled(i.map(i=>i.negentropy(t,e,n,r))),!0}publish(t,e){return VA(this.internalPublish(n=>jA(n.publish(t,e))).pipe(rA(function(t,e){(function(t,e){return rA(mO(t,e,arguments.length>=2,!1,!0))})(yO,[])(t).subscribe(e)}),(n=[],rA(function(t,e){var r=!1;t.subscribe(iA(e,function(t){r=!0,e.next(t)},function(){r||e.next(n),e.complete()}))}))));var n}request(e,n){const r=n?.complete??t.completeOnAny(t.completeAfterFirstRelay(5e3),t.completeOnAllEose());return this.internalSubscription(t=>t.req(e,{...n,reconnect:n?.reconnect??t.requestReconnect})).pipe(r?Lj(r):tA,KA({first:n?.timeout??3e4}),pO(t=>"EVENT"===t.type),YA(t=>t.event),null===n?.eventStore?tA:zN(n?.eventStore??new CN),PO())}subscription(t,e){return this.internalSubscription(n=>n.req(t,{...e,reconnect:e?.reconnect??n.subscriptionReconnect})).pipe(pO(t=>"EVENT"===t.type),YA(t=>t.event),null===e?.eventStore?tA:zN(e?.eventStore??new CN),PO())}count(t,e=qP()){return this.relays$.pipe(NO(n=>nO(Object.fromEntries(n.map(n=>[n.url,n.count(t,e)])))),PO())}sync(t,e,n){return aO(async()=>{const t=(await Promise.all(this.relays.map(async t=>[t,await t.getSupported()]))).filter(([t,e])=>e?.includes(77)).map(([t])=>t);if(0===t.length)throw new Error("No relays support NIP-77 negentropy sync");return t}).pipe(NO(r=>cO(...r.map(r=>r.sync(t,e,n)))),PO())}static completeAfterFirstRelay(t=5e3){return e=>e.pipe(pO(t=>"EOSE"===t.type)).pipe(wO(1),NO(()=>lO(t)),YA(()=>!0))}static completeOnAllEose(){return t=>t.pipe(pO(t=>"OPEN"===t.type||"EOSE"===t.type||"ERROR"===t.type),IO((t,e)=>t.set(e.from,e.type),new Map),YA(t=>Array.from(t.values()).every(t=>"OPEN"!==t)))}static completeOnAny(...t){return bO(e=>cO(...t.map(t=>e.pipe(t))))}static completeOnAll(...t){return bO(e=>nO(t.map(t=>e.pipe(t))).pipe(YA(t=>t.every(t=>!!t))))}},Aj={url:"",deserializer:function(t){return JSON.parse(t.data)},serializer:function(t){return JSON.stringify(t)}},Oj=function(t){function e(e,n){var r=t.call(this)||this;if(r._socket=null,e instanceof eA)r.destination=n,r.source=e;else{var i=r._config=RM({},Aj);if(r._output=new aA,"string"==typeof e)i.url=e;else for(var s in e)e.hasOwnProperty(s)&&(i[s]=e[s]);if(!i.WebSocketCtor&&WebSocket)i.WebSocketCtor=WebSocket;else if(!i.WebSocketCtor)throw new Error("no WebSocket constructor can be found");r.destination=new hA}return r}return EM(e,t),e.prototype.lift=function(t){var n=new e(this._config,this.destination);return n.operator=t,n.source=this,n},e.prototype._resetState=function(){this._socket=null,this.source||(this.destination=new hA),this._output=new aA},e.prototype.multiplex=function(t,e,n){var r=this;return new eA(function(i){try{r.next(t())}catch(xD){i.error(xD)}var s=r.subscribe({next:function(t){try{n(t)&&i.next(t)}catch(xD){i.error(xD)}},error:function(t){return i.error(t)},complete:function(){return i.complete()}});return function(){try{r.next(e())}catch(xD){i.error(xD)}s.unsubscribe()}})},e.prototype._connectSocket=function(){var t=this,e=this._config,n=e.WebSocketCtor,r=e.protocol,i=e.url,s=e.binaryType,o=this._output,a=null;try{a=r?new n(i,r):new n(i),this._socket=a,s&&(this._socket.binaryType=s)}catch(c){return void o.error(c)}var l=new DM(function(){t._socket=null,a&&1===a.readyState&&a.close()});a.onopen=function(e){if(!t._socket)return a.close(),void t._resetState();var n=t._config.openObserver;n&&n.next(e);var r=t.destination;t.destination=GM.create(function(e){if(1===a.readyState)try{var n=t._config.serializer;a.send(n(e))}catch(c){t.destination.error(c)}},function(e){var n=t._config.closingObserver;n&&n.next(void 0),e&&e.code?a.close(e.code,e.reason):o.error(new TypeError("WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }")),t._resetState()},function(){var e=t._config.closingObserver;e&&e.next(void 0),a.close(),t._resetState()}),r&&r instanceof hA&&l.add(r.subscribe(t.destination))},a.onerror=function(e){t._resetState(),o.error(e)},a.onclose=function(e){a===t._socket&&t._resetState();var n=t._config.closeObserver;n&&n.next(e),e.wasClean?o.complete():o.error(e)},a.onmessage=function(e){try{var n=t._config.deserializer;o.next(n(e))}catch(xD){o.error(xD)}}},e.prototype._subscribe=function(t){var e=this,n=this.source;return n?n.subscribe(t):(this._socket||this._connectSocket(),this._output.subscribe(t),t.add(function(){var t=e._socket;0===e._output.observers.length&&(!t||1!==t.readyState&&0!==t.readyState||t.close(),e._resetState())}),t)},e.prototype.unsubscribe=function(){var e=this._socket;!e||1!==e.readyState&&0!==e.readyState||e.close(),this._resetState(),t.prototype.unsubscribe.call(this)},e}(lA),Nj="auth-required:",Fj={count:3,delay:(t,e)=>lO(1e3*e),resetOnSuccess:!0};function Dj(t){return"number"==typeof t?{...Fj,count:t}:{...Fj,...t??{}}}!function(t){t[t.RECEIVE=1]="RECEIVE",t[t.SEND=2]="SEND",t[t.BOTH=3]="BOTH"}(Pj||(Pj={}));var zj=class extends Error{reason;constructor(t){super(t),this.reason=t,this.name="RelayClosedError"}},jj=class extends zj{constructor(t){super(t),this.name="AuthRequiredError"}},Uj={"auth-required":jj,unsupported:zj,error:zj,blocked:zj,restricted:zj,"rate-limited":zj,pow:zj,invalid:zj,duplicate:zj,mute:zj};function Bj(t){const e=Uj[t.split(":")[0]];return e?new e(t):null}var $j={ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0},qj=class t{url;log=qO.extend("Relay");socket;_ready$=new cA(!0);ready$=this._ready$.asObservable();reconnectTimer;attempts$=new cA(0);connected$=new cA(!1);challenge$=new cA(null);authenticated$;authenticatedAs$;authentication$=new cA(null);authenticationResponse$=new cA(null);notices$=new cA([]);error$=new cA(null);message$;notice$;lastMessageReceivedAt=0;_lastMessageAt$=new cA(0);lastMessageAt$=this._lastMessageAt$.asObservable();status$;information$;_nip11=null;icon$;limitations$;supported$;open$=new aA;close$=new aA;closing$=new aA;reqs$=new cA({});get ready(){return this._ready$.value}get connected(){return this.connected$.value}get challenge(){return this.challenge$.value}get notices(){return this.notices$.value}get authenticated(){return!0===this.authenticationResponse?.ok}get authentication(){return this.authentication$.value}get authenticatedAs(){return this.authenticated?this.authentication?.pubkey??null:null}get authenticationResponse(){return this.authenticationResponse$.value}get information(){return this._nip11}get lastMessageAt(){return this._lastMessageAt$.value}get reqs(){return this.reqs$.value}eventTimeout=1e4;publishTimeout=3e4;keepAlive=3e4;enablePing=!1;pingFrequency=29e3;pingTimeout=2e4;subscriptionReconnect;requestReconnect;publishRetry;onUnresponsive;receivedAuthRequiredForReq=new cA(!1);receivedAuthRequiredForEvent=new cA(!1);authRequiredForRead$;authRequiredForPublish$;resetState(){null!==this.challenge$.value&&this.challenge$.next(null),this.authenticationResponse$.value&&this.authenticationResponse$.next(null),null!==this.authentication$.value&&this.authentication$.next(null),this.notices$.value.length>0&&this.notices$.next([]),this.receivedAuthRequiredForReq.value&&this.receivedAuthRequiredForReq.next(!1),this.receivedAuthRequiredForEvent.value&&this.receivedAuthRequiredForEvent.next(!1)}watchTower;internalSubscriptions=new DM;reconnectSubscription=null;destroy$=new hA(1);constructor(e,n){var r;this.url=e,this.log=this.log.extend(e),void 0!==n?.eventTimeout&&(this.eventTimeout=n.eventTimeout),void 0!==n?.publishTimeout&&(this.publishTimeout=n.publishTimeout),void 0!==n?.keepAlive&&(this.keepAlive=n.keepAlive),void 0!==n?.enablePing&&(this.enablePing=n.enablePing),void 0!==n?.pingFrequency&&(this.pingFrequency=n.pingFrequency),void 0!==n?.pingTimeout&&(this.pingTimeout=n.pingTimeout),void 0!==n?.onUnresponsive&&(this.onUnresponsive=n.onUnresponsive),this.subscriptionReconnect=Dj(n?.subscriptionReconnect),this.requestReconnect=Dj(n?.requestReconnect),this.publishRetry={...Fj,...n?.publishRetry??{}},this.authenticated$=this.authenticationResponse$.pipe(YA(t=>!0===t?.ok)),this.authenticatedAs$=nO([this.authenticated$,this.authentication$]).pipe(YA(([t,e])=>t&&e?e.pubkey:null)),this.reconnectTimer=t.createReconnectTimer(e),this.internalSubscriptions.add(this.open$.subscribe(()=>{this.log("Connected"),this.connected$.next(!0),this.attempts$.next(0),this.error$.next(null),this.resetState()})),this.internalSubscriptions.add(this.close$.subscribe(t=>{this.connected$.value?this.log("Disconnected"):this.log("Failed to connect"),this.connected$.value&&this.connected$.next(!1),this.attempts$.next(this.attempts$.value+1),this.resetState(),t.wasClean||this.startReconnectTimer(t)})),this.socket=(r={url:e,openObserver:this.open$,closeObserver:this.close$,closingObserver:this.closing$,WebSocketCtor:n?.WebSocket},new Oj(r)),this.information$=aO(()=>(this.log("Fetching NIP-11 information document"),t.fetchInformationDocument(this.url))).pipe(gO(()=>UA(null)),zO(t=>this._nip11=t),AO(1)),this.limitations$=this.information$.pipe(YA(t=>t?t.limitation:null)),this.supported$=this.information$.pipe(YA(t=>t&&Array.isArray(t.supported_nips)?t.supported_nips.filter(t=>"number"==typeof t):null)),this.icon$=this.information$.pipe(YA(t=>t?.icon||new URL("/favicon.ico",QP(this.url)).toString())),this.authRequiredForRead$=this.receivedAuthRequiredForReq,this.authRequiredForPublish$=this.receivedAuthRequiredForEvent,this.internalSubscriptions.add(this.authRequiredForRead$.pipe(pO(t=>!0===t),wO(1)).subscribe(()=>this.log("Auth required for REQ"))),this.internalSubscriptions.add(this.authRequiredForPublish$.pipe(pO(t=>!0===t),wO(1)).subscribe(()=>this.log("Auth required for EVENT"))),this.status$=nO({url:UA(this.url),connected:this.connected$,authenticated:this.authenticated$,authenticatedAs:this.authenticatedAs$,ready:this._ready$,authRequiredForRead:this.authRequiredForRead$,authRequiredForPublish:this.authRequiredForPublish$,challenge:this.challenge$.asObservable()}).pipe(AO(1));const i=this.socket.pipe(pO(t=>Array.isArray(t)&&"NOTICE"===t[0]),YA(t=>t[1]),IO((t,e)=>[...t,e],[]),zO(t=>this.notices$.next(t))),s=this.socket.pipe(pO(t=>"AUTH"===t[0]),YA(t=>t[1]),zO(t=>{this.log("Received AUTH challenge",t),this.challenge$.next(t)})),o=new aA,a=this.socket.pipe(zO(t=>{const e=Date.now();this.lastMessageReceivedAt=e,this._lastMessageAt$.next(e),o.next(t)}));this.message$=o.asObservable(),this.notice$=this.message$.pipe(pO(t=>Array.isArray(t)&&"NOTICE"===t[0]),YA(t=>t[1]));const l=this.connected$.pipe(NO(t=>t&&this.enablePing?lO(this.pingFrequency,this.pingFrequency).pipe(iO(()=>{if(Date.now()-this.lastMessageReceivedAtArray.isArray(e)&&("EOSE"===e[0]||"CLOSED"===e[0])&&e[1]===t),wO(1),KA({first:this.pingTimeout,with:()=>{const t=Date.now(),e=this.onUnresponsive?.({url:this.url,lastMessageAt:this.lastMessageReceivedAt,now:t,attempts:this.attempts$.value})??"reconnect",n=new Error(`Relay ping timeout after ${this.pingTimeout}ms`);return"reconnect"===e?(this.log("Relay connection has become unresponsive, triggering reconnect"),this.startReconnectTimer(n)):"close"===e?(this.log("Relay connection has become unresponsive, closing connection"),this.error$.next(n),this.socket.complete()):this.log("Relay connection has become unresponsive (ignoring per policy)"),uO}}),kO(()=>this.send(["CLOSE",t])))})):uO),gO(()=>uO));this.watchTower=this.ready$.pipe(NO(t=>t?cO(a,i,s,l).pipe(_O(),gO(t=>(this.startReconnectTimer(t instanceof Error?t:new Error("Connection error")),uO)),PO({resetOnRefCountZero:()=>lO(this.keepAlive).pipe(FO(this.destroy$))})):uO),PO())}startReconnectTimer(t){this.ready&&(this.error$.next(t instanceof Error?t:new Error("Connection error")),this._ready$.next(!1),this.reconnectSubscription?.unsubscribe(),this.reconnectSubscription=this.reconnectTimer(t,this.attempts$.value).pipe(wO(1)).subscribe(()=>{this.reconnectSubscription=null,this._ready$.next(!0)}))}waitForAuth(t,e){return nO([t,this.authenticated$]).pipe(RO(this.watchTower),pO(([t,e])=>!t||e),wO(1),NO(()=>e))}waitForReady(t){return this.ready?t:this.ready$.pipe(pO(t=>t),wO(1),NO(()=>t))}multiplex(t,e,n){return this.socket.multiplex(t,e,n)}send(t){this.socket.next(t)}req(t,e){const n=e?.id??qP(),r=e?.waitForAuth??!0;let i;if("function"==typeof t){const e=t(this);i=($A(e)?e:cO(UA(e),uO)).pipe(YA(t=>Array.isArray(t)?t:[t]))}else i=($A(t)?t:cO(UA(t),uO)).pipe(YA(t=>Array.isArray(t)?t:[t]));const s=i.pipe(_O(),SO(!0));let o=!1,a=!1;const l=this.socket.pipe(pO(t=>Array.isArray(t)&&("EVENT"===t[0]||"CLOSED"===t[0]||"EOSE"===t[0])&&t[1]===n),YA(t=>"EVENT"===t[0]&&"object"==typeof t[2]?{type:"EVENT",from:this.url,id:t[1],event:t[2]}:"CLOSED"===t[0]?{type:"CLOSED",from:this.url,id:t[1],reason:t[2]??""}:{type:"EOSE",from:this.url,id:t[1]}),zO(t=>{if("CLOSED"===t.type){o=!0;const e=Bj(t.reason);if(e)throw e;a=!0}}),DO(t=>"CLOSED"!==t.type,!0),PO()),c=i.pipe(YA(t=>(o=!1,a=!1,this.socket.next(["REQ",n,...t]),this.reqs$.next({...this.reqs$.value,[n]:t}),{type:"OPEN",id:n,filters:t,from:this.url})),kO(()=>{o||this.socket.next(["CLOSE",n]);const{[n]:t,...e}=this.reqs$.value;this.reqs$.next(e)}),NO(t=>l.pipe(OO(t)))),u=cO(this.watchTower,c).pipe(FO(l.pipe(_O(),SO(!0))),FO(s),zO(t=>{"EVENT"===t.type&&nM(t.event,this.url)}),PO()),h=r?this.waitForAuth(this.authRequiredForRead$,u):u;return aO(()=>this.waitForReady(h)).pipe(LO({delay:t=>t instanceof jj?(this.log("Auth required for REQ"),this.receivedAuthRequiredForReq.next(!0),r?this.authenticated$.pipe(pO(t=>t),wO(1)):BA(()=>t)):BA(()=>t)}),this.customConnectionRetryOperator(e?.reconnect),this.customRepeatOperator(e?.resubscribe,()=>a),PO())}count(t,e=qP()){let n=!1;const r=this.socket.pipe(pO(t=>Array.isArray(t)&&("COUNT"===t[0]||"CLOSED"===t[0])&&t[1]===e),YA(t=>{if("COUNT"===t[0])return t[2];if("CLOSED"===t[0]){n=!0;const e=Bj(t[2]??"");if(e)throw e}return null}),DO(t=>null!==t,!0),pO(t=>null!==t),PO()),i=aO(()=>(n=!1,this.socket.next(Array.isArray(t)?["COUNT",e,...t]:["COUNT",e,t]),r)).pipe(kO(()=>{n||this.socket.next(["CLOSE",e])})),s=cO(this.watchTower,i).pipe(FO(r.pipe(_O(),SO(!0))),wO(1),gO(t=>(t instanceof jj&&!this.receivedAuthRequiredForReq.value&&(this.log("Auth required for COUNT"),this.receivedAuthRequiredForReq.next(!0)),BA(()=>t))),KA({first:1e4,with:()=>BA(()=>new Error("COUNT timeout"))}));return this.waitForReady(this.waitForAuth(this.authRequiredForRead$,s)).pipe(PO())}event(t,e="EVENT"){const n=aO(()=>(this.socket.next([e,t]),this.socket.pipe(pO(e=>"OK"===e[0]&&e[1]===t.id),YA(t=>({ok:t[2],message:t[3],from:this.url}))))).pipe(PO()),r=cO(this.watchTower,n).pipe(FO(n.pipe(_O(),SO(!0))),wO(1),zO(({ok:t,message:e})=>{!1===t&&e?.startsWith(Nj)&&!this.receivedAuthRequiredForEvent.value&&(this.log("Auth required for publish"),this.receivedAuthRequiredForEvent.next(!0))}),KA({first:this.eventTimeout,with:()=>UA({ok:!1,from:this.url,message:"Timeout"})}));return"AUTH"===e?this.waitForReady(r).pipe(PO()):this.waitForReady(this.waitForAuth(this.authRequiredForPublish$,r)).pipe(PO())}auth(t){return this.authentication$.next(t),VA(this.event(t,"AUTH").pipe(zO(t=>this.authenticationResponse$.next(t))))}async negentropy(t,e,n,r){if(!1===(await this.getSupported())?.includes(77))throw new Error("Relay does not support NIP-77");const{buildStorageVector:i,buildStorageFromFilter:s,negentropySync:o}=await uj(async()=>{const{buildStorageVector:t,buildStorageFromFilter:e,negentropySync:n}=await import("./negentropy-C2aqP_zP.js");return{buildStorageVector:t,buildStorageFromFilter:e,negentropySync:n}},[]);return o(Array.isArray(t)?i(t):await s(t,e),this.socket,e,n,r)}authenticate(t){if(!this.challenge)throw new Error("Have not received authentication challenge");const e=t.signEvent(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,this.challenge));return VA((e instanceof Promise?jA(e):UA(e)).pipe(NO(t=>this.auth(t))))}customRetryOperator(t,e){return!1===t||void 0===t?tA:"number"==typeof t?LO({...e,count:t}):!0===t?e?LO(e):LO():LO({...e,...t})}customConnectionRetryOperator(t,e){if(!1===t||void 0===t)return tA;const n="number"==typeof t?{...e,count:t}:!0===t?e??{}:{...e,...t};return LO({...n,delay:(t,e)=>t instanceof zj?BA(()=>t):"number"==typeof n.delay?lO(n.delay):"function"==typeof n.delay?n.delay(t,e):UA(null)})}customRepeatOperator(t,e){if(!1===t||void 0===t)return tA;const n=n=>{if(e&&!e())return bA;if("object"==typeof t){if("number"==typeof t.delay)return lO(t.delay);if("function"==typeof t.delay)return t.delay(n)}return UA(null)};return TO(!0===t?{delay:n}:"number"==typeof t?{count:t,delay:n}:{...t,delay:n})}customTimeoutOperator(t,e){return!1===t?tA:UN(!0===t?e:t??e)}subscription(t,e){return this.req(t,{...e,reconnect:e?.reconnect??this.subscriptionReconnect}).pipe(pO(t=>"EOSE"===t.type||"EVENT"===t.type),YA(t=>"EOSE"===t.type?"EOSE":t.event),PO())}request(t,e){return this.req(t,{...e,reconnect:e?.reconnect??this.requestReconnect}).pipe(e?.complete?Lj(e?.complete):tA,KA({first:e?.timeout??3e4}),DO(t=>"EOSE"!==t.type),pO(t=>"EVENT"===t.type),YA(t=>t.event),PO())}publish(t,e){return VA(this.event(t).pipe(iO(t=>!1===t.ok&&t.message?.startsWith(Nj)?BA(()=>new jj(t.message??"")):UA(t)),this.customRetryOperator(e?.retries??e?.reconnect??!0,this.publishRetry),this.customTimeoutOperator(e?.timeout,this.publishTimeout)))}sync(t,e,n=Pj.RECEIVE){return new eA(r=>{const i=new AbortController;let s=!1;return this.negentropy(t,e,async(e,i)=>{if(n&Pj.SEND&&e.length>0){const n=await(async e=>Array.isArray(t)?t.filter(t=>e.includes(t.id)):t.getByFilters({ids:e}))(e);await Promise.allSettled(n.map(async t=>{const e=await VA(this.event(t));return e.ok&&nM(t,this.url),e}))}n&Pj.RECEIVE&&i.length>0&&await VA(this.req({ids:i}).pipe(DO(t=>"EOSE"!==t.type),pO(t=>"EVENT"===t.type),YA(t=>t.event),Reflect.has(t,"add")?DN(t):tA,zO(t=>r.next(t))))},{signal:i.signal}).then(()=>{s||r.complete()}).catch(t=>{s||r.error(t)}),()=>{s||(s=!0,i.abort())}}).pipe(PO())}close(){this.destroy$.next(),this.destroy$.complete(),this.reconnectSubscription?.unsubscribe(),this.reconnectSubscription=null,this.internalSubscriptions.unsubscribe(),this.connected$.value&&this.connected$.next(!1),this._ready$.next(!1),this._ready$.complete(),this.socket.unsubscribe()}async getInformation(){return WA(this.information$)}async getLimitations(){return WA(this.limitations$)}async getSupported(){return WA(this.supported$)}static fetchInformationDocument(t){return jA(fetch(QP(t),{headers:{Accept:"application/nostr+json"}}).then(t=>t.json())).pipe(gO(()=>UA(null)),UN(1e4))}static createReconnectTimer(t){return(t,e=0)=>lO(Math.min(1e3*Math.pow(1.5,e),3e5))}static afterOpen(t){return e=>e.pipe(pO(t=>"OPEN"===t.type),NO(()=>e.pipe(t)))}static completeOr(...t){return e=>nO(t.map(t=>e.pipe(t,OO(!1)))).pipe(YA(t=>t.some(t=>!!t)))}static completeAnd(...t){return e=>nO(t.map(t=>e.pipe(t,OO(!1)))).pipe(YA(t=>t.every(t=>!!t)))}static defaultComplete(t,e=1e4){return this.completeOr(()=>lO(t),this.afterOpen(()=>lO(e)))}},Vj=class{options;relays$=new cA(new Map);get relays(){return this.relays$.value}status$;ignoreOffline=!1;add$=new aA;remove$=new aA;constructor(t){this.options=t,this.status$=this.relays$.pipe(YA(t=>Array.from(t.values())),NO(t=>0===t.length?UA({}):cO(...t.map(t=>t.status$)).pipe(IO((t,e)=>({...t,[e.url]:e}),{}),OO({}))),AO(1))}relay(t){t=tM(t);let e=this.relays.get(t);return e||(e=new qj(t,this.options),this.relays.set(t,e),this.relays$.next(this.relays),this.add$.next(e),e)}group(t,e=this.ignoreOffline){let n=Array.isArray(t)?t.map(t=>this.relay(t)):t.pipe(YA(t=>t.map(t=>this.relay(t))));return e&&(n=(Array.isArray(n)?UA(n):n).pipe(NO(t=>0===t.length?UA([]):nO(t.map(t=>t.ready$.pipe(pO(t=>t),wO(1),YA(()=>t),OO(null)))).pipe(YA(t=>t.filter(t=>null!==t)))))),new Mj(n)}remove(t,e=!0){let n;if("string"==typeof t){if(n=this.relays.get(t),!n)return}else{if(!Array.from(this.relays.values()).some(e=>e===t))return;n=t}e&&n?.close(),this.relays.delete(n.url),this.relays$.next(this.relays),this.remove$.next(n)}close(){for(const t of[...this.relays.values()])this.remove(t,!0)}req(t,e,n){return this.group(t).req(e,n)}event(t,e){return this.group(t).event(e)}negentropy(t,e,n,r,i){return this.group(t).negentropy(e,n,r,i)}publish(t,e,n){return this.group(t).publish(e,n)}request(t,e,n){return this.group(t).request(e,n)}subscription(t,e,n){return this.group(t).subscription(e,n)}subscriptionMap(t,e){const n=$A(t)?t:UA(t);return this.group(n.pipe(YA(t=>Object.keys(t)))).subscription(t=>n.pipe(YA(e=>e[t.url]),xO(eN)),e)}outboxSubscription(t,e,n){const r=$A(t)?t.pipe(YA(t=>uN(t,e))):uN(t,e);return this.subscriptionMap(r,n)}count(t,e,n){return this.group(t,!1).count(e,n)}sync(t,e,n,r){return this.group(t,!1).sync(e,n,r)}},Wj=a({default:()=>Hj}),Hj=class extends pp{pool=new Vj({enablePing:!0});async publish(t,e){if(!t||0===t.length)throw new Error("No relays provided to publish the event.");const n=await this.pool.publish(t,e);if(!n.some(t=>t.ok))throw new Error(`Failed to publish event. Responses: ${JSON.stringify(n)}`);return n}},Gj=class{},Kj=class extends Gj{constructor(t){super(),this.message=t}},Zj=class extends Gj{},Yj=class extends Gj{},Xj=class extends Gj{},Jj=class extends Gj{},Qj=class extends Gj{},tU=class extends Gj{},eU={invalid_request:class extends Gj{},invalid_grant:class extends Qj{},unauthorized_client:class extends Jj{},access_denied:class extends Jj{},unsupported_response_type:class extends Jj{},invalid_scope:class extends Gj{},server_error:class extends Jj{},temporarily_unavailable:class extends Jj{},invalid_client:class extends Qj{},unsupported_grant_type:class extends Qj{},invalid_token:class extends Gj{}},nU=t=>{const e=eU[t];return e?new e:new Kj(t)},rU="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",iU=t=>{const e=t.slice(7).replace(/"/g,"").split(",").map(t=>{const[e,n]=t.trim().split("=");return{[e]:n}}).reduce((t,e)=>({...t,...e}),{});return{realm:e.realm,error:e.error,errorDescription:e.error_description,errorUri:e.error_uri}},sU=t=>{let e=btoa(t);return e=e.replace(/\+/g,"-"),e=e.replace(/\//g,"_"),e=e.replace(/=/g,""),e},oU=(t,e)=>{let n=e.split("?");if(n.length<2)return;n=n[1].split("#");const r=n[0].split("&");for(const i of r){const[e,n]=i.split("=");if(e===t)return decodeURIComponent(n)}},aU=t=>Object.entries(t).map(([t,e])=>`${t}=${encodeURIComponent(e)}`).join("&"),lU="WWW-Authenticate",cU=class{constructor(t,e){this.state={},this.config=t,this.storage=e||hU,this.ready=new Promise(t=>this.setReady=t),this.recoverState()}async reset(){this.state={},await this.saveState(),this.authCodeForAccessTokenPromise=void 0,this.refreshTokenForAccessTokenPromise=void 0}async requestAuthorizationCode(t){const{clientId:e,extraAuthorizationParams:n,redirectUrl:r,scopes:i}=this.config,{codeChallenge:s,codeVerifier:o}=await(async()=>{const t=new Uint32Array(96);crypto.getRandomValues(t);const e=sU(Array.from(t).map(t=>rU[t%66]).join("")),n=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e)),r=new Uint8Array(n);let i="";const s=r.byteLength;for(let o=0;o{const t=new Uint32Array(32);return crypto.getRandomValues(t),Array.from(t).map(t=>rU[t%66]).join("")})();this.state={...this.state,codeChallenge:s,codeVerifier:o,stateQueryParam:a},await this.saveState();let l=this.config.authorizationUrl+`?response_type=code&client_id=${encodeURIComponent(e)}&redirect_uri=${encodeURIComponent(r)}&state=${a}&code_challenge=${encodeURIComponent(s)}&code_challenge_method=S256`;if(i&&(l+=`&scope=${encodeURIComponent(i.join(" "))}`),n||t){const e={...n,...t};l+=`&${aU(e)}`}location.replace(l)}isReturningFromAuthServer(){return!!oU("code",location.href)}async receiveCode(){await this.ready;const t=oU("error",location.href);if(t)throw nU(t);if(oU("state",location.href)!==this.state.stateQueryParam)throw console.warn('"state" parameter doesn\'t match the one sent! Possible malicious activity.'),new Xj;if(this.state.authorizationCode=oU("code",location.href),!this.state.authorizationCode)throw new Yj;this.saveState()}async getTokens(t){const{accessToken:e,authorizationCode:n,idToken:r,refreshToken:i,scopes:s}=this.state;if(n)return this.exchangeAuthCodeForAccessToken(t);if(!e)throw new Zj;if(this.isAccessTokenExpired()){if(this.config.onAccessTokenExpiry)return this.config.onAccessTokenExpiry();throw new tU}return Promise.resolve({accessToken:e,idToken:r,refreshToken:i,scopes:s})}async exchangeAuthCodeForAccessToken(t){this.authCodeForAccessTokenPromise||(this.authCodeForAccessTokenPromise=this.fetchAccessTokenUsingCode(t));const e=await this.authCodeForAccessTokenPromise;return this.authCodeForAccessTokenPromise=void 0,this.state.authorizationCode=void 0,this.setTokens(e)}async exchangeRefreshTokenForAccessToken(){this.refreshTokenForAccessTokenPromise||(this.refreshTokenForAccessTokenPromise=this.fetchAccessTokenUsingRefreshToken());const t=await this.refreshTokenForAccessTokenPromise;return this.refreshTokenForAccessTokenPromise=void 0,this.setTokens(t)}makeRetryFetchFunction(t){return async(e,...n)=>{const r=await t(e,...n);if(401===r.status){const i=r.headers.get(lU.toLowerCase());if(i&&"invalid_token"===iU(i).error)return await this.exchangeRefreshTokenForAccessToken(),e=await this.requestInterceptor(e),t(e,...n)}return r}}decorateFetchWithInterceptors(t){return async(e,...n)=>{"string"==typeof e&&(e=new Request(e)),e=await this.requestInterceptor(e);const r=await t(e,...n);return this.responseInterceptor(r)}}async requestInterceptor(t){const e=await this.getTokens();return t.headers.set("Authorization",`Bearer ${e.accessToken}`),t}async responseInterceptor(t){if(401!==t.status)return t;const e=t.headers.get(lU.toLowerCase());if(e){const t=iU(e).error;throw"invalid_grant"===t&&this.config.onInvalidGrant&&await this.config.onInvalidGrant(),"invalid_token"===t&&this.config.onInvalidToken&&await this.config.onInvalidToken(),nU(t)}return t}getGrantedScopes(){return this.state.scopes}isAuthorized(){return!!this.state.accessToken}isAccessTokenExpired(){const{accessTokenExpiry:t}=this.state;return Boolean(t&&new Date>=new Date(t))}async fetchAccessTokenUsingCode(t){const{authorizationCode:e,codeVerifier:n=""}=this.state,{clientId:r,redirectUrl:i}=this.config;n?e||console.warn("No authorization grant code is being passed."):console.warn("No code verifier is being sent.");const s=this.config.tokenUrl,o={grant_type:"authorization_code",code:e,redirect_uri:i,client_id:r,code_verifier:n,...t},a=new URLSearchParams(o).toString();return this.makeTokenRequest(s,a)}fetchAccessTokenUsingRefreshToken(){const{extraRefreshParams:t,clientId:e,tokenUrl:n}=this.config,{refreshToken:r}=this.state;r||console.warn("No refresh token is present.");const i=n;let s=`grant_type=refresh_token&refresh_token=${r}&client_id=${e}`;return t&&(s=`${s}&${aU(t)}`),this.makeTokenRequest(i,s)}async makeTokenRequest(t,e){const n=await fetch(t,{method:"POST",body:e,headers:{"Content-Type":"application/x-www-form-urlencoded"}}),r=await n.json();if(!n.ok)throw"invalid_grant"===r.error&&this.config.onInvalidGrant&&await this.config.onInvalidGrant(),nU(r.error);const{access_token:i,expires_in:s,id_token:o,refresh_token:a,scope:l}=r;return{accessToken:i,expiresIn:s,idToken:o,refreshToken:a,scope:l}}async setTokens(t){const{accessToken:e,expiresIn:n,idToken:r,refreshToken:i,scope:s}=t;return this.state.accessToken=e,n&&(this.state.accessTokenExpiry=new Date(Date.now()+1e3*parseInt(n,10)).toString()),r&&(this.state.idToken=r),i&&(this.state.refreshToken=i),s&&(this.state.scopes=s.split(" ")),await this.saveState(),{accessToken:this.state.accessToken,idToken:this.state.idToken,refreshToken:this.state.refreshToken,scopes:s?this.state.scopes:[]}}async recoverState(){this.state=JSON.parse(await this.storage.loadState()||"{}"),this.setReady(),this.config.storeRefreshToken||(this.state.refreshToken=this.refreshToken)}async saveState(){this.refreshToken=this.state.refreshToken;const t={...this.state};this.config.storeRefreshToken||delete t.refreshToken,await this.storage.saveState(JSON.stringify(t))}},uU="oauth2authcodepkce-state",hU={saveState:t=>localStorage.setItem(uU,t),loadState:()=>localStorage.getItem(uU)},dU=a({default:()=>fU}),pU=class{saveState(t){localStorage.setItem("marco:osm_auth_state",t)}loadState(){const t=localStorage.getItem("marco:osm_auth_state");if(!t)return!1;try{return JSON.parse(t),t}catch(e){return console.warn("Failed to parse OSM auth state",e),!1}}},fU=class extends pp{static{aF(this.prototype,"isConnected",[Vr],function(){return!1})}#yt=void cF(this,"isConnected");static{aF(this.prototype,"userDisplayName",[Vr],function(){return null})}#vt=void cF(this,"userDisplayName");oauthClient;constructor(){super(...arguments);const t="https://www.openstreetmap.org",e=`${window.location.origin}/oauth/osm/callback`;this.oauthClient=new cU({scopes:["read_prefs","write_api"],authorizationUrl:`${t}/oauth2/authorize`,tokenUrl:`${t}/oauth2/token`,clientId:"jIn8l5mT8FZOGYiIYXG1Yvj_2FZKB9TJ1edZwOJPsRU",redirectUrl:e,storeRefreshToken:!0,onAccessTokenExpiry(){return this.exchangeRefreshTokenForAccessToken()}},new pU),this.restoreSession()}async restoreSession(){try{await this.oauthClient.ready}catch(t){console.warn("oauthClient.ready failed",t)}if(await this.oauthClient.isAuthorized()){this.isConnected=!0;const t=localStorage.getItem("marco:osm_user_display_name");t?this.userDisplayName=t:await this.fetchUserInfo()}}async login(){await this.oauthClient.requestAuthorizationCode()}async handleCallback(){await this.oauthClient.receiveCode(),await this.oauthClient.getTokens(),this.isConnected=!0,await this.fetchUserInfo()}async logout(){await this.oauthClient.reset(),this.isConnected=!1,this.userDisplayName=null,localStorage.removeItem("marco:osm_user_display_name")}async fetchUserInfo(){try{const t=await this.oauthClient.getTokens(),e=await fetch("https://api.openstreetmap.org/api/0.6/user/details.json",{headers:{Authorization:`Bearer ${t.accessToken}`}});if(e.ok){const t=await e.json();console.debug("OSM data:",t);const n=t.user.display_name;this.userDisplayName=n,localStorage.setItem("marco:osm_user_display_name",n)}else console.error("Failed to fetch OSM user info",e.status)}catch(t){console.error("Error fetching OSM user info",t)}}},gU=a({capitalize:()=>yU,formatRelativeDate:()=>vU,humanizeOsmTag:()=>mU});function mU(t){return"string"==typeof t&&t?t.replace(/[_-]/g," ").replace(/\w\S*/g,t=>t.replace(/^\w/,t=>t.toUpperCase())):""}function yU(t){return"string"==typeof t&&t?t.charAt(0).toUpperCase()+t.slice(1):""}function vU(t){if(!t)return"";const e=new Date(1e3*t),n=new Date-e,r=Math.floor(n/6e4),i=Math.floor(r/60),s=Math.floor(i/24);return r<1?"just now":r<60?`${r} min ago`:i<24?`${i} hr ago`:s<7?`${s} day${1===s?"":"s"} ago`:e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}var bU=a({getLocalizedName:()=>wU,getPlaceType:()=>xU});function wU(t,e="Untitled Place"){if(!t)return e;const n=navigator.languages||[navigator.language||"en"];for(const r of n){if(!r)continue;const e=`name:${r.split("-")[0]}`;if(t[e])return t[e]}return t.name?t.name:t["name:en"]?t["name:en"]:e}var _U=["amenity","shop","tourism","historic","leisure","office","craft","building","landuse","public_transport","highway","aeroway","waterway","natural","place","border_type","admin_title"];function xU(t){if(!t)return null;let e=null;for(const n of _U){const r=t[n];if(r){if("yes"===r){e||(e=n);continue}return mU(r)}}return e?mU(e):null}var CU=a({POI_CATEGORIES:()=>SU,getCategoryById:()=>kU}),SU=[{id:"restaurants",label:"Restaurants",icon:"fork-and-knife",filter:['["amenity"~"^(restaurant|fast_food|food_court|pub|cafe)$"]["cuisine"!~"coffee"]'],types:["node","way"]},{id:"coffee",label:"Coffee",icon:"cup-and-saucer",filter:['["amenity"~"^(cafe|ice_cream)$"]','["shop"~"^(coffee|tea)$"]','["cuisine"~"coffee_shop"]'],types:["node","way"]},{id:"groceries",label:"Groceries",icon:"shopping-basket",filter:['["shop"~"^(supermarket|convenience|grocery|greengrocer|bakery|butcher|deli|farm|seafood)$"]'],types:["node","way"]},{id:"things-to-do",label:"Things to do",icon:"feather-camera",filter:['["tourism"~"^(museum|gallery|attraction|viewpoint|zoo|theme_park|aquarium|artwork|information)$"]','["amenity"~"^(cinema|theatre|arts_centre|planetarium)$"]','["leisure"~"^(sports_centre|stadium|water_park)$"]','["historic"]','["shop"="flea_market"]'],types:["node","way","relation"]},{id:"accommodation",label:"Hotels",icon:"person-sleeping-in-bed",filter:['["tourism"~"^(hotel|hostel|motel|chalet|guest_house)$"]'],types:["node","way","relation"]}];function kU(t){return SU.find(e=>e.id===t)}var EU,RU=a({default:()=>TU}),TU=class t extends pp{static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{aF(this.prototype,"localForage",[dp])}#$=void cF(this,"localForage");controller=null;cachedResults=null;lastQueryKey=null;cachedPlaces=new Map;static STORE_NAME="osm-cache";static CACHE_TTL_MS=6048e5;static IN_MEMORY_TTL_MS=1e4;_buildCacheKey(t,e){return`${t}:${e}`}async _readLocalCache(e,n){const r=this._buildCacheKey(e,n);try{const e=await this.localForage.get(t.STORE_NAME,r);if(!e)return null;const n="string"==typeof e?JSON.parse(e):e;return!n||"number"!=typeof n.timestamp||Date.now()-n.timestamp>t.CACHE_TTL_MS?(await this.localForage.remove(t.STORE_NAME,r),null):n.data}catch{try{await this.localForage.remove(t.STORE_NAME,r)}catch{}return null}}async _writeLocalCache(e,n,r){if(!r)return;const i=this._buildCacheKey(e,n);try{await this.localForage.set(t.STORE_NAME,i,{data:r,timestamp:Date.now()})}catch(s){console.debug("[osm] Failed to write IndexedDB cache entry",s)}}async getCachedOsmObject(e,n){if(!e||!n)return null;const r=this._buildCacheKey(e,n),i=this.cachedPlaces.get(r);return i&&Date.now()-i.timestamp{this.cachedPlaces.delete(e)},t.IN_MEMORY_TTL_MS),this._writeLocalCache(n,r,i)):console.debug(`[osm] Skipping cache write for ${e}: data has no title`)}cancelAll(){this.controller&&(this.controller.abort(),this.controller=null)}async getNearbyPois(t,e,n=50){const r=`${t},${e},${n}`;if(this.lastQueryKey===r&&this.cachedResults)return console.debug("Returning cached Overpass results for:",r),this.cachedResults;this.controller&&this.controller.abort(),this.controller=new AbortController;const i=this.controller.signal,s=[`~"^(${["amenity","shop","tourism","historic","leisure","office","craft","building","landuse","public_transport","aeroway"].join("|")})$"~".*"`],o=Object.entries({public_transport:["stop_area","platform"]}).map(([t,e])=>`["${t}"!~"^(${e.join("|")})$"]`).join(""),a=`\n[out:json][timeout:25];\n(\n node(around:${n},${t},${e})\n [${s}]${o}[~"^name"~"."];\n way(around:${n},${t},${e})\n [${s}]${o}[~"^name"~"."];\n relation(around:${n},${t},${e})\n [${s}]${o}[~"^name"~"."];\n);\nout center;\n `.trim(),l=`${this.settings.overpassApi}?data=${encodeURIComponent(a)}`;try{const t=await this.fetchWithRetry(l,{signal:i});if(!t.ok)throw new Error("Overpass request failed");const e=(await t.json()).elements.map(this.normalizePoi);return this.lastQueryKey=r,this.cachedResults=e,e}catch(c){if("AbortError"===c.name)return console.debug("Overpass request aborted"),[];throw c}}async getCategoryPois(t,e,n,r){const i=kU(e);if(!i||!t)return[];const s=n&&r?`cat:${e}:${n}:${r}`:null;if(s&&this.lastQueryKey===s&&this.cachedResults)return console.debug("Returning cached category results for:",s),this.cachedResults;this.controller&&this.controller.abort(),this.controller=new AbortController;const o=this.controller.signal,{minLat:a,minLon:l,maxLat:c,maxLon:u}=t,h=[],d=i.types||["node","way","relation"];i.filter.forEach(t=>{d.forEach(e=>{h.push(`${e}${t}[~"^name"~"."];`)})});const p=`\n[out:json][timeout:25][bbox:${a},${l},${c},${u}];\n(\n ${h.join("\n ")}\n);\nout center;\n `.trim(),f=`${this.settings.overpassApi}?data=${encodeURIComponent(p)}`;try{const t=await this.fetchWithRetry(f,{signal:o});if(!t.ok)throw new Error("Overpass request failed");const e=(await t.json()).elements.map(this.normalizePoi);return s&&(this.lastQueryKey=s,this.cachedResults=e),e}catch(g){if("AbortError"===g.name)return console.debug("Category search aborted"),[];throw console.error("Category search failed",g),g}}normalizePoi(t){const e=t.tags||{},n=xU(e)||"Point of Interest";return{title:wU(e),lat:t.lat||t.center?.lat,lon:t.lon||t.center?.lon,url:e.website,osmId:String(t.id),osmType:t.type,osmTags:e,description:e.description,source:"osm",type:n}}async fetchWithRetry(t,e={},n=3){try{const r=await fetch(t,e);return!r.ok&&n>0&&[502,503,504,429].includes(r.status)?(console.warn(`Overpass request failed with ${r.status}. Retrying... (${n} left)`),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1)):r}catch(r){if(n>0&&"AbortError"!==r.name)return console.debug(`Retrying Overpass request... (${n} left)`),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1);throw r}}async getPoiById(t,e=null){let n;n="node"===e?`[out:json][timeout:25];node(${t});out center;`:"way"===e?`[out:json][timeout:25];way(${t});out center;`:`\n[out:json][timeout:25];\n(\n node(${t});\n way(${t});\n);\nout center;\n `.trim();const r=`${this.settings.overpassApi}?data=${encodeURIComponent(n)}`,i=await this.fetchWithRetry(r);if(!i.ok)throw new Error("Overpass request failed");const s=await i.json();return s.elements[0]?this.normalizePoi(s.elements[0]):null}async fetchOsmObject(e,n,{forceFresh:r=!1}={}){if(!e||!n)return null;const i=this._buildCacheKey(n,e);if(r)return this._fetchAndCacheOsmObject(e,n,i);const s=this.cachedPlaces.get(i);if(s&&Date.now()-s.timestamp{console.debug("[osm] Background refresh failed for",i,t)}),o):this._fetchAndCacheOsmObject(e,n,i)}async _refreshOsmObject(t,e,n){const r=await this._fetchOsmObjectFromApi(t,e);return r&&this._storeInMemoryAndLocalStorage(n,e,t,r),r}async _fetchAndCacheOsmObject(t,e,n){const r=await this._fetchOsmObjectFromApi(t,e);return r&&this._storeInMemoryAndLocalStorage(n,e,t,r),r}async _fetchOsmObjectFromApi(t,e){let n;if("node"===e)n=`https://www.openstreetmap.org/api/0.6/node/${t}.json`;else if("way"===e)n=`https://www.openstreetmap.org/api/0.6/way/${t}/full.json`;else{if("relation"!==e)return console.error("Unknown OSM type:",e),null;n=`https://www.openstreetmap.org/api/0.6/relation/${t}/full.json`}try{const r=await this.fetchWithRetry(n);if(!r.ok){if(410===r.status)return console.warn("OSM object has been deleted"),null;throw new Error(`OSM API request failed: ${r.status}`)}const i=await r.json();return this.normalizeOsmApiData(i.elements,t,e)}catch(r){return console.error("Failed to fetch OSM object:",r),null}}async fetchOsmObjectsBatch(t){const e=new Map;if(!t||0===t.length)return e;const n=[];for(const{osmType:s,osmId:o}of t){if(!s||!o)continue;const t=this._buildCacheKey(s,o),r=await this.getCachedOsmObject(s,o);r?e.set(t,r):n.push({osmType:s,osmId:o,cacheKey:t})}if(0===n.length)return e;const r=new Map;for(const s of n)r.has(s.osmType)||r.set(s.osmType,[]),r.get(s.osmType).push(s);const i=[];for(const[s,o]of r)i.push(this._fetchOsmObjectsByType(s,o,e));return await Promise.allSettled(i),e}async _fetchOsmObjectsByType(t,e,n){for(let i=0;it.osmId).join(","),a="way"===t?"ways":t+"s",l=`https://www.openstreetmap.org/api/0.6/${a}.json?${a}=${o}`;try{const e=await this.fetchWithRetry(l);if(!e.ok){console.warn(`[osm] Batch fetch failed for ${t} (${e.status})`,o);continue}const r=await e.json();for(const i of s){const e=this.normalizeOsmApiData(r.elements,i.osmId,t);e&&n.set(i.cacheKey,e)}}catch(r){console.error(`[osm] Batch fetch error for ${t}:`,r)}}}normalizeOsmApiData(t,e,n){if(!t||0===t.length)return null;let r=t.find(t=>String(t.id)===String(e)&&t.type===n);if(!r)return null;let i=r;if("relation"===n&&r.members){const e=r.members.find(t=>"label"===t.role&&"node"===t.type),n=r.members.find(t=>"admin_centre"===t.role&&"node"===t.type),s=e||n;if(s){const e=t.find(t=>String(t.id)===String(s.ref)&&"node"===t.type);e&&(i=e)}}let s=i.lat,o=i.lon,a=null,l=null;if("way"===n&&r.nodes){const e=new Map;t.forEach(t=>{"node"===t.type&&e.set(t.id,[t.lon,t.lat])});const n=r.nodes.map(t=>e.get(t)).filter(Boolean);if(n.length>0){if(i===r){const t=n.reduce((t,e)=>t+e[1],0),e=n.reduce((t,e)=>t+e[0],0);s=t/n.length,o=e/n.length}const t=n.map(t=>t[1]),e=n.map(t=>t[0]);if(a={minLat:Math.min(...t),maxLat:Math.max(...t),minLon:Math.min(...e),maxLon:Math.max(...e)},n.length>1){const t=n[0],e=n[n.length-1];l=t[0]===e[0]&&t[1]===e[1]?{type:"Polygon",coordinates:[n]}:{type:"LineString",coordinates:n}}}}else if("relation"===n&&r.members){const e=[],n=new Map;t.forEach(t=>{"node"===t.type&&n.set(t.id,t)});const c=[];if(r.members.forEach(r=>{if("node"===r.type){const t=n.get(r.ref);t&&e.push(t)}else if("way"===r.type){const i=t.find(t=>"way"===t.type&&t.id===r.ref);if(i&&i.nodes){const t=[];i.nodes.forEach(r=>{const i=n.get(r);i&&(e.push(i),t.push([i.lon,i.lat]))}),t.length>1&&c.push(t)}}}),e.length>0){if(i===r){const t=e.reduce((t,e)=>t+e.lat,0),n=e.reduce((t,e)=>t+e.lon,0);s=t/e.length,o=n/e.length}const t=e.map(t=>t.lat),n=e.map(t=>t.lon);a={minLat:Math.min(...t),maxLat:Math.max(...t),minLon:Math.min(...n),maxLon:Math.max(...n)}}c.length>0&&(l={type:"MultiLineString",coordinates:c})}const c=i.tags||{},u=xU(c)||"Point of Interest";return{title:wU(c),lat:s,lon:o,bbox:a,geojson:l,url:c.website,osmId:String(i.id),osmType:i.type,osmTags:c,description:c.description,source:"osm",type:u}}},LU=a({default:()=>IU}),IU=class extends pp{static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");controller=null;cancelAll(){this.controller&&(this.controller.abort(),this.controller=null)}get baseUrl(){return this.settings.photonApi}async search(t,e,n,r=10){if(!t||t.length<2)return[];this.controller&&this.controller.abort(),this.controller=new AbortController;const i=this.controller.signal,s=new URLSearchParams({q:t,limit:String(r)});e&&n&&(s.append("lat",parseFloat(e).toFixed(4)),s.append("lon",parseFloat(n).toFixed(4)));const o=`${this.baseUrl}?${s.toString()}`;try{const t=await this.fetchWithRetry(o,{signal:i});if(!t.ok)throw new Error(`Photon request failed with status ${t.status}`);const e=await t.json();return e.features?e.features.map(t=>this.normalizeFeature(t)):[]}catch(a){return"AbortError"===a.name||console.error("Photon search error:",a),[]}}normalizeFeature(t){const e=t.properties||{},n=(t.geometry||{}).coordinates||[],r=n[0],i=n[1],s=[];e.street&&s.push(e.housenumber?`${e.street} ${e.housenumber}`:e.street),e.city&&e.city!==e.name&&s.push(e.city),e.state&&e.state!==e.city&&s.push(e.state),e.country&&s.push(e.country);const o=s.join(", "),a=e.name||o||"Unknown Place",l={...e};e.osm_key&&e.osm_value&&(l[e.osm_key]=e.osm_value);const c=xU(l)||mU(e.osm_value);return{title:a,lat:i,lon:r,osmId:e.osm_id,osmType:{N:"node",W:"way",R:"relation"}[e.osm_type]||e.osm_type,osmTags:l,description:e.name?o:s.slice(1).join(", "),source:"photon",type:c}}async fetchWithRetry(t,e={},n=3){try{const r=await fetch(t,e);return!r.ok&&n>0&&[502,503,504,429].includes(r.status)?(console.warn(`Photon request failed with ${r.status}. Retrying... (${n} left)`),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1)):r}catch(r){if(n>0&&"AbortError"!==r.name)return console.debug(`Retrying Photon request... (${n} left)`,r),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1);throw r}}},PU=a({default:()=>AU}),MU={overpassApi:"https://overpass-api.de/api/interpreter",mapKinetic:!0,photonApi:"https://photon.komoot.io/api/",showQuickSearchButtons:!0,nostrPhotoFallbackUploads:!1,nostrReadRelays:null,nostrWriteRelays:null,nostrReadRelayExclusions:null,nostrWriteRelayExclusions:null,experimentalEnablePhotoDeletion:!1},AU=class extends pp{static{aF(this.prototype,"overpassApi",[Vr],function(){return MU.overpassApi})}#bt=void cF(this,"overpassApi");static{aF(this.prototype,"mapKinetic",[Vr],function(){return MU.mapKinetic})}#wt=void cF(this,"mapKinetic");static{aF(this.prototype,"photonApi",[Vr],function(){return MU.photonApi})}#_t=void cF(this,"photonApi");static{aF(this.prototype,"showQuickSearchButtons",[Vr],function(){return MU.showQuickSearchButtons})}#xt=void cF(this,"showQuickSearchButtons");static{aF(this.prototype,"nostrPhotoFallbackUploads",[Vr],function(){return MU.nostrPhotoFallbackUploads})}#Ct=void cF(this,"nostrPhotoFallbackUploads");static{aF(this.prototype,"nostrReadRelays",[Vr],function(){return MU.nostrReadRelays})}#St=void cF(this,"nostrReadRelays");static{aF(this.prototype,"nostrWriteRelays",[Vr],function(){return MU.nostrWriteRelays})}#kt=void cF(this,"nostrWriteRelays");static{aF(this.prototype,"nostrReadRelayExclusions",[Vr],function(){return MU.nostrReadRelayExclusions})}#Et=void cF(this,"nostrReadRelayExclusions");static{aF(this.prototype,"nostrWriteRelayExclusions",[Vr],function(){return MU.nostrWriteRelayExclusions})}#Rt=void cF(this,"nostrWriteRelayExclusions");static{aF(this.prototype,"experimentalEnablePhotoDeletion",[Vr],function(){return MU.experimentalEnablePhotoDeletion})}#Tt=void cF(this,"experimentalEnablePhotoDeletion");overpassApis=[{name:"overpass-api.de (DE)",url:"https://overpass-api.de/api/interpreter"},{name:"private.coffee (AT)",url:"https://overpass.private.coffee/api/interpreter"}];photonApis=[{name:"photon.komoot.io",url:"https://photon.komoot.io/api/"}];constructor(){super(...arguments),this.loadSettings()}loadSettings(){let t={};const e=localStorage.getItem("marco:settings");if(e)try{t=JSON.parse(e)}catch(r){console.error("Failed to parse settings from localStorage",r)}else{const e=localStorage.getItem("marco:overpass-api");e&&(t.overpassApi=e);const n=localStorage.getItem("marco:map-kinetic");null!==n&&(t.mapKinetic="true"===n);const r=localStorage.getItem("marco:show-quick-search");null!==r&&(t.showQuickSearchButtons="true"===r);const i=localStorage.getItem("marco:nostr-photo-fallback-uploads");null!==i&&(t.nostrPhotoFallbackUploads="true"===i);const s=localStorage.getItem("marco:photon-api");s&&(t.photonApi=s)}const n={...MU,...t};this.overpassApis.some(t=>t.url===n.overpassApi)||(n.overpassApi=MU.overpassApi),this.overpassApi=n.overpassApi,this.mapKinetic=n.mapKinetic,this.photonApi=n.photonApi,this.showQuickSearchButtons=n.showQuickSearchButtons,this.nostrPhotoFallbackUploads=n.nostrPhotoFallbackUploads,this.nostrReadRelays=n.nostrReadRelays,this.nostrWriteRelays=n.nostrWriteRelays,this.nostrReadRelayExclusions=n.nostrReadRelayExclusions,this.nostrWriteRelayExclusions=n.nostrWriteRelayExclusions,this.experimentalEnablePhotoDeletion=n.experimentalEnablePhotoDeletion,this.saveSettings()}saveSettings(){const t={overpassApi:this.overpassApi,mapKinetic:this.mapKinetic,photonApi:this.photonApi,showQuickSearchButtons:this.showQuickSearchButtons,nostrPhotoFallbackUploads:this.nostrPhotoFallbackUploads,nostrReadRelays:this.nostrReadRelays,nostrWriteRelays:this.nostrWriteRelays,nostrReadRelayExclusions:this.nostrReadRelayExclusions,nostrWriteRelayExclusions:this.nostrWriteRelayExclusions,experimentalEnablePhotoDeletion:this.experimentalEnablePhotoDeletion};localStorage.setItem("marco:settings",JSON.stringify(t))}update(t,e){t in MU&&(this[t]=e,this.saveSettings())}},OU=o((t,e)=>{var n,r;n=t,r=function(){return function(){var t={548:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Access=void 0;class n{constructor(t){this.rs=t,this.reset(!1)}get scopes(){return Object.keys(this.scopeModeMap).map(t=>({name:t,mode:this.scopeModeMap[t]}))}get scopeParameter(){return this.scopes.map(t=>`${this._scopeNameForParameter(t)}:${t.mode}`).join(" ")}claim(t,e){if("string"!=typeof t||-1!==t.indexOf("/")||0===t.length)throw new Error("Scope should be a non-empty string without forward slashes");if("string"!=typeof e||!e.match(/^rw?$/))throw new Error("Mode should be either 'r' or 'rw'");this._adjustRootPaths(t),this.scopeModeMap[t]=e,this._notifyChange()}get(t){return this.scopeModeMap[t]}remove(t){const e={};for(const n in this.scopeModeMap)e[n]=this.scopeModeMap[n];this.reset(!1),delete e[t];for(const n in e)this._adjustRootPaths(n),this.scopeModeMap[n]=e[n];this._notifyChange()}checkPermission(t,e){const n=this.get(t);return n&&("r"===e||"rw"===n)}checkPathPermission(t,e){if(this.checkPermission("*",e))return!0;const n=this._getModuleName(t);return!!this.checkPermission(n,e)}reset(t=!0){this.rootPaths=[],this.scopeModeMap={},t&&this._notifyChange()}_getModuleName(t){if("/"!==t[0])throw new Error("Path should start with a slash");const e=t.replace(/^\/public/,"").match(/^\/([^/]*)\//);return e?e[1]:"*"}_adjustRootPaths(t){"*"in this.scopeModeMap||"*"===t?this.rootPaths=["/"]:t in this.scopeModeMap||(this.rootPaths.push("/"+t+"/"),this.rootPaths.push("/public/"+t+"/"))}_scopeNameForParameter(t){if("*"===t.name&&this.storageType){if("2012.04"===this.storageType)return"";if(this.storageType.match(/remotestorage-0[01]/))return"root"}return t.name}setStorageType(t){this.storageType=t}_notifyChange(){this.rs&&"function"==typeof this.rs._checkScopeChange&&this.rs._checkScopeChange()}static _rs_init(){}}e.Access=n,e.default=n},275:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Authorize=void 0;const s=i(n(28)),o=i(n(334)),a=n(746),l=i(n(503)),c=n(368);let u;function h(t){const e=t||d.getLocation().href,n={};for(const[s,o]of new URL(e).searchParams)n[s]=o;const r=e.indexOf("#");if(-1===r)return n;const i=e.substring(r+1);return i.includes("=")?i.split("&").reduce(function(t,e){const n=e.split("=");if("state"===n[0]&&n[1].match(/rsDiscovery/)){let e=decodeURIComponent(n[1]);const r=e.substr(e.indexOf("rsDiscovery=")).split("&")[0].split("=")[1];t.rsDiscovery=JSON.parse(atob(r)),e=e.replace(new RegExp("&?rsDiscovery="+r),""),e.length>0&&(t.state=e)}else t[decodeURIComponent(n[0])]=decodeURIComponent(n[1]);return t},n):n}class d{static authorize(t,e){if((0,o.default)("[Authorize] authURL = ",e.authURL,"scope = ",e.scope,"redirectUri = ",e.redirectUri,"clientId = ",e.clientId,"response_type =",e.response_type),!e.scope)throw new Error("Cannot authorize due to undefined or empty scope; did you forget to access.claim()?");if("function"==typeof t._rememberPendingScope&&t._rememberPendingScope(e.scope),!(0,a.localStorageAvailable)()&&"remotestorage"===t.backend){e.redirectUri+=e.redirectUri.indexOf("#")>0?"&":"#";const n={userAddress:t.remote.userAddress,href:t.remote.href,storageApi:t.remote.storageApi,properties:t.remote.properties};e.redirectUri+="rsDiscovery="+(0,a.toBase64)(JSON.stringify(n))}const n=function(t){const e=new URL(t.redirectUri);t.state||(t.state=e.hash?e.hash.substring(1):""),t.response_type||(t.response_type="token");const n=new URL(t.authURL);n.searchParams.set("redirect_uri",t.redirectUri.replace(/#.*$/,"")),n.searchParams.set("scope",t.scope),n.searchParams.set("client_id",t.clientId);for(const r of["state","response_type","code_challenge","code_challenge_method","token_access_type"]){const e=t[r];e&&n.searchParams.set(r,e)}return n.href}(e);a.globalContext.cordova&&(d.getLocation().href.startsWith("file:")||"string"==typeof s.default.cordovaRedirectUri&&e.redirectUri===s.default.cordovaRedirectUri)?d.openWindow(n,e.redirectUri,"location=yes,clearsessioncache=yes,clearcache=yes").then(n=>{t.remote.configure({token:n.access_token}),"function"==typeof t._completeAuthorization&&t._completeAuthorization(n.scope||e.scope)}):d.setLocation(n)}static refreshAccessToken(t,e,n){return r(this,void 0,void 0,function*(){var t,r,i;yield e.configure({token:null,tokenType:null});const s=new URLSearchParams({grant_type:"refresh_token",client_id:e.clientId,refresh_token:n}),a=yield(0,c.requestWithTimeout)("POST",e.TOKEN_URL,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString(),responseType:"json"});if(200!==(null==a?void 0:a.status))throw yield e.configure({refreshToken:null}),new l.default("refresh token rejected:"+JSON.stringify(a.response));{(0,o.default)(`[Authorize] access token good for ${null===(t=null==a?void 0:a.response)||void 0===t?void 0:t.expires_in} seconds`);const n={token:null===(r=null==a?void 0:a.response)||void 0===r?void 0:r.access_token,tokenType:null===(i=null==a?void 0:a.response)||void 0===i?void 0:i.token_type};if(!n.token)throw new Error(`no access_token in "successful" refresh: ${a.response}`);yield e.configure(n)}})}static setLocation(t){if("string"==typeof t)document.location.href=t;else{if("object"!=typeof t)throw"Invalid location "+t;document.location.href=t.href}}static _rs_supported(){return"undefined"!=typeof document}static _rs_cleanup(t){t.removeEventListener("features-loaded",u)}}e.Authorize=d,d.IMPLIED_FAKE_TOKEN=!1,d.getLocation=function(){return document.location},d.openWindow=function(t,e,n){return new Promise((r,i)=>{const s=open(t,"_blank",n);function o(){i("Authorization was canceled")}s&&!s.closed?(s.addEventListener("loadstart",function(t){if(0!==t.url.indexOf(e))return;s.removeEventListener("exit",o),s.close();const n=h(t.url);n?r(n):i("Authorization error")}),s.addEventListener("exit",o)):i("Authorization popup was blocked")})},d._rs_init=function(t){const e=h(),n=function(t){return"string"==typeof t.access_token||"string"==typeof t.code||"string"==typeof t.error||"string"==typeof t.remotestorage||"object"==typeof t.rsDiscovery}(e);let i;n&&(i=d.getLocation(),i.hash=""),u=function(){let s=!1;if(n){if(e.error)throw"function"==typeof t._forgetPendingScope&&t._forgetPendingScope(),"access_denied"===e.error?new l.default("Authorization failed: access denied",{code:"access_denied"}):new l.default(`Authorization failed: ${e.error}`);e.rsDiscovery&&t.remote.configure(e.rsDiscovery),e.access_token&&(t.remote.configure({token:e.access_token}),"function"==typeof t._completeAuthorization&&t._completeAuthorization(e.scope),s=!0),e.remotestorage&&(t.connect(e.remotestorage),s=!0),e.state&&(i=d.getLocation(),d.setLocation(i.href.split("#")[0]+"#"+e.state)),e.code&&(function(e){r(this,void 0,void 0,function*(){var n,r,s,a,l;const u=sessionStorage.getItem("remotestorage:codeVerifier");if(!u)return void(0,o.default)("[Authorize] Ignoring OAuth code parameter, because no PKCE code verifier found in sessionStorage");i=d.getLocation();let h=i.origin;"/"!==i.pathname&&(h+=i.pathname);const p=new URLSearchParams({code:e,grant_type:"authorization_code",client_id:t.remote.clientId,redirect_uri:h,code_verifier:u}),f=yield(0,c.requestWithTimeout)("POST",t.remote.TOKEN_URL,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:p.toString(),responseType:"json"});switch(f.status){case 200:{(0,o.default)(`[Authorize] access token good for ${null===(n=null==f?void 0:f.response)||void 0===n?void 0:n.expires_in} seconds`);const e={token:null===(r=null==f?void 0:f.response)||void 0===r?void 0:r.access_token,refreshToken:null===(s=null==f?void 0:f.response)||void 0===s?void 0:s.refresh_token,tokenType:null===(a=null==f?void 0:f.response)||void 0===a?void 0:a.token_type};e.token?(t.remote.configure(e),"function"==typeof t._completeAuthorization&&t._completeAuthorization(null===(l=null==f?void 0:f.response)||void 0===l?void 0:l.scope)):t._emit("error",new Error(`no access_token in "successful" response: ${f.response}`)),sessionStorage.removeItem("remotestorage:codeVerifier");break}default:"function"==typeof t._forgetPendingScope&&t._forgetPendingScope(),t._emit("error",new Error(`${f.statusText}: ${f.response}`))}})}(e.code),s=!0),s||t.remote.stopWaitingForToken()}else t.remote.stopWaitingForToken()},t.on("features-loaded",u)},e.default=d},424:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.BaseClient=void 0;const s=i(n(439)),o=i(n(613)),a=i(n(491)),l=i(n(93)),c=i(n(28)),u=n(746);class h{constructor(t,e){if(this.schemas={configurable:!0,get(){return h.Types.inScope(this.moduleName)}},"/"!==e[e.length-1])throw"Not a folder: "+e;"/"===e&&(this.makePath=t=>("/"===t[0]?"":"/")+t),this.storage=t,this.base=e,this.moduleName=function(t){const e=t.split("/");return t.length>2?e[1]:"root"}(this.base),this.addEvents(["change"]),this.on=this.on.bind(this),t.onChange(this.base,this._fireChange.bind(this))}scope(t){return new h(this.storage,this.makePath(t))}getListing(t,e){return r(this,void 0,void 0,function*(){if("string"!=typeof t)t="";else if(t.length>0&&!(0,u.isFolder)(t))return Promise.reject("Not a folder: "+t);return this.storage.get(this.makePath(t),e).then(t=>404===t.statusCode?{}:t.body)})}getAll(t,e){return r(this,void 0,void 0,function*(){if("string"!=typeof t)t="";else if(t.length>0&&!(0,u.isFolder)(t))return Promise.reject("Not a folder: "+t);return this.storage.get(this.makePath(t),e).then(n=>{if(404===n.statusCode)return{};if("object"==typeof n.body){const r=Object.keys(n.body);if(0===r.length)return{};const i=r.map(r=>this.storage.get(this.makePath(t+r),e).then(t=>{if("string"==typeof t.body)try{t.body=JSON.parse(t.body)}catch(t){}"object"==typeof t.body&&(n.body[r]=t.body)}));return Promise.all(i).then(()=>n.body)}})})}getFile(t,e){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.getFile must be a string"):this.storage.get(this.makePath(t),e).then(t=>({data:t.body,contentType:t.contentType,revision:t.revision}))})}storeFile(t,e,n){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'contentType' of baseClient.storeFile must be a string"):"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.storeFile must be a string"):"string"!=typeof n&&"object"!=typeof n?Promise.reject("Argument 'body' of baseClient.storeFile must be a string, ArrayBuffer, or ArrayBufferView"):(this.storage.access.checkPathPermission(this.makePath(e),"rw")||console.warn("WARNING: Editing a document to which only read access ('r') was claimed"),this.storage.put(this.makePath(e),n,t).then(t=>200===t.statusCode||201===t.statusCode?t.revision:Promise.reject("Request (PUT "+this.makePath(e)+") failed with status: "+t.statusCode)))})}getObject(t,e){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.getObject must be a string"):this.storage.get(this.makePath(t),e).then(e=>{if("object"==typeof e.body)return e.body;if("string"==typeof e.body)try{return JSON.parse(e.body)}catch(e){throw new Error("Not valid JSON: "+this.makePath(t))}else if(void 0!==e.body&&200===e.statusCode)return Promise.reject("Not an object: "+this.makePath(t))})})}storeObject(t,e,n){return r(this,void 0,void 0,function*(){if("string"!=typeof t)return Promise.reject("Argument 'typeAlias' of baseClient.storeObject must be a string");if("string"!=typeof e)return Promise.reject("Argument 'path' of baseClient.storeObject must be a string");if("object"!=typeof n)return Promise.reject("Argument 'object' of baseClient.storeObject must be an object");this._attachType(n,t);try{const t=this.validate(n);if(!t.valid)return Promise.reject(t)}catch(t){return Promise.reject(t)}return this.storage.put(this.makePath(e),JSON.stringify(n),"application/json; charset=UTF-8").then(t=>200===t.statusCode||201===t.statusCode?t.revision:Promise.reject("Request (PUT "+this.makePath(e)+") failed with status: "+t.statusCode))})}remove(t){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.remove must be a string"):(this.storage.access.checkPathPermission(this.makePath(t),"rw")||console.warn("WARNING: Removing a document to which only read access ('r') was claimed"),this.storage.delete(this.makePath(t),this.storage.connected))})}getItemURL(t){return r(this,void 0,void 0,function*(){if("string"!=typeof t)throw"Argument 'path' of baseClient.getItemURL must be a string";if(this.storage.connected)return"function"==typeof this.storage.remote.getItemURL?this.storage.remote.getItemURL(this.makePath(t)):this.storage.remote.href+(0,u.cleanPath)(this.makePath(t))})}cache(t,e="ALL"){if("string"!=typeof t)throw"Argument 'path' of baseClient.cache must be a string";if("string"!=typeof e)throw"Argument 'strategy' of baseClient.cache must be a string or undefined";if("FLUSH"!==e&&"SEEN"!==e&&"ALL"!==e)throw'Argument \'strategy\' of baseclient.cache must be one of ["FLUSH", "SEEN", "ALL"]';return this.storage.caching.set(this.makePath(t),e),this}declareType(t,e,n){let r;if(n&&"string"==typeof e)r=e;else if(n||"string"==typeof e){if(!n&&"string"==typeof e)throw new Error("declareType() requires a JSON Schema object to be passed, in order to validate object types/formats")}else n=e,r=this._defaultTypeURI(t);h.Types.declare(this.moduleName,t,r,n)}validate(t){const e=h.Types.getSchema(t["@context"]);if(e)return s.default.validateResult(t,e);throw new a.default(t["@context"])}_defaultTypeURI(t){return"http://remotestorage.io/spec/modules/"+encodeURIComponent(this.moduleName)+"/"+encodeURIComponent(t)}_attachType(t,e){t["@context"]=h.Types.resolveAlias(this.moduleName+"/"+e)||this._defaultTypeURI(e)}makePath(t){return this.base+(t||"")}_fireChange(t){c.default.changeEvents[t.origin]&&(["new","old","lastCommon"].forEach(function(e){if((!t[e+"ContentType"]||/^application\/(.*)json(.*)/.exec(t[e+"ContentType"]))&&"string"==typeof t[e+"Value"])try{t[e+"Value"]=JSON.parse(t[e+"Value"])}catch(t){}}),this._emit("change",t))}static _rs_init(){}}e.BaseClient=h,h.Types=o.default,(0,u.applyMixins)(h,[l.default]),e.default=h},285:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Caching=void 0;const i=n(746),s=r(n(334));class o{constructor(t){this.pendingActivations=[],this._access=t.access,this.reset()}set(t,e){if("string"!=typeof t)throw new Error("path should be a string");if(!(0,i.isFolder)(t))throw new Error("path should be a folder");if(!this._access.checkPathPermission(t,"r"))throw new Error('No access to path "'+t+'". You must claim access to it first.');if(void 0===e||!e.match(/^(FLUSH|SEEN|ALL)$/))throw new Error("strategy should be 'FLUSH', 'SEEN', or 'ALL'");this._rootPaths[t]=e,"ALL"===e&&(this.activateHandler?this.activateHandler(t):this.pendingActivations.push(t))}enable(t){this.set(t,"ALL")}disable(t){this.set(t,"FLUSH")}onActivate(t){(0,s.default)("[Caching] Setting activate handler",t,this.pendingActivations),this.activateHandler=t;for(let e=0;e{this.emitChange(t.data)})}get(t,e,n){return r(this,void 0,void 0,function*(){return"number"==typeof e?this.getNodes((0,c.pathsFromRoot)(t)).then(r=>{const i=u(r[t]);return h(r,e)?n(t):i?{statusCode:200,body:i.body||i.itemsMap,contentType:(0,c.stripLegacyCharsetBinary)(i.contentType||null)}:{statusCode:404}}):this.getNodes([t]).then(e=>{const n=u(e[t]);if(n){if((0,c.isFolder)(t))for(const t in n.itemsMap)n.itemsMap.hasOwnProperty(t)&&!1===n.itemsMap[t]&&delete n.itemsMap[t];return{statusCode:200,body:n.body||n.itemsMap,contentType:(0,c.stripLegacyCharsetBinary)(n.contentType||null)}}return{statusCode:404}})})}put(t,e,n){return r(this,void 0,void 0,function*(){const r=(0,c.pathsFromRoot)(t);return this._updateNodes(r,function(t,r){try{for(let i=0,s=t.length;i0)break}else console.error("Cannot delete non-existing node "+i)}return n})})}flush(t){return this._getAllDescendentPaths(t).then(t=>this.getNodes(t)).then(t=>{for(const e in t){const n=t[e];n&&n.common&&n.local&&this.emitChange({path:n.path,origin:"local",oldValue:!1===n.local.body?void 0:n.local.body,newValue:!1===n.common.body?void 0:n.common.body}),t[e]=void 0}return this.setNodes(t)})}emitChange(t){a.default.changeEvents[t.origin]&&this._emit("change",t)}fireInitial(){a.default.changeEvents.local&&this.forAllNodes(t=>{if((0,c.isDocument)(t.path)){const e=u(t);e&&this.emitChange({path:t.path,origin:"local",oldValue:void 0,oldContentType:void 0,newValue:e.body,newContentType:e.contentType})}}).then(()=>{this._emit("local-events-done")})}onDiff(t){this.diffHandler=t}_updateNodes(t,e){return new Promise((n,r)=>{this._doUpdateNodes(t,e,{resolve:n,reject:r})})}_doUpdateNodes(t,e,n){return r(this,void 0,void 0,function*(){if(this._updateNodesRunning)return void this._updateNodesQueued.push({paths:t,cb:e,promise:n});this._updateNodesRunning=!0;try{let r=yield this.getNodes(t);const i=(0,c.deepClone)(r),s=[];r=e(t,r);for(const t in r){const e=r[t];(0,c.equal)(e,i[t])?delete r[t]:(0,c.isDocument)(t)&&((0,c.equal)(e.local.body,e.local.previousBody)&&e.local.contentType===e.local.previousContentType||s.push({path:t,origin:"window",oldValue:e.local.previousBody,newValue:!1===e.local.body?void 0:e.local.body,oldContentType:e.local.previousContentType,newContentType:e.local.contentType}),void 0===e.local.body?r[t]=void 0:(delete e.local.previousBody,delete e.local.previousContentType))}yield this.setNodes(r),this._emitChangeEvents(s),n.resolve({statusCode:200})}catch(t){n.reject(t)}this._updateNodesRunning=!1;const r=this._updateNodesQueued.shift();r&&(yield this._doUpdateNodes(r.paths,r.cb,r.promise))})}_emitChangeEvents(t){for(let e=0,n=t.length;e{const n=[t],r=u(e[t]),i=Object.keys(r.itemsMap).map(e=>this._getAllDescendentPaths(t+e).then(t=>{for(let e=0,r=t.length;en)}):Promise.resolve([t])}_getInternals(){return{getLatest:u,makeNode:d,isOutdated:h}}}(0,c.applyMixins)(f,[o.default]),t.exports=f},28:function(t){t.exports={cache:!0,changeEvents:{local:!0,window:!1,remote:!0,conflict:!0},cordovaRedirectUri:void 0,discovery:{allowPrivateAddresses:!0,timeout:5e3},logging:!1,modules:[],backgroundSyncInterval:6e4,disableFeatures:[],isBackground:!1,requestTimeout:3e4,syncInterval:1e4}},373:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(713)),s=r(n(28)),o=r(n(334)),a=n(746);let l;const c="remotestorage:discover";let u={};const h=function(t){if(t in u)return Promise.resolve(u[t]);const e=new i.default({tls_only:!1,uri_fallback:!0,request_timeout:s.default.discovery.timeout,allow_private_addresses:s.default.discovery.allowPrivateAddresses});let n;const r=new Promise((t,e)=>{n=setTimeout(()=>{e(new Error("timed out"))},s.default.discovery.timeout)});return Promise.race([e.lookup(t),r]).then(e=>{if(clearTimeout(n),"object"!=typeof e.idx.links.remotestorage||"number"!=typeof e.idx.links.remotestorage.length||e.idx.links.remotestorage.length<=0)throw(0,o.default)("[Discover] WebFinger record for "+t+" does not have remotestorage defined in the links section ",JSON.stringify(e.object)),new Error("WebFinger record for "+t+" does not have remotestorage defined in the links section.");const r=e.idx.links.remotestorage[0],i=r.properties||{},s=i["http://tools.ietf.org/html/rfc6749#section-4.2"]||i["auth-endpoint"],a=i["http://remotestorage.io/spec/version"]||r.type;return u[t]={href:r.href,storageApi:a,authURL:s,properties:i},l&&localStorage.setItem(c,JSON.stringify({cache:u})),u[t]}).catch(t=>{throw clearTimeout(n),t})};(h.DiscoveryError=function(t){this.name="DiscoveryError",this.message=t,this.stack=(new Error).stack}).prototype=Object.create(Error.prototype),h.DiscoveryError.prototype.constructor=h.DiscoveryError,h._rs_init=function(){if(l=(0,a.localStorageAvailable)(),l){const t=JSON.parse(localStorage.getItem(c));t&&(u=t.cache)}},h._rs_supported=function(){return Object.prototype.hasOwnProperty.call(a.globalContext,"fetch")||Object.prototype.hasOwnProperty.call(a.globalContext,"XMLHttpRequest")},h._rs_cleanup=function(){l&&localStorage.removeItem(c)},t.exports=h},706:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const s=i(n(93)),o=i(n(941)),a=i(n(982)),l=i(n(503)),c=n(746),u=n(368),h=n(684),d=i(n(275));let p;const f="remotestorage:dropbox",g="https://api.dropboxapi.com/2/files/list_folder",m="https://api.dropboxapi.com/2/files/list_folder/continue";function y(t){return("/remotestorage/"+t).replace(/\/+$/,"").replace(/\/+/g,"/")}const v=/[\u007f-\uffff]/g;function b(t){return JSON.stringify(t).replace(v,function(t){return"\\u"+("000"+t.charCodeAt(0).toString(16)).slice(-4)})}function w(t,e){return new RegExp("^"+e.join("\\/")+"(\\/|$)").test(t.error_summary)}class _ extends h.RemoteBase{constructor(t){if(super(t),this.online=!0,this.storageApi="draft-dejong-remotestorage-19",this._initialFetchDone=!1,this.addEvents(["connected","not-connected"]),this.clientId=t.apiKeys.dropbox.appKey,this.TOKEN_URL="https://api.dropboxapi.com/oauth2/token",this._revCache=new o.default("rev"),this._fetchDeltaCursor=null,this._fetchDeltaPromise=null,this._itemRefs={},p=(0,c.localStorageAvailable)(),p){const t=(0,c.getJSONFromLocalStorage)(f);t&&this.configure(t),this._itemRefs=(0,c.getJSONFromLocalStorage)(`${f}:shares`)||{}}this.connected&&setTimeout(this._emit.bind(this),0,"connected")}connect(){return r(this,void 0,void 0,function*(){try{if(this.rs.setBackend("dropbox"),this.token)S(this.rs);else{const{codeVerifier:t,codeChallenge:e,state:n}=yield(0,c.generateCodeVerifier)();sessionStorage.setItem("remotestorage:codeVerifier",t),sessionStorage.setItem("remotestorage:state",n),this.rs.authorize({authURL:"https://www.dropbox.com/oauth2/authorize",scope:"account_info.read files.content.read files.content.write files.metadata.read files.metadata.write sharing.read sharing.write",clientId:this.clientId,response_type:"code",state:n,code_challenge:e,code_challenge_method:"S256",token_access_type:"offline"})}}catch(t){throw this.rs._emit("error",t),this.rs.setBackend(void 0),t}})}configure(t){return r(this,void 0,void 0,function*(){void 0!==t.userAddress&&(this.userAddress=t.userAddress),void 0!==t.token&&(this.token=t.token),void 0!==t.refreshToken&&(this.refreshToken=t.refreshToken),void 0!==t.tokenType&&(this.tokenType=t.tokenType);const e=()=>{p&&localStorage.setItem(f,JSON.stringify({userAddress:this.userAddress,token:this.token,refreshToken:this.refreshToken,tokenType:this.tokenType}))};if(this.refreshToken||this.token)if(this.connected=!0,this.userAddress)this._emit("connected"),e();else try{const t=yield this.info();this.userAddress=t.email,this._emit("connected"),e()}catch(t){this.connected=!1,this.rs._emit("error",new Error("Could not fetch user info.")),e.apply(this)}else(()=>{this.connected=!1,p&&(localStorage.removeItem(f),localStorage.removeItem(`${f}:shares`)),this.rs.setBackend(void 0)})()})}_getFolder(t){const e=this._revCache,n=n=>{let i;if(200!==n.status&&409!==n.status)return Promise.reject("Unexpected response status: "+n.status);try{i=JSON.parse(n.responseText)}catch(t){return Promise.reject(t)}if(409===n.status)return w(i,["path","not_found"])?Promise.resolve({}):Promise.reject(new Error("API returned an error: "+i.error_summary));const s=i.entries.reduce((n,r)=>{try{const i="folder"===r[".tag"],s=r.path_display.split("/").slice(-1)[0]+(i?"/":"");if(i)n[s]={ETag:e.get(t+s)};else{const e=new Date(r.server_modified);n[s]={ETag:r.rev,"Content-Length":r.size,"Last-Modified":e.toUTCString()},this._revCache.set(t+s,r.rev)}}catch(e){console.error(`[Dropbox] folder “${t}” has entry ${JSON.stringify(r)}:`,e)}return n},{});return i.has_more?r(i.cursor).then(function(t){return Object.assign(s,t)}):Promise.resolve(s)},r=t=>{const e={body:{cursor:t}};return this._request("POST",m,e).then(n)};return this._request("POST",g,{body:{path:y(t)}}).then(n).then(function(n){return Promise.resolve({statusCode:200,body:n,contentType:"application/json; charset=UTF-8",revision:e.get(t)})})}get(t,e={}){if(!this.connected)return Promise.reject("not connected (path: "+t+")");const n=this._revCache.get(t);if(null===n)return Promise.resolve({statusCode:404});if(e&&e.ifNoneMatch){if(!this._initialFetchDone)return this.fetchDelta().then(()=>this.get(t,e));if(n&&n===e.ifNoneMatch)return Promise.resolve({statusCode:304})}if("/"===t.slice(-1))return this._getFolder(t);const r={headers:{"Dropbox-API-Arg":b({path:y(t)})},responseType:"arraybuffer"};return e&&e.ifNoneMatch&&(r.headers["If-None-Match"]=e.ifNoneMatch),this._request("GET","https://content.dropboxapi.com/2/files/download",r).then(e=>{const n=e.status;let r,i,s,o;return 200!==n&&409!==n?Promise.resolve({statusCode:n}):(r=e.getResponseHeader("Dropbox-API-Result"),(0,c.getTextFromArrayBuffer)(e.response,"UTF-8").then(a=>{i=a,409===n&&(r=i);try{r=JSON.parse(r)}catch(t){return Promise.reject(t)}if(409===n)return w(r,["path","not_found"])?{statusCode:404}:Promise.reject(new Error('API error while downloading file ("'+t+'"): '+r.error_summary));if(s=e.getResponseHeader("Content-Type"),o=r.rev,this._revCache.set(t,o),this._shareIfNeeded(t),(0,c.shouldBeTreatedAsBinary)(a,s))i=e.response;else try{i=JSON.parse(i),s="application/json; charset=UTF-8"}catch(t){}return{statusCode:n,body:i,contentType:(0,c.stripLegacyCharsetBinary)(s),revision:o}}))})}put(t,e,n){return r(this,arguments,void 0,function*(t,e,n,r={}){if(!this.connected)throw new Error("not connected (path: "+t+")");const i=this._revCache.get(t);if(r&&r.ifMatch&&i&&i!==r.ifMatch)return{statusCode:412,revision:i};if(r&&"*"===r.ifNoneMatch&&i&&"rev"!==i)return{statusCode:412,revision:i};if(e.length>157286400)throw new Error("Cannot upload file larger than 150MB");const s={body:e,contentType:n,path:t};if(r&&(r.ifMatch||"*"===r.ifNoneMatch)){const e=yield this._getMetadata(t);if(r&&"*"===r.ifNoneMatch&&e)return{statusCode:412,revision:e.rev};if(r&&r.ifMatch&&e&&e.rev!==r.ifMatch)return{statusCode:412,revision:e.rev}}const o=yield this._uploadSimple(s);return this._shareIfNeeded(t),o})}delete(t){return r(this,arguments,void 0,function*(t,e={}){if(!this.connected)throw new Error("not connected (path: "+t+")");const n=this._revCache.get(t);if((null==e?void 0:e.ifMatch)&&n&&e.ifMatch!==n)return{statusCode:412,revision:n};if(null==e?void 0:e.ifMatch){const n=yield this._getMetadata(t);if((null==e?void 0:e.ifMatch)&&n&&n.rev!==e.ifMatch)return{statusCode:412,revision:n.rev}}return this._deleteSimple(t)})}_shareIfNeeded(t){if(t.match(/^\/public\/.*[^/]$/)&&void 0===this._itemRefs[t])return this.share(t)}getItemURL(t){return r(this,void 0,void 0,function*(){if(t.match(/^\/public\/.*[^/]$/))return this._itemRefs[t]?this._itemRefs[t]:this.share(t)})}share(t){const e={body:{path:y(t)}};return this._request("POST","https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings",e).then(e=>{if(200!==e.status&&409!==e.status)return Promise.reject(new Error("Invalid response status:"+e.status));let n;try{n=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid response body: "+e.responseText))}return 409===e.status?w(n,["shared_link_already_exists"])?this._getSharedLink(t):Promise.reject(new Error("API error: "+n.error_summary)):Promise.resolve(n.url)}).then(e=>(this._itemRefs[t]=e,p&&localStorage.setItem("remotestorage:dropbox:shares",JSON.stringify(this._itemRefs)),Promise.resolve(e)),e=>(e.message='Sharing Dropbox file or folder ("'+t+'") failed: '+e.message,Promise.reject(e)))}info(){return this._request("POST","https://api.dropboxapi.com/2/users/get_current_account",{}).then(function(t){let e;try{const n=JSON.parse(t.responseText);e=null==n?void 0:n.email}catch(e){return Promise.reject(new Error("Could not query current account info: Invalid API response: "+t.responseText))}return Promise.resolve({email:e})})}_request(t,e,n){return r(this,arguments,void 0,function*(t,e,n,r=1){if(this.isForbiddenRequestMethod(t,e))throw`Don't use ${t} on directories!`;if(!this.token)throw new l.default("No access token");var i;n.headers||(n.headers={}),n.headers.Authorization="Bearer "+this.token,"object"!=typeof n.body||(i=n.body)instanceof ArrayBuffer||(0,u.isArrayBufferView)(i)||(n.body=JSON.stringify(n.body),n.headers["Content-Type"]="application/json; charset=UTF-8"),this.rs._emit("wire-busy",{method:t,isFolder:(0,c.isFolder)(e)});try{const i=yield(0,u.requestWithTimeout)(t,e,n);return this.online||(this.online=!0,this.rs._emit("network-online")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!0}),401===(null==i?void 0:i.status)&&this.refreshToken?r>=3?(console.error(`Abandoned after ${r} attempts: ${t} ${e}`),i):(this.rs._emit("wire-busy",{method:t,isFolder:(0,c.isFolder)(e)}),yield d.default.refreshAccessToken(this.rs,this,this.refreshToken),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!0}),this._request(t,e,n,r+1)):[503,429].includes(null==i?void 0:i.status)?(this.online&&(this.online=!1,this.rs._emit("network-offline")),r>=3?(console.warn(`Abandoned after ${r} attempts: ${t} ${e}`),i):(yield new Promise(t=>setTimeout(t,(0,u.retryAfterMs)(i))),this._request(t,e,n,r+1))):i}catch(n){throw this.online&&(this.online=!1,this.rs._emit("network-offline")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!1}),n}})}fetchDelta(...t){if(this._fetchDeltaPromise)return this._fetchDeltaPromise;const e=t=>r(this,void 0,void 0,function*(){let n,r;"string"==typeof t?(n=m,r={cursor:t}):(n=g,r={path:"/remotestorage",recursive:!0,include_deleted:!0});try{const i=yield this._request("POST",n,{body:r});if(401===i.status)throw new l.default;if(200!==i.status&&409!==i.status)throw new Error("Invalid response status: "+i.status);let s;try{s=JSON.parse(i.responseText)}catch(t){throw new Error("Invalid response body: "+i.responseText)}if(409===i.status){if(!w(s,["path","not_found"]))throw new Error("API returned an error: "+s.error_summary);s={cursor:null,entries:[],has_more:!1}}if(t||this._revCache.deactivatePropagation(),s.entries.forEach(t=>{const e=t.path_display.slice(14);"deleted"===t[".tag"]?(this._revCache.delete(e),this._revCache.delete(e+"/")):"file"===t[".tag"]&&this._revCache.set(e,t.rev)}),this._fetchDeltaCursor=s.cursor,s.has_more)return e(s.cursor);this._revCache.activatePropagation(),this._initialFetchDone=!0}catch(t){if("timeout"===t)return;throw t}});return this._fetchDeltaPromise=e(this._fetchDeltaCursor).catch(t=>("object"==typeof t&&"message"in t?t.message="Dropbox: fetchDelta: "+t.message:t=`Dropbox: fetchDelta: ${t}`,this.rs._emit("error",t),this._fetchDeltaPromise=null,Promise.reject(t))).then(()=>(this._fetchDeltaPromise=null,Promise.resolve(t))),this._fetchDeltaPromise}_getMetadata(t){const e={path:y(t)};return this._request("POST","https://api.dropboxapi.com/2/files/get_metadata",{body:e}).then(t=>{if(200!==t.status&&409!==t.status)return Promise.reject(new Error("Invalid response status:"+t.status));let e;try{e=JSON.parse(t.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+t.responseText))}return 409===t.status?w(e,["path","not_found"])?Promise.resolve():Promise.reject(new Error("API error: "+e.error_summary)):Promise.resolve(e)}).then(void 0,e=>(e.message='Could not load metadata for file or folder ("'+t+'"): '+e.message,Promise.reject(e)))}_uploadSimple(t){const e={path:y(t.path),mode:{".tag":"overwrite",update:void 0},mute:!0};return t.ifMatch&&(e.mode={".tag":"update",update:t.ifMatch}),this._request("POST","https://content.dropboxapi.com/2/files/upload",{body:t.body,headers:{"Content-Type":"application/octet-stream","Dropbox-API-Arg":b(e)}}).then(e=>{if(200!==e.status&&409!==e.status)return Promise.resolve({statusCode:e.status});let n;try{n=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid API result: "+e.responseText))}return 409===e.status?w(n,["path","conflict"])?this._getMetadata(t.path).then(function(t){return Promise.resolve({statusCode:412,revision:t.rev})}):(this.rs._emit("error",new Error(n.error_summary)),Promise.resolve({statusCode:e.status})):(this._revCache.set(t.path,n.rev),Promise.resolve({statusCode:e.status,revision:n.rev}))})}_deleteSimple(t){const e={path:y(t)};return this._request("POST","https://api.dropboxapi.com/2/files/delete",{body:e}).then(t=>{if(200!==t.status&&409!==t.status)return Promise.resolve({statusCode:t.status});let e;try{e=JSON.parse(t.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+t.responseText))}if(409===t.status){if(w(e,["path_lookup","not_found"]))return Promise.resolve({statusCode:404});this.rs._emit("error",new Error(e.error_summary))}return Promise.resolve({statusCode:t.status,revision:200===t.status?e.rev:void 0})}).then(e=>(200!==e.statusCode&&404!==e.statusCode||(this._revCache.delete(t),delete this._itemRefs[t]),Promise.resolve(e)),e=>(e.message='Could not delete Dropbox file or folder ("'+t+'"): '+e.message,Promise.reject(e)))}_getSharedLink(t){return r(this,void 0,void 0,function*(){const e={body:{path:y(t),direct_only:!0}};return this._request("POST","https://api.dropboxapi.com/2/sharing/list_shared_links",e).then(t=>{if(200!==t.status&&409!==t.status)return Promise.reject(new Error("Invalid response status: "+t.status));let e;try{e=JSON.parse(t.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+t.responseText))}return 409===t.status?Promise.reject(new Error("API error: "+(null==e?void 0:e.error_summary)||0)):e.links.length?Promise.resolve(e.links[0].url):Promise.reject(new Error("No links returned"))},e=>(e.message='Could not get link to a shared file or folder ("'+t+'"): '+e.message,Promise.reject(e)))})}static _rs_init(t){p=(0,c.localStorageAvailable)(),t.apiKeys.dropbox&&(t.dropbox=new _(t)),"dropbox"===t.backend&&S(t)}static _rs_supported(){return!0}static _rs_cleanup(t){(function(t){(function(t){t._origRemote&&(t.remote=t._origRemote,delete t._origRemote)})(t),function(t){t._dropboxOrigSync&&(t.sync.sync=t._dropboxOrigSync,delete t._dropboxOrigSync)}(t),C(t)})(t),p&&localStorage.removeItem(f),t.setBackend(void 0)}}function x(t,...e){t._dropboxOrigSync||(t._dropboxOrigSync=t.sync.sync.bind(t.sync),t.sync.sync=function(){return this.dropbox.fetchDelta(t,...e).then(t._dropboxOrigSync,function(e){t._emit("error",new a.default(e)),t._emit("sync-done",{completed:!1})})}.bind(t))}function C(t){t._dropboxOrigSyncCycle&&(t.syncCycle=t._dropboxOrigSyncCycle,delete t._dropboxOrigSyncCycle)}function S(t){(function(t){t._origRemote||(t._origRemote=t.remote,t.remote=t.dropbox)})(t),t.sync?x(t):function(t,...e){t._dropboxOrigSyncCycle||(t._dropboxOrigSyncCycle=t.syncCycle,t.syncCycle=()=>{if(!t.sync)throw new Error("expected sync to be initialized by now");x(t),t._dropboxOrigSyncCycle(t,...e),C(t)})}(t)}(0,c.applyMixins)(_,[s.default]),t.exports=_},451:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(93)),s=n(746),o=r(n(334));class a{constructor(){this.addEvents(["background","foreground"]),this.mode="undefined"!=typeof window?"browser":"node","browser"===this.mode&&(this.setBrowserPrefixedNames(),document.addEventListener(this.visibilityChangeEvent,this.setVisibility.bind(this),!1),this.setVisibility())}setBrowserPrefixedNames(){"browser"===this.mode&&(void 0!==document.hidden?(this.hiddenProperty="hidden",this.visibilityChangeEvent="visibilitychange"):void 0!==document.mozHidden?(this.hiddenProperty="mozHidden",this.visibilityChangeEvent="mozvisibilitychange"):void 0!==document.msHidden?(this.hiddenProperty="msHidden",this.visibilityChangeEvent="msvisibilitychange"):void 0!==document.webkitHidden&&(this.hiddenProperty="webkitHidden",this.visibilityChangeEvent="webkitvisibilitychange"))}setVisibility(){document[this.hiddenProperty]?((0,o.default)("[Env] Going into background mode"),this.goBackground()):((0,o.default)("[Env] Going into foreground mode"),this.goForeground())}isBrowser(){return"browser"===this.mode}isNode(){return"node"===this.mode}goBackground(){this._emit("background")}goForeground(){this._emit("foreground")}static _rs_init(){}static _rs_cleanup(){}}(0,s.applyMixins)(a,[i.default]),t.exports=a},93:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.EventHandling=void 0;const i=r(n(334));class s{addEvents(t){t.forEach(t=>this._addEvent(t))}addEventListener(t,e){if("string"!=typeof t)throw new Error("Argument eventName should be a string");if("function"!=typeof e)throw new Error("Argument handler should be a function");(0,i.default)("[EventHandling] Adding event listener",t),this._validateEvent(t),this._handlers[t].push(e)}on(t,e){return this.addEventListener(t,e)}removeEventListener(t,e){this._validateEvent(t);const n=this._handlers[t].length;for(let r=0;r{t(...e)})}_validateEvent(t){if(!(t in this._handlers))throw new Error("Unknown event: "+t)}_delegateEvent(t,e){e.on(t,e=>{this._emit(t,e)})}_addEvent(t){void 0===this._handlers&&(this._handlers={}),this._handlers[t]=[]}}e.EventHandling=s,e.default=s},545:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(28)),s=r(n(451)),o=r(n(334)),a=n(746),l=r(n(370)),c=r(n(548)),u=r(n(275)),h=r(n(373)),d=r(n(424)),p=r(n(801)),f=r(n(706)),g=r(n(600)),m=r(n(313)),y=r(n(285)),v=r(n(567)),b=r(n(794)),w=r(n(365));t.exports={features:[],featuresDone:0,readyFired:!1,loadFeatures(){this.features=[],this.featuresDone=0,this.readyFired=!1,this.featureModules={WireClient:g.default,Dropbox:f.default,GoogleDrive:p.default,Access:c.default,Discover:h.default,Authorize:u.default,BaseClient:d.default,Env:s.default},i.default.cache&&(0,a.extend)(this.featureModules,{Caching:y.default,IndexedDB:v.default,LocalStorage:b.default,InMemoryStorage:w.default,Sync:m.default}),i.default.disableFeatures.forEach(t=>{this.featureModules[t]&&delete this.featureModules[t]}),this._allLoaded=!1;for(const t in this.featureModules)this.loadFeature(t)},hasFeature(t){for(let e=this.features.length-1;e>=0;e--)if(this.features[e].name===t)return this.features[e].supported;return!1},loadFeature(t){const e=this.featureModules[t],n=!e._rs_supported||e._rs_supported();(0,o.default)(`[RemoteStorage] [FEATURE ${t}] initializing ...`),"object"==typeof n?n.then(()=>{this.featureSupported(t,!0),this.initFeature(t)},()=>{this.featureSupported(t,!1)}):"boolean"==typeof n?(this.featureSupported(t,n),n&&this.initFeature(t)):this.featureSupported(t,!1)},initFeature(t){const e=this.featureModules[t];let n;try{n=e._rs_init(this)}catch(e){return void this.featureFailed(t,e)}"object"==typeof n&&"function"==typeof n.then?n.then(()=>{this.featureInitialized(t)},e=>{this.featureFailed(t,e)}):this.featureInitialized(t)},featureFailed(t,e){(0,o.default)(`[RemoteStorage] [FEATURE ${t}] initialization failed (${e})`),this.featureDone()},featureSupported(t,e){(0,o.default)(`[RemoteStorage] [FEATURE ${t}]${e?"":"not "} supported`),e||this.featureDone()},featureInitialized(t){(0,o.default)(`[RemoteStorage] [FEATURE ${t}] initialized`),this.features.push({name:t,init:this.featureModules[t]._rs_init,supported:!0,cleanup:this.featureModules[t]._rs_cleanup}),this.featureDone()},featureDone(){this.featuresDone++,this.featuresDone===Object.keys(this.featureModules).length&&setTimeout(this.featuresLoaded.bind(this),0)},_setCachingModule(){["IndexedDB","LocalStorage","InMemoryStorage"].some(t=>{if(this.features.some(e=>e.name===t))return this.features.local=this.featureModules[t],!0})},_fireReady(){try{this.readyFired||(this._emit("ready"),this.readyFired=!0)}catch(t){console.error("'ready' failed: ",t,t.stack),this._emit("error",t)}},featuresLoaded(){(0,o.default)("[RemoteStorage] All features loaded"),this._setCachingModule(),this.local=i.default.cache&&this.features.local&&new this.features.local,this.local&&this.remote?(this._setGPD(l.default,this),this._bindChange(this.local)):this.remote&&this._setGPD(this.remote,this.remote),this.remote&&(this.remote.on("connected",()=>{this._fireReady(),this._emit("connected")}),this.remote.on("not-connected",()=>{this._fireReady(),this._emit("not-connected")}),this.remote.connected&&(this._fireReady(),this._emit("connected")),this.hasFeature("Authorize")||this.remote.stopWaitingForToken()),this._collectCleanupFunctions();try{this._allLoaded=!0,this._emit("features-loaded")}catch(t){(0,a.logError)(t),this._emit("error",t)}this._processPending()},_collectCleanupFunctions(){this._cleanups=[];for(let t=0;t=n-this.maxAge?e.v:void 0}set(t,e){this._items[t]={v:e,t:(new Date).getTime()}}}class m extends a.RemoteBase{constructor(t,e){if(super(t),this.online=!0,this.storageApi="draft-dejong-remotestorage-19",this.addEvents(["connected","not-connected"]),this.clientId=e,this._fileIdCache=new g(300),u=(0,s.localStorageAvailable)(),u){const t=(0,s.getJSONFromLocalStorage)(l);t&&this.configure(t)}}configure(t){void 0!==t.userAddress&&(this.userAddress=t.userAddress),void 0!==t.token&&(this.token=t.token);const e=function(){u&&localStorage.setItem(l,JSON.stringify({userAddress:this.userAddress,token:this.token}))},n=function(){this.connected=!1,delete this.token,u&&localStorage.removeItem(l)};this.token?(this.connected=!0,this.userAddress?(this._emit("connected"),e.apply(this)):this.info().then(t=>{this.userAddress=t.user.emailAddress,this._emit("connected"),e.apply(this)}).catch(()=>{n.apply(this),this.rs._emit("error",new Error("Could not fetch user info."))})):n.apply(this)}connect(){this.rs.setBackend("googledrive"),this.rs.authorize({authURL:"https://accounts.google.com/o/oauth2/auth",scope:"https://www.googleapis.com/auth/drive",clientId:this.clientId})}get(t,e={}){return(0,s.isFolder)(t)?this._getFolder(f(t)):this._getFile(f(t),e)}put(t,e,n,r={}){const i=f(t);function s(t){if(t.status>=200&&t.status<300){const e=JSON.parse(t.responseText),n=this.stripQuotes(e.etag);return Promise.resolve({statusCode:200,contentType:e.mimeType,revision:n})}return 412===t.status?Promise.resolve({statusCode:412,revision:"conflict"}):Promise.reject("PUT failed with status "+t.status+" ("+t.responseText+")")}return this._getFileId(i).then(t=>t?r&&"*"===r.ifNoneMatch?s({status:412}):this._updateFile(t,i,e,n,r).then(s):this._createFile(i,e,n).then(s))}delete(t,e={}){const n=f(t);return this._getFileId(n).then(t=>t?this._getMeta(t).then(n=>{let r;return"object"==typeof n&&"string"==typeof n.etag&&(r=this.stripQuotes(n.etag)),e&&e.ifMatch&&e.ifMatch!==r?{statusCode:412,revision:r}:this._request("DELETE","https://www.googleapis.com/drive/v2/files/"+t,{}).then(t=>200===t.status||204===t.status?{statusCode:200}:Promise.reject("Delete failed: "+t.status+" ("+t.responseText+")"))}):Promise.resolve({statusCode:200}))}info(){return this._request("GET","https://www.googleapis.com/drive/v2/about?fields=user",{}).then(function(t){try{const e=JSON.parse(t.responseText);return Promise.resolve(e)}catch(t){return Promise.reject(t)}})}_updateFile(t,e,n,r,i){const s={mimeType:r},o={"Content-Type":"application/json; charset=UTF-8"};return i&&i.ifMatch&&(o["If-Match"]=this.addQuotes(i.ifMatch)),this._request("PUT","https://www.googleapis.com/upload/drive/v2/files/"+t+"?uploadType=resumable",{body:JSON.stringify(s),headers:o}).then(t=>412===t.status?t:this._request("PUT",t.getResponseHeader("Location"),{body:r.match(/^application\/json/)?JSON.stringify(n):n}))}_createFile(t,e,n){return this._getParentId(t).then(r=>{const i={title:h(p(t)),mimeType:n,parents:[{kind:"drive#fileLink",id:r}]};return this._request("POST","https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable",{body:JSON.stringify(i),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(t=>this._request("POST",t.getResponseHeader("Location"),{body:n.match(/^application\/json/)?JSON.stringify(e):e}))})}_getFile(t,e){return this._getFileId(t).then(t=>this._getMeta(t).then(t=>{let n;if("object"==typeof t&&"string"==typeof t.etag&&(n=this.stripQuotes(t.etag)),e&&e.ifNoneMatch&&n===e.ifNoneMatch)return Promise.resolve({statusCode:304});if(!t.downloadUrl){if(!t.exportLinks||!t.exportLinks["text/html"])return Promise.resolve({statusCode:200,body:"",contentType:t.mimeType,revision:n});t.mimeType+=";export=text/html",t.downloadUrl=t.exportLinks["text/html"]}return this._request("GET",t.downloadUrl,{responseType:"arraybuffer"}).then(e=>(0,s.getTextFromArrayBuffer)(e.response,"UTF-8").then(function(r){let i=r;if(t.mimeType.match(/^application\/json/))try{i=JSON.parse(i)}catch(t){}else(0,s.shouldBeTreatedAsBinary)(r,t.mimeType)&&(i=e.response);return{statusCode:200,body:i,contentType:(0,s.stripLegacyCharsetBinary)(t.mimeType),revision:n}}))}))}_getFolder(t){return this._getFileId(t).then(e=>{let n,r,i;if(!e)return Promise.resolve({statusCode:404});const o="'"+e+"' in parents";return this._request("GET","https://www.googleapis.com/drive/v2/files?q="+encodeURIComponent(o)+"&fields=items(downloadUrl%2Cetag%2CfileSize%2Cid%2CmimeType%2Ctitle%2Clabels)&maxResults=1000&trashed=false",{}).then(e=>{var o;if(200!==e.status)return Promise.reject("request failed or something: "+e.status);try{n=JSON.parse(e.responseText)}catch(t){return Promise.reject("non-JSON response from GoogleDrive")}i={};for(const a of n.items)null!==(o=a.labels)&&void 0!==o&&o.trashed||(r=this.stripQuotes(a.etag),a.mimeType===c?(this._fileIdCache.set(t+(0,s.cleanPath)(a.title)+"/",a.id),i[a.title+"/"]={ETag:r}):(this._fileIdCache.set(t+(0,s.cleanPath)(a.title),a.id),i[a.title]={ETag:r,"Content-Type":a.mimeType,"Content-Length":a.fileSize}));return Promise.resolve({statusCode:200,body:i,contentType:"application/json; charset=UTF-8",revision:void 0})})})}_getParentId(t){const e=d(t);return this._getFileId(e).then(t=>t?Promise.resolve(t):this._createFolder(e))}_createFolder(t){return this._getParentId(t).then(e=>this._request("POST","https://www.googleapis.com/drive/v2/files",{body:JSON.stringify({title:h(p(t)),mimeType:c,parents:[{id:e}]}),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(t=>{const e=JSON.parse(t.responseText);return Promise.resolve(e.id)}))}_getFileId(t){let e;return"/"===t?Promise.resolve("root"):(e=this._fileIdCache.get(t))?Promise.resolve(e):this._getFolder(d(t)).then(()=>(e=this._fileIdCache.get(t),e?Promise.resolve(e):"/"===t.substr(-1)?this._createFolder(t).then(()=>this._getFileId(t)):Promise.resolve()))}_getMeta(t){return this._request("GET","https://www.googleapis.com/drive/v2/files/"+t,{}).then(function(e){return 200===e.status?Promise.resolve(JSON.parse(e.responseText)):Promise.reject("request (getting metadata for "+t+") failed with status: "+e.status)})}_request(t,e,n){return this.isForbiddenRequestMethod(t,e)?Promise.reject(`Don't use ${t} on directories!`):(n.headers||(n.headers={}),n.headers.Authorization="Bearer "+this.token,this.rs._emit("wire-busy",{method:t,isFolder:(0,s.isFolder)(e)}),(0,o.requestWithTimeout)(t,e,n).then(n=>n&&401===n.status?void this.connect():(this.online||(this.online=!0,this.rs._emit("network-online")),this.rs._emit("wire-done",{method:t,isFolder:(0,s.isFolder)(e),success:!0}),Promise.resolve(n)),n=>(this.online&&(this.online=!1,this.rs._emit("network-offline")),this.rs._emit("wire-done",{method:t,isFolder:(0,s.isFolder)(e),success:!1}),Promise.reject(n))))}getItemURL(t){return r(this,void 0,void 0,function*(){throw new Error("getItemURL is not implemented for Google Drive yet")})}static _rs_init(t){const e=t.apiKeys.googledrive;e&&(t.googledrive=new m(t,e.clientId),"googledrive"===t.backend&&(t._origRemote=t.remote,t.remote=t.googledrive))}static _rs_supported(){return!0}static _rs_cleanup(t){t.setBackend(void 0),t._origRemote&&(t.remote=t._origRemote,delete t._origRemote)}}(0,s.applyMixins)(m,[i.default]),t.exports=m},567:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const s=i(n(93)),o=i(n(496)),a=i(n(334)),l=n(746),c="remotestorage";let u;class h extends o.default{constructor(t){super(),this.addEvents(["change","local-events-done"]),this.db=t||u,this.db?(this.getsRunning=0,this.putsRunning=0,this.changesQueued={},this.changesRunning={},this.commitSlownessWarning=null):(0,a.default)("[IndexedDB] Failed to open DB")}getNodes(t){return r(this,void 0,void 0,function*(){const e=[],n={};for(let r=0,i=t.length;r0?this.getNodesFromDb(e).then(function(t){for(const e in n)t[e]=n[e];return t}):n})}setNodes(t){return r(this,void 0,void 0,function*(){for(const e in t)this.changesQueued[e]=t[e]||!1;this.maybeFlush()})}maybeFlush(){0===this.putsRunning?this.flushChangesQueued():this.commitSlownessWarning||(this.commitSlownessWarning=n.g.setInterval(function(){console.warn("WARNING: waited more than 10 seconds for previous commit to finish")},1e4))}flushChangesQueued(){this.commitSlownessWarning&&(clearInterval(this.commitSlownessWarning),this.commitSlownessWarning=null),Object.keys(this.changesQueued).length>0&&(this.changesRunning=this.changesQueued,this.changesQueued={},this.setNodesInDb(this.changesRunning).then(this.flushChangesQueued.bind(this)))}getNodesFromDb(t){return new Promise((e,n)=>{const r=this.db.transaction(["nodes"],"readonly"),i=r.objectStore("nodes"),s={};this.getsRunning++,t.map(t=>{i.get(t).onsuccess=e=>{s[t]=e.target.result}}),r.oncomplete=()=>{e(s),this.getsRunning--},r.onerror=r.onabort=()=>{n("get transaction error/abort"),this.getsRunning--}})}setNodesInDb(t){return r(this,void 0,void 0,function*(){return new Promise((e,n)=>{const r=this.db.transaction(["nodes"],"readwrite"),i=r.objectStore("nodes"),s=(new Date).getTime();this.putsRunning++,(0,a.default)("[IndexedDB] Starting puts",t,this.putsRunning);for(const o in t){const e=t[o];if("object"==typeof e)try{i.put(e)}catch(t){throw(0,a.default)("[IndexedDB] Error while putting",e,t),t}else try{i.delete(o)}catch(t){throw(0,a.default)("[IndexedDB] Error while removing",i,e,t),t}}r.oncomplete=()=>{this.putsRunning--,(0,a.default)("[IndexedDB] Finished puts",t,this.putsRunning,(new Date).getTime()-s+"ms"),e()},r.onerror=()=>{this.putsRunning--,n("transaction error")},r.onabort=()=>{n("transaction abort"),this.putsRunning--}})})}reset(t){const e=this.db.name;this.db.close(),h.clean(e,()=>{h.open(e,(n,r)=>{n?(0,a.default)(`[IndexedDB] Error while resetting database ${e}:`,n):this.db=r,"function"==typeof t&&t(self)})})}forAllNodes(t){return r(this,void 0,void 0,function*(){return new Promise(e=>{this.db.transaction(["nodes"],"readonly").objectStore("nodes").openCursor().onsuccess=n=>{const r=n.target.result;r?(t(r.value),r.continue()):e()}})})}closeDB(){0===this.putsRunning?this.db.close():setTimeout(this.closeDB.bind(this),100)}static open(t,e){const n=setTimeout(function(){e("timeout trying to open db")},1e4);try{const r=indexedDB.open(t,2);r.onerror=function(){(0,a.default)("[IndexedDB] Opening DB failed",r),clearTimeout(n),e(r.error)},r.onupgradeneeded=function(t){const e=r.result;(0,a.default)("[IndexedDB] Upgrade: from ",t.oldVersion," to ",t.newVersion),e.objectStoreNames.contains("nodes")||((0,a.default)("[IndexedDB] Creating object store: nodes"),e.createObjectStore("nodes",{keyPath:"path"})),e.objectStoreNames.contains("changes")||((0,a.default)("[IndexedDB] Creating object store: changes"),e.createObjectStore("changes",{keyPath:"path"}))},r.onsuccess=function(){clearTimeout(n);const i=r.result;if(!i.objectStoreNames.contains("nodes")||!i.objectStoreNames.contains("changes"))return(0,a.default)("[IndexedDB] Missing object store. Resetting the database."),i.close(),void h.clean(t,function(){h.open(t,e)});e(null,r.result)}}catch(r){(0,a.default)("[IndexedDB] Failed to open database: "+r),(0,a.default)("[IndexedDB] Resetting database and trying again."),clearTimeout(n),h.clean(t,function(){h.open(t,e)})}}static clean(t,e){const n=indexedDB.deleteDatabase(t);n.onblocked=function(e){console.warn(`Deleting IndexedDB database "${t}" is blocked by another open connection`,e)},n.onsuccess=function(){(0,a.default)(`[IndexedDB] Deleted database "${t}"`),e()},n.onerror=n.onabort=function(e){console.error('Failed to remove database "'+t+'"',e)}}static _rs_init(t){return new Promise((e,n)=>{h.open(c,function(r,i){if(r)n(r);else{if(!i)return void n(new Error("IndexedDB opened without a database instance"));u=i,i.onerror=e=>{t._emit("error",h.eventToError(e))},e()}})})}static _rs_supported(){return new Promise((t,e)=>{const n=(0,l.getGlobalContext)();let r=!1;if("undefined"!=typeof navigator&&navigator.userAgent.match(/Android (2|3|4\.[0-3])/)&&(navigator.userAgent.match(/Chrome|Firefox/)||(r=!0)),"indexedDB"in n&&!r)try{const n=indexedDB.open("rs-check");n.onerror=function(){e()},n.onsuccess=function(){n.result.close(),indexedDB.deleteDatabase("rs-check"),t()}}catch(t){e()}else e()})}static _rs_cleanup(t){return new Promise(e=>{t.local instanceof h&&t.local.closeDB(),h.clean(c,e)})}static eventToError(t){var e;const n=null==t?void 0:t.target,r=null==n?void 0:n.error;if(r)return r;if(null===(e=null==n?void 0:n.db)||void 0===e?void 0:e.name){const t=n.objectStoreNames,e=t?Array.from(t).join(", "):"";return new Error(`Error in store(s) “${e}” in database “${n.db.name}”`)}return new Error("Unknown IndexedDB error")}diffHandler(){}}(0,l.applyMixins)(h,[s.default]),t.exports=h},365:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(93)),s=r(n(496)),o=n(746);class a extends s.default{constructor(){super(),this._storage={},this.addEvents(["change","local-events-done"])}getNodes(t){const e={};for(let n=0,r=t.length;n=2e3&&t<=36e5}var M;!function(t){t.GOOGLE="googledrive",t.DROPBOX="dropbox"}(M||(M={}));class A{constructor(t){if(this._pending=[],this._cleanups=[],this._pathHandlers={change:{}},this.apiKeys={},this._init=x.default.loadFeatures,this.features=x.default.features,this.loadFeature=x.default.loadFeature,this.featureSupported=x.default.featureSupported,this.featureDone=x.default.featureDone,this.featuresDone=x.default.featuresDone,this.featuresLoaded=x.default.featuresLoaded,this.featureInitialized=x.default.featureInitialized,this.featureFailed=x.default.featureFailed,this.hasFeature=x.default.hasFeature,this._setCachingModule=x.default._setCachingModule,this._collectCleanupFunctions=x.default._collectCleanupFunctions,this._fireReady=x.default._fireReady,this.initFeature=x.default.initFeature,"object"==typeof t&&null!==t){const e=t,{discovery:n}=e,r=a(e,["discovery"]);Object.assign(c.default,r),n&&"object"==typeof n&&Object.assign(c.default.discovery,n)}if(this.addEvents(["ready","authing","connecting","connected","disconnected","not-connected","conflict","error","features-loaded","scope-change-required","sync-interval-change","sync-started","sync-req-done","sync-done","wire-busy","wire-done","network-offline","network-online"]),this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")}),k=(0,h.localStorageAvailable)(),k){this.apiKeys=(0,h.getJSONFromLocalStorage)("remotestorage:api-keys")||{};const t=localStorage.getItem("remotestorage:backend");"dropbox"===t||"googledrive"===t?this.setBackend(t):this.setBackend("remotestorage")}this._authorizedScope=this._loadAuthorizedScope(),this._scopeChangeRequired=!1,this._scopeChangeEvent=null;const e=this.on;this.on=function(t,n){const r=e.call(this,t,n);if("scope-change-required"===t&&this._scopeChangeRequired&&this._scopeChangeEvent&&setTimeout(()=>{n(this._scopeChangeEvent)},0),this._allLoaded)switch(t){case"features-loaded":setTimeout(n,0);break;case"ready":this.remote&&setTimeout(n,0);break;case"connected":this.remote&&this.remote.connected&&setTimeout(n,0);break;case"not-connected":this.remote&&!this.remote.connected&&setTimeout(n,0)}return r},this._init(),this.fireInitial=function(){this.local&&setTimeout(this.local.fireInitial.bind(this.local),0)}.bind(this),this.on("ready",this.fireInitial.bind(this)),this.loadModules()}get connected(){return this.remote.connected}get scopeChangeRequired(){return this._scopeChangeRequired}loadModules(){c.default.modules.forEach(this.addModule.bind(this))}authorize(t){if(this.access.setStorageType(this.remote.storageApi),void 0===t.scope&&(t.scope=this.access.scopeParameter),S.cordova&&"string"==typeof c.default.cordovaRedirectUri)t.redirectUri=c.default.cordovaRedirectUri;else{const e=p.default.getLocation();let n=e.origin;"/"!==e.pathname&&(n+=e.pathname),t.redirectUri=n}void 0===t.clientId&&(t.clientId=t.redirectUri.match(/^(https?:\/\/[^/]+)/)[0]),p.default.authorize(this,t)}impliedauth(t,e){t=t||this.remote.storageApi,e=e||String(document.location),(0,u.default)("ImpliedAuth proceeding due to absent authURL; storageApi = "+t+" redirectUri = "+e),this.remote.configure({token:p.default.IMPLIED_FAKE_TOKEN}),document.location.href=e}connect(t,e){if(this.setBackend("remotestorage"),t.indexOf("@")<0&&!t.match(/^(https?:\/\/)?[^\s\/$\.?#]+\.[^\s]*$/))this._emit("error",new A.DiscoveryError("Not a valid user address or URL."));else{if(t.indexOf("@")<0&&!t.match(/^https?:\/\//)&&(t=`https://${t}`),S.cordova){if("string"!=typeof c.default.cordovaRedirectUri)return void this._emit("error",new A.DiscoveryError("Please supply a custom HTTPS redirect URI for your Cordova app"));if(!S.cordova.InAppBrowser)return void this._emit("error",new A.DiscoveryError("Please include the InAppBrowser Cordova plugin to enable OAuth"))}this.remote.configure({userAddress:t}),this._emit("connecting"),A.Discover(t).then(n=>{if(this._emit("authing"),n.userAddress=t,this.remote.configure(n),!this.remote.connected)if(n.authURL)if(void 0===e)this.authorize({authURL:n.authURL});else{if("string"!=typeof e)throw new Error("Supplied bearer token must be a string");(0,u.default)("Skipping authorization sequence and connecting with known token"),this.remote.configure({token:e}),this._rememberAuthorizedScope(this.access.scopeParameter)}else this.impliedauth()},()=>{this._emit("error",new A.DiscoveryError("No storage information found for this user address."))})}}reconnect(){this.remote.configure({token:null}),"remotestorage"===this.backend?this.connect(this.remote.userAddress):this.remote.connect()}reauthorize(){this.reconnect()}disconnect(){this.remote&&this.remote.configure({userAddress:null,href:null,storageApi:null,token:null,refreshToken:null,properties:null}),this._forgetPendingScope(),this._rememberAuthorizedScope(null),this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")});const t=this._cleanups.length;let e=0;const n=()=>{e++,e>=t&&(this._init(),(0,u.default)('Cleanups done, emitting "disconnected" event'),this._emit("disconnected"))};t>0?this._cleanups.forEach(t=>{const e=t(this);"object"==typeof e&&"function"==typeof e.then?e.then(n):n()}):n()}setBackend(t){if(this.backend=t,k&&(void 0!==t?localStorage.setItem("remotestorage:backend",t):localStorage.removeItem("remotestorage:backend")),void 0===t)return this._authorizedScope=null,this._scopeChangeRequired=!1,void(this._scopeChangeEvent=null);this._authorizedScope=this._loadAuthorizedScope(),this._checkScopeChange()}_rememberPendingScope(t){const e=T(t);k&&(e&&this.backend?localStorage.setItem(R,JSON.stringify({backend:this.backend,scope:e})):localStorage.removeItem(R))}_forgetPendingScope(){k&&localStorage.removeItem(R)}_rememberAuthorizedScope(t){const e=T(t);k?e&&this.backend?(localStorage.setItem(E,JSON.stringify({backend:this.backend,scope:e})),this._authorizedScope=e,this._checkScopeChange()):(localStorage.removeItem(E),this._authorizedScope=null,this._checkScopeChange()):(this._authorizedScope=e,this._checkScopeChange())}_completeAuthorization(t){const e=this._loadPendingScope()||T(t);this._forgetPendingScope(),e?this._rememberAuthorizedScope(e):this._checkScopeChange()}_checkScopeChange(){const t=T(this.access.scopeParameter),e=this._authorizedScope||this._loadAuthorizedScope(),n=!(!t||!e||t===e),r=n&&(!this._scopeChangeRequired||!this._scopeChangeEvent||this._scopeChangeEvent.requestedScope!==t||this._scopeChangeEvent.authorizedScope!==e);this._scopeChangeRequired=n,n?(this._scopeChangeEvent=this._buildScopeChangeEvent(t,e),r&&this._emit("scope-change-required",this._scopeChangeEvent)):this._scopeChangeEvent=null}_loadAuthorizedScope(){if(!k||!this.backend)return null;const t=L(E);return t&&t.backend===this.backend?T(t.scope):null}_loadPendingScope(){if(!k||!this.backend)return null;const t=L(R);return t&&t.backend===this.backend?T(t.scope):null}_buildScopeChangeEvent(t=T(this.access.scopeParameter),e=this._authorizedScope){return{requestedScope:t||"",authorizedScope:e||"",reauthorize:this.reauthorize.bind(this)}}onChange(t,e){this._pathHandlers.change[t]||(this._pathHandlers.change[t]=[]),this._pathHandlers.change[t].push(e)}enableLog(){c.default.logging=!0}disableLog(){c.default.logging=!1}log(...t){u.default.apply(A,t)}setApiKeys(t){const e=[M.GOOGLE,M.DROPBOX];if("object"!=typeof t||!Object.keys(t).every(t=>e.includes(t)))return console.error("setApiKeys() was called with invalid arguments"),!1;Object.keys(t).forEach(e=>{const n=t[e];if(n){switch(e){case M.DROPBOX:this.apiKeys[M.DROPBOX]={appKey:n},void 0!==this.dropbox&&this.dropbox.clientId===n||v.default._rs_init(this);break;case M.GOOGLE:this.apiKeys[M.GOOGLE]={clientId:n},void 0!==this.googledrive&&this.googledrive.clientId===n||y.default._rs_init(this)}return!0}delete this.apiKeys[e]}),k&&localStorage.setItem("remotestorage:api-keys",JSON.stringify(this.apiKeys))}setCordovaRedirectUri(t){if("string"!=typeof t||!t.match(/http(s)?:\/\//))throw new Error("Cordova redirect URI must be a URI string");c.default.cordovaRedirectUri=t}_setGPD(t,e){function n(t){return function(...n){return t.apply(e,n).then(I.bind(this))}}this.get=n(t.get),this.put=n(t.put),this.delete=n(t.delete)}_pendingGPD(t){return(...e)=>{const n=Array.prototype.slice.call(e);return new Promise((e,r)=>{this._pending.push({method:t,args:n,promise:{resolve:e,reject:r}})})}}_processPending(){this._pending.forEach(t=>{try{this[t.method](...t.args).then(t.promise.resolve,t.promise.reject)}catch(e){t.promise.reject(e)}}),this._pending=[]}_bindChange(t){t.on("change",this._dispatchEvent.bind(this,"change"))}_dispatchEvent(t,e){Object.keys(this._pathHandlers[t]).forEach(n=>{const r=n.length;e.path.substr(0,r)===n&&this._pathHandlers[t][n].forEach(t=>{const r={};for(const n in e)r[n]=e[n];r.relativePath=e.path.replace(new RegExp("^"+n),"");try{t(r)}catch(t){console.error("'change' handler failed: ",t,t.stack),this._emit("error",t)}})})}scope(t){if("string"!=typeof t)throw"Argument 'path' of baseClient.scope must be a string";return this.access.checkPathPermission(t,"r")||console.warn("WARNING: Please use remoteStorage.access.claim() to ask for access permissions first: https://remotestorage.io/rs.js/docs/api/access/classes/Access.html#claim"),new f.default(this,t)}getSyncInterval(){return c.default.syncInterval}setSyncInterval(t){if(!P(t))throw t+" is not a valid sync interval";const e=c.default.syncInterval;c.default.syncInterval=t,this._emit("sync-interval-change",{oldValue:e,newValue:t})}getBackgroundSyncInterval(){return c.default.backgroundSyncInterval}setBackgroundSyncInterval(t){if(!P(t))throw t+" is not a valid sync interval";const e=c.default.backgroundSyncInterval;c.default.backgroundSyncInterval=t,this._emit("sync-interval-change",{oldValue:e,newValue:t})}getCurrentSyncInterval(){return c.default.isBackground?c.default.backgroundSyncInterval:c.default.syncInterval}getRequestTimeout(){return c.default.requestTimeout}setRequestTimeout(t){if("number"!=typeof t)throw t+" is not a valid request timeout";c.default.requestTimeout=t}setupSyncCycle(){this.sync&&!this.sync.stopped&&((0,u.default)("[Sync] Setting up sync cycle"),this.on("sync-done",()=>{(0,u.default)("[Sync] Sync done. Setting timer to",this.getCurrentSyncInterval()),this.sync&&!this.sync.stopped&&(this._syncTimer&&clearTimeout(this._syncTimer),this._syncTimer=setTimeout(this.sync.sync.bind(this.sync),this.getCurrentSyncInterval()))}),this.sync.sync())}startSync(){return c.default.cache?(this.sync.stopped=!1,this.syncStopped=!1,this.sync.sync()):(console.warn("Nothing to sync, because caching is disabled."),Promise.resolve())}stopSync(){clearTimeout(this._syncTimer),this._syncTimer=void 0,this.sync?((0,u.default)("[Sync] Stopping sync"),this.sync.stopped=!0):((0,u.default)("[Sync] Will instantiate sync stopped"),this.syncStopped=!0)}addModule(t){const e=t.name,n=t.builder;if(Object.defineProperty(this,e,{configurable:!0,get:function(){const t=this._loadModule(e,n);return Object.defineProperty(this,e,{value:t}),t}}),-1!==e.indexOf("-")){const t=e.replace(/\-[a-z]/g,function(t){return t[1].toUpperCase()});Object.defineProperty(this,t,{get:function(){return this[e]}})}}_loadModule(t,e){if(e)return e(new f.default(this,"/"+t+"/"),new f.default(this,"/public/"+t+"/")).exports;throw"Unknown module: "+t}}e.RemoteStorage=A,A.SyncError=w.default,A.Unauthorized=_.default,A.Discover=b.default,A.DiscoveryError=b.default.DiscoveryError,A.util=C,Object.defineProperty(A.prototype,"access",{configurable:!0,get:function(){const t=new d.default(this);return Object.defineProperty(this,"access",{value:t,writable:!0,configurable:!0}),t}}),Object.defineProperty(A.prototype,"caching",{configurable:!0,get:function(){const t=new g.default(this);return Object.defineProperty(this,"caching",{value:t,writable:!0,configurable:!0}),t}}),(0,h.applyMixins)(A,[m.EventHandling]),e.default=A},368:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.isArrayBufferView=void 0,e.retryAfterMs=function(t){const e=1e3*parseInt(t.getResponseHeader("Retry-After"));return e>=1e3?e:Math.max(1500,Math.min(6e4,Math.round(o.default.syncInterval/(2.9+.2*Math.random()))))},e.requestWithTimeout=function(t,n,i){return r(this,void 0,void 0,function*(){return"function"==typeof fetch?function(t,e,n){return r(this,void 0,void 0,function*(){const r="function"==typeof AbortController?new AbortController:null;let i;const a=new Promise((t,e)=>{i=setTimeout(()=>{r&&r.abort(),e("timeout")},o.default.requestTimeout)});let l;const c={},u=fetch(e,{method:t,headers:n.headers,body:n.body,signal:r?r.signal:void 0}).then(t=>{switch((0,s.default)("[requests fetch]",t),t.headers.forEach((t,e)=>{c[e.toUpperCase()]=t}),l={readyState:4,status:t.status,statusText:t.statusText,response:void 0,getResponseHeader:t=>c[t.toUpperCase()]||null,responseType:n.responseType,responseURL:e},n.responseType){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"json":return t.json();case void 0:case"":case"text":return t.text();default:throw new Error("responseType 'document' is not currently supported using fetch")}}).then(t=>(l.response=t,n.responseType&&"text"!==n.responseType||(l.responseText=t),l)).finally(()=>{clearTimeout(i)});return Promise.race([u,a])})}(t,n,i):"function"==typeof XMLHttpRequest?function(t,n,i){return r(this,void 0,void 0,function*(){return new Promise((r,a)=>{(0,s.default)("[requests XHR]",t,n);let l=!1;const c=setTimeout(()=>{l=!0,a("timeout")},o.default.requestTimeout),u=new XMLHttpRequest;if(u.open(t,n,!0),i.responseType&&(u.responseType=i.responseType),i.headers)for(const t in i.headers)u.setRequestHeader(t,i.headers[t]);u.onload=()=>{l||(clearTimeout(c),r(u))},u.onerror=t=>{l||(clearTimeout(c),a(t))};let h=i.body;"object"==typeof h&&!(0,e.isArrayBufferView)(h)&&h instanceof ArrayBuffer&&(h=new Uint8Array(h)),u.send(h)})})}(t,n,i):Promise.reject("[Requests] You need to add a polyfill for fetch or XMLHttpRequest")})};const s=i(n(334)),o=i(n(28));if("function"==typeof(n.g||window).ArrayBufferView)e.isArrayBufferView=function(t){return t&&t instanceof(n.g||window).ArrayBufferView};else{const t=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];e.isArrayBufferView=function(e){for(let n=0;n<8;n++)if(e instanceof t[n])return!0;return!1}}},941:function(t){t.exports=class{constructor(t){this._itemsRev={},this._storage={},this._canPropagate=!1,this.defaultValue=t,this.activatePropagation()}get(t){t=t.toLowerCase();let e=this._storage[t];return void 0===e&&(e=this.defaultValue,this._storage[t]=e),e}set(t,e){return t=t.toLowerCase(),this._storage[t]===e||(this._storage[t]=e,e||delete this._itemsRev[t],this._updateParentFolderItemRev(t,e),this._canPropagate&&this._propagate(t)),e}delete(t){return this.set(t,null)}deactivatePropagation(){return this._canPropagate=!1,!0}activatePropagation(){return this._canPropagate||(this._generateFolderRev("/"),this._canPropagate=!0),!0}_hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n0&&(n=this._generateHash(t))}return this.set(t,n),n}}},491:function(t){class e extends Error{constructor(t){super();const e=new Error("Schema not found: "+t);return e.name="SchemaNotFound",e}}t.exports=e},982:function(t){class e extends Error{constructor(t){super(),this.name="SyncError",this.message="Sync failed: ","string"==typeof t?this.message+=t:(this.message+=t.message,this.stack=t.stack,this.originalError=t)}}t.exports=e},313:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Sync=void 0;const s=i(n(28)),o=i(n(451)),a=i(n(93)),l=i(n(334)),c=i(n(275)),u=i(n(982)),h=i(n(503)),d=n(746);let p,f;function g(t,e,n){return{action:t,path:e,promise:n}}function m(t,e){return t.common.revision!==e&&(!t.remote||t.remote.revision!==e)}function y(t){return!!t.common&&!!t.common.revision}class v{constructor(t){this.numThreads=10,this._tasks={},this._running={},this._timeStarted={},this._finishedTasks=[],this.rs=t,this.rs.local.onDiff(t=>{this.addTask(t),this.doTasks()}),this.rs.caching.onActivate(t=>{this.addTask(t),this.doTasks()}),this.addEvents(["done","req-done"])}now(){return(new Date).getTime()}queueGetRequest(t){return r(this,void 0,void 0,function*(){return new Promise((e,n)=>{this.rs.remote.connected?this.rs.remote.online?(this.addTask(t,function(){this.rs.local.get(t).then(t=>e(t))}.bind(this)),this.doTasks()):n("cannot fulfill maxAge requirement - remote is not online"):n("cannot fulfill maxAge requirement - remote is not connected")})})}corruptServerItemsMap(t){if("object"!=typeof t||Array.isArray(t))return!0;for(const e in t){const n=t[e];if("object"!=typeof n)return!0;if("string"!=typeof n.ETag)return!0;if((0,d.isFolder)(e)){if(-1!==e.substring(0,e.length-1).indexOf("/"))return!0}else if(-1!==e.indexOf("/"))return!0}return!1}corruptItemsMap(t){if("object"!=typeof t||Array.isArray(t))return!0;for(const e in t)if("boolean"!=typeof t[e])return!0;return!1}corruptRevision(t){return"object"!=typeof t||Array.isArray(t)||t.revision&&"string"!=typeof t.revision||t.body&&"string"!=typeof t.body&&"object"!=typeof t.body||t.contentType&&"string"!=typeof t.contentType||t.contentLength&&"number"!=typeof t.contentLength||t.timestamp&&"number"!=typeof t.timestamp||t.itemsMap&&this.corruptItemsMap(t.itemsMap)}isCorrupt(t){return"object"!=typeof t||Array.isArray(t)||"string"!=typeof t.path||this.corruptRevision(t.common)||t.local&&this.corruptRevision(t.local)||t.remote&&this.corruptRevision(t.remote)||t.push&&this.corruptRevision(t.push)}hasTasks(){return Object.keys(this._tasks).length>0}collectDiffTasks(){return r(this,void 0,void 0,function*(){let t=0;return this.rs.local.forAllNodes(e=>{t>100||(this.isCorrupt(e)?((0,l.default)("[Sync] WARNING: corrupt node in local cache",e),"object"==typeof e&&e.path&&(this.addTask(e.path),t++)):(this.needsFetch(e)&&this.rs.access.checkPathPermission(e.path,"r")||(0,d.isDocument)(e.path)&&this.needsPush(e)&&this.rs.access.checkPathPermission(e.path,"rw"))&&(this.addTask(e.path),t++))}).then(()=>t)})}inConflict(t){return!(!t.local||!t.remote||void 0===t.remote.body&&!t.remote.itemsMap)}needsRefresh(t){return!!t.common&&(!t.common.timestamp||this.now()-t.common.timestamp>s.default.syncInterval)}needsFetch(t){return!!this.inConflict(t)||!(!t.common||void 0!==t.common.itemsMap||void 0!==t.common.body)||!(!t.remote||void 0!==t.remote.itemsMap||void 0!==t.remote.body)}needsPush(t){return!this.inConflict(t)&&(!(!t.local||t.push)||void 0)}needsRemotePut(t){return!(!t.local||void 0===t.local.body||!1===t.local.body)}needsRemoteDelete(t){return t.local&&!1===t.local.body}getParentPath(t){const e=t.match(/^(.*\/)([^\/]+\/?)$/);if(e)return e[1];throw new Error('Not a valid path: "'+t+'"')}deleteChildPathsFromTasks(){for(const t in this._tasks){const e=(0,d.pathsFromRoot)(t);for(let n=1;n{let e;if(this.needsRefresh(t)){try{e=this.getParentPath(t.path)}catch(t){}e&&this.rs.access.checkPathPermission(e,"r")?this.addTask(e):this.rs.access.checkPathPermission(t.path,"r")&&this.addTask(t.path)}}),this.deleteChildPathsFromTasks()})}flush(t){for(const e in t)"FLUSH"===this.rs.caching.checkPath(e)&&t[e]&&!t[e].local&&((0,l.default)("[Sync] Flushing",e),t[e]=void 0);return t}doTask(t){return r(this,void 0,void 0,function*(){return this.rs.local.getNodes([t]).then(e=>{const n=e[t];return void 0===n||function(t){return!(!t.remote||!t.remote.revision||t.remote.itemsMap||t.remote.body)}(n)?g("get",t,this.rs.remote.get(t)):this.needsRemotePut(n)?(n.push=(0,d.deepClone)(n.local),n.push.timestamp=this.now(),this.rs.local.setNodes(this.flush(e)).then(()=>{let e;return e=y(n)?{ifMatch:n.common.revision}:{ifNoneMatch:"*"},g("put",t,this.rs.remote.put(t,n.push.body,n.push.contentType,e))})):this.needsRemoteDelete(n)?(n.push={body:!1,timestamp:this.now()},this.rs.local.setNodes(this.flush(e)).then(()=>y(n)?g("delete",t,this.rs.remote.delete(t,{ifMatch:n.common.revision})):g("get",t,this.rs.remote.get(t)))):y(n)?g("get",t,this.rs.remote.get(t,{ifNoneMatch:n.common.revision})):g("get",t,this.rs.remote.get(t))})})}autoMergeFolder(t){if(t.remote.itemsMap&&(t.common=t.remote,delete t.remote,t.common.itemsMap)){for(const e in t.common.itemsMap)t.local.itemsMap[e]||(t.local.itemsMap[e]=!1);for(const e in t.local.itemsMap)t.common.itemsMap[e]||this.addTask(t.path+e);(0,d.equal)(t.local.itemsMap,t.common.itemsMap)&&delete t.local}return t}autoMergeDocument(t){var e;return function(t){return(!t.remote||!t.remote.revision||t.remote.revision===t.common.revision)&&(void 0===t.common.body&&!1===t.remote.body||t.remote.body===t.common.body&&t.remote.contentType===t.common.contentType)}(t)?delete(t=function(t){return t.remote&&!1===t.remote.body&&t.local&&!1===t.local.body&&delete t.local,t}(t)).remote:void 0!==t.remote.body&&(!1===t.remote.body&&!1===(null===(e=t.local)||void 0===e?void 0:e.body)||((0,l.default)("[Sync] Emitting conflict event"),setTimeout(this.rs.local.emitChange.bind(this.rs.local),10,{origin:"conflict",path:t.path,oldValue:t.local.body,newValue:t.remote.body,lastCommonValue:t.common.body,oldContentType:t.local.contentType,newContentType:t.remote.contentType,lastCommonContentType:t.common.contentType})),!1===t.remote.body?t.common={}:t.common=t.remote,delete t.remote,delete t.local),t}autoMerge(t){if(t.remote){if(t.local)return(0,d.isFolder)(t.path)?this.autoMergeFolder(t):this.autoMergeDocument(t);if((0,d.isFolder)(t.path))void 0!==t.remote.itemsMap&&(t.common=t.remote,delete t.remote);else if(void 0!==t.remote.body){const e={origin:"remote",path:t.path,oldValue:!1===t.common.body?void 0:t.common.body,newValue:!1===t.remote.body?void 0:t.remote.body,oldContentType:t.common.contentType,newContentType:t.remote.contentType};if(void 0===e.oldValue&&void 0===e.newValue||this.rs.local.emitChange(e),!1===t.remote.body)return;t.common=t.remote,delete t.remote}return t}t.common.body&&this.rs.local.emitChange({origin:"remote",path:t.path,oldValue:t.common.body,newValue:void 0,oldContentType:t.common.contentType,newContentType:void 0})}updateCommonTimestamp(t,e){return r(this,void 0,void 0,function*(){return this.rs.local.getNodes([t]).then(n=>(n[t]&&n[t].common&&n[t].common.revision===e&&(n[t].common.timestamp=this.now()),this.rs.local.setNodes(this.flush(n))))})}markChildren(t,e,n,i){return r(this,void 0,void 0,function*(){const r=[],s={},o={};for(const n in e)r.push(t+n),s[t+n]=e[n];for(const e in i)r.push(t+e);const a=yield this.rs.local.getNodes(r);let l,c;for(const e in a)if(c=a[e],s[e])c&&c.common?m(c,s[e].ETag)&&(n[e]=(0,d.deepClone)(c),n[e].remote={revision:s[e].ETag,timestamp:this.now()},n[e]=this.autoMerge(n[e])):(l=this.rs.caching.checkPath(e),"ALL"===l&&(n[e]={path:e,common:{timestamp:this.now()},remote:{revision:s[e].ETag,timestamp:this.now()}})),n[e]&&s[e]["Content-Type"]&&(n[e].remote.contentType=s[e]["Content-Type"]),n[e]&&s[e]["Content-Length"]&&(n[e].remote.contentLength=s[e]["Content-Length"]);else if(i[e.substring(t.length)]&&c&&c.common){if(c.common.itemsMap)for(const t in c.common.itemsMap)o[e+t]=!0;if(c.local&&c.local.itemsMap)for(const t in c.local.itemsMap)o[e+t]=!0;if(c.remote||(0,d.isFolder)(e))n[e]=void 0;else if(n[e]=this.autoMerge(c),void 0===n[e]){const r=n[this.getParentPath(e)],i=e.substring(t.length);r&&r.local&&(delete r.local.itemsMap[i],(0,d.equal)(r.local.itemsMap,r.common.itemsMap)&&delete r.local)}}const u=yield this.markRemoteDeletions(Object.keys(o),n);u&&(yield this.rs.local.setNodes(this.flush(u)))})}markRemoteDeletions(t,e){return r(this,void 0,void 0,function*(){if(0===t.length)return e;const n=yield this.rs.local.getNodes(t),r={};function i(t,e){if(t&&t.itemsMap)for(const n in t.itemsMap)r[e+n]=!0}for(const t in n){const r=n[t];r&&((0,d.isFolder)(t)?(i(r.common,t),i(r.local,t)):r.common&&void 0!==r.common.body&&(e[t]=(0,d.deepClone)(r),e[t].remote={body:!1,timestamp:this.now()},e[t]=this.autoMerge(e[t])))}const s=yield this.markRemoteDeletions(Object.keys(r),e);s&&(yield this.rs.local.setNodes(this.flush(s)))})}completeFetch(t,e,n,i){return r(this,void 0,void 0,function*(){let r,s;const o=(0,d.pathsFromRoot)(t);(0,d.isFolder)(t)?r=[t]:(s=o[1],r=[t,s]);const a=yield this.rs.local.getNodes(r),l=a[s],c={};let u,h=a[t];function p(t){if(t&&t.itemsMap)for(u in t.itemsMap)e[u]||(c[u]=!0)}if("object"==typeof h&&h.path===t&&"object"==typeof h.common||(h={path:t,common:{}},a[t]=h),h.remote={revision:i,timestamp:this.now()},(0,d.isFolder)(t))for(u in p(h.common),p(h.remote),h.remote.itemsMap={},e)h.remote.itemsMap[u]=!0;else h.remote.body=e,h.remote.contentType=n,l&&l.local&&l.local.itemsMap&&(u=t.substring(s.length),!1!==e?l.local.itemsMap[u]=!0:l.local.itemsMap[u]&&delete l.local.itemsMap[u],(0,d.equal)(l.local.itemsMap,l.common.itemsMap)&&delete l.local);return a[t]=this.autoMerge(h),{toBeSaved:a,missingChildren:c}})}completePush(t,e,n,i){return r(this,void 0,void 0,function*(){const r=yield this.rs.local.getNodes([t]),s=r[t];if(!s.push)throw this.stopped=!0,new Error("completePush called but no push version!");n?((0,l.default)("[Sync] We have a conflict"),s.remote&&s.remote.revision===i||(s.remote={revision:i||"conflict",timestamp:this.now()},delete s.push),r[t]=this.autoMerge(s)):(s.common={revision:i,timestamp:this.now()},"put"===e?(s.common.body=s.push.body,s.common.contentType=s.push.contentType,(0,d.equal)(s.local.body,s.push.body)&&s.local.contentType===s.push.contentType&&delete s.local,delete s.push):"delete"===e&&(!1===s.local.body?r[t]=void 0:delete s.push)),yield this.rs.local.setNodes(this.flush(r))})}dealWithFailure(t){return r(this,void 0,void 0,function*(){const e=yield this.rs.local.getNodes([t]);if(e[t])return delete e[t].push,this.rs.local.setNodes(this.flush(e))})}interpretStatus(t){const e={statusCode:t,successful:void 0,conflict:void 0,unAuth:void 0,notFound:void 0,changed:void 0,networkProblems:void 0};return"string"!=typeof t||"offline"!==t&&"timeout"!==t?"number"==typeof t?(e.successful=2===Math.floor(t/100)||304===t||412===t||404===t,e.conflict=412===t,e.unAuth=401===t&&this.rs.remote.token!==c.default.IMPLIED_FAKE_TOKEN||402===t||403===t,e.notFound=404===t,e.changed=304!==t,e):void 0:(e.successful=!1,e.networkProblems=!0,e)}handleGetResponse(t,e,n,i,s){return r(this,void 0,void 0,function*(){if(e.notFound&&(n=!!(0,d.isFolder)(t)&&{}),e.changed){const e=yield this.completeFetch(t,n,i,s);if((0,d.isFolder)(t)){if(this.corruptServerItemsMap(n))return(0,l.default)("[Sync] WARNING: Discarding corrupt folder description from server for "+t),!1;yield this.markChildren(t,n,e.toBeSaved,e.missingChildren)}else yield this.rs.local.setNodes(this.flush(e.toBeSaved))}else yield this.updateCommonTimestamp(t,s);return!0})}handleResponse(t,e,n){return r(this,void 0,void 0,function*(){const r=this.interpretStatus(n.statusCode);if(r.successful){if("get"===e)return this.handleGetResponse(t,r,n.body,n.contentType,n.revision);if("put"===e||"delete"===e)return this.completePush(t,e,r.conflict,n.revision).then(function(){return!0});throw new Error(`cannot handle response for unknown action ${e}`)}{let e;return e=r.unAuth?new h.default:r.networkProblems?new u.default("Network request failed."):new Error("HTTP response code "+r.statusCode+" received."),this.dealWithFailure(t).then(()=>{throw this.rs._emit("error",e),e})}})}finishTask(t){return r(this,arguments,void 0,function*(t,e=!0){if(void 0===t.action)return void delete this._running[t.path];if(e&&((0,l.default)("[Sync] queue finished task:",t.path),this._finishedTasks.push(t),this._finishedTasks.length>1))return void(0,l.default)("[Sync] delaying finished task:",t.path);let n;(0,l.default)("[Sync] run task:",t.path);try{n=yield t.promise}catch(e){(0,l.default)("[Sync] wire client rejects its promise",t.path,t.action,e),n={statusCode:"offline"}}try{const e=yield this.handleResponse(t.path,t.action,n);this.finishSuccessfulTask(t,e)}catch(e){this.finishUnsuccessfulTask(t,e)}})}finishSuccessfulTask(t,e){return r(this,void 0,void 0,function*(){if(this._finishedTasks.shift(),delete this._timeStarted[t.path],delete this._running[t.path],e&&this._tasks[t.path]){for(let e=0;e0?yield this.finishTask(this._finishedTasks[0],!1):yield this.collectTasks(!1).then(()=>{!this.hasTasks()||this.stopped?(this.done||(this.done=!0),this.rs._emit("sync-done",{completed:!0})):setTimeout(()=>{this.doTasks()},10)})})}finishUnsuccessfulTask(t,e){return r(this,void 0,void 0,function*(){(0,l.default)("[Sync]",e.message),this._finishedTasks.shift(),delete this._timeStarted[t.path],delete this._running[t.path],this.rs._emit("sync-req-done",{tasksRemaining:Object.keys(this._tasks).length}),this._finishedTasks.length>0?yield this.finishTask(this._finishedTasks[0],!1):this.done||(this.done=!0,this.rs._emit("sync-done",{completed:!1}))})}tasksWanted(){return this.rs.remote.connected?this.rs.remote.online?this.numThreads:1:0}doTasks(){const t=this.tasksWanted()-Object.keys(this._running).length;if(t<=0)return!0;this.hasTasks()&&!this.done&&this.rs._emit("sync-started");let e,n=0;for(e in this._tasks)if(!this._running[e]&&(this._timeStarted[e]=this.now(),this._running[e]=this.doTask(e).then(this.finishTask.bind(this)),n++,n>=t))break;return n>=t}collectTasks(){return r(this,arguments,void 0,function*(t=!0){if(!this.hasTasks()&&!this.stopped)return(yield this.collectDiffTasks())>0?void 0:t?this.collectRefreshTasks():void 0})}addTask(t,e){this._tasks[t]||(this._tasks[t]=[]),"function"==typeof e&&this._tasks[t].push(e)}sync(){return r(this,void 0,void 0,function*(){if(this.done=!1,!this.doTasks()){try{yield this.collectTasks()}catch(t){throw(0,l.default)("[Sync] Sync error",t),new Error("Local cache unavailable")}this.doTasks()}})}static _rs_init(t){p=function(){const e=new o.default;e.isBrowser()&&function(t,e){function n(t){const n=e.getCurrentSyncInterval();s.default.isBackground=!t;const r=e.getCurrentSyncInterval();e._emit("sync-interval-change",{oldValue:n,newValue:r})}t.on("background",()=>n(!1)),t.on("foreground",()=>n(!0))}(e,t),t.sync||(t.sync=new v(t),t.syncStopped&&((0,l.default)("[Sync] Initializing with sync stopped"),t.sync.stopped=!0,delete t.syncStopped)),t.setupSyncCycle()},f=function(){t.removeEventListener("connected",f),t.startSync()},t.on("ready",p),t.on("connected",f)}static _rs_cleanup(t){t.stopSync(),t.removeEventListener("ready",p),t.removeEventListener("connected",f),t.caching.resetActivationHandler(),t.sync=void 0,delete t.sync}}e.Sync=v,(0,d.applyMixins)(v,[a.default]),e.default=v},370:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})};const i=(this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(n(334));function s(t){return"dropbox"===this.backend&&!!t.match(/^\/public\/.*[^\/]$/)}const o={get:function(t,e){if(this.local){if(void 0===e)e="object"==typeof(n=this).remote&&n.remote.connected&&n.remote.online?2*n.getSyncInterval():((0,i.default)("Not setting default maxAge, because remote is offline or not connected"),!1);else if("number"!=typeof e&&!1!==e)return Promise.reject("Argument 'maxAge' must be 'false' or a number");return this.local.get(t,e,this.sync.queueGetRequest.bind(this.sync))}return this.remote.get(t);var n},put:function(t,e,n){return s.bind(this)(t)?o._wrapBusyDone.call(this,this.remote.put(t,e,n)):this.local?this.local.put(t,e,n):o._wrapBusyDone.call(this,this.remote.put(t,e,n))},delete:function(t,e){return this.local?this.local.delete(t,e):o._wrapBusyDone.call(this,this.remote.delete(t,e))},_wrapBusyDone:function(t){return r(this,void 0,void 0,function*(){return this._emit("wire-busy"),t.then(t=>(this._emit("wire-done",{success:!0}),Promise.resolve(t)),t=>(this._emit("wire-done",{success:!1}),Promise.reject(t)))})}};t.exports=o},613:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BaseClientTypes=void 0;class n{constructor(){this.uris={},this.schemas={},this.aliases={}}declare(t,e,n,r){const i=t+"/"+e;if(r.extends){const e=r.extends.split("/"),n=1===e.length?t+"/"+e.shift():e.join("/"),s=this.uris[n];if(!s)throw"Type '"+i+"' tries to extend unknown schema '"+n+"'";r.extends=this.schemas[s]}this.uris[i]=n,this.aliases[n]=i,this.schemas[n]=r}resolveAlias(t){return this.uris[t]}getSchema(t){return this.schemas[t]}inScope(t){const e=t.length,n={};for(const r in this.uris)if(r.substr(0,e+1)===t+"/"){const t=this.uris[r];n[t]=this.schemas[t]}return n}}e.BaseClientTypes=n,e.default=new n},503:function(t){class e extends Error{constructor(t,e={}){super(),this.name="Unauthorized",this.message=void 0===t?"App authorization expired or revoked.":t,void 0!==e.code&&(this.code=e.code),this.stack=(new Error).stack}}t.exports=e},746:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.toBase64=e.getTextFromArrayBuffer=e.stripLegacyCharsetBinary=e.shouldBeTreatedAsBinary=e.getJSONFromLocalStorage=e.localStorageAvailable=e.pathsFromRoot=e.deepClone=e.equal=e.bindAll=e.cleanPath=e.baseName=e.isDocument=e.isFolder=e.containingFolder=e.extend=e.getGlobalContext=e.globalContext=e.logError=void 0,e.generateCodeVerifier=function(){return r(this,arguments,void 0,function*(t=128){const e=new Uint8Array(t);crypto.getRandomValues(e);const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=Array.from(e).map(t=>n[t%66]),i=r.join(""),s=Uint8Array.from(r.map(t=>t.charCodeAt(0))),o=(a=yield crypto.subtle.digest("SHA-256",s),btoa(String.fromCharCode.apply(null,new Uint8Array(a))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""));var a;return crypto.getRandomValues(e),{codeVerifier:i,codeChallenge:o,state:Array.from(e).map(t=>n[t%66]).join("")}})},e.applyMixins=function(t,e){e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{Object.defineProperty(t.prototype,n,Object.getOwnPropertyDescriptor(e.prototype,n))})})},e.logError=t=>{"string"==typeof t?console.error(t):console.error(t.message,t.stack)},e.globalContext="undefined"!=typeof window?window:"object"==typeof self?self:n.g,e.getGlobalContext=()=>"undefined"!=typeof window?window:"object"==typeof self?self:n.g,e.extend=(...t)=>{const e=t[0];return Array.prototype.slice.call(t,1).forEach(function(t){for(const n in t)e[n]=t[n]}),e},e.containingFolder=t=>{if(""===t)return"/";if(!t)throw"Path not given!";return t.replace(/\/+/g,"/").replace(/[^\/]+\/?$/,"")},e.isFolder=t=>"/"===t.slice(-1),e.isDocument=t=>!(0,e.isFolder)(t),e.baseName=t=>{const n=t.split("/");return(0,e.isFolder)(t)?n[n.length-2]+"/":n[n.length-1]},e.cleanPath=t=>t.replace(/\/+/g,"/").split("/").map(encodeURIComponent).join("/").replace(/'/g,"%27"),e.bindAll=t=>{for(const e in this)"function"==typeof t[e]&&(t[e]=t[e].bind(t))},e.equal=(t,n,r=[])=>{let i;if(typeof t!=typeof n)return!1;if("number"==typeof t||"boolean"==typeof t||"string"==typeof t)return t===n;if("function"==typeof t)return t.toString()===n.toString();if(t instanceof ArrayBuffer&&n instanceof ArrayBuffer&&(t=new Uint8Array(t),n=new Uint8Array(n)),null===t||null===n)return t===n;if(t instanceof Array){if(t.length!==n.length)return!1;for(let i=0,s=t.length;i=0)continue;s=r.slice(),s.push(n[i])}if(!(0,e.equal)(t[i],n[i],s))return!1}}return!0},e.deepClone=t=>void 0===t?void 0:"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t)),e.pathsFromRoot=t=>{const e=[t],n=t.replace(/\/$/,"").split("/");for(;n.length>1;)n.pop(),e.push(n.join("/")+"/");return e},e.localStorageAvailable=()=>{const t=(0,e.getGlobalContext)();if(!("localStorage"in t))return!1;try{return t.localStorage.setItem("rs-check","1"),t.localStorage.removeItem("rs-check"),!0}catch(t){return!1}},e.getJSONFromLocalStorage=t=>{const n=(0,e.getGlobalContext)();try{return JSON.parse(n.localStorage.getItem(t))}catch(t){}},e.shouldBeTreatedAsBinary=(t,e)=>!!(e&&e.match(/charset=binary/)||/[\x00-\x08\x0E-\x1F\x80-\x9F\uFFFD]/.test(t)),e.stripLegacyCharsetBinary=t=>t?t.replace(/\s*;\s*charset=binary\b/i,""):t,e.getTextFromArrayBuffer=(t,n)=>new Promise(r=>{if("undefined"==typeof Blob||"undefined"==typeof FileReader)r(Buffer.from(t).toString(n));else{let i;const s=e.globalContext;if(s.BlobBuilder=s.BlobBuilder||s.WebKitBlobBuilder,void 0!==s.BlobBuilder){const e=new s.BlobBuilder;e.append(t),i=e.getBlob()}else i=new Blob([t]);const o=new FileReader;"function"==typeof o.addEventListener?o.addEventListener("loadend",function(t){r(t.target.result)}):o.onloadend=function(t){r(t.target.result)},o.readAsText(i,n)}}),e.toBase64=t=>{const n=(0,e.getGlobalContext)();return"btoa"in n?n.btoa(t):Buffer.from(t).toString("base64")}},600:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const s=i(n(275)),o=i(n(93)),a=i(n(503)),l=i(n(334)),c=n(746),u=n(368),h=n(684);let d;const p="remotestorage:wireclient",f={"draft-dejong-remotestorage-00":2,"draft-dejong-remotestorage-01":3,"draft-dejong-remotestorage-02":4,"https://www.w3.org/community/rww/wiki/read-write-web-00#simple":1};class g extends h.RemoteBase{constructor(t){if(super(t),this._revisionCache={},d=(0,c.localStorageAvailable)(),this.addEvents(["connected","not-connected"]),d){const t=function(){const{userAddress:t,href:e,storageApi:n,token:r,properties:i}=(0,c.getJSONFromLocalStorage)(p)||{};return{userAddress:t,href:e,storageApi:n,token:r,properties:i}}();t&&setTimeout(()=>{this.configure(t)},0)}this.connected&&setTimeout(this._emit.bind(this),0,"connected")}_request(t,e,n,i,o,h,d){return r(this,void 0,void 0,function*(){if(this.isForbiddenRequestMethod(t,e))return Promise.reject(`Don't use ${t} on directories!`);let r;return n!==s.default.IMPLIED_FAKE_TOKEN&&(i.Authorization="Bearer "+n),this.rs._emit("wire-busy",{method:t,isFolder:(0,c.isFolder)(e)}),(0,u.requestWithTimeout)(t,e,{body:o,headers:i,responseType:"arraybuffer"}).then(n=>{if(this.online||(this.online=!0,this.rs._emit("network-online")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!0}),i=n.status,[401,403,404,412].indexOf(i)>=0)return(0,l.default)("[WireClient] Error response status",n.status),r=h?this.stripQuotes(n.getResponseHeader("ETag")):void 0,401===n.status&&this.rs._emit("error",new a.default),Promise.resolve({statusCode:n.status,revision:r});if(function(t){return[201,204,304].indexOf(t)>=0}(n.status)||200===n.status&&"GET"!==t)return r=this.stripQuotes(n.getResponseHeader("ETag")),(0,l.default)("[WireClient] Successful request",r),Promise.resolve({statusCode:n.status,revision:r});{const t=n.getResponseHeader("Content-Type");r=h?this.stripQuotes(n.getResponseHeader("ETag")):200===n.status?d:void 0;const e=function(t){let e,n="utf-8";return t&&(e=t.match(/charset=(.+)$/),e&&(n=e[1])),n}(t);return(0,c.shouldBeTreatedAsBinary)(n.response,t)?((0,l.default)("[WireClient] Successful request with unknown or binary mime-type",r),Promise.resolve({statusCode:n.status,body:n.response,contentType:(0,c.stripLegacyCharsetBinary)(t),revision:r})):(0,c.getTextFromArrayBuffer)(n.response,e).then(e=>((0,l.default)("[WireClient] Successful request",r),Promise.resolve({statusCode:n.status,body:e,contentType:(0,c.stripLegacyCharsetBinary)(t),revision:r})))}var i},n=>(this.online&&(this.online=!1,this.rs._emit("network-offline")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!1}),Promise.reject(n)))})}configure(t){if("object"!=typeof t)throw new Error("WireClient configure settings parameter should be an object");if(void 0!==t.userAddress&&(this.userAddress=t.userAddress),void 0!==t.href&&(this.href=t.href),void 0!==t.storageApi&&(this.storageApi=t.storageApi),void 0!==t.token&&(this.token=t.token),void 0!==t.properties&&(this.properties=t.properties),"string"==typeof this.storageApi){const t=f[this.storageApi]||5;this.supportsRevs=t>=2}this.href&&this.token?(this.connected=!0,this.online=!0,this._emit("connected")):this.connected=!1,d&&localStorage.setItem(p,JSON.stringify({userAddress:this.userAddress,href:this.href,storageApi:this.storageApi,token:this.token,properties:this.properties}))}get(t,e={}){if(!this.connected)return Promise.reject("not connected (path: "+t+")");const n={};return this.supportsRevs&&e.ifNoneMatch&&(n["If-None-Match"]=this.addQuotes(e.ifNoneMatch)),this._request("GET",this.href+(0,c.cleanPath)(t),this.token,n,void 0,this.supportsRevs,this._revisionCache[t]).then(e=>{if(!(0,c.isFolder)(t))return Promise.resolve(e);let n={};if(void 0!==e.body)try{e.body=JSON.parse(e.body)}catch(e){return Promise.reject("Folder description at "+this.href+(0,c.cleanPath)(t)+" is not JSON")}if(200===e.statusCode&&"object"==typeof e.body){if(0===Object.keys(e.body).length)e.statusCode=404;else if("http://remotestorage.io/spec/folder-description"===(r=e.body)["@context"]&&"object"==typeof r.items){for(const n in e.body.items)this._revisionCache[t+n]=e.body.items[n].ETag;n=e.body.items}else Object.keys(e.body).forEach(r=>{this._revisionCache[t+r]=e.body[r],n[r]={ETag:e.body[r]}});return e.body=n,Promise.resolve(e)}return Promise.resolve(e);var r})}put(t,e,n,r={}){if(!this.connected)return Promise.reject("not connected (path: "+t+")");const i={"Content-Type":n};return this.supportsRevs&&(r.ifMatch&&(i["If-Match"]=this.addQuotes(r.ifMatch)),r.ifNoneMatch&&(i["If-None-Match"]=this.addQuotes(r.ifNoneMatch))),this._request("PUT",this.href+(0,c.cleanPath)(t),this.token,i,e,this.supportsRevs)}delete(t,e={}){if(!this.connected)throw new Error("not connected (path: "+t+")");e||(e={});const n={};return this.supportsRevs&&e.ifMatch&&(n["If-Match"]=this.addQuotes(e.ifMatch)),this._request("DELETE",this.href+(0,c.cleanPath)(t),this.token,n,void 0,this.supportsRevs)}static _rs_init(t){t.remote=new g(t),t.remote.online=!0}static _rs_supported(){return"function"==typeof fetch||"function"==typeof XMLHttpRequest}static _rs_cleanup(){d&&delete localStorage[p]}}(0,c.applyMixins)(g,[o.default]),t.exports=g},439:function(t,e){var n;void 0===(n=function(){var t,e,n,r;Object.keys||(Object.keys=(t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),r=(n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(i){if("object"!=typeof i&&"function"!=typeof i||null===i)throw new TypeError("Object.keys called on non-object");var s=[];for(var o in i)t.call(i,o)&&s.push(o);if(e)for(var a=0;a>>0;if(0===n)return-1;var r=0;if(arguments.length>1&&((r=Number(arguments[1]))!=r?r=0:0!==r&&r!==1/0&&r!==-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=n)return-1;for(var i=r>=0?r:Math.max(n-Math.abs(r),0);i0&&(e+=u.suffices["*"]&&n||",",u.suffices["*"]&&l&&(e+=u.name+"=")),e+=a?encodeURIComponent(h[p]).replace(/!/g,"%21"):o(h[p])}else if("object"==typeof h){l&&!u.suffices["*"]&&(e+=u.name+"=");var f=!0;for(var g in h)f||(e+=u.suffices["*"]&&n||","),f=!1,e+=a?encodeURIComponent(g).replace(/!/g,"%21"):o(g),e+=u.suffices["*"]?"=":",",e+=a?encodeURIComponent(h[g]).replace(/!/g,"%21"):o(h[g])}else l&&(e+=u.name,c&&""===h||(e+="=")),null!=u.truncate&&(h=h.substring(0,u.truncate)),e+=a?encodeURIComponent(h).replace(/!/g,"%21"):o(h)}return e};return w.varNames=u,{prefix:r,substitution:w}}function l(t){if(!(this instanceof l))return new l(t);for(var e=t.split("{"),n=[e.shift()],r=[],i=[],s=[];e.length>0;){var o=e.shift(),c=o.split("}")[0],u=o.substring(c.length+1),h=a(c);i.push(h.substitution),r.push(h.prefix),n.push(u),s=s.concat(h.substitution.varNames)}this.fill=function(t){for(var e=n[0],r=0;r0&&"/"===e.charAt(t.length-1)||"#"===n.charAt(0)||"?"===n.charAt(0))return!0}return!1}(e,t.id)&&void 0===this.schemas[t.id]&&(this.schemas[t.id]=t),t)if("enum"!==r)if("object"==typeof t[r])this.searchSchemas(t[r],e);else if("$ref"===r){var i=g(t[r]);i&&void 0===this.schemas[i]&&void 0===this.missingMap[i]&&(this.missingMap[i]=i)}},c.prototype.addSchema=function(t,e){if("string"!=typeof t||void 0===e){if("object"!=typeof t||"string"!=typeof t.id)return;t=(e=t).id}t===g(t)+"#"&&(t=g(t)),this.schemas[t]=e,delete this.missingMap[t],m(e,t),this.searchSchemas(e,t)},c.prototype.getSchemaMap=function(){var t={};for(var e in this.schemas)t[e]=this.schemas[e];return t},c.prototype.getSchemaUris=function(t){var e=[];for(var n in this.schemas)t&&!t.test(n)||e.push(n);return e},c.prototype.getMissingUris=function(t){var e=[];for(var n in this.missingMap)t&&!t.test(n)||e.push(n);return e},c.prototype.dropSchemas=function(){this.schemas={},this.reset()},c.prototype.reset=function(){this.missing=[],this.missingMap={},this.errors=[]},c.prototype.validateAll=function(t,e,n,r,i){var s;if(!(e=this.resolveRefs(e)))return null;if(e instanceof x)return this.errors.push(e),e;var o,a=this.errors.length,l=null,c=null;if(this.checkRecursive&&t&&"object"==typeof t){if(s=!this.scanned.length,t[this.validatedSchemasKey]){var u=t[this.validatedSchemasKey].indexOf(e);if(-1!==u)return this.errors=this.errors.concat(t[this.validationErrorsKey][u]),null}if(Object.isFrozen(t)&&-1!==(o=this.scannedFrozen.indexOf(t))){var h=this.scannedFrozenSchemas[o].indexOf(e);if(-1!==h)return this.errors=this.errors.concat(this.scannedFrozenValidationErrors[o][h]),null}if(this.scanned.push(t),Object.isFrozen(t))-1===o&&(o=this.scannedFrozen.length,this.scannedFrozen.push(t),this.scannedFrozenSchemas.push([])),l=this.scannedFrozenSchemas[o].length,this.scannedFrozenSchemas[o][l]=e,this.scannedFrozenValidationErrors[o][l]=[];else{if(!t[this.validatedSchemasKey])try{Object.defineProperty(t,this.validatedSchemasKey,{value:[],configurable:!0}),Object.defineProperty(t,this.validationErrorsKey,{value:[],configurable:!0})}catch(e){t[this.validatedSchemasKey]=[],t[this.validationErrorsKey]=[]}c=t[this.validatedSchemasKey].length,t[this.validatedSchemasKey][c]=e,t[this.validationErrorsKey][c]=[]}}var d=this.errors.length,p=this.validateBasic(t,e,i)||this.validateNumeric(t,e,i)||this.validateString(t,e,i)||this.validateArray(t,e,i)||this.validateObject(t,e,i)||this.validateCombinations(t,e,i)||this.validateHypermedia(t,e,i)||this.validateFormat(t,e,i)||this.validateDefinedKeywords(t,e,i)||null;if(s){for(;this.scanned.length;)delete this.scanned.pop()[this.validatedSchemasKey];this.scannedFrozen=[],this.scannedFrozenSchemas=[]}if(p||d!==this.errors.length)for(;n&&n.length||r&&r.length;){var f=n&&n.length?""+n.pop():null,g=r&&r.length?""+r.pop():null;p&&(p=p.prefixWith(f,g)),this.prefixErrors(d,f,g)}return null!==l?this.scannedFrozenValidationErrors[o][l]=this.errors.slice(a):null!==c&&(t[this.validationErrorsKey][c]=this.errors.slice(a)),this.handleError(p)},c.prototype.validateFormat=function(t,e){if("string"!=typeof e.format||!this.formatValidators[e.format])return null;var n=this.formatValidators[e.format].call(null,t,e);return"string"==typeof n||"number"==typeof n?this.createError(v.FORMAT_CUSTOM,{message:n},"","/format",null,t,e):n&&"object"==typeof n?this.createError(v.FORMAT_CUSTOM,{message:n.message||"?"},n.dataPath||"",n.schemaPath||"/format",null,t,e):null},c.prototype.validateDefinedKeywords=function(t,e,n){for(var r in this.definedKeywords)if(void 0!==e[r])for(var i=this.definedKeywords[r],s=0;s=h&&re.maximum)return this.createError(v.NUMBER_MAXIMUM,{value:t,maximum:e.maximum},"","/maximum",null,t,e);if(e.exclusiveMaximum&&t===e.maximum)return this.createError(v.NUMBER_MAXIMUM_EXCLUSIVE,{value:t,maximum:e.maximum},"","/exclusiveMaximum",null,t,e)}return null},c.prototype.validateNaN=function(t,e){return"number"!=typeof t?null:!0===isNaN(t)||t===1/0||t===-1/0?this.createError(v.NUMBER_NOT_A_NUMBER,{value:t},"","/type",null,t,e):null},c.prototype.validateString=function(t,e,n){return this.validateStringLength(t,e,n)||this.validateStringPattern(t,e,n)||null},c.prototype.validateStringLength=function(t,e){return"string"!=typeof t?null:void 0!==e.minLength&&t.lengthe.maxLength?this.createError(v.STRING_LENGTH_LONG,{length:t.length,maximum:e.maxLength},"","/maxLength",null,t,e):null},c.prototype.validateStringPattern=function(t,e){if("string"!=typeof t||"string"!=typeof e.pattern&&!(e.pattern instanceof RegExp))return null;var n;if(e.pattern instanceof RegExp)n=e.pattern;else{var r,i="",s=e.pattern.match(/^\/(.+)\/([img]*)$/);s?(r=s[1],i=s[2]):r=e.pattern,n=new RegExp(r,i)}return n.test(t)?null:this.createError(v.STRING_PATTERN,{pattern:e.pattern},"","/pattern",null,t,e)},c.prototype.validateArray=function(t,e,n){return Array.isArray(t)&&(this.validateArrayLength(t,e,n)||this.validateArrayUniqueItems(t,e,n)||this.validateArrayItems(t,e,n))||null},c.prototype.validateArrayLength=function(t,e){var n;return void 0!==e.minItems&&t.lengthe.maxItems&&(n=this.createError(v.ARRAY_LENGTH_LONG,{length:t.length,maximum:e.maxItems},"","/maxItems",null,t,e),this.handleError(n))?n:null},c.prototype.validateArrayUniqueItems=function(t,e){if(e.uniqueItems)for(var n=0;ne.maxProperties&&(n=this.createError(v.OBJECT_PROPERTIES_MAXIMUM,{propertyCount:r.length,maximum:e.maxProperties},"","/maxProperties",null,t,e),this.handleError(n))?n:null},c.prototype.validateObjectRequiredProperties=function(t,e){if(void 0!==e.required)for(var n=0;n 10000");if(void 0!==v[t])throw new Error("Error already defined: "+t+" as "+v[t]);if(void 0!==b[e])throw new Error("Error code already used: "+b[e]+" as "+e);for(var r in v[t]=e,b[e]=t,_[t]=_[e]=n,C){var i=C[r];i[t]&&(i[e]=i[e]||i[t])}},reset:function(){i.reset(),this.error=null,this.missing=[],this.valid=!0},missing:[],error:null,valid:!0,normSchema:m,resolveUrl:f,getDocumentUri:g,errorCodes:v};return s.language(e||"en"),s}();return S.addLanguage("en-gb",_),S.tv4=S,S}.apply(e,[]))||(t.exports=n)},713:function(t){!function(){{const e=function(){var t={"http://webfinger.net/rel/avatar":"avatar",remotestorage:"remotestorage","http://tools.ietf.org/id/draft-dejong-remotestorage":"remotestorage",remoteStorage:"remotestorage","http://www.packetizer.com/rel/share":"share","http://webfinger.net/rel/profile-page":"profile",me:"profile",vcard:"vcard",blog:"blog","http://packetizer.com/rel/blog":"blog","http://schemas.google.com/g/2010#updates-from":"updates","https://camlistore.org/rel/server":"camilstore"},e={avatar:[],remotestorage:[],blog:[],vcard:[],updates:[],share:[],profile:[],camlistore:[]},n=["webfinger","host-meta","host-meta.json"],r="(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)",i=new RegExp(`^(?:${r}\\.){3}${r}$`),s=new RegExp(`^(${r})\\.(${r})\\.(${r})\\.(${r})$`),o=/^localhost(?:\.localdomain)?(?::\d+)?$/,a=/^\d+$/,l=/^[a-zA-Z0-9.-]+$/,c=/^127\.(?:\d{1,3}\.){2}\d{1,3}$/;function u(t){const e=t.match(s);return e?e.slice(1).map(Number):null}function h(t){const[e,n]=t;return 0===e||10===e||127===e||172===e&&n>=16&&n<=31||192===e&&168===n||169===e&&254===n||e>=224&&e<=239||e>=240}class d extends Error{status;constructor(t,e){super(t),this.name="WebFingerError",this.status=e}}class p{static default;config;constructor(t={}){this.config={tls_only:void 0===t.tls_only||t.tls_only,uri_fallback:void 0!==t.uri_fallback&&t.uri_fallback,request_timeout:void 0!==t.request_timeout?t.request_timeout:1e4,allow_private_addresses:void 0!==t.allow_private_addresses&&t.allow_private_addresses}}async fetchJRD(t,e=0){if(e>3)throw new d("too many redirects");const n=new AbortController,r=setTimeout(()=>{n.abort()},this.config.request_timeout);try{const i=await fetch(t,{headers:{Accept:"application/jrd+json, application/json"},redirect:"manual",signal:n.signal});if(i.status>=300&&i.status<400){const n=i.headers.get("location");if(!n)throw new d("redirect without location header");let s;try{s=new URL(n,t)}catch{throw new d("invalid redirect URL")}try{await this.resolveAndValidateHost(s.host)}catch(t){if(t instanceof d)throw new d("redirect to private or internal address blocked");throw t}return clearTimeout(r),this.fetchJRD(s.toString(),e+1)}if(404===i.status)throw new d("resource not found",404);if(!i.ok)throw new d("error during request",i.status);const s=i.headers.get("content-type")||"",o=s.toLowerCase().split(";")[0].trim();"application/jrd+json"===o||("application/json"===o?console.debug('WebFinger: Server uses "application/json" instead of RFC 7033 recommended "application/jrd+json".'):console.warn(`WebFinger: Server returned unexpected content-type "${s}". Expected "application/jrd+json" per RFC 7033.`));const a=await i.text();if(p.isValidJSON(a))return a;throw new d("invalid json")}catch(t){if(n.signal.aborted)throw new d("request timed out");throw t}finally{clearTimeout(r)}}static isValidJSON(t){try{JSON.parse(t)}catch{return!1}return!0}static isLocalhost(t){return o.test(t)}static isPrivateAddress(t){let e=t;if(e.startsWith("[")&&e.includes("]:"))e=e.substring(1,e.lastIndexOf("]:"));else if(e.startsWith("[")&&e.endsWith("]"))e=e.substring(1,e.length-1);else if(e.includes(":")&&1===(e.match(/:/g)||[]).length){const t=e.split(":"),n=t[0],r=t[1];if(r&&!a.test(r))throw new d("invalid host format");(n.match(i)||n.match(l))&&(e=n)}if("localhost"===e||"127.0.0.1"===e||e.match(c)||"::1"===e||"localhost.localdomain"===e)return!0;const n=u(e);if(n)return h(n);const r=function(t){let e=t.toLowerCase();const n=u(e.substring(e.lastIndexOf(":")+1));if(n&&(e=`${e.substring(0,e.lastIndexOf(":"))}:${(n[0]<<8|n[1]).toString(16)}:${(n[2]<<8|n[3]).toString(16)}`),!/^[0-9a-f:]+$/.test(e)||e.indexOf("::")!==e.lastIndexOf("::"))return null;const r=e.includes("::"),[i="",s=""]=e.split("::"),o=i?i.split(":"):[],a=r&&s?s.split(":"):[],l=8-o.length-a.length;if(!r&&8!==o.length||r&&l<1)return null;const c=(r?[...o,...Array(l).fill("0"),...a]:o).map(t=>Number.parseInt(t,16));return 8===c.length&&c.every(t=>t>=0&&t<=65535)?c:null}(e);if(r){const t=r.slice(0,5).every(t=>0===t)&&65535===r[5],e=r.slice(0,6).every(t=>0===t);if(t||e)return h([r[6]>>8,255&r[6],r[7]>>8,255&r[7]]);const n=r[0];return 64512==(65024&n)||65152==(65472&n)||!(65280&~n)}return!1}static getExplicitPort(t){if(t.startsWith("[")){const e=t.lastIndexOf("]:");if(-1!==e){const n=t.substring(e+2);if(!a.test(n))throw new d("invalid host format");return n}return}if(1===(t.match(/:/g)||[]).length){const[,e=""]=t.split(":");if(!e||!a.test(e))throw new d("invalid host format");return e}}static parseAddress(t){const e=t.replace(/ /g,"");if(e.includes("://")){let t;try{t=new URL(e)}catch{throw new d("invalid URI format")}if(!t.hostname)throw new d("could not determine host from address");return{host:t.host}}const n=e.split("@");if(2!==n.length||!n[1])throw new d("invalid useraddress format");return{host:n[1]}}async resolveAndValidateHost(t){const e=p.normalizeHost(t);if(!this.config.allow_private_addresses){if(p.isPrivateAddress(e.host))throw new d("private or internal addresses are not allowed");await this.validateDNSResolution(e.hostname)}return e}static normalizeHost(t){const e=t.split("/")[0];if(!e||0===e.length)throw new d("invalid host format");if(/[?# @]/.test(e))throw new d("invalid characters in host");const n=p.getExplicitPort(e);let r;try{r=new URL(`http://${e}`)}catch{throw new d("invalid host format")}const i=r.hostname;return{host:n?`${i}:${n}`:r.host||i,hostname:i}}static async processJRD(n,r){const i=JSON.parse(r);if("object"!=typeof i||"object"!=typeof i.links)throw void 0!==i.error?new d(i.error):new d("unknown response from server");const s={object:i,idx:{properties:{name:void 0},links:JSON.parse(JSON.stringify(e))}};(Array.isArray(i.links)?i.links:[]).map(function(e){if(Object.prototype.hasOwnProperty.call(t,String(e.rel))){const n=t[String(e.rel)];if(s.idx.links[n]){const t={href:String(e.href||""),rel:String(e.rel||"")};Object.keys(e).map(function(n){"object"==typeof e[n]&&null!==e[n]?t[n]=e[n]:t[n]=String(e[n])}),s.idx.links[n].push(t)}}});const o=i.properties||{};for(const t in o)Object.prototype.hasOwnProperty.call(o,t)&&"http://packetizer.com/ns/name"===t&&(s.idx.properties.name=o[t]);return s}async validateDNSResolution(t){if(!t.match(i)&&!t.includes(":")&&"localhost"!==t&&"undefined"!=typeof process&&process.versions?.node){const e="function"==typeof process.getBuiltinModule?process.getBuiltinModule("node:dns")?.promises:null;if(e)try{const[n,r]=await Promise.allSettled([e.resolve4(t).catch(()=>[]),e.resolve6(t).catch(()=>[])]),i="fulfilled"===n.status?n.value:[],s="fulfilled"===r.status?r.value:[];for(const e of[...i,...s])if(p.isPrivateAddress(e))throw new d(`hostname ${t} resolves to private address ${e}`)}catch(t){if(t instanceof d)throw t}}}async lookup(t){if(!t)throw new d("address is required");const{host:e}=p.parseAddress(t),{host:r}=await this.resolveAndValidateHost(e);let i=0,s="https";p.isLocalhost(r)&&(s="http");const o=async t=>{if(this.config.uri_fallback&&i!==n.length-1)return i+=1,a();if(this.config.tls_only||"https"!==s)throw t instanceof Error?t:new d(String(t));return i=0,s="http",a()},a=async()=>{const e=(()=>{let e="";return t.split("://")[1]||(e="acct:"),s+"://"+r+"/.well-known/"+n[i]+"?resource="+e+t})();try{const t=await this.fetchJRD(e);return p.processJRD(e,t)}catch(t){return await o(t)}};return a()}async lookupLink(t,n){if(Object.prototype.hasOwnProperty.call(e,n)){const e=(await this.lookup(t)).idx.links[n];return 0===e.length?Promise.reject('no links found with rel="'+n+'"'):Promise.resolve(e[0])}return Promise.reject("unsupported rel "+n)}}return p.default=p,p}();t.exports=e,t.exports.default=e}}("undefined"!=typeof self&&self)}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n(423).default}()},"object"==typeof t&&"object"==typeof e?e.exports=r():"function"==typeof define&&define.amd?define("RemoteStorage",[],r):"object"==typeof t?t.RemoteStorage=r():n.RemoteStorage=r()}),NU=l(OU(),1),FU="0123456789ABCDEFGHJKMNPQRSTVWXYZ";!function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"}(EU||(EU={}));var DU=class extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}};function zU(t){const e=Math.floor(32*t())%32;return FU.charAt(e)}var jU={type:"object",properties:{id:{type:"string"},title:{type:"string"},lat:{type:"number"},lon:{type:"number"},geohash:{type:"string"},zoom:{type:"number"},url:{type:"string"},osmId:{type:"string"},osmType:{type:"string"},osmTags:{type:"object",additionalProperties:{type:"string"}},description:{type:"string"},tags:{type:"array",items:{type:"string"},default:[]},createdAt:{type:"string",format:"date-time"},updatedAt:{type:"string",format:"date-time"}},required:["id","title","lat","lon","geohash","createdAt"]},UU={type:"object",properties:{id:{type:"string"},title:{type:"string"},color:{type:"string"},placeRefs:{type:"array",items:{type:"object",properties:{id:{type:"string"},geohash:{type:"string"}},required:["id","geohash"]},default:[]},createdAt:{type:"string",format:"date-time"},updatedAt:{type:"string",format:"date-time"}},required:["id","title","placeRefs","createdAt"]},BU={name:"places",builder:function(t){function e(t,e){return`${t.substring(0,2)}/${t.substring(2,4)}/${e}`}t.declareType("place",jU),t.declareType("list",UU);const n={async getAll(){const e=await t.getAll("_lists/");return e?Object.values(e):[]},async get(e){const n=`_lists/${e}`;return t.getObject(n)},async getPlaces(n){const r=await this.get(n);if(!r)throw new Error(`List not found: ${n}`);if(!r.placeRefs||!Array.isArray(r.placeRefs))return[];const i=r.placeRefs.map(async n=>{if(!n.id||!n.geohash)return null;const r=e(n.geohash,n.id);return await t.getObject(r)});return(await Promise.all(i)).filter(t=>!!t)},async create(e,n,r){const i=`_lists/${e}`;let s=await t.getObject(i);const o=(new Date).toISOString();return s?(s.title=n,r&&(s.color=r),s.updatedAt=o):s={id:e,title:n,color:r,placeRefs:[],createdAt:o,updatedAt:o},await t.storeObject("list",i,s),s},async delete(e){await t.remove(`_lists/${e}`)},async addPlace(e,n,r){const i=`_lists/${e}`,s=await t.getObject(i);if(!s)throw new Error(`List not found: ${e}`);return-1===s.placeRefs.findIndex(t=>t.id===n)&&(s.placeRefs.push({id:n,geohash:r}),s.updatedAt=(new Date).toISOString(),await t.storeObject("list",i,s)),s},async removePlace(e,n){const r=`_lists/${e}`,i=await t.getObject(r);if(!i)throw new Error(`List not found: ${e}`);const s=i.placeRefs.findIndex(t=>t.id===n);return-1!==s&&(i.placeRefs.splice(s,1),i.updatedAt=(new Date).toISOString(),await t.storeObject("list",r,i)),i},async initDefaults(){for(const t of[{id:"to-go",title:"Want to go",color:"#2e9e4f"},{id:"to-do",title:"To do",color:"#2a7fff"}])await this.get(t.id)||await this.create(t.id,t.title,t.color)}};return{exports:{lists:n,store:async function(n){const r=function(t){const e=(new Date).toISOString(),n=t.id||function(t,e){const n=e||function(){const t="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:null,e=t&&(t.crypto||t.msCrypto)||null;if("function"==typeof e?.getRandomValues)return()=>{const t=new Uint8Array(1);return e.getRandomValues(t),t[0]/256};if("function"==typeof e?.randomBytes)return()=>e.randomBytes(1).readUInt8()/256;throw new DU(EU.PRNGDetectFailure,"Failed to find a reliable PRNG")}();return function(t,e=10){if(isNaN(t))throw new DU(EU.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>0xffffffffffff)throw new DU(EU.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${t}`);if(t<0)throw new DU(EU.EncodeTimeNegative,`Time must be positive: ${t}`);if(!1===Number.isInteger(t))throw new DU(EU.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let i=e;i>0;i--)n=t%32,r=FU.charAt(n)+r,t=(t-n)/32;return r}(!t||isNaN(t)?Date.now():t,10)+function(t,e){let n="";for(;t>0;t--)n=zU(e)+n;return n}(16,n)}(),r="number"==typeof t.lat?t.lat:0,i="number"==typeof t.lon?t.lon:0,s=t.title||"Untitled Place",o=t.geohash||_j.encode(r,i,10),a={...t,id:n,lat:r,lon:i,geohash:o,title:s,tags:t.tags||[],createdAt:t.createdAt||e,updatedAt:t.id?e:void 0};return Object.keys(a).forEach(t=>{void 0===a[t]&&delete a[t]}),a}(n),i=e(r.geohash,r.id);return await t.storeObject("place",i,r),r},remove:async function(r,i){if(!r||!i)throw new Error("Both id and geohash are required to remove a place");const s=await n.getAll();await Promise.all(s.map(async e=>{const n=e.placeRefs.findIndex(t=>t.id===r);-1!==n&&(e.placeRefs.splice(n,1),e.updatedAt=(new Date).toISOString(),await t.storeObject("list",`_lists/${e.id}`,e))}));const o=e(i,r);return t.remove(o)},get:async function(n,r){if(!n||!r)throw new Error("Both id and geohash are required to get a place");const i=e(r,n);return t.getObject(i)},listByPrefix:async function(e){let n="";return e.length>=2&&(n+=e.substring(0,2)+"/"),e.length>=4&&(n+=e.substring(2,4)+"/"),t.getAll(n)},getPlaces:async function(e){const n=[],r=async e=>{const r=await t.getAll(e,!1);r&&Object.values(r).forEach(t=>{t&&"object"==typeof t&&!t.toString().endsWith("/")&&n.push(t)})};if(e&&e.length>0){const t=e.map(async t=>{if(t.length<4)return;const e=t.substring(0,2),n=t.substring(2,4);await r(`${e}/${n}/`)});await Promise.all(t)}else{const e=t=>{if(!t||"object"!=typeof t)return[];let e=t;return t.items&&"object"==typeof t.items&&(e=t.items),Object.keys(e).filter(t=>t.endsWith("/")&&!t.startsWith("@"))},n=e(await t.getListing("",!1));await Promise.all(n.map(async n=>{const i=await t.getListing(n,!1),s=e(i);await Promise.all(s.map(async t=>{await r(n+t)}))}))}return n}}}}},$U=o((t,e)=>{var n,r;n=self,r=()=>(()=>{var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function r(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}t.d(e,{default:()=>i});const i=function(){return t=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.rs=e,this.leaveOpen=!!n.leaveOpen&&n.leaveOpen,this.autoCloseAfter=n.autoCloseAfter?n.autoCloseAfter:1500,this.skipInitial=!!n.skipInitial&&n.skipInitial,this.logging=!!n.logging&&n.logging,this.parentContainerEl=null,n.hasOwnProperty("modalBackdrop")){if("boolean"!=typeof n.modalBackdrop&&"onlySmallScreens"!==n.modalBackdrop)throw'options.modalBackdrop has to be true/false or "onlySmallScreens"';this.modalBackdrop=n.modalBackdrop}else this.modalBackdrop="onlySmallScreens";this.active=!1,this.online=!1,this.closed=!1,this.lastSynced=null,this.lastSyncedUpdateLoop=null},e=[{key:"log",value:function(){if(this.logging){for(var t,e=arguments.length,n=new Array(e),r=0;r

Connect your storage

To sync data with your account
';var e=document.createElement("style");return e.innerHTML='#remotestorage-widget {\n z-index: 21000000;\n}\n\n.rs-widget {\n box-sizing: border-box;\n overflow: hidden;\n max-width: 350px;\n padding: 10px;\n margin: 10px;\n border-radius: 3px;\n background-color: #fff;\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n font-family: arial, sans-serif;\n font-size: 16px;\n color: #333;\n will-change: max-height, height, width, opacity, max-width, background, box-shadow;\n transition-property: width, height, opacity, max-width, max-height, background, box-shadow;\n transition-duration: 300ms;\n}\n\n.rs-widget * {\n box-sizing: border-box;\n}\n\n.rs-widget .rs-hidden {\n display: none;\n}\n\n.rs-box {\n overflow: hidden;\n will-change: height;\n transition-property: height, width, max-height;\n transition-duration: 300ms;\n transition-timing-function: ease-in;\n opacity: 0;\n max-height: 0px;\n}\n\n.rs-box.rs-selected:not([aria-hidden=true]) {\n opacity: 1;\n max-height: 420px;\n}\n\n/* Main logo */\n.rs-main-logo {\n float: left;\n height: 36px;\n width: 36px;\n margin-top: 1px;\n margin-right: 0.625em;\n transition: margin-left 300ms ease-out, transform 300ms ease-out;\n cursor: pointer;\n}\n.rs-widget .rs-backend-remotestorage svg#rs-main-logo-remotestorage {\n display: block;\n}\n.rs-widget[class*="rs-backend-"]:not(.rs-backend-remotestorage) svg#rs-main-logo-remotestorage {\n display: none;\n}\n.rs-widget.rs-backend-dropbox svg#rs-main-logo-dropbox {\n display: block;\n}\n.rs-widget:not(.rs-backend-dropbox) svg#rs-main-logo-dropbox {\n display: none;\n}\n.rs-widget.rs-backend-googledrive svg#rs-main-logo-googledrive {\n display: block;\n}\n.rs-widget:not(.rs-backend-googledrive) svg#rs-main-logo-googledrive {\n display: none;\n}\n\npolygon.rs-logo-shape {\n fill: #FF4B03;\n}\n\npolygon.rs-logo-shape,\n#rs-main-logo-dropbox path,\n#rs-main-logo-googledrive path {\n transition-property: fill;\n transition-duration: 0.5s;\n}\n\n.rs-offline polygon.rs-logo-shape,\n.rs-offline #rs-main-logo-dropbox path,\n.rs-offline #rs-main-logo-googledrive path {\n fill: #888;\n transition-property: fill;\n transition-duration: 0.5s;\n}\n\n/* Hide everything except logo when connected and clicked outside of box */\n.rs-closed {\n max-width: 56px;\n background-color: transparent;\n box-shadow: none;\n opacity: 0.5;\n\n transition: max-height 100ms ease-out 0ms, max-width 300ms ease-out 300ms, background 300ms ease-in 200ms, opacity 300ms ease 200ms;\n}\n\n.rs-closed:hover {\n cursor: pointer;\n opacity: 1;\n}\n\n.rs-box-initial {\n transition-duration: 0ms;\n}\n\n.rs-box-initial:hover {\n cursor: pointer;\n}\n\n.rs-widget a {\n color: #0093cc;\n}\n\n/* HEADLINE */\n.rs-small-headline {\n font-size: 1em;\n font-weight: bold;\n margin: 0;\n margin-bottom: 2px;\n height: 1.2em;\n word-break: break-all;\n overflow: hidden;\n line-height: 1em;\n}\n\n.rs-sub-headline {\n word-break: break-all;\n overflow: hidden;\n color: #666;\n font-size: 0.92em;\n height: 1.2em;\n}\n.rs-big-headline {\n font-size: 1.625em;\n font-weight: normal;\n text-align: center;\n margin-top: 20px;\n margin-bottom: 20px;\n}\n\n/* BUTTONS */\n.rs-button {\n font: inherit;\n color: inherit;\n background-color: transparent;\n border: 1px solid #dcdcdc;\n border-radius: 3px;\n cursor: pointer;\n}\n.rs-button-small {\n padding: 0.6em 0.7em;\n margin-left: 0.2em;\n transition: border-color 300ms ease-out;\n}\n.rs-button-small svg {\n vertical-align: top;\n}\n.rs-button-wrap {\n margin-top: 10px;\n}\n\n.rs-button-wrap img,\n.rs-button-wrap svg {\n float: left;\n margin-right: 0.6em;\n width: 40px;\n height: 40px;\n}\n\n.rs-button-big {\n padding: 15px 10px;\n margin-bottom: 10px;\n display: block;\n width: 100%;\n text-align: left;\n transition: box-shadow 200ms;\n}\n.rs-button-big > div {\n font-size: 1.125em;\n padding: 10px 0;\n}\n.rs-button-big:hover {\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n}\n.rs-button-big:active {\n background-color: #eee;\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n}\n.rs-button-big:last-child {\n margin-bottom: 0;\n}\n\n.rs-content {\n padding: 0 10px 10px 10px;\n}\n\n\n.rs-state-choose .rs-main-logo,\n.rs-state-sign-in .rs-main-logo {\n margin-left: 45%;\n float: none;\n}\n\n.rs-sign-in-form input[type=text] {\n padding: 15px 10px;\n display: block;\n width: 100%;\n font: inherit;\n height: 52px;\n border: 1px solid #aaa;\n border-radius: 0;\n box-shadow: none;\n}\n.rs-sign-in-form button.rs-connect {\n padding: 15px 10px;\n margin-top: 20px;\n margin-bottom: 15px;\n display: block;\n width: 100%;\n border: none;\n border-radius: 3px;\n background-color: #3fb34f;\n font: inherit;\n color: #fff;\n transition: box-shadow 200ms, background-color 200ms;\n}\n\n.rs-sign-in-form button.rs-connect:hover {\n cursor: pointer;\n background-color: #4BCB5D;\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n}\n\n.rs-sign-in-form button.rs-connect:active {\n background-color: #3fb34f;\n}\n\n.rs-sign-in-form button.rs-connect:disabled,\n.rs-sign-in-form button.rs-connect:disabled:hover {\n background-color: #aaa;\n}\n\n.rs-sign-in-form button.rs-connecting svg {\n height: 1em;\n width: auto;\n vertical-align: middle;\n margin-left: 0.5em;\n animation: rs-spin 1s linear infinite;\n}\n\n.rs-sign-in-error.rs-hidden,\n.rs-box-error.rs-hidden {\n height: 0;\n}\n\n.rs-sign-in-error.rs-visible,\n.rs-box-error.rs-visible {\n height: auto;\n border-radius: 3px;\n padding: 0.5em 0.5em;\n margin-top: 0.5em;\n text-align: center;\n background-color: rgba(255,0,0,0.1);\n color: darkred;\n}\n\n.rs-box-error {\n display: flex;\n flex-direction: row;\n}\n\n.rs-box-error .rs-error-message {\n flex: auto;\n}\n\n /*Choose provider box */\n.rs-box-choose {\n text-align: center;\n overflow: hidden;\n}\n\n.rs-box-choose p {\n margin-top: 0;\n margin-bottom: 20px;\n line-height: 1.4em;\n}\n\n/*Connected box */\n.rs-box-connected {\n display: flex;\n flex-direction: row;\n height: 40px;\n transition: height 0s;\n}\n.rs-connected-text {\n flex: auto;\n min-width: 0;\n}\n.rs-box-connected .rs-user {\n font-weight: bold;\n text-overflow: ellipsis;\n overflow: hidden;\n word-break: keep-all;\n}\n.rs-connected-buttons, .rs-error-buttons {\n flex: none;\n}\n.rs-disconnect:hover {\n border-color: #FF2D2D;\n}\n.rs-disconnect:hover .rs-icon{\n fill: #FF2D2D;\n}\n.rs-sync:hover {\n border-color: #FFBB0C;\n}\n.rs-sync:hover .rs-icon {\n fill: #FFBB0C;\n}\n.rs-sync.rs-rotate {\n border-color: #FFBB0C;\n}\n.rs-sync.rs-rotate .rs-icon {\n fill: #FFBB0C;\n animation: rs-spin 1s linear infinite;\n}\n\n/* Floating widget styles (top right corner) */\n.rs-floating {\n position: fixed;\n top: 0;\n right: 0;\n}\n\n@keyframes rs-spin {\n 100% {\n transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n/* Small/mobile screens */\n@media screen and (max-width: 420px) {\n .rs-widget {\n font-size: 100%;\n transition: all 300ms ease-out;\n max-width: 400px;\n }\n .rs-floating {\n position: relative;\n top: auto;\n right: auto\n }\n .rs-closed {\n max-width: 56px;\n }\n .rs-state-choose,\n .rs-state-sign-in {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n max-width: 100%;\n }\n}\n\n/* remove dotted outline border on Firefox */\n.rs-widget a:focus,\n.rs-widget a:active,\n.rs-widget button:focus,\n.rs-widget input:focus {\n outline:none;\n}\n.rs-widget button::-moz-focus-inner,\n.rs-widget input[type="button"]::-moz-focus-inner {\n border:0;\n}\n\n/* prevent rounded buttons on mobile Safari */\n.rs-widget button,\n.rs-widget input[type="button"] {\n -webkit-appearance: none;\n}\n\n.remotestorage-widget-modal-backdrop {\n display: none;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: rgba(0, 0, 0, 0.5);\n opacity: 0;\n transition: opacity 0.3s linear;\n}\n\n.remotestorage-widget-modal-backdrop.visible {\n opacity: 1;\n transition: opacity 0.3s linear;\n}\n',t.appendChild(e),t}},{key:"setModalClass",value:function(){if(this.modalBackdrop){if("onlySmallScreens"===this.modalBackdrop&&!this.isSmallScreen())return;this.rsWidget.classList.add("rs-modal")}}},{key:"setupElements",value:function(){if(!this.parentContainerEl)throw new Error("Parent container element not found");this.rsWidget=this.parentContainerEl.querySelector(".rs-widget"),this.rsBackdrop=this.parentContainerEl.querySelector(".remotestorage-widget-modal-backdrop"),this.rsInitial=this.parentContainerEl.querySelector(".rs-box-initial"),this.rsChoose=this.parentContainerEl.querySelector(".rs-box-choose"),this.rsConnected=this.parentContainerEl.querySelector(".rs-box-connected"),this.rsSignIn=this.parentContainerEl.querySelector(".rs-box-sign-in"),this.rsConnectedLabel=this.parentContainerEl.querySelector(".rs-box-connected .rs-sub-headline"),this.rsChooseRemoteStorageButton=this.parentContainerEl.querySelector("button.rs-choose-rs"),this.rsChooseDropboxButton=this.parentContainerEl.querySelector("button.rs-choose-dropbox"),this.rsChooseGoogleDriveButton=this.parentContainerEl.querySelector("button.rs-choose-googledrive"),this.rsErrorBox=this.parentContainerEl.querySelector(".rs-box-error .rs-error-message"),this.rs.apiKeys.hasOwnProperty("googledrive")||this.rsChooseGoogleDriveButton.parentNode.removeChild(this.rsChooseGoogleDriveButton),this.rs.apiKeys.hasOwnProperty("dropbox")||this.rsChooseDropboxButton.parentNode.removeChild(this.rsChooseDropboxButton),this.rsSignInForm=this.parentContainerEl.querySelector(".rs-sign-in-form"),this.rsAddressInput=this.rsSignInForm.querySelector("input[name=rs-user-address]"),this.rsConnectButton=this.parentContainerEl.querySelector(".rs-connect"),this.rsDisconnectButton=this.parentContainerEl.querySelector(".rs-disconnect"),this.rsSyncButton=this.parentContainerEl.querySelector(".rs-sync"),this.rsLogo=this.parentContainerEl.querySelector(".rs-widget-icon"),this.rsErrorReconnectLink=this.parentContainerEl.querySelector(".rs-box-error a.rs-reconnect"),this.rsErrorDisconnectButton=this.parentContainerEl.querySelector(".rs-box-error button.rs-disconnect"),this.rsConnectedUser=this.parentContainerEl.querySelector(".rs-connected-text h1.rs-user")}},{key:"setupHandlers",value:function(){var t=this;this.rs.on("connected",function(){return t.eventHandler("connected")}),this.rs.on("ready",function(){return t.eventHandler("ready")}),this.rs.on("disconnected",function(){return t.eventHandler("disconnected")}),this.rs.on("network-online",function(){return t.eventHandler("network-online")}),this.rs.on("network-offline",function(){return t.eventHandler("network-offline")}),this.rs.on("error",function(e){return t.eventHandler("error",e)}),this.setEventListeners(),this.setClickHandlers()}},{key:"attach",value:function(t){var e=this.createHtmlTemplate(t);if(this.parentContainerEl,t instanceof HTMLElement)this.parentContainerEl=t;else if("string"==typeof t){if(this.parentContainerEl=document.getElementById(t),!this.parentContainerEl)throw new Error('Failed to find target DOM element with id="'+t+'"')}else{if(t)throw new Error("Unknown element type. Expected instance of HTMLElement or type of string.");this.parentContainerEl=document.body}this.parentContainerEl.appendChild(e),this.setupElements(),this.setupHandlers(),this.setInitialState(),this.setModalClass()}},{key:"setEventListeners",value:function(){var t=this;this.rsSignInForm.addEventListener("submit",function(e){e.preventDefault();var n=t.parentContainerEl.querySelector("input[name=rs-user-address]").value.trim();t.disableConnectButton(),t.rs.connect(n)})}},{key:"showChooseOrSignIn",value:function(){this.rsWidget.classList.contains("rs-modal")&&(this.rsBackdrop.style.display="block",this.rsBackdrop.classList.add("visible")),this.rs.apiKeys&&Object.keys(this.rs.apiKeys).length>0?this.setState("choose"):this.setState("sign-in")}},{key:"setClickHandlers",value:function(){var t=this;this.rsInitial.addEventListener("click",function(){return t.showChooseOrSignIn()}),this.rsChooseRemoteStorageButton.addEventListener("click",function(){t.setState("sign-in"),t.rsAddressInput.focus()}),this.rsChooseDropboxButton.addEventListener("click",function(){return t.rs.dropbox.connect()}),this.rsChooseGoogleDriveButton.addEventListener("click",function(){return t.rs.googledrive.connect()}),this.rsDisconnectButton.addEventListener("click",function(){return t.rs.disconnect()}),this.rsErrorReconnectLink.addEventListener("click",function(){return t.rs.reconnect()}),this.rsErrorDisconnectButton.addEventListener("click",function(){return t.rs.disconnect()}),this.rs.hasFeature("Sync")&&this.rsSyncButton.addEventListener("click",function(){t.rsSyncButton.classList.contains("rs-rotate")?(t.rs.stopSync(),t.rsSyncButton.classList.remove("rs-rotate")):(t.rsConnectedLabel.textContent="Synchronizing",t.rs.startSync(),t.rsSyncButton.classList.add("rs-rotate"))}),document.addEventListener("click",function(){return t.close()}),this.rsWidget.addEventListener("click",function(t){return t.stopPropagation()}),this.rsLogo.addEventListener("click",function(){return t.toggle()})}},{key:"toggle",value:function(){this.closed?this.open():"initial"===this.state?this.showChooseOrSignIn():this.close()}},{key:"open",value:function(){this.closed=!1,this.rsWidget.classList.remove("rs-closed"),this.shouldCloseWhenSyncDone=!1;var t=this.parentContainerEl.querySelector(".rs-box.rs-selected");t&&t.setAttribute("aria-hidden","false")}},{key:"close",value:function(){var t=this;if("error"!==this.state){if(!this.leaveOpen&&this.active){this.closed=!0,this.rsWidget.classList.add("rs-closed");var e=this.parentContainerEl.querySelector(".rs-box.rs-selected");e&&e.setAttribute("aria-hidden","true")}else this.active?this.setState("connected"):this.setInitialState();this.rsWidget.classList.contains("rs-modal")&&(this.rsBackdrop.classList.remove("visible"),setTimeout(function(){t.rsBackdrop.style.display="none"},300))}}},{key:"disableConnectButton",value:function(){this.rsConnectButton.disabled=!0,this.rsConnectButton.classList.add("rs-connecting"),this.rsConnectButton.innerHTML="Connecting ".concat('\n \n \n \n \n \n \n\n')}},{key:"enableConnectButton",value:function(){this.rsConnectButton.disabled=!1,this.rsConnectButton.textContent="Connect",this.rsConnectButton.classList.remove("rs-connecting")}},{key:"setOffline",value:function(){this.online&&(this.rsWidget.classList.add("rs-offline"),this.rsConnectedLabel.textContent="Offline",this.online=!1)}},{key:"setOnline",value:function(){this.online||(this.rsWidget.classList.remove("rs-offline"),this.active&&(this.rsConnectedLabel.textContent="Connected")),this.online=!0}},{key:"setBackendClass",value:function(t){this.rsWidget.classList.remove("rs-backend-remotestorage"),this.rsWidget.classList.remove("rs-backend-dropbox"),this.rsWidget.classList.remove("rs-backend-googledrive"),t&&this.rsWidget.classList.add("rs-backend-".concat(t))}},{key:"showErrorBox",value:function(t){this.rsErrorBox.innerHTML=t,this.setState("error")}},{key:"hideErrorBox",value:function(){this.rsErrorBox.innerHTML="",this.close()}},{key:"handleSyncStarted",value:function(){var t=this;this.syncInProgress=!0,this.rsSyncButton.classList.add("rs-rotate"),setTimeout(function(){t.syncInProgress&&(t.rsConnectedLabel.textContent="Synchronizing")},1e3)}},{key:"handleDiscoveryError",value:function(t){var e=this.parentContainerEl.querySelector(".rs-sign-in-error");e.innerHTML=t.message,e.classList.remove("rs-hidden"),e.classList.add("rs-visible"),this.enableConnectButton()}},{key:"handleSyncError",value:function(){this.setOffline()}},{key:"handleUnauthorized",value:function(t){t.code&&"access_denied"===t.code?this.rs.disconnect():(this.open(),this.showErrorBox(t.message+" "),this.rsErrorBox.appendChild(this.rsErrorReconnectLink),this.rsErrorReconnectLink.classList.remove("rs-hidden"))}},{key:"updateLastSyncedStatus",value:function(){var t=new Date;this.online?(this.lastSynced=t,this.rsConnectedLabel.textContent="Synced"):this.rsWidget.classList.contains("rs-state-unauthorized")||(this.rsConnectedLabel.textContent="Offline")}},{key:"isSmallScreen",value:function(){return window.innerWidth<421}}],e&&function(t,e){for(var n=0;nMs(t.cancelId))}))),s=r.has(e)?r.get(e).debouncedTask:(...n)=>{r.delete(e),t[e](...n)};let o=As(t,s,...n);r.set(e,{debouncedTask:s,cancelId:o})}var HU=a({default:()=>GU}),GU=class extends pp{static{aF(this.prototype,"osm",[dp])}#B=void cF(this,"osm");static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");rs;widget;static{aF(this.prototype,"placesInView",[Vr],function(){return[]})}#It=void cF(this,"placesInView");static{aF(this.prototype,"savedPlaces",[Vr],function(){return[]})}#Pt=void cF(this,"savedPlaces");static{aF(this.prototype,"loadedPrefixes",[Vr],function(){return[]})}#Mt=void cF(this,"loadedPrefixes");static{aF(this.prototype,"currentBbox",[Vr],function(){return null})}#At=void cF(this,"currentBbox");static{aF(this.prototype,"lists",[Vr],function(){return[]})}#Ot=void cF(this,"lists");static{aF(this.prototype,"version",[Vr],function(){return 0})}#Nt=void cF(this,"version");static{aF(this.prototype,"initialSyncDone",[Vr],function(){return!1})}#Ft=void cF(this,"initialSyncDone");static{aF(this.prototype,"connected",[Vr],function(){return!1})}#Dt=void cF(this,"connected");static{aF(this.prototype,"userAddress",[Vr],function(){return null})}#zt=void cF(this,"userAddress");static{aF(this.prototype,"isWidgetOpen",[Vr],function(){return!1})}#jt=void cF(this,"isWidgetOpen");isNewConnection=!0;constructor(){super(...arguments),this.checkInitialConnectionState(),this.rs=new NU.default({modules:[BU]}),this.rs.access.claim("places","rw"),this.rs.caching.enable("/places/"),window.remoteStorage=this.rs,this.widget=new qU.default(this.rs,{leaveOpen:!0,skipInitial:!0}),this.rs.on("ready",()=>{}),this.rs.on("error",t=>{t&&(console.info("[rs] Error —",`${t.name}: ${t.message}`),"Unauthorized"===t.name&&this.showConnectWidget())}),this.rs.on("connected",()=>{this.connected=!0,this.userAddress=this.rs.remote.userAddress,this.isNewConnection&&(this.toast.show("Remote storage connected",3e3),this.isNewConnection=!1),this.loadLists()}),this.rs.on("not-connected",()=>{this.loadLists()}),this.rs.on("disconnected",()=>{this.connected=!1,this.userAddress=null,this.placesInView=[],this.savedPlaces=[],this.loadedPrefixes=[],this.lists=[],this.initialSyncDone=!1,this.isNewConnection=!0}),this.rs.on("sync-done",()=>{this.initialSyncDone||(this.initialSyncDone=!0,this.loadLists())}),this.rs.scope("/places/").on("change",t=>{t.relativePath.startsWith("_lists/")?this.loadLists():(this.handlePlaceChange(t),WU(this,"reloadCurrentView",200))})}checkInitialConnectionState(){this.isNewConnection=!0;try{if(window.localStorage)for(const t of["remotestorage:wireclient","remotestorage:dropbox","remotestorage:googledrive"]){const e=window.localStorage.getItem(t);if(e){const t=JSON.parse(e);if(t&&t.token){this.isNewConnection=!1;break}}}}catch(t){console.warn("Failed to check localStorage for existing connection:",t)}}handlePlaceChange(t){const{newValue:e,relativePath:n}=t,r=n.split("/"),i=r[r.length-1];if(e){const t={...e,id:i},n=this.savedPlaces.findIndex(t=>t.id===i);if(-1!==n){const e=[...this.savedPlaces];e[n]=t,this.savedPlaces=e}else this.savedPlaces=[...this.savedPlaces,t]}else this.savedPlaces=this.savedPlaces.filter(t=>t.id!==i)}get places(){return this.rs.places}notifyChange(){this.version++,WU(this,"reloadCurrentView",200)}reloadCurrentView(){if(!this.currentBbox)return;const t=Cj(this.currentBbox);console.debug("Reloading view due to changes, prefixes:",t),this.loadAllPlaces(t)}async loadLists(){try{if(!this.places.lists)return;await this.places.lists.initDefaults();const t=await this.places.lists.getAll();this.lists=t||[],this.lists.forEach(t=>{"to-go"===t.id?t.icon="bookmark":"to-do"===t.id&&(t.icon="check-square")}),this.refreshPlaceListAssociations()}catch(t){console.error("Failed to load lists:",t)}}refreshPlaceListAssociations(){const t=new Map;this.lists.forEach(e=>{e.placeRefs&&Array.isArray(e.placeRefs)&&e.placeRefs.forEach(n=>{n.id&&(t.has(n.id)||t.set(n.id,[]),t.get(n.id).push(e.id))})});const e=e=>(e._listIds=t.get(e.id)||[],e);this.savedPlaces=this.savedPlaces.map(t=>e({...t})),this.placesInView=this.placesInView.map(t=>e({...t}))}async togglePlaceList(t,e,n){if(!t)return;let r=t;if(!t.id||!t.geohash){if(!n)return;r=await this.storePlace(t)}try{return n?await this.places.lists.addPlace(e,r.id,r.geohash):await this.places.lists.removePlace(e,r.id),await this.loadLists(),this.findPlaceById(r.id)}catch(i){throw console.error("Failed to toggle place in list:",i),i}}async getPlacesInList(t){return this.places&&this.places.lists?this.places.lists.getPlaces(t):[]}async loadPlacesInBounds(t){const e=Cj(t).filter(t=>!this.loadedPrefixes.includes(t));0!==e.length&&(console.debug("Loading new prefixes:",e),await this.loadAllPlaces(e),this.loadedPrefixes=[...this.loadedPrefixes,...e],this.currentBbox=t)}async loadAllPlaces(t=null){try{const e=await this.places.getPlaces(t);if(e&&Array.isArray(e)){if(t){const n=new Set(t),r=this.placesInView.filter(t=>{if(!t.lat||!t.lon)return!1;try{const e=_j.encode(t.lat,t.lon,4);return!n.has(e)}catch{return!0}});this.placesInView=[...r,...e]}else this.placesInView=e;this.refreshPlaceListAssociations()}else t||(this.placesInView=[]);console.debug("Loaded saved places:",this.placesInView.length)}catch(e){console.error("Failed to load places:",e)}}findPlaceById(t){if(!t)return;const e=String(t);let n=this.savedPlaces.find(t=>t.id&&String(t.id)===e);return n||(n=this.placesInView.find(t=>t.id&&String(t.id)===e),n||(n=this.savedPlaces.find(t=>t.osmId&&String(t.osmId)===e),n||(n=this.placesInView.find(t=>t.osmId&&String(t.osmId)===e),n)))}isPlaceSaved(t){return!!this.findPlaceById(t)}async storePlace(t){const e=await this.places.store(t);return this.savedPlaces.some(t=>t.id===e.id)?this.savedPlaces=this.savedPlaces.map(t=>t.id===e.id?e:t):this.savedPlaces=[...this.savedPlaces,e],this.placesInView.some(t=>t.id===e.id)?this.placesInView=this.placesInView.map(t=>t.id===e.id?e:t):this.placesInView=[...this.placesInView,e],e}async updatePlace(t){const e=await this.places.store(t),n=this.savedPlaces.findIndex(t=>t.id===e.id);if(-1!==n){const t=[...this.savedPlaces];t[n]=e,this.savedPlaces=t}return this.placesInView=this.placesInView.map(t=>t.id===e.id?e:t),e}async removePlace(t){await this.places.remove(t.id,t.geohash),this.savedPlaces=this.savedPlaces.filter(e=>e.id!==t.id),this.placesInView.length>0&&(this.placesInView=this.placesInView.filter(e=>e.id!==t.id))}async refreshPlace(t){if(!(t&&t.id&&t.osmId&&t.osmType))return null;try{console.debug(`Checking for updates for ${t.title} (${t.osmId})`);const e=await this.osm.fetchOsmObject(t.osmId,t.osmType,{forceFresh:!0});if(!e)return console.warn("Could not fetch fresh data for",t.osmId),null;let n=!1;const r={},i=Math.abs(t.lat-e.lat),s=Math.abs(t.lon-e.lon);(i>1e-5||s>1e-5)&&(n=!0,r.lat=e.lat,r.lon=e.lon);const o=t.osmTags||{},a=e.osmTags||{},l=new Set([...Object.keys(o),...Object.keys(a)]);for(const t of l)if(o[t]!==a[t]){n=!0,r.osmTags=a;break}if(!n)return console.debug("No changes detected for",t.title),null;console.debug("Changes detected:",r);const c={...t,...r},u=wU(o),h=wU(a);return t.title===u&&u!==h&&(c.title=h),await this.updatePlace(c)}catch(e){return console.error("Failed to refresh place:",e),null}}showConnectWidget(){this.isWidgetOpen=!0,document.querySelector(".rs-widget")||this.widget.attach("rs-widget-container")}static{lF(this.prototype,"showConnectWidget",[ql])}closeWidget(){this.isWidgetOpen=!1}static{lF(this.prototype,"closeWidget",[ql])}disconnect(){this.rs.disconnect(),this.isWidgetOpen=!1}static{lF(this.prototype,"disconnect",[ql])}},KU=a({default:()=>ZU}),ZU=class extends pp{static{aF(this.prototype,"message",[Vr],function(){return null})}#Ut=void cF(this,"message");static{aF(this.prototype,"isVisible",[Vr],function(){return!1})}#Bt=void cF(this,"isVisible");timeoutId=null;show(t,e=3e3){this.message=t,this.isVisible=!0,this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isVisible=!1},e)}},YU=a({getDistance:()=>XU});function XU(t,e,n,r){const i=t*Math.PI/180,s=n*Math.PI/180,o=(n-t)*Math.PI/180,a=(r-e)*Math.PI/180,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(s)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3}var JU=a({getIcon:()=>eB,isIconFilled:()=>nB}),QU={activity:'',angelfish:'\n \n',"arrow-left":'',barbell:'\n \n',banknote:'\n \n',"badge-shield-with-fire":'\n \n',"beach-umbrella-in-ground":'\n \n',"beer-mug-with-foam":'\n \n',bookmark:'',"boxing-glove-up":'\n \n',"burger-and-drink-cup-with-straw":'\n \n',bridge:'\n \n',bus:'\n \n',camera:'\n \n',"feather-camera":'',"check-square":'',"chevron-left":'',"chevron-right":'',"cigarette-with-smoke-curl":'\n \n',"city-gate":'\n \n',climbing_wall:'\n \n',check:'',"alert-circle":'',"alert-triangle":'',"classical-building":'\n \n',"classical-building-with-clock":'\n \n',"classical-building-with-dome-and-flag":'\n \n',"classical-building-with-flag":'\n \n',"commercial-building":'\n \n',"clothes-hanger":'\n \n',cleaver:'\n \n',cloth:'\n \n',cocktail:'\n \n',clock:'',"coffee-bean":'\n \n',"comedy-mask-and-tragedy-mask":'\n \n',croissant:'\n \n',"cup-and-saucer":'\n \n',database:'',donut:'\n \n',edit:'',eyeglasses:'\n \n',facebook:'',"fancy-mirror-with-reflection-and-stars":'\n \n',"family-restroom-symbol":'\n \n',film:'\n \n',"fingernail-polished":'\n \n',fish:'\n \n',"flag-checkered":'\n \n',"flower-bouquet":'\n \n',"fork-and-knife":'\n \n',fort:'\n \n',gift:'',globe:'',gravestone:'\n \n',"grecian-vase":'\n \n',"greek-cross":'\n \n',heart:'',home:'',"ice-cream-on-cone":'\n \n',"industrial-building":'\n \n',info:'',"info-i":'\n \n',instagram:'',jewel:'\n \n',"log-in":'',"log-out":'',"lowrise-building":'\n \n',mail:'',map:'',"map-pin":'',"market-stall":'\n \n',"memorial-stone-with-inscription":'\n \n',menu:'',"mobile-phone-with-keypad-and-antenna":'\n \n',"molar-tooth":'\n \n',"more-horizontal":'',"more-vertical":'',navigation:'',"needle-and-spool-of-thread":'\n \n',nostrich:'\n \n\n',"open-book":'\n \n',palace:'\n \n',"person-cricket-batting-at-cricket-ball":'\n \n',"person-boarding-tram-with-destination-display-and-pantograph-on-tram-track":'\n \n',"person-jockeying-racehorse":'\n \n',"person-playing-tennis":'\n \n',"person-running":'\n \n',"person-sleeping-in-bed":'\n \n',"person-swimming-in-water":'\n \n',"person-swinging-golf-club":'\n \n',phone:'',"plane-top-right":'\n \n',"plant-in-raised-planter":'\n \n',"place-of-worship-building":'\n \n',"play-structure-with-slide":'\n \n',"police-officer-with-stop-arm":'\n \n',plus:'',"round-structure-with-flag":'\n \n',remotestorage:'\n\x3c!-- Creator: CorelDRAW X7 --\x3e\n\n \n',"sailing-ship-in-water":'\n \n',"scissors-open":'\n \n',"shipwreck-in-water":'\n \n',"steam-train-on-railway-track":'\n \n',"shopping-bag":'\n \n',search:'',server:'',settings:'',"shopping-basket":'\n \n',"shopping-cart":'\n \n',"table-tennis-paddle":'\n \n',"tattoo-machine":'\n \n',toolbox:'\n \n',target:'',"trash-2":'',"upload-cloud":'',"tree-and-bench-with-backrest":'\n \n',user:'',"village-buildings":'\n \n',"wall-hanging-with-mountains-and-sun":'\n \n',"womens-and-mens-restroom-symbol":'\n \n',whatsapp:'\n\n \n\n',wikipedia:'\n\n\n',winding_way_wide:'\n \n',parking_p:'\n \n',car:'\n \n',"car-and-wrench":'\n \n',"castle-keep":'\n \n',x:'',zap:'',"loading-ring":''},tB=["fork-and-knife","wikipedia","whatsapp","cup-and-saucer","coffee-bean","shopping-basket","person-sleeping-in-bed","loading-ring","nostrich"];function eB(t){return QU[t]}function nB(t){return tB.includes(t)}var rB=a({POI_ICON_RULES:()=>iB,getIconNameForTags:()=>sB,getIconSvgForTags:()=>oB}),iB=[{tags:{cuisine:"donut"},icon:"donut"},{tags:{cuisine:"doughnut"},icon:"donut"},{tags:{cuisine:"coffee_shop"},icon:"coffee-bean"},{tags:{cuisine:"coffee"},icon:"coffee-bean"},{tags:{amenity:"ice_cream"},icon:"ice-cream-on-cone"},{tags:{cuisine:"ice_cream"},icon:"ice-cream-on-cone"},{tags:{shop:"ice_cream"},icon:"ice-cream-on-cone"},{tags:{amenity:"cafe"},icon:"cup-and-saucer"},{tags:{amenity:"restaurant"},icon:"fork-and-knife"},{tags:{amenity:"fast_food"},icon:"burger-and-drink-cup-with-straw"},{tags:{amenity:"pub"},icon:"beer-mug-with-foam"},{tags:{amenity:"bar"},icon:"cocktail"},{tags:{amenity:"food_court"},icon:"fork-and-knife"},{tags:{amenity:"childcare"},icon:"family-restroom-symbol"},{tags:{amenity:"community_centre"},icon:"family-restroom-symbol"},{tags:{amenity:"social_centre"},icon:"family-restroom-symbol"},{tags:{amenity:"social_facility"},icon:"family-restroom-symbol"},{tags:{amenity:"bank"},icon:"banknote"},{tags:{amenity:"place_of_worship"},icon:"place-of-worship-building"},{tags:{amenity:"townhall"},icon:"classical-building-with-clock"},{tags:{building:"townhall"},icon:"classical-building-with-clock"},{tags:{amenity:"fire_station"},icon:"badge-shield-with-fire"},{tags:{amenity:"police"},icon:"police-officer-with-stop-arm"},{tags:{amenity:"toilets"},icon:"womens-and-mens-restroom-symbol"},{tags:{amenity:"school"},icon:"open-book"},{tags:{amenity:"driving_school"},icon:"car"},{tags:{shop:"coffee"},icon:"coffee-bean"},{tags:{shop:"tea"},icon:"coffee-bean"},{tags:{shop:"pastry"},icon:"donut"},{tags:{shop:"supermarket"},icon:"shopping-cart"},{tags:{shop:"convenience"},icon:"shopping-basket"},{tags:{shop:"grocery"},icon:"shopping-basket"},{tags:{shop:"greengrocer"},icon:"shopping-basket"},{tags:{shop:"bakery"},icon:"croissant"},{tags:{shop:"butcher"},icon:"cleaver"},{tags:{shop:"seafood"},icon:"fish"},{tags:{shop:"deli"},icon:"shopping-basket"},{tags:{shop:"clothes"},icon:"clothes-hanger"},{tags:{shop:"clothing"},icon:"clothes-hanger"},{tags:{shop:"hairdresser"},icon:"scissors-open"},{tags:{shop:"optician"},icon:"eyeglasses"},{tags:{shop:"fabric"},icon:"cloth"},{tags:{shop:"flea_market"},icon:"market-stall"},{tags:{shop:"kiosk"},icon:"shopping-basket"},{tags:{shop:"leather"},icon:"shopping-bag"},{tags:{shop:"tailor"},icon:"needle-and-spool-of-thread"},{tags:{shop:"jewelry"},icon:"jewel"},{tags:{shop:"jewellery"},icon:"jewel"},{tags:{shop:"tobacco"},icon:"cigarette-with-smoke-curl"},{tags:{shop:"cannabis"},icon:"cigarette-with-smoke-curl"},{tags:{shop:"florist"},icon:"flower-bouquet"},{tags:{shop:"garden_centre"},icon:"plant-in-raised-planter"},{tags:{shop:"estate_agent"},icon:"village-buildings"},{tags:{shop:"mobile_phone"},icon:"mobile-phone-with-keypad-and-antenna"},{tags:{beauty:"nails"},icon:"fingernail-polished"},{tags:{shop:"tattoo"},icon:"tattoo-machine"},{tags:{shop:"beauty"},icon:"fancy-mirror-with-reflection-and-stars"},{tags:{shop:"car_repair"},icon:"car-and-wrench"},{tags:{craft:"tailor"},icon:"needle-and-spool-of-thread"},{tags:{office:"estate_agent"},icon:"village-buildings"},{tags:{office:!0},icon:"commercial-building"},{tags:{craft:!0},icon:"toolbox"},{tags:{shop:!0},icon:"shopping-bag"},{tags:{natural:"beach"},icon:"beach-umbrella-in-ground"},{tags:{leisure:"park"},icon:"tree-and-bench-with-backrest"},{tags:{leisure:"playground"},icon:"play-structure-with-slide"},{tags:{aeroway:"aerodrome"},icon:"plane-top-right"},{tags:{aeroway:"heliport"},icon:"plane-top-right"},{tags:{aeroway:"helipad"},icon:"plane-top-right"},{tags:{highway:"bus_stop"},icon:"bus"},{tags:{bus:!0},icon:"bus"},{tags:{railway:"tram_stop"},icon:"person-boarding-tram-with-destination-display-and-pantograph-on-tram-track"},{tags:{tourism:"museum"},icon:"classical-building"},{tags:{tourism:"gallery"},icon:"wall-hanging-with-mountains-and-sun"},{tags:{tourism:"aquarium"},icon:"angelfish"},{tags:{tourism:"theme_park"},icon:"camera"},{tags:{tourism:"attraction"},icon:"camera"},{tags:{tourism:"viewpoint"},icon:"camera"},{tags:{tourism:"zoo"},icon:"camera"},{tags:{tourism:"artwork"},icon:"camera"},{tags:{tourism:"information"},icon:"info-i"},{tags:{amenity:"cinema"},icon:"film"},{tags:{amenity:"theatre"},icon:"camera"},{tags:{amenity:"arts_centre"},icon:"comedy-mask-and-tragedy-mask"},{tags:{amenity:"arts_center"},icon:"comedy-mask-and-tragedy-mask"},{tags:{historic:"canal"},icon:"winding_way_wide"},{tags:{historic:"bridge"},icon:"bridge"},{tags:{historic:"bridge_site"},icon:"bridge"},{tags:{historic:"fort"},icon:"fort"},{tags:{historic:"city_gate"},icon:"city-gate"},{tags:{historic:"castle"},icon:"palace"},{tags:{building:"tower",historic:"yes"},icon:"castle-keep"},{tags:{historic:"building"},icon:"classical-building-with-flag"},{tags:{historic:"archaeological_site"},icon:"grecian-vase"},{tags:{historic:"memorial"},icon:"memorial-stone-with-inscription"},{tags:{historic:"tomb"},icon:"gravestone"},{tags:{historic:"monument"},icon:"classical-building-with-dome-and-flag"},{tags:{historic:"folly"},icon:"classical-building"},{tags:{historic:"industrial"},icon:"industrial-building"},{tags:{historic:"railway_station"},icon:"steam-train-on-railway-track"},{tags:{historic:"ship"},icon:"sailing-ship-in-water"},{tags:{historic:"wreck"},icon:"shipwreck-in-water"},{tags:{historic:"ruins"},icon:"camera"},{tags:{historic:"ruin"},icon:"camera"},{tags:{historic:"yes"},icon:"camera"},{tags:{tourism:"hotel"},icon:"person-sleeping-in-bed"},{tags:{tourism:"hostel"},icon:"person-sleeping-in-bed"},{tags:{tourism:"motel"},icon:"person-sleeping-in-bed"},{tags:{tourism:"guest_house"},icon:"person-sleeping-in-bed"},{tags:{sport:"motor"},icon:"flag-checkered"},{tags:{sport:"karting"},icon:"flag-checkered"},{tags:{sport:"motocross"},icon:"flag-checkered"},{tags:{sport:"cricket"},icon:"person-cricket-batting-at-cricket-ball"},{tags:{sport:"boxing"},icon:"boxing-glove-up"},{tags:{sport:"martial_arts"},icon:"boxing-glove-up"},{tags:{sport:"tennis"},icon:"person-playing-tennis"},{tags:{sport:"squash"},icon:"person-playing-tennis"},{tags:{sport:"padel"},icon:"person-playing-tennis"},{tags:{sport:"table_tennis"},icon:"table-tennis-paddle"},{tags:{sport:"climbing"},icon:"climbing_wall"},{tags:{leisure:"water_park"},icon:"person-swimming-in-water"},{tags:{sport:"swimming"},icon:"person-swimming-in-water"},{tags:{sport:"golf"},icon:"person-swinging-golf-club"},{tags:{leisure:"golf_course"},icon:"person-swinging-golf-club"},{tags:{sport:"horse_racing"},icon:"person-jockeying-racehorse"},{tags:{sport:"fitness"},icon:"barbell"},{tags:{sport:"fitness_centre"},icon:"barbell"},{tags:{leisure:"fitness_centre"},icon:"barbell"},{tags:{sport:"stadium"},icon:"round-structure-with-flag"},{tags:{leisure:"stadium"},icon:"round-structure-with-flag"},{tags:{leisure:"sports_centre"},icon:"person-running"},{tags:{leisure:"pitch"},icon:"person-running"},{tags:{sport:!0},icon:"person-running"},{tags:{amenity:"dentist"},icon:"molar-tooth"},{tags:{healthcare:"dentist"},icon:"molar-tooth"},{tags:{healthcare:!0},icon:"greek-cross"},{tags:{amenity:"parking"},icon:"parking_p"},{tags:{building:"commercial"},icon:"commercial-building"},{tags:{building:"apartments"},icon:"lowrise-building"}];function sB(t){if(!t)return null;for(const e of iB){let n=!0;for(const[r,i]of Object.entries(e.tags)){const e=t[r];if(!e){n=!1;break}const s=e.split(";").map(t=>t.trim());if(!0!==i&&!s.includes(i)){n=!1;break}}if(n)return e.icon}return null}function oB(t){const e=sB(t);return e?eB(e):null}var aB=a({getMatchingPoiCategories:()=>lB,getMatchingPoiCategoryIds:()=>cB});function lB(t,e){return Array.isArray(e)&&t?e.filter(e=>!!Array.isArray(e.filter)&&e.filter.some(e=>function(t,e){const n=function(t){if(!t)return[];const e=t.match(/\[[^\]]+\]/g);return e?e.map(t=>function(t){const e=t.match(/^"([^"]+)"$/);if(e)return{type:"presence",key:e[1]};const n=t.match(/^"([^"]+)"\s*=\s*"([^"]*)"$/);if(n)return{type:"equals",key:n[1],value:n[2]};const r=t.match(/^"([^"]+)"\s*~\s*"([^"]*)"$/);if(r)return{type:"regex",key:r[1],pattern:r[2],regex:new RegExp(r[2])};const i=t.match(/^"([^"]+)"\s*!~\s*"([^"]*)"$/);return i?{type:"not-regex",key:i[1],pattern:i[2],regex:new RegExp(i[2])}:null}(t.slice(1,-1).trim())).filter(Boolean):[]}(e);return 0!==n.length&&n.every(e=>function(t,e){const n=function(t,e){if(!t||!e)return[];const n=t[e];return null==n?[]:String(n).split(";").map(t=>t.trim()).filter(Boolean)}(t,e.key);switch(e.type){case"presence":return n.length>0;case"equals":return n.some(t=>t===e.value);case"regex":return n.some(t=>e.regex.test(t));case"not-regex":return 0===n.length||!n.some(t=>e.regex.test(t));default:return!1}}(t,e))}(t,e))):[]}function cB(t,e){return lB(t,e).map(t=>t.id)}var uB=a({CATEGORY_TAGS:()=>hB,getSuggestedPhotoTags:()=>dB}),hB={restaurants:["food","menu","vibe","front"],coffee:["food","menu","vibe","front"],groceries:["front","food"],"things-to-do":["architecture","amenities","vibe","front"],accommodation:["rooms","amenities","food","vibe","front"]};function dB(t){const e=cB(t?.osmTags||t?.tags||{},SU),n=[];for(const r of e){const t=hB[r];if(Array.isArray(t))for(const e of t)n.includes(e)||n.push(e)}return 0===n.length?[]:n}var pB=a({mapToStorageSchema:()=>fB});function fB(t){return{title:t.title||wU(t.osmTags,"Untitled Place"),lat:t.lat,lon:t.lon,tags:[],url:t.osmTags?.website,osmId:String(t.osmId||t.id),osmType:t.osmType,osmTags:t.osmTags||{},description:t.description}}var gB=a({getSocialInfo:()=>yB}),mB=(t,...e)=>{for(const n of e)if(t[n])return t[n];return null};function yB(t,e){if(!t)return null;const n=`${e}.com`,r=mB(t,`contact:${e}`,e);if(!r)return null;if(r.startsWith("http"))try{const t=new URL(r);return"facebook"===e&&"/profile.php"===t.pathname&&t.searchParams.has("id")?{url:r,username:t.searchParams.get("id")}:{url:r,username:t.pathname.replace(/^\/|\/$/g,"")||r}}catch{return{url:r,username:r}}const i=r.replace(/^@/,"");return{url:`https://${n}/${i}`,username:i}}var vB,bB,wB,_B,xB,CB=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","#","$","%","*","+",",","-",".",":",";","=","?","@","[","]","^","_","{","|","}","~"],SB=t=>{let e=0;for(let n=0;n{var n="";for(let r=1;r<=e;r++){let i=Math.floor(t)/Math.pow(83,e-r)%83;n+=CB[Math.floor(i)]}return n},EB=t=>{let e=t/255;return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},RB=t=>{let e=Math.max(0,Math.min(1,t));return e<=.0031308?Math.trunc(12.92*e*255+.5):Math.trunc(255*(1.055*Math.pow(e,.4166666666666667)-.055)+.5)},TB=(t,e)=>(t=>t<0?-1:1)(t)*Math.pow(Math.abs(t),e),LB=class extends Error{constructor(t){super(t),this.name="ValidationError",this.message=t}},IB=t=>{let e=t>>8&255,n=255&t;return[EB(t>>16),EB(e),EB(n)]},PB=(t,e)=>{let n=Math.floor(t/361),r=Math.floor(t/19)%19,i=t%19;return[TB((n-9)/9,2)*e,TB((r-9)/9,2)*e,TB((i-9)/9,2)*e]},MB=(t,e,n,r)=>{let i=0,s=0,o=0,a=4*e;for(let c=0;c{if("PROCESS_IMAGE"!==t.data?.type)return;const{id:e,file:n,targetWidth:r,targetHeight:i,quality:s,computeBlurhash:o}=t.data;try{let t,c;try{const e=await createImageBitmap(n,{resizeWidth:r,resizeHeight:i,resizeQuality:"high"});if(t=new OffscreenCanvas(r,i),c=t.getContext("2d"),!c)throw new Error("Failed to get 2d context from OffscreenCanvas");c.drawImage(e,0,0,r,i),e.close()}catch(a){console.warn("Hardware resize failed, falling back to stepped software scaling:",a);const e=await n.arrayBuffer(),s=new Blob([e],{type:n.type}),o=await createImageBitmap(s);let l=o.width,u=o.height,h=new OffscreenCanvas(l,u),d=h.getContext("2d");for(d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(o,0,0);.5*h.width>r&&.5*h.height>i;){const t=new OffscreenCanvas(Math.floor(.5*h.width),Math.floor(.5*h.height)),e=t.getContext("2d");e.imageSmoothingEnabled=!0,e.imageSmoothingQuality="high",e.drawImage(h,0,0,t.width,t.height),h=t}t=new OffscreenCanvas(r,i),c=t.getContext("2d"),c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(h,0,0,r,i),o.close()}let u=null;if(o)try{u=((t,e,n)=>{if(e*n*4!==t.length)throw new LB("Width and height must match the pixels array");let r=[];for(let l=0;l<3;l++)for(let i=0;i<4;i++){let s=0==i&&0==l?1:2,o=MB(t,e,n,(t,r)=>s*Math.cos(Math.PI*i*t/e)*Math.cos(Math.PI*l*r/n));r.push(o)}let i,s=r[0],o=r.slice(1),a="";if(a+=kB(21,1),o.length>0){let t=Math.max(...o.map(t=>Math.max(...t))),e=Math.floor(Math.max(0,Math.min(82,Math.floor(166*t-.5))));i=(e+1)/166,a+=kB(e,1)}else i=1,a+=kB(0,1);return a+=kB((t=>(RB(t[0])<<16)+(RB(t[1])<<8)+RB(t[2]))(s),4),o.forEach(t=>{a+=kB(((t,e)=>19*Math.floor(Math.max(0,Math.min(18,Math.floor(9*TB(t[0]/e,.5)+9.5))))*19+19*Math.floor(Math.max(0,Math.min(18,Math.floor(9*TB(t[1]/e,.5)+9.5))))+Math.floor(Math.max(0,Math.min(18,Math.floor(9*TB(t[2]/e,.5)+9.5)))))(t,i),2)}),a})(c.getImageData(0,0,r,i).data,r,i)}catch(l){console.warn("Could not generate blurhash (possible canvas fingerprinting protection):",l)}const h=await t.convertToBlob({type:"image/jpeg",quality:s}),d=`${r}x${i}`;self.postMessage({id:e,success:!0,blob:h,dim:d,blurhash:u})}catch(e6){self.postMessage({id:e,success:!1,error:e6.message})}};var DB="undefined"!=typeof FastBoot,zB="routeDidChange",jB=["separator","prepend","replace"],UB=(vB=dp("router"),bB=dp("-document"),wB=class extends pp{constructor(t){if(super(t),NB(this,"router",_B,this),NB(this,"document",xB,this),OB(this,"tokens",[]),OB(this,"_defaultConfig",{separator:" | ",prepend:!0,replace:null}),OB(this,"scheduleTitleUpdate",()=>{Is("afterRender",this,this._updateTitle)}),this._validateExistingTitleElement(),function(t){return"resolveRegistration"in t}(t)){const n=t.resolveRegistration("config:environment");"object"==typeof(e=n)&&null!==e&&"pageTitle"in e&&jB.forEach(t=>{if(!function(t){if(null==t)return!0;if(!cr(t)&&"number"==typeof t.size)return!t.size;if("object"==typeof t){let e=ur(t,"size");if("number"==typeof e)return!e;let n=ur(t,"length");if("number"==typeof n)return!n}return"number"==typeof t.length&&"function"!=typeof t&&!t.length}(n.pageTitle[t])){const e=n.pageTitle[t];this._defaultConfig[t]=e}})}var e;this.router.on(zB,this.scheduleTitleUpdate)}applyTokenDefaults(t){const e=this._defaultConfig.separator,n=this._defaultConfig.prepend,r=this._defaultConfig.replace;t.previous??=null,t.next??=null,null==t.separator&&(t.separator=e),null==t.prepend&&null!=n&&(t.prepend=n),null==t.replace&&null!=r&&(t.replace=r)}inheritFromPrevious(t){const e=t.previous;e&&(null==t.separator&&(t.separator=e.separator),null==t.prepend&&(t.prepend=e.prepend))}push(t){const e=this._findTokenById(t.id);if(e){const n=this.tokens.indexOf(e),r=[...this.tokens];return t.previous=e.previous,t.next=e.next,this.inheritFromPrevious(t),this.applyTokenDefaults(t),r.splice(n,1,t),void(this.tokens=r)}const n=this.tokens.slice(-1)[0];n&&(t.previous=n??null,n.next=t,this.inheritFromPrevious(t)),this.applyTokenDefaults(t),this.tokens=[...this.tokens,t]}remove(t){const e=this._findTokenById(t);if(!e)return;const{next:n,previous:r}=e;n&&(n.previous=r),r&&(r.next=n),e.previous=e.next=null;const i=[...this.tokens];i.splice(i.indexOf(e),1),this.tokens=i}get visibleTokens(){const t=this.tokens;let e=t?t.length:0;const n=[];for(;e--;){const r=t[e];if(r){if(r.replace){n.unshift(r);break}n.unshift(r)}}return n}get sortedTokens(){const t=this.visibleTokens;if(!t)return[];let e=!0,n=[];const r=[n],i=[];return t.forEach(t=>{t.front?i.unshift(t):t.prepend?(e&&(e=!1,n=[],r.push(n)),n.unshift(t)):(e||(e=!0,n=[],r.push(n)),n.push(t))}),i.concat(r.reduce((t,e)=>t.concat(e),[]))}toString(){const t=this.sortedTokens,e=[];for(let n=0,r=t.length;ne.id===t)}updateFastbootTitle(t){if(!DB)return;const e=this.document.head,n=e.childNodes;for(let s=0;sUB}),$B=wl.create({target:null,action:null,actionContext:null,actionContextObject:Yn("actionContext",function(){let t=ur(this,"actionContext");if("string"==typeof t){let e=ur(this,t);return void 0===e&&(e=ur(Xr.lookup,t)),e}return t}),triggerAction(t={}){let{action:e,target:n,actionContext:r}=t;e=e||ur(this,"action"),n=n||function(t){let e=ur(t,"target");if(e){if("string"==typeof e){let n=ur(t,e);return void 0===n&&(n=ur(Xr.lookup,e)),n}return e}return t._target?t._target:null}(this),void 0===r&&(r=ur(this,"actionContextObject")||this);let i=Array.isArray(r)?r:[r];if(n&&e){let t;if(t=null!=(s=n)&&"object"==typeof s&&"function"==typeof s.send?n.send(e,...i):n[e](...i),!1!==t)return!0}var s;return!1}}),qB=wl.create({send(t,...e){let n=this.actions&&this.actions[t];if(n&&!0!==n.apply(this,e))return;let r=ur(this,"target");r&&r.send(...arguments)}}),VB=Object.freeze({appendChild(){throw new Error("You can't use appendChild outside of the rendering process")},handleEvent:()=>!0,rerender(){},destroy(){}}),WB=Object.freeze({...VB}),HB=Object.freeze({...VB,rerender(t){t.renderer.rerender()},destroy(t){t.renderer.remove(t)},handleEvent:(t,e,n)=>!t.has(e)||cv(0,0,()=>_s(t,t.trigger,e,n))}),GB=Object.freeze({...HB,enter(t){t.renderer.register(t)}}),KB=Object.freeze({...VB,appendChild(){throw new Error("You can't call appendChild on a view being destroyed")},rerender(){throw new Error("You can't call rerender on a view being destroyed")}}),ZB=Object.freeze({preRender:WB,inDOM:GB,hasElement:HB,destroying:KB}),YB=class extends(Yc.extend(vc,Sl)){isView=!0;_superTrigger;_superHas;init(t){super.init(t),this._superTrigger=this.trigger,this.trigger=this._trigger,this._superHas=this.has,this.has=this._has,this.parentView??=null,this._state="preRender",this._currentState=this._states.preRender}static{Gh(this.prototype,"renderer",[$r("renderer","-dom")])}#$t=void Zh(this,"renderer");instrumentDetails(t){return t.object=this.toString(),t.containerKey=this._debugContainerKey,t.view=this,t}_trigger(t,...e){this._superTrigger(t,...e);let n=this[t];if("function"==typeof n)return n.apply(this,e)}_has(t){return"function"==typeof this[t]||this._superHas(t)}static isViewFactory=!0};YB.prototype._states=ZB;var XB=a({Input:()=>l_,Textarea:()=>h_,capabilities:()=>lb,default:()=>t$,getComponentTemplate:()=>Op,setComponentManager:()=>e$,setComponentTemplate:()=>Ap}),JB=new WeakMap,QB=Object.freeze([]),t$=class extends(YB.extend($B,qB,{didReceiveAttrs(){},didRender(){},didUpdate(){},didUpdateAttrs(){},willRender(){},willUpdate(){}},{concatenatedProperties:["attributeBindings","classNames","classNameBindings"],classNames:QB,classNameBindings:QB})){isComponent=!0;init(t){super.init(t),this._superRerender=this.rerender,this.rerender=this._rerender,this[Tv]=!1,this[Rv]=ft(),this[Lv]=null;const e=this._dispatcher;if(e){let t=JB.get(e);t||(t=new WeakSet,JB.set(e,t));let n=Object.getPrototypeOf(this);t.has(n)||(e.lazyEvents.forEach((t,n)=>{null!==t&&"function"==typeof this[t]&&e.setupHandlerForBrowserEvent(n)}),t.add(n))}this.elementId||""===this.tagName||(this.elementId=al(this))}__dispatcher;get _dispatcher(){if(void 0===this.__dispatcher){let t=Ur(this);if(t.lookup("-environment:main").isInteractive){let e=t.lookup("event_dispatcher:main");this.__dispatcher=e}else this.__dispatcher=null}return this.__dispatcher}on(t,e,n){return this._dispatcher?.setupHandlerForEmberEvent(t),super.on(t,e,n)}_rerender(){dt(this[Rv]),this._superRerender()}[Un](t,e){if(this[Tv])return;let n=Ev.get(this),r=void 0!==n?n[t]:void 0;void 0!==r&&be(r)&&_e(r,2===arguments.length?e:ur(this,t))}getAttr(t){return this.get(t)}readDOMAttr(t){let e=Jl(this),n="http://www.w3.org/2000/svg"===e.namespaceURI,{type:r,normalized:i}=Cg(e,t);return n||"attr"===r?e.getAttribute(i):e[i]}get childViews(){return ic(this)}static{Kh(this.prototype,"childViews",[C({configurable:!1,enumerable:!1})])}appendChild(t){sc(this,t)}_transitionTo(t){let e=this._currentState,n=this._currentState=this._states[t];this._state=t,e&&e.exit&&e.exit(this),n.enter&&n.enter(this)}nearestOfType(t){let e=this.parentView;for(;e;){if(t.detect(e.constructor))return e;e=e.parentView}}nearestWithProperty(t){let e=this.parentView;for(;e;){if(t in e)return e;e=e.parentView}}rerender(){return this._currentState.rerender(this)}get element(){return this.renderer.getElement(this)}static{Kh(this.prototype,"element",[C({configurable:!1,enumerable:!1})])}appendTo(t){let e;return e=Mo&&"string"==typeof t?document.querySelector(t):t,this.renderer.appendTo(this,e),this}append(){return this.appendTo(document.body)}willInsertElement(){return this}didInsertElement(){return this}willClearRender(){return this}destroy(){return super.destroy(),this._currentState.destroy(this),this}willDestroyElement(){return this}didDestroyElement(){return this}parentViewDidChange(){return this}handleEvent(t,e){return this._currentState.handleEvent(this,t,e)}static isComponentFactory=!0;static toString(){return"@ember/component"}};function e$(t,e){return gb(t,e)}t$.reopenClass({positionalParams:[]}),Nu(Nv,t$);var n$=a({default:()=>u$}),r$=new WeakMap,i$=new WeakMap,s$=class{constructor(t,e){this.args=e,r$.set(this,!1),i$.set(this,!1)}args;get isDestroying(){return r$.get(this)||!1}get isDestroyed(){return i$.get(this)||!1}willDestroy(){}},o$=class{owner;constructor(t){this.owner=t}createComponent(t,e){return new t(this.owner,e.named)}getContext(t){return t}},a$=lb(0,{destructor:!0,asyncLifecycleCallbacks:!1,updateHook:!1});function l$(t){t.isDestroyed||(et(t),function(t){i$.set(t,!0)}(t))}var c$=class extends o${capabilities=a$;destroyComponent(t){t.isDestroying||(function(t){r$.set(t,!0)}(t),ks("actions",t,t.willDestroy),ks("destroy",this,l$,t))}},u$=class extends s${constructor(t,e){super(t,e),Br(this,t)}};e$(t=>new c$(t),u$);var h$=mb,d$=class extends u${get svg(){return eB(this.args.name)}get size(){return this.args.size||16}get color(){return this.args.color||"#898989"}get style(){return $v(`width:${this.size}px;height:${this.size}px;color:${this.color}`)}get title(){return this.args.title||""}get isFilled(){return this.args.filled||nB(this.args.name)}static{Ap(rg({id:null,block:'[[[41,[30,0,["svg"]],[[[1," "],[10,1],[15,0,[29,["icon ",[52,[30,0,["isFilled"]],"icon-filled"]]]],[15,5,[30,0,["style"]]],[15,"title",[30,0,["title"]]],[12],[1,"\\n "],[1,[28,[32,0],[[30,0,["svg"]]],null]],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({htmlSafe:$v}),isStrictMode:!0}),this)}};function p$(t){return Bt(t.argsCache)}var f$=class{argsCache;constructor(t,e=()=>ay){let n=Ut(()=>e(t));this.argsCache=n}get named(){return p$(this).named||sy}get positional(){return p$(this).positional||oy}};function g$(t,e,n){const r=jr(t),i=Ou(e).getDelegateFor(r);let s,o=new f$(t,n),a=i.createHelper(e,o);if(!wu(i))throw new Error("TODO: unreachable, to be implemented with hasScheduledEffect");return s=Ut(()=>i.getValue(a)),Q(t,s),_u(i)&&Q(s,i.getDestroyable(a)),s}function m$(t,e){return t===e}function y$(t,e){return t!==e}function v$(t,e){return t>e}function b$(t,e){return t>=e}function w$(t,e){return tfe(()=>{let e;for(let n=0;nfe(()=>{let e;for(let n=0;n!U(t[0]),k$={createInstance:!0,wrapped:!0},E$=new class{getCapabilities(){return k$}getDebugName(t){return`(element "${t.tagName}")`}getSelf(){return ce}getDestroyable(){return null}didCreateElement(){}create(t,e){return e.tagName||null}getTagName(t){return t}didRenderLayout(){}didUpdateLayout(){}didCreate(){}didUpdate(){}},R$=class{constructor(t){this.tagName=t}toString(){return`(element "${this.tagName}")`}};Nu(E$,R$.prototype);var T$=new Map;Uv(({positional:t,named:e})=>fe(()=>function(t){let e=T$.get(t);return void 0===e&&(e=new R$(t),T$.set(t,e)),e}(we(t[0])),null));var L$=Wv,I$=v$;function P$(t){return"object"==typeof t&&t&&"isTruthy"in t&&"boolean"==typeof t.isTruthy?t.isTruthy:Ic(t)?0!==t.length:!!t}var M$=class extends wb{compute(t){for(let e=0,n=t.length;et.tags||[]);return[...new Set(t)]}static{Ap(rg({id:null,block:'[[[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"contribution-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,1],[[30,1],[30,2]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"contribution-thumb"],[12],[1,"\\n"],[41,[30,0,["primaryPhoto"]],[[[1," "],[10,"img"],[15,"src",[28,[32,2],[[30,0,["primaryPhoto","thumbUrl"]],[30,0,["primaryPhoto","url"]]],null]],[15,"alt",[28,[32,2],[[30,0,["primaryPhoto","alt"]],"Place photo"],null]],[14,"loading","lazy"],[12],[13],[1,"\\n"]],[]],null],[41,[28,[32,3],[[30,0,["extraPhotoCount"]],0],null],[[[1," "],[10,1],[14,0,"contribution-thumb-badge"],[12],[1,"+"],[1,[30,0,["extraPhotoCount"]]],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"contribution-info"],[12],[1,"\\n "],[10,0],[14,0,"contribution-place"],[12],[1,"\\n"],[41,[30,0,["placeName"]],[[[1," "],[1,[30,0,["placeName"]]],[1,"\\n"]],[]],[[[41,[30,0,["isNameLoading"]],[[[1," "],[10,1],[14,0,"contribution-name-loading"],[12],[1,"Loading…"],[13],[1,"\\n"]],[]],[[[1," "],[10,1],[14,0,"contribution-name-loading"],[12],[1,"Unnamed place"],[13],[1,"\\n "]],[]]]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"contribution-meta"],[12],[1,"\\n "],[1,[28,[32,4],[[30,2,["createdAt"]]],null]],[1,"\\n"],[41,[28,[32,3],[[30,0,["item","photos","length"]],1],null],[[[1," ·\\n "],[1,[30,0,["item","photos","length"]]],[1,"\\n photos\\n"]],[]],[[[1," · 1 photo\\n"]],[]]],[1," "],[13],[1,"\\n"],[41,[30,0,["tags","length"]],[[[1," "],[10,0],[14,0,"contribution-tags"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["tags"]]],null]],null],null,[[[1," "],[10,1],[14,0,"contribution-tag"],[12],[1,[30,3]],[13],[1,"\\n"]],[3]],null],[1," "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onSelect","@item","tag"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,fn:L$,or:M$,__keyword__gt:I$,formatRelativeDate:A$}),isStrictMode:!0}),this)}},N$=ob,F$=Ap(rg({id:null,block:'[[[11,0],[24,0,"modal-overlay"],[24,"role","dialog"],[24,"tabindex","-1"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[11,0],[24,0,"modal-content"],[24,"role","document"],[24,"tabindex","0"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[11,"button"],[16,0,[29,["close-modal-btn btn-text ",[52,[30,3],"disabled"]]]],[16,"disabled",[30,3]],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",24,"currentColor"]],null],[1,"\\n "],[13],[1,"\\n "],[18,4,null],[1,"\\n "],[13],[1,"\\n"],[13]],["@close","@stopProp","@disableClose","&default"],["if","yield"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,Icon:d$}),isStrictMode:!0}),N$()),D$=class extends u${get isTesting(){return"test"===rx.environment}get destinationElement(){return document.getElementById("modal-portal")||document.body}stopProp(t){t.stopPropagation()}static{lF(this.prototype,"stopProp",[ql])}close(){this.args.disableClose||this.args.onClose&&this.args.onClose()}static{lF(this.prototype,"close",[ql])}static{Ap(rg({id:null,block:'[[[41,[30,0,["isTesting"]],[[[1," "],[8,[32,0],null,[["@close","@stopProp","@disableClose"],[[30,0,["close"]],[30,0,["stopProp"]],[30,1]]],[["default"],[[[[1,"\\n "],[18,2,null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],[[[40,[[[1," "],[8,[32,0],null,[["@close","@stopProp","@disableClose"],[[30,0,["close"]],[30,0,["stopProp"]],[30,1]]],[["default"],[[[[1,"\\n "],[18,2,null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],"%cursor:0%",[28,[31,3],[[30,0,["destinationElement"]]],null]]],[]]]],["@disableClose","&default"],["if","yield","in-element","-in-el-null"]]',moduleName:"(unknown template module)",scope:()=>({ModalContent:F$}),isStrictMode:!0}),this)}},z$=class extends wb{compute(t){for(let e=0,n=t.length;e!P$(t))}var B$=class{capabilities=pb();constructor(t){this.owner=t}createModifier(t,e){return{instance:new t(this.owner,e),element:null}}installModifier(t,e,n){(function(t,e){const n=t;return n.element=e,n})(t,e).instance.modify(e,n.positional,n.named)}updateModifier(t,e){t.instance.modify(t.element,e.positional,e.named)}destroyModifier({instance:t}){et(t)}};h$(t=>new B$(t),class{constructor(t,e){Y_(this,t)}modify(t,e,n){}});var $$=new class{capabilities=pb();createModifier(t){return{element:null,instance:t}}installModifier(t,e,n){const r=function(t,e){const n=t;return n.element=e,n}(t,e),{positional:i,named:s}=n,o=t.instance(e,i,s);"function"==typeof o&&(r.teardown=o)}updateModifier(t,e){"function"==typeof t.teardown&&t.teardown();const n=t.instance(t.element,e.positional,e.named);"function"==typeof n&&(t.teardown=n)}destroyModifier(t){"function"==typeof t.teardown&&t.teardown()}getDebugName(t){return t.instance.toString()}getDebugInstance(t){return t}};function q$(t,e){return t.toString=()=>e?.name||t.name,h$(()=>$$,t)}var V$=o((t,e)=>{e.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}}),W$=o(t=>{var e,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];t.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},t.getSymbolTotalCodewords=function(t){return n[t]},t.getBCHDigit=function(t){let e=0;for(;0!==t;)e++,t>>>=1;return e},t.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');e=t},t.isKanjiModeEnabled=function(){return void 0!==e},t.toSJIS=function(t){return e(t)}}),H$=o(t=>{t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},t.from=function(e,n){if(t.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(r){return n}}}),G$=o((t,e)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(let n=0;n>>e-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},e.exports=n}),K$=o((t,e)=>{function n(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}n.prototype.set=function(t,e,n,r){const i=t*this.size+e;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(t,e){return this.data[t*this.size+e]},n.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n},n.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]},e.exports=n}),Z$=o(t=>{var e=W$().getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,r=e(t),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),s=[r-7];for(let e=1;e{var e=W$().getSymbolSize;t.getPositions=function(t){const n=e(t);return[[0,0],[n-7,0],[0,n-7]]}}),X$=o(t=>{function e(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}}t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},t.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(t){const e=t.size;let n=0,r=0,i=0,s=null,o=null;for(let a=0;a=5&&(n+=r-5+3),s=e,r=1),e=t.get(l,a),e===o?i++:(i>=5&&(n+=i-5+3),o=e,i=1)}r>=5&&(n+=r-5+3),i>=5&&(n+=i-5+3)}return n},t.getPenaltyN2=function(t){const e=t.size;let n=0;for(let r=0;r=10&&(1488===r||93===r)&&n++,i=i<<1&2047|t.get(o,s),o>=10&&(1488===i||93===i)&&n++}return 40*n},t.getPenaltyN4=function(t){let e=0;const n=t.data.length;for(let r=0;r{var e=H$(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];t.getBlocksCount=function(t,r){switch(r){case e.L:return n[4*(t-1)+0];case e.M:return n[4*(t-1)+1];case e.Q:return n[4*(t-1)+2];case e.H:return n[4*(t-1)+3];default:return}},t.getTotalCodewordsCount=function(t,n){switch(n){case e.L:return r[4*(t-1)+0];case e.M:return r[4*(t-1)+1];case e.Q:return r[4*(t-1)+2];case e.H:return r[4*(t-1)+3];default:return}}}),Q$=o(t=>{var e=new Uint8Array(512),n=new Uint8Array(256);!function(){let t=1;for(let r=0;r<255;r++)e[r]=t,n[t]=r,t<<=1,256&t&&(t^=285);for(let n=255;n<512;n++)e[n]=e[n-255]}(),t.log=function(t){if(t<1)throw new Error("log("+t+")");return n[t]},t.exp=function(t){return e[t]},t.mul=function(t,r){return 0===t||0===r?0:e[n[t]+n[r]]}}),tq=o(t=>{var e=Q$();t.mul=function(t,n){const r=new Uint8Array(t.length+n.length-1);for(let i=0;i=0;){const t=r[0];for(let s=0;s{var n=tq();function r(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(t){this.degree=t,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const r=n.mod(e,this.genPoly),i=this.degree-r.length;if(i>0){const t=new Uint8Array(this.degree);return t.set(r,i),t}return r},e.exports=r}),nq=o(t=>{t.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}}),rq=o(t=>{var e="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",n="(?:(?![A-Z0-9 $%*+\\-./:]|"+(e=e.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";t.KANJI=new RegExp(e,"g"),t.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),t.BYTE=new RegExp(n,"g"),t.NUMERIC=new RegExp("[0-9]+","g"),t.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var r=new RegExp("^"+e+"$"),i=new RegExp("^[0-9]+$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");t.testKanji=function(t){return r.test(t)},t.testNumeric=function(t){return i.test(t)},t.testAlphanumeric=function(t){return s.test(t)}}),iq=o(t=>{var e=nq(),n=rq();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(t,n){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!e.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?t.ccBits[0]:n<27?t.ccBits[1]:t.ccBits[2]},t.getBestModeForData=function(e){return n.testNumeric(e)?t.NUMERIC:n.testAlphanumeric(e)?t.ALPHANUMERIC:n.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},t.isValid=function(t){return t&&t.bit&&t.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+e)}}(e)}catch(r){return n}}}),sq=o(t=>{var e=W$(),n=J$(),r=H$(),i=iq(),s=nq(),o=e.getBCHDigit(7973);function a(t,e){return i.getCharCountIndicator(t,e)+4}function l(t,e){let n=0;return t.forEach(function(t){const r=a(t.mode,e);n+=r+t.getBitsLength()}),n}t.from=function(t,e){return s.isValid(t)?parseInt(t,10):e},t.getCapacity=function(t,r,o){if(!s.isValid(t))throw new Error("Invalid QR Code version");void 0===o&&(o=i.BYTE);const l=8*(e.getSymbolTotalCodewords(t)-n.getTotalCodewordsCount(t,r));if(o===i.MIXED)return l;const c=l-a(o,t);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},t.getBestVersionForData=function(e,n){let s;const o=r.from(n,r.M);if(Array.isArray(e)){if(e.length>1)return function(e,n){for(let r=1;r<=40;r++)if(l(e,r)<=t.getCapacity(r,n,i.MIXED))return r}(e,o);if(0===e.length)return 1;s=e[0]}else s=e;return function(e,n,r){for(let i=1;i<=40;i++)if(n<=t.getCapacity(i,r,e))return i}(s.mode,s.getLength(),o)},t.getEncodedBits=function(t){if(!s.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;e.getBCHDigit(n)-o>=0;)n^=7973<{var e=W$(),n=e.getBCHDigit(1335);t.getEncodedBits=function(t,r){const i=t.bit<<3|r;let s=i<<10;for(;e.getBCHDigit(s)-n>=0;)s^=1335<{var n=iq();function r(t){this.mode=n.NUMERIC,this.data=t.toString()}r.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){let e,n,r;for(e=0;e+3<=this.data.length;e+=3)n=this.data.substr(e,3),r=parseInt(n,10),t.put(r,10);const i=this.data.length-e;i>0&&(n=this.data.substr(e),r=parseInt(n,10),t.put(r,3*i+1))},e.exports=r}),lq=o((t,e)=>{var n=iq(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(t){this.mode=n.ALPHANUMERIC,this.data=t}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=45*r.indexOf(this.data[e]);n+=r.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(r.indexOf(this.data[e]),6)},e.exports=i}),cq=o((t,e)=>{var n=iq();function r(t){this.mode=n.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}r.getBitsLength=function(t){return 8*t},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){for(let e=0,n=this.data.length;e{var n=iq(),r=W$();function i(t){this.mode=n.KANJI,this.data=t}i.getBitsLength=function(t){return 13*t},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e;for(e=0;e=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13)}},e.exports=i}),hq=o((t,e)=>{var n={single_source_shortest_paths:function(t,e,r){var i={},s={};s[e]=0;var o,a,l,c,u,h,d,p=n.PriorityQueue.make();for(p.push(e,0);!p.empty();)for(l in a=(o=p.pop()).value,c=o.cost,u=t[a]||{})u.hasOwnProperty(l)&&(h=c+u[l],d=s[l],(void 0===s[l]||d>h)&&(s[l]=h,p.push(l,h),i[l]=a));if(void 0!==r&&void 0===s[r]){var f=["Could not find a path from ",e," to ",r,"."].join("");throw new Error(f)}return i},extract_shortest_path_from_predecessor_list:function(t,e){for(var n=[],r=e;r;)n.push(r),t[r],r=t[r];return n.reverse(),n},find_path:function(t,e,r){var i=n.single_source_shortest_paths(t,e,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(t){var e,r=n.PriorityQueue,i={};for(e in t=t||{},r)r.hasOwnProperty(e)&&(i[e]=r[e]);return i.queue=[],i.sorter=t.sorter||r.default_sorter,i},default_sorter:function(t,e){return t.cost-e.cost},push:function(t,e){var n={value:t,cost:e};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==e&&(e.exports=n)}),dq=o(t=>{var e=iq(),n=aq(),r=lq(),i=cq(),s=uq(),o=rq(),a=W$(),l=hq();function c(t){return unescape(encodeURIComponent(t)).length}function u(t,e,n){const r=[];let i;for(;null!==(i=t.exec(n));)r.push({data:i[0],index:i.index,mode:e,length:i[0].length});return r}function h(t){const n=u(o.NUMERIC,e.NUMERIC,t),r=u(o.ALPHANUMERIC,e.ALPHANUMERIC,t);let i,s;return a.isKanjiModeEnabled()?(i=u(o.BYTE,e.BYTE,t),s=u(o.KANJI,e.KANJI,t)):(i=u(o.BYTE_KANJI,e.BYTE,t),s=[]),n.concat(r,i,s).sort(function(t,e){return t.index-e.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function d(t,o){switch(o){case e.NUMERIC:return n.getBitsLength(t);case e.ALPHANUMERIC:return r.getBitsLength(t);case e.KANJI:return s.getBitsLength(t);case e.BYTE:return i.getBitsLength(t)}}function p(t,o){let l;const c=e.getBestModeForData(t);if(l=e.from(o,c),l!==e.BYTE&&l.bit=0?t[t.length-1]:null;return n&&n.mode===e.mode?(t[t.length-1].data+=e.data,t):(t.push(e),t)},[]))},t.rawSplit=function(e){return t.fromArray(h(e,a.isKanjiModeEnabled()))}}),pq=o(t=>{var e=W$(),n=H$(),r=G$(),i=K$(),s=Z$(),o=Y$(),a=X$(),l=J$(),c=eq(),u=sq(),h=oq(),d=iq(),p=dq();function f(t,e,n){const r=t.size,i=h.getEncodedBits(e,n);let s,o;for(s=0;s<15;s++)o=1==(i>>s&1),s<6?t.set(s,8,o,!0):s<8?t.set(s+1,8,o,!0):t.set(r-15+s,8,o,!0),s<8?t.set(8,r-s-1,o,!0):s<9?t.set(8,15-s-1+1,o,!0):t.set(8,15-s-1,o,!0);t.set(r-8,8,1,!0)}t.create=function(t,h){if(void 0===t||""===t)throw new Error("No input text");let g,m,y=n.M;return void 0!==h&&(y=n.from(h.errorCorrectionLevel,n.M),g=u.from(h.version),m=a.from(h.maskPattern),h.toSJISFunc&&e.setToSJISFunction(h.toSJISFunc)),function(t,n,h,g){let m;if(Array.isArray(t))m=p.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");{let e=n;if(!e){const n=p.rawSplit(t);e=u.getBestVersionForData(n,h)}m=p.fromString(t,e||40)}}const y=u.getBestVersionForData(m,h);if(!y)throw new Error("The amount of data is too big to be stored in a QR Code");if(n){if(n=0&&r<=6&&(0===i||6===i)||i>=0&&i<=6&&(0===r||6===r)||r>=2&&r<=4&&i>=2&&i<=4?t.set(e+r,s+i,!0,!0):t.set(e+r,s+i,!1,!0))}}(w,n),function(t){const e=t.size;for(let n=8;n=7&&function(t,e){const n=t.size,r=u.getEncodedBits(e);let i,s,o;for(let a=0;a<18;a++)i=Math.floor(a/3),s=a%3+n-8-3,o=1==(r>>a&1),t.set(i,s,o,!0),t.set(s,i,o,!0)}(w,n),function(t,e){const n=t.size;let r=-1,i=n-1,s=7,o=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!t.isReserved(i,a-n)){let r=!1;o>>s&1)),t.set(i,a-n,r),s--,-1===s&&(o++,s=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(w,v),isNaN(g)&&(g=a.getBestMask(w,f.bind(null,w,h))),a.applyMask(g,w),f(w,h,g),{modules:w,version:n,errorCorrectionLevel:h,maskPattern:g,segments:m}}(t,g,y,m)}}),fq=o(t=>{function e(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");let e=t.slice().replace("#","").split("");if(e.length<3||5===e.length||e.length>8)throw new Error("Invalid hex color: "+t);3!==e.length&&4!==e.length||(e=Array.prototype.concat.apply([],e.map(function(t){return[t,t]}))),6===e.length&&e.push("F","F");const n=parseInt(e.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+e.slice(0,6).join("")}}t.getOptions=function(t){t||(t={}),t.color||(t.color={});const n=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,r=t.width&&t.width>=21?t.width:void 0,i=t.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:e(t.color.dark||"#000000ff"),light:e(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},t.getScale=function(t,e){return e.width&&e.width>=t+2*e.margin?e.width/(t+2*e.margin):e.scale},t.getImageWidth=function(e,n){const r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){const i=n.modules.size,s=n.modules.data,o=t.getScale(i,r),a=Math.floor((i+2*r.margin)*o),l=r.margin*o,c=[r.color.light,r.color.dark];for(let t=0;t=l&&n>=l&&t{var e=fq();t.render=function(t,n,r){let i=r,s=n;void 0!==i||n&&n.getContext||(i=n,n=void 0),n||(s=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),i=e.getOptions(i);const o=e.getImageWidth(t.modules.size,i),a=s.getContext("2d"),l=a.createImageData(o,o);return e.qrToImageData(l.data,t,i),function(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+"px",e.style.width=n+"px"}(a,s,o),a.putImageData(l,0,0),s},t.renderToDataURL=function(e,n,r){let i=r;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});const s=t.render(e,n,i),o=i.type||"image/png",a=i.rendererOpts||{};return s.toDataURL(o,a.quality)}}),mq=o(t=>{var e=fq();function n(t,e){const n=t.a/255,r=e+'="'+t.hex+'"';return n<1?r+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function r(t,e,n){let r=t+e;return void 0!==n&&(r+=" "+n),r}t.render=function(t,i,s){const o=e.getOptions(i),a=t.modules.size,l=t.modules.data,c=a+2*o.margin,u=o.color.light.a?"':"",h="0&&c>0&&t[l-1]||(i+=o?r("M",c+n,.5+u+n):r("m",s,0),s=0,o=!1),c+1',d='viewBox="0 0 '+c+" "+c+'"',p=''+u+h+"\n";return"function"==typeof s&&s(null,p),p}}),yq=o(t=>{var e=V$(),n=pq(),r=gq(),i=mq();function s(t,r,i,s,o){const a=[].slice.call(arguments,1),l=a.length,c="function"==typeof a[l-1];if(!c&&!e())throw new Error("Callback required as last argument");if(!c){if(l<1)throw new Error("Too few arguments provided");return 1===l?(i=r,r=s=void 0):2!==l||r.getContext||(s=i,i=r,r=void 0),new Promise(function(e,o){try{e(t(n.create(i,s),r,s))}catch(a){o(a)}})}if(l<2)throw new Error("Too few arguments provided");2===l?(o=i,i=r,r=s=void 0):3===l&&(r.getContext&&void 0===o?(o=s,s=void 0):(o=s,s=i,i=r,r=void 0));try{const e=n.create(i,s);o(null,t(e,r,s))}catch(u){o(u)}}t.create=n.create,t.toCanvas=s.bind(null,r.render),t.toDataURL=s.bind(null,r.renderToDataURL),t.toString=s.bind(null,function(t,e,n){return i.render(t,n)})}),vq=l(yq(),1),bq=q$((t,[e])=>{e&&vq.toCanvas(t,e,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).catch(t=>{console.error("Failed to generate QR code",t)})}),wq=class extends u${static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");get hasExtension(){return"undefined"!=typeof window&&void 0!==window.nostr}async connectExtension(){try{await this.nostrAuth.connectWithExtension(),this.toast.show("Nostr connected successfully"),this.args.onConnect&&this.args.onConnect()}catch(t){console.error(t),alert(t.message)}}static{lF(this.prototype,"connectExtension",[ql])}async connectApp(){try{await this.nostrAuth.connectWithApp(),this.toast.show("Nostr connected successfully"),this.args.onConnect&&this.args.onConnect()}catch(t){console.error(t),alert(t.message)}}static{lF(this.prototype,"connectApp",[ql])}async copyConnectUri(){const t=this.nostrAuth.connectUri;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();const n=document.execCommand("copy");if(document.body.removeChild(e),!n)throw new Error("Fallback copy failed")}this.toast.show("Connection link copied to clipboard")}catch(xD){console.error("Failed to copy text: ",xD),alert("Failed to copy link")}}static{lF(this.prototype,"copyConnectUri",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"nostr-connect-modal"],[12],[1,"\\n "],[10,"h2"],[12],[1,"Connect with Nostr"],[13],[1,"\\n\\n "],[10,0],[14,0,"nostr-connect-options"],[12],[1,"\\n"],[41,[30,0,["hasExtension"]],[[[1," "],[11,"button"],[24,0,"btn btn-primary"],[24,4,"button"],[4,[32,0],["click",[30,0,["connectExtension"]]],null],[12],[1,"\\n Browser Extension (nos2x, Alby)\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,"button"],[14,0,"btn btn-outline"],[14,"disabled",""],[14,"title","No Nostr extension found in your browser"],[14,4,"button"],[12],[1,"\\n Browser Extension (Not Found)\\n "],[13],[1,"\\n"]],[]]],[1,"\\n "],[11,"button"],[24,0,"btn btn-primary"],[24,4,"button"],[4,[32,0],["click",[30,0,["connectApp"]]],null],[12],[1,"\\n Mobile Signer App (Amber, etc.)\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n"],[41,[28,[32,1],[[30,0,["nostrAuth","connectStatus"]],"waiting"],null],[[[1," "],[10,0],[14,0,"nostr-connect-status"],[12],[1,"\\n"],[41,[30,0,["nostrAuth","isMobile"]],[[[1," "],[10,2],[12],[1,"Waiting for you to approve the connection in your mobile signer\\n app..."],[13],[1,"\\n "],[10,0],[14,0,"mobile-connect-actions"],[12],[1,"\\n "],[10,3],[15,6,[30,0,["nostrAuth","connectUri"]]],[14,0,"btn btn-primary"],[12],[1,"\\n Open Signer App\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline"],[24,4,"button"],[4,[32,0],["click",[30,0,["copyConnectUri"]]],null],[12],[1,"\\n Copy Connection Link\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,2],[12],[1,"Scan this QR code with a Nostr signer app (like Amber):"],[13],[1,"\\n "],[10,0],[14,0,"qr-code-container"],[12],[1,"\\n "],[11,"canvas"],[4,[32,2],[[30,0,["nostrAuth","connectUri"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n"]],[]],null],[13]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,eq:j$,qrCode:bq}),isStrictMode:!0}),this)}},_q=q$((t,[e])=>{t&&"number"==typeof e&&e>0&&requestAnimationFrame(()=>{t.scrollTop=e})}),xq=class extends u${static{aF(this.prototype,"isNostrConnectModalOpen",[Vr],function(){return!1})}#qt=void cF(this,"isNostrConnectModalOpen");openNostrConnectModal(t){t.preventDefault(),this.isNostrConnectModalOpen=!0}static{lF(this.prototype,"openNostrConnectModal",[ql])}closeNostrConnectModal(){this.isNostrConnectModalOpen=!1}static{lF(this.prototype,"closeNostrConnectModal",[ql])}onNostrConnected(){this.closeNostrConnectModal(),this.args.onNostrConnected?.()}static{lF(this.prototype,"onNostrConnected",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"\\n "],[10,1],[14,0,"sidebar-header-icon-wrapper"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["activity",20,"#898989"]],null],[1,"\\n "],[13],[1,"\\n My Contributions\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[11,0],[24,0,"sidebar-content"],[4,[32,2],[[30,3]],null],[12],[1,"\\n"],[41,[30,4],[[[1," "],[10,0],[14,0,"sidebar-loading"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["loading-ring",24,"#898989"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],[[[41,[28,[32,3],[[30,5]],null],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"\\n "],[11,3],[24,6,"#"],[24,"role","button"],[24,"tabindex","0"],[4,[32,0],["click",[30,0,["openNostrConnectModal"]]],null],[12],[1,"Connect your Nostr account"],[13],[1,"\\n to see your contributions.\\n "],[13],[1,"\\n"]],[]],[[[41,[28,[32,3],[[30,6,["length"]]],null],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"No contributions yet. Start by adding photos to\\n places."],[13],[1,"\\n"]],[]],[[[1," "],[10,"ul"],[14,0,"contributions-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,6]],null]],null],null,[[[41,[28,[32,4],[[30,7,["type"]],"photo"],null],[[[1," "],[8,[32,5],null,[["@item","@onSelect"],[[30,7],[30,8]]],null],[1,"\\n"]],[]],null]],[7]],null],[1," "],[13],[1,"\\n "]],[]]]],[]]]],[]]],[1," "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[41,[30,0,["isNostrConnectModalOpen"]],[[[1," "],[8,[32,6],null,[["@onClose"],[[30,0,["closeNostrConnectModal"]]]],[["default"],[[[[1,"\\n "],[8,[32,7],null,[["@onConnect"],[[30,0,["onNostrConnected"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null]],["@onBack","@onClose","@scrollTop","@isLoading","@isConnected","@items","item","@onSelect"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,Icon:d$,restoreScroll:_q,not:U$,eq:j$,ContributionPhoto:O$,Modal:D$,NostrConnect:wq}),isStrictMode:!0}),this)}},Cq=a({default:()=>Sq}),Sq=Ap(rg({id:null,block:'[[[41,[30,1,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@items","@isLoading","@isConnected","@scrollTop","@onSelect","@onBack","@onClose","@onNostrConnected"],[[30,1,["items"]],[30,1,["loadContributionsTask","isRunning"]],[30,1,["isConnected"]],[30,1,["scrollTop"]],[30,1,["selectContribution"]],[30,1,["backToMenu"]],[30,1,["close"]],[30,1,["onNostrConnected"]]]],null],[1,"\\n"]],[]],null]],["@controller"],["if"]]',moduleName:"(unknown template module)",scope:()=>({ContributionsTimeline:xq}),isStrictMode:!0}),N$()),kq=class{assert(){}async(t){Promise.resolve().then(t)}reportUncaughtRejection(){this.async(t=>{throw t})}defer(){let t={promise:null,resolve:null,reject:null};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}globalDebuggingEnabled(){return!1}},Eq=new kq,Rq=class{constructor(t){this.maxConcurrency=t||1}},Tq="CANCELLED",Lq="STARTED",Iq="QUEUED",Pq={type:Lq},Mq={type:Iq},Aq=t=>({type:Tq,reason:t}),Oq=Aq("it belongs to a 'drop' Task that was already running"),Nq=class{constructor(t){this.remainingSlots=t}step(){return this.remainingSlots>0?(this.remainingSlots--,Pq):Oq}},Fq=class extends Rq{makeReducer(){return new Nq(this.maxConcurrency)}},Dq=class{constructor(t){this.remainingSlots=t}step(){return this.remainingSlots>0?(this.remainingSlots--,Pq):Mq}},zq=class extends Rq{makeReducer(){return new Dq(this.maxConcurrency)}},jq=Aq("it belongs to a 'keepLatest' Task that was already running"),Uq=class{constructor(t,e){this.remainingSlots=t,this.numToCancel=e}step(){return this.remainingSlots>0?(this.remainingSlots--,Pq):this.numToCancel>0?(this.numToCancel--,jq):Mq}},Bq=class extends Rq{makeReducer(t,e){let n=t+e;return new Uq(this.maxConcurrency,n-this.maxConcurrency-1)}},$q=Aq("it belongs to a 'restartable' Task that was .perform()ed again"),qq=class{constructor(t){this.numToCancel=t}step(){return this.numToCancel>0?(this.numToCancel--,$q):Pq}},Vq=class extends Rq{makeReducer(t,e){return new qq(t+e-this.maxConcurrency)}},Wq=new class{step(){return Pq}},Hq=class{makeReducer(){return Wq}},Gq=new Map,Kq=class{constructor(t,e,n){this.stateTracker=e,this.schedulerPolicy=t,this.initialTaskInstances=n,this.startingInstances=[]}process(){let[t,e,n]=this.filterFinishedTaskInstances(),r=this.schedulerPolicy.makeReducer(e,n),i=t.filter(t=>this.setTaskInstanceExecutionState(t,r.step()));return this.stateTracker.computeFinalStates(t=>this.applyState(t)),this.startingInstances.forEach(t=>t.start()),i}filterFinishedTaskInstances(){let t=0,e=0;return[this.initialTaskInstances.filter(n=>{let r=this.stateTracker.stateFor(n.task),i=n.executor.state;return i.isFinished?(r.onCompletion(n),!1):(i.hasStarted?t+=1:e+=1,!0)}),t,e]}setTaskInstanceExecutionState(t,e){let n=this.stateTracker.stateFor(t.task);switch(t.executor.counted||(t.executor.counted=!0,n.onPerformed(t)),e.type){case Tq:return t.cancel(e.reason),!1;case Lq:return t.executor.state.hasStarted||(this.startingInstances.push(t),n.onStart(t)),n.onRunning(t),!0;case Iq:return n.onQueued(t),!0}}applyState(t){let{taskable:e}=t;if(!e.onState)return;const{guid:n}=e;if(Gq.has(n)&&t.tagt(e))}forEachState(t){this.states.forEach(e=>t(e))}},Jq=new class{onCompletion(){}onPerformed(){}onStart(){}onRunning(){}onQueued(){}},Qq=class{stateFor(){return Jq}computeFinalStates(){}},tV=class{constructor(t,e){this.schedulerPolicy=t,this.stateTrackingEnabled=e,this.taskInstances=[]}cancelAll(t,e){let n=this.taskInstances.map(n=>{n.task.guids[t]&&n.executor.cancel(e)}).filter(t=>!!t);return Promise.all(n)}perform(t){t.onFinalize(()=>this.scheduleRefresh()),this.taskInstances.push(t),this.refresh()}scheduleRefresh(){Promise.resolve().then(()=>this.refresh())}refresh(){let t=this.stateTrackingEnabled?new Xq:new Qq,e=new Kq(this.schedulerPolicy,t,this.taskInstances);this.taskInstances=e.process()}},eV=class{constructor(t,e,n){this.value=t,this.done=e,this.errored=n}},nV=class{constructor(t){this.done=!1,this.generatorFactory=t,this.iterator=null}step(t,e){try{let{value:n,done:r}=this.getIterator()[e](t);return r?this.finalize(n,!1):new eV(n,!1,!1)}catch(n){return this.finalize(n,!0)}}getIterator(){return this.iterator||this.done||(this.iterator=this.generatorFactory()),this.iterator}finalize(t,e){return this.done=!0,this.iterator=null,new eV(t,!0,e)}},rV="__ec_cancel__",iV="__ec_yieldable__",sV="next",oV="throw",aV="return",lV="cancel",cV=class{constructor(t,e){this._taskInstance=t,this._resumeIndex=e}getTaskInstance(){return this._taskInstance}cancel(){let t=this._taskInstance;t.proceed.call(t,this._resumeIndex,lV)}next(t){let e=this._taskInstance;e.proceed.call(e,this._resumeIndex,sV,t)}return(t){let e=this._taskInstance;e.proceed.call(e,this._resumeIndex,aV,t)}throw(t){let e=this._taskInstance;e.proceed.call(e,this._resumeIndex,oV,t)}},uV=class{constructor(){this[iV]=this[iV].bind(this)}onYield(){}_deferable(){let t={resolve:void 0,reject:void 0};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}_toPromise(){let t=this._deferable(),e=this[iV]({proceed(e,n,r){"next"==n||"return"==n?t.resolve(r):t.reject(r)}},0);return t.promise[rV]=e,t.promise}then(...t){return this._toPromise().then(...t)}catch(...t){return this._toPromise().catch(...t)}finally(...t){return this._toPromise().finally(...t)}[iV](t,e){let n=new cV(t,e);return this.onYield(n)}},hV=(new class extends uV{onYield(){}},{completionState:0,value:null,error:null,isSuccessful:!1,isError:!1,isCanceled:!1,hasStarted:!1,isFinished:!1}),dV=class{constructor(t,e){this.kind=t,this.reason=e,this.promise=new Promise(t=>{this.finalize=t})}},pV={},fV=[],gV=class{constructor({generatorFactory:t,env:e,debug:n}){this.generatorState=new nV(t),this.state=Object.assign({},hV),this.index=1,this.disposers=[],this.finalizeCallbacks=[],this.env=e,this.debug=n,this.cancelRequest=null}start(){this.state.hasStarted||this.cancelRequest||(this.setState({hasStarted:!0}),this.proceedSync(sV,void 0))}cancel(t){return this.requestCancel(t)?(this.state.hasStarted?this.proceedWithCancelAsync():this.finalizeWithCancel(),this.cancelRequest.promise):(t.finalize(),t.promise)}setState(t){Object.assign(this.state,t),this.taskInstance.setState(this.state)}proceedChecked(t,e,n){this.state.isFinished||this.advanceIndex(t)&&("cancel"===e?(this.requestCancel(new dV("yielded"),n),this.proceedWithCancelAsync()):this.proceedAsync(e,n))}proceedWithCancelAsync(){this.proceedAsync(aV,pV)}proceedAsync(t,e){this.advanceIndex(this.index),this.env.async(()=>this.proceedSync(t,e))}proceedSync(t,e){this.state.isFinished||(this.dispose(),this.generatorState.done?this.handleResolvedReturnedValue(t,e):this.handleResolvedContinueValue(t,e))}handleResolvedContinueValue(t,e){let n=this.index,r=this.generatorStep(e,t);this.advanceIndex(n)&&(r.errored?this.finalize(r.value,2):this.handleYieldedValue(r))}handleResolvedReturnedValue(t,e){switch(t){case sV:case aV:this.finalize(e,1);break;case oV:this.finalize(e,2)}}handleYieldedUnknownThenable(t){let e=this.index;t.then(t=>{this.proceedChecked(e,sV,t)},t=>{this.proceedChecked(e,oV,t)})}advanceIndex(t){if(this.index===t)return++this.index}handleYieldedValue(t){let e=t.value;e?(this.addDisposer(e[rV]),e.__ec_yieldable__?this.invokeYieldable(e):"function"==typeof e.then?this.handleYieldedUnknownThenable(e):this.proceedWithSimpleValue(e)):this.proceedWithSimpleValue(e)}proceedWithSimpleValue(t){this.proceedAsync(sV,t)}addDisposer(t){"function"==typeof t&&this.disposers.push(t)}dispose(){let t=this.disposers;0!==t.length&&(this.disposers=[],t.forEach(t=>t()))}generatorStep(t,e){fV.push(this);let n=this.generatorState.step(t,e);if(fV.pop(),this._expectsLinkedYield){let t=n.value;t&&"PERFORM_TYPE_LINKED"===t.performType||console.warn("You performed a .linked() task without immediately yielding/returning it. This is currently unsupported (but might be supported in future version of ember-concurrency)."),this._expectsLinkedYield=!1}return n}maybeResolveDefer(){this.defer&&this.state.isFinished&&(1===this.state.completionState?this.defer.resolve(this.state.value):this.defer.reject(this.state.error))}onFinalize(t){this.finalizeCallbacks.push(t),this.state.isFinished&&this.runFinalizeCallbacks()}runFinalizeCallbacks(){this.finalizeCallbacks.forEach(t=>t()),this.finalizeCallbacks=[],this.maybeResolveDefer(),this.maybeThrowUnhandledTaskErrorLater()}promise(){return this.defer||(this.defer=this.env.defer(),this.asyncErrorsHandled=!0,this.maybeResolveDefer()),this.defer.promise}maybeThrowUnhandledTaskErrorLater(){var t;this.asyncErrorsHandled||2!==this.state.completionState||(t=this.state.error)&&"TaskCancelation"===t.name||this.env.async(()=>{this.asyncErrorsHandled||this.env.reportUncaughtRejection(this.state.error)})}requestCancel(t){return!this.cancelRequest&&!this.state.isFinished&&(this.cancelRequest=t,!0)}finalize(t,e){if(this.cancelRequest)return this.finalizeWithCancel();let n={completionState:e};1===e?(n.isSuccessful=!0,n.value=t):2===e?(n.isError=!0,n.error=t):3===e&&(n.error=t),this.finalizeShared(n)}finalizeWithCancel(){let t=this.taskInstance.formatCancelReason(this.cancelRequest.reason),e=new Error(t);this.debugEnabled()&&console.log(t),e.name="TaskCancelation",this.finalizeShared({isCanceled:!0,completionState:3,error:e,cancelReason:t}),this.cancelRequest.finalize()}debugEnabled(){return this.debug||this.env.globalDebuggingEnabled()}finalizeShared(t){this.index++,t.isFinished=!0,this.setState(t),this.runFinalizeCallbacks()}invokeYieldable(t){try{let e=t[iV](this.taskInstance,this.index);this.addDisposer(e)}catch(e){this.env.reportUncaughtRejection(e)}}onYielded(t,e){this.asyncErrorsHandled=!0,this.onFinalize(()=>{let n=this.state.completionState;1===n?t.proceed(e,sV,this.state.value):2===n?t.proceed(e,oV,this.state.error):3===n&&t.proceed(e,lV,null)});let n=this.getPerformType();if("PERFORM_TYPE_UNLINKED"!==n)return()=>{this.detectSelfCancelLoop(n,t),this.cancel(new dV("parent_cancel"))}}getPerformType(){return this.taskInstance.performType||"PERFORM_TYPE_DEFAULT"}detectSelfCancelLoop(t,e){if("PERFORM_TYPE_DEFAULT"!==t)return;let n=e.executor&&e.executor.cancelRequest;!n||"lifespan_end"!==n.kind||this.cancelRequest||this.state.isFinished||this.taskInstance.selfCancelLoopWarning(e)}},mV={last:null,lastRunning:null,lastPerformed:null,lastSuccessful:null,lastComplete:null,lastErrored:null,lastCanceled:null,lastIncomplete:null,performCount:0};Object.freeze(mV);var yV=0,vV=class{constructor(t){this.context=t.context,this.debug=t.debug||!1,this.enabledModifiers=t.enabledModifiers,this.env=t.env,this.group=t.group,this.hasEnabledEvents=t.hasEnabledEvents,this.modifierOptions=t.modifierOptions,this.name=t.name,this.onStateCallback=t.onStateCallback,this.scheduler=t.scheduler,this.guid="ec_"+yV++,this.guids={},this.guids[this.guid]=!0,this.group&&Object.assign(this.guids,this.group.guids)}cancelAll(t){let{reason:e,cancelRequestKind:n,resetState:r}=t||{};e=e||".cancelAll() was explicitly called on the Task";let i=new dV(n||"explicit",e);return this.scheduler.cancelAll(this.guid,i).then(()=>{r&&this._resetState()})}get _isAlive(){return!0}_resetState(){this.setState(mV)}setState(){}};Object.assign(vV.prototype,mV),Object.assign(vV.prototype,{numRunning:0,numQueued:0,isRunning:!1,isQueued:!1,isIdle:!0,state:"idle"});var bV,wV,_V=class{constructor(t,e,n){this.task=t,this.performType=e,this.linkedObject=n}perform(...t){return this.task._performShared(t,this.performType,this.linkedObject)}},xV=class t extends vV{constructor(t){super(t),this.generatorFactory=t.generatorFactory,this.perform=this._perform.bind(this)}linked(){let t=fV[fV.length-1];if(!t)throw new Error("You can only call .linked() from within a task.");return new _V(this,"PERFORM_TYPE_LINKED",t)}unlinked(){return new _V(this,"PERFORM_TYPE_UNLINKED",null)}toString(){return``}_clone(){return new t({context:this.context,debug:this.debug,env:this.env,generatorFactory:this.generatorFactory,group:this.group,hasEnabledEvents:this.hasEnabledEvents,name:this.name,onStateCallback:this.onStateCallback,scheduler:this.scheduler})}_curry(...t){let e=this._clone();return e._curryArgs=[...this._curryArgs||[],...t],e}_perform(...t){return this._performShared(t,"PERFORM_TYPE_DEFAULT",null)}_performShared(t,e,n){let r=this._curryArgs?[...this._curryArgs,...t]:t,i=this._taskInstanceFactory(r,e,n);return"PERFORM_TYPE_LINKED"===e&&(n._expectsLinkedYield=!0),this._isAlive||i.cancel(),this.scheduler.perform(i),i}_taskInstanceOptions(t,e,n){return{args:t,executor:new gV({generatorFactory:()=>this.generatorFactory(t),env:this.env,debug:this.debug}),performType:e,hasEnabledEvents:this.hasEnabledEvents}}},CV={enqueue:(t,e)=>e&&t.setBufferPolicy(zq),debug:(t,e)=>e&&t.setDebug(e),drop:(t,e)=>e&&t.setBufferPolicy(Fq),keepLatest:(t,e)=>e&&t.setBufferPolicy(Bq),maxConcurrency:(t,e)=>t.setMaxConcurrency(e),onState:(t,e)=>t.setOnState(e),restartable:(t,e)=>e&&t.setBufferPolicy(Vq)},SV=class{env=Eq;_debug=null;_enabledModifiers=[];_hasSetConcurrencyConstraint=!1;_hasSetBufferPolicy=!1;_hasEnabledEvents=!1;_maxConcurrency=null;_onStateCallback=(t,e)=>e.setState(t);_schedulerPolicyClass=Hq;constructor(t="",e=null,n={}){this.name=t,this.taskDefinition=e,this.options=n,this._processModifierOptions(n)}createTask(t){let e=this.getTaskOptions(t);return new xV(Object.assign({generatorFactory:e=>this.taskDefinition.apply(t,e)},e))}getModifier(t){if(function(t){return t in CV}(t))return CV[t].bind(null,this)}getOptions(){return this.options}getScheduler(t,e){return new tV(t,e)}getTaskOptions(t){let e,n=this._onStateCallback,r=new this._schedulerPolicyClass(this._maxConcurrency);return e=this.getScheduler(r,n&&"function"==typeof n),{context:t,debug:this._debug,env:this.env,name:this.name,group:void 0,scheduler:e,hasEnabledEvents:this._hasEnabledEvents,onStateCallback:n,enabledModifiers:this._enabledModifiers,modifierOptions:this.getOptions()}}setBufferPolicy(t){return function(t){if(t._hasSetBufferPolicy)throw new Error(`Cannot set multiple buffer policies on a task. ${t._schedulerPolicyClass} has already been set for task '${t.name}'`)}(this),this._hasSetBufferPolicy=!0,this._hasSetConcurrencyConstraint=!0,this._schedulerPolicyClass=t,this}setDebug(t){return this._debug=t,this}setEvented(t){return this._hasEnabledEvents=t,this}setMaxConcurrency(t){return this._hasSetConcurrencyConstraint=!0,this._maxConcurrency=t,this}setName(t){return this.name=t,this}setOnState(t){return this._onStateCallback=t,this}setTaskDefinition(t){return this.taskDefinition=t,this}_processModifierOptions(t){if(t)for(let e of Object.keys(t)){let n=t[e],r=this.getModifier(e);"function"==typeof r&&r(n)&&this._enabledModifiers.push(e)}}},kV=a({EventTarget:()=>Oo,Promise:()=>ra,all:()=>aa,allSettled:()=>ca,asap:()=>Ea,async:()=>Da,cast:()=>Fa,configure:()=>Fo,default:()=>Ua,defer:()=>ma,denodeify:()=>sa,filter:()=>Ca,hash:()=>da,hashSettled:()=>fa,map:()=>va,off:()=>ja,on:()=>za,race:()=>ua,reject:()=>wa,resolve:()=>ba,rethrow:()=>ga}),EV=new class extends kq{assert(...t){}async(t){_s(()=>ks("actions",t))}reportUncaughtRejection(t){Ps(null,function(){throw t})}defer(){return ma()}globalDebuggingEnabled(){return!1}},RV=class extends tV{scheduleRefresh(){Ls(this,this.refresh)}},TV=class{constructor({task:t,args:e,executor:n,performType:r,hasEnabledEvents:i}){this.task=t,this.args=e,this.performType=r,this.executor=n,this.executor.taskInstance=this,this.hasEnabledEvents=i}setState(){}formatCancelReason(){}selfCancelLoopWarning(){}onFinalize(t){this.executor.onFinalize(t)}proceed(t,e,n){this.executor.proceedChecked(t,e,n)}[iV](t,e){return this.executor.onYielded(t,e)}cancel(t=".cancel() was explicitly called"){this.executor.cancel(new dV("explicit",t))}then(...t){return this.executor.promise().then(...t)}catch(...t){return this.executor.promise().catch(...t)}finally(...t){return this.executor.promise().finally(...t)}toString(){return`${this.task} TaskInstance`}start(){return this.executor.start(),this}};function LV(t,e){return Object.keys(t).reduce((e,n)=>function(t,e,n){const r=Object.getOwnPropertyDescriptor(t,n);return r.initializer=r.initializer||(()=>t[n]),delete r.value,e[n]=Vr(e,n,r),e}(t,e,n),e)}Object.assign(TV.prototype,hV),Object.assign(TV.prototype,{state:"waiting",isDropped:!1,isRunning:!0}),bV=LV(mV,{}),bV=LV({numRunning:0,numQueued:0,isRunning:!1,isQueued:!1,isIdle:!0,state:"idle"},bV),wV=LV(hV,{}),wV=LV({state:"waiting",isDropped:!1,isRunning:!1},wV),Object.freeze(bV),Object.freeze(wV);var IV=class extends TV{setState(t){let e=this._recomputeState(t);Object.assign(this,{...t,isRunning:!t.isFinished,isDropped:"dropped"===e,state:e})}_recomputeState(t){return t.isDropped?"dropped":t.isCanceled?t.hasStarted?"canceled":"dropped":t.isFinished?"finished":t.hasStarted?"running":"waiting"}formatCancelReason(t){return`TaskInstance '${this.getName()}' was canceled because ${t}. For more information, see: http://ember-concurrency.com/docs/task-cancelation-help`}getName(){return this.name||(this.name=this.task&&this.task.name||""),this.name}selfCancelLoopWarning(t){let e=`\`${t.getName()}\``,n=`\`${this.getName()}\``;console.warn(`ember-concurrency detected a potentially hazardous "self-cancel loop" between parent task ${e} and child task ${n}. If you want child task ${n} to be canceled when parent task ${e} is canceled, please change \`.perform()\` to \`.linked().perform()\`. If you want child task ${n} to keep running after parent task ${e} is canceled, change it to \`.unlinked().perform()\``)}triggerEvent(...t){if(!this.hasEnabledEvents)return;let e=this.task,n=e.context,r=e&&e.name;if(n&&n.trigger&&r){let[e,...i]=t;n.trigger(`${r}:${e}`,...i)}}};wV&&Object.defineProperties(IV.prototype,wV);var PV={_performCount:0,setState(t){this._performCount=this._performCount+(t.numPerformedInc||0);let e=t.numRunning>0,n=t.numQueued>0,r=Object.assign({},t,{performCount:this._performCount,isRunning:e,isQueued:n,isIdle:!e&&!n,state:e?"running":"idle"});Object.assign(this,r)},onState(t,e){e.onStateCallback&&e.onStateCallback(t,e)}},MV=class t extends xV{constructor(t){super(t),rt(this.context)||Ex(this.context,()=>{this.cancelAll({reason:"the object it lives on was destroyed or unrendered",cancelRequestKind:"lifespan_end"})})}get _isAlive(){return!rt(this.context)}_taskInstanceFactory(t,e,n){let r=this._taskInstanceOptions(t,e,n);return r.task=this,new IV(r)}_clone(){return new t({context:this.context,debug:this.debug,env:this.env,generatorFactory:this.generatorFactory,group:this.group,hasEnabledEvents:this.hasEnabledEvents,name:this.name,onStateCallback:this.onStateCallback,scheduler:this.scheduler})}};bV&&Object.defineProperties(MV.prototype,bV),Object.assign(MV.prototype,PV);var AV=class extends SV{env=EV;createTask(t){this.taskDefinition;let e=this.getTaskOptions(t);return new MV(Object.assign({generatorFactory:e=>this.taskDefinition.apply(t,e)},e))}getModifier(t){return super.getModifier(t)}getScheduler(t,e){return new RV(t,e)}get taskFn(){return this.taskDefinition}set taskFn(t){this.setTaskDefinition(t)}};function OV(t,e,n,r){let i=e;r&&(i=Object.assign({},i),i[r]=!0);const s=t();return new AV(n||"",s.generator,i).createTask(s.context)}var NV=a({default:()=>FV}),FV=class extends tu{static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"contributions",[dp])}#Ht=void cF(this,"contributions");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");loadContributionsTask=OV(()=>({context:this,generator:function*(t){t&&(yield this.contributions.load(t))}}),{restartable:!0},"loadContributionsTask",null);get scrollTop(){return this.mapUi.getScrollPosition("contributions")}get items(){return this.contributions.items}get isConnected(){return this.nostrAuth.isConnected}selectContribution(t){if(!t)return;const e=document.querySelector(".sidebar-content");e&&this.mapUi.saveScrollPosition("contributions",e.scrollTop),this.mapUi.returnToRoute={name:"contributions"},this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!0,this.router.transitionTo(`/place/${t.placeIdentifier}`)}static{lF(this.prototype,"selectContribution",[ql])}onNostrConnected(){this.loadContributionsTask.perform(this.nostrAuth.pubkey)}static{lF(this.prototype,"onNostrConnected",[ql])}backToMenu(){this.router.transitionTo("menu")}static{lF(this.prototype,"backToMenu",[ql])}close(){this.router.transitionTo("index")}static{lF(this.prototype,"close",[ql])}},DV=a({default:()=>zV}),zV=class extends Jh{static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"contributions",[dp])}#Ht=void cF(this,"contributions");activate(){this.mapUi.showSidebar()}setupController(t,e){super.setupController(t,e),t&&t.loadContributionsTask&&t.loadContributionsTask.perform(this.nostrAuth.pubkey)}deactivate(){this.contributions.stop()}},jV=a({default:()=>UV}),UV=Ap(rg({id:null,block:'[[[46,[28,[31,1],null,null],null,null,null]],[],["component","-outlet"]]',moduleName:"(unknown template module)",isStrictMode:!0}),N$()),BV=a({default:()=>$V}),$V=class extends Jh{static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");activate(){this.mapUi.showSidebar()}},qV=class extends u${static{aF(this.prototype,"title",[Vr],function(){return""})}#Gt=void cF(this,"title");static{aF(this.prototype,"description",[Vr],function(){return""})}#Kt=void cF(this,"description");constructor(){super(...arguments),this.title=this.args.place?.title||"",this.description=this.args.place?.description||""}get shouldAutofocus(){return"undefined"!=typeof window&&window.innerWidth>768}handleSubmit(t){t.preventDefault(),this.args.onSave&&this.args.onSave({title:this.title,description:this.description})}static{lF(this.prototype,"handleSubmit",[ql])}updateTitle(t){this.title=t.target.value}static{lF(this.prototype,"updateTitle",[ql])}updateDescription(t){this.description=t.target.value}static{lF(this.prototype,"updateDescription",[ql])}static{Ap(rg({id:null,block:'[[[11,"form"],[24,0,"edit-form"],[4,[32,0],["submit",[30,0,["handleSubmit"]]],null],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","edit-title"],[12],[1,"Title"],[13],[1,"\\n"],[1," "],[11,"input"],[24,1,"edit-title"],[16,2,[30,0,["title"]]],[24,0,"form-control"],[24,"placeholder","Name of the place"],[16,"autofocus",[30,0,["shouldAutofocus"]]],[24,4,"text"],[4,[32,0],["input",[30,0,["updateTitle"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","edit-desc"],[12],[1,"Description"],[13],[1,"\\n "],[11,"textarea"],[24,1,"edit-desc"],[16,2,[30,0,["description"]]],[24,0,"form-control"],[24,"rows","3"],[24,"placeholder","Add some details..."],[4,[32,0],["input",[30,0,["updateDescription"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"edit-actions"],[12],[1,"\\n "],[10,"button"],[14,0,"btn btn-blue"],[14,4,"submit"],[12],[1,"Save"],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"Cancel"],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onCancel"],[]]',moduleName:"(unknown template module)",scope:()=>({on:Ww}),isStrictMode:!0}),this)}},VV=q$((t,[e])=>{const n=n=>{t&&!t.contains(n.target)&&e(n)},r=setTimeout(()=>{document.addEventListener("click",n)},0);return()=>{clearTimeout(r),document.removeEventListener("click",n)}}),WV=class extends u${static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"_forceClear",[Vr],function(){return!1})}#Zt=void cF(this,"_forceClear");get isSaved(){return this.args.isSaved}get placeListIds(){return this._forceClear?[]:this.args.place._listIds||[]}styleFor(t){return $v(`background-color: ${t}`)}isInList(t){return!!this.placeListIds&&this.placeListIds.includes(t.id)}static{lF(this.prototype,"isInList",[ql])}async toggleSaved(){if(this.isSaved){const{osmId:t,osmType:e}=this.args.place;if(await this.storage.removePlace(this.args.place),this.args.place&&(this.args.place.id=null,this.args.place.createdAt=null,this.args.place._listIds=[],this._forceClear=!0),t&&e){const t={...this.args.place};delete t.id,delete t.createdAt,delete t._listIds,this.router.transitionTo("place",t)}else this.router.transitionTo("index");this.args.onClose&&this.args.onClose()}else await this.storage.storePlace(this.args.place)}static{lF(this.prototype,"toggleSaved",[ql])}async toggleList(t){const e=!this.placeListIds.includes(t.id);e&&!this.isSaved&&await this.storage.storePlace(this.args.place);try{await this.storage.togglePlaceList(this.args.place,t.id,e)}catch(n){console.error(n),alert("Failed to update list: "+n.message)}}static{lF(this.prototype,"toggleList",[ql])}static{Ap(rg({id:null,block:'[[[11,0],[24,0,"place-lists-manager"],[4,[32,0],[[30,1]],null],[12],[1,"\\n "],[10,0],[14,0,"list-item master-toggle"],[12],[1,"\\n "],[10,"label"],[12],[1,"\\n "],[11,"input"],[16,"checked",[30,0,["isSaved"]]],[24,4,"checkbox"],[4,[32,1],["change",[30,0,["toggleSaved"]]],null],[12],[13],[1,"\\n "],[10,1],[14,0,"list-color-dot"],[12],[13],[1,"\\n "],[10,1],[14,0,"list-name"],[12],[1,"Saved places"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"divider"],[12],[13],[1,"\\n\\n "],[10,0],[14,0,"lists-container"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["storage","lists"]]],null]],null],null,[[[1," "],[10,0],[14,0,"list-item"],[12],[1,"\\n "],[10,"label"],[12],[1,"\\n "],[11,"input"],[16,"checked",[28,[30,0,["isInList"]],[[30,2]],null]],[16,"disabled",[52,[51,[30,0,["isSaved"]]],true]],[24,4,"checkbox"],[4,[32,1],["change",[28,[32,2],[[30,0,["toggleList"]],[30,2]],null]],null],[12],[13],[1,"\\n"],[1," "],[10,1],[14,0,"list-color-dot"],[15,5,[28,[30,0,["styleFor"]],[[30,2,["color"]]],null]],[12],[13],[1,"\\n "],[10,1],[14,0,"list-name"],[12],[1,[30,2,["title"]]],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n"],[13]],["@onClose","list"],["each","-track-array","unless"]]',moduleName:"(unknown template module)",scope:()=>({onClickOutside:VV,on:Ww,fn:L$}),isStrictMode:!0}),this)}},HV=class extends u${renderBlurhash=q$((t,[e,n,r])=>{if(!e||!t)return;const i=n||32,s=r||18;t.width=i,t.height=s;const o=t.getContext("2d");if(o)try{const t=((t,e,n)=>{(t=>{if(!t||t.length<6)throw new LB("The blurhash string must be at least 6 characters");let e=SB(t[0]),n=Math.floor(e/9)+1,r=e%9+1;if(t.length!==4+2*r*n)throw new LB(`blurhash length mismatch: length is ${t.length} but it should be ${4+2*r*n}`)})(t);let r=SB(t[0]),i=Math.floor(r/9)+1,s=r%9+1,o=(SB(t[1])+1)/166,a=new Array(s*i);for(let u=0;u({context:this,generator:function*(t){this.error="",this.statusText="Processing";try{const e=yield this.imageProcessor.process(t,1920,.9,!0);this.blurhash=e.blurhash;const n=yield this.imageProcessor.process(t,350,.9,!1);let r,i;const s=ez(),o=t=>{"signing"===t&&(this.statusText="Signing photo upload"),"uploading"===t&&(this.statusText="Uploading photo")},a=t=>{"signing"===t&&(this.statusText="Signing thumbnail upload"),"uploading"===t&&(this.statusText="Uploading thumbnail")};if(s)r=yield this.blossom.upload(e.blob,{sequential:!0,onProgress:o}),i=yield this.blossom.upload(n.blob,{sequential:!0,onProgress:a});else{const t=this.blossom.upload(e.blob,{onProgress:o}),s=this.blossom.upload(n.blob,{onProgress:a});[r,i]=yield Promise.all([t,s])}this.args.onSuccess&&this.args.onSuccess({file:t,url:r.url,fallbackUrls:r.fallbackUrls,thumbUrl:i.url,blurhash:e.blurhash,type:"image/jpeg",dim:e.dim,hash:r.hash,thumbHash:i.hash})}catch(e){this.error=e.message}}}),null,"uploadTask",null);static{Ap(rg({id:null,block:'[[[10,0],[15,0,[29,["photo-upload-item\\n ",[52,[30,0,["uploadTask","isRunning"]],"is-uploading"],"\\n ",[52,[30,0,["error"]],"has-error"]]]],[12],[1,"\\n"],[41,[30,0,["blurhash"]],[[[1," "],[8,[32,0],[[24,0,"place-header-photo-blur"]],[["@hash"],[[30,0,["blurhash"]]]],null],[1,"\\n"]],[]],null],[1," "],[10,"img"],[15,"src",[30,0,["thumbnailUrl"]]],[14,"alt","thumbnail"],[12],[13],[1,"\\n\\n"],[41,[30,0,["uploadTask","isRunning"]],[[[1," "],[10,0],[14,0,"overlay"],[12],[1,"\\n "],[8,[32,1],[[24,0,"spin-animation"]],[["@name","@size","@color"],["loading-ring",24,"white"]],null],[1,"\\n"],[41,[30,0,["statusText"]],[[[1," "],[10,1],[14,0,"upload-status-text"],[12],[1,[30,0,["statusText"]]],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["error"]],[[[1," "],[11,"button"],[24,0,"overlay error-overlay"],[16,"title",[30,0,["error"]]],[24,4,"button"],[4,[32,2],["click",[30,0,["showErrorToast"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["alert-circle",24,"white"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[11,"button"],[24,0,"btn-remove-photo"],[24,"title","Remove photo"],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,1],[30,2]],null]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",16,"white"]],null],[1,"\\n "],[13],[1,"\\n"],[13]],["@onRemove","@file"],["if"]]',moduleName:"(unknown template module)",scope:()=>({Blurhash:HV,Icon:d$,on:Ww,fn:L$}),isStrictMode:!0}),this)}},KV=kb(function([t]){return yU(t)}),ZV=kb(function([t,e]){return!!Array.isArray(t)&&t.includes(e)}),YV=class extends u${static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"nostrRelay",[dp])}#at=void cF(this,"nostrRelay");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"blossom",[dp])}#Yt=void cF(this,"blossom");static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");static{aF(this.prototype,"file",[Vr],function(){return null})}#ne=void cF(this,"file");static{aF(this.prototype,"uploadedPhoto",[Vr],function(){return null})}#re=void cF(this,"uploadedPhoto");static{aF(this.prototype,"error",[Vr],function(){return""})}#te=void cF(this,"error");static{aF(this.prototype,"isPublishing",[Vr],function(){return!1})}#ie=void cF(this,"isPublishing");static{aF(this.prototype,"isDragging",[Vr],function(){return!1})}#se=void cF(this,"isDragging");static{aF(this.prototype,"selectedTags",[Vr],function(){return[]})}#oe=void cF(this,"selectedTags");static{aF(this.prototype,"altText",[Vr],function(){return""})}#ae=void cF(this,"altText");get place(){return this.args.place||{}}get title(){return this.place.title||"this place"}get allUploaded(){return this.file&&this.uploadedPhoto&&this.file===this.uploadedPhoto.file}get suggestedTags(){return dB(this.place)}handleFileSelect(t){this.addFile(t.target.files[0]),t.target.value=""}static{lF(this.prototype,"handleFileSelect",[ql])}handleDragOver(t){t.preventDefault(),this.isDragging=!0}static{lF(this.prototype,"handleDragOver",[ql])}handleDragLeave(t){t.preventDefault(),this.isDragging=!1}static{lF(this.prototype,"handleDragLeave",[ql])}handleDrop(t){t.preventDefault(),this.isDragging=!1,t.dataTransfer.files.length>0&&this.addFile(t.dataTransfer.files[0])}static{lF(this.prototype,"handleDrop",[ql])}addFile(t){t&&t.type.startsWith("image/")?(this.error="",this.uploadedPhoto&&this.deletePhotoTask.perform(this.uploadedPhoto),this.file=t,this.uploadedPhoto=null,this.args.onUploadStateChange&&this.args.onUploadStateChange(!0)):this.error="Please select a valid image file."}handleUploadSuccess(t){this.uploadedPhoto=t}static{lF(this.prototype,"handleUploadSuccess",[ql])}removeFile(){this.uploadedPhoto&&this.deletePhotoTask.perform(this.uploadedPhoto),this.file=null,this.uploadedPhoto=null,this.selectedTags=[],this.altText="",this.args.onUploadStateChange&&this.args.onUploadStateChange(!1)}static{lF(this.prototype,"removeFile",[ql])}toggleTag(t){this.selectedTags.includes(t)?this.selectedTags=[]:this.selectedTags=[t]}static{lF(this.prototype,"toggleTag",[ql])}updateAltText(t){this.altText=t.target.value}static{lF(this.prototype,"updateAltText",[ql])}deletePhotoTask=OV(()=>({context:this,generator:function*(t){try{t.hash&&(yield this.blossom.delete(t.hash)),t.thumbHash&&(yield this.blossom.delete(t.thumbHash))}catch(e){this.toast.show(`Failed to delete photo from server: ${e.message}`,5e3)}}}),null,"deletePhotoTask",null);async publish(){if(!this.nostrAuth.isConnected)return void(this.error="You must connect Nostr first.");if(!this.allUploaded)return void(this.error="Please wait for all photos to finish uploading.");const{osmId:t,lat:e,lon:n}=this.place,r=this.place.osmType||"node";if(t){this.error="",this.isPublishing=!0;try{const i=[["i",`osm:${r}:${t}`]];for(const t of this.selectedTags)i.push(["t",t]);e&&n&&(i.push(["g",_j.encode(e,n,4)]),i.push(["g",_j.encode(e,n,6)]),i.push(["g",_j.encode(e,n,7)]),i.push(["g",_j.encode(e,n,9)]));const s=this.uploadedPhoto,o=["imeta",`url ${s.url}`];o.push(`m ${s.type}`),s.dim&&o.push(`dim ${s.dim}`);const a=this.altText.trim();if(a&&o.push(`alt ${a}`),s.fallbackUrls&&s.fallbackUrls.length>0)for(const t of s.fallbackUrls)o.push(`fallback ${t}`);s.thumbUrl&&o.push(`thumb ${s.thumbUrl}`),s.blurhash&&o.push(`blurhash ${s.blurhash}`),i.push(o);const l=await bN.fromKind(360).content("").modifyPublicTags(()=>i).as(this.nostrAuth.signer).sign();await this.nostrRelay.publish(this.nostrData.activeWriteRelays,l),this.nostrData.store.add(l),this.toast.show("Photo published successfully"),this.file=null,this.uploadedPhoto=null,this.altText="",this.args.onUploadStateChange&&this.args.onUploadStateChange(!1),this.args.onClose&&this.args.onClose(l.id)}catch(i){this.error="Failed to publish: "+i.message}finally{this.isPublishing=!1}}else this.error="This place does not have a valid OSM ID."}static{lF(this.prototype,"publish",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"place-photo-upload"],[12],[1,"\\n "],[10,"h2"],[12],[1,"Add Photo for "],[1,[30,0,["title"]]],[13],[1,"\\n\\n"],[41,[30,0,["error"]],[[[1," "],[10,0],[14,0,"alert alert-error"],[12],[1,"\\n "],[1,[30,0,["error"]]],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["file"]],[[[1," "],[8,[32,0],null,[["@file","@onSuccess","@onRemove"],[[30,0,["file"]],[30,0,["handleUploadSuccess"]],[30,0,["removeFile"]]]],null],[1,"\\n\\n"],[41,[30,0,["suggestedTags","length"]],[[[1," "],[10,0],[14,0,"photo-tag-suggestions"],[12],[1,"\\n "],[10,2],[14,0,"photo-tag-suggestions-title"],[12],[1,"\\n Choose a tag/category (optional):\\n "],[13],[1,"\\n "],[10,0],[14,0,"photo-tag-suggestions-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["suggestedTags"]]],null]],null],null,[[[1," "],[11,"button"],[16,0,[29,["photo-tag-chip\\n ",[52,[28,[32,1],[[30,0,["selectedTags"]],[30,1]],null],"is-selected"]]]],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["toggleTag"]],[30,1]],null]],null],[12],[1,"\\n "],[1,[28,[32,4],[[30,1]],null]],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","photo-alt-input"],[12],[1,"Description (optional):"],[13],[1,"\\n "],[11,"input"],[24,1,"photo-alt-input"],[24,0,"form-control"],[24,"placeholder","Describe this photo"],[16,2,[30,0,["altText"]]],[16,"disabled",[30,0,["isPublishing"]]],[24,4,"text"],[4,[32,2],["input",[30,0,["updateAltText"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n\\n "],[11,"button"],[24,0,"btn btn-primary btn-publish"],[16,"disabled",[28,[32,5],[[28,[32,6],[[30,0,["allUploaded"]]],null],[30,0,["isPublishing"]]],null]],[24,4,"button"],[4,[32,2],["click",[30,0,["publish"]]],null],[12],[1,"\\n"],[41,[30,0,["isPublishing"]],[[[1," Publishing...\\n"]],[]],[[[1," Publish Photo\\n"]],[]]],[1," "],[13],[1,"\\n"]],[]],[[[1," "],[11,0],[16,0,[29,["dropzone ",[52,[30,0,["isDragging"]],"is-dragging"]]]],[4,[32,2],["dragover",[30,0,["handleDragOver"]]],null],[4,[32,2],["dragleave",[30,0,["handleDragLeave"]]],null],[4,[32,2],["drop",[30,0,["handleDrop"]]],null],[12],[1,"\\n "],[10,"label"],[14,"for","photo-upload-input"],[14,0,"dropzone-label"],[12],[1,"\\n "],[8,[32,7],null,[["@name","@size","@color"],["upload-cloud",48,"#ccc"]],null],[1,"\\n "],[10,2],[12],[1,"Drag and drop a photo here, or click to browse"],[13],[1,"\\n "],[13],[1,"\\n "],[11,"input"],[24,1,"photo-upload-input"],[24,"accept","image/*"],[24,0,"file-input-hidden"],[16,"disabled",[30,0,["isPublishing"]]],[24,4,"file"],[4,[32,2],["change",[30,0,["handleFileSelect"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n"]],[]]],[13]],["tag"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({PlacePhotoUploadItem:GV,includes:ZV,on:Ww,fn:L$,capitalize:KV,or:M$,not:U$,Icon:d$}),isStrictMode:!0}),this)}},XV=q$((t,[e])=>{if(!e)return;let n;t.classList.remove("loaded"),t.classList.remove("loaded-instant");const r=()=>{const e=t.parentElement,n=e&&"PICTURE"===e.tagName?e.parentElement:e;if(n&&n.closest(".photo-carousel.gallery-main")){const t=n.querySelector(".place-header-photo-blur");t&&(t.style.opacity="0")}},i=()=>{t.classList.contains("loaded-instant")||t.classList.add("loaded"),r()};return t.addEventListener("load",i),n=new IntersectionObserver((n,i)=>{n.forEach(n=>{if(n.isIntersecting){i.unobserve(t);const n=new Image;n.src=e,n.complete&&(t.classList.add("loaded-instant"),r());const s=t.parentElement;s&&"PICTURE"===s.tagName&&s.querySelectorAll("source").forEach(t=>{t.dataset.srcset&&(t.srcset=t.dataset.srcset)}),t.dataset.src?t.src=t.dataset.src:t.src=e}})},{root:null,rootMargin:"100px 100%",threshold:0}),n.observe(t),()=>{t.removeEventListener("load",i),n&&n.disconnect()}}),JV=class extends u${static{aF(this.prototype,"canScrollLeft",[Vr],function(){return!1})}#le=void cF(this,"canScrollLeft");static{aF(this.prototype,"canScrollRight",[Vr],function(){return!1})}#ce=void cF(this,"canScrollRight");internalEventId=null;carouselElement=null;get photos(){return this.args.photos||[]}get showChevrons(){return this.photos.length>1}get cannotScrollLeft(){return!this.canScrollLeft}get cannotScrollRight(){return!this.canScrollRight}get isGalleryMain(){return"gallery-main"===this.args.variant}get isGalleryThumbnails(){return"gallery-thumbnails"===this.args.variant}get variantClass(){return this.args.variant||"inline"}lastResetKey=null;resetScrollPosition=q$((t,[e])=>{void 0!==e&&e!==this.lastResetKey&&(this.lastResetKey=e,t.scrollLeft=0,setTimeout(()=>this.updateScrollState(),50))});isProgrammaticScroll=!1;scrollToNewPhoto=q$((t,[e])=>{if(e&&e!==this.lastEventId){const n=!this.lastEventId;if(this.lastEventId=e,this.internalEventId===e)return;this.internalEventId=e,this.isProgrammaticScroll=!0;const r=()=>{const r=t.querySelector(`[data-event-id="${e}"]`);if(r)if(n){const e=t.style.scrollBehavior;t.style.scrollBehavior="auto",t.scrollLeft=r.offsetLeft,setTimeout(()=>{t.style.scrollBehavior=e,this.isProgrammaticScroll=!1},50)}else t.scrollLeft=r.offsetLeft,setTimeout(()=>{this.isProgrammaticScroll=!1},500);else this.isProgrammaticScroll=!1};n?r():setTimeout(r,100)}});setupCarousel=q$(t=>{let e,n;return this.carouselElement=t,setTimeout(()=>{this.updateScrollState()},50),window.ResizeObserver&&(e=new ResizeObserver(()=>this.updateScrollState()),e.observe(t)),this.args.onVisiblePhotoChange&&window.IntersectionObserver&&"test"!==rx.environment&&(n=new IntersectionObserver(t=>{if(!this.isProgrammaticScroll)for(let e of t)if(e.isIntersecting&&e.intersectionRatio>=.5){const t=e.target.dataset.eventId;this.internalEventId=t;const n=this.photos.find(e=>e.eventId===t);n&&this.args.onVisiblePhotoChange(n)}},{root:t,threshold:.5}),t.querySelectorAll(".carousel-slide").forEach(t=>n.observe(t))),()=>{e&&e.unobserve(t),n&&n.disconnect()}});updateScrollState(){if(!this.carouselElement)return;const{scrollLeft:t,scrollWidth:e,clientWidth:n}=this.carouselElement;this.canScrollLeft=t>1,this.canScrollRight=t+n({on:Ww,and:z$,eq:j$,fn:L$,Blurhash:HV,fadeInImage:XV,Icon:d$}),isStrictMode:!0}),this)}},QV=class extends u${static{aF(this.prototype,"isOpen",[Vr],function(){return!1})}#ue=void cF(this,"isOpen");toggleMenu(t){t?.stopPropagation(),this.isOpen=!this.isOpen}static{lF(this.prototype,"toggleMenu",[ql])}closeMenu(t){t?.stopPropagation(),this.isOpen=!1}static{lF(this.prototype,"closeMenu",[ql])}get triggerIcon(){return this.args.triggerIcon||"more-vertical"}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"dropdown-menu-container"],[12],[1,"\\n "],[11,"button"],[24,0,"dropdown-trigger-btn btn-press"],[16,"title",[30,1]],[24,4,"button"],[4,[32,0],["click",[30,0,["toggleMenu"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],[[30,0,["triggerIcon"]],[30,2],[30,3]]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["isOpen"]],[[[1," "],[10,0],[15,0,[29,["dropdown-popover ",[30,4]]]],[12],[1,"\\n "],[18,5,[[30,0,["closeMenu"]]]],[1,"\\n "],[13],[1,"\\n "],[11,0],[24,0,"menu-backdrop"],[24,"role","button"],[4,[32,0],["click",[30,0,["closeMenu"]]],null],[12],[13],[1,"\\n"]],[]],null],[13]],["@triggerTitle","@iconSize","@iconColor","@popoverClass","&default"],["if","yield"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,Icon:d$}),isStrictMode:!0}),this)}},tW=Ap(rg({id:null,block:'[[[11,0],[24,0,"photo-gallery-overlay"],[24,"role","dialog"],[24,"tabindex","-1"],[4,[32,0],["click",[30,1]],null],[4,[30,2],[[30,3]],null],[12],[1,"\\n"],[1," "],[10,0],[14,0,"photo-gallery-content"],[15,"data-current-event-id",[30,4,["eventId"]]],[12],[1,"\\n "],[10,0],[14,0,"actions-btn-container"],[12],[1,"\\n "],[8,[32,1],null,[["@iconSize","@triggerIcon","@iconColor"],[24,"more-horizontal","white"]],[["default"],[[[[1,"\\n "],[11,"button"],[24,0,"dropdown-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,2],[[30,6],[30,5]],null]],null],[12],[1,"Copy Photo Event ID"],[13],[1,"\\n"],[41,[30,7],[[[1," "],[11,"button"],[24,0,"dropdown-item text-danger"],[24,4,"button"],[4,[32,0],["click",[28,[32,2],[[30,8,["perform"]],[30,5]],null]],null],[12],[1,"Delete Photo"],[13],[1,"\\n"]],[]],null],[1," "]],[5]]]]],[1,"\\n "],[13],[1,"\\n\\n "],[11,"button"],[24,0,"close-btn btn-text"],[24,"aria-label","Close gallery"],[24,"title","Close"],[24,4,"button"],[4,[32,0],["click",[30,9]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["x",24,"white"]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"main-photo-container"],[12],[1,"\\n "],[8,[32,4],null,[["@variant","@photos","@scrollToEventId","@onVisiblePhotoChange","@name"],["gallery-main",[30,10],[30,4,["eventId"]],[30,11],[30,12]]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"thumbnail-strip-container"],[12],[1,"\\n "],[8,[32,4],null,[["@variant","@photos","@scrollToEventId","@onPhotoClick","@name"],["gallery-thumbnails",[30,10],[30,4,["eventId"]],[30,13],[30,12]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@handleBackgroundClick","@bindKeyboard","@handleKeydown","@currentPhoto","closeMenu","@copyEventId","@canDeletePhoto","@deletePhotoTask","@handleClose","@photos","@handleVisiblePhotoChange","@placeName","@selectPhoto"],["if"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,DropdownMenu:QV,fn:L$,Icon:d$,PhotoCarousel:JV}),isStrictMode:!0}),N$()),eW=class extends u${get isTesting(){return"test"===rx.environment}get destinationElement(){return document.getElementById("modal-portal")||document.body}static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"nostrRelay",[dp])}#at=void cF(this,"nostrRelay");static{aF(this.prototype,"blossom",[dp])}#Yt=void cF(this,"blossom");static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{aF(this.prototype,"currentPhoto",[Vr],function(){return this.args.selectedPhoto||this.args.photos?.[0]})}#he=void cF(this,"currentPhoto");get isCreator(){return this.currentPhoto?.pubkey&&this.nostrAuth.pubkey&&this.currentPhoto.pubkey===this.nostrAuth.pubkey}get canDeletePhoto(){return this.isCreator&&!0===this.settings.experimentalEnablePhotoDeletion}bindKeyboard=q$((t,[e])=>(document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)));handleClose(){this.args.onClose&&this.args.onClose()}static{lF(this.prototype,"handleClose",[ql])}handleBackgroundClick(t){t.target.closest(".thumbnail-strip-container")||t.target.closest(".carousel-nav-btn")||t.target.closest(".close-btn")||t.target.closest(".actions-btn-container")||this.handleClose()}static{lF(this.prototype,"handleBackgroundClick",[ql])}selectPhoto(t){this.currentPhoto=t}static{lF(this.prototype,"selectPhoto",[ql])}handleVisiblePhotoChange(t){this.currentPhoto!==t&&(this.currentPhoto=t)}static{lF(this.prototype,"handleVisiblePhotoChange",[ql])}handleKeydown(t){if(!this.args.photos||0===this.args.photos.length)return;if("Escape"===t.key)return void this.handleClose();const e=this.args.photos.indexOf(this.currentPhoto);-1!==e&&("ArrowLeft"===t.key&&e>0?this.currentPhoto=this.args.photos[e-1]:"ArrowRight"===t.key&&e({context:this,generator:function*(t){if(confirm("Are you sure you want to delete this photo? This cannot be undone."))try{const n=[["e",this.currentPhoto.eventId]];this.currentPhoto.placeIdentifier&&n.push(["i",this.currentPhoto.placeIdentifier]);const r=yield bN.fromKind(5).content("Deleted photo").modifyPublicTags(()=>n).as(this.nostrAuth.signer).sign();yield this.nostrRelay.publish(this.nostrData.activeWriteRelays,r),this.nostrData.store.add(r);const i=/[0-9a-f]{64}/i;if(this.currentPhoto.url){const t=this.currentPhoto.url.match(i);if(t)try{yield this.blossom.delete(t[0])}catch(e){console.warn("Failed to delete main image from blossom:",e)}}if(this.currentPhoto.thumbUrl){const t=this.currentPhoto.thumbUrl.match(i);if(t)try{yield this.blossom.delete(t[0])}catch(e){console.warn("Failed to delete thumb image from blossom:",e)}}this.toast.show("Photo deleted successfully"),t&&t(),this.handleClose()}catch(e){console.error("Failed to delete photo:",e),this.toast.show("Failed to delete photo: "+e.message),t&&t()}else t&&t()}}),null,"deletePhotoTask",null);static{Ap(rg({id:null,block:'[[[41,[30,0,["isTesting"]],[[[1," "],[8,[32,0],null,[["@handleBackgroundClick","@bindKeyboard","@handleKeydown","@copyEventId","@canDeletePhoto","@deletePhotoTask","@handleClose","@photos","@currentPhoto","@handleVisiblePhotoChange","@placeName","@selectPhoto"],[[30,0,["handleBackgroundClick"]],[30,0,["bindKeyboard"]],[30,0,["handleKeydown"]],[30,0,["copyEventId"]],[30,0,["canDeletePhoto"]],[30,0,["deletePhotoTask"]],[30,0,["handleClose"]],[30,1],[30,0,["currentPhoto"]],[30,0,["handleVisiblePhotoChange"]],[30,2],[30,0,["selectPhoto"]]]],null],[1,"\\n"]],[]],[[[40,[[[1," "],[8,[32,0],null,[["@handleBackgroundClick","@bindKeyboard","@handleKeydown","@copyEventId","@canDeletePhoto","@deletePhotoTask","@handleClose","@photos","@currentPhoto","@handleVisiblePhotoChange","@placeName","@selectPhoto"],[[30,0,["handleBackgroundClick"]],[30,0,["bindKeyboard"]],[30,0,["handleKeydown"]],[30,0,["copyEventId"]],[30,0,["canDeletePhoto"]],[30,0,["deletePhotoTask"]],[30,0,["handleClose"]],[30,1],[30,0,["currentPhoto"]],[30,0,["handleVisiblePhotoChange"]],[30,2],[30,0,["selectPhoto"]]]],null],[1,"\\n"]],[]],"%cursor:0%",[28,[31,2],[[30,0,["destinationElement"]]],null]]],[]]]],["@photos","@placeName"],["if","in-element","-in-el-null"]]',moduleName:"(unknown template module)",scope:()=>({GalleryContent:tW}),isStrictMode:!0}),this)}},nW=class extends u${static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"isEditing",[Vr],function(){return!1})}#de=void cF(this,"isEditing");static{aF(this.prototype,"showLists",[Vr],function(){return!1})}#pe=void cF(this,"showLists");static{aF(this.prototype,"isPhotoUploadActive",[Vr],function(){return!1})}#fe=void cF(this,"isPhotoUploadActive");static{aF(this.prototype,"isConnectingNostr",[Vr],function(){return!1})}#ge=void cF(this,"isConnectingNostr");static{aF(this.prototype,"isGalleryOpen",[Vr],function(){return!1})}#me=void cF(this,"isGalleryOpen");static{aF(this.prototype,"selectedGalleryPhoto",[Vr],function(){return null})}#ye=void cF(this,"selectedGalleryPhoto");static{aF(this.prototype,"isPhotoUploadModalOpen",[Vr],function(){return!1})}#ve=void cF(this,"isPhotoUploadModalOpen");static{aF(this.prototype,"isNostrConnectModalOpen",[Vr],function(){return!1})}#qt=void cF(this,"isNostrConnectModalOpen");static{aF(this.prototype,"newlyUploadedPhotoId",[Vr],function(){return null})}#be=void cF(this,"newlyUploadedPhotoId");handleUploadStateChange(t){this.isPhotoUploadActive=t}static{lF(this.prototype,"handleUploadStateChange",[ql])}openPhotoUploadModal(t){t&&t.preventDefault(),this.nostrAuth.isConnected?this.isPhotoUploadModalOpen=!0:this.isNostrConnectModalOpen=!0}static{lF(this.prototype,"openPhotoUploadModal",[ql])}closePhotoUploadModal(t){this.isPhotoUploadActive||(this.isPhotoUploadModalOpen=!1,"string"==typeof t&&(this.newlyUploadedPhotoId=t,setTimeout(()=>{const t=document.querySelector(".sidebar-content");t&&(t.scrollTop=0)},50)))}static{lF(this.prototype,"closePhotoUploadModal",[ql])}closeNostrConnectModal(){this.isNostrConnectModalOpen=!1}static{lF(this.prototype,"closeNostrConnectModal",[ql])}onNostrConnected(){this.isNostrConnectModalOpen=!1,this.isPhotoUploadModalOpen=!0}static{lF(this.prototype,"onNostrConnected",[ql])}get isSaved(){return this.storage.isPlaceSaved(this.place.id||this.place.osmId)}get place(){return this.args.place||{}}get saveablePlace(){return this.place.createdAt?this.place:fB(this.place)}get tags(){return this.place.osmTags||{}}get name(){return this.place.title||wU(this.tags)||"Unnamed Place"}get photos(){return bj(this.nostrData.placePhotos).map(t=>({...t,style:$v(`--slide-ratio: ${t.aspectRatio};`)}))}startEditing(){this.isSaved&&(this.isEditing=!0)}static{lF(this.prototype,"startEditing",[ql])}cancelEditing(){this.isEditing=!1}static{lF(this.prototype,"cancelEditing",[ql])}toggleLists(t){t&&t.stopPropagation(),this.showLists=!this.showLists}static{lF(this.prototype,"toggleLists",[ql])}closeLists(){this.showLists=!1}static{lF(this.prototype,"closeLists",[ql])}async saveChanges(t){this.args.onSave&&await this.args.onSave({...this.place,...t}),this.isEditing=!1}static{lF(this.prototype,"saveChanges",[ql])}get type(){return xU(this.tags)}get address(){const t=this.tags,e=[],n=(...e)=>{for(const n of e)if(t[n])return t[n];return null};let r=n("addr:street","street");const i=n("addr:housenumber","housenumber");r&&(i&&(r=`${r} ${i}`),e.push(r));let s=n("addr:city","city");const o=n("addr:postcode","postcode");s&&(o&&(s=`${o} ${s}`),e.push(s));const a=n("addr:state","state"),l=n("addr:country","country");return a&&a!==s&&e.push(a),l&&e.push(l),0===e.length?null:e.join(", ")}formatMultiLine(t,e){if(!t)return null;const n=[...new Set(t.split(";").map(t=>t.trim()).filter(Boolean))];return 0===n.length?null:$v("phone"===e?n.map(t=>`${t}`).join("
"):"email"===e?n.map(t=>`${t}`).join("
"):"whatsapp"===e?n.map(t=>`${t}`).join("
"):"url"===e?n.map(t=>`${this.getDomain(t)}`).join("
"):n.join("
"))}get phone(){const t=[this.tags.phone,this.tags["contact:phone"],this.tags.mobile,this.tags["contact:mobile"]].filter(Boolean);return 0===t.length?null:this.formatMultiLine(t.join(";"),"phone")}get whatsapp(){const t=[this.tags.whatsapp,this.tags["contact:whatsapp"]].filter(Boolean);return 0===t.length?null:this.formatMultiLine(t.join(";"),"whatsapp")}get email(){const t=this.tags.email||this.tags["contact:email"];return this.formatMultiLine(t,"email")}get website(){const t=this.place.url||this.tags.website||this.tags["contact:website"];return this.formatMultiLine(t,"url")}getDomain(t){try{return new URL(t).hostname}catch{return t}}get openingHours(){const t=this.tags.opening_hours;return this.formatMultiLine(t)}get cuisine(){return this.tags.cuisine?this.tags.cuisine.split(";").map(t=>mU(t)).join(", "):null}get facebook(){return yB(this.tags,"facebook")}get instagram(){return yB(this.tags,"instagram")}get wikipedia(){const t=this.tags.wikipedia;return t?t.split(";").map(t=>t.trim()).filter(Boolean)[0]:null}get geoLink(){const t=this.place.lat,e=this.place.lon;return t&&e?`geo:${t},${e}?q=${t},${e}(${encodeURIComponent(this.name)})`:"#"}get visibleGeoLink(){const t=this.place.lat,e=this.place.lon;return t&&e?`${Number(t).toFixed(6)}, ${Number(e).toFixed(6)}`:""}get osmUrl(){const t=this.place.osmId;if(t)return`https://www.openstreetmap.org/${this.place.osmType||"node"}/${t}`;const e=this.place.lat,n=this.place.lon;if(!e||!n)return null;const r=this.mapUi.currentCenter?.lat??e,i=this.mapUi.currentCenter?.lon??n,s=this.mapUi.currentZoom??17,o=Math.round(s);return`https://www.openstreetmap.org/search?lat=${e}&lon=${n}&zoom=${o}#map=${o}/${Number(r).toFixed(5)}/${Number(i).toFixed(5)}`}get gmapsUrl(){return this.place.gmapsId||this.place.osmId?`https://www.google.com/maps/search/?api=1&query=${this.name}&query=${this.place.lat},${this.place.lon}`:null}get showDescription(){return"photon"!==this.place.source&&!!this.place.description}openGallery(t){this.selectedGalleryPhoto=t,this.isGalleryOpen=!0}static{lF(this.prototype,"openGallery",[ql])}closeGallery(){this.isGalleryOpen=!1,this.selectedGalleryPhoto=null}static{lF(this.prototype,"closeGallery",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"place-details"],[12],[1,"\\n"],[41,[30,0,["isEditing"]],[[[1," "],[8,[32,0],null,[["@place","@onSave","@onCancel"],[[30,0,["place"]],[30,0,["saveChanges"]],[30,0,["cancelEditing"]]]],null],[1,"\\n"]],[]],[[[1," "],[8,[32,1],null,[["@variant","@photos","@name","@resetKey","@scrollToEventId","@onPhotoClick"],["inline",[30,0,["photos"]],[30,0,["name"]],[30,0,["place","osmId"]],[30,0,["newlyUploadedPhotoId"]],[30,0,["openGallery"]]]],null],[1,"\\n "],[10,"h3"],[12],[1,[30,0,["name"]]],[13],[1,"\\n "],[10,2],[14,0,"place-type"],[12],[1,"\\n "],[1,[30,0,["type"]]],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["showDescription"]],[[[1," "],[10,2],[14,0,"place-description"],[12],[1,"\\n "],[1,[30,0,["place","description"]]],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[]]],[1,"\\n "],[10,0],[14,0,"actions"],[12],[1,"\\n "],[10,0],[14,0,"save-button-wrapper"],[12],[1,"\\n "],[11,"button"],[16,0,[52,[30,0,["isSaved"]],"btn btn-secondary","btn btn-outline"]],[24,4,"button"],[4,[32,2],["click",[30,0,["toggleLists"]]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@color"],["bookmark",[52,[30,0,["isSaved"]],"currentColor","var(--link-color)"]]],null],[1,"\\n "],[1,[52,[30,0,["isSaved"]],"Saved","Save"]],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["showLists"]],[[[1," "],[8,[32,4],null,[["@place","@onClose","@isSaved"],[[30,0,["saveablePlace"]],[30,0,["closeLists"]],[30,0,["isSaved"]]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["isSaved"]],[[[1," "],[11,"button"],[24,0,"btn btn-outline"],[24,"title","Edit"],[16,"disabled",[30,0,["isEditing"]]],[24,4,"button"],[4,[32,2],["click",[30,0,["startEditing"]]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@color"],["edit","var(--link-color)"]],null],[1,"\\n Edit\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"meta-info"],[12],[1,"\\n\\n"],[41,[30,0,["cuisine"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["fork-and-knife","Cuisine"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["cuisine"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["openingHours"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["clock","Opening hours"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["openingHours"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["phone"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["phone","Phone"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["phone"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["whatsapp"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["whatsapp","WhatsApp"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["whatsapp"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["website"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["globe","Website"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["website"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["email"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["mail","Email"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["email"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["facebook"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["facebook","Facebook"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["facebook","url"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n "],[1,[30,0,["facebook","username"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["instagram"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["instagram","Instagram"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["instagram","url"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n "],[1,[30,0,["instagram","username"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["wikipedia"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["wikipedia","Wikipedia"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[29,["https://wikipedia.org/wiki/",[30,0,["wikipedia"]]]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n Wikipedia\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"meta-info"],[12],[1,"\\n\\n"],[41,[30,0,["address"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["home","Address"]],null],[1,"\\n "],[10,1],[12],[1,[30,0,["address"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["map-pin","Geo link"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["geoLink"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n "],[1,[30,0,["visibleGeoLink"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["osmUrl"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name"],["map"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["osmUrl"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n OpenStreetMap\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["gmapsUrl"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name"],["map"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["gmapsUrl"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n Google Maps\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["place","osmId"]],[[[1," "],[10,0],[14,0,"meta-info"],[12],[1,"\\n "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name"],["feather-camera"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[11,"button"],[24,0,"btn-link"],[24,4,"button"],[4,[32,2],["click",[30,0,["openPhotoUploadModal"]]],null],[12],[1,"\\n Add a photo\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[13],[1,"\\n\\n"],[41,[30,0,["isPhotoUploadModalOpen"]],[[[1," "],[8,[32,5],null,[["@onClose","@disableClose"],[[30,0,["closePhotoUploadModal"]],[30,0,["isPhotoUploadActive"]]]],[["default"],[[[[1,"\\n "],[8,[32,6],null,[["@place","@onClose","@onUploadStateChange"],[[30,0,["saveablePlace"]],[30,0,["closePhotoUploadModal"]],[30,0,["handleUploadStateChange"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["isNostrConnectModalOpen"]],[[[1," "],[8,[32,5],null,[["@onClose"],[[30,0,["closeNostrConnectModal"]]]],[["default"],[[[[1,"\\n "],[8,[32,7],null,[["@onConnect"],[[30,0,["onNostrConnected"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["isGalleryOpen"]],[[[1," "],[8,[32,8],null,[["@photos","@selectedPhoto","@placeName","@onClose"],[[30,0,["photos"]],[30,0,["selectedGalleryPhoto"]],[30,0,["name"]],[30,0,["closeGallery"]]]],null],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlaceEditForm:qV,PhotoCarousel:JV,on:Ww,Icon:d$,PlaceListsManager:WV,Modal:D$,PlacePhotoUpload:YV,NostrConnect:wq,PhotoGallery:eW}),isStrictMode:!0}),this)}},rW=kb(function([t]){return mU(t)}),iW=class extends u${static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");createNewPlace(){const t=this.router.currentRoute.queryParams,e=t.lat,n=t.lon;e&&n?this.router.transitionTo("place.new",{queryParams:{lat:e,lon:n}}):this.router.transitionTo("place.new",{queryParams:{lat:0,lon:0}})}static{lF(this.prototype,"createNewPlace",[ql])}selectPlace(t){this.args.onSelect&&this.args.onSelect(t)}static{lF(this.prototype,"selectPlace",[ql])}clearSelection(){this.args.onSelect&&this.args.onSelect(null)}static{lF(this.prototype,"clearSelection",[ql])}async toggleSave(t){if(t)if(t.createdAt)try{if(await this.storage.removePlace(t),console.debug("Place deleted:",t.title),this.args.onBookmarkChange&&this.args.onBookmarkChange(),this.args.onUpdate){const e={...t,id:void 0,geohash:void 0,createdAt:void 0};this.args.onUpdate(e)}this.args.onSelect&&this.args.onSelect(null),this.args.onClose&&this.args.onClose()}catch(e){console.error("Failed to delete:",e),alert("Failed to delete: "+e.message)}else{const e={title:wU(t.osmTags,"Untitled Place"),lat:t.lat,lon:t.lon,tags:[],url:t.osmTags.website,osmId:String(t.osmId||t.id),osmType:t.osmType,osmTags:t.osmTags};try{const t=await this.storage.storePlace(e);console.debug("Place saved:",e.title),this.args.onBookmarkChange&&this.args.onBookmarkChange(),this.args.onUpdate&&this.args.onUpdate(t),this.args.onSelect&&this.args.onSelect(t)}catch(e6){console.error("Failed to save place:",e6),alert("Failed to save place: "+e6.message)}}}static{lF(this.prototype,"toggleSave",[ql])}async updateBookmark(t){try{const e=await this.storage.updatePlace(t);console.debug("Place updated:",e.title),this.args.onBookmarkChange&&this.args.onBookmarkChange(),this.args.onUpdate&&this.args.onUpdate(e)}catch(e){console.error("Failed to update place:",e),alert("Failed to update place: "+e.message)}}static{lF(this.prototype,"updateBookmark",[ql])}get isNearbySearch(){const t=this.router.currentRoute.queryParams;return!t.q&&!t.category&&t.lat&&t.lon}get hasHeaderPhoto(){return this.args.selectedPlace&&this.nostrData.placePhotos&&this.nostrData.placePhotos.length>0}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[15,0,[29,["sidebar-header\\n ",[52,[30,0,["hasHeaderPhoto"]],"no-border"],"\\n ",[52,[28,[32,0],[[28,[32,1],[[30,1]],null],[30,2]],null],"has-back-btn"]]]],[12],[1,"\\n"],[41,[30,1],[[[1," "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,2],["click",[30,0,["clearSelection"]]],null],[12],[8,[32,3],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[13],[1,"\\n"]],[]],[[[41,[30,2],[[[1," "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,2],["click",[30,2]],null],[12],[8,[32,3],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[13],[1,"\\n"]],[]],null],[41,[30,2],[[[1," "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"\\n "],[10,1],[14,0,"sidebar-header-icon-wrapper"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["bookmark",20,[28,[32,4],[[30,3],"#898989"],null]]],null],[1,"\\n "],[13],[1,"\\n "],[1,[30,4]],[1,"\\n "],[13],[1,"\\n"]],[]],[[[41,[30,0,["isNearbySearch"]],[[[1," "],[10,"h2"],[12],[8,[32,3],null,[["@name","@size","@color"],["target",20,"#ea4335"]],null],[1,"\\n Nearby"],[13],[1,"\\n"]],[]],[[[1," "],[10,"h2"],[12],[8,[32,3],null,[["@name","@size","@color"],["search",20,"#333"]],null],[1,"\\n Results"],[13],[1,"\\n"]],[]]]],[]]]],[]]],[1," "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,2],["click",[30,5]],null],[12],[8,[32,3],null,[["@name","@size","@color"],["x",20,"#333"]],null],[13],[1,"\\n "],[13],[1,"\\n\\n "],[11,0],[24,0,"sidebar-content"],[4,[32,5],[[30,6]],null],[12],[1,"\\n"],[41,[30,1],[[[1," "],[8,[32,6],null,[["@place","@onToggleSave","@onSave"],[[30,1],[30,0,["toggleSave"]],[30,0,["updateBookmark"]]]],null],[1,"\\n"]],[]],[[[41,[30,7],[[[1," "],[10,0],[14,0,"sidebar-loading"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["loading-ring",24,"#898989"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],[[[41,[30,8],[[[1," "],[10,"ul"],[14,0,"places-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,8]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"place-item"],[24,4,"button"],[4,[32,2],["click",[28,[32,7],[[30,0,["selectPlace"]],[30,9]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"place-name"],[12],[1,[28,[32,4],[[30,9,["title"]],[30,9,["osmTags","name"]],[30,9,["osmTags","name:en"]],"Unnamed Place"],null]],[13],[1,"\\n "],[10,0],[14,0,"place-type"],[12],[1,"\\n"],[41,[28,[32,8],[[30,9,["source"]],"osm"],null],[[[1," "],[1,[28,[32,9],[[30,9,["type"]]],null]],[1,"\\n"]],[]],[[[41,[28,[32,8],[[30,9,["source"]],"photon"],null],[[[1," "],[1,[30,9,["description"]]],[1,"\\n"]],[]],[[[41,[28,[32,10],[[30,9,["osmTags"]]],null],[[[1," "],[1,[28,[32,10],[[30,9,["osmTags"]]],null]],[1,"\\n"]],[]],[[[1," Saved place\\n "]],[]]]],[]]]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[9]],null],[1," "],[13],[1,"\\n"]],[]],[[[41,[30,0,["isNearbySearch"]],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"No places found nearby."],[13],[1,"\\n"]],[]],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"No results found."],[13],[1,"\\n"]],[]]]],[]]],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline create-place"],[24,4,"button"],[4,[32,2],["click",[30,0,["createNewPlace"]]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["plus",18,"var(--link-color)"]],null],[1,"\\n Create new place\\n "],[13],[1,"\\n"]],[]]]],[]]],[1," "],[13],[1,"\\n"],[13]],["@selectedPlace","@onBack","@color","@title","@onClose","@scrollTop","@isLoading","@places","place"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({and:z$,not:U$,on:Ww,Icon:d$,or:M$,restoreScroll:_q,PlaceDetails:nW,fn:L$,eq:j$,humanizeOsmTag:rW,getPlaceType:xU}),isStrictMode:!0}),this)}},sW=a({default:()=>oW}),oW=Ap(rg({id:null,block:'[[[41,[30,1,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@places","@title","@color","@scrollTop","@isLoading","@onSelect","@onClose","@onBack"],[[30,1,["places"]],[30,1,["listTitle"]],[30,1,["listColor"]],[30,1,["scrollTop"]],[30,1,["loadPlacesTask","isRunning"]],[30,1,["selectPlace"]],[30,1,["close"]],[30,1,["backToLists"]]]],null],[1,"\\n"]],[]],null]],["@controller"],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlacesSidebar:iW}),isStrictMode:!0}),N$()),aW=a({default:()=>dW});function lW(t){const e=t.createdAt;if(!e)return 0;if("number"==typeof e)return e;const n=Date.parse(e);return isNaN(n)?0:n}var cW,uW,hW,dW=class extends tu{static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"model",[Vr])}#we=void cF(this,"model");static{aF(this.prototype,"loadedPlaces",[Vr],function(){return[]})}#_e=void cF(this,"loadedPlaces");get listId(){return this.model?.list_id}loadPlacesTask=OV(()=>({context:this,generator:function*(t){this.loadedPlaces=[];try{this.loadedPlaces=yield this.storage.getPlacesInList(t)}catch(e){console.error("Failed to load places in list",t,e),this.loadedPlaces=[]}}}),{restartable:!0},"loadPlacesTask",null);get scrollTop(){return this.mapUi.getScrollPosition(`list-${this.listId}`)}get listColor(){const t=this.storage.lists.find(t=>t.id===this.listId);return t&&t.color?t.color:getComputedStyle(document.documentElement).getPropertyValue("--default-list-color").trim()}get listTitle(){const t=this.storage.lists.find(t=>t.id===this.listId);return t?t.title:"Collections"}get places(){const t=this.storage.lists.find(t=>t.id===this.listId),e=new Set(t?.placeRefs?.map(t=>t.id)||[]),n=this.storage.savedPlaces.filter(t=>e.has(t.id)),r=[],i=new Set;return n.forEach(t=>{r.push(t),i.add(t.id)}),this.loadedPlaces.forEach(t=>{e.has(t.id)&&!i.has(t.id)&&(r.push(t),i.add(t.id))}),r.sort((t,e)=>lW(e)-lW(t))}selectPlace(t){if(t){const e=document.querySelector(".sidebar-content");e&&this.mapUi.saveScrollPosition(`list-${this.listId}`,e.scrollTop),this.mapUi.returnToRoute={name:"lists.list",model:this.listId},this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!0,this.router.transitionTo("place",t)}}static{lF(this.prototype,"selectPlace",[ql])}close(){this.router.transitionTo("index")}static{lF(this.prototype,"close",[ql])}backToLists(){this.router.transitionTo("lists.index")}static{lF(this.prototype,"backToLists",[ql])}},pW=a({default:()=>fW}),fW=class extends Jh{static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");model(t){return{list_id:t.list_id}}setupController(t,e){console.debug("DEBUG: setupController controller is:",t),console.debug("DEBUG: controller.loadPlacesTask is:",t?.loadPlacesTask),t.model=e,super.setupController(t,e),t&&t.loadPlacesTask?t.loadPlacesTask.perform(e.list_id):console.error("DEBUG: ERROR! controller.loadPlacesTask is undefined!")}},gW=a({default:()=>mW}),mW=class extends u${static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");styleFor(t){const e=t||getComputedStyle(document.documentElement).getPropertyValue("--default-list-color").trim();return $v(`background-color: ${e}`)}selectList(t){this.router.transitionTo("lists.list",t)}static{lF(this.prototype,"selectList",[ql])}close(){this.router.transitionTo("index")}static{lF(this.prototype,"close",[ql])}backToMenu(){this.router.transitionTo("menu")}static{lF(this.prototype,"backToMenu",[ql])}static{Ap(rg({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,0,["backToMenu"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"\\n "],[10,1],[14,0,"sidebar-header-icon-wrapper"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["bookmark",20,"#898989"]],null],[1,"\\n "],[13],[1,"\\n Collections\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,0,["close"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"ul"],[14,0,"places-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["storage","lists"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"lists-index-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,2],[[30,0,["selectList"]],[30,1,["id"]]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"lists-index-item-left"],[12],[1,"\\n"],[1," "],[10,1],[14,0,"list-color-dot"],[15,5,[28,[30,0,["styleFor"]],[[30,1,["color"]]],null]],[12],[13],[1,"\\n "],[10,0],[14,0,"lists-index-name"],[12],[1,[30,1,["title"]]],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"lists-index-count"],[12],[1,"\\n"],[41,[30,1,["placeRefs","length"]],[[[1," "],[1,[30,1,["placeRefs","length"]]],[1,"\\n places\\n"]],[]],[[[1," empty\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null]],["list"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,Icon:d$,fn:L$}),isStrictMode:!0}),this)}},yW=a({default:()=>vW}),vW=class extends Jh{},bW=a({default:()=>wW}),wW=class extends u${static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");selectPlace(t){if(t){const e=document.querySelector(".sidebar-content");e&&this.mapUi.saveScrollPosition("search",e.scrollTop),this.mapUi.returnToSearch=!0,this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!0,this.router.transitionTo("place",t)}}static{lF(this.prototype,"selectPlace",[ql])}close(){this.mapUi.hideSidebar()}static{lF(this.prototype,"close",[ql])}static{Ap(rg({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@places","@scrollTop","@onSelect","@onClose"],[[30,0,["mapUi","searchResults"]],[28,[30,0,["mapUi","getScrollPosition"]],["search"],null],[30,0,["selectPlace"]],[30,0,["close"]]]],null],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlacesSidebar:iW}),isStrictMode:!0}),this)}},_W=a({default:()=>xW}),xW=class extends tu{static{aF(this.prototype,"osm",[dp])}#B=void cF(this,"osm");static{aF(this.prototype,"photon",[dp])}#xe=void cF(this,"photon");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");queryParams=["lat","lon","q","selected","category"];lat=null;lon=null;q=null;selected=null;category=null;fetchResultsTask=OV(()=>({context:this,generator:function*(t){const e=this.mapUi.currentSearch&&t.q===this.mapUi.currentSearch.q&&t.category===this.mapUi.currentSearch.category&&t.lat===this.mapUi.currentSearch.lat&&t.lon===this.mapUi.currentSearch.lon,n=this.mapUi.searchResults&&this.mapUi.searchResults.length>0;if(e&&n)return void(this.mapUi.isSidebarVisible&&this.mapUi.showSidebar());this.mapUi.hideSidebar(),this.mapUi.clearSearchResults();const r=t.lat?parseFloat(t.lat):null,i=t.lon?parseFloat(t.lon):null;let s=[],o=null,a=null;try{if(t.category&&r&&i){o="category",a=t.category,this.mapUi.startLoading(o,a);let e=this.mapUi.currentBounds;if(!e){const t=.01;e={minLat:r-t,maxLat:r+t,minLon:i-t,maxLon:i+t}}s=yield this.osm.getCategoryPois(e,t.category,r,i),s=s.map(t=>({...t,_distance:XU(r,i,t.lat,t.lon)})).sort((t,e)=>t._distance-e._distance)}else if(t.q){o="text",a=t.q,this.mapUi.startLoading(o,a),s=yield this.photon.search(t.q,r,i);const e=t.q.toLowerCase();let n=[];e.length>=3&&(n=this.storage.savedPlaces.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))),n.forEach(t=>{s.find(e=>t.osmId&&e.osmId===t.osmId||e.id&&e.id===t.id)||s.push(t)})}else if(r&&i){const t=50;s=yield this.osm.getNearbyPois(r,i,t),this.storage.savedPlaces.filter(e=>XU(r,i,e.lat,e.lon)<=t).forEach(t=>{s.find(e=>t.osmId&&e.osmId===t.osmId||e.id&&e.id===t.id)||s.push(t)}),s=s.map(t=>({...t,_distance:XU(r,i,t.lat,t.lon)})).sort((t,e)=>t._distance-e._distance)}}catch(e6){return console.error("Search request failed.",e6),this.toast.show("Search request failed. Please try again."),void this.mapUi.stopSearch()}finally{o&&a&&this.mapUi.stopLoading(o,a)}s=s.map(t=>this.storage.findPlaceById(t.osmId)||t);const l=t.selected||t.q;if(l&&s.length>0){let t=s.find(t=>t.osmTags&&(t.osmTags.name===l||t.osmTags["name:en"]===l));if(!t){const e=s[0];e._distance<=10&&(t=e)}if(t)return this.router.replaceWith("place",t),void this.mapUi.stopSearch()}this.mapUi.setSearchResults(s),this.mapUi.showSidebar(),this.mapUi.stopSearch()}}),{restartable:!0},"fetchResultsTask",null)},CW=a({default:()=>SW}),SW=class extends Jh{static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");queryParams={lat:{refreshModel:!0},lon:{refreshModel:!0},q:{refreshModel:!0},selected:{refreshModel:!0},category:{refreshModel:!0}};model(t){return t}setupController(t,e){super.setupController(t,e),t.fetchResultsTask.perform(e);const{q:n,category:r,lat:i,lon:s}=this.paramsFor("search");this.mapUi.currentSearch={q:n,category:r,lat:i,lon:s}}resetController(t,e){e&&(t.fetchResultsTask.cancelAll(),this.mapUi.stopSearch())}error(t,e){return this.mapUi.stopSearch(),this.toast.show("Search request failed. Please try again."),e&&e.abort(),!1}static{lF(this.prototype,"error",[ql])}},kW=a({cacheFor:()=>Qn,guidFor:()=>al}),EW=(cW=dp("page-title"),hW=FB((uW=class extends wb{constructor(t){super(t),NB(this,"tokens",hW,this),OB(this,"tokenId",al(this)),this.tokens.push({id:this.tokenId})}compute(t,e){const n={...e,id:this.tokenId,title:t.join("")};return this.tokens.push(n),this.tokens.scheduleTitleUpdate(),""}willDestroy(){super.willDestroy(),this.tokens.remove(this.tokenId),this.tokens.scheduleTitleUpdate()}}).prototype,"tokens",[cW],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),uW),RW="add",TW="remove",LW="propertychange";function IW(t){for(const e in t)delete t[e]}function PW(t){let e;for(e in t)return!1;return!e}function MW(t,e,n,r,i){if(i){const i=n;n=function(s){return t.removeEventListener(e,n),i.call(r??this,s)}}else r&&r!==t&&(n=n.bind(r));const s={target:t,type:e,listener:n};return t.addEventListener(e,n),s}function AW(t,e,n,r){return MW(t,e,n,r,!0)}function OW(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),IW(t))}var NW="change",FW="contextmenu",DW="click",zW="keydown",jW="keypress",UW="touchmove",BW="wheel",$W=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function qW(t,e){return t>e?1:te?-1:0}function WW(t,e,n){if(t[0]<=e)return 0;const r=t.length;if(e<=t[r-1])return r-1;if("function"==typeof n){for(let i=1;i0?i-1:i}return r-1}if(n>0){for(let n=1;n0)}removeEventListener(t,e){if(!this.listeners_)return;const n=this.listeners_[t];if(!n)return;const r=n.indexOf(e);-1!==r&&(this.pendingRemovals_&&t in this.pendingRemovals_?(n[r]=XW,++this.pendingRemovals_[t]):(n.splice(r,1),0===n.length&&delete this.listeners_[t]))}},nH=class extends eH{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(NW)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const n=t.length,r=new Array(n);for(let i=0;i0;)this.pop()}extend(t){for(let e=0,n=t.length;ethis.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new cH(RW,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let n=0,r=e.length;n=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new cH(TW,e,t)),e}setAt(t,e){if(t>=this.getLength())return void this.insertAt(t,e);if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new cH(TW,n,t)),this.dispatchEvent(new cH(RW,e,t))}updateLength_(){this.set(lH,this.array_.length)}assertUnique_(t,e){const n=this.array_;for(let r=0,i=n.length;r{this.clickTimeoutId_=void 0;const e=new dH(pH.SINGLECLICK,this.map_,t);this.dispatchEvent(e)},250)}updateActivePointers_(t){const e=t,n=e.pointerId;if(e.type==pH.POINTERUP||e.type==pH.POINTERCANCEL){delete this.trackedTouches_[n];for(const t in this.trackedTouches_)if(this.trackedTouches_[t].target!==e.target){delete this.trackedTouches_[t];break}}else e.type!=pH.POINTERDOWN&&e.type!=pH.POINTERMOVE||(this.trackedTouches_[n]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new dH(pH.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),0===this.activePointers_.length&&(this.dragListenerKeys_.forEach(OW),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return 0===t.button}handlePointerDown_(t){this.emulateClicks_=0===this.activePointers_.length,this.updateActivePointers_(t);const e=new dH(pH.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),0===this.dragListenerKeys_.length){const t=this.map_.getOwnerDocument();this.dragListenerKeys_.push(MW(t,pH.POINTERMOVE,this.handlePointerMove_,this),MW(t,pH.POINTERUP,this.handlePointerUp_,this),MW(this.element_,pH.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push(MW(this.element_.getRootNode(),pH.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new dH(pH.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!(!this.down_||!this.isMoving_(t));this.dispatchEvent(new dH(pH.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;e&&!e.defaultPrevented||"boolean"==typeof t.cancelable&&!0!==t.cancelable||t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(OW(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(UW,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(OW(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(OW),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},SH="postrender",kH="loadstart",EH="loadend",RH="layergroup",TH="size",LH="target",IH="view";function PH(t,e){if(!t)throw new Error(e)}var MH=1/0,AH=class{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,IW(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,n=t[0];1==t.length?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const r=this.keyFunction_(n);return delete this.queuedElements_[r],n}enqueue(t){PH(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=1/0&&(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0)}getCount(){return this.elements_.length}getLeftChildIndex_(t){return 2*t+1}getRightChildIndex_(t){return 2*t+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return 0===this.elements_.length}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,n=this.priorities_,r=e.length,i=e[t],s=n[t],o=t;for(;t>1;){const i=this.getLeftChildIndex_(t),s=this.getRightChildIndex_(t),o=st;){const t=this.getParentIndex_(e);if(!(r[t]>s))break;n[e]=n[t],r[e]=r[t],e=t}n[e]=i,r[e]=s}reprioritize(){const t=this.priorityFunction_,e=this.elements_,n=this.priorities_;let r=0;const i=e.length;let s,o,a;for(o=0;ot.apply(null,e),t=>t[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(NW,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,n=e.getState();if(2===n||3===n||4===n){3!==n&&e.removeEventListener(NW,this.boundHandleTileChange_);const t=e.getKey();t in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[t],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let n=0;for(;this.tilesLoading_0;){const t=this.dequeue()[0],e=t.getKey();0!==t.getState()||e in this.tilesLoadingKeys_||(this.tilesLoadingKeys_[e]=!0,++this.tilesLoading_,++n,t.load())}}},NH={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function FH(t,e,n){return Math.min(Math.max(t,e),n)}function DH(t,e,n,r,i,s){const o=i-n,a=s-r;if(0!==o||0!==a){const l=((t-n)*o+(e-r)*a)/(o*o+a*a);l>1?(n=i,r=s):l>0&&(n+=o*l,r+=a*l)}return zH(t,e,n,r)}function zH(t,e,n,r){const i=n-t,s=r-e;return i*i+s*s}function jH(t){return 180*t/Math.PI}function UH(t){return t*Math.PI/180}function BH(t,e){const n=t%e;return n*e<0?n+e:n}function $H(t,e,n){return t+n*(e-t)}function qH(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function VH(t,e){return Math.floor(qH(t,e))}function WH(t,e){return Math.ceil(qH(t,e))}function HH(t,e,n){if(t>=e&&tp&&(d=(p+d)/2,p=d),f>g&&(f=(g+f)/2,g=f);let m=FH(r[0],d,p),y=FH(r[1],f,g);if(o&&n&&i){const t=30*i;m+=-t*Math.log(1+Math.max(0,d-r[0])/t)+t*Math.log(1+Math.max(0,r[0]-p)/t),y+=-t*Math.log(1+Math.max(0,f-r[1])/t)+t*Math.log(1+Math.max(0,r[1]-g)/t)}return[m,y]}}function KH(t){return t}function ZH(t){const e=[1/0,1/0,-1/0,-1/0];for(let n=0,r=t.length;ni&&(l|=4),as&&(l|=2),0===l&&(l=1),l}function rG(t,e,n,r,i){return i?(i[0]=t,i[1]=e,i[2]=n,i[3]=r,i):[t,e,n,r]}function iG(t){return rG(1/0,1/0,-1/0,-1/0,t)}function sG(t,e){const n=t[0],r=t[1];return rG(n,r,n,r,e)}function oG(t,e,n,r,i){return uG(iG(i),t,e,n,r)}function aG(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function lG(t,e){return e[0]t[2]&&(t[2]=e[2]),e[1]t[3]&&(t[3]=e[3]),t}function cG(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function uG(t,e,n,r,i){for(;ne[0]?r[0]=t[0]:r[0]=e[0],t[1]>e[1]?r[1]=t[1]:r[1]=e[1],t[2]n&&u.push([n,r,o,s]),lr&&u.push([o,r,l,a]),c=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function RG(t){return t[2]1){const e=t[2]-t[0],n=t[3]-t[1];for(let s=0;s=n[2])){const e=kG(n),i=Math.floor((r[0]-n[0])/e)*e;t[0]-=i,t[2]-=i}return t}function IG(t,e,n){if(e.canWrapX()){const r=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[r[0],t[1],r[2],t[3]]];LG(t,e);const i=kG(r);if(kG(t)>i&&!n)return[[r[0],t[1],r[2],t[3]]];if(t[0]r[2])return[[t[0],t[1],r[2],t[3]],[r[0],t[1],t[2]-i,t[3]]]}return[t]}function PG(t,e){let n=[t];for(let r=0,i=e.length;r0;++r){const t=[];for(let i=0,s=n.length;i=0;--r)if(t[r]!=e[r]){n=!1;break}return n}function AG(t,e){const n=Math.cos(e),r=Math.sin(e),i=t[0]*n-t[1]*r,s=t[1]*n+t[0]*r;return t[0]=i,t[1]=s,t}function OG(t,e){if(e.canWrapX()){const n=kG(e.getExtent()),r=function(t,e,n){const r=e.getExtent();let i=0;return e.canWrapX()&&(t[0]r[2])&&(n=n||kG(r),i=Math.floor((t[0]-r[0])/n)),i}(t,e,n);r&&(t[0]-=r*n)}return t}function NG(t){return Math.pow(t,3)}function FG(t){return 1-NG(1-t)}function DG(t){return 3*t*t-2*t*t*t}function zG(t){return t}function jG(t,e,n){n=n||6371008.8;const r=UH(t[1]),i=UH(e[1]),s=(i-r)/2,o=UH(e[0]-t[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(r)*Math.cos(i);return 2*n*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function UG(t,e,n,r){r=r||6371008.8;const i=UH(t[1]),s=UH(t[0]),o=e/r,a=Math.asin(Math.sin(i)*Math.cos(o)+Math.cos(i)*Math.sin(o)*Math.cos(n));return[jH(s+Math.atan2(Math.sin(n)*Math.sin(o)*Math.cos(i),Math.cos(o)-Math.sin(i)*Math.sin(a))),jH(a)]}function BG(...t){console.warn(...t)}var $G={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},qG=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||$G[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}},VG=6378137,WG=Math.PI*VG,HG=[-WG,-WG,WG,WG],GG=[-180,-85,180,85],KG=VG*Math.log(Math.tan(Math.PI/2)),ZG=class extends qG{constructor(t){super({code:t,units:"m",extent:HG,global:!0,worldExtent:GG,getPointResolution:function(t,e){return t/Math.cosh(e[1]/VG)}})}},YG=[new ZG("EPSG:3857"),new ZG("EPSG:102100"),new ZG("EPSG:102113"),new ZG("EPSG:900913"),new ZG("http://www.opengis.net/def/crs/EPSG/0/3857"),new ZG("http://www.opengis.net/gml/srs/epsg.xml#3857")],XG=[-180,-90,180,90],JG=6378137*Math.PI/180,QG=class extends qG{constructor(t,e){super({code:t,units:"degrees",extent:XG,axisOrientation:e,global:!0,metersPerUnit:JG,worldExtent:XG})}},tK=[new QG("CRS:84"),new QG("EPSG:4326","neu"),new QG("urn:ogc:def:crs:OGC:1.3:CRS84"),new QG("urn:ogc:def:crs:OGC:2:84"),new QG("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new QG("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new QG("http://www.opengis.net/def/crs/EPSG/0/4326","neu")],eK={},nK={};function rK(t,e,n){const r=t.getCode(),i=e.getCode();r in nK||(nK[r]={}),nK[r][i]=n}function iK(t,e){return t in nK&&e in nK[t]?nK[t][e]:null}var sK=.9996,oK=.00669438,aK=oK*oK*oK,lK=oK/.99330562,cK=Math.sqrt(.99330562),uK=(1-cK)/(1+cK),hK=uK*uK,dK=hK*uK,pK=dK*uK,fK=pK*uK,gK=.9983242984503243,mK=35*aK/3072,yK=1.5*uK-27/32*dK+269/512*fK,vK=21/16*hK-55/32*pK,bK=151/96*dK-417/128*fK,wK=1097/512*pK,_K=6378137;function xK(t,e,n){const r=t-5e5,i=(n.north?e:e-1e7)/sK/(_K*gK),s=i+yK*Math.sin(2*i)+vK*Math.sin(4*i)+bK*Math.sin(6*i)+wK*Math.sin(8*i),o=Math.sin(s),a=o*o,l=Math.cos(s),c=o/l,u=c*c,h=u*u,d=1-oK*a,p=Math.sqrt(1-oK*a),f=lK*l**2,g=f*f,m=r/(_K/p*sK),y=m*m,v=y*m,b=v*m,w=b*m,_=s-c/(.99330562/d)*(y/2-b/24*(5+3*u+10*f-4*g-9*lK))+w*m/720*(61+90*u+298*f+45*h-252*lK-3*g);let x=(m-v/6*(1+2*u+f)+w/120*(5-2*f+28*u-3*g+8*lK+24*h))/l;return x=HH(x+UH(SK(n.number)),-Math.PI,Math.PI),[jH(x),jH(_)]}function CK(t,e,n){t=HH(t,-180,180),e<-80?e=-80:e>84&&(e=84);const r=UH(e),i=Math.sin(r),s=Math.cos(r),o=i/s,a=o*o,l=a*a,c=UH(t),u=UH(SK(n.number)),h=_K/Math.sqrt(1-oK*i**2),d=lK*s**2,p=s*HH(c-u,-Math.PI,Math.PI),f=p*p,g=f*p,m=g*p,y=m*p,v=y*p,b=_K*(gK*r-.002514607064228144*Math.sin(2*r)+26390466021299826e-22*Math.sin(4*r)-mK*Math.sin(6*r)),w=sK*h*(p+g/6*(1-a+d)+y/120*(5-18*a+l+72*d-58*lK))+5e5;let _=sK*(b+h*o*(f/2+m/24*(5-a+9*d+4*d**2)+v/720*(61-58*a+l+600*d-330*lK)));return n.north||(_+=1e7),[w,_]}function SK(t){return 6*(t-1)-180+3}var kK=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function EK(t){let e=0;for(const i of kK){const n=t.match(i);if(n){e=parseInt(n[1]);break}}if(!e)return null;let n=0,r=!1;return e>32700&&e<32761?n=e-32700:e>32600&&e<32661&&(r=!0,n=e-32600),n?{number:n,north:r}:null}function RK(t,e){return function(n,r,i,s){const o=n.length;i=i>1?i:2,s=s??i,r||(r=i>2?n.slice():new Array(o));for(let a=0;a180)&&(n[0]=BH(r+180,360)-180),n}function VK(t,e){if(t===e)return!0;const n=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||WK(t,e)===NK)&&n}function WK(t,e){const n=t.getCode(),r=e.getCode();let i=iK(n,r);if(i)return i;let s=null,o=null;for(const l of PK)s||(s=l(t)),o||(o=l(e));if(!s&&!o)return null;const a="EPSG:4326";if(o)if(s)i=HK(s.inverse,o.forward);else{const t=iK(n,a);t&&(i=HK(t,o.forward))}else{const t=iK(a,r);t&&(i=HK(s.inverse,t))}return i&&(DK(t),DK(e),rK(t,e,i)),i}function HK(t,e){return function(n,r,i,s){return r=t(n,r,i,s),e(r,r,i,s)}}function GK(t,e){return WK(zK(t),zK(e))}function KK(t,e,n){const r=GK(e,n);if(!r){const t=zK(e).getCode(),r=zK(n).getCode();throw new Error(`No transform available between ${t} and ${r}`)}return r(t,void 0,t.length)}function ZK(t,e,n,r){return TG(t,GK(e,n),void 0,r)}function YK(t){return t}function XK(t){return AK&&!MG(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(AK=!1,BG("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t}function JK(t){return t}UK(YG),UK(tK),TK=YG,LK=function(t,e,n,r){const i=t.length;n=n>1?n:2,r=r??n,void 0===e&&(e=n>2?t.slice():new Array(i));for(let s=0;sKG?n=KG:n<-KG&&(n=-KG),e[s+1]=n}return e},IK=function(t,e,n,r){const i=t.length;n=n>1?n:2,r=r??n,void 0===e&&(e=n>2?t.slice():new Array(i));for(let s=0;s{if(!n)return this.getSimplifiedGeometry(e);const r=this.clone();return r.applyTransform(n),r.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return rH()}closestPointXY(t,e,n,r){return rH()}containsXY(t,e){return 0===this.closestPointXY(t,e,fZ,Number.MIN_VALUE)}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return rH()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&iG(t),this.extentRevision_=this.getRevision()}return function(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t}(this.extent_,t)}rotate(t,e){rH()}scale(t,e,n){rH()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return rH()}getType(){return rH()}applyTransform(t){rH()}intersectsExtent(t){return rH()}translate(t,e){rH()}transform(t,e){const n=zK(t),r="tile-pixels"==n.getUnits()?function(t,r,i){const s=n.getExtent(),o=n.getWorldExtent(),a=wG(o)/wG(s);aZ(pZ,o[0],o[3],a,-a,0,0,0);const l=hZ(t,0,t.length,i,pZ,r),c=GK(n,e);return c?c(l,l,i):l}:GK(n,e);return this.applyTransform(r),this}},mZ=class extends gZ{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return oG(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return rH()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length1)h=n;else{if(d>0){for(let i=0;ii&&(i=a),s=n,o=r}return i}function CZ(t,e,n,r,i){for(let s=0,o=n.length;ss&&(n-a)*(s-l)-(i-a)*(r-l)>0&&o++:r<=s&&(n-a)*(s-l)-(i-a)*(r-l)<0&&o--,a=n,l=r}return 0!==o}function OZ(t,e,n,r,i,s){if(0===n.length)return!1;if(!AZ(t,e,n[0],r,i,s))return!1;for(let o=1,a=n.length;o=i[0]&&s[2]<=i[2]||s[1]>=i[1]&&s[3]<=i[3]||NZ(t,e,n,r,function(t,e){return function(t,e,n){let r=!1;const i=nG(t,e),s=nG(t,n);if(1===i||1===s)r=!0;else{const o=t[0],a=t[1],l=t[2],c=t[3],u=e[0],h=e[1],d=n[0],p=n[1],f=(p-h)/(d-u);let g,m;2&s&&!(2&i)&&(g=d-(p-c)/f,r=g>=o&&g<=l),r||!(4&s)||4&i||(m=p-(d-l)*f,r=m>=a&&m<=c),r||!(8&s)||8&i||(g=d-(p-a)/f,r=g>=o&&g<=l),r||!(16&s)||16&i||(m=p-(d-o)*f,r=m>=a&&m<=c)}return r}(i,t,e)}))}function DZ(t,e,n,r,i){return!!(FZ(t,e,n,r,i)||AZ(t,e,n,r,i[0],i[1])||AZ(t,e,n,r,i[0],i[3])||AZ(t,e,n,r,i[2],i[1])||AZ(t,e,n,r,i[2],i[3]))}function zZ(t,e,n,r,i){if(!DZ(t,e,n[0],r,i))return!1;if(1===n.length)return!0;for(let s=1,o=n.length;s0;){const n=c.pop(),s=c.pop();let o=0;const a=t[s],h=t[s+1],d=t[n],p=t[n+1];for(let e=s+r;eo&&(u=e,o=n)}o>i&&(l[(u-e)/r]=1,s+r0&&f>d)&&(p<0&&g0&&g>p)?(a=n,l=h):(s[o++]=a,s[o++]=l,c=a,u=l,a=n,l=h)}return s[o++]=a,s[o++]=l,o}function qZ(t,e,n,r,i,s,o,a){for(let l=0,c=n.length;ly&&(c=(u+h)/2,OZ(t,e,n,r,c,f)&&(m=c,y=i)),u=h}return isNaN(m)&&(m=i[s]),o?(o.push(m,f,y),o):[m,f,y]}function GZ(t,e,n,r,i){let s=[];for(let o=0,a=n.length;o0}function YZ(t,e,n,r,i){i=void 0!==i&&i;for(let s=0,o=n.length;su&&h1&&"function"==typeof arguments[n-1]&&(e=arguments[n-1],--n);let r=0;for(;r0}getInteracting(){return this.hints_[1]>0}cancelAnimations(){let t;this.setHint(0,-this.hints_[0]);for(let e=0,n=this.animations_.length;e=0;--n){const r=this.animations_[n];let i=!0;for(let n=0,s=r.length;n0?o/s.duration:1;a>=1?(s.complete=!0,a=1):i=!1;const l=s.easing(a);if(s.sourceCenter){const t=s.sourceCenter[0],e=s.sourceCenter[1],n=s.targetCenter[0],r=s.targetCenter[1];this.nextCenter_=s.targetCenter;const i=t+l*(n-t),o=e+l*(r-e);this.targetCenter_=[i,o]}if(s.sourceResolution&&s.targetResolution){const t=1===l?s.targetResolution:s.sourceResolution+l*(s.targetResolution-s.sourceResolution);if(s.anchor){const e=this.getViewportSize_(this.getRotation()),n=this.constraints_.resolution(t,0,e,!0);this.targetCenter_=this.calculateCenterZoom(n,s.anchor)}this.nextResolution_=s.targetResolution,this.targetResolution_=t,this.applyTargetState_(!0)}if(void 0!==s.sourceRotation&&void 0!==s.targetRotation){const t=1===l?BH(s.targetRotation+Math.PI,2*Math.PI)-Math.PI:s.sourceRotation+l*(s.targetRotation-s.sourceRotation);if(s.anchor){const e=this.constraints_.rotation(t,!0);this.targetCenter_=this.calculateCenterRotate(e,s.anchor)}this.nextRotation_=s.targetRotation,this.targetRotation_=t}if(this.applyTargetState_(!0),e=!0,!s.complete)break}if(i){this.animations_[n]=null,this.setHint(0,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=r[0].callback;t&&cY(t,!0)}}this.animations_=this.animations_.filter(Boolean),e&&void 0===this.updateAnimationKey_&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let n;const r=this.getCenterInternal();var i,s;return void 0!==r&&(n=[r[0]-e[0],r[1]-e[1]],AG(n,t-this.getRotation()),s=e,(i=n)[0]+=+s[0],i[1]+=+s[1]),n}calculateCenterZoom(t,e){let n;const r=this.getCenterInternal(),i=this.getResolution();return void 0!==r&&void 0!==i&&(n=[e[0]-t*(e[0]-r[0])/i,e[1]-t*(e[1]-r[1])/i]),n}getViewportSize_(t){const e=this.viewportSize_;if(t){const n=e[0],r=e[1];return[Math.abs(n*Math.cos(t))+Math.abs(r*Math.sin(t)),Math.abs(n*Math.sin(t))+Math.abs(r*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t?YK(t,this.getProjection()):t}getCenterInternal(){return this.get(NH.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return void 0!==t?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){return e=this.calculateExtentInternal(t),this.getProjection(),e;var e}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();PH(e,"The view center is not defined");const n=this.getResolution();PH(void 0!==n,"The view resolution is not defined");const r=this.getRotation();return PH(void 0!==r,"The view rotation is not defined"),vG(e,n,r,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(NH.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(JK(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=kG(t)/e[0],r=wG(t)/e[1];return Math.max(n,r)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(e/n)/Math.log(t);return function(n){return e/Math.pow(t,n*r)}}getRotation(){return this.get(NH.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),n=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,i=Math.log(n/r)/e;return function(t){return Math.log(n/t)/e/i}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const n=this.padding_;return n&&(e=[e[0]-n[1]-n[3],e[1]-n[0]-n[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),n=this.getRotation();let r=this.getCenterInternal();const i=this.padding_;if(i){const t=this.getViewportSizeMinusPadding_();r=hY(r,this.getViewportSize_(),[t[0]/2+i[3],t[1]/2+i[0]],e,n)}return{center:r.slice(0),projection:void 0!==t?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return void 0!==e&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e,n,r=this.minZoom_||0;if(this.resolutions_){const i=WW(this.resolutions_,t,1);r=i,e=this.resolutions_[i],n=i==this.resolutions_.length-1?2:e/this.resolutions_[i+1]}else e=this.maxResolution_,n=this.zoomFactor_;return r+Math.log(e/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(1===this.resolutions_.length)return this.resolutions_[0];const e=FH(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,FH(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(PH(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t))PH(!RG(t),"Cannot fit empty extent provided as `geometry`"),n=nY(JK(t,this.getProjection()));else if("Circle"===t.getType()){const e=JK(t.getExtent(),this.getProjection());n=nY(e),n.rotate(this.getRotation(),mG(e))}else{const e=null;n=e?t.clone().transform(e,this.getProjection()):t}this.fitInternal(n,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),n=Math.cos(e),r=Math.sin(-e),i=t.getFlatCoordinates(),s=t.getStride();let o=1/0,a=1/0,l=-1/0,c=-1/0;for(let u=0,h=i.length;ut.trim().replace(/^['"]|['"]$/g,"")),n};function _Y(t,e,n,r){let i;return i=n&&n.length?n.shift():vH?new class extends OffscreenCanvas{style={}}(t??300,e??150):document.createElement("canvas"),t&&(i.width=t),e&&(i.height=e),i.getContext("2d",r)}function xY(){return dY||(dY=_Y(1,1)),dY}function CY(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}function SY(t){let e=t.offsetWidth;const n=getComputedStyle(t);return e+=parseInt(n.marginLeft,10)+parseInt(n.marginRight,10),e}function kY(t){let e=t.offsetHeight;const n=getComputedStyle(t);return e+=parseInt(n.marginTop,10)+parseInt(n.marginBottom,10),e}function EY(t,e){const n=e.parentNode;n&&n.replaceChild(t,e)}function RY(t){for(;t.lastChild;)t.lastChild.remove()}function TY(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const e=this.childNodes.indexOf(t);if(-1===e)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){const n=this.childNodes.indexOf(e);if(-1===n)throw new Error("Reference node not found");return this.childNodes.splice(n,0,t),t},style:{}},{get:(t,e,n)=>"firstElementChild"===e?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,n)})}function LY(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas}var IY=class extends aH{constructor(t){super();const e=t.element;!e||t.target||e.style.pointerEvents||(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,n=this.listenerKeys.length;ee.getAttributions(t)));if(void 0!==this.attributions_&&(Array.isArray(this.attributions_)?this.attributions_.forEach(t=>n.add(t)):n.add(this.attributions_)),!this.overrideCollapsible_){const t=!e.some(t=>!1===t.getSource()?.getAttributionsCollapsible());this.setCollapsible(t)}return Array.from(n)}async updateElement_(t){if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=await Promise.all(this.collectSourceAttributions_(t).map(t=>QW(()=>t))),n=e.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!KW(e,this.renderedAttributions_)){RY(this.ulElement_);for(let t=0,n=e.length;t0&&e%(2*Math.PI)!=0?t.animate({rotation:0,duration:this.duration_,easing:FG}):t.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const n=e.viewState.rotation;if(n!=this.rotation_){const t="rotate("+n+"rad)";if(this.autoHide_){const t=this.element.classList.contains(pY);t||0!==n?t&&0!==n&&this.element.classList.remove(pY):this.element.classList.add(pY)}this.label_.style.transform=t}this.rotation_=n}},AY=class extends IY{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=void 0!==t.className?t.className:"ol-zoom",n=void 0!==t.delta?t.delta:1,r=void 0!==t.zoomInClassName?t.zoomInClassName:e+"-in",i=void 0!==t.zoomOutClassName?t.zoomOutClassName:e+"-out",s=void 0!==t.zoomInLabel?t.zoomInLabel:"+",o=void 0!==t.zoomOutLabel?t.zoomOutLabel:"–",a=void 0!==t.zoomInTipLabel?t.zoomInTipLabel:"Zoom in",l=void 0!==t.zoomOutTipLabel?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=a,c.appendChild("string"==typeof s?document.createTextNode(s):s),c.addEventListener(DW,this.handleClick_.bind(this,n),!1);const u=document.createElement("button");u.className=i,u.setAttribute("type","button"),u.title=l,u.appendChild("string"==typeof o?document.createTextNode(o):o),u.addEventListener(DW,this.handleClick_.bind(this,-n),!1);const h=e+" "+fY+" "+gY,d=this.element;d.className=h,d.appendChild(c),d.appendChild(u),this.duration_=void 0!==t.duration?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const e=this.getMap().getView();if(!e)return;const n=e.getZoom();if(void 0!==n){const r=e.getConstrainedZoom(n+t);this.duration_>0?(e.getAnimating()&&e.cancelAnimations(),e.animate({zoom:r,duration:this.duration_,easing:FG})):e.setZoom(r)}}};function OY(t){t=t||{};const e=new uH;return(void 0===t.zoom||t.zoom)&&e.push(new AY(t.zoomOptions)),(void 0===t.rotate||t.rotate)&&e.push(new MY(t.rotateOptions)),(void 0===t.attribution||t.attribution)&&e.push(new PY(t.attributionOptions)),e}var NY=class{constructor(t,e,n){this.decay_=t,this.minVelocity_=e,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]0&&this.points_[n+2]>t;)n-=3;const r=this.points_[e+2]-this.points_[n+2];if(r<1e3/60)return!1;const i=this.points_[e]-this.points_[n],s=this.points_[e+1]-this.points_[n+1];return this.angle_=Math.atan2(s,i),this.initialVelocity_=Math.sqrt(i*i+s*s)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}},FY="active",DY=class extends aH{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(FY)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(FY,t)}setMap(t){this.map_=t}};function zY(t,e,n,r){const i=t.getZoom();if(void 0===i)return;const s=t.getConstrainedZoom(i+e),o=t.getResolutionForZoom(s);t.getAnimating()&&t.cancelAnimations(),t.animate({resolution:o,anchor:n,duration:void 0!==r?r:250,easing:FG})}var jY=class extends DY{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:250}handleEvent(t){let e=!1;if(t.type==pH.DBLCLICK){const n=t.originalEvent,r=t.map,i=t.coordinate,s=n.shiftKey?-this.delta_:this.delta_;zY(r.getView(),s,i,this.duration_),n.preventDefault(),e=!0}return!e}};function UY(t){const e=arguments;return function(t){let n=!0;for(let r=0,i=e.length;r0}}else if(t.type==pH.POINTERDOWN){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==pH.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function XY(t){const e=t.length;let n=0,r=0;for(let i=0;i0&&this.condition_(t)){const e=t.map.getView();return this.lastCentroid=null,e.getAnimating()&&e.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},QY=class extends YY{constructor(t){t=t||{},super({stopDown:YW}),this.condition_=t.condition?t.condition:BY,this.lastAngle_=void 0,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){if(!KY(t))return;const e=t.map,n=e.getView();if(n.getConstraints().rotation===oY)return;const r=e.getSize(),i=t.pixel,s=Math.atan2(r[1]/2-i[1],i[0]-r[0]/2);if(void 0!==this.lastAngle_){const t=s-this.lastAngle_;n.adjustRotationInternal(-t)}this.lastAngle_=s}handleUpEvent(t){return!KY(t)||(t.map.getView().endInteraction(this.duration_),!1)}handleDownEvent(t){return!(!KY(t)||!VY(t)||!this.condition_(t)||(t.map.getView().beginInteraction(),this.lastAngle_=void 0,0))}},tX=class extends $W{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,n="px",r=this.element_.style;r.left=Math.min(t[0],e[0])+n,r.top=Math.min(t[1],e[1])+n,r.width=Math.abs(e[0]-t[0])+n,r.height=Math.abs(e[1]-t[1])+n}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,n=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new eY([n])}getGeometry(){return this.geometry_}},eX="boxcancel",nX=class extends tH{constructor(t,e,n){super(t),this.coordinate=e,this.mapBrowserEvent=n}},rX=class extends YY{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new tX(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??VY,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,n){const r=n[0]-e[0],i=n[1]-e[1];return r*r+i*i>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new nX("boxdrag",t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new nX(e?"boxend":eX,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return!!this.condition_(t)&&(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new nX("boxstart",t.coordinate,t)),!0)}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new nX(eX,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new nX(eX,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}},iX=class extends rX{constructor(t){super({condition:(t=t||{}).condition?t.condition:HY,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=void 0!==t.duration?t.duration:200,this.out_=void 0!==t.out&&t.out}onBoxEnd(t){const e=this.getMap().getView();let n=this.getGeometry();if(this.out_){const t=e.rotatedExtentForGeometry(n),r=e.getResolutionForExtentInternal(t),i=e.getResolution()/r;n=n.clone(),n.scale(i*i)}e.fitInternal(n,{duration:this.duration_,easing:FG})}},sX="ArrowLeft",oX="ArrowRight",aX="ArrowDown",lX=class extends DY{constructor(t){super(),t=t||{},this.defaultCondition_=function(t){return WY(t)&&GY(t)},this.condition_=void 0!==t.condition?t.condition:this.defaultCondition_,this.duration_=void 0!==t.duration?t.duration:100,this.pixelDelta_=void 0!==t.pixelDelta?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==zW){const n=t.originalEvent,r=n.key;if(this.condition_(t)&&(r==aX||r==sX||r==oX||"ArrowUp"==r)){const i=t.map.getView(),s=i.getResolution()*this.pixelDelta_;let o=0,a=0;r==aX?a=-s:r==sX?o=-s:r==oX?o=s:a=s;const l=[o,a];AG(l,i.getRotation()),function(t,e,n){const r=t.getCenterInternal();if(r){const i=[r[0]+e[0],r[1]+e[1]];t.animateInternal({duration:void 0!==n?n:250,easing:zG,center:t.getConstrainedCenter(i)})}}(i,l,this.duration_),n.preventDefault(),e=!0}}return!e}},cX=class extends DY{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(t){return!function(t){const e=t.originalEvent;return mH?e.metaKey:e.ctrlKey}(t)&&GY(t)},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:100}handleEvent(t){let e=!1;if(t.type==zW||t.type==jW){const n=t.originalEvent,r=n.key;if(this.condition_(t)&&("+"===r||"-"===r)){const i=t.map,s="+"===r?this.delta_:-this.delta_;zY(i.getView(),s,void 0,this.duration_),n.preventDefault(),e=!0}}return!e}},uX=class extends DY{constructor(t){super(t=t||{}),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=void 0!==t.maxDelta?t.maxDelta:1,this.duration_=void 0!==t.duration?t.duration:250,this.timeout_=void 0!==t.timeout?t.timeout:80,this.useAnchor_=void 0===t.useAnchor||t.useAnchor,this.constrainResolution_=void 0!==t.constrainResolution&&t.constrainResolution;const e=t.condition?t.condition:qY;this.condition_=t.onFocusOnly?UY($Y,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(t){if(this.ctrlKeyListenerKeys_.forEach(OW),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){const e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push(MW(e,"keydown",t=>{"Control"===t.key&&(this.ctrlKeyPressed_=!0)}),MW(e,"keyup",t=>{"Control"===t.key&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;const e=t.getView(),n=this.lastDelta_?this.lastDelta_>0?1:-1:0;e.endInteraction(this.constrainResolution_||e.getConstrainResolution()?100:void 0,n,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t))return!0;if(t.type!==BW)return!0;const e=t.map,n=t.originalEvent;n.preventDefault();const r=n.ctrlKey&&!this.ctrlKeyPressed_;n.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=t.pixel);let i=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:i*=40;break;case WheelEvent.DOM_DELTA_PAGE:i*=300}if(0===i)return!1;this.lastDelta_=i;const s=Date.now();void 0===this.startTime_&&(this.startTime_=s),(!this.mode_||s-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(i)<4?"trackpad":"wheel");const o=e.getView();if("trackpad"===this.mode_)return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(o.getAnimating()&&o.cancelAnimations(),o.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),r&&(i*=3),o.adjustZoom(-i/this.deltaPerZoom_,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=s,!1;this.totalDelta_+=i;const a=Math.max(this.timeout_-(s-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,e),a),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let n=-FH(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),zY(e,n,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}},hX=class extends YY{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=YW),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=void 0!==t.threshold?t.threshold:.3,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){let e=0;const n=this.targetPointers[0],r=this.targetPointers[1],i=Math.atan2(r.clientY-n.clientY,r.clientX-n.clientX);if(void 0!==this.lastAngle_){const t=i-this.lastAngle_;this.rotationDelta_+=t,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=t}this.lastAngle_=i;const s=t.map,o=s.getView();o.getConstraints().rotation!==oY&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(XY(this.targetPointers))),this.rotating_&&(s.render(),o.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return!(this.targetPointers.length<2&&(t.map.getView().endInteraction(this.duration_),1))}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},dX=class extends YY{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=YW),super(e),this.anchor_=null,this.duration_=void 0!==t.duration?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const n=this.targetPointers[0],r=this.targetPointers[1],i=n.clientX-r.clientX,s=n.clientY-r.clientY,o=Math.sqrt(i*i+s*s);void 0!==this.lastDistance_&&(e=this.lastDistance_/o),this.lastDistance_=o;const a=t.map,l=a.getView();1!=e&&(this.lastScaleDelta_=e),this.anchor_=a.getCoordinateFromPixelInternal(a.getEventPixel(XY(this.targetPointers))),a.render(),l.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const e=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,n),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}};function pX(t){t=t||{};const e=new uH,n=new NY(-.005,.05,100);return(void 0===t.altShiftDragRotate||t.altShiftDragRotate)&&e.push(new QY),(void 0===t.doubleClickZoom||t.doubleClickZoom)&&e.push(new jY({delta:t.zoomDelta,duration:t.zoomDuration})),(void 0===t.dragPan||t.dragPan)&&e.push(new JY({onFocusOnly:t.onFocusOnly,kinetic:n})),(void 0===t.pinchRotate||t.pinchRotate)&&e.push(new hX),(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new dX({duration:t.zoomDuration})),(void 0===t.keyboard||t.keyboard)&&(e.push(new lX),e.push(new cX({delta:t.zoomDelta,duration:t.zoomDuration}))),(void 0===t.mouseWheelZoom||t.mouseWheelZoom)&&e.push(new uX({onFocusOnly:t.onFocusOnly,duration:t.zoomDuration})),(void 0===t.shiftDragZoom||t.shiftDragZoom)&&e.push(new iX({duration:t.zoomDuration})),e}var fX="opacity",gX="visible",mX="extent",yX="zIndex",vX="maxResolution",bX="minResolution",wX="maxZoom",_X="minZoom",xX="source",CX=class extends aH{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);"object"==typeof t.properties&&(delete e.properties,Object.assign(e,t.properties)),e[fX]=void 0!==t.opacity?t.opacity:1,PH("number"==typeof e[fX],"Layer opacity must be a number"),e[gX]=void 0===t.visible||t.visible,e[yX]=t.zIndex,e[vX]=void 0!==t.maxResolution?t.maxResolution:1/0,e[bX]=void 0!==t.minResolution?t.minResolution:0,e[_X]=void 0!==t.minZoom?t.minZoom:-1/0,e[wX]=void 0!==t.maxZoom?t.maxZoom:1/0,this.className_=void 0!==e.className?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:void 0===t||t},n=this.getZIndex();return e.opacity=FH(Math.round(100*this.getOpacity())/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=void 0!==n||e.managed?n:1/0,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return rH()}getLayerStatesArray(t){return rH()}getExtent(){return this.get(mX)}getMaxResolution(){return this.get(vX)}getMinResolution(){return this.get(bX)}getMinZoom(){return this.get(_X)}getMaxZoom(){return this.get(wX)}getOpacity(){return this.get(fX)}getSourceState(){return rH()}getVisible(){return this.get(gX)}getZIndex(){return this.get(yX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(mX,t)}setMaxResolution(t){this.set(vX,t)}setMinResolution(t){this.set(bX,t)}setMaxZoom(t){this.set(wX,t)}setMinZoom(t){this.set(_X,t)}setOpacity(t){PH("number"==typeof t,"Layer opacity must be a number"),this.set(fX,t)}setVisible(t){this.set(gX,t)}setZIndex(t){this.set(yX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},SX="addlayer",kX="removelayer",EX=class extends tH{constructor(t,e){super(t),this.layer=e}},RX="layers",TX=class t extends CX{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let n=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(RX,this.handleLayersChanged_),n?Array.isArray(n)?n=new uH(n.slice(),{unique:!0}):PH("function"==typeof n.getArray,"Expected `layers` to be an array or a `Collection`"):n=new uH(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(OW),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(MW(t,RW,this.handleLayersAdd_,this),MW(t,TW,this.handleLayersRemove_,this));for(const n in this.listenerKeys_)this.listenerKeys_[n].forEach(OW);IW(this.listenerKeys_);const e=t.getArray();for(let n=0,r=e.length;n{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const n=this.getMapInternal();let r;if(!t&&n&&(t=n.getView()),e=t instanceof lY?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&n&&(e.layerStatesArray=n.getLayerGroup().getLayerStatesArray()),e.layerStatesArray){if(r=e.layerStatesArray.find(t=>t.layer===this),!r)return!1}else r=this.getLayerState();const i=this.getExtent();return OX(r,e.viewState)&&(!i||EG(i,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let n=e(t instanceof lY?t.getViewStateAndExtent():t);return Array.isArray(n)||(n=[n]),n}render(t,e){const n=this.getRenderer();return n.prepareFrame(t)?(this.rendered=!0,n.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set("map",t)}getMapInternal(){return this.get("map")}setMap(t){this.mapPrecomposeKey_&&(OW(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(OW(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=MW(t,PX,this.handlePrecompose_,this),this.mapRenderKey_=MW(this,NW,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,n=this.getLayerState(!1);PH(!e.some(t=>t.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(n)}setSource(t){this.set(xX,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function OX(t,e){if(!t.visible)return!1;const n=e.resolution;if(n=t.maxResolution)return!1;const r=e.zoom;return r>t.minZoom&&r<=t.maxZoom}function NX(t,e,n=0,r=t.length-1,i=DX){for(;r>n;){if(r-n>600){const s=r-n+1,o=e-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);NX(t,e,Math.max(n,Math.floor(e-o*l/s+c)),Math.min(r,Math.floor(e+(s-o)*l/s+c)),i)}const s=t[e];let o=n,a=r;for(FX(t,n,e),i(t[r],s)>0&&FX(t,n,r);o0;)a--}0===i(t[n],s)?FX(t,n,a):(a++,FX(t,a,r)),a<=e&&(n=a+1),e<=a&&(r=a-1)}}function FX(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function DX(t,e){return te?1:0}var zX=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!YX(t,e))return n;const r=this.toBBox,i=[];for(;e;){for(let s=0;s=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)}_split(t,e){const n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);const s=this._chooseSplitIndex(n,i,r),o=XX(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,UX(n,this.toBBox),UX(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(n,o)}_splitRoot(t,e){this.data=XX([t,e]),this.data.height=t.height+1,this.data.leaf=!1,UX(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let r,i=1/0,s=1/0;for(let o=e;o<=n-e;o++){const e=BX(t,0,o,this.toBBox),a=BX(t,o,n,this.toBBox),l=KX(e,a),c=WX(e)+WX(a);l=e;l--){const e=t.children[l];$X(o,t.leaf?i(e):e),a+=HX(o)}return a}_adjustParentBBoxes(t,e,n){for(let r=n;r>=0;r--)$X(e[r],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():UX(t[n],this.toBBox)}};function jX(t,e,n){if(!n)return e.indexOf(t);for(let r=0;r=t.minX&&e.maxY>=t.minY}function XX(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function JX(t,e,n,r,i){const s=[e,n];for(;s.length;){if((n=s.pop())-(e=s.pop())<=r)continue;const o=e+Math.ceil((n-e)/r/2)*r;NX(t,o,e,n,i),s.push(e,o,o,n)}}var QX,tJ=[NaN,NaN,NaN,0],eJ=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,nJ=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,rJ=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,iJ=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function sJ(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function oJ(t){throw new Error('failed to parse "'+t+'" as color')}function aJ(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(nJ)||t.match(eJ)||t.match(rJ);if(e){const t=e[4],n=100/255;return[FH(sJ(e[1],n)+.5|0,0,255),FH(sJ(e[2],n)+.5|0,0,255),FH(sJ(e[3],n)+.5|0,0,255),void 0!==t?FH(sJ(t,100),0,1):1]}oJ(t)}if(t.startsWith("#")){if(iJ.test(t)){const e=t.substring(1),n=e.length<=4?1:2,r=[0,0,0,255];for(let t=0,i=e.length;t.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function dJ(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function pJ(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function fJ(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function gJ(t){const e=pJ(t[0]),n=pJ(t[1]),r=pJ(t[2]),i=fJ(.222488403*e+.716873169*n+.06060791*r),s=500*(fJ(.452247074*e+.399439023*n+.148375274*r)-i),o=200*(i-fJ(.016863605*e+.117638439*n+.865350722*r)),a=Math.atan2(o,s)*(180/Math.PI);return[116*i-16,Math.sqrt(s*s+o*o),a<0?a+360:a,t[3]]}function mJ(t){if("none"===t)return tJ;if(lJ.hasOwnProperty(t))return lJ[t];if(cJ>=1024){let t=0;for(const e in lJ)3&t++||(delete lJ[e],--cJ)}const e=aJ(t);4!==e.length&&oJ(t);for(const n of e)isNaN(n)&&oJ(t);return lJ[t]=e,++cJ,e}function yJ(t){return Array.isArray(t)?t:mJ(t)}function vJ(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let n=t[1];n!=(0|n)&&(n=n+.5|0);let r=t[2];return r!=(0|r)&&(r=r+.5|0),"rgba("+e+","+n+","+r+","+(void 0===t[3]?1:Math.round(1e3*t[3])/1e3)+")"}function bJ(t){return t[0]>0&&t[1]>0}function wJ(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}var _J=0,xJ=1<<_J++,CJ=1<<_J++,SJ=1<<_J++,kJ=1<<_J++,EJ=1<<_J++,RJ=1<<_J++,TJ=Math.pow(2,6)-1,LJ={[xJ]:"boolean",[CJ]:"number",[SJ]:"string",[kJ]:"color",[EJ]:"number[]",[RJ]:"size"},IJ=Object.keys(LJ).map(Number).sort(qW);function PJ(t){const e=[];for(const n of IJ)MJ(t,n)&&e.push(LJ[n]);return 0===e.length?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function MJ(t,e){return(t&e)===e}function AJ(t,e){return!!(t&e)}function OJ(t,e){return t===e}var NJ=class{constructor(t,e){if(!function(t){return t in LJ}(t))throw new Error(`literal expressions must have a specific type, got ${PJ(t)}`);this.type=t,this.value=e}},FJ=class{constructor(t,e,...n){this.type=t,this.operator=e,this.args=n}};function DJ(t){return{variables:new Map,properties:new Map,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1,inputVariables:t}}function zJ(t,e,n){switch(typeof t){case"boolean":if(OJ(e,SJ))return new NJ(SJ,t?"true":"false");if(!MJ(e,xJ))throw new Error(`got a boolean, but expected ${PJ(e)}`);return new NJ(xJ,t);case"number":if(OJ(e,RJ))return new NJ(RJ,wJ(t));if(OJ(e,xJ))return new NJ(xJ,!!t);if(OJ(e,SJ))return new NJ(SJ,t.toString());if(!MJ(e,CJ))throw new Error(`got a number, but expected ${PJ(e)}`);return new NJ(CJ,t);case"string":if(OJ(e,kJ))return new NJ(kJ,mJ(t));if(OJ(e,xJ))return new NJ(xJ,!!t);if(!MJ(e,SJ))throw new Error(`got a string, but expected ${PJ(e)}`);return new NJ(SJ,t)}if(!Array.isArray(t))throw new Error("expression must be an array or a primitive value");if(0===t.length)throw new Error("empty expression");if("string"==typeof t[0])return function(t,e,n){const r=t[0],i=MQ[r];if(!i)throw new Error(`unknown operator: ${r}`);return i(t,e,n)}(t,e,n);for(const r of t)if("number"!=typeof r)throw new Error("expected an array of numbers");if(OJ(e,RJ)){if(2!==t.length)throw new Error(`expected an array of two values for a size, got ${t.length}`);return new NJ(RJ,t)}if(OJ(e,kJ)){if(3===t.length)return new NJ(kJ,[...t,1]);if(4===t.length)return new NJ(kJ,t);throw new Error(`expected an array of 3 or 4 values for a color, got ${t.length}`)}if(!MJ(e,EJ))throw new Error(`got an array of numbers, but expected ${PJ(e)}`);return new NJ(EJ,t)}var jJ="get",UJ="var",BJ="concat",$J="geometry-type",qJ="line-metric",VJ="any",WJ="all",HJ="!",GJ="resolution",KJ="zoom",ZJ="time",YJ="==",XJ="!=",JJ=">",QJ=">=",tQ="<",eQ="<=",nQ="*",rQ="/",iQ="+",sQ="-",oQ="clamp",aQ="%",lQ="^",cQ="abs",uQ="floor",hQ="ceil",dQ="round",pQ="sin",fQ="cos",gQ="atan",mQ="sqrt",yQ="match",vQ="between",bQ="interpolate",wQ="coalesce",_Q="case",xQ="in",CQ="number",SQ="string",kQ="array",EQ="color",RQ="id",TQ="band",LQ="palette",IQ="to-string",PQ="has",MQ={[jJ]:BQ(FQ(1,1/0),AQ),[UJ]:function(t,e,n){const r=t[1];if("string"!=typeof r)throw new Error("expected a string argument for var operation");let i=e;const s=n.inputVariables?.[r];if(void 0!==s){const t=zJ(s,TJ,n);if(!(t instanceof NJ))throw new Error(`style variables should only be literal values (no expressions!), variable name: ${r}`);let o=t.type;if("string"==typeof s&&AJ(i,kJ)&&!AJ(i,SJ)?o=kJ:Array.isArray(s)&&2===s.length&&AJ(i,RJ)&&!AJ(i,EJ)&&(o=RJ),i&=o,0===i)throw new Error(`the type expected from the var operator (${PJ(e)}) did not have any overlap with the type of the corresponding style variables (${PJ(o)}), variable name: ${r}`)}if(n.variables.has(r)){const t=n.variables.get(r);if(i&=t,0===i)throw new Error(`a new type expected from the var operator (${PJ(e)}) did not have any overlap with the previous type expected for it (${PJ(t)}), variable name: ${r}`)}return n.variables.set(r,i),new FJ(i,"var",new NJ(SJ,r))},[PQ]:BQ(FQ(1,1/0),AQ),[RQ]:BQ(function(t,e,n){n.featureId=!0},NQ),[BJ]:BQ(FQ(2,1/0),zQ(SJ)),[$J]:BQ(function(t,e,n){n.geometryType=!0},NQ),[qJ]:BQ(function(t,e,n){n.mCoordinate=!0},NQ),[GJ]:BQ(OQ,NQ),[KJ]:BQ(OQ,NQ),[ZJ]:BQ(OQ,NQ),[VJ]:BQ(FQ(2,1/0),zQ(xJ)),[WJ]:BQ(FQ(2,1/0),zQ(xJ)),[HJ]:BQ(FQ(1,1),zQ(xJ)),[YJ]:BQ(FQ(2,2),jQ()),[XJ]:BQ(FQ(2,2),jQ()),[JJ]:BQ(FQ(2,2),zQ(CJ)),[QJ]:BQ(FQ(2,2),zQ(CJ)),[tQ]:BQ(FQ(2,2),zQ(CJ)),[eQ]:BQ(FQ(2,2),zQ(CJ)),[nQ]:BQ(FQ(2,1/0),DQ),[wQ]:BQ(FQ(2,1/0),DQ),[rQ]:BQ(FQ(2,2),zQ(CJ)),[iQ]:BQ(FQ(2,1/0),zQ(CJ)),[sQ]:BQ(FQ(2,2),zQ(CJ)),[oQ]:BQ(FQ(3,3),zQ(CJ)),[aQ]:BQ(FQ(2,2),zQ(CJ)),[lQ]:BQ(FQ(2,2),zQ(CJ)),[cQ]:BQ(FQ(1,1),zQ(CJ)),[uQ]:BQ(FQ(1,1),zQ(CJ)),[hQ]:BQ(FQ(1,1),zQ(CJ)),[dQ]:BQ(FQ(1,1),zQ(CJ)),[pQ]:BQ(FQ(1,1),zQ(CJ)),[fQ]:BQ(FQ(1,1),zQ(CJ)),[gQ]:BQ(FQ(1,2),zQ(CJ)),[mQ]:BQ(FQ(1,1),zQ(CJ)),[yQ]:BQ(FQ(4,1/0),UQ,function(t,e,n){const r=t.length-1,i=zJ(t[t.length-1],e,n);let s=SJ|CJ|xJ;const o=new Array(r-2);for(let a=0;ae)throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${r}, got ${i}`)}}function DQ(t,e,n){const r=t.length-1,i=new Array(r);for(let s=0;s{for(let e=0;e{for(let e=0;e{const r=t.args;let i=n.properties[e];for(let t=1,e=r.length;tt.variables[e];case PQ:return n=>{const r=t.args;if(!(e in n.properties))return!1;let i=n.properties[e];for(let t=1,e=r.length;tt.featureId;case $J:return t=>t.geometryType;case BJ:{const n=t.args.map(t=>VQ(t,e));return t=>"".concat(...n.map(e=>e(t).toString()))}case GJ:return t=>t.resolution;case VJ:case WJ:case vQ:case xQ:case"!":return function(t,e){const n=t.operator,r=t.args.length,i=new Array(r);for(let s=0;s{for(let e=0;e{for(let e=0;e{const e=i[0](t),n=i[1](t),r=i[2](t);return e>=n&&e<=r};case xQ:return t=>{const e=i[0](t);for(let n=1;n!i[0](t);default:throw new Error(`Unsupported logical operator ${n}`)}}(t,e);case YJ:case XJ:case"<":case eQ:case">":case QJ:return function(t,e){const n=t.operator,r=VQ(t.args[0],e),i=VQ(t.args[1],e);switch(n){case YJ:return t=>r(t)===i(t);case XJ:return t=>r(t)!==i(t);case"<":return t=>r(t)r(t)<=i(t);case">":return t=>r(t)>i(t);case QJ:return t=>r(t)>=i(t);default:throw new Error(`Unsupported comparison operator ${n}`)}}(t,e);case"*":case"/":case"+":case"-":case oQ:case"%":case"^":case cQ:case uQ:case hQ:case dQ:case pQ:case fQ:case gQ:case mQ:return function(t,e){const n=t.operator,r=t.args.length,i=new Array(r);for(let s=0;s{let e=1;for(let n=0;ni[0](t)/i[1](t);case"+":return t=>{let e=0;for(let n=0;ni[0](t)-i[1](t);case oQ:return t=>{const e=i[0](t),n=i[1](t);if(er?r:e};case"%":return t=>i[0](t)%i[1](t);case"^":return t=>Math.pow(i[0](t),i[1](t));case cQ:return t=>Math.abs(i[0](t));case uQ:return t=>Math.floor(i[0](t));case hQ:return t=>Math.ceil(i[0](t));case dQ:return t=>Math.round(i[0](t));case pQ:return t=>Math.sin(i[0](t));case fQ:return t=>Math.cos(i[0](t));case gQ:return 2===r?t=>Math.atan2(i[0](t),i[1](t)):t=>Math.atan(i[0](t));case mQ:return t=>Math.sqrt(i[0](t));default:throw new Error(`Unsupported numeric operator ${n}`)}}(t,e);case _Q:return function(t,e){const n=t.args.length,r=new Array(n);for(let i=0;i{for(let e=0;e{const e=r[0](t);for(let i=1;i{const e=r[0](t),i=r[1](t);let s,o;for(let a=2;a=i)return 2===a?l:c?HQ(e,i,s,o,n,l):WQ(e,i,s,o,n,l);s=n,o=l}return o}}(t,e);case IQ:return function(t,e){const n=t.operator,r=t.args.length,i=new Array(r);for(let s=0;s{const n=i[0](e);return t.args[0].type===kJ?vJ(n):n.toString()};throw new Error(`Unsupported convert operator ${n}`)}(t,e);default:throw new Error(`Unsupported operator ${n}`)}}function WQ(t,e,n,r,i,s){const o=i-n;if(0===o)return r;const a=e-n;return r+(1===t?a/o:(Math.pow(t,a)-1)/(Math.pow(t,o)-1))*(s-r)}function HQ(t,e,n,r,i,s){if(i-n===0)return r;const o=gJ(r),a=gJ(s);let l=a[2]-o[2];return l>180?l-=360:l<-180&&(l+=360),function(t){const e=(t[0]+16)/116,n=t[1],r=t[2]*Math.PI/180,i=dJ(e),s=dJ(e+n/500*Math.cos(r)),o=dJ(e-n/200*Math.sin(r)),a=hJ(3.021973625*s-1.617392459*i-.404875592*o),l=hJ(-.943766287*s+1.916279586*i+.027607165*o),c=hJ(.069407491*s-.22898585*i+1.159737864*o);return[FH(a+.5|0,0,255),FH(l+.5|0,0,255),FH(c+.5|0,0,255),t[3]]}([WQ(t,e,n,o[0],i,a[0]),WQ(t,e,n,o[1],i,a[1]),o[2]+WQ(t,e,n,0,i,l),WQ(t,e,n,r[3],i,s[3])])}var GQ=class extends eH{constructor(t,e,n,r){super(),this.extent=t,this.pixelRatio_=n,this.resolution=e,this.state="function"==typeof r?0:r,this.image_=null,this.loader="function"==typeof r?r:null}changed(){this.dispatchEvent(NW)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(0==this.state&&this.loader){this.state=1,this.changed();const t=this.getResolution(),e=Array.isArray(t)?t[0]:t;QW(()=>this.loader(this.getExtent(),e,this.getPixelRatio())).then(t=>{"image"in t&&(this.image_=t.image),"extent"in t&&(this.extent=t.extent),"resolution"in t&&(this.resolution=t.resolution),"pixelRatio"in t&&(this.pixelRatio_=t.pixelRatio),(t instanceof HTMLImageElement||wH&&t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)&&(this.image_=t),this.state=2}).catch(t=>{this.state=3,console.error(t)}).finally(()=>this.changed())}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}};function KQ(t,e){return t+":"+(e?yJ(e):"null")}var ZQ=new class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const n=this.cache_[e];3&t++||n.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){const n=KQ(t,e);return n in this.cache_?this.cache_[n]:null}getPattern(t,e){const n=KQ(t,e);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,n,r){const i=KQ(t,e),s=i in this.cache_;this.cache_[i]=n,r&&(0===n.getImageState()&&n.load(),1===n.getImageState()?n.ready().then(()=>{this.patternCache_[i]=xY().createPattern(n.getImage(1),"repeat")}):this.patternCache_[i]=xY().createPattern(n.getImage(1),"repeat")),s||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}},YQ=null,XQ=class extends eH{constructor(t,e,n,r,i){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.canvas_={},this.color_=i,this.imageState_=void 0===r?0:r,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(void 0===this.tainted_&&2===this.imageState_){YQ||(YQ=_Y(1,1,void 0,{willReadFrequently:!0})),YQ.drawImage(this.image_,0,0);try{YQ.getImageData(0,0,1,1),this.tainted_=!1}catch{YQ=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(NW)}handleImageError_(){this.imageState_=3,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=2,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}setImage(t){this.image_=t}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],n=_Y(t,e);n.fillRect(0,0,t,e),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(0===this.imageState_){this.image_||this.initializeImage_(),this.imageState_=1;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&(t=this.image_,e=this.src_,e&&(t.src=e),t.src&&bH?new Promise((e,n)=>t.decode().then(()=>e(t)).catch(r=>t.complete&&t.width?e(t):n(r))):function(t){return new Promise((e,n)=>{function r(){s(),e(t)}function i(){s(),n(new Error("Image load error"))}function s(){t.removeEventListener("load",r),t.removeEventListener("error",i)}t.addEventListener("load",r),t.addEventListener("error",i)})}(t)).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}var t,e}replaceColor_(t){if(!this.color_||this.canvas_[t]||2!==this.imageState_)return;const e=this.image_,n=_Y(Math.ceil(e.width*t),Math.ceil(e.height*t)),r=n.canvas;var i;n.scale(t,t),n.drawImage(e,0,0),n.globalCompositeOperation="multiply",n.fillStyle="string"==typeof(i=this.color_)?i:vJ(i),n.fillRect(0,0,r.width/t,r.height/t),n.globalCompositeOperation="destination-in",n.drawImage(e,0,0),this.canvas_[t]=r}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(2===this.imageState_||3===this.imageState_)t();else{const e=()=>{2!==this.imageState_&&3!==this.imageState_||(this.removeEventListener(NW,e),t())};this.addEventListener(NW,e)}})),this.ready_}};function JQ(t,e,n,r,i,s){let o=void 0===e?void 0:ZQ.get(e,i);return o||(o=new XQ(t,t&&"src"in t?t.src||void 0:e,n,r,i),ZQ.set(e,i,o,s)),s&&o&&!ZQ.getPattern(e,i)&&ZQ.set(e,i,o,s),o}function QQ(t){return t?Array.isArray(t)?vJ(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return ZQ.getPattern(t.src,t.color);const e=t.src+":"+t.offset,n=ZQ.getPattern(e,t.color);if(n)return n;const r=ZQ.get(t.src,null);if(2!==r.getImageState())return null;const i=_Y(t.size[0],t.size[1]);return i.drawImage(r.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),JQ(i.canvas,e,void 0,2,t.color,!0),ZQ.getPattern(e,t.color)}(t):t:null}var t0,e0="#000",n0="round",r0=[],i0="round",s0="#000",o0="center",a0=[0,0,0,0],l0=new aH,c0=null,u0={},h0=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function d0(t,e,n){return`${t} ${e} 16px "${n}"`}var p0=function(){const t=100;let e,n;async function r(t){await n.ready;const e=wY(t),r=e.families[0].toLowerCase(),i=e.weight,s=[];return n.forEach(t=>{const n=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),o=bY[t.weight]||t.weight;n===r&&t.style===e.style&&o==i&&s.push(t)}),0!==s.length&&(await Promise.all(s.map(t=>t.load().then(()=>!0,()=>!1)))).some(t=>t)}async function i(){await n.ready;let s=!0;const o=l0.getProperties(),a=Object.keys(o).filter(e=>o[e]=0;--e){const n=a[e];let i=o[n];iMath.max(e,m0(t,n)),0);return n[e]=r,r}var v0=class t{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=wJ(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const e=this.getScale();return new t({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return rH()}getImage(t){return rH()}getHitDetectionImage(){return rH()}getPixelRatio(t){return 1}getImageState(){return rH()}getImageSize(){return rH()}getOrigin(){return rH()}getSize(){return rH()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=wJ(t)}listenImageChange(t){rH()}load(){rH()}unlistenImageChange(t){rH()}ready(){return Promise.resolve()}},b0=class t extends v0{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?1:2,1===this.imageState_&&this.ready().then(()=>this.imageState_=2),this.render()}clone(){const e=this.getScale(),n=new t({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return n.setOpacity(this.getOpacity()),n}getAnchor(){const t=this.size_,e=this.getDisplacement(),n=this.getScaleArray();return[t[0]/2-e[0]/n[0],t[1]/2+e[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),n=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let r=ZQ.get(n,null)?.getImage(1);if(!r){const e=this.renderOptions_,i=Math.ceil(e.size*t),s=_Y(i,i);this.draw_(e,s,t),r=s.canvas;const o=new XQ(r,void 0,null,2,null);ZQ.set(n,null,o),createImageBitmap(r).then(t=>{o.setImage(t)})}return r}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,n){if(0===e||this.points_===1/0||"bevel"!==t&&"miter"!==t)return e;let r=this.radius,i=void 0===this.radius2_?r:this.radius2_;if(r{this.patternImage_=null}),0===e.getImageState()&&e.load(),1===e.getImageState()&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?sH(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:yJ(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}};function x0(t,e,n,r){return void 0!==n&&void 0!==r?[n/t,r/e]:void 0!==n?n/t:void 0!==r?r/e:1}var C0=class t extends v0{constructor(t){const e=void 0!==(t=t||{}).opacity?t.opacity:1,n=void 0!==t.rotation?t.rotation:0,r=void 0!==t.scale?t.scale:1,i=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:e,rotation:n,scale:r,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:i,declutterMode:t.declutterMode}),this.anchor_=void 0!==t.anchor?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==t.anchorOrigin?t.anchorOrigin:"top-left",this.anchorXUnits_=void 0!==t.anchorXUnits?t.anchorXUnits:"fraction",this.anchorYUnits_=void 0!==t.anchorYUnits?t.anchorYUnits:"fraction",this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;const s=void 0!==t.img?t.img:null;let o,a=t.src;if(PH(!(void 0!==a&&s),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!s||(a=s.src||sH(s)),PH(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),PH(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),"`width` or `height` cannot be provided together with `scale`"),void 0!==t.src?o=0:void 0!==s&&(o="complete"in s?s.complete?s.src?2:0:1:2),this.color_=void 0!==t.color?yJ(t.color):null,this.iconImage_=JQ(s,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},o,this.color_),this.offset_=void 0!==t.offset?t.offset:[0,0],this.offsetOrigin_=void 0!==t.offsetOrigin?t.offsetOrigin:"top-left",this.origin_=null,this.size_=void 0!==t.size?t.size:null,this.initialOptions_,void 0!==t.width||void 0!==t.height){let e,n;if(t.size)[e,n]=t.size;else{const r=this.getImage(1);if(r.width&&r.height)e=r.width,n=r.height;else if(r instanceof HTMLImageElement){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const n=this.iconImage_.getSize();this.setScale(x0(n[0],n[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(x0(e,n,t.width,t.height))}}clone(){let e,n,r;return this.initialOptions_?(n=this.initialOptions_.width,r=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new t({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:n,height:r,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const e=this.getSize();if("fraction"==this.anchorXUnits_||"fraction"==this.anchorYUnits_){if(!e)return null;t=this.anchor_.slice(),"fraction"==this.anchorXUnits_&&(t[0]*=e[0]),"fraction"==this.anchorYUnits_&&(t[1]*=e[1])}if("top-left"!=this.anchorOrigin_){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),"top-right"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[0]=-t[0]+e[0]),"bottom-left"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),n=this.getScaleArray();return[t[0]-e[0]/n[0],t[1]+e[1]/n[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){const e=t?yJ(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((t,n)=>t===e[n]))return;this.color_=e;const n=this.getSrc(),r=void 0!==n?null:this.getHitDetectionImage(),i=void 0!==n?0:this.iconImage_.getImageState();this.iconImage_=JQ(r,n,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},i,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if("top-left"!=this.offsetOrigin_){const e=this.getSize(),n=this.iconImage_.getSize();if(!e||!n)return null;t=t.slice(),"top-right"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[0]=n[0]-e[0]-t[0]),"bottom-left"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[1]=n[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=JQ(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},0,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();return this.size_?this.size_[0]*t[0]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(NW,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(NW,t)}ready(){return this.iconImage_.ready()}},S0=class t{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){const e=this.getColor();return new t({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}},k0=class t{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=T0,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let e=this.getGeometry();return e&&"object"==typeof e&&(e=e.clone()),new t({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=T0,this.geometry_=t}setZIndex(t){this.zIndex_=t}},E0=null;function R0(){if(!E0){const t=new _0({color:"rgba(255,255,255,0.4)"}),e=new S0({color:"#3399CC",width:1.25});E0=[new k0({image:new w0({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return E0}function T0(t){return t.getGeometry()}var L0=class t{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=wJ(void 0!==t.scale?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=void 0!==t.fill?t.fill:new _0({color:"#333"}),this.maxAngle_=void 0!==t.maxAngle?t.maxAngle:Math.PI/4,this.placement_=void 0!==t.placement?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=void 0!==t.stroke?t.stroke:null,this.offsetX_=void 0!==t.offsetX?t.offsetX:0,this.offsetY_=void 0!==t.offsetY?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=void 0===t.padding?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const e=this.getScale();return new t({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof _0?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=wJ(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}};function I0(){return!0}function P0(t,e){e=e??DJ();const n=t.length,r=new Array(n);for(let o=0;o0&&"string"==typeof p[0]?g=j0(t,"icon-color",e):f=J0(p,"icon-color"));const m=function(t,e){const n=t[e];if(void 0!==n){if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);return n}}(t,"icon-cross-origin"),y=function(t,e){const n=t[e];if(void 0!==n)return Z0(n,e)}(t,"icon-offset"),v=H0(t,"icon-offset-origin"),b=V0(t,"icon-width"),w={src:r,anchorOrigin:u,anchorXUnits:h,anchorYUnits:d,crossOrigin:m,offset:y,offsetOrigin:v,height:V0(t,"icon-height"),width:b,size:W0(t,"icon-size"),declutterMode:K0(t,"icon-declutter-mode")};let _=null;return function(t){if(_)g&&_.setColor(g(t));else{const e=g?g(t):f;_=new C0(void 0!==e?Object.assign({},w,{color:e}):Object.assign({},w))}return o&&_.setOpacity(o(t)),a&&_.setDisplacement(a(t)),l&&_.setRotation(l(t)),c&&_.setRotateWithView(c(t)),s&&_.setScale(s(t)),i&&_.setAnchor(i(t)),_}}(t,e):"shape-points"in t?function(t,e){const n="shape-",r="shape-points",i="shape-radius",s=X0(t[r],r);if(!(i in t))throw new Error(`Expected a number for ${i}`);const o=F0(t,i,e),a="number"==typeof t[i]?t[i]:5,l="shape-radius2",c=F0(t,l,e),u="number"==typeof t[l]?t[l]:void 0,h=A0(t,n,e),d=O0(t,n,e),p=q0(t,"shape-scale",e),f=B0(t,"shape-displacement",e),g=F0(t,"shape-rotation",e),m=z0(t,"shape-rotate-with-view",e),y=V0(t,"shape-angle"),v=K0(t,"shape-declutter-mode"),b=new b0({points:s,radius:a,radius2:u,angle:y,declutterMode:v});return function(t){return o&&b.setRadius(o(t)),c&&b.setRadius2(c(t)),h&&b.setFill(h(t)),d&&b.setStroke(d(t)),f&&b.setDisplacement(f(t)),g&&b.setRotation(g(t)),m&&b.setRotateWithView(m(t)),p&&b.setScale(p(t)),b}}(t,e):"circle-radius"in t?function(t,e){const n="circle-",r=A0(t,n,e),i=O0(t,n,e),s=F0(t,"circle-radius",e),o=q0(t,"circle-scale",e),a=B0(t,"circle-displacement",e),l=F0(t,"circle-rotation",e),c=z0(t,"circle-rotate-with-view",e),u=K0(t,"circle-declutter-mode"),h=new w0({radius:5,declutterMode:u});return function(t){return s&&h.setRadius(s(t)),r&&h.setFill(r(t)),i&&h.setStroke(i(t)),a&&h.setDisplacement(a(t)),l&&h.setRotation(l(t)),c&&h.setRotateWithView(c(t)),o&&h.setScale(o(t)),h}}(t,e):null}(t,e),o=F0(t,"z-index",e);if(!(n||r||i||s||PW(t)))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(t));const a=new k0;return function(t){let e=!0;if(n){const r=n(t);r&&(e=!1),a.setFill(r)}if(r){const n=r(t);n&&(e=!1),a.setStroke(n)}if(i){const n=i(t);n&&(e=!1),a.setText(n)}if(s){const n=s(t);n&&(e=!1),a.setImage(n)}return o&&a.setZIndex(o(t)),e?null:a}}function A0(t,e,n){let r;if(e+"fill-pattern-src"in t)r=function(t,e,n){const r=D0(t,e+"pattern-src",n),i=$0(t,e+"pattern-offset",n),s=$0(t,e+"pattern-size",n),o=j0(t,e+"color",n);return function(t){return{src:r(t),offset:i&&i(t),size:s&&s(t),color:o&&o(t)}}}(t,e+"fill-",n);else{if("none"===t[e+"fill-color"])return()=>null;r=j0(t,e+"fill-color",n)}if(!r)return null;const i=new _0;return function(t){const e=r(t);return e===tJ?null:(i.setColor(e),i)}}function O0(t,e,n){const r=F0(t,e+"stroke-width",n),i=j0(t,e+"stroke-color",n);if(!r&&!i)return null;const s=D0(t,e+"stroke-line-cap",n),o=D0(t,e+"stroke-line-join",n),a=U0(t,e+"stroke-line-dash",n),l=F0(t,e+"stroke-line-dash-offset",n),c=F0(t,e+"stroke-miter-limit",n),u=F0(t,e+"stroke-offset",n),h=new S0;return function(t){if(i){const e=i(t);if(e===tJ)return null;h.setColor(e)}if(r&&h.setWidth(r(t)),s){const e=s(t);if("butt"!==e&&"round"!==e&&"square"!==e)throw new Error("Expected butt, round, or square line cap");h.setLineCap(e)}if(o){const e=o(t);if("bevel"!==e&&"round"!==e&&"miter"!==e)throw new Error("Expected bevel, round, or miter line join");h.setLineJoin(e)}return a&&h.setLineDash(a(t)),l&&h.setLineDashOffset(l(t)),c&&h.setMiterLimit(c(t)),u&&h.setOffset(u(t)),h}}function N0(t,e){if(!(e in t))return;const n=t[e];return void 0===n?void 0:n}function F0(t,e,n){const r=N0(t,e);if(void 0===r)return;const i=qQ(r,CJ,n);return function(t){return X0(i(t),e)}}function D0(t,e,n){const r=N0(t,e);if(void 0===r)return null;const i=qQ(r,SJ,n);return function(t){return Y0(i(t),e)}}function z0(t,e,n){const r=N0(t,e);if(void 0===r)return null;const i=qQ(r,xJ,n);return function(t){const n=i(t);if("boolean"!=typeof n)throw new Error(`Expected a boolean for ${e}`);return n}}function j0(t,e,n){const r=N0(t,e);if(void 0===r)return null;const i=qQ(r,kJ,n);return function(t){return J0(i(t),e)}}function U0(t,e,n){const r=N0(t,e);if(void 0===r)return null;if(Array.isArray(r)&&(0===r.length||"string"!=typeof r[0])){const t=r.map((t,r)=>{if("number"==typeof t)return()=>t;const i=qQ(t,CJ,n);return function(t){return X0(i(t),`${e}[${r}]`)}});return function(e){const n=new Array(t.length);for(let r=0;r4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return n}function Q0(t,e){const n=Z0(t,e);if(2!==n.length)throw new Error(`Expected an array of two numbers for ${e}`);return n}var t1="renderOrder",e1=class extends AX{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=void 0!==t.renderBuffer?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=void 0!==t.updateWhileAnimating&&t.updateWhileAnimating,this.updateWhileInteracting_=void 0!==t.updateWhileInteracting&&t.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(t1)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const n=this.getDeclutter();n in t.declutter==0&&(t.declutter[n]=new zX(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(t1,t)}setStyle(t){this.style_=void 0===t?R0:t;const e=function(t){if(void 0===t)return R0;if(!t)return null;if("function"==typeof t)return t;if(t instanceof k0)return t;if(Array.isArray(t)&&0===t.length)return[];if(Array.isArray(t)&&t[0]instanceof k0){const e=t.length,n=new Array(e);for(let r=0;r=0;--r){const i=f[r],s=i.layer;if(s.hasRenderer()&&OX(i,c)&&o.call(a,s)){const r=s.getRenderer(),o=s.getSource();if(r&&o){const s=o.getWrapX()?d:t,a=u.bind(null,i.managed);y[0]=s[0]+p[b][0],y[1]=s[1]+p[b][1],l=r.forEachFeatureAtCoordinate(y,e,n,a,m)}if(l)return l}}if(0===m.length)return;const v=1/m.length;return m.forEach((t,e)=>t.distanceSq+=e*v),m.sort((t,e)=>t.distanceSq-e.distanceSq),m.some(t=>l=t.callback(t.feature,t.layer,t.geometry)),l}hasFeatureAtCoordinate(t,e,n,r,i,s){return void 0!==this.forEachFeatureAtCoordinate(t,e,n,r,ZW,this,i,s)}getMap(){return this.map_}renderFrame(t){rH()}scheduleExpireIconCache(t){ZQ.canExpireCache()&&t.postRenderFunctions.push(i1)}};function i1(){ZQ.expire()}var s1=class extends r1{constructor(t){super(t),this.fontChangeListenerKey_=MW(l0,LW,t.redrawText,t),this.element_=vH?TY():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=fY+" ol-layers";const n=t.getViewport();n&&n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const n=this.getMap();if(n.hasListener(t)){const r=new n1(t,void 0,e);n.dispatchEvent(r)}}disposeInternal(){OW(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t)return void(this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1));this.calculateMatrices2D(t),this.dispatchRenderEvent(PX,t);const e=t.layerStatesArray.sort((t,e)=>t.zIndex-e.zIndex);e.some(t=>t.layer instanceof e1&&t.layer.getDeclutter())&&(t.declutter={});const n=t.viewState;this.children_.length=0;const r=this.getMap().getTargetElement();let i;LY(r)&&(i=r.getContext("2d"),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,r.width,r.height));const s=[];let o=i?r:null;for(let a=0,l=e.length;a0)&&(i.fillStyle=e,i.fillRect(0,0,i.canvas.width,i.canvas.height)),!LY(t)||0===t.width)continue;i.save();const n=a.style.opacity||t.style.opacity;i.globalAlpha=""===n?1:Number(n);const r=t.style.transform;if(r)i.transform(...uZ(r));else{const e=parseFloat(t.style.width)/t.width,n=parseFloat(t.style.height)/t.height;i.transform(e,0,0,n,0,0)}i.drawImage(t,0,0),i.restore()}this.dispatchRenderEvent("postcompose",t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let n=e.length-1;n>=0;--n){const r=e[n],i=r.layer;i.getDeclutter()&&i.renderDeclutter(t,r)}e.forEach(e=>e.layer.renderDeferred(t))}}};function o1(t){t instanceof AX?t.setMapInternal(null):t instanceof TX&&t.getLayers().forEach(o1)}function a1(t,e){if(t instanceof AX)t.setMapInternal(e);else if(t instanceof TX){const n=t.getLayers().getArray();for(let t=0,r=n.length;tthis.updateSize())),this.controls=e.controls||(vH?new uH:OY()),this.interactions=e.interactions||(vH?new uH:pX({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new OH(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(RH,this.handleLayerGroupChanged_),this.addChangeListener(IH,this.handleViewChanged_),this.addChangeListener(TH,this.handleSizeChanged_),this.addChangeListener(LH,this.handleTargetChanged_),this.setProperties(e.values);const n=this;!t.view||t.view instanceof lY||t.view.then(function(t){n.setView(new lY(t))}),this.controls.addEventListener(RW,t=>{t.element.setMap(this)}),this.controls.addEventListener(TW,t=>{t.element.setMap(null)}),this.interactions.addEventListener(RW,t=>{t.element.setMap(this)}),this.interactions.addEventListener(TW,t=>{t.element.setMap(null)}),this.overlays_.addEventListener(RW,t=>{this.addOverlayInternal_(t.element)}),this.overlays_.addEventListener(TW,t=>{const e=t.element.getId();void 0!==e&&delete this.overlayIdIndex_[e.toString()],t.element.setMap(null)}),this.controls.forEach(t=>{t.setMap(this)}),this.interactions.forEach(t=>{t.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){a1(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();void 0!==e&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,n){if(!this.frameState_||!this.renderer_)return;const r=this.getCoordinateFromPixelInternal(t),i=void 0!==(n=void 0!==n?n:{}).hitTolerance?n.hitTolerance:0,s=void 0!==n.layerFilter?n.layerFilter:ZW,o=!1!==n.checkWrapped;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,i,o,e,null,s,null)}getFeaturesAtPixel(t,e){const n=[];return this.forEachFeatureAtPixel(t,function(t){n.push(t)},e),n}getAllLayers(){const t=[];return function e(n){n.forEach(function(n){n instanceof TX?e(n.getLayers()):t.push(n)})}(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const n=this.getCoordinateFromPixelInternal(t),r=void 0!==(e=void 0!==e?e:{}).layerFilter?e.layerFilter:ZW,i=void 0!==e.hitTolerance?e.hitTolerance:0,s=!1!==e.checkWrapped;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,i,s,r,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const e=this.viewport_.getBoundingClientRect(),n=this.getSize(),r=e.width/n[0],i=e.height/n[1],s="changedTouches"in t?t.changedTouches[0]:t;return[(s.clientX-e.left)/r,(s.clientY-e.top)/i]}getTarget(){return this.get(LH)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return YK(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?sZ(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return void 0!==e?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(RH)}setLayers(t){const e=this.getLayerGroup();if(t instanceof uH)return void e.setLayers(t);const n=e.getLayers();n.clear(),n.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,n=t.length;e=0;n--){const r=e[n];if(r.getMap()===this&&r.getActive()&&this.getTargetElement()&&(!r.handleEvent(t)||t.propagationStopped))break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let n=this.maxTilesLoading_,r=n;const i=t?t.viewHints:void 0,s=!!i&&(i[0]||i[1]);if(s){const e=Date.now()-t.time>8;n=e?0:8,r=e?0:2}e.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new EX("removelayer",e)),this.set(RH,t)}setSize(t){this.set(TH,t)}setTarget(t){this.set(LH,t)}setView(t){if(!t||t instanceof lY)return void this.set(IH,t);this.set(IH,new lY);const e=this;t.then(function(t){e.setView(new lY(t))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,r;if(LY(t)){const e=t.getContext("2d").getTransform();n=t.width/e.a,r=t.height/e.d}else{const e=getComputedStyle(t);n=t.offsetWidth-parseFloat(e.borderLeftWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderRightWidth),r=t.offsetHeight-parseFloat(e.borderTopWidth)-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderBottomWidth)}isNaN(n)||isNaN(r)||(e=[Math.max(0,n),Math.max(0,r)],!bJ(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&BG("No map visible because the map container's width or height are 0."))}const n=this.getSize();!e||n&&KW(e,n)||(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}},c1="element",u1="map",h1="offset",d1="position",p1="positioning",f1=class extends aH{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=void 0===t.insertFirst||t.insertFirst,this.stopEvent=void 0===t.stopEvent||t.stopEvent,this.element=document.createElement("div"),this.element.className=void 0!==t.className?t.className:"ol-overlay-container ol-selectable",this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=!0===t.autoPan?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(c1,this.handleElementChanged),this.addChangeListener(u1,this.handleMapChanged),this.addChangeListener(h1,this.handleOffsetChanged),this.addChangeListener(d1,this.handlePositionChanged),this.addChangeListener(p1,this.handlePositioningChanged),void 0!==t.element&&this.setElement(t.element),this.setOffset(void 0!==t.offset?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),void 0!==t.position&&this.setPosition(t.position)}getElement(){return this.get(c1)}getId(){return this.id}getMap(){return this.get(u1)||null}getOffset(){return this.get(h1)}getPosition(){return this.get(d1)}getPositioning(){return this.get(p1)}handleElementChanged(){RY(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),OW(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=MW(t,SH,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(c1,t)}setMap(t){this.set(u1,t)}setOffset(t){this.set(h1,t)}setPosition(t){this.set(d1,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(d1))return;const n=this.getRect(e.getTargetElement(),e.getSize()),r=this.getElement(),i=this.getRect(r,[SY(r),kY(r)]),s=void 0===(t=t||{}).margin?20:t.margin;if(!tG(n,i)){const r=i[0]-n[0],o=n[2]-i[2],a=i[1]-n[1],l=n[3]-i[3],c=[0,0];if(r<0?c[0]=r-s:o<0&&(c[0]=Math.abs(o)+s),a<0?c[1]=a-s:l<0&&(c[1]=Math.abs(l)+s),0!==c[0]||0!==c[1]){const n=e.getView().getCenterInternal(),r=e.getPixelFromCoordinateInternal(n);if(!r)return;const i=[r[0]+c[0],r[1]+c[1]],s=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(i),duration:s.duration,easing:s.easing})}}}getRect(t,e){const n=t.getBoundingClientRect(),r=n.left+window.pageXOffset,i=n.top+window.pageYOffset;return[r,i,r+e[0],i+e[1]]}setPositioning(t){this.set(p1,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e)return void this.setVisible(!1);const n=t.getPixelFromCoordinate(e),r=t.getSize();this.updateRenderedPosition(n,r)}updateRenderedPosition(t,e){const n=this.element.style,r=this.getOffset(),i=this.getPositioning();this.setVisible(!0);let s="0%",o="0%";"bottom-right"==i||"center-right"==i||"top-right"==i?s="-100%":"bottom-center"!=i&&"center-center"!=i&&"top-center"!=i||(s="-50%"),"bottom-left"==i||"bottom-center"==i||"bottom-right"==i?o="-100%":"center-left"!=i&&"center-center"!=i&&"center-right"!=i||(o="-50%");const a=`translate(${s}, ${o}) translate(${t[0]+r[0]}px, ${t[1]+r[1]}px)`;this.rendered.transform_!=a&&(this.rendered.transform_=a,n.transform=a)}getOptions(){return this.options}},g1=class t extends aH{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if("function"==typeof t.getSimplifiedGeometry){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const e=new t,n=this.geometryName_;e.setGeometryName(n);const r=this.getPropertiesInternal();if(r){const t=this.getGeometry();for(const i in r)i===n&&t?e.set(i,t.clone()):e.set(i,r[i],!0)}const i=this.getStyle();return i&&e.setStyle(i),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(OW(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=MW(t,NW,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?function(t){if("function"==typeof t)return t;let e;return Array.isArray(t)?e=t:(PH("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[t]),function(){return e}}(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}};function m1(t,e,n,r,i,s,o){let a,l;const c=(n-e)/r;if(1===c)a=e;else if(2===c)a=e,l=i;else if(0!==c){let s=t[e],o=t[e+1],c=0;const u=[0];for(let i=e+r;i>1),i=+n(t[r],e),i<0?s=r+1:(o=r,a=!i);return a?s:~s}(u,h);d<0?(l=(h-u[-d-2])/(u[-d-1]-u[-d-2]),a=e+(-d-2)*r):a=e+d*r}o=o>1?o:2,s=s||new Array(o);for(let u=0;u>1;ia&&(this.instructions.push([4,a,c,t,n,LZ,i]),this.hitDetectionInstructions.push([4,a,c,t,r||n,LZ,i]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),c=this.coordinates.length,this.instructions.push([4,a,c,t,n,void 0,i]),this.hitDetectionInstructions.push([4,a,c,t,r||n,void 0,i])}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[0,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[0,e,0,t,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;let e;t.reverse();const n=t.length;let r,i,s=-1;for(e=0;ethis.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){const n=this.state;this.fillStyleToState(t,n),this.strokeStyleToState(e,n)}createFill(t){const e=t.fillStyle,n=[10,e];return"string"!=typeof e&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[k1,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const n=t.fillStyle;(void 0!==n&&"string"!=typeof n||t.currentFillStyle!=n)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=n)}updateStrokeStyle(t,e){const n=t.strokeStyle,r=t.lineCap,i=t.lineDash,s=t.lineDashOffset,o=t.lineJoin,a=t.lineWidth,l=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=n||t.currentLineCap!=r||i!=t.currentLineDash&&!KW(t.currentLineDash,i)||t.currentLineDashOffset!=s||t.currentLineJoin!=o||t.currentLineWidth!=a||t.currentMiterLimit!=l||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=n,t.currentLineCap=r,t.currentLineDash=i,t.currentLineDashOffset=s,t.currentLineJoin=o,t.currentLineWidth=a,t.currentMiterLimit=l,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[7,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=XH(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;YH(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},P1=class extends I1{constructor(t,e,n,r){super(t,e,n,r)}drawFlatCoordinatess_(t,e,n,r,i){const s=this.state,o=void 0!==s.fillStyle,a=void 0!==s.strokeStyle,l=n.length;this.instructions.push(T1),this.hitDetectionInstructions.push(T1);for(let c=0;cthis.drawCircle(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==r.fillStyle&&this.hitDetectionInstructions.push([10,e0]),void 0!==r.strokeStyle&&this.hitDetectionInstructions.push([k1,s0,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,r0,0]);const a=t.getFlatCoordinates(),l=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const u=[2,c,o];this.instructions.push(T1,u),this.hitDetectionInstructions.push(T1,u),void 0!==r.fillStyle&&(this.instructions.push(E1),this.hitDetectionInstructions.push(E1)),void 0!==r.strokeStyle&&(this.instructions.push(R1),this.hitDetectionInstructions.push(R1)),this.endGeometry(e)}drawPolygon(t,e,n){const r=this.state,i=r.fillStyle,s=r.strokeStyle,o=r.strokeOffset;if(void 0===i&&void 0===s)return;if(this.handleStrokeOffset_(()=>this.drawPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==r.fillStyle&&this.hitDetectionInstructions.push([10,e0]),void 0!==r.strokeStyle&&this.hitDetectionInstructions.push([k1,s0,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,r0,0]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(l,0,a,c,o),this.endGeometry(e)}drawMultiPolygon(t,e,n){const r=this.state,i=r.fillStyle,s=r.strokeStyle,o=r.strokeOffset;if(void 0===i&&void 0===s)return;if(this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==r.fillStyle&&this.hitDetectionInstructions.push([10,e0]),void 0!==r.strokeStyle&&this.hitDetectionInstructions.push([k1,s0,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,r0,0]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),c=t.getStride();let u=0;for(let h=0,d=a.length;h0&&void 0!==n&&void 0!==r&&(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=r,e.strokeOffset=i,t(),e.fillStyle=n,!0)}},M1=0,A1=1;function O1(t,e,n,r,i,s,o,a){const l=o-i,c=a-s;let u=0,h=1;if(0===l){if(in)return!1}else{let e=(t-i)/l,r=(n-i)/l;if(e>r){const t=e;e=r,r=t}if(e>u&&(u=e),rh)return!1}if(0===c){if(sr)return!1}else{let t=(e-s)/c,n=(r-s)/c;if(t>n){const e=t;t=n,n=e}if(t>u&&(u=t),nh)return!1}return M1=u,A1=h,!0}function N1(t,e,n,r,i){const s=[];let o=n,a=0,l=e.slice(n,2);for(;a=t){const e=(t-a+h)/h,d=$H(n,c,e),p=$H(r,u,e);l.push(d,p),s.push(l),l=[d,p],a==t&&(o+=i),a=0}else if(a0&&s.push(l),s}function F1(t,e,n,r,i){let s,o,a,l,c,u,h,d,p,f,g=n,m=n,y=0,v=0,b=n;for(o=n;ot&&(v>y&&(y=v,g=b,m=o),v=0,b=o-i)),a=l,h=p,d=f),c=n,u=r}return v+=l,v>y?[b,o]:[g,m]}var D1,z1={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},j1={Circle:P1,Default:I1,Image:class extends I1{constructor(t,e,n,r){super(t,e,n,r),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,n){if(!this.image_||this.maxExtent&&!QH(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,n);const r=t.getFlatCoordinates(),i=t.getStride(),s=this.coordinates.length,o=this.appendFlatPointCoordinates(r,i);this.instructions.push([6,s,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([6,s,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,n){if(!this.image_)return;this.beginGeometry(t,e,n);const r=t.getFlatCoordinates(),i=[];for(let a=0,l=r.length;a{const r=o[2*(t+n)]===c[n*u]&&o[2*(t+n)+1]===c[n*u+1];return r||--t,r})}this.saveTextStates_();const h=s.backgroundFill?this.createFill(this.fillStyleToState(s.backgroundFill)):null,d=s.backgroundStroke?this.createStroke(this.strokeStyleToState(s.backgroundStroke)):null;this.beginGeometry(t,e,n);let p=s.padding;if(p!=a0&&(s.scale[0]<0||s.scale[1]<0)){let t=s.padding[0],e=s.padding[1],n=s.padding[2],r=s.padding[3];s.scale[0]<0&&(e=-e,r=-r),s.scale[1]<0&&(t=-t,n=-n),p=[t,e,n,r]}const f=this.pixelRatio;this.instructions.push([6,a,i,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,p==a0?a0:p.map(function(t){return t*f}),h,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,r]);const g=1/f,m=h?h.slice(0):null;m&&(m[1]=e0),this.hitDetectionInstructions.push([6,a,i,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[g,g],NaN,this.declutterMode_,this.declutterImageWithText_,p,m,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?e0:this.fillKey_,this.textOffsetX_,this.textOffsetY_,r]),this.endGeometry(e)}else{const r=t.getExtent();if(!EG(this.maxExtent,r))return;let i;if(c=t.getFlatCoordinates(),"LineString"==l)i=[c.length];else if("MultiLineString"==l)i=t.getEnds();else if("Polygon"==l)i=t.getEnds().slice(0,1);else if("MultiPolygon"==l){const e=t.getEndss();i=[];for(let t=0,n=e.length;t0?l:2*Math.PI-l}([t,e],[n,r],[i,s]);if(Math.cos(d)>.998)return[t+u*o,e+h*o];const p=Math.cos(d/2),f=Math.sin(d/2);return[t+1/f*(f*a+p*l)*o,e+1/f*(-p*a+f*l)*o]}function q1(t,e,n=!1){for(let r=0,i=t.length-2;rr+e;s-=e){const n=t[r],i=t[r+1],o=t[r+e],a=t[r+e+1],l=t[s],c=t[s+1],u=t[s+e],h=t[s+e+1],d=(h-c)*(o-n)-(u-l)*(a-i);if(0===d)continue;const p=((u-l)*(i-c)-(h-c)*(n-l))/d,f=((o-n)*(i-c)-(a-i)*(n-l))/d;if(p>0&&p<1&&f>0&&f<1){const l=n+p*(o-n),c=i+p*(a-i);t[r+e]=l,t[r+e+1]=c,t.splice(r+2*e,s-r-e);break}}return t}function V1(t,e,n,r,i,s,o,a,l,c,u,h,d=!0){let p=t[e],f=t[e+1],g=0,m=0,y=0,v=0;function b(){g=p,m=f,p=t[e+=r],f=t[e+1],v+=y,y=Math.sqrt((p-g)*(p-g)+(f-m)*(f-m))}do{b()}while(et[2]}else T=_>E;const L=Math.PI,I=[],P=C+r===e;let M;if(y=0,v=S,p=t[e=C],f=t[e+1],P)return b(),M=Math.atan2(f-m,p-g),T&&(M+=M>0?-L:L),I[0]=[(E+_)/2,(R+x)/2,(k-s)/2,M,i],I;i=i.replace(/\n/g," ");const A=Array.from((D1||(D1=new Intl.Segmenter(void 0,{granularity:"grapheme"})),D1).segment(i),t=>t.segment);for(let O=0,N=A.length;O0?-L:L),void 0!==M){let e=t-M;if(e+=e>L?-2*L:e<-L?2*L:0,Math.abs(e)>o)return null}M=t;const i=O;let h=0;for(;O{if("function"==typeof t[e])return this.pendingMethod_=e,this.pushMethodArgs_},set:(t,e,n)=>(this.push_(e,n),!0)})}push_(...t){const e=this.instructions_,n=this.zIndex+this.offset_;e[n]||(e[n]=[]),e[n].push(...t)}pushMethodArgs_=(...t)=>{this.push_(this.pendingMethod_,t)};pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let n=0,r=e.length;n0&&t.push("\n",""),t.push(e,""),t}function e2(t,e,n){return n%2==0&&(t+=e),t}var n2=class{constructor(t,e,n,r,i){this.overlaps=n,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=eZ(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=i?new W1:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,n,r){const i=t+e+n+r;if(this.labels_[i])return this.labels_[i];const s=r?this.strokeStates[r]:null,o=n?this.fillStates[n]:null,a=this.textStates[e],l=this.pixelRatio,c=[a.scale[0]*l,a.scale[1]*l],u=a.justify?z1[a.justify]:Q1(Array.isArray(t)?t[0]:t,a.textAlign||"center"),h=r&&s.lineWidth?s.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(t2,[]),{width:p,height:f,widths:g,heights:m,lineWidths:y}=function(t,e){const n=[],r=[],i=[];let s=0,o=0,a=0,l=0;for(let c=0,u=e.length;c<=u;c+=2){const h=e[c];if("\n"===h||c===u){s=Math.max(s,o),i.push(o),o=0,a+=l,l=0;continue}const d=e[c+1]||t.font,p=m0(d,h);n.push(p),o+=p;const f=f0(d);r.push(f),l=Math.max(l,f)}return{width:s,height:a,widths:n,heights:r,lineWidths:i}}(a,d),v=p+h,b=[],w=(v+2)*c[0],_=(f+h)*c[1],x={width:w<0?Math.floor(w):Math.ceil(w),height:_<0?Math.floor(_):Math.ceil(_),contextInstructions:b};1==c[0]&&1==c[1]||b.push("scale",c),r&&(b.push("strokeStyle",s.strokeStyle),b.push("lineWidth",h),b.push("lineCap",s.lineCap),b.push("lineJoin",s.lineJoin),b.push("miterLimit",s.miterLimit),b.push("setLineDash",[s.lineDash]),b.push("lineDashOffset",s.lineDashOffset)),n&&b.push("fillStyle",o.fillStyle),b.push("textBaseline","middle"),b.push("textAlign","center");const C=.5-u;let S=u*v+C*h;const k=[],E=[];let R,T=0,L=0,I=0,P=0;for(let M=0,A=d.length;Mt?t-l:i,b=s+c>e?e-c:s,w=p[3]+v*h[0]+p[1],_=p[0]+b*h[1]+p[2],x=m-p[3],C=y-p[0];let S;return(f||0!==u)&&(G1[0]=x,Y1[0]=x,G1[1]=C,K1[1]=C,K1[0]=x+w,Z1[0]=K1[0],Z1[1]=C+_,Y1[1]=Z1[1]),0!==u?(S=aZ(eZ(),n,r,1,1,u,-n,-r),sZ(S,G1),sZ(S,K1),sZ(S,Z1),sZ(S,Y1),rG(Math.min(G1[0],K1[0],Z1[0],Y1[0]),Math.min(G1[1],K1[1],Z1[1],Y1[1]),Math.max(G1[0],K1[0],Z1[0],Y1[0]),Math.max(G1[1],K1[1],Z1[1],Y1[1]),H1)):rG(Math.min(x,x+w),Math.min(C,C+_),Math.max(x,x+w),Math.max(C,C+_),H1),d&&(m=Math.round(m),y=Math.round(y)),{drawImageX:m,drawImageY:y,drawImageW:v,drawImageH:b,originX:l,originY:c,declutterBox:{minX:H1[0],minY:H1[1],maxX:H1[2],maxY:H1[3],value:g},canvasTransform:S,scale:h}}replayImageOrLabel_(t,e,n,r,i,s,o){const a=!(!s&&!o),l=r.declutterBox,c=o?o[2]*r.scale[0]/2:0;return l.minX-c<=e[0]&&l.maxX+c>=0&&l.minY-c<=e[1]&&l.maxY+c>=0&&(a&&this.replayTextBackground_(t,G1,K1,Z1,Y1,s,o),function(t,e,n,r,i,s,o,a,l,c,u){t.save(),1!==n&&(void 0===t.globalAlpha?t.globalAlpha=t=>t.globalAlpha*=n:t.globalAlpha*=n),e&&t.transform.apply(t,e),r.contextInstructions?(t.translate(l,c),t.scale(u[0],u[1]),function(t,e){const n=t.contextInstructions;for(let r=0,i=n.length;rF&&(this.fill_(t),I=0),P>F&&(t.stroke(),P=0),I||P||(t.beginPath(),_=NaN,x=NaN),++d;break;case 2:g=n[1],b=n[2]??0;const r=c[g],u=c[g+1],h=c[g+2]-b-r,p=c[g+3]-b-u,B=Math.sqrt(h*h+p*p);t.moveTo(r+B,u),t.arc(r,u,B,0,2*Math.PI,!0),++d;break;case 3:t.closePath(),++d;break;case 4:g=n[1],f=n[2];const $=n[3],q=n[4],V=n[5];N.geometry=$,N.feature=D,d in M||(M[d]=[]);const W=M[d];V?V(c,g,f,2,W):(W[0]=c[g],W[1]=c[g+1],W.length=2),l&&(l.zIndex=n[6]),q(W,N),++d;break;case 6:g=n[1],f=n[2],k=n[3],y=n[4],v=n[5];let H=n[6];const G=n[7],K=n[8],Z=n[9],Y=n[10];let X=n[11];const J=n[12];let Q=n[13];w=n[14]||"declutter";const tt=n[15];if(!k&&n.length>=20){E=n[19],R=n[20],T=n[21],L=n[22];const t=this.drawLabelWithPointPlacement_(E,R,T,L);k=t.label,n[3]=k;const e=n[23];y=(t.anchorX-e)*this.pixelRatio,n[4]=y;const r=n[24];v=(t.anchorY-r)*this.pixelRatio,n[5]=v,H=k.height,n[6]=H,Q=k.width,n[13]=Q}let et,nt,rt,it;n.length>25&&(et=n[25]),n.length>17?(nt=n[16],rt=n[17],it=n[18]):(nt=a0,rt=null,it=null),Y&&O?X+=A:Y||O||(X-=A);let st=0;for(;g!i2.includes(t)),o2=!1,a2=!1,l2=class{constructor(t,e,n,r,i,s,o){this.maxExtent_=t,this.overlaps_=r,this.pixelRatio_=n,this.resolution_=e,this.renderBuffer_=s,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=eZ(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(i,o)}clip(t,e){const n=this.getClipCoords(e);t.beginPath(),t.moveTo(n[0],n[1]),t.lineTo(n[2],n[3]),t.lineTo(n[4],n[5]),t.lineTo(n[6],n[7]),t.clip()}createExecutors_(t,e){for(const n in t){let r=this.executorsByZIndex_[n];void 0===r&&(r={},this.executorsByZIndex_[n]=r);const i=t[n];for(const t in i){const n=i[t];r[t]=new n2(this.resolution_,this.pixelRatio_,this.overlaps_,n,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const n=this.executorsByZIndex_[e];for(let e=0,r=t.length;e{const n=_Y(1,1,null,{willReadFrequently:e});let r=0;const i=performance.now();for(;performance.now()-i<50;++r)n.fillStyle=`rgba(255,0,${r%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return t=r>t?r:t,r};o2={[e(!0)]:!0,[e(!1)]:!1,[e(void 0)]:void 0}[t],a2=!0}();const o=2*(r=Math.round(r))+1,a=aZ(this.hitDetectionTransform_,r+.5,r+.5,1/e,-1/e,-n,-t[0],-t[1]),l=!this.hitDetectionContext_;l&&(this.hitDetectionContext_=_Y(o,o,null,{willReadFrequently:o2}));const c=this.hitDetectionContext_;let u;c.canvas.width!==o||c.canvas.height!==o?(c.canvas.width=o,c.canvas.height=o):l||c.clearRect(0,0,o,o),void 0!==this.renderBuffer_&&(u=[1/0,1/0,-1/0,-1/0],cG(u,t),YH(u,e*(this.renderBuffer_+r),u));const h=function(t){if(void 0!==c2[t])return c2[t];const e=2*t+1,n=t*t,r=new Array(n+1);for(let s=0;s<=t;++s)for(let i=0;i<=t;++i){const o=s*s+i*i;if(o>n)break;let a=r[o];a||(a=[],r[o]=a),a.push(4*((t+s)*e+(t+i))+3),s>0&&a.push(4*((t-s)*e+(t+i))+3),i>0&&(a.push(4*((t+s)*e+(t-i))+3),s>0&&a.push(4*((t-s)*e+(t-i))+3))}const i=[];for(let s=0,o=r.length;s0){if(!s||"none"===n||"Image"!==d&&"Text"!==d||s.includes(t)){const n=(h[l]-3)/4,s=r-n%o,a=r-(n/o|0),c=i(t,e,s*s+a*a);if(c)return c}c.clearRect(0,0,o,o);break}}const f=Object.keys(this.executorsByZIndex_).map(Number);let g,m,y,v,b;for(f.sort(qW),g=f.length-1;g>=0;--g){const t=f[g].toString();for(y=this.executorsByZIndex_[t],m=r2.length-1;m>=0;--m)if(d=r2[m],v=y[d],void 0!==v&&(b=v.executeHitDetection(c,a,n,p,u),b))return b}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const n=e[0],r=e[1],i=e[2],s=e[3],o=[n,r,n,s,i,s,i,r];return hZ(o,0,8,2,t,o),o}isEmpty(){return PW(this.executorsByZIndex_)}execute(t,e,n,r,i,s,o){const a=Object.keys(this.executorsByZIndex_).map(Number);a.sort(o?VW:qW),s=s||r2;const l=r2.length;for(let c=0,u=a.length;cp.execute(t,e,n,r,i,o)):p.execute(h,e,n,r,i,o),d&&h.restore(),s){s.offset();const t=a[c]*l+r2.indexOf(u);this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(s)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(qW);for(let n=0,r=e.length;n{t.draw(this.renderedContext_),t.clear()}),t[e[n]].length=0}},c2={},u2=class extends S1{constructor(t,e,n,r,i,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=n,this.transform_=r,this.transformRotation_=r?qH(Math.atan2(r[1],r[0]),10):0,this.viewRotation_=i,this.squaredTolerance_=s,this.userTransform_=o,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=eZ()}drawImages_(t,e,n,r){if(!this.image_)return;const i=hZ(t,e,n,r,this.transform_,this.pixelCoordinates_),s=this.context_,o=this.tmpLocalTransform_,a=s.globalAlpha;1!=this.imageOpacity_&&(s.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;0===this.transformRotation_&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let c=0,u=i.length;c0){const t=a.length,e=i||Math.abs(a[0]-a[t-2])<1e-6&&Math.abs(a[1]-a[t-1])<1e-6;a=B1(a,0,t,2,s,e,a),q1(a,2,e)}o.moveTo(a[0],a[1]);let l=a.length;i&&(l-=2);for(let c=2;ct*this.pixelRatio_),lineDashOffset:(i||0)*this.pixelRatio_,lineJoin:void 0!==s?s:i0,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:QQ(t||s0),strokeOffset:(c??0)*this.pixelRatio_}}else this.strokeState_=null}setImageStyle(t){let e;if(!t||!(e=t.getSize()))return void(this.image_=null);const n=t.getPixelRatio(this.pixelRatio_),r=t.getAnchor(),i=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*n,this.imageAnchorY_=r[1]*n,this.imageHeight_=e[1]*n,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=i[0],this.imageOriginY_=i[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const s=t.getScaleArray();this.imageScale_=[s[0]*this.pixelRatio_/n,s[1]*this.pixelRatio_/n],this.imageWidth_=e[0]*n}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:QQ(t||e0)}}else this.textFillState_=null;const n=t.getStroke();if(n){const t=n.getColor(),e=n.getLineCap(),r=n.getLineDash(),i=n.getLineDashOffset(),s=n.getLineJoin(),o=n.getWidth(),a=n.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:n0,lineDash:r||r0,lineDashOffset:i||0,lineJoin:void 0!==s?s:i0,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:10,strokeStyle:QQ(t||s0)}}else this.textStrokeState_=null;const r=t.getFont(),i=t.getOffsetX(),s=t.getOffsetY(),o=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),h=t.getTextBaseline();this.textState_={font:void 0!==r?r:"10px sans-serif",textAlign:void 0!==u?u:o0,textBaseline:void 0!==h?h:"middle"},this.text_=void 0!==c?Array.isArray(c)?c.reduce((t,e,n)=>t+(n%2?" ":e),""):c:"",this.textOffsetX_=void 0!==i?this.pixelRatio_*i:0,this.textOffsetY_=void 0!==s?this.pixelRatio_*s:0,this.textRotateWithView_=void 0!==o&&o,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}},h2=.5;function d2(t,e,n,r,i,s,o,a,l){const c=i,u=_Y(t[0]*h2,t[1]*h2);u.imageSmoothingEnabled=!1;const h=u.canvas,d=new u2(u,h2,i,null,o,a,l?WK(null,l):null),p=n.length,f=Math.floor(16777215/p),g={};for(let y=1;y<=p;++y){const t=n[y-1],e=t.getStyleFunction()||r;if(!e)continue;let i=e(t,s);if(!i)continue;Array.isArray(i)||(i=[i]);const o=(y*f).toString(16).padStart(7,"#00000");for(let n=0,r=i.length;n0;return h&&Promise.all(l).then(()=>i(null)),function(t,e,n,r,i,s,o){const a=n.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(r,i);n.getRenderer()?b2(t,l,n,e,o):(0,f2[l.getType()])(t,l,n,e,o,s)}(t,e,n,r,s,o,a),h}function b2(t,e,n,r,i){if("GeometryCollection"==e.getType()){const s=e.getGeometries();for(let e=0,o=s.length;ethis.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}updateStaleKeys(t){this.renderedSourceKey_?this.renderedSourceKey_!==t&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=t):this.renderedSourceKey_=t}getFeatures(t){return rH()}getData(t){return null}prepareFrame(t){return rH()}renderFrame(t,e){return rH()}forEachFeatureAtCoordinate(t,e,n,r,i){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;2!==e.getState()&&3!==e.getState()||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return 2!=e&&3!=e&&t.addEventListener(NW,this.boundHandleImageChange_),0==e&&(t.load(),e=t.getState()),2==e}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},_2=[],x2=null,C2=class extends w2{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=eZ(),this.pixelTransform=eZ(),this.inversePixelTransform=eZ(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,n){let r;x2||(x2=_Y(1,1,void 0,{willReadFrequently:!0})),x2.clearRect(0,0,1,1);try{x2.drawImage(t,e,n,1,1,0,0,1,1),r=x2.getImageData(0,0,1,1).data}catch{return x2=null,null}return r}getBackground(t){let e=this.getLayer().getBackground();return"function"==typeof e&&(e=e(t.viewState.resolution)),e||void 0}useContainer(t,e,n,r,i){if(LY(t)&&0===this.pixelTransform[1]&&0===this.pixelTransform[2]&&0===this.pixelTransform[4]&&0===this.pixelTransform[5]&&t.width===r&&t.height===i){const e=t,r=e.getContext("2d");if(r)return this.container=t,this.context=r,this.containerReused=!0,void(n&&(r.fillStyle=n,r.fillRect(0,0,e.width,e.height)))}const s=this.getLayer().getClassName();let o,a;if(t&&t.className===s&&(!n||t&&t.style.backgroundColor&&KW(yJ(t.style.backgroundColor),yJ(n)))){const e=t.firstElementChild;LY(e)&&(a=e.getContext("2d"))}if(a&&function(t,e){const n=uZ(t),r=uZ(e);for(let i=0;i<6;++i)if(0!==Math.round((n[i]-r[i])*cZ[i]))return!1;return!0}(a.canvas.style.transform,e)?(this.container=t,this.context=a,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){o=vH?TY():document.createElement("div"),o.className=s;let t=o.style;t.position="absolute",t.width="100%",t.height="100%",a=_Y();const e=a.canvas;o.appendChild(e),t=e.style,t.position="absolute",t.left="0",t.transformOrigin="top left",this.container=o,this.context=a}this.containerReused||!n||this.container.style.backgroundColor||(this.container.style.backgroundColor=n)}clipUnrotated(t,e,n){const r=CG(n),i=SG(n),s=gG(n),o=fG(n);sZ(e.coordinateToPixelTransform,r),sZ(e.coordinateToPixelTransform,i),sZ(e.coordinateToPixelTransform,s),sZ(e.coordinateToPixelTransform,o);const a=this.inversePixelTransform;sZ(a,r),sZ(a,i),sZ(a,s),sZ(a,o),t.save(),t.beginPath(),t.moveTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(i[0]),Math.round(i[1])),t.lineTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.clip()}prepareContainer(t,e){const n=t.extent,r=t.viewState.resolution,i=t.viewState.rotation,s=t.pixelRatio,o=Math.round(kG(n)/r*s),a=Math.round(wG(n)/r*s);aZ(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/s,1/s,i,-o/2,-a/2),lZ(this.inversePixelTransform,this.pixelTransform);const l="matrix("+this.pixelTransform.join(", ")+")",c=this.getBackground(t);if(this.useContainer(e,l,c,o,a),!this.containerReused){const t=this.context.canvas;t.width!=o||t.height!=a?(t.width=o,t.height=a):this.context.clearRect(0,0,o,a),l!==t.style.transform&&(t.style.transform=l)}}dispatchRenderEvent_(t,e,n){const r=this.getLayer();if(r.hasListener(t)){const i=new n1(t,this.inversePixelTransform,n,e);r.dispatchEvent(i)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(LX,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(IX,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new W1),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(LX,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(IX,this.context,t))}getRenderTransform(t,e,n,r,i,s,o){const a=i/2,l=s/2,c=r/e,u=-c,h=-t[0]+o,d=-t[1];return aZ(this.tempTransform,a,l,c,u,-n,h,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}},S2=class extends C2{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=[1/0,1/0,-1/0,-1/0],this.wrappedRenderedExtent_=[1/0,1/0,-1/0,-1/0],this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,n){const r=e.extent,i=e.viewState,s=i.center,o=i.resolution,a=i.projection,l=i.rotation,c=a.getExtent(),u=this.getLayer().getSource(),h=this.getLayer().getDeclutter(),d=e.pixelRatio,p=e.viewHints,f=!(p[0]||p[1]),g=this.context,m=Math.round(kG(r)/o*d),y=Math.round(wG(r)/o*d),v=u.getWrapX()&&a.canWrapX(),b=v?kG(c):null,w=v?Math.ceil((r[2]-c[2])/b)+(this.extendX_?2:1):1;let _=v?Math.floor((r[0]-c[0])/b)-(this.extendX_?1:0):0;do{let r=this.getRenderTransform(s,o,0,d,m,y,_*b);e.declutter&&(r=r.slice(0)),t.execute(g,[g.canvas.width,g.canvas.height],r,l,f,void 0===n?r2:n?i2:s2,n?h&&e.declutter[h]:void 0)}while(++_{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=this.frameState.size.slice(),e=this.renderedCenter_,n=this.renderedResolution_,r=this.renderedRotation_,i=this.renderedProjection_,s=this.wrappedRenderedExtent_,o=this.getLayer(),a=[],l=t[0]*h2,c=t[1]*h2;a.push(this.getRenderTransform(e,n,r,h2,l,c,0).slice());const u=o.getSource(),h=i.getExtent();if(u.getWrapX()&&i.canWrapX()&&!tG(h,s)){let t=s[0];const i=kG(h);let o,u=0;for(;th[2];)++u,o=i*u,a.push(this.getRenderTransform(e,n,r,h2,l,c,o).slice()),t-=i}const d=null;this.hitDetectionImageData_=d2(t,a,this.renderedFeatures_,o.getStyleFunction(),s,n,r,m2(n,this.renderedPixelRatio_),d?i:null)}e(p2(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,n,r,i){if(!this.replayGroup_)return;const s=e.viewState.resolution,o=e.viewState.rotation,a=this.getLayer(),l={},c=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,s,o,n,function(t,e,n){const s=sH(t),o=l[s];if(o){if(!0!==o&&nt.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),n=e.getSource();if(!n)return!1;const r=t.viewHints[0],i=t.viewHints[1],s=e.getUpdateWhileAnimating(),o=e.getUpdateWhileInteracting();if(this.ready&&!s&&r||!o&&i)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,l=t.viewState,c=l.projection,u=l.resolution,h=t.pixelRatio,d=e.getRevision(),p=e.getRenderBuffer();let f=e.getRenderOrder();void 0===f&&(f=g2);const g=l.center.slice(),m=YH(a,p*u),y=m.slice(),v=[m.slice()],b=c.getExtent(),w=n.getWrapX()&&c.canWrapX();if(this.extendX_=!1,w){const t=n.getExtent();t&&!RG(t)&&(this.extendX_=t[0]b[2])}if(w&&(!tG(b,t.extent)||this.extendX_)){const t=kG(b),e=Math.max(kG(m)/2,t);let n=b[0],r=b[2];this.extendX_&&(n-=t,r+=t),m[0]=n-e,m[2]=r+e,OG(g,c);const i=LG(v[0],c);i[0]b[0]&&i[2]>b[2]&&v.push([i[0]-t,i[1],i[2]-t,i[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===h&&this.renderedRevision_==d&&this.renderedRenderOrder_==f&&this.renderedFrameDeclutter_===!!t.declutter&&tG(this.wrappedRenderedExtent_,m))return KW(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=g,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const _=new U1(y2(u,h),m,u,h);for(let L=0,I=v.length;L{let r;const i=t.getStyleFunction()||e.getStyleFunction();if(i&&(r=i(t,u)),r){const e=this.renderFeature(t,x,r,_,undefined,this.getLayer().getDeclutter(),n);C=C&&!e}},k=m,E=n.getFeaturesInExtent(k);f&&E.sort(f);for(let L=0,I=E.length;L=200&&a.status<300){const t=e.getType();try{let r;"text"==t||"json"==t?r=a.responseText:"xml"==t?r=a.responseXML||a.responseText:"arraybuffer"==t&&(r=a.response),r?s(e.readFeatures(r,{extent:n,featureProjection:i}),e.readProjection(r)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function R2(t,e){return function(n,r,i,s,o){E2(t,e,n,r,i,t=>{this.addFeatures(t),void 0!==s&&s(t)},()=>{this.changed(),void 0!==o&&o()})}}function T2(){return[[-1/0,-1/0,1/0,1/0]]}function L2(t){return[t]}var I2=eZ(),P2=class t{constructor(t,e,n,r,i,s){this.styleFunction,this.extent_,this.id_=s,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=n||null,this.properties_=i,this.squaredTolerance_,this.stride_=r,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_="Point"===this.type_?sG(this.flatCoordinates_):oG(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=mG(this.getExtent());this.flatInteriorPoints_=HZ(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=tY(this.flatCoordinates_,this.ends_),e=x1(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=GZ(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=m1(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const n=this.ends_;for(let r=0,i=n.length;r{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),n&&this.simplifiedGeometry_.applyTransform(n);const r=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":r.length=jZ(r,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,r,0),i=[r.length];break;case"MultiLineString":i=[],r.length=UZ(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,r,0,i);break;case"Polygon":i=[],r.length=qZ(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),r,0,i)}return i&&(this.simplifiedGeometry_=new t(this.type_,r,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};P2.prototype.getFlatCoordinates=P2.prototype.getOrientedFlatCoordinates;var M2=class{constructor(t){this.rbush_=new zX(t),this.items_={}}insert(t,e){const n={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(n),this.items_[sH(e)]=n}load(t,e){const n=new Array(e.length);for(let r=0,i=e.length;r{const n=()=>{const r=this.getState();"ready"===r?(this.un("change",n),t()):"error"===r&&(this.un("change",n),e(new Error("Source failed to load")))};this.on("change",n)})}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=O2(t),this.changed()}setState(t){this.state_=t,this.changed()}};function O2(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),()=>t):null}var N2="addfeature",F2="removefeature",D2=class extends tH{constructor(t,e,n){super(t),this.feature=e,this.features=n}},z2=class extends A2{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===t.wrapX||t.wrapX}),this.on,this.once,this.un,this.loader_=XW,this.format_=t.format||null,this.overlaps_=void 0===t.overlaps||t.overlaps,this.url_=t.url,void 0!==t.loader?this.loader_=t.loader:void 0!==this.url_&&(PH(this.format_,"`format` must be set when `url` is set"),this.loader_=R2(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:T2;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let n,r;this.featuresRtree_=e?new M2:null,this.loadedExtentsRtree_=new M2,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(t.features)?r=t.features:t.features&&(n=t.features,r=n.getArray()),e||void 0!==n||(n=new uH(r)),void 0!==r&&this.addFeaturesInternal(r),void 0!==n&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=sH(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const n=t.getGeometry();if(n){const e=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new D2(N2,t))}setupChangeEvents_(t,e){e instanceof P2||(this.featureChangeKeys_[t]=[MW(e,NW,this.handleFeatureChange_,this),MW(e,LW,this.handleFeatureChange_,this)])}addToIndex_(t,e){let n=!0;if(void 0!==e.getId()){const t=String(e.getId());if(t in this.idIndex_)if(e instanceof P2){const r=this.idIndex_[t];r instanceof P2?Array.isArray(r)?r.push(e):this.idIndex_[t]=[r,e]:n=!1}else n=!1;else this.idIndex_[t]=e}return n&&(PH(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),n}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],n=[],r=[];for(let i=0,s=t.length;i{e||(e=!0,this.addFeature(t.element),e=!1)}),t.addEventListener(TW,t=>{e||(e=!0,this.removeFeature(t.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_)this.featureChangeKeys_[t].forEach(OW);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(t=>{this.removeFeatureInternal(t)});for(const t in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[t])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new D2("clear");this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const n=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(n,function(n){const r=n.getGeometry();if(r instanceof P2||r.intersectsCoordinate(t))return e(n)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(n){const r=n.getGeometry();if(r instanceof P2||r.intersectsExtent(t)){const t=e(n);if(t)return t}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),PW(this.nullGeometryFeatures_)||GW(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(t){e.push(t)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const n=IG(t,e);return[].concat(...n.map(t=>this.featuresRtree_.getInExtent(t)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const n=t[0],r=t[1];let i=null;const s=[NaN,NaN];let o=1/0;const a=[-1/0,-1/0,1/0,1/0];return e=e||ZW,this.featuresRtree_.forEachInExtent(a,function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e instanceof P2?0:e.closestPointXY(n,r,s,o),o{this.loading=Number(this.loading)-1,this.dispatchEvent(new D2("featuresloadend",void 0,t))},s=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new D2("featuresloaderror"))};let o=!1;const a=this.loader_.call(this,t,e,n,t=>o||i(t),()=>o||s());a instanceof Promise?(o=!0,a.then(t=>{this.addFeatures(t),i(t)}).catch(s)):this.loader_.length<4&&(this.loading=!1),r.insert(t,{extent:t.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,n=[];e.forEachInExtent(t,function(t){n.push(t)}),n.forEach(n=>{e.remove(n);const r=xG(n.extent,t);for(const t of r)e.insert(t,{extent:t})})}removeFeatures(t){let e=!1;for(let n=0,r=t.length;nt.clone())}var B2=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=g1,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?zK(e.dataProjection):this.readProjection(t);e.extent&&n&&"tile-pixels"===n.getUnits()&&(n=zK(n),n.setWorldExtent(e.extent)),e={dataProjection:n,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return rH()}readFeature(t,e){return rH()}readFeatures(t,e){return rH()}readGeometry(t,e){return rH()}readProjection(t){return rH()}writeFeature(t,e){return rH()}writeFeatures(t,e){return rH()}writeGeometry(t,e){return rH()}};function $2(t,e,n){const r=n?zK(n.featureProjection):null,i=n?zK(n.dataProjection):null;let s=t;if(r&&i&&!VK(r,i)){e&&(s=t.clone());const n=e?r:i,o=e?i:r;"tile-pixels"===n.getUnits()?s.transform(n,o):s.applyTransform(GK(n,o))}if(e&&n&&void 0!==n.decimals){const e=Math.pow(10,n.decimals),r=function(t){for(let n=0,r=t.length;nV2({...t,geometry:e})).flat();const r="MultiPolygon"===n.type?"Polygon":n.type;if("GeometryCollection"===r||"Circle"===r)throw new Error("Unsupported geometry type: "+r);const i=n.layout.length;return $2(new P2(r,"Polygon"===r?function(t,e,n){return Array.isArray(e[0])?(XZ(t,0,e,n)||QZ(t=t.slice(),0,e,n),t):(YZ(t,0,e,n)||JZ(t=t.slice(),0,e,n),t)}(n.flatCoordinates,n.ends,i):n.flatCoordinates,n.ends?.flat(),i,t.properties||{},t.id).enableSimplifyTransformed(),!1,e)}function W2(t,e){if(!t)return null;if(Array.isArray(t)){const n=t.map(t=>W2(t,e));return new j2(n)}return $2(new(0,q2[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}var H2=class extends B2{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(G2(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(G2(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return rH()}readFeaturesFromObject(t,e){return rH()}readGeometry(t,e){return this.readGeometryFromObject(G2(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return rH()}readProjection(t){return this.readProjectionFromObject(G2(t))}readProjectionFromObject(t){return rH()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return rH()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return rH()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return rH()}};function G2(t){return"string"==typeof t?JSON.parse(t)||null:null!==t?t:null}var K2=class extends H2{constructor(t){t=t||{},super(),this.dataProjection=zK(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=zK(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let n=null;n="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const r=Z2(n.geometry);if(this.featureClass===P2)return V2({geometry:r,id:n.id,properties:n.properties},e);const i=new(0,this.featureClass);return this.geometryName_?i.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&i.setGeometryName(n.geometry_name),i.setGeometry(W2(r,e)),"id"in n&&i.setId(n.id),n.properties&&i.setProperties(n.properties,!0),i}readFeaturesFromObject(t,e){let n=null;if("FeatureCollection"===t.type){n=[];const r=t.features;for(let t=0,i=r.length;t":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}},u3=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function h3(t,e){const n={};for(const r in t)"ref"!==r&&(n[r]=t[r]);return u3.forEach(t=>{t in e&&(n[t]=e[t])}),n}function d3(t){t=t.slice();const e=Object.create(null);for(let n=0;n`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}var O3=[y3,v3,b3,w3,_3,x3,E3,C3,M3(S3),R3,L3,T3,I3,P3];function N3(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!N3(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of O3)if(!N3(t,e))return null}return`Expected ${A3(t)} but found ${A3(e)} instead.`}function F3(t,e){return e.some(e=>e.kind===t.kind)}function D3(t,e){return e.some(e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t)}function z3(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}var j3=.96422,U3=.82521,B3=4/29,$3=6/29,q3=3*$3*$3,V3=$3*$3*$3,W3=Math.PI/180,H3=180/Math.PI;function G3(t){return(t%=360)<0&&(t+=360),t}function K3([t,e,n,r]){let i,s;const o=Y3((.2225045*(t=Z3(t))+.7168786*(e=Z3(e))+.0606169*(n=Z3(n)))/1);t===e&&e===n?i=s=o:(i=Y3((.4360747*t+.3850649*e+.1430804*n)/j3),s=Y3((.0139322*t+.0971045*e+.7141733*n)/U3));const a=116*o-16;return[a<0?0:a,500*(i-o),200*(o-s),r]}function Z3(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Y3(t){return t>V3?Math.pow(t,1/3):t/q3+B3}function X3([t,e,n,r]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,o=isNaN(n)?i:i-n/200;return i=1*Q3(i),s=j3*Q3(s),o=U3*Q3(o),[J3(3.1338561*s-1.6168667*i-.4906146*o),J3(-.9787684*s+1.9161415*i+.033454*o),J3(.0719453*s-.2289914*i+1.4052427*o),r]}function J3(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function Q3(t){return t>$3?t*t*t:q3*(t-B3)}var t5=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function e5(t,e){return t5(t,e)?t[e]:void 0}function n5(t){return parseInt(t.padEnd(2,t),16)/255}function r5(t,e){return i5(e?t/100:t,0,1)}function i5(t,e,n){return Math.min(Math.max(e,t),n)}function s5(t){return!t.some(Number.isNaN)}var o5={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function a5(t,e,n){return t+n*(e-t)}function l5(t,e,n){return t.map((t,r)=>a5(t,e[r],n))}var c5=class t{constructor(t,e,n,r=1,i=!0){this.r=t,this.g=e,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,n,r]))}static{this.black=new t(0,0,0,1)}static{this.white=new t(1,1,1,1)}static{this.transparent=new t(0,0,0,0)}static{this.red=new t(1,0,0,1)}static parse(e){if(e instanceof t)return e;if("string"!=typeof e)return;const n=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=e5(o5,t);if(e){const[t,n,r]=e;return[t/255,n/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let n=1;return[n5(t.slice(n,n+=e)),n5(t.slice(n,n+=e)),n5(t.slice(n,n+=e)),n5(t.slice(n,n+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,n,r,i,s,o,a,l,c,u,h,d]=e,p=[i||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const t=[r,o,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[i5(+n/e,0,1),i5(+s/e,0,1),i5(+l/e,0,1),h?r5(+h,d):1];if(s5(t))return t}}return}}const n=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){const[t,e,r,i,s,o,a,l,c]=n,u=[r||" ",s||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const t=[+e,i5(+i,0,100),i5(+o,0,100),l?r5(+l,c):1];if(s5(t))return function([t,e,n,r]){function i(r){const i=(r+t/30)%12,s=e*Math.min(n,1-n);return n-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=G3(t),e/=100,n/=100,[i(0),i(8),i(4),r]}(t)}}}(e);return n?new t(...n,!1):void 0}get rgb(){const{r:t,g:e,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter("rgb",[t/i,e/i,n/i,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,n,r,i]=K3(t),s=Math.sqrt(n*n+r*r);return[Math.round(1e4*s)?G3(Math.atan2(r,n)*H3):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",K3(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,n,r]=this.rgb;return`rgba(${[t,e,n].map(t=>Math.round(255*t)).join(",")},${r})`}static interpolate(e,n,r,i="rgb"){switch(i){case"rgb":{const[i,s,o,a]=l5(e.rgb,n.rgb,r);return new t(i,s,o,a,!1)}case"hcl":{const[i,s,o,a]=e.hcl,[l,c,u,h]=n.hcl;let d,p;if(isNaN(i)||isNaN(l))isNaN(i)?isNaN(l)?d=NaN:(d=l,1!==o&&0!==o||(p=c)):(d=i,1!==u&&0!==u||(p=s));else{let t=l-i;l>i&&t>180?t-=360:l180&&(t+=360),d=i+r*t}const[f,g,m,y]=function([t,e,n,r]){return t=isNaN(t)?0:t*W3,X3([n,Math.cos(t)*e,Math.sin(t)*e,r])}([d,p??a5(s,c,r),a5(o,u,r),a5(a,h,r)]);return new t(f,g,m,y,!1)}case"lab":{const[i,s,o,a]=X3(l5(e.lab,n.lab,r));return new t(i,s,o,a,!1)}}}},u5=class{constructor(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}},h5=["bottom","center","top"],d5=class{constructor(t,e,n,r,i,s){this.text=t,this.image=e,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=s}},p5=class t{constructor(t){this.sections=t}static fromString(e){return new t([new d5(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(t=>0!==t.text.length||t.image&&0!==t.image.name.length)}static factory(e){return e instanceof t?e:t.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(t=>t.text).join("")}},f5=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,n,r){return new t(l5(e.values,n.values,r))}},g5=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,n,r){return new t(l5(e.values,n.values,r))}},m5=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("string"==typeof e){const n=c5.parse(e);if(!n)return;return new t([n])}if(!Array.isArray(e))return;const n=[];for(const t of e){if("string"!=typeof t)return;const e=c5.parse(t);if(!e)return;n.push(e)}return new t(n)}toString(){return JSON.stringify(this.values)}static interpolate(e,n,r,i="rgb"){const s=[];if(e.values.length!=n.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${n.values.length}), cannot interpolate.`);for(let t=0;t=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function C5(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof _5||t instanceof c5||t instanceof u5||t instanceof p5||t instanceof f5||t instanceof g5||t instanceof m5||t instanceof b5||t instanceof w5)return!0;if(Array.isArray(t)){for(const e of t)if(!C5(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!C5(t[e]))return!1;return!0}return!1}function S5(t){if(null===t)return y3;if("string"==typeof t)return b3;if("boolean"==typeof t)return w3;if("number"==typeof t)return v3;if(t instanceof c5)return _3;if(t instanceof _5)return x3;if(t instanceof u5)return k3;if(t instanceof p5)return E3;if(t instanceof f5)return R3;if(t instanceof g5)return L3;if(t instanceof m5)return T3;if(t instanceof b5)return P3;if(t instanceof w5)return I3;if(Array.isArray(t)){const e=t.length;let n;for(const r of t){const t=S5(r);if(n){if(n===t)continue;n=S3;break}n=t}return M3(n||S3,e)}return C3}function k5(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof c5||t instanceof _5||t instanceof p5||t instanceof f5||t instanceof g5||t instanceof m5||t instanceof b5||t instanceof w5?t.toString():JSON.stringify(t)}var E5=class t{constructor(t,e){this.type=t,this.value=e}static parse(e,n){if(2!==e.length)return n.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!C5(e[1]))return n.error("invalid value");const r=e[1];let i=S5(r);const s=n.expectedType;return"array"!==i.kind||0!==i.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(i=s),new t(i,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}},R5={string:b3,number:v3,boolean:w3,object:C3},T5=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");let r,i=1;const s=e[0];if("array"===s){let t,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in R5)||"object"===r)return n.error('The item type argument of "array" must be one of string, number, boolean',1);t=R5[r],i++}else t=S3;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return n.error('The length argument to "array" must be a positive integer literal',2);s=e[2],i++}r=M3(t,s)}else{if(!R5[s])throw new Error(`Types doesn't contain name = ${s}`);r=R5[s]}const o=[];for(;it.outputDefined())}},L5={"to-boolean":w3,"to-color":_3,"to-number":v3,"to-string":b3},I5=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");const r=e[0];if(!L5[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return n.error("Expected one argument.");const i=L5[r],s=[];for(let t=1;t4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:x5(e[0],e[1],e[2],e[3]),!n))return new c5(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new y5(n||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const n of this.args){e=n.evaluate(t);const r=f5.parse(e);if(r)return r}throw new y5(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"numberArray":{let e;for(const n of this.args){e=n.evaluate(t);const r=g5.parse(e);if(r)return r}throw new y5(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"colorArray":{let e;for(const n of this.args){e=n.evaluate(t);const r=m5.parse(e);if(r)return r}throw new y5(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const n of this.args){e=n.evaluate(t);const r=b5.parse(e);if(r)return r}throw new y5(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const n of this.args){if(e=n.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new y5(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return p5.fromString(k5(this.args[0].evaluate(t)));case"resolvedImage":return w5.fromString(k5(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return k5(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},P5=["Unknown","Point","LineString","Polygon"],M5=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?P5[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=c5.parse(t),this._parseColorCache.set(t,e)),e}},A5=class t{constructor(t,e,n=[],r,i=new m3,s=[]){this.registry=t,this.path=n,this.key=n.map(t=>`[${t}]`).join(""),this.scope=i,this.errors=s,this.expectedType=r,this._isConstant=e}parse(t,e,n,r,i={}){return e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)}_parse(t,e){function n(t,e,n){return"assert"===n?new T5(e,[t]):"coerce"===n?new I5(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const i=t[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[i];if(s){let i=s.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,r=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==r.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===t.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(r.kind))i=n(i,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,r))return null}else i=n(i,t,e.typeAnnotation||"assert")}if(!(i instanceof E5)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){const t=new M5;try{i=new E5(i.type,i.evaluate(t))}catch(r){return this.error(r.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof t} instead.`)}concat(e,n,r){const i="number"==typeof e?this.path.concat(e):this.path,s=r?this.scope.concat(r):this.scope;return new t(this.registry,this._isConstant,i,n||null,s,this.errors)}error(t,...e){const n=`${this.key}${e.map(t=>`[${t}]`).join("")}`;this.errors.push(new g3(n,t))}checkSubtype(t,e){const n=N3(t,e);return n&&this.error(n),n}},O5=class t{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(e,n){if(e.length<4)return n.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let t=1;te))throw new y5("Input is not a number.");o=a-1}return 0}var D5=class t{constructor(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[r,i]of n)this.labels.push(r),this.outputs.push(i)}static parse(e,n){if(e.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return n.error("Expected an even number of arguments.");const r=n.parse(e[1],1,v3);if(!r)return null;const i=[];let s=null;n.expectedType&&"value"!==n.expectedType.kind&&(s=n.expectedType);for(let t=1;t=r)return n.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=n.parse(o,l,s);if(!c)return null;s=s||c.type,i.push([r,c])}return new t(s,r,i)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);const i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[F5(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}},z5=class t{constructor(t,e,n,r,i){this.type=t,this.operator=e,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[s,o]of i)this.labels.push(s),this.outputs.push(o)}static interpolationFactor(t,e,n,r){let i=0;if("exponential"===t.name)i=j5(e,t.base,n,r);else if("linear"===t.name)i=j5(e,1,n,r);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=function(t,e,n,r){const i=3*t,s=3*(n-t)-i,o=1-i-s,a=3*e,l=3*(r-e)-a,c=1-a-l;return function(t,e=1e-6){if(t<=0)return 0;if(t>=1)return 1;let n=t;for(let h=0;h<8;h++){const r=((o*n+s)*n+i)*n-t;if(Math.abs(r)a?r=n:u=n,n=.5*(r+u)}return((c*n+l)*n+a)*n}}(s[0],s[1],s[2],s[3])(j5(e,1,n,r))}return i}static parse(e,n){let[r,i,s,...o]=e;if(!Array.isArray(i)||0===i.length)return n.error("Expected an interpolation type expression.",1);if("linear"===i[0])i={name:"linear"};else if("exponential"===i[0]){const t=i[1];if("number"!=typeof t)return n.error("Exponential interpolation requires a numeric base.",1,1);i={name:"exponential",base:t}}else{if("cubic-bezier"!==i[0])return n.error(`Unknown interpolation type ${String(i[0])}`,1,0);{const t=i.slice(1);if(4!==t.length||t.some(t=>"number"!=typeof t||t<0||t>1))return n.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);i={name:"cubic-bezier",controlPoints:t}}}if(e.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return n.error("Expected an even number of arguments.");if(s=n.parse(s,2,v3),!s)return null;const a=[];let l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||n.expectedType==T3?n.expectedType&&"value"!==n.expectedType.kind&&(l=n.expectedType):l=_3;for(let t=0;t=e)return n.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const c=n.parse(r,s,l);if(!c)return null;l=l||c.type,a.push([e,c])}return z3(l,v3)||z3(l,x3)||z3(l,_3)||z3(l,R3)||z3(l,L3)||z3(l,T3)||z3(l,P3)||z3(l,M3(v3))?new t(l,r,i,s,a):n.error(`Type ${A3(l)} is not interpolatable.`)}evaluate(e){const n=this.labels,r=this.outputs;if(1===n.length)return r[0].evaluate(e);const i=this.input.evaluate(e);if(i<=n[0])return r[0].evaluate(e);const s=n.length;if(i>=n[s-1])return r[s-1].evaluate(e);const o=F5(n,i),a=n[o],l=n[o+1],c=t.interpolationFactor(this.interpolation,i,a,l),u=r[o].evaluate(e),h=r[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return a5(u,h,c);case"color":return c5.interpolate(u,h,c);case"padding":return f5.interpolate(u,h,c);case"colorArray":return m5.interpolate(u,h,c);case"numberArray":return g5.interpolate(u,h,c);case"variableAnchorOffsetCollection":return b5.interpolate(u,h,c);case"array":return l5(u,h,c);case"projectionDefinition":return _5.interpolate(u,h,c)}case"interpolate-hcl":switch(this.type.kind){case"color":return c5.interpolate(u,h,c,"hcl");case"colorArray":return m5.interpolate(u,h,c,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return c5.interpolate(u,h,c,"lab");case"colorArray":return m5.interpolate(u,h,c,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function j5(t,e,n,r){const i=r-n,s=t-n;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}c5.interpolate,f5.interpolate,g5.interpolate,m5.interpolate,b5.interpolate;var U5=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");let r=null;const i=n.expectedType;i&&"value"!==i.kind&&(r=i);const s=[];for(const t of e.slice(1)){const e=n.parse(t,1+s.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r=r||e.type,s.push(e)}if(!r)throw new Error("No output type");return i&&s.some(t=>N3(i,t.type))?new t(S3,s):new t(r,s)}evaluate(t){let e,n=null,r=0;for(const i of this.args)if(r++,n=i.evaluate(t),n&&n instanceof w5&&!n.available&&(e||(e=n.name),n=null,r===this.args.length&&(n=e)),null!==n)break;return n}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function B5(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function $5(t,e,n,r){return 0===r.compare(e,n)}function q5(t,e,n){const r="=="!==t&&"!="!==t;return class i{constructor(t,e,n){this.type=w3,this.lhs=t,this.rhs=e,this.collator=n,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const n=t[0];let s=e.parse(t[1],1,S3);if(!s)return null;if(!B5(n,s.type))return e.concat(1).error(`"${n}" comparisons are not supported for type '${A3(s.type)}'.`);let o=e.parse(t[2],2,S3);if(!o)return null;if(!B5(n,o.type))return e.concat(2).error(`"${n}" comparisons are not supported for type '${A3(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${A3(s.type)}' and '${A3(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new T5(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new T5(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,k3),!a)return null}return new i(s,o,a)}evaluate(i){const s=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const e=S5(s),n=S5(o);if(e.kind!==n.kind||"string"!==e.kind&&"number"!==e.kind)throw new y5(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=S5(s),n=S5(o);if("string"!==t.kind||"string"!==n.kind)return e(i,s,o)}return this.collator?n(i,s,o,this.collator.evaluate(i)):e(i,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}var V5=q5("==",function(t,e,n){return e===n},$5),W5=q5("!=",function(t,e,n){return e!==n},function(t,e,n,r){return!$5(0,e,n,r)}),H5=q5("<",function(t,e,n){return e",function(t,e,n){return e>n},function(t,e,n,r){return r.compare(e,n)>0}),K5=q5("<=",function(t,e,n){return e<=n},function(t,e,n,r){return r.compare(e,n)<=0}),Z5=q5(">=",function(t,e,n){return e>=n},function(t,e,n,r){return r.compare(e,n)>=0}),Y5=class t{constructor(t,e,n){this.type=k3,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e}static parse(e,n){if(2!==e.length)return n.error("Expected one argument.");const r=e[1];if("object"!=typeof r||Array.isArray(r))return n.error("Collator options argument must be an object.");const i=n.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,w3);if(!i)return null;const s=n.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,w3);if(!s)return null;let o=null;return r.locale&&(o=n.parse(r.locale,1,b3),!o)?null:new t(i,s,o)}evaluate(t){return new u5(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}},X5=8192;function J5(t,e){const n=(180+t[0])/360,r=(i=t[1],(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360);var i;const s=Math.pow(2,e.z);return[Math.round(n*s*X5),Math.round(r*s*X5)]}function Q5(t,e){const n=Math.pow(2,e.z);return[(i=(t[0]/X5+e.x)/n,360*i-180),(r=(t[1]/X5+e.y)/n,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,i}function t4(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function e4(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function n4(t,e,n){return e[1]>t[1]!=n[1]>t[1]&&t[0]<(n[0]-e[0])*(t[1]-e[1])/(n[1]-e[1])+e[0]}function r4(t,e,n){const r=t[0]-e[0],i=t[1]-e[1],s=t[0]-n[0],o=t[1]-n[1];return r*o-s*i===0&&r*s<=0&&i*o<=0}function i4(t,e,n,r){const i=[e[0]-t[0],e[1]-t[1]];return 0!==function(t,e){return t[0]*e[1]-t[1]*e[0]}([r[0]-n[0],r[1]-n[1]],i)&&!(!u4(t,e,n,r)||!u4(n,r,t,e))}function s4(t,e,n){for(const r of n)for(let n=0;n0&&h<0||u<0&&h>0}function h4(t,e,n){const r=[];for(let i=0;in[2]){const e=.5*r;let i=t[0]-n[0]>e?-r:n[0]-t[0]>e?r:0;0===i&&(i=t[0]-n[2]>e?-r:n[2]-t[0]>e?r:0),t[0]+=i}t4(e,t)}function f4(t,e,n,r){const i=Math.pow(2,r.z)*X5,s=[r.x*X5,r.y*X5],o=[];for(const a of t)for(const t of a){const r=[t.x+s[0],t.y+s[1]];p4(r,e,n,i),o.push(r)}return o}function g4(t,e,n,r){const i=Math.pow(2,r.z)*X5,s=[r.x*X5,r.y*X5],o=[];for(const a of t){const t=[];for(const n of a){const r=[n.x+s[0],n.y+s[1]];t4(e,r),t.push(r)}o.push(t)}if(e[2]-e[0]<=i/2){!function(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}(e);for(const t of o)for(const r of t)p4(r,e,n,i)}return o}var m4=class t{constructor(t,e){this.type=w3,this.geojson=t,this.geometries=e}static parse(e,n){if(2!==e.length)return n.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(C5(e[1])){const n=e[1];if("FeatureCollection"===n.type){const e=[];for(const t of n.features){const{type:n,coordinates:r}=t.geometry;"Polygon"===n&&e.push(r),"MultiPolygon"===n&&e.push(...r)}if(e.length)return new t(n,{type:"MultiPolygon",coordinates:e})}else if("Feature"===n.type){const e=n.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new t(n,n.geometry)}else if("Polygon"===n.type||"MultiPolygon"===n.type)return new t(n,n)}return n.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=h4(e.coordinates,r,i),o=f4(t.geometry(),n,r,i);if(!e4(n,r))return!1;for(const t of o)if(!o4(t,s))return!1}if("MultiPolygon"===e.type){const s=d4(e.coordinates,r,i),o=f4(t.geometry(),n,r,i);if(!e4(n,r))return!1;for(const t of o)if(!a4(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=h4(e.coordinates,r,i),o=g4(t.geometry(),n,r,i);if(!e4(n,r))return!1;for(const t of o)if(!l4(t,s))return!1}if("MultiPolygon"===e.type){const s=d4(e.coordinates,r,i),o=g4(t.geometry(),n,r,i);if(!e4(n,r))return!1;for(const t of o)if(!c4(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},y4=class{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(n(r,s)>=0)break;e[t]=s,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[r],t=r}e[t]=i}};function v4(t){let e=0;for(let n,r,i=0,s=t.length,o=s-1;i1?(l=t[a+1][0],c=t[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(e[0]-l)*this.kx,h=(e[1]-c)*this.ky;const p=u*u+h*h;p180;)t-=360;return t}};function _4(t,e){return e[0]-t[0]}function x4(t){return t[1]-t[0]+1}function C4(t,e){return t[1]>=t[0]&&t[1]t[1])return[null,null];const n=x4(t);if(e){if(2===n)return[t,null];const e=Math.floor(n/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===n)return[t,null];const r=Math.floor(n/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function k4(t,e){if(!C4(e,t.length))return[1/0,1/0,-1/0,-1/0];const n=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)t4(n,t[r]);return n}function E4(t){const e=[1/0,1/0,-1/0,-1/0];for(const n of t)for(const t of n)t4(e,t);return e}function R4(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function T4(t,e,n){if(!R4(t)||!R4(e))return NaN;let r=0,i=0;return t[2]e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=r)return r;if(e4(i,s)){if(N4(t,e))return 0}else if(N4(e,t))return 0;let o=1/0;for(const a of t)for(let t=0,r=a.length,i=r-1;t0;){const i=o.pop();if(i[0]>=s)continue;const l=i[1],c=e?50:100;if(x4(l)<=c){if(!C4(l,t.length))return NaN;if(e){const e=O4(t,l,n,r);if(isNaN(e)||0===e)return e;s=Math.min(s,e)}else for(let e=l[0];e<=l[1];++e){const i=A4(t[e],n,r);if(s=Math.min(s,i),0===s)return 0}}else{const n=S4(l,e);D4(o,s,r,t,a,n[0]),D4(o,s,r,t,a,n[1])}}return s}function U4(t,e,n,r,i,s=1/0){let o=Math.min(s,i.distance(t[0],n[0]));if(0===o)return o;const a=new y4([[0,[0,t.length-1],[0,n.length-1]]],_4);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],c=s[2],u=e?50:100,h=r?50:100;if(x4(l)<=u&&x4(c)<=h){if(!C4(l,t.length)&&C4(c,n.length))return NaN;let s;if(e&&r)s=P4(t,l,n,c,i),o=Math.min(o,s);else if(e&&!r){const e=t.slice(l[0],l[1]+1);for(let t=c[0];t<=c[1];++t)if(s=L4(n[t],e,i),o=Math.min(o,s),0===o)return o}else if(!e&&r){const e=n.slice(c[0],c[1]+1);for(let n=l[0];n<=l[1];++n)if(s=L4(t[n],e,i),o=Math.min(o,s),0===o)return o}else s=M4(t,l,n,c,i),o=Math.min(o,s)}else{const s=S4(l,e),u=S4(c,r);z4(a,o,i,t,n,s[0],u[0]),z4(a,o,i,t,n,s[0],u[1]),z4(a,o,i,t,n,s[1],u[0]),z4(a,o,i,t,n,s[1],u[1])}}return o}function B4(t){return"MultiPolygon"===t.type?t.coordinates.map(t=>({type:"Polygon",coordinates:t})):"MultiLineString"===t.type?t.coordinates.map(t=>({type:"LineString",coordinates:t})):"MultiPoint"===t.type?t.coordinates.map(t=>({type:"Point",coordinates:t})):[t]}var $4=class t{constructor(t,e){this.type=v3,this.geojson=t,this.geometries=e}static parse(e,n){if(2!==e.length)return n.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(C5(e[1])){const n=e[1];if("FeatureCollection"===n.type)return new t(n,n.features.map(t=>B4(t.geometry)).flat());if("Feature"===n.type)return new t(n,B4(n.geometry));if("type"in n&&"coordinates"in n)return new t(n,B4(n))}return n.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=t.geometry(),r=n.flat().map(e=>Q5([e.x,e.y],t.canonical));if(0===n.length)return NaN;const i=new w4(r[0][1]);let s=1/0;for(const o of e){switch(o.type){case"Point":s=Math.min(s,U4(r,!1,[o.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,U4(r,!1,o.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,j4(r,!1,o.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=t.geometry(),r=n.flat().map(e=>Q5([e.x,e.y],t.canonical));if(0===n.length)return NaN;const i=new w4(r[0][1]);let s=1/0;for(const o of e){switch(o.type){case"Point":s=Math.min(s,U4(r,!0,[o.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,U4(r,!0,o.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,j4(r,!0,o.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const n=t.geometry();if(0===n.length||0===n[0].length)return NaN;const r=function(t){if(t.length<=1)return[t];const e=[];let n,r;for(const i of t){const t=v4(i);0!==t&&(i.area=Math.abs(t),void 0===r&&(r=t<0),r===t<0?(n&&e.push(n),n=[i]):n.push(i))}return n&&e.push(n),e}(n).map(e=>e.map(e=>e.map(e=>Q5([e.x,e.y],t.canonical)))),i=new w4(r[0][0][0][1]);let s=1/0;for(const o of e)for(const t of r){switch(o.type){case"Point":s=Math.min(s,j4([o.coordinates],!1,t,i,s));break;case"LineString":s=Math.min(s,j4(o.coordinates,!0,t,i,s));break;case"Polygon":s=Math.min(s,F4(t,o.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},q4=class t{constructor(t){this.type=S3,this.key=t}static parse(e,n){if(2!==e.length)return n.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=e[1];return null==r?n.error("Global state property must be defined."):"string"!=typeof r?n.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new t(r)}evaluate(t){const e=t.globals?.globalState;return e&&0!==Object.keys(e).length?e5(e,this.key)??null:null}eachChild(){}outputDefined(){return!1}},V4={"==":V5,"!=":W5,">":G5,"<":H5,">=":Z5,"<=":K5,array:T5,at:class t{constructor(t,e,n){this.type=t,this.index=e,this.input=n}static parse(e,n){if(3!==e.length)return n.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,v3),i=n.parse(e[2],2,M3(n.expectedType||S3));if(!r||!i)return null;const s=i.type;return new t(s.itemType,r,i)}evaluate(t){const e=this.index.evaluate(t),n=this.input.evaluate(t);if(e<0)throw new y5(`Array index out of bounds: ${e} < 0.`);if(e>=n.length)throw new y5(`Array index out of bounds: ${e} > ${n.length-1}.`);if(e!==Math.floor(e))throw new y5(`Array index must be an integer, but found ${e} instead.`);return n[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},boolean:T5,case:class t{constructor(t,e,n){this.type=t,this.branches=e,this.otherwise=n}static parse(e,n){if(e.length<4)return n.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return n.error("Expected an odd number of arguments.");let r;n.expectedType&&"value"!==n.expectedType.kind&&(r=n.expectedType);const i=[];for(let t=1;te.outputDefined())&&this.otherwise.outputDefined()}},coalesce:U5,collator:Y5,format:class t{constructor(t){this.type=E3,this.sections=t}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return n.error("First argument must be an image or text section.");const i=[];let s=!1;for(let t=1;t<=e.length-1;++t){const r=e[t];if(s&&"object"==typeof r&&!Array.isArray(r)){s=!1;let t=null;if(r["font-scale"]&&(t=n.parse(r["font-scale"],1,v3),!t))return null;let e=null;if(r["text-font"]&&(e=n.parse(r["text-font"],1,M3(b3)),!e))return null;let o=null;if(r["text-color"]&&(o=n.parse(r["text-color"],1,_3),!o))return null;let a=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!h5.includes(r["vertical-align"]))return n.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(a=n.parse(r["vertical-align"],1,b3),!a)return null}const l=i[i.length-1];l.scale=t,l.font=e,l.textColor=o,l.verticalAlign=a}else{const r=n.parse(e[t],1,S3);if(!r)return null;const o=r.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return n.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,i.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new t(i)}evaluate(t){return new p5(this.sections.map(e=>{const n=e.content.evaluate(t);return S5(n)===I3?new d5("",n,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new d5(k5(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}},image:class t{constructor(t){this.type=I3,this.input=t}static parse(e,n){if(2!==e.length)return n.error("Expected two arguments.");const r=n.parse(e[1],1,b3);return r?new t(r):n.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),n=w5.fromString(e);return n&&t.availableImages&&(n.available=t.availableImages.indexOf(e)>-1),n}eachChild(t){t(this.input)}outputDefined(){return!1}},in:class t{constructor(t,e){this.type=w3,this.needle=t,this.haystack=e}static parse(e,n){if(3!==e.length)return n.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,S3),i=n.parse(e[2],2,S3);return r&&i?F3(r.type,[w3,b3,v3,y3,S3])?new t(r,i):n.error(`Expected first argument to be of type boolean, string, number or null, but found ${A3(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!n)return!1;if(!D3(e,["boolean","string","number","null"]))throw new y5(`Expected first argument to be of type boolean, string, number or null, but found ${A3(S5(e))} instead.`);if(!D3(n,["string","array"]))throw new y5(`Expected second argument to be of type array or string, but found ${A3(S5(n))} instead.`);return n.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},"index-of":class t{constructor(t,e,n){this.type=v3,this.needle=t,this.haystack=e,this.fromIndex=n}static parse(e,n){if(e.length<=2||e.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,S3),i=n.parse(e[2],2,S3);if(!r||!i)return null;if(!F3(r.type,[w3,b3,v3,y3,S3]))return n.error(`Expected first argument to be of type boolean, string, number or null, but found ${A3(r.type)} instead`);if(4===e.length){const s=n.parse(e[3],3,v3);return s?new t(r,i,s):null}return new t(r,i)}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!D3(e,["boolean","string","number","null"]))throw new y5(`Expected first argument to be of type boolean, string, number or null, but found ${A3(S5(e))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(t)),D3(n,["string"])){const t=n.indexOf(e,r);return-1===t?-1:[...n.slice(0,t)].length}if(D3(n,["array"]))return n.indexOf(e,r);throw new y5(`Expected second argument to be of type array or string, but found ${A3(S5(n))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},interpolate:z5,"interpolate-hcl":z5,"interpolate-lab":z5,length:class t{constructor(t){this.type=v3,this.input=t}static parse(e,n){if(2!==e.length)return n.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=n.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?n.error(`Expected argument of type string or array, but found ${A3(r.type)} instead.`):new t(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new y5(`Expected value to be of type string or array, but found ${A3(S5(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}},let:O5,literal:E5,match:class t{constructor(t,e,n,r,i,s){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=s}static parse(e,n){if(e.length<5)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return n.error("Expected an even number of arguments.");let r,i;n.expectedType&&"value"!==n.expectedType.kind&&(i=n.expectedType);const s={},o=[];for(let t=2;tNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,S5(t)))return null}else r=S5(t);if(void 0!==s[String(t)])return c.error("Branch labels must be unique.");s[String(t)]=o.length}const u=n.parse(l,t,i);if(!u)return null;i=i||u.type,o.push(u)}const a=n.parse(e[1],1,S3);if(!a)return null;const l=n.parse(e[e.length-1],e.length-1,i);return l?"value"!==a.type.kind&&n.concat(1).checkSubtype(r,a.type)?null:new t(r,i,a,s,o,l):null}evaluate(t){const e=this.input.evaluate(t);return(S5(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}},number:T5,"number-format":class t{constructor(t,e,n,r,i,s){this.type=b3,this.number=t,this.locale=e,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=s}static parse(e,n){if(3!==e.length)return n.error("Expected two arguments.");const r=n.parse(e[1],1,v3);if(!r)return null;const i=e[2];if("object"!=typeof i||Array.isArray(i))return n.error("NumberFormat options argument must be an object.");let s=null;if(i.locale&&(s=n.parse(i.locale,1,b3),!s))return null;let o=null;if(i.currency&&(o=n.parse(i.currency,1,b3),!o))return null;let a=null;if(i.unit&&(a=n.parse(i.unit,1,b3),!a))return null;if(o&&a)return n.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(i["min-fraction-digits"]&&(l=n.parse(i["min-fraction-digits"],1,v3),!l))return null;let c=null;return i["max-fraction-digits"]&&(c=n.parse(i["max-fraction-digits"],1,v3),!c)?null:new t(r,s,o,a,l,c)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}},object:T5,slice:class t{constructor(t,e,n,r){this.type=t,this.input=e,this.beginIndex=n,this.endIndex=r}static parse(e,n){if(e.length<=2||e.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,S3),i=n.parse(e[2],2,v3);if(!r||!i)return null;if(!F3(r.type,[M3(S3),b3,S3]))return n.error(`Expected first argument to be of type array or string, but found ${A3(r.type)} instead`);if(4===e.length){const s=n.parse(e[3],3,v3);return s?new t(r.type,r,i,s):null}return new t(r.type,r,i)}evaluate(t){const e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);let r;if(this.endIndex&&(r=this.endIndex.evaluate(t)),D3(e,["string"]))return[...e].slice(n,r).join("");if(D3(e,["array"]))return e.slice(n,r);throw new y5(`Expected first argument to be of type array or string, but found ${A3(S5(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},step:D5,string:T5,"to-boolean":I5,"to-color":I5,"to-number":I5,"to-string":I5,var:N5,within:m4,distance:$4,"global-state":q4},W4=class t{constructor(t,e,n,r){this.name=t,this.type=e,this._evaluate=n,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(e,n){const r=e[0],i=t.definitions[r];if(!i)return n.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(i)?i[0]:i.type,o=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,a=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let l=null;for(const[c,u]of a){l=new A5(n.registry,Y4,n.path,null,n.scope);const i=[];let o=!1;for(let t=1;t{return e=t,Array.isArray(e)?`(${e.map(A3).join(", ")})`:`(${A3(e.type)}...)`;var e}).join(" | "),r=[];for(let i=1;i{n=e?n&&Y4(t):n&&t instanceof E5}),!!n&&X4(t)&&Q4(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function X4(t){if(t instanceof W4){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof m4)return!1;if(t instanceof $4)return!1;let e=!0;return t.eachChild(t=>{e&&!X4(t)&&(e=!1)}),e}function J4(t){if(t instanceof W4&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild(t=>{e&&!J4(t)&&(e=!1)}),e}function Q4(t,e){if(t instanceof W4&&e.indexOf(t.name)>=0)return!1;let n=!0;return t.eachChild(t=>{n&&!Q4(t,e)&&(n=!1)}),n}function t6(t){return{result:"success",value:t}}function e6(t){return{result:"error",value:t}}function n6(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function r6(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function i6(t){return!!t.expression&&t.expression.interpolated}function s6(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function o6(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&S5(t)===C3}W4.register(V4,{error:[{kind:"error"},[b3],(t,[e])=>{throw new y5(e.evaluate(t))}],typeof:[b3,[S3],(t,[e])=>A3(S5(e.evaluate(t)))],"to-rgba":[M3(v3,4),[_3],(t,[e])=>{const[n,r,i,s]=e.evaluate(t).rgb;return[255*n,255*r,255*i,s]}],rgb:[_3,[v3,v3,v3],H4],rgba:[_3,[v3,v3,v3,v3],H4],has:{type:w3,overloads:[[[b3],(t,[e])=>G4(e.evaluate(t),t.properties())],[[b3,C3],(t,[e,n])=>G4(e.evaluate(t),n.evaluate(t))]]},get:{type:S3,overloads:[[[b3],(t,[e])=>K4(e.evaluate(t),t.properties())],[[b3,C3],(t,[e,n])=>K4(e.evaluate(t),n.evaluate(t))]]},"feature-state":[S3,[b3],(t,[e])=>K4(e.evaluate(t),t.featureState||{})],properties:[C3,[],t=>t.properties()],"geometry-type":[b3,[],t=>t.geometryType()],id:[S3,[],t=>t.id()],zoom:[v3,[],t=>t.globals.zoom],"heatmap-density":[v3,[],t=>t.globals.heatmapDensity||0],elevation:[v3,[],t=>t.globals.elevation||0],"line-progress":[v3,[],t=>t.globals.lineProgress||0],accumulated:[S3,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[v3,Z4(v3),(t,e)=>{let n=0;for(const r of e)n+=r.evaluate(t);return n}],"*":[v3,Z4(v3),(t,e)=>{let n=1;for(const r of e)n*=r.evaluate(t);return n}],"-":{type:v3,overloads:[[[v3,v3],(t,[e,n])=>e.evaluate(t)-n.evaluate(t)],[[v3],(t,[e])=>-e.evaluate(t)]]},"/":[v3,[v3,v3],(t,[e,n])=>e.evaluate(t)/n.evaluate(t)],"%":[v3,[v3,v3],(t,[e,n])=>e.evaluate(t)%n.evaluate(t)],ln2:[v3,[],()=>Math.LN2],pi:[v3,[],()=>Math.PI],e:[v3,[],()=>Math.E],"^":[v3,[v3,v3],(t,[e,n])=>Math.pow(e.evaluate(t),n.evaluate(t))],sqrt:[v3,[v3],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[v3,[v3],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[v3,[v3],(t,[e])=>Math.log(e.evaluate(t))],log2:[v3,[v3],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[v3,[v3],(t,[e])=>Math.sin(e.evaluate(t))],cos:[v3,[v3],(t,[e])=>Math.cos(e.evaluate(t))],tan:[v3,[v3],(t,[e])=>Math.tan(e.evaluate(t))],asin:[v3,[v3],(t,[e])=>Math.asin(e.evaluate(t))],acos:[v3,[v3],(t,[e])=>Math.acos(e.evaluate(t))],atan:[v3,[v3],(t,[e])=>Math.atan(e.evaluate(t))],min:[v3,Z4(v3),(t,e)=>Math.min(...e.map(e=>e.evaluate(t)))],max:[v3,Z4(v3),(t,e)=>Math.max(...e.map(e=>e.evaluate(t)))],abs:[v3,[v3],(t,[e])=>Math.abs(e.evaluate(t))],round:[v3,[v3],(t,[e])=>{const n=e.evaluate(t);return n<0?-Math.round(-n):Math.round(n)}],floor:[v3,[v3],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[v3,[v3],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[w3,[b3,S3],(t,[e,n])=>t.properties()[e.value]===n.value],"filter-id-==":[w3,[S3],(t,[e])=>t.id()===e.value],"filter-type-==":[w3,[b3],(t,[e])=>t.geometryType()===e.value],"filter-<":[w3,[b3,S3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r{const n=t.id(),r=e.value;return typeof n==typeof r&&n":[w3,[b3,S3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[w3,[S3],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>r}],"filter-<=":[w3,[b3,S3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[w3,[S3],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n<=r}],"filter->=":[w3,[b3,S3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[w3,[S3],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>=r}],"filter-has":[w3,[S3],(t,[e])=>e.value in t.properties()],"filter-has-id":[w3,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[w3,[M3(b3)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[w3,[M3(S3)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[w3,[b3,M3(S3)],(t,[e,n])=>n.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[w3,[b3,M3(S3)],(t,[e,n])=>function(t,e,n,r){for(;n<=r;){const i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[e.value],n.value,0,n.value.length-1)],all:{type:w3,overloads:[[[w3,w3],(t,[e,n])=>e.evaluate(t)&&n.evaluate(t)],[Z4(w3),(t,e)=>{for(const n of e)if(!n.evaluate(t))return!1;return!0}]]},any:{type:w3,overloads:[[[w3,w3],(t,[e,n])=>e.evaluate(t)||n.evaluate(t)],[Z4(w3),(t,e)=>{for(const n of e)if(n.evaluate(t))return!0;return!1}]]},"!":[w3,[w3],(t,[e])=>!e.evaluate(t)],"is-supported-script":[w3,[b3],(t,[e])=>{const n=t.globals&&t.globals.isSupportedScript;return!n||n(e.evaluate(t))}],upcase:[b3,[b3],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[b3,[b3],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[b3,Z4(S3),(t,e)=>e.map(e=>k5(e.evaluate(t))).join("")],split:[M3(b3),[b3,b3],(t,[e,n])=>e.evaluate(t).split(n.evaluate(t))],join:[b3,[M3(b3),b3],(t,[e,n])=>e.evaluate(t).join(n.evaluate(t))],"resolved-locale":[b3,[k3],(t,[e])=>e.evaluate(t).resolvedLocale()]});var a6=class{constructor(t,e,n){this.expression=t,this._warningHistory={},this._evaluator=new M5,this._defaultValue=e?function(t){if("color"===t.type&&o6(t.default))return new c5(0,0,0,0);switch(t.type){case"color":return c5.parse(t.default)||null;case"padding":return f5.parse(t.default)||null;case"numberArray":return g5.parse(t.default)||null;case"colorArray":return m5.parse(t.default)||null;case"variableAnchorOffsetCollection":return b5.parse(t.default)||null;case"projectionDefinition":return _5.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this._globalState=n}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=g6(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,n,r,i,s){this._globalState&&(t=g6(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new y5(`Expected value to be one of ${Object.keys(this._enumValues).map(t=>JSON.stringify(t)).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(o){return this._warningHistory[o.message]||(this._warningHistory[o.message]=!0,"undefined"!=typeof console&&console.warn(o.message)),this._defaultValue}}};function l6(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in V4}function c6(t,e,n){const r=new A5(V4,Y4,[],e?function(t){const e={color:_3,string:b3,number:v3,enum:b3,boolean:w3,formatted:E3,padding:R3,numberArray:L3,colorArray:T3,projectionDefinition:x3,resolvedImage:I3,variableAnchorOffsetCollection:P3};return"array"===t.type?M3(e[t.value]||S3,t.length):e[t.type]}(e):void 0),i=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return i?t6(new a6(i,e,n)):e6(r.errors)}var u6=class{constructor(t,e,n){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!J4(e.expression),this.globalStateRefs=f6(e.expression),this._globalState=n}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=g6(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._globalState&&(t=g6(t,this._globalState)),this._styleExpression.evaluate(t,e,n,r,i,s)}},h6=class{constructor(t,e,n,r,i){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!J4(e.expression),this.globalStateRefs=f6(e.expression),this.interpolationType=r,this._globalState=i}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=g6(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._globalState&&(t=g6(t,this._globalState)),this._styleExpression.evaluate(t,e,n,r,i,s)}interpolationFactor(t,e,n){return this.interpolationType?z5.interpolationFactor(this.interpolationType,t,e,n):0}};function d6(t,e,n){const r=c6(t,e,n);if("error"===r.result)return r;const i=r.value.expression,s=X4(i);if(!s&&!n6(e))return e6([new g3("","data expressions not supported")]);const o=Q4(i,["zoom"]);if(!o&&!r6(e))return e6([new g3("","zoom expressions not supported")]);const a=p6(i);if(!a&&!o)return e6([new g3("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(a instanceof g3)return e6([a]);if(a instanceof z5&&!i6(e))return e6([new g3("",'"interpolate" expressions cannot be used with this property')]);if(!a)return t6(new u6(s?"constant":"source",r.value,n));const l=a instanceof z5?a.interpolation:void 0;return t6(new h6(s?"camera":"composite",r.value,a.labels,l,n))}function p6(t){let e=null;if(t instanceof O5)e=p6(t.result);else if(t instanceof U5){for(const n of t.args)if(e=p6(n),e)break}else(t instanceof D5||t instanceof z5)&&t.input instanceof W4&&"zoom"===t.input.name&&(e=t);return e instanceof g3||t.eachChild(t=>{const n=p6(t);n instanceof g3?e=n:!e&&n?e=new g3("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new g3("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function f6(t,e=new Set){return t instanceof q4&&e.add(t.key),t.eachChild(t=>{f6(t,e)}),e}function g6(t,e){const{zoom:n,heatmapDensity:r,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a}=t??{};return{zoom:n,heatmapDensity:r,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:e}}function m6(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!m6(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}var y6={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function v6(t,e){return te?1:0}function b6(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?_6(t[1],t[2],e):"any"===e?(n=t.slice(1),["any"].concat(n.map(w6))):"all"===e?["all"].concat(t.slice(1).map(w6)):"none"===e?["all"].concat(t.slice(1).map(w6).map(S6)):"in"===e?x6(t[1],t.slice(2)):"!in"===e?S6(x6(t[1],t.slice(2))):"has"===e?C6(t[1]):"!has"!==e||S6(C6(t[1]));var n}function _6(t,e,n){switch(t){case"$type":return[`filter-type-${n}`,e];case"$id":return[`filter-id-${n}`,e];default:return[`filter-${n}`,t,e]}}function x6(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(t=>typeof t!=typeof e[0])?["filter-in-large",t,["literal",e.sort(v6)]]:["filter-in-small",t,["literal",e]]}}function C6(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function S6(t){return["!",t]}function k6(t){return"object"==typeof t?["literal",t]:t}function E6(t,e){let n=t.stops;if(!n)return function(t,e){const n=["get",t.property];if(void 0===t.default)return"string"===e.type?["string",n]:n;if("enum"===e.type)return["match",n,Object.keys(e.values),n,t.default];{const r=["color"===e.type?"to-color":e.type,n,k6(t.default)];return"array"===e.type&&r.splice(1,0,e.value,e.length||null),r}}(t,e);const r=n&&"object"==typeof n[0][0],i=r||void 0!==t.property,s=r||!i;return n=n.map(t=>!i&&e.tokens&&"string"==typeof t[1]?[t[0],A6(t[1])]:[t[0],k6(t[1])]),r?function(t,e,n){const r={},i={},s=[];for(let o=0;o3&&e===t[t.length-2]||(r&&2===t.length||t.push(e),t.push(n))}function M6(t,e){return t.type?t.type:e.expression.interpolated?"exponential":"interval"}function A6(t){const e=["concat"],n=/{([^{}]+)}/g;let r=0;for(let i=n.exec(t);null!==i;i=n.exec(t)){const s=t.slice(r,n.lastIndex-i[0].length);r=n.lastIndex,s.length>0&&e.push(s),e.push(["get",i[1]])}if(1===e.length)return t;if(rr.maximum?[new p3(e,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]}function U6(t){const e=t.valueSpec,n=N6(t.value.type);let r,i,s,o={};const a="categorical"!==n&&void 0===t.value.property,l=!a,c="array"===s6(t.value.stops)&&"array"===s6(t.value.stops[0])&&"object"===s6(t.value.stops[0][0]),u=D6({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===n)return[new p3(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(z6({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===s6(r)&&0===r.length&&e.push(new p3(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===n&&a&&u.push(new p3(t.key,t.value,'missing required property "property"')),"identity"===n||t.value.stops||u.push(new p3(t.key,t.value,'missing required property "stops"')),"exponential"===n&&t.valueSpec.expression&&!i6(t.valueSpec)&&u.push(new p3(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!n6(t.valueSpec)?u.push(new p3(t.key,t.value,"property functions not supported")):a&&!r6(t.valueSpec)&&u.push(new p3(t.key,t.value,"zoom functions not supported"))),"categorical"!==n&&!c||void 0!==t.value.property||u.push(new p3(t.key,t.value,'"property" property is required')),u;function h(t){let n=[];const r=t.value,a=t.key;if("array"!==s6(r))return[new p3(a,r,`array expected, ${s6(r)} found`)];if(2!==r.length)return[new p3(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==s6(r[0]))return[new p3(a,r,`object expected, ${s6(r[0])} found`)];if(void 0===r[0].zoom)return[new p3(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new p3(a,r,"object stop key must have value")];if(s&&s>N6(r[0].zoom))return[new p3(a,r[0].zoom,"stop zoom values must appear in ascending order")];N6(r[0].zoom)!==s&&(s=N6(r[0].zoom),i=void 0,o={}),n=n.concat(D6({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:j6,value:d}}))}else n=n.concat(d({key:`${a}[0]`,value:r[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return l6(F6(r[1]))?n.concat([new p3(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):n.concat(t.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function d(t,s){const a=s6(t.value),l=N6(t.value),c=null!==t.value?t.value:s;if(r){if(a!==r)return[new p3(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new p3(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==n){let r=`number expected, ${a} found`;return n6(e)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new p3(t.key,c,r)]}return"categorical"!==n||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===a&&void 0!==i&&lnew p3(`${t.key}${e.key}`,t.value,e.message));const n=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new p3(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!J4(n))return[new p3(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!J4(n))return[new p3(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Q4(n,["zoom","feature-state"]))return[new p3(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!X4(n))return[new p3(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $6(t){const e=t.key,n=t.value,r=s6(n);return"string"!==r?[new p3(e,n,`color expected, ${r} found`)]:c5.parse(String(n))?[]:[new p3(e,n,`color expected, "${n}" found`)]}function q6(t){const e=t.key,n=t.value,r=t.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(N6(n))&&i.push(new p3(e,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(N6(n))&&i.push(new p3(e,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function V6(t){return m6(F6(t.value))?B6(f3({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):W6(t)}function W6(t){const e=t.value,n=t.key;if("array"!==s6(e))return[new p3(n,e,`array expected, ${s6(e)} found`)];const r=t.styleSpec;let i,s=[];if(e.length<1)return[new p3(n,e,"filter array must have at least 1 element")];switch(s=s.concat(q6({key:`${n}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),N6(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===N6(e[1])&&s.push(new p3(n,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new p3(n,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=s6(e[1]),"string"!==i&&s.push(new p3(`${n}[1]`,e[1],`string expected, ${i} found`)));for(let o=2;o{t in n&&e.push(new p3(r,n[t],`"${t}" is prohibited for ref layers`))}),i.layers.forEach(e=>{N6(e.id)===a&&(t=e)}),t?t.ref?e.push(new p3(r,n.ref,"ref cannot reference another ref layer")):o=N6(t.type):e.push(new p3(r,n.ref,`ref layer "${a}" not found`))}else if("background"!==o)if(n.source){const t=i.sources&&i.sources[n.source],s=t&&N6(t.type);t?"vector"===s&&"raster"===o?e.push(new p3(r,n.source,`layer "${n.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===o||"raster-dem"!==s&&"color-relief"===o?e.push(new p3(r,n.source,`layer "${n.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==o?e.push(new p3(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==s||n["source-layer"]?"raster-dem"===s&&"hillshade"!==o&&"color-relief"!==o?e.push(new p3(r,n.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==o||!n.paint||!n.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new p3(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new p3(r,n,`layer "${n.id}" must specify a "source-layer"`)):e.push(new p3(r,n.source,`source "${n.source}" not found`))}else e.push(new p3(r,n,'missing required property "source"'));return"raster"===o&&n.paint?.resampling&&n.paint?.["raster-resampling"]&&e.push(new p3(r,n.paint,`layer "${n.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),e=e.concat(D6({key:r,value:n,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:n.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:n,objectKey:"type"}),filter:V6,layout:t=>D6({layer:n,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>K6(f3({layerType:o},t))}}),paint:t=>D6({layer:n,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>G6(f3({layerType:o},t))}})}})),e}function Y6(t){const e=t.value,n=t.key,r=s6(e);return"string"!==r?[new p3(n,e,`string expected, ${r} found`)]:[]}var X6={promoteId:function({key:t,value:e}){if("string"===s6(e))return Y6({key:t,value:e});{const n=[];for(const r in e)n.push(...Y6({key:`${t}.${r}`,value:e[r]}));return n}}};function J6(t){const e=t.value,n=t.key,r=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return[new p3(n,e,'"type" is required')];const o=N6(e.type);let a;switch(o){case"vector":case"raster":return a=D6({key:n,value:e,valueSpec:r[`source_${o.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:X6,validateSpec:s}),a;case"raster-dem":return a=function(t){const e=t.sourceName??"",n=t.value,r=t.styleSpec,i=r.source_raster_dem,s=t.style;let o=[];const a=s6(n);if(void 0===n)return o;if("object"!==a)return o.push(new p3("source_raster_dem",n,`object expected, ${a} found`)),o;const l="custom"===N6(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const h in n)!l&&c.includes(h)?o.push(new p3(h,n[h],`In "${e}": "${h}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):i[h]?o=o.concat(t.validateSpec({key:h,value:n[h],valueSpec:i[h],validateSpec:t.validateSpec,style:s,styleSpec:r})):o.push(new p3(h,n[h],`unknown property "${h}"`));return o}({sourceName:n,value:e,style:t.style,styleSpec:r,validateSpec:s}),a;case"geojson":if(a=D6({key:n,value:e,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:s,objectElementValidators:X6}),e.cluster)for(const t in e.clusterProperties){const[r,i]=e.clusterProperties[t],o="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...B6({key:`${n}.${t}.map`,value:i,validateSpec:s,expressionContext:"cluster-map"})),a.push(...B6({key:`${n}.${t}.reduce`,value:o,validateSpec:s,expressionContext:"cluster-reduce"}))}return a;case"video":return D6({key:n,value:e,valueSpec:r.source_video,style:i,validateSpec:s,styleSpec:r});case"image":return D6({key:n,value:e,valueSpec:r.source_image,style:i,validateSpec:s,styleSpec:r});case"canvas":return[new p3(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return q6({key:`${n}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:s,styleSpec:r})}}function Q6(t){const e=t.value,n=t.styleSpec,r=n.light,i=t.style;let s=[];const o=s6(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new p3("light",e,`object expected, ${o} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=o&&r[o[1]]&&r[o[1]].transition?s.concat(t.validateSpec({key:a,value:e[a],valueSpec:n.transition,validateSpec:t.validateSpec,style:i,styleSpec:n})):r[a]?s.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:i,styleSpec:n})):s.concat([new p3(a,e[a],`unknown property "${a}"`)])}return s}function t8(t){const e=t.value,n=t.styleSpec,r=n.sky,i=t.style,s=s6(e);if(void 0===e)return[];if("object"!==s)return[new p3("sky",e,`object expected, ${s} found`)];let o=[];for(const a in e)o=r[a]?o.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],style:i,styleSpec:n})):o.concat([new p3(a,e[a],`unknown property "${a}"`)]);return o}function e8(t){const e=t.value,n=t.styleSpec,r=n.terrain,i=t.style;let s=[];const o=s6(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new p3("terrain",e,`object expected, ${o} found`)]),s;for(const a in e)s=r[a]?s.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:i,styleSpec:n})):s.concat([new p3(a,e[a],`unknown property "${a}"`)]);return s}function n8(t){let e=[];const n=t.value,r=t.key;if(Array.isArray(n)){const i=[],s=[];for(const o in n)n[o].id&&i.includes(n[o].id)&&e.push(new p3(r,n,`all the sprites' ids must be unique, but ${n[o].id} is duplicated`)),i.push(n[o].id),n[o].url&&s.includes(n[o].url)&&e.push(new p3(r,n,`all the sprites' URLs must be unique, but ${n[o].url} is duplicated`)),s.push(n[o].url),e=e.concat(D6({key:`${r}[${o}]`,value:n[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Y6({key:r,value:n})}function r8(t){return Boolean(t)&&t.constructor===Object}function i8(t){return r8(t.value)?[]:[new p3(t.key,t.value,`object expected, ${s6(t.value)} found`)]}var s8={"*":()=>[],array:z6,boolean:function(t){const e=t.value,n=t.key,r=s6(e);return"boolean"!==r?[new p3(n,e,`boolean expected, ${r} found`)]:[]},number:j6,color:$6,constants:O6,enum:q6,filter:V6,function:U6,layer:Z6,object:D6,source:J6,light:Q6,sky:t8,terrain:e8,projection:function(t){const e=t.value,n=t.styleSpec,r=n.projection,i=t.style,s=s6(e);if(void 0===e)return[];if("object"!==s)return[new p3("projection",e,`object expected, ${s} found`)];let o=[];for(const a in e)o=r[a]?o.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],style:i,styleSpec:n})):o.concat([new p3(a,e[a],`unknown property "${a}"`)]);return o},projectionDefinition:function(t){const e=t.key;let n=t.value;n=n instanceof String?n.valueOf():n;const r=s6(n);return"array"!==r||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(n)||function(t){return!!["interpolate","step","literal"].includes(t[0])}(n)?["array","string"].includes(r)?[]:[new p3(e,n,`projection expected, invalid type "${r}" found`)]:[new p3(e,n,`projection expected, invalid array ${JSON.stringify(n)} found`)]},string:Y6,formatted:function(t){return 0===Y6(t).length?[]:B6(t)},resolvedImage:function(t){return 0===Y6(t).length?[]:B6(t)},padding:function(t){const e=t.key,n=t.value;if("array"===s6(n)){if(n.length<1||n.length>4)return[new p3(e,n,`padding requires 1 to 4 values; ${n.length} values found`)];const r={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(n=n.concat(O6({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:o8}))),u8(n)}function c8(t){return function(e){return t(Object.assign({},e,{validateSpec:o8}))}}function u8(t){return[].concat(t).sort((t,e)=>t.line-e.line)}function h8(t){return function(...e){return u8(t.apply(this,e))}}l8.source=h8(c8(J6)),l8.sprite=h8(c8(n8)),l8.glyphs=h8(c8(a8)),l8.light=h8(c8(Q6)),l8.sky=h8(c8(t8)),l8.terrain=h8(c8(e8)),l8.state=h8(c8(i8)),l8.layer=h8(c8(Z6)),l8.filter=h8(c8(V6)),l8.paintProperty=h8(c8(G6)),l8.layoutProperty=h8(c8(K6));var d8=c3,p8=4294967296,f8="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8"),g8=class{constructor(t){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(t,e,n=this.length){let r;for(;r=this.nextField(n);)t(r,e,this);return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*p8;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*p8;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf,n=e[this.pos++];if(n<128)return n;let r,i=127&n;return r=e[this.pos++],i|=(127&r)<<7,r<128?i:(r=e[this.pos++],i|=(127&r)<<14,r<128?i:(r=e[this.pos++],i|=(127&r)<<21,r<128?i:(r=e[this.pos],i|=(15&r)<<28,function(t,e,n){const r=n.buf;let i,s;if(s=r[n.pos++],i=(112&s)>>4,s<128)return m8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<3,s<128)return m8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<10,s<128)return m8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<17,s<128)return m8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<24,s<128)return m8(t,i,e);if(s=r[n.pos++],i|=(1&s)<<31,s<128)return m8(t,i,e);throw new Error("Expected varint not more than 10 bytes")}(i,t,this))))}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&f8?f8.decode(this.buf.subarray(e,t)):function(t,e,n){let r="",i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+c>n)break;1===c?e<128&&(l=e):2===c?(s=t[i+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===c?(s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),i+=c}return r}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos=t)return 0;const e=this.readVarint();return this.type=7&e,this._valueStart=this.pos,e>>>3}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}};function m8(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}var y8=class extends B2{constructor(t){super(),t=t||{},this.dataProjection=new qG({code:"",units:"tile-pixels"}),this.featureClass=t.featureClass?t.featureClass:P2,this.geometryName_=t.geometryName,this.layerName_=t.layerName?t.layerName:"layer",this.layers_=t.layers?t.layers:null,this.idProperty_=t.idProperty,this.supportedMediaTypes=["application/vnd.mapbox-vector-tile","application/x-protobuf"]}readRawGeometry_(t,e,n,r){t.pos=e.geometry;const i=t.readVarint()+t.pos;let s=1,o=0,a=0,l=0,c=0,u=0;for(;t.pos>3}if(o--,1===s||2===s)a+=t.readSVarint(),l+=t.readSVarint(),1===s&&c>u&&(r.push(c),u=c),n.push(a,l),c+=2;else{if(7!==s)throw new Error("Invalid command found in the PBF");c>u&&(n.push(n[u],n[u+1]),c+=2)}}c>u&&(r.push(c),u=c)}createFeature_(t,e,n){const r=e.type;if(0===r)return null;let i;const s=e.properties;let o;this.idProperty_?(o=s[this.idProperty_],delete s[this.idProperty_]):o=e.id,s[this.layerName_]=e.layer.name;const a=[],l=[];this.readRawGeometry_(t,e,a,l);const c=function(t,e){let n;return 1===t?n=1===e?"Point":"MultiPoint":2===t?n=1===e?"LineString":"MultiLineString":3===t&&(n="Polygon"),n}(r,l.length);if(this.featureClass===P2)i=new this.featureClass(c,a,l,2,s,o),i.transform(n.dataProjection);else{let t;if("Polygon"==c){const e=tY(a,l);t=e.length>1?new C1(a,"XY",e):new eY(a,"XY",l)}else t="Point"===c?new WZ(a,"XY"):"LineString"===c?new b1(a,"XY"):"MultiPoint"===c?new _1(a,"XY"):"MultiLineString"===c?new w1(a,"XY",l):null;i=new(0,this.featureClass),this.geometryName_&&i.setGeometryName(this.geometryName_);const e=$2(t,!1,n);i.setGeometry(e),void 0!==o&&i.setId(o),i.setProperties(s,!0)}return i}getType(){return"arraybuffer"}readFeatures(t,e){const n=this.layers_,r=zK((e=this.adaptOptions(e)).dataProjection);r.setWorldExtent(e.extent),e.dataProjection=r;const i=new g8(t),s=i.readFields(v8,{}),o=[];for(const a in s){if(n&&!n.includes(a))continue;const t=s[a],l=t?[0,0,t.extent,t.extent]:null;r.setExtent(l);for(let n=0,r=t.length;n>3)?n.readString():2===t?n.readFloat():3===t?n.readDouble():4===t?n.readVarint(!0):5===t?n.readVarint():6===t?n.readSVarint():7===t?n.readBoolean():null;e.values.push(r)}}function w8(t,e,n){if(1==t)e.id=n.readVarint();else if(2==t){const t=n.readVarint()+n.pos;for(;n.post)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){rH()}getAlpha(t,e){if(!this.transition_)return 1;let n=this.transitionStarts_[t];if(n){if(-1===n)return 1}else n=e,this.transitionStarts_[t]=n;const r=e-n+1e3/60;return r>=this.transition_?1:NG(r/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}};function C8(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}var S8,k8=new Error("disposed"),E8=[256,256],R8=class extends x8{constructor(t){super(t.tileCoord,0,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=C8(this.data_);return t?[t.width,t.height]:E8}getData(){return this.data_}getError(){return this.error_}load(){if(0!==this.state&&3!==this.state)return;this.state=1,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=2,t.changed()}).catch(function(e){t.error_=e,t.state=3,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(k8),this.controller_=null),super.disposeInternal()}},T8=class extends x8{constructor(t,e,n,r,i,s){super(t,e,s),this.crossOrigin_=r?.crossOrigin,this.referrerPolicy_=r?.referrerPolicy,this.src_=n,this.key=n,this.image_,vH?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=i}getImage(){return this.image_}setImage(t){this.image_=t,this.state=2,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=3,this.unlistenImage_(),this.image_=function(){const t=_Y(1,1);return t.fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas}(),this.changed()}handleImageLoad_(){if(vH)this.state=2;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=2:this.state=4}this.unlistenImage_(),this.changed()}load(){3==this.state&&(this.state=0,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),0==this.state&&(this.state=1,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=function(t,e,n){const r=t;let i=!0,s=!1,o=!1;const a=[AW(r,"load",function(){o=!0,s||e()})];return r.src&&bH?(s=!0,r.decode().then(function(){i&&e()}).catch(function(){i&&(o?e():n())})):a.push(AW(r,"error",n)),function(){i=!1,a.forEach(OW)}}(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}},L8=class{constructor(t,e,n,r){this.minX=t,this.maxX=e,this.minY=n,this.maxY=r}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minXthis.maxX&&(this.maxX=t.maxX),t.minYthis.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}};function I8(t,e,n,r,i){return void 0!==i?(i.minX=t,i.maxX=e,i.minY=n,i.maxY=r,i):new L8(t,e,n,r)}var P8=[];function M8(t,e,n,r,i){t.beginPath(),t.moveTo(0,0),t.lineTo(e,n),t.lineTo(r,i),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,r)+1,Math.max(n,i)),t.restore()}function A8(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function O8(t,e,n,r){const i=KK(n,e,t);let s=jK(e,r,n);const o=e.getMetersPerUnit();void 0!==o&&(s*=o);const a=t.getMetersPerUnit();void 0!==a&&(s/=a);const l=t.getExtent();if(!l||QH(l,i)){const e=jK(t,s,i)/s;isFinite(e)&&e>0&&(s/=e)}return s}function N8(t,e,n,r,i,s,o,a,l,c,u,h,d,p){const f=_Y(Math.round(n*t),Math.round(n*e),P8);if(h||(f.imageSmoothingEnabled=!1),0===l.length)return f.canvas;function g(t){return Math.round(t*n)/n}f.scale(n,n),f.globalCompositeOperation="lighter";const m=[1/0,1/0,-1/0,-1/0];let y;l.forEach(function(t){lG(m,t.extent)});const v=n/r,b=(h?1:1+Math.pow(2,-24))/v;if(!d||1!==l.length||0!==c){if(y=_Y(Math.round(kG(m)*v),Math.round(wG(m)*v),P8),h||(y.imageSmoothingEnabled=!1),i&&p){const t=(i[0]-m[0])*v,e=-(i[3]-m[3])*v,n=kG(i)*v,r=wG(i)*v;y.rect(t,e,n,r),y.clip()}l.forEach(function(t){if(t.image.width>0&&t.image.height>0){if(t.clipExtent){y.save();const e=(t.clipExtent[0]-m[0])*v,n=-(t.clipExtent[3]-m[3])*v,r=kG(t.clipExtent)*v,i=wG(t.clipExtent)*v;y.rect(h?e:Math.round(e),h?n:Math.round(n),h?r:Math.round(e+r)-Math.round(e),h?i:Math.round(n+i)-Math.round(n)),y.clip()}const e=(t.extent[0]-m[0])*v,n=-(t.extent[3]-m[3])*v,r=kG(t.extent)*v,i=wG(t.extent)*v;y.drawImage(t.image,c,c,t.image.width-2*c,t.image.height-2*c,h?e:Math.round(e),h?n:Math.round(n),h?r:Math.round(e+r)-Math.round(e),h?i:Math.round(n+i)-Math.round(n)),t.clipExtent&&y.restore()}})}const w=CG(o);return a.getTriangles().forEach(function(t){const e=t.source,n=t.target;let r=e[0][0],i=e[0][1],o=e[1][0],a=e[1][1],c=e[2][0],u=e[2][1];const d=g((n[0][0]-w[0])/s),p=g(-(n[0][1]-w[1])/s),v=g((n[1][0]-w[0])/s),_=g(-(n[1][1]-w[1])/s),x=g((n[2][0]-w[0])/s),C=g(-(n[2][1]-w[1])/s),S=r,k=i;r=0,i=0,o-=S,a-=k,c-=S,u-=k;const E=function(t){const e=t.length;for(let r=0;ri&&(i=e,n=o)}if(0===i)return null;const s=t[n];t[n]=t[r],t[r]=s;for(let o=r+1;o=0;r--){n[r]=t[r][e]/t[r][r];for(let i=r-1;i>=0;i--)t[i][e]-=t[i][r]*n[r]}return n}([[o,a,0,0,v-d],[c,u,0,0,x-d],[0,0,o,a,_-p],[0,0,c,u,C-p]]);if(!E)return;if(f.save(),f.beginPath(),function(){if(void 0===S8){const t=_Y(6,6,P8);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",M8(t,4,5,4,0),M8(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;S8=A8(e,0)||A8(e,4)||A8(e,8),CY(t),P8.push(t.canvas)}return S8}()||!h){f.moveTo(v,_);const t=4,e=d-v,n=p-_;for(let r=0;rsZ(o,KK(t,this.targetProj_,this.sourceProj_)),function(t,e,n,r){const i=t.length;n=void 0!==n?n:2,r=r??n,e=void 0!==e?e:new Array(i);for(let s=0;s=o?t[s+n]:i[n]}return e}):GK(this.targetProj_,this.sourceProj_);var c;this.transformInv_=function(t){const e=t[0]+"/"+t[1];return a[e]||(a[e]=l(t)),a[e]},this.maxSourceExtent_=r,this.errorThresholdSquared_=i*i,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&kG(r)>=kG(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?kG(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?kG(this.targetProj_.getExtent()):null;const u=CG(n),h=SG(n),d=gG(n),p=fG(n),f=this.transformInv_(u),g=this.transformInv_(h),m=this.transformInv_(d),y=this.transformInv_(p),v=10+(s?Math.max(0,Math.ceil(Math.log2(pG(n)/(s*s*256*256)))):0);if(this.addQuad_(u,h,d,p,f,g,m,y,v),this.wrapsXInSource_){let t=1/0;this.triangles_.forEach(function(e){t=Math.min(t,e.source[0][0],e.source[1][0],e.source[2][0])}),this.triangles_.forEach(e=>{if(Math.max(e.source[0][0],e.source[1][0],e.source[2][0])-t>this.sourceWorldWidth_/2){const n=[[e.source[0][0],e.source[0][1]],[e.source[1][0],e.source[1][1]],[e.source[2][0],e.source[2][1]]];n[0][0]-t>this.sourceWorldWidth_/2&&(n[0][0]-=this.sourceWorldWidth_),n[1][0]-t>this.sourceWorldWidth_/2&&(n[1][0]-=this.sourceWorldWidth_),n[2][0]-t>this.sourceWorldWidth_/2&&(n[2][0]-=this.sourceWorldWidth_);const r=Math.min(n[0][0],n[1][0],n[2][0]);Math.max(n[0][0],n[1][0],n[2][0])-r.5&&u<1;let p=!1;if(l>0&&(this.targetProj_.isGlobal()&&this.targetWorldWidth_&&(p=kG(ZH([t,e,n,r]))/this.targetWorldWidth_>.25||p),!d&&this.sourceProj_.isGlobal()&&u&&(p=u>.25||p)),!p&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!EG(c,this.maxSourceExtent_))return;let f=0;if(!(p||isFinite(i[0])&&isFinite(i[1])&&isFinite(s[0])&&isFinite(s[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(a[0])&&isFinite(a[1])))if(l>0)p=!0;else if(f=(isFinite(i[0])&&isFinite(i[1])?0:8)+(isFinite(s[0])&&isFinite(s[1])?0:4)+(isFinite(o[0])&&isFinite(o[1])?0:2)+(isFinite(a[0])&&isFinite(a[1])?0:1),1!=f&&2!=f&&4!=f&&8!=f)return;if(l>0){if(!p){const e=[(t[0]+n[0])/2,(t[1]+n[1])/2],r=this.transformInv_(e);let s;s=d?(BH(i[0],h)+BH(o[0],h))/2-BH(r[0],h):(i[0]+o[0])/2-r[0];const a=(i[1]+o[1])/2-r[1];p=s*s+a*a>this.errorThresholdSquared_}if(p){if(Math.abs(t[0]-n[0])<=Math.abs(t[1]-n[1])){const c=[(e[0]+n[0])/2,(e[1]+n[1])/2],u=this.transformInv_(c),h=[(r[0]+t[0])/2,(r[1]+t[1])/2],d=this.transformInv_(h);this.addQuad_(t,e,c,h,i,s,u,d,l-1),this.addQuad_(h,c,n,r,d,u,o,a,l-1)}else{const c=[(t[0]+e[0])/2,(t[1]+e[1])/2],u=this.transformInv_(c),h=[(n[0]+r[0])/2,(n[1]+r[1])/2],d=this.transformInv_(h);this.addQuad_(t,c,h,r,i,u,d,a,l-1),this.addQuad_(c,e,n,h,u,s,o,d,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}11&f||this.addTriangle_(t,n,r,i,o,a),14&f||this.addTriangle_(t,n,e,i,o,s),f&&(13&f||this.addTriangle_(e,r,t,s,a,i),7&f||this.addTriangle_(e,r,n,s,a,o))}calculateSourceExtent(){const t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach(function(e){const n=e.source;cG(t,n[0]),cG(t,n[1]),cG(t,n[2])}),t}getTriangles(){return this.triangles_}},D8=class extends x8{constructor(t,e,n,r,i,s,o,a,l,c,u,h){super(i,0,h),this.renderEdges_=void 0!==u&&u,this.pixelRatio_=o,this.gutter_=a,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=r,this.wrappedTileCoord_=s||i,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const d=r.getTileCoordExtent(this.wrappedTileCoord_),p=this.targetTileGrid_.getExtent();let f=this.sourceTileGrid_.getExtent();const g=p?_G(d,p):d;if(0===pG(g))return void(this.state=4);const m=t.getExtent();m&&(f=f?_G(f,m):m);const y=r.getResolution(this.wrappedTileCoord_[0]),v=function(t,e,n,r){let i=O8(t,e,mG(n),r);return(!isFinite(i)||i<=0)&&dG(n,function(n){return i=O8(t,e,n,r),isFinite(i)&&i>0}),i}(t,n,g,y);if(!isFinite(v)||v<=0)return void(this.state=4);const b=void 0!==c?c:.5;if(this.triangulation_=new F8(t,n,g,f,v*b,y),0===this.triangulation_.getTriangles().length)return void(this.state=4);this.sourceZ_=e.getZForResolution(v);let w=this.triangulation_.calculateSourceExtent();if(f&&(t.canWrapX()?(w[1]=FH(w[1],f[1],f[3]),w[3]=FH(w[3],f[1],f[3])):w=_G(w,f)),pG(w)){let n=0,r=0;t.canWrapX()&&(n=kG(m),r=Math.floor((w[0]-m[0])/n)),IG(w.slice(),t,!0).forEach(t=>{const i=e.getTileRangeForExtentAndZ(t,this.sourceZ_);for(let e=i.minX;e<=i.maxX;e++)for(let t=i.minY;t<=i.maxY;t++){const i=r*n;this.sourceTiles_.push({getTile:()=>l(this.sourceZ_,e,t,o),offset:i})}++r}),0===this.sourceTiles_.length&&(this.state=4)}else this.state=4}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const n=e.tile;if(n&&2==n.getState()){const r=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);r[0]+=e.offset,r[2]+=e.offset;const i=this.clipExtent_?.slice();i&&(i[0]+=e.offset,i[2]+=e.offset),t.push({extent:r,clipExtent:i,image:n.getImage()})}}),this.sourceTiles_.length=0,0===t.length)this.state=3;else{const e=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(e),r="number"==typeof n?n:n[0],i="number"==typeof n?n:n[1],s=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=N8(r,i,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=2}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(0==this.state){this.state=1,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const n=e.getState();if(0==n||1==n){t++;const n=MW(e,NW,()=>{const r=e.getState();2!=r&&3!=r&&4!=r||(OW(n),t--,0===t&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t}){0==t.getState()&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(OW),this.sourcesListenerKeys_=null}release(){this.canvas_&&(CY(this.canvas_.getContext("2d")),P8.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},z8=class{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof $W&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const n=this.entries_[t];return PH(void 0!==n,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(t){const e=this.entries_[t];return PH(void 0!==e,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.key_;return t}getValues(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){PH(!(t in this.entries_),"Tried to set a value for a key that is used already");const n={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[t]=n,++this.count_}setSize(t){this.highWaterMark=t}};function j8(t,e,n,r){return void 0!==r?(r[0]=t,r[1]=e,r[2]=n,r):[t,e,n]}function U8(t,e,n,r,i){return`${sH(t)},${e},${function(t,e,n){return t+"/"+e+"/"+n}(n,r,i)}`}function B8(t,e,n){if(!(n in t))return t[n]=new Set([e]),!0;const r=t[n],i=r.has(e);return i||r.add(e),!i}function $8(t,e,n){const r=t[n];return!!r&&r.delete(e)}function q8(t,e){const n=t.layerStatesArray[t.layerIndex];n.extent&&(e=_G(e,JK(n.extent,t.viewState.projection)));const r=n.layer.getRenderSource();if(!r.getWrapX()){const n=r.getTileGridForProjection(t.viewState.projection).getExtent();n&&(e=_G(e,n))}return e}var V8=class extends C2{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new L8(0,0,0,0),this.tempTileCoord_=j8(0,0,0);const n=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new z8(n),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=.5*n}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new z8(512)),this.sourceTileCache_}getOrCreateTile(t,e,n,r){const i=this.tileCache_,s=this.getLayer().getSource(),o=U8(s,s.getKey(),t,e,n);let a;if(i.containsKey(o))a=i.get(o);else{const l=r.viewState.projection,c=s.getProjection();if(a=s.getTile(t,e,n,r.pixelRatio,l,!c||VK(c,l)?void 0:this.getSourceTileCache()),!a)return null;i.set(o,a)}return a}getTile(t,e,n,r){return this.getOrCreateTile(t,e,n,r)||null}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),r=sZ(e.pixelToCoordinateTransform,t.slice()),i=n.getExtent();if(i&&!QH(i,r))return null;const s=e.viewState,o=n.getRenderSource(),a=o.getTileGridForProjection(s.projection),l=o.getTilePixelRatio(e.pixelRatio);for(let c=a.getZForResolution(s.resolution);c>=a.getMinZoom();--c){const t=a.getTileCoordForCoordAndZ(r,c),n=this.getTile(c,t[1],t[2],e);if(!n||2!==n.getState())continue;const i=a.getOrigin(c),u=wJ(a.getTileSize(c)),h=a.getResolution(c);let d;if(n instanceof T8||n instanceof D8)d=n.getImage();else{if(!(n instanceof R8))continue;if(d=C8(n.getData()),!d)continue}const p=Math.floor(l*((r[0]-i[0])/h-t[1]*u[0])),f=Math.floor(l*((i[1]-r[1])/h-t[2]*u[1])),g=Math.round(l*o.getGutterForProjection(s.projection));return this.getImageData(d,p+g,f+g)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const n=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,n,r,i){const s=t.viewState,o=this.getLayer(),a=o.getRenderSource(),l=a.getTileGridForProjection(s.projection),c=sH(a);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],h=o.getMapInternal(),d=Math.max(n-i,l.getMinZoom(),l.getZForResolution(Math.min(o.getMaxResolution(),h?h.getView().getResolutionForZoom(Math.max(o.getMinZoom(),0)):l.getResolution(0)),a.zDirection)),p=s.rotation,f=p?bG(s.center,s.resolution,p,t.size):void 0;for(let g=n;g>=d;--g){const n=l.getTileRangeForExtentAndZ(e,g,this.tempTileRange_),i=l.getResolution(g);for(let e=n.minX;e<=n.maxX;++e)for(let s=n.minY;s<=n.maxY;++s){if(p&&!l.tileCoordIntersectsViewport([g,e,s],f))continue;const n=this.getTile(g,e,s,t);if(!n)continue;if(!B8(r,n,g))continue;const o=n.getKey();if(u[o]=!0,0===n.getState()&&!t.tileQueue.isKeyQueued(o)){const r=j8(g,e,s,this.tempTileCoord_);t.tileQueue.enqueue([n,c,l.getTileCoordCenter(r),i])}}}}findStaleTile_(t,e){const n=this.tileCache_,r=t[0],i=t[1],s=t[2],o=this.getStaleKeys();for(let a=0;a0&&setTimeout(()=>{this.enqueueTiles(t,x,h-1,w,_-1)},0),!(h in w))return this.container;const C=sH(this),S=t.time;for(const P of w[h]){const e=P.getState();if(4===e)continue;const n=P.tileCoord;if(2===e&&1===P.getAlpha(C,S)){P.endTransition(C);continue}if(3!==e&&(this.renderComplete=!1),this.findStaleTile_(n,w)){$8(w,P,h),t.animate=!0;continue}if(this.findAltTiles_(u,n,h+1,w))continue;const r=u.getMinZoom();for(let t=h-1;t>=r&&!this.findAltTiles_(u,n,t,w);--t);}const k=d/s*a/f,E=this.getRenderContext(t);aZ(this.tempTransform,g/2,m/2,k,k,0,-g/2,-m/2),this.layerExtent&&this.clipUnrotated(E,t,this.layerExtent),c.getInterpolate()||(E.imageSmoothingEnabled=!1),this.preRender(E,t);const R=Object.keys(w).map(Number);R.sort(qW);const T=[],L=[],I=[];for(let P=R.length-1;P>=0;--P){const e=R[P],n=c.getTilePixelSize(e,a,i),r=u.getResolution(e)/d,s=n[0]*r*k,o=n[1]*r*k,l=u.getTileCoordForCoordAndZ(CG(b),e),p=u.getTileCoordExtent(l),g=sZ(this.tempTransform,[f*(p[0]-b[0])/d,f*(b[3]-p[3])/d]),m=f*c.getGutterForProjection(i);for(const i of w[e]){if(2!==i.getState())continue;const n=i.tileCoord,r=l[1]-n[1],a=Math.round(g[0]-(r-1)*s),u=l[2]-n[2],d=Math.round(g[1]-(u-1)*o),p=Math.round(g[0]-r*s),f=Math.round(g[1]-u*o),y=a-p,v=d-f,b=e===h;if(b&&i.inTransition(C)){I.push({tile:i,x:p,y:f,w:y,h:v,gutter:m}),this.renderedTiles.unshift(i),this.updateUsedTiles(t.usedTiles,c,i);continue}const w=[p,f,p+y,f+v],_=[];for(let t=0,i=T.length;t0&&(x=PG(w,_)),T.push(w),L.push(e),this.drawTile(i,t,p,f,y,v,m,b,x),this.renderedTiles.unshift(i),this.updateUsedTiles(t.usedTiles,c,i)}}for(let P=0,M=I.length;P{const n=sH(c),r=e.wantedTiles[n],i=r?Object.keys(r).length:0;this.updateCacheSize(i),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(e)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,n,r,i,s,o,a,l){let c;if(t instanceof R8){if(c=C8(t.getData()),!c)throw new Error("Rendering array data is not yet supported")}else c=this.getTileImage(t);if(!c)return;const u=this.getRenderContext(e),h=sH(this),d=e.layerStatesArray[e.layerIndex],p=d.opacity*(a?t.getAlpha(h,e.time):1),f=p!==u.globalAlpha;f&&(u.save(),u.globalAlpha=p);const g=c.width-2*o,m=c.height-2*o;if(l){const t=g/i,e=m/s;for(let i=0,s=l.length;it.value):null;let y;t:for(let v=p.length-1;v>=0;--v){const e=p[v];if(!EG(l.getTileCoordExtent(e.wrappedTileCoord),u))continue;const r=e.executorGroups[f];for(let i=0,a=r.length;i{const n=this.getLayer(),r=n.getSource(),i=this.renderedProjection,s=i.getExtent(),o=this.renderedResolution,a=r.getTileGridForProjection(i),l=sZ(this.renderedPixelToCoordinateTransform_,t.slice()),c=a.getTileCoordForCoordAndResolution(l,o).toString(),u=this.renderedTiles.find(t=>t.tileCoord.toString()===c&&2===t.getState());if(!u||u.loadingSourceTiles>0)return void e([]);r.getWrapX()&&i.canWrapX()&&!tG(s,a.getTileCoordExtent(u.tileCoord))&&OG(l,i);const h=sH(n),d=CG(a.getTileCoordExtent(u.wrappedTileCoord)),p=[(l[0]-d[0])/o,(d[1]-l[1])/o],f=u.getSourceTiles().reduce((t,e)=>t.concat(e.getFeatures()),[]);let g=u.hitDetectionImageData[h];if(!g){const t=wJ(a.getTileSize(a.getZForResolution(o,r.zDirection))),e=this.renderedRotation_;g=d2(t,[this.getRenderTransform(a.getTileCoordCenter(u.wrappedTileCoord),o,0,h2,t[0]*h2,t[1]*h2,0)],f,n.getStyleFunction(),a.getTileCoordExtent(u.wrappedTileCoord),u.getReplayState(n).renderedResolution,e),u.hitDetectionImageData[h]=g}e(p2(p,f,g))})}getFeaturesInExtent(t){const e=[],n=this.getTileCache();if(0===n.getCount())return e;const r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),i=r.getZForResolution(this.renderedResolution),s={};return n.forEach(n=>{if(n.tileCoord[0]!==i||2!==n.getState())return;const o=n.getSourceTiles();for(let i=0,a=o.length;i=0;--r)n[r].execute(this.context,o,this.getTileRenderTransform(e,t),t.viewState.rotation,s,i2,l)}n.globalAlpha=r}renderDeferredInternal(t){const e=this.renderedTiles,n=sH(this.getLayer()),r=e.reduce((t,e,r)=>(e.executorGroups[n].forEach(e=>t.push({executorGroup:e,index:r})),t),[]),i=r.map(({executorGroup:t})=>t.getDeferredZIndexContexts()),s={};for(let a=0,l=r.length;a{i.forEach((e,n)=>{e[t]&&(e[t].forEach(t=>{const{executorGroup:e,index:i}=r[n],s=e.getRenderedContext(),o=s.globalAlpha;s.globalAlpha=this.renderedOpacity_;const a=this.tileClipContexts_[i];a&&a.draw(s),t.draw(s),a&&s.restore(),s.globalAlpha=o,t.clear()}),e[t].length=0)})}),this.layerExtent&&this.context.restore()}getTileRenderTransform(t,e){const n=e.pixelRatio,r=e.viewState,i=r.center,s=r.resolution,o=r.rotation,a=e.size,l=Math.round(a[0]*n),c=Math.round(a[1]*n),u=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),h=t.tileCoord,d=u.getTileCoordExtent(t.wrappedTileCoord),p=u.getTileCoordExtent(h,this.tempExtent)[0]-d[0];return rZ(oZ(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(i,s,o,n,l,c,p))}clipTileContext_(t,e,n,r,i,s){const o=[];for(let l=0,c=n.length;l!i2.includes(t)):Y8[s],c=e.viewState,u=c.rotation;this.layerExtent&&this.clipUnrotated(t,e,this.layerExtent);const h=i.getSource(),d=h.getTileGridForProjection(c.projection).getZForResolution(c.resolution,h.zDirection),p=this.renderedTiles,f=[],g=[],m=[],y=sH(i);let v=!0;for(let b=p.length-1;b>=0;--b){const n=p[b];v=v&&!n.getReplayState(i).dirty;const s=n.executorGroups[y].filter(t=>t.hasExecutors(l));if(0===s.length)continue;const o=this.getTileRenderTransform(n,e),c=n.tileCoord[0];let h=!1;const w=s[0].getClipCoords(QK);let _,x=t;if(w){const t=[w[0],w[1],w[4],w[5]];_=new W1,x=_.getContext(),d!==c&&(h=this.clipTileContext_(x,t,f,g,c,o)),f.push(t),g.push(c)}for(let i=0,d=s.length;ivoid 0!==t)),this.minZoom=void 0!==e?e:0,this.resolutions_=n,PH(function(t){const e=((t,e)=>e-t)||qW;return t.every(function(n,r){if(0===r)return!0;const i=e(t[r-1],n);return!(i>0||0===i)})}(this.resolutions_),"`resolutions` must be sorted in descending order"),!t.origins)for(let s=0,o=this.resolutions_.length-1;s{const n=new L8(Math.min(0,t[0]),Math.max(t[0]-1,-1),Math.min(0,t[1]),Math.max(t[1]-1,-1));if(i){const t=this.getTileRangeForExtentAndZ(i,e);n.minX=Math.max(t.minX,n.minX),n.maxX=Math.min(t.maxX,n.maxX),n.minY=Math.max(t.minY,n.minY),n.maxY=Math.min(t.maxY,n.maxY)}return n}):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,n){const r=this.getTileRangeForExtentAndZ(t,e);for(let i=r.minX,s=r.maxX;i<=s;++i)for(let t=r.minY,o=r.maxY;t<=o;++t)n([e,i,t])}forEachTileCoordParentTileRange(t,e,n,r){let i,s,o,a=null,l=t[0]-1;for(2===this.zoomFactor_?(s=t[1],o=t[2]):a=this.getTileCoordExtent(t,r);l>=this.minZoom;){if(void 0!==s&&void 0!==o?(s=Math.floor(s/2),o=Math.floor(o/2),i=I8(s,s,o,o,n)):i=this.getTileRangeForExtentAndZ(a,l,n),e(l,i))return!0;--l}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,n){if(t[0]this.maxZoom||e0?r:Math.max(s/n[0],i/n[1]);const o=e+1,a=new Array(o);for(let l=0;ln||n>e.getMaxZoom())return!1;const s=e.getFullTileRange(n);return!s||s.containsXY(r,i)}(t,r)?t:null}clear(){}refresh(){this.clear(),super.refresh()}},d7=class extends tH{constructor(t,e){super(t),this.tile=e}},p7=class t extends h7{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tilePixelRatio:e.tilePixelRatio,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===t.prototype.tileUrlFunction,this.tileLoadFunction=e.tileLoadFunction,e.tileUrlFunction&&(this.tileUrlFunction=e.tileUrlFunction),this.urls=null,e.urls?this.setUrls(e.urls):e.url&&this.setUrl(e.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,n=sH(e),r=e.getState();let i;1==r?(this.tileLoadingKeys_[n]=!0,i="tileloadstart"):n in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[n],i=3==r?"tileloaderror":2==r?"tileloadend":void 0),null!=i&&this.dispatchEvent(new d7(i,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,void 0!==e?this.setKey(e):this.changed()}setUrl(t){const e=function(t){const e=[];let n=/\{([a-z])-([a-z])\}/.exec(t);if(n){const r=n[1].charCodeAt(0),i=n[2].charCodeAt(0);let s;for(s=r;s<=i;++s)e.push(t.replace(n[0],String.fromCharCode(s)));return e}if(n=/\{(\d+)-(\d+)\}/.exec(t),n){const r=parseInt(n[2],10);for(let i=parseInt(n[1],10);i<=r;i++)e.push(t.replace(n[0],i.toString()));return e}return e.push(t),e}(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join("\n");this.generateTileUrlFunction_?this.setTileUrlFunction(u7(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,n){}},f7=class extends p7{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:g7,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:void 0===t.interpolate||t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy=t.referrerPolicy,this.tileClass=void 0!==t.tileClass?t.tileClass:T8,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!VK(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||VK(e,t)))return this.tileGrid;const n=sH(t);return n in this.tileGridForProjection||(this.tileGridForProjection[n]=e7(t)),this.tileGridForProjection[n]}createTile_(t,e,n,r,i,s){const o=[t,e,n],a=this.getTileCoordForTileUrlFunction(o,i),l=a?this.tileUrlFunction(a,r,i):void 0,c=new this.tileClass(o,void 0!==l?0:4,void 0!==l?l:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=s,c.addEventListener(NW,this.handleTileChange.bind(this)),c}getTile(t,e,n,r,i,s){const o=this.getProjection();if(!o||!i||VK(o,i))return this.getTileInternal(t,e,n,r,o||i);const a=[t,e,n],l=this.getKey(),c=this.getTileGridForProjection(o),u=this.getTileGridForProjection(i),h=this.getTileCoordForTileUrlFunction(a,i),d=new D8(o,c,i,u,a,h,this.getTilePixelRatio(r),this.getGutter(),(t,e,n,r)=>this.getTileInternal(t,e,n,r,o,s),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(t,e,n,r,i,s){const o=this.getKey(),a=U8(this,o,t,e,n);if(s&&s.containsKey(a))return s.get(a);const l=this.createTile_(t,e,n,r,i,o);return s?.set(a,l),l}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const n=zK(t);if(n){const t=sH(n);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}};function g7(t,e){if(vH){const n=t.getCrossOrigin();let r="same-origin",i="same-origin";"anonymous"===n||""===n?(r="cors",i="omit"):"use-credentials"===n&&(r="cors",i="include");const s={mode:r,credentials:i,referrerPolicy:t.getReferrerPolicy()};return void fetch(e,s).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.blob()}).then(t=>createImageBitmap(t)).then(e=>{const n=t.getImage();n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),e.close?.(),n.dispatchEvent(new Event("load"))}).catch(()=>{t.getImage().dispatchEvent(new Event("error"))})}t.getImage().src=e}var m7=class extends f7{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:zK("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.tileJSON_=null,this.tileSize_=t.tileSize,t.url)if(t.jsonp)!function(t,e,n){const r=document.createElement("script"),i="olc_"+sH(e);function s(){delete window[i],r.parentNode.removeChild(r)}r.async=!0,r.src=t+(t.includes("?")?"&":"?")+"callback="+i;const o=setTimeout(function(){s(),n&&n()},1e4);window[i]=function(t){clearTimeout(o),s(),e(t)},document.head.appendChild(r)}(t.url,this.handleTileJSONResponse.bind(this),this.handleTileJSONError.bind(this));else{const e=new XMLHttpRequest;e.addEventListener("load",this.onXHRLoad_.bind(this)),e.addEventListener("error",this.onXHRError_.bind(this)),e.open("GET",t.url),e.send()}else{if(!t.tileJSON)throw new Error("Either `url` or `tileJSON` options must be provided");this.handleTileJSONResponse(t.tileJSON)}}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch{return void this.handleTileJSONError()}this.handleTileJSONResponse(t)}else this.handleTileJSONError()}onXHRError_(t){this.handleTileJSONError()}getTileJSON(){return this.tileJSON_}handleTileJSONResponse(t){const e=zK("EPSG:4326"),n=this.getProjection();let r;if(void 0!==t.bounds){const i=WK(e,n);r=TG(t.bounds,i)}const i=i7(n),s=t.minzoom||0,o=n7({extent:i,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=u7(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==r?r:i;this.setAttributions(function(n){return EG(e,n.extent)?[t.attribution]:null})}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}},y7=[],v7=class extends x8{constructor(t,e,n,r,i){super(t,e,{transition:0}),this.context_=null,this.executorGroups={},this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=r.bind(void 0,this),this.removeSourceTiles_=i,this.wrappedTileCoord=n}getContext(){return this.context_||(this.context_=_Y(1,1,y7)),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(t){const e=sH(t);return e in this.replayState_||(this.replayState_[e]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedPixelRatio:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[e]}load(){this.getSourceTiles()}release(){this.context_&&(CY(this.context_),y7.push(this.context_.canvas),this.context_=null),this.removeSourceTiles_(this),this.sourceTiles.length=0,super.release()}},b7=class extends x8{constructor(t,e,n,r,i,s){super(t,e,s),this.extent=null,this.format_=r,this.features_=null,this.loader_,this.projection=null,this.resolution,this.tileLoadFunction_=i,this.url_=n,this.key=n}getTileUrl(){return this.url_}getFormat(){return this.format_}getFeatures(){return this.features_}load(){0==this.state&&(this.setState(1),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(t,e){this.setFeatures(t)}onError(){this.setState(3)}setFeatures(t){this.features_=t,this.setState(2)}setLoader(t){this.loader_=t}},w7=class extends p7{constructor(t){const e=t.projection||"EPSG:3857",n=t.extent||i7(e),r=t.tileGrid||n7({extent:n,maxResolution:t.maxResolution,maxZoom:void 0!==t.maxZoom?t.maxZoom:22,minZoom:t.minZoom,tileSize:t.tileSize||512});super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,interpolate:!0,projection:e,state:t.state,tileGrid:r,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:_7,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:void 0===t.zDirection?1:t.zDirection}),this.format_=t.format?t.format:null,this.tileKeysBySourceTileUrl_={},this.sourceTiles_={},this.overlaps_=null==t.overlaps||t.overlaps,this.tileClass=t.tileClass?t.tileClass:b7,this.tileGrids_={}}getOverlaps(){return this.overlaps_}getSourceZ_(t,e,n){const r=this.projection,i=e&&r&&!VK(e,r)?t/r.getMetersPerUnit()*e.getMetersPerUnit():t;return this.tileGrid.getZForResolution(i,n)}getSourceTiles(t,e,n,r){if(0===n.getState()){n.setState(1);const i=n.wrappedTileCoord,s=this.getTileGridForProjection(e);let o=s.getTileCoordExtent(i);const a=i[0],l=s.getResolution(a);YH(o,-l,o);const c=this.projection;e&&this.projection&&!VK(e,c)&&(o=ZK(o,e,c));const u=this.tileGrid,h=u.getExtent();h&&_G(o,h,o);const d=this.getSourceZ_(l,e,this.zDirection),p=r||this.tileUrlFunction;u.forEachTileCoord(o,d,r=>{const i=p(r,t,e);this.sourceTiles_[i]||(this.sourceTiles_[i]=new this.tileClass(r,i?0:4,i,this.format_,this.tileLoadFunction));const s=this.sourceTiles_[i];n.sourceTiles.push(s),this.tileKeysBySourceTileUrl_[i]||(this.tileKeysBySourceTileUrl_[i]=[]),this.tileKeysBySourceTileUrl_[i].push(n.getKey());const o=s.getState();if(o<2){const t=e=>{this.handleTileChange(e);const r=s.getState();if(2===r||3===r){const e=s.getKey();e in n.errorTileKeys?2===s.getState()&&delete n.errorTileKeys[e]:n.loadingSourceTiles--,3===r?n.errorTileKeys[e]=!0:s.removeEventListener(NW,t),0===n.loadingSourceTiles&&n.setState(PW(n.errorTileKeys)?2:3)}};s.addEventListener(NW,t),n.loadingSourceTiles++}0===o&&(s.extent=u.getTileCoordExtent(r),s.projection=this.projection,s.resolution=u.getResolution(r[0]),s.load())}),n.loadingSourceTiles||n.setState(n.sourceTiles.some(t=>3===t.getState())?3:2)}return n.sourceTiles}removeSourceTiles(t){const e=t.getKey(),n=t.sourceTiles;for(let r=0,i=n.length;r{u=u&&!this.tileUrlFunction(t,r,l)})}const h=this.tileUrlFunction,d=new v7(s,u?4:0,o,t=>this.getSourceTiles(r,i,t,h),this.removeSourceTiles.bind(this));return d.key=this.getKey(),d}getTileGridForProjection(t){const e=t.getCode();let n=this.tileGrids_[e];if(!n){const r=this.projection;if(null!==r&&!VK(r,t))return e7(t);const i=this.tileGrid,s=i.getResolutions().slice(),o=s.map(function(t,e){return i.getOrigin(e)}),a=s.map(function(t,e){return i.getTileSize(e)}),l=43;for(let t=s.length;tk7.pitch||0],"distance-from-center":[{kind:"number"},[],()=>k7.distanceFromCenter||0],"to-hsla":[{kind:"array",itemType:{kind:"number"},N:4},[{kind:"string"}],(t,[e])=>function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=t[3],s=Math.max(e,n,r),o=Math.min(e,n,r),a=(s+o)/2;let l,c;if(s===o)l=0,c=0;else{const t=s-o;switch(c=a>.5?t/(2-s-o):t/(s+o),s){case e:l=(n-r)/t+(ne.evaluate(t)],"measure-light":[{kind:"number"},[{kind:"value"}],()=>1],config:[{kind:"value"},[{kind:"string"}],(t,[e])=>{const n=S7[e.evaluate(t)];return void 0===n?{}:n}]});var E7="https://api.mapbox.com";function R7(t){return 0!==t.indexOf("mapbox://")?"":t.slice(9)}function T7(t,e,n){const r=R7(t);if(!e||!r)return decodeURI(new URL(t,n).href);if(0!==r.indexOf("sprites/"))throw new Error(`unexpected sprites url: ${t}`);const i=r.slice(8);return`${E7}/styles/v1/${i}/sprite?access_token=${e}`}function L7(t,e){const n=R7(t);if(!n||!e)return decodeURI(new URL(t,location.href).href);if(0!==n.indexOf("styles/"))throw new Error(`unexpected style url: ${t}`);const r=n.slice(7);return`${E7}/styles/v1/${r}?&access_token=${e}`}var I7=["a","b","c","d"];function P7(t,e,n,r){const i=new URL(t,r||location.href),s=R7(t);return s?"mapbox.satellite"===s?[`https://api.mapbox.com/v4/${s}/{z}/{x}/{y}${window.devicePixelRatio>=1.5?"@2x":""}.webp?access_token=${e}`]:I7.map(t=>`https://${t}.tiles.mapbox.com/v4/${s}/{z}/{x}/{y}.vector.pbf?access_token=${e}`):e?(i.searchParams.has(n)||i.searchParams.set(n,e),[decodeURI(i.href)]):[decodeURI(i.href)]}var M7=class extends C2{constructor(t){super(t),this.image=null,this.renderedSourceRevision_=0}getImage(){return this.image?this.image.getImage():null}prepareFrame(t){const e=t.layerStatesArray[t.layerIndex],n=t.pixelRatio,r=t.viewState,i=r.resolution,s=this.getLayer().getSource(),o=t.viewHints;let a=t.extent;if(void 0!==e.extent&&(a=_G(a,JK(e.extent,r.projection))),!o[0]&&!o[1]&&!RG(a))if(s){this.getLayer().rendered||this.renderedSourceRevision_===s.getRevision()||(this.image=null),this.renderedSourceRevision_=s.getRevision();const t=r.projection,e=s.getImage(a,i,n,t);e&&(this.loadImage(e)?this.image=e:4===e.getState()&&(this.image=null))}else this.image=null;return!!this.image}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),r=sZ(e.pixelToCoordinateTransform,t.slice()),i=n.getExtent();if(i&&!QH(i,r))return null;const s=this.image.getExtent(),o=this.image.getImage(),a=kG(s),l=Math.floor(o.width*((r[0]-s[0])/a));if(l<0||l>=o.width)return null;const c=wG(s),u=Math.floor(o.height*((s[3]-r[1])/c));return u<0||u>=o.height?null:this.getImageData(o,l,u)}renderFrame(t,e){const n=this.image,r=n.getExtent(),i=n.getResolution(),[s,o]=Array.isArray(i)?i:[i,i],a=n.getPixelRatio(),l=t.layerStatesArray[t.layerIndex],c=t.pixelRatio,u=t.viewState,h=u.center,d=u.resolution,p=c*s/(d*a),f=c*o/(d*a);this.prepareContainer(t,e);const g=this.context.canvas.width,m=this.context.canvas.height,y=this.getRenderContext(t);let v=!1,b=!0;if(l.extent){const e=JK(l.extent,u.projection);b=EG(e,t.extent),v=b&&!tG(e,t.extent),v&&this.clipUnrotated(y,t,e)}const w=n.getImage(),_=aZ(this.tempTransform,g/2,m/2,p,f,0,a*(r[0]-h[0])/s,a*(h[1]-r[3])/o);this.renderedResolution=o*c/a;const x=w.width*_[0],C=w.height*_[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,t),b&&x>=.5&&C>=.5){const t=_[4],e=_[5],n=l.opacity;1!==n&&(y.save(),y.globalAlpha=n),y.drawImage(w,0,0,+w.width,+w.height,t,e,x,C),1!==n&&y.restore()}return this.postRender(this.context,t),v&&y.restore(),y.imageSmoothingEnabled=!0,this.container}},A7=class extends AX{constructor(t){super(t=t||{})}},O7=class extends A7{constructor(t){super(t)}createRenderer(){return new M7(this)}getData(t){return super.getData(t)}},N7=class extends GQ{constructor(t,e,n,r,i){super(t,e,n,void 0!==i?0:2),this.loader_=void 0!==i?i:null,this.canvas_=r,this.error_=null}getError(){return this.error_}handleLoad_(t){t?(this.error_=t,this.state=3):this.state=2,this.changed()}load(){0==this.state&&(this.state=1,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}};function F7(t){return Array.isArray(t)?Math.min(...t):t}var D7=class extends GQ{constructor(t,e,n,r,i,s,o){let a=t.getExtent();a&&t.canWrapX()&&(a=a.slice(),a[0]=-1/0,a[2]=1/0);let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);const c=l?_G(n,l):n,u=O8(t,e,mG(c),r),h=new F8(t,e,c,a,.5*u,r),d=h.calculateSourceExtent(),p=RG(d)?null:s(d,u,i),f=p?0:4,g=p?p.getPixelRatio():1;super(n,r,g,f),this.targetProj_=e,this.maxSourceExtent_=a,this.triangulation_=h,this.targetResolution_=r,this.targetExtent_=n,this.sourceImage_=p,this.sourcePixelRatio_=g,this.interpolate_=o,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){1==this.state&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(2==t){const t=kG(this.targetExtent_)/this.targetResolution_,e=wG(this.targetExtent_)/this.targetResolution_;this.canvas_=N8(t,e,this.sourcePixelRatio_,F7(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=t,this.changed()}load(){if(0==this.state){this.state=1,this.changed();const t=this.sourceImage_.getState();2==t||3==t?this.reproject_():(this.sourceListenerKey_=MW(this.sourceImage_,NW,()=>{const t=this.sourceImage_.getState();2!=t&&3!=t||(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){OW(this.sourceListenerKey_),this.sourceListenerKey_=null}},z7=class extends tH{constructor(t,e){super(t),this.image=e}},j7=class extends A2{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:void 0===t.interpolate||t.interpolate}),this.on,this.once,this.un,this.loader=t.loader||null,this.resolutions_=void 0!==t.resolutions?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=!!t.loader&&0===t.loader.length,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();return e&&(t=e[WW(e,t,0)]),t}getImage(t,e,n,r){const i=this.getProjection();if(!i||!r||VK(i,r))return i&&(r=i),this.getImageInternal(t,e,n,r);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&VK(this.reprojectedImage_.getProjection(),r)&&this.reprojectedImage_.getResolution()==e&&aG(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new D7(i,r,t,e,n,(t,e,n)=>this.getImageInternal(t,e,n,i),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,n,r){if(this.loader){const i=function(t,e,n){const r=e/n,i=mG(t),s=WH(kG(t)/r,4),o=WH(wG(t)/r,4);return vG(i,r,0,[s+2*WH(0*s/2,4),o+2*WH(0*o/2,4)])}(t,e,n),s=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===r&&(this.wantedExtent_&&tG(this.wantedExtent_,i)||tG(this.image.getExtent(),i))&&(this.wantedResolution_&&F7(this.wantedResolution_)===s||F7(this.image.getResolution())===s)))return this.image;this.wantedProjection_=r,this.wantedExtent_=i,this.wantedResolution_=s,this.image=new GQ(i,s,n,this.loader),this.image.addEventListener(NW,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const e=t.target;let n;switch(e.getState()){case 1:this.loading=!0,n="imageloadstart";break;case 2:this.loading=!1,n="imageloadend";break;case 3:this.loading=!1,n="imageloaderror";break;default:return}this.hasListener(n)&&this.dispatchEvent(new z7(n,e))}};function U7(t){return function(e){const n=e.buffers,r=e.meta,i=e.imageOps,s=e.width,o=e.height,a=n.length,l=n[0].byteLength;if(i){const e=new Array(a);for(let t=0;tthis.maxQueueLength_;)this.queue_.shift().callback(null,null)}dispatch_(){if(this.running_||0===this.queue_.length)return;const t=this.queue_.shift();this.job_=t;const e=t.inputs[0].width,n=t.inputs[0].height,r=t.inputs.map(function(t){return t.data.buffer}),i=this.workers_.length;if(this.running_=i,1===i)return void this.workers_[0].postMessage({buffers:r,meta:t.meta,imageOps:this.imageOps_,width:e,height:n},r);const s=t.inputs[0].data.length,o=4*Math.ceil(s/4/i);for(let a=0;at*h/180),w=(e.altitudes||[45]).map(t=>t*h/180),_=Math.min(b.length,w.length,y.length,v.length,4),x=f<2?.4:f<4.5?.35:.3,C=f<15?Math.pow(2,(15-f)*x):1;function S(t,e="mapbox"){return"mapbox"===e?.1*(256*t[0]*256+256*t[1]+t[2])-1e4:"terrarium"===e?256*t[0]+t[1]+t[2]/256-32768:0}function k(t,e){return 0!==t?Math.atan2(e,-t):h/2*(e>0?1:-1)}const E="igor"===g?function(t,e){const n=k(t*=2*p,e*=2*p),r=b[0]+h,i=Math.atan(Math.sqrt(t*t+e*e))*(2/h);let s=(n+r)/h+.5;s%=2,s<0&&(s+=2);const o=1-Math.abs(s-1),a=i*o,l=i*(1-o),c=y[0],u=v[0];return[c.r*a+u.r*l,c.g*a+u.g*l,c.b*a+u.b*l,c.a*a+u.a*l]}:"basic"===g?function(t,e){t*=2*p,e*=2*p;const n=b[0]+h,r=Math.cos(n),i=Math.sin(n),s=Math.cos(w[0]),o=(Math.sin(w[0])-(e*r*s-t*i*s))/Math.sqrt(1+t*t+e*e),a=Math.max(0,Math.min(1,o));if(a>.5){const t=2*a-1,e=v[0];return[e.r*t,e.g*t,e.b*t,e.a*t]}const l=1-2*a,c=y[0];return[c.r*l,c.g*l,c.b*l,c.a*l]}:"combined"===g?function(t,e){t*=2*p,e*=2*p;const n=b[0]+h,r=Math.cos(n),i=Math.sin(n),s=Math.cos(w[0]),o=Math.sin(w[0]);let a=Math.acos((o-(e*r*s-t*i*s))/Math.sqrt(1+t*t+e*e));a=Math.max(0,Math.min(h/2,a));const l=Math.atan(Math.sqrt(t*t+e*e))*(4/h/h),c=a*l,u=(h/2-a)*l,d=y[0],f=v[0];return[d.r*c+f.r*u,d.g*c+f.g*u,d.b*c+f.b*u,d.a*c+f.a*u]}:"multidirectional"===g?function(t,e){const n=(t*=2*p)*t+(e*=2*p)*e,r=Math.sqrt(1+n);let i=0,s=0,o=0,a=0;for(let l=0;l<_;l++){const n=Math.cos(w[l]),c=(Math.sin(w[l])-(e*-Math.cos(b[l])*n-t*-Math.sin(b[l])*n))/r,u=Math.max(0,Math.min(1,c)),h=y[Math.min(l,y.length-1)],d=v[Math.min(l,v.length-1)];if(u>.5){const t=(2*u-1)/_;i+=d.r*t,s+=d.g*t,o+=d.b*t,a+=d.a*t}else{const t=(1-2*u)/_;i+=h.r*t,s+=h.g*t,o+=h.b*t,a+=h.a*t}}return[i,s,o,a]}:function(t,e){const n=b[0]+h,r=Math.atan(.625*Math.sqrt(t*t+e*e)),i=k(t,e),s=1.875-1.75*p,o=.5*h,a=.5!==p?(Math.pow(s,r)-1)/(Math.pow(s,o)-1)*o:r,l=Math.cos(a),c=Math.min(Math.max(2*p,0),1),u=(1-l)*c,d=m,f=d.r*u,g=d.g*u,w=d.b*u,_=d.a*u;let x=(i+n)/h+.5;x%=2,x<0&&(x+=2);const C=Math.abs(x-1),S=Math.sin(a)*c,E=y[0],R=v[0],T=(E.r*(1-C)+R.r*C)*S,L=(E.g*(1-C)+R.g*C)*S,I=(E.b*(1-C)+R.b*C)*S,P=(E.a*(1-C)+R.a*C)*S;return[f*(1-P)+T,g*(1-P)+L,w*(1-P)+I,_*(1-P)+P]};let R,T,L,I,P,M,A,O,N,F,D;for(T=0;T<=c;++T)for(P=0===T?0:T-1,M=T===c?c:T+1,R=0;R<=l;++R){L=0===R?0:R-1,I=R===l?l:R+1,A=4*(T*r+L),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],O=S(u,d),A=4*(T*r+I),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],N=S(u,d),F=(N-O)/a*C,A=4*(P*r+R),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],O=S(u,d),A=4*(M*r+R),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],N=S(u,d),D=(N-O)/a*C;const t=E(F,D),e=t[3];A=4*(T*r+R),e>0&&(o[A]=t[0]/e*255,o[A+1]=t[1]/e*255,o[A+2]=t[2]/e*255),o[A+3]=255*e}return new ImageData(o,r,i)}function Z7(t,e){const n=t[0],r=n.width,i=n.height,s=n.data,o=new Uint8ClampedArray(s.length),a=r-1,l=i-1,c=[0,0,0,0];let u,h,d;const p=(f=e.saturation)>0?1-1/(1.001-f):-f;var f;const g=(m=e.contrast)>0?1/(1-m):1+m;var m;const y=function(t){t*=Math.PI/180;const e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}(e.hueRotate),v=y,b=[y[2],y[0],y[1]],w=[y[1],y[2],y[0]],_=e.brightnessLow,x=e.brightnessHigh;for(h=0;h<=l;++h)for(u=0;u<=a;++u){d=4*(h*r+u),c[0]=s[d],c[1]=s[d+1],c[2]=s[d+2],c[3]=s[d+3];const t=c[0],e=c[1],n=c[2],i=(t,e)=>{let n=0;for(let r=0;r1?h[h.length-2].toLowerCase():"";if(d==p||d==p.replace("-","")||f+"-"+d==p){o=i?o:Y7[p],h.pop(),f&&p.startsWith(f)&&h.pop();break}}i||"number"!=typeof d||(o=d,i=!0);var g=h.join(X7).replace("Klokantech Noto Sans","Noto Sans").replace("DIN Pro","Barlow").replace("Arial Unicode MS","Arial");-1!==g.indexOf(X7)&&(g='"'+g+'"'),l.push(g)}r=Q7[t]=[a,o,l]}return r[0]+X7+r[1]+X7+e+"px"+(n?"/"+n:"")+X7+r[2]}var e9=Object.freeze({}),n9={},r9={},i9=0;function s9(t){return t.id||(t.id=i9++),t.id}function o9(t){let e=n9[t.id];return e||(e={},n9[s9(t)]=e),e}function a9(t){return t*Math.PI/180}var l9=function(){const t=[];for(let e=78271.51696402048;t.length<=24;e/=2)t.push(e);return t}();function c9(t,e){if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,e);const n=document.createElement("canvas");return n.width=t,n.height=e,n}function u9(t,e){let n=0;const r=e.length;for(;ni).then(t=>t instanceof Response?(r&&(r.url=t.url),o(t)):(t instanceof Request||(t=new Request(t)),t.headers.get("Accept")||t.headers.set("Accept","application/json"),r&&(r.url=t.url),fetch(t).then(o).catch(s))).catch(s);return d9[e]=[i,a],a}function f9(t,e){if("string"!=typeof t)return Promise.resolve(t);if(!t.trim().startsWith("{"))return p9("Style",t=L7(t,e.accessToken),e);try{const e=JSON.parse(t);return Promise.resolve(e)}catch(e6){return Promise.reject(e6)}}var g9={};function m9(t,e,n={}){const r=[e,JSON.stringify(t)].toString();let i=g9[r];if(!i||n.transformRequest){let s;n.transformRequest&&(s=(t,e)=>{const r=n.transformRequest&&n.transformRequest(e,"Tiles")||e;if(t instanceof b7)t.setLoader((e,n,i)=>{const s=function(n){n.arrayBuffer().then(n=>{const r=t.getFormat().readFeatures(n,{extent:e,featureProjection:i});t.setFeatures(r)})};QW(()=>r).then(e=>{if(e instanceof Response)return s(e);fetch(e).then(s).catch(()=>t.setState(3))}).catch(()=>t.setState(3))});else{const e=t.getImage();QW(()=>r).then(n=>{if("string"==typeof n)return void(e.src=n);const r=t=>t.blob().then(t=>{const n=URL.createObjectURL(t);e.addEventListener("load",()=>URL.revokeObjectURL(n)),e.addEventListener("error",()=>URL.revokeObjectURL(n)),e.src=n});if(n instanceof Response)return r(n);fetch(n).then(r).catch(()=>t.setState(3))}).catch(()=>t.setState(3))}});const o=t.url;if(o&&!t.tiles){const r=P7(o,n.accessToken,n.accessTokenParam||"access_token",e||location.href);if(o.startsWith("mapbox://"))i=Promise.resolve({tileJson:Object.assign({},t,{url:void 0,tiles:r}),tileLoadFunction:s});else{const t={};i=p9("Source",r[0],n,t).then(function(e){return e.tiles=e.tiles.map(function(r){return"tms"===e.scheme&&(r=r.replace("{y}","{-y}")),P7(r,n.accessToken,n.accessTokenParam||"access_token",t.url)[0]}),Promise.resolve({tileJson:e,tileLoadFunction:s})})}}else t.tiles?(t=Object.assign({},t,{tiles:t.tiles.map(function(r){return"tms"===t.scheme&&(r=r.replace("{y}","{-y}")),P7(r,n.accessToken,n.accessTokenParam||"access_token",e||location.href)[0]})}),i=Promise.resolve({tileJson:Object.assign({},t),tileLoadFunction:s})):i=Promise.reject(new Error("source has no `tiles` nor `url`"));g9[r]=i}return i}function y9(t,e,n,r){const i=[2*n*e.pixelRatio+e.width,2*n*e.pixelRatio+e.height],s=c9(i[0],i[1]),o=s.getContext("2d");o.drawImage(t,e.x,e.y,e.width,e.height,n*e.pixelRatio,n*e.pixelRatio,e.width,e.height);const a=o.getImageData(0,0,i[0],i[1]);o.globalCompositeOperation="destination-over",o.fillStyle=`rgba(${255*r.r},${255*r.g},${255*r.b},${r.a})`;const l=a.data;for(let c=0,u=a.width;c0&&o.arc(c,t,n*e.pixelRatio,0,2*Math.PI);return o.fill(),s}function v9(t,e,n){const r=Math.max(0,Math.min(1,(n-t)/(e-t)));return r*r*(3-2*r)}function b9(t,e,n){const r=c9(e.width,e.height),i=r.getContext("2d");i.drawImage(t,e.x,e.y,e.width,e.height,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),o=s.data;for(let a=0,l=s.width;a0?(o[e+0]=Math.round(255*n.r*r),o[e+1]=Math.round(255*n.g*r),o[e+2]=Math.round(255*n.b*r),o[e+3]=Math.round(255*r)):o[e+3]=0}return i.putImageData(s,0,0),r}var w9,_9=Array(256).join(" ");function x9(t,e){if(e>=.05){let n="";const r=t.split("\n"),i=_9.slice(0,Math.round(e/.1));for(let t=0,e=r.length;t0&&(n+="\n"),n+=r[t].split("").join(i);return n}return t}function C9(){return w9||(w9=c9(1,1).getContext("2d")),w9}function S9(t,e){if(/\d+ \d+/.test(t)){const[n,r]=t.split(" ").map(Number);return n<=e&&e<=r}return t==e}function k9(t,e){return C9().measureText(t).width+(t.length-1)*e}var E9={};function R9(t,e,n,r){if(-1!==t.indexOf("\n")){const i=t.split("\n"),s=[];for(let t=0,o=i.length;t1){const t=C9();t.font=e;const i=t.measureText("M").width*n;let a="";const l=[];for(let e=0,n=o.length;e1;++e){const t=l[e];if(k9(t,r)<.35*i){const i=e>0?k9(l[e-1],r):1/0,s=e.7*i&&k9(s,r)<.6*i){const o=t.split(" "),a=o.pop();k9(a,r)<.2*i&&(l[e]=o.join(" "),l[e+1]=a+" "+s),n-=1}}s=l.join("\n")}else s=t;s=x9(s,r),E9[i]=s}return s}l0.on("propertychange",()=>{for(const t in E9)delete E9[t]});var T9,L9,I9=["Arial","Courier New","Times New Roman","Verdana","sans-serif","serif","monospace","cursive","fantasy"],P9={},M9={Point:1,MultiPoint:1,LineString:2,MultiLineString:2,Polygon:3,MultiPolygon:3},A9={center:[.5,.5],left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],"top-left":[0,0],"top-right":[1,0],"bottom-left":[0,1],"bottom-right":[1,1]},O9=function(t,e){let n=d6(t,e);if("error"===n.result){const r=C7(t);r!==t&&(n=d6(r,e))}if("error"===n.result){const r=n.value[0];return console.error("Error parsing expression:",t,r.key,r.message),{evaluate:()=>e.default}}return n.value};function N9(t,e,n,r,i,s){const o=t.id;i||(i={},console.warn("No functionCache provided to getValue()")),i[o]||(i[o]={});const a=i[o];if(!a[n]){let r=(t[e]||e9)[n];const i=d8[`${e}_${t.type}`]&&d8[`${e}_${t.type}`][n];void 0===r&&i&&(r=i.default);let s=l6(r);if(!s&&o6(r)&&(r=E6(r,i),s=!0),s){const t=O9(r,i);a[n]=t.evaluate.bind(t)}else{const t=i?i.type:typeof r;"color"!==t&&"colorArray"!==t||(r=c5.parse(r));let e=!1;if("array"===t)for(let n=0;n!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};m6(t)||(t=w6(t));const e=c6(t,y6,void 0);if("error"===e.result)throw new Error(e.value.map(t=>`${t.key}: ${t.message}`).join(", "));return{filter:(t,n,r)=>e.value.evaluate(t,n,{},r),needGeometry:b6(t),getGlobalStateRefs:()=>f6(e.value.expression)}}(e).filter}catch(i){console.warn("Filter will evaluate to false: "+i.message),r[t]=function(){return!1}}return r[t](k7,n)}function z9(t,e){if(t){if(0===t.a||0===e)return;const n=t.a;return e=void 0===e?1:e,0===n?"transparent":"rgba("+Math.round(255*t.r/n)+","+Math.round(255*t.g/n)+","+Math.round(255*t.b/n)+","+n*e+")"}return t}var j9=/\{[^{}}]*\}/g;function U9(t,e){return t.replace(j9,function(t){return e[t.slice(1,-1)]||""})}function B9(t,e){let n=t.split(":")[0];return n===t&&(n="default"),e[n]}var $9={},q9=c5.parse("#000000"),V9=c5.parse("#FFFFFF"),W9=c5.parse("#000000"),H9=["raster-saturation","raster-contrast","raster-brightness-max","raster-brightness-min","raster-hue-rotate"],G9=["background","circle","fill","fill-extrusion","line","symbol","raster","hillshade"];function K9(t,e=512){return t.getExtent()?n7({extent:t.getExtent(),tileSize:e,maxZoom:22}).getResolutions():l9}function Z9(t,e){return e.accessToken||(e=Object.assign({},e),new URL(t).searchParams.forEach((t,n)=>{e.accessToken=t,e.accessTokenParam=n})),e}var Y9=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function X9(t,e){if(!e.ref)return e;const n=t.find(t=>t.id===e.ref);if(!n)return e;const r=Object.assign({},e);for(const i of Y9)!(i in r)&&i in n&&(r[i]=n[i]);return r}function J9(t,e,n){const r=new m7({tileJSON:e,tileSize:t.tileSize||e.tileSize||512}),i=r.getTileJSON(),s=r.getTileGrid(),o=zK(n.projection||"EPSG:3857"),a=function(t,e){const n=t.bounds;if(n){const t=$K([n[0],n[1]],e),r=$K([n[2],n[3]],e);return[t[0],t[1],r[0],r[1]]}return zK(e).getExtent()}(i,o),l=o.getExtent(),c=i.minzoom||0,u=i.maxzoom||22,h={attributions:r.getAttributions(),projection:o,tileGrid:new t7({origin:l?CG(l):s.getOrigin(0),extent:a||s.getExtent(),minZoom:c,resolutions:K9(o,e.tileSize).slice(0,u+1),tileSize:s.getTileSize(0)})};return Array.isArray(i.tiles)?h.urls=i.tiles:h.url=i.tiles,h}function Q9(t,e,n){return new Promise(function(r,i){m9(t,e,n).then(function({tileJson:e,tileLoadFunction:i}){const s=J9(t,e,n);s.tileLoadFunction=i,s.format=new y8({layerName:"mvt:layer"});const o=new w7(s);o.set("mapbox-source",t),r(o)}).catch(i)})}function ttt(t){return`{bbox-${(t?t.getCode():"EPSG:3857").toLowerCase().replace(/[^a-z0-9]/g,"-")}}`}function ett(t,e,n){const r=new K8;return function(t,e,n){return new Promise(function(r,i){m9(t,e,n).then(function({tileJson:e,tileLoadFunction:i}){const s=new m7({interpolate:void 0===n.interpolate||n.interpolate,transition:0,crossOrigin:"anonymous",tileJSON:e});s.tileGrid=J9(t,e,n).tileGrid,n.projection&&(s.projection=zK(n.projection));const o=s.getTileUrlFunction();i&&s.setTileLoadFunction(i),s.setTileUrlFunction(function(t,e,n){const r=ttt(n);let i=o(t,e,n);if(-1!=i.indexOf(r)){const e=s.getTileGrid().getTileCoordExtent(t);i=i.replace(r,e.toString())}return i}),s.set("mapbox-source",t),r(s)}).catch(function(t){i(t)})})}(t,e,n).then(function(t){r.setSource(t)}).catch(function(){r.setSource(void 0)}),r}function ntt(t,e,n){const r=n.projection?new K2({dataProjection:n.projection}):new K2,i=t.data,s={};if("string"==typeof i){const[s]=P7(i,n.accessToken,n.accessTokenParam||"access_token",e||location.href);if(/\{bbox-[0-9a-z-]+\}/.test(s)){const e=(t,e,n)=>{const r=ttt(n);return s.replace(r,`${t.join(",")}`)},i=new z2({attributions:t.attribution,format:r,loader:(t,r,s,o,a)=>{p9("GeoJSON","function"==typeof e?e(t,r,s):e,n).then(t=>{const e=i.getFormat().readFeatures(t,{featureProjection:s});i.addFeatures(e),o(e)}).catch(()=>{i.removeLoadedExtent(t),a()})},strategy:L2});return i.set("mapbox-source",t),i}const o=new z2({attributions:t.attribution,format:r,url:s,loader:(t,e,r,i,a)=>{p9("GeoJSON",s,n).then(t=>{const e=o.getFormat().readFeatures(t,{featureProjection:r});o.addFeatures(e),i(e)}).catch(()=>{o.removeLoadedExtent(t),a()})}});return o}s.features=r.readFeatures(i,{featureProjection:"EPSG:3857"});const o=new z2(Object.assign({attributions:t.attribution,format:r},s));return o.set("mapbox-source",t),o}function rtt(t,e,n,r){n=X9(t.layers,n);const i=o9(t),s=n.type;let o=n.source;const a=t.sources[o];let l;var c;return"background"==s?(l=function(t,e,n){const r=vH?{style:{}}:document.createElement("div");return r.className="ol-mapbox-style-background",r.style.position="absolute",r.style.width="100%",r.style.height="100%",new AX({source:new A2({}),render(i){const s=function(t,e,n,r){const i={id:t.id,type:t.type},s=t.paint||{};let o;i.paint=s,k7.zoom=u9(e,n.resolutions||l9),k7.distanceFromCenter=0;const a=N9(i,"paint","background-color",e9,r);return void 0!==s["background-opacity"]&&(o=N9(i,"paint","background-opacity",e9,r)),"none"===N9(i,"layout","visibility",e9,r)?void 0:z9(a,o)}(t,i.viewState.resolution,e,n);return r.style.backgroundColor=s,r}})}(n,r,i),o=void 0):"vector"==a.type?l=function(t,e,n){const r=new J8({declutter:!0,visible:!1});return Q9(t,e,n).then(function(t){r.setSource(t)}).catch(function(){r.setSource(void 0)}),r}(a,e,r):"raster"==a.type?(Object.keys(n.paint||{}).find(t=>H9.includes(t))?(c=ett(a,e,r),l=new O7({source:new V7({operationType:"image",operation:Z7,sources:[c]})}),function(t,e,n,r){t.getSource().on("beforeoperations",function(t){k7.zoom=u9(t.resolution,n.resolutions||l9),k7.distanceFromCenter=0;const i=t.data;i.saturation=N9(e,"paint","raster-saturation",e9,r),i.contrast=N9(e,"paint","raster-contrast",e9,r),i.brightnessHigh=N9(e,"paint","raster-brightness-max",e9,r),i.brightnessLow=N9(e,"paint","raster-brightness-min",e9,r),i.hueRotate=N9(e,"paint","raster-hue-rotate",e9,r)})}(l,n,r,i)):l=ett(a,e,r),l.setVisible(!n.layout||"none"!==N9(n,"layout","visibility",e9,i)),l.on("prerender",function(t,e,n){let r=null;return function(i){t.paint&&"raster-opacity"in t.paint&&i.frameState.viewState.zoom!==r&&(r=i.frameState.viewState.zoom,delete n[t.id],function(t,e,n,r){k7.zoom=n,k7.distanceFromCenter=0;const i=N9(t,"paint","raster-opacity",e9,r);e.setOpacity(i)}(t,e,r,n))}}(n,l,i))):"geojson"==a.type?l=function(t,e,n){return new k2({declutter:!0,source:ntt(t,e,n),visible:!1})}(a,e,r):"raster-dem"==a.type&&"hillshade"==n.type&&(l=function(t){return new O7({source:new V7({operationType:"image",operation:K7,sources:[t]})})}(ett(a,e,r)),function(t,e,n,r,i){t.getSource().on("beforeoperations",function(t){const s=t.data;s.resolution=jK(r.projection||"EPSG:3857",t.resolution,mG(t.extent),"m");const o=u9(t.resolution,r.resolutions||l9);k7.zoom=o,k7.distanceFromCenter=0,s.zoom=o,s.encoding=e.encoding,s.method=N9(n,"paint","hillshade-method",e9,i)||"standard",s.exaggeration=N9(n,"paint","hillshade-exaggeration",e9,i);let a=N9(n,"paint","hillshade-illumination-direction",e9,i);null==a&&(a=335),s.azimuths=Array.isArray(a)?a:[a],s.sunAz=s.azimuths[0];let l=N9(n,"paint","hillshade-illumination-altitude",e9,i);function c(t){return t&&t.values?t.values[0]:t}function u(t){const e=n.paint?.[t];if(Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&void 0!==c5.parse(e[0]))return e.map(t=>c5.parse(t));let r=N9(n,"paint",t,e9,i);return r=c(r),r?[r]:void 0}null==l&&(l=45),s.altitudes=Array.isArray(l)?l:[l],s.highlightColors=u("hillshade-highlight-color"),s.highlightColor=s.highlightColors?.[0]||V9,s.highlightColors||(s.highlightColors=[s.highlightColor]),s.shadowColors=u("hillshade-shadow-color"),s.shadowColor=s.shadowColors?.[0]||q9,s.shadowColors||(s.shadowColors=[s.shadowColor]),s.accentColor=c(N9(n,"paint","hillshade-accent-color",e9,i))||W9})}(l,a,n,r,i),l.setVisible(!n.layout||"none"!==N9(n,"layout","visibility",e9,i))),l&&l.set("mapbox-source",o),l}function itt(t,e,n,r){t.schema&&Object.assign(S7,Object.keys(t.schema).reduce((e,n)=>(e[n]=t.schema[n]?.default,e),{}));const i=[];let s=null;if(e instanceof l1){if(s=e.getView(),!s.isDef()&&!s.getRotation()&&!s.getResolutions()){const t=r.projection?zK(r.projection):s.getProjection();s=new lY(Object.assign(s.getProperties(),{maxResolution:l9[0]/$G[t.getUnits()],projection:r.projection||s.getProjection()})),e.setView(s)}"center"in t&&!s.getCenter()&&s.setCenter($K(t.center,s.getProjection())),"zoom"in t&&void 0===s.getZoom()&&s.setResolution(l9[0]/$G[s.getProjection().getUnits()]/Math.pow(2,t.zoom)),s.getCenter()&&void 0!==s.getZoom()||s.fit(s.getProjection().getExtent(),{nearest:!0,size:e.getSize()})}e.set("mapbox-style",t),e.set("mapbox-metadata",{styleUrl:n,options:r});const o=t.layers;let a,l,c,u=[];for(let h=0,d=o.length;h0||n>0)&&t.setMaxResolution(Math.min(h9(Math.max(0,o-1e-12),l9),h9(Math.max(0,n-1e-12),e.getResolutions()))),a<24&&t.setMinResolution(h9(a,l9))}}else o>0&&t.setMaxResolution(h9(Math.max(0,o-1e-12),l9));u instanceof z2||u instanceof w7?function(t,e,n="",r={},i){let s,o,a,l,c=!0;return"string"==typeof n||Array.isArray(n)?l=n:(a=n,l=a.source||a.layers,r=a),"string"==typeof r?(s=r,a={}):(s=r.styleUrl,a=r),!1===a.updateSource&&(c=!1),i||(i=a.resolutions),s||"string"!=typeof e||e.trim().startsWith("{")||(s=e),s&&(s=s.startsWith("data:")?location.href:L7(s,a.accessToken),a=Z9(s,a)),new Promise(function(n,r){f9(e,a).then(function(e){if(8!=e.version)return r(new Error("glStyle version 8 required."));if(!(t instanceof k2||t instanceof J8))return r(new Error("Can only apply to VectorLayer or VectorTileLayer"));const u=t instanceof J8?"vector":"geojson";if(l?o=Array.isArray(l)?e.layers.find(function(t){return t.id===l[0]}).source:l:(o=e.layers.find(function(t){return t.source&&e.sources[t.source].type===u}).source,l=o),!o)return r(new Error(`No ${u} source found in the glStyle.`));function h(){if(!c)return Promise.resolve();if(t instanceof J8)return Q9(e.sources[o],s,a).then(function(e){const n=t.getSource();n?e!==n&&(n.setTileUrlFunction(e.getTileUrlFunction()),"function"==typeof n.setUrls&&"function"==typeof e.getUrls&&n.setUrls(e.getUrls()),n.format_||(n.format_=e.format_),n.getAttributions()||n.setAttributions(e.getAttributions()),n.getTileLoadFunction()===_7&&n.setTileLoadFunction(e.getTileLoadFunction()),VK(n.getProjection(),e.getProjection())&&(n.tileGrid=e.getTileGrid())):t.setSource(e);const r=t.getSource().getTileGrid();!isFinite(t.getMaxResolution())&&!isFinite(t.getMinZoom())&&r.getMinZoom()>0&&t.setMaxResolution(h9(Math.max(0,r.getMinZoom()-1e-12),r.getResolutions()))});const n=e.sources[o];let r=t.getSource();r&&r.get("mapbox-source")===n||(r=ntt(n,s,a));const i=t.getSource();return i?r!==i&&(i.getAttributions()||i.setAttributions(r.getAttributions()),i.format_||(i.format_=r.getFormat()),i.url_=r.getUrl()):t.setSource(r),Promise.resolve()}let d,p;const f={},g={};function m(){if(p||e.sprite&&!f)p?(t.setStyle(p),h().then(n).catch(r)):r(new Error("Something went wrong trying to apply style."));else{if(a.projection&&!i){const t=zK(a.projection).getUnits();"m"!==t&&(i=l9.map(e=>e/$G[t]))}let s;const c=t.getSource();c instanceof w7&&c.format_ instanceof y8&&(s=c.format_.layerName_),p=function(t,e,n,r=l9,i,s,o,a){if("string"==typeof e&&(e=JSON.parse(e)),e.schema)for(const b in e.schema){const t=e.schema[b];"default"in t&&(S7[b]=t.default)}if(8!=e.version)throw new Error("glStyle version 8 required.");$9[function(t,e){return s9(t)+"."+sH(e)}(e,t)]=Array.from(arguments);const l={};("string"==typeof s||s instanceof Request||s instanceof Response||s instanceof Promise)&&(s={default:s});for(const b in s){const e=s[b];QW(()=>e).then(async e=>{let n;if("undefined"!=typeof Image){const r=new Image;if("string"==typeof e)r.crossOrigin="anonymous",r.src=e;else{let t;e instanceof Request?t=await fetch(e):e instanceof Response&&(t=e);const i=await t.blob();n=URL.createObjectURL(i),r.src=n}r.addEventListener("load",function e(){r.removeEventListener("load",e),l[b]={image:r,size:[r.width,r.height]},t.changed(),n&&URL.revokeObjectURL(n)}),r.addEventListener("error",function t(){URL.revokeObjectURL(n),r.removeEventListener("error",t)})}else if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){const t=self;t.postMessage({action:"loadImage",src:e}),t.addEventListener("message",function(t){"imageLoaded"===t.data.action&&t.data.src===e&&(l[b]={image:t.data.image,size:[t.data.image.width,t.data.image.height]})})}})}const c=d3(e.layers),u={},h=[],d={},p={},f=o9(e),g=function(t){let e=r9[t.id];return e||(e={},r9[s9(t)]=e),e}(e);let m;for(let b=0,w=c.length;b=h.maxzoom)continue;const S=h.filter;if(!S||D9(w,S,k,g)){let r,c,g,v,b,w;R=h;const S=u.index;if(3==_&&("fill"==h.type||"fill-extrusion"==h.type))if(c=N9(h,"paint",h.type+"-opacity",k,f,E),h.type+"-pattern"in C){const t=N9(h,"paint",h.type+"-pattern",k,f,E);if(t){const e="string"==typeof t?U9(t,m):t.toString(),n=B9(e,l);if(i&&i[e]&&n){++T,w=y[T],w&&w.getFill()&&!w.getStroke()&&!w.getText()||(w=new k0({fill:new _0}),y[T]=w),g=w.getFill(),w.setZIndex(S);const t=e+"."+c;let r=p[t];if(!r){const s=i[e],o=c9(s.width,s.height),a=o.getContext("2d");a.globalAlpha=c,a.drawImage(n.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r=a.createPattern(o,"repeat"),p[t]=r}g.setColor(r)}}}else if(r=z9(N9(h,"paint",h.type+"-color",k,f,E),c),h.type+"-outline-color"in C&&(b=z9(N9(h,"paint",h.type+"-outline-color",k,f,E),c)),b||(b=r),r||b){if(++T,w=y[T],(!w||r&&!w.getFill()||!r&&w.getFill()||b&&!w.getStroke()||!b&&w.getStroke()||w.getText())&&(w=new k0({fill:r?new _0:void 0,stroke:b?new S0:void 0}),y[T]=w),r&&(g=w.getFill(),g.setColor(r)),"fill-extrusion"===h.type){const t=N9(h,"paint","fill-extrusion-height",k,f,E);if(t>0){const e=Math.max(.1,.9-Math.min(t,225)/280);if(b&&"transparent"!==b){const t=c5.parse(b);b=`rgba(${Math.round(255*t.r*e)},${Math.round(255*t.g*e)},${Math.round(255*t.b*e)},${t.a})`}}}b&&(v=w.getStroke(),v.setColor(b),v.setWidth(.5)),w.setZIndex(S)}if(1!=_&&"line"==h.type){r="line-pattern"in C?void 0:z9(N9(h,"paint","line-color",k,f,E),N9(h,"paint","line-opacity",k,f,E));const t=N9(h,"paint","line-width",k,f,E);r&&t>0&&(++T,w=y[T],w&&w.getStroke()&&!w.getFill()&&!w.getText()||(w=new k0({stroke:new S0}),y[T]=w),v=w.getStroke(),v.setLineCap(N9(h,"layout","line-cap",k,f,E)),v.setLineJoin(N9(h,"layout","line-join",k,f,E)),v.setMiterLimit(N9(h,"layout","line-miter-limit",k,f,E)),v.setColor(r),v.setWidth(t),v.setLineDash(C["line-dasharray"]?N9(h,"paint","line-dasharray",k,f,E).map(function(e){return e*t}):null),"function"==typeof v.setOffset&&v.setOffset(N9(h,"paint","line-offset",k,f,E)),w.setZIndex(S))}let L,I,P,M,A,O,N,F,D,z=!1,j=null,U=0;if((1==_||2==_)&&"icon-image"in x){const e=N9(h,"layout","icon-image",k,f,E);if(e){let r;L="string"==typeof e?U9(e,m):e.toString();const o=a?a(t,L):void 0,c=B9(L,l);if(i&&i[L]&&c||o){const t=N9(h,"layout","icon-rotation-alignment",k,f,E);if(2==_){const e=n.getGeometry();if(e.getFlatMidpoint||e.getFlatMidpoints){const n=e.getExtent();if(Math.sqrt(Math.max(Math.pow((n[2]-n[0])/s,2),Math.pow((n[3]-n[1])/s,2)))>150){const n="MultiLineString"===e.getType()?e.getFlatMidpoints():e.getFlatMidpoint();if(L9||(L9=new P2("Point",T9=[NaN,NaN],[],2,{},void 0)),r=L9,T9[0]=n[0],T9[1]=n[1],"line"===N9(h,"layout","symbol-placement",k,f,E)&&"map"===t){const t=e.getStride(),r=e.getFlatCoordinates();for(let e=0,i=r.length-t;e=l){U=Math.atan2(s-a,o-i);break}}}}}}if(2!==_||r){const e=N9(h,"layout","icon-size",k,f,E),n=void 0!==C["icon-color"]?N9(h,"paint","icon-color",k,f,E):null;if(!n||0!==n.a){const r=N9(h,"paint","icon-halo-color",k,f,E),s=N9(h,"paint","icon-halo-width",k,f,E);let a=`${L}.${e}.${s}.${r}`;if(null!==n&&(a+=`.${n}`),I=d[a],!I){const l=F9(h,k,"icon",f);let u;"icon-offset"in x&&(u=N9(h,"layout","icon-offset",k,f,E).slice(0),u[0]*=e,u[1]*=-e);let p=n?[255*n.r,255*n.g,255*n.b,n.a]:void 0;if(o){const n={color:p,rotateWithView:"map"===t,displacement:u,declutterMode:l,scale:e};"string"==typeof o?n.src=o:(n.img=o,n.imgSize=[o.width,o.height]),I=new C0(n)}else{const o=i[L];let a,h,d;s?o.sdf?(a=y9(b9(c.image,o,n||[0,0,0,1]),{x:0,y:0,width:o.width,height:o.height,pixelRatio:o.pixelRatio},s,r),p=void 0):a=y9(c.image,o,s,r):(o.sdf&&(c.unSDFed||(c.image=b9(c.image,{x:0,y:0,width:c.size[0],height:c.size[1]},{r:1,g:1,b:1,a:1}),c.unSDFed=!0)),a=c.image,h=[o.width,o.height],d=[o.x,o.y]),I=new C0({color:p,img:a,imgSize:c.size,size:h,offset:d,rotateWithView:"map"===t,scale:e/o.pixelRatio,displacement:u,declutterMode:l})}d[a]=I}}I&&(++T,w=y[T],w&&w.getImage()&&!w.getFill()&&!w.getStroke()||(w=new k0,y[T]=w),w.setGeometry(r),I.setRotation(U+a9(N9(h,"layout","icon-rotate",k,f,E))),I.setOpacity(N9(h,"paint","icon-opacity",k,f,E)),I.setAnchor(A9[N9(h,"layout","icon-anchor",k,f,E)]),w.setImage(I),j=w.getText(),w.setText(void 0),w.setZIndex(S),z=!0,P=!1)}else P=!0}}}if(1==_&&"circle"===h.type){++T,w=y[T],w&&w.getImage()&&!w.getFill()&&!w.getStroke()||(w=new k0,y[T]=w);const t="circle-radius"in C?N9(h,"paint","circle-radius",k,f,E):5,e=z9(N9(h,"paint","circle-stroke-color",k,f,E),N9(h,"paint","circle-stroke-opacity",k,f,E)),n=N9(h,"paint","circle-translate",k,f,E),r=z9(N9(h,"paint","circle-color",k,f,E),N9(h,"paint","circle-opacity",k,f,E)),i=N9(h,"paint","circle-stroke-width",k,f,E),s=t+"."+e+"."+r+"."+i+"."+n[0]+"."+n[1];I=d[s],I||(I=new w0({radius:t,displacement:[n[0],-n[1]],stroke:e&&i>0?new S0({width:i,color:e}):void 0,fill:r?new _0({color:r}):void 0,declutterMode:"none"}),d[s]=I),w.setImage(I),j=w.getText(),w.setText(void 0),w.setGeometry(void 0),w.setZIndex(S),z=!0}if("text-field"in x){N=Math.round(N9(h,"layout","text-size",k,f,E));const t=N9(h,"layout","text-font",k,f,E);O=N9(h,"layout","text-line-height",k,f,E),A=t9(o?o(t,e.metadata?e.metadata["ol:webfonts"]:void 0):t,N,O),A.includes("sans-serif")||(A+=",sans-serif"),F=N9(h,"layout","text-letter-spacing",k,f,E),D=N9(h,"layout","text-max-width",k,f,E);const n=N9(h,"layout","text-field",k,f,E);M="object"==typeof n&&n.sections?1===n.sections.length?n.toString():n.sections.reduce((e,n)=>{const r=n.fontStack?n.fontStack.split(","):t,i=t9(o?o(r):r,N*(n.scale||1),O);let s=n.text;if("\n"===s)return e.push("\n",""),e;if(2==_)return e.push(x9(s,F),i),e;s=R9(s,i,D,F).split("\n");for(let t=0,o=s.length;t0&&e.push("\n",""),e.push(s[t],i);return e},[]):U9(n,m).trim(),c=N9(h,"paint","text-opacity",k,f,E)}if(M&&c&&!P){z||(++T,w=y[T],w&&w.getText()&&!w.getFill()&&!w.getStroke()||(w=new k0,y[T]=w),w.setImage(void 0),w.setGeometry(void 0));const t=F9(h,k,"text",f);w.getText()||w.setText(j),j=w.getText(),(!j||"getDeclutterMode"in j&&j.getDeclutterMode()!==t)&&(j=new L0({padding:[2,2,2,2],declutterMode:t}),w.setText(j));const e=N9(h,"layout","text-transform",k,f,E);"uppercase"==e?M=Array.isArray(M)?M.map((t,e)=>e%2?t:t.toUpperCase()):M.toUpperCase():"lowercase"==e&&(M=Array.isArray(M)?M.map((t,e)=>e%2?t:t.toLowerCase()):M.toLowerCase());const n=Array.isArray(M)?M:2==_?x9(M,F):R9(M,A,D,F);if(j.setText(n),j.setFont(A),j.setRotation(a9(N9(h,"layout","text-rotate",k,f,E))),"function"==typeof j.setKeepUpright){const t=N9(h,"layout","text-keep-upright",k,f,E);j.setKeepUpright(t)}const r=N9(h,"layout","text-anchor",k,f,E),i=z||1==_?"point":N9(h,"layout","symbol-placement",k,f,E);let s;if("line-center"===i?(j.setPlacement("line"),s="center"):j.setPlacement(i),"line"===i&&"function"==typeof j.setRepeat){const t=N9(h,"layout","symbol-spacing",k,f,E);j.setRepeat(2*t)}j.setOverflow("point"===i);let o=N9(h,"paint","text-halo-width",k,f,E);const a=N9(h,"layout","text-offset",k,f,E),l=N9(h,"paint","text-translate",k,f,E);let u=0,d=0;if("point"==i){s="center",-1!==r.indexOf("left")?(s="left",d=o):-1!==r.indexOf("right")&&(s="right",d=-o);const t=N9(h,"layout","text-rotation-alignment",k,f,E);j.setRotateWithView("map"==t)}else j.setMaxAngle(a9(N9(h,"layout","text-max-angle",k,f,E))*M.length/n.length),j.setRotateWithView(!1);j.setTextAlign(s);let p="middle";0==r.indexOf("bottom")?(p="bottom",u=-o-.5*(O-1)*N):0==r.indexOf("top")&&(p="top",u=o+.5*(O-1)*N),j.setTextBaseline(p);const g=N9(h,"layout","text-justify",k,f,E);j.setJustify("auto"===g?void 0:g),j.setOffsetX(a[0]*N+d+l[0]),j.setOffsetY(a[1]*N+u+l[1]);const m=j.getFill()||new _0;m.setColor(z9(N9(h,"paint","text-color",k,f,E),c)),j.setFill(m);const v=z9(N9(h,"paint","text-halo-color",k,f,E),c);if(v&&o>0){const t=j.getStroke()||new S0;t.setColor(v),o*=2;const e=.5*N;t.setWidth(o<=e?o:e),j.setStroke(t)}else j.setStroke(void 0);const b=N9(h,"layout","text-padding",k,f,E),x=j.getPadding();b!==x[0]&&(x[0]=b,x[1]=b,x[2]=b,x[3]=b),w.setZIndex(S)}}}return T>-1?(y.length=T+1,y):void 0};return t.setStyle(v),t.set("mapbox-layers",h),t.set("mapbox-source",m),t.set("mapbox-featurestate",t.get("mapbox-featurestate")||{}),v}(t,e,l,i,f,g,(t,e=a.webfonts)=>function(t,e="https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css"){if(vH)return t;let n;for(let r=0,i=t.length;r{await document.fonts.ready;for(let t=0,r=n.length;tt.family.replace(/^['"]|['"]$/g,"").toLowerCase()===i.toLowerCase()&&S9(t.weight,s)&&t.style===o)){const t=e.replace("{font-family}",i.replace(/ /g,"-").toLowerCase()).replace("{Font+Family}",i.replace(/ /g,"+")).replace("{fontweight}",s).replace("{-fontstyle}",o.replace("normal","").replace(/(.+)/,"-$1")).replace("{fontstyle}",o);if(!document.querySelector('link[href="'+t+'"]')){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}}}})(),t):t}(t,e),a.getImage,s),t.getStyle()?h().then(n).catch(r):r(new Error(`Nothing to show for source [${o}]`))}}if(e.sprite){const t=function(t,e,n){if("string"==typeof t)return[{id:"default",url:T7(t,e,n)}];for(const r of t)r.url=T7(r.url,e,n);return t}(e.sprite,a.accessToken,s||location.href);d=vH?1:window.devicePixelRatio>=1.5?.5:1;const n=.5==d?"@2x":"";Promise.all(t.map(function(t){const e=new URL(t.url);let i=e.origin+e.pathname+n+".json"+e.search;return new Promise(function(t,n){p9("Sprite",i,a).then(t).catch(function(){i=e.origin+e.pathname+".json"+e.search,p9("Sprite",i,a).then(t).catch(n)})}).then(function(i){let s;if(void 0===i&&r(new Error("No sprites found.")),s=e.origin+e.pathname+n+".png"+e.search,a.transformRequest){const t=a.transformRequest(s,"SpriteImage")||s;(t instanceof Request||t instanceof Promise)&&(s=t)}g[t.id]=s;for(const e in i){const n="default"==t.id?e:`${t.id}:${e}`;f[n]=i[e]}}).catch(function(t){r(new Error(`Sprites cannot be loaded: ${i}: ${t.message}`))})})).then(m).catch(r)}else m()}).catch(r)})}(t,n,e,Object.assign({styleUrl:r},s)).then(function(){!function(t,e,n){function r(){const r=e.get("mapbox-style");if(!r)return;const i=d3(r.layers),s=t.get("mapbox-layers"),o=i.filter(function(t){return s.includes(t.id)}).some(function(t){return!t.layout||"visible"===N9(t,"layout","visibility",e9,n)});t.get("visible")!==o&&t.setVisible(o)}t.on("change",r),r()}(t,i,o9(n)),l()}).catch(c):l()}else c(new Error("Error accessing data for source "+t.get("mapbox-source")))};t.set("mapbox-layers",e);const h=i.getLayers();-1===h.getArray().indexOf(t)&&h.push(t),t.getSource()?u():t.once("change:source",u)})}var ott=class extends u${static{aF(this.prototype,"osm",[dp])}#B=void cF(this,"osm");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");mapInstance;bookmarkSource;searchResultsSource;selectedShapeSource;searchOverlay;searchOverlayElement;selectedPinOverlay;selectedPinElement;crosshairElement;crosshairOverlay;ignoreNextMapClick=!1;setupMap=q$(t=>{if(this.mapInstance)return;const e=new TX;this.selectedShapeSource=new z2;const n=new k2({source:this.selectedShapeSource,style:new k0({stroke:new S0({color:"#3388ff",width:4}),fill:new _0({color:"rgba(51, 136, 255, 0.1)"})}),zIndex:5});this.bookmarkSource=new z2;const r=new k2({source:this.bookmarkSource,style:t=>{const e=t.get("originalPlace");let n=getComputedStyle(document.documentElement).getPropertyValue("--default-list-color").trim()||"#000000";if(e&&e._listIds&&e._listIds.length>0){const t=e._listIds[0],r=this.storage.lists.find(e=>e.id===t);r&&r.color&&(n=r.color)}return[new k0({image:new w0({radius:10,fill:new _0({color:"rgba(0, 0, 0, 0.2)"}),displacement:[0,-2]})}),new k0({image:new w0({radius:9,fill:new _0({color:n}),stroke:new S0({color:"#fff",width:2})})})]},zIndex:10});this.searchResultsSource=new z2;const i=new Map,s=new k2({source:this.searchResultsSource,style:t=>{const e=t.get("originalPlace"),n=this.mapUi.selectedPlace;if(n){const t=e.osmId&&n.osmId&&e.osmId===n.osmId,r=e.id&&n.id&&e.id===n.id,i=e.lat===n.lat&&e.lon===n.lon;if(t||r||i)return new k0({})}const r=sB(e.osmTags||e),s=r||"default";if(!i.has(s)){const t=getComputedStyle(document.documentElement).getPropertyValue("--marker-color-primary").trim()||"#ea4335";let e=``;if(r){const n=eB(r);if(n){let r=n.trim();const i=r.indexOf("",i)+1,o=r.lastIndexOf("");-1!==i&&-1!==o&&(r=r.substring(s,o)),e=`\n \n \n ${r}\n \n `}}const n=`\n \n \n \n \n \n \n \n ${e}\n \n `;i.set(s,"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(n.trim()))}return new k0({image:new C0({src:i.get(s),anchor:[.5,.65],scale:1})})},zIndex:11});let o=[14.21683569,27.060114248],a=2.661,l=!1;try{const t=localStorage.getItem("marco:map-view");if(t){const e=JSON.parse(t);e.center&&Array.isArray(e.center)&&2===e.center.length&&"number"==typeof e.zoom&&(o=e.center,a=e.zoom,l=!0)}}catch(k){console.warn("Failed to restore map view:",k)}const c=new lY({center:$K(o),zoom:a,projection:"EPSG:3857"});this.mapInstance=new l1({target:t,layers:[e,n,s,r],view:c,controls:OY({zoom:!0,rotate:!0,attribution:!0}),interactions:pX({dragPan:!1})});const u=qK(c.getCenter());this.mapUi.updateCenter(u[1],u[0]),this.mapUi.updateZoom(c.getZoom()),function(t,e,n={}){let r,i;if(vH){if(!(t instanceof l1||t instanceof TX))throw new Error("ol-mapbox-style in a web worker requires a Map or a LayerGroup as first argument");i=t}else i="string"==typeof t||t instanceof HTMLElement?new l1({target:t}):t;if("string"==typeof e){const t=e.startsWith("data:")?location.href:L7(e,n.accessToken);n=Z9(t,n),r=new Promise(function(r,s){f9(e,n).then(function(e){itt(e,i,t,n).then(function(){r(i)}).catch(s)}).catch(function(t){s(new Error(`Could not load ${e}: ${t.message}`))})})}else r=new Promise(function(t,r){itt(e,i,!n.styleUrl||n.styleUrl.startsWith("data:")?location.href:L7(n.styleUrl,n.accessToken),n).then(function(){t(i)}).catch(r)})}(this.mapInstance,"https://tiles.openfreemap.org/styles/liberty",{webfonts:"data:text/css,"}),this.searchOverlayElement=document.createElement("div"),this.searchOverlayElement.className="search-pulse",this.searchOverlay=new f1({element:this.searchOverlayElement,positioning:"center-center",stopEvent:!1}),this.mapInstance.addOverlay(this.searchOverlay),this.selectedPinElement=document.createElement("div"),this.selectedPinElement.className="selected-pin-container";const h=document.createElement("div");h.className="selected-pin",h.innerHTML='';const d=document.createElement("div");d.className="selected-pin-shadow",this.selectedPinElement.appendChild(h),this.selectedPinElement.appendChild(d),this.selectedPinOverlay=new f1({element:this.selectedPinElement,positioning:"bottom-center",stopEvent:!1}),this.mapInstance.addOverlay(this.selectedPinOverlay),this.crosshairElement=document.createElement("div"),this.crosshairElement.className="map-crosshair",this.crosshairElement.innerHTML='\n \n \n \n \n ',t.appendChild(this.crosshairElement),this.locationOverlayElement=document.createElement("div"),this.locationOverlayElement.className="search-pulse blue",this.locationOverlay=new f1({element:this.locationOverlayElement,positioning:"center-center",stopEvent:!1}),this.mapInstance.addOverlay(this.locationOverlay),t.addEventListener("pointerdown",()=>{this.mapUi.searchBoxHasFocus&&(this.ignoreNextMapClick=!0)},!0);const p=new l3({trackingOptions:{enableHighAccuracy:!0},projection:c.getProjection()}),f=new g1;f.setStyle(new k0({image:new w0({radius:6,fill:new _0({color:"#3399CC"}),stroke:new S0({color:"#fff",width:2})})}));const g=new z2({features:[f]}),m=new k2({source:g,zIndex:15});p.on("change:position",function(){const t=p.getPosition();f.setGeometry(t?new WZ(t):null)});const y=document.createElement("div");y.className="ol-control ol-locate";const v=document.createElement("button");let b,w;v.style.display="flex",v.style.alignItems="center",v.style.justifyContent="center",v.innerHTML=`${eB("navigation")}`,v.title="Locate Me",y.appendChild(v);const _=()=>{b&&(clearTimeout(b),b=null);try{w&&(p.un("change:position",x),w=null)}catch{}this.locationOverlayElement&&this.locationOverlayElement.classList.remove("active")},x=()=>{const t=p.getPosition(),e=p.getAccuracyGeometry(),n=p.getAccuracy();if(console.debug("Geolocation change:",{coordinates:t,accuracy:n}),!t)return;const r=this.mapInstance.getSize(),i=this.mapInstance.getView();let s=null;if(this.locationOverlayElement){const e=i.getResolution(),r=2*(n||50)/jK(i.getProjection(),e,t);this.locationOverlayElement.style.width=`${r}px`,this.locationOverlayElement.style.height=`${r}px`,this.locationOverlay.setPosition(t)}if(n&&n<=20&&_(),e){const t=e.getExtent();s=3.162*i.getResolutionForExtent(t,r)}else n&&(s=6.325*n/Math.min(r[0],r[1])/jK(i.getProjection(),1,t));let o={center:t,duration:1e3};if(s){const t=i.getResolutionForZoom(17);o.resolution=Math.max(s,t)}else o.zoom=16;this.mapInstance.getView().animate(o)},C=()=>{console.debug("Getting current geolocation..."),_(),p.setTracking(!0);const t=p.getPosition();this.locationOverlayElement&&this.locationOverlayElement.classList.add("active"),t&&x(),w=p.on("change:position",x),b=setTimeout(()=>{_()},1e4)};v.addEventListener("click",C);const S=new IY({element:y});this.mapInstance.addLayer(m),this.mapInstance.addControl(S),l||"index"!==this.router.currentRouteName||C(),this.mapInstance.on("singleclick",this.handleMapClick),this.mapInstance.on("moveend",this.handleMapMove),this.mapInstance.on("pointermove",t=>{const e=this.mapInstance.getEventPixel(t.originalEvent),n=this.mapInstance.hasFeatureAtPixel(e,{hitTolerance:10});this.mapInstance.getTarget().style.cursor=n?"pointer":""}),this.storage.rs.on("ready",()=>{this.handleMapMove()})});updateInteractions=q$(()=>{if(!this.mapInstance)return;this.mapInstance.getInteractions().getArray().slice().forEach(t=>{t instanceof JY&&this.mapInstance.removeInteraction(t)});const t=!!this.settings.mapKinetic&&new NY(-.005,.05,100);this.settings.mapKinetic&&window.innerWidth<=768&&(t.minVelocity_=.25),this.mapInstance.addInteraction(new JY({kinetic:t}))});updateSearchResults=q$(()=>{if(!this.searchResultsSource)return;this.searchResultsSource.clear();const t=this.mapUi.searchResults;if(!t||0===t.length)return;const e=[];t.forEach(t=>{if(t.lat&&t.lon){const n=new g1({geometry:new WZ($K([t.lon,t.lat])),name:t.title,id:t.id,isSearchResult:!0,originalPlace:t});e.push(n)}}),e.length>0&&this.searchResultsSource.addFeatures(e)});updateSelectedPin=q$(()=>{const t=this.mapUi.selectedPlace,e=this.mapUi.selectionOptions||{};if(this.searchResultsSource&&this.searchResultsSource.changed(),this.selectedPinOverlay&&this.selectedPinElement)if(this.selectedShapeSource&&this.selectedShapeSource.clear(),t&&t.lat&&t.lon){const r=$K([t.lon,t.lat]);if(this.selectedPinOverlay.setPosition(r),this.selectedPinElement.classList.remove("active"),this.selectedPinElement.offsetWidth,this.selectedPinElement.classList.add("active"),t.geojson&&this.selectedShapeSource)try{const e=(new K2).readFeature(t.geojson,{featureProjection:"EPSG:3857"});this.selectedShapeSource.addFeature(e)}catch(n){console.warn("Failed to render selected place shape:",n)}e.preventZoom?t.bbox&&!this.bboxFitsInView(t.bbox)?this.zoomToBbox(t.bbox):this.handlePinVisibility(r,{maintainZoom:!0}):t.bbox?this.zoomToBbox(t.bbox):this.handlePinVisibility(r)}else this.selectedPinElement.classList.remove("active"),this.selectedPinOverlay.setPosition(void 0)});bboxFitsInView(t){if(!this.mapInstance||!t)return!0;const e=this.mapInstance.getView(),n=this.mapInstance.getSize();return tG(e.calculateExtent(n),[...$K([t.minLon,t.minLat]),...$K([t.maxLon,t.maxLat])])}zoomToBbox(t){if(!this.mapInstance||!t)return;const e=this.mapInstance.getView(),n=this.mapInstance.getSize(),r=[...$K([t.minLon,t.minLat]),...$K([t.maxLon,t.maxLat])];let i=[.15*n[1],.15*n[0],.15*n[1],.15*n[0]];if(n[0]<=768){const t=.5*n[1],e=.15*t,r=.5*n[1]+.15*t;i[0]=e,i[2]=r}else if(this.args.isSidebarOpen){const t=getComputedStyle(document.documentElement).getPropertyValue("--sidebar-width").trim(),e=parseInt(t,10)||360,r=n[0]-e;i[3]=e+.15*r,i[1]=.15*r}const s=e.getZoom();e.fit(r,{padding:i,duration:1e3,easing:t=>t*(2-t),maxZoom:Math.max(s,18)})}handlePinVisibility(t,e={}){if(!this.mapInstance)return;const n=this.mapInstance.getView().getZoom();if(!e.maintainZoom&&n<16)return void this.animateToSmartCenter(t,16);const r=this.mapInstance.getPixelFromCoordinate(t),i=this.mapInstance.getSize();if(!r||r[0]<0||r[0]>i[0]||r[1]<0||r[1]>i[1]){const n=e.maintainZoom?null:16;this.animateToSmartCenter(t,n)}else this.panIfObscured(t)}animateToSmartCenter(t,e=null){if(!this.mapInstance)return;const n=this.mapInstance.getSize(),r=this.mapInstance.getView();let i=r.getResolution();null!==e&&(i=r.getResolutionForZoom(e));let s=t;if(n[0]<=768){const e=n[1],r=document.querySelector(".app-header"),o=r?r.offsetHeight:60,a=(e/2-(o+(e/2-o)/2))*i;s=[t[0],t[1]-a]}else if(this.args.isSidebarOpen){const e=getComputedStyle(document.documentElement).getPropertyValue("--sidebar-width").trim(),n=(parseInt(e,10)||360)/2*i;s=[t[0]-n,t[1]]}const o={center:s,duration:1e3,easing:t=>t*(2-t)};null!==e&&(o.zoom=e),r.animate(o)}panIfObscured(t){if(!this.mapInstance)return;const e=this.mapInstance.getSize(),n=this.mapInstance.getPixelFromCoordinate(t);if(!n)return;const r=this.mapInstance.getView(),i=r.getCenter(),s=r.getResolution();let o=n[0],a=n[1],l=!1;const c=document.querySelector(".app-header"),u=c?c.offsetHeight:60;if(e[0]<=768){const t=e[1],r=t/2;n[1]>r&&(a=u+(t/2-u)/2,l=!0)}else if(this.args.isSidebarOpen){const t=getComputedStyle(document.documentElement).getPropertyValue("--sidebar-width").trim(),r=parseInt(t,10)||360;n[0]t*(2-t)})}}updateBookmarks=q$(()=>{const t=this.storage.placesInView;this.loadBookmarks(t)});async loadBookmarks(t=[]){try{if(!this.bookmarkSource)return;t&&0!==t.length||(t=this.storage.placesInView),this.bookmarkSource.clear(),t&&Array.isArray(t)&&t.forEach(t=>{if(t.lat&&t.lon){const e=new g1({geometry:new WZ($K([t.lon,t.lat])),name:t.title,id:t.id,isBookmark:!0,originalPlace:t});this.bookmarkSource.addFeature(e)}})}catch(e){console.error("Failed to load bookmarks:",e)}}syncPulse=q$(()=>{this.searchOverlayElement&&(this.mapUi.isSearching?this.searchOverlayElement.classList.add("active"):this.searchOverlayElement.classList.remove("active"))});syncCreationMode=q$(()=>{if(this.crosshairElement&&this.mapInstance)if(this.mapUi.isCreating){this.crosshairElement.classList.add("visible");const t=this.mapUi.creationCoordinates;if(t&&t.lat&&t.lon){const e=$K([t.lon,t.lat]);this.animateToCrosshair(e)}}else this.crosshairElement.classList.remove("visible")});animateToCrosshair(t){if(!this.mapInstance||!this.crosshairElement)return;const e=this.mapInstance.getTargetElement().getBoundingClientRect(),n=this.crosshairElement.getBoundingClientRect(),r=n.left+n.width/2-e.left,i=n.top+n.height/2-e.top,s=this.mapInstance.getSize(),o=r-s[0]/2,a=i-s[1]/2,l=this.mapInstance.getView(),c=l.getResolution(),u=o*c,h=-a*c,d=t[0]-u,p=t[1]-h,f=l.getCenter();Math.sqrt(Math.pow(f[0]-d,2)+Math.pow(f[1]-p,2))>5*c&&l.animate({center:[d,p],duration:800,easing:t=>t*(2-t)})}handleMapMove=async()=>{if(!this.mapInstance||this.isDestroying||this.isDestroyed)return;const t=this.mapInstance.getView(),e=qK(t.getCenter());if(this.mapUi.updateCenter(e[1],e[0]),this.mapUi.updateZoom(t.getZoom()),this.mapUi.isCreating){const t=this.mapInstance.getTargetElement().getBoundingClientRect(),e=this.crosshairElement.getBoundingClientRect(),n=e.left+e.width/2-t.left,r=e.top+e.height/2-t.top,i=qK(this.mapInstance.getCoordinateFromPixel([n,r])),s=parseFloat(i[1].toFixed(6)),o=parseFloat(i[0].toFixed(6));this.mapUi.updateCreationCoordinates(s,o),this.router.replaceWith("place.new",{queryParams:{lat:s,lon:o}})}const n=this.mapInstance.getSize(),r=this.mapInstance.getView().calculateExtent(n),[i,s]=qK([r[0],r[1]]),[o,a]=qK([r[2],r[3]]),l={minLat:s,minLon:i,maxLat:a,maxLon:o};if(this.mapUi.updateBounds(l),await this.storage.loadPlacesInBounds(l),!this.isDestroying&&!this.isDestroyed){this.nostrData.loadPlacesInBounds(l),this.loadBookmarks(this.storage.placesInView);try{const t=this.mapInstance.getView(),e={center:qK(t.getCenter()),zoom:t.getZoom()};localStorage.setItem("marco:map-view",JSON.stringify(e))}catch(c){console.warn("Failed to save map view:",c)}}};handleMapClick=async t=>{if(this.ignoreNextMapClick)return void(this.ignoreNextMapClick=!1);const e=this.mapInstance.getFeaturesAtPixel(t.pixel,{hitTolerance:10});let n=null,r=null,i=null;if(e&&e.length>0){console.debug(`Found ${e.length} features in map layer:`);for(const n of e)console.debug(n);const t=e.find(t=>t.get("isBookmark")),s=e.find(t=>t.get("isSearchResult"));t?n=t.get("originalPlace"):s&&(r=s.get("originalPlace"));const o=e[0].getProperties();o.name&&(i=o.name)}const s=t=>{("search"===this.router.currentRouteName||this.mapUi.currentSearch&&this.mapUi.searchResults.length>0)&&(this.mapUi.returnToSearch=!0),this.mapUi.preventNextZoom=!0,this.mapUi.selectPlace(t,{preventZoom:!0}),this.mapUi.showSidebar(),this.router.transitionTo("place",t)};if(this.args.isSidebarOpen){const t=n||r;return t?(console.debug("Clicked feature while sidebar open (switching):",t),void s(t)):void(this.args.onOutsideClick&&this.args.onOutsideClick())}if(n)return console.debug("Clicked bookmark:",n),void s(n);if(r)return console.debug("Clicked search result:",r),void s(r);if(this.mapUi.searchResults&&this.mapUi.searchResults.length>0)return console.debug("Clearing active search and markers on map click"),void this.router.transitionTo("index");if(this.mapInstance.getView().getZoom()<16)return;const[o,a]=qK(t.coordinate),l=i?30:50;if(this.searchOverlayElement){const e=this.mapInstance.getView(),n=2*l/jK(e.getProjection(),e.getResolution(),t.coordinate);this.searchOverlayElement.style.width=`${n}px`,this.searchOverlayElement.style.height=`${n}px`,this.searchOverlay.setPosition(t.coordinate)}this.mapUi.startSearch();const c={lat:a.toFixed(6),lon:o.toFixed(6),q:null,category:null,selected:i||null};this.router.transitionTo("search",{queryParams:c})};static{Ap(rg({id:null,block:'[[[11,0],[16,0,[29,["map-container ",[52,[30,1],"sidebar-open"]]]],[4,[30,0,["setupMap"]],null,null],[4,[30,0,["updateInteractions"]],null,null],[4,[30,0,["updateBookmarks"]],null,null],[4,[30,0,["updateSearchResults"]],null,null],[4,[30,0,["updateSelectedPin"]],null,null],[4,[30,0,["syncPulse"]],null,null],[4,[30,0,["syncCreationMode"]],null,null],[12],[13]],["@isSidebarOpen"],["if"]]',moduleName:"(unknown template module)",isStrictMode:!0}),this)}},att=class extends u${static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"osmAuth",[dp])}#Ce=void cF(this,"osmAuth");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"isNostrConnectModalOpen",[Vr],function(){return!1})}#qt=void cF(this,"isNostrConnectModalOpen");connectRS(){this.args.onClose(),this.args.storage.showConnectWidget()}static{lF(this.prototype,"connectRS",[ql])}disconnectRS(){this.args.storage.disconnect()}static{lF(this.prototype,"disconnectRS",[ql])}connectOsm(){this.args.onClose(),this.osmAuth.login()}static{lF(this.prototype,"connectOsm",[ql])}disconnectOsm(){this.osmAuth.logout()}static{lF(this.prototype,"disconnectOsm",[ql])}openNostrConnectModal(){this.isNostrConnectModalOpen=!0}static{lF(this.prototype,"openNostrConnectModal",[ql])}closeNostrConnectModal(){this.isNostrConnectModalOpen=!1}static{lF(this.prototype,"closeNostrConnectModal",[ql])}disconnectNostr(){this.nostrAuth.disconnect()}static{lF(this.prototype,"disconnectNostr",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"user-menu-popover"],[12],[1,"\\n "],[10,"ul"],[14,0,"account-list"],[12],[1,"\\n "],[10,"li"],[14,0,"account-item"],[12],[1,"\\n "],[10,0],[14,0,"account-header"],[12],[1,"\\n "],[10,0],[14,0,"account-info"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["remotestorage",18]],null],[1,"\\n "],[10,1],[12],[1,"RemoteStorage"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,1,["connected"]],[[[1," "],[11,"button"],[24,0,"btn-text text-danger"],[24,4,"button"],[4,[32,1],["click",[30,0,["disconnectRS"]]],null],[12],[1,"Disconnect"],[13],[1,"\\n"]],[]],[[[1," "],[11,"button"],[24,0,"btn-text text-primary"],[24,4,"button"],[4,[32,1],["click",[30,0,["connectRS"]]],null],[12],[1,"Connect"],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"account-status"],[12],[1,"\\n"],[41,[30,1,["connected"]],[[[1," "],[10,"strong"],[12],[1,[30,1,["userAddress"]]],[13],[1,"\\n"]],[]],[[[1," Not connected\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,"li"],[14,0,"account-item"],[12],[1,"\\n "],[10,0],[14,0,"account-header"],[12],[1,"\\n "],[10,0],[14,0,"account-info"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["map",18]],null],[1,"\\n "],[10,1],[12],[1,"OpenStreetMap"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["osmAuth","isConnected"]],[[[1," "],[11,"button"],[24,0,"btn-text text-danger"],[24,4,"button"],[4,[32,1],["click",[30,0,["disconnectOsm"]]],null],[12],[1,"Disconnect"],[13],[1,"\\n"]],[]],[[[1," "],[11,"button"],[24,0,"btn-text text-primary"],[24,4,"button"],[4,[32,1],["click",[30,0,["connectOsm"]]],null],[12],[1,"Connect"],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"account-status"],[12],[1,"\\n"],[41,[30,0,["osmAuth","isConnected"]],[[[1," "],[10,"strong"],[12],[1,[30,0,["osmAuth","userDisplayName"]]],[13],[1,"\\n"]],[]],[[[1," Not connected\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,"li"],[14,0,"account-item"],[12],[1,"\\n "],[10,0],[14,0,"account-header"],[12],[1,"\\n "],[10,0],[14,0,"account-info"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["zap",18]],null],[1,"\\n "],[10,1],[12],[1,"Nostr"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["nostrAuth","isConnected"]],[[[1," "],[11,"button"],[24,0,"btn-text text-danger"],[24,4,"button"],[4,[32,1],["click",[30,0,["disconnectNostr"]]],null],[12],[1,"Disconnect"],[13],[1,"\\n"]],[]],[[[1," "],[11,"button"],[24,0,"btn-text text-primary"],[24,4,"button"],[4,[32,1],["click",[30,0,["openNostrConnectModal"]]],null],[12],[1,"Connect"],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"account-status"],[12],[1,"\\n"],[41,[30,0,["nostrAuth","isConnected"]],[[[1," "],[10,"strong"],[15,"title",[30,0,["nostrAuth","pubkey"]]],[12],[1,"\\n "],[1,[30,0,["nostrData","userDisplayName"]]],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," Not connected\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[41,[30,0,["isNostrConnectModalOpen"]],[[[1," "],[8,[32,2],null,[["@onClose"],[[30,0,["closeNostrConnectModal"]]]],[["default"],[[[[1,"\\n "],[8,[32,3],null,[["@onConnect"],[[30,0,["closeNostrConnectModal"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null]],["@storage"],["if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:d$,on:Ww,Modal:D$,NostrConnect:wq}),isStrictMode:!0}),this)}};function ltt(t){return t}function ctt(t){return Object.keys(t).map(e=>t[e])}function utt(t){if(t)if(t instanceof IV)t.executor.asyncErrorsHandled=!0;else if(t instanceof uV)return t._toPromise();return t}function htt(t,e,n){return function(r){let i=function(t,e){if(Array.isArray(t))return t.map(e);if("object"==typeof t&&null!==t){let n={};return Object.keys(t).forEach(r=>{n[r]=e(t[r])}),n}return t}(r,utt),s=n(i);Array.isArray(s);let o=Ua.defer();t[e](i).then(o.resolve,o.reject);let a=!1,l=()=>{a||(a=!0,s.forEach(t=>{t&&(t instanceof IV?t.cancel():"function"==typeof t.__ec_cancel__&&t[rV]())}))},c=o.promise.finally(l);return c[rV]=l,c}}htt(Ua.Promise,"all",ltt),htt(Ua,"allSettled",ltt),htt(ra,"race",ltt),htt(Ua,"hash",ctt),htt(Ua,"hashSettled",ctt);var dtt=class extends uV{_deferable(){return EV.defer()}},ptt=class extends dtt{constructor(t){super(),this.ms=t}onYield(t){let e=Ts(()=>t.next(),this.ms);return()=>Ms(e)}},ftt=class extends u${static{aF(this.prototype,"photon",[dp])}#xe=void cF(this,"photon");static{aF(this.prototype,"osm",[dp])}#B=void cF(this,"osm");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"map",[dp])}#Se=void cF(this,"map");static{aF(this.prototype,"_internalQuery",[Vr],function(){return""})}#ke=void cF(this,"_internalQuery");static{aF(this.prototype,"results",[Vr],function(){return[]})}#Ee=void cF(this,"results");static{aF(this.prototype,"isFocused",[Vr],function(){return!1})}#Re=void cF(this,"isFocused");static{aF(this.prototype,"isLoading",[Vr],function(){return!1})}#Te=void cF(this,"isLoading");get query(){return this.args.query??this._internalQuery}set query(t){this._internalQuery=t}get showPopover(){return this.isFocused&&this.results.length>0}handleInput(t){const e=t.target.value;this.query=e,this.args.onQueryChange&&this.args.onQueryChange(e),e.length<2?this.results=[]:this.searchTask.perform(e)}static{lF(this.prototype,"handleInput",[ql])}formatSavedPlace(t){const e=(t._listIds||[]).map(t=>this.storage.lists?.find(e=>e.id===t)?.title).filter(Boolean).join(", "),n=e?`Saved place (${e})`:"Saved place";return{source:"saved",id:t.id,title:t.title,icon:"bookmark",description:n,osmId:t.osmId,osmType:t.osmType,lat:t.lat,lon:t.lon}}searchTask=OV(()=>({context:this,generator:function*(t){yield new ptt(300);const e="string"==typeof t?t:this.query;if(!(e.length<2)){this.isLoading=!0;try{let t,n;this.mapUi.currentCenter&&({lat:t,lon:n}=this.mapUi.currentCenter);const r=e.toLowerCase(),i=SU.filter(t=>t.label.toLowerCase().includes(r)).map(t=>({source:"category",title:t.label,id:t.id,icon:"search"}));let s=[];r.length>=3&&(s=this.storage.savedPlaces.filter(t=>t.title&&t.title.toLowerCase().includes(r)).map(t=>this.formatSavedPlace(t)));const o=yield this.photon.search(e,t,n),a=new Set(s.map(t=>t.osmId).filter(Boolean)),l=o.filter(t=>!a.has(t.osmId));this.results=[...i,...s,...l]}catch(n){console.error("Search failed",n),this.results=[]}finally{this.isLoading=!1}}}}),{restartable:!0},"searchTask",null);handleFocus(){this.isFocused=!0,this.mapUi.setSearchBoxFocus(!0),this.query.length>=2&&0===this.results.length&&this.searchTask.perform()}static{lF(this.prototype,"handleFocus",[ql])}handleBlur(){setTimeout(()=>{this.isFocused=!1,this.mapUi.setSearchBoxFocus(!1)},300)}static{lF(this.prototype,"handleBlur",[ql])}handleSubmit(t){if(t.preventDefault(),!this.query)return;let e={q:this.query,selected:null,category:null};if(this.mapUi.currentCenter){const{lat:t,lon:n}=this.mapUi.currentCenter;e.lat=parseFloat(t).toFixed(4),e.lon=parseFloat(n).toFixed(4)}this.router.transitionTo("search",{queryParams:e}),this.isFocused=!1}static{lF(this.prototype,"handleSubmit",[ql])}selectResult(t){if("category"===t.source){this.query=t.title,this.args.onQueryChange&&this.args.onQueryChange(t.title),this.results=[];let e=null,n=null;return this.mapUi.currentCenter&&(({lat:e,lon:n}=this.mapUi.currentCenter),e=e?.toString(),n=n?.toString()),void this.router.transitionTo("search",{queryParams:{q:t.title,category:t.id,selected:null,lat:e,lon:n}})}if(this.query=t.title,this.args.onQueryChange&&this.args.onQueryChange(t.title),this.results=[],"saved"===t.source&&t.id&&!t.osmId)this.router.transitionTo("place",t.id);else if(t.osmId){const e=`osm:${t.osmType}:${t.osmId}`;this.router.transitionTo("place",e)}else this.router.transitionTo("search",{queryParams:{q:t.title,lat:t.lat,lon:t.lon,selected:null,category:null}})}static{lF(this.prototype,"selectResult",[ql])}clear(){this.searchTask.cancelAll(),this.mapUi.stopLoading(),this.osm.cancelAll(),this.photon.cancelAll(),this.query="",this.results=[],this.args.onQueryChange&&this.args.onQueryChange(""),this.router.transitionTo("index")}static{lF(this.prototype,"clear",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"search-box"],[12],[1,"\\n "],[11,"form"],[24,0,"search-form"],[4,[32,0],["submit",[30,0,["handleSubmit"]]],null],[12],[1,"\\n "],[11,"button"],[24,0,"menu-btn-integrated"],[24,"aria-label","Menu"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["menu",20,"#5f6368"]],null],[1,"\\n "],[13],[1,"\\n\\n "],[11,"input"],[24,0,"search-input"],[24,"placeholder","Search places..."],[24,"aria-label","Search places"],[16,2,[30,0,["query"]]],[24,"autocomplete","off"],[24,4,"search"],[4,[32,0],["input",[30,0,["handleInput"]]],null],[4,[32,0],["focus",[30,0,["handleFocus"]]],null],[4,[32,0],["blur",[30,0,["handleBlur"]]],null],[12],[13],[1,"\\n\\n "],[10,"button"],[14,0,"search-submit-btn"],[14,"aria-label","Search"],[14,4,"submit"],[12],[1,"\\n"],[41,[28,[32,2],[[28,[32,3],[[30,0,["mapUi","loadingState","type"]],"text"],null],[28,[32,3],[[30,0,["mapUi","loadingState","type"]],"category"],null]],null],[[[1," "],[8,[32,1],null,[["@name","@size"],["loading-ring",20]],null],[1,"\\n"]],[]],[[[1," "],[8,[32,1],null,[["@name","@size","@color"],["search",20,"#5f6368"]],null],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["query"]],[[[1," "],[11,"button"],[24,0,"search-clear-btn"],[24,"aria-label","Clear"],[24,4,"button"],[4,[32,0],["click",[30,0,["clear"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#5f6368"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["showPopover"]],[[[1," "],[10,0],[14,0,"search-results-popover"],[12],[1,"\\n "],[10,"ul"],[14,0,"search-results-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["results"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"search-result-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,4],[[30,0,["selectResult"]],[30,2]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"result-icon"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],[[52,[30,2,["icon"]],[30,2,["icon"]],"map-pin"],16,"#666"]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"result-info"],[12],[1,"\\n "],[10,1],[14,0,"result-title"],[12],[1,[30,2,["title"]]],[13],[1,"\\n"],[41,[28,[32,3],[[30,2,["source"]],"osm"],null],[[[1," "],[10,1],[14,0,"result-desc"],[12],[1,[28,[32,5],[[30,2,["type"]]],null]],[13],[1,"\\n"]],[]],[[[41,[30,2,["description"]],[[[1," "],[10,1],[14,0,"result-desc"],[12],[1,[30,2,["description"]]],[13],[1,"\\n"]],[]],null]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[13]],["@onToggleMenu","result"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,Icon:d$,or:M$,eq:j$,fn:L$,humanizeOsmTag:rW}),isStrictMode:!0}),this)}},gtt=class extends u${static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");get categories(){return SU}searchCategory(t){this.args.onSelect&&this.args.onSelect(t);let e={category:t.id,q:null};if(this.mapUi.currentCenter){const{lat:t,lon:n}=this.mapUi.currentCenter;e.lat=parseFloat(t).toFixed(4),e.lon=parseFloat(n).toFixed(4)}this.router.transitionTo("search",{queryParams:e})}static{lF(this.prototype,"searchCategory",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"category-chips-scroll"],[12],[1,"\\n "],[10,0],[14,0,"category-chips-container"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["categories"]]],null]],null],null,[[[1," "],[11,"button"],[24,0,"category-chip"],[16,"aria-label",[30,1,["label"]]],[16,"disabled",[28,[32,0],[[28,[32,1],[[30,0,["mapUi","loadingState","type"]],"category"],null],[28,[32,1],[[30,0,["mapUi","loadingState","value"]],[30,1,["id"]]],null]],null]],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["searchCategory"]],[30,1]],null]],null],[12],[1,"\\n "],[8,[32,4],null,[["@name","@size"],[[30,1,["icon"]],16]],null],[1,"\\n "],[10,1],[12],[1,[30,1,["label"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n"],[13]],["category"],["each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({and:z$,eq:j$,on:Ww,fn:L$,Icon:d$}),isStrictMode:!0}),this)}},mtt=q$((t,[e])=>{let n=null;return async function(){if(e)try{const r=await caches.open("nostr-image-cache-v1"),i=await r.match(e);if(i){const e=await i.blob();return n=URL.createObjectURL(e),void(t.src=n)}const s=await fetch(e,{mode:"cors",credentials:"omit"});if(s.ok){const i=s.clone();await r.put(e,i);const o=await s.blob();n=URL.createObjectURL(o),t.src=n}else t.src=e}catch(e6){console.warn(`Failed to cache image ${e}, falling back to standard src`,e6),t.src=e}else t.src=""}(),()=>{n&&(URL.revokeObjectURL(n),n=null)}}),ytt=class extends u${static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{aF(this.prototype,"nostrAuth",[dp])}#N=void cF(this,"nostrAuth");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"isUserMenuOpen",[Vr],function(){return!1})}#Le=void cF(this,"isUserMenuOpen");static{aF(this.prototype,"searchQuery",[Vr],function(){return""})}#Ie=void cF(this,"searchQuery");constructor(){super(...arguments),this.router&&"function"==typeof this.router.on&&this.router.on("routeDidChange",this.syncSearchQuery),this.syncSearchQuery()}willDestroy(){this.router&&"function"==typeof this.router.off&&this.router.off("routeDidChange",this.syncSearchQuery),super.willDestroy(...arguments)}syncSearchQuery(){const t=this.mapUi.currentSearch||this.router?.currentRoute?.queryParams;if(t?.q)this.searchQuery=t.q;else if(t?.category){const e=SU.find(e=>e.id===t.category);this.searchQuery=e?e.label:t.category}else this.searchQuery=""}static{lF(this.prototype,"syncSearchQuery",[ql])}get isSearching(){return!(!this.mapUi.searchBoxHasFocus||!this.searchQuery)||("search"===this.router?.currentRouteName?!this.mapUi.loadingState&&this.mapUi.searchResults&&this.mapUi.searchResults.length>0:!("search"===this.router?.currentRouteName||!this.searchQuery))}get showQuickSearch(){const t=this.mapUi.currentZoom??13;return this.settings.showQuickSearchButtons&&t>=12}toggleUserMenu(){this.isUserMenuOpen=!this.isUserMenuOpen}static{lF(this.prototype,"toggleUserMenu",[ql])}closeUserMenu(){this.isUserMenuOpen=!1}static{lF(this.prototype,"closeUserMenu",[ql])}handleQueryChange(t){this.searchQuery=t}static{lF(this.prototype,"handleQueryChange",[ql])}handleChipSelect(t){this.searchQuery=t.label}static{lF(this.prototype,"handleChipSelect",[ql])}static{Ap(rg({id:null,block:'[[[10,"header"],[14,0,"app-header"],[12],[1,"\\n "],[10,0],[14,0,"header-left"],[12],[1,"\\n "],[8,[32,0],null,[["@query","@onToggleMenu","@onQueryChange"],[[30,0,["searchQuery"]],[30,1],[30,0,["handleQueryChange"]]]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["showQuickSearch"]],[[[1," "],[10,0],[15,0,[29,["header-center ",[52,[30,0,["isSearching"]],"searching"]]]],[12],[1,"\\n "],[8,[32,1],null,[["@onSelect"],[[30,0,["handleChipSelect"]]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[10,0],[14,0,"header-right"],[12],[1,"\\n "],[10,0],[14,0,"user-menu-container"],[12],[1,"\\n "],[11,"button"],[24,0,"user-btn btn-press"],[24,"aria-label","User Menu"],[24,4,"button"],[4,[32,2],["click",[30,0,["toggleUserMenu"]]],null],[12],[1,"\\n"],[41,[28,[32,3],[[30,0,["nostrAuth","isConnected"]],[30,0,["nostrData","profile","picture"]]],null],[[[1," "],[11,"img"],[24,0,"user-avatar"],[24,"alt","User Avatar"],[4,[32,4],[[30,0,["nostrData","profile","picture"]]],null],[12],[13],[1,"\\n"]],[]],[[[1," "],[10,0],[14,0,"user-avatar-placeholder"],[12],[1,"\\n "],[8,[32,5],null,[["@name","@size","@color"],["user",20,"white"]],null],[1,"\\n "],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["isUserMenuOpen"]],[[[1," "],[8,[32,6],null,[["@storage","@onClose"],[[30,0,["storage"]],[30,0,["closeUserMenu"]]]],null],[1,"\\n "],[11,0],[24,0,"menu-backdrop"],[24,"role","button"],[4,[32,2],["click",[30,0,["closeUserMenu"]]],null],[12],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onToggleMenu"],["if"]]',moduleName:"(unknown template module)",scope:()=>({SearchBox:ftt,CategoryChips:gtt,on:Ww,and:z$,cachedImage:mtt,Icon:d$,UserMenu:att}),isStrictMode:!0}),this)}},vtt=class extends u${static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");static{Ap(rg({id:null,block:'[[[41,[30,0,["toast","isVisible"]],[[[1," "],[10,0],[14,0,"toast-notification"],[12],[1,"\\n "],[1,[30,0,["toast","message"]]],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",isStrictMode:!0}),this)}},btt=a({default:()=>wtt}),wtt=class extends u${static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");get isSidebarOpen(){const t=this.router.currentRouteName;return this.mapUi.isSidebarVisible&&("place"===t||"place.new"===t||"search"===t||"menu"===t||"contributions"===t||t.startsWith("lists"))}constructor(){super(...arguments),console.debug("Application component constructed"),this.storage}toggleAppMenu(){"menu"===this.router.currentRouteName?this.router.transitionTo("index"):this.router.transitionTo("menu")}static{lF(this.prototype,"toggleAppMenu",[ql])}handleOutsideClick(){const t=this.router.currentRouteName;("search"===t||"place"===t||"menu"===t||"contributions"===t||t.startsWith("lists"))&&(this.mapUi.clearSelection(),this.mapUi.hideSidebar(),"menu"===t||"contributions"===t||t.startsWith("lists")?this.router.transitionTo("index"):"place"===t&&(this.mapUi.returnToSearch&&this.mapUi.currentSearch?this.router.transitionTo("search",{queryParams:this.mapUi.currentSearch}):this.router.transitionTo("index")))}static{lF(this.prototype,"handleOutsideClick",[ql])}refreshBookmarks(){this.storage.notifyChange()}static{lF(this.prototype,"refreshBookmarks",[ql])}static{Ap(rg({id:null,block:'[[[1,[28,[32,0],["Marco"],null]],[1,"\\n\\n"],[10,0],[15,0,[52,[30,0,["mapUi","isSidebarOpening"]],"sidebar-opening"]],[12],[1,"\\n "],[8,[32,1],null,[["@onToggleMenu"],[[30,0,["toggleAppMenu"]]]],null],[1,"\\n\\n "],[10,0],[14,1,"rs-widget-container"],[15,0,[52,[30,0,["storage","isWidgetOpen"]],"visible"]],[12],[13],[1,"\\n\\n"],[41,[30,0,["storage","isWidgetOpen"]],[[[1," "],[11,0],[24,0,"rs-backdrop"],[24,"role","button"],[4,[32,2],["click",[30,0,["storage","closeWidget"]]],null],[12],[13],[1,"\\n"]],[]],null],[1,"\\n "],[8,[32,3],null,[["@isSidebarOpen","@onOutsideClick"],[[30,0,["isSidebarOpen"]],[30,0,["handleOutsideClick"]]]],null],[1,"\\n\\n "],[8,[32,4],null,null,null],[1,"\\n\\n "],[46,[28,[31,2],null,null],null,null,null],[1,"\\n"],[13]],[],["if","component","-outlet"]]',moduleName:"(unknown template module)",scope:()=>({pageTitle:EW,AppHeader:ytt,on:Ww,Map:ott,Toast:vtt}),isStrictMode:!0}),this)}},_tt=a({default:()=>xtt}),xtt=class extends Jh{static{aF(this.prototype,"osm",[dp])}#B=void cF(this,"osm");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage")},Ctt=a({default:()=>Stt}),Stt=class extends Jh{static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");activate(){this.mapUi.clearSearchResults(),this.mapUi.hideSidebar()}},ktt=Ap(rg({id:null,block:'[[[10,0],[14,0,"sidebar-header"],[12],[1,"\\n "],[10,"h2"],[12],[1,"\\n "],[10,1],[14,0,"app-logo-icon"],[12],[1,"\\n "],[1,[28,[32,0],[[32,1]],null]],[1,"\\n "],[13],[1,"\\n Marco\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,2],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"ul"],[14,0,"app-menu"],[12],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["bookmark",20]],null],[1,"\\n "],[10,1],[12],[1,"Collections"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[30,3]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["activity",20]],null],[1,"\\n "],[10,1],[12],[1,"My Contributions"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[28,[32,4],[[30,4],"settings"],null]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["settings",20]],null],[1,"\\n "],[10,1],[12],[1,"Settings"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[28,[32,4],[[30,4],"about"],null]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["info",20]],null],[1,"\\n "],[10,1],[12],[1,"About"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onClose","@onSavedPlaces","@onContributions","@onNavigate"],[]]',moduleName:"(unknown template module)",scope:()=>({htmlSafe:$v,iconRounded:'\n \x3c!-- Background --\x3e\n \n\n \x3c!-- Subtle map grid (kept well outside safe zone) --\x3e\n \n \n \n \n\n \n \n \n \n\n \x3c!-- Location pin (exact app shape, larger, centered, safe-zone compliant) --\x3e\n \x3c!-- Safe zone target: ~680px diameter --\x3e\n \n \n \n \n\n',on:Ww,Icon:d$,fn:L$}),isStrictMode:!0}),N$()),Ett=class extends u${static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{Ap(rg({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["map",20]],null],[1,"\\n "],[10,1],[12],[1,"Map & UI"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","show-quick-search"],[12],[1,"Quick search buttons visible"],[13],[1,"\\n "],[11,"select"],[24,1,"show-quick-search"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"showQuickSearchButtons"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","showQuickSearchButtons"]],"selected"]],[12],[1,"\\n Yes\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","showQuickSearchButtons"]]],"selected"]],[12],[1,"\\n No\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","map-kinetic"],[12],[1,"Map Inertia (Kinetic Panning)"],[13],[1,"\\n "],[11,"select"],[24,1,"map-kinetic"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"mapKinetic"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","mapKinetic"]],"selected"]],[12],[1,"\\n On\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","mapKinetic"]]],"selected"]],[12],[1,"\\n Off\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onChange"],["if","unless"]]',moduleName:"(unknown template module)",scope:()=>({Icon:d$,on:Ww,fn:L$}),isStrictMode:!0}),this)}},Rtt=class extends u${static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{Ap(rg({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["server",20]],null],[1,"\\n "],[10,1],[12],[1,"API Providers"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","overpass-api"],[12],[1,"Overpass API Provider"],[13],[1,"\\n "],[11,"select"],[24,1,"overpass-api"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"overpassApi"],null]],null],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["settings","overpassApis"]]],null]],null],null,[[[1," "],[10,"option"],[15,2,[30,2,["url"]]],[15,"selected",[52,[28,[32,3],[[30,2,["url"]],[30,0,["settings","overpassApi"]]],null],"selected"]],[12],[1,"\\n "],[1,[30,2,["name"]]],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","photon-api"],[12],[1,"Photon API Provider"],[13],[1,"\\n "],[11,"select"],[24,1,"photon-api"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"photonApi"],null]],null],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["settings","photonApis"]]],null]],null],null,[[[1," "],[10,"option"],[15,2,[30,3,["url"]]],[15,"selected",[52,[28,[32,3],[[30,3,["url"]],[30,0,["settings","photonApi"]]],null],"selected"]],[12],[1,"\\n "],[1,[30,3,["name"]]],[1,"\\n "],[13],[1,"\\n"]],[3]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onChange","api","api"],["each","-track-array","if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:d$,on:Ww,fn:L$,eq:j$}),isStrictMode:!0}),this)}},Ttt=t=>t?t.replace(/^wss?:\/\//,""):"",Ltt=class extends u${static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{aF(this.prototype,"nostrData",[dp])}#F=void cF(this,"nostrData");static{aF(this.prototype,"toast",[dp])}#Lt=void cF(this,"toast");static{aF(this.prototype,"newReadRelay",[Vr],function(){return""})}#Pe=void cF(this,"newReadRelay");static{aF(this.prototype,"newWriteRelay",[Vr],function(){return""})}#Me=void cF(this,"newWriteRelay");get customReadRelays(){return vj(this.settings.nostrReadRelays||[],this.nostrData.requiredReadRelays)}get customWriteRelays(){return vj(this.settings.nostrWriteRelays||[],this.nostrData.requiredWriteRelays)}get readRelayExclusions(){return this.settings.nostrReadRelayExclusions||[]}get writeRelayExclusions(){return this.settings.nostrWriteRelayExclusions||[]}get requiredReadRelaySet(){return new Set(this.nostrData.requiredReadRelays.filter(Boolean))}get requiredWriteRelaySet(){return new Set(this.nostrData.requiredWriteRelays.filter(Boolean))}get mailboxReadRelaySet(){return new Set(this.nostrData.mailboxReadRelays)}get mailboxWriteRelaySet(){return new Set(this.nostrData.mailboxWriteRelays)}get hasReadOverrides(){return this.customReadRelays.length>0||this.readRelayExclusions.length>0}get hasWriteOverrides(){return this.customWriteRelays.length>0||this.writeRelayExclusions.length>0}get readRelaysForDisplay(){return this.nostrData.activeReadRelays.map(t=>({url:t,isRequired:this.requiredReadRelaySet.has(t)}))}get writeRelaysForDisplay(){return this.nostrData.activeWriteRelays.map(t=>({url:t,isRequired:this.requiredWriteRelaySet.has(t)}))}updateNewReadRelay(t){this.newReadRelay=t.target.value}static{lF(this.prototype,"updateNewReadRelay",[ql])}updateNewWriteRelay(t){this.newWriteRelay=t.target.value}static{lF(this.prototype,"updateNewWriteRelay",[ql])}addReadRelay(){const t=gj(this.newReadRelay);if(!t)return;const e=vj(yj(this.nostrData.requiredReadRelays,[...this.customReadRelays,t]),this.nostrData.requiredReadRelays),n=this.readRelayExclusions.filter(e=>gj(e)!==t);this.settings.update("nostrReadRelays",e.length>0?e:null),this.settings.update("nostrReadRelayExclusions",n.length>0?n:null),this.newReadRelay=""}static{lF(this.prototype,"addReadRelay",[ql])}removeReadRelay(t){if(this.requiredReadRelaySet.has(t))return;const e=gj(t),n=this.customReadRelays.filter(t=>gj(t)!==e),r=this.mailboxReadRelaySet.has(e)?Array.from(new Set([...this.readRelayExclusions,e])):this.readRelayExclusions;this.settings.update("nostrReadRelays",n.length>0?n:null),this.settings.update("nostrReadRelayExclusions",r.length>0?r:null)}static{lF(this.prototype,"removeReadRelay",[ql])}handleReadRelayKeydown(t){"Enter"===t.key&&this.addReadRelay()}static{lF(this.prototype,"handleReadRelayKeydown",[ql])}handleWriteRelayKeydown(t){"Enter"===t.key&&this.addWriteRelay()}static{lF(this.prototype,"handleWriteRelayKeydown",[ql])}resetReadRelays(){this.settings.update("nostrReadRelays",null),this.settings.update("nostrReadRelayExclusions",null)}static{lF(this.prototype,"resetReadRelays",[ql])}addWriteRelay(){const t=gj(this.newWriteRelay);if(!t)return;const e=vj(yj(this.nostrData.requiredWriteRelays,[...this.customWriteRelays,t]),this.nostrData.requiredWriteRelays),n=this.writeRelayExclusions.filter(e=>gj(e)!==t);this.settings.update("nostrWriteRelays",e.length>0?e:null),this.settings.update("nostrWriteRelayExclusions",n.length>0?n:null),this.newWriteRelay=""}static{lF(this.prototype,"addWriteRelay",[ql])}removeWriteRelay(t){if(this.requiredWriteRelaySet.has(t))return;const e=gj(t),n=this.customWriteRelays.filter(t=>gj(t)!==e),r=this.mailboxWriteRelaySet.has(e)?Array.from(new Set([...this.writeRelayExclusions,e])):this.writeRelayExclusions;this.settings.update("nostrWriteRelays",n.length>0?n:null),this.settings.update("nostrWriteRelayExclusions",r.length>0?r:null)}static{lF(this.prototype,"removeWriteRelay",[ql])}resetWriteRelays(){this.settings.update("nostrWriteRelays",null),this.settings.update("nostrWriteRelayExclusions",null)}static{lF(this.prototype,"resetWriteRelays",[ql])}async clearCache(){try{await this.nostrData.clearCache(),this.toast.show("Nostr cache cleared")}catch(t){this.toast.show(`Failed to clear Nostr cache: ${t.message}`)}}static{lF(this.prototype,"clearCache",[ql])}static{Ap(rg({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["zap",20]],null],[1,"\\n "],[10,1],[12],[1,"Nostr"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","new-read-relay"],[12],[1,"Read Relays"],[13],[1,"\\n "],[10,"ul"],[14,0,"relay-list"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["readRelaysForDisplay"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[10,1],[12],[1,[28,[32,1],[[30,1,["url"]]],null]],[13],[1,"\\n"],[41,[51,[30,1,["isRequired"]]],[[[1," "],[11,"button"],[24,0,"btn-remove-relay"],[24,"title","Remove relay"],[24,"aria-label","Remove"],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["removeReadRelay"]],[30,1,["url"]]],null]],null],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size","@color"],["x",14,"currentColor"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"add-relay-input"],[12],[1,"\\n "],[11,"input"],[24,1,"new-read-relay"],[24,0,"form-control"],[24,"placeholder","relay.example.com"],[16,2,[30,0,["newReadRelay"]]],[24,4,"text"],[4,[32,2],["input",[30,0,["updateNewReadRelay"]]],null],[4,[32,2],["keydown",[30,0,["handleReadRelayKeydown"]]],null],[12],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-secondary"],[24,4,"button"],[4,[32,2],["click",[30,0,["addReadRelay"]]],null],[12],[1,"Add"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["hasReadOverrides"]],[[[1," "],[11,"button"],[24,0,"btn-link reset-relays"],[24,4,"button"],[4,[32,2],["click",[30,0,["resetReadRelays"]]],null],[12],[1,"\\n Reset to Defaults\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","new-write-relay"],[12],[1,"Write Relays"],[13],[1,"\\n "],[10,"ul"],[14,0,"relay-list"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["writeRelaysForDisplay"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[10,1],[12],[1,[28,[32,1],[[30,2,["url"]]],null]],[13],[1,"\\n"],[41,[51,[30,2,["isRequired"]]],[[[1," "],[11,"button"],[24,0,"btn-remove-relay"],[24,"title","Remove relay"],[24,"aria-label","Remove"],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["removeWriteRelay"]],[30,2,["url"]]],null]],null],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size","@color"],["x",14,"currentColor"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"add-relay-input"],[12],[1,"\\n "],[11,"input"],[24,1,"new-write-relay"],[24,0,"form-control"],[24,"placeholder","relay.example.com"],[16,2,[30,0,["newWriteRelay"]]],[24,4,"text"],[4,[32,2],["input",[30,0,["updateNewWriteRelay"]]],null],[4,[32,2],["keydown",[30,0,["handleWriteRelayKeydown"]]],null],[12],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-secondary"],[24,4,"button"],[4,[32,2],["click",[30,0,["addWriteRelay"]]],null],[12],[1,"Add"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["hasWriteOverrides"]],[[[1," "],[11,"button"],[24,0,"btn-link reset-relays"],[24,4,"button"],[4,[32,2],["click",[30,0,["resetWriteRelays"]]],null],[12],[1,"\\n Reset to Defaults\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","nostr-photo-fallback-uploads"],[12],[1,"Upload photos to fallback\\n servers"],[13],[1,"\\n "],[11,"select"],[24,1,"nostr-photo-fallback-uploads"],[24,0,"form-control"],[4,[32,2],["change",[28,[32,3],[[30,3],"nostrPhotoFallbackUploads"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","nostrPhotoFallbackUploads"]],"selected"]],[12],[1,"\\n Yes\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","nostrPhotoFallbackUploads"]]],"selected"]],[12],[1,"\\n No\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[12],[1,"Cached data"],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline btn-full"],[24,4,"button"],[4,[32,2],["click",[30,0,["clearCache"]]],null],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size","@color"],["database",18,"var(--danger-color)"]],null],[1,"\\n Clear profiles, photos, and reviews\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["relay","relay","@onChange"],["each","-track-array","unless","if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:d$,stripProtocol:Ttt,on:Ww,fn:L$}),isStrictMode:!0}),this)}},Itt=class extends u${static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");static{Ap(rg({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["alert-triangle",20]],null],[1,"\\n "],[10,1],[12],[1,"Experimental"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","experimental-enable-photo-deletion"],[12],[1,"Enable photo deletion\\n (own photos)"],[13],[1,"\\n "],[11,"select"],[24,1,"experimental-enable-photo-deletion"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"experimentalEnablePhotoDeletion"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","experimentalEnablePhotoDeletion"]],"selected"]],[12],[1,"\\n On\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","experimentalEnablePhotoDeletion"]]],"selected"]],[12],[1,"\\n Off\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onChange"],["if","unless"]]',moduleName:"(unknown template module)",scope:()=>({Icon:d$,on:Ww,fn:L$}),isStrictMode:!0}),this)}},Ptt=class extends u${static{aF(this.prototype,"settings",[dp])}#D=void cF(this,"settings");updateSetting(t,e){let n=e.target.value;"true"===n&&(n=!0),"false"===n&&(n=!1),this.settings.update(t,n)}static{lF(this.prototype,"updateSetting",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"Settings"],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"section"],[14,0,"settings-section"],[12],[1,"\\n "],[8,[32,2],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[8,[32,3],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[8,[32,4],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[8,[32,5],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[13],[1,"\\n"],[13]],["@onBack","@onClose"],[]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,Icon:d$,AppMenuSettingsMapUi:Ett,AppMenuSettingsApis:Rtt,AppMenuSettingsNostr:Ltt,AppMenuSettingsExperimental:Itt}),isStrictMode:!0}),this)}},Mtt=Ap(rg({id:null,block:'[[[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"About"],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"section"],[14,0,"about-section"],[12],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Marco"],[13],[1,"\\n (as in\\n "],[10,3],[14,6,"https://en.wikipedia.org/wiki/Marco_Polo"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"Marco Polo"],[13],[1,") is an unhosted maps application that respects your\\n privacy and choices.\\n "],[13],[1,"\\n "],[10,2],[12],[1,"\\n Connect your own\\n "],[10,3],[14,6,"https://remotestorage.io/"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"remote storage"],[13],[1,"\\n to sync place bookmarks across apps and devices.\\n "],[13],[1,"\\n "],[10,2],[12],[1,"\\n Connect your\\n "],[10,3],[14,6,"https://start.nostr.net"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"Nostr"],[13],[1,"\\n identity to publish photos of places.\\n "],[13],[1,"\\n\\n "],[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size"],["gift",20]],null],[1,"\\n "],[10,1],[12],[1,"Open Source"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content"],[12],[1,"\\n "],[10,"table"],[12],[1,"\\n "],[10,"thead"],[12],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"th"],[12],[1,"Source"],[13],[1,"\\n "],[10,"th"],[12],[1,"License"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tbody"],[12],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://gitea.kosmos.org/raucao/marco"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Marco App\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n "],[10,"abbr"],[14,"title","GNU Affero General Public License"],[12],[1,"AGPL"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://openstreetmap.org/copyright"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Map Data\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://opendatacommons.org/licenses/odbl/"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n "],[10,"abbr"],[14,"title","Open Data Commons Open Database License"],[12],[1,"ODbL"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://openfreemap.org"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Map tiles\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://github.com/hyperknot/openfreemap/blob/main/LICENSE.md"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Various\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://github.com/feathericons/feather"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Feather Icons\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://en.wikipedia.org/wiki/MIT_License"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n "],[10,"abbr"],[14,"title","MIT License"],[12],[1,"MIT"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://pinhead.ink/"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Pinhead Icons\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://github.com/waysidemapping/pinhead?tab=readme-ov-file#where-the-icons-are-from"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Various\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["heart",20,"#e5533d"]],null],[1,"\\n "],[10,1],[12],[1,"Contribute"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content"],[12],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Most impactful:"],[13],[1,"\\n "],[13],[1,"\\n "],[10,"ul"],[12],[1,"\\n "],[10,"li"],[12],[1,"\\n Add and improve data for points of interest in\\n "],[10,3],[14,6,"https://www.openstreetmap.org"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"OpenStreetMap"],[13],[1,".\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n Add place photos with your Nostr account.\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Most appreciated:"],[13],[1,"\\n Use this app as much as you can and\\n "],[10,3],[14,6,"https://community.remotestorage.io/t/marco-an-unhosted-maps-app/941"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"submit feedback"],[13],[1,"\\n about your experience, problems, feature wishes, etc.\\n "],[13],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Most supportive:"],[13],[1,"\\n Tell others about this app, on social media, in blog posts,\\n educational videos, etc.\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onBack","@onClose"],[]]',moduleName:"(unknown template module)",scope:()=>({on:Ww,Icon:d$}),isStrictMode:!0}),N$()),Att=class extends u${static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"currentView",[Vr],function(){return"menu"})}#Ae=void cF(this,"currentView");setView(t){this.currentView=t}static{lF(this.prototype,"setView",[ql])}goToSavedPlaces(){this.router.transitionTo("lists.index")}static{lF(this.prototype,"goToSavedPlaces",[ql])}goToContributions(){this.router.transitionTo("contributions")}static{lF(this.prototype,"goToContributions",[ql])}static{Ap(rg({id:null,block:'[[[10,0],[14,0,"sidebar app-menu-pane"],[12],[1,"\\n"],[41,[28,[32,0],[[30,0,["currentView"]],"menu"],null],[[[1," "],[8,[32,1],null,[["@onNavigate","@onClose","@onSavedPlaces","@onContributions"],[[30,0,["setView"]],[30,1],[30,0,["goToSavedPlaces"]],[30,0,["goToContributions"]]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["currentView"]],"settings"],null],[[[1," "],[8,[32,2],null,[["@onBack","@onClose"],[[28,[32,3],[[30,0,["setView"]],"menu"],null],[30,1]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["currentView"]],"about"],null],[[[1," "],[8,[32,4],null,[["@onBack","@onClose"],[[28,[32,3],[[30,0,["setView"]],"menu"],null],[30,1]]],null],[1,"\\n "]],[]],null]],[]]]],[]]],[13]],["@onClose"],["if"]]',moduleName:"(unknown template module)",scope:()=>({eq:j$,AppMenuHome:ktt,AppMenuSettings:Ptt,fn:L$,AppMenuAbout:Mtt}),isStrictMode:!0}),this)}},Ott=a({default:()=>Ntt}),Ntt=class extends u${static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");close(){this.router.transitionTo("index")}static{lF(this.prototype,"close",[ql])}static{Ap(rg({id:null,block:'[[[8,[32,0],null,[["@onClose"],[[30,0,["close"]]]],null]],[],[]]',moduleName:"(unknown template module)",scope:()=>({AppMenu:Att}),isStrictMode:!0}),this)}},Ftt=a({default:()=>Dtt}),Dtt=class extends Jh{static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");activate(){this.mapUi.showSidebar()}},ztt=a({default:()=>jtt}),jtt=class extends Jh{static{aF(this.prototype,"osmAuth",[dp])}#Ce=void cF(this,"osmAuth");static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");async model(){try{await this.osmAuth.handleCallback()}catch(t){console.error("Failed to handle OSM OAuth callback",t)}finally{this.router.transitionTo("index")}}},Utt=a({default:()=>Btt}),Btt=class extends u${static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");static{aF(this.prototype,"localPlace",[Vr],function(){return null})}#Oe=void cF(this,"localPlace");constructor(){super(...arguments),this.localPlace=this.args.model}get place(){const t=this.args.model,e=t.osmId||t.id;return this.storage.findPlaceById(e)||(!this.localPlace||this.localPlace.osmId!==e&&this.localPlace.id!==e?t.createdAt?{...t,id:void 0,createdAt:void 0,geohash:void 0}:t:this.localPlace)}handleUpdate(t){console.debug("Updating local place state:",t),this.localPlace=t,this.storage.notifyChange()}static{lF(this.prototype,"handleUpdate",[ql])}refreshMap(){this.storage.notifyChange()}static{lF(this.prototype,"refreshMap",[ql])}navigateBack(t){if(null===t)if(this.mapUi.returnToRoute){this.mapUi.showSidebar();const{name:t,model:e}=this.mapUi.returnToRoute;void 0!==e?this.router.transitionTo(t,e):this.router.transitionTo(t)}else this.mapUi.returnToSearch&&this.mapUi.currentSearch?(this.mapUi.showSidebar(),this.router.transitionTo("search",{queryParams:this.mapUi.currentSearch})):this.router.transitionTo("index");else this.mapUi.showSidebar(),this.router.transitionTo("place",t)}static{lF(this.prototype,"navigateBack",[ql])}close(){this.mapUi.clearSelection(),this.mapUi.hideSidebar(),this.mapUi.returnToSearch&&this.mapUi.currentSearch?this.router.transitionTo("search",{queryParams:this.mapUi.currentSearch}):this.router.transitionTo("index")}static{lF(this.prototype,"close",[ql])}static{Ap(rg({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@selectedPlace","@onClose","@onSelect","@onBookmarkChange","@onUpdate"],[[30,0,["place"]],[30,0,["close"]],[30,0,["navigateBack"]],[30,0,["refreshMap"]],[30,0,["handleUpdate"]]]],null],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlacesSidebar:iW}),isStrictMode:!0}),this)}},$tt=a({default:()=>qtt}),qtt=class extends Jh{static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"osm",[dp])}#B=void cF(this,"osm");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");async model(t){const e=t.place_id;let n,r,i=!1;(e.startsWith("osm:node:")||e.startsWith("osm:way:")||e.startsWith("osm:relation:"))&&(i=!0,[,n,r]=e.split(":"),console.debug(`Fetching explicit OSM ${n}:`,r));let s=null;i&&(s=this.loadOsmPlace(r,n)),await this.waitForSync();let o=i?r:e,a=this.storage.findPlaceById(o);return a&&i&&a.osmType!==n&&(a=null),a?(console.debug("Found in bookmarks:",a.title),a):i?(console.debug(`Not in bookmarks, using explicitly fetched OSM ${n}:`,r),await s):(console.warn("Not in bookmarks:",e),null)}async waitForSync(){if(this.storage.initialSyncDone)return;console.debug("Waiting for initial storage sync...");const t=Date.now();for(;!this.storage.initialSyncDone;){if(Date.now()-t>5e3){console.warn("Timed out waiting for initial sync");break}await new Promise(t=>setTimeout(t,100))}}async afterModel(t){if(t&&t.osmId&&t.osmType&&"node"!==t.osmType&&!t.geojson){console.debug("Model missing geometry, fetching full OSM details...");const e=await this.loadOsmPlace(t.osmId,t.osmType);e&&(Object.assign(t,e),console.debug("Enriched model with full OSM details",t))}if(t){const e={preventZoom:this.mapUi.preventNextZoom};this.mapUi.selectPlace(t,e),this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!1}this.mapUi.stopSearch()}deactivate(){this.mapUi.clearSelection(),this.mapUi.returnToSearch=!1,this.mapUi.returnToRoute=null}async loadOsmPlace(t,e=null){try{const n=await this.osm.fetchOsmObject(t,e);if(n)return console.debug("Found OSM POI:",n),n}catch(n){console.error("Failed to fetch POI",n)}return null}setupController(t,e){super.setupController(t,e),this.checkUpdates(e)}async checkUpdates(t){if(t&&t.osmId&&t.osmType){if(t.id){const e=await this.storage.refreshPlace(t);return void(e&&this.mapUi.selectPlace(e,{preventZoom:!0}))}try{const e=await this.osm.fetchOsmObject(t.osmId,t.osmType,{forceFresh:!0});e&&function(t,e){const n=Math.abs((t.lat??0)-(e.lat??0)),r=Math.abs((t.lon??0)-(e.lon??0));if(n>1e-5||r>1e-5)return!0;const i=t.osmTags||{},s=e.osmTags||{},o=new Set([...Object.keys(i),...Object.keys(s)]);for(const a of o)if(i[a]!==s[a])return!0;return!1}(t,e)&&(Object.assign(t,e),this.mapUi.selectPlace(t,{preventZoom:!0}))}catch(e){console.debug("[place] Fresh fetch failed for",t.osmId,e)}}}serialize(t){return t.osmId&&t.osmType?{place_id:`osm:${t.osmType}:${t.osmId}`}:t.id?{place_id:t.id}:{place_id:t.osmId}}},Vtt=a({default:()=>Wtt}),Wtt=class extends u${static{aF(this.prototype,"router",[dp])}#Vt=void cF(this,"router");static{aF(this.prototype,"storage",[dp])}#U=void cF(this,"storage");static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");get initialPlace(){return{title:"",description:""}}close(){this.router.transitionTo("index")}static{lF(this.prototype,"close",[ql])}async savePlace(t){try{const e=this.mapUi.creationCoordinates||{lat:this.args.model.lat,lon:this.args.model.lon},n=parseFloat(e.lat.toFixed(6)),r=parseFloat(e.lon.toFixed(6)),i={title:t.title||"Untitled Place",description:t.description,lat:n,lon:r,tags:[],osmTags:{}},s=await this.storage.storePlace(i);console.debug("Created private place:",s.title),this.router.replaceWith("place",s)}catch(e){console.error("Failed to create place:",e),alert("Failed to create place: "+e.message)}}static{lF(this.prototype,"savePlace",[ql])}static{Ap(rg({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[14,0,"sidebar-header"],[12],[1,"\\n "],[10,"h2"],[12],[8,[32,0],null,[["@name","@size","@color"],["plus-circle",20,"#ea4335"]],null],[1,"\\n New Place"],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,1],["click",[30,0,["close"]]],null],[12],[8,[32,0],null,[["@name","@size","@color"],["x",20,"#333"]],null],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,2],[14,0,"helper-text"],[12],[1,"\\n Drag the map to position the crosshair.\\n "],[13],[1,"\\n\\n "],[8,[32,2],null,[["@place","@onSave","@onCancel"],[[30,0,["initialPlace"]],[30,0,["savePlace"]],[30,0,["close"]]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:d$,on:Ww,PlaceEditForm:qV}),isStrictMode:!0}),this)}},Htt=a({default:()=>Gtt}),Gtt=class extends Jh{static{aF(this.prototype,"mapUi",[dp])}#Wt=void cF(this,"mapUi");queryParams={lat:{refreshModel:!0},lon:{refreshModel:!0}};model(t){return{lat:parseFloat(t.lat),lon:parseFloat(t.lon)}}setupController(t,e){super.setupController(t,e),e.lat&&e.lon&&this.mapUi.updateCreationCoordinates(e.lat,e.lon),this.mapUi.startCreating(),this.mapUi.showSidebar()}deactivate(){this.mapUi.stopCreating()}},Ktt=Object.assign({},J_,{"marco/config/environment":nx,"marco/deprecation-workflow":_x,"marco/router":Lx,"marco/services/blossom":uF,"marco/services/contributions":wF,"marco/services/image-processor":SF,"marco/services/local-forage":RF,"marco/services/map-ui":IF,"marco/services/nostr-auth":iz,"marco/services/nostr-data":Sj,"marco/services/nostr-relay":Wj,"marco/services/osm-auth":dU,"marco/services/osm":RU,"marco/services/photon":LU,"marco/services/settings":PU,"marco/services/storage":HU,"marco/services/toast":KU,"marco/utils/contributions":fF,"marco/utils/device":tz,"marco/utils/format-text":gU,"marco/utils/geo":YU,"marco/utils/geohash-coverage":xj,"marco/utils/icons":JU,"marco/utils/nostr":fj,"marco/utils/osm-icons":rB,"marco/utils/osm":bU,"marco/utils/photo-tag-suggestions":uB,"marco/utils/place-mapping":pB,"marco/utils/poi-categories":CU,"marco/utils/poi-category-matcher":aB,"marco/utils/social-links":gB,"marco/workers/image-processor":AB,"marco/services/page-title":BB,"marco/templates/contributions":Cq,"marco/controllers/contributions":NV,"marco/routes/contributions":DV,"marco/templates/lists":jV,"marco/routes/lists":BV,"marco/templates/lists/list":sW,"marco/controllers/lists/list":aW,"marco/routes/lists/list":pW,"marco/templates/lists/index":gW,"marco/routes/lists/index":yW,"marco/templates/search":bW,"marco/controllers/search":_W,"marco/routes/search":CW,"marco/templates/application":btt,"marco/routes/application":_tt,"marco/routes/index":Ctt,"marco/templates/menu":Ott,"marco/routes/menu":Ftt,"marco/routes/oauth/osm-callback":ztt,"marco/templates/place":Utt,"marco/routes/place":$tt,"marco/templates/place/new":Vtt,"marco/routes/place/new":Htt},{}),Ztt=class{constructor(t,e,n){this.limit=t,this.func=e,this.store=n,this.size=0,this.misses=0,this.hits=0,this.store=n||new Map}get(t){let e=this.store.get(t);return this.store.has(t)?(this.hits++,this.store.get(t)):(this.misses++,e=this.set(t,this.func(t)),e)}set(t,e){return this.limit>this.size&&(this.size++,this.store.set(t,e)),e}purge(){this.store.clear(),this.size=0,this.hits=0,this.misses=0}},Ytt=/[ _]/g,Xtt=new Ztt(1e3,t=>{return(e=t,oet.get(e)).replace(Ytt,"-");var e}),Jtt=/^(\-|_)+(.)?/,Qtt=/(.)(\-|\_|\.|\s)+(.)?/g,tet=/(^|\/|\.)([a-z])/g,eet=new Ztt(1e3,t=>{const e=(t,e,n)=>n?`_${n.toUpperCase()}`:"",n=(t,e,n,r)=>e+(r?r.toUpperCase():""),r=t.split("/");for(let i=0;it.toUpperCase())}),net=/([a-z\d])([A-Z]+)/g,ret=/\-|\s+/g,iet=new Ztt(1e3,t=>t.replace(net,"$1_$2").replace(ret,"_").toLowerCase()),set=/([a-z\d])([A-Z])/g,oet=new Ztt(1e3,t=>t.replace(set,"$1_$2").toLowerCase()),aet=class{constructor(t){this._entries=t||globalThis.requirejs.entries}moduleNames(){return Object.keys(this._entries)}has(t){return t in this._entries}get(...t){return globalThis.require(...t)}},cet=class{static moduleBasedResolver=!0;moduleBasedResolver=!0;_deprecatedPodModulePrefix=!1;_normalizeCache=Object.create(null);static create(t){return new this(t)}moduleNameLookupPatterns=[this.podBasedModuleName,this.podBasedComponentsInSubdir,this.mainModuleName,this.defaultModuleName,this.nestedColocationComponentModuleName];static withModules(t){return class extends(this){static explicitModules=t}}constructor(t){if(Object.assign(this,t),!this._moduleRegistry){let t=this.constructor.explicitModules;t?this._moduleRegistry={moduleNames:()=>Object.keys(t),has:e=>Boolean(t[e]),get:e=>t[e],addModules(e){t=Object.assign({},t,e)}}:(void 0===globalThis.requirejs.entries&&(globalThis.requirejs.entries=globalThis.requirejs._eak_seen),this._moduleRegistry=new aet)}this.pluralizedTypes=this.pluralizedTypes||Object.create(null),this.pluralizedTypes.config||(this.pluralizedTypes.config="config")}makeToString(t,e){return this.namespace.modulePrefix+"@"+e+":"}shouldWrapInClassFactory(){return!1}parseName(t){if(!0===t.parsedName)return t;let e,n,r,i=t.split("@");if(3===i.length){if(0===i[0].length){e=`@${i[1]}`;let t=i[2].split(":");n=t[0],r=t[1]}else e=`@${i[1]}`,n=i[0].slice(0,-1),r=i[2];"template:components"===n&&(r=`components/${r}`,n="template")}else if(2===i.length){let t=i[0].split(":");if(2===t.length)0===t[1].length?(n=t[0],r=`@${i[1]}`):(e=t[1],n=t[0],r=i[1]);else{let t=i[1].split(":");e=i[0],n=t[0],r=t[1]}"template"===n&&0===e.lastIndexOf("components/",0)&&(r=`components/${r}`,e=e.slice(11))}else i=t.split(":"),n=i[0],r=i[1];let s=r,o=this.namespace;return{parsedName:!0,fullName:t,prefix:e||this.prefix({type:n}),type:n,fullNameWithoutType:s,name:r,root:o,resolveMethodName:"resolve"+(a=n,eet.get(a))};var a}resolveOther(t){uet("`modulePrefix` must be defined",this.namespace.modulePrefix);let e=this.findModuleName(t);if(e){let r=this._extractDefaultExport(e,t);if(void 0===r)throw new Error(` Expected to find: '${t.fullName}' within '${e}' but got 'undefined'. Did you forget to 'export default' within '${e}'?`);return this.shouldWrapInClassFactory(r,t)&&(n=r,r={create:t=>"function"==typeof n.extend?n.extend(t):n}),r}var n}normalize(t){return this._normalizeCache[t]||(this._normalizeCache[t]=this._normalize(t))}resolve(t){if("resolver:current"===t)return{create:()=>this};let e,n=this.parseName(t),r=n.resolveMethodName;return"function"==typeof this[r]&&(e=this[r](n)),null==e&&(e=this.resolveOther(n)),e}addModules(t){if(!this._moduleRegistry.addModules)throw new Error("addModules is only supported when your Resolver has been configured to use static modules via Resolver.withModules()");this._moduleRegistry.addModules(t)}_normalize(t){let e=t.split(":");if(e.length>1){let t=e[0];return"component"===t||"helper"===t||"modifier"===t||"template"===t&&0===e[1].indexOf("components/")?t+":"+e[1].replace(/_/g,"-"):t+":"+(n=e[1].replace(/\./g,"/"),Xtt.get(n))}return t;var n}pluralize(t){return this.pluralizedTypes[t]||(this.pluralizedTypes[t]=t+"s")}podBasedLookupWithPrefix(t,e){let n=e.fullNameWithoutType;return"template"===e.type&&(n=n.replace(/^components\//,"")),t+"/"+n+"/"+e.type}podBasedModuleName(t){let e=this.namespace.podModulePrefix||this.namespace.modulePrefix;return this.podBasedLookupWithPrefix(e,t)}podBasedComponentsInSubdir(t){let e=this.namespace.podModulePrefix||this.namespace.modulePrefix;if(e+="/components","component"===t.type||/^components/.test(t.fullNameWithoutType))return this.podBasedLookupWithPrefix(e,t)}resolveEngine(t){let e=t.fullNameWithoutType+"/engine";if(this._moduleRegistry.has(e))return this._extractDefaultExport(e)}resolveRouteMap(t){let e=t.fullNameWithoutType,n=e+"/routes";if(this._moduleRegistry.has(n)){let t=this._extractDefaultExport(n);return uet(`The route map for ${e} should be wrapped by 'buildRoutes' before exporting.`,t.isRouteMap),t}}resolveTemplate(t){return this.resolveOther(t)}mainModuleName(t){if("main"===t.fullNameWithoutType)return t.prefix+"/"+t.type}defaultModuleName(t){return t.prefix+"/"+this.pluralize(t.type)+"/"+t.fullNameWithoutType}nestedColocationComponentModuleName(t){if("component"===t.type)return t.prefix+"/"+this.pluralize(t.type)+"/"+t.fullNameWithoutType+"/index"}prefix(t){let e=this.namespace.modulePrefix;return this.namespace[t.type+"Prefix"]&&(e=this.namespace[t.type+"Prefix"]),e}findModuleName(t){let e,n=this.moduleNameLookupPatterns;for(let r=0,i=n.length;rr.length+i.length)return t+":"+e.slice(s+r.length,o);let a=n+"/"+this.pluralize(t)+"/";return 0===e.indexOf(a)&&e.length>a.length?t+":"+e.slice(a.length):void 0}_extractDefaultExport(t){let e=this._moduleRegistry.get(t,null,null,!0);return e&&e.default&&(e=e.default),e}};function uet(t,e){if(!e)throw new Error(t)}(class extends X_{modulePrefix=rx.modulePrefix;podModulePrefix=rx.podModulePrefix;Resolver=cet.withModules(Ktt);inspector=function(t){!function(t){globalThis.emberInspectorApps||(globalThis.emberInspectorApps=[]),globalThis.emberInspectorApps.push({app:t,name:`app-${globalThis.emberInspectorApps.length}`,loadCompatInspector:()=>uj(()=>import("./modules-4-12-7mlk2oAE.js"),[])}),globalThis.dispatchEvent&&globalThis.dispatchEvent(new Event("Ember"))}(t)}(this)}).create(rx.APP);export{Wv as $,ol as $n,rt as $r,zp as $t,lx as A,hc as An,Ye as Ar,lm as At,pb as B,lc as Bn,te as Br,fg as Bt,YA as C,Yc as Cn,sr as Cr,sy as Ct,eA as D,_c as Dn,Yn as Dr,Qm as Dt,iA as E,kc as En,Un as Er,_m as Et,A_ as F,ic as Fn,Ae as Fr,Vg as Ft,ib as G,tc as Gn,Zt as Gr,Up as Gt,yb as H,Kl as Hn,ne as Hr,jp as Ht,jw as I,Xl as In,ke as Ir,im as It,ob as J,Dl as Jn,Nt as Jr,Vp as Jt,sb as K,Ul as Kn,Kt as Kr,Wp as Kt,hb as L,Gl as Ln,Ee as Lr,Bg as Lt,S_ as M,ec as Mn,Xe as Mr,Qg as Mt,__ as N,nc as Nn,tn as Nr,em as Nt,qP as O,wc as On,We as Or,Xm as Ot,x_ as P,Hl as Pn,Pe as Pr,nm as Pt,Vv as Q,sl as Qn,it as Qr,Dp as Qt,fb as R,cc as Rn,ie as Rr,Cg as Rt,dO as S,Xc as Sn,ur as Sr,ay as St,AA as T,Pc as Tn,nr as Tr,Ym as Tt,mb as U,Wl as Un,re as Ur,$p as Ut,gb as V,Jl as Vn,Qt as Vr,yg as Vt,tb as W,Ql as Wn,Jt as Wr,Bp as Wt,Kv as X,Sl as Xn,lt as Xr,Hp as Xt,eb as Y,Rl as Yn,ct as Yr,Gp as Yt,Zv as Z,wl as Zn,et as Zr,Np as Zt,qB as _,gu as _n,Cr as _r,Uy as _t,v$ as a,b as ai,Fu as an,Po as ar,ky as at,qO as b,lu as bn,vr as br,ly as bt,_$ as c,_u as cn,fs as cr,Ty as ct,C$ as d,ju as dn,ei as dr,qy as dt,tt as ei,Fp as en,al as er,Hv as et,g$ as f,wu as fn,Kr as fr,Iy as ft,ZB as g,Iu as gn,Sr as gr,ev as gt,YB as h,Mu as hn,Ir as hr,nv as ht,m$ as i,w as ii,xu as in,Ba as ir,iv as it,K_ as j,sc as jn,Je as jr,qg as jt,kx as k,yc as kn,qe as kr,Jm as kt,y$ as l,Du as ln,xi as lr,$y as lt,XB as m,Nu as mn,Mr as mr,rv as mt,kV as n,d as ni,Ap as nn,Qa as nr,Dv as nt,b$ as o,v as oi,Ou as on,Lo as or,Sy as ot,n$ as p,bu as pn,Dr as pr,Cy as pt,rb as q,jl as qn,xt as qr,qp as qt,x$ as r,u as ri,up as rn,$a as rr,gv as rt,w$ as s,a as si,Pu as sn,Hs as sr,wy as st,kW as t,g as ti,Op as tn,el as tr,jv as tt,S$ as u,zu as un,ni as ur,_y as ut,$B as v,vu as vn,Pr as vr,Ly as vt,WA as w,Hc as wn,er as wr,oy as wt,PO as x,au as xn,fr as xr,bm as xt,sF as y,yu as yn,Er as yr,jy as yt,lb as z,oc as zn,ee as zr,gg as zt}; \ No newline at end of file diff --git a/release/assets/main-MT6QR2E9.js b/release/assets/main-MT6QR2E9.js deleted file mode 100644 index 920bbcd..0000000 --- a/release/assets/main-MT6QR2E9.js +++ /dev/null @@ -1 +0,0 @@ -var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:"Module"}),r},l=(o,a,l)=>(l=null!=o?t(i(o)):{},((t,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;ui[t]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return t})(!a&&o&&o.__esModule&&s.call(o,"default")?l:e(l,"default",{value:o,enumerable:!0}),o));!function(){const t=document.createElement("link").relList;if(!(t&&t.supports&&t.supports("modulepreload"))){for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const n of t)if("childList"===n.type)for(const t of n.addedNodes)"LINK"===t.tagName&&"modulepreload"===t.rel&&e(t)}).observe(document,{childList:!0,subtree:!0})}function e(t){if(t.ep)return;t.ep=!0;const e=function(t){const e={};return t.integrity&&(e.integrity=t.integrity),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),"use-credentials"===t.crossOrigin?e.credentials="include":"anonymous"===t.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(t);fetch(t.href,e)}}();var c,u=Object.prototype,h=Symbol("undefined"),d=function(t){return t[t.ADD=0]="ADD",t[t.ONCE=1]="ONCE",t[t.REMOVE=2]="REMOVE",t}(d||{}),p=1,f=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(t){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=t,this.proto=void 0===t.constructor?void 0:t.constructor.prototype,this._listeners=void 0}get parent(){let t=this._parent;if(void 0===t){let e=g(this.source);this._parent=t=null===e||e===u?null:b(e)}return t}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(t){return this.proto===this.source&&this.source===t}_getOrCreateOwnMap(t){return this[t]||(this[t]=Object.create(null))}_getOrCreateOwnSet(t){return this[t]||(this[t]=new Set)}_findInheritedMap(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r){let t=r.get(e);if(void 0!==t)return t}n=n.parent}}_hasInInheritedSet(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r&&r.has(e))return!0;n=n.parent}return!1}valueFor(t){let e=this._values;return void 0!==e?e[t]:void 0}setValueFor(t,e){this._getOrCreateOwnMap("_values")[t]=e}revisionFor(t){let e=this._revisions;return void 0!==e?e[t]:void 0}setRevisionFor(t,e){this._getOrCreateOwnMap("_revisions")[t]=e}writableLazyChainsFor(t){let e=this._getOrCreateOwnMap("_lazyChains"),n=e[t];return void 0===n&&(n=e[t]=[]),n}readableLazyChainsFor(t){let e=this._lazyChains;if(void 0!==e)return e[t]}addMixin(t){this._getOrCreateOwnSet("_mixins").add(t)}hasMixin(t){return this._hasInInheritedSet("_mixins",t)}forEachMixins(t){let e,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(e=void 0===e?new Set:e,r.forEach(n=>{e.has(n)||(e.add(n),t(n))})),n=n.parent}}writeDescriptors(t,e){(this._descriptors||(this._descriptors=new Map)).set(t,e)}peekDescriptors(t){let e=this._findInheritedMap("_descriptors",t);return e===h?void 0:e}removeDescriptors(t){this.writeDescriptors(t,h)}forEachDescriptors(t){let e,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(e=void 0===e?new Set:e,r.forEach((n,r)=>{e.has(r)||(e.add(r),n!==h&&t(r,n))})),n=n.parent}}addToListeners(t,e,n,r,i){this.pushListener(t,e,n,r?d.ONCE:d.ADD,i)}removeFromListeners(t,e,n){this.pushListener(t,e,n,d.REMOVE)}pushListener(t,e,n,r,i=!1){let s=this.writableListeners(),o=w(s,t,e,n);if(-1!==o&&o0&&(t.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(let n of e)-1===w(t,n.event,n.target,n.method)&&(t.unshift(n),this._inheritedEnd++)}}this._flattenedVersion=p}return this._listeners}matchingListeners(t){let e,n=this.flattenedListeners();if(void 0!==n)for(let r of n)r.event!==t||r.kind!==d.ADD&&r.kind!==d.ONCE||(void 0===e&&(e=[]),e.push(r.target,r.method,r.kind===d.ONCE));return e}observerEvents(){let t,e=this.flattenedListeners();if(void 0!==e)for(let n of e)n.kind!==d.ADD&&n.kind!==d.ONCE||-1===n.event.indexOf(":change")||(void 0===t&&(t=[]),t.push(n));return t}},g=Object.getPrototypeOf,m=new WeakMap;function y(t,e){m.set(t,e)}function v(t){let e=m.get(t);if(void 0!==e)return e;let n=g(t);for(;null!==n;){if(e=m.get(n),void 0!==e)return e.proto!==n&&(e.proto=n),e;n=g(n)}return null}var b=function(t){let e=v(t);if(null!==e&&e.source===t)return e;let n=new f(t);return y(t,n),n};function w(t,e,n,r){for(let i=t.length-1;i>=0;i--){let s=t[i];if(s.event===e&&s.target===n&&s.method===r)return i}return-1}function _(t){let[e,n,r]=t;return 3===t.length&&("function"==typeof e||"object"==typeof e&&null!==e)&&"string"==typeof n&&("object"==typeof r&&null!==r||void 0===r)}function x(t){let e=function(){return t};return M(e),e}var C=class{enumerable=!0;configurable=!0;_dependentKeys=void 0;_meta=void 0;setup(t,e,n,r){r.writeDescriptors(e,this)}teardown(t,e,n){n.removeDescriptors(e)}};function k(t,e){return function(){return e.get(this,t)}}function S(t,e){let n=function(n){return e.set(this,t,n)};return E.add(n),n}var E=new WeakSet;function R(t,e){let n=function(e,n,r,i){let s=3===arguments.length?b(e):i;return t.setup(e,n,r,s),{enumerable:t.enumerable,configurable:t.configurable,get:k(n,t),set:S(n,t)}};return M(n,t),Object.setPrototypeOf(n,e.prototype),n}var T=new WeakMap;function L(t,e,n){let r=void 0===n?v(t):n;if(null!==r)return r.peekDescriptors(e)}function P(t){return T.get(t)}function I(t){return"function"==typeof t&&T.has(t)}function M(t,e=!0){T.set(t,e)}var A={ENABLE_OPTIONAL_FEATURES:!1,EXTEND_PROTOTYPES:{Array:!1},LOG_STACKTRACE_ON_DEPRECATION:!0,LOG_VERSION:!0,LOG_INSPECTOR_HINT:!0,RAISE_ON_DEPRECATION:!1,STRUCTURED_PROFILE:!1,_DEBUG_RENDER_TREE:!1,_ALL_DEPRECATIONS_ENABLED:!1,_OVERRIDE_DEPRECATION_VERSION:null,_DEFAULT_ASYNC_OBSERVERS:!1,_RERENDER_LOOP_LIMIT:1e3,FEATURES:{}},O=globalThis.EmberENV;if("object"==typeof O&&null!==O){for(let e in O){if(!Object.prototype.hasOwnProperty.call(O,e)||"EXTEND_PROTOTYPES"===e||"EMBER_LOAD_HOOKS"===e)continue;let t=A[e];A[e]=!0===t?!1!==O[e]:!1===t?!0===O[e]:O[e]}let{FEATURES:t}=O;if("object"==typeof t&&null!==t)for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(A.FEATURES[e]=!0===t[e])}function F(){return A}var N,z,D,j,U,B,$,q,V=()=>{},W=new WeakMap,H=Symbol("BrandedArray");function G(t){return Array.isArray(t)&&H in t}function K(t,e){if(null===t)return e;if(G(t))return t.push(e),t;{const n=[t,e];return n[H]=!0,n}}function Z(t,e){G(t)?t.forEach(e):null!==t&&e(t)}function Y(t,e){if(G(t)&&t.length>1){let n=t.indexOf(e),r=t.length-1;return n!==r&&(t[n]=t[r]),t.length=r,t}return null}function X(t){let e=W.get(t);return void 0===e&&(e={parents:null,children:null,eagerDestructors:null,destructors:null,state:0},W.set(t,e)),e}function J(t,e){let n=X(t),r=X(e);return n.children=K(n.children,e),r.parents=K(r.parents,t),e}function Q(t,e,n=!1){let r=X(t),i=n?"eagerDestructors":"destructors";return r[i]=K(r[i],e),e}function tt(t){let e=X(t);if(e.state>=1)return;let{parents:n,children:r,eagerDestructors:i,destructors:s}=e;e.state=1,Z(r,tt),Z(i,e=>{e(t)}),Z(s,e=>{N(t,e)}),z(()=>{Z(n,e=>{!function(t,e){let n=X(e);2!==n.state&&(n.children=Y(n.children,t))}(t,e)}),e.state=2})}function et(t){let e=W.get(t);return void 0!==e&&null!==e.children}function nt(t){let e=W.get(t);return void 0!==e&&e.state>=1}function rt(t){let e=W.get(t);return void 0!==e&&e.state>=2}var it=1;function st(){it++}var ot=Symbol("TAG_COMPUTE");function at(t){return t[ot]()}function lt(t,e){return e>=t[ot]()}var ct=Symbol("TAG_TYPE"),ut=class t{static combine(e){switch(e.length){case 0:return gt;case 1:return e[0];default:{let n=new t(2);return n.subtag=e,n}}}revision=1;lastChecked=1;lastValue=1;isUpdating=!1;subtag=null;subtagBufferCache=null;constructor(t){this[ct]=t}[ot](){let{lastChecked:t}=this;if(this.isUpdating)this.lastChecked=++it;else if(t!==it){this.isUpdating=!0,this.lastChecked=it;try{let{subtag:t,revision:e}=this;if(null!==t)if(Array.isArray(t))for(const n of t){let t=n[ot]();e=Math.max(t,e)}else{let n=t[ot]();n===this.subtagBufferCache?e=Math.max(e,this.lastValue):(this.subtagBufferCache=null,e=Math.max(e,n))}this.lastValue=e}finally{this.isUpdating=!1}}return this.lastValue}static updateTag(t,e){let n=t,r=e;r===gt?n.subtag=null:(n.subtagBufferCache=r[ot](),n.subtag=r)}static dirtyTag(t,e){t.revision=++it,V()}},ht=ut.dirtyTag,dt=ut.updateTag;function pt(){return new ut(0)}function ft(){return new ut(1)}var gt=new ut(3);function mt(t){return t===gt}var yt=class{[ct]=100;[ot](){return NaN}},vt=new yt,bt=class{[ct]=101;[ot](){return it}},wt=new bt,_t=ut.combine,xt=ft(),Ct=ft(),kt=ft();at(xt),ht(xt),at(xt),dt(xt,_t([Ct,kt])),at(xt),ht(Ct),at(xt),ht(kt),at(xt),dt(xt,kt),at(xt),ht(kt),at(xt);var St=class{tags=new Set;last=null;add(t){t!==gt&&(this.tags.add(t),this.last=t)}combine(){let{tags:t}=this;return 0===t.size?gt:1===t.size?this.last:_t(Array.from(this.tags))}},Et=null,Rt=[];function Tt(){Rt.push(Et),Et=new St}function Lt(){let t=Et;return Et=Rt.pop()||null,function(t){if(null==t)throw new Error("Expected value to be present");return t}(t).combine()}function Pt(){Rt.push(Et),Et=null}function It(){Et=Rt.pop()||null}function Mt(){for(;Rt.length>0;)Rt.pop();Et=null}function At(){return null!==Et}function Ot(t){null!==Et&&Et.add(t)}var Ft=Symbol("FN"),Nt=Symbol("LAST_VALUE"),zt=Symbol("TAG"),Dt=Symbol("SNAPSHOT");function jt(t){return{[Ft]:t,[Nt]:void 0,[zt]:void 0,[Dt]:-1}}function Ut(t){let e=t[Ft],n=t[zt],r=t[Dt];if(void 0!==n&<(n,r))Ot(n);else{Tt();try{t[Nt]=e()}finally{n=Lt(),t[zt]=n,t[Dt]=at(n),Ot(n)}}return t[Nt]}function Bt(t){return mt(t[zt])}function $t(t){let e;Tt();try{t()}finally{e=Lt()}return e}function qt(t){Pt();try{return t()}finally{It()}}var Vt=new WeakMap;function Wt(t,e,n){let r=void 0===n?Vt.get(t):n;if(void 0===r)return;let i=r.get(e);void 0!==i&&ht(i,!0)}function Ht(t){let e=Vt.get(t);return void 0===e&&(e=new Map,Vt.set(t,e)),e}function Gt(t,e,n){let r=void 0===n?Ht(t):n,i=r.get(e);return void 0===i&&(i=ft(),r.set(e,i)),i}function Kt(t){return null!==t&&("object"==typeof t||"function"==typeof t)}function Zt(t){return t}function Yt(t){return t}function Xt(t){return!!t&&t.length>0}function Jt(t){return 0===t.length?void 0:t[t.length-1]}function Qt(t){return 0===t.length?void 0:t[0]}function te(){return Object.create(null)}function ee(t){return null!=t}function ne(t){return"function"==typeof t||"object"==typeof t&&null!==t}var re=class{stack;current=null;constructor(t=[]){this.stack=t}get size(){return this.stack.length}push(t){this.current=t,this.stack.push(t)}pop(){let t=this.stack.pop();return this.current=Jt(this.stack)??null,void 0===t?null:t}nth(t){let e=this.stack.length;return ebe(t),null,t.debugLabel):t}function ge(t){return 3===t[ie]}function me(t){const e=pe(()=>be(t),e=>we(t,e));return e.debugLabel=t.debugLabel,e[ie]=3,e}function ye(t){return t.tag===gt}function ve(t){return null!==t.update}function be(t){const e=t;let{tag:n}=e;if(n===gt)return e.lastValue;const{lastRevision:r}=e;let i;if(null!==n&<(n,r))i=e.lastValue;else{const{compute:t}=e,r=$t(()=>{i=e.lastValue=t()});n=e.tag=r,e.lastRevision=at(r)}return Ot(n),i}function we(t,e){(0,t.update)(e)}function _e(t,e){const n=t,r=n[ie];let i,s=n.children;if(null===s)s=n.children=new Map;else{const t=s.get(e);if(t)return t}if(2===r){const t=be(n);i=ee(t)?de(t[e]):ae}else i=pe(()=>{const t=be(n);if(ee(t))return U(t,e)},t=>{const r=be(n);if(ee(r))return B(r,e,t)});return s.set(e,i),i}function xe(t,e){let n=t;for(const r of e)n=_e(n,r);return n}var Ce=new WeakMap;function ke(t){return Ce.get(t)}function Se(t,e){Ce.set(t,e)}function Ee(t){if("symbol"==typeof t)return null;const e=Number(t);return isNaN(e)?null:e%1==0?e:null}var Re=class{constructor(t){this.named=t}get(t,e){const n=this.named[e];if(void 0!==n)return be(n)}has(t,e){return e in this.named}ownKeys(){return Object.keys(this.named)}isExtensible(){return!1}getOwnPropertyDescriptor(t,e){return{enumerable:!0,configurable:!0}}},Te=class{constructor(t){this.positional=t}get(t,e){let{positional:n}=this;if("length"===e)return n.length;const r=Ee(e);return null!==r&&r>=0&&r=0&&n{const{named:e,positional:n}=t,r=new Re(e),i=new Te(n),s=Object.create(null),o=new Proxy(s,r),a=new Proxy([],i);return Se(o,(t,n)=>function(t,e){return $t(()=>{e in t&&be(t[e])})}(e,n)),Se(a,(t,e)=>function(t,e){return $t(()=>{"[]"===e&&t.forEach(be);const n=Ee(e);null!==n&&n>=0&&n-1?function(t){return Ue.test(Be.call(t))}:function(){return!0},qe=new WeakMap,Ve=Object.freeze(function(){});function We(t){let e=qe.get(t);return void 0===e&&(e=$e(t),qe.set(t,e)),e}qe.set(Ve,!1);var He=class{listeners=void 0;observers=void 0},Ge=new WeakMap;function Ke(t){let e=Ge.get(t);return void 0===e&&(e=new He,Ge.set(t,e)),e}function Ze(t){return Ge.get(t)}function Ye(t,e){Ke(t).observers=e}function Xe(t,e){Ke(t).listeners=e}var Je=new WeakSet;function Qe(t,e){return We(t)?!Je.has(e)&&We(e)?tn(t,tn(e,Ve)):tn(t,e):t}function tn(t,e){function n(){let n=this._super;this._super=e;let r=t.apply(this,arguments);return this._super=n,r}Je.add(n);let r=Ge.get(t);return void 0!==r&&Ge.set(n,r),n}function en(t,e,n,r,i,s=!0){r||"function"!=typeof n||(r=n,n=null),b(t).addToListeners(e,n,r,!0===i,s)}function nn(t,e,n,r){let i,s;"object"==typeof n?(i=n,s=r):(i=null,s=n),b(t).removeFromListeners(e,i,s)}function rn(t,e,n,r,i){if(void 0===r){let n=void 0===i?v(t):i;r=null!==n?n.matchingListeners(e):void 0}if(void 0===r||0===r.length)return!1;for(let s=r.length-3;s>=0;s-=3){let i=r[s],o=r[s+1],a=r[s+2];if(!o)continue;a&&nn(t,e,i,o),i||(i=t);let l=typeof o;"string"!==l&&"symbol"!==l||(o=i[o]),o.apply(i,n)}return!0}function sn(t,e){let n=v(t);if(null===n)return!1;let r=n.matchingListeners(e);return void 0!==r&&r.length>0}function on(...t){let e=t.pop();return Xe(e,t),e}function an(t){return t+":change"}var ln=!A._DEFAULT_ASYNC_OBSERVERS,cn=new Map,un=new Map;function hn(t,e,n,r,i=ln){let s=an(e);en(t,s,n,r,!1,i);let o=v(t);null!==o&&(o.isPrototypeMeta(t)||o.isInitializing())||pn(t,s,i)}function dn(t,e,n,r,i=ln){let s=an(e),o=v(t);null!==o&&(o.isPrototypeMeta(t)||o.isInitializing())||mn(t,s,i),nn(t,s,n,r)}function pn(t,e,n=!1){let r=function(t,e){let n=!0===e?cn:un;return n.has(t)||(n.set(t,new Map),Q(t,()=>function(t){cn.size>0&&cn.delete(t),un.size>0&&un.delete(t)}(t),!0)),n.get(t)}(t,n);if(r.has(e))r.get(e).count++;else{let n=e.substring(0,e.lastIndexOf(":")),i=De(t,n,Ht(t),v(t));r.set(e,{count:1,path:n,tag:i,lastRevision:at(i),suspended:!1})}}var fn=!1,gn=[];function mn(t,e,n=!1){if(!0===fn)return void gn.push([t,e,n]);let r=!0===n?cn:un,i=r.get(t);if(void 0!==i){let n=i.get(e);n.count--,0===n.count&&(i.delete(e),0===i.size&&r.delete(t))}}function yn(t){un.has(t)&&un.get(t).forEach(e=>{e.tag=De(t,e.path,Ht(t),v(t)),e.lastRevision=at(e.tag)}),cn.has(t)&&cn.get(t).forEach(e=>{e.tag=De(t,e.path,Ht(t),v(t)),e.lastRevision=at(e.tag)})}var vn=0;function bn(t){let e=at(wt);vn!==e&&(vn=e,un.forEach((e,n)=>{let r=v(n);e.forEach((e,i)=>{if(!lt(e.tag,e.lastRevision)){let s=()=>{try{rn(n,i,[n,e.path],void 0,r)}finally{e.tag=De(n,e.path,Ht(n),v(n)),e.lastRevision=at(e.tag)}};t?t("actions",s):s()}})}))}function wn(){cn.forEach((t,e)=>{let n=v(e);t.forEach((t,r)=>{if(!t.suspended&&!lt(t.tag,t.lastRevision))try{t.suspended=!0,rn(e,r,[e,t.path],void 0,n)}finally{t.tag=De(e,t.path,Ht(e),v(e)),t.lastRevision=at(t.tag),t.suspended=!1}})})}function _n(t,e,n){let r=cn.get(t);if(!r)return;let i=r.get(an(e));i&&(i.suspended=n)}var xn=()=>{},{toString:Cn}=Object.prototype,{toString:kn}=Function.prototype,{isArray:Sn}=Array,{keys:En}=Object,{stringify:Rn}=JSON,Tn=100,Ln=/^[\w$]+$/;function Pn(t){return"number"==typeof t&&2===arguments.length?this:In(t,0)}function In(t,e,n){let r=!1;switch(typeof t){case"undefined":return"undefined";case"object":if(null===t)return"null";if(Sn(t)){r=!0;break}if(t.toString===Cn||void 0===t.toString)break;return t.toString();case"function":return t.toString===kn?t.name?`[Function:${t.name}]`:"[Function]":t.toString();case"string":return Rn(t);default:return t.toString()}if(void 0===n)n=new WeakSet;else if(n.has(t))return"[Circular]";return n.add(t),r?function(t,e,n){if(e>4)return"[Array]";let r="[";for(let i=0;i=Tn){r+=`... ${t.length-Tn} more items`;break}r+=In(t[i],e,n)}return r+=" ]",r}(t,e+1,n):function(t,e,n){if(e>4)return"[Object]";let r="{",i=En(t);for(let s=0;s=Tn){r+=`... ${i.length-Tn} more keys`;break}let o=i[s];xn(),r+=`${Mn(String(o))}: ${In(t[o],e,n)}`}return r+=" }",r}(t,e+1,n)}function Mn(t){return Ln.test(t)?t:Rn(t)}var An=/\.@each$/;function On(t,e){let n=t.indexOf("{");n<0?e(t.replace(An,".[]")):Fn("",t,n,e)}function Fn(t,e,n,r){let i,s,o=e.indexOf("}"),a=0,l=e.substring(n+1,o).split(","),c=e.substring(o+1);for(t+=e.substring(0,n),s=l.length;a0&&this._property(...t)}setup(t,e,n,r){if(super.setup(t,e,n,r),!1===this._hasConfig){let{get:t,set:e}=n;void 0!==t&&(this._getter=t),void 0!==e&&(this._setter=function(n,r){let i=e.call(this,r);return void 0!==t&&void 0===i?t.call(this):i})}}_property(...t){let e=[];function n(t){e.push(t)}for(let r of t)On(r,n);this._dependentKeys=e}get(t,e){let n,r=b(t),i=Ht(t),s=Gt(t,e,i),o=r.revisionFor(e);if(void 0!==o&<(s,o))n=r.valueFor(e);else{let{_getter:o,_dependentKeys:a}=this;qt(()=>{n=o.call(t,e)}),void 0!==a&&dt(s,ze(t,a,i,r)),r.setValueFor(e,n),r.setRevisionFor(e,at(s)),Ne(r,e,n)}return Ot(s),Array.isArray(n)&&Ot(Gt(n,"[]")),n}set(t,e,n){this._readOnly&&this._throwReadOnlyError(t,e);let r,i=b(t);i.isInitializing()&&void 0!==this._dependentKeys&&this._dependentKeys.length>0&&"function"==typeof t[jn]&&t.isComponent&&hn(t,e,()=>{t[jn](e)},void 0,!0);try{$n(),r=this._set(t,e,n,i),Ne(i,e,r);let s=Ht(t),o=Gt(t,e,s),{_dependentKeys:a}=this;void 0!==a&&dt(o,ze(t,a,s,i)),i.setRevisionFor(e,at(o))}finally{qn()}return r}_throwReadOnlyError(t,e){throw new Error(`Cannot set read-only property "${e}" on object: ${Pn(t)}`)}_set(t,e,n,r){let i,s=void 0!==r.revisionFor(e),o=r.valueFor(e),{_setter:a}=this;_n(t,e,!0);try{i=a.call(t,e,n,o)}finally{_n(t,e,!1)}return s&&o===i||(r.setValueFor(e,i),Bn(t,e,r,n)),i}teardown(t,e,n){void 0!==n.revisionFor(e)&&(n.setRevisionFor(e,void 0),n.setValueFor(e,void 0)),super.teardown(t,e,n)}},Gn=class extends Hn{get(t,e){let n,r=b(t),i=Ht(t),s=Gt(t,e,i),o=r.revisionFor(e);if(void 0!==o&<(s,o))n=r.valueFor(e);else{let{_getter:i}=this,o=$t(()=>{n=i.call(t,e)});dt(s,o),r.setValueFor(e,n),r.setRevisionFor(e,at(s)),Ne(r,e,n)}return Ot(s),Array.isArray(n)&&Ot(Gt(n,"[]",i)),n}},Kn=class extends Function{readOnly(){return P(this)._readOnly=!0,this}meta(t){let e=P(this);return 0===arguments.length?e._meta||{}:(e._meta=t,this)}get _getter(){return P(this)._getter}set enumerable(t){P(this).enumerable=t}};function Zn(...t){return _(t)?R(new Hn([]),Kn)(t[0],t[1],t[2]):R(new Hn(t),Kn)}function Yn(...t){return R(new Gn(t),Kn)}function Xn(t,e){return Boolean(L(t,e))}function Jn(t,e){let n=v(t);return n?n.valueFor(e):void 0}var Qn=new WeakSet;function tr(t){return!!Kt(t)&&Qn.has(t)}function er(t){Kt(t)&&Qn.add(t)}var nr=new WeakSet;function rr(t){return nr.has(t)}var ir=class{size=0;misses=0;hits=0;constructor(t,e,n=new Map){this.limit=t,this.func=e,this.store=n}get(t){return this.store.has(t)?(this.hits++,this.store.get(t)):(this.misses++,this.set(t,this.func(t)))}set(t,e){return this.limit>this.size&&(this.size++,this.store.set(t,e)),e}purge(){this.store.clear(),this.size=0,this.hits=0,this.misses=0}},sr=new ir(1e3,t=>t.indexOf("."));function or(t){return"string"==typeof t&&-1!==sr.get(t)}var ar=Symbol("PROXY_CONTENT");function lr(t){return"object"==typeof t&&null!==t&&"function"==typeof t.unknownProperty}function cr(t,e){return or(e)?hr(t,e):ur(t,e)}function ur(t,e){if(null==t)return;let n;return"object"==typeof t||"function"==typeof t?(n=t[e],void 0===n&&"object"==typeof t&&!(e in t)&&lr(t)&&(n=t.unknownProperty(e)),At()&&(Ot(Gt(t,e)),(Array.isArray(n)||rr(n))&&Ot(Gt(n,"[]")))):n=t[e],n}function hr(t,e,n){let r="string"==typeof e?e.split("."):e;for(let i of r){if(null==t||t.isDestroyed)return;if(n&&("__proto__"===i||"constructor"===i))return;t=ur(t,i)}return t}ur("foo","a"),ur("foo",1),ur({},"a"),ur({},1),ur({unknownProperty(){}},"a"),ur({unknownProperty(){}},1),cr({},"foo"),cr({},"foo.bar");var dr={};function pr(t,e){let n=t;do{let t=Object.getOwnPropertyDescriptor(n,e);if(void 0!==t)return t;n=Object.getPrototypeOf(n)}while(null!==n);return null}function fr(t,e,n,r){return t.isDestroyed?n:or(e)?function(t,e,n,r){let i=e.split("."),s=i.pop(),o=hr(t,i,!0);if(null!=o)return fr(o,s,n);if(!r)throw new Error(`Property set failed: object in path "${i.join(".")}" could not be found.`)}(t,e,n,r):gr(t,e,n)}function gr(t,e,n){let r,i=pr(t,e);return null!==i&&E.has(i.set)?(t[e]=n,n):(r=t[e],void 0!==r||"object"!=typeof t||e in t||"function"!=typeof t.setUnknownProperty?(t[e]=n,r!==n&&Bn(t,e)):t.setUnknownProperty(e,n),n)}function mr(t,e,n){return fr(t,e,n,!0)}function yr(t){return R(new br(t),vr)}er(dr),$t(()=>ur({},"a")),$t(()=>ur({},1)),$t(()=>ur({a:[]},"a")),$t(()=>ur({a:dr},"a"));var vr=class extends Function{readOnly(){return P(this).readOnly(),this}oneWay(){return P(this).oneWay(),this}meta(t){let e=P(this);if(0===arguments.length)return e._meta||{};e._meta=t}},br=class extends C{altKey;constructor(t){super(),this.altKey=t}setup(t,e,n,r){super.setup(t,e,n,r),Fe.add(this)}get(t,e){let n,r=b(t),i=Ht(t),s=Gt(t,e,i);qt(()=>{n=cr(t,this.altKey)});let o=r.revisionFor(e);return void 0!==o&<(s,o)||(dt(s,De(t,this.altKey,i,r)),r.setRevisionFor(e,at(s)),Ne(r,e,n)),Ot(s),n}set(t,e,n){return fr(t,this.altKey,n)}readOnly(){this.set=wr}oneWay(){this.set=_r}};function wr(t,e){throw new Error(`Cannot set read-only property '${e}' on object: ${Pn(t)}`)}function _r(t,e,n){return Nn(t,e,null),fr(t,e,n)}function xr(t,e,n,r){return void 0===e?(e=0,n=r=-1):(void 0===n&&(n=-1),void 0===r&&(r=-1)),rn(t,"@array:before",[t,e,n,r]),t}function Cr(t,e,n,r,i=!0){void 0===e?(e=0,n=r=-1):(void 0===n&&(n=-1),void 0===r&&(r=-1));let s=v(t);if(i&&((r<0||n<0||r-n!==0)&&Bn(t,"length",s),Bn(t,"[]",s)),rn(t,"@array:change",[t,e,n,r]),null!==s){let i=-1===n?0:n,o=t.length-((-1===r?0:r)-i),a=e<0?o+e:e;void 0!==s.revisionFor("firstObject")&&0===a&&Bn(t,"firstObject",s),void 0!==s.revisionFor("lastObject")&&o-1Mr}),Mr="7.2.0",Ar=class{_registry;_coreLibIndex;constructor(){this._registry=[],this._coreLibIndex=0}_getLibraryByName(t){let e=this._registry;for(let n of e)if(n.name===t)return n}register(t,e,n){let r=this._registry.length;this._getLibraryByName(t)||(n&&(r=this._coreLibIndex++),this._registry.splice(r,0,{name:t,version:e}))}registerCoreLibrary(t,e){this.register(t,e,!0)}deRegister(t){let e,n=this._getLibraryByName(t);n&&(e=this._registry.indexOf(n),this._registry.splice(e,1))}},Or=new Ar;function Fr(t,e){let n,r={},i=1;for(2===arguments.length&&Array.isArray(e)?(i=0,n=arguments[1]):n=Array.from(arguments);i{let n=Object.keys(e);for(let r of n)fr(t,r,e[r])}),e}Or.registerCoreLibrary("Ember",Mr);var zr=Symbol("OWNER");function Dr(t){return t[zr]}function jr(t){return Dr(t)}function Ur(t,e){!function(t,e){t[zr]=e}(t,e)}function Br(t,...e){let n,r;_(e)?n=e:"string"==typeof e[0]&&(r=e[0]);let i=Zn({get:function(e){return(jr(this)||this.container).lookup(`${t}:${r||e}`)},set(t,e){Nn(this,t,null,e)}});return n?i(n[0],n[1],n[2]):i}function $r(t,e){let n=new WeakMap,r="function"==typeof e;return{getter:function(i){let s;return Ot(Gt(i,t)),r&&!n.has(i)?(s=e.call(i),n.set(i,s)):s=n.get(i),s},setter:function(e,r){Wt(e,t),n.set(e,r)}}}function qr(...t){if(!_(t)){let e=t[0],n=e?e.initializer:void 0,r=e?e.value:void 0,i=function(t,e){return Vr([t,e,{initializer:n||(()=>r)}])};return M(i),i}return Vr(t)}function Vr([t,e,n]){let{getter:r,setter:i}=$r(e,n?n.initializer:void 0);function s(){let t=r(this);return(Array.isArray(t)||rr(t))&&Ot(Gt(t,"[]")),t}function o(t){i(this,t),Wt(this,Ie)}let a={enumerable:!0,configurable:!0,isTracked:!0,get:s,set:o};return E.add(o),b(t).writeDescriptors(e,new Wr(s,o)),a}var Wr=class{constructor(t,e){this._get=t,this._set=e,Fe.add(this)}get(t){return this._get.call(t)}set(t,e,n){this._set.call(t,n)}},Hr=(...t)=>{const[e,n,r]=t,i=new WeakMap,s=r.get;r.get=function(){return i.has(this)||i.set(this,jt(s.bind(this))),Ut(i.get(this))}},Gr=a({ENV:()=>A,context:()=>Yr,getENV:()=>F,getLookup:()=>Xr,setLookup:()=>Jr}),Kr=globalThis,Zr=Kr.Ember,Yr=void 0===Zr?{imports:Kr,exports:Kr,lookup:Kr}:{imports:Zr.imports||Kr,exports:Zr.exports||Kr,lookup:Zr.lookup||Kr};function Xr(){return Yr.lookup}function Jr(t){Yr.lookup=t}var Qr=new WeakMap;function ti(t,e){Kt(t)&&Qr.set(t,e)}function ei(t){return Qr.get(t)}var ni=Object.prototype.hasOwnProperty,ri=!1,ii={_set:0,_unprocessedNamespaces:!1,get unprocessedNamespaces(){return this._unprocessedNamespaces},set unprocessedNamespaces(t){this._set++,this._unprocessedNamespaces=t}},si=!1,oi=[],ai=Object.create(null);function li(t){ii.unprocessedNamespaces=!0,oi.push(t)}function ci(t){let e=ei(t);delete ai[e],oi.splice(oi.indexOf(t),1),e in Yr.lookup&&t===Yr.lookup[e]&&(Yr.lookup[e]=void 0)}function ui(){if(!ii.unprocessedNamespaces)return;let t=Yr.lookup,e=Object.keys(t);for(let n of e){if(!bi(n.charCodeAt(0)))continue;let e=wi(t,n);e&&ti(e,n)}}function hi(t){return ri||pi(),ai[t]}function di(t){yi([t.toString()],t,new Set)}function pi(){let t=ii.unprocessedNamespaces;if(t&&(ui(),ii.unprocessedNamespaces=!1),t||si){let t=oi;for(let e of t)di(e);si=!1}}function fi(){return ri}function gi(t){ri=Boolean(t)}function mi(){si=!0}function yi(t,e,n){let r=t.length,i=t.join(".");ai[i]=e,ti(e,i);for(let s in e){if(!ni.call(e,s))continue;let i=e[s];if(t[r]=s,i&&void 0===ei(i))ti(i,t.join("."));else if(i&&vi(i)){if(n.has(i))continue;n.add(i),yi(t,i,n)}}t.length=r}function vi(t){return null!=t&&"object"==typeof t&&t.isNamespace}function bi(t){return t>=65&&t<=90}function wi(t,e){try{let n=t[e];return(null!==n&&"object"==typeof n||"function"==typeof n)&&n.isNamespace&&n}catch(n){}}var _i=a({ASYNC_OBSERVERS:()=>un,ComputedDescriptor:()=>C,ComputedProperty:()=>Hn,DEBUG_INJECTION_FUNCTIONS:()=>{},Libraries:()=>Ar,NAMESPACES:()=>oi,NAMESPACES_BY_ID:()=>ai,PROPERTY_DID_CHANGE:()=>jn,PROXY_CONTENT:()=>ar,SYNC_OBSERVERS:()=>cn,TrackedDescriptor:()=>Wr,_getPath:()=>hr,_getProp:()=>ur,_setProp:()=>gr,activateObserver:()=>pn,addArrayObserver:()=>Lr,addListener:()=>en,addNamespace:()=>li,addObserver:()=>hn,alias:()=>yr,arrayContentDidChange:()=>Cr,arrayContentWillChange:()=>xr,autoComputed:()=>Yn,beginPropertyChanges:()=>$n,cached:()=>Hr,changeProperties:()=>Vn,computed:()=>Zn,createCache:()=>jt,defineDecorator:()=>zn,defineProperty:()=>Nn,defineValue:()=>Dn,deprecateProperty:()=>xi,descriptorForDecorator:()=>P,descriptorForProperty:()=>L,eachProxyArrayDidChange:()=>Si,eachProxyArrayWillChange:()=>ki,endPropertyChanges:()=>qn,expandProperties:()=>On,findNamespace:()=>hi,findNamespaces:()=>ui,flushAsyncObservers:()=>bn,get:()=>cr,getCachedValueFor:()=>Jn,getProperties:()=>Fr,getValue:()=>Ut,hasListeners:()=>sn,hasUnknownProperty:()=>lr,inject:()=>Br,isClassicDecorator:()=>I,isComputed:()=>Xn,isConst:()=>Bt,isElementDescriptor:()=>_,isNamespaceSearchDisabled:()=>fi,libraries:()=>Or,makeComputedDecorator:()=>R,markObjectAsDirty:()=>Oe,nativeDescDecorator:()=>x,notifyPropertyChange:()=>Bn,objectAt:()=>Pe,on:()=>on,processAllNamespaces:()=>pi,processNamespace:()=>di,removeArrayObserver:()=>Pr,removeListener:()=>nn,removeNamespace:()=>ci,removeObserver:()=>dn,replace:()=>Sr,replaceInNativeArray:()=>Rr,revalidateObservers:()=>yn,sendEvent:()=>rn,set:()=>fr,setClassicDecorator:()=>M,setNamespaceSearchDisabled:()=>gi,setProperties:()=>Nr,setUnprocessedMixins:()=>mi,tagForObject:()=>Ae,tagForProperty:()=>Me,tracked:()=>qr,trySet:()=>mr});function xi(t,e,n){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,set(t){fr(this,n,t)},get(){return cr(this,n)}})}var Ci=new WeakMap;function ki(t,e,n,r){let i=Ci.get(t);void 0!==i&&i.arrayWillChange(t,e,n,r)}function Si(t,e,n,r){let i=Ci.get(t);void 0!==i&&i.arrayDidChange(t,e,n,r)}var Ei={get onerror(){}},Ri=setTimeout,Ti=()=>{};function Li(t){if("function"==typeof Promise){const e=Promise.resolve();return()=>e.then(t)}if("function"==typeof MutationObserver){let e=0,n=new MutationObserver(t),r=document.createTextNode("");return n.observe(r,{characterData:!0}),()=>(e=++e%2,r.data=""+e,e)}return()=>Ri(t,0)}function Pi(t){let e=Ti;return{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),now:()=>Date.now(),next:Li(t),clearNext:e}}var Ii=/\d+/;function Mi(t){let e=typeof t;return"number"===e&&t==t||"string"===e&&Ii.test(t)}function Ai(t){return t.onError||t.onErrorTarget&&t.onErrorTarget[t.onErrorMethod]}function Oi(t,e,n){let r=-1;for(let i=0,s=n.length;i=e[n]?i=n+6:s=n;return t>=e[i]?i+6:i}var Di=class{constructor(t,e={},n={}){this._queueBeingFlushed=[],this.targetQueues=new Map,this.index=0,this._queue=[],this.name=t,this.options=e,this.globalOptions=n}stackFor(t){if(t0){let t=Ai(this.globalOptions);s=t?this.invokeWithOnError:this.invoke;for(let o=this.index;o0&&this.flush(!0)}hasWork(){return this._queueBeingFlushed.length>0||this._queue.length>0}cancel({target:t,method:e}){let n=this._queue,r=this.targetQueues.get(t);void 0!==r&&r.delete(e);let i=Oi(t,e,n);return i>-1?(n[i+1]=null,!0):(n=this._queueBeingFlushed,i=Oi(t,e,n),i>-1&&(n[i+1]=null,!0))}push(t,e,n,r){return this._queue.push(t,e,n,r),{queue:this,target:t,method:e}}pushUnique(t,e,n,r){let i=this.targetQueues.get(t);void 0===i&&(i=new Map,this.targetQueues.set(t,i));let s=i.get(e);if(void 0===s){let s=this._queue.push(t,e,n,r)-4;i.set(e,s)}else{let t=this._queue;t[s+2]=n,t[s+3]=r}return{queue:this,target:t,method:e}}_getDebugInfo(t){if(t)return Ni(this._queue,4)}invoke(t,e,n){void 0===n?e.call(t):e.apply(t,n)}invokeWithOnError(t,e,n,r,i){try{void 0===n?e.call(t):e.apply(t,n)}catch(Z4){r(Z4,i)}}},ji=class{constructor(t=[],e){this.queues={},this.queueNameIndex=0,this.queueNames=t,t.reduce(function(t,n){return t[n]=new Di(n,e[n],e),t},this.queues)}schedule(t,e,n,r,i,s){let o=this.queues[t];if(void 0===o)throw new Error(`You attempted to schedule an action in a queue (${t}) that doesn't exist`);if(null==n)throw new Error(`You attempted to schedule an action in a queue (${t}) for a method that doesn't exist`);return this.queueNameIndex=0,i?o.pushUnique(e,n,r,s):o.push(e,n,r,s)}flush(t=!1){let e,n,r=this.queueNames.length;for(;this.queueNameIndexi){let e=r-i;t=new Array(e);for(let n=0;n{cs++,!1!==this._autorun&&(this._autorun=!1,this._autorunStack=null,this._end(!0))};let n=this.options._buildPlatform||Pi;this._platform=n(this._boundAutorunEnd)}get counters(){return{begin:Hi,end:Gi,events:{begin:Ki,end:0},autoruns:{created:ls,completed:cs},run:Zi,join:Yi,defer:Xi,schedule:Ji,scheduleIterable:Qi,deferOnce:ts,scheduleOnce:es,setTimeout:ns,later:rs,throttle:is,debounce:ss,cancelTimers:os,cancel:as,loops:{total:us,nested:hs}}}get defaultQueue(){return this._defaultQueue}begin(){Hi++;let t,e=this.options,n=this.currentInstance;return!1!==this._autorun?(t=n,this._cancelAutorun()):(null!==n&&(hs++,this.instanceStack.push(n)),us++,t=this.currentInstance=new ji(this.queueNames,e),Ki++,this._trigger("begin",t,n)),this._onBegin(t,n),t}end(){Gi++,this._end(!1)}on(t,e){if("function"!=typeof e)throw new TypeError("Callback must be a function");let n=this._eventCallbacks[t];if(void 0===n)throw new TypeError(`Cannot on() event ${t} because it does not exist`);n.push(e)}off(t,e){let n=this._eventCallbacks[t];if(!t||void 0===n)throw new TypeError(`Cannot off() event ${t} because it does not exist`);let r=!1;if(e)for(let i=0;i0&&Mi(n[i-1])&&(r=parseInt(n.pop(),10)),[t,e,n,r]}(...arguments);return this._later(t,e,n,r)}throttle(){is++;let t,[e,n,r,i,s=!0]=Vi(...arguments),o=Fi(e,n,this._timers);if(-1===o)t=this._later(e,n,s?$i:r,i),s&&this._join(e,n,r);else{t=this._timers[o+1];let e=o+4;this._timers[e]!==$i&&(this._timers[e]=r)}return t}debounce(){ss++;let t,[e,n,r,i,s=!1]=Vi(...arguments),o=this._timers,a=Fi(e,n,o);if(-1===a)t=this._later(e,n,s?$i:r,i),s&&this._join(e,n,r);else{let s=this._platform.now()+i,l=a+4;o[l]===$i&&(r=$i),t=o[a+1];let c=zi(s,o);if(a+6===c)o[a]=s,o[l]=r;else{let i=this._timers[a+5];this._timers.splice(c,0,s,t,e,n,r,i),this._timers.splice(a,6)}0===a&&this._reinstallTimerTimeout()}return t}cancelTimers(){os++,this._clearTimerTimeout(),this._timers=[],this._cancelAutorun()}hasTimers(){return this._timers.length>0||this._autorun}cancel(t){if(as++,null==t)return!1;let e=typeof t;return"number"===e?this._cancelLaterTimer(t):!("object"!==e||!t.queue||!t.method)&&t.queue.cancel(t)}ensureInstance(){this._ensureInstance()}getDebugInfo(){if(this.DEBUG)return{autorun:this._autorunStack,counters:this.counters,timers:Ni(this._timers,6,2),instanceStack:[this.currentInstance,...this.instanceStack].map(t=>t&&t._getDebugInfo(this.DEBUG))}}_end(t){let e=this.currentInstance,n=null;if(null===e)throw new Error("end called without begin");let r,i=!1;try{r=e.flush(t)}finally{if(!i)if(i=!0,1===r){const t=this.queueNames[e.queueNameIndex];this._scheduleAutorun(t)}else this.currentInstance=null,this.instanceStack.length>0&&(n=this.instanceStack.pop(),this.currentInstance=n),this._trigger("end",e,n),this._onEnd(e,n)}}_join(t,e,n){return null===this.currentInstance?this._run(t,e,n):void 0===t&&void 0===n?e():e.apply(t,n)}_run(t,e,n){let r=Ai(this.options);if(this.begin(),r)try{return e.apply(t,n)}catch(Z4){r(Z4)}finally{this.end()}else try{return e.apply(t,n)}finally{this.end()}}_cancelAutorun(){this._autorun&&(this._platform.clearNext(),this._autorun=!1,this._autorunStack=null)}_later(t,e,n,r){let i=this.DEBUG?new Error:void 0,s=this._platform.now()+r,o=Wi++;if(0===this._timers.length)this._timers.push(s,o,t,e,n,i),this._installTimerTimeout();else{let r=zi(s,this._timers);this._timers.splice(r,0,s,o,t,e,n,i),this._reinstallTimerTimeout()}return o}_cancelLaterTimer(t){for(let e=1;e0&&(this.begin(),this._scheduleExpiredTimers(),this.end())}_scheduleExpiredTimers(){let t=this._timers,e=0,n=t.length,r=this._defaultQueue,i=this._platform.now();for(;ei);e+=6){let n=t[e+4];if(n!==$i){let i=t[e+2],s=t[e+3],o=t[e+5];this.currentInstance.schedule(r,i,s,n,!1,o)}}t.splice(0,e),this._installTimerTimeout()}_reinstallTimerTimeout(){this._clearTimerTimeout(),this._installTimerTimeout()}_clearTimerTimeout(){null!==this._timerTimeoutId&&(this._platform.clearTimeout(this._timerTimeoutId),this._timerTimeoutId=null)}_installTimerTimeout(){if(0===this._timers.length)return;let t=this._timers[0],e=this._platform.now(),n=Math.max(0,t-e);this._timerTimeoutId=this._platform.setTimeout(this._boundRunExpiredTimers,n)}_ensureInstance(){let t=this.currentInstance;return null===t&&(this._autorunStack=this.DEBUG?new Error:void 0,t=this.begin(),this._scheduleAutorun(this.queueNames[0])),t}_scheduleAutorun(t){ls++;const e=this._platform.next,n=this.options.flush;n?n(t,e):e(),this._autorun=!0}};ds.Queue=Di,ds.buildPlatform=Pi,ds.buildNext=Li;var ps=a({_backburner:()=>vs,_cancelTimers:()=>Es,_getCurrentRunLoop:()=>gs,_hasScheduledTimers:()=>Ss,_queues:()=>ys,_rsvpErrorQueue:()=>ms,begin:()=>xs,bind:()=>_s,cancel:()=>Is,debounce:()=>Ms,end:()=>Cs,join:()=>ws,later:()=>Rs,next:()=>Ps,once:()=>Ts,run:()=>bs,schedule:()=>ks,scheduleOnce:()=>Ls,throttle:()=>As}),fs=null;function gs(){return fs}var ms=`${Math.random()}${Date.now()}`.replace(".",""),ys=["actions","routerTransitions","render","afterRender","destroy",ms],vs=new ds(ys,{defaultQueue:"actions",onBegin:function(t){fs=t},onEnd:function(t,e){fs=e,bn(ks)},onErrorTarget:Ei,onErrorMethod:"onerror",flush:function(t,e){"render"!==t&&t!==ms||bn(ks),e()}});function bs(...t){return vs.run(...t)}function ws(t,e,...n){return vs.join(t,e,...n)}function _s(...t){return(...e)=>ws(...t.concat(e))}function xs(){vs.begin()}function Cs(){vs.end()}function ks(...t){return vs.schedule(...t)}function Ss(){return vs.hasTimers()}function Es(){vs.cancelTimers()}function Rs(...t){return vs.later(...t)}function Ts(...t){return vs.scheduleOnce("actions",...t)}function Ls(...t){return vs.scheduleOnce(...t)}function Ps(...t){return vs.later(...t,1)}function Is(t){return vs.cancel(t)}function Ms(...t){return vs.debounce(...t)}function As(...t){return vs.throttle(...t)}var Os=new Set([Symbol.iterator,"concat","entries","every","filter","find","findIndex","flat","flatMap","forEach","includes","indexOf","join","keys","lastIndexOf","map","reduce","reduceRight","slice","some","values"]),Fs=new Set(["fill","push","unshift"]);function Ns(t){if("symbol"==typeof t)return null;const e=Number(t);return isNaN(e)?null:e%1==0?e:null}var zs=class t{#t;constructor(e,n){this.#t=n;const r=e.slice(),i=this,s=new Map;let o=!1;return new Proxy(r,{get(t,e){const n=Ns(e);if(null!==n)return i.#e(n),Ot(i.#n),t[n];if("length"===e)return o?o=!1:Ot(i.#n),t[e];if(Fs.has(e)&&(o=!0),Os.has(e)){let n=s.get(e);return void 0===n&&(n=(...n)=>(Ot(i.#n),t[e](...n)),s.set(e,n)),n}return t[e]},set(t,e,n){if(i.#t.equals(t[e],n))return!0;t[e]=n;const r=Ns(e);return null!==r?(i.#r(r),i.#i()):"length"===e&&i.#i(),!0},getPrototypeOf:()=>t.prototype})}#n=ft();#s=new Map;#e(t){let e=this.#s.get(t);void 0===e&&(e=ft(),this.#s.set(t,e)),Ot(e)}#r(t){const e=this.#s.get(t);e&&ht(e)}#i(){ht(this.#n),this.#s.clear()}};function Ds(t,e){return new zs(t??[],{equals:e?.equals??Object.is,description:e?.description})}Object.setPrototypeOf(zs.prototype,Array.prototype);var js=class t{#t;#s=new Map;#n=ft();#e(t){let e=this.#s.get(t);void 0===e&&(e=ft(),this.#s.set(t,e)),Ot(e)}#r(t){const e=this.#s.get(t);e&&ht(e)}#i(){ht(this.#n)}constructor(e,n){this.#t=n;const r=Object.getPrototypeOf(e),i=Object.getOwnPropertyDescriptors(e),s=Object.create(r);for(const t in i)Object.defineProperty(s,t,i[t]);const o=this;return new Proxy(s,{get:(t,e)=>(o.#e(e),t[e]),has:(t,e)=>(o.#e(e),e in t),ownKeys:t=>(Ot(o.#n),Reflect.ownKeys(t)),set:(t,e,n)=>(o.#t.equals(t[e],n)||(t[e]=n,o.#r(e),o.#i()),!0),deleteProperty:(t,e)=>(e in t&&(delete t[e],o.#r(e),o.#s.delete(e),o.#i()),!0),getPrototypeOf:()=>t.prototype})}};function Us(t,e){return new js(t??{},{equals:e?.equals??Object.is,description:e?.description})}function Bs(t,e){const n=e?.equals??Object.is,r=new Set(t??[]),i=ft(),s=new Map;function o(t){const e=s.get(t);e&&ht(e)}const a=new Proxy(r,{get(t,e,r){if("add"===e)return function(e){if(t.has(e)){if(n(e,e))return a}else ht(i);return o(e),t.add(e),a};if("delete"===e)return function(e){return!!t.has(e)&&(o(e),ht(i),s.delete(e),t.delete(e))};if("clear"===e)return function(){0!==t.size&&(s.forEach(t=>ht(t)),ht(i),s.clear(),t.clear())};if("has"===e)return function(e){return Ot(function(t){let e=s.get(t);return void 0===e&&(e=ft(),s.set(t,e)),e}(e)),t.has(e)};if("size"===e)return Ot(i),t.size;const l=Reflect.get(t,e,r);return"function"==typeof l?function(...e){return Ot(i),l.apply(t,e)}:l}});return a}function $s(t,e){const n=e?.equals??Object.is,r=new WeakSet(t??[]),i=new WeakMap;function s(t){const e=i.get(t);e&&ht(e)}const o=new Proxy(r,{get(t,e,r){if("add"===e)return function(e){return t.has(e)&&n(e,e)||(t.add(e),s(e)),o};if("delete"===e)return function(e){return!!t.has(e)&&(s(e),i.delete(e),t.delete(e))};if("has"===e)return function(e){return Ot(function(t){let e=i.get(t);return void 0===e&&(e=ft(),i.set(t,e)),e}(e)),t.has(e)};const a=Reflect.get(t,e,r);return"function"==typeof a?a.bind(t):a}});return o}function qs(t,e){const n=e?.equals??Object.is,r=t instanceof Map?new Map(t.entries()):new Map(t??[]),i=ft(),s=new Map;function o(t){let e=s.get(t);return void 0===e&&(e=ft(),s.set(t,e)),e}function a(t){const e=s.get(t);e&&ht(e)}const l=new Proxy(r,{get(t,e,r){if("set"===e)return function(e,r){return t.has(e)&&n(t.get(e),r)||(a(e),ht(i),t.set(e,r)),l};if("delete"===e)return function(e){return!!t.has(e)&&(a(e),ht(i),s.delete(e),t.delete(e))};if("clear"===e)return function(){0!==t.size&&(s.forEach(t=>ht(t)),s.clear(),ht(i),t.clear())};if("get"===e)return function(e){return Ot(o(e)),t.get(e)};if("has"===e)return function(e){return Ot(o(e)),t.has(e)};if("size"===e)return Ot(i),t.size;const c=Reflect.get(t,e,r);return"function"==typeof c?function(...e){return Ot(i),c.apply(t,e)}:c}});return l}function Vs(t,e){const n=e?.equals??Object.is,r=t??[],i=r instanceof WeakMap?r:new WeakMap(r),s=new WeakMap;function o(t){let e=s.get(t);return void 0===e&&(e=ft(),s.set(t,e)),e}function a(t){const e=s.get(t);e&&ht(e)}const l=new Proxy(i,{get(t,e,r){if("set"===e)return function(e,r){return t.has(e)&&n(t.get(e),r)||(a(e),t.set(e,r)),l};if("delete"===e)return function(e){return!!t.has(e)&&(a(e),s.delete(e),t.delete(e))};if("get"===e)return function(e){return Ot(o(e)),t.get(e)};if("has"===e)return function(e){return Ot(o(e)),t.has(e)};const i=Reflect.get(t,e,r);return"function"==typeof i?i.bind(t):i}});return l}var Ws=a({ALLOW_CYCLES:()=>{},COMPUTE:()=>ot,CONSTANT:()=>0,CONSTANT_TAG:()=>gt,CURRENT_TAG:()=>wt,CurrentTag:()=>bt,INITIAL:()=>1,VOLATILE:()=>NaN,VOLATILE_TAG:()=>vt,VolatileTag:()=>yt,beginTrackFrame:()=>Tt,beginUntrackFrame:()=>Pt,bump:()=>st,combine:()=>_t,consumeTag:()=>Ot,createCache:()=>jt,createTag:()=>pt,createUpdatableTag:()=>ft,debug:()=>Hs,dirtyTag:()=>ht,dirtyTagFor:()=>Wt,endTrackFrame:()=>Lt,endUntrackFrame:()=>It,getValue:()=>Ut,isConst:()=>Bt,isConstTag:()=>mt,isTracking:()=>At,resetTracking:()=>Mt,tagFor:()=>Gt,tagMetaFor:()=>Ht,track:()=>$t,trackedArray:()=>Ds,trackedData:()=>$r,trackedMap:()=>qs,trackedObject:()=>Us,trackedSet:()=>Bs,trackedWeakMap:()=>Vs,trackedWeakSet:()=>$s,untrack:()=>qt,updateTag:()=>dt,validateTag:()=>lt,valueForTag:()=>at}),Hs={},Gs=Symbol("GLIMMER_VALIDATOR_REGISTRATION");if(Reflect.has(globalThis,Gs))throw new Error("The `@glimmer/validator` library has been included twice in this application. It could be different versions of the package, or the same version included twice by mistake. `@glimmer/validator` depends on having a single copy of the package in use at any time in an application, even if they are the same version. You must dedupe your build to remove the duplicate packages in order to prevent this error.");Reflect.set(globalThis,Gs,!0);var Ks="@warp-drive/core",Zs=globalThis;Zs.__warpDrive_universalCache=Zs.__warpDrive_universalCache??{},Zs[Ks]=Zs[Ks]??{__version:"5.8.2"};var Ys=Zs[Ks],Xs=Ys.__warpDrive_ModuleScopedCaches??{};if(Ys.__warpDrive_hasOtherCopy)throw new Error("Multiple copies of WarpDrive detected, the application will malfunction.");function Js(t,e){return e}function Qs(t){return Xs[`(transient) ${t}`]??null}function to(t,e){return e}Ys.__warpDrive_hasOtherCopy=!0,to(0,Symbol.for("wd:skip-cache")),to(0,Symbol.for("wd:enable-hydration")),Js(0,Symbol("IS_FUTURE")),Js(0,Symbol("DOC")),Js(0,Symbol("FROZEN")),Js(0,Symbol.for("Collection"));var eo=to(0,new WeakMap);function no(t,e){eo.set(t,e)}to(0,new Map),Js(0,Symbol("IS_CACHE_HANDLER"));var ro=Js(0,Symbol("#[]"));function io(t,e){return Qs("signalHooks").createSignal(t,e)}Js(0,Symbol("#{}"));var so={isInitializer:!0};function oo(t){return"object"==typeof t&&null!==t&&Object.getPrototypeOf(t)===so}var ao=Js(0,Symbol("Signals"));function lo(t){return t[ao]||function(t){t[ao]=new Map}(t),t[ao]}function co(t,e,n,r){const i={key:n,context:e,signal:io(e,n),value:oo(r)?r.value.call(e):r,isStale:!1};return t.set(n,i),i}function uo(t,e){return t?.get(e)}function ho(t,e){return{enumerable:!0,configurable:!1,get(){const n=function(t,e,n,r){let i=uo(t,n);return i||(i=co(t,e,n,r)),function(t){Qs("signalHooks").consumeSignal(t)}(i.signal),i}(lo(this),this,t,e);return n.isStale=!1,n.value},set(n){const r=function(t,e,n,r){let i=uo(t,n);return i||(i=co(t,e,n,r)),i}(lo(this),this,t,e);var i;r.value!==n&&(r.value=n,(i=r)&&(i.isStale=!0,function(t){Qs("signalHooks").notifySignal(t)}(i.signal)))}}}function po(t,e,n){Object.defineProperty(t,e,ho(e,n))}function fo(t,e,n){const r=ho(e,n);r.enumerable=!1,Object.defineProperty(t,e,r)}function go(t,e,n){const r=n.get;return n.get=function(){const t=lo(this);let n=t.get(e);return n||(n=function(t,e,n,r){{const i=function(t,e,n){return Qs("signalHooks").createMemo(t,e,n)}(e,n,r);return t.set(n,i),i}}(t,this,e,r.bind(this))),n()},n}var mo=new WeakMap;function yo(t){return t instanceof DOMException&&"AbortError"===t.name}var vo=class{_stream=null;_future;_triggered=!1;_trigger(){if(this._triggered)return;this._triggered=!0;const t=this._future.getStream();t.sizeHint&&(this._sizeHint=t.sizeHint),this.promise=t.then(t=>t?async function(t,e){const n=e,r=t.getReader();let i=0,s=null!==n._stream&&n._stream.readable.locked,o=s,a=n._stream?.writable.getWriter();const l=[];for(n._isPending=!1,n._isStarted=!0,n._startTime=performance.now();;){const{value:t,done:e}=await r.read();if(e)break;if(i+=t.byteLength,n._bytesLoaded=i,n._lastPacketTime=performance.now(),s=s||null!==n._stream&&n._stream.readable.locked,s){if(!o){o=!0,a=n._stream.writable.getWriter();for(const t of l)await a.ready,await a.write(t);l.length=0}await a.ready,await a.write(t)}else l.push(t)}o?(await a.ready,await a.close()):n._stream&&(await n._stream.readable.cancel("The Stream Has Already Ended"),n._stream=null),n._endTime=performance.now(),n._isComplete=!0,n._isStarted=!1}(t,this):(this._isPending=!1,void(this._isComplete=!0)),t=>{this._isPending=!1,this._isStarted=!1,yo(t)&&(this._isCancelled=!0,this._isComplete=!0),this._isErrored=!0,this._error=t})}promise=null;get isPending(){return this._trigger(),this._isPending}get sizeHint(){return this._trigger(),this._sizeHint}get stream(){if(this._trigger(),!this._stream){if(this._isComplete||this._isCancelled||this._isErrored)return null;this._stream=new TransformStream}return this._stream.readable}get isStarted(){return this._trigger(),this._isStarted}get bytesLoaded(){return this._trigger(),this._bytesLoaded}get startTime(){return this._trigger(),this._startTime}get endTime(){return this._trigger(),this._endTime}get lastPacketTime(){return this._trigger(),this._lastPacketTime}get isComplete(){return this._trigger(),this._isComplete}get isCancelled(){return this._trigger(),this._isCancelled}get isErrored(){return this._trigger(),this._isErrored}get error(){return this._trigger(),this._error}get elapsedTime(){return(this.endTime||this.lastPacketTime)-this.startTime}get completedRatio(){return this.sizeHint?this.bytesLoaded/this.sizeHint:0}get remainingRatio(){return 1-this.completedRatio}get duration(){return this.endTime-this.startTime}get speed(){return this.bytesLoaded/(this.elapsedTime/1e3)}constructor(t){this._future=t}abort=()=>{this._future.abort()}};fo(vo.prototype,"_isPending",!0),fo(vo.prototype,"_isStarted",!1),fo(vo.prototype,"_isComplete",!1),fo(vo.prototype,"_isCancelled",!1),fo(vo.prototype,"_isErrored",!1),fo(vo.prototype,"_error",null),fo(vo.prototype,"_sizeHint",0),fo(vo.prototype,"_bytesLoaded",0),fo(vo.prototype,"_startTime",0),fo(vo.prototype,"_endTime",0),fo(vo.prototype,"_lastPacketTime",0);var bo={};function wo(t,e,n){const r=Object.assign({},e),i=Object.assign({},r.cacheOptions);return n?i.reload=!0:!1===n?(delete i.reload,i.backgroundReload=!0):(delete i.backgroundReload,delete i.reload),r.cacheOptions=i,t.request(r)}function _o(t,e,n){let r={...Object.getOwnPropertyDescriptor(t,e)};for(let i of n)r=i(t,e,r)||r;void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(t):void 0,r.initializer=void 0),Object.defineProperty(t,e,r)}po(bo,"reason",null),po(bo,"value",null),po(bo,"result",null),po(bo,"error",null),po(bo,"status","pending"),po(bo,"isPending",!0),po(bo,"isLoading",!0),po(bo,"isSuccess",!1),po(bo,"isError",!1),po(bo,"request",null),po(bo,"response",null),Object.defineProperty(bo,"isCancelled",{get(){return this.isError&&yo(this.reason)}}),Object.defineProperty(bo,"loadingState",{get(){return this._loadingState||(this._loadingState=new vo(this._request)),this._loadingState}});var xo=Symbol.dispose||Symbol.for("dispose"),Co=class{_requester;constructor(t,e){this._args=e,this.store=t,this._subscribedTo=null,this._subscription=null,this._intervalStart=null,this._invalidated=!1,this._nextInterval=null,this._requester=null,this.isDestroyed=!1,this[xo]=So,this._installListeners(),this._beginPolling()}async _beginPolling(){try{this.isIdle||await this.request}catch{}finally{this.isDestroyed||this._scheduleInterval()}}get isIdle(){const{request:t,query:e}=this._args;return Boolean(!t&&!e)}static{_o(this.prototype,"isIdle",[go])}get autorefreshTypes(){const{autorefresh:t}=this._args;let e;return e=!0===t?["online","invalid"]:"string"==typeof t?t.split(","):[],new Set(e)}static{_o(this.prototype,"autorefreshTypes",[go])}async _scheduleInterval(){const{autorefreshThreshold:t}=this._args;if("undefined"!=typeof window&&"number"==typeof t&&t>0&&this.autorefreshTypes.has("interval")&&null===this._intervalStart){if(this._latestRequest){try{await this._latestRequest}catch{}if(this.isDestroyed)return}this._intervalStart=Date.now(),this._nextInterval=setTimeout(()=>{this._maybeUpdate()},t)}}_clearInterval(){this._nextInterval&&(clearTimeout(this._nextInterval),this._intervalStart=null)}_updateSubscriptions(){if(this.isIdle)return;const t=this._request.lid;if(this._subscribedTo===t)return;this._removeSubscriptions();const e=this._getRequester();this._requester=e,t&&ko(e)&&(this._subscribedTo=t,this._subscription=e.notifications.subscribe(t,(n,r)=>{if(!this._isUpdating)switch(r){case"invalidated":this.autorefreshTypes.has("invalid")&&(this._invalidated=!0,this._maybeUpdate());break;case"state":{const n=e.requestManager._deduped.get(t)?.priority,r=this.reqState;n?n.blocking&&!r.isLoading?(this.isRefreshing=!1,this._maybeUpdate("policy",!0)):this.isRefreshing=!0:this.isRefreshing=!1}}}))}_removeSubscriptions(){const t=this._requester;this._subscription&&t&&ko(t)&&(t.notifications.unsubscribe(this._subscription),this._subscribedTo=null,this._subscription=null,this._requester=null)}_installListeners(){"undefined"!=typeof window&&(this.isOnline=window.navigator.onLine,this._unavailableStart=this.isOnline?null:Date.now(),this.isHidden="hidden"===document.visibilityState,this._onlineChanged=t=>{this.isOnline="online"===t.type,"offline"===t.type&&null===this._unavailableStart&&(this._unavailableStart=Date.now()),this._maybeUpdate()},this._backgroundChanged=()=>{const t="hidden"===document.visibilityState;this.isHidden=t,t&&null===this._unavailableStart&&(this._unavailableStart=Date.now()),this._maybeUpdate()},window.addEventListener("online",this._onlineChanged,{passive:!0,capture:!0}),window.addEventListener("offline",this._onlineChanged,{passive:!0,capture:!0}),document.addEventListener("visibilitychange",this._backgroundChanged,{passive:!0,capture:!0}))}_maybeUpdate(t,e){if(this.isIdle)return;const{reqState:n}=this;if(n.isPending)return;if(!Boolean(this.isOnline&&!this.isHidden&&(t||this.autorefreshTypes.size))){if(!e&&t&&"_invalidated"!==t)throw new Error("Reload not available: the network is not online or the tab is hidden");return}const{autorefreshTypes:r}=this;let i=this._invalidated||Boolean(t);if(!i&&r.has("online")){const{_unavailableStart:t}=this,{autorefreshThreshold:e}=this._args,n="number"==typeof e?e:3e4;i=Boolean(t&&Date.now()-t>n)}if(!i&&r.has("interval")){const{_intervalStart:t}=this,{autorefreshThreshold:e}=this._args;t&&"number"==typeof e&&e>0&&(i=Boolean(Date.now()-t>=e))}if(this._unavailableStart=null,this._invalidated=!1,i){this._clearInterval(),this._isUpdating=!0;const e=("_invalidated"===t?null:t)??this._args.autorefreshBehavior??"policy",r=this._getRequester();switch(n._request.requester||(n._request.requester=r),e){case"reload":this._latestRequest=n.reload();break;case"refresh":this._latestRequest=n.refresh();break;case"policy":this._latestRequest=n.refresh(!0)}"refresh"!==e&&(this._localRequest=this._latestRequest),this._scheduleInterval(),this._latestRequest.finally(()=>{this._isUpdating=!1})}}_getRequester(){return this._args.request?.requester?this._args.request.requester:this.store}retry=async()=>{this._maybeUpdate("reload"),await this._localRequest};refresh=async()=>{this._maybeUpdate("refresh"),await this._latestRequest};get errorFeatures(){return{isHidden:this.isHidden,isOnline:this.isOnline,retry:this.retry}}static{_o(this.prototype,"errorFeatures",[go])}get contentFeatures(){const t={isHidden:this.isHidden,isOnline:this.isOnline,reload:this.retry,refresh:this.refresh,isRefreshing:this.isRefreshing,latestRequest:this._latestRequest};return t.isRefreshing&&(t.abort=()=>{this._latestRequest?.abort()}),t}static{_o(this.prototype,"contentFeatures",[go])}get _request(){const{request:t,query:e}=this._args,{_localRequest:n,_originalRequest:r,_originalQuery:i}=this;return n&&t===r&&e===i?n:(this._originalQuery=e,this._originalRequest=t,t||this.store.request(e))}static{_o(this.prototype,"_request",[go])}get request(){{const t=this._request;return this._updateSubscriptions(),t}}static{_o(this.prototype,"request",[go])}get reqState(){return function(t){let e=mo.get(t);return e||(e=function(t){const e=(n=t,eo.get(n));var n;const r=Object.create(bo);return r._request=t,r.reload=()=>wo(t.requester,r.request,!0),r.refresh=(e=!1)=>wo(t.requester,r.request,!0===e&&null),e?e.isError?(r.error=e.result,r.reason=e.result,r.status="rejected",r.isError=!0,r.isPending=!1,r.isLoading=!1,r.request=e.result.request,r.response=e.result.response):(r.result=e.result.content,r.value=e.result.content,r.status="fulfilled",r.isSuccess=!0,r.isPending=!1,r.isLoading=!1,r.request=e.result.request,r.response=e.result.response):t.then(e=>{no(t,{isError:!1,result:e}),r.result=e.content,r.value=e.content,r.status="fulfilled",r.isSuccess=!0,r.isPending=!1,r.isLoading=!1,r.request=e.request,r.response=e.response},e=>{no(t,{isError:!0,result:e}),r.error=e,r.reason=e,r.status="rejected",r.isError=!0,r.isPending=!1,r.isLoading=!1,r.request=e.request,r.response=e.response}),r}(t),mo.set(t,e)),e}(this.request)}get result(){return this.reqState.result}};function ko(t){return"requestManager"in t}function So(){const t=this;t.isDestroyed=!0,t._removeSubscriptions(),"undefined"!=typeof window&&(t._clearInterval(),window.removeEventListener("online",t._onlineChanged,{passive:!0,capture:!0}),window.removeEventListener("offline",t._onlineChanged,{passive:!0,capture:!0}),document.removeEventListener("visibilitychange",t._backgroundChanged,{passive:!0,capture:!0}))}po(Co.prototype,"isOnline",!0),po(Co.prototype,"isHidden",!1),po(Co.prototype,"isRefreshing",!1),po(Co.prototype,"_localRequest",void 0),po(Co.prototype,"_latestRequest",void 0);var Eo={};po(Eo,"reason",null),po(Eo,"value",null),po(Eo,"result",null),po(Eo,"error",null),po(Eo,"status","pending"),po(Eo,"isPending",!0),po(Eo,"isLoading",!0),po(Eo,"isSuccess",!1),po(Eo,"isError",!1);var Ro=ht;!function(){const t=function(t){const e=t.wellknown.Array;return{createSignal:(t,n)=>n===e?[Me(t,n),Me(t,"length"),Me(t,"[]")]:Me(t,n),consumeSignal(t){if(Array.isArray(t))return Ot(t[0]),Ot(t[1]),void Ot(t[2]);Ot(t)},notifySignal(t){if(Array.isArray(t))return Ro(t[0]),Ro(t[1]),void Ro(t[2]);Ro(t)},createMemo:(t,e,n)=>{{const r=Me(t,e),i=jt(n);let s;const o=()=>{s=Ut(i)};return()=>{const t=$t(o);return dt(r,t),Ot(t),s}}},willSyncFlushWatchers:()=>!!vs.currentInstance&&!0!==vs._autorun,waitFor:async t=>t}}({wellknown:{Array:ro}});var e;e=t,Xs["(transient) signalHooks"]=e}();var To=a({getOwner:()=>Lo,setOwner:()=>Ur}),Lo=jr;function Po(t){let e=Object.create(t);return e._dict=null,delete e._dict,e}var Io="object"==typeof self&&null!==self&&self.Object===Object&&"undefined"!=typeof Window&&self.constructor===Window&&"object"==typeof document&&null!==document&&self.document===document&&"object"==typeof location&&null!==location&&self.location===location&&"object"==typeof history&&null!==history&&self.history===history&&"object"==typeof navigator&&null!==navigator&&self.navigator===navigator&&"string"==typeof navigator.userAgent;function Mo(t){let e=t._promiseCallbacks;return e||(e=t._promiseCallbacks={}),e}var Ao={mixin(t){return t.on=this.on,t.off=this.off,t.trigger=this.trigger,t._promiseCallbacks=void 0,t},on(t,e){if("function"!=typeof e)throw new TypeError("Callback must be a function");let n=Mo(this),r=n[t];r||(r=n[t]=[]),-1===r.indexOf(e)&&r.push(e)},off(t,e){let n=Mo(this);if(!e)return void(n[t]=[]);let r=n[t],i=r.indexOf(e);-1!==i&&r.splice(i,1)},trigger(t,e,n){let r=Mo(this)[t];if(r){let t;for(let i=0;i{for(let t=0;t{e===n?Ho(t,n):Vo(t,n)},e=>Go(t,e))}(t,e):"function"==typeof n?function(t,e,n){Oo.async(t=>{let r=!1,i=function(n,i){try{n.call(i,n=>{r||(r=!0,e===n?Ho(t,n):Vo(t,n))},e=>{r||(r=!0,Go(t,e))})}catch(s){return s}}(n,e,t._label);!r&&i&&(r=!0,Go(t,i))},t)}(t,e,n):Ho(t,e)}function Vo(t,e){if(t===e)Ho(t,e);else if(function(t){let e=typeof t;return null!==t&&("object"===e||"function"===e)}(e)){let n;try{n=e.then}catch(Z4){return void Go(t,Z4)}qo(t,e,n)}else Ho(t,e)}function Wo(t){t._onError&&t._onError(t._result),Zo(t)}function Ho(t,e){t._state===Uo&&(t._result=e,t._state=Bo,0===t._subscribers.length?Oo.instrument&&zo("fulfilled",t):Oo.async(Zo,t))}function Go(t,e){t._state===Uo&&(t._state=$o,t._result=e,Oo.async(Wo,t))}function Ko(t,e,n,r){let i=t._subscribers,s=i.length;t._onError=null,i[s]=e,i[s+Bo]=n,i[s+$o]=r,0===s&&t._state&&Oo.async(Zo,t)}function Zo(t){let e=t._subscribers,n=t._state;if(Oo.instrument&&zo(n===Bo?"fulfilled":"rejected",t),0===e.length)return;let r,i,s=t._result;for(let o=0;oYo(i,s,n,o))}return s}var Jo=class{constructor(t,e,n,r){this._instanceConstructor=t,this.promise=new t(jo,r),this._abortOnReject=n,this._isUsingOwnPromise=t===na,this._isUsingOwnResolve=t.resolve===Do,this._init(...arguments)}_init(t,e){let n=e.length||0;this.length=n,this._remaining=n,this._result=new Array(n),this._enumerate(e)}_enumerate(t){let e=this.length,n=this.promise;for(let r=0;n._state===Uo&&re(t)),e,n)}else this._willSettleAt(r.resolve(t),e,n)}_eachEntry(t,e,n){null!==t&&"object"==typeof t?this._settleMaybeThenable(t,e,n):this._setResultAt(Bo,e,t,n)}_settledAt(t,e,n,r){let i=this.promise;i._state===Uo&&(this._abortOnReject&&t===$o?Go(i,n):(this._setResultAt(t,e,n,r),this._checkFullfillment()))}_setResultAt(t,e,n,r){this._remaining--,this._result[e]=n}_willSettleAt(t,e,n){Ko(t,void 0,t=>this._settledAt(Bo,e,t,n),t=>this._settledAt($o,e,t,n))}};function Qo(t,e,n){this._remaining--,this._result[e]=t===Bo?{state:"fulfilled",value:n}:{state:"rejected",reason:n}}var ta="rsvp_"+Date.now()+"-",ea=0,na=class t{constructor(e,n){this._id=ea++,this._label=n,this._state=void 0,this._result=void 0,this._subscribers=[],Oo.instrument&&zo("created",this),jo!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(t,e){let n=!1;try{e(e=>{n||(n=!0,Vo(t,e))},e=>{n||(n=!0,Go(t,e))})}catch(r){Go(t,r)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}_onError(t){Oo.after(()=>{this._onError&&Oo.trigger("error",t,this._label)})}catch(t,e){return this.then(void 0,t,e)}finally(t,e){let n=this,r=n.constructor;return"function"==typeof t?n.then(e=>r.resolve(t()).then(()=>e),e=>r.resolve(t()).then(()=>{throw e})):n.then(t,t)}};function ra(t,e){return{then:(n,r)=>t.call(e,n,r)}}function ia(t,e){let n=function(){let n=arguments.length,r=new Array(n+1),i=!1;for(let t=0;tsa(t,e,n,r))}(s,r,t,this):sa(s,r,t,this)};return n.__proto__=t,n}function sa(t,e,n,r){try{n.apply(r,e)}catch(Z4){Go(t,Z4)}return t}function oa(t,e){return na.all(t,e)}na.cast=Do,na.all=function(t,e){return Array.isArray(t)?new Jo(this,t,!0,e).promise:this.reject(new TypeError("Promise.all must be called with an array"),e)},na.race=function(t,e){let n=this,r=new n(jo,e);if(!Array.isArray(t))return Go(r,new TypeError("Promise.race must be called with an array")),r;for(let i=0;r._state===Uo&&iVo(r,t),t=>Go(r,t));return r},na.resolve=Do,na.reject=function(t,e){let n=new this(jo,e);return Go(n,t),n},na.prototype._guidKey=ta,na.prototype.then=Xo;var aa=class extends Jo{constructor(t,e,n){super(t,e,!1,n)}};function la(t,e){return Array.isArray(t)?new aa(na,t,e).promise:na.reject(new TypeError("Promise.allSettled must be called with an array"),e)}function ca(t,e){return na.race(t,e)}aa.prototype._setResultAt=Qo;var ua=class extends Jo{constructor(t,e,n=!0,r){super(t,e,n,r)}_init(t,e){this._result={},this._enumerate(e)}_enumerate(t){let e,n,r=Object.keys(t),i=r.length,s=this.promise;this._remaining=i;for(let o=0;s._state===Uo&&o{throw t}),t}function ga(t){let e={resolve:void 0,reject:void 0};return e.promise=new na((t,n)=>{e.resolve=t,e.reject=n},t),e}da.prototype._setResultAt=Qo;var ma=class extends Jo{constructor(t,e,n,r){super(t,e,!0,r,n)}_init(t,e,n,r,i){let s=e.length||0;this.length=s,this._remaining=s,this._result=new Array(s),this._mapFn=i,this._enumerate(e)}_setResultAt(t,e,n,r){if(r)try{this._eachEntry(this._mapFn(n,e),e,!1)}catch(Z4){this._settledAt($o,e,Z4,!1)}else this._remaining--,this._result[e]=n}};function ya(t,e,n){return"function"!=typeof e?na.reject(new TypeError("map expects a function as a second argument"),n):na.resolve(t,n).then(function(t){if(!Array.isArray(t))throw new TypeError("map must be called with an array");return new ma(na,t,e,n).promise})}function va(t,e){return na.resolve(t,e)}function ba(t,e){return na.reject(t,e)}var wa={},_a=class extends ma{_checkFullfillment(){if(0===this._remaining&&null!==this._result){let t=this._result.filter(t=>t!==wa);Ho(this.promise,t),this._result=null}}_setResultAt(t,e,n,r){if(r){this._result[e]=n;let t,r=!0;try{t=this._mapFn(n,e)}catch(Z4){r=!1,this._settledAt($o,e,Z4,!1)}r&&this._eachEntry(t,e,!1)}else this._remaining--,n||(this._result[e]=wa)}};function xa(t,e,n){return"function"!=typeof e?na.reject(new TypeError("filter expects function as a second argument"),n):na.resolve(t,n).then(function(t){if(!Array.isArray(t))throw new TypeError("filter must be called with an array");return new _a(na,t,e,n).promise})}var Ca,ka=0;function Sa(t,e){Aa[ka]=t,Aa[ka+1]=e,2===(ka+=2)&&Ma()}var Ea="undefined"!=typeof window?window:void 0,Ra=Ea||{},Ta=Ra.MutationObserver||Ra.WebKitMutationObserver,La="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Pa="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function Ia(){return()=>setTimeout(Oa,1)}var Ma,Aa=new Array(1e3);function Oa(){for(let t=0;tt(Oa)}():Ta?function(){let t=0,e=new Ta(Oa),n=document.createTextNode("");return e.observe(n,{characterData:!0}),()=>n.data=t=++t%2}():Pa?function(){let t=new MessageChannel;return t.port1.onmessage=Oa,()=>t.port2.postMessage(0)}():void 0===Ea&&"function"==typeof window.require?function(){try{const t=Function("return this")().require("vertx");return void 0!==(Ca=t.runOnLoop||t.runOnContext)?function(){Ca(Oa)}:Ia()}catch(t){return Ia()}}():Ia(),Oo.async=Sa,Oo.after=t=>setTimeout(t,0);var Fa=va,Na=(t,e)=>Oo.async(t,e);function za(){Oo.on(...arguments)}function Da(){Oo.off(...arguments)}if("undefined"!=typeof window&&"object"==typeof window.__PROMISE_INSTRUMENTATION__){let t=window.__PROMISE_INSTRUMENTATION__;Fo("instrument",!0);for(let e in t)t.hasOwnProperty(e)&&za(e,t[e])}var ja={asap:Sa,cast:Fa,Promise:na,EventTarget:Ao,all:oa,allSettled:la,race:ca,hash:ha,hashSettled:pa,rethrow:fa,defer:ga,denodeify:ia,configure:Fo,on:za,off:Da,resolve:va,reject:ba,map:ya,async:Na,filter:xa},Ua=Object.freeze(Object.defineProperty({__proto__:null,EventTarget:Ao,Promise:na,all:oa,allSettled:la,asap:Sa,async:Na,cast:Fa,configure:Fo,default:ja,defer:ga,denodeify:ia,filter:xa,hash:ha,hashSettled:pa,map:ya,off:Da,on:za,race:ca,reject:ba,resolve:va,rethrow:fa},Symbol.toStringTag,{value:"Module"}));function Ba(t){let e=function(t){if(!t)return;let e=t;return e.errorThrown?function(t){let e=t.errorThrown;return"string"==typeof e&&(e=new Error(e)),Object.defineProperty(e,"__reason_with_error_thrown__",{value:t,enumerable:!1}),e}(e):"UnrecognizedURLError"!==t.name&&"TransitionAborted"!==t.name?t:void 0}(t);if(e){let t=null;if(!t)throw e;t(e)}}Fo("async",(t,e)=>{vs.schedule("actions",null,t,e)}),Fo("after",t=>{vs.schedule(ms,null,t)}),za("error",Ba);var $a=class{static _leakTracking;owner;registry;cache;factoryManagerCache;validationCache;isDestroyed;isDestroying;constructor(t,e={}){this.registry=t,this.owner=e.owner||null,this.cache=Po(e.cache||null),this.factoryManagerCache=Po(e.factoryManagerCache||null),this.isDestroyed=!1,this.isDestroying=!1}lookup(t,e){if(this.isDestroyed)throw new Error(`Cannot call \`.lookup('${t}')\` after the owner has been destroyed`);return function(t,e,n={}){let r=e;if(!0===n.singleton||void 0===n.singleton&&qa(t,e)){let e=t.cache[r];if(void 0!==e)return e}return function(t,e,n,r){let i=Wa(t,e,n);if(void 0!==i){if(function(t,e,{instantiate:n,singleton:r}){return!1!==r&&!1!==n&&(!0===r||qa(t,e))&&Va(t,e)}(t,n,r)){let n=t.cache[e]=i.create();return t.isDestroying&&"function"==typeof n.destroy&&n.destroy(),n}if(function(t,e,{instantiate:n,singleton:r}){return!1!==n&&(!1===r||!qa(t,e))&&Va(t,e)}(t,n,r))return i.create();if(function(t,e,{instantiate:n,singleton:r}){return!1!==r&&!n&&qa(t,e)&&!Va(t,e)}(t,n,r)||function(t,e,{instantiate:n,singleton:r}){return!(!1!==n||!1!==r&&qa(t,e)||Va(t,e))}(t,n,r))return i.class;throw new Error("Could not create factory")}}(t,r,e,n)}(this,this.registry.normalize(t),e)}destroy(){this.isDestroying=!0,Ha(this)}finalizeDestroy(){Ga(this),this.isDestroyed=!0}reset(t){this.isDestroyed||(void 0===t?(Ha(this),Ga(this)):function(t,e){let n=t.cache[e];delete t.factoryManagerCache[e],n&&(delete t.cache[e],n.destroy&&n.destroy())}(this,this.registry.normalize(t)))}ownerInjection(){let t={};return Ur(t,this.owner),t}factoryFor(t){if(this.isDestroyed)throw new Error(`Cannot call \`.factoryFor('${t}')\` after the owner has been destroyed`);return Wa(this,this.registry.normalize(t),t)}};function qa(t,e){return!1!==t.registry.getOption(e,"singleton")}function Va(t,e){return!1!==t.registry.getOption(e,"instantiate")}function Wa(t,e,n){let r=t.factoryManagerCache[e];if(void 0!==r)return r;let i=t.registry.resolve(e);if(void 0===i)return;let s=new Xa(t,i,n,e);return t.factoryManagerCache[e]=s,s}function Ha(t){let e=t.cache,n=Object.keys(e);for(let r of n){let t=e[r];t.destroy&&t.destroy()}}function Ga(t){t.cache=Po(null),t.factoryManagerCache=Po(null)}var Ka=Symbol("INIT_FACTORY");function Za(t){return t[Ka]}function Ya(t,e){t[Ka]=e}var Xa=class{container;owner;class;fullName;normalizedName;madeToString;injections;constructor(t,e,n,r){this.container=t,this.owner=t.owner,this.class=e,this.fullName=n,this.normalizedName=r,this.madeToString=void 0,this.injections=void 0}toString(){return void 0===this.madeToString&&(this.madeToString=this.container.registry.makeToString(this.class,this.fullName)),this.madeToString}create(t){let{container:e}=this;if(e.isDestroyed)throw new Error(`Cannot create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`);let n=t?{...t}:{};return Ur(n,e.owner),Ya(n,this),this.class.create(n)}};function Ja(t){let e=Object.create(null);e[t]=1;for(let n in e)if(n===t)return n;return t}var Qa=0;function tl(){return++Qa}var el="ember",nl=new WeakMap,rl=new Map,il=Ja(`__ember${Date.now()}`);function sl(t,e=el){let n=e+tl().toString();return Kt(t)&&nl.set(t,n),n}function ol(t){let e;if(Kt(t))e=nl.get(t),void 0===e&&(e=`${el}${tl()}`,nl.set(t,e));else if(e=rl.get(t),void 0===e){let n=typeof t;e="string"===n?`st${tl()}`:"number"===n?`nu${tl()}`:"symbol"===n?`sy${tl()}`:`(${t})`,rl.set(t,e)}return e}var al=Array.prototype.concat;function ll(t,e,n,r){let i=n[t]||r[t];return e[t]&&(i=i?al.call(i,e[t]):e[t]),i}function cl(t,e,n,r){if(!0===n)return e;let i=n._getter;if(void 0===i)return e;let s=r[t],o="function"==typeof s?P(s):s;if(void 0===o||!0===o)return e;let a=o._getter;if(void 0===a)return e;let l,c=Qe(i,a),u=n._setter,h=o._setter;if(l=void 0!==h?void 0!==u?Qe(u,h):h:u,c!==i||l!==u){let t=n._dependentKeys||[],e=new Hn([...t,{get:c,set:l}]);return e._readOnly=n._readOnly,e._meta=n._meta,e.enumerable=n.enumerable,R(e,Hn)}return e}function ul(t,e,n,r){if(void 0!==r[t])return e;let i=n[t];return"function"==typeof i?Qe(e,i):e}function hl(t){return t?Array.isArray(t)?t:[t]:[]}function dl(t,e,n){return hl(n[t]).concat(hl(e))}function pl(t,e,n){let r=n[t];if(!r)return e;let i=Object.assign({},r),s=!1,o=Object.keys(e);for(let a of o){let t=e[a];"function"==typeof t?(s=!0,i[a]=ul(a,t,r,{})):i[a]=t}return s&&(i._super=Ve),i}function fl(t,e,n,r,i,s,o){let a;for(let l=0;l{let e=s.indexOf(t);-1!==e&&s.splice(e,1)}))}else gl(e,a,n,r,i,s,o)}function gl(t,e,n,r,i,s,o){let a=ll("concatenatedProperties",e,r,i),l=ll("mergedProperties",e,r,i),c=Object.keys(e);for(let u of c){let c=e[u];if(void 0===c)continue;if(-1===s.indexOf(u)){s.push(u);let e=t.peekDescriptors(u);if(void 0===e){if(!I(c)){let t=r[u]=i[u];"function"==typeof t&&ml(i,u,t,!1)}}else n[u]=e,o.push(u),e.teardown(i,u,t)}let h="function"==typeof c;if(h){let t=P(c);if(void 0!==t){n[u]=cl(u,c,t,n),r[u]=void 0;continue}}a&&a.indexOf(u)>=0||"concatenatedProperties"===u||"mergedProperties"===u?c=dl(u,c,r):l&&l.indexOf(u)>-1?c=pl(u,c,r):h&&(c=ul(u,c,r,n)),r[u]=c,n[u]=void 0}}function ml(t,e,n,r){let i=Ze(n);if(void 0===i)return;let{observers:s,listeners:o}=i;if(void 0!==s){let n=r?hn:dn;for(let r of s.paths)n(t,r,null,e,s.sync)}if(void 0!==o){let n=r?en:nn;for(let r of o)n(t,r,null,e)}}function yl(t,e,n=!1){let r=Object.create(null),i=Object.create(null),s=b(t),o=[],a=[];t._super=Ve,fl(e,s,r,i,t,o,a);for(let l of o){let e=i[l],o=r[l];void 0!==e?("function"==typeof e&&ml(t,l,e,!0),Dn(t,l,e,-1!==a.indexOf(l),!n)):void 0!==o&&zn(t,l,o,s)}return s.isPrototypeMeta(t)||yn(t),t}var vl=new WeakSet,bl=class t{mixins;properties;ownerConstructor;_without;constructor(t,e){vl.add(this),this.properties=function(t){if(void 0!==t)for(let e of Object.keys(t)){let n=Object.getOwnPropertyDescriptor(t,e);void 0===n.get&&void 0===n.set||Object.defineProperty(t,e,{value:x(n)})}return t}(e),this.mixins=wl(t),this.ownerConstructor=void 0,this._without=void 0}static create(...t){return mi(),new this(t,void 0)}static mixins(t){let e=v(t),n=[];return null===e||e.forEachMixins(t=>{t.properties||n.push(t)}),n}reopen(...e){if(0===e.length)return this;if(this.properties){let e=new t(void 0,this.properties);this.properties=void 0,this.mixins=[e]}else this.mixins||(this.mixins=[]);return this.mixins=this.mixins.concat(wl(e)),this}apply(t,e=!1){return yl(t,[this],e)}applyPartial(t){return yl(t,[this])}detect(t){if("object"!=typeof t||null===t)return!1;if(vl.has(t))return _l(t,this);let e=v(t);return null!==e&&e.hasMixin(this)}without(...e){let n=new t([this]);return n._without=e,n}keys(){return xl(this)}toString(){return"(unknown mixin)"}};function wl(t){let e,n=t&&t.length||0;if(n>0){e=new Array(n);for(let r=0;r_l(t,e,n))}function xl(t,e=new Set,n=new Set){if(!n.has(t)){if(n.add(t),t.properties){let n=Object.keys(t.properties);for(let t of n)e.add(t)}else t.mixins&&t.mixins.forEach(t=>xl(t,e,n));return e}}var Cl=bl.create({mergedProperties:["actions"],send(t,...e){if(this.actions&&this.actions[t]&&!0!==this.actions[t].apply(this,e))return;let n=cr(this,"target");n&&n.send(...arguments)}}),{isArray:kl}=Array;function Sl(t){return null==t?[]:kl(t)?t:[t]}var El=a({default:()=>Ol});function Rl(t){return"object"==typeof t&&null!==t&&"function"==typeof t.setUnknownProperty}var Tl=bl.prototype.reopen,Ll=new WeakSet,Pl=new WeakMap,Il=new Set;function Ml(t){Il.has(t)||t.destroy()}function Al(t,e){let n=b(t);if(void 0!==e){let r=t.concatenatedProperties,i=t.mergedProperties,s=Object.keys(e);for(let o of s){let s=e[o],a=L(t,o,n),l=void 0!==a;if(!l){if(void 0!==r&&r.length>0&&r.includes(o)){let e=t[o];s=e?Sl(e).concat(s):Sl(s)}if(void 0!==i&&i.length>0&&i.includes(o)){let e=t[o];s=Object.assign({},e,s)}}l?a.set(t,o,s):Rl(t)&&!(o in t)?t.setUnknownProperty(o,s):t[o]=s}}t.init(e),n.unsetInitializing();let r=n.observerEvents();if(void 0!==r)for(let i=0;in.willDestroy()),b(e).setInitializing()}reopen(...t){return yl(this,t),this}init(t){}get isDestroyed(){return rt(this)}set isDestroyed(t){}get isDestroying(){return nt(this)}set isDestroying(t){}destroy(){Il.add(this);try{tt(this)}finally{Il.delete(this)}return this}willDestroy(){}toString(){let t="object"==typeof this&&null!==this&&"function"==typeof this.toStringExtension?`:${this.toStringExtension()}`:"";return`<${Za(this)||"(unknown)"}:${ol(this)}${t}>`}static extend(...t){let e=class extends(this){};return Tl.apply(e.PrototypeMixin,t),e}static create(...t){let e,n=t[0];return void 0!==n?(e=new this(jr(n)),Ya(e,Za(n))):e=new this,t.length<=1?Al(e,n):Al(e,Fl.apply(this,t)),e}static reopen(...t){return this.willReopen(),Tl.apply(this.PrototypeMixin,t),this}static willReopen(){let t=this.prototype;Ll.has(t)&&(Ll.delete(t),Pl.has(this)&&Pl.set(this,bl.create(this.PrototypeMixin)))}static reopenClass(...t){return yl(this,t),this}static detect(t){if("function"!=typeof t)return!1;for(;t;){if(t===this)return!0;t=t.superclass}return!1}static detectInstance(t){return t instanceof this}static metaForProperty(t){return L(this.proto(),t)._meta||{}}static eachComputedProperty(t,e=this){this.proto();let n={};b(this.prototype).forEachDescriptors((r,i)=>{if(i.enumerable){let s=i._meta||n;t.call(e,r,s)}})}static get PrototypeMixin(){let t=Pl.get(this);return void 0===t&&(t=bl.create(),t.ownerConstructor=this,Pl.set(this,t)),t}static get superclass(){let t=Object.getPrototypeOf(this);return t!==Function.prototype?t:void 0}static proto(){let t=this.prototype;if(!Ll.has(t)){Ll.add(t);let e=this.superclass;e&&e.proto(),Pl.has(this)&&this.PrototypeMixin.apply(t)}return t}static toString(){return`<${Za(this)||"(unknown)"}:constructor>`}static isClass=!0;static isMethod=!1;static _onLookup;static _lazyInjections};function Fl(...t){let e={};for(let n of t){let t=Object.keys(n);for(let r=0,i=t.length;rzl}),zl=bl.create({get(t){return cr(this,t)},getProperties(...t){return Fr(this,...t)},set(t,e){return fr(this,t,e)},setProperties(t){return Nr(this,t)},beginPropertyChanges(){return $n(),this},endPropertyChanges(){return qn(),this},notifyPropertyChange(t){return Bn(this,t),this},addObserver(t,e,n,r){return hn(this,t,e,n,r),this},removeObserver(t,e,n,r){return dn(this,t,e,n,r),this},hasObserverFor(t){return sn(this,`${t}:change`)},incrementProperty(t,e=1){return fr(this,t,(parseFloat(cr(this,t))||0)+e)},decrementProperty(t,e=1){return fr(this,t,(cr(this,t)||0)-e)},toggleProperty(t){return fr(this,t,!cr(this,t))},cacheFor(t){let e=v(this);return null!==e?e.valueFor(t):void 0}}),Dl=a({action:()=>$l,computed:()=>Zn,default:()=>jl,defineProperty:()=>Nn,get:()=>cr,getProperties:()=>Fr,notifyPropertyChange:()=>Bn,observer:()=>ql,set:()=>fr,setProperties:()=>Nr,trySet:()=>mr}),jl=class extends(Ol.extend(zl)){get _debugContainerKey(){let t=Za(this);return void 0!==t&&t.fullName}},Ul=new WeakMap;function Bl(t,e,n){var r;if(null!=(r=t)&&void 0!==r.constructor&&"function"==typeof r.constructor.proto&&t.constructor.proto(),!Object.prototype.hasOwnProperty.call(t,"actions")){let e=t.actions;t.actions=e?Object.assign({},e):{}}return t.actions[e]=n,{get(){let t=Ul.get(this);void 0===t&&(t=new Map,Ul.set(this,t));let e=t.get(n);return void 0===e&&(e=n.bind(this),t.set(n,e)),e}}}function $l(...t){let e;if(!_(t)){e=t[0];let n=function(t,n){return Bl(t,n,e)};return M(n),n}let[n,r,i]=t;return e=i?.value,Bl(n,r,e)}function ql(...t){let e,n,r,i=t.pop();"function"==typeof i?(e=i,n=t,r=!A._DEFAULT_ASYNC_OBSERVERS):(e=i.fn,n=i.dependentKeys,r=i.sync);let s=[];for(let o of n)On(o,t=>s.push(t));return Ye(e,{paths:s,sync:r}),e}function Vl(t){if(!(t instanceof MouseEvent))return!1;let e=t.shiftKey||t.metaKey||t.altKey||t.ctrlKey,n=0!==t.button;return!e&&!n}function Wl(t){return'Binding style attributes may introduce cross-site scripting vulnerabilities; please ensure that values being bound are properly escaped. For more information, including how to disable this warning, see https://deprecations.emberjs.com/v1.x/#toc_binding-style-attributes. Style affected: "'+t+'"'}function Hl(t){let e=t.lookup("-view-registry:main"),n=[];return Object.keys(e).forEach(t=>{let r=e[t];null===r.parentView&&n.push(r)}),n}function Gl(t){return""!==t.tagName&&t.elementId?t.elementId:ol(t)}M($l);var Kl=new WeakMap,Zl=new WeakMap;function Yl(t){return Kl.get(t)||null}function Xl(t){return Zl.get(t)||null}function Jl(t,e){Kl.set(t,e)}function Ql(t,e){Zl.set(t,e)}function tc(t){Kl.delete(t)}function ec(t){Zl.delete(t)}var nc=new WeakMap;function rc(t){return function(t,e){let n=[],r=nc.get(t);return void 0!==r&&r.forEach(t=>{let r=e[t];!r||r.isDestroying||r.isDestroyed||n.push(r)}),n}(t,jr(t).lookup("-view-registry:main"))}function ic(t,e){let n=nc.get(t);void 0===n&&(n=function(t){let e=new Set;return nc.set(t,e),e}(t)),n.add(Gl(e))}function sc(t){return t.renderer.getBounds(t)}function oc(t){let e=sc(t),n=document.createRange();return n.setStartBefore(e.firstNode),n.setEndAfter(e.lastNode),n}function ac(t){return oc(t).getClientRects()}function lc(t){return oc(t).getBoundingClientRect()}var cc="ember-application",uc=class extends jl{events={touchstart:"touchStart",touchmove:"touchMove",touchend:"touchEnd",touchcancel:"touchCancel",keydown:"keyDown",keyup:"keyUp",keypress:"keyPress",mousedown:"mouseDown",mouseup:"mouseUp",contextmenu:"contextMenu",click:"click",dblclick:"doubleClick",focusin:"focusIn",focusout:"focusOut",submit:"submit",input:"input",change:"change",dragstart:"dragStart",drag:"drag",dragenter:"dragEnter",dragleave:"dragLeave",dragover:"dragOver",drop:"drop",dragend:"dragEnd"};rootElement="body";_eventHandlers=Object.create(null);_didSetup=!1;finalEventNameMapping=null;_sanitizedRootElement=null;lazyEvents=new Map;_reverseEventNameMapping=null;setup(t,e){let n=this.finalEventNameMapping={...cr(this,"events"),...t};this._reverseEventNameMapping=Object.keys(n).reduce((t,e)=>{let r=n[e];return r?{...t,[r]:e}:t},{});let r=this.lazyEvents;null!=e&&fr(this,"rootElement",e);let i=cr(this,"rootElement"),s="string"!=typeof i?i:document.querySelector(i);s.classList.add(cc),this._sanitizedRootElement=s;for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&r.set(o,n[o]??null);this._didSetup=!0}setupHandlerForBrowserEvent(t){this.setupHandler(this._sanitizedRootElement,t,this.finalEventNameMapping[t]??null)}setupHandlerForEmberEvent(t){let e=this._reverseEventNameMapping?.[t];e&&this.setupHandler(this._sanitizedRootElement,e,t)}setupHandler(t,e,n){if(null===n||!this.lazyEvents.has(e))return;let r=(t,e)=>{let r=Yl(t),i=!0;return r&&(i=r.handleEvent(n,e)),i},i=this._eventHandlers[e]=t=>{let e=t.target;do{if(Yl(e)){if(!1===r(e,t)){t.preventDefault(),t.stopPropagation();break}if(!0===t.cancelBubble)break}e=e.parentNode}while(e instanceof Element)};t.addEventListener(e,i),this.lazyEvents.delete(e)}destroy(){if(!1===this._didSetup)return;let t=this._sanitizedRootElement;if(t){for(let e in this._eventHandlers)t.removeEventListener(e,this._eventHandlers[e]);return t.classList.remove(cc),this._super(...arguments)}}toString(){return"(EventDispatcher)"}},hc=/^[^:]+:[^:]+$/,dc=class{_failSet;resolver;fallback;registrations;_normalizeCache;_options;_resolveCache;_typeOptions;constructor(t={}){this.fallback=t.fallback||null,this.resolver=t.resolver||null,this.registrations=Po(t.registrations||null),this._normalizeCache=Po(null),this._resolveCache=Po(null),this._failSet=new Set,this._options=Po(null),this._typeOptions=Po(null)}container(t){return new $a(this,t)}register(t,e,n={}){let r=this.normalize(t);this._failSet.delete(r),this.registrations[r]=e,this._options[r]=n}unregister(t){let e=this.normalize(t);delete this.registrations[e],delete this._resolveCache[e],delete this._options[e],this._failSet.delete(e)}resolve(t){let e=function(t,e){let n,r=e,i=t._resolveCache[r];return void 0!==i?i:t._failSet.has(r)?void 0:(t.resolver&&(n=t.resolver.resolve(r)),void 0===n&&(n=t.registrations[r]),void 0===n?t._failSet.add(r):t._resolveCache[r]=n,n)}(this,this.normalize(t));return void 0===e&&null!==this.fallback&&(e=this.fallback.resolve(t)),e}describe(t){return null!==this.resolver&&this.resolver.lookupDescription?this.resolver.lookupDescription(t):null!==this.fallback?this.fallback.describe(t):t}normalizeFullName(t){return null!==this.resolver&&this.resolver.normalize?this.resolver.normalize(t):null!==this.fallback?this.fallback.normalizeFullName(t):t}normalize(t){return this._normalizeCache[t]||(this._normalizeCache[t]=this.normalizeFullName(t))}makeToString(t,e){return null!==this.resolver&&this.resolver.makeToString?this.resolver.makeToString(t,e):null!==this.fallback?this.fallback.makeToString(t,e):"string"==typeof t?t:t.name??"(unknown class)"}has(t){return!!this.isValidFullName(t)&&function(t,e){return void 0!==t.resolve(e)}(this,this.normalize(t))}optionsForType(t,e){this._typeOptions[t]=e}getOptionsForType(t){let e=this._typeOptions[t];return void 0===e&&null!==this.fallback&&(e=this.fallback.getOptionsForType(t)),e}options(t,e){let n=this.normalize(t);this._options[n]=e}getOptions(t){let e=this.normalize(t),n=this._options[e];return void 0===n&&null!==this.fallback&&(n=this.fallback.getOptions(t)),n}getOption(t,e){let n=this._options[t];if(void 0!==n&&void 0!==n[e])return n[e];let r=t.split(":")[0];return n=this._typeOptions[r],n&&void 0!==n[e]?n[e]:null!==this.fallback?this.fallback.getOption(t,e):void 0}knownForType(t){let e,n,r=Po(null),i=Object.keys(this.registrations);for(let s of i)s.split(":")[0]===t&&(r[s]=!0);return null!==this.fallback&&(e=this.fallback.knownForType(t)),null!==this.resolver&&this.resolver.knownForType&&(n=this.resolver.knownForType(t)),Object.assign({},e,r,n)}isValidFullName(t){return hc.test(t)}},pc=Po(null),fc=`${Math.random()}${Date.now()}`.replace(".","");function gc([t]){let e=pc[t];if(e)return e;let[n,r]=t.split(":");return pc[t]=Ja(`${n}:${r}-${fc}`)}var mc=a({default:()=>yc,on:()=>on}),yc=bl.create({on(t,e,n){return en(this,t,e,n),this},one(t,e,n){return en(this,t,e,n,!0),this},trigger(t,...e){rn(this,t,e)},off(t,e,n){return nn(this,t,e,n),this},has(t){return sn(this,t)}}),vc=bl.create(),bc=a({default:()=>wc}),wc=bl.create(vc),_c={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object AsyncFunction]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object FileList]":"filelist"},{toString:xc}=Object.prototype;function Cc(t){if(null===t)return"null";if(void 0===t)return"undefined";let e=_c[xc.call(t)]||"object";return"function"===e?Ol.detect(t)&&(e="class"):"object"===e&&(t instanceof Error?e="error":t instanceof Ol?e="instance":t instanceof Date&&(e="date")),e}var kc=bl.create({compare:null}),Sc={undefined:0,null:1,boolean:2,number:3,string:4,array:5,object:6,instance:7,function:8,class:9,date:10,regexp:11,filelist:12,error:13};function Ec(t,e){return Math.sign(t-e)}function Rc(t,e){if(t===e)return 0;let n=Cc(t),r=Cc(e);if("instance"===n&&Tc(t)&&t.constructor.compare)return t.constructor.compare(t,e);if("instance"===r&&Tc(e)&&e.constructor.compare)return-1*e.constructor.compare(e,t);let i=Ec(Sc[n],Sc[r]);if(0!==i)return i;switch(n){case"boolean":return Ec(Number(t),Number(e));case"number":return Ec(t,e);case"string":return Ec(t.localeCompare(e),0);case"array":{let n=t.length,r=e.length,i=Math.min(n,r);for(let s=0;sKc,MutableArray:()=>Wc,NativeArray:()=>Hc,default:()=>Vc,isArray:()=>Lc,makeArray:()=>Sl,removeAt:()=>Uc,uniqBy:()=>Ac}),Ic=Object.freeze([]),Mc=t=>t;function Ac(t,e=Mc){let n=Kc(),r=new Set,i="function"==typeof e?e:t=>cr(t,e);return t.forEach(t=>{let e=i(t);r.has(e)||(r.add(e),n.push(t))}),n}function Oc(...t){let e=2===t.length,[n,r]=t;return e?t=>r===cr(t,n):t=>Boolean(cr(t,n))}function Fc(t,e,n){let r=t.length;for(let i=n;i!r(t,e,n),0)}function jc(t,e,n=0,r){let i=t.length;return n<0&&(n+=i),Fc(t,r&&e!=e?t=>t!=t:t=>t===e,n)}function Uc(t,e,n){return Sr(t,e,n??1,Ic),t}function Bc(t,e,n){return Sr(t,e,0,[n]),n}function $c(t){let e=Zn(t);return e.enumerable=!1,e}function qc(t){return this.map(e=>cr(e,t))}var Vc=bl.create(vc,{init(){this._super(...arguments),nr.add(this)},objectsAt(t){return t.map(t=>Pe(this,t))},"[]":$c({get(){return this},set(t,e){return this.replace(0,this.length,e),this}}),firstObject:$c(function(){return Pe(this,0)}).readOnly(),lastObject:$c(function(){return Pe(this,this.length-1)}).readOnly(),slice(t=0,e){let n,r=Kc(),i=this.length;for(t<0&&(t=i+t),n=void 0===e||e>i?i:e<0?i+e:e;t=n)&&(e=n-1),e<0&&(e+=n);for(let r=e;r>=0;r--)if(Pe(this,r)===t)return r;return-1},forEach(t,e=null){let n=this.length;for(let r=0;rfr(n,t,e))},map(t,e=null){let n=Kc();return this.forEach((r,i,s)=>n[i]=t.call(e,r,i,s)),n},mapBy:qc,filter(t,e=null){let n=Kc();return this.forEach((r,i,s)=>{t.call(e,r,i,s)&&n.push(r)}),n},reject(t,e=null){return this.filter(function(){return!t.apply(e,arguments)})},filterBy(){return this.filter(Oc(...arguments))},rejectBy(){return this.reject(Oc(...arguments))},find(t,e=null){return Nc(this,t,e)},findBy(){return Nc(this,Oc(...arguments))},every(t,e=null){return Dc(this,t,e)},isEvery(){return Dc(this,Oc(...arguments))},any(t,e=null){return zc(this,t,e)},isAny(){return zc(this,Oc(...arguments))},reduce(t,e){let n=e,r=0;if(!(arguments.length>1)){if(0===this.length)throw new TypeError("Reduce of empty array with no initial value");n=this.objectAt(0),r=1}for(let i=r;in.push(r[t]?.(...e))),n},toArray(){return this.map(t=>t)},compact(){return this.filter(t=>null!=t)},includes(t,e){return-1!==jc(this,t,e,!0)},sortBy(){let t=arguments;return this.toArray().sort((e,n)=>{for(let r=0;re!==t:t=>t==t;return this.filter(e)}}),Wc=bl.create(Vc,wc,{clear(){let t=this.length;return 0===t||this.replace(0,t,Ic),this},insertAt(t,e){return Bc(this,t,e),this},removeAt(t,e){return Uc(this,t,e)},pushObject(t){return Bc(this,this.length,t)},pushObjects(t){return this.replace(this.length,0,t),this},popObject(){let t=this.length;if(0===t)return null;let e=Pe(this,t-1);return this.removeAt(t-1,1),e},shiftObject(){if(0===this.length)return null;let t=Pe(this,0);return this.removeAt(0),t},unshiftObject(t){return Bc(this,0,t)},unshiftObjects(t){return this.replace(0,0,t),this},reverseObjects(){let t=this.length;if(0===t)return this;let e=this.toArray().reverse();return this.replace(0,t,e),this},setObjects(t){if(0===t.length)return this.clear();let e=this.length;return this.replace(0,e,t),this},removeObject(t){let e=this.length||0;for(;--e>=0;)Pe(this,e)===t&&this.removeAt(e);return this},removeObjects(t){$n();for(let e=t.length-1;e>=0;e--)this.removeObject(t[e]);return qn(),this},addObject(t){return this.includes(t)||this.pushObject(t),this},addObjects(t){return $n(),t.forEach(t=>this.addObject(t)),qn(),this}}),Hc=bl.create(Wc,zl,{objectAt(t){return this[t]},replace(t,e,n=Ic){return Rr(this,t,e,n),this}}),Gc=["length"];Hc.keys().forEach(t=>{Array.prototype[t]&&Gc.push(t)}),Hc=Hc.without(...Gc);var Kc=function(t){return rr(t)?t:Hc.apply(t??[])},Zc=class extends jl{},Yc=a({ControllerMixin:()=>Jc,default:()=>Qc,inject:()=>tu}),Xc=Symbol("MODEL"),Jc=bl.create(Cl,{isController:!0,concatenatedProperties:["queryParams"],target:null,store:null,init(){this._super(...arguments);let t=jr(this);t&&(this.namespace=t.lookup("application:main"),this.target=t.lookup("router:main"))},model:Zn({get(){return this[Xc]},set(t,e){return this[Xc]=e}}),queryParams:null,_qpDelegate:null,_qpChanged(t,e){let n=e.indexOf(".[]"),r=-1===n?e:e.slice(0,n);(0,t._qpDelegate)(r,cr(t,r))}}),Qc=class extends(Zc.extend(Jc)){};function tu(...t){return Br("controller",...t)}var eu=!1;function nu(){return eu}function ru(t){eu=Boolean(t)}var iu=Symbol("ENGINE_PARENT");function su(t){return t[iu]}var ou=bl.create({__container__:null,ownerInjection(){return this.__container__.ownerInjection()},lookup(t,e){return this.__container__.lookup(t,e)},destroy(){let t=this.__container__;t&&ws(()=>{t.destroy(),ks("destroy",t,"finalizeDestroy")}),this._super()},factoryFor(t){return this.__container__.factoryFor(t)}}),au=bl.create({__registry__:null,resolveRegistration(t){return this.__registry__.resolve(t)},register:lu("register"),unregister:lu("unregister"),hasRegistration:lu("has"),registeredOption:lu("getOption"),registerOptions:lu("options"),registeredOptions:lu("getOptions"),registerOptionsForType:lu("optionsForType"),registeredOptionsForType:lu("getOptionsForType")});function lu(t){return function(...e){return this.__registry__[t](...e)}}var cu=class extends(jl.extend(au,ou)){static setupRegistry(t,e){}[iu];_booted=!1;init(t){super.init(t),ol(this),this.base??=this.application;let e=this.__registry__=new dc({fallback:this.base.__registry__});this.__container__=e.container({owner:this}),this._booted=!1}_bootPromise=null;boot(t){return this._bootPromise||(this._bootPromise=new Ua.Promise(e=>{e(this._bootSync(t))})),this._bootPromise}_bootSync(t){return this._booted||(this.cloneParentDependencies(),this.setupRegistry(t),this.base.runInstanceInitializers(this),this._booted=!0),this}setupRegistry(t=this.__container__.lookup("-environment:main")){this.constructor.setupRegistry(this.__registry__,t)}unregister(t){this.__container__.reset(t),this.__registry__.unregister(t)}buildChildEngineInstance(t,e={}){let n=this.lookup(`engine:${t}`);if(!n)throw new Error(`You attempted to mount the engine '${t}', but it is not registered with its parent.`);let r=n.buildInstance(e);return r[iu]=this,r}cloneParentDependencies(){const t=su(this);["route:basic","service:-routing"].forEach(e=>{let n=t.resolveRegistration(e);this.register(e,n)});let e=t.lookup("-environment:main");this.register("-environment:main",e,{instantiate:!1});let n=["router:main",gc`-bucket-cache:main`,"-view-registry:main","renderer:-dom","service:-document"];e.isInteractive&&n.push("event_dispatcher:main"),n.forEach(e=>{let n=t.lookup(e);this.register(e,n,{instantiate:!1})})}},uu=function(t,e,n){let{get:r}=n;return void 0!==r&&(n.get=function(){let t,n=Gt(this,e),i=$t(()=>{t=r.call(this)});return dt(n,i),Ot(i),t}),n};function hu(...t){if(_(t)){let[e,n,r]=t;return uu(0,n,r)}{const e=t[0];let n=function(t,n){return uu(0,n,e)};return M(n),n}}M(hu);var du={Empty:0,dynamicLayout:1,dynamicTag:2,prepareArgs:4,createArgs:8,attributeHook:16,elementHook:32,dynamicScope:64,createCaller:128,updateHook:256,createInstance:512,wrapped:1024,willDestroy:2048,hasSubOwner:4096},pu=du.Empty;function fu(t){return pu|gu(t,"dynamicLayout")|gu(t,"dynamicTag")|gu(t,"prepareArgs")|gu(t,"createArgs")|gu(t,"attributeHook")|gu(t,"elementHook")|gu(t,"dynamicScope")|gu(t,"createCaller")|gu(t,"updateHook")|gu(t,"createInstance")|gu(t,"wrapped")|gu(t,"willDestroy")|gu(t,"hasSubOwner")}function gu(t,e){return t[e]?du[e]:pu}function mu(t,e,n){return!!(e&n)}function yu(t,e){return!!(t&e)}function vu(t,e={}){return{hasValue:Boolean(e.hasValue),hasDestroyable:Boolean(e.hasDestroyable),hasScheduledEffect:Boolean(e.hasScheduledEffect)}}function bu(t){return t.capabilities.hasValue}function wu(t){return t.capabilities.hasDestroyable}var _u=class{constructor(t){this.factory=t}helperManagerDelegates=new WeakMap;undefinedDelegate=null;getDelegateForOwner(t){let e=this.helperManagerDelegates.get(t);if(void 0===e){let{factory:n}=this;e=n(t),this.helperManagerDelegates.set(t,e)}return e}getDelegateFor(t){if(void 0===t){let{undefinedDelegate:t}=this;if(null===t){let{factory:e}=this;this.undefinedDelegate=t=e(void 0)}return t}return this.getDelegateForOwner(t)}getHelper(t){return(e,n)=>{let r=this.getDelegateFor(n);const i=Le(e),s=r.createHelper(t,i);if(bu(r)){let t=pe(()=>r.getValue(s),null);return wu(r)&&J(t,r.getDestroyable(s)),t}if(wu(r)){let t=he(void 0);return J(t,r.getDestroyable(s)),t}return ae}}},xu=class{capabilities={hasValue:!0,hasDestroyable:!1,hasScheduledEffect:!1};createHelper(t,e){return{fn:t,args:e}}getValue({fn:t,args:e}){return Object.keys(e.named).length>0?t(...e.positional,e.named):t(...e.positional)}getDebugName(t){return t.name?`(helper function ${t.name})`:"(anonymous helper function)"}},Cu=new WeakMap,ku=new WeakMap,Su=new WeakMap,Eu=Object.getPrototypeOf;function Ru(t,e,n){return t.set(n,e),n}function Tu(t,e){let n=e;for(;null!==n;){const e=t.get(n);if(void 0!==e)return e;n=Eu(n)}}function Lu(t,e){return Ru(ku,t,e)}function Pu(t){const e=Tu(ku,t);return void 0===e?null:e}function Iu(t,e){return Ru(Su,t,e)}var Mu=new _u(()=>new xu);function Au(t){let e=Tu(Su,t);return void 0===e&&"function"==typeof t&&(e=Mu),e||null}function Ou(t,e){return Ru(Cu,t,e)}function Fu(t){const e=Tu(Cu,t);return void 0===e?null:e}function Nu(t){return void 0!==Tu(Cu,t)}function zu(t){return function(t){return"function"==typeof t}(t)||void 0!==Tu(Su,t)}function Du(t){return void 0!==Tu(ku,t)}var ju=Object.create;function Uu(){var t=ju(null);return t.__=void 0,delete t.__,t}var Bu=function(t,e,n){this.path=t,this.matcher=e,this.delegate=n};Bu.prototype.to=function(t,e){var n=this.delegate;if(n&&n.willAddRoute&&(t=n.willAddRoute(this.matcher.target,t)),this.matcher.add(this.path,t),e){if(0===e.length)throw new Error("You must have an argument in the function passed to `to`");this.matcher.addChild(this.path,t,e,this.delegate)}};var $u=function(t){this.routes=Uu(),this.children=Uu(),this.target=t};function qu(t,e,n){return function(r,i){var s=t+r;if(!i)return new Bu(s,e,n);i(qu(s,e,n))}}function Vu(t,e,n){for(var r=0,i=0;i0&&47===e.charCodeAt(0)&&(e=e.substr(1));for(var r=e.split("/"),i=void 0,s=void 0,o=0;o2&&"[]"===s.slice(o-2)&&(a=!0,n[s=s.slice(0,o-2)]||(n[s]=[])),l=i[1]?dh(i[1]):""),a?n[s].push(l):n[s]=l}return n},ph.prototype.recognize=function(t){var e,n=[this.rootState],r={},i=!1,s=t.indexOf("#");-1!==s&&(t=t.substr(0,s));var o=t.indexOf("?");if(-1!==o){var a=t.substr(o+1,t.length);t=t.substr(0,o),r=this.parseQueryString(a)}"/"!==t.charAt(0)&&(t="/"+t);var l=t;ph.ENCODE_AND_DECODE_PATH_SEGMENTS?t=Hu(t):(t=decodeURI(t),l=decodeURI(l));var c=t.length;c>1&&"/"===t.charAt(c-1)&&(t=t.substr(0,c-1),l=l.substr(0,l.length-1),i=!0);for(var u=0;u0){let i=t[r-1];if(function(t){if(t&&"object"==typeof t){let e=t;return"queryParams"in e&&Object.keys(e.queryParams).every(t=>"string"==typeof t)}return!1}(i))return n=i.queryParams,e=mh.call(t,0,r-1),[e,n]}return[t,null]}function wh(t){for(let e in t){let n=t[e];if("number"==typeof n)t[e]=String(n);else if(Array.isArray(n))for(let t=0,e=n.length;t{throw this.router.transitionDidError(t,this)},Eh("Handle Abort"))}else this.promise=na.resolve(this[Rh]),this[Th]={}}then(t,e,n){return this.promise.then(t,e,n)}catch(t,e){return this.promise.catch(t,e)}finally(t,e){return this.promise.finally(t,e)}abort(){this.rollback();let e=new t(this.router,void 0,void 0,void 0);return e.to=this.from,e.from=this.from,e.isAborted=!0,this.router.routeWillChange(e),this.router.routeDidChange(e),this}rollback(){this.isAborted||(_h(this.router,this.sequence,this.targetName+": transition was aborted"),void 0!==this.intent&&null!==this.intent&&(this.intent.preTransitionState=this.router.state),this.isAborted=!0,this.isActive=!1,this.router.activeTransition=void 0)}redirect(t){this[Ph]=t,this.rollback(),this.router.routeWillChange(t)}retry(){this.abort();let t=this.router.transitionByIntent(this.intent,!1);return null!==this.urlMethod&&t.method(this.urlMethod),t}method(t){return this.urlMethod=t,this}send(t=!1,e,n,r,i){this.trigger(t,e,n,r,i)}trigger(t=!1,e,...n){"string"==typeof t&&(e=t,t=!1),this.router.triggerEvent(this[Rh].routeInfos.slice(0,this.resolveIndex+1),t,e,n)}followRedirects(){return this.promise.catch(t=>this[Ph]?this[Ph].followRedirects():na.reject(t))}toString(){return"Transition (sequence "+this.sequence+")"}log(t){_h(this.router,this.sequence,t)}};function Mh(t){return _h(t.router,t.sequence,"detected abort."),fh()}function Ah(t){return"object"==typeof t&&t instanceof Ih&&t.isTransition}var Oh=function(){function t(e){let n=Error.call(this,e);this.name="UnrecognizedURLError",this.message=e||"UnrecognizedURL",Error.captureStackTrace?Error.captureStackTrace(this,t):this.stack=n.stack}return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}();function Fh(t,e){let n=t.factoryFor("controller:basic").class;n=class extends n{toString(){return`(generated ${e} controller)`}};let r=`controller:${e}`;return t.register(r,n),t.factoryFor(r)}function Nh(t,e){Fh(t,e);let n=`controller:${e}`;return t.lookup(n)}var zh=/\./g;function Dh(t){let e,n,r=(t=t.slice())[t.length-1];return function(t){if(t&&"object"==typeof t){let e=t.queryParams;if(e&&"object"==typeof e)return Object.keys(e).every(t=>"string"==typeof t)}return!1}(r)?(t.pop(),e=r.queryParams):e={},"string"==typeof t[0]&&(n=t.shift()),{routeName:n,models:t,queryParams:e}}function jh(t,e){if(e._namesStashed)return;let n,r=e[e.length-1].name,i=t._routerMicrolib.recognizer.handlersFor(r);for(let s=0;s(t[e]=n,t),s)}serializeQueryParamKey(t){return t}serializeQueryParam(t,e,n){return this._router._serializeQueryParam(t,n)}deserializeQueryParam(t,e,n){return this._router._deserializeQueryParam(t,n)}_optionsForQueryParam(t){const e=cr(this,"queryParams");return cr(e,t.urlKey)||cr(e,t.prop)||e[t.urlKey]||e[t.prop]||{}}resetController(t,e,n){return this}exit(t){this.deactivate(t),this.trigger("deactivate",t),this.teardownViews()}_internalReset(t,e){let n=this.controller;n._qpDelegate=cr(this,"_qp").states.inactive,this.resetController(n,t,e)}enter(t){this[Yh]=void 0,this.activate(t),this.trigger("activate",t)}deactivate(t){}activate(t){}intermediateTransitionTo(...t){let[e,...n]=function(t,e){let n,r=jr(t),i=r.mountPoint;if(r.routable&&"string"==typeof e[0]){if(n=e[0],qh(n))throw new Error("Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.");n=`${i}.${n}`,e[0]=n}return e}(this,t);this._router.intermediateTransitionTo(e,...n)}refresh(){return this._router._routerMicrolib.refresh(this)}setup(t,e){let n=this.controllerName||this.routeName,r=this.controllerFor(n,!0)??this.generateController(n),i=cr(this,"_qp");if(!this.controller){let t=i.propertyNames;!function(t,e){e.forEach(e=>{if(void 0===L(t,e)){let n=pr(t,e);null===n||"function"!=typeof n.get&&"function"!=typeof n.set||Nn(t,e,hu({get:n.get,set:n.set}))}hn(t,`${e}.[]`,t,t._qpChanged,!1)})}(r,t),this.controller=r}if(r._qpDelegate=i.states.allowOverrides,e){jh(this._router,e[Rh].routeInfos);let t=this._bucketCache,n=e[Th];i.propertyNames.forEach(e=>{let s=i.map[e];s.values=n;let o=Bh(s.route.fullRouteName,s.parts,s.values),a=t.lookup(o,e,s.undecoratedDefaultValue);fr(r,e,a)});let s=td(this,e[Rh]);Nr(r,s)}this.setupController(r,t,e),this._environment.options.shouldRender&&this[Zh](),bn(!1)}_qpChanged(t,e,n){if(!n)return;let r=this._bucketCache,i=Bh(n.route.fullRouteName,n.parts,n.values);r.stash(i,t,e)}beforeModel(t){}afterModel(t,e){}redirect(t,e){}contextDidChange(){this.currentModel=this.context}model(t,e){let n,r,i=cr(this,"_qp").map;for(let s in t){if("queryParams"===s||i&&s in i)continue;let t=s.match(/^(.*)_id$/);null!==t&&(n=t[1]),r=!0}if(!n){if(r)return Object.assign({},t);if(e.resolveIndex<1)return;return e[Rh].routeInfos[e.resolveIndex-1].context}}deserialize(t,e){return this.model(this._paramsFor(this.routeName,t),e)}setupController(t,e,n){t&&void 0!==e&&fr(t,"model",e)}controllerFor(t,e=!1){let n=jr(this),r=n.lookup(`route:${t}`);return r&&r.controllerName&&(t=r.controllerName),n.lookup(`controller:${t}`)}generateController(t){return Nh(jr(this),t)}modelFor(t){let e,n=jr(this),r=this._router&&this._router._routerMicrolib?this._router._routerMicrolib.activeTransition:void 0;e=n.routable&&void 0!==r?nd(n,t):t;let i=n.lookup(`route:${e}`);if(null!=r){let t=i&&i.routeName||e;if(Object.prototype.hasOwnProperty.call(r.resolvedModels,t))return r.resolvedModels[t]}return i?.currentModel}[Yh]=void 0;[Zh](){this[Yh]=function(t){let e,n=jr(t),r=t.routeName,i=n.lookup(`controller:${t.controllerName||r}`),s=t.currentModel,o=n.lookup(`template:${t.templateName||r}`);return e=o?Nu(o)?o:o(n):t._topLevelViewTemplate(n),{owner:n,name:r,controller:i,model:s,template:e}}(this),Ts(this._router,"_setOutlets")}willDestroy(){this.teardownViews()}teardownViews(){this[Yh]&&(this[Yh]=void 0,Ts(this._router,"_setOutlets"))}buildRouteInfoMetadata(){}_paramsFor(t,e){return void 0!==this._router._routerMicrolib.activeTransition?this.paramsFor(t):e}get _store(){const t=jr(this);return this.routeName,{find(e,n){let r=t.factoryFor(`model:${e}`);if(r)return r=r.class,r.find(n)}}}static{Gh(this.prototype,"_store",[Zn])}get _qp(){let t={},e=this.controllerName||this.routeName,n=jr(this),r=n.lookup(`controller:${e}`),i=cr(this,"queryParams"),s=Object.keys(i).length>0;r?t=function(t,e){let n={},r={defaultValue:!0,type:!0,scope:!0,as:!0};for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]={...t[i],...e[i]},r[i]=!0);for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&!r[i]&&(n[i]={...e[i],...t[i]});return n}(function(t){let e={};for(let n of t)$h(n,e);return e}(cr(r,"queryParams")||[]),i):s&&(r=Nh(n,e),t=i);let o=[],a={},l=[];for(let c in t){if(!Object.prototype.hasOwnProperty.call(t,c))continue;if("unknownProperty"===c||"_super"===c)continue;let n,i=t[c],s=i.scope||"model";"controller"===s&&(n=[]);let u=i.as||this.serializeQueryParamKey(c),h=cr(r,c);h=ed(h);let d=i.type||Cc(h),p=this.serializeQueryParam(h,u,d),f=`${e}:${c}`,g={undecoratedDefaultValue:cr(r,c),defaultValue:h,serializedDefaultValue:p,serializedValue:p,type:d,urlKey:u,prop:c,scopedPropertyName:f,controllerName:e,route:this,parts:n,values:null,scope:s};a[c]=a[u]=a[f]=g,o.push(g),l.push(c)}return{qps:o,map:a,propertyNames:l,states:{inactive:(t,e)=>{let n=a[t];this._qpChanged(t,e,n)},active:(t,e)=>{let n=a[t];return this._qpChanged(t,e,n),this._activeQPChanged(n,e)},allowOverrides:(t,e)=>{let n=a[t];return this._qpChanged(t,e,n),this._updatingQPChanged(n)}}}}static{Gh(this.prototype,"_qp",[Zn])}};function Jh(t){return t[Yh]}function Qh(t,e){if(e.fullQueryParams)return e.fullQueryParams;let n=e.routeInfos.every(t=>t.route),r={...e.queryParams};return t._deserializeQueryParams(e.routeInfos,r),n&&(e.fullQueryParams=r),r}function td(t,e){e.queryParamsFor=e.queryParamsFor||{};let n=t.fullRouteName,r=e.queryParamsFor[n];if(r)return r;let i=Qh(t._router,e),s=e.queryParamsFor[n]={},o=cr(t,"_qp").qps;for(let a of o){let t=a.prop in i;s[a.prop]=t?i[a.prop]:ed(a.defaultValue)}return s}function ed(t){return Array.isArray(t)?Kc(t.slice()):t}function nd(t,e){if(t.routable){let n=t.mountPoint;return"application"===e?n:`${n}.${e}`}return e}var rd=Xh.prototype.serialize;Xh.reopen({mergedProperties:["queryParams"],queryParams:{},templateName:null,controllerName:null,send(...t){if(this._router&&this._router._routerMicrolib||!nu())this._router.send(...t);else{let e=t.shift(),n=this.actions[e];if(n)return n.apply(this,t)}},actions:{queryParamsDidChange(t,e,n){let r=cr(this,"_qp").map,i=Object.keys(t).concat(Object.keys(n));for(let s of i){let t=r[s];if(t&&cr(this._optionsForQueryParam(t),"refreshModel")&&this._router.currentState){this.refresh();break}}return!0},finalizeQueryParamChange(t,e,n){if("application"!==this.fullRouteName)return!0;if(!n)return;let r,i=n[Rh].routeInfos,s=this._router,o=s._queryParamsFor(i),a=s._qpUpdates,l=!1;jh(s,i);for(let c of o.qps){let i,s,o=c.route,u=o.controller,h=c.urlKey in t&&c.urlKey;if(a.has(c.urlKey)?(i=cr(u,c.prop),s=o.serializeQueryParam(i,c.urlKey,c.type)):h?(s=t[h],void 0!==s&&(i=o.deserializeQueryParam(s,c.urlKey,c.type))):(s=c.serializedDefaultValue,i=ed(c.defaultValue)),u._qpDelegate=cr(o,"_qp").states.inactive,s!==c.serializedValue){if(n.queryParamsOnly&&!1!==r){let t=cr(o._optionsForQueryParam(c),"replace");t?r=!0:!1===t&&(r=!1)}fr(u,c.prop,i),l=!0}c.serializedValue=s,c.serializedDefaultValue!==s&&e.push({value:s,visible:!0,key:h||c.urlKey})}!0===l&&bn(!1),r&&n.method("replace"),o.qps.forEach(t=>{let e=cr(t.route,"_qp");t.route.controller._qpDelegate=cr(e,"states.active")}),s._qpUpdates.clear()}}});var id=0;function sd(t){return"function"==typeof t}var od=class t{parent;matches;enableLoadingSubstates;explicitIndex=!1;options;constructor(t=null,e){this.parent=t,this.enableLoadingSubstates=Boolean(e&&e.enableLoadingSubstates),this.matches=[],this.options=e}route(e,n,r){let i,s=null,o=`/_unused_dummy_error_path_route_${e}/:error`;if(sd(n)?(i={},s=n):sd(r)?(i=n,s=r):i=n||{},this.enableLoadingSubstates&&(ld(this,`${e}_loading`,{resetNamespace:i.resetNamespace}),ld(this,`${e}_error`,{resetNamespace:i.resetNamespace,path:o})),s){let n=ad(this,e,i.resetNamespace),r=new t(n,this.options);ld(r,"loading"),ld(r,"error",{path:o}),s.call(r),ld(this,e,i,r.generate())}else ld(this,e,i)}push(t,e,n,r){let i=e.split(".");if(this.options.engineInfo){let t=e.slice(this.options.engineInfo.fullName.length+1),n=Object.assign({localFullName:t},this.options.engineInfo);r&&(n.serializeMethod=r),this.options.addRouteForEngine(e,n)}else if(r)throw new Error(`Defining a route serializer on route '${e}' outside an Engine is not allowed.`);""!==t&&"/"!==t&&"index"!==i[i.length-1]||(this.explicitIndex=!0),this.matches.push(t,e,n)}generate(){let t=this.matches;return this.explicitIndex||this.route("index",{path:"/"}),e=>{for(let n=0;n0){let i=Object.assign({},n);return this.emberRouter._prepareQueryParams(t,e,i),Vh(i,r.queryParams)}return!0}},ud=new WeakMap;function hd(t,e={},n={includeAttributes:!1,localizeMapUpdates:!1}){const r=new WeakMap;return t.map((i,s)=>{let{name:o,params:a,paramNames:l,context:c,route:u}=i,h=i;if(ud.has(h)&&n.includeAttributes){let t=ud.get(h);t=function(t,e){let n={get metadata(){return pd(t)}};return!Object.isExtensible(e)||e.hasOwnProperty("metadata")?Object.freeze(Object.assign({},e,n)):Object.assign(e,n)}(u,t);let e=dd(t,c);return r.set(h,t),n.localizeMapUpdates||ud.set(h,e),e}const d=n.localizeMapUpdates?r:ud;let p={find(e,n){let r,i=[];3===e.length&&(i=t.map(t=>d.get(t)));for(let s=0;t.length>s;s++)if(r=d.get(t[s]),e.call(n,r,s,i))return r},get name(){return o},get paramNames(){return l},get metadata(){return pd(i.route)},get parent(){let e=t[s-1];return void 0===e?null:d.get(e)},get child(){let e=t[s+1];return void 0===e?null:d.get(e)},get localName(){let t=this.name.split(".");return t[t.length-1]},get params(){return a},get queryParams(){return e}};return n.includeAttributes&&(p=dd(p,c)),r.set(i,p),n.localizeMapUpdates||ud.set(i,p),p})}function dd(t,e){let n={get attributes(){return e}};return!Object.isExtensible(t)||t.hasOwnProperty("attributes")?Object.freeze(Object.assign({},t,n)):Object.assign(t,n)}function pd(t){return null!=t&&void 0!==t.buildRouteInfoMetadata?t.buildRouteInfoMetadata():null}var fd=class{_routePromise=void 0;_route=null;router;params={};isResolved=!1;constructor(t,e,n,r){this.name=e,this.paramNames=n,this.router=t,r&&this._processRoute(r)}getModel(t){return na.resolve(this.context)}serialize(t){return this.params||{}}resolve(t){return na.resolve(this.routePromise).then(e=>(gh(t),e)).then(()=>this.runBeforeModelHook(t)).then(()=>gh(t)).then(()=>this.getModel(t)).then(e=>(gh(t),e)).then(e=>this.runAfterModelHook(t,e)).then(e=>this.becomeResolved(t,e))}becomeResolved(t,e){let n,r=this.serialize(e);t&&(this.stashResolvedModel(t,e),t[Th]=t[Th]||{},t[Th][this.name]=r);let i=e===this.context;!("context"in this)&&i||(n=e);let s=ud.get(this),o=new gd(this.router,this.name,this.paramNames,r,this.route,n);return void 0!==s&&ud.set(o,s),o}shouldSupersede(t){if(!t)return!0;let e=t.context===this.context;return t.name!==this.name||"context"in this&&!e||this.hasOwnProperty("params")&&!function(t,e){if(t===e)return!0;if(!t||!e)return!1;for(let n in t)if(t.hasOwnProperty(n)&&t[n]!==e[n])return!1;return!0}(this.params,t.params)}get route(){return null!==this._route?this._route:this.fetchRoute()}set route(t){this._route=t}get routePromise(){return this._routePromise||this.fetchRoute(),this._routePromise}set routePromise(t){this._routePromise=t}log(t,e){t.log&&t.log(this.name+": "+e)}updateRoute(t){return t._internalName=this.name,this.route=t}runBeforeModelHook(t){let e;return t.trigger&&t.trigger(!0,"willResolveModel",t,this.route),this.route&&void 0!==this.route.beforeModel&&(e=this.route.beforeModel(t)),Ah(e)&&(e=null),na.resolve(e)}runAfterModelHook(t,e){let n,r=this.name;var i;return this.stashResolvedModel(t,e),void 0!==this.route&&void 0!==this.route.afterModel&&(n=this.route.afterModel(e,t)),n=Ah(i=n)?null:i,na.resolve(n).then(()=>t.resolvedModels[r])}stashResolvedModel(t,e){t.resolvedModels=t.resolvedModels||{},t.resolvedModels[this.name]=e}fetchRoute(){let t=this.router.getRoute(this.name);return this._processRoute(t)}_processRoute(t){return this.routePromise=na.resolve(t),function(t){return null!==t&&"object"==typeof t&&"function"==typeof t.then}(t)?(this.routePromise=this.routePromise.then(t=>this.updateRoute(t)),void(this.route=void 0)):t?this.updateRoute(t):void 0}},gd=class extends fd{isResolved;context;constructor(t,e,n,r,i,s){super(t,e,n,i),this.params=r,this.isResolved=!0,this.context=s}resolve(t){return t&&t.resolvedModels&&(t.resolvedModels[this.name]=this.context),na.resolve(this)}},md=class extends fd{params={};constructor(t,e,n,r,i){super(t,e,n,i),r&&(this.params=r)}getModel(t){let e=this.params;t&&t[Lh]&&(e={},vh(e,this.params),e.queryParams=t[Lh]);let n,r=this.route;return r.deserialize?n=r.deserialize(e,t):r.model&&(n=r.model(e,t)),n&&Ah(n)&&(n=void 0),na.resolve(n)}},yd=class extends fd{serializer;constructor(t,e,n,r){super(t,e,n),this.context=r,this.serializer=this.router.getSerializer(e)}getModel(t){return void 0!==this.router.log&&this.router.log(this.name+": resolving provided model"),super.getModel(t)}serialize(t){let{paramNames:e,context:n}=this;t||(t=n);let r={};if(xh(t))return r[e[0]]=t,r;if(this.serializer)return this.serializer.call(null,t,e);if(void 0!==this.route&&this.route.serialize)return this.route.serialize(t,e);if(1!==e.length)return;let i=e[0];return/_id$/.test(i)?r[i]=t.id:r[i]=t,r}},vd=class{data;router;constructor(t,e={}){this.router=t,this.data=e}preTransitionState};function bd(t,e,n){let r=t.routeInfos,i=e.resolveIndex>=r.length?r.length-1:e.resolveIndex,s=e.isAborted;throw new Cd(n,t.routeInfos[i].route,s,t)}function wd(t,e){if(e.resolveIndex===t.routeInfos.length)return;let n=t.routeInfos[e.resolveIndex],r=_d.bind(null,t,e);return n.resolve(e).then(r,null,t.promiseLabel("Proceed"))}function _d(t,e,n){let r=t.routeInfos[e.resolveIndex].isResolved;if(t.routeInfos[e.resolveIndex++]=n,!r){let{route:t}=n;void 0!==t&&t.redirect&&t.redirect(n.context,e)}return gh(e),wd(t,e)}var xd=class{routeInfos=[];queryParams={};params={};promiseLabel(t){let e="";return Ch(this.routeInfos,function(t){return""!==e&&(e+="."),e+=t.name,!0}),Eh("'"+e+"': "+t)}resolve(t){let e=this.params;Ch(this.routeInfos,t=>(e[t.name]=t.params||{},!0)),t.resolveIndex=0;let n=wd.bind(null,this,t),r=bd.bind(null,this,t);return na.resolve(null,this.promiseLabel("Start transition")).then(n,null,this.promiseLabel("Resolve route")).catch(r,this.promiseLabel("Handle error")).then(()=>this)}},Cd=class{constructor(t,e,n,r){this.error=t,this.route=e,this.wasAborted=n,this.state=r}},kd=class extends vd{name;pivotHandler;contexts;queryParams;preTransitionState=void 0;constructor(t,e,n,r=[],i={},s){super(t,s),this.name=e,this.pivotHandler=n,this.contexts=r,this.queryParams=i}applyToState(t,e){let n=this.router.recognizer.handlersFor(this.name),r=n[n.length-1].handler;return this.applyToHandlers(t,n,r,e,!1)}applyToHandlers(t,e,n,r,i){let s,o,a=new xd,l=this.contexts.slice(0),c=e.length;if(this.pivotHandler)for(s=0,o=e.length;s=0;--s){let o=e[s],u=o.handler,h=t.routeInfos[s],d=null;if(d=o.names.length>0?s>=c?this.createParamHandlerInfo(u,o.names,l,h):this.getHandlerInfoForDynamicSegment(u,o.names,l,h,n,s):this.createParamHandlerInfo(u,o.names,l,h),i){d=d.becomeResolved(null,d.context);let t=h&&h.context;o.names.length>0&&void 0!==h.context&&d.context===t&&(d.params=h&&h.params),d.context=t}let p=h;(s>=c||d.shouldSupersede(h))&&(c=Math.min(s,c),p=d),r&&!i&&(p=p.becomeResolved(null,p.context)),a.routeInfos.unshift(p)}if(l.length>0)throw new Error("More context objects were passed than there are dynamic segments for the route: "+n);return r||this.invalidateChildren(a.routeInfos,c),vh(a.queryParams,this.queryParams||{}),r&&t.queryParams&&vh(a.queryParams,t.queryParams),a}invalidateChildren(t,e){for(let n=e,r=t.length;n0){if(o=n[n.length-1],xh(o))return this.createParamHandlerInfo(t,e,n,r);n.pop()}else{if(r&&r.name===t)return r;if(!this.preTransitionState)return r;o=this.preTransitionState.routeInfos[s]?.context}return new yd(this.router,t,e,o)}createParamHandlerInfo(t,e,n,r){let i={},s=e.length,o=[];for(;s--;){let a=r&&t===r.name&&r.params||{},l=n[n.length-1],c=e[s];xh(l)?i[c]=String(n.pop()):a.hasOwnProperty(c)?i[c]=a[c]:o.push(c)}if(o.length>0)throw new Error(`You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route ${t}. Missing params: ${o}`);return new md(this.router,t,e,i)}},Sd=class extends vd{preTransitionState;url;constructor(t,e,n){super(t,n),this.url=e,this.preTransitionState=void 0}applyToState(t){let e,n,r=new xd,i=this.router.recognizer.recognize(this.url);if(!i)throw new Oh(this.url);let s=!1,o=this.url;function a(t){if(t&&t.inaccessibleByURL)throw new Oh(o);return t}for(e=0,n=i.length;e=0&&r;--n){let i=e[n],s=i.handler;t.add(e,{as:s}),r="/"===i.path||""===i.path||".index"===s.slice(-6)}})}hasRoute(t){return this.recognizer.hasRoute(t)}queryParamsTransition(t,e,n,r){if(this.fireQueryParamDidChange(r,t),!e&&this.activeTransition)return this.activeTransition;{let t=new Ih(this,void 0,void 0);return t.queryParamsOnly=!0,n.queryParams=this.finalizeQueryParamChange(r.routeInfos,r.queryParams,t),t[Lh]=r.queryParams,this.toReadOnlyInfos(t,r),this.routeWillChange(t),t.promise=t.promise.then(e=>(t.isAborted||(this._updateURL(t,n),this.didTransition(this.currentRouteInfos),this.toInfos(t,r.routeInfos,!0),this.routeDidChange(t)),e),null,Eh("Transition complete")),t}}transitionByIntent(t,e){try{return this.getTransitionByIntent(t,e)}catch(n){return new Ih(this,t,void 0,n,void 0)}}recognize(t){let e=new Sd(this,t),n=this.generateNewState(e);if(null===n)return n;let r=hd(n.routeInfos,n.queryParams,{includeAttributes:!1,localizeMapUpdates:!0});return r[r.length-1]}recognizeAndLoad(t){let e=new Sd(this,t),n=this.generateNewState(e);if(null===n)return na.reject(`URL ${t} was not recognized`);let r=new Ih(this,e,n,void 0);return r.then(()=>{let t=hd(n.routeInfos,r[Lh],{includeAttributes:!0,localizeMapUpdates:!1});return t[t.length-1]})}generateNewState(t){try{return t.applyToState(this.state,!1)}catch(e){return null}}getTransitionByIntent(t,e){let n,r=Boolean(this.activeTransition),i=r?this.activeTransition[Rh]:this.state,s=t.applyToState(i,e),o=kh(i.queryParams,s.queryParams);if(Rd(s.routeInfos,i.routeInfos)){if(o){let t=this.queryParamsTransition(o,r,i,s);return t.queryParamsOnly=!0,t}return this.activeTransition||new Ih(this,void 0,void 0)}if(e){let t=new Ih(this,void 0,s);return t.isIntermediate=!0,this.toReadOnlyInfos(t,s),this.setupContexts(s,t),this.routeWillChange(t),this.activeTransition}return n=new Ih(this,t,s,void 0,this.activeTransition),function(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;nthis.finalizeTransition(n,t),null,Eh("Settle transition promise when transition is finalized")),r||this.notifyExistingHandlers(s,n),this.fireQueryParamDidChange(s,o),n}doTransition(t,e=[],n=!1){let r,i=e[e.length-1],s={};if(i&&Object.prototype.hasOwnProperty.call(i,"queryParams")&&(s=e.pop().queryParams),void 0===t){_h(this,"Updating query params");let{routeInfos:t}=this.state;r=new kd(this,t[t.length-1].name,void 0,[],s)}else"/"===t.charAt(0)?(_h(this,"Attempting URL transition to "+t),r=new Sd(this,t)):(_h(this,"Attempting transition to "+t),r=new kd(this,t,void 0,e,s));return this.transitionByIntent(r,n)}finalizeTransition(t,e){try{_h(t.router,t.sequence,"Resolved all models on destination route; finalizing transition.");let n=e.routeInfos;return this.setupContexts(e,t),t.isAborted?(this.state.routeInfos=this.currentRouteInfos,na.reject(Mh(t))):(this._updateURL(t,e),t.isActive=!1,this.activeTransition=void 0,this.triggerEvent(this.currentRouteInfos,!0,"didTransition",[]),this.didTransition(this.currentRouteInfos),this.toInfos(t,e.routeInfos,!0),this.routeDidChange(t),_h(this,t.sequence,"TRANSITION COMPLETE."),n[n.length-1].route)}catch(r){if("object"!=typeof(n=r)||null===n||"TRANSITION_ABORTED"!==n.code){let e=t[Rh].routeInfos;t.trigger(!0,"error",r,t,e[e.length-1].route),t.abort()}throw r}var n}setupContexts(t,e){let n,r,i,s=this.partitionRoutes(this.state,t);for(n=0,r=s.exited.length;n=0;--o){let t=r[o];vh(s,t.params),t.route.inaccessibleByURL&&(n=null)}if(n){s.queryParams=t._visibleQueryParams||e.queryParams;let r=this.recognizer.generate(i,s),o=t.isCausedByInitialTransition,a="replace"===n&&!t.isCausedByAbortingTransition,l=t.queryParamsOnly&&"replace"===n,c="replace"===n&&t.isCausedByAbortingReplaceTransition;o||a||l||c?this.replaceURL(r):this.updateURL(r)}}finalizeQueryParamChange(t,e,n){for(let s in e)e.hasOwnProperty(s)&&null===e[s]&&delete e[s];let r=[];this.triggerEvent(t,!0,"finalizeQueryParamChange",[e,r,n]),n&&(n._visibleQueryParams={});let i={};for(let s=0,o=r.length;s0){let n=hd(e,Object.assign({},this._lastQueryParams),{includeAttributes:!0,localizeMapUpdates:!1});t.from=n[n.length-1]||null}}toInfos(t,e,n=!1){if(void 0!==t&&e.length>0){let r=hd(e,Object.assign({},t[Lh]),{includeAttributes:n,localizeMapUpdates:!1});t.to=r[r.length-1]||null}}notifyExistingHandlers(t,e){let n,r,i,s,o=this.state.routeInfos;for(r=o.length,n=0;n{t.setURL(n),fr(e,"currentURL",n)})}didTransition(t){e.didTransition(t)}willTransition(t,n){e.willTransition(t,n)}triggerEvent(t,n,r,i){return zd.bind(e)(t,n,r,i)}routeWillChange(t){e.trigger("routeWillChange",t),e._routerService.trigger("routeWillChange",t),t.isIntermediate&&e.set("currentRoute",t.to)}routeDidChange(t){e.set("currentRoute",t.to),Ts(()=>{e.trigger("routeDidChange",t),e._routerService.trigger("routeDidChange",t)})}transitionDidError(t,n){return t.wasAborted||n.isAborted?Mh(n):(n.trigger(!1,"error",t.error,n,t.route),e._isErrorHandled(t.error)?(n.rollback(),this.routeDidChange(n),t.error):(n.abort(),t.error))}replaceURL(n){t.replaceURL?Ts(()=>{t.replaceURL(n),fr(e,"currentURL",n)}):this.updateURL(n)}},s=this.constructor.dslCallbacks||[Ld],o=this._buildDSL();o.route("application",{path:"/",resetNamespace:!0,overrideNameAssertion:!0},function(){for(let t=0;tn.factoryFor(`route-map:${t}`),addRouteForEngine(t,n){e._engineInfoByRoute[t]||(e._engineInfoByRoute[t]=n)}})}_resetQueuedQueryParameterChanges(){this._queuedQPChanges={}}_hasModuleBasedResolver(){let t=cr(Lo(this),"application.__registry__.resolver.moduleBasedResolver");return Boolean(t)}startRouting(){if(this.setupRouter()){let t=cr(this,"initialURL");void 0===t&&(t=cr(this,"location").getURL());let e=this.handleURL(t);if(e&&e.error)throw e.error}}setupRouter(){if(this._didSetupRouter)return!1;this._didSetupRouter=!0,this._setupLocation();let t=cr(this,"location");return!cr(t,"cancelRouterSetup")&&(this._initRouterJs(),t.onUpdateURL(t=>{this.handleURL(t)}),!0)}_setOutlets(){if(this.isDestroying||this.isDestroyed)return;let t=this._routerMicrolib.currentRouteInfos;if(!t)return;let e=null,n=null;for(let r of t){let t=Jh(r.route);if(!t)break;{let r={render:t,outlets:{main:void 0}};n?n.outlets.main=r:e=r,n=r}}if(null!==e)if(this._toplevelView)this._toplevelView.setOutletState(e);else{let t=Lo(this),n=t.factoryFor("view:-outlet"),r=t.lookup("application:main"),i=t.lookup("-environment:main"),s=t.lookup("template:-outlet");this._toplevelView=n.create({environment:i,template:s,application:r}),this._toplevelView.setOutletState(e),t.lookup("-application-instance:main").didCreateRootView(this._toplevelView)}}handleURL(t){let e=t.split(/#(.+)?/)[0];return this._doURLTransition("handleURL",e)}_doURLTransition(t,e){this._initialTransitionStarted=!0;let n=this._routerMicrolib[t](e||"/");return Ud(n,this),n}transitionTo(...t){if(qh(t[0]))return this._doURLTransition("transitionTo",t[0]);let{routeName:e,models:n,queryParams:r}=Dh(t);return this._doTransition(e,n,r)}intermediateTransitionTo(t,...e){this._routerMicrolib.intermediateTransitionTo(t,...e),jd(this)}replaceWith(...t){return this.transitionTo(...t).method("replace")}generate(t,...e){let n=this._routerMicrolib.generate(t,...e);return this.location.formatURL(n)}isActive(t){return this._routerMicrolib.isActive(t)}isActiveIntent(t,e,n){return this.currentState.isActiveIntent(t,e,n)}send(t,...e){this._routerMicrolib.trigger(t,...e)}hasRoute(t){return this._routerMicrolib.hasRoute(t)}reset(){this._didSetupRouter=!1,this._initialTransitionStarted=!1,this._routerMicrolib&&this._routerMicrolib.reset()}willDestroy(){this._toplevelView&&(this._toplevelView.destroy(),this._toplevelView=null),super.willDestroy(),this.reset();let t=this._engineInstances;for(let e in t){let n=t[e];for(let t in n)bs(n[t],"destroy")}}_activeQPChanged(t,e){this._queuedQPChanges[t]=e,Ts(this,this._fireQueryParamTransition)}_updatingQPChanged(t){this._qpUpdates.add(t)}_fireQueryParamTransition(){this.transitionTo({queryParams:this._queuedQPChanges}),this._resetQueuedQueryParameterChanges()}_setupLocation(){let t=this.location,e=this.rootURL,n=Lo(this);"string"==typeof t&&(t=fr(this,"location",n.lookup(`location:${t}`))),null!==t&&"object"==typeof t&&(e&&fr(t,"rootURL",e),"function"==typeof t.initState&&t.initState())}_serializeQueryParams(t,e){Bd(this,t,e,(t,n,r)=>{if(r)delete e[t],e[r.urlKey]=r.route.serializeQueryParam(n,r.urlKey,r.type);else{if(void 0===n)return;e[t]=this._serializeQueryParam(n,Cc(n))}})}_serializeQueryParam(t,e){return null==t?t:"array"===e?JSON.stringify(t):`${t}`}_deserializeQueryParams(t,e){Bd(this,t,e,(t,n,r)=>{r&&(delete e[t],e[r.prop]=r.route.deserializeQueryParam(n,r.urlKey,r.type))})}_deserializeQueryParam(t,e){return null==t?t:"boolean"===e?"true"===t:"number"===e?Number(t).valueOf():"array"===e?Kc(JSON.parse(t)):t}_pruneDefaultQueryParamValues(t,e){let n=this._queryParamsFor(t);for(let r in e){let t=n.map[r];t&&t.serializedDefaultValue===e[r]&&delete e[r]}}_doTransition(t,e,n,r){let i=t||function(t){let e=t.activeTransition?t.activeTransition[Rh].routeInfos:t.state.routeInfos;return e[e.length-1].name}(this._routerMicrolib);this._initialTransitionStarted=!0;let s={};this._processActiveTransitionQueryParams(i,e,s,n),Object.assign(s,n),this._prepareQueryParams(i,e,s,Boolean(r));let o=this._routerMicrolib.transitionTo(i,...e,{queryParams:s});return Ud(o,this),o}_processActiveTransitionQueryParams(t,e,n,r){if(!this._routerMicrolib.activeTransition)return;let i={},s=this._qpUpdates,o=Qh(this,this._routerMicrolib.activeTransition[Rh]);for(let a in o)s.has(a)||(i[a]=o[a]);this._fullyScopeQueryParams(t,e,r),this._fullyScopeQueryParams(t,e,i),Object.assign(n,i)}_prepareQueryParams(t,e,n,r){let i=Dd(this,t,e);this._hydrateUnsuppliedQueryParams(i,n,Boolean(r)),this._serializeQueryParams(i.routeInfos,n),r||this._pruneDefaultQueryParamValues(i.routeInfos,n)}_getQPMeta(t){let e=t.route;return e&&cr(e,"_qp")}_queryParamsFor(t){let e=t[t.length-1].name,n=this._qpCache[e];if(void 0!==n)return n;let r,i=!0,s={},o=[];for(let l of t)if(r=this._getQPMeta(l),r){for(let t of r.qps)o.push(t);Object.assign(s,r.map)}else i=!1;let a={qps:o,map:s};return i&&(this._qpCache[e]=a),a}_fullyScopeQueryParams(t,e,n){let r,i=Dd(this,t,e).routeInfos;for(let s of i)if(r=this._getQPMeta(s),r)for(let t of r.qps){let e=t.prop in n&&t.prop||t.scopedPropertyName in n&&t.scopedPropertyName||t.urlKey in n&&t.urlKey;e&&e!==t.scopedPropertyName&&(n[t.scopedPropertyName]=n[e],delete n[e])}}_hydrateUnsuppliedQueryParams(t,e,n){let r,i,s,o=t.routeInfos,a=this._bucketCache;for(let l of o)if(r=this._getQPMeta(l),r)for(let n=0,o=r.qps.length;n=0;--n){let r=t[n],i=r.route;if(void 0!==i&&!0!==e(i,r))return}}var Ad={willResolveModel(t,e,n){this._scheduleLoadingEvent(e,n)},error(t,e,n){let r=this,i=t[t.length-1];Md(t,(t,n)=>{if(n!==i){let n=Fd(t,"error");if(n)return r._markErrorAsHandled(e),r.intermediateTransitionTo(n,e),!1}let s=Od(t,"error");return!s||(r._markErrorAsHandled(e),r.intermediateTransitionTo(s,e),!1)}),function(t,e){let n,r=[];n=t&&"object"==typeof t&&"object"==typeof t.errorThrown?t.errorThrown:t,e&&r.push(e),n&&(n.message&&r.push(n.message),n.stack&&r.push(n.stack),"string"==typeof n&&r.push(n)),console.error(...r)}(e,`Error while processing route: ${n.targetName}`)},loading(t,e){let n=this,r=t[t.length-1];Md(t,(t,i)=>{if(i!==r){let e=Fd(t,"loading");if(e)return n.intermediateTransitionTo(e),!1}let s=Od(t,"loading");return s?(n.intermediateTransitionTo(s),!1):e.pivotHandler!==t})}};function Od(t,e){let n=Lo(t),{routeName:r,fullRouteName:i,_router:s}=t,o=`${i}_${e}`;return Nd(n,s,`${r}_${e}`,o)?o:""}function Fd(t,e){let n=Lo(t),{routeName:r,fullRouteName:i,_router:s}=t,o="application"===i?e:`${i}.${e}`;return Nd(n,s,"application"===r?e:`${r}.${e}`,o)?o:""}function Nd(t,e,n,r){let i=e.hasRoute(r),s=t.factoryFor(`template:${n}`)||t.factoryFor(`route:${n}`);return i&&s}function zd(t,e,n,r){if(!t){if(e)return;throw new Error(`Can't trigger action '${n}' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call \`.send()\` on the \`Transition\` object passed to the \`model/beforeModel/afterModel\` hooks.`)}let i,s,o,a=!1;for(let c=t.length-1;c>=0;c--)if(i=t[c],s=i.route,o=s&&s.actions&&s.actions[n],o){if(!0!==o.apply(s,r))return void("error"===n&&s._router._markErrorAsHandled(r[0]));a=!0}let l=Ad[n];if(l)l.call(this,t,...r);else if(!a&&!e)throw new Error(`Nothing handled the action '${n}'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.`)}function Dd(t,e,n){let r=t._routerMicrolib.applyIntent(e,n),{routeInfos:i,params:s}=r;for(let o of i)o.isResolved?s[o.name]=o.params:s[o.name]=o.serialize(o.context);return r}function jd(t){let e=t._routerMicrolib.currentRouteInfos;if(0===e.length)return;let n=Id._routePath(e),r=e[e.length-1].name,i=t.location.getURL();fr(t,"currentPath",n),fr(t,"currentRouteName",r),fr(t,"currentURL",i)}function Ud(t,e){let n=new cd(e,e._routerMicrolib,t[Rh]);e.currentState||e.set("currentState",n),e.set("targetState",n),t.promise=t.catch(t=>{if(!e._isErrorHandled(t))throw t;e._clearHandledError(t)},"Transition Error")}function Bd(t,e,n,r){let i=t._queryParamsFor(e);for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&r(s,n[s],i.map[s])}function $d(t){return void 0!==t.hash?t.hash.substring(0):""}Id.reopen({didTransition:function(){jd(this),this._cancelSlowTransitionTimer(),this.notifyPropertyChange("url"),this.set("currentState",this.targetState)},willTransition:function(){},rootURL:"/",location:"hash",url:Zn(function(){let t=cr(this,"location");if("string"!=typeof t)return t.getURL()})});var qd=class extends jl{_hashchangeHandler;_location;init(){this.location=this._location??window.location,this._hashchangeHandler=void 0}getHash(){return $d(this.location)}getURL(){let t=this.getHash().substring(1),e=t;return"/"!==e[0]&&(e="/",t&&(e+=`#${t}`)),e}setURL(t){this.location.hash=t,this.lastSetURL=t}replaceURL(t){this.location.replace(`#${t}`),this.lastSetURL=t}lastSetURL=null;onUpdateURL(t){this._removeEventListener(),this._hashchangeHandler=_s(this,function(){let e=this.getURL();this.lastSetURL!==e&&(this.lastSetURL=null,t(e))}),window.addEventListener("hashchange",this._hashchangeHandler)}formatURL(t){return`#${t}`}willDestroy(){this._removeEventListener()}_removeEventListener(){this._hashchangeHandler&&window.removeEventListener("hashchange",this._hashchangeHandler)}};function Vd(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){let e,n;return e=16*Math.random()|0,n="x"===t?e:3&e|8,n.toString(16)})}var Wd=class extends jl{history;_popstateHandler;rootURL="/";getHash(){return $d(this.location)}init(){this._super(...arguments);let t=document.querySelector("base"),e="";null!==t&&t.hasAttribute("href")&&(e=t.getAttribute("href")??""),this.baseURL=e,this.location=this.location??window.location,this._popstateHandler=void 0}initState(){let t=this.history??window.history;this.history=t;let{state:e}=t,n=this.formatURL(this.getURL());e&&e.path===n||this.replaceState(n)}getURL(){let{location:t,rootURL:e,baseURL:n}=this,r=t.pathname;e=e.replace(/\/$/,""),n=n.replace(/\/$/,"");let i=r.replace(new RegExp(`^${n}(?=/|$)`),"").replace(new RegExp(`^${e}(?=/|$)`),"").replace(/\/\//g,"/");return i+=(t.search||"")+this.getHash(),i}setURL(t){let{state:e}=this.history;t=this.formatURL(t),e&&e.path===t||this.pushState(t)}replaceURL(t){let{state:e}=this.history;t=this.formatURL(t),e&&e.path===t||this.replaceState(t)}pushState(t){let e={path:t,uuid:Vd()};this.history.pushState(e,"",t)}replaceState(t){let e={path:t,uuid:Vd()};this.history.replaceState(e,"",t)}onUpdateURL(t){this._removeEventListener(),this._popstateHandler=()=>{t(this.getURL())},window.addEventListener("popstate",this._popstateHandler)}formatURL(t){let{rootURL:e,baseURL:n}=this;return""!==t?(e=e.replace(/\/$/,""),n=n.replace(/\/$/,"")):"/"===n[0]&&"/"===e[0]&&(n=n.replace(/\/$/,"")),n+e+t}willDestroy(){this._removeEventListener()}_removeEventListener(){this._popstateHandler&&window.removeEventListener("popstate",this._popstateHandler)}},Hd=class extends jl{updateCallback;initState(){this._super(...arguments);let{rootURL:t}=this}getURL(){let{path:t,rootURL:e}=this;return e=e.replace(/\/$/,""),t.replace(new RegExp(`^${e}(?=/|$)`),"")}setURL(t){this.path=t}onUpdateURL(t){this.updateCallback=t}handleURL(t){this.path=t,this.updateCallback&&this.updateCallback(t)}formatURL(t){let{rootURL:e}=this;return""!==t&&(e=e.replace(/\/$/,"")),e+t}};function Gd(t,e){return(t,...n)=>{let r=function(t,e){let n=[];function r(t){n.push(t)}for(let i of e)On(i,r);return n}(0,[t,...n]);return Zn(...r,function(){let t=r.length-1;for(let n=0;nt),Gd(0,t=>!t);var Zd=/[ _]/g,Yd=new ir(1e3,t=>{return(e=t,np.get(e)).replace(Zd,"-");var e}),Xd=/^(-|_)+(.)?/,Jd=/(.)(-|_|\.|\s)+(.)?/g,Qd=/(^|\/|\.)([a-z])/g,tp=new ir(1e3,t=>{let e=(t,e,n)=>n?`_${n.toUpperCase()}`:"",n=(t,e,n,r)=>e+(r?r.toUpperCase():""),r=t.split("/");for(let i=0;it.toUpperCase())}),ep=/([a-z\d])([A-Z])/g,np=new ir(1e3,t=>t.replace(ep,"$1_$2").toLowerCase());function rp(t){return Yd.get(t)}function ip(t){return Object.hasOwnProperty.call(t.since,"enabled")||A._ALL_DEPRECATIONS_ENABLED}var sp=parseFloat(A._OVERRIDE_DEPRECATION_VERSION??"7.2.0");function op(t){return function(t,e=sp){let n=t.replace(/(\.0+)/g,"");return e>=parseFloat(n)}(t.until)}function ap(t){return{options:t,test:!ip(t),isEnabled:ip(t)||op(t),isRemoved:op(t)}}var lp={DEPRECATE_IMPORT_EMBER:t=>ap({id:`deprecate-import-${rp(t).toLowerCase()}-from-ember`,for:"ember-source",since:{available:"5.10.0",enabled:"6.5.0"},until:"7.0.0",url:`https://deprecations.emberjs.com/id/import-${rp(t).toLowerCase()}-from-ember`}),DEPRECATE_IMPORT_INJECT:ap({for:"ember-source",id:"importing-inject-from-ember-service",since:{available:"6.2.0",enabled:"6.3.0"},until:"7.0.0",url:"https://deprecations.emberjs.com/id/importing-inject-from-ember-service"})},cp=a({default:()=>dp,inject:()=>up,service:()=>hp});function up(...t){return function(t,e){const{options:n}=e;if(e.isRemoved)throw new Error(`The API deprecated by ${n.id} was removed in ember-source ${n.until}. The message was: Importing \`inject\` from \`@ember/service\` is deprecated. Please import \`service\` instead.. Please see ${n.url} for more details.`)}(0,lp.DEPRECATE_IMPORT_INJECT),Br("service",...t)}function hp(...t){return Br("service",...t)}var dp=class extends Zc{static isServiceFactory=!0},pp=Symbol("ROUTER");function fp(t,e){return"/"===e?t:t.substring(e.length)}var gp=class extends(dp.extend(yc)){[pp];get _router(){let t=this[pp];if(void 0!==t)return t;let e=jr(this).lookup("router:main");return this[pp]=e}willDestroy(){super.willDestroy(),this[pp]=void 0}transitionTo(...t){if(qh(t[0]))return this._router._doURLTransition("transitionTo",t[0]);let{routeName:e,models:n,queryParams:r}=Dh(t);return this._router._doTransition(e,n,r,!0)}replaceWith(...t){return this.transitionTo(...t).method("replace")}urlFor(t,...e){return this._router.setupRouter(),this._router.generate(t,...e)}isActive(...t){let{routeName:e,models:n,queryParams:r}=Dh(t);this._router.setupRouter();let i=this._router._routerMicrolib;if(Ot(Gt(this._router,"currentURL")),!i.isActiveIntent(e,n))return!1;if(Object.keys(r).length>0){let t=e;r=Object.assign({},r),this._router._prepareQueryParams(t,n,r,!0);let s=Object.assign({},i.state.queryParams);return this._router._prepareQueryParams(t,n,s,!0),Vh(r,s)}return!0}recognize(t){this._router.setupRouter();let e=fp(t,this.rootURL);return this._router._routerMicrolib.recognize(e)}recognizeAndLoad(t){this._router.setupRouter();let e=fp(t,this.rootURL);return this._router._routerMicrolib.recognizeAndLoad(e)}refresh(t){if(!t)return this._router._routerMicrolib.refresh();let e=jr(this).lookup(`route:${t}`);return this._router._routerMicrolib.refresh(e)}static{Hh(this.prototype,"currentRouteName",[Kd("_router.currentRouteName")])}#o=void Kh(this,"currentRouteName");static{Hh(this.prototype,"currentURL",[Kd("_router.currentURL")])}#a=void Kh(this,"currentURL");static{Hh(this.prototype,"location",[Kd("_router.location")])}#l=void Kh(this,"location");static{Hh(this.prototype,"rootURL",[Kd("_router.rootURL")])}#c=void Kh(this,"rootURL");static{Hh(this.prototype,"currentRoute",[Kd("_router.currentRoute")])}#u=void Kh(this,"currentRoute")},mp=class extends dp{[pp];get router(){let t=this[pp];if(void 0!==t)return t;let e=jr(this).lookup("router:main");return e.setupRouter(),this[pp]=e}hasRoute(t){return this.router.hasRoute(t)}transitionTo(t,e,n,r){let i=this.router._doTransition(t,e,n);return r&&i.method("replace"),i}normalizeQueryParams(t,e,n){this.router._prepareQueryParams(t,e,n)}_generateURL(t,e,n){let r={};return n&&(Object.assign(r,n),this.normalizeQueryParams(t,e,r)),this.router.generate(t,...e,{queryParams:r})}generateURL(t,e,n){if(this.router._initialTransitionStarted)return this._generateURL(t,e,n);try{return this._generateURL(t,e,n)}catch(r){return}}isActiveForRoute(t,e,n,r){let i=this.router._routerMicrolib.recognizer.handlersFor(n),s=i[i.length-1].handler,o=function(t,e){let n=0;for(let r=0;ro&&(n=s),r.isActiveIntent(n,t,e)}};mp.reopen({targetState:Kd("router.targetState"),currentState:Kd("router.currentState"),currentRouteName:Kd("router.currentRouteName"),currentPath:Kd("router.currentPath")});var yp=class{cache;constructor(){this.cache=new Map}has(t){return this.cache.has(t)}stash(t,e,n){let r=this.cache.get(t);void 0===r&&(r=new Map,this.cache.set(t,r)),r.set(e,n)}lookup(t,e,n){if(!this.has(t))return n;let r=this.cache.get(t);return r.has(e)?r.get(e):n}},vp=Io?self:null,bp=Io?self.location:null,wp=Io?self.history:null,_p=Io?self.navigator.userAgent:"Lynx (textmode)",xp=!(!Io||"object"!=typeof chrome||"object"==typeof opera),Cp=!!Io&&/Firefox|FxiOS/.test(_p),kp=Object.freeze(Object.defineProperty({__proto__:null,hasDOM:Io,history:wp,isChrome:xp,isFirefox:Cp,location:bp,userAgent:_p,window:vp},Symbol.toStringTag,{value:"Module"})),Sp=-536870913;function Ep(t){return(t|=0)<0?function(t){return t&Sp}(t):function(t){return~t}(t)}function Rp(t){return(t|=0)>Sp?function(t){return~t}(t):function(t){return 536870912|t}(t)}function Tp(t){if("number"==typeof t)return t;{let e=t.errors[0];throw new Error(`Compile Error: ${e.problem} @ ${e.span.start}..${e.span.end}`)}}function Lp(t){if("error"===t.result)throw new Error(`Compile Error: ${t.problem} @ ${t.span.start}..${t.span.end}`);return t}[1,-1].forEach(t=>Rp(Ep(t)));var Pp=new WeakMap,Ip=Reflect.getPrototypeOf;function Mp(t,e){return Pp.set(e,t),e}function Ap(t){let e=t;for(;null!==e;){let t=Pp.get(e);if(void 0!==t)return t;e=Ip(e)}}var Op=Object.assign;function Fp(t){return Object.values(t)}function Np(t){return Object.entries(t)}function zp(t){return Object.keys(t)}var Dp=Object.freeze([]);function jp(){return Dp}var Up=jp(),Bp=jp();function $p(t){return t===Dp}function*qp(t){for(let e=t.length-1;e>=0;e--)yield t[e]}function*Vp(t){let e=0;for(const n of t)yield[e++,n]}function*Wp(t,e){for(let n=0;n255)throw new Error(`Opcode type over 8-bits. Got ${t}.`);let r=t|e|arguments.length-2<<8;this.buffer.push(r);for(const i of n)this.buffer.push(i);this.size=this.buffer.length}patch(t,e){if(-1!==this.buffer[t+1])throw new Error("Trying to patch operand in populated slot instead of a reserved slot.");this.buffer[t+1]=e}},Zp=32,Yp=31;function Xp(t){return e=>{if(!function(t){return Array.isArray(t)&&2===t.length}(e))return!1;let n=e[0];return n===Yp||n===Zp||n===t}}var Jp=Xp(39),Qp=Xp(38),tf=Xp(37),ef=Xp(35);function nf(t,e,n,r){let{symbols:{upvars:i}}=n,s=i[t[1]],o=e?.lookupBuiltInHelper?.(s)??null;return r.helper(o,s)}var rf=1004,sf=1005,of=1010,af=1e3,lf=1001,cf=1002;function uf(t){return{type:1,value:t}}function hf(t){return{type:5,value:t}}function df(t){return{type:7,value:t}}function pf(t){return{type:8,value:t}}var ff=class{labels=te();targets=[];label(t,e){this.labels[t]=e}target(t,e){this.targets.push({at:t,target:e})}patch(t){let{targets:e,labels:n}=this;for(const{at:r,target:i}of e){let e=n[i]-r;Gp(t.getbyaddr(r)),t.setbyaddr(r,e)}}};function gf(t,e,n,r){let{program:{constants:i},resolver:s}=e;if(function(t){return t<1e3}(r[0])){let[e,...n]=r;t.push(i,e,...n)}else switch(r[0]){case af:return t.label(r[1]);case lf:return t.startLabels();case cf:return t.stopLabels();case rf:return function(t,e,n,[,r,i]){if(Jp(r),r[0]===Zp){let{scopeValues:t,owner:s,symbols:{lexical:o}}=n,a=t[r[1]];i(e.component(a,s,!1,o?.at(r[1])))}else{let{symbols:{upvars:s},owner:o}=n,a=s[r[1]],l=t?.lookupComponent?.(a,o)??null;i(e.resolvedComponent(l,a))}}(s,i,n,r);case 1003:return function(t,e,n,[,r,i]){Qp(r);let s=r[0];if(s===Zp){let{scopeValues:t,symbols:{lexical:s}}=n,o=t[r[1]];i(e.modifier(o,s?.at(r[1])??void 0))}else if(s===Yp){let{symbols:{upvars:s}}=n,o=s[r[1]],a=t?.lookupBuiltInModifier?.(o)??null;i(e.modifier(a,o))}else{let{symbols:{upvars:s},owner:o}=n,a=s[r[1]],l=t?.lookupModifier?.(a,o)??null;i(e.modifier(l))}}(s,i,n,r);case sf:return function(t,e,n,[,r,i]){tf(r);let s=r[0];if(s===Zp){let{scopeValues:t}=n,s=t[r[1]];i(e.helper(s))}else if(s===Yp)i(nf(r,t,n,e));else{let{symbols:{upvars:s},owner:o}=n,a=s[r[1]],l=t?.lookupHelper?.(a,o)??null;i(e.helper(l,a))}}(s,i,n,r);case 1007:return function(t,e,n,[,r,{ifComponent:i,ifHelper:s}]){ef(r);let o=r[0];if(o===Zp){let{scopeValues:t,owner:o,symbols:{lexical:a}}=n,l=t[r[1]],c=e.component(l,o,!0,a?.at(r[1]));if(null!==c)return void i(c);s(e.helper(l,null,!0))}else if(o===Yp)s(nf(r,t,n,e));else{let{symbols:{upvars:o},owner:a}=n,l=o[r[1]],c=t?.lookupComponent?.(l,a)??null;if(null!==c)i(e.resolvedComponent(c,l));else{let n=t?.lookupHelper?.(l,a)??null;s(e.helper(n,l))}}}(s,i,n,r);case 1008:return function(t,e,n,[,r,{ifComponent:i,ifHelper:s,ifValue:o}]){ef(r);let a=r[0];if(a===Zp){let{scopeValues:t,owner:a,symbols:{lexical:l}}=n,c=t[r[1]];if("function"!=typeof c&&("object"!=typeof c||null===c))return void o(e.value(c));let u=e.component(c,a,!0,l?.at(r[1]));if(null!==u)return void i(u);let h=e.helper(c,null,!0);if(null!==h)return void s(h);o(e.value(c))}else if(a===Yp)s(nf(r,t,n,e));else{let{symbols:{upvars:o},owner:a}=n,l=o[r[1]],c=t?.lookupComponent?.(l,a)??null;if(null!==c)return void i(e.resolvedComponent(c,l));let u=t?.lookupHelper?.(l,a)??null;null!==u&&s(e.helper(u,l))}}(s,i,n,r);case of:{let[,t,e]=r;e(n.symbols.upvars[t],n.moduleName);break}case 1011:{let[,t,e]=r,s=n.scopeValues[t];e(i.value(s));break}default:throw new Error(`Unexpected high level opcode ${r[0]}`)}}var mf=class{labelsStack=new re;encoder=new Kp([]);errors=[];handle;constructor(t,e,n){this.heap=t,this.meta=e,this.stdlib=n,this.handle=t.malloc()}error(t){this.encoder.encode(30,0),this.errors.push(t)}commit(t){let e=this.handle;return this.heap.pushMachine(5),this.heap.finishMalloc(e,t),Xt(this.errors)?{errors:this.errors,handle:e}:e}push(t,e,...n){let{heap:r}=this,i=e|((s=e)>=0&&s<=15?1024:0)|n.length<<8;var s;r.pushRaw(i);for(let o=0;o=-536870912?Ep(n):function(t){return{type:6,value:t}}(n)),t(30,n)}function kf(t,e,n,r){t(0),Mf(t,n,r,!1),t(16,e),t(1),t(36,8)}function Sf(t,e,n,r){t(0),Mf(t,e,n,!1),t(33,2,1),t(107),r?(t(36,8),r(),t(1),t(34,1)):(t(1),t(34,1),t(36,8))}function Ef(t,e,n,r,i){t(0),Mf(t,r,i,!1),t(86),_f(t,n),t(77,e,{type:2,value:void 0}),t(1),t(36,8)}function Rf(t,e,n){Mf(t,n,null,!0),t(23,e),t(24),t(61),t(64),t(40),t(1)}function Tf(t,e){!function(t,e){null!==e?t(63,df({parameters:e})):Cf(t,null)}(t,e&&e[1]),t(62),If(t,e)}function Lf(t,e){t(0),If(t,e),t(61),t(2),t(1)}function Pf(t,e,n){let r=e[1],i=r.length,s=Math.min(n,i);if(0!==s){if(t(0),s){t(39);for(let e=0;e{for(let n of e)_f(t,n);t(27,e.length)}),bf.add(28,(t,[,e,n,r])=>{tf(e)?t(sf,e,e=>{kf(t,e,n,r)}):(_f(t,e),Sf(t,n,r))}),bf.add(50,(t,[,e,n,r,i])=>{Ef(t,n,e,r,i)}),bf.add(30,(t,[,e,n])=>{t(21,e),wf(t,n)}),bf.add(Zp,(t,[,e,n])=>{t(1011,e,e=>{t(29,e),wf(t,n)})}),bf.add(Yp,(t,e)=>{t(of,e[1],()=>{t(sf,e,e=>{kf(t,e,null,null)})})}),bf.add(37,(t,e)=>{t(of,e[1],()=>{t(sf,e,e=>{kf(t,e,null,null)})})}),bf.add(27,t=>xf(t,void 0)),bf.add(48,(t,[,e])=>{_f(t,e),t(25)}),bf.add(49,(t,[,e])=>{_f(t,e),t(24),t(61),t(26)}),bf.add(52,(t,[,e,n,r])=>{_f(t,r),_f(t,n),_f(t,e),t(109)}),bf.add(51,(t,[,e])=>{_f(t,e),t(110)}),bf.add(53,(t,[,e])=>{_f(t,e),t(111)}),bf.add(54,(t,[,e])=>{t(0),Mf(t,e,null,!1),t(112),t(1),t(36,8)});var Ff=class t{names;constructor(t){this.blocks=t,this.names=t?Object.keys(t):[]}get(t){return this.blocks&&this.blocks[t]||null}has(t){let{blocks:e}=this;return null!==e&&t in e}with(e,n){let{blocks:r}=this;return new t(r?Op({},r,{[e]:n}):{[e]:n})}get hasAny(){return null!==this.blocks}},Nf=new Ff(null);function zf(t){if(null===t)return Nf;let e=te(),[n,r]=t;for(const[i,s]of Vp(n))e[s]=Zt(r[i]);return new Ff(e)}function Df(t,e,n){let r=[],i=0;n(function(t,e){r.push({match:t,callback:e,label:"CLAUSE"+i++})}),t(69,1),e(),t(lf);for(let s of r.slice(0,-1))t(67,uf(s.label),s.match);for(let s=r.length-1;s>=0;s--){let e=Zt(r[s]);t(af,e.label),t(34,1),e.callback(),0!==s&&t(4,uf("END"))}t(af,"END"),t(cf),t(70)}function jf(t,e,n){t(lf),t(0),t(6,uf("ENDINITIAL")),t(69,e()),n(),t(af,"FINALLY"),t(70),t(5),t(af,"ENDINITIAL"),t(1),t(cf)}function Uf(t,e,n,r){return jf(t,e,()=>{t(66,uf("ELSE")),n(),t(4,uf("FINALLY")),t(af,"ELSE"),void 0!==r&&r()})}var Bf="&attrs";function $f(t,e,n,r,i,s){let{compilable:o,capabilities:a,handle:l}=e,c=n?[n,[]]:null,u=zf(s);o?(t(78,l),function(t,{capabilities:e,layout:n,elementBlock:r,positional:i,named:s,blocks:o}){let{symbolTable:a}=n;if(yu(e,du.prepareArgs))return void Vf(t,{capabilities:e,elementBlock:r,positional:i,named:s,atNames:!0,blocks:o,layout:n});t(36,4),t(33,3,1),t(35,4),t(0);let{symbols:l}=a,c=[],u=[],h=[],d=o.names;if(null!==r){let e=l.indexOf(Bf);-1!==e&&(Tf(t,r),c.push(e))}for(const p of d){let e=l.indexOf(`&${p}`);-1!==e&&(Tf(t,o.get(p)),c.push(e))}if(yu(e,du.createArgs)){let e=Af(t,i)<<4;e|=8;let n=Up;if(null!==s){n=s[0];let e=s[1];for(let r=0;r0?1:0),t(19,0);for(const p of qp(u))-1===p?t(34,1):t(19,p+1);null!==i&&t(34,i.length);for(const p of qp(c))t(20,p+1);t(28,pf(n)),t(61),t(2),t(100,4),t(1),t(40),yu(e,du.dynamicScope)&&t(60),t(98),t(35,4)}(t,{capabilities:a,layout:o,elementBlock:c,positional:r,named:i,blocks:u})):(t(78,l),Vf(t,{capabilities:a,elementBlock:c,positional:r,named:i,atNames:!0,blocks:u}))}function qf(t,e,n,r,i,s,o,a){let l=n?[n,[]]:null,c=zf(s);jf(t,()=>(_f(t,e),t(33,3,0),2),()=>{t(66,uf("ELSE")),a?t(81):t(80,{type:2,value:void 0}),t(79),Vf(t,{capabilities:!0,elementBlock:l,positional:r,named:i,atNames:o,blocks:c}),t(af,"ELSE")})}function Vf(t,{capabilities:e,elementBlock:n,positional:r,named:i,atNames:s,blocks:o,layout:a}){let l=Boolean(o),c=!0===e||yu(e,du.prepareArgs)||0!==i?.[0].length,u=o.with("attrs",n);t(36,4),t(33,3,1),t(35,4),t(0),function(t,e,n,r,i){let s=r.names;for(const l of s)Tf(t,r.get(l));let o=Af(t,e)<<4;i&&(o|=8),r.hasAny&&(o|=7);let a=Dp;if(n){a=n[0];let e=n[1];for(let n=0;n{a?(t(63,df(a.symbolTable)),t(28,pf(a)),t(61)):t(92,4),t(95,4)}),t(35,4)}function Wf(t,e,n,r,i=null){t(97,4),t(59),t(87,0|e),i&&i(),t(88,4),t(90,4),t(38,4),t(19,0),r&&t(17,4),n&&t(18,4),t(34,1),t(96,4),t(100,4),t(1),t(40),t(60),t(98)}var Hf=new vf,Gf=["class","id","value","name","type","style","href"],Kf=["div","span","p","a"];function Zf(t){return"string"==typeof t?t:Kf[t]}function Yf(t){return"string"==typeof t?t:Gf[t]}function Xf(t){return null===t?null:[t[0].map(t=>`@${t}`),t[1]]}Hf.add(3,(t,e)=>t(42,e[1])),Hf.add(13,t=>t(55)),Hf.add(12,t=>t(54)),Hf.add(4,(t,[,e,n,r])=>{Qp(e)?t(1003,e,e=>{t(0),Mf(t,n,r,!1),t(57,e),t(1)}):(_f(t,e),t(0),Mf(t,n,r,!1),t(33,2,1),t(108),t(1))}),Hf.add(14,(t,[,e,n,r])=>{t(51,Yf(e),n,r??null)}),Hf.add(24,(t,[,e,n,r])=>{t(105,Yf(e),n,r??null)}),Hf.add(15,(t,[,e,n,r])=>{_f(t,n),t(52,Yf(e),!1,r??null)}),Hf.add(22,(t,[,e,n,r])=>{_f(t,n),t(52,Yf(e),!0,r??null)}),Hf.add(16,(t,[,e,n,r])=>{_f(t,n),t(53,Yf(e),!1,r??null)}),Hf.add(23,(t,[,e,n,r])=>{_f(t,n),t(53,Yf(e),!0,r??null)}),Hf.add(10,(t,[,e])=>{t(48,Zf(e))}),Hf.add(11,(t,[,e])=>{t(89),t(48,Zf(e))}),Hf.add(8,(t,[,e,n,r,i])=>{Jp(e)?t(rf,e,e=>{$f(t,e,n,null,r,i)}):qf(t,e,n,null,r,i,!0,!0)}),Hf.add(18,(t,[,e,n])=>Rf(t,e,n)),Hf.add(17,(t,[,e])=>Rf(t,e,null)),Hf.add(26,(t,[,e,n,r])=>{t(103,function(t,e,n){return{type:3,value:{locals:t,upvars:e,lexical:n}}}(e,n,r))}),Hf.add(1,(t,[,e])=>{if(Array.isArray(e))if(ef(e))t(1008,e,{ifComponent(e){$f(t,e,null,null,null,null)},ifHelper(e){t(0),kf(t,e,null,null),t(3,hf("cautious-non-dynamic-append")),t(1)},ifValue(e){t(0),t(29,e),t(3,hf("cautious-non-dynamic-append")),t(1)}});else if(28===e[0]){let[,n,r,i]=e;ef(n)?t(1007,n,{ifComponent(e){$f(t,e,null,r,Xf(i),null)},ifHelper(e){t(0),kf(t,e,r,i),t(3,hf("cautious-non-dynamic-append")),t(1)}}):Df(t,()=>{_f(t,n),t(106)},e=>{e(0,()=>{t(68),t(81),t(79),Vf(t,{capabilities:!0,elementBlock:null,positional:r,named:i,atNames:!1,blocks:zf(null)})}),e(1,()=>{Sf(t,r,i,()=>{t(3,hf("cautious-non-dynamic-append"))})})})}else t(0),_f(t,e),t(3,hf("cautious-append")),t(1);else t(41,null==e?"":String(e))}),Hf.add(2,(t,[,e])=>{Array.isArray(e)?(t(0),_f(t,e),t(3,hf("trusting-append")),t(1)):t(41,null==e?"":String(e))}),Hf.add(6,(t,[,e,n,r,i])=>{Jp(e)?t(rf,e,e=>{$f(t,e,null,n,Xf(r),i)}):qf(t,e,null,n,r,i,!1,!1)}),Hf.add(40,(t,[,e,n,r,i])=>{Uf(t,()=>(_f(t,n),void 0===i?xf(t,void 0):_f(t,i),_f(t,r),t(33,3,0),4),()=>{t(50),Lf(t,e),t(56)})}),Hf.add(41,(t,[,e,n,r])=>Uf(t,()=>(_f(t,e),t(71),1),()=>{Lf(t,n)},r?()=>{Lf(t,r)}:void 0)),Hf.add(42,(t,[,e,n,r,i])=>jf(t,()=>(n?_f(t,n):xf(t,null),_f(t,e),2),()=>{t(72,uf("BODY"),uf("ELSE")),t(0),t(33,2,1),t(6,uf("ITER")),t(af,"ITER"),t(74,uf("BREAK")),t(af,"BODY"),Pf(t,r,2),t(34,2),t(4,uf("FINALLY")),t(af,"BREAK"),t(1),t(73),t(4,uf("FINALLY")),t(af,"ELSE"),i&&Lf(t,i)})),Hf.add(44,(t,[,e,n])=>{Pf(t,n,Af(t,e))}),Hf.add(45,(t,[,e,n])=>{if(e){let[r,i]=e;Af(t,i),function(t,e,n){t(59),t(58,e),n(),t(60)}(t,r,()=>{Lf(t,n)})}else Lf(t,n)}),Hf.add(46,(t,[,e,n,r,i])=>{Jp(e)?t(rf,e,e=>{$f(t,e,null,n,Xf(r),i)}):qf(t,e,null,n,r,i,!1,!1)});var Jf=class{compiled=new WeakMap;constructor(t,e,n,r="plain block"){this.statements=t,this.meta=e,this.symbolTable=n,this.moduleName=r}compile(t){return function(t,e){if(t.compiled.has(e))return t.compiled.get(e);t.compiled.set(e,-1);let{statements:n,meta:r}=t,i=function(t,e,n){let r=Hf,i=yf(n,e),{encoder:s,evaluation:o}=i;function a(...t){gf(s,o,e,t)}for(const l of t)r.compile(a,l);return i.encoder.commit(e.size)}(n,r,e);return t.compiled.set(e,i),i}(this,t)}},Qf=class{symbolTable;compiled=null;attrsBlockNumber;meta;constructor(t,e){this.layout=t,this.moduleName=e;let{block:n}=t,[,r]=n;r=r.slice();let i=r.indexOf(Bf);this.attrsBlockNumber=-1===i?r.push(Bf):i+1,this.symbolTable={symbols:r},this.meta=Of(t)}compile(t){if(null!==this.compiled)return this.compiled;let e=Of(this.layout),n=yf(t,e),{encoder:r,evaluation:i}=n;var s,o,a;s=function(...t){gf(r,i,e,t)},o=this.layout,a=this.attrsBlockNumber,s(lf),function(t,e,n){t(36,5),n(),t(35,5)}(s,0,()=>{s(91,4),s(31),s(33,3,0)}),s(66,uf("BODY")),s(36,5),s(89),s(49),s(99,4),Rf(s,a,null),s(54),s(af,"BODY"),Lf(s,[o.block[0],[]]),s(36,5),s(66,uf("END")),s(55),s(af,"END"),s(35,5),s(cf);let l=n.encoder.commit(e.size);return"number"!=typeof l||(this.compiled=l),l}},tg=0,eg={cacheHit:0,cacheMiss:0};function ng({id:t,moduleName:e,block:n,scope:r,isStrictMode:i}){let s,o=t||"client-"+tg++,a=null,l=new WeakMap,c=t=>{if(void 0===s&&(s=JSON.parse(n)),void 0===t)return null===a?(eg.cacheMiss++,a=new rg({id:o,block:s,moduleName:e,owner:null,scope:r,isStrictMode:i})):eg.cacheHit++,a;let c=l.get(t);return void 0===c?(eg.cacheMiss++,c=new rg({id:o,block:s,moduleName:e,owner:t,scope:r,isStrictMode:i}),l.set(t,c)):eg.cacheHit++,c};return c.__id=o,c.__meta={moduleName:e},c}var rg=class{result="ok";layout=null;wrappedLayout=null;constructor(t){this.parsedLayout=t}get moduleName(){return this.parsedLayout.moduleName}get id(){return this.parsedLayout.id}get referrer(){return{moduleName:this.parsedLayout.moduleName,owner:this.parsedLayout.owner}}asLayout(){return this.layout?this.layout:this.layout=function(t,e){let[n,r]=t.block;return new Jf(n,Of(t),{symbols:r},e)}(Op({},this.parsedLayout),this.moduleName)}asWrappedLayout(){return this.wrappedLayout?this.wrappedLayout:this.wrappedLayout=new Qf(Op({},this.parsedLayout),this.moduleName)}},ig=class{offset=0;constructor(t){this.heap=t}get size(){return 1+((768&this.heap.getbyaddr(this.offset))>>8)}get isMachine(){return 1024&this.heap.getbyaddr(this.offset)?1:0}get type(){return 255&this.heap.getbyaddr(this.offset)}get op1(){return this.heap.getbyaddr(this.offset+1)}get op2(){return this.heap.getbyaddr(this.offset+2)}get op3(){return this.heap.getbyaddr(this.offset+3)}},sg=1048576,og=class{offset=0;heap;handleTable;handleState;constructor(){this.heap=new Int32Array(sg),this.handleTable=[],this.handleState=[]}entries(){return this.offset}pushRaw(t){this.sizeCheck(),this.heap[this.offset++]=t}pushOp(t){this.pushRaw(t)}pushMachine(t){this.pushRaw(1024|t)}sizeCheck(){let{heap:t}=this;if(this.offset===this.heap.length){let e=new Int32Array(t.length+sg);e.set(t,0),this.heap=e}}getbyaddr(t){return this.heap[t]}setbyaddr(t,e){this.heap[t]=e}malloc(){return this.handleTable.push(this.offset),this.handleTable.length-1}finishMalloc(t){}size(){return this.offset}getaddr(t){return this.handleTable[t]}sizeof(t){return this.handleTable,-1}free(t){this.handleState[t]=1}compact(){let t=0,{handleTable:e,handleState:n,heap:r}=this;for(let i=0;i[t,e]));helperDefinitionCache=new WeakMap;modifierDefinitionCache=new WeakMap;componentDefinitionCache=new WeakMap;value(t){let e=this.indexMap,n=e.get(t);return void 0===n&&(n=this.values.push(t)-1,e.set(t,n)),n}array(t){if(0===t.length)return hg;let e=new Array(t.length);for(let n=0;nt}helper(t,e=null,n){let r=this.helperDefinitionCache.get(t);if(void 0===r){let e=Au(t);if(null===e)return this.helperDefinitionCache.set(t,null),null;let n="function"==typeof e?e:e.getHelper(t);r=this.value(n),this.helperDefinitionCache.set(t,r),this.helperDefinitionCount++}return r}modifier(t,e=null,n){let r=this.modifierDefinitionCache.get(t);if(void 0===r){let n=Pu(t);if(null===n)return this.modifierDefinitionCache.set(t,null),null;let i={resolvedName:e,manager:n,state:t};r=this.value(i),this.modifierDefinitionCache.set(t,r),this.modifierDefinitionCount++}return r}component(t,e,n,r){let i=this.componentDefinitionCache.get(t);if(void 0===i){let n=Fu(t);if(null===n)return this.componentDefinitionCache.set(t,null),null;let s,o=fu(n.getCapabilities(t)),a=Ap(t),l=null;s=mu(0,o,du.dynamicLayout)?a?.(e):a?.(e)??this.defaultTemplate,void 0!==s&&(s=Lp(s),l=mu(0,o,du.wrapped)?s.asWrappedLayout():s.asLayout()),i={resolvedName:null,handle:-1,manager:n,capabilities:o,state:t,compilable:l},i.handle=this.value(i),r&&(i.debugName=r),this.componentDefinitionCache.set(t,i),this.componentDefinitionCount++}return i}resolvedComponent(t,e){let n=this.componentDefinitionCache.get(t);if(void 0===n){let{manager:r,state:i,template:s}=t,o=fu(r.getCapabilities(t)),a=null;mu(0,o,du.dynamicLayout)||(s=s??this.defaultTemplate),null!==s&&(s=Lp(s),a=mu(0,o,du.wrapped)?s.asWrappedLayout():s.asLayout()),n={resolvedName:e,handle:-1,manager:r,capabilities:o,state:i,compilable:a},n.handle=this.value(n),this.componentDefinitionCache.set(t,n),this.componentDefinitionCount++}return n}getValue(t){return this.values[t]}getArray(t){let e=this.reifiedArrs,n=e[t];if(void 0===n){let r=this.getValue(t);n=new Array(r.length);for(const[t,e]of Vp(r))n[t]=this.getValue(e);e[t]=n}return n}},pg=class{constructor(t,e){this.element=t,this.nextSibling=e}},fg=class{constructor(t,e,n){this.parentNode=t,this.first=e,this.last=n}parentElement(){return this.parentNode}firstNode(){return this.first}lastNode(){return this.last}};function gg(t,e){let n=t.parentElement(),r=t.firstNode(),i=t.lastNode(),s=r;for(;;){let t=s.nextSibling;if(n.insertBefore(s,e),s===i)return t;s=Yt(t)}}function mg(t){let e=t.parentElement(),n=t.firstNode(),r=t.lastNode(),i=n;for(;;){let t=i.nextSibling;if(e.removeChild(i),i===r)return t;i=Yt(t)}}function yg(t){return vg(t)?"":String(t)}function vg(t){return null==t||"function"!=typeof t.toString}function bg(t){return null!==t&&"object"==typeof t}function wg(t){return bg(t)&&"function"==typeof t.toHTML}function _g(t){return"string"==typeof t}function xg(t,e){let n,r;if(e in t)r=e,n="prop";else{let i=e.toLowerCase();i in t?(n="prop",r=i):(n="attr",r=e)}return"prop"!==n||"style"!==r.toLowerCase()&&!function(t,e){let n=kg[t.toUpperCase()];return!(!n||!n[e.toLowerCase()])}(t.tagName,r)||(n="attr"),{normalized:r,type:n}}var Cg,kg={INPUT:{form:!0,autocorrect:!0,list:!0},SELECT:{form:!0},OPTION:{form:!0},TEXTAREA:{form:!0},LABEL:{form:!0},FIELDSET:{form:!0},LEGEND:{form:!0},OBJECT:{form:!0},OUTPUT:{form:!0},BUTTON:{form:!0}},Sg="http://www.w3.org/1998/Math/MathML",Eg=["javascript:","vbscript:"],Rg=["A","AREA","BODY","LINK","IMG","IFRAME","BASE","FORM","BUTTON","INPUT"],Tg=["EMBED"],Lg=["IFRAME","OBJECT"],Pg=["href","src","background","action","formaction","xlink:href"],Ig=["src"],Mg=["src","data"];function Ag(t,e){return-1!==t.indexOf(e)}function Og(t,e){return(null===t||Ag(Rg,t.toUpperCase()))&&Ag(Pg,e)}function Fg(t,e){return null!==t&&Ag(Tg,t.toUpperCase())&&Ag(Ig,e)}function Ng(t,e){return null!==t&&Ag(Lg,t.toUpperCase())&&Ag(Mg,e)}function zg(t,e){return Og(t,e)||Fg(t,e)||Ng(t,e)}function Dg(t){return Cg||(Cg=function(){const t=URL;if("object"==typeof t&&null!==t&&"function"==typeof t.parse){let e=t;return t=>{let n=null;return"string"==typeof t&&(n=e.parse(t.replace(/[\t\n\r]/gu,"")).protocol),null===n?":":n}}if("function"==typeof t)return e=>{try{return new t(e).protocol}catch{return":"}};throw new Error('@glimmer/runtime needs a valid "globalThis.URL"')}()),Cg(t)}function jg(t,e,n){if(null==n)return n;if(wg(n))return n.toHTML();const r=t.tagName;let i=yg(n);if(Og(r,e)){let t=Dg(i);if(Ag(Eg,t))return`unsafe:${i}`}if(Ng(r,e)){let t=Dg(i);if("data:"===t||Ag(Eg,t))return`unsafe:${i}`}return Fg(r,e)?`unsafe:${i}`:i}function Ug(t,e,n){const{tagName:r,namespaceURI:i}=t,s={element:t,name:e,namespace:n};if("http://www.w3.org/2000/svg"===i)return Bg(r,e,s);const{type:o,normalized:a}=xg(t,e);return"attr"===o?Bg(r,a,s):function(t,e,n){return zg(t,e)?new Wg(e,n):function(t,e){return("INPUT"===t||"TEXTAREA"===t)&&"value"===e}(t,e)?new Gg(e,n):function(t,e){return"OPTION"===t&&"selected"===e}(t,e)?new Kg(e,n):new Vg(e,n)}(r,a,s)}function Bg(t,e,n){return zg(t,e)?new Hg(n):new qg(n)}var $g=class{constructor(t){this.attribute=t}},qg=class extends $g{set(t,e,n){const r=Zg(e);if(null!==r){const{name:e,namespace:n}=this.attribute;t.__setAttribute(e,r,n)}}update(t,e){const n=Zg(t),{element:r,name:i}=this.attribute;null===n?r.removeAttribute(i):r.setAttribute(i,n)}},Vg=class extends $g{constructor(t,e){super(e),this.normalizedName=t}value;set(t,e,n){null!=e&&(this.value=e,t.__setProperty(this.normalizedName,e))}update(t,e){const{element:n}=this.attribute;this.value!==t&&(n[this.normalizedName]=this.value=t,null==t&&this.removeAttribute())}removeAttribute(){const{element:t,namespace:e}=this.attribute;e?t.removeAttributeNS(e,this.normalizedName):t.removeAttribute(this.normalizedName)}},Wg=class extends Vg{set(t,e,n){const{element:r,name:i}=this.attribute,s=jg(r,i,e);super.set(t,s,n)}update(t,e){const{element:n,name:r}=this.attribute,i=jg(n,r,t);super.update(i,e)}},Hg=class extends qg{set(t,e,n){const{element:r,name:i}=this.attribute,s=jg(r,i,e);super.set(t,s,n)}update(t,e){const{element:n,name:r}=this.attribute,i=jg(n,r,t);super.update(i,e)}},Gg=class extends Vg{set(t,e){const n=yg(e);t.__setProperty("value",n),""===e&&"INPUT"===this.attribute.element.tagName&&t.__setAttribute("value","",null)}update(t){const e=this.attribute.element,n=e.value,r=yg(t);n!==r&&(e.value=r)}},Kg=class extends Vg{set(t,e){null!=e&&!1!==e&&t.__setProperty("selected",!0)}update(t){this.attribute.element.selected=!!t}};function Zg(t){return!1===t||null==t||void 0===t.toString?null:!0===t?"":"function"==typeof t?null:String(t)}var Yg=class{constructor(t){this.node=t}firstNode(){return this.node}},Xg=class{constructor(t){this.node=t}lastNode(){return this.node}},Jg=class{dom;updateOperations;constructing=null;operations=null;env;cursors=new re;modifierStack=new re;blockStack=new re;static forInitialRender(t,e){return new this(t,e.element,e.nextSibling).initialize()}static resume(t,e){let n=new this(t,e.parentElement(),e.reset(t)).initialize();return n.pushBlock(e),n}constructor(t,e,n){this.pushElement(e,n),this.env=t,this.dom=t.getAppendOperations(),this.updateOperations=t.getDOM()}initialize(){return this.pushAppendingBlock(),this}debugBlocks(){return this.blockStack.toArray()}get element(){return this.cursors.current.element}get nextSibling(){return this.cursors.current.nextSibling}get hasBlocks(){return this.blockStack.size>0}block(){return this.blockStack.current}popElement(){this.cursors.pop(),this.cursors.current}pushAppendingBlock(){return this.pushBlock(new Qg(this.element))}pushResettableBlock(){return this.pushBlock(new em(this.element))}pushBlockList(t){return this.pushBlock(new nm(this.element,t))}pushBlock(t,e=!1){let n=this.blockStack.current;return null!==n&&(e||n.didAppendBounds(t)),this.__openBlock(),this.blockStack.push(t),t}popBlock(){return this.block().finalize(this),this.__closeBlock(),this.blockStack.pop()}__openBlock(){}__closeBlock(){}openElement(t){let e=this.__openElement(t);return this.constructing=e,e}__openElement(t){return this.dom.createElement(t,this.element)}flushElement(t){let e=this.element,n=this.constructing;this.__flushElement(e,n),this.constructing=null,this.operations=null,this.pushModifiers(t),this.pushElement(n,null),this.didOpenElement(n)}__flushElement(t,e){this.dom.insertBefore(t,e,this.nextSibling)}closeElement(){return this.willCloseElement(),this.popElement(),this.popModifiers()}pushRemoteElement(t,e,n){return this.__pushRemoteElement(t,e,n)}__pushRemoteElement(t,e,n){if(this.pushElement(t,n),void 0===n)for(;t.lastChild;)t.removeChild(t.lastChild);let r=new tm(t);return this.pushBlock(r,!0)}popRemoteElement(){const t=this.popBlock();return this.popElement(),t}pushElement(t,e=null){this.cursors.push(new pg(t,e))}pushModifiers(t){this.modifierStack.push(t)}popModifiers(){return this.modifierStack.pop()}didAppendBounds(t){return this.block().didAppendBounds(t),t}didAppendNode(t){return this.block().didAppendNode(t),t}didOpenElement(t){return this.block().openElement(t),t}willCloseElement(){this.block().closeElement()}appendText(t){return this.didAppendNode(this.__appendText(t))}__appendText(t){let{dom:e,element:n,nextSibling:r}=this,i=e.createTextNode(t);return e.insertBefore(n,i,r),i}__appendNode(t){return this.dom.insertBefore(this.element,t,this.nextSibling),t}__appendFragment(t){let e=t.firstChild;if(e){let n=new fg(this.element,e,t.lastChild);return this.dom.insertBefore(this.element,t,this.nextSibling),n}{const t=this.__appendComment("");return new fg(this.element,t,t)}}__appendHTML(t){return this.dom.insertHTMLBefore(this.element,this.nextSibling,t)}appendDynamicHTML(t){let e=this.trustedContent(t);this.didAppendBounds(e)}appendDynamicText(t){let e=this.untrustedContent(t);return this.didAppendNode(e),e}appendDynamicFragment(t){let e=this.__appendFragment(t);this.didAppendBounds(e)}appendDynamicNode(t){let e=this.__appendNode(t),n=new fg(this.element,e,e);this.didAppendBounds(n)}trustedContent(t){return this.__appendHTML(t)}untrustedContent(t){return this.__appendText(t)}appendComment(t){return this.didAppendNode(this.__appendComment(t))}__appendComment(t){let{dom:e,element:n,nextSibling:r}=this,i=e.createComment(t);return e.insertBefore(n,i,r),i}__setAttribute(t,e,n){this.dom.setAttribute(this.constructing,t,e,n)}__setProperty(t,e){this.constructing[t]=e}setStaticAttribute(t,e,n){this.__setAttribute(t,e,n)}setDynamicAttribute(t,e,n,r){let i=Ug(this.constructing,t,r);return i.set(this,e,this.env),i}},Qg=class{first=null;last=null;nesting=0;constructor(t){this.parent=t}parentElement(){return this.parent}firstNode(){return this.first.firstNode()}lastNode(){return this.last.lastNode()}openElement(t){this.didAppendNode(t),this.nesting++}closeElement(){this.nesting--}didAppendNode(t){0===this.nesting&&(this.first||(this.first=new Yg(t)),this.last=new Xg(t))}didAppendBounds(t){0===this.nesting&&(this.first||(this.first=t),this.last=t)}finalize(t){null===this.first&&t.appendComment("")}},tm=class extends Qg{constructor(t){super(t),Q(this,()=>{this.parentElement()===this.firstNode().parentNode&&mg(this)})}},em=class extends Qg{constructor(t){super(t)}reset(){tt(this);let t=mg(this);return this.first=null,this.last=null,this.nesting=0,t}},nm=class{constructor(t,e){this.parent=t,this.boundList=e,this.parent=t,this.boundList=e}parentElement(){return this.parent}firstNode(){return this.boundList[0].firstNode()}lastNode(){let t=this.boundList;return t[t.length-1].lastNode()}openElement(t){}closeElement(){}didAppendNode(t){}didAppendBounds(t){}finalize(t){this.boundList.length}};function rm(t,e){return Jg.forInitialRender(t,e)}var im={foreignObject:1,desc:1,title:1},sm=Object.create(null),om=class{constructor(t){this.document=t,this.setupUselessElement()}setupUselessElement(){this.uselessElement=this.document.createElement("div")}createElement(t,e){let n,r,i,s;if(e?(n="http://www.w3.org/2000/svg"===e.namespaceURI||"svg"===t,i=e.namespaceURI===Sg||"math"===t,r=!!im[e.tagName]):(n="svg"===t,i="math"===t,r=!1),!i&&!n||r)return this.document.createElement(t);if(sm[t])throw new Error(`Cannot create a ${t} inside an SVG context`);return s=i?Sg:"http://www.w3.org/2000/svg",this.document.createElementNS(s,t)}insertBefore(t,e,n){t.insertBefore(e,n)}insertHTMLBefore(t,e,n){if(""===n){const n=this.createComment("");return t.insertBefore(n,e),new fg(t,n,n)}const r=e?e.previousSibling:t.lastChild;let i;if(null===e)t.insertAdjacentHTML("beforeend",n),i=t.lastChild;else if(e instanceof HTMLElement)e.insertAdjacentHTML("beforebegin",n),i=e.previousSibling;else{const{uselessElement:r}=this;t.insertBefore(r,e),r.insertAdjacentHTML("beforebegin",n),i=r.previousSibling,t.removeChild(r)}const s=r?r.nextSibling:t.firstChild;return new fg(t,s,i)}createTextNode(t){return this.document.createTextNode(t)}createComment(t){return this.document.createComment(t)}},am=class extends om{createElementNS(t,e){return this.document.createElementNS(t,e)}setAttribute(t,e,n,r=null){r?t.setAttributeNS(r,e,n):t.setAttribute(e,n)}};function lm(t){return t}function cm(t){return"getDebugCustomRenderTree"in t}new class{validate(t){switch(t){case 4:case 5:case 3:case 2:case 1:case 0:case 6:case 7:case 8:return!0;default:return!1}}expected(){return"Register"}};var um=Symbol("TYPE"),hm=Symbol("INNER"),dm=Symbol("OWNER"),pm=Symbol("ARGS"),fm=Symbol("RESOLVED"),gm=new WeakSet;function mm(t){return gm.has(t)}function ym(t,e){return mm(t)&&t[um]===e}var vm=class{[um];[hm];[dm];[pm];[fm];constructor(t,e,n,r,i=!1){gm.add(this),this[um]=t,this[hm]=e,this[dm]=n,this[pm]=r,this[fm]=i}};function bm(t){let e,n,r,i,s,o=t;for(;;){let{[pm]:t,[hm]:a}=o;if(null!==t){let{named:r,positional:i}=t;i.length>0&&(e=void 0===e?i:i.concat(e)),void 0===n&&(n=[]),n.unshift(r)}if(!mm(a)){r=a,i=o[dm],s=o[fm];break}o=a}return{definition:r,owner:i,resolved:s,positional:e,named:n}}function wm(t,e,n,r,i=!1){return new vm(t,e,n,r,i)}var _m=0,xm=class{id=_m++;value;constructor(t){this.value=t}get(){return this.value}release(){this.value=null}toString(){let t=`Ref ${this.id}`;if(null===this.value)return`${t} (released)`;try{return`${t}: ${this.value}`}catch{return t}}},Cm=class{stack=new re;refs=new WeakMap;roots=new Set;nodes=new WeakMap;begin(){this.reset()}create(t,e){let n=Op({},e,{bounds:null,refs:new Set});this.nodes.set(t,n),this.appendChild(n,t),this.enter(t)}update(t){this.enter(t)}didRender(t,e){this.nodeFor(t).bounds=e,this.exit()}willDestroy(t){this.refs.get(t).release()}commit(){this.reset()}capture(){return this.captureRefs(this.roots)}reset(){if(0!==this.stack.size){let t=this.stack.toArray()[0],e=this.refs.get(t);for(void 0!==e&&this.roots.delete(e);!this.stack.isEmpty();)this.stack.pop()}}enter(t){this.stack.push(t)}exit(){this.stack.pop()}nodeFor(t){return this.nodes.get(t)}appendChild(t,e){let n=this.stack.current,r=new xm(e);if(this.refs.set(e,r),n){let e=this.nodeFor(n);e.refs.add(r),t.parent=e}else this.roots.add(r)}captureRefs(t){let e=[];return t.forEach(n=>{let r=n.get();r?e.push(this.captureNode(`render-node:${n.id}`,r)):t.delete(n)}),e}captureNode(t,e){let n=this.nodeFor(e),{type:r,name:i,args:s,instance:o,refs:a}=n,l=this.captureBounds(n),c=this.captureRefs(a);return{id:t,type:r,name:i,args:ry(s),instance:o,bounds:l,children:c}}captureBounds(t){let e=t.bounds;return{parentElement:e.parentElement(),firstNode:e.firstNode(),lastNode:e.lastNode()}}},km=new class{evaluateOpcode=new Array(113).fill(null);constructor(){}add(t,e,n="syscall"){this.evaluateOpcode[t]={syscall:"machine"!==n,evaluate:e}}evaluate(t,e,n){let r=this.evaluateOpcode[n];r.syscall?(e.isMachine,r.syscall,e.isMachine,e.type,r.evaluate(t,e)):(e.isMachine,r.syscall,e.isMachine,e.type,r.evaluate(t.lowlevel,e))}};km.add(39,t=>t.pushChildScope()),km.add(40,t=>t.popScope()),km.add(59,t=>t.pushDynamicScope()),km.add(60,t=>t.popDynamicScope()),km.add(28,(t,{op1:e})=>{t.stack.push(t.constants.getValue(e))}),km.add(29,(t,{op1:e})=>{t.stack.push(he(t.constants.getValue(e)))}),km.add(30,(t,{op1:e})=>{let n=t.stack;if(e>=0){let r=t.constants.getValue(e);n.push(r)}else n.push(Rp(e))}),km.add(31,t=>{let e,n=t.stack,r=lm(n.pop());e=void 0===r?ae:null===r?le:!0===r?ce:!1===r?ue:oe(r),n.push(e)}),km.add(33,(t,{op1:e,op2:n})=>{let r=lm(t.fetchValue(lm(e)))-n;t.stack.dup(r)}),km.add(34,(t,{op1:e})=>{t.stack.pop(e)}),km.add(35,(t,{op1:e})=>{t.load(lm(e))}),km.add(36,(t,{op1:e})=>{t.fetch(lm(e))}),km.add(58,(t,{op1:e})=>{let n=t.constants.getArray(e);t.bindDynamicScope(n)}),km.add(69,(t,{op1:e})=>{t.enter(e)}),km.add(70,t=>{t.exit()}),km.add(63,(t,{op1:e})=>{t.stack.push(t.constants.getValue(e))}),km.add(62,t=>{t.stack.push(t.scope())}),km.add(61,t=>{let e=t.stack,n=e.pop();n?e.push(t.compile(n)):e.push(null)}),km.add(64,t=>{let{stack:e}=t,n=lm(e.pop()),r=lm(e.pop()),i=lm(e.pop()),s=lm(e.pop());if(null===i||null===n)return t.lowlevel.pushFrame(),void t.pushScope(r??t.scope());let o=r;{let t=i.parameters,e=t.length;if(e>0){o=o.child();for(let n=0;n{let n=lm(t.stack.pop()),r=Boolean(be(n));ye(n)?r&&t.lowlevel.goto(e):(r&&t.lowlevel.goto(e),t.updateWith(new Sm(n)))}),km.add(66,(t,{op1:e})=>{let n=lm(t.stack.pop()),r=Boolean(be(n));ye(n)?r||t.lowlevel.goto(e):(r||t.lowlevel.goto(e),t.updateWith(new Sm(n)))}),km.add(67,(t,{op1:e,op2:n})=>{lm(t.stack.peek())===n&&t.lowlevel.goto(e)}),km.add(68,t=>{let e=lm(t.stack.peek());ye(e)||t.updateWith(new Sm(e))}),km.add(71,t=>{let{stack:e}=t,n=lm(e.pop());e.push(pe(()=>j(be(n))))});var Sm=class{last;constructor(t){this.ref=t,this.last=be(t)}evaluate(t){let{last:e,ref:n}=this;e!==be(n)&&t.throw()}},Em=class{last;constructor(t,e){this.ref=t,this.filter=e,this.last=e(be(t))}evaluate(t){let{last:e,ref:n,filter:r}=this;e!==r(be(n))&&t.throw()}},Rm=class{tag=gt;lastRevision=1;target;finalize(t,e){this.target=e,this.didModify(t)}evaluate(t){let{tag:e,target:n,lastRevision:r}=this;!t.alwaysRevalidate&<(e,r)&&(Ot(e),t.goto(n))}didModify(t){this.tag=t,this.lastRevision=at(this.tag),Ot(t)}},Tm=class{constructor(t){this.debugLabel=t}evaluate(){Tt(this.debugLabel)}},Lm=class{constructor(t){this.target=t}evaluate(){let t=Lt();this.target.didModify(t)}};km.add(41,(t,{op1:e})=>{t.tree().appendText(t.constants.getValue(e))}),km.add(42,(t,{op1:e})=>{t.tree().appendComment(t.constants.getValue(e))}),km.add(48,(t,{op1:e})=>{t.tree().openElement(t.constants.getValue(e))}),km.add(49,t=>{let e=lm(be(lm(t.stack.pop())));t.tree().openElement(e)}),km.add(50,t=>{let e=lm(t.stack.pop()),n=lm(t.stack.pop()),r=lm(t.stack.pop()),i=lm(be(e)),s=lm(be(n)),o=be(r);ye(e)||t.updateWith(new Sm(e)),void 0===s||ye(n)||t.updateWith(new Sm(n));let a=t.tree().pushRemoteElement(i,o,s);if(t.associateDestroyable(a),void 0!==t.env.debugRenderTree){let r=Zm(void 0===s?{}:{insertBefore:n},[e]);t.env.debugRenderTree.create(a,{type:"keyword",name:"in-element",args:r,instance:null}),Q(a,()=>{t.env.debugRenderTree?.willDestroy(a)})}}),km.add(56,t=>{let e=t.tree().popRemoteElement();void 0!==t.env.debugRenderTree&&t.env.debugRenderTree.didRender(e,e)}),km.add(54,t=>{let e=lm(t.fetchValue(6)),n=null;e&&(n=e.flush(t),t.loadValue(6,null)),t.tree().flushElement(n)}),km.add(55,t=>{let e=t.tree().closeElement();null!==e&&e.forEach(e=>{t.env.scheduleInstallModifier(e);const n=e.manager.getDestroyable(e.state);null!==n&&t.associateDestroyable(n)})}),km.add(57,(t,{op1:e})=>{let n=lm(t.stack.pop());if(!t.env.isInteractive)return;let r=t.getOwner(),i=t.constants.getValue(e),{manager:s}=i,{constructing:o}=t.tree(),a=n.capture(),l=s.create(r,o,i.state,a),c={manager:s,state:l,definition:i};lm(t.fetchValue(6)).addModifier(t,c,a);let u=s.getTag(l);return null!==u?(Ot(u),t.updateWith(new Pm(u,c))):void 0}),km.add(108,t=>{let{stack:e}=t,n=lm(e.pop()),r=lm(e.pop());if(!t.env.isInteractive)return;let i=r.capture(),{positional:s,named:o}=i,{constructing:a}=t.tree(),l=t.getOwner(),c=pe(()=>{let t,e,r=be(n);if(!ne(r))return;if(ym(r,2)){let{definition:n,owner:a,positional:l,named:c}=bm(r);e=n,t=a,void 0!==l&&(i.positional=l.concat(s)),void 0!==c&&(i.named=Object.assign({},...c,o))}else e=r,t=l;let c=Pu(e);if(null===c)throw new Error("BUG: modifier manager expected");let u={resolvedName:null,manager:c,state:e};return{manager:c,state:c.create(t,a,u.state,i),definition:u}}),u=be(c),h=null;return void 0!==u&&(lm(t.fetchValue(6)).addModifier(t,u,i),h=u.manager.getTag(u.state),null!==h&&Ot(h)),!ye(n)||h?t.updateWith(new Im(h,u,c)):void 0});var Pm=class{lastUpdated;constructor(t,e){this.tag=t,this.modifier=e,this.lastUpdated=at(t)}evaluate(t){let{modifier:e,tag:n,lastUpdated:r}=this;Ot(n),lt(n,r)||(t.env.scheduleUpdateModifier(e),this.lastUpdated=at(n))}},Im=class{lastUpdated;constructor(t,e,n){this.tag=t,this.instance=e,this.instanceRef=n,this.lastUpdated=at(t??wt)}evaluate(t){let{tag:e,lastUpdated:n,instance:r,instanceRef:i}=this,s=be(i);if(s!==r){if(void 0!==r){let t=r.manager.getDestroyable(r.state);null!==t&&tt(t)}if(void 0!==s){let{manager:n,state:r}=s,i=n.getDestroyable(r);null!==i&&J(this,i),e=n.getTag(r),null!==e&&(this.lastUpdated=at(e)),this.tag=e,t.env.scheduleInstallModifier(s)}this.instance=s}else null===e||lt(e,n)||(t.env.scheduleUpdateModifier(r),this.lastUpdated=at(e));null!==e&&Ot(e)}};km.add(51,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=r?t.constants.getValue(r):null;t.tree().setStaticAttribute(i,s,o)}),km.add(52,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=lm(t.stack.pop()),a=be(o),l=r?t.constants.getValue(r):null,c=t.tree().setDynamicAttribute(i,a,s,l);ye(o)||t.updateWith(new Mm(o,c,t.env))});var Mm=class{updateRef;constructor(t,e,n){let r=!1;this.updateRef=pe(()=>{let i=be(t);r?e.update(i,n):r=!0}),be(this.updateRef)}evaluate(){be(this.updateRef)}};km.add(78,(t,{op1:e})=>{let n=t.constants.getValue(e),{manager:r,capabilities:i}=n,s={definition:n,manager:r,capabilities:i,state:null,handle:null,table:null,lookup:null};t.stack.push(s)}),km.add(80,(t,{op1:e})=>{let n,r=t.stack,i=lm(be(lm(r.pop()))),s=t.constants,o=t.getOwner();if(s.getValue(e),t.loadValue(7,null),"string"==typeof i){let e=function(t,e,n,r){let i=t?.lookupComponent?.(n,r)??null;return e.resolvedComponent(i,n)}(t.context.resolver,s,i,o);n=e}else n=mm(i)?i:s.component(i,o);r.push(n)}),km.add(81,t=>{let e,n=t.stack,r=be(lm(n.pop())),i=t.constants;e=mm(r)?r:i.component(r,t.getOwner(),!0),n.push(e)}),km.add(79,t=>{let e,n,{stack:r}=t,i=r.pop();mm(i)?n=e=null:(n=i.manager,e=i.capabilities),r.push({definition:i,capabilities:e,manager:n,state:null,handle:null,table:null})}),km.add(82,(t,{op1:e,op2:n,op3:r})=>{let i=t.stack,s=t.constants.getArray(e),o=r>>4,a=8&r,l=7&r?t.constants.getArray(n):Up;t.args.setup(i,s,l,o,!!a),i.push(t.args)}),km.add(83,t=>{let{stack:e}=t;e.push(t.args.empty(e))}),km.add(86,t=>{let e=t.stack,n=lm(e.pop()).capture();e.push(n)}),km.add(85,(t,{op1:e})=>{let n=t.stack,r=t.fetchValue(lm(e)),i=lm(n.pop()),{definition:s}=r;if(ym(s,0)){s.manager;let e=t.constants,{definition:n,owner:o,resolved:a,positional:l,named:c}=bm(s);if(a)s=n;else if("string"==typeof n){let r=t.context.resolver?.lookupComponent?.(n,o)??null;s=e.resolvedComponent(r,n)}else s=e.component(n,o);void 0!==c&&i.named.merge(Op({},...c)),void 0!==l&&(i.realloc(l.length),i.positional.prepend(l));let{manager:u}=s;r.definition=s,r.manager=u,r.capabilities=s.capabilities,t.loadValue(7,o)}let{manager:o,state:a}=s;if(!mu(0,r.capabilities,du.prepareArgs))return void n.push(i);let l=i.blocks.values,c=i.blocks.names,u=o.prepareArgs(a,i);if(u){i.clear();for(let i=0;i{let n=lm(t.fetchValue(4)),{definition:r,manager:i,capabilities:s}=n;if(!mu(0,s,du.createInstance))return;let o=null;mu(0,s,du.dynamicScope)&&(o=t.dynamicScope());let a=1&e,l=null;mu(0,s,du.createArgs)&&(l=lm(t.stack.peek()));let c=null;mu(0,s,du.createCaller)&&(c=t.getSelf());let u=i.create(t.getOwner(),r.state,l,t.env,o,c,!!a);n.state=u,mu(0,s,du.updateHook)&&t.updateWith(new zm(u,i,o))}),km.add(88,(t,{op1:e})=>{let{manager:n,state:r,capabilities:i}=lm(t.fetchValue(lm(e))),s=n.getDestroyable(r);s&&t.associateDestroyable(s)}),km.add(97,(t,{op1:e})=>{t.beginCacheGroup(void 0),t.tree().pushAppendingBlock()}),km.add(89,t=>{t.loadValue(6,new Am)}),km.add(53,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=lm(t.stack.pop()),a=r?t.constants.getValue(r):null;lm(t.fetchValue(6)).setAttribute(i,o,s,a)}),km.add(105,(t,{op1:e,op2:n,op3:r})=>{let i=t.constants.getValue(e),s=t.constants.getValue(n),o=r?t.constants.getValue(r):null;lm(t.fetchValue(6)).setStaticAttribute(i,s,o)});var Am=class{attributes=te();classes=[];modifiers=[];setAttribute(t,e,n,r){let i={value:e,namespace:r,trusting:n};"class"===t&&this.classes.push(e),this.attributes[t]=i}setStaticAttribute(t,e,n){let r={value:e,namespace:n};"class"===t&&this.classes.push(e),this.attributes[t]=r}addModifier(t,e,n){if(this.modifiers.push(e),void 0!==t.env.debugRenderTree){const{manager:r,definition:i,state:s}=e;if(null===s||"object"!=typeof s&&"function"!=typeof s)return;let{element:o,constructing:a}=t.tree(),l=i.resolvedName??r.getDebugName(i.state),c=r.getDebugInstance(s),u=new fg(o,a,a);t.env.debugRenderTree.create(s,{type:"modifier",name:l,args:n,instance:c}),t.env.debugRenderTree.didRender(s,u),t.associateDestroyable(s),t.updateWith(new jm(s)),t.updateWith(new Um(s,u)),Q(s,()=>{t.env.debugRenderTree?.willDestroy(s)})}}flush(t){let e,n=this.attributes;for(let r in this.attributes){if("type"===r){e=n[r];continue}let i=Zt(this.attributes[r]);"class"===r?Fm(t,"class",Om(this.classes),i.namespace,i.trusting):Fm(t,r,i.value,i.namespace,i.trusting)}return void 0!==e&&Fm(t,"type",e.value,e.namespace,e.trusting),this.modifiers}};function Om(t){return 0===t.length?"":1===t.length?t[0]:function(t){return t.every(t=>"string"==typeof t)}(t)?t.join(" "):(e=t,pe(()=>{let t=[];for(const n of e){let e=yg("string"==typeof n?n:be(n));e&&t.push(e)}return 0===t.length?null:t.join(" ")}));var e}function Fm(t,e,n,r,i=!1){if("string"==typeof n)t.tree().setStaticAttribute(e,n,r);else{let s=t.tree().setDynamicAttribute(e,be(n),i,r);ye(n)||t.updateWith(new Mm(n,s,t.env))}}function Nm(t,e,n,r,i){let s=n.table.symbols.indexOf(t),o=r.get(e);-1!==s&&i.scope().bindBlock(s+1,o),n.lookup&&(n.lookup[t]=o)}km.add(99,(t,{op1:e})=>{let{definition:n,state:r}=lm(t.fetchValue(lm(e))),{manager:i}=n,s=lm(t.fetchValue(6));i.didCreateElement(r,t.tree().constructing,s)}),km.add(90,(t,{op1:e,op2:n})=>{let{definition:r,state:i}=lm(t.fetchValue(lm(e))),{manager:s}=r,o=s.getSelf(i);if(void 0!==t.env.debugRenderTree){let r,s=lm(t.fetchValue(lm(e))),{definition:a,manager:l}=s;if(t.stack.peek()===t.args)r=t.args.capture();else{let e=t.constants.getArray(n);t.args.setup(t.stack,e,[],0,!0),r=t.args.capture()}let c=a.compilable;if(null===c){mu(0,s.capabilities,du.dynamicLayout);let e=t.context.resolver;c=null===e?null:l.getDynamicLayout(i,e)}if(t.associateDestroyable(s),cm(l))l.getDebugCustomRenderTree(s.definition.state,s.state,r).forEach(e=>{let{bucket:n}=e;t.env.debugRenderTree.create(n,e),Q(s,()=>{t.env.debugRenderTree?.willDestroy(n)}),t.updateWith(new jm(n))});else{let e=function(t,e=t.manager){return t.resolvedName??t.debugName??e.getDebugName(t.state)}(a,l);t.env.debugRenderTree.create(s,{type:"component",name:e,args:r,instance:be(o)}),Q(s,()=>{t.env.debugRenderTree?.willDestroy(s)}),t.updateWith(new jm(s))}}t.stack.push(o)}),km.add(91,(t,{op1:e})=>{let{definition:n,state:r}=lm(t.fetchValue(lm(e))),{manager:i}=n,s=i.getTagName(r);t.stack.push(s)}),km.add(92,(t,{op1:e})=>{let n=lm(t.fetchValue(lm(e))),{manager:r,definition:i}=n,{stack:s}=t,{compilable:o}=i;if(null===o){let{capabilities:e}=n;mu(0,e,du.dynamicLayout);let i=t.context.resolver;o=null===i?null:r.getDynamicLayout(n.state,i),null===o&&(o=mu(0,e,du.wrapped)?Lp(t.constants.defaultTemplate).asWrappedLayout():Lp(t.constants.defaultTemplate).asLayout())}let a=o.compile(t.context);s.push(o.symbolTable),s.push(a)}),km.add(75,(t,{op1:e})=>{let n=lm(t.stack.pop()),r=lm(t.stack.pop()),{manager:i,capabilities:s}=n,o={definition:n,manager:i,capabilities:s,state:null,handle:r.handle,table:r.symbolTable,lookup:null};t.loadValue(lm(e),o)}),km.add(95,(t,{op1:e})=>{let{stack:n}=t,r=lm(n.pop()),i=lm(n.pop()),s=lm(t.fetchValue(lm(e)));s.handle=r,s.table=i}),km.add(38,(t,{op1:e})=>{let n,{table:r,manager:i,capabilities:s,state:o}=lm(t.fetchValue(lm(e)));mu(0,s,du.hasSubOwner)?(n=i.getOwner(o),t.loadValue(7,null)):(n=t.fetchValue(7),null===n?n=t.getOwner():t.loadValue(7,null)),t.pushRootScope(r.symbols.length+1,n)}),km.add(17,(t,{op1:e})=>{let n=lm(t.fetchValue(lm(e))),r=t.scope(),i=lm(t.stack.peek()),s=i.named.atNames;for(let o=s.length-1;o>=0;o--){let t=Zt(s[o]),e=n.table.symbols.indexOf(t),a=i.named.get(t,!0);-1!==e&&r.bindSymbol(e+1,a),n.lookup&&(n.lookup[t]=a)}}),km.add(18,(t,{op1:e})=>{let n=lm(t.fetchValue(lm(e))),{blocks:r}=lm(t.stack.peek());for(const[i]of Vp(r.names))Nm(Zt(r.symbolNames[i]),Zt(r.names[i]),n,r,t)}),km.add(96,(t,{op1:e})=>{let n=lm(t.fetchValue(lm(e)));t.call(n.handle)}),km.add(100,(t,{op1:e})=>{let n=lm(t.fetchValue(lm(e))),{manager:r,state:i,capabilities:s}=n,o=t.tree().popBlock();void 0!==t.env.debugRenderTree&&(cm(r)?r.getDebugCustomRenderTree(n.definition.state,i,oy).reverse().forEach(e=>{let{bucket:n}=e;t.env.debugRenderTree.didRender(n,o),t.updateWith(new Um(n,o))}):(t.env.debugRenderTree.didRender(n,o),t.updateWith(new Um(n,o)))),mu(0,s,du.createInstance)&&(lm(r).didRenderLayout(i,o),t.env.didCreate(n),t.updateWith(new Dm(n,o)))}),km.add(98,t=>{t.commitCacheGroup()});var zm=class{constructor(t,e,n){this.component=t,this.manager=e,this.dynamicScope=n}evaluate(t){let{component:e,manager:n,dynamicScope:r}=this;n.update(e,r)}},Dm=class{constructor(t,e){this.component=t,this.bounds=e}evaluate(t){let{component:e,bounds:n}=this,{manager:r,state:i}=e;r.didUpdateLayout(i,n),t.env.didUpdate(e)}},jm=class{constructor(t){this.bucket=t}evaluate(t){t.env.debugRenderTree?.update(this.bucket)}},Um=class{constructor(t,e){this.bucket=t,this.bounds=e}evaluate(t){t.env.debugRenderTree?.didRender(this.bucket,this.bounds)}},Bm=(new class{validate(t){return"object"==typeof t&&null!==t&&ie in t}expected(){return"Reference"}},class{stack=null;positional=new qm;named=new Vm;blocks=new Gm;constructor(){}empty(t){let e=t.registers[3]+1;return this.named.empty(t,e),this.positional.empty(t,e),this.blocks.empty(t,e),this}setup(t,e,n,r,i){this.stack=t;let s=this.named,o=e.length,a=t.registers[3]-o+1;s.setup(t,a,o,e,i);let l=a-r;this.positional.setup(t,l,r);let c=this.blocks,u=n.length,h=l-3*u;c.setup(t,h,u,n)}get base(){return this.blocks.base}get length(){return this.positional.length+this.named.length+3*this.blocks.length}at(t){return this.positional.at(t)}realloc(t){let{stack:e}=this;if(t>0&&null!==e){let{positional:n,named:r}=this,i=n.base+t;for(let t=n.length+r.length-1;t>=0;t--)e.copy(t+n.base,t+i);n.base+=t,r.base+=t,e.registers[3]+=t}}capture(){let t=0===this.positional.length?sy:this.positional.capture();return{named:0===this.named.length?iy:this.named.capture(),positional:t}}clear(){let{stack:t,length:e}=this;e>0&&null!==t&&t.pop(e)}}),$m=jp(),qm=class{base=0;length=0;stack=null;_references=null;constructor(){}empty(t,e){this.stack=t,this.base=e,this.length=0,this._references=$m}setup(t,e,n){this.stack=t,this.base=e,this.length=n,this._references=0===n?$m:null}at(t){let{base:e,length:n,stack:r}=this;return t<0||t>=n?ae:lm(r.get(t,e))}capture(){return this.references}prepend(t){let e=t.length;if(e>0){let{base:n,length:r,stack:i}=this;this.base=n-=e,this.length=r+e;for(let s=0;s0){let{names:n,length:r,stack:i}=this,s=n.slice();for(const o of e)-1===s.indexOf(o)&&(r=s.push(o),i.push(t[o]));this.length=r,this._references=null,this._names=s,this._atNames=null}}get references(){let t=this._references;if(!t){let{base:e,length:n,stack:r}=this;t=this._references=r.slice(e,e+n)}return t}toSyntheticName(t){return t.slice(1)}toAtName(t){return`@${t}`}};function Wm(t){return`&${t}`}var Hm=jp(),Gm=class{internalValues=null;_symbolNames=null;internalTag=null;names=Up;length=0;base=0;constructor(){}empty(t,e){this.stack=t,this.names=Up,this.base=e,this.length=0,this._symbolNames=null,this.internalTag=gt,this.internalValues=Hm}setup(t,e,n,r){this.stack=t,this.names=r,this.base=e,this.length=n,this._symbolNames=null,0===n?(this.internalTag=gt,this.internalValues=Hm):(this.internalTag=null,this.internalValues=null)}get values(){let t=this.internalValues;if(!t){let{base:e,length:n,stack:r}=this;t=this.internalValues=r.slice(e,e+3*n)}return t}has(t){return-1!==this.names.indexOf(t)}get(t){let e=this.names.indexOf(t);if(-1===e)return null;let{base:n,stack:r}=this,i=lm(r.get(3*e,n)),s=lm(r.get(3*e+1,n)),o=lm(r.get(3*e+2,n));return null===o?null:[o,s,i]}capture(){return new Km(this.names,this.values)}get symbolNames(){let t=this._symbolNames;return null===t&&(t=this._symbolNames=this.names.map(Wm)),t}},Km=class{length;constructor(t,e){this.names=t,this.values=e,this.length=t.length}has(t){return-1!==this.names.indexOf(t)}get(t){let e=this.names.indexOf(t);return-1===e?null:[this.values[3*e+2],this.values[3*e+1],this.values[3*e]]}};function Zm(t,e){return{named:t,positional:e}}function Ym(t){let e=te();for(const[n,r]of Object.entries(t))e[n]=be(r);return e}function Xm(t){return t.map(be)}function Jm(t){return{named:Ym(t.named),positional:Xm(t.positional)}}var Qm=Symbol("ARGUMENT_ERROR");function ty(t){return null!==t&&"object"==typeof t&&t[Qm]}function ey(t){return{[Qm]:!0,error:t}}function ny(t){let e=te();for(const[r,i]of Object.entries(t))try{e[r]=be(i)}catch(n){e[r]=ey(n)}return e}function ry(t){return{named:ny(t.named),positional:(e=t.positional,e.map(t=>{try{return be(t)}catch(e){return ey(e)}}))};var e}var iy=Object.freeze(Object.create(null)),sy=$m,oy=Zm(iy,sy),ay=a({FALSE_REFERENCE:()=>ue,NULL_REFERENCE:()=>le,REFERENCE:()=>ie,TRUE_REFERENCE:()=>ce,UNDEFINED_REFERENCE:()=>ae,childRefFor:()=>_e,childRefFromParts:()=>xe,createComputeRef:()=>pe,createConstRef:()=>he,createDebugAliasRef:()=>{},createInvokableRef:()=>me,createIteratorItemRef:()=>my,createIteratorRef:()=>gy,createPrimitiveRef:()=>oe,createReadOnlyRef:()=>fe,createUnboundRef:()=>de,isConstRef:()=>ye,isInvokableRef:()=>ge,isUpdatableRef:()=>ve,updateRef:()=>we,valueForRef:()=>be}),ly={},cy=(t,e)=>e,uy=(t,e)=>String(e),hy=t=>null===t?ly:t,dy=class{_weakMap;_primitiveMap;get weakMap(){return void 0===this._weakMap&&(this._weakMap=new WeakMap),this._weakMap}get primitiveMap(){return void 0===this._primitiveMap&&(this._primitiveMap=new Map),this._primitiveMap}set(t,e){ne(t)?this.weakMap.set(t,e):this.primitiveMap.set(t,e)}get(t){return ne(t)?this.weakMap.get(t):this.primitiveMap.get(t)}},py=new dy;function fy(t){let e=new dy;return(n,r)=>{let i=t(n,r),s=e.get(i)||0;return e.set(i,s+1),0===s?i:function(t,e){let n=py.get(t);void 0===n&&(n=[],py.set(t,n));let r=n[e];return void 0===r&&(r={value:t,count:e},n[e]=r),r}(i,s)}}function gy(t,e){return pe(()=>{let n=be(t),r=function(t){switch(t){case"@key":return fy(cy);case"@index":return fy(uy);case"@identity":return fy(hy);default:return e=t,fy(t=>null==t?t:$(t,e))}var e}(e);if(Array.isArray(n))return new vy(n,r);let i=D(n);return null===i?new vy(Dp,()=>null):new yy(i,r)})}function my(t){let e=t,n=pt();return pe(()=>(Ot(n),e),t=>{e!==t&&(e=t,ht(n))})}var yy=class{constructor(t,e){this.inner=t,this.keyFor=e}isEmpty(){return this.inner.isEmpty()}next(){let t=this.inner.next();return null!==t&&(t.key=this.keyFor(t.value,t.memo)),t}},vy=class{current;pos=0;constructor(t,e){this.iterator=t,this.keyFor=e,0===t.length?this.current={kind:"empty"}:this.current={kind:"first",value:t[this.pos]}}isEmpty(){return"empty"===this.current.kind}next(){let t,e=this.current;if("first"===e.kind)this.current={kind:"progress"},t=e.value;else{if(this.pos>=this.iterator.length-1)return null;t=this.iterator[++this.pos]}let{keyFor:n}=this;return{key:n(t,this.pos),value:t,memo:this.pos}}},by=class t{bucket;constructor(t){this.bucket=t?Op({},t):{}}get(t){return this.bucket[t]}set(t,e){return this.bucket[t]=e}child(){return new t(this.bucket)}},wy=class t{static root(e,{self:n,size:r=0}){let i=new Array(r+1).fill(ae);return new t(e,i,null).init({self:n})}static sized(e,n=0){let r=new Array(n+1).fill(ae);return new t(e,r,null)}owner;slots;callerScope;constructor(t,e,n){this.owner=t,this.slots=e,this.callerScope=n}init({self:t}){return this.slots[0]=t,this}snapshot(){return this.slots.slice()}getSelf(){return this.get(0)}getSymbol(t){return this.get(t)}getBlock(t){let e=this.get(t);return e===ae?null:e}bind(t,e){this.set(t,e)}bindSelf(t){this.set(0,t)}bindSymbol(t,e){this.set(t,e)}bindBlock(t,e){this.set(t,e)}bindCallerScope(t){this.callerScope=t}getCallerScope(){return this.callerScope}child(){return new t(this.owner,this.slots.slice(),this.callerScope)}get(t){if(t>=this.slots.length)throw new RangeError(`BUG: cannot get $${t} from scope; length=${this.slots.length}`);return this.slots[t]}set(t,e){if(t>=this.slots.length)throw new RangeError(`BUG: cannot get $${t} from scope; length=${this.slots.length}`);this.slots[t]=e}};["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach(t=>sm[t]=1);var _y=/[\t\n\v\f\r \xa0\u{1680}\u{180e}\u{2000}-\u{200a}\u{2028}\u{2029}\u{202f}\u{205f}\u{3000}\u{feff}]/u;function xy(t){return _y.test(t)}var Cy=class extends om{namespace;constructor(t){super(t),this.document=t,this.namespace=null}setAttribute(t,e,n){t.setAttribute(e,n)}removeAttribute(t,e){t.removeAttribute(e)}insertAfter(t,e,n){this.insertBefore(t,e,n.nextSibling)}},ky=Cy,Sy=Symbol("TRANSACTION"),Ey=class{scheduledInstallModifiers=[];scheduledUpdateModifiers=[];createdComponents=[];updatedComponents=[];didCreate(t){this.createdComponents.push(t)}didUpdate(t){this.updatedComponents.push(t)}scheduleInstallModifier(t){this.scheduledInstallModifiers.push(t)}scheduleUpdateModifier(t){this.scheduledUpdateModifiers.push(t)}commit(){let{createdComponents:t,updatedComponents:e}=this;for(const{manager:i,state:s}of t)i.didCreate(s);for(const{manager:i,state:s}of e)i.didUpdate(s);let{scheduledInstallModifiers:n,scheduledUpdateModifiers:r}=this;for(const{manager:i,state:s,definition:o}of n){let t=i.getTag(s);if(null!==t){let e=$t(()=>i.install(s));dt(t,e)}else i.install(s)}for(const{manager:i,state:s,definition:o}of r){let t=i.getTag(s);if(null!==t){let e=$t(()=>i.update(s));dt(t,e)}else i.update(s)}}},Ry=class{[Sy]=null;updateOperations;isInteractive;isArgumentCaptureError;debugRenderTree;constructor(t,e){this.delegate=e,this.isInteractive=e.isInteractive,this.debugRenderTree=this.delegate.enableDebugTooling?new Cm:void 0,this.isArgumentCaptureError=this.delegate.enableDebugTooling?ty:void 0,t.appendOperations?(this.appendOperations=t.appendOperations,this.updateOperations=t.updateOperations):t.document&&(this.appendOperations=new am(t.document),this.updateOperations=new Cy(t.document))}getAppendOperations(){return this.appendOperations}getDOM(){return this.updateOperations}begin(){this[Sy],this.debugRenderTree?.begin(),this[Sy]=new Ey}get transaction(){return this[Sy]}didCreate(t){this.transaction.didCreate(t)}didUpdate(t){this.transaction.didUpdate(t)}scheduleInstallModifier(t){this.isInteractive&&this.transaction.scheduleInstallModifier(t)}scheduleUpdateModifier(t){this.isInteractive&&this.transaction.scheduleUpdateModifier(t)}commit(){let t=this.transaction;this[Sy]=null,t.commit(),this.debugRenderTree?.commit(),this.delegate.onTransactionCommit()}};function Ty(t,e,n,r){return{env:new Ry(t,e),program:new ag(n.constants,n.heap),resolver:r}}function Ly(t,e){if(t[Sy])e();else{t.begin();try{e()}finally{t.commit()}}}function Py(t){return"string"==typeof t?t:"function"!=typeof t.toString?"":String(t)}function Iy(t){let e,n=Au(t);return e=null===n?null:"function"==typeof n?n:n.getHelper(t),e}function My(t){return t===ae}km.add(77,(t,{op1:e,op2:n})=>{let r=t.stack,i=r.pop(),s=r.pop(),o=t.getOwner();t.context.resolver,t.loadValue(8,function(t,e,n,r){let i,s;return pe(()=>{let o=be(e);return o===i||(s=ym(o,t)?r?wm(t,o,n,r):r:0===t&&"string"==typeof o&&o||ne(o)?wm(t,o,n,r):null,i=o),s})}(e,i,o,s))}),km.add(107,t=>{let e,n=t.stack,r=n.pop(),i=n.pop().capture(),s=t.getOwner(),o=pe(()=>{void 0!==e&&tt(e);let t=be(r);if(ym(t,1)){let{definition:n,owner:r,positional:s,named:a}=bm(t),l=Iy(n);void 0!==a&&(i.named=Op({},...a,i.named)),void 0!==s&&(i.positional=s.concat(i.positional)),e=l(i,r),J(o,e)}else ne(t)?(e=Iy(t)(i,s),et(e)&&J(o,e)):e=ae}),a=pe(()=>(be(o),be(e)));t.associateDestroyable(o),t.loadValue(8,a)}),km.add(16,(t,{op1:e})=>{let n=t.stack,r=t.constants.getValue(e)(n.pop().capture(),t.getOwner(),t.dynamicScope());et(r)&&t.associateDestroyable(r),t.loadValue(8,r)}),km.add(21,(t,{op1:e})=>{let n=t.referenceForSymbol(e);t.stack.push(n)}),km.add(19,(t,{op1:e})=>{let n=t.stack.pop();t.scope().bindSymbol(e,n)}),km.add(20,(t,{op1:e})=>{let n=t.stack.pop(),r=t.stack.pop(),i=t.stack.pop();t.scope().bindBlock(e,[n,r,i])}),km.add(37,(t,{op1:e})=>{t.pushRootScope(e,t.getOwner())}),km.add(22,(t,{op1:e})=>{let n=t.constants.getValue(e),r=t.stack.pop();t.stack.push(_e(r,n))}),km.add(23,(t,{op1:e})=>{let{stack:n}=t,r=t.scope().getBlock(e);n.push(r)}),km.add(24,t=>{let{stack:e}=t,n=e.pop();if(n&&!My(n)){let[t,r,i]=n;e.push(i),e.push(r),e.push(t)}else e.push(null),e.push(null),e.push(null)}),km.add(25,t=>{let{stack:e}=t,n=e.pop();n&&!My(n)?e.push(ce):e.push(ue)}),km.add(26,t=>{t.stack.pop(),t.stack.pop();let e=t.stack.pop(),n=e&&e.parameters.length;t.stack.push(n?ce:ue)}),km.add(27,(t,{op1:e})=>{let n=new Array(e);for(let i=e;i>0;i--)n[i-1]=lm(t.stack.pop());var r;t.stack.push((r=n,pe(()=>{const t=[];for(const e of r){const n=be(e);null!=n&&t.push(Py(n))}return t.length>0?t.join(""):null})))}),km.add(109,t=>{let e=t.stack.pop(),n=t.stack.pop(),r=t.stack.pop();t.stack.push(pe(()=>j(be(e))?be(n):be(r)))}),km.add(110,t=>{let e=t.stack.pop();t.stack.push(pe(()=>!j(be(e))))}),km.add(111,t=>{let e=t.dynamicScope(),n=t.stack,r=n.pop();n.push(pe(()=>{let t=String(be(r));return be(e.get(t))}))}),km.add(112,t=>{let{positional:e}=t.stack.pop().capture();t.loadValue(8,pe(()=>{console.log(...Xm(e))}))});var Ay=class{constructor(t,e,n){this.node=t,this.reference=e,this.lastValue=n}evaluate(){let t,e=be(this.reference),{lastValue:n}=this;e!==n&&(t=vg(e)?"":_g(e)?e:String(e),t!==n)&&(this.node.nodeValue=this.lastValue=t)}};function Oy(t){return function(t){return _g(t)||vg(t)||"boolean"==typeof t||"number"==typeof t}(t)?2:ym(t,0)||Nu(t)?0:ym(t,1)||zu(t)?1:wg(t)?4:function(t){return bg(t)&&11===t.nodeType}(t)?5:function(t){return bg(t)&&"number"==typeof t.nodeType}(t)?6:2}function Fy(t){return ne(t)?ym(t,0)||Nu(t)?0:1:2}function Ny(t,e){console.info("Use `context`, and `get()` to debug this template."),e("this")}km.add(76,t=>{let e=t.stack.peek();t.stack.push(Oy(be(e))),ye(e)||t.updateWith(new Em(e,Oy))}),km.add(106,t=>{let e=t.stack.peek();t.stack.push(Fy(be(e))),ye(e)||t.updateWith(new Em(e,Fy))}),km.add(43,t=>{let e=be(t.stack.pop()),n=vg(e)?"":String(e);t.tree().appendDynamicHTML(n)}),km.add(44,t=>{let e=be(t.stack.pop()).toHTML(),n=vg(e)?"":e;t.tree().appendDynamicHTML(n)}),km.add(47,t=>{let e=t.stack.pop(),n=be(e),r=vg(n)?"":String(n),i=t.tree().appendDynamicText(r);ye(e)||t.updateWith(new Ay(i,e,r))}),km.add(45,t=>{let e=be(t.stack.pop());t.tree().appendDynamicFragment(e)}),km.add(46,t=>{let e=be(t.stack.pop());t.tree().appendDynamicNode(e)});var zy=Ny;function Dy(t){zy=t}function jy(){zy=Ny}var Uy=class{#h;constructor(t,e){this.scope=t,this.#h=e}get(t){let e,{scope:n}=this,r=this.#h,i=t.split("."),[s,...o]=t.split(".");return"this"===s?e=n.getSelf():r.locals[s]?e=n.getSymbol(r.locals[s]):(e=this.scope.getSelf(),o=i),o.reduce((t,e)=>_e(t,e),e)}};km.add(103,(t,{op1:e})=>{let n=t.constants.getValue(e),r=new Uy(t.scope(),n);zy(be(t.getSelf()),t=>be(r.get(t)))}),km.add(72,(t,{op1:e,op2:n})=>{let r=t.stack,i=r.pop(),s=be(r.pop()),o=gy(i,null===s?"@identity":String(s)),a=be(o);t.updateWith(new Em(o,t=>t.isEmpty())),a.isEmpty()?t.lowlevel.goto(n+1):(t.enterList(o,e),t.stack.push(a))}),km.add(73,t=>{t.exitList()}),km.add(74,(t,{op1:e})=>{let n=t.stack.peek().next();null!==n?t.registerItem(t.enterItem(n)):t.lowlevel.goto(e)});var By=class{currentOpSize=0;registers;context;constructor(t,e,n,r){this.stack=t,this.externs=n,this.context=e,this.registers=r}fetchRegister(t){return this.registers[t]}loadRegister(t,e){this.registers[t]=e}setPc(t){this.registers[0]=t}pushFrame(){this.stack.push(this.registers[1]),this.stack.push(this.registers[2]),this.registers[2]=this.registers[3]-1}popFrame(){this.registers[3]=this.registers[2]-1,this.registers[1]=this.stack.get(0),this.registers[2]=this.stack.get(1)}pushSmallFrame(){this.stack.push(this.registers[1])}popSmallFrame(){this.registers[1]=this.stack.pop()}goto(t){this.setPc(this.target(t))}target(t){return this.registers[0]+t-this.currentOpSize}call(t){this.registers[1]=this.registers[0],this.setPc(this.context.program.heap.getaddr(t))}returnTo(t){this.registers[1]=this.target(t)}return(){this.setPc(this.registers[1])}nextStatement(){let{registers:t,context:e}=this,n=t[0];if(-1===n)return null;let r=e.program.opcode(n),i=this.currentOpSize=r.size;return this.registers[0]+=i,r}evaluateOuter(t,e){this.evaluateInner(t,e)}evaluateInner(t,e){t.isMachine?this.evaluateMachine(t,e):this.evaluateSyscall(t,e)}evaluateMachine(t,e){switch(t.type){case 0:return void this.pushFrame();case 1:return void this.popFrame();case 3:return void this.call(t.op1);case 2:return void e.call(this.stack.pop());case 4:return void this.goto(t.op1);case 5:return void e.return();case 6:return void this.returnTo(t.op1)}}evaluateSyscall(t,e){km.evaluate(e,t,t.type)}},$y=class{env;dom;alwaysRevalidate;frameStack=new re;constructor(t,{alwaysRevalidate:e=!1}){this.env=t,this.dom=t.getDOM(),this.alwaysRevalidate=e}execute(t,e){this._execute(t,e)}_execute(t,e){let{frameStack:n}=this;for(this.try(t,e);!n.isEmpty();){let t=this.frame.nextStatement();void 0!==t?t.evaluate(this):n.pop()}}get frame(){return this.frameStack.current}goto(t){this.frame.goto(t)}try(t,e){this.frameStack.push(new Gy(t,e))}throw(){this.frame.handleException(),this.frameStack.pop()}},qy=class{children;bounds;constructor(t,e,n,r){this.state=t,this.context=e,this.children=r,this.bounds=n}parentElement(){return this.bounds.parentElement()}firstNode(){return this.bounds.firstNode()}lastNode(){return this.bounds.lastNode()}evaluate(t){t.try(this.children,null)}},Vy=class extends qy{type="try";evaluate(t){t.try(this.children,this)}handleException(){let{state:t,bounds:e,context:{env:n}}=this;!function(t){let{children:e}=X(t);Z(e,tt)}(this);let r=Jg.resume(n,e),i=t.evaluate(r),s=this.children=[],o=i.execute(t=>{t.updateWith(this),t.pushUpdating(s)});J(this,o.drop)}},Wy=class extends Vy{retained=!1;index=-1;constructor(t,e,n,r,i,s){super(t,e,n,[]),this.key=r,this.memo=i,this.value=s}shouldRemove(){return!this.retained}reset(){this.retained=!1}},Hy=class extends qy{type="list-block";opcodeMap=new Map;marker=null;lastIterator;constructor(t,e,n,r,i){super(t,e,n,r),this.iterableRef=i,this.lastIterator=be(i)}initializeChild(t){t.index=this.children.length-1,this.opcodeMap.set(t.key,t)}evaluate(t){let e=be(this.iterableRef);if(this.lastIterator!==e){let{bounds:n}=this,{dom:r}=t,i=this.marker=r.createComment("");r.insertAfter(n.parentElement(),i,n.lastNode()),this.sync(e),this.parentElement().removeChild(i),this.marker=null,this.lastIterator=e}super.evaluate(t)}sync(t){let{opcodeMap:e,children:n}=this,r=0,i=0;for(this.children=this.bounds.boundList=[];;){let s=t.next();if(null===s)break;let o=n[r],{key:a}=s;for(;void 0!==o&&o.retained;)o=n[++r];if(void 0!==o&&o.key===a)this.retainItem(o,s),r++;else if(e.has(a)){let t=e.get(a);if(t.index{let r=e.enterItem(t);r.index=s.length,s.push(r),n.set(a,r),J(this,r)})}moveItem(t,e,n){let r,i,{children:s}=this;we(t.memo,e.memo),we(t.value,e.value),t.retained=!0,void 0===n?gg(t,this.marker):(r=t.lastNode().nextSibling,i=n.firstNode(),r!==i&&gg(t,i)),t.index=s.length,s.push(t)}deleteItem(t){tt(t),mg(t),this.opcodeMap.delete(t.key)}},Gy=class{current=0;constructor(t,e){this.ops=t,this.exceptionHandler=e}goto(t){this.current=t}nextStatement(){return this.ops[this.current++]}handleException(){this.exceptionHandler&&this.exceptionHandler.handleException()}},Ky=class{constructor(t,e,n,r){this.env=t,this.updating=e,this.bounds=n,this.drop=r,J(this,r),Q(this,()=>mg(this.bounds))}rerender({alwaysRevalidate:t=!1}={alwaysRevalidate:!1}){let{env:e,updating:n}=this;new $y(e,{alwaysRevalidate:t}).execute(n,this)}parentElement(){return this.bounds.parentElement()}firstNode(){return this.bounds.firstNode()}lastNode(){return this.bounds.lastNode()}handleException(){}},Zy=class{static restore(t,e){const n=new this(t.slice(),function(t){return[0,-1,t,0]}(t.length-1));return n.registers[0]=e,n.registers[3]=t.length-1,n.registers[2]=-1,n}registers;constructor(t=[],e){this.stack=t,this.registers=e}push(t){this.stack[++this.registers[3]]=t}dup(t=this.registers[3]){this.stack[++this.registers[3]]=this.stack[t]}copy(t,e){this.stack[e]=this.stack[t]}pop(t=1){let e=this.stack[this.registers[3]];return this.registers[3]-=t,e}peek(t=0){return this.stack[this.registers[3]-t]}get(t,e=this.registers[2]){return this.stack[e+t]}set(t,e,n=this.registers[2]){this.stack[n+e]=t}slice(t,e){return this.stack.slice(t,e)}capture(t){let e=this.registers[3]+1,n=e-t;return this.stack.slice(n,e)}reset(){this.stack.length=0}},Yy=class{drop={};scope=new re;dynamicScope=new re;updating=new re;cache=new re;list=new re;destroyable=new re;constructor(t,e){this.scope.push(t),this.dynamicScope.push(e),this.destroyable.push(this.drop)}},Xy=class t{#d;args;lowlevel;debug;trace;get stack(){return this.lowlevel.stack}get pc(){return this.lowlevel.fetchRegister(0)}#p=[null,null,null,null,null,null,null,null,null];fetch(t){let e=this.fetchValue(t);this.stack.push(e)}load(t){let e=this.stack.pop();this.loadValue(t,e)}loadValue(t,e){this.#p[t]=e}fetchValue(t){return function(t){return t<=3}(t)?this.lowlevel.fetchRegister(t):this.#p[t]}call(t){null!==t&&this.lowlevel.call(t)}return(){this.lowlevel.return()}#f;context;constructor({scope:t,dynamicScope:e,stack:n,pc:r},i,s){let o=Zy.restore(n,r);this.#f=s,this.context=i,this.#d=new Yy(t,e),this.args=new Bm,this.lowlevel=new By(o,i,void 0,o.registers),this.pushUpdating()}static initial(e,n){let r=wy.root(n.owner,n.scope??{self:ae,size:0});const i=function(t,e,n){return{pc:t,scope:e,dynamicScope:n,stack:[]}}(e.program.heap.getaddr(n.handle),r,n.dynamicScope);return new t(i,e,n.tree)}compile(t){return Tp(t.compile(this.context))}get constants(){return this.context.program.constants}get program(){return this.context.program}get env(){return this.context.env}captureClosure(t,e=this.lowlevel.fetchRegister(0)){return{pc:e,scope:this.scope(),dynamicScope:this.dynamicScope(),stack:this.stack.capture(t)}}capture(t,e=this.lowlevel.fetchRegister(0)){return new Jy(this.captureClosure(t,e),this.context)}beginCacheGroup(t){let e=this.updating(),n=new Rm;e.push(n),e.push(new Tm(t)),this.#d.cache.push(n),Tt()}commitCacheGroup(){let t=this.updating(),e=this.#d.cache.pop(),n=Lt();t.push(new Lm(e)),e.finalize(n,t.length)}enter(t){let e=this.capture(t),n=this.tree().pushResettableBlock(),r=new Vy(e,this.context,n,[]);this.didEnter(r)}enterItem({key:t,value:e,memo:n}){let{stack:r}=this,i=my(e),s=my(n);r.push(i),r.push(s);let o=this.capture(2),a=this.tree().pushResettableBlock(),l=new Wy(o,this.context,a,t,s,i);return this.didEnter(l),l}registerItem(t){this.listBlock().initializeChild(t)}enterList(t,e){let n=[],r=this.lowlevel.target(e),i=this.capture(0,r),s=this.tree().pushBlockList(n),o=new Hy(i,this.context,s,n,t);this.#d.list.push(o),this.didEnter(o)}didEnter(t){this.associateDestroyable(t),this.#d.destroyable.push(t),this.updateWith(t),this.pushUpdating(t.children)}exit(){this.#d.destroyable.pop(),this.#f.popBlock(),this.popUpdating()}exitList(){this.exit(),this.#d.list.pop()}pushRootScope(t,e){let n=wy.sized(e,t);return this.#d.scope.push(n),n}pushChildScope(){this.#d.scope.push(this.scope().child())}pushScope(t){this.#d.scope.push(t)}popScope(){this.#d.scope.pop()}pushDynamicScope(){let t=this.dynamicScope().child();return this.#d.dynamicScope.push(t),t}bindDynamicScope(t){let e=this.dynamicScope();for(const n of qp(t))e.set(n,this.stack.pop())}pushUpdating(t=[]){this.#d.updating.push(t)}popUpdating(){return this.#d.updating.pop()}updateWith(t){this.updating().push(t)}listBlock(){return this.#d.list.current}associateDestroyable(t){J(this.#d.destroyable.current,t)}updating(){return this.#d.updating.current}tree(){return this.#f}scope(){return this.#d.scope.current}dynamicScope(){return this.#d.dynamicScope.current}popDynamicScope(){this.#d.dynamicScope.pop()}getOwner(){return this.scope().owner}getSelf(){return this.scope().getSelf()}referenceForSymbol(t){return this.scope().getSymbol(t)}execute(t){return this._execute(t)}_execute(t){let e;t&&t(this);do{e=this.next()}while(!e.done);return e.value}next(){let t,{env:e}=this,n=this.lowlevel.nextStatement();return null!==n?(this.lowlevel.evaluateOuter(n,this),t={done:!1,value:null}):(this.stack.reset(),t={done:!0,value:new Ky(e,this.popUpdating(),this.#f.popBlock(),this.#d.drop)}),t}},Jy=class{state;context;constructor(t,e){this.state=t,this.context=e}evaluate(t){return new Xy(this.state,this.context,t)}},Qy=class{constructor(t){this.vm=t}next(){return this.vm.next()}sync(){return this.vm.execute()}};function tv(t,e){let n;return Ly(t,()=>n=e.sync()),n}function ev(t,e,n,r,i,s=new by){let o=Tp(i.compile(t)),a=i.symbolTable.symbols.length,l=Xy.initial(t,{scope:{self:n,size:a},dynamicScope:s,tree:r,handle:o,owner:e});return new Qy(l)}function nv(t,e,n,r,i={},s=new by){return function(t,e,n,r,i){const s=Object.keys(i).map(t=>[t,i[t]]),o=["main","else","attrs"],a=s.map(([t])=>`@${t}`);let l=t.constants.component(r,n,void 0,"{ROOT}");t.lowlevel.pushFrame();for(let h=0;h<3*o.length;h++)t.stack.push(null);t.stack.push(null),s.forEach(([,e])=>{t.stack.push(e)}),t.args.setup(t.stack,a,o,0,!0);const c=l.compilable,u={handle:Tp(c.compile(e)),symbolTable:c.symbolTable};return t.stack.push(t.args),t.stack.push(u),t.stack.push(l),new Qy(t)}(Xy.initial(t,{tree:e,handle:t.stdlib.main,dynamicScope:s,owner:n}),t,n,r,function(t){const e=he(t);return Object.keys(t).reduce((t,n)=>(t[n]=_e(e,n),t),{})}(i))}var rv=a({_instrumentStart:()=>uv,flaggedInstrument:()=>lv,instrument:()=>av,reset:()=>pv,subscribe:()=>hv,subscribers:()=>iv,unsubscribe:()=>dv}),iv=[],sv={},ov=()=>performance.now();function av(t,e,n,r){let i,s,o;if(arguments.length<=3&&"function"==typeof e?(s=e,o=n):(i=e,s=n,o=r),0===iv.length)return s.call(o);let a=i||{},l=uv(t,()=>a);return l===cv?s.call(o):function(t,e,n,r){try{return t.call(r)}catch(i){throw n.exception=i,i}finally{e()}}(s,l,a,o)}function lv(t,e,n){return n()}function cv(){}function uv(t,e,n){if(0===iv.length)return cv;let r=sv[t];if(r||(r=function(t){let e=[];for(let n of iv)n.regex.test(t)&&e.push(n.object);return sv[t]=e,e}(t)),0===r.length)return cv;let i,s=e(n),o=A.STRUCTURED_PROFILE;o&&(i=`${t}: ${s.object}`,console.time(i));let a=[],l=ov();for(let u of r)a.push(u.before(t,l,s));const c=r;return function(){let e=ov();for(let n=0;n-1?mv(e,i.split(".")):_e(e,i);r.setAttribute(s,a,!1,null)}function bv(t,e){let n;return pe(()=>{let r=be(t);return!0===r?n||(n=rp(e)):r||0===r?String(r):null})}function wv(){}var _v=class{classRef=null;rootRef;argsRevision;constructor(t,e,n,r,i,s){this.component=t,this.args=e,this.argsTag=n,this.finalizer=r,this.hasWrappedElement=i,this.isInteractive=s,this.classRef=null,this.argsRevision=null===e?0:at(n),this.rootRef=he(t),Q(this,()=>this.willDestroy(),!0),Q(this,()=>this.component.destroy())}willDestroy(){let{component:t,isInteractive:e}=this;if(e){Pt(),t.trigger("willDestroyElement"),t.trigger("willClearRender"),It();let e=Xl(t);e&&(tc(e),ec(t))}t.renderer.unregister(t)}finalize(){let{finalizer:t}=this;t(),this.finalizer=wv}};function xv(t){let e=Object.create(null),n=Object.create(null);for(let r in t){let i=t[r],s=be(i);ve(i)?e[r]=new kv(i,s):e[r]=s,n[r]=s}return n.attrs=e,n}var Cv=Symbol("REF"),kv=class{value;[fv];[Cv];constructor(t,e){this[fv]=!0,this[Cv]=t,this.value=e}update(t){we(this[Cv],t)}},Sv=new WeakMap,Ev=Symbol("DIRTY_TAG"),Rv=Symbol("IS_DISPATCHING_ATTRS"),Tv=Symbol("BOUNDS"),Lv=oe("ember-view"),Pv=class{templateFor(t){let e,{layout:n,layoutName:r}=t,i=jr(t);if(void 0===n){if(void 0===r)return null;e=i.lookup(`template:${r}`)}else{if("function"!=typeof n)return null;e=n}return gv(e(i)).asWrappedLayout()}getDynamicLayout(t){return this.templateFor(t.component)}getTagName(t){let{component:e,hasWrappedElement:n}=t;return n?e&&e.tagName||"div":null}getCapabilities(){return Av}prepareArgs(t,e){if(e.named.has("__ARGS__")){let{__ARGS__:t,...n}=e.named.capture(),r=be(t);return{positional:r.positional,named:{...n,...r.named}}}const{positionalParams:n}=t.class??t;if(null==n||0===e.positional.length)return null;let r;if("string"==typeof n){let t=e.positional.capture();r={[n]:pe(()=>Xm(t))},Object.assign(r,e.named.capture())}else{if(!(Array.isArray(n)&&n.length>0))return null;{const t=Math.min(n.length,e.positional.length);r={},Object.assign(r,e.named.capture());for(let i=0;i{s.setAttribute("class",oe(t),!1,null)}),l&&l.length&&l.forEach(t=>{!function(t,e,n){let[r,i,s]=e.split(":");if(""===r)n.setAttribute("class",oe(i),!0,null);else{let e,o=r.indexOf(".")>-1,a=o?r.split("."):[],l=o?mv(t,a):_e(t,r);e=void 0===i?bv(l,o?a[a.length-1]:r):function(t,e,n){return pe(()=>be(t)?e:n)}(l,i,s),n.setAttribute("class",e,!1,null)}}(r,t,s)}),s.setAttribute("class",Lv,!1,null),"ariaRole"in t&&s.setAttribute("role",_e(r,"ariaRole"),!1,null),t._transitionTo("hasElement"),n&&(Pt(),t.trigger("willInsertElement"),It())}didRenderLayout(t,e){t.component[Tv]=e,t.finalize()}didCreate({component:t,isInteractive:e}){e&&(t._transitionTo("inDOM"),t.trigger("didInsertElement"),t.trigger("didRender"))}update(t){let{component:e,args:n,argsTag:r,argsRevision:i,isInteractive:s}=t;if(t.finalizer=uv("render.component",Mv,e),Pt(),null!==n&&!lt(r,i)){Tt();let i=xv(n);r=t.argsTag=Lt(),t.argsRevision=at(r),e[Rv]=!0,e.setProperties(i),e[Rv]=!1,e.trigger("didUpdateAttrs"),e.trigger("didReceiveAttrs")}s&&(e.trigger("willUpdate"),e.trigger("willRender")),It(),Ot(r),Ot(e[Ev])}didUpdateLayout(t){t.finalize()}didUpdate({component:t,isInteractive:e}){e&&(t.trigger("didUpdate"),t.trigger("didRender"))}getDestroyable(t){return t}};function Iv(t){return t.instrumentDetails({initialRender:!0})}function Mv(t){return t.instrumentDetails({initialRender:!1})}var Av={dynamicLayout:!0,dynamicTag:!0,prepareArgs:!0,createArgs:!0,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!0,willDestroy:!0,hasSubOwner:!1},Ov=new Pv;function Fv(t){return t===Ov}function Nv(t){let e=cr(t,"content");return dt(Ae(t),Ae(e)),e}function zv(t,e,n){let r=Ht(t),i=Gt(t,e,r);if(e in t)return i;{let s=[i,Gt(t,"content",r)],o=Nv(t);return Kt(o)&&s.push(Me(o,e,n)),_t(s)}}var Dv=bl.create({content:null,init(){this._super(...arguments),er(this),Ae(this),Se(this,zv)},willDestroy(){this.set("content",null),this._super(...arguments)},isTruthy:Zn("content",function(){return Boolean(cr(this,"content"))}),unknownProperty(t){let e=Nv(this);return e?cr(e,t):void 0},setUnknownProperty(t,e){let n=b(this);return n.isInitializing()||n.isPrototypeMeta(this)?(Nn(this,t,null,e),e):fr(Nv(this),t,e)}});function jv(t){return Iu(t,{})}var Uv=class{__string;constructor(t){this.__string=t}toString(){return`${this.__string}`}toHTML(){return this.toString()}},Bv=function(t){return null==t?t="":"string"!=typeof t&&(t=String(t)),new Uv(t)};function $v(t){return Iu(t,{})}var qv=$v(({positional:t})=>pe(()=>Xm(t),null)),Vv=$v(({positional:t})=>{let e=t[0];return pe(()=>(...n)=>{let[r,...i]=Xm(t);if(ge(e)){let t=i.length>0?i[0]:n[0];return void we(e,t)}return r.call(null,...i,...n)},null)}),Wv=$v(({named:t})=>{let e=pe(()=>Ym(t),null),n=new Map;for(let r in t)n.set(r,t[r]);return e.children=n,e}),Hv=t=>(t=>null==t||"function"!=typeof t.toString)(t)?"":String(t),Gv=$v(({positional:t})=>pe(()=>Xm(t).map(Hv).join(""),null)),Kv=$v(({positional:t})=>{let e=t[0]??ae,n=t[1]??ae;return pe(()=>{let t=be(e);if(ee(t))return $(t,String(be(n)))},t=>{let r=be(e);if(ee(r))return q(r,String(be(n)),t)})}),Zv=class{tag=ft();element;args;listener=null;constructor(t,e){this.element=t,this.args=e,Q(this,()=>{let{element:t,listener:e}=this;if(e){let{eventName:n,callback:r,options:i}=e;Jv(t,n,r,i)}})}updateListener(){let t,e,n,{element:r,args:i,listener:s}=this,o=i.positional[0],a=o?be(o):void 0,l=i.positional[1],c=l?be(l):void 0;{let{once:r,passive:s,capture:o}=i.named;r&&(t=be(r)),s&&(e=be(s)),o&&(n=be(o))}let u,h=!1;if(h=null===s||a!==s.eventName||c!==s.userProvidedCallback||t!==s.once||e!==s.passive||n!==s.capture,h&&(void 0===t&&void 0===e&&void 0===n||(u={once:t,passive:e,capture:n})),h){let i=c;this.listener={eventName:a,callback:i,userProvidedCallback:c,once:t,passive:e,capture:n,options:u},s&&Jv(r,s.eventName,s.callback,s.options),function(t,e,n,r){Yv++,t.addEventListener(e,n,r)}(r,a,i,u)}}},Yv=0,Xv=0;function Jv(t,e,n,r){Xv++,t.removeEventListener(e,n,r)}var Qv,tb=Lu(new class{getDebugName(){return"on"}getDebugInstance(){return null}get counters(){return{adds:Yv,removes:Xv}}create(t,e,n,r){return new Zv(e,r)}getTag({tag:t}){return t}install(t){t.updateListener()}update(t){t.updateListener()}getDestroyable(t){return t}},{}),eb={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!1,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!1,updateHook:!1,createInstance:!1,wrapped:!1,willDestroy:!1,hasSubOwner:!1},nb=class{getCapabilities(){return eb}getDebugName({name:t}){return t}getSelf(){return le}getDestroyable(){return null}},rb=new nb,ib=class{constructor(t="@glimmer/component/template-only",e="(unknown template-only component)"){this.moduleName=t,this.name=e}toString(){return this.moduleName}};function sb(t,e){return new ib(t,e)}Ou(rb,ib.prototype);var ob={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1};function ab(t,e={}){let n=Boolean(e.updateHook);return{asyncLifeCycleCallbacks:Boolean(e.asyncLifecycleCallbacks),destructor:Boolean(e.destructor),updateHook:n}}function lb(t){return t.capabilities.asyncLifeCycleCallbacks}function cb(t){return t.capabilities.updateHook}var ub=class{componentManagerDelegates=new WeakMap;constructor(t){this.factory=t}getDelegateFor(t){let{componentManagerDelegates:e}=this,n=e.get(t);if(void 0===n){let{factory:r}=this;n=r(t),e.set(t,n)}return n}create(t,e,n){let r=this.getDelegateFor(t),i=Le(n.capture()),s=r.createComponent(e,i);return new hb(s,r,i)}getDebugName(t){return"function"==typeof t?t.name:t.toString()}update(t){let{delegate:e}=t;if(cb(e)){let{component:n,args:r}=t;e.updateComponent(n,r)}}didCreate({component:t,delegate:e}){lb(e)&&e.didCreateComponent(t)}didUpdate({component:t,delegate:e}){(function(t){return lb(t)&&cb(t)})(e)&&e.didUpdateComponent(t)}didRenderLayout(){}didUpdateLayout(){}getSelf({component:t,delegate:e}){return he(e.getContext(t))}getDestroyable(t){const{delegate:e}=t;if(function(t){return t.capabilities.destructor}(e)){const{component:n}=t;return Q(t,()=>e.destroyComponent(n)),t}return null}getCapabilities(){return ob}},hb=class{constructor(t,e,n){this.component=t,this.delegate=e,this.args=n}};function db(t,e={}){return{disableAutoTracking:Boolean(e.disableAutoTracking)}}var pb=class{componentManagerDelegates=new WeakMap;constructor(t){this.factory=t}getDelegateFor(t){let{componentManagerDelegates:e}=this,n=e.get(t);if(void 0===n){let{factory:r}=this;n=r(t),e.set(t,n)}return n}create(t,e,n,r){let i,s=this.getDelegateFor(t),o=Le(r),a=s.createModifier(n,o);return i={tag:ft(),element:e,delegate:s,args:o,modifier:a},Q(i,()=>s.destroyModifier(a,o)),i}getDebugName(t){return"function"==typeof t?t.name||t.toString():""}getDebugInstance({modifier:t}){return t}getTag({tag:t}){return t}install({element:t,args:e,modifier:n,delegate:r}){let{capabilities:i}=r;i.disableAutoTracking?qt(()=>r.installModifier(n,t,e)):r.installModifier(n,t,e)}update({args:t,modifier:e,delegate:n}){let{capabilities:r}=n;r.disableAutoTracking?qt(()=>n.updateModifier(e,t)):n.updateModifier(e,t)}getDestroyable(t){return t}};function fb(t,e){return Ou(new ub(t),e)}function gb(t,e){return Lu(new pb(t),e)}function mb(t,e){return Iu(new _u(t),e)}var yb=Symbol("RECOMPUTE_TAG"),vb=Symbol("IS_CLASSIC_HELPER"),bb=class extends Zc{static isHelperFactory=!0;static[vb]=!0;static helper=kb;init(t){super.init(t),this[yb]=pt()}recompute(){ws(()=>ht(this[yb]))}},wb=class{capabilities=vu(0,{hasValue:!0,hasDestroyable:!0});ownerInjection;constructor(t){let e={};Ur(e,t),this.ownerInjection=e}createHelper(t,e){return{instance:(n=t,null!=n&&"class"in n?t.create():t.create(this.ownerInjection)),args:e};var n}getDestroyable({instance:t}){return t}getValue({instance:t,args:e}){let{positional:n,named:r}=e,i=t.compute(n,r);return Ot(t[yb]),i}getDebugName(t){return Qv((t.class||t).prototype)}};mb(t=>new wb(t),bb);var _b=Au(bb),xb=class{isHelperFactory=!0;constructor(t){this.compute=t}create(){return{compute:this.compute}}},Cb=new class{capabilities=vu(0,{hasValue:!0});createHelper(t,e){return()=>t.compute.call(null,e.positional,e.named)}getValue(t){return t()}getDebugName(t){return Qv(t.compute)}};function kb(t){return new xb(t)}mb(()=>Cb,xb.prototype);var Sb=jv(()=>he("30000000-1000-4000-2000-100000000000".replace(/[0-3]/g,t=>(4*t^16*Math.random()>>(2&t)).toString(16)))),Eb=class{constructor(t,e,n,r,i){this.main=t,this.trustingGuardedAppend=e,this.cautiousGuardedAppend=n,this.trustingNonDynamicAppend=r,this.cautiousNonDynamicAppend=i}get"trusting-append"(){return this.trustingGuardedAppend}get"cautious-append"(){return this.cautiousGuardedAppend}get"trusting-non-dynamic-append"(){return this.trustingNonDynamicAppend}get"cautious-non-dynamic-append"(){return this.cautiousNonDynamicAppend}getAppend(t){return t?this.trustingGuardedAppend:this.cautiousGuardedAppend}};function Rb(t,e,n){Df(t,()=>t(76),r=>{r(2,()=>{e?(t(68),t(43)):t(47)}),"number"==typeof n?(r(0,()=>{t(68),t(81),t(79),function(t){t(36,4),t(33,3,1),t(35,4),t(0),t(83),t(85,4),Wf(t,!1,!1,!0,()=>{t(92,4),t(95,4)}),t(35,4)}(t)}),r(1,()=>{Sf(t,null,null,()=>{t(3,n)})})):(r(0,()=>{t(47)}),r(1,()=>{t(47)})),r(4,()=>{t(68),t(44)}),r(5,()=>{t(68),t(45)}),r(6,()=>{t(68),t(46)})})}var Tb={symbols:{locals:null,upvars:null},moduleName:"stdlib",scopeValues:null,isStrictMode:!0,owner:null,size:0};function Lb(t,e){let n=new mf(t.program.heap,Tb);e(function(...e){gf(n,t,Tb,e)});let r=n.commit(0);if("number"!=typeof r)throw new Error("Unexpected errors compiling std");return r}var Pb=class{constants;heap;resolver;stdlib;createOp;env;program;constructor({constants:t,heap:e},n,r){this.constants=t,this.heap=e,this.resolver=r.resolver,this.createOp=n,this.env=r.env,this.program=r.program,this.stdlib=function(t){let e=Lb(t,t=>function(t){t(75,4),Wf(t,!1,!1,!0)}(t)),n=Lb(t,t=>Rb(t,!0,null)),r=Lb(t,t=>Rb(t,!1,null)),i=Lb(t,t=>Rb(t,!0,n)),s=Lb(t,t=>Rb(t,!1,r));return new Eb(e,i,s,n,r)}(this)}};function Ib(t){return{object:`${t.name}:main`}}var Mb,Ab={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!1,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!0,updateHook:!1,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1},Ob=fu(Ab),Fb=new class{create(t,e,n,r,i){let s=i.get("outletState"),o=e.ref;i.set("outletState",o);let a={finalize:uv("render.outlet",Ib,e)};if(void 0!==r.debugRenderTree){let t=be(s)?.render?.owner,e=be(o)?.render?.owner;if(t&&t!==e){let t=e,{mountPoint:n}=t;n&&(a.engine={mountPoint:n,instance:t})}}return a}getDebugName({name:t}){return`{{outlet}} for ${t}`}getDebugCustomRenderTree(t,e){let n=[];return n.push({bucket:e,type:"outlet",name:"main",args:oy,instance:void 0}),e.engine&&n.push({bucket:e.engine,type:"engine",name:e.engine.mountPoint,args:oy,instance:e.engine.instance}),n}getCapabilities(){return Ab}getSelf(){return ae}didCreate(){}didUpdate(){}didRenderLayout(t){t.finalize()}didUpdateLayout(){}getDestroyable(){return null}},Nb=ng({id:null,block:'[[[8,[30,1],null,[["@controller","@model"],[[30,2],[30,3]]],null]],["@Component","@controller","@model"],[]]',moduleName:"(unknown template module)",isStrictMode:!0}),zb=class{handle=-1;resolvedName=null;manager=Fb;capabilities=Ob;compilable;constructor(t,e){this.state=e,this.compilable=gv(Nb(t)).asLayout()}},Db=class extends Pv{component;constructor(t){super(),this.component=t}create(t,e,n,{isInteractive:r},i){let s=this.component,o=uv("render.component",Iv,s);i.view=s;let a=""!==s.tagName;a||(r&&s.trigger("willRender"),s._transitionTo("hasElement"),r&&s.trigger("willInsertElement"));let l=new _v(s,null,gt,o,a,r);return Ot(s[Ev]),l}},jb={dynamicLayout:!0,dynamicTag:!0,prepareArgs:!1,createArgs:!1,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!0,willDestroy:!1,hasSubOwner:!1},Ub=class{handle=-1;resolvedName="-top-level";state;manager;capabilities=fu(jb);compilable=null;constructor(t){this.manager=new Db(t);let e=Za(t);this.state=e}},Bb=class{constructor(t){this.inner=t}},$b=jv(({positional:t})=>{const e=t[0];return pe(()=>{let t=be(e);return Ot(Ae(t)),tr(t)&&(t=Nv(t)),new Bb(t)})}),qb=class{position=0;constructor(t){this.length=t}isEmpty(){return!1}memoFor(t){return t}next(){let{length:t,position:e}=this;if(e>=t)return null;let n=this.valueFor(e),r=this.memoFor(e);return this.position++,{value:n,memo:r}}},Vb=class extends qb{static from(t){return t.length>0?new this(t):null}static fromForEachable(t){let e=[];return t.forEach(t=>e.push(t)),this.from(e)}constructor(t){super(t.length),this.array=t}valueFor(t){return this.array[t]}},Wb=class extends qb{static from(t){return t.length>0?new this(t):null}constructor(t){super(t.length),this.array=t}valueFor(t){return Pe(this.array,t)}},Hb=class extends qb{static fromIndexable(t){let e=Object.keys(t);if(0===e.length)return null;{let n=[];for(let r of e){let e;e=t[r],At()&&(Ot(Gt(t,r)),Array.isArray(e)&&Ot(Gt(e,"[]"))),n.push(e)}return new this(e,n)}}static fromForEachable(t){let e=[],n=[],r=0,i=!1;return t.forEach(function(t,s){i=i||arguments.length>=2,i&&e.push(s),n.push(t),r++}),0===r?null:i?new this(e,n):new Vb(n)}constructor(t,e){super(e.length),this.keys=t,this.values=e}valueFor(t){return this.values[t]}memoFor(t){return this.keys[t]}},Gb=class{static from(t){let e=t[Symbol.iterator](),n=e.next(),{done:r}=n;return r?null:new this(e,n)}position=0;constructor(t,e){this.iterable=t,this.result=e}isEmpty(){return!1}next(){let{iterable:t,result:e,position:n}=this;if(e.done)return null;let r=this.valueFor(e,n),i=this.memoFor(e,n);return this.position++,this.result=t.next(),{value:r,memo:i}}},Kb=class extends Gb{valueFor(t){return t.value}memoFor(t,e){return e}},Zb=class extends Gb{valueFor(t){return t.value[1]}memoFor(t){return t.value[0]}};function Yb(t){return null!=t&&"function"==typeof t.forEach}function Xb(t){return null!=t&&"function"==typeof t[Symbol.iterator]}V=(Mb={scheduleRevalidate(){vs.ensureInstance()},toBool:function(t){return tr(t)?(Ot(Me(t,"content")),Boolean(cr(t,"isTruthy"))):Lc(t)?(Ot(Me(t,"[]")),0!==t.length):null!==(e=t)&&"object"==typeof e&&"function"==typeof e.toHTML?Boolean(t.toString()):Boolean(t);var e},toIterator:function(t){return t instanceof Bb?function(t){return null===(e=t)||"object"!=typeof e&&"function"!=typeof e?null:Array.isArray(t)||rr(t)?Hb.fromIndexable(t):Xb(t)?Zb.from(t):Yb(t)?Hb.fromForEachable(t):Hb.fromIndexable(t);var e}(t.inner):function(t){return Kt(t)?Array.isArray(t)?Vb.from(t):rr(t)?Wb.from(t):Xb(t)?Kb.from(t):Yb(t)?Vb.fromForEachable(t):null:null}(t)},getProp:ur,setProp:gr,getPath:cr,setPath:fr,scheduleDestroy(t,e){ks("actions",null,e,t)},scheduleDestroyed(t){ks("destroy",null,t)},warnIfStyleNotTrusted(t){},assert(t,e,n){},deprecate(t,e,n){}}).scheduleRevalidate,N=Mb.scheduleDestroy,z=Mb.scheduleDestroyed,D=Mb.toIterator,j=Mb.toBool,U=Mb.getProp,B=Mb.setProp,$=Mb.getPath,q=Mb.setPath;var Jb=class{enableDebugTooling=A._DEBUG_RENDER_TREE;constructor(t,e){this.owner=t,this.isInteractive=e}onTransactionCommit(){}},Qb=jv(({positional:t,named:e})=>{const n=t[0];let r=e.type,i=e.loc,s=e.original;return be(r),be(i),be(s),pe(()=>be(n))}),tw=jv(t=>t.positional[0]),ew=jv(({positional:t})=>pe(()=>{let e=t[0],n=t[1],r=be(e).split("."),i=r[r.length-1],s=be(n);return!0===s?rp(i):s||0===s?String(s):""})),nw=jv(({positional:t},e)=>{let n=be(t[0]);return he(e.factoryFor(n)?.class)}),rw=jv(({positional:t})=>{const e=t[0];return pe(()=>{let t=be(e);return Kt(t)&&Ot(Me(t,"[]")),t})}),iw=jv(({positional:t})=>me(t[0])),sw=jv(({positional:t})=>fe(t[0])),ow=jv(({positional:t,named:e})=>de(be(t[0]))),aw={dynamicLayout:!0,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!0},lw=new class{getDynamicLayout(t){return gv(t.engine.lookup("template:application")(t.engine)).asLayout()}getCapabilities(){return aw}getOwner(t){return t.engine}create(t,{name:e},n,r){let i=t.buildChildEngineInstance(e);i.boot();let s,o,a,l,c=i.factoryFor("controller:application")||Fh(i,"application");if(n.named.has("model")&&(l=n.named.get("model")),void 0===l)s=c.create(),o=he(s),a={engine:i,controller:s,self:o,modelRef:l};else{let t=be(l);s=c.create({model:t}),o=he(s),a={engine:i,controller:s,self:o,modelRef:l}}return r.debugRenderTree&&J(i,s),a}getDebugName({name:t}){return t}getDebugCustomRenderTree(t,e,n){return[{bucket:e.engine,instance:e.engine,type:"engine",name:t.name,args:n},{bucket:e.controller,instance:e.controller,type:"route-template",name:"application",args:n}]}getSelf({self:t}){return t}getDestroyable(t){return t.engine}didCreate(){}didUpdate(){}didRenderLayout(){}didUpdateLayout(){}update(t){let{controller:e,modelRef:n}=t;void 0!==n&&e.set("model",be(n))}},cw=class{handle=-1;state;manager=lw;compilable=null;capabilities=fu(aw);constructor(t){this.resolvedName=t,this.state={name:t}}},uw=jv((t,e)=>{let n,r,i,s=t.positional[0];return n=Zm(t.named,sy),pe(()=>{let t=be(s);return"string"==typeof t?(r===t||(r=t,i=wm(0,new cw(t),e,n,!0)),i):(i=null,r=null,null)})}),hw={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!1,updateHook:!1,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1},dw=fu(hw),pw=new class{create(t,e,n){let r=n.named.get("controller");return{self:r,controller:be(r)}}getSelf({self:t}){return t}getDebugName({name:t}){return`route-template (${t})`}getDebugCustomRenderTree({name:t},e,n){return[{bucket:e,type:"route-template",name:t,args:n,instance:e.controller}]}getCapabilities(){return hw}didRenderLayout(){}didUpdateLayout(){}didCreate(){}didUpdate(){}getDestroyable(){return null}},fw=class{handle=-1;resolvedName;state;manager=pw;capabilities=dw;compilable;constructor(t,e){let n=gv(e);this.resolvedName=t,this.state={name:t},this.compilable=n.asLayout()}};function gw(t,e,n){return wm(0,new fw(e,n),t,null,!0)}var mw=jv((t,e,n)=>{let r=pe(()=>be(n.get("outletState"))?.outlets?.main),i=null,s=null;return pe(()=>{let t=be(r),n=function(t,e){if(void 0===e)return null;let n=e.render;if(void 0===n)return null;let r=n.template;return null==r?null:{ref:t,name:n.name,template:r,controller:n.controller}}(r,t);if(!function(t,e){return null!==t&&null!==e&&t.template===e.template&&t.controller===e.controller}(n,i))if(i=n,null!==n){let o,a=t?.render?.owner??e,l=te(),c=n.template;o=Nu(c)?c:gw(a,n.name,c),l.Component=he(o),l.controller=he(n.controller);let u=xe(r,["render","model"]),h=be(u);l.model=pe(()=>(i===n&&(h=be(u)),h));let d=Zm(l,sy);s=wm(0,new zb(e,n),a,d,!0)}else s=null;return s})});function yw(t){return{object:`component:${t}`}}var vw={mut:iw,readonly:sw,unbound:ow,"-hash":Wv,"-each-in":$b,"-normalize-class":ew,"-resolve":nw,"-track-array":rw,"-mount":uw,"-outlet":mw,"-in-el-null":tw},bw={...vw,array:qv,concat:Gv,fn:Vv,get:Kv,hash:Wv,"unique-id":Sb};bw["-disallow-dynamic-resolution"]=Qb;var ww={},_w={...ww,on:tb},xw=class{componentDefinitionCache=new Map;lookupPartial(){return null}lookupHelper(t,e){let n=bw[t];if(void 0!==n)return n;let r=e.factoryFor(`helper:${t}`);if(void 0===r)return null;let i=r.class;return void 0===i?null:"function"==typeof i&&!0===i[vb]?(Iu(_b,r),r):i}lookupBuiltInHelper(t){return vw[t]??null}lookupModifier(t,e){let n=_w[t];if(void 0!==n)return n;let r=e.factoryFor(`modifier:${t}`);return void 0===r?null:r.class||null}lookupBuiltInModifier(t){return ww[t]??null}lookupComponent(t,e){let n=function(t,e){let n=function(t,e){let n=`component:${t}`;return e.factoryFor(n)||null}(e,t);if(null!=(r=n)&&"function"==typeof r.create&&n.class){let t=Ap(n.class);if(void 0!==t)return{component:n,layout:t}}var r;return null===n?null:{component:n,layout:null}}(e,t);if(null===n)return null;let r,i=null;r=null===n.component?i=n.layout(e):n.component;let s=this.componentDefinitionCache.get(r);if(void 0!==s)return s;null===i&&null!==n.layout&&(i=n.layout(e));let o=uv("render.getComponentDefinition",yw,t),a=null;if(null===n.component)a={state:sb(void 0,t),manager:rb,template:i};else{let t=n.component,e=t.class,r=Fu(e);a={state:Fv(r)?t:e,manager:r,template:i}}return o(),this.componentDefinitionCache.set(r,a),a}},Cw="-top-level",kw=class t{static extend(e){return class extends t{static create(t){return t?super.create(Object.assign({},e,t)):super.create(e)}}}static reopenClass(t){Object.assign(this,t)}static create(e){let{environment:n,application:r,template:i}=e,s=jr(e),o=i(s);return new t(n,s,o,r)}ref;state;constructor(t,e,n,r){this._environment=t,this.owner=e,this.template=n,this.namespace=r;let i=pt(),s={outlets:{main:void 0},render:{owner:e,name:Cw,controller:void 0,model:void 0,template:n}},o=this.ref=pe(()=>(Ot(i),s),t=>{ht(i),s.outlets.main=t});this.state={ref:o,name:Cw,template:n,controller:void 0}}appendTo(t){let e;e=this._environment.hasDOM&&"string"==typeof t?document.querySelector(t):t,ks("render",this.owner.lookup("renderer:-dom"),"appendOutletView",this,e)}rerender(){}setOutletState(t){we(this.ref,t)}destroy(){}},Sw=class t{constructor(t,e){this.view=t,this.outletState=e}child(){return new t(this.view,this.outletState)}get(t){return this.outletState}set(t,e){return this.outletState=e,e}},Ew=()=>{},Rw=class{type="component";#g;#m;constructor(t,e,n){this.#m=()=>{let r=nv(t.context,t.builder(t.env,n.into),t.owner,e,n?.args),i=this.#g=r.sync();J(this,this.#g),this.#m=()=>{if(!nt(i)&&!rt(i))return i.rerender({alwaysRevalidate:!1})}}}isFor(t){return!1}render(){this.#m()}destroy(){tt(this)}get destroyed(){return rt(this)}get result(){return this.#g}},Tw=class{type="classic";id;result;destroyed;render;env;constructor(t,e,n,r,i,s,o,a){this.root=t,this.id=t instanceof kw?ol(t):Gl(t),this.result=void 0,this.destroyed=!1,this.env=e.env,this.render=()=>{let t=gv(r).asLayout(),l=ev(e,n,i,a(e.env,{element:s,nextSibling:null}),t,o),c=this.result=l.sync();J(this,c),this.render=()=>{if(!nt(c)&&!rt(c))return c.rerender({alwaysRevalidate:!1})}}}isFor(t){return this.root===t}destroy(){let{result:t,env:e}=this;this.destroyed=!0,this.root=null,this.result=void 0,this.render=void 0,void 0!==t&&Ly(e,()=>tt(t))}},Lw=[];function Pw(t){let e=Lw.indexOf(t);Lw.splice(e,1)}var Iw=null,Mw=0;vs.on("begin",function(){for(let t of Lw)t.rerender()}),vs.on("end",function(){for(let t of Lw)if(!t.isValid()){if(Mw>A._RERENDER_LOOP_LIMIT)throw Mw=0,t.destroy(),new Error("infinite rendering invalidation detected");return Mw++,vs.join(null,Ew)}Mw=0,function(){if(null!==Iw){let t=Iw.resolve;Iw=null,vs.join(null,t)}}()});var Aw=class t{static create(e,n){const r=new t(e,n);return J(n,r),r}#y;#v=-1;#b=!1;#w=!1;#_=[];#x=[];constructor(t,e){this.#y=t,Q(this,()=>{this.clearAllRoots(e)})}get debug(){return{roots:this.#_,inRenderTransaction:this.#b,isInteractive:this.isInteractive}}get roots(){return this.#_}get owner(){return this.#y.owner}get builder(){return this.#y.builder}get context(){return this.#y.context}get env(){return this.context.env}get isInteractive(){return this.#y.context.env.isInteractive}renderRoot(t,e){let n=this.#_;return n.push(t),J(this,t),1===n.length&&function(t){Lw.push(t)}(e),this.#C(e),t}#C(t){if(this.#b)return;this.#b=!0;let e=!1;try{this.renderRoots(t),e=!0}finally{e||(this.#v=at(wt)),this.#b=!1}}renderRoots(t){let e,n=this.#_,r=this.#x;do{e=n.length,Ly(this.context.env,()=>{for(let t=0;t=e||i.render()}this.#v=at(wt)})}while(n.length>e);for(;r.length;){let t=r.pop(),e=n.indexOf(t);n.splice(e,1)}0===this.#_.length&&Pw(t)}scheduleRevalidate(t){vs.scheduleOnce("render",this,this.revalidate,t)}isValid(){return this.#w||0===this.#_.length||lt(wt,this.#v)}revalidate(t){this.isValid()||this.#C(t)}clearAllRoots(t){let e=this.#_;for(let n of e)tt(n);this.#x.length=0,this.#_=[],e.length&&Pw(t)}},Ow=class t{static strict(e,n,r){return new t(e,{hasDOM:Io,...r},n,new xw,rm)}state;constructor(t,e,n,r,i){let s={constants:new dg,heap:new og},o=Ty({document:n},new Jb(t,e.isInteractive),s,r),a=new Pb(s,t=>new ig(t),o);this.state=Aw.create({owner:t,context:a,builder:i},this)}get debugRenderTree(){let{debugRenderTree:t}=this.state.env;return t}isValid(){return this.state.isValid()}destroy(){tt(this)}render(t,e){const n=new Rw(this.state,t,{args:e.args,into:(r=e.into,"element"in r?r:{element:r,nextSibling:null})});var r;return this.state.renderRoot(n,this)}rerender(){this.state.scheduleRevalidate(this)}},Fw=class extends Ow{static strict(t,e,n){return new Ow(t,{hasDOM:Io,...n},e,new xw,rm)}_rootTemplate;_viewRegistry;static create(t){let{_viewRegistry:e}=t,n=jr(t),r=n.lookup("service:-document"),i=n.lookup("-environment:main"),s=n.lookup(gc`template:-root`),o=n.lookup("service:-dom-builder");return new this(n,r,i,s,e,o)}constructor(t,e,n,r,i,s=rm,o=new xw){super(t,n,e,o,s),this._rootTemplate=r(t),this._viewRegistry=i||t.lookup("-view-registry:main")}appendOutletView(t,e){let n=new zb((r=t).owner,r.state);var r;let{name:i,template:s}=t.state,o=te();o.Component=he(gw(t.owner,i,s)),o.controller=ae,o.model=ae;let a=Zm(o,sy);this._appendDefinition(t,wm(0,n,t.owner,a,!0),e)}appendTo(t,e){let n=new Ub(t);this._appendDefinition(t,wm(0,n,this.state.owner,null,!0),e)}_appendDefinition(t,e,n){let r=he(e),i=new Sw(null,ae),s=new Tw(t,this.state.context,this.state.owner,this._rootTemplate,r,n,i,this.state.builder);this.state.renderRoot(s,this)}cleanupRootFor(t){if(rt(this))return;let e=this.state.roots,n=e.length;for(;n--;){let r=e[n];"classic"===r.type&&r.isFor(t)&&(r.destroy(),e.splice(n,1))}}remove(t){t._transitionTo("destroying"),this.cleanupRootFor(t),this.state.isInteractive&&t.trigger("didDestroyElement")}get _roots(){return this.state.debug.roots}get _inRenderTransaction(){return this.state.debug.inRenderTransaction}get _isInteractive(){return this.state.debug.isInteractive}get _context(){return this.state.context}register(t){let e=Gl(t);this._viewRegistry[e]=t}unregister(t){delete this._viewRegistry[Gl(t)]}getElement(t){if(this._isInteractive)return Xl(t);throw new Error("Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).")}getBounds(t){let e=t[Tv];return{parentElement:e.parentElement(),firstNode:e.firstNode(),lastNode:e.lastNode()}}},Nw=class extends cu{rootElement=null;init(t){super.init(t),this.application._watchInstance(this),this.register("-application-instance:main",this,{instantiate:!1})}_bootSync(t){return this._booted||(t=new zw(t),this.setupRegistry(t),t.rootElement?this.rootElement=t.rootElement:this.rootElement=this.application.rootElement,t.location&&fr(this.router,"location",t.location),this.application.runInstanceInitializers(this),t.isInteractive&&this.setupEventDispatcher(),this._booted=!0),this}setupRegistry(t){this.constructor.setupRegistry(this.__registry__,t)}_router;get router(){if(!this._router){let t=this.lookup("router:main");this._router=t}return this._router}didCreateRootView(t){t.appendTo(this.rootElement)}startRouting(){this.router.startRouting()}setupRouter(){this.router.setupRouter()}handleURL(t){return this.setupRouter(),this.router.handleURL(t)}setupEventDispatcher(){let t=this.lookup("event_dispatcher:main"),e=cr(this.application,"customEvents"),n=cr(this,"customEvents"),r=Object.assign({},e,n);return t.setup(r,this.rootElement),t}getURL(){return this.router.url}visit(t){this.setupRouter();let e=this.__container__.lookup("-environment:main"),n=this.router,r=cr(n,"location");return r.setURL(t),n.handleURL(r.getURL()).followRedirects().then(()=>e.options.shouldRender?function(){if(null===Iw){let t;Iw={promise:new Promise(e=>t=e),resolve:t},gs()||vs.schedule("actions",null,Ew)}return Iw.promise}().then(()=>this):this,t=>{throw t.error&&t.error instanceof Error?t.error:"TransitionAborted"===t.name?new Error(t.message):t})}willDestroy(){super.willDestroy(),this.application._unwatchInstance(this)}static setupRegistry(t,e={}){let n=e instanceof zw?e:new zw(e);t.register("-environment:main",n.toEnvironment(),{instantiate:!1}),t.register("service:-document",n.document,{instantiate:!1}),super.setupRegistry(t,n)}},zw=class{isInteractive;_renderMode;isBrowser;location=null;shouldRender;document;rootElement;constructor(t={}){this.isInteractive=Boolean(Io),this._renderMode=t._renderMode,void 0!==t.isBrowser?this.isBrowser=Boolean(t.isBrowser):this.isBrowser=Boolean(Io),this.isBrowser||(this.isInteractive=!1,this.location="none"),void 0!==t.shouldRender?this.shouldRender=Boolean(t.shouldRender):this.shouldRender=!0,this.shouldRender||(this.isInteractive=!1),t.document?this.document=t.document:this.document="undefined"!=typeof document?document:null,t.rootElement&&(this.rootElement=t.rootElement),void 0!==t.location&&(this.location=t.location),void 0!==t.isInteractive&&(this.isInteractive=Boolean(t.isInteractive))}toEnvironment(){return{...kp,hasDOM:this.isBrowser,isInteractive:this.isInteractive,_renderMode:this._renderMode,options:this}}},Dw=a({default:()=>jw}),jw=class extends jl{static NAMESPACES=oi;static NAMESPACES_BY_ID=ai;static processAll=pi;static byName=hi;init(t){super.init(t),li(this)}toString(){let t=cr(this,"name")||cr(this,"modulePrefix");if(t)return t;ui();let e=ei(this);return void 0===e&&(e=ol(this),ti(this,e)),e}nameClasses(){di(this)}destroy(){return ci(this),super.destroy()}};jw.prototype.isNamespace=!0;var Uw=function(){function t(){this._vertices=new Bw}return t.prototype.add=function(t,e,n,r){if(!t)throw new Error("argument `key` is required");var i=this._vertices,s=i.add(t);if(s.val=e,n)if("string"==typeof n)i.addEdge(s,i.add(n));else for(var o=0;o0){var r="cycle detected: "+e;throw this.each(this.path,function(t){r+=" <- "+t}),new Error(r)}}},t.prototype.reset=function(){this.stack.length=0,this.path.length=0,this.result.length=0;for(var t=0,e=this.length;t=0){var a=this[o];if(a.flag)continue;if(a.flag=!0,i.push(o),e===a.key)break;r.push(~o),this.pushIncoming(a)}else i.pop(),s.push(~o)}},t.prototype.pushIncoming=function(t){for(var e=this.stack,n=t.length-1;n>=0;n--){var r=t[n];this[r].flag||e.push(r)}},t.prototype.each=function(t,e){for(var n=0,r=t.length;n{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.test(e)&&"class"===Cc(t[e])&&n.push(rp(e.replace(r,"")))}),n}},Vw=tb;function Ww(){}var Hw=class{static toString(){return"internal component"}constructor(t,e,n){this.owner=t,this.args=e,this.caller=n,Ur(this,t)}get id(){return ol(this)}get class(){return"ember-view"}validateArguments(){for(let t of Object.keys(this.args.named))this.isSupportedArgument(t)||this.onUnsupportedArgument(t)}named(t){let e=this.args.named[t];return e?be(e):void 0}positional(t){let e=this.args.positional[t];return e?be(e):void 0}listenerFor(t){return this.named(t)||Ww}isSupportedArgument(t){return!1}onUnsupportedArgument(t){}toString(){return`<${this.constructor}:${ol(this)}>`}},Gw=new WeakMap;function Kw(t,e){let n={create(){throw void 0},toString:()=>t.toString()};return Gw.set(n,t),Ou(Yw,n),Mp(e,n),n}var Zw={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!0,dynamicScope:!1,updateHook:!1,createInstance:!0,wrapped:!1,willDestroy:!1,hasSubOwner:!1},Yw=new class{getCapabilities(){return Zw}create(t,e,n,r,i,s){let o=new(a=e,Gw.get(a))(t,n.capture(),be(s));var a;return qt(o.validateArguments.bind(o)),o}didCreate(){}didUpdate(){}didRenderLayout(){}didUpdateLayout(){}getDebugName(t){return t.toString()}getSelf(t){return he(t)}getDestroyable(t){return t}},Xw=ng({id:null,block:'[[[11,"input"],[16,1,[30,0,["id"]]],[16,0,[30,0,["class"]]],[17,1],[16,4,[30,0,["type"]]],[16,"checked",[30,0,["checked"]]],[16,2,[30,0,["value"]]],[4,[32,0],["change",[30,0,["change"]]],null],[4,[32,0],["input",[30,0,["input"]]],null],[4,[32,0],["keyup",[30,0,["keyUp"]]],null],[4,[32,0],["paste",[30,0,["valueDidChange"]]],null],[4,[32,0],["cut",[30,0,["valueDidChange"]]],null],[12],[13]],["&attrs"],[]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/input.hbs",scope:()=>({on:Vw}),isStrictMode:!0}),Jw=Object.freeze({});function Qw(t){return function(t){return t.target}(t).value}function t_(t){return void 0===t?new n_(void 0):ye(t)?new n_(be(t)):ve(t)?new r_(t):new i_(t)}var e_,n_=class{static{Hh(this.prototype,"value",[qr])}#k=void Kh(this,"value");constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}},r_=class{constructor(t){this.reference=t}get(){return be(this.reference)}set(t){we(this.reference,t)}},i_=class{local;upstream;lastUpstreamValue=Jw;constructor(t){this.upstream=new r_(t)}get(){let t=this.upstream.get();return t!==this.lastUpstreamValue&&(this.lastUpstreamValue=t,this.local=new n_(t)),this.local.get()}set(t){this.local.set(t)}},s_=class extends Hw{validateArguments(){super.validateArguments()}_value=t_(this.args.named.value);get value(){return this._value.get()}set value(t){this._value.set(t)}valueDidChange(t){this.value=Qw(t)}static{Gh(this.prototype,"valueDidChange",[$l])}change(t){this.valueDidChange(t)}input(t){this.valueDidChange(t)}keyUp(t){switch(t.key){case"Enter":this.listenerFor("enter")(t),this.listenerFor("insert-newline")(t);break;case"Escape":this.listenerFor("escape-press")(t)}}static{Gh(this.prototype,"keyUp",[$l])}listenerFor(t){let e=super.listenerFor(t);return this.isVirtualEventListener(t,e)?function(t){return e=>t(Qw(e),e)}(e):e}isVirtualEventListener(t,e){return-1!==["enter","insert-newline","escape-press"].indexOf(t)}};if(Io){const t=Object.create(null),e=document.createElement("input");t[""]=!1,t.text=!0,t.checkbox=!0,e_=n=>{let r=t[n];if(void 0===r){try{e.type=n,r=e.type===n}catch(i){r=!1}finally{e.type="text"}t[n]=r}return r}}else e_=t=>""!==t;var o_=class extends s_{static toString(){return"Input"}get class(){return this.isCheckbox?"ember-checkbox ember-view":"ember-text-field ember-view"}get type(){let t=this.named("type");return null==t?"text":e_(t)?t:"text"}get isCheckbox(){return"checkbox"===this.named("type")}_checked=t_(this.args.named.checked);get checked(){return this.isCheckbox?this._checked.get():void 0}set checked(t){this._checked.set(t)}change(t){this.isCheckbox?this.checkedDidChange(t):super.change(t)}static{Gh(this.prototype,"change",[$l])}input(t){this.isCheckbox||super.input(t)}static{Gh(this.prototype,"input",[$l])}checkedDidChange(t){let e=t.target;this.checked=e.checked}static{Gh(this.prototype,"checkedDidChange",[$l])}isSupportedArgument(t){return-1!==["type","value","checked","enter","insert-newline","escape-press"].indexOf(t)||super.isSupportedArgument(t)}},a_=Kw(o_,Xw),l_=ng({id:null,block:'[[[11,"textarea"],[16,1,[30,0,["id"]]],[16,0,[30,0,["class"]]],[17,1],[16,2,[30,0,["value"]]],[4,[32,0],["change",[30,0,["change"]]],null],[4,[32,0],["input",[30,0,["input"]]],null],[4,[32,0],["keyup",[30,0,["keyUp"]]],null],[4,[32,0],["paste",[30,0,["valueDidChange"]]],null],[4,[32,0],["cut",[30,0,["valueDidChange"]]],null],[12],[13]],["&attrs"],[]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/textarea.hbs",scope:()=>({on:Vw}),isStrictMode:!0}),c_=class extends s_{static toString(){return"Textarea"}get class(){return"ember-text-area ember-view"}change(t){super.change(t)}static{Gh(this.prototype,"change",[$l])}input(t){super.input(t)}static{Gh(this.prototype,"input",[$l])}isSupportedArgument(t){return-1!==["type","value","enter","insert-newline","escape-press"].indexOf(t)||super.isSupportedArgument(t)}},u_=Kw(c_,l_),h_=ng({id:null,block:'[[[11,3],[16,1,[30,0,["id"]]],[16,0,[30,0,["class"]]],[16,"role",[30,0,["role"]]],[16,"title",[30,0,["title"]]],[16,"rel",[30,0,["rel"]]],[16,"tabindex",[30,0,["tabindex"]]],[16,"target",[30,0,["target"]]],[17,1],[16,6,[30,0,["href"]]],[4,[32,0],["click",[30,0,["click"]]],null],[12],[18,2,null],[13]],["&attrs","&default"],["yield"]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/link-to.hbs",scope:()=>({on:Vw}),isStrictMode:!0}),d_=[],p_={};function f_(t){return null==t}function g_(t){return"object"==typeof t&&null!==t&&!0===t.isQueryParams}var m_=class extends Hw{static toString(){return"LinkTo"}static{Hh(this.prototype,"routing",[hp("-routing")])}#S=void Kh(this,"routing");validateArguments(){super.validateArguments()}get class(){let t="ember-view";return this.isActive?(t+=this.classFor("active"),!1===this.willBeActive&&(t+=" ember-transitioning-out")):this.willBeActive&&(t+=" ember-transitioning-in"),this.isLoading&&(t+=this.classFor("loading")),this.isDisabled&&(t+=this.classFor("disabled")),t}get href(){if(this.isLoading)return"#";let{routing:t,route:e,models:n,query:r}=this;return Ot(Gt(t,"currentState")),t.generateURL(e,n,r)}click(t){if(!Vl(t))return;let e=t.currentTarget,n=e instanceof SVGAElement?e.target.baseVal:e.target;if(""!==n&&"_self"!==n)return;if(this.preventDefault(t),this.isDisabled)return;if(this.isLoading)return;let{routing:r,route:i,models:s,query:o,replace:a}=this,l={transition:void 0};lv(0,0,()=>{l.transition=r.transitionTo(i,s,o,a)})}static{Gh(this.prototype,"click",[$l])}get route(){if("route"in this.args.named){let t=this.named("route");return t&&this.namespaceRoute(t)}return this.currentRoute}currentRouteCache=jt(()=>(Ot(Gt(this.routing,"currentState")),qt(()=>this.routing.currentRouteName)));get currentRoute(){return Ut(this.currentRouteCache)}get models(){return"models"in this.args.named?this.named("models"):"model"in this.args.named?[this.named("model")]:d_}get query(){return"query"in this.args.named?{...this.named("query")}:p_}get replace(){return!0===this.named("replace")}get isActive(){return this.isActiveForState(this.routing.currentState)}get willBeActive(){let t=this.routing.currentState,e=this.routing.targetState;return t===e?null:this.isActiveForState(e)}get isLoading(){return f_(this.route)||this.models.some(t=>f_(t))}get isDisabled(){return Boolean(this.named("disabled"))}get isEngine(){return void 0!==su(this.owner)}get engineMountPoint(){return this.owner.mountPoint}classFor(t){let e=this.named(`${t}Class`);return!0===e||f_(e)?` ${t}`:e?` ${e}`:""}namespaceRoute(t){let{engineMountPoint:e}=this;return void 0===e?t:"application"===t?e:`${e}.${t}`}isActiveForState(t){if(f_(t))return!1;if(this.isLoading)return!1;let e=this.named("current-when");if("boolean"==typeof e)return e;if("string"==typeof e){let{routing:n}=this;return e.split(" ").some(e=>n.isActiveForRoute([],void 0,this.namespaceRoute(e),t))}{let{route:e,models:n,query:r,routing:i}=this;return i.isActiveForRoute(n,r,e,t)}}preventDefault(t){t.preventDefault()}isSupportedArgument(t){return-1!==["route","model","models","query","replace","disabled","current-when","activeClass","loadingClass","disabledClass"].indexOf(t)||super.isSupportedArgument(t)}},{prototype:y_}=m_,v_=(t,e)=>t?Object.getOwnPropertyDescriptor(t,e)||v_(Object.getPrototypeOf(t),e):null;{let t=y_.onUnsupportedArgument;Object.defineProperty(y_,"onUnsupportedArgument",{configurable:!0,enumerable:!1,value:function(e){"href"===e||t.call(this,e)}})}{let t=v_(y_,"models").get;Object.defineProperty(y_,"models",{configurable:!0,enumerable:!1,get:function(){let e=t.call(this);return e.length>0&&!("query"in this.args.named)&&g_(e[e.length-1])&&(e=e.slice(0,-1)),e}});let e=v_(y_,"query").get;Object.defineProperty(y_,"query",{configurable:!0,enumerable:!1,get:function(){if("query"in this.args.named){let t=e.call(this);return g_(t)?t.values??p_:t}{let e=t.call(this);if(e.length>0){let t=e[e.length-1];if(g_(t)&&null!==t.values)return t.values}return p_}}})}{let t=y_.onUnsupportedArgument;Object.defineProperty(y_,"onUnsupportedArgument",{configurable:!0,enumerable:!1,value:function(e){"params"!==e&&t.call(this,e)}})}var b_=Kw(m_,h_),w_="%+b:0%";function __(t){return t.nodeValue===w_}var x_=class extends pg{candidate=null;openBlockDepth;injectedOmittedNode=!1;constructor(t,e,n){super(t,e),this.startingBlockDepth=n,this.openBlockDepth=n-1}},C_=class extends Jg{unmatchedAttributes=null;blockDepth=0;startingBlockOffset;constructor(t,e,n){if(super(t,e,n),n)throw new Error("Rehydration with nextSibling not supported");let r=this.currentCursor.element.firstChild;for(;null!==r&&!k_(r);)r=r.nextSibling;this.candidate=r;const i=E_(r);if(0!==i){const t=i-1,e=this.dom.createComment(`%+b:${t}%`);r.parentNode.insertBefore(e,this.candidate);let n=r.nextSibling;for(;null!==n&&(!S_(n)||E_(n)!==i);)n=n.nextSibling;const s=this.dom.createComment(`%-b:${t}%`);r.parentNode.insertBefore(s,n.nextSibling),this.candidate=e,this.startingBlockOffset=t}else this.startingBlockOffset=0}get currentCursor(){return this.cursors.current}get candidate(){return this.currentCursor?this.currentCursor.candidate:null}set candidate(t){this.currentCursor.candidate=t}disableRehydration(t){const e=this.currentCursor;e.candidate=null,e.nextSibling=t}enableRehydration(t){const e=this.currentCursor;e.candidate=t,e.nextSibling=null}pushElement(t,e=null){const n=new x_(t,e,this.blockDepth||0);null!==this.candidate&&(n.candidate=t.firstChild,this.candidate=t.nextSibling),this.cursors.push(n)}clearMismatch(t){let e=t;const n=this.currentCursor;if(null!==n){const t=n.openBlockDepth;if(t>=n.startingBlockDepth)for(;e&&!(S_(e)&&t>=R_(e,this.startingBlockOffset));)e=this.remove(e);else for(;null!==e;)e=this.remove(e);this.disableRehydration(e)}}__openBlock(){const{currentCursor:t}=this;if(null===t)return;const e=this.blockDepth;this.blockDepth++;const{candidate:n}=t;if(null===n)return;const{tagName:r}=t.element;k_(n)&&R_(n,this.startingBlockOffset)===e?(this.candidate=this.remove(n),t.openBlockDepth=e):"TITLE"!==r&&"SCRIPT"!==r&&"STYLE"!==r&&this.clearMismatch(n)}__closeBlock(){const{currentCursor:t}=this;if(null===t)return;const e=t.openBlockDepth;this.blockDepth--;const{candidate:n}=t;let r=!1;if(null!==n)if(r=!0,S_(n)&&R_(n,this.startingBlockOffset)===e){const e=this.remove(n);this.candidate=e,t.openBlockDepth--}else this.clearMismatch(n),r=!1;if(!r){const e=t.nextSibling;if(null!==e&&S_(e)&&R_(e,this.startingBlockOffset)===this.blockDepth){const n=this.remove(e);this.enableRehydration(n),t.openBlockDepth--}}}__appendNode(t){const{candidate:e}=this;return e||super.__appendNode(t)}__appendHTML(t){const e=this.markerBounds();if(e){const t=e.firstNode(),n=e.lastNode(),r=new fg(this.element,t.nextSibling,n.previousSibling),i=this.remove(t);return this.remove(n),null!==i&&P_(i)&&(this.candidate=this.remove(i),null!==this.candidate&&this.clearMismatch(this.candidate)),r}return super.__appendHTML(t)}remove(t){const e=t.parentNode,n=t.nextSibling;return e.removeChild(t),n}markerBounds(){const t=this.candidate;if(t&&L_(t)){const e=t;let n=e.nextSibling;for(;!L_(n);)n=Yt(n.nextSibling);return new fg(this.element,e,n)}return null}__appendText(t){const{candidate:e}=this;return e?3===e.nodeType?(e.nodeValue!==t&&(e.nodeValue=t),this.candidate=e.nextSibling,e):8===(n=e).nodeType&&"%|%"===n.nodeValue||P_(e)&&""===t?(this.candidate=this.remove(e),this.__appendText(t)):(this.clearMismatch(e),super.__appendText(t)):super.__appendText(t);var n}__appendComment(t){const e=this.candidate;return e&&8===e.nodeType?(e.nodeValue!==t&&(e.nodeValue=t),this.candidate=e.nextSibling,e):(e&&this.clearMismatch(e),super.__appendComment(t))}__openElement(t){const e=this.candidate;if(e&&T_(e)&&function(t,e){return"http://www.w3.org/2000/svg"===t.namespaceURI?t.tagName===e:t.tagName===e.toUpperCase()}(e,t))return this.unmatchedAttributes=[].slice.call(e.attributes),e;if(e){if(T_(e)&&"TBODY"===e.tagName)return this.pushElement(e,null),this.currentCursor.injectedOmittedNode=!0,this.__openElement(t);this.clearMismatch(e)}return super.__openElement(t)}__setAttribute(t,e,n){const r=this.unmatchedAttributes;if(r){const n=I_(r,t);if(n)return n.value!==e&&(n.value=e),void r.splice(r.indexOf(n),1)}return super.__setAttribute(t,e,n)}__setProperty(t,e){const n=this.unmatchedAttributes;if(n){const r=I_(n,t);if(r)return r.value!==e&&(r.value=e),void n.splice(n.indexOf(r),1)}return super.__setProperty(t,e)}__flushElement(t,e){const{unmatchedAttributes:n}=this;if(n){for(const t of n)this.constructing.removeAttribute(t.name);this.unmatchedAttributes=null}else super.__flushElement(t,e)}willCloseElement(){const{candidate:t,currentCursor:e}=this;null!==t&&this.clearMismatch(t),e&&e.injectedOmittedNode&&this.popElement(),super.willCloseElement()}getMarker(t,e){const n=t.querySelector(`script[glmr="${e}"]`);return n?(function(t){t.nodeType}(r=n),r):null;var r}__pushRemoteElement(t,e,n){const r=this.getMarker(t,e);if(!r||r.parentNode,void 0===n){for(;null!==t.firstChild&&t.firstChild!==r;)this.remove(t.firstChild);n=null}const i=new x_(t,null,this.blockDepth);this.cursors.push(i),null===r?this.disableRehydration(n):this.candidate=this.remove(r);const s=new tm(t);return this.pushBlock(s,!0)}didAppendBounds(t){if(super.didAppendBounds(t),this.candidate){const e=t.lastNode();this.candidate=e.nextSibling}return t}};function k_(t){return 8===t.nodeType&&0===t.nodeValue.lastIndexOf("%+b:",0)}function S_(t){return 8===t.nodeType&&0===t.nodeValue.lastIndexOf("%-b:",0)}function E_(t){return parseInt(t.nodeValue.slice(4),10)}function R_(t,e){return E_(t)-e}function T_(t){return 1===t.nodeType}function L_(t){return 8===t.nodeType&&"%glmr%"===t.nodeValue}function P_(t){return 8===t.nodeType&&"% %"===t.nodeValue}function I_(t,e){for(const n of t)if(n.name===e)return n}function M_(t,e){return C_.forInitialRender(t,e)}var A_=new WeakMap,O_=class extends Jg{serializeBlockDepth=0;__openBlock(){let{tagName:t}=this.element;if("TITLE"!==t&&"SCRIPT"!==t&&"STYLE"!==t){let t=this.serializeBlockDepth++;this.__appendComment(`%+b:${t}%`)}super.__openBlock()}__closeBlock(){let{tagName:t}=this.element;if(super.__closeBlock(),"TITLE"!==t&&"SCRIPT"!==t&&"STYLE"!==t){let t=--this.serializeBlockDepth;this.__appendComment(`%-b:${t}%`)}}__appendHTML(t){let{tagName:e}=this.element;if("TITLE"===e||"SCRIPT"===e||"STYLE"===e)return super.__appendHTML(t);let n=this.__appendComment("%glmr%");if("TABLE"===e){let e=t.indexOf("<");e>-1&&"tr"===t.slice(e+1,e+3)&&(t=`${t}`)}""===t?this.__appendComment("% %"):super.__appendHTML(t);let r=this.__appendComment("%glmr%");return new fg(this.element,n,r)}__appendText(t){let{tagName:e}=this.element,n=function(t){let{element:e,nextSibling:n}=t;return null===n?e.lastChild:n.previousSibling}(this);return"TITLE"===e||"SCRIPT"===e||"STYLE"===e?super.__appendText(t):""===t?this.__appendComment("% %"):(n&&3===n.nodeType&&this.__appendComment("%|%"),super.__appendText(t))}closeElement(){return A_.has(this.element)&&(A_.delete(this.element),super.closeElement()),super.closeElement()}openElement(t){return"tr"===t&&"TBODY"!==this.element.tagName&&"THEAD"!==this.element.tagName&&"TFOOT"!==this.element.tagName&&(this.openElement("tbody"),A_.set(this.constructing,!0),this.flushElement(null)),super.openElement(t)}pushRemoteElement(t,e,n=null){let{dom:r}=this,i=r.createElement("script");return i.setAttribute("glmr",e),r.insertBefore(t,i,n),super.pushRemoteElement(t,e,n)}};function F_(t,e){return O_.forInitialRender(t,e)}var N_=ng({id:null,block:'[[[46,[30,0],null,null,null]],[],["component"]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/root.hbs",isStrictMode:!0}),z_=ng({id:null,block:'[[[46,[28,[32,0],null,null],null,null,null]],[],["component"]]',moduleName:"packages/@ember/-internals/glimmer/lib/templates/outlet.hbs",scope:()=>({outletHelper:mw}),isStrictMode:!0});function D_(t){t.register("service:-dom-builder",{create(t){switch(jr(t).lookup("-environment:main")._renderMode){case"serialize":return F_.bind(null);case"rehydrate":return M_.bind(null);default:return rm.bind(null)}}}),t.register(gc`template:-root`,N_),t.register("renderer:-dom",Fw)}var j_=class t{moduleBasedResolver=!0;#E=new Map;original;static create({namespace:e}){return new t(e.modules)}constructor(t){this.addModules(t)}addModules(t){for(let[e,n]of Object.entries(t))this.#E.set(this.#R(e),n)}#R(t){return t.replace(U_,"").replace(B_,"")}#T(t){return"config"===t?t:t+"s"}resolve(t){let[e,n]=t.split(":");n=this.#L(e,n);for(let r of[this.#P,this.#I,this.#M,this.#A]){let t=r.call(this,e,n);if(t)return this.#O(t.hit)}}#O(t){return t&&t.default&&(t=t.default),t}normalize(t){let[e,n]=t.split(":");return n=this.#L(e,n),`${e}:${n}`}#L(t,e){return"component"===t||"helper"===t||"modifier"===t||"template"===t&&0===e.indexOf("components/")?e.replace(/_/g,"-"):e.replace(/\./g,"/").replace($_,"$1_$2").toLowerCase().replace(q_,"-")}#P(t,e){if("resolver"===t&&"current"===e)return{hit:{create:()=>this}}}#I(t,e){if("main"===e){let e=this.#E.get(t);if(e)return{hit:e}}}#M(t,e){let n=`${this.#T(t)}/${e}`,r=this.#E.get(n);if(r)return{hit:r}}#A(t,e){if("component"!==t)return;let n=`${this.#T(t)}/${e}/index`,r=this.#E.get(n);return r?{hit:r}:void 0}},U_=/\.\w{1,4}$/,B_=/^\.\//,$_=/([a-z\d])([A-Z])/g,q_=/[ _]/g,V_=class extends(jw.extend(au)){static initializers=Object.create(null);static instanceInitializers=Object.create(null);static initializer=H_("initializers");static instanceInitializer=H_("instanceInitializers");static buildRegistry(t){let e=new dc({resolver:W_(t)});return e.set=fr,e.register("application:main",t,{instantiate:!1}),function(t){t.optionsForType("component",{singleton:!1}),t.optionsForType("view",{singleton:!1}),t.register("controller:basic",Qc,{instantiate:!1}),t.register("service:-routing",mp),t.register("resolver-for-debugging:main",t.resolver,{instantiate:!1}),t.register("container-debug-adapter:main",qw)}(e),function(t){t.optionsForType("template",{instantiate:!1}),t.register("view:-outlet",kw),t.register("template:-outlet",z_),t.optionsForType("helper",{instantiate:!1}),t.register("component:input",a_),t.register("component:link-to",b_),t.register("component:textarea",u_)}(e),e}Resolver=j_;init(t){super.init(t),this.buildRegistry()}_initializersRan=!1;ensureInitializers(){this._initializersRan||(this.runInitializers(),this._initializersRan=!0)}buildInstance(t={}){return this.ensureInitializers(),cu.create({...t,base:this})}buildRegistry(){return this.__registry__=this.constructor.buildRegistry(this)}initializer(t){this.constructor.initializer(t)}instanceInitializer(t){this.constructor.instanceInitializer(t)}runInitializers(){this._runInitializer("initializers",(t,e)=>{e.initialize(this)})}runInstanceInitializers(t){this._runInitializer("instanceInitializers",(e,n)=>{n.initialize(t)})}_runInitializer(t,e){let n,r=cr(this.constructor,t),i=function(t){let e=[];for(let n in t)e.push(n);return e}(r),s=new Uw;for(let o of i)n=r[o],s.add(n.name,n,n.before,n.after);s.topsort(e)}};function W_(t){let e={namespace:t};return t.Resolver.create(e)}function H_(t){return function(e){let n=this.superclass;if(void 0!==n[t]&&n[t]===this[t]){let e={[t]:Object.create(this[t])};this.reopenClass(e)}this[t][e.name]=e}}var G_=a({default:()=>Y_,getOwner:()=>K_,setOwner:()=>Z_}),K_=Lo,Z_=Ur,Y_=class extends V_{static buildRegistry(t){let e=super.buildRegistry(t);return function(t){t.register("router:main",Id),t.register("-view-registry:main",{create:()=>Po(null)}),t.register("route:basic",Xh),t.register("event_dispatcher:main",uc),t.register("location:hash",qd),t.register("location:history",Wd),t.register("location:none",Hd),t.register(gc`-bucket-cache:main`,{create:()=>new yp}),t.register("service:router",gp)}(e),D_(e),e}static initializer=H_("initializers");static instanceInitializer=H_("instanceInitializers");init(t){super.init(t),this.rootElement??="body",this._document??=null,this.eventDispatcher??=null,this.customEvents??=null,this.autoboot??=!0,this._document??=Io?window.document:null,this._readinessDeferrals=1,this._booted=!1,this._applicationInstances=new Set,this.autoboot=Boolean(this.autoboot),this.autoboot&&(this.Router=(this.Router||Id).extend(),this._buildDeprecatedInstance(),this.waitForDOMReady())}buildInstance(t={}){return Nw.create({...t,base:this,application:this})}_watchInstance(t){this._applicationInstances.add(t)}_unwatchInstance(t){return this._applicationInstances.delete(t)}Router;__deprecatedInstance__;__container__;_buildDeprecatedInstance(){let t=this.buildInstance();this.__deprecatedInstance__=t,this.__container__=t.__container__}waitForDOMReady(){const t=this._document;if(null===t||"loading"!==t.readyState)ks("actions",this,this.domReady);else{let e=()=>{t.removeEventListener("DOMContentLoaded",e),bs(this,this.domReady)};t.addEventListener("DOMContentLoaded",e)}}domReady(){this.isDestroying||this.isDestroyed||this._bootSync()}deferReadiness(){this._readinessDeferrals++}advanceReadiness(){this._readinessDeferrals--,0===this._readinessDeferrals&&Ts(this,this.didBecomeReady)}_bootPromise=null;boot(){if(this._bootPromise)return this._bootPromise;try{this._bootSync()}catch(t){}return this._bootPromise}_bootResolver=null;_bootSync(){if(this._booted||this.isDestroying||this.isDestroyed)return;let t=this._bootResolver=Ua.defer();this._bootPromise=t.promise;try{this.runInitializers(),this.advanceReadiness()}catch(Z4){throw t.reject(Z4),Z4}}reset(){let t=this.__deprecatedInstance__;this._readinessDeferrals=1,this._bootPromise=null,this._bootResolver=null,this._booted=!1,ws(this,function(){bs(t,"destroy"),this._buildDeprecatedInstance(),ks("actions",this,"_bootSync")})}didBecomeReady(){if(!this.isDestroying&&!this.isDestroyed)try{if(this.autoboot){let t=this.__deprecatedInstance__;t._bootSync(),this.ready(),t.startRouting()}this._bootResolver.resolve(this),this._booted=!0}catch(Z4){throw this._bootResolver.reject(Z4),Z4}}ready(){return this}willDestroy(){super.willDestroy(),this._applicationInstances.size&&(this._applicationInstances.forEach(t=>t.destroy()),this._applicationInstances.clear())}visit(t,e){return this.boot().then(()=>{let n=this.buildInstance();return n.boot(e).then(()=>n.visit(t)).catch(t=>{throw bs(n,"destroy"),t})})}},X_=Object.assign({},{});function J_(){return Q_.global}var Q_=globalThis.__embroider_macros__runtime_config__||={};Q_.packages||={},Q_.global||={};Object.assign(Q_.packages,{}),Object.assign(Q_.global,{});var tx="undefined"!=typeof window?window._embroider_macros_runtime_config:void 0;if(tx){let t={config:function(t){return Q_.packages[t]},getGlobalConfig:J_,setConfig(t,e){Q_.packages[t]=e},setGlobalConfig(t,e){Q_.global[t]=e}};for(let e of tx)e(t)}var ex=a({default:()=>nx,enterTestMode:()=>rx}),nx={modulePrefix:"marco",environment:"production",rootURL:"/",locationType:"history",EmberENV:{},APP:{}};function rx(){nx.locationType="none",nx.APP.rootElement="#ember-testing",nx.APP.autoboot=!1;const t=J_()["@embroider/macros"];t&&(t.isTesting=!0)}var ix=()=>{},sx=()=>{};function ox(t){let e=t.lookup("renderer:-dom");if(!e)throw new Error("BUG: owner is missing renderer");return e.debugRenderTree.capture()}var ax=a({_warnIfUsingStrippedFeatureFlags:()=>{},assert:()=>xn,captureRenderTree:()=>ox,debug:()=>hx,debugFreeze:()=>px,debugSeal:()=>dx,deprecate:()=>vx,deprecateFunc:()=>yx,getDebugFunction:()=>mx,info:()=>cx,inspect:()=>Pn,isTesting:()=>nu,registerDeprecationHandler:()=>ix,registerWarnHandler:()=>sx,runInDebug:()=>fx,setDebugFunction:()=>gx,setTesting:()=>ru,warn:()=>ux}),lx=()=>{},cx=lx,ux=lx,hx=lx,dx=lx,px=lx,fx=lx,gx=lx,mx=lx,yx=function(){return arguments[arguments.length-1]};function vx(){}var bx,wx=a({});bx={throwOnUnhandled:!1,workflow:[]},self.deprecationWorkflow=self.deprecationWorkflow||{},self.deprecationWorkflow.deprecationLog={messages:new Set},self.deprecationWorkflow.flushDeprecations=t=>function({handler:t="silence",config:e={}}={}){let n=self.deprecationWorkflow.deprecationLog.messages,r=e.workflow??[],i=n.values().filter(t=>!r.some(e=>e.matchId===t)).map(e=>({handler:t,matchId:e})),s={...e,workflow:[...r,...i]};return`import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow';\n\nsetupDeprecationWorkflow(${JSON.stringify(s,void 0,2)});`}({config:bx,...t}),function(){const t="TEST_WAITERS",e="undefined"!=typeof Symbol?Symbol.for(t):t,n=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;throw new Error("unable to locate global object")}();let r=n[e];void 0===r&&(r=n[e]=new Map)}();var _x=class{name;constructor(t){this.name=t}beginAsync(){return this}endAsync(){}waitUntil(){return!0}debugInfo(){return[]}reset(){}};function xx(t){return new _x(t)}xx("@ember/test-waiters:promise-waiter"),xx("@ember/test-waiters:generator-waiter");var Cx,kx=a({assertDestroyablesDestroyed:()=>{},associateDestroyableChild:()=>J,destroy:()=>tt,enableDestroyableTracking:()=>{},isDestroyed:()=>rt,isDestroying:()=>nt,registerDestructor:()=>Sx,unregisterDestructor:()=>Ex});function Sx(t,e){return Q(t,e)}function Ex(t,e){return function(t,e,n=!1){let r=X(t),i=n?"eagerDestructors":"destructors";r[i]=Y(r[i],e)}(t,e)}(Cx=To,Cx?.__esModule?Cx:{default:Cx,...Cx}).getOwner;var Rx=Id,Tx=a({default:()=>Lx}),Lx=class extends Rx{location=nx.locationType;rootURL=nx.rootURL};function Px(t){return 0===t||3===t||1e4<=t&&t<2e4}function Ix(t){return 3e4<=t&&t<4e4}function Mx(t,e){const n=e instanceof Array?e:[e];return function(t){if(!(t instanceof Object))return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.pubkey)return!1;if(!t.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(t.tags))return!1;for(let e=0;e0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Fx(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}Lx.map(function(){this.route("place",{path:"/place/:place_id"}),this.route("place.new",{path:"/place/new"}),this.route("search"),this.route("menu"),this.route("lists",function(){this.route("list",{path:"/:list_id"})}),this.route("contributions"),this.route("oauth",function(){this.route("osm-callback",{path:"/osm/callback"})})});var Nx="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,zx=t=>t instanceof Uint8Array,Dx=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),jx=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Ux(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!zx(t))throw new Error("expected Uint8Array, got "+typeof t);return t}var Bx=class{clone(){return this._cloneInto()}};function $x(t){const e=e=>t().update(Ux(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function qx(t=32){if(Nx&&"function"==typeof Nx.getRandomValues)return Nx.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}var Vx=class extends Bx{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Dx(this.buffer)}update(t){Fx(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Ux(t)).length;for(let s=0;sr-s&&(this.process(n,0),s=0);for(let u=s;u>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=Dx(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;ut&e^~t&n,Hx=(t,e,n)=>t&e^t&n^e&n,Gx=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Kx=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zx=new Uint32Array(64),Yx=class extends Vx{constructor(){super(64,32,8,!1),this.A=0|Kx[0],this.B=0|Kx[1],this.C=0|Kx[2],this.D=0|Kx[3],this.E=0|Kx[4],this.F=0|Kx[5],this.G=0|Kx[6],this.H=0|Kx[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[t,e,n,r,i,s,o,a]}set(t,e,n,r,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let u=0;u<16;u++,e+=4)Zx[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){const t=Zx[u-15],e=Zx[u-2],n=jx(t,7)^jx(t,18)^t>>>3,r=jx(e,17)^jx(e,19)^e>>>10;Zx[u]=r+Zx[u-7]+n+Zx[u-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let u=0;u<64;u++){const t=c+(jx(o,6)^jx(o,11)^jx(o,25))+Wx(o,a,l)+Gx[u]+Zx[u]|0,e=(jx(n,2)^jx(n,13)^jx(n,22))+Hx(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){Zx.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Xx=$x(()=>new Yx),Jx=a({bitGet:()=>vC,bitLen:()=>yC,bitMask:()=>wC,bitSet:()=>bC,bytesToHex:()=>iC,bytesToNumberBE:()=>lC,bytesToNumberLE:()=>cC,concatBytes:()=>fC,createHmacDrbg:()=>CC,ensureBytes:()=>pC,equalBytes:()=>gC,hexToBytes:()=>aC,hexToNumber:()=>oC,numberToBytesBE:()=>uC,numberToBytesLE:()=>hC,numberToHexUnpadded:()=>sC,numberToVarBytesBE:()=>dC,utf8ToBytes:()=>mC,validateObject:()=>SC}),Qx=BigInt(0),tC=BigInt(1),eC=BigInt(2),nC=t=>t instanceof Uint8Array,rC=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function iC(t){if(!nC(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+e.length,0));let n=0;return t.forEach(t=>{if(!nC(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}function gC(t,e){if(t.length!==e.length)return!1;for(let n=0;nQx;t>>=tC,e+=1);return e}function vC(t,e){return t>>BigInt(e)&tC}var bC=(t,e,n)=>t|(n?tC:Qx)<(eC<new Uint8Array(t),xC=t=>Uint8Array.from(t);function CC(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=_C(t),i=_C(t),s=0;const o=()=>{r.fill(1),i.fill(0),s=0},a=(...t)=>n(i,r,...t),l=(t=_C())=>{i=a(xC([0]),t),r=a(),0!==t.length&&(i=a(xC([1]),t),r=a())},c=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t{let n;for(o(),l(t);!(n=e(c()));)l();return o(),n}}var kC={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function SC(t,e,n={}){const r=(e,n,r)=>{const i=kC[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const s=t[e];if(!(r&&void 0===s||i(s,t)))throw new Error(`Invalid param ${String(e)}=${s} (${typeof s}), expected ${n}`)};for(const[i,s]of Object.entries(e))r(i,s,!1);for(const[i,s]of Object.entries(n))r(i,s,!0);return t}var EC=BigInt(0),RC=BigInt(1),TC=BigInt(2),LC=BigInt(3),PC=BigInt(4),IC=BigInt(5),MC=BigInt(8);function AC(t,e){const n=t%e;return n>=EC?n:e+n}function OC(t,e,n){if(n<=EC||e 0");if(n===RC)return EC;let r=RC;for(;e>EC;)e&RC&&(r=r*t%n),t=t*t%n,e>>=RC;return r}function FC(t,e,n){let r=t;for(;e-- >EC;)r*=r,r%=n;return r}function NC(t,e){if(t===EC||e<=EC)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=AC(t,e),r=e,i=EC,s=RC,o=RC,a=EC;for(;n!==EC;){const t=r/n,e=r%n,l=i-o*t,c=s-a*t;r=n,n=e,i=o,s=a,o=l,a=c}if(r!==RC)throw new Error("invert: does not exist");return AC(i,e)}BigInt(9),BigInt(16);var zC=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function DC(t,e){const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function jC(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function UC(t){const e=jC(t);return e+Math.ceil(e/2)}var BC=BigInt(0),$C=BigInt(1);function qC(t){return function(t){const e=zC.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});SC(t,e)}(t.Fp),SC(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...DC(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var{bytesToNumberBE:VC,hexToBytes:WC}=Jx,HC={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=HC;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:VC(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=HC,n="string"==typeof t?WC(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:i,l:s}=HC._parseInt(n.subarray(2)),{d:o,l:a}=HC._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},r=e(n(t.s)),i=e(n(t.r)),s=r.length/2,o=i.length/2,a=n(s),l=n(o);return`30${n(o+s+4)}02${l}${i}02${a}${r}`}},GC=BigInt(0),KC=BigInt(1),ZC=BigInt(3);var YC=class extends Bx{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Ax(t.outputLen),Ax(t.blockLen)}(t);const n=Ux(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let s=0;snew YC(t,e).update(n).digest();function JC(t){return{hash:t,hmac:(e,...n)=>XC(t,e,function(...t){const e=new Uint8Array(t.reduce((t,e)=>t+e.length,0));let n=0;return t.forEach(t=>{if(!zx(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}(...n)),randomBytes:qx}}XC.create=(t,e)=>new YC(t,e);var QC=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),tk=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ek=BigInt(1),nk=BigInt(2),rk=(t,e)=>(t+e/nk)/e;function ik(t){const e=QC,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=t*t*t%e,u=c*c*t%e,h=FC(u,n,e)*u%e,d=FC(h,n,e)*u%e,p=FC(d,nk,e)*c%e,f=FC(p,i,e)*p%e,g=FC(f,s,e)*f%e,m=FC(g,a,e)*g%e,y=FC(m,l,e)*m%e,v=FC(y,a,e)*g%e,b=FC(v,n,e)*u%e,w=FC(b,o,e)*f%e,_=FC(w,r,e)*c%e,x=FC(_,nk,e);if(!sk.eql(sk.sqr(x),t))throw new Error("Cannot find square root");return x}var sk=function(t,e,n=!1,r={}){if(t<=EC)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=DC(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=function(t){if(t%PC===LC){const e=(t+RC)/PC;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}}if(t%MC===IC){const e=(t-IC)/MC;return function(t,n){const r=t.mul(n,TC),i=t.pow(r,e),s=t.mul(n,i),o=t.mul(t.mul(s,TC),i),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-RC)/TC;let n,r,i;for(n=t-RC,r=0;n%TC===EC;n/=TC,r++);for(i=TC;iAC(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return EC<=e&&et===EC,isOdd:t=>(t&RC)===RC,neg:e=>AC(-e,t),eql:(t,e)=>t===e,sqr:e=>AC(e*e,t),add:(e,n)=>AC(e+n,t),sub:(e,n)=>AC(e-n,t),mul:(e,n)=>AC(e*n,t),pow:(t,e)=>function(t,e,n){if(n 0");if(n===EC)return t.ONE;if(n===RC)return e;let r=t.ONE,i=e;for(;n>EC;)n&RC&&(r=t.mul(r,i)),i=t.sqr(i),n>>=RC;return r}(a,t,e),div:(e,n)=>AC(e*NC(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>NC(e,t),sqrt:r.sqrt||(t=>o(a,t)),invertBatch:t=>function(t,e){const n=new Array(e.length),r=e.reduce((e,r,i)=>t.is0(r)?e:(n[i]=e,t.mul(e,r)),t.ONE),i=t.inv(r);return e.reduceRight((e,r,i)=>t.is0(r)?e:(n[i]=t.mul(e,n[i]),t.mul(e,r)),i),n}(a,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?hC(t,s):uC(t,s),fromBytes:t=>{if(t.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${t.length}`);return n?cC(t):lC(t)}});return Object.freeze(a)}(QC,void 0,void 0,{sqrt:ik}),ok=function(t,e){const n=e=>function(t){const e=function(t){const e=qC(t);return SC(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,i=n.BYTES+1,s=2*n.BYTES+1;function o(t){return AC(t,r)}function a(t){return NC(t,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:h}=function(t){const e=function(t){const e=qC(t);SC(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:n}=e,r=e.toBytes||((t,e)=>{const r=e.toAffine();return fC(Uint8Array.from([4]),n.toBytes(r.x),n.toBytes(r.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function s(t){const{a:r,b:i}=e,s=n.sqr(t),o=n.mul(s,t);return n.add(n.add(o,n.mul(t,r)),i)}if(!n.eql(n.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function o(t){return"bigint"==typeof t&&GCn.eql(t,n.ZERO);return i(e)&&i(r)?h.ZERO:new h(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(h.fromAffine)}static fromHex(t){const e=h.fromAffine(i(pC("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw new Error("bad point: x or y not FE");const i=n.sqr(r),o=s(t);if(!n.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:i}=this,{px:s,py:o,pz:a}=t,l=n.eql(n.mul(e,a),n.mul(s,i)),c=n.eql(n.mul(r,a),n.mul(o,i));return l&&c}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,i=n.mul(r,ZC),{px:s,py:o,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,d=n.mul(s,s),p=n.mul(o,o),f=n.mul(a,a),g=n.mul(s,o);return g=n.add(g,g),u=n.mul(s,a),u=n.add(u,u),l=n.mul(t,u),c=n.mul(i,f),c=n.add(l,c),l=n.sub(p,c),c=n.add(p,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(i,u),f=n.mul(t,f),g=n.sub(d,f),g=n.mul(t,g),g=n.add(g,u),u=n.add(d,d),d=n.add(u,d),d=n.add(d,f),d=n.mul(d,g),c=n.add(c,d),f=n.mul(o,a),f=n.add(f,f),d=n.mul(f,g),l=n.sub(l,d),u=n.mul(f,p),u=n.add(u,u),u=n.add(u,u),new h(l,c,u)}add(t){u(t);const{px:r,py:i,pz:s}=this,{px:o,py:a,pz:l}=t;let c=n.ZERO,d=n.ZERO,p=n.ZERO;const f=e.a,g=n.mul(e.b,ZC);let m=n.mul(r,o),y=n.mul(i,a),v=n.mul(s,l),b=n.add(r,i),w=n.add(o,a);b=n.mul(b,w),w=n.add(m,y),b=n.sub(b,w),w=n.add(r,s);let _=n.add(o,l);return w=n.mul(w,_),_=n.add(m,v),w=n.sub(w,_),_=n.add(i,s),c=n.add(a,l),_=n.mul(_,c),c=n.add(y,v),_=n.sub(_,c),p=n.mul(f,w),c=n.mul(g,v),p=n.add(c,p),c=n.sub(y,p),p=n.add(y,p),d=n.mul(c,p),y=n.add(m,m),y=n.add(y,m),v=n.mul(f,v),w=n.mul(g,w),y=n.add(y,v),v=n.sub(m,v),v=n.mul(f,v),w=n.add(w,v),m=n.mul(y,w),d=n.add(d,m),m=n.mul(_,w),c=n.mul(b,c),c=n.sub(c,m),m=n.mul(b,y),p=n.mul(_,p),p=n.add(p,m),new h(c,d,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,t=>{const e=n.invertBatch(t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(h.fromAffine)})}multiplyUnsafe(t){const r=h.ZERO;if(t===GC)return r;if(a(t),t===KC)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:s,k1:o,k2neg:l,k2:c}=i.splitScalar(t),u=r,d=r,f=this;for(;o>GC||c>GC;)o&KC&&(u=u.add(f)),c&KC&&(d=d.add(f)),f=f.double(),o>>=KC,c>>=KC;return s&&(u=u.negate()),l&&(d=d.negate()),d=new h(n.mul(d.px,i.beta),d.py,d.pz),u.add(d)}multiply(t){a(t);let r,i,s=t;const{endo:o}=e;if(o){const{k1neg:t,k1:e,k2neg:a,k2:l}=o.splitScalar(s);let{p:c,f:u}=this.wNAF(e),{p:d,f:f}=this.wNAF(l);c=p.constTimeNegate(t,c),d=p.constTimeNegate(a,d),d=new h(n.mul(d.px,o.beta),d.py,d.pz),r=c.add(d),i=u.add(f)}else{const{p:t,f:e}=this.wNAF(s);r=t,i=e}return h.normalizeZ([r,i])[0]}multiplyAndAddUnsafe(t,e,n){const r=h.BASE,i=(t,e)=>e!==GC&&e!==KC&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),s=i(this,e).add(i(t,n));return s.is0()?void 0:s}toAffine(t){const{px:e,py:r,pz:i}=this,s=this.is0();null==t&&(t=s?n.ONE:n.inv(i));const o=n.mul(e,t),a=n.mul(r,t),l=n.mul(i,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(l,n.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===KC)return!0;if(n)return n(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===KC?this:n?n(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(h,this,t)}toHex(t=!0){return iC(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const d=e.nBitLength,p=function(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,i=e;for(;n>BC;)n&$C&&(r=r.add(i)),i=i.double(),n>>=$C;return r},precomputeWindow(t,e){const{windows:n,windowSize:i}=r(e),s=[];let o=t,a=o;for(let r=0;r>=d,r>a&&(r-=h,s+=$C);const o=e,p=e+Math.abs(r)-1,f=t%2!=0,g=r<0;0===r?c=c.add(n(f,i[o])):l=l.add(n(g,i[p]))}return{p:l,f:c}},wNAFCached(t,e,n,r){const i=t._WINDOW_SIZE||1;let s=e.get(t);return s||(s=this.precomputeWindow(t,i),1!==i&&e.set(t,r(s))),this.wNAF(i,s,n)}}}(h,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:s,isWithinCurveOrder:o}}({...e,toBytes(t,e,r){const i=e.toAffine(),s=n.toBytes(i.x),o=fC;return r?o(Uint8Array.from([e.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,n.toBytes(i.y))},fromBytes(t){const e=t.length,r=t[0],o=t.subarray(1);if(e!==i||2!==r&&3!==r){if(e===s&&4===r)return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))};throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const t=lC(o);if(!(GC<(a=t)&&aiC(uC(t,e.nByteLength));function p(t){return t>r>>KC}const f=(t,e,n)=>lC(t.slice(e,n));class g{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=pC("compactSignature",t,2*n),new g(f(t,0,n),f(t,n,2*n))}static fromDER(t){const{r:e,s:n}=HC.toSig(pC("DER",t));return new g(e,n)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r:r,s:i,recovery:s}=this,c=b(pC("msgHash",t));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const u=2===s||3===s?r+e.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&s?"03":"02",p=l.fromHex(h+d(u)),f=a(u),g=o(-c*f),m=o(i*f),y=l.BASE.multiplyAndAddUnsafe(p,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return aC(this.toDERHex())}toDERHex(){return HC.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return aC(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(t){try{return c(t),!0}catch(Z4){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=UC(e.n);return function(t,e,n=!1){const r=t.length,i=jC(e),s=UC(e);if(r<16||r1024)throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);const o=AC(n?lC(t):cC(t),e-RC)+RC;return n?hC(o,i):uC(o,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=l.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function y(t){const e=t instanceof Uint8Array,n="string"==typeof t,r=(e||n)&&t.length;return e?r===i||r===s:n?r===2*i||r===2*s:t instanceof l}const v=e.bits2int||function(t){const n=lC(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},b=e.bits2int_modN||function(t){return o(v(t))},w=wC(e.nBitLength);function _(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(GC<=t&&tt in i))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=e;let{lowS:d,prehash:f,extraEntropy:m}=i;null==d&&(d=!0),t=pC("msgHash",t),f&&(t=pC("prehashed msgHash",s(t)));const y=b(t),w=c(r),C=[_(w),_(y)];if(null!=m){const t=!0===m?u(n.BYTES):m;C.push(pC("extraEntropy",t))}const k=fC(...C),S=y;return{seed:k,k2sig:function(t){const e=v(t);if(!h(e))return;const n=a(e),r=l.BASE.multiply(e).toAffine(),i=o(r.x);if(i===GC)return;const s=o(n*o(S+i*w));if(s===GC)return;let c=(r.x===i?0:2)|Number(r.y&KC),u=s;return d&&p(s)&&(u=function(t){return p(t)?o(-t):t}(s),c^=1),new g(i,u,c)}}}(t,r,i),d=e;return CC(d.hash.outputLen,d.nByteLength,d.hmac)(s,u)},verify:function(t,n,r,i=C){const s=t;if(n=pC("msgHash",n),r=pC("publicKey",r),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=i;let h,d;try{if("string"==typeof s||s instanceof Uint8Array)try{h=g.fromDER(s)}catch(x){if(!(x instanceof HC.Err))throw x;h=g.fromCompact(s)}else{if("object"!=typeof s||"bigint"!=typeof s.r||"bigint"!=typeof s.s)throw new Error("PARSE");{const{r:t,s:e}=s;h=new g(t,e)}}d=l.fromHex(r)}catch(Z4){if("PARSE"===Z4.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&h.hasHighS())return!1;u&&(n=e.hash(n));const{r:p,s:f}=h,m=b(n),y=a(f),v=o(m*y),w=o(p*y),_=l.BASE.multiplyAndAddUnsafe(d,v,w)?.toAffine();return!!_&&o(_.x)===p},ProjectivePoint:l,Signature:g,utils:m}}({...t,...JC(e)});return Object.freeze({...n(e),create:n})}({a:BigInt(0),b:BigInt(7),Fp:sk,n:tk,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=tk,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ek*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,o=BigInt("0x100000000000000000000000000000000"),a=rk(s*t,e),l=rk(-r*t,e);let c=AC(t-a*n-l*i,e),u=AC(-a*r-l*s,e);const h=c>o,d=u>o;if(h&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:h,k1:c,k2neg:d,k2:u}}}},Xx),ak=BigInt(0),lk=t=>"bigint"==typeof t&&akt.charCodeAt(0)));n=fC(e,e),ck[t]=n}return Xx(fC(n,...e))}var hk=t=>t.toRawBytes(!0).slice(1),dk=t=>uC(t,32),pk=t=>AC(t,QC),fk=t=>AC(t,tk),gk=ok.ProjectivePoint;function mk(t){let e=ok.utils.normPrivateKeyToScalar(t),n=gk.fromPrivateKey(e);return{scalar:n.hasEvenY()?e:fk(-e),bytes:hk(n)}}function yk(t){if(!lk(t))throw new Error("bad x: need 0 < x < p");const e=pk(t*t);let n=ik(pk(e*t+BigInt(7)));n%nk!==ak&&(n=pk(-n));const r=new gk(t,n,ek);return r.assertValidity(),r}function vk(...t){return fk(lC(uk("BIP0340/challenge",...t)))}function bk(t){return mk(t).bytes}function wk(t,e,n=qx(32)){const r=pC("message",t),{bytes:i,scalar:s}=mk(e),o=pC("auxRand",n,32),a=uk("BIP0340/nonce",dk(s^lC(uk("BIP0340/aux",o))),i,r),l=fk(lC(a));if(l===ak)throw new Error("sign failed: k is zero");const{bytes:c,scalar:u}=mk(l),h=vk(c,i,r),d=new Uint8Array(64);if(d.set(c,0),d.set(dk(fk(u+h*s)),32),!_k(d,r,i))throw new Error("sign: Invalid signature produced");return d}function _k(t,e,n){const r=pC("signature",t,64),i=pC("message",e),s=pC("publicKey",n,32);try{const t=yk(lC(s)),e=lC(r.subarray(0,32));if(!lk(e))return!1;const n=lC(r.subarray(32,64));if(!(t=>"bigint"==typeof t&&ak({getPublicKey:bk,sign:wk,verify:_k,utils:{randomPrivateKey:ok.utils.randomPrivateKey,lift_x:yk,pointToBytes:hk,numberToBytesBE:uC,bytesToNumberBE:lC,taggedHash:uk,mod:AC}}))(),Ck="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,kk=t=>t instanceof Uint8Array,Sk=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ek=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");var Rk=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Tk(t){if(!kk(t))throw new Error("Uint8Array expected");let e="";for(let n=0;nt+e.length,0));let n=0;return t.forEach(t=>{if(!kk(t))throw new Error("Uint8Array expected");e.set(t,n),n+=t.length}),e}var Mk=class{clone(){return this._cloneInto()}};function Ak(t){const e=e=>t().update(Pk(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ok(t=32){if(Ck&&"function"==typeof Ck.getRandomValues)return Ck.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function Fk(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Nk(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}var zk={number:Fk,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:Nk,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Fk(t.outputLen),Fk(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},output:function(t,e){Nk(t);const n=e.outputLen;if(t.lengthr-s&&(this.process(n,0),s=0);for(let u=s;u>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const o=Sk(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;ut&e^~t&n,Uk=(t,e,n)=>t&e^t&n^e&n,Bk=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$k=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qk=new Uint32Array(64),Vk=class extends Dk{constructor(){super(64,32,8,!1),this.A=0|$k[0],this.B=0|$k[1],this.C=0|$k[2],this.D=0|$k[3],this.E=0|$k[4],this.F=0|$k[5],this.G=0|$k[6],this.H=0|$k[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:s,G:o,H:a}=this;return[t,e,n,r,i,s,o,a]}set(t,e,n,r,i,s,o,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(t,e){for(let u=0;u<16;u++,e+=4)qk[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){const t=qk[u-15],e=qk[u-2],n=Ek(t,7)^Ek(t,18)^t>>>3,r=Ek(e,17)^Ek(e,19)^e>>>10;qk[u]=r+qk[u-7]+n+qk[u-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let u=0;u<64;u++){const t=c+(Ek(o,6)^Ek(o,11)^Ek(o,25))+jk(o,a,l)+Bk[u]+qk[u]|0,e=(Ek(n,2)^Ek(n,13)^Ek(n,22))+Uk(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){qk.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Wk=class extends Vk{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}},Hk=Ak(()=>new Vk);function Gk(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function Kk(...t){const e=(t,e)=>n=>t(e(n));return{encode:Array.from(t).reverse().reduce((t,n)=>t?e(t,n.encode):n.encode,void 0),decode:t.reduce((t,n)=>t?e(t,n.decode):n.decode,void 0)}}function Zk(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map(e=>{if(Gk(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]})},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map(e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const n=t.indexOf(e);if(-1===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n})}}}function Yk(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function Xk(t,e="="){if(Gk(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function Jk(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function Qk(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let r=0;const i=[],s=Array.from(t);for(s.forEach(t=>{if(Gk(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)});;){let t=0,o=!0;for(let i=r;inew Wk);var tS=(t,e)=>e?tS(e,t%e):t,eS=(t,e)=>t+(e-tS(t,e));function nS(t,e,n,r){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(eS(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${eS(e,n)}`);let i=0,s=0;const o=2**n-1,a=[];for(const l of t){if(Gk(l),l>=2**e)throw new Error(`convertRadix2: invalid data word=${l} from=${e}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)a.push((i>>s-n&o)>>>0);i&=2**s-1}if(i=i<=e)throw new Error("Excess padding");if(!r&&i)throw new Error(`Non-zero padding: ${i}`);return r&&s>0&&a.push(i>>>0),a}function rS(t,e=!1){if(Gk(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(eS(8,t)>32||eS(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return nS(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(nS(n,t,8,e))}}}function iS(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(n){}}}var sS=Kk(rS(4),Zk("0123456789ABCDEF"),Yk("")),oS=Kk(rS(5),Zk("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Xk(5),Yk("")),aS=(Kk(rS(5),Zk("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Xk(5),Yk("")),Kk(rS(5),Zk("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),Yk(""),Jk(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),Kk(rS(6),Zk("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Xk(6),Yk(""))),lS=Kk(rS(6),Zk("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Xk(6),Yk("")),cS=t=>Kk((Gk(58),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Qk(Array.from(t),256,58)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Qk(t,58,256))}}),Zk(t),Yk("")),uS=cS("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),hS=(cS("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),cS("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),dS={encode(t){let e="";for(let n=0;n>25;let n=(33554431&t)<<5;for(let r=0;r>r&1)&&(n^=fS[r]);return n}function mS(t,e,n=1){const r=t.length;let i=1;for(let s=0;s126)throw new Error(`Invalid prefix (${t})`);i=gS(i)^e>>5}i=gS(i);for(let s=0;sn)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${n})`);const r=t.toLowerCase();if(t!==r&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(t=r).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const s=t.slice(0,i),o=t.slice(i+1);if(o.length<6)throw new Error("Data must be at least 6 characters long");const a=pS.decode(o).slice(0,-6),l=mS(s,a,e);if(!o.endsWith(l))throw new Error(`Invalid checksum in ${t}: expected "${l}"`);return{prefix:s,words:a}}return{encode:function(t,n,r=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);const i=t.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);return`${t=t.toLowerCase()}1${pS.encode(n)}${mS(t,n,e)}`},decode:o,decodeToBytes:function(t){const{prefix:e,words:n}=o(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:iS(o),fromWords:r,fromWordsUnsafe:s,toWords:i}}var vS=yS("bech32"),bS=(yS("bech32m"),{utf8:{encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},hex:Kk(rS(4),Zk("0123456789abcdef"),Yk(""),Jk(t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),base16:sS,base32:oS,base64:aS,base64url:lS,base58:uS,base58xmr:dS});function wS(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function _S(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function xS(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function CS(t,...e){if(!xS(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function kS(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function SS(t,e){CS(t);const n=e.outputLen;if(t.lengthnew Uint8Array(t.buffer,t.byteOffset,t.byteLength),RS=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),TS=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");var LS=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function PS(t){CS(t);let e="";for(let n=0;n=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function MS(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let i=0,s=0;i(Object.assign(e,t),e);function NS(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),s=BigInt(4294967295),o=Number(n>>i&s),a=Number(n&s),l=r?4:0,c=r?0:4;t.setUint32(e+l,o,r),t.setUint32(e+c,a,r)}var zS=16,DS=new Uint8Array(16),jS=RS(DS),US=(t,e,n,r)=>({s3:n<<31|r>>>1,s2:e<<31|n>>>1,s1:t<<31|e>>>1,s0:t>>>1^225<<24&-(1&r)}),BS=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255,$S=class{constructor(t,e){this.blockLen=zS,this.outputLen=zS,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,CS(t=AS(t),16);const n=TS(t);let r=n.getUint32(0,!1),i=n.getUint32(4,!1),s=n.getUint32(8,!1),o=n.getUint32(12,!1);const a=[];for(let d=0;d<128;d++)a.push({s0:BS(r),s1:BS(i),s2:BS(s),s3:BS(o)}),({s0:r,s1:i,s2:s,s3:o}=US(r,i,s,o));const l=(t=>t>65536?8:t>1024?4:2)(e||1024);if(![1,2,4,8].includes(l))throw new Error(`ghash: wrong window size=${l}, should be 2, 4 or 8`);this.W=l;const c=128/l,u=this.windowSize=2**l,h=[];for(let d=0;d>>l-s-1&1))continue;const{s0:o,s1:c,s2:u,s3:h}=a[l*d+s];e^=o,n^=c,r^=u,i^=h}h.push({s0:e,s1:n,s2:r,s3:i})}this.t=h}_updateBlock(t,e,n,r){t^=this.s0,e^=this.s1,n^=this.s2,r^=this.s3;const{W:i,t:s,windowSize:o}=this;let a=0,l=0,c=0,u=0;const h=(1<>>8*t&255;for(let t=8/i-1;t>=0;t--){const n=e>>>i*t&h,{s0:r,s1:p,s2:f,s3:g}=s[d*o+n];a^=r,l^=p,c^=f,u^=g,d+=1}}this.s0=a,this.s1=l,this.s2=c,this.s3=u}update(t){t=AS(t),kS(this);const e=RS(t),n=Math.floor(t.length/zS),r=t.length%zS;for(let i=0;i>>1|n,n=(1&e)<<7}return t[0]^=225&-e,t}((t=AS(t)).slice());super(n,e),n.fill(0)}update(t){t=AS(t),kS(this);const e=RS(t),n=t.length%zS,r=Math.floor(t.length/zS);for(let i=0;it(n,e.length).update(AS(e)).digest(),n=t(new Uint8Array(16),0);return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=(e,n)=>t(e,n),e}var WS=VS((t,e)=>new $S(t,e)),HS=VS((t,e)=>new qS(t,e)),GS=16,KS=new Uint8Array(GS);function ZS(t){return t<<1^283&-(t>>7)}function YS(t,e){let n=0;for(;e>0;e>>=1)n^=t&-(1&e),t=ZS(t);return n}var XS=(()=>{let t=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=ZS(r))t[n]=r;const e=new Uint8Array(256);e[0]=99;for(let n=0;n<255;n++){let r=t[255-n];r|=r<<8,e[t[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return e})(),JS=XS.map((t,e)=>XS.indexOf(e)),QS=t=>t<<24|t>>>8,tE=t=>t<<8|t>>>24;function eE(t,e){if(256!==t.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map((n,r)=>e(t[r])),r=n.map(tE),i=r.map(tE),s=i.map(tE),o=new Uint32Array(65536),a=new Uint32Array(65536),l=new Uint16Array(65536);for(let c=0;c<256;c++)for(let e=0;e<256;e++){const u=256*c+e;o[u]=n[c]^r[e],a[u]=i[c]^s[e],l[u]=t[c]<<8|t[e]}return{sbox:t,sbox2:l,T0:n,T1:r,T2:i,T3:s,T01:o,T23:a}}var nE=eE(XS,t=>YS(t,3)<<24|t<<16|t<<8|YS(t,2)),rE=eE(JS,t=>YS(t,11)<<24|YS(t,13)<<16|YS(t,9)<<8|YS(t,14)),iE=(()=>{const t=new Uint8Array(16);for(let e=0,n=1;e<16;e++,n=ZS(n))t[e]=n;return t})();function sE(t){CS(t);const e=t.length;if(![16,24,32].includes(e))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);const{sbox2:n}=nE,r=RS(t),i=r.length,s=t=>lE(n,t,t,t,t),o=new Uint32Array(e+28);o.set(r);for(let a=i;a6&&a%i===4&&(t=s(t)),o[a]=o[a-i]^t}return o}function oE(t){const e=sE(t),n=e.slice(),r=e.length,{sbox2:i}=nE,{T0:s,T1:o,T2:a,T3:l}=rE;for(let c=0;c>>8&255]^a[e>>>16&255]^l[e>>>24]}return n}function aE(t,e,n,r,i,s){return t[n<<8&65280|r>>>8&255]^e[i>>>8&65280|s>>>24&255]}function lE(t,e,n,r,i){return t[255&e|65280&n]|t[r>>>16&255|i>>>16&65280]<<16}function cE(t,e,n,r,i){const{sbox2:s,T01:o,T23:a}=nE;let l=0;e^=t[l++],n^=t[l++],r^=t[l++],i^=t[l++];const c=t.length/4-2;for(let u=0;u>>0,a.setUint32(u,d,e),({s0:p,s1:f,s2:g,s3:m}=cE(t,o[0],o[1],o[2],o[3]));const y=GS*Math.floor(l.length/4);if(y16)throw new Error(`aes/pcks5: wrong padding byte: ${r}`);const i=t.subarray(0,-r);for(let s=0;s=0;t--)e=e+(255&s[t])|0,s[t]=255&e,e>>>=8;({s0:a,s1:l,s2:c,s3:u}=cE(t,o[0],o[1],o[2],o[3]))}const p=GS*Math.floor(h.length/4);if(pn(t,e),decrypt:(t,e)=>n(t,e)}}),FS({blockSize:16},function(t,e={}){CS(t);const n=!e.disablePadding;return{encrypt:(e,r)=>{CS(e);const{b:i,o:s,out:o}=fE(e,n,r),a=sE(t);let l=0;for(;l+4<=i.length;){const{s0:t,s1:e,s2:n,s3:r}=cE(a,i[l+0],i[l+1],i[l+2],i[l+3]);s[l++]=t,s[l++]=e,s[l++]=n,s[l++]=r}if(n){const t=mE(e.subarray(4*l)),{s0:n,s1:r,s2:i,s3:o}=cE(a,t[0],t[1],t[2],t[3]);s[l++]=n,s[l++]=r,s[l++]=i,s[l++]=o}return a.fill(0),o},decrypt:(e,r)=>{pE(e);const i=oE(t),s=hE(e.length,r),o=RS(e),a=RS(s);for(let t=0;t+4<=o.length;){const{s0:e,s1:n,s2:r,s3:s}=uE(i,o[t+0],o[t+1],o[t+2],o[t+3]);a[t++]=e,a[t++]=n,a[t++]=r,a[t++]=s}return i.fill(0),gE(s,n)}}});var yE=FS({blockSize:16,nonceLength:16},function(t,e,n={}){CS(t),CS(e,16);const r=!n.disablePadding;return{encrypt:(n,i)=>{const s=sE(t),{b:o,o:a,out:l}=fE(n,r,i),c=RS(e);let u=c[0],h=c[1],d=c[2],p=c[3],f=0;for(;f+4<=o.length;)u^=o[f+0],h^=o[f+1],d^=o[f+2],p^=o[f+3],({s0:u,s1:h,s2:d,s3:p}=cE(s,u,h,d,p)),a[f++]=u,a[f++]=h,a[f++]=d,a[f++]=p;if(r){const t=mE(n.subarray(4*f));u^=t[0],h^=t[1],d^=t[2],p^=t[3],({s0:u,s1:h,s2:d,s3:p}=cE(s,u,h,d,p)),a[f++]=u,a[f++]=h,a[f++]=d,a[f++]=p}return s.fill(0),l},decrypt:(n,i)=>{pE(n);const s=oE(t),o=RS(e),a=hE(n.length,i),l=RS(n),c=RS(a);let u=o[0],h=o[1],d=o[2],p=o[3];for(let t=0;t+4<=l.length;){const e=u,n=h,r=d,i=p;u=l[t+0],h=l[t+1],d=l[t+2],p=l[t+3];const{s0:o,s1:a,s2:f,s3:g}=uE(s,u,h,d,p);c[t++]=o^e,c[t++]=a^n,c[t++]=f^r,c[t++]=g^i}return s.fill(0),gE(a,r)}}});function vE(t,e,n,r,i){const s=t.create(n,r.length+(i?.length||0));i&&s.update(i),s.update(r);const o=new Uint8Array(16),a=TS(o);return i&&NS(a,0,BigInt(8*i.length),e),NS(a,8,BigInt(8*r.length),e),s.update(o),s.digest()}FS({blockSize:16,nonceLength:16},function(t,e){function n(n,r,i){const s=sE(t),o=n.length;i=hE(o,i);const a=RS(n),l=RS(i),c=r?l:a,u=RS(e);let h=u[0],d=u[1],p=u[2],f=u[3];for(let t=0;t+4<=a.length;){const{s0:e,s1:n,s2:r,s3:i}=cE(s,h,d,p,f);l[t+0]=a[t+0]^e,l[t+1]=a[t+1]^n,l[t+2]=a[t+2]^r,l[t+3]=a[t+3]^i,h=c[t++],d=c[t++],p=c[t++],f=c[t++]}const g=GS*Math.floor(a.length/4);if(gn(t,!0,e),decrypt:(t,e)=>n(t,!1,e)}}),FS({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){if(CS(e),0===e.length)throw new Error("aes/gcm: empty nonce");function r(t,e,r){const i=vE(WS,!1,t,r,n);for(let n=0;n{CS(t);const{xk:e,authKey:n,counter:s,tagMask:o}=i(),a=new Uint8Array(t.length+16);dE(e,!1,s,t,a);const l=r(n,o,a.subarray(0,a.length-16));return a.set(l,t.length),e.fill(0),a},decrypt:t=>{if(CS(t),t.length<16)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:e,authKey:n,counter:s,tagMask:o}=i(),a=t.subarray(0,-16),l=t.subarray(-16);if(!OS(r(n,o,a),l))throw new Error("aes/gcm: invalid ghash tag");const c=dE(e,!1,s,a);return n.fill(0),o.fill(0),e.fill(0),c}}});var bE=(t,e,n)=>r=>{if(!Number.isSafeInteger(r)||e>r||r>n)throw new Error(`${t}: invalid value=${r}, must be [${e}..${n}]`)},wE=(FS({blockSize:16,nonceLength:12,tagLength:16},function(t,e,n){const r=bE("AAD",0,2**36),i=bE("plaintext",0,2**36),s=bE("nonce",12,12),o=bE("ciphertext",16,2**36+16);function a(){const n=t.length;if(16!==n&&24!==n&&32!==n)throw new Error(`key length must be 16, 24 or 32 bytes, got: ${n} bytes`);const r=sE(t),i=new Uint8Array(n),s=new Uint8Array(16),o=RS(e);let a=0,l=o[0],c=o[1],u=o[2],h=0;for(const t of[s,i].map(RS)){const e=RS(t);for(let t=0;t{CS(t),i(t.length);const{encKey:e,authKey:n}=a(),r=l(e,n,t),s=new Uint8Array(t.length+16);return s.set(r,t.length),s.set(c(e,r,t)),e.fill(0),n.fill(0),s},decrypt:t=>{CS(t),o(t.length);const e=t.subarray(-16),{encKey:n,authKey:r}=a(),i=c(n,e,t.subarray(0,-16)),s=l(n,r,i);if(n.fill(0),r.fill(0),!OS(e,s))throw new Error("invalid polyval tag");return i}}}),(t,e)=>255&t[e++]|(255&t[e++])<<8),_E=class{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,CS(t=AS(t),32);const e=wE(t,0),n=wE(t,2),r=wE(t,4),i=wE(t,6),s=wE(t,8),o=wE(t,10),a=wE(t,12),l=wE(t,14);this.r[0]=8191&e,this.r[1]=8191&(e>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|i<<9),this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,this.r[6]=8191&(s>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|l<<8),this.r[9]=l>>>5&127;for(let c=0;c<8;c++)this.pad[c]=wE(t,16+2*c)}process(t,e,n=!1){const r=n?0:2048,{h:i,r:s}=this,o=s[0],a=s[1],l=s[2],c=s[3],u=s[4],h=s[5],d=s[6],p=s[7],f=s[8],g=s[9],m=wE(t,e+0),y=wE(t,e+2),v=wE(t,e+4),b=wE(t,e+6),w=wE(t,e+8),_=wE(t,e+10),x=wE(t,e+12),C=wE(t,e+14);let k=i[0]+(8191&m),S=i[1]+(8191&(m>>>13|y<<3)),E=i[2]+(8191&(y>>>10|v<<6)),R=i[3]+(8191&(v>>>7|b<<9)),T=i[4]+(8191&(b>>>4|w<<12)),L=i[5]+(w>>>1&8191),P=i[6]+(8191&(w>>>14|_<<2)),I=i[7]+(8191&(_>>>11|x<<5)),M=i[8]+(8191&(x>>>8|C<<8)),A=i[9]+(C>>>5|r),O=0,F=O+k*o+S*(5*g)+E*(5*f)+R*(5*p)+T*(5*d);O=F>>>13,F&=8191,F+=L*(5*h)+P*(5*u)+I*(5*c)+M*(5*l)+A*(5*a),O+=F>>>13,F&=8191;let N=O+k*a+S*o+E*(5*g)+R*(5*f)+T*(5*p);O=N>>>13,N&=8191,N+=L*(5*d)+P*(5*h)+I*(5*u)+M*(5*c)+A*(5*l),O+=N>>>13,N&=8191;let z=O+k*l+S*a+E*o+R*(5*g)+T*(5*f);O=z>>>13,z&=8191,z+=L*(5*p)+P*(5*d)+I*(5*h)+M*(5*u)+A*(5*c),O+=z>>>13,z&=8191;let D=O+k*c+S*l+E*a+R*o+T*(5*g);O=D>>>13,D&=8191,D+=L*(5*f)+P*(5*p)+I*(5*d)+M*(5*h)+A*(5*u),O+=D>>>13,D&=8191;let j=O+k*u+S*c+E*l+R*a+T*o;O=j>>>13,j&=8191,j+=L*(5*g)+P*(5*f)+I*(5*p)+M*(5*d)+A*(5*h),O+=j>>>13,j&=8191;let U=O+k*h+S*u+E*c+R*l+T*a;O=U>>>13,U&=8191,U+=L*o+P*(5*g)+I*(5*f)+M*(5*p)+A*(5*d),O+=U>>>13,U&=8191;let B=O+k*d+S*h+E*u+R*c+T*l;O=B>>>13,B&=8191,B+=L*a+P*o+I*(5*g)+M*(5*f)+A*(5*p),O+=B>>>13,B&=8191;let $=O+k*p+S*d+E*h+R*u+T*c;O=$>>>13,$&=8191,$+=L*l+P*a+I*o+M*(5*g)+A*(5*f),O+=$>>>13,$&=8191;let q=O+k*f+S*p+E*d+R*h+T*u;O=q>>>13,q&=8191,q+=L*c+P*l+I*a+M*o+A*(5*g),O+=q>>>13,q&=8191;let V=O+k*g+S*f+E*p+R*d+T*h;O=V>>>13,V&=8191,V+=L*u+P*c+I*l+M*a+A*o,O+=V>>>13,V&=8191,O=(O<<2)+O|0,O=O+F|0,F=8191&O,O>>>=13,N+=O,i[0]=F,i[1]=N,i[2]=z,i[3]=D,i[4]=j,i[5]=U,i[6]=B,i[7]=$,i[8]=q,i[9]=V}finalize(){const{h:t,pad:e}=this,n=new Uint16Array(10);let r=t[1]>>>13;t[1]&=8191;for(let o=2;o<10;o++)t[o]+=r,r=t[o]>>>13,t[o]&=8191;t[0]+=5*r,r=t[0]>>>13,t[0]&=8191,t[1]+=r,r=t[1]>>>13,t[1]&=8191,t[2]+=r,n[0]=t[0]+5,r=n[0]>>>13,n[0]&=8191;for(let o=1;o<10;o++)n[o]=t[o]+r,r=n[o]>>>13,n[o]&=8191;n[9]-=8192;let i=(1^r)-1;for(let o=0;o<10;o++)n[o]&=i;i=~i;for(let o=0;o<10;o++)t[o]=t[o]&i|n[o];t[0]=65535&(t[0]|t[1]<<13),t[1]=65535&(t[1]>>>3|t[2]<<10),t[2]=65535&(t[2]>>>6|t[3]<<7),t[3]=65535&(t[3]>>>9|t[4]<<4),t[4]=65535&(t[4]>>>12|t[5]<<1|t[6]<<14),t[5]=65535&(t[6]>>>2|t[7]<<11),t[6]=65535&(t[7]>>>5|t[8]<<8),t[7]=65535&(t[8]>>>8|t[9]<<5);let s=t[0]+e[0];t[0]=65535&s;for(let o=1;o<8;o++)s=(t[o]+e[o]|0)+(s>>>16)|0,t[o]=65535&s}update(t){kS(this);const{buffer:e,blockLen:n}=this,r=(t=AS(t)).length;for(let i=0;i>>0,t[i++]=n[s]>>>8;return t}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}},xE=function(t){const e=(e,n)=>t(n).update(AS(e)).digest(),n=t(new Uint8Array(32));return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e}(t=>new _E(t)),CE=t=>Uint8Array.from(t.split("").map(t=>t.charCodeAt(0))),kE=CE("expand 16-byte k"),SE=CE("expand 32-byte k"),EE=RS(kE),RE=RS(SE);function TE(t,e){return t<>>32-e}function LE(t){return t.byteOffset%4==0}RE.slice();var PE=2**32-1,IE=new Uint32Array;function ME(t,e){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:s,rounds:o}=function(t,e){if(null==e||"object"!=typeof e)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e)}(0,e);if("function"!=typeof t)throw new Error("core must be a function");return wS(i),wS(o),_S(s),_S(n),(e,a,l,c,u=0)=>{CS(e),CS(a),CS(l);const h=l.length;if(c||(c=new Uint8Array(h)),CS(c),wS(u),u<0||u>=PE)throw new Error("arx: counter overflow");if(c.length=PE)throw new Error("arx: counter overflow");const g=Math.min(64,l-f);if(h&&64===g){const t=f/4;if(f%4!=0)throw new Error("arx: invalid block position");for(let e,n=0;n<16;n++)e=t+n,p[e]=d[e]^u[n];f+=64;continue}for(let t,e=0;e0;)d.pop().fill(0);return c}}function AE(t,e,n,r,i,s=20){let o=t[0],a=t[1],l=t[2],c=t[3],u=e[0],h=e[1],d=e[2],p=e[3],f=e[4],g=e[5],m=e[6],y=e[7],v=i,b=n[0],w=n[1],_=n[2],x=o,C=a,k=l,S=c,E=u,R=h,T=d,L=p,P=f,I=g,M=m,A=y,O=v,F=b,N=w,z=_;for(let j=0;j{t.update(e);const n=e.length%16;n&&t.update(NE.subarray(n))},DE=new Uint8Array(32);function jE(t,e,n,r,i){const s=t(e,n,DE),o=xE.create(s);i&&zE(o,i),zE(o,r);const a=new Uint8Array(16),l=TS(a);NS(l,0,BigInt(i?i.length:0),!0),NS(l,8,BigInt(r.length),!0),o.update(a);const c=o.digest();return s.fill(0),c}var UE=t=>(e,n,r)=>(CS(e,32),CS(n),{encrypt:(i,s)=>{const o=i.length,a=o+16;s?CS(s,a):s=new Uint8Array(a),t(e,n,i,s,1);const l=jE(t,e,n,s.subarray(0,-16),r);return s.set(l,o),s},decrypt:(i,s)=>{const o=i.length,a=o-16;if(o<16)throw new Error("encrypted data must be at least 16 bytes");s?CS(s,a):s=new Uint8Array(a);const l=i.subarray(0,-16);if(!OS(i.subarray(-16),jE(t,e,n,l,r)))throw new Error("invalid tag");return t(e,n,l,s,1),s}}),BE=(UE(OE),UE(FE),class extends Mk{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,zk.hash(t);const n=Pk(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let s=0;snew BE(t,e).update(n).digest();$E.create=(t,e)=>new BE(t,e);var qE=new Uint8Array([0]),VE=new Uint8Array,WE=Object.defineProperty,HE=(t,e)=>{for(var n in e)WE(t,n,{get:e[n],enumerable:!0})},GE=Symbol("verified");function KE(t){if(!(t instanceof Object))return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.pubkey)return!1;if(!t.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(t.tags))return!1;for(let e=0;enR,QueueNode:()=>eR,binarySearch:()=>tR,bytesToHex:()=>Tk,hexToBytes:()=>Lk,insertEventIntoAscendingList:()=>QE,insertEventIntoDescendingList:()=>JE,normalizeURL:()=>XE,utf8Decoder:()=>ZE,utf8Encoder:()=>YE});var ZE=new TextDecoder("utf-8"),YE=new TextEncoder;function XE(t){try{-1===t.indexOf("://")&&(t="wss://"+t);let e=new URL(t);return"http:"===e.protocol?e.protocol="ws:":"https:"===e.protocol&&(e.protocol="wss:"),e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),("80"===e.port&&"ws:"===e.protocol||"443"===e.port&&"wss:"===e.protocol)&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}catch(e){throw new Error(`Invalid URL: ${t}`)}}function JE(t,e){const[n,r]=tR(t,t=>e.id===t.id?0:e.created_at===t.created_at?-1:t.created_at-e.created_at);return r||t.splice(n,0,e),t}function QE(t,e){const[n,r]=tR(t,t=>e.id===t.id?0:e.created_at===t.created_at?-1:e.created_at-t.created_at);return r||t.splice(n,0,e),t}function tR(t,e){let n=0,r=t.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),s=e(t[i]);if(0===s)return[i,!0];s<0?r=i-1:n=i+1}return[n,!1]}var eR=class{value;next=null;prev=null;constructor(t){this.value=t}},nR=class{first;last;constructor(){this.first=null,this.last=null}enqueue(t){const e=new eR(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){const t=this.first;return this.first=null,this.last=null,t.value}const t=this.first;return this.first=t.next,this.first&&(this.first.prev=null),t.value}};function rR(t){return Tk(Hk(YE.encode(function(t){if(!KE(t))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}(t))))}var iR=new class{generateSecretKey(){return xk.utils.randomPrivateKey()}getPublicKey(t){return Tk(xk.getPublicKey(t))}finalizeEvent(t,e){const n=t;return n.pubkey=Tk(xk.getPublicKey(e)),n.id=rR(n),n.sig=Tk(xk.sign(rR(n),e)),n[GE]=!0,n}verifyEvent(t){if("boolean"==typeof t[GE])return t[GE];const e=rR(t);if(e!==t.id)return t[GE]=!1,!1;try{const n=xk.verify(t.sig,e,t.pubkey);return t[GE]=n,n}catch(mz){return t[GE]=!1,!1}}},sR=iR.generateSecretKey,oR=iR.getPublicKey,aR=iR.finalizeEvent,lR=iR.verifyEvent,cR={};function uR(t){return t<1e4&&0!==t&&3!==t}function hR(t){return 0===t||3===t||1e4<=t&&t<2e4}function dR(t){return 2e4<=t&&t<3e4}function pR(t){return 3e4<=t&&t<4e4}function fR(t){return uR(t)?"regular":hR(t)?"replaceable":dR(t)?"ephemeral":pR(t)?"parameterized":"unknown"}function gR(t,e){const n=e instanceof Array?e:[e];return KE(t)&&n.includes(t.kind)||!1}HE(cR,{Application:()=>UT,BadgeAward:()=>kR,BadgeDefinition:()=>AT,BlockedRelaysList:()=>dT,BlossomServerList:()=>bT,BookmarkList:()=>cT,Bookmarksets:()=>PT,Calendar:()=>GT,CalendarEventRSVP:()=>KT,ChannelCreation:()=>OR,ChannelHideMessage:()=>zR,ChannelMessage:()=>NR,ChannelMetadata:()=>FR,ChannelMuteUser:()=>DR,ChatMessage:()=>SR,ClassifiedListing:()=>qT,ClientAuth:()=>xT,Comment:()=>qR,CommunitiesList:()=>uT,CommunityDefinition:()=>JT,CommunityPostApproval:()=>XR,Contacts:()=>bR,CreateOrUpdateProduct:()=>NT,CreateOrUpdateStall:()=>FT,Curationsets:()=>IT,Date:()=>WT,DirectMessageRelaysList:()=>yT,DraftClassifiedListing:()=>VT,DraftLong:()=>DT,Emojisets:()=>jT,EncryptedDirectMessage:()=>wR,EventDeletion:()=>_R,FavoriteRelays:()=>fT,FileMessage:()=>LR,FileMetadata:()=>$R,FileServerPreference:()=>vT,Followsets:()=>RT,ForumThread:()=>ER,GenericRepost:()=>PR,Genericlists:()=>TT,GiftWrap:()=>UR,GroupMetadata:()=>QT,HTTPAuth:()=>ET,Handlerinformation:()=>XT,Handlerrecommendation:()=>YT,Highlights:()=>iT,InterestsList:()=>gT,Interestsets:()=>OT,JobFeedback:()=>tT,JobRequest:()=>JR,JobResult:()=>QR,Label:()=>YR,LightningPubRPC:()=>_T,LiveChatMessage:()=>VR,LiveEvent:()=>BT,LongFormArticle:()=>zT,Metadata:()=>mR,Mutelist:()=>oT,NWCWalletInfo:()=>wT,NWCWalletRequest:()=>CT,NWCWalletResponse:()=>kT,NormalVideo:()=>MR,NostrConnect:()=>ST,OpenTimestamps:()=>jR,Photo:()=>IR,Pinlist:()=>aT,Poll:()=>BR,PollResponse:()=>sT,PrivateDirectMessage:()=>TR,ProblemTracker:()=>GR,ProfileBadges:()=>MT,PublicChatsList:()=>hT,Reaction:()=>CR,RecommendRelay:()=>vR,RelayList:()=>lT,RelayReview:()=>ZT,Relaysets:()=>LT,Report:()=>KR,Reporting:()=>ZR,Repost:()=>xR,Seal:()=>RR,SearchRelaysList:()=>pT,ShortTextNote:()=>yR,ShortVideo:()=>AR,Time:()=>HT,UserEmojiList:()=>mT,UserStatuses:()=>$T,Voice:()=>WR,VoiceComment:()=>HR,Zap:()=>rT,ZapGoal:()=>eT,ZapRequest:()=>nT,classifyKind:()=>fR,isAddressableKind:()=>pR,isEphemeralKind:()=>dR,isKind:()=>gR,isRegularKind:()=>uR,isReplaceableKind:()=>hR});var mR=0,yR=1,vR=2,bR=3,wR=4,_R=5,xR=6,CR=7,kR=8,SR=9,ER=11,RR=13,TR=14,LR=15,PR=16,IR=20,MR=21,AR=22,OR=40,FR=41,NR=42,zR=43,DR=44,jR=1040,UR=1059,BR=1068,$R=1063,qR=1111,VR=1311,WR=1222,HR=1244,GR=1971,KR=1984,ZR=1984,YR=1985,XR=4550,JR=5999,QR=6999,tT=7e3,eT=9041,nT=9734,rT=9735,iT=9802,sT=1018,oT=1e4,aT=10001,lT=10002,cT=10003,uT=10004,hT=10005,dT=10006,pT=10007,fT=10012,gT=10015,mT=10030,yT=10050,vT=10096,bT=10063,wT=13194,_T=21e3,xT=22242,CT=23194,kT=23195,ST=24133,ET=27235,RT=3e4,TT=30001,LT=30002,PT=30003,IT=30004,MT=30008,AT=30009,OT=30015,FT=30017,NT=30018,zT=30023,DT=30024,jT=30030,UT=30078,BT=30311,$T=30315,qT=30402,VT=30403,WT=31922,HT=31923,GT=31924,KT=31925,ZT=31987,YT=31989,XT=31990,JT=34550,QT=39e3;function tL(t,e){let n=e.length+3,r=t.indexOf(`"${e}":`)+n,i=t.slice(r).indexOf('"')+r+1;return t.slice(i,i+64)}function eL(t,e){let n=e.length,r=t.indexOf(`"${e}":`)+n+3,i=t.slice(r),s=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,s),10)}function nL(t){let e=t.slice(0,22).indexOf('"EVENT"');if(-1===e)return null;let n=t.slice(e+7+1).indexOf('"');if(-1===n)return null;let r=e+7+1+n,i=t.slice(r+1,80).indexOf('"');if(-1===i)return null;let s=r+1+i;return t.slice(r+1,s)}function rL(t,e){return e===tL(t,"id")}function iL(t,e){return e===tL(t,"pubkey")}function sL(t,e){return e===eL(t,"kind")}function oL(t,e){return{kind:xT,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}HE({},{getHex64:()=>tL,getInt:()=>eL,getSubscriptionId:()=>nL,matchEventId:()=>rL,matchEventKind:()=>sL,matchEventPubkey:()=>iL}),HE({},{makeAuthEvent:()=>oL});try{WebSocket}catch{}try{WebSocket}catch{}HE({},{BECH32_REGEX:()=>cL,Bech32MaxSize:()=>lL,NostrTypeGuard:()=>aL,decode:()=>hL,decodeNostrURI:()=>uL,encodeBytes:()=>yL,naddrEncode:()=>wL,neventEncode:()=>bL,noteEncode:()=>gL,nprofileEncode:()=>vL,npubEncode:()=>fL,nsecEncode:()=>pL});var aL={isNProfile:t=>/^nprofile1[a-z\d]+$/.test(t||""),isNEvent:t=>/^nevent1[a-z\d]+$/.test(t||""),isNAddr:t=>/^naddr1[a-z\d]+$/.test(t||""),isNSec:t=>/^nsec1[a-z\d]{58}$/.test(t||""),isNPub:t=>/^npub1[a-z\d]{58}$/.test(t||""),isNote:t=>/^note1[a-z\d]+$/.test(t||""),isNcryptsec:t=>/^ncryptsec1[a-z\d]+$/.test(t||"")},lL=5e3,cL=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function uL(t){try{return t.startsWith("nostr:")&&(t=t.substring(6)),hL(t)}catch(e){return{type:"invalid",data:null}}}function hL(t){let{prefix:e,words:n}=vS.decode(t,lL),r=new Uint8Array(vS.fromWords(n));switch(e){case"nprofile":{let t=dL(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Tk(t[0][0]),relays:t[1]?t[1].map(t=>ZE.decode(t)):[]}}}case"nevent":{let t=dL(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(t[2]&&32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(t[3]&&4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Tk(t[0][0]),relays:t[1]?t[1].map(t=>ZE.decode(t)):[],author:t[2]?.[0]?Tk(t[2][0]):void 0,kind:t[3]?.[0]?parseInt(Tk(t[3][0]),16):void 0}}}case"naddr":{let t=dL(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!t[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!t[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:ZE.decode(t[0][0]),pubkey:Tk(t[2][0]),kind:parseInt(Tk(t[3][0]),16),relays:t[1]?t[1].map(t=>ZE.decode(t)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:Tk(r)};default:throw new Error(`unknown prefix ${e}`)}}function dL(t){let e={},n=t;for(;n.length>0;){let t=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.lengthYE.encode(t))}))}function bL(t){let e;return void 0!==t.kind&&(e=function(t){const e=new Uint8Array(4);return e[0]=t>>24&255,e[1]=t>>16&255,e[2]=t>>8&255,e[3]=255&t,e}(t.kind)),mL("nevent",_L({0:[Lk(t.id)],1:(t.relays||[]).map(t=>YE.encode(t)),2:t.author?[Lk(t.author)]:[],3:e?[new Uint8Array(e)]:[]}))}function wL(t){let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,t.kind,!1),mL("naddr",_L({0:[YE.encode(t.identifier)],1:(t.relays||[]).map(t=>YE.encode(t)),2:[Lk(t.pubkey)],3:[new Uint8Array(e)]}))}function _L(t){let e=[];return Object.entries(t).reverse().forEach(([t,n])=>{n.forEach(n=>{let r=new Uint8Array(n.length+2);r.set([parseInt(t)],0),r.set([n.length],1),r.set(n,2),e.push(r)})}),Ik(...e)}var xL={};function CL(t,e,n){const r=t instanceof Uint8Array?Tk(t):t,i=SL(ok.getSharedSecret(r,"02"+e));let s=Uint8Array.from(Ok(16)),o=YE.encode(n),a=yE(i,s).encrypt(o);return`${aS.encode(new Uint8Array(a))}?iv=${aS.encode(new Uint8Array(s.buffer))}`}function kL(t,e,n){const r=t instanceof Uint8Array?Tk(t):t;let[i,s]=n.split("?iv="),o=SL(ok.getSharedSecret(r,"02"+e)),a=aS.decode(s),l=aS.decode(i),c=yE(o,a).decrypt(l);return ZE.decode(c)}function SL(t){return t.slice(1,33)}HE(xL,{decrypt:()=>kL,encrypt:()=>CL}),HE({},{NIP05_REGEX:()=>RL,isNip05:()=>TL,isValid:()=>ML,queryProfile:()=>IL,searchDomain:()=>PL,useFetchImplementation:()=>LL});var EL,RL=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,TL=t=>RL.test(t||"");try{EL=fetch}catch(iet){}function LL(t){EL=t}async function PL(t,e=""){try{const n=`https://${t}/.well-known/nostr.json?name=${e}`,r=await EL(n,{redirect:"manual"});if(200!==r.status)throw Error("Wrong response code");return(await r.json()).names}catch(iet){return{}}}async function IL(t){const e=t.match(RL);if(!e)return null;const[,n="_",r]=e;try{const t=`https://${r}/.well-known/nostr.json?name=${n}`,e=await EL(t,{redirect:"manual"});if(200!==e.status)throw Error("Wrong response code");const i=await e.json(),s=i.names[n];return s?{pubkey:s,relays:i.relays?.[s]}:null}catch(i){return null}}async function ML(t,e){const n=await IL(e);return!!n&&n.pubkey===t}function AL(t){const e={reply:void 0,root:void 0,mentions:[],profiles:[],quotes:[]};let n,r;for(let i=t.tags.length-1;i>=0;i--){const s=t.tags[i];if("e"===s[0]&&s[1]){const[t,i,o,a,l]=s,c={id:i,relays:o?[o]:[],author:l};if("root"===a){e.root=c;continue}if("reply"===a){e.reply=c;continue}if("mention"===a){e.mentions.push(c);continue}n?r=c:n=c,e.mentions.push(c);continue}if("q"===s[0]&&s[1]){const[t,n,r]=s;e.quotes.push({id:n,relays:r?[r]:[]})}"p"===s[0]&&s[1]&&e.profiles.push({pubkey:s[1],relays:s[2]?[s[2]]:[]})}return e.root||(e.root=r||n||e.reply),e.reply||(e.reply=n||e.root),[e.reply,e.root].forEach(t=>{if(!t)return;let n=e.mentions.indexOf(t);if(-1!==n&&e.mentions.splice(n,1),t.author){let n=e.profiles.find(e=>e.pubkey===t.author);n&&n.relays&&(t.relays||(t.relays=[]),n.relays.forEach(e=>{-1===t.relays?.indexOf(e)&&t.relays.push(e)}),n.relays=t.relays)}}),e.mentions.forEach(t=>{if(t.author){let n=e.profiles.find(e=>e.pubkey===t.author);n&&n.relays&&(t.relays||(t.relays=[]),n.relays.forEach(e=>{-1===t.relays.indexOf(e)&&t.relays.push(e)}),n.relays=t.relays)}}),e}function OL(){}async function FL(t){return await(await fetch(t.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function NL(t){let e=0;for(let n=0;n<64;n+=8){const r=parseInt(t.substring(n,n+8),16);if(0!==r){e+=Math.clz32(r);break}e+=32}return e}function zL(t,e){let n=0;const r=t,i=["nonce",n.toString(),e.toString()];for(r.tags.push(i);;){const t=Math.floor((new Date).getTime()/1e3);if(t!==r.created_at&&(n=0,r.created_at=t),i[1]=(++n).toString(),r.id=DL(r),NL(r.id)>=e)break}return r}function DL(t){return Tk(Hk(YE.encode(JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content]))))}HE({},{parse:()=>AL}),HE({},{fetchRelayInformation:()=>FL,useFetchImplementation:()=>OL}),HE({},{fastEventHash:()=>DL,getPow:()=>NL,minePow:()=>zL}),HE({},{unwrapEvent:()=>cP,unwrapManyEvents:()=>uP,wrapEvent:()=>aP,wrapManyEvents:()=>lP}),HE({},{createRumor:()=>tP,createSeal:()=>eP,createWrap:()=>nP,unwrapEvent:()=>sP,unwrapManyEvents:()=>oP,wrapEvent:()=>rP,wrapManyEvents:()=>iP});var jL={};HE(jL,{decrypt:()=>GL,encrypt:()=>HL,getConversationKey:()=>$L,v2:()=>KL});var UL=1,BL=65535;function $L(t,e){const n=ok.getSharedSecret(t,"02"+e).subarray(1,33);return r=Hk,i=n,s="nip44-v2",zk.hash(r),void 0===s&&(s=new Uint8Array(r.outputLen)),$E(r,Pk(s),Pk(i));var r,i,s}function qL(t,e){const n=function(t,e,n,r=32){if(zk.hash(t),zk.number(r),r>255*t.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/t.outputLen);void 0===n&&(n=VE);const s=new Uint8Array(i*t.outputLen),o=$E.create(t,e),a=o._cloneInto(),l=new Uint8Array(o.outputLen);for(let c=0;cBL)throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");const e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}(n),e,new Uint8Array(VL(n)-n))}(t),a=OE(r,i,o),l=WL(s,a,n);return aS.encode(Ik(new Uint8Array([2]),n,a,l))}function GL(t,e){const{nonce:n,ciphertext:r,mac:i}=function(t){if("string"!=typeof t)throw new Error("payload must be a valid string");const e=t.length;if(e<132||e>87472)throw new Error("invalid payload length: "+e);if("#"===t[0])throw new Error("unknown encryption version");let n;try{n=aS.decode(t)}catch(Z4){throw new Error("invalid base64: "+Z4.message)}const r=n.length;if(r<99||r>65603)throw new Error("invalid data length: "+r);const i=n[0];if(2!==i)throw new Error("unknown encryption version "+i);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}(t),{chacha_key:s,chacha_nonce:o,hmac_key:a}=qL(e,n);if(!OS(WL(a,r,n),i))throw new Error("invalid MAC");return function(t){const e=new DataView(t.buffer).getUint16(0),n=t.subarray(2,2+e);if(eBL||n.length!==e||t.length!==2+VL(e))throw new Error("invalid padding");return ZE.decode(n)}(OE(s,o,r))}var KL={utils:{getConversationKey:$L,calcPaddedLen:VL},encrypt:HL,decrypt:GL},ZL=()=>Math.round(Date.now()/1e3),YL=()=>Math.round(ZL()-172800*Math.random()),XL=(t,e)=>$L(t,e),JL=(t,e,n)=>HL(JSON.stringify(t),XL(e,n)),QL=(t,e)=>JSON.parse(GL(t.content,XL(e,t.pubkey)));function tP(t,e){const n={created_at:ZL(),content:"",tags:[],...t,pubkey:oR(e)};return n.id=rR(n),n}function eP(t,e,n){return aR({kind:RR,content:JL(t,e,n),created_at:YL(),tags:[]},e)}function nP(t,e){const n=sR();return aR({kind:UR,content:JL(t,n,e),created_at:YL(),tags:[["p",e]]},n)}function rP(t,e,n){return nP(eP(tP(t,e),e,n),n)}function iP(t,e,n){if(!n||0===n.length)throw new Error("At least one recipient is required.");const r=[rP(t,e,oR(e))];return n.forEach(n=>{r.push(rP(t,e,n))}),r}function sP(t,e){return QL(QL(t,e),e)}function oP(t,e){let n=[];return t.forEach(t=>{n.push(sP(t,e))}),n.sort((t,e)=>t.created_at-e.created_at),n}function aP(t,e,n,r,i){return rP(function(t,e,n,r){const i={created_at:Math.ceil(Date.now()/1e3),kind:TR,tags:[],content:e};return(Array.isArray(t)?t:[t]).forEach(({publicKey:t,relayUrl:e})=>{i.tags.push(e?["p",t,e]:["p",t])}),r&&i.tags.push(["e",r.eventId,r.relayUrl||"","reply"]),n&&i.tags.push(["subject",n]),i}(e,n,r,i),t,e.publicKey)}function lP(t,e,n,r,i){if(!e||0===e.length)throw new Error("At least one recipient is required.");return[{publicKey:oR(t)},...e].map(e=>aP(t,e,n,r,i))}var cP=sP,uP=oP;function hP(t,e,n,r){let i;const s=[...t.tags??[],["e",e.id,n],["p",e.pubkey]];return e.kind===yR?i=xR:(i=PR,s.push(["k",String(e.kind)])),aR({kind:i,tags:s,content:""===t.content||e.tags?.find(t=>"-"===t[0])?"":JSON.stringify(e),created_at:t.created_at},r)}function dP(t){if(![xR,PR].includes(t.kind))return;let e,n;for(let r=t.tags.length-1;r>=0&&(void 0===e||void 0===n);r--){const i=t.tags[r];i.length>=2&&("e"===i[0]&&void 0===e?e=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==e?{id:e[1],relays:[e[2],n?.[2]].filter(t=>"string"==typeof t),author:n?.[1]}:void 0}function pP(t,{skipVerification:e}={}){const n=dP(t);if(void 0===n||""===t.content)return;let r;try{r=JSON.parse(t.content)}catch(Z4){return}return r.id===n.id&&(e||lR(r))?r:void 0}HE({},{finishRepostEvent:()=>hP,getRepostedEvent:()=>pP,getRepostedEventPointer:()=>dP}),HE({},{NOSTR_URI_REGEX:()=>fP,parse:()=>mP,test:()=>gP});var fP=new RegExp(`nostr:(${cL.source})`);function gP(t){return"string"==typeof t&&new RegExp(`^${fP.source}$`).test(t)}function mP(t){const e=t.match(new RegExp(`^${fP.source}$`));if(!e)throw new Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:hL(e[1])}}function yP(t,e,n){const r=e.tags.filter(t=>t.length>=2&&("e"===t[0]||"p"===t[0]));return aR({...t,kind:CR,tags:[...t.tags??[],...r,["e",e.id],["p",e.pubkey]],content:t.content??"+"},n)}function vP(t){if(t.kind!==CR)return;let e,n;for(let r=t.tags.length-1;r>=0&&(void 0===e||void 0===n);r--){const i=t.tags[r];i.length>=2&&("e"===i[0]&&void 0===e?e=i:"p"===i[0]&&void 0===n&&(n=i))}return void 0!==e&&void 0!==n?{id:e[1],relays:[e[2],n[2]].filter(t=>void 0!==t),author:n[1]}:void 0}HE({},{finishReactionEvent:()=>yP,getReactedEventPointer:()=>vP}),HE({},{parse:()=>xP});var bP=/\W/m,wP=/[^\w\/] |[^\w\/]$|$|,| /m,_P=42;function*xP(t){let e=[];if("string"!=typeof t){for(let n=0;n=3&&e.push({type:"emoji",shortcode:r[1],url:r[2]})}t=t.content}const n=t.length;let r=0,i=0;t:for(;i=0&&aCP,channelHideMessageEvent:()=>EP,channelMessageEvent:()=>SP,channelMetadataEvent:()=>kP,channelMuteUserEvent:()=>RP});var CP=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return aR({kind:OR,tags:[...t.tags??[]],content:n,created_at:t.created_at},e)},kP=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return aR({kind:FR,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},SP=(t,e)=>{const n=[["e",t.channel_create_event_id,t.relay_url,"root"]];return t.reply_to_channel_message_event_id&&n.push(["e",t.reply_to_channel_message_event_id,t.relay_url,"reply"]),aR({kind:NR,tags:[...n,...t.tags??[]],content:t.content,created_at:t.created_at},e)},EP=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return aR({kind:zR,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:n,created_at:t.created_at},e)},RP=(t,e)=>{let n;if("object"==typeof t.content)n=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;n=t.content}return aR({kind:DR,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:n,created_at:t.created_at},e)};HE({},{EMOJI_SHORTCODE_REGEX:()=>PP,matchAll:()=>MP,regex:()=>IP,replaceAll:()=>AP});var TP,LP,PP=/:(\w+):/,IP=()=>new RegExp(`\\B${PP.source}\\B`,"g");function*MP(t){const e=t.matchAll(IP());for(const r of e)try{const[t,e]=r;yield{shortcode:t,name:e,start:r.index,end:r.index+t.length}}catch(n){}}function AP(t,e){return t.replaceAll(IP(),(t,n)=>e({shortcode:t,name:n}))}HE({},{useFetchImplementation:()=>OP,validateGithub:()=>FP});try{TP=fetch}catch{}function OP(t){TP=t}async function FP(t,e,n){try{return await(await TP(`https://gist.github.com/${e}/${n}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch(iet){return!1}}function NP(t){const{host:e,pathname:n,searchParams:r}=new URL(t),i=n||e,s=r.get("relay"),o=r.get("secret");if(!i||!s||!o)throw new Error("invalid connection string");return{pubkey:i,relay:s,secret:o}}async function zP(t,e,n){const r=CL(e,t,JSON.stringify({method:"pay_invoice",params:{invoice:n}}));return aR({kind:CT,created_at:Math.round(Date.now()/1e3),content:r,tags:[["p",t]]},e)}function DP(t){return t=(t=t.trim().toLowerCase()).normalize("NFKC"),Array.from(t).map(t=>/\p{Letter}/u.test(t)||/\p{Number}/u.test(t)?t:"-").join("")}HE({},{makeNwcRequestEvent:()=>zP,parseConnectionString:()=>NP}),HE({},{normalizeIdentifier:()=>DP}),HE({},{getSatoshisAmountFromBolt11:()=>VP,getZapEndpoint:()=>UP,makeZapReceipt:()=>qP,makeZapRequest:()=>BP,useFetchImplementation:()=>jP,validateZapRequest:()=>$P});try{LP=fetch}catch{}function jP(t){LP=t}async function UP(t){try{let e="",{lud06:n,lud16:r}=JSON.parse(t.content);if(r){let[t,n]=r.split("@");e=new URL(`/.well-known/lnurlp/${t}`,`https://${n}`).toString()}else{if(!n)return null;{let{words:t}=vS.decode(n,1e3),r=vS.fromWords(t);e=ZE.decode(r)}}let i=await(await LP(e)).json();if(i.allowsNostr&&i.nostrPubkey)return i.callback}catch(mz){}return null}function BP(t){let e={kind:9734,created_at:Math.round(Date.now()/1e3),content:t.comment||"",tags:[["p","pubkey"in t?t.pubkey:t.event.pubkey],["amount",t.amount.toString()],["relays",...t.relays]]};if("event"in t){if(e.tags.push(["e",t.event.id]),hR(t.event.kind)){const n=["a",`${t.event.kind}:${t.event.pubkey}:`];e.tags.push(n)}else if(pR(t.event.kind)){let n=t.event.tags.find(([t,e])=>"d"===t&&e);if(!n)throw new Error("d tag not found or is empty");const r=["a",`${t.event.kind}:${t.event.pubkey}:${n[1]}`];e.tags.push(r)}e.tags.push(["k",t.event.kind.toString()])}return e}function $P(t){let e;try{e=JSON.parse(t)}catch(mz){return"Invalid zap request JSON."}if(!KE(e))return"Zap request is not a valid Nostr event.";if(!lR(e))return"Invalid signature on zap request.";let n=e.tags.find(([t,e])=>"p"===t&&e);if(!n)return"Zap request doesn't have a 'p' tag.";if(!n[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let r=e.tags.find(([t,e])=>"e"===t&&e);return r&&!r[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":e.tags.find(([t,e])=>"relays"===t&&e)?null:"Zap request doesn't have a 'relays' tag."}function qP({zapRequest:t,preimage:e,bolt11:n,paidAt:r}){let i=JSON.parse(t),s=i.tags.filter(([t])=>"e"===t||"p"===t||"a"===t),o={kind:9735,created_at:Math.round(r.getTime()/1e3),content:"",tags:[...s,["P",i.pubkey],["bolt11",n],["description",t]]};return e&&o.tags.push(["preimage",e]),o}function VP(t){if(t.length<50)return 0;const e=(t=t.substring(0,50)).lastIndexOf("1");if(-1===e)return 0;const n=t.substring(0,e);if(!n.startsWith("lnbc"))return 0;const r=n.substring(4);if(r.length<1)return 0;const i=r[r.length-1],s=i.charCodeAt(0)-"0".charCodeAt(0),o=s>=0&&s<=9;let a=r.length-1;if(o&&a++,a<1)return 0;const l=parseInt(r.substring(0,a));switch(i){case"m":return 1e5*l;case"u":return 100*l;case"n":return l/10;case"p":return l/1e4;default:return 1e8*l}}HE({},{Negentropy:()=>JP,NegentropyStorageVector:()=>XP,NegentropySync:()=>eI});var WP=32,HP=class{_raw;length;constructor(t){"number"==typeof t?(this._raw=new Uint8Array(t),this.length=0):t instanceof Uint8Array?(this._raw=new Uint8Array(t),this.length=t.length):(this._raw=new Uint8Array(512),this.length=0)}unwrap(){return this._raw.subarray(0,this.length)}get capacity(){return this._raw.byteLength}extend(t){if(t instanceof HP&&(t=t.unwrap()),"number"!=typeof t.length)throw Error("bad length");const e=t.length+this.length;if(this.capacity>>=7;e.reverse();for(let n=0;n4294967295&&(n=1),r.setUint32(t,4294967295&o,!0),e=n,n=0}}negate(){let t=new DataView(this.buf.buffer);for(let n=0;n<8;n++){let e=4*n;t.setUint32(e,~t.getUint32(e,!0))}let e=new Uint8Array(WP);e[0]=1,this.add(e)}getFingerprint(t){let e=new HP;return e.extend(this.buf),e.extend(KP(t)),Hk(e.unwrap()).subarray(0,16)}},XP=class{items;sealed;constructor(){this.items=[],this.sealed=!1}insert(t,e){if(this.sealed)throw Error("already sealed");const n=MS(e);if(n.byteLength!==WP)throw Error("bad id size for added item");this.items.push({timestamp:t,id:n})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(tI);for(let t=1;t=this.items.length)throw Error("out of range");return this.items[t]}iterate(t,e,n){this._checkSealed(),this._checkBounds(t,e);for(let r=t;rtI(t,n)<0)}fingerprint(t,e){let n=new YP;return n.setToZero(),this.iterate(t,e,t=>(n.add(t.id),!0)),n.getFingerprint(e-t)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(t,e){if(t>e||e>this.items.length)throw Error("bad range")}_binarySearch(t,e,n,r){let i=n-e;for(;i>0;){let n=e,s=Math.floor(i/2);n+=s,r(t[n])?(e=++n,i-=s+1):i=s}return e}},JP=class{storage;frameSizeLimit;lastTimestampIn;lastTimestampOut;constructor(t,e=6e4){if(e<4096)throw Error("frameSizeLimit too small");this.storage=t,this.frameSizeLimit=e,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(t,e){return{timestamp:t,id:e||new Uint8Array(0)}}initiate(){let t=new HP;return t.extend(new Uint8Array([97])),this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),t),PS(t.unwrap())}reconcile(t,e,n){const r=new HP(MS(t));this.lastTimestampIn=this.lastTimestampOut=0;let i=new HP;i.extend(new Uint8Array([97]));let s=ZP(r,1)[0];if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(97!==s)throw Error("unsupported negentropy protocol version requested: "+(s-96));let o=this.storage.size(),a=this._bound(0),l=0,c=!1;for(;0!==r.length;){let t=new HP,s=()=>{c&&(c=!1,t.extend(this.encodeBound(a)),t.extend(KP(0)))},u=this.decodeBound(r),h=GP(r),d=l,p=this.storage.findLowerBound(l,o,u);if(0===h)c=!0;else if(1===h)0!==QP(ZP(r,16),this.storage.fingerprint(d,p))?(s(),this.splitRange(d,p,u,t)):c=!0;else{if(2!==h)throw Error("unexpected mode");{let t=GP(r),i={};for(let e=0;e{let n=t.id;const r=PS(n);return i[r]?delete i[PS(n)]:e?.(r),!0}),n)for(let e of Object.values(i))n(PS(e))}}if(this.exceededFrameSizeLimit(i.length+t.length)){let t=this.storage.fingerprint(p,o);i.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),i.extend(KP(1)),i.extend(t);break}i.extend(t),l=p,a=u}return 1===i.length?null:PS(i.unwrap())}splitRange(t,e,n,r){let i=e-t;if(i<32)r.extend(this.encodeBound(n)),r.extend(KP(2)),r.extend(KP(i)),this.storage.iterate(t,e,t=>(r.extend(t.id),!0));else{let s=Math.floor(i/16),o=i%16,a=t;for(let t=0;t<16;t++){let i,l=s+(t(r===a-1?t=n:e=n,!0)),i=this.getMinimalBound(t,e)}r.extend(this.encodeBound(i)),r.extend(KP(1)),r.extend(c)}}}exceededFrameSizeLimit(t){return t>this.frameSizeLimit-200}decodeTimestampIn(t){let e=GP(t);return e=0===e?Number.MAX_VALUE:e-1,this.lastTimestampIn===Number.MAX_VALUE||e===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(e+=this.lastTimestampIn,this.lastTimestampIn=e,e)}decodeBound(t){let e=this.decodeTimestampIn(t),n=GP(t);if(n>WP)throw Error("bound key too long");return{timestamp:e,id:ZP(t,n)}}encodeTimestampOut(t){if(t===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,KP(0);let e=t;return t-=this.lastTimestampOut,this.lastTimestampOut=e,KP(t+1)}encodeBound(t){let e=new HP;return e.extend(this.encodeTimestampOut(t.timestamp)),e.extend(KP(t.id.length)),e.extend(t.id),e}getMinimalBound(t,e){if(e.timestamp!==t.timestamp)return this._bound(e.timestamp);{let n=0,r=e.id,i=t.id;for(let t=0;te[n])return 1}return t.byteLength>e.byteLength?1:t.byteLength{switch(t[0]){case"NEG-MSG":t.length<3&&console.warn(`got invalid NEG-MSG from ${this.relay.url}: ${t}`);try{const e=this.neg.reconcile(t[2],this.onhave,this.onneed);e?this.relay.send(`["NEG-MSG", "${this.subscription.id}", "${e}"]`):(this.close(),r.onclose?.())}catch(Z4){console.error("negentropy reconcile error:",Z4),r?.onclose?.(`reconcile error: ${Z4}`)}break;case"NEG-CLOSE":{const e=t[2];console.warn("negentropy error:",e),r.onclose?.(e);break}case"NEG-ERR":r.onclose?.()}}}async start(){const t=this.neg.initiate();this.relay.send(`["NEG-OPEN","${this.subscription.id}",${JSON.stringify(this.filter)},"${t}"]`)}close(){this.relay.send(`["NEG-CLOSE","${this.subscription.id}"]`),this.subscription.close()}};HE({},{getToken:()=>rI,hashPayload:()=>uI,unpackEventFromToken:()=>sI,validateEvent:()=>dI,validateEventKind:()=>aI,validateEventMethodTag:()=>cI,validateEventPayloadTag:()=>hI,validateEventTimestamp:()=>oI,validateEventUrlTag:()=>lI,validateToken:()=>iI});var nI="Nostr ";async function rI(t,e,n,r=!1,i){const s={kind:ET,tags:[["u",t],["method",e]],created_at:Math.round((new Date).getTime()/1e3),content:""};i&&s.tags.push(["payload",uI(i)]);const o=await n(s);return(r?nI:"")+aS.encode(YE.encode(JSON.stringify(o)))}async function iI(t,e,n){return await dI(await sI(t).catch(t=>{throw t}),e,n).catch(t=>{throw t})}async function sI(t){if(!t)throw new Error("Missing token");t=t.replace(nI,"");const e=ZE.decode(aS.decode(t));if(!e||0===e.length||!e.startsWith("{"))throw new Error("Invalid token");return JSON.parse(e)}function oI(t){return!!t.created_at&&Math.round((new Date).getTime()/1e3)-t.created_at<60}function aI(t){return t.kind===ET}function lI(t,e){const n=t.tags.find(t=>"u"===t[0]);return!!n&&n.length>0&&n[1]===e}function cI(t,e){const n=t.tags.find(t=>"method"===t[0]);return!!n&&n.length>0&&n[1].toLowerCase()===e.toLowerCase()}function uI(t){return Tk(Hk(YE.encode(JSON.stringify(t))))}function hI(t,e){const n=t.tags.find(t=>"payload"===t[0]);if(!n)return!1;const r=uI(e);return n.length>0&&n[1]===r}async function dI(t,e,n,r){if(!lR(t))throw new Error("Invalid nostr event, signature invalid");if(!aI(t))throw new Error("Invalid nostr event, kind invalid");if(!oI(t))throw new Error("Invalid nostr event, created_at timestamp invalid");if(!lI(t,e))throw new Error("Invalid nostr event, url tag invalid");if(!cI(t,n))throw new Error("Invalid nostr event, method tag invalid");if(Boolean(r)&&"object"==typeof r&&Object.keys(r).length>0&&!hI(t,r))throw new Error("Invalid nostr event, payload tag does not match request body hash");return!0}var pI=Symbol("verified");new TextDecoder("utf-8");var fI=new TextEncoder;function gI(t){return Tk(Hk(fI.encode(function(t){if(!function(t){if(!(t instanceof Object))return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.pubkey)return!1;if(!t.pubkey.match(/^[a-f0-9]{64}$/))return!1;if(!Array.isArray(t.tags))return!1;for(let e=0;ee.id===t.id?0:e.created_at===t.created_at?-1:t.created_at-e.created_at);return r||t.splice(n,0,e),t}function CI(t,e){let n=0,r=t.length-1;for(;n<=r;){const i=Math.floor((n+r)/2),s=e(t[i]);if(0===s)return[i,!0];s<0?r=i-1:n=i+1}return[n,!1]}new TextDecoder("utf-8"),new TextEncoder;var kI=Symbol.for("event-store"),SI=Symbol.for("event-uid"),EI=Symbol.for("replaceable-address"),RI=Symbol.for("from-cache"),TI=Symbol.for("replaceable-identifier");function LI(t){return Px(t)||Ix(t)}function PI(t,e,n){return t+":"+e+":"+(n??"")}function II(t){return _I(t,TI,()=>t.tags.find(t=>"d"===t[0])?.[1]??"")}var MI=Symbol.for("encrypted-content"),AI={[cR.EncryptedDirectMessage]:"nip04",[cR.Seal]:"nip44",[cR.GiftWrap]:"nip44"};function OI(t,e){return AI[t]=e,t}function FI(t,e,n){const r=n??AI[t];if(!r)throw new Error(`Event kind ${t} does not support encrypted content`);const i=e[r];if(!i)throw new Error(`Signer does not support ${r} encryption`);return i}var NI=new Set([MI]);function zI(t){return t}function DI(...t){return UI(t.filter(t=>!!t),NI)}function jI(...t){return UI(t.filter(t=>!!t))}function UI(t,e){return 0===t.length?zI:async function(n){return t.reduce(async(t,n)=>{const r=await n(await t);if(e&&"object"==typeof r&&null!==r&&"object"==typeof t&&null!==t){const t=Reflect.ownKeys(r).filter(t=>"symbol"==typeof t);for(const n of t)e.has(n)||Reflect.deleteProperty(r,n)}return r},n)}}function BI(){return Math.round(Date.now()/1e3)}var $I=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[t]];return e};function qI(t,e){return void 0!==t[0]&&void 0!==t[1]&&(!e||t[0]===e)}function VI(t){return qI(t,"e")}function WI(t){return qI(t,"p")}function HI(t){return qI(t,"r")}function GI(t){return qI(t,"a")}var KI=(t,...e)=>e.reduce((t,e)=>{const n=[];for(const r of t)try{const t=e(r);if(void 0===t)continue;n.push(t)}catch(Z4){}return n},t),ZI=new TextDecoder("utf-8"),YI=(new TextEncoder,5e3);function XI(t){let e={},n=t;for(;n.length>0;){let t=n[0],r=n[1],i=n.slice(2,2+r);if(n=n.slice(2+r),i.length=8&&nM.test(t)}function iM(t){return!!t&&64===t.length&&!!t.toLowerCase().match(/^[0-9a-f]{64}$/)}function sM(t){const e=t[1];if(!e||!iM(e))return null;const n={id:e};return t[2]&&rM(t[2])&&(n.relays=[QI(t[2])]),n}function oM(t){if(!t[1])return null;const e=function(t,e=!1){const n=t.split(":"),r=n[0]?parseInt(n[0]):void 0,i=n[1];if(void 0===r)return null;if(void 0===i||""===i||!iM(i))return null;const s=n.slice(2).join(":");return e&&""===s?null:{kind:r,pubkey:i,identifier:s}}(t[1]);return e?(t[2]&&rM(t[2])&&(e.relays=[QI(t[2])]),e):null}function aM(t){const e=t[1];if(!e||!iM(e))return null;const n={pubkey:e};return t[2]&&rM(t[2])&&(n.relays=[QI(t[2])]),n}function lM(t){return"object"==typeof t&&null!==t&&"id"in t&&"string"==typeof t.id}function cM(t,e){return lM(e)?t.id===e.id&&(!e.author||t.pubkey===e.author):t.kind===e.kind&&t.pubkey===e.pubkey&&II(t)===(e.identifier??"")}var uM=MI,hM=FI,dM=new Set([OI(cR.DraftLong,"nip04")]);function pM(t,e){return dM.add(OI(t,e)),t}function fM(t){return function(t){return void 0!==AI[t]}(t)&&dM.has(t)}function gM(t){if(fM(t.kind))return uM in t?Reflect.get(t,uM):function(t){return Reflect.get(t,MI)}(t)}function mM(t,e){if(!fM(t.kind))throw new Error("Event kind does not support hidden content");!function(t,e){Reflect.set(t,MI,e),function(t){if(!function(t){return null!=t&&64===t.id?.length&&"string"==typeof t.sig&&"string"==typeof t.pubkey&&64===t.pubkey.length&&"string"==typeof t.content&&Array.isArray(t.tags)&&"number"==typeof t.created_at&&t.created_at>0}(t))return;const e=function(t){return Reflect.get(t,kI)}(t);e&&e.update(t)}(t)}(t,e)}var yM=Symbol.for("hidden-tags"),vM=new Set([pM(cR.BookmarkList,"nip04"),pM(cR.InterestsList,"nip04"),pM(cR.Mutelist,"nip04"),pM(cR.CommunitiesList,"nip04"),pM(cR.PublicChatsList,"nip04"),pM(cR.SearchRelaysList,"nip04"),pM(10009,"nip04"),pM(cR.Bookmarksets,"nip04"),pM(cR.Relaysets,"nip04"),pM(cR.Followsets,"nip04"),pM(cR.Curationsets,"nip04"),pM(cR.Interestsets,"nip04")]);function bM(t){return fM(t)&&vM.has(t)}function wM(t){return bM(t.kind)&&function(t){return fM(t.kind)&&function(t){return t.content.length>0}(t)}(t)}function _M(t){if(!bM(t.kind))return;if(yM in t)return t[yM];const e=gM(t);if(void 0===e)return;const n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Content is not an array of tags");const r=n.filter(t=>Array.isArray(t)).map(t=>t.map(t=>String(t)));return Reflect.set(t,yM,r),r}var xM=Symbol.for("public-contacts"),CM=Symbol.for("hidden-contacts"),kM=function(t,e){return kM=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},kM(t,e)};function SM(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}kM(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var EM=function(){return EM=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function LM(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,s=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(Z4){i={error:Z4}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function PM(t,e,n){if(n||2===arguments.length)for(var r,i=0,s=e.length;i0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var e=this,n=this,r=n.hasError,i=n.isStopped,s=n.observers;return r||i?zM:(this.currentObservers=null,s.push(t),new NM(function(){e.currentObservers=null,FM(s,t)}))},e.prototype._checkFinalizedStatuses=function(t){var e=this,n=e.hasError,r=e.thrownError,i=e.isStopped;n?t.error(r):i&&t.complete()},e.prototype.asObservable=function(){var t=new tA;return t.source=this,t},e.create=function(t,e){return new aA(t,e)},e}(tA),aA=function(t){function e(e,n){var r=t.call(this)||this;return r.destination=e,r.source=n,r}return SM(e,t),e.prototype.next=function(t){var e,n;null===(n=null===(e=this.destination)||void 0===e?void 0:e.next)||void 0===n||n.call(e,t)},e.prototype.error=function(t){var e,n;null===(n=null===(e=this.destination)||void 0===e?void 0:e.error)||void 0===n||n.call(e,t)},e.prototype.complete=function(){var t,e;null===(e=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===e||e.call(t)},e.prototype._subscribe=function(t){var e,n;return null!==(n=null===(e=this.source)||void 0===e?void 0:e.subscribe(t))&&void 0!==n?n:zM},e}(oA),lA=function(t){function e(e){var n=t.call(this)||this;return n._value=e,n}return SM(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return!n.closed&&e.next(this._value),n},e.prototype.getValue=function(){var t=this,e=t.hasError,n=t.thrownError,r=t._value;if(e)throw n;return this._throwIfClosed(),r},e.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},e}(oA),cA={now:function(){return(cA.delegate||Date).now()},delegate:void 0},uA=function(t){function e(e,n,r){void 0===e&&(e=1/0),void 0===n&&(n=1/0),void 0===r&&(r=cA);var i=t.call(this)||this;return i._bufferSize=e,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,e),i._windowTime=Math.max(1,n),i}return SM(e,t),e.prototype.next=function(e){var n=this,r=n.isStopped,i=n._buffer,s=n._infiniteTimeWindow,o=n._timestampProvider,a=n._windowTime;r||(i.push(e),!s&&i.push(o.now()+a)),this._trimBuffer(),t.prototype.next.call(this,e)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var e=this._innerSubscribe(t),n=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i1||a(t,e)})},e&&(r[t]=e(r[t])))}function a(t,e){try{(n=i[t](e)).value instanceof IM?Promise.resolve(n.value.v).then(l,c):u(s[0][2],n)}catch(r){u(s[0][3],r)}var n}function l(t){a("next",t)}function c(t){a("throw",t)}function u(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}(this,arguments)}function IA(t){return MM(null==t?void 0:t.getReader)}function MA(t){if(t instanceof tA)return t;if(null!=t){if(SA(t))return r=t,new tA(function(t){var e=r[JM]();if(MM(e.subscribe))return e.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(CA(t))return function(t){return new tA(function(e){for(var n=0;n0&&h(i)},void 0,void 0,function(){(null==s?void 0:s.closed)||null==s||s.unsubscribe(),a=null})),!c&&h(null!=r?"number"==typeof r?r:+r-l.now():i)})}function KA(t){throw new HA(t)}function ZA(t,e){return nA(function(n,r){var i=0;n.subscribe(rA(r,function(n){r.next(t.call(e,n,i++))}))})}var YA=Array.isArray,XA=Array.isArray,JA=Object.getPrototypeOf,QA=Object.prototype,tO=Object.keys;function eO(){for(var t=[],e=0;e=0?OA(n,s,c,o,!0):i=!0,c();var u=rA(n,function(t){var e,n,i=r.slice();try{for(var s=TM(i),o=s.next();!o.done;o=s.next()){var c=o.value,u=c.buffer;u.push(t),a<=u.length&&l(c)}}catch(h){e={error:h}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}},function(){for(;null==r?void 0:r.length;)n.next(r.shift().buffer);null==u||u.unsubscribe(),n.complete(),n.unsubscribe()},void 0,function(){return r=null});e.subscribe(u)})}function fO(t){return nA(function(e,n){var r,i=null,s=!1;i=e.subscribe(rA(n,void 0,void 0,function(o){r=MA(t(o,fO(t)(e))),i?(i.unsubscribe(),i=null,r.subscribe(n)):s=!0})),s&&(i.unsubscribe(),i=null,r.subscribe(n))})}function gO(t,e,n,r,i){return function(s,o){var a=n,l=e,c=0;s.subscribe(rA(o,function(e){var n=c++;l=a?t(l,e,n):(a=!0,e),r&&o.next(l)},i&&function(){a&&o.next(l),o.complete()}))}}var mO=function(t,e){return t.push(e),t},yO={connector:function(){return new oA}};function vO(t,e){void 0===e&&(e=yO);var n=e.connector;return nA(function(e,r){var i,s=n();MA(t((i=s,new tA(function(t){return i.subscribe(t)})))).subscribe(r),r.add(e.subscribe(s))})}function bO(t){return t<=0?function(){return vA}:nA(function(e,n){var r=0;e.subscribe(rA(n,function(e){++r<=t&&(n.next(e),t<=r&&n.complete())}))})}function wO(){return nA(function(t,e){t.subscribe(rA(e,$M))})}function _O(t,e){return void 0===e&&(e=QM),t=null!=t?t:xO,nA(function(n,r){var i,s=!0;n.subscribe(rA(r,function(n){var o=e(n);!s&&t(i,o)||(s=!1,i=o,r.next(n))}))})}function xO(t,e){return t===e}function CO(){for(var t=[],e=0;e=2,!0))}function PO(t){void 0===t&&(t={});var e=t.connector,n=void 0===e?function(){return new oA}:e,r=t.resetOnError,i=void 0===r||r,s=t.resetOnComplete,o=void 0===s||s,a=t.resetOnRefCountZero,l=void 0===a||a;return function(t){var e,r,s,a=0,c=!1,u=!1,h=function(){null==r||r.unsubscribe(),r=void 0},d=function(){h(),e=s=void 0,c=u=!1},p=function(){var t=e;d(),null==t||t.unsubscribe()};return nA(function(t,f){a++,u||c||h();var g=s=null!=s?s:n();f.add(function(){0!==--a||u||c||(r=IO(p,l))}),g.subscribe(f),!e&&a>0&&(e=new KM({next:function(t){return g.next(t)},error:function(t){u=!0,h(),r=IO(d,i,t),g.error(t)},complete:function(){c=!0,h(),r=IO(d,o),g.complete()}}),MA(t).subscribe(e))})(t)}}function IO(t,e){for(var n=[],r=2;r{var n=1e3,r=60*n,i=60*r,s=24*i,o=7*s;function a(t,e,n,r){var i=e>=1.5*n;return Math.round(t/n)+" "+r+(i?"s":"")}e.exports=function(t,e){e=e||{};var l,c,u=typeof t;if("string"===u&&t.length>0)return function(t){if(!((t=String(t)).length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var a=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*s;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*r;case"seconds":case"second":case"secs":case"sec":case"s":return a*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(t);if("number"===u&&isFinite(t))return e.long?(l=t,(c=Math.abs(l))>=s?a(l,c,s,"day"):c>=i?a(l,c,i,"hour"):c>=r?a(l,c,r,"minute"):c>=n?a(l,c,n,"second"):l+" ms"):function(t){var e=Math.abs(t);return e>=s?Math.round(t/s)+"d":e>=i?Math.round(t/i)+"h":e>=r?Math.round(t/r)+"m":e>=n?Math.round(t/n)+"s":t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}}),jO=o((t,e)=>{e.exports=function(t){function e(t){let r,i,s,o=null;function a(...t){if(!a.enabled)return;const n=a,i=Number(new Date);n.diff=i-(r||i),n.prev=r,n.curr=i,r=i,t[0]=e.coerce(t[0]),"string"!=typeof t[0]&&t.unshift("%O");let s=0;t[0]=t[0].replace(/%([a-zA-Z%])/g,(r,i)=>{if("%%"===r)return"%";s++;const o=e.formatters[i];if("function"==typeof o){const e=t[s];r=o.call(n,e),t.splice(s,1),s--}return r}),e.formatArgs.call(n,t),(n.log||e.log).apply(n,t)}return a.namespace=t,a.useColors=e.useColors(),a.color=e.selectColor(t),a.extend=n,a.destroy=e.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==e.namespaces&&(i=e.namespaces,s=e.enabled(t)),s),set:t=>{o=t}}),"function"==typeof e.init&&e.init(a),a}function n(t,n){const r=e(this.namespace+(void 0===n?":":n)+t);return r.log=this.log,r}function r(t,e){let n=0,r=0,i=-1,s=0;for(;n"-"+t)].join(",");return e.enable(""),t},e.enable=function(t){e.save(t),e.namespaces=t,e.names=[],e.skips=[];const n=("string"==typeof t?t:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const r of n)"-"===r[0]?e.skips.push(r.slice(1)):e.names.push(r)},e.enabled=function(t){for(const n of e.skips)if(r(t,n))return!1;for(const n of e.names)if(r(t,n))return!0;return!1},e.humanize=DO(),e.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(n=>{e[n]=t[n]}),e.names=[],e.skips=[],e.formatters={},e.selectColor=function(t){let n=0;for(let e=0;e{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,t=>{"%%"!==t&&(r++,"%c"===t&&(i=r))}),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(Z4){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(Z4){}return!e&&"undefined"!=typeof process&&"env"in process&&(e={}.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(Z4){}}(),t.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=jO()(t);var{formatters:n}=e.exports;n.j=function(t){try{return JSON.stringify(t)}catch(Z4){return"[UnexpectedJSONParseError]: "+Z4.message}}}),BO=l(UO(),1),$O=(0,BO.default)("applesauce"),qO=$O.extend("event-cache"),VO=Symbol("expiration-timestamp");function WO(t){return _I(t,VO,()=>{const e=t.tags.find(t=>"expiration"===t[0])?.[1];return e?parseInt(e):void 0})}var HO=o((t,e)=>{e.exports=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if((r=e.length)!=n.length)return!1;for(i=r;0!==i--;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(s=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(i=r;0!==i--;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;0!==i--;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!=e&&n!=n}}),GO=l(HO(),1),KO="abcdefghijklmnopqrstuvwxyz",ZO=new Set((KO+KO.toUpperCase()).split("")),YO=Symbol.for("indexable-tags");function XO(t){let e=Reflect.get(t,YO);if(!e){const n=new Set;for(const e of t.tags)e.length>=2&&1===e[0].length&&ZO.has(e[0])&&n.add(e[0]+":"+e[1]);e=n,Reflect.set(t,YO,n)}return e}function JO(t,e){if(t.ids&&-1===t.ids.indexOf(e.id))return!1;if(t.kinds&&-1===t.kinds.indexOf(e.kind))return!1;if(t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;if(t.since&&e.created_att.until)return!1;for(let n in t)if("&"===n[0]){let r=n.slice(1),i=t[n];if(i&&i.length>0){const t=XO(e);for(const e of i)if(!t.has(r+":"+e))return!1}}for(let n in t)if("#"===n[0]){let r=n.slice(1),i=t[n];if(i){const n=t[`&${r}`],s=n?i.filter(t=>!n.includes(t)):i;if(0===s.length)continue;const o=XO(e);if(!1===s.some(t=>o.has(r+":"+t)))return!1}}return!0}function QO(t,e){for(let n=0;n[t,this.get(t)])}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0===--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const n=this.items[t];this.ttl>0&&n.expiry<=Date.now()?this.delete(t):(e=n.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,n=!1,r=this.resetTtl){let i;if(n||this.has(t)){if(i=this.items[t],i.value=e,!1===n&&r&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,n=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==n&&(n.next=e),null!==e&&(e.prev=n)}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1===++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(t=this.keys()){return t.map(t=>this.get(t))}},nF=Symbol.for("mailboxes-inboxes"),rF=Symbol.for("mailboxes-outboxes");function iF(t){return _I(t,nF,()=>{const e=[];for(const n of t.tags)if(HI(n))try{const[,t,r]=n;!t||!rM(t)||e.includes(t)||"read"!==r&&void 0!==r||e.push(QI(t))}catch{}return e})}function sF(t){return _I(t,rF,()=>{const e=[];for(const n of t.tags)if(HI(n))try{const[t,r,i]=n;"r"!==t||!rM(r)||e.includes(r)||"write"!==i&&void 0!==i||e.push(QI(r))}catch{}return e})}var oF=Symbol.for("profile-content");function aF(t){return _I(t,oF,()=>{const e=function(t){try{return JSON.parse(t)}catch(Z4){return}}(t.content);if(e)return e.nip05&&"string"!=typeof e.nip05&&(e.nip05=String(e.nip05)),e.website&&e.website?.length>0&&!1===e.website?.startsWith("http")&&(e.website="https://"+e.website),e})}function lF(t){return!(!t||t.kind!==cR.Metadata&&t.kind!==cR.Handlerinformation||!aF(t))}function cF(t,e){return Object.fromEntries(Array.from(Object.entries(t)).map(([t,n])=>[t,{authors:n.map(t=>t.pubkey),...e}]))}function uF(t,e=!0){return n=>function(t,e,n=!0){const r=t.find(t=>t[0]===e[0]);return r?n?t.map(t=>t===r?e:t):t:[...t,e]}(n,t,e)}function hF(t,e=!0){return dF(uF(t,e))}function dF(...t){return async e=>({...e,tags:await jI(...t)(Array.from(e.tags))})}function pF(t,...e){return 0===(e=e.filter(t=>!!t)).length?t=>t:async n=>{if(!t)throw new Error("Missing signer for hidden tags");if(!bM(n.kind))throw new Error("Event kind does not support hidden tags");let r,i;if(wM(n)?(i=_M(n),void 0===i&&(wM(n)?(r=await t.getPublicKey(),i=await async function(t,e,n){if(!bM(t.kind))throw new Error("Event kind does not support hidden tags");if(function(t){if(!bM(t.kind))return!1;try{return yM in t||function(t){return!!fM(t.kind)&&function(t){return!0===Reflect.has(t,MI)}(t)&&!0===Reflect.has(t,uM)}(t)&&void 0!==_M(t)}catch{}return!1}(t))return t[yM];await async function(t,e,n){if(!fM(t.kind))throw new Error("Event kind does not support hidden content");if(uM in t)return Reflect.get(t,uM);const r=await FI(t.kind,e,n).decrypt(t.pubkey,t.content);return mM(t,r),r}(t,e,n);const r=_M(t);if(void 0===r)throw new Error("Failed to unlock hidden tags");return function(t,e){if(!bM(t.kind))throw new Error("Event kind does not support hidden tags");Reflect.set(t,yM,e),mM(t,JSON.stringify(e))}(t,r),r}({...n,pubkey:r},t)):i=[])):i=[],void 0===i)throw new Error("Failed to find hidden tags");const s=await jI(...e)(i),o=function(t,e){return hM(t,e)}(n.kind,t);r||(r=await t.getPublicKey());const a=JSON.stringify(s),l=await o.encrypt(r,a);return{...n,content:l,[MI]:a}}}function fF(t){return hF(["alt",t])}function gF(t){return hF(["expiration",t.toString()],!0)}function mF(t=!0){return dF(t?uF(["-"]):t=>t.filter(t=>!("-"===t[0])))}function yF(t){return async e=>{if(!t)throw new Error("Missing signer");Reflect.deleteProperty(e,"id"),Reflect.deleteProperty(e,"sig");const n=await t.getPublicKey(),r={...e,pubkey:n};return Reflect.has(e,MI)&&Reflect.set(r,MI,Reflect.get(e,MI)),r}}var vF=class t extends Promise{static fromKind(e){return new t(t=>t({kind:e,created_at:BI(),tags:[],content:""}))}static fromEvent(e){return new t(t=>t(function(t){return{kind:t.kind,created_at:BI(),tags:Array.from(t.tags),content:t.content}}(e)))}_signerRef={};get signer(){return this._signerRef.signer}set signer(t){this._signerRef.signer=t}chain(t){const e=new(0,this.constructor)(e=>e(this.then(async e=>{const n=await t(e);for(const t of Reflect.ownKeys(n))"symbol"!=typeof t||NI.has(t)||Reflect.deleteProperty(n,t);return n})));return e._signerRef=this._signerRef,e}as(t){return this._signerRef.signer=t,this}strip(){return new t(t=>t(this.then(t=>({content:t.content,tags:t.tags,created_at:t.created_at,kind:t.kind}))))}stamp(e=this.signer){return new t((t,n)=>{if(!e)return n(new Error("Signer required for stamping"));t(this.then(t=>yF(e)(t)))})}async sign(t=this.signer){if(!t)throw new Error("Missing signer");this.signer||(this.signer=t);const e=await(this),n=await function(t){return async e=>{if(!t)throw new Error("Missing signer");const n=await yF(t)(e),r=await t.signEvent(n);if(Reflect.has(e,"pubkey")&&Reflect.get(e,"pubkey")!==r.pubkey)throw new Error("Signer modified pubkey");if(!Mx(r,e.kind))throw new Error("Signer modified event kind");return Reflect.has(e,MI)&&Reflect.set(r,MI,Reflect.get(e,MI)),r}}(t)(e);if(Reflect.has(e,"pubkey")&&Reflect.get(e,"pubkey")!==n.pubkey)throw new Error("Signer modified pubkey");if(Mx(n,e.kind))return n;throw new Error("Signer modified event kind")}kind(e){return new t(t=>({...t,kind:e}))}content(t){return this.chain(e=>({...e,content:t}))}created(t=BI()){return t instanceof Date&&(t=Math.floor(t.getTime()/1e3)),this.chain(e=>({...e,created_at:t}))}meta(t){return this.chain(function(t){return DI(t?.protected?mF(!0):t=>t,t?.expiration?gF(t.expiration):t=>t,t?.alt?fF(t.alt):t=>t)}(t))}alt(t){return this.chain(fF(t))}expiration(t){return this.chain(gF(t))}contentWarning(t){return this.chain(function(t){return e=>{let n=Array.from(e.tags);return n=n.filter(t=>"content-warning"!==t[0]),"string"==typeof t?n.push(["content-warning",t]):!0===t&&n.push(["content-warning"]),{...e,tags:n}}}(t))}protected(t){return this.chain(mF(t))}modifyTags(...t){let e;return e=this.chain(n=>function(t,e){let n=[],r=[];return void 0===t?n=r=[]:Array.isArray(t)?n=t:"function"==typeof t?n=[t]:("function"==typeof t.public?n=[t.public]:t.public&&(n=t.public),"function"==typeof t.hidden?r=[t.hidden]:t.hidden&&(r=t.hidden)),DI(n.length>0?dF(...n):void 0,r.length>0?pF(e,...r):void 0)}(t[0],e.signer)(n)),e}modifyPublicTags(...t){return this.chain(dF(...t))}modifyHiddenTags(...t){let e;return e=this.chain(n=>pF(e.signer,...t)(n)),e}encryptedContent(t,e,n){let r;return r=this.chain(i=>{const s=r.signer;if(!s)throw new Error("Signer required for encrypted content");return function(t,e,n,r){return async i=>{if(!n)throw new Error("Signer required for encrypted content");const s=await FI(i.kind,n,r).encrypt(t,e);return{...i,content:s,[MI]:e}}}(t,e,s,n)(i)}),r}},bF=o((t,e)=>{function n(t,e){var n,r;if(0===e.length)return t;for(n=0,r=e.length;nnull!==t).map(e=>(e.author=t.pubkey,e))}(t);if(r.length>0){let i=this.deletedIds.get(e);i||(i=new Set,this.deletedIds.set(e,i));for(const e of r){i.add(e.id);const r={pointer:e,until:t.created_at};n.push(r),this.deletedSubject.next(r)}}const i=function(t){return t.tags.filter(GI).map(oM).filter(t=>null!==t).filter(e=>e.pubkey===t.pubkey)}(t);if(i.length>0){let r=this.deletedIdentifiers.get(e);r||(r=new Map,this.deletedIdentifiers.set(e,r));for(const e of i){const i=e.kind+"|"+e.identifier;r.set(i,t.created_at);const s={pointer:e,until:t.created_at};n.push(s),this.deletedSubject.next(s)}}return n}check(t){const e=t.pubkey;if(Px(t.kind)||Ix(t.kind)){const n=this.deletedIdentifiers.get(e);if(!n)return!1;const r=II(t),i=t.kind+"|"+r,s=n.get(i);return void 0!==s&&s>=t.created_at}{const n=this.deletedIds.get(e);return!!n&&n.has(t.id)}}filter(t){return t.filter(t=>!1===this.check(t))}},xF=class{log=$O.extend("EventMemory");kinds=new Map;authors=new Map;tags=new eF;created_at=[];kindAuthor=new Map;events=new eF;replaceable=new Map;get size(){return this.events.size}hasEvent(t){return this.events.has(t)}getEvent(t){return this.events.get(t)}hasReplaceable(t,e,n){const r=this.replaceable.get(PI(t,e,n));return!!r&&r.length>0}getReplaceable(t,e,n){const r=PI(t,e,n);return this.replaceable.get(r)?.[0]}getReplaceableHistory(t,e,n){const r=PI(t,e,n);return this.replaceable.get(r)}getByFilters(t){return Array.from(this.getEventsForFilters(Array.isArray(t)?t:[t]))}getTimeline(t){const e=[],n=this.getByFilters(t);for(const r of n)xI(e,r);return e}add(t){const e=t.id,n=this.events.get(e);if(n)return n;this.events.set(e,t),this.getKindIndex(t.kind).add(t),this.getAuthorsIndex(t.pubkey).add(t),this.getKindAuthorIndex(t.kind,t.pubkey).add(t);for(const r of XO(t))this.tags.has(r)&&this.getTagIndex(r).add(t);if(xI(this.created_at,t),LI(t.kind)){const e=t.tags.find(t=>"d"===t[0])?.[1],n=PI(t.kind,t.pubkey,e);let r=this.replaceable.get(n);this.replaceable.has(n)||(r=[],this.replaceable.set(n,r)),xI(r,t)}return t}remove(t){let e="string"==typeof t?this.events.get(t):t;if(!e)return!1;const n=e.id;if(!this.events.has(n))return!1;const r=this.authors.get(e.pubkey);r&&(r.delete(e),0===r.size&&this.authors.delete(e.pubkey));const i=this.kinds.get(e.kind);i&&(i.delete(e),0===i.size&&this.kinds.delete(e.kind));const s=`${e.kind}:${e.pubkey}`,o=this.kindAuthor.get(s);o&&(o.delete(e),0===o.size&&this.kindAuthor.delete(s));for(const a of XO(e))if(this.tags.has(a)){const t=this.getTagIndex(a);t.delete(e),0===t.size&&this.tags.delete(a)}if(this.removeFromSortedArray(this.created_at,e),this.events.delete(n),LI(e.kind)){const t=e.tags.find(t=>"d"===t[0])?.[1],n=PI(e.kind,e.pubkey,t),r=this.replaceable.get(n);r&&(this.removeFromSortedArray(r,e),0===r.length&&this.replaceable.delete(n))}return this.claims.delete(e),!0}removeByFilters(t){const e=this.getByFilters(t);let n=0;for(const r of e)this.remove(r)&&n++;return n}update(t){}claims=new WeakMap;touch(t){this.events.has(t.id)&&this.events.set(t.id,t)}claim(t){const e=this.claims.get(t)||0;this.claims.set(t,e+1),this.touch(t)}isClaimed(t){const e=this.claims.get(t);return void 0!==e&&e>0}removeClaim(t){const e=this.claims.get(t);if(void 0!==e&&e>0){const n=e-1;0===n?this.claims.delete(t):this.claims.set(t,n)}}clearClaim(t){this.claims.delete(t)}*unclaimed(){let t=this.events.first;for(;t;){const e=t.value;this.isClaimed(e)||(yield e),t=t.next}return 0}prune(t){let e=0;const n=this.unclaimed();for(const r of n)if(this.remove(r),e++,t&&e>=t)break;return e}getKindIndex(t){return this.kinds.has(t)||this.kinds.set(t,new Set),this.kinds.get(t)}getAuthorsIndex(t){return this.authors.has(t)||this.authors.set(t,new Set),this.authors.get(t)}getKindAuthorIndex(t,e){const n=`${t}:${e}`;return this.kindAuthor.has(n)||this.kindAuthor.set(n,new Set),this.kindAuthor.get(n)}getTagIndex(t){if(!this.tags.has(t)){const e=new Set,n=Date.now();for(const i of this.events.values())XO(i).has(t)&&e.add(i);const r=Date.now()-n;r>100&&this.log(`Built index ${t} took ${r}ms`),this.tags.set(t,e)}return this.tags.get(t)}removeFromSortedArray(t,e){if(0===t.length)return;const n=CI(t,t=>t.created_at-e.created_at);if(n){let r=n[0],i=!1;if(t[r]===e)return void t.splice(r,1);for(let n=r-1;n>=0&&t[n].created_at===e.created_at;n--)if(t[n]===e){t.splice(n,1),i=!0;break}if(i)return;for(let n=r+1;nt.created_at-e):void 0;i&&(n=Math.max(0,Math.min(i[0],this.created_at.length-1)));const s=t?CI(this.created_at,e=>e.created_at-t):void 0;if(s&&(r=Math.max(0,Math.min(s[0],this.created_at.length-1))),!(n>r))for(let o=n;o<=r;o++){const n=this.created_at[o];if(!(void 0!==e&&n.created_at>e)){if(void 0!==t&&n.created_at{const r=t instanceof Set?t:new Set(t);if(e)n=r,e=!1;else for(const e of n)r.has(e)||n.delete(e);return n};t.ids&&r(this.iterateIds(t.ids));let i=null;void 0!==t.since&&(i=Array.from(this.iterateTime(t.since,t.until)),r(i));for(const s of ZO){const e=t[`&${s}`];if(e?.length)for(const t of e)r(this.iterateTag(s,[t]))}for(const s of ZO){const e=t[`#${s}`];if(e?.length){const n=t[`&${s}`],i=n?e.filter(t=>!n.includes(t)):e;i.length>0&&r(this.iterateTag(s,i))}}if(t.authors&&t.kinds&&t.authors.length*t.kinds.length<=20){const e=new Set;for(const n of t.kinds)for(const r of t.authors){const t=`${n}:${r}`,i=this.kindAuthor.get(t);if(i)for(const n of i)e.add(n)}r(e)}else t.authors&&r(this.iterateAuthors(t.authors)),t.kinds&&r(this.iterateKinds(t.kinds));if(void 0===t.since&&void 0!==t.until&&(i=Array.from(this.iterateTime(t.since,t.until)),r(i)),e)return new Set(this.events.values());if(t.limit&&i){const e=new Set;for(const r of i){if(e.size>=t.limit)break;n.has(r)&&e.add(r)}return e}return n}getEventsForFilters(t){if(0===t.length)return new Set;let e=new Set;for(const n of t){const t=this.getEventsForFilter(n);for(const n of t)e.add(n)}return e}reset(){this.events.clear(),this.kinds.clear(),this.authors.clear(),this.kindAuthor.clear(),this.tags.clear(),this.created_at=[],this.replaceable.clear(),this.claims=new WeakMap}};function CF(t){return e=>{const n=new Set;return e.pipe(zO(e=>{if(void 0!==e)if(Array.isArray(e))for(const r of e)n.has(r)||(n.add(r),t.claim(r));else n.has(e)||(n.add(e),t.claim(e))}),kO(()=>{for(const e of n)t.removeClaim(e)}))}}function kF(t){return e=>{let n;return e.pipe(zO(e=>{n!==e&&(n&&t.removeClaim(n),e&&t.claim(e),n=e)}),kO(()=>{n&&t.removeClaim(n)}))}}function SF(t,e){return OO(n=>n?jA(n):t.eventLoader?DA(t.eventLoader(e)).pipe(AO(void 0)):jA(n))}function EF(t){return"string"==typeof t&&(t={id:t}),e=>lO(oO(()=>function(t,e){const n=t.getEvent(e.id);return n instanceof Promise?DA(n):jA(n)}(e,t)).pipe(e.eventLoader?SF(e,t):QM),e.insert$.pipe(dO(e=>e.id===t.id)),e.remove$.pipe(dO(e=>e.id===t.id),bO(1),ZA(()=>{}))).pipe(_O((t,e)=>t?.id===e?.id),kF(e))}function RF(t){return e=>{let n;return lO(oO(()=>function(t,e){const n=t.getReplaceable(e.kind,e.pubkey,e.identifier);return n instanceof Promise?DA(n):jA(n)}(e,t)).pipe(e.eventLoader?SF(e,t):QM),e.insert$.pipe(dO(e=>e.pubkey==t.pubkey&&e.kind===t.kind&&(void 0===t.identifier||II(e)===t.identifier)))).pipe(zO(t=>n=t),EO(e.remove$.pipe(dO(t=>t.id===n?.id),ZA(()=>{}))),_O((t,e)=>void 0===t||void 0===e?t===e:e.created_at{const r=new Map,i=t=>e?t.id:function(t){let e=Reflect.get(t,SI);return e||(e=LI(t.kind)?function(t){return LI(t.kind)?_I(t,EI,()=>PI(t.kind,t.pubkey,II(t))):null}(t)??t.id:t.id,Reflect.set(t,SI,e)),e}(t);return oO(()=>{const e=n.getTimeline(t);return e instanceof Promise?DA(e):jA(e)}).pipe(CF(n),EO(n.insert$.pipe(dO(e=>QO(t,e)),CF(n))),EO(n.remove$.pipe(dO(e=>QO(t,e)),ZA(t=>t.id))),LO((t,n)=>{if("string"==typeof n){const e=t.find(t=>t.id===n);if(e){const t=i(e);r.get(t)?.id===n&&r.delete(t)}return t.filter(t=>t.id!==n)}if(Array.isArray(n)){r.clear();for(const t of n)r.set(i(t),t);return[...n]}let s=[...t];const o=i(n),a=r.get(o);if(a&&(!LI(n.kind)||!e&&n.created_atr.clear()))}}function LF(t,e=!1){return t=Array.isArray(t)?t:[t],n=>{const r=e?vA:oO(()=>function(t,e){const n=t.getByFilters(e);return n instanceof Promise?DA(n).pipe(rO(t=>DA(t))):DA(n)}(n,t));return lO(r,n.insert$.pipe(dO(e=>QO(t,e))))}}function PF(t){return"string"==typeof t&&(t={pubkey:t}),e=>{return e.replaceable({kind:cR.Contacts,pubkey:t.pubkey,relays:t.relays}).pipe((n=e,t=>{let e;return lO(t.pipe(zO(t=>e=t)),n.update$.pipe(dO(t=>t.id===e?.id)))}),ZA(t=>{return t?function(...t){const e=new Map;for(const n of t)if(Array.isArray(n))for(const t of n)t&&e.set(t.pubkey,t);else n&&e.set(n.pubkey,n);return Array.from(e.values())}(function(t){return _I(t,xM,()=>KI(t.tags,t=>WI(t)?t:void 0,t=>aM(t)??void 0))}(e=t),function(t){if(CM in t)return t[CM];const e=_M(t);if(!e)return;const n=KI(e,t=>WI(t)?t:void 0,t=>aM(t)??void 0);return Reflect.set(t,CM,n),n}(e)):[];var e}));var n}}function IF(t){return"string"==typeof t&&(t={pubkey:t}),e=>e.replaceable({kind:cR.RelayList,pubkey:t.pubkey,relays:t.relays}).pipe(ZA(t=>t&&{inboxes:iF(t),outboxes:sF(t)}))}function MF(t){return"string"==typeof t&&(t={pubkey:t}),e=>e.replaceable({kind:cR.Metadata,pubkey:t.pubkey,relays:t.relays}).pipe(dO(lF),ZA(t=>t&&aF(t)))}var AF=class{models=new Map;modelKeepWarm=6e4;destroy$=new uA(1);model(t,...e){let n=this.models.get(t);n||(n=new Map,this.models.set(t,n));const r=t.getKey?t.getKey(...e):(0,wF.default)(e);let i=n.get(r);if(!i){const s=()=>{n.get(r)===i&&n.delete(r)};i=t(...e)(this).pipe(kO(s),PO({connector:()=>new uA(1),resetOnComplete:()=>lO(aO(this.modelKeepWarm),this.destroy$),resetOnRefCountZero:()=>lO(aO(this.modelKeepWarm),this.destroy$)}),FO(this.destroy$)),n.set(r,i)}return i}filters(t,e=!1){return Array.isArray(t)||(t=[t]),this.model(LF,t,e)}event(t){return"string"==typeof t||lM(t)?this.model(EF,t):this.replaceable(t)}replaceable(...t){let e;if(1===t.length)e=t[0];else if(3===t.length||2===t.length){let[n,r,i]=t;e={kind:n,pubkey:r,identifier:i}}if(!e)throw new Error("Invalid arguments, expected address pointer or kind, pubkey, identifier");return this.model(RF,e)}addressable(t){return this.replaceable(t)}timeline(t,e=!1){return this.model(TF,t,e)}profile(t){return this.model(MF,t)}contacts(t){return"string"==typeof t&&(t={pubkey:t}),this.model(PF,t)}mailboxes(t){return"string"==typeof t&&(t={pubkey:t}),this.model(IF,t)}dispose(){this.destroy$.next(),this.destroy$.complete()}},OF=class{expired$;expiredSubject;expirations=new Map;timer=null;nextCheck=null;constructor(){this.expiredSubject=new oA,this.expired$=this.expiredSubject.asObservable()}track(t){const e=WO(t);if(!e||!Number.isFinite(e))return;const n=BI();if(e<=n)return;if(this.expirations.set(t.id,e),this.timer&&this.nextCheck&&this.nextCheck<=e)return;this.timer&&clearTimeout(this.timer);const r=e-n;r>0&&(this.timer=setTimeout(this.emitNotifications.bind(this),1e3*r+10),this.nextCheck=e)}forget(t){this.expirations.delete(t)}check(t){const e=WO(t);return!!e&&e<=BI()}dispose(){this.timer&&clearTimeout(this.timer),this.timer=null,this.nextCheck=null,this.expirations.clear(),this.expiredSubject.complete()}[Symbol.dispose](){this.dispose()}emitNotifications(){const t=BI();let e=1/0;for(const[n,r]of this.expirations)r<=t?(this.expirations.delete(n),this.expiredSubject.next(n)):r0&&(this.timer=setTimeout(this.emitNotifications.bind(this),1e3*n+10),this.nextCheck=e)}}},FF=class t extends AF{database;memory;deletes;expiration;keepOldVersions=!1;keepExpired=!1;keepDeleted=!1;_verifyEventMethod=wI;get verifyEvent(){return this._verifyEventMethod}set verifyEvent(t){this._verifyEventMethod=t,void 0===t&&console.warn("[applesauce-core] EventStore.verifyEvent is undefined; signature checks are disabled.")}insert$=new oA;update$=new oA;remove$=new oA;eventLoader;internalSubscriptions=new NM;constructor(t){super(),t?.database?(this.database=t.database,this.memory=new xF):this.database=this.memory=new xF,void 0!==t?.keepDeleted&&(this.keepDeleted=t.keepDeleted),void 0!==t?.keepExpired&&(this.keepExpired=t.keepExpired),void 0!==t?.keepOldVersions&&(this.keepOldVersions=t.keepOldVersions),t?.verifyEvent&&(this.verifyEvent=t.verifyEvent),this.deletes=t?.deleteManager??new _F,this.internalSubscriptions.add(this.deletes.deleted$.subscribe(this.handleDeleteNotification.bind(this))),this.expiration=t?.expirationManager??new OF,this.internalSubscriptions.add(this.expiration.expired$.subscribe(this.handleExpiredNotification.bind(this)))}mapToMemory(t){if(void 0!==t)return this.memory?this.memory.add(t):t}handleDeleteNotification({pointer:t,until:e}){if(!this.keepDeleted)if(lM(t)){const n=this.getEvent(t.id);n&&e>=n.created_at&&cM(n,t)&&this.remove(n)}else if(function(t){return"object"==typeof t&&null!==t&&"identifier"in t&&"pubkey"in t&&"kind"in t&&"string"==typeof t.identifier&&"string"==typeof t.pubkey&&"number"==typeof t.kind}(t)){const n=this.getReplaceableHistory(t.kind,t.pubkey,t.identifier);if(n)for(const r of n)e>=r.created_at&&cM(r,t)&&this.remove(r)}}handleExpiredNotification(t){this.keepExpired||this.remove(t)}static copySymbolsToDuplicateEvent(t,e){if(t.kind!==e.kind)throw new Error("Source and destination events must have the same kind");if((n=t.kind)<1e4&&0!==n&&3!==n&&t.id!==e.id)throw new Error("Source and destination events must have the same ID");var n;if(LI(t.kind)&&t.pubkey!==e.pubkey&&II(t)!==II(e))throw new Error("Source and destination events must have the same pubkey and replaceable identifier");let r=!1;const i=(s=t,Reflect.get(s,tM));var s;if(i){for(const t of i)eM(e,t);r=!0}const o=[RI,pI,MI];for(const a of o)a in t&&!(a in e)&&(Reflect.set(e,a,Reflect.get(t,a)),r=!0);return r}add(e,n){if(e.kind===cR.EventDeletion)return this.deletes.add(e),e;if(this.deletes.check(e))return e;const r=WO(e);if(!1===this.keepExpired&&r&&r<=BI())return null;n&&eM(e,n);const i=LI(e.kind)?II(e):void 0;if(!1===this.keepOldVersions&&LI(e.kind)){const n=this.database.getReplaceableHistory(e.kind,e.pubkey,i);if(n&&n.length>0){let r=n[0];for(const t of n)(t.created_at>r.created_at||t.created_at===r.created_at&&t.idr.created_at||e.created_at===r.created_at&&e.id0){let e=t[0];for(const r of t)(r.created_at>e.created_at||r.created_at===e.created_at&&r.idt!==e);for(const t of n)this.remove(t);if(n.length>0)return e}}return!1===this.keepExpired&&void 0!==r&&this.expiration.track(o),o}remove(t){const e="string"==typeof t?t:t.id;let n=this.memory.getEvent(e);this.expiration.forget(e),n&&Reflect.deleteProperty(n,kI),this.memory!==this.database&&this.memory.remove(t);const r=this.database.remove(t);return r&&n&&this.remove$.next(n),r}removeByFilters(t){const e=this.getByFilters(t);for(const r of e)this.expiration.forget(r.id);this.memory!==this.database&&this.memory.removeByFilters(t);const n=this.database.removeByFilters(t);for(const r of e)this.remove$.next(r);return n}update(t){return!!this.database.add(t)&&(this.database.update?.(t),this.update$.next(t),!0)}hasEvent(t){return"string"==typeof t?this.memory.hasEvent(t)||this.database.hasEvent(t):lM(t)?this.memory.hasEvent(t.id)||this.database.hasEvent(t.id):this.hasReplaceable(t.kind,t.pubkey,t.identifier)}getEvent(t){return"string"==typeof t?this.memory.getEvent(t)??this.mapToMemory(this.database.getEvent(t)):lM(t)?this.memory.getEvent(t.id)??this.mapToMemory(this.database.getEvent(t.id)):this.getReplaceable(t.kind,t.pubkey,t.identifier)}hasReplaceable(t,e,n){return this.memory.hasReplaceable(t,e,n)||this.database.hasReplaceable(t,e,n)}getReplaceable(t,e,n){return this.memory.getReplaceable(t,e,n)??this.mapToMemory(this.database.getReplaceable(t,e,n))}getReplaceableHistory(t,e,n){return this.memory.getReplaceableHistory(t,e,n)??this.database.getReplaceableHistory(t,e,n)?.map(t=>this.mapToMemory(t)??t)}getByFilters(t){const e=this.database.getByFilters(t);return this.memory?e.map(t=>this.mapToMemory(t)):e}getTimeline(t){const e=this.database.getTimeline(t);return this.memory?e.map(t=>this.mapToMemory(t)):e}touch(t){return this.memory.touch(t)}claim(t){return this.memory.claim(t)}isClaimed(t){return this.memory.isClaimed(t)??!1}removeClaim(t){return this.memory.removeClaim(t)}clearClaim(t){return this.memory.clearClaim(t)}unclaimed(){return this.memory.unclaimed()||function*(){}()}prune(t){return this.memory.prune(t)??0}dispose(){const t=this.eventLoader;t&&"function"==typeof t[Symbol.dispose]&&t[Symbol.dispose](),this.eventLoader=void 0,super.dispose(),this.internalSubscriptions.unsubscribe(),this.expiration.dispose?.(),this.insert$.complete(),this.update$.complete(),this.remove$.complete()}[Symbol.dispose](){this.dispose()}};function NF(t,e=!0){return n=>{const r=n.pipe(PO());return r.pipe(rO(e=>{if("string"==typeof e)return vA;const n=t.add(e);return n instanceof Promise?DA(n):jA(n)}),fO(()=>jA(null)),dO(t=>null!==t),e?nA(function(t,e){var n=new Set;t.subscribe(rA(e,function(t){var r=t;n.has(r)||(n.add(r),e.next(t))}))}):QM,EO(r.pipe(dO(t=>"string"==typeof t))))}}function zF(t){return NF(t,!0)}var DF=class extends Error{};function jF(t,e){return GA({first:t,with:()=>UA(()=>new DF(e??"Timeout"))})}function UF(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name&&"BYTES_PER_ELEMENT"in t&&1===t.BYTES_PER_ELEMENT}var BF=t=>t?`"${t}" `:"";function $F(t,e,n=""){if(UF(t)&&(void 0===e||t.length===e))return t;void 0!==e&&function(t,e=""){if("number"!=typeof t)throw new TypeError(BF(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(BF(e)+"expected integer >= 0, got "+t)}(e,"length");const r=UF(t),i=void 0!==e?` of length ${e}`:"",s=r?`length=${t.length}`:"type="+typeof t,o=BF(n)+"expected Uint8Array"+i+", got "+s;if(!r)throw new TypeError(o);throw new RangeError(o)}var qF=(t,e)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(("object"===e?"":`"${e}" `)+"expected object, got type="+typeof t)};function VF(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function WF(...t){for(let e=0;e>>e}function KF(t,e={}){if("function"!=typeof t)throw new TypeError('"hashCons" expected function, got type='+typeof t);e=function(t,e,n="opts"){return qF(t,"defaults"),void 0!==e&&qF(e,n),Object.assign(t,e)}({},e,"info");const n=(e,n)=>t(n).update(e).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=e=>t(e),Object.assign(n,e),Object.freeze(n)}var ZF=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function YF(t,e,n){return t&e^~t&n}function XF(t,e,n){return t&e^t&n^e&n}var JF=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,r){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=HF(this.buffer)}update(t){VF(this),$F(t);const{view:e,buffer:n,blockLen:r}=this,i=t.length;let s=!1;for(let o=0;o=n))throw new RangeError('"output" expected length >= '+n)}(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:s}=this;e[s++]=128,e.fill(0,s),this.padOffset>r-s&&(this.process(n,0),e.fill(0)),function(t,e,n,r){const i=(t=>t/2**32|0)(n),s=(t=>t>>>0)(n);t.setUint32(e,r?s:i,r),t.setUint32(e+4,r?i:s,r)}(n,r-8,8*this.length,i),this.process(n,0),this.roundClean();const o=t===e?n:HF(t),a=this.outputLen,l=a/4,c=this.get();if(a%4||l>c.length)throw new Error("invalid outputLen");for(let u=0;u>>3,r=GF(e,17)^GF(e,19)^e>>>10;eN[u]=r+eN[u-7]+n+eN[u-16]|0}let{A:n,B:r,C:i,D:s,E:o,F:a,G:l,H:c}=this;for(let u=0;u<64;u++){const t=c+(GF(o,6)^GF(o,11)^GF(o,25))+YF(o,a,l)+tN[u]+eN[u]|0,e=(GF(n,2)^GF(n,13)^GF(n,22))+XF(n,r,i)|0;c=l,l=a,a=o,o=s+t|0,s=i,i=r,r=n,n=t+e|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,i,s,o,a,l,c)}roundClean(){WF(eN)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),WF(this.buffer)}},rN=class extends nN{constructor(){super(32,QF)}},iN=KF(()=>new rN,ZF(1)),sN=new WeakMap;function oN(t,e,n,r){let i={configurable:!0,enumerable:!0,writable:!0,initializer:null};r&&(i.initializer=r);for(let s of n)i=s(t,e,i)||i;void 0===i.initializer?Object.defineProperty(t,e,i):function(t,e,n){let r=sN.get(t);r||(r=new Map,sN.set(t,r)),r.set(e,n)}(t,e,i)}function aN(t,e,n){let r={...Object.getOwnPropertyDescriptor(t,e)};for(let i of n)r=i(t,e,r)||r;void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(t):void 0,r.initializer=void 0),Object.defineProperty(t,e,r)}function lN(t,e){let n=function(t,e){var n;let r=t.prototype;for(;r;){let t=null==(n=sN.get(r))?void 0:n.get(e);if(t)return t;r=Object.getPrototypeOf(r)}}(t.constructor,e);n&&Object.defineProperty(t,e,{enumerable:n.enumerable,configurable:n.configurable,writable:n.writable,value:n.initializer?n.initializer.call(t):void 0})}var cN=a({DEFAULT_BLOSSOM_SERVER:()=>uN,default:()=>dN}),uN="https://blossom.nostr.build";function hN(t,e){let n=t||"https://blossom.nostr.build";return n.endsWith("/")&&(n=n.slice(0,-1)),e.startsWith("/")?`${n}${e}`:`${n}/${e}`}var dN=class extends dp{static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");get servers(){const t=this.nostrData.blossomServers,e=t.length?t:[uN];return this.settings.nostrPhotoFallbackUploads?e:[e[0]]}async _getAuthHeader(t,e,n){const r=Math.floor(Date.now()/1e3),i=new URL(n).hostname,s=await vF.fromKind(24242).content("upload"===t?"Upload photo for place":"Delete photo").modifyPublicTags(()=>[["t",t],["x",e],["expiration",String(r+3600)],["server",i]]).created(r).as(this.nostrAuth.signer).sign();return`Nostr ${btoa(JSON.stringify(s)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}async _uploadToServer(t,e,n,r){const i=hN(n,"upload");r&&r("signing");const s=await this._getAuthHeader("upload",e,n);r&&r("uploading");const o=await fetch(i,{method:"PUT",headers:{Authorization:s,"X-SHA-256":e},body:t});if(!o.ok){const t=await o.text();throw new Error(`Upload failed (${o.status}): ${t}`)}return o.json()}async upload(t,e={sequential:!1}){if(!this.nostrAuth.isConnected)throw new Error("Not connected");const n=await t.arrayBuffer();let r;r="undefined"!=typeof crypto&&crypto.subtle&&crypto.subtle.digest?await crypto.subtle.digest("SHA-256",n):iN(new Uint8Array(n));const i=function(t){return Array.from(new Uint8Array(t)).map(t=>t.toString(16).padStart(2,"0")).join("")}(r),s=this.servers,o=s[0],a=s.slice(1),l=[];let c;if(e.sequential){c=await this._uploadToServer(t,i,o,e.onProgress);for(const n of a)try{const r=await this._uploadToServer(t,i,n,e.onProgress);l.push(r.url)}catch(Z4){console.warn(`Fallback upload to ${n} failed:`,Z4)}}else{const n=this._uploadToServer(t,i,o,e.onProgress),r=a.map(n=>this._uploadToServer(t,i,n,e.onProgress));c=await n;const s=await Promise.allSettled(r);for(let t=0;tthis._deleteFromServer(t,e));await i;const o=await Promise.allSettled(s);for(let a=0;amN}),fN=3600;function gN(t){const e=t.tags||[],n=e.filter(t=>"t"===t[0]).map(t=>t[1]).filter(Boolean),r=e.find(t=>"imeta"===t[0]);if(!r)return null;let i=null,s=null,o=null,a=!1,l=16/9,c=null;for(const h of r.slice(1))if(h.startsWith("url "))i=h.substring(4);else if(h.startsWith("thumb "))s=h.substring(6);else if(h.startsWith("blurhash "))o=h.substring(9);else if(h.startsWith("dim ")){const[t,e]=h.substring(4).split("x").map(Number);t&&e&&(l=t/e,t>e&&(a=!0))}else if(h.startsWith("alt ")){const t=h.substring(4).trim();c="A photo of a place"===t?null:t||null}if(!i)return null;const u=e.find(t=>"i"===t[0])?.[1];return{eventId:t.id,pubkey:t.pubkey,createdAt:t.created_at,url:i,thumbUrl:s,blurhash:o,isLandscape:a,aspectRatio:l,placeIdentifier:u,tags:n,alt:c}}function mN(t,e=3){if(!t||0===t.length)return[];const n=function(t){const e=new Set;for(const n of t)if(5===n.kind)for(const t of n.tags||[])"e"===t[0]&&t[1]&&e.add(t[1]);return t.filter(t=>360===t.kind&&!e.has(t.id))}(t);if(0===n.length)return[];const r=new Map;for(const o of n){const t=(o.tags||[]).find(t=>"i"===t[0])?.[1];t&&(r.has(t)||r.set(t,[]),r.get(t).push(o))}const i=e*fN,s=[];for(const[o,a]of r){const t=[...a].sort((t,e)=>e.created_at-t.created_at);let e=[],n=null;for(const r of t)null!==n&&n-r.created_at>i&&(s.push(yN(o,e)),e=[]),e.push(r),n=r.created_at;e.length>0&&s.push(yN(o,e))}return s.filter(t=>t.photos.length>0).sort((t,e)=>e.createdAt-t.createdAt)}function yN(t,e){const n=e.map(gN).filter(Boolean).sort((t,e)=>t.createdAt-e.createdAt),r=e.reduce((t,e)=>e.created_at>t?e.created_at:t,0),[,i,s]=t.split(":");return{type:"photo",placeIdentifier:t,osmType:i,osmId:s,placeName:null,placeNameLoading:!0,photos:n,createdAt:r,eventCount:e.length}}var vN=a({default:()=>wN}),bN="marco:contributions:name_cache",wN=class extends dp{static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"osm",[hp])}#j=void lN(this,"osm");static{oN(this.prototype,"items",[qr],function(){return[]})}#U=void lN(this,"items");_sub=null;_pendingBatchPromise=null;_lastBatchSignature="";_nameCache=new Map;_unresolvable=new Set;constructor(){super(...arguments),this._loadNameCache()}_loadNameCache(){if("undefined"!=typeof localStorage)try{const t=localStorage.getItem(bN);if(t){const e=JSON.parse(t);e&&"object"==typeof e&&(this._nameCache=new Map(Object.entries(e)))}}catch{}}_saveNameCache(){if("undefined"!=typeof localStorage)try{const t=Object.fromEntries(this._nameCache);localStorage.setItem(bN,JSON.stringify(t))}catch(t){console.debug("[contributions] Failed to persist name cache",t)}}async load(t){t?(this._sub=this.nostrData.store.timeline([{kinds:[360,5],authors:[t]}]).subscribe(t=>{this._updateItems(t)}),await this.nostrData.loadMyContributions(t)):this.items=[]}stop(){this._sub&&(this._sub.unsubscribe(),this._sub=null),this.items=[],this._lastBatchSignature="",this._pendingBatchPromise=null,this._unresolvable.clear()}willDestroy(){this.stop(),super.willDestroy(...arguments)}_updateItems(t){const e=mN(t);for(const n of e){const t=this._resolveCachedName(n);t&&(n.placeName=t,n.placeNameLoading=!1)}this.items=e,this._maybeBatchFetchNames(e)}_resolveCachedName(t){const e=this.storage.findPlaceById(t.osmId);return e?.title?e.title:this._nameCache.has(t.placeIdentifier)?this._nameCache.get(t.placeIdentifier):this.osm.getCachedOsmObject(t.osmType,t.osmId)?.title||null}_isUnresolvable(t){return this._unresolvable.has(t.placeIdentifier)}_maybeBatchFetchNames(t){const e=t.filter(t=>t.placeNameLoading&&!this._isUnresolvable(t));for(const r of t)r.placeNameLoading&&this._isUnresolvable(r)&&(r.placeName=this._fallbackName(r),r.placeNameLoading=!1);if(0===e.length)return void(this.items.some(t=>!t.placeNameLoading)&&(this.items=[...this.items]));const n=e.map(t=>t.placeIdentifier).sort().join("|");n===this._lastBatchSignature&&this._pendingBatchPromise||(this._lastBatchSignature=n,this._pendingBatchPromise=this._batchResolveNames(e).then(t=>{for(const e of this.items)e.placeNameLoading&&(t.has(e.placeIdentifier)?(e.placeName=t.get(e.placeIdentifier),e.placeNameLoading=!1):(this._unresolvable.add(e.placeIdentifier),e.placeName=this._fallbackName(e),e.placeNameLoading=!1));this._saveNameCache(),this.items=[...this.items]}).catch(t=>{console.error("[contributions] Batch name resolution failed",t);for(const e of this.items)e.placeNameLoading&&(this._unresolvable.add(e.placeIdentifier),e.placeName=this._fallbackName(e),e.placeNameLoading=!1);this._saveNameCache(),this.items=[...this.items]}).finally(()=>{this._pendingBatchPromise=null}))}_fallbackName(t){return`OSM ${t.osmType} ${t.osmId}`}async _batchResolveNames(t){const e=new Map,n=[];for(const i of t){const t=this._resolveCachedName(i);t?e.set(i.placeIdentifier,t):n.push({osmType:i.osmType,osmId:i.osmId})}if(0===n.length)return e;const r=await this.osm.fetchOsmObjectsBatch(n);for(const i of t){if(e.has(i.placeIdentifier))continue;const t=`${i.osmType}:${i.osmId}`,n=r.get(t);n?.title&&(e.set(i.placeIdentifier,n.title),this._nameCache.set(i.placeIdentifier,n.title))}return this._saveNameCache(),e}};function _N(t){return new Worker("/assets/image-processor-TE4QOxly.js",{name:t?.name})}var xN=a({default:()=>CN}),CN=class extends dp{_worker=null;_callbacks=new Map;_msgId=0;constructor(){super(...arguments),this._initWorker()}_initWorker(){if(!this._worker&&void 0!==_N)try{this._worker=new _N,this._worker.onmessage=this._handleMessage.bind(this),this._worker.onerror=this._handleError.bind(this)}catch(t){console.warn("Failed to initialize image-processor worker:",t)}}_handleMessage(t){const{id:e,success:n,blob:r,dim:i,blurhash:s,error:o}=t.data,a=this._callbacks.get(e);a&&(this._callbacks.delete(e),n?a.resolve({blob:r,dim:i,blurhash:s}):a.reject(new Error(o)))}_handleError(t){console.error("Image Processor Worker Error:",t);for(const[,e]of this._callbacks.entries())e.reject(new Error("Worker crashed"));this._callbacks.clear(),this._worker.terminate(),this._worker=null,this._initWorker()}_getImageDimensions(t){return new Promise((e,n)=>{const r=new Image,i=URL.createObjectURL(t);r.onload=()=>{const t={width:r.width,height:r.height};URL.revokeObjectURL(i),e(t)},r.onerror=()=>{URL.revokeObjectURL(i),n(new Error("Could not read image dimensions"))},r.src=i})}async process(t,e,n,r=!1){if(!this._worker)throw new Error("Image processor worker is not available.");try{const{width:i,height:s}=await this._getImageDimensions(t);let o=i,a=s;return i>s?i>e&&(a=Math.round(s*(e/i)),o=e):s>e&&(o=Math.round(i*(e/s)),a=e),new Promise((e,i)=>{const s=++this._msgId;this._callbacks.set(s,{resolve:e,reject:i}),this._worker.postMessage({type:"PROCESS_IMAGE",id:s,file:t,targetWidth:o,targetHeight:a,quality:n,computeBlurhash:r})})}catch(i){throw new Error(`Failed to process image: ${i.message}`,{cause:i})}}willDestroy(){super.willDestroy(...arguments),this._worker&&(this._worker.terminate(),this._worker=null),this._callbacks.clear()}},kN=a({default:()=>SN}),SN=class extends dp{static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"selectedPlace",[qr],function(){return null})}#B=void lN(this,"selectedPlace");static{oN(this.prototype,"isSearching",[qr],function(){return!1})}#$=void lN(this,"isSearching");static{oN(this.prototype,"isCreating",[qr],function(){return!1})}#q=void lN(this,"isCreating");static{oN(this.prototype,"creationCoordinates",[qr],function(){return null})}#V=void lN(this,"creationCoordinates");static{oN(this.prototype,"returnToSearch",[qr],function(){return!1})}#W=void lN(this,"returnToSearch");static{oN(this.prototype,"returnToRoute",[qr],function(){return null})}#H=void lN(this,"returnToRoute");static{oN(this.prototype,"currentCenter",[qr],function(){return null})}#G=void lN(this,"currentCenter");static{oN(this.prototype,"currentBounds",[qr],function(){return null})}#K=void lN(this,"currentBounds");static{oN(this.prototype,"currentZoom",[qr],function(){return null})}#Z=void lN(this,"currentZoom");static{oN(this.prototype,"searchBoxHasFocus",[qr],function(){return!1})}#Y=void lN(this,"searchBoxHasFocus");static{oN(this.prototype,"selectionOptions",[qr],function(){return{}})}#X=void lN(this,"selectionOptions");static{oN(this.prototype,"preventNextZoom",[qr],function(){return!1})}#J=void lN(this,"preventNextZoom");static{oN(this.prototype,"searchResults",[qr],function(){return[]})}#Q=void lN(this,"searchResults");static{oN(this.prototype,"currentSearch",[qr],function(){return null})}#tt=void lN(this,"currentSearch");static{oN(this.prototype,"loadingState",[qr],function(){return null})}#et=void lN(this,"loadingState");static{oN(this.prototype,"isSidebarVisible",[qr],function(){return!1})}#nt=void lN(this,"isSidebarVisible");static{oN(this.prototype,"isSidebarOpening",[qr],function(){return!1})}#rt=void lN(this,"isSidebarOpening");scrollPositions={};saveScrollPosition(t,e){this.scrollPositions[t]=e}static{aN(this.prototype,"saveScrollPosition",[$l])}getScrollPosition(t){return this.scrollPositions[t]||0}static{aN(this.prototype,"getScrollPosition",[$l])}showSidebar(){this.isSidebarVisible||(this.isSidebarVisible=!0,this.isSidebarOpening=!0,setTimeout(()=>{this.isSidebarOpening=!1},250))}hideSidebar(){this.isSidebarVisible=!1,this.isSidebarOpening=!1}selectPlace(t,e={}){this.selectedPlace=t,this.selectionOptions=e,this.nostrData.loadPhotosForPlace(t)}clearSelection(){this.selectedPlace=null,this.selectionOptions={},this.preventNextZoom=!1,this.nostrData.loadPhotosForPlace(null)}setSearchResults(t){this.searchResults=t||[]}clearSearchResults(){this.searchResults=[],this.currentSearch=null}startSearch(){this.isSearching=!0,this.isCreating=!1,this.preventNextZoom=!1}stopSearch(){this.isSearching=!1}startCreating(){this.isCreating=!0,this.isSearching=!1}stopCreating(){this.isCreating=!1,this.creationCoordinates=null}updateCreationCoordinates(t,e){this.creationCoordinates={lat:t,lon:e}}setSearchBoxFocus(t){this.searchBoxHasFocus=t}updateCenter(t,e){this.currentCenter={lat:t,lon:e}}updateZoom(t){this.currentZoom=t}updateBounds(t){this.currentBounds=t}startLoading(t,e){this.loadingState={type:t,value:e}}stopLoading(t=null,e=null){t||e?this.loadingState&&this.loadingState.type===t&&this.loadingState.value===e&&(this.loadingState=null):this.loadingState=null}};function EN(){let t,e;const n=new Promise((n,r)=>{t=n,e=r});return n.resolve=t,n.reject=e,n}"navigator"in globalThis&&navigator.userAgent.includes("Android")&&navigator.clipboard&&navigator.clipboard.readText;var RN=class extends Error{},TN=class{get nip04(){return window.nostr?.nip04}get nip44(){return window.nostr?.nip44}pubkey=void 0;async getPublicKey(){if(!window.nostr)throw new RN("Signer extension missing");if(this.pubkey)return this.pubkey;const t=await window.nostr.getPublicKey();if(!iM(t))throw new Error("Extension returned an invalid public key");return this.pubkey=t,this.pubkey}async signEvent(t){if(!window.nostr)throw new RN("Signer extension missing");const e=await window.nostr.signEvent(t);if(!wI(e))throw new Error("Extension returned an invalid event");return e}};function LN(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name&&"BYTES_PER_ELEMENT"in t&&1===t.BYTES_PER_ELEMENT}function PN(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function IN(t){if("function"!=typeof t)throw new TypeError("function expected");return!0}function MN(t,e){if("string"!=typeof e)throw new TypeError(`${t}: string expected`);return!0}function AN(t){if("number"!=typeof t)throw new TypeError("number expected, got "+typeof t);if(!Number.isSafeInteger(t))throw new RangeError(`invalid integer: ${t}`)}function ON(t){if(!Array.isArray(t))throw new TypeError("array expected")}function FN(t,e){if(!PN(!0,e))throw new TypeError(`${t}: array of strings expected`)}function NN(t,e){if(!PN(!1,e))throw new TypeError(`${t}: array of numbers expected`)}function zN(...t){const e=t=>t,n=(t,e)=>n=>t(e(n));return{encode:t.map(t=>t.encode).reduceRight(n,e),decode:t.map(t=>t.decode).reduce(n,e)}}function DN(t){const e="string"==typeof t?t.split(""):t,n=e.length;FN("alphabet",e);const r=new Map(e.map((t,e)=>[t,e]));return{encode:r=>(ON(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${t}`);return e[r]})),decode:e=>(ON(e),e.map(e=>{MN("alphabet.decode",e);const n=r.get(e);if(void 0===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}function jN(t=""){return MN("join",t),{encode:e=>(FN("join.decode",e),e.join(t)),decode:e=>(MN("join.decode",e),e.split(t))}}function UN(t,e="="){return AN(t),MN("padding",e),{encode(n){for(FN("padding.encode",n);n.length*t%8;)n.push(e);return n},decode(n){FN("padding.decode",n);let r=n.length;if(r*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if((r-1)*t%8==0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function BN(t){return IN(t),{encode:t=>t,decode:e=>t(e)}}var $N=(t,e)=>0===e?t:$N(e,t%e),qN=(t,e)=>t+(e-$N(t,e)),VN=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function WN(t,e,n,r){if(ON(t),e<=0||e>32)throw new RangeError(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new RangeError(`convertRadix2: wrong to=${n}`);if(qN(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${qN(e,n)}`);let i=0,s=0;const o=VN[e],a=VN[n]-1,l=[];for(const c of t){if(AN(c),c>=o)throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);if(i=i<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=n;s-=n)l.push((i>>s-n&a)>>>0);const t=VN[s];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<=e)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&s>0&&l.push(i>>>0),l}function HN(t,e=!1){if(AN(t),t<=0||t>32)throw new RangeError("radix2: bits should be in (0..32]");if(qN(8,t)>32||qN(t,8)>32)throw new RangeError("radix2: carry overflow");return{encode:n=>{if(!LN(n))throw new TypeError("radix2.encode input should be Uint8Array");return WN(Array.from(n),8,t,!e)},decode:n=>(NN("radix2.decode",n),Uint8Array.from(WN(n,t,8,e)))}}function GN(t){return IN(t),function(...e){try{return t.apply(null,e)}catch(n){}}}zN(HN(4),DN("0123456789ABCDEF"),jN("")),zN(HN(5),DN("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),UN(5),jN("")),zN(HN(5),DN("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),jN("")),zN(HN(5),DN("0123456789ABCDEFGHIJKLMNOPQRSTUV"),UN(5),jN("")),zN(HN(5),DN("0123456789ABCDEFGHIJKLMNOPQRSTUV"),jN("")),zN(HN(5),DN("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),jN(""),BN(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));var KN=(()=>"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64)(),ZN=(KN||zN(HN(6),DN("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),UN(6),jN("")),zN(HN(6),DN("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),jN("")),KN||zN(HN(6),DN("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),UN(6),jN("")),zN(HN(6),DN("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),jN("")),zN(DN("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),jN(""))),YN=[996825010,642813549,513874426,1027748829,705979059];function XN(t){const e=t>>25;let n=(33554431&t)<<5;for(let r=0;r>r&1)&&(n^=YN[r]);return n}function JN(t,e,n=1){const r=t.length;let i=1;for(let s=0;s126)throw new Error(`Invalid prefix (${t})`);i=XN(i)^e>>5}i=XN(i);for(let s=0;sr)throw new TypeError(`Length ${s} exceeds limit ${r}`);const o=t.toLowerCase(),a=JN(o,n,e);return`${o}1${ZN.encode(n)}${a}`}function a(t,n=90){MN("bech32.decode input",t);const r=t.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${t}). Expected (8..${n})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const s=i.lastIndexOf("1");if(0===s||-1===s)throw new Error('Letter "1" must be present between prefix and data only');const o=i.slice(0,s),a=i.slice(s+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const l=ZN.decode(a).slice(0,-6),c=JN(o,l,e);if(!a.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:o,words:l}}return{encode:o,decode:a,encodeFromBytes:function(t,e){return o(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:n}=a(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:GN(a),fromWords:r,fromWordsUnsafe:s,toWords:i}}var tz,ez,nz=Object.freeze(QN("bech32")),rz=(QN("bech32m"),(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)()||zN(HN(4),DN("0123456789abcdef"),jN(""),BN(t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),new TextEncoder),iz=new TextDecoder;function sz(t){if(!iM(t.remote))throw new Error("Invalid nbunksec: remote is not a valid hex key");if(!iM(t.clientKey))throw new Error("Invalid nbunksec: clientKey is not a valid hex key");if(0===t.relays.length)throw new Error("Invalid nbunksec: missing relays");return function(t){try{const e=[],n=Lk(t.pubkey);e.push(new Uint8Array([0,n.length]),n);const r=Lk(t.local_key);e.push(new Uint8Array([1,r.length]),r);for(const a of t.relays){const t=rz.encode(a);e.push(new Uint8Array([2,t.length]),t)}if(t.secret){const n=rz.encode(t.secret);e.push(new Uint8Array([3,n.length]),n)}const i=e.reduce((t,e)=>t+e.length,0),s=new Uint8Array(i);let o=0;for(const t of e)s.set(t,o),o+=t.length;return nz.encode("nbunksec",nz.toWords(s),!1)}catch(Z4){throw new Error(`Failed to encode bunker info: ${Z4}`)}}({pubkey:t.remote,local_key:t.clientKey,relays:t.relays,secret:t.bunkerSecret??t.secret})}pM(cR.NostrConnect,"nip44"),function(t){t.GetPublicKey="get_public_key",t.SignEvent="sign_event",t.Ping="ping",t.Nip04Encrypt="nip04_encrypt",t.Nip04Decrypt="nip04_decrypt",t.Nip44Encrypt="nip44_encrypt",t.Nip44Decrypt="nip44_decrypt",t.SwitchRelays="switch_relays"}(tz||(tz={})),function(t){t.Connect="connect",t.CreateAccount="create_account",t.GetPublicKey="get_public_key",t.SignEvent="sign_event",t.Ping="ping",t.Nip04Encrypt="nip04_encrypt",t.Nip04Decrypt="nip04_decrypt",t.Nip44Encrypt="nip44_encrypt",t.Nip44Decrypt="nip44_decrypt",t.SwitchRelays="switch_relays",t.Logout="logout"}(ez||(ez={}));var oz=class t{key;constructor(t){this.key=t||yI()}async getPublicKey(){return vI(this.key)}async signEvent(t){return bI(t,this.key)}nip04={encrypt:async(t,e)=>xL.encrypt(this.key,t,e),decrypt:async(t,e)=>xL.decrypt(this.key,t,e)};nip44={encrypt:async(t,e)=>jL.v2.encrypt(e,jL.v2.utils.getConversationKey(this.key,t)),decrypt:async(t,e)=>jL.v2.decrypt(e,jL.v2.utils.getConversationKey(this.key,t))};static fromKey(e){const n=function(t){if(t instanceof Uint8Array)return 32!==t.length?null:t;if(iM(t))return Lk(t);try{const e=function(t){let{prefix:e,words:n}=vS.decode(t,5e3),r=new Uint8Array(vS.fromWords(n));switch(e){case"nprofile":{let t=XI(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nprofile");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:Tk(t[0][0]),relays:t[1]?t[1].map(t=>ZI.decode(t)):[]}}}case"nevent":{let t=XI(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for nevent");if(32!==t[0][0].length)throw new Error("TLV 0 should be 32 bytes");if(t[2]&&32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(t[3]&&4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:Tk(t[0][0]),relays:t[1]?t[1].map(t=>ZI.decode(t)):[],author:t[2]?.[0]?Tk(t[2][0]):void 0,kind:t[3]?.[0]?parseInt(Tk(t[3][0]),16):void 0}}}case"naddr":{let t=XI(r);if(!t[0]?.[0])throw new Error("missing TLV 0 for naddr");if(!t[2]?.[0])throw new Error("missing TLV 2 for naddr");if(32!==t[2][0].length)throw new Error("TLV 2 should be 32 bytes");if(!t[3]?.[0])throw new Error("missing TLV 3 for naddr");if(4!==t[3][0].length)throw new Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:ZI.decode(t[0][0]),pubkey:Tk(t[2][0]),kind:parseInt(Tk(t[3][0]),16),relays:t[1]?t[1].map(t=>ZI.decode(t)):[]}}}case"nsec":return{type:e,data:r};case"npub":case"note":return{type:e,data:Tk(r)};default:throw new Error(`unknown prefix ${e}`)}}(t);return"nsec"!==e.type?null:e.data}catch{return null}}(e);if(!n)throw new Error("Invalid private key");return new t(n)}};async function az(t){window.open(t,"auth","width=400,height=600,resizable=no,status=no,location=no,toolbar=no,menubar=no")}var lz=class t{static subscriptionMethod=void 0;static publishMethod=void 0;static pool=void 0;publishMethod;subscriptionMethod;log=$O.extend("NostrConnectSigner");signer;listening=!1;isConnected=!1;pubkey;relays;remote;get clientPubkey(){return vI(this.signer.key)}onAuth=az;verifyEvent=wI;connectSecret;bunkerSecret;get secret(){return this.connectSecret}set secret(t){this.connectSecret=t}nip04;nip44;constructor(e){this.relays=e.relays,this.pubkey=e.pubkey,this.remote=e.remote,this.connectSecret=e.connectSecret||e.secret||$I(12),this.bunkerSecret=e.bunkerSecret;const{subscriptionMethod:n,publishMethod:r}=function(t,e){const n=t.subscriptionMethod||t.pool?.subscription.bind(t.pool)||e?.subscriptionMethod||e?.pool?.subscription.bind(e.pool);if(!n)throw new Error("Missing subscriptionMethod, either pass a method or set subscriptionMethod globally on the class");const r=t.publishMethod||t.pool?.publish.bind(t.pool)||e?.publishMethod||e?.pool?.publish.bind(e.pool);if(!r)throw new Error("Missing publishMethod, either pass a method or set publishMethod globally on the class");return{subscriptionMethod:n,publishMethod:r}}(e,t);this.subscriptionMethod=(t,e)=>n(t,e),this.publishMethod=(t,e)=>r(t,e),e.onAuth&&(this.onAuth=e.onAuth),this.signer=e?.signer||new oz,this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)},this.nip44={encrypt:this.nip44Encrypt.bind(this),decrypt:this.nip44Decrypt.bind(this)}}req;async open(){if(this.listening)return;this.listening=!0;const t=await this.signer.getPublicKey();this.req=DA(this.subscriptionMethod(this.relays,[{kinds:[cR.NostrConnect],"#p":[t]}])).pipe(RO(),TO(),dO(t=>"string"!=typeof t)).subscribe(this.handleEvent.bind(this)),this.log("Opened",this.relays)}async close(){this.listening=!1,this.isConnected=!1,this.req&&(this.req.unsubscribe(),this.req=void 0),this.waitingPromise&&(this.waitingPromise.reject(new Error("Closed")),this.waitingPromise=null),this.log("Closed")}requests=new Map;auths=new Set;async handleEvent(t){if(this.verifyEvent(t)&&(!this.remote||t.pubkey===this.remote))try{const n=gM(t)??(function(t){const e=t.length;return!(e<28)&&"?"==t[e-28]&&"i"==t[e-27]&&"v"==t[e-26]&&"="==t[e-25]}(t.content)?await this.signer.nip04.decrypt(t.pubkey,t.content):await this.signer.nip44.decrypt(t.pubkey,t.content));if(!n)return;const r=JSON.parse(n);if(!this.remote&&("ack"===r.result||this.connectSecret&&r.result===this.connectSecret))return this.log("Got ack response from",t.pubkey,r.result),this.isConnected=!0,this.remote=t.pubkey,this.waitingPromise?.resolve(),void(this.waitingPromise=null);if(r.id){const t=this.requests.get(r.id);if(!t)return;if(r.error)if(this.log("Got Error",r.id,r.result,r.error),"auth_url"===r.result){if(!this.auths.has(r.id)&&(this.auths.add(r.id),this.onAuth))try{await this.onAuth(r.error)}catch(e){t.reject(e)}}else t.reject(new Error(r.error));else r.result&&(this.log("Got Response",r.id,r.result),t.resolve(r.result))}}catch(e){}}async createRequestEvent(t,e=this.remote,n=cR.NostrConnect){if(!e)throw new Error("Missing target pubkey");return await this.signer.signEvent({kind:n,created_at:BI(),tags:[["p",e]],content:t})}async makeRequest(t,e,n=cR.NostrConnect){if(!this.remote)throw new Error("Missing remote signer pubkey");const r=$I(8),i={id:r,method:t,params:e},s=await this.signer.nip44.encrypt(this.remote,JSON.stringify(i)),o=await this.createRequestEvent(s,this.remote,n);this.log(`Sending ${r} (${t}) ${JSON.stringify(e)}`);const a=EN();this.requests.set(r,a);const l=this.publishMethod?.(this.relays,o);return l instanceof Promise?await l:"subscribe"in l&&await new Promise(t=>l.subscribe({complete:t})),this.log(`Sent ${r} (${t})`),a}async connect(t,e){if(!this.remote&&this.pubkey&&(this.remote=this.pubkey),!this.remote)throw new Error("Missing remote signer pubkey");await this.open();try{void 0!==t&&(this.bunkerSecret=t);const n=await this.makeRequest(ez.Connect,[this.remote,this.bunkerSecret||"",e?.join(",")??""]);return this.isConnected=!0,n}catch(n){throw this.isConnected=!1,this.close(),n}}waitingPromise=null;waitForSigner(t){return this.isConnected?Promise.resolve():(this.open(),this.waitingPromise=EN(),t?.addEventListener("abort",()=>{this.waitingPromise?.reject(new Error("Aborted")),this.waitingPromise=null,this.close()},!0),this.waitingPromise)}async createAccount(t,e,n,r){if(!this.remote)throw new Error("Remote pubkey must be set");await this.open();try{const i=await this.makeRequest(ez.CreateAccount,[t,e,n??"",r?.join(",")??""]);return this.pubkey=i,this.isConnected=!0,i}catch(i){throw this.isConnected=!1,this.close(),i}}async requireConnection(){this.isConnected||await this.connect()}async getPublicKey(){if(this.pubkey)return this.pubkey;await this.requireConnection();const t=await this.makeRequest(ez.GetPublicKey,[]);if(!iM(t))throw new Error("Remote signer returned an invalid public key");return t}async signEvent(t){await this.requireConnection();const e=await this.makeRequest(ez.SignEvent,[JSON.stringify(t)]),n=JSON.parse(e);if(!this.verifyEvent(n))throw new Error("Invalid event");return n}async nip04Encrypt(t,e){return await this.requireConnection(),this.makeRequest(ez.Nip04Encrypt,[t,e])}async nip04Decrypt(t,e){await this.requireConnection();const n=await this.makeRequest(ez.Nip04Decrypt,[t,e]);return n.startsWith('["')&&n.endsWith('"]')?JSON.parse(n)[0]:n}async nip44Encrypt(t,e){return await this.requireConnection(),this.makeRequest(ez.Nip44Encrypt,[t,e])}async nip44Decrypt(t,e){await this.requireConnection();const n=await this.makeRequest(ez.Nip44Decrypt,[t,e]);return n.startsWith('["')&&n.endsWith('"]')?JSON.parse(n)[0]:n}async ping(){return await this.requireConnection(),this.makeRequest(ez.Ping,[])}async switchRelays(){await this.requireConnection();const t=await this.makeRequest(ez.SwitchRelays,[]);return null!==t&&Array.isArray(t)&&t.length>0&&(this.log("Switching relays from",this.relays,"to",t),this.relays=t,this.listening&&(await this.close(),await this.open())),t}async logout(){try{this.isConnected&&this.remote&&await this.makeRequest(ez.Logout,[])}catch(Z4){this.log("Failed to send logout request",Z4)}finally{this.isConnected=!1,await this.close()}}getNostrConnectURI(t){return function(t){const e=new URLSearchParams,n=t.connectSecret??t.secret;if(!n)throw new Error("Invalid nostrconnect URI: missing secret");e.set("secret",n),t.metadata?.name&&e.set("name",t.metadata.name),t.metadata?.url&&e.set("url",String(t.metadata.url)),t.metadata?.image&&e.set("image",t.metadata.image),t.metadata?.permissions&&e.set("perms",t.metadata.permissions.join(","));for(const r of t.relays)e.append("relay",r);return`nostrconnect://${t.client}?`+e.toString()}({client:vI(this.signer.key),connectSecret:this.connectSecret,relays:this.relays,metadata:t})}getNbunksec(){if(!this.remote)throw new Error("Cant create nbunksec when remote signer is not set");return sz({remote:this.remote,clientKey:Tk(this.signer.key),relays:this.relays,bunkerSecret:this.bunkerSecret})}static parseBunkerURI(t){return function(t){const e=new URL(t),n=e.host||e.pathname.replace("//","");if(!iM(n))throw new Error("Invalid bunker URI: remote is not a valid hex key");const r=e.searchParams.getAll("relay");if(0===r.length)throw new Error("Invalid bunker URI: missing relays");const i=e.searchParams.get("secret")??void 0;return{remote:n,relays:r,secret:i,bunkerSecret:i}}(t)}static parseNbunksec(t){return function(t){const e=function(t){try{const{prefix:e,words:n}=nz.decode(t,!1);if("nbunksec"!==e)throw new Error(`Invalid prefix: ${e}`);const r=nz.fromWords(n);let i=0;const s={pubkey:"",local_key:"",relays:[]};for(;i`${tz.SignEvent}:${t}`)]}(t)}static async fromBunkerURI(e,n){const{remote:r,relays:i,bunkerSecret:s}=t.parseBunkerURI(e),o=new t({relays:i,remote:r,bunkerSecret:s,...n});return await o.connect(s,n?.permissions),o}static async fromNbunksec(e,n){const{remote:r,clientKey:i,relays:s,bunkerSecret:o}=t.parseNbunksec(e),a=new t({relays:s,remote:r,signer:new oz(Lk(i)),bunkerSecret:o,...n});return await a.connect(o,n?.permissions),a}},cz=Object.freeze({p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,h:1n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n}),{p:uz,n:hz,Gx:dz,Gy:pz,b:fz}=cz,gz={publicKey:33,publicKeyUncompressed:65,signature:64,seed:48},mz=(t="",e=Error)=>{const n=new e(t),{captureStackTrace:r}=Error;throw"function"==typeof r&&r(n,mz),n},yz=(t,e,n="")=>{const r=(i=t)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name&&1===i.BYTES_PER_ELEMENT;var i;const s=t?.length,o=void 0!==e;return!r||o&&s!==e?mz((n&&`"${n}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(r?`length=${s}`:"type="+typeof t),r?RangeError:TypeError):t},vz=t=>new Uint8Array(t),bz=(t,e)=>t.toString(16).padStart(e,"0"),wz=t=>{let e="";for(const n of yz(t))e+=bz(n,2);return e},_z=t=>t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0,xz=t=>{const e="hex invalid";if("string"!=typeof t)return mz(e);const n=t.length,r=n/2;if(n%2)return mz(e);const i=vz(r);for(let s=0,o=0;s{let e=0;for(const i of t)e+=yz(i).length;const n=vz(e);let r=0;for(const i of t)n.set(i,r),r+=i.length;return n},kz=BigInt,Sz=(t,e,n,r="bad number: out of range")=>"bigint"!=typeof t?mz(r,TypeError):e<=t&&t{const n=t%e;return n>=0n?n:e+n},Rz=t=>t instanceof Az?t:mz("Point expected"),Tz=t=>Ez(Ez(t*t)*t+fz),Lz=t=>Sz(t,0n,uz),Pz=t=>Sz(t,1n,uz),Iz=t=>!(1n&t),Mz=t=>Uint8Array.of(t),Az=class t{static BASE;static ZERO;X;Y;Z;constructor(t,e,n){this.X=Lz(t),this.Y=Pz(e),this.Z=Lz(n),Object.freeze(this)}static CURVE(){return cz}static fromAffine(e){const{x:n,y:r}=e;return 0n===n&&0n===r?Fz:new t(n,r,1n)}static fromBytes(e){yz(e);const{publicKey:n,publicKeyUncompressed:r}=gz;let i;const s=e.length,o=e[0],a=e.subarray(1),l=Nz(a,0,32);if(s===n&&(2===o||3===o)){let e=(t=>{const e=Tz(Pz(t));let n=1n;for(let r=e,i=(uz+1n)/4n;i>0n;i>>=1n)1n&i&&(n=n*r%uz),r=r*r%uz;return Ez(n*n)!==e&&mz("sqrt invalid"),Iz(n)?n:Ez(-n)})(l);3===o&&(e=Ez(-e)),i=new t(l,e,1n)}return s===r&&4===o&&(i=new t(l,Nz(a,32,64),1n)),i?i.assertValidity():mz("bad point: not on curve")}static fromHex(e){return t.fromBytes(xz(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}equals(t){const{X:e,Y:n,Z:r}=this,{X:i,Y:s,Z:o}=Rz(t),a=Ez(e*o),l=Ez(i*r),c=Ez(n*o),u=Ez(s*r);return a===l&&c===u}is0(){return this.equals(Fz)}negate(){return new t(this.X,Ez(-this.Y),this.Z)}double(){return this.add(this)}add(e){const{X:n,Y:r,Z:i}=this,{X:s,Y:o,Z:a}=Rz(e);let l=0n,c=0n,u=0n;const h=Ez(3n*fz);let d=Ez(n*s),p=Ez(r*o),f=Ez(i*a),g=Ez(n+r),m=Ez(s+o);g=Ez(g*m),m=Ez(d+p),g=Ez(g-m),m=Ez(n+i);let y=Ez(s+a);return m=Ez(m*y),y=Ez(d+f),m=Ez(m-y),y=Ez(r+i),l=Ez(o+a),y=Ez(y*l),l=Ez(p+f),y=Ez(y-l),u=Ez(0n*m),l=Ez(h*f),u=Ez(l+u),l=Ez(p-u),u=Ez(p+u),c=Ez(l*u),p=Ez(d+d),p=Ez(p+d),f=Ez(0n*f),m=Ez(h*m),p=Ez(p+f),f=Ez(d-f),f=Ez(0n*f),m=Ez(m+f),d=Ez(p*m),c=Ez(c+d),d=Ez(y*m),l=Ez(g*l),l=Ez(l-d),d=Ez(g*p),u=Ez(y*u),u=Ez(u+d),new t(l,c,u)}subtract(t){return this.add(Rz(t).negate())}multiply(t,e=!0){if(!e&&0n===t)return Fz;if((t=>{Sz(t,1n,hz)})(t),1n===t)return this;if(this.equals(Oz))return $z(t).p;let n=Fz,r=Oz;for(let i=this;t>0n;i=i.double(),t>>=1n)1n&t?n=n.add(i):e&&(r=r.add(i));return n}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:e,Z:n}=this;if(this.equals(Fz))return{x:0n,y:0n};if(1n===n)return{x:t,y:e};const r=((t,e)=>{(0n===t||e<=0n)&&mz("no inverse n="+t+" mod="+e);let n=Ez(t,e),r=e,i=0n,s=1n,o=1n,a=0n;for(;0n!==n;){const t=r/n,e=r%n,l=i-o*t,c=s-a*t;r=n,n=e,i=o,s=a,o=l,a=c}return 1n===r?Ez(i,e):mz("no inverse")})(n,uz);return 1n!==Ez(n*r)&&mz("inverse invalid"),{x:Ez(t*r),y:Ez(e*r)}}assertValidity(){const{x:t,y:e}=this.toAffine();return Pz(t),Pz(e),Ez(e*e)===Tz(t)?this:mz("bad point: not on curve")}toBytes(t=!0){const{x:e,y:n}=this.assertValidity().toAffine(),r=Dz(e);return t?Cz((t=>Mz(Iz(t)?2:3))(n),r):Cz(Mz(4),r,Dz(n))}toHex(t){return wz(this.toBytes(t))}},Oz=new Az(dz,pz,1n),Fz=new Az(0n,1n,0n);Az.BASE=Oz,Az.ZERO=Fz;var Nz=(t,e,n)=>(t=>kz("0x"+(wz(t)||"0")))(t.subarray(e,n)),zz=2n**256n,Dz=t=>xz(bz(Sz(t,0n,zz),64)),jz=Math.ceil(32)+1,Uz=void 0,Bz=(t,e)=>{const n=e.negate();return t?n:e},$z=t=>{const e=Uz||(Uz=(()=>{const t=[];let e=Oz,n=e;for(let r=0;r>=s,a>128&&(a-=256,t+=1n);const l=128*o,c=l,u=l+Math.abs(a)-1,h=o%2!=0,d=a<0;0===a?r=r.add(Bz(h,e[c])):n=n.add(Bz(d,e[u]))}return 0n!==t&&mz("invalid wnaf"),{p:n,f:r}};function qz(t){return Az.fromHex(t).toHex().substring(2)}var Vz=new TextDecoder("utf-8"),Wz=new TextEncoder;function Hz(t){return btoa(String.fromCharCode(...t))}function Gz(t){return new Uint8Array(atob(t).split("").map(t=>t.charCodeAt(0)))}(class t{log=$O.extend("SerialPortSigner");writer=null;pubkey;get isConnected(){return!!this.writer}verifyEvent=wI;nip04;constructor(){this.nip04={encrypt:this.nip04Encrypt.bind(this),decrypt:this.nip04Decrypt.bind(this)}}lastCommand=null;async callMethodOnDevice(e,n,r={}){if(!t.SUPPORTED)throw new Error("Serial devices are not supported");if(this.writer||await this.connectToDevice(r),this.lastCommand)throw new Error("Previous command to device still pending!");const i=EN();return this.lastCommand=i,this.sendCommand(e,n),setTimeout(()=>{i.reject(new Error("Device timeout")),this.lastCommand===i&&(this.lastCommand=null)},6e3),this.lastCommand}async connectToDevice({onConnect:e,onDisconnect:n,onError:r,onDone:i}){let s,o=await window.navigator.serial.requestPort();await o.open({baudRate:9600}),await new Promise(t=>setTimeout(t,1e3)),(async()=>{for(;o&&o.readable;){const e=new window.TextDecoderStream;o.readable.pipeTo(e.writable),s=e.readable.getReader();const n=this.readFromSerialPort(s);try{for(;;){const{value:e,done:r}=await n("\n");if(e){const{method:n,data:r}=this.parseResponse(e);if("/ping"===n&&this.log("Pong"),-1===t.PUBLIC_METHODS.indexOf(n))continue;this.log("Received: ",n,r),this.lastCommand&&(this.lastCommand.resolve(r),this.lastCommand=null)}if(r)return this.lastCommand=null,this.writer=null,void(i&&i())}}catch(Z4){if(Z4 instanceof Error)throw this.writer=null,r&&r(Z4),this.lastCommand&&(this.lastCommand.reject(Z4),this.lastCommand=null),Z4}}})();const a=new window.TextEncoderStream;a.readable.pipeTo(o.writable),this.writer=a.writable.getWriter(),await this.sendCommand(t.METHOD_PING),await this.sendCommand(t.METHOD_PING,[window.location.host]),e&&e(),o.addEventListener("disconnect",()=>{this.log("Disconnected"),this.lastCommand=null,this.writer=null,n&&n()})}async sendCommand(t,e=[]){if(!this.writer)return;this.log("Send command",t,e);const n=[t].concat(e).join(" ");await this.writer.write(n+"\n")}readFromSerialPort(t){let e,n=[];return async(r="\n")=>{if(n.length)return{value:n.shift().trim(),done:!1};const i=[];for(e&&(i.push(e),e=void 0);;){const{value:s,done:o}=await t.read();if(s){const t=s.split(r);if(t.length>1)return i.push(t.shift()),e=t.pop(),n=t,{value:i.join("").trim(),done:!1};i.push(s)}if(o)return{value:i.join("").trim(),done:!0}}}}parseResponse(t){const e=t.split(" ")[0];return{method:e,data:t.substring(e.length).trim()}}async nip04Encrypt(e,n){const r=Lk(await this.callMethodOnDevice(t.METHOD_SHARED_SECRET,[qz(e)]));let i=Uint8Array.from(window.crypto.getRandomValues(new Uint8Array(16))),s=Wz.encode(n),o=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-CBC",iv:i},o,s);return`${Hz(new Uint8Array(a))}?iv=${Hz(new Uint8Array(i.buffer))}`}async nip04Decrypt(e,n){let[r,i]=n.split("?iv=");const s=Lk(await this.callMethodOnDevice(t.METHOD_SHARED_SECRET,[qz(e)]));let o=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),a=Gz(r),l=Gz(i),c=await crypto.subtle.decrypt({name:"AES-CBC",iv:l},o,a);return Vz.decode(c)}async getPublicKey(){const e=await this.callMethodOnDevice(t.METHOD_PUBLIC_KEY,[]);return this.pubkey=e,e}async restore(e){await this.callMethodOnDevice(t.METHOD_RESTORE,[Tk(e)])}async signEvent(e){const n=e.pubkey||this.pubkey;if(!n)throw new Error("Unknown signer pubkey");const r={...e,id:gI({...e,pubkey:n})},i=await this.callMethodOnDevice(t.METHOD_SIGN_MESSAGE,[r.id]),s={...r,sig:i,pubkey:n};if(!this.verifyEvent(s))throw new Error("Invalid signature");return s}ping(){this.sendCommand(t.METHOD_PING,[window.location.host])}static SUPPORTED="navigator"in globalThis&&!!navigator.serial;static METHOD_PING="/ping";static METHOD_LOG="/log";static METHOD_SIGN_MESSAGE="/sign-message";static METHOD_SHARED_SECRET="/shared-secret";static METHOD_PUBLIC_KEY="/public-key";static METHOD_RESTORE="/restore";static PUBLIC_METHODS=[t.METHOD_PUBLIC_KEY,t.METHOD_SIGN_MESSAGE,t.METHOD_SHARED_SECRET,t.METHOD_RESTORE]});var Kz=a({isMobile:()=>Zz});function Zz(){return"undefined"!=typeof navigator&&/Mobi|Android|iPhone|iPad/i.test(navigator.userAgent)}var Yz,Xz,Jz=a({default:()=>sD}),Qz="marco:nostr_pubkey",tD="marco:nostr_signer_type",eD="marco:nostr_connect_local_key",nD="marco:nostr_connect_remote_pubkey",rD="marco:nostr_connect_relay",iD="wss://nostr.kosmos.org",sD=class extends dp{static{oN(this.prototype,"nostrRelay",[hp])}#it=void lN(this,"nostrRelay");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"pubkey",[qr],function(){return null})}#st=void lN(this,"pubkey");static{oN(this.prototype,"signerType",[qr],function(){return null})}#ot=void lN(this,"signerType");static{oN(this.prototype,"connectStatus",[qr],function(){return null})}#at=void lN(this,"connectStatus");static{oN(this.prototype,"connectUri",[qr],function(){return null})}#lt=void lN(this,"connectUri");_signerInstance=null;constructor(){super(...arguments),"undefined"!=typeof localStorage&&(localStorage.debug="applesauce:*");const t=localStorage.getItem(Qz),e=localStorage.getItem(tD);t&&(this.pubkey=t,this.signerType=e||"extension",this._verifyPubkey())}async _verifyPubkey(){if("extension"===this.signerType){if(void 0===window.nostr)return void this.disconnect();try{const t=await(new TN).getPublicKey();t!==this.pubkey&&(this.pubkey=t,localStorage.setItem(Qz,this.pubkey)),this.nostrData.loadProfile(this.pubkey)}catch(t){console.warn("Failed to verify extension nostr pubkey, logging out",t),this.disconnect()}}else if("connect"===this.signerType)try{await this._initConnectSigner()}catch(t){console.warn("Failed to verify connect nostr pubkey, logging out",t),this.disconnect()}}get isMobile(){return Zz()}get isConnected(){return!!this.pubkey&&("extension"!==this.signerType||void 0!==window.nostr)}get signer(){return this._signerInstance?this._signerInstance:"extension"===this.signerType&&void 0!==window.nostr?new TN:(this.signerType,null)}async connectWithExtension(){if(void 0===window.nostr)throw new Error("No NIP-07 Nostr extension found (e.g., Alby, nos2x).");try{return this._signerInstance=new TN,this.pubkey=await this._signerInstance.getPublicKey(),this.signerType="extension",localStorage.setItem(Qz,this.pubkey),localStorage.setItem(tD,"extension"),this.nostrData.loadProfile(this.pubkey),this.pubkey}catch(Z4){throw console.error("Failed to get public key from extension:",Z4),Z4}}_getLocalSigner(){let t,e=localStorage.getItem(eD);return e?t=oz.fromKey(e):(t=new oz,e=Array.from(t.key).map(t=>t.toString(16).padStart(2,"0")).join(""),localStorage.setItem(eD,e)),t}async connectWithApp(){this.connectStatus="waiting";try{const e=this._getLocalSigner(),n=iD;localStorage.setItem(rD,n),this._signerInstance=new lz({pool:this.nostrRelay.pool,relays:[n],signer:e,onAuth:async t=>{confirm(`Your signer app requests authentication via a web page. Open it now?\n\nURL: ${t}`)&&window.open(t,"_blank")}}),this.connectUri=this._signerInstance.getNostrConnectURI({name:"Marco",url:window.location.origin,description:"An unhosted maps application.",icons:[]}),this.isMobile&&(console.debug("Mobile detected, triggering deep link intent."),window.location.href=this.connectUri),console.debug("Opening signer connection to relay..."),await this._signerInstance.open(),console.debug("Signer connection opened successfully."),console.debug("Waiting for remote signer to ack via relay...");try{await this._signerInstance.waitForSigner(),console.debug("Remote signer ack received!")}catch(t){throw console.error("Error while waiting for remote signer ack:",t),t}return this.pubkey=await this._signerInstance.getPublicKey(),this.signerType="connect",this.connectStatus="connected",localStorage.setItem(Qz,this.pubkey),localStorage.setItem(tD,"connect"),localStorage.setItem(nD,this._signerInstance.remote),this.nostrData.loadProfile(this.pubkey),this.pubkey}catch(Z4){throw this.connectStatus=null,console.error("Failed to connect via Nostr Connect:",Z4),Z4}}async _initConnectSigner(){const t=localStorage.getItem(nD),e=localStorage.getItem(rD)||iD;if(!t)throw new Error("Missing Nostr Connect remote pubkey.");const n=this._getLocalSigner();if(this._signerInstance=new lz({pool:this.nostrRelay.pool,relays:[e],signer:n,remote:t,onAuth:async t=>{confirm(`Your signer app requests authentication via a web page. Open it now?\n\nURL: ${t}`)&&window.open(t,"_blank")}}),await this._signerInstance.open(),await this._signerInstance.getPublicKey()!==this.pubkey)throw new Error("Remote signer pubkey mismatch");this.nostrData.loadProfile(this.pubkey)}async signEvent(t){if(!this.signer)throw new Error("Not connected or extension missing. Please connect Nostr again.");return await this.signer.signEvent(t)}async disconnect(){this.pubkey=null,this.nostrData?.loadProfile(null),this.signerType=null,this.connectStatus=null,this.connectUri=null,this._signerInstance&&"function"==typeof this._signerInstance.close&&await this._signerInstance.close(),this._signerInstance=null,localStorage.removeItem(Qz),localStorage.removeItem(tD),localStorage.removeItem(eD),localStorage.removeItem(nD),localStorage.removeItem(rD)}},oD=(t,e)=>e.some(e=>t instanceof e),aD=new WeakMap,lD=new WeakMap,cD=new WeakMap,uD={get(t,e,n){if(t instanceof IDBTransaction){if("done"===e)return aD.get(t);if("store"===e)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return dD(t[e])},set:(t,e,n)=>(t[e]=n,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function hD(t){uD=t(uD)}function dD(t){if(t instanceof IDBRequest)return function(t){const e=new Promise((e,n)=>{const r=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{e(dD(t.result)),r()},s=()=>{n(t.error),r()};t.addEventListener("success",i),t.addEventListener("error",s)});return cD.set(e,t),e}(t);if(lD.has(t))return lD.get(t);const e=function(t){return"function"==typeof t?(e=t,(Xz||(Xz=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(pD(this),t),dD(this.request)}:function(...t){return dD(e.apply(pD(this),t))}):(t instanceof IDBTransaction&&function(t){if(aD.has(t))return;const e=new Promise((e,n)=>{const r=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{e(),r()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)});aD.set(t,e)}(t),oD(t,Yz||(Yz=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(t,uD):t);var e}(t);return e!==t&&(lD.set(t,e),cD.set(e,t)),e}var pD=t=>cD.get(t),fD=["get","getKey","getAll","getAllKeys","count"],gD=["put","add","delete","clear"],mD=new Map;function yD(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(mD.get(e))return mD.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,i=gD.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!fD.includes(n))return;const s=async function(t,...e){const s=this.transaction(t,i?"readwrite":"readonly");let o=s.store;return r&&(o=o.index(e.shift())),(await Promise.all([o[n](...e),i&&s.done]))[0]};return mD.set(e,s),s}hD(t=>({...t,get:(e,n,r)=>yD(e,n)||t.get(e,n,r),has:(e,n)=>!!yD(e,n)||t.has(e,n)}));var vD=["continue","continuePrimaryKey","advance"],bD={},wD=new WeakMap,_D=new WeakMap,xD={get(t,e){if(!vD.includes(e))return t[e];let n=bD[e];return n||(n=bD[e]=function(...t){wD.set(this,_D.get(this)[e](...t))}),n}};async function*CD(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;const n=new Proxy(e,xD);for(_D.set(n,e),cD.set(n,pD(e));e;)yield n,e=await(wD.get(n)||e.continue()),wD.delete(n)}function kD(t,e){return e===Symbol.asyncIterator&&oD(t,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===e&&oD(t,[IDBIndex,IDBObjectStore])}function SD(t){return 0===t||3===t||t>=1e4&&t<2e4}function ED(t){return t>=3e4&&t<4e4}function RD(t){return t>=2e4&&t<3e4}hD(t=>({...t,get:(e,n,r)=>kD(e,n)?CD:t.get(e,n,r),has:(e,n)=>kD(e,n)||t.has(e,n)}));var TD=Symbol.for("indexable-tags");function LD(t,e){if(t.ids&&-1===t.ids.indexOf(e.id))return!1;if(t.kinds&&-1===t.kinds.indexOf(e.kind))return!1;if(t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;if(t.since&&e.created_att.until)return!1;const n=function(t){let e=Reflect.get(t,TD);if(!e){e=new Set;for(const n of t.tags)n.length>=2&&1===n[0].length&&e.add(n[0]+":"+n[1]);Reflect.set(t,TD,e)}return e}(e);for(const r in t)if("&"===r[0]){const e=r.slice(1),i=t[r];if(i&&i.length>0)for(const t of i)if(!n.has(e+":"+t))return!1}for(const r in t)if("#"===r[0]){const e=r.slice(1),i=t[r];if(i){const r=t[`&${e}`],s=r?i.filter(t=>!r.includes(t)):i;if(0===s.length)continue;if(!s.some(t=>n.has(e+":"+t)))return!1}}return!0}function PD(t,e){for(let n=0;nt.length>=2&&1===t[0].length&&MD.includes(t[0])).map(t=>t[0]+t[1])}function FD(t){if(Reflect.has(t,AD))return Reflect.get(t,AD);let e;if(SD(t.kind)||ED(t.kind)){const n=t.tags.find(t=>"d"===t[0])?.[1];e=t.kind+":"+t.pubkey+":"+(n??"")}else e=t.id;return Reflect.set(t,AD,e),e}async function ND(t="nostr-idb",e){return await function(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(t,e),a=dD(o);return r&&o.addEventListener("upgradeneeded",t=>{r(dD(o.result),t.oldVersion,t.newVersion,dD(o.transaction),t)}),n&&o.addEventListener("blocked",t=>n(t.oldVersion,t.newVersion,t)),a.then(t=>{s&&t.addEventListener("close",()=>s()),i&&t.addEventListener("versionchange",t=>i(t.oldVersion,t.newVersion,t))}).catch(()=>{}),a}(t,3,{...e,async upgrade(t,n,r,i,s){if(0===n){const e=t.createObjectStore("events");e.createIndex("id","event.id",{unique:!0}),e.createIndex("pubkey","event.pubkey"),e.createIndex("kind","event.kind"),e.createIndex("created_at","event.created_at"),e.createIndex("tags","tags",{multiEntry:!0}),t.createObjectStore("used",{keyPath:"uid"}).createIndex("date","date")}1===n&&(t.deleteObjectStore("events"),t.deleteObjectStore("used"),t.deleteObjectStore("seen")),n<=2&&await async function(t){const e=t.objectStore("events");let n=await e.openCursor();const r=[];for(;n;){const t=n.primaryKey,e=n.value,i=e.event;if(SD(i.kind)||ED(i.kind)){const n=FD(i);t!==n&&r.push({oldKey:t,newKey:n,value:e})}n=await n.continue()}for(const{oldKey:i,newKey:s,value:o}of r)await e.delete(i),await e.put(o,s)}(i),e?.upgrade&&e.upgrade(t,n,r,i,s)}})}function zD(t,e){return e.created_at-t.created_at}var DD=a({countEventsForFilters:()=>KD,getEventsForFilters:()=>GD,getIdsForFilter:()=>WD,getIdsForFilters:()=>HD,queryForKinds:()=>qD,queryForPubkeys:()=>jD,queryForTag:()=>UD,queryForTagAnd:()=>BD,queryForTime:()=>VD});function jD(t,e=[],n){const r=[],i=new Set;if(n)for(const l of e){const t=n.getPubkeyIndex(l);if(t){for(const e of t)i.add(e);r.push(l)}}if(r.length===e.length)return Promise.resolve(i);const s=t.transaction("events","readonly"),o=s.objectStore("events").index("pubkey"),a=e.filter(t=>!r.includes(t)).map(t=>o.getAllKeys(t).then(e=>((t,e)=>{for(const n of e)i.add(n);n&&n.setPubkeyIndex(t,new Set(e))})(t,e)));return s.commit(),Promise.all(a).then(()=>i)}function UD(t,e,n,r){const i=[],s=new Set;if(r)for(const c of n){const t=r.getTagIndex(e+c);if(t){for(const e of t)s.add(e);i.push(c)}}if(i.length===n.length)return Promise.resolve(s);const o=t.transaction("events","readonly"),a=o.objectStore("events").index("tags"),l=n.map(t=>a.getAllKeys(e+t).then(n=>((t,n)=>{for(const e of n)s.add(e);r&&r.setTagIndex(e+t,new Set(n))})(t,n)));return o.commit(),Promise.all(l).then(()=>s)}function BD(t,e,n,r){if(0===n.length)return Promise.resolve(new Set);if(1===n.length)return UD(t,e,n,r);const i=[],s=[];if(r)for(const c of n){const t=r.getTagIndex(e+c);t&&(s.push(t),i.push(c))}if(i.length===n.length)return Promise.resolve($D(s));const o=t.transaction("events","readonly"),a=o.objectStore("events").index("tags"),l=n.filter(t=>!i.includes(t)).map(t=>a.getAllKeys(e+t).then(n=>((t,n)=>{const i=new Set(n);s.push(i),r&&r.setTagIndex(e+t,i)})(t,n)));return o.commit(),Promise.all(l).then(()=>$D(s))}function $D(t){if(0===t.length)return new Set;const e=t.slice().sort((t,e)=>t.size-e.size);let n=e[0];for(let r=1;r!r.includes(t)).map(t=>o.getAllKeys(t).then(e=>((t,e)=>{for(const n of e)i.add(n);n&&n.setKindIndex(t,new Set(e))})(t,e)));return s.commit(),Promise.all(a).then(()=>i)}async function VD(t,e,n){let r;if(void 0!==e&&void 0!==n)r=IDBKeyRange.bound(e,n);else if(void 0!==e)r=IDBKeyRange.lowerBound(e);else{if(void 0===n)throw new Error("Missing since or until");r=IDBKeyRange.upperBound(n)}return(await t.getAllKeysFromIndex("events","created_at",r)).reverse()}async function WD(t,e,n){if(e.search)return new Set;if(e.ids)return new Set(e.ids);let r=null;const i=t=>{const e=t instanceof Set?t:new Set(t);if(r)for(const n of r)e.has(n)||r.delete(n);else r=e;return r};let s=null;void 0!==e.since&&(s=await VD(t,e.since,e.until),i(s));for(const o of MD){const r=e[`&${o}`],s=e[`#${o}`];if(r?.length&&i(await BD(t,o,r,n)),s?.length){const e=r?.length?s.filter(t=>!r.includes(t)):s;e.length>0&&i(await UD(t,o,e,n))}}if(e.authors&&i(await jD(t,e.authors,n)),e.kinds&&i(await qD(t,e.kinds,n)),void 0===e.since&&void 0!==e.until&&(s=await VD(t,e.since,e.until),i(s)),e.limit&&s){const t=new Set;for(const n of s){if(t.size>=e.limit)break;r.has(n)&&t.add(n)}return t}if(null===r)throw new Error("Empty filter");return r}async function HD(t,e,n){if(0===e.length)throw new Error("No Filters");let r=new Set;for(const i of e){const e=await WD(t,i,n);for(const t of e)r.add(t)}return r}async function GD(t,e,n,r){const i=await HD(t,e,n);return await async function(t,e,n,r){const i=[];let s=[];if(r)for(const d of e){const t=r.get(d);t?i.push(t):s.push(d)}else s=e;const o=t.transaction("events","readonly"),a=o.objectStore("events"),l=t=>t&&i.push(t.event),c=Array.from(s).map(t=>a.get(t).then(l));o.commit();const u=await Promise.all(c).then(()=>i.sort(zD));let h=1/0;for(const d of n)d.limit&&d.limith&&(u.length=h),u}(t,Array.from(i),e,r)}async function KD(t,e,n){return(await HD(t,e,n)).size}var ZD=BO.default("nostr-idb"),YD=ZD.extend("prune");async function XD(t,e,n){const r=t.transaction("events","readwrite"),i=r.objectStore("events"),s=await i.get(e);if(!s)return await r.commit(),!1;if(await i.delete(e),await r.commit(),n){const t=s.event;n.removeEvent(t)}return!0}var JD=ZD.extend("WriteQueue"),QD=class{db;queuedIds=new Set;eventQueue=[];lastUsedQueue=new Set;processEvents=null;constructor(t){this.db=t}addEvent(t){const e=FD(t);this.queuedIds.has(e)||(this.eventQueue.push(t),this.queuedIds.add(e),this.touch(t))}addEvents(t){const e=t.filter(t=>!this.queuedIds.has(FD(t)));if(0!==e.length){this.eventQueue.push(...e);for(const t of e)this.queuedIds.add(FD(t));this.touch(e)}}touch(t){if(Array.isArray(t))for(const e of t)this.lastUsedQueue.add(FD(e));else this.lastUsedQueue.add(FD(t))}matchPending(t){return this.eventQueue.filter(e=>PD(t,e))}async flush(t=1e3){if(this.eventQueue.length>0){let e=[];for(let n=0;nfunction(t){if("object"!=typeof t||null===t)return!1;if("number"!=typeof t.kind)return!1;if("string"!=typeof t.content)return!1;if("number"!=typeof t.created_at)return!1;if("string"!=typeof t.id)return!1;if(!/^[a-f0-9]{64}$/.test(t.id))return!1;if("string"!=typeof t.pubkey)return!1;if(!/^[a-f0-9]{64}$/.test(t.pubkey))return!1;if(!Array.isArray(t.tags))return!1;for(const e of t.tags){if(!Array.isArray(e))return!1;for(const t of e)if("string"!=typeof t)return!1}return!0}(t))).filter(t=>SD(t.kind)||ED(t.kind)),r={};if(n.length>0){const e=t.transaction("events","readonly"),i=n.map(t=>{const n=FD(t);return e.store.get(n).then(t=>t&&(r[n]=t.event.created_at))});e.commit(),await Promise.all(i)}const i=t.transaction("events","readwrite");for(const s of e){const t=FD(s);(!r[t]||s.created_at>r[t])&&i.objectStore("events").put({event:s,tags:OD(s)},t)}await i.commit()}(this.db,e),JD(`Wrote ${e.length} to database`),this.eventQueue.length>0&&JD(`${this.eventQueue.length} left`)}this.lastUsedQueue.size>0&&(await async function(t,e){const n=t.transaction("used","readwrite"),r=Math.floor((new Date).valueOf()/1e3);for(const i of e)n.objectStore("used").put({uid:i,date:r});await n.commit()}(this.db,this.lastUsedQueue),this.lastUsedQueue.clear())}clear(){this.eventQueue=[]}},tj=ZD.extend("cache:indexes"),ej=class extends Set{type;key;constructor(t,e,n){super(t),this.type=e,this.key=n}},nj=class{kinds=new Map;pubkeys=new Map;tags=new Map;get count(){return this.kinds.size+this.pubkeys.size+this.tags.size}max=1e3;lastUsed=[];useIndex(t){const e=this.lastUsed.indexOf(t);-1!==e&&this.lastUsed.splice(e,e+1),this.lastUsed.push(t)}getKindIndex(t){const e=this.kinds.get(t);return e&&this.useIndex(e),e}setKindIndex(t,e){const n=new ej(e,"kind",t);this.kinds.set(t,n),this.useIndex(n),this.pruneIndexes()}getPubkeyIndex(t){const e=this.pubkeys.get(t);return e&&this.useIndex(e),e}setPubkeyIndex(t,e){const n=new ej(e,"pubkey",t);this.pubkeys.set(t,n),this.useIndex(n),this.pruneIndexes()}getTagIndex(t){const e=this.tags.get(t);return e&&this.useIndex(e),e}setTagIndex(t,e){const n=new ej(e,"tag",t);this.tags.set(t,n),this.useIndex(n),this.pruneIndexes()}addEventToIndexes(t){const e=FD(t);this.getKindIndex(t.kind)?.add(e),this.getPubkeyIndex(t.pubkey)?.add(e);const n=OD(t);for(const r of n)this.getTagIndex(r)?.add(e)}removeEvent(t){const e=FD(t);this.getKindIndex(t.kind)?.delete(e),this.getPubkeyIndex(t.pubkey)?.delete(e);const n=OD(t);for(const r of n)this.getTagIndex(r)?.delete(e)}clear(){this.kinds.clear(),this.pubkeys.clear(),this.tags.clear(),this.lastUsed=[]}pruneIndexes(){for(;this.lastUsed.length>0&&this.lastUsed.length>this.max;){const t=this.lastUsed.shift();if(!t)return;switch(tj(`Forgetting ${t.type}:${t.key}`),t.type){case"kind":this.kinds.delete(t.key);break;case"pubkey":this.pubkeys.delete(t.key);break;case"tag":this.tags.delete(t.key)}}}},rj={},ij=function(t,e){let n=Promise.resolve();if(e&&e.length>0){const t=document.getElementsByTagName("link"),i=document.querySelector("meta[property=csp-nonce]"),s=i?.nonce||i?.getAttribute("nonce");r=e.map(e=>{var n;if(n=e=function(t){return"/"+t}(e),(e=import.meta.resolve?import.meta.resolve(n):new URL(n,import.meta.url).href)in rj)return;rj[e]=!0;const r=e.endsWith(".css");for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.href===e&&(!r||"stylesheet"===n.rel))return}const i=document.createElement("link");return i.rel=r?"stylesheet":"modulepreload",r||(i.as="script"),i.crossOrigin="",i.href=e,s&&i.setAttribute("nonce",s),document.head.appendChild(i),r?new Promise((t,n)=>{i.addEventListener("load",t),i.addEventListener("error",()=>n(new Error(`Unable to preload CSS for ${e}`)))}):void 0}),n=Promise.all(r.map(t=>Promise.resolve(t).then(t=>({status:"fulfilled",value:t}),t=>({status:"rejected",reason:t}))))}var r;function i(t){const e=new Event("vite:preloadError",{cancelable:!0});if(e.payload=t,window.dispatchEvent(e),!e.defaultPrevented)throw t}return n.then(e=>{for(const t of e||[])"rejected"===t.status&&i(t.reason);return t().catch(i)})},sj={batchWrite:1e3,writeInterval:100,cacheIndexes:1e3,pruneInterval:6e4,maxEvents:1e4},oj=ZD.extend("nostridb"),aj=class{options;running=!1;writeInterval;pruneInterval;eventMap=new Map;writeQueue=null;indexCache;db=null;baseEoseTimeout=4400;subscriptions=new Map;constructor(t,e={}){this.options={...sj,...e},t&&(this.db=t,this.writeQueue=new QD(t)),this.indexCache=new nj,this.indexCache.max=this.options.cacheIndexes,this.start()}async getDb(){return this.db||(this.db=await ND()),this.db}async getWriteQueue(){if(this.writeQueue)return this.writeQueue;const t=await this.getDb();return this.writeQueue=new QD(t),this.writeQueue}async flush(){await(await this.getWriteQueue()).flush(),this.writeInterval=setTimeout(this.flush.bind(this),this.options.writeInterval)}async start(){if(this.running)return;oj("Starting"),this.running=!0;const t=await this.getDb();await this.flush(),this.pruneInterval=setInterval(()=>{!async function(t,e){const n=await function(t){return t.transaction("events","readonly").store.count()}(t);if(n<=e)return;const r=n-e;if(r<=0)return;YD(`Pruning database to ${e}`);const i=(await t.getAll("used")).sort((t,e)=>t.date-e.date),s=[];let o=r;for(const u of i){if(o<=0)break;const t=u.uid;s.push(t),o--}if(0===s.length)return;const a=t.transaction("events","readwrite"),l=t.transaction("used","readwrite"),c=[];for(const u of s)c.push(a.store.delete(u)),c.push(l.store.delete(u));a.commit(),l.commit(),await Promise.all(c),YD(`Removed ${s.length} old events`)}(t,this.options.maxEvents)},this.options.pruneInterval)}async stop(){this.running&&(this.writeInterval&&(clearTimeout(this.writeInterval),this.writeInterval=void 0),this.pruneInterval&&(clearInterval(this.pruneInterval),this.pruneInterval=void 0),this.running=!1,oj("Stopped"))}async add(t){RD(t.kind)||((await this.getWriteQueue()).addEvent(t),this.indexCache.addEventToIndexes(t));const e=FD(t);if(!this.eventMap.has(e)){RD(t.kind)||this.eventMap.set(e,t);for(const[e,n]of this.subscriptions)n.event&&PD(n.filters,t)&&n.event(t)}return!0}async event(t){return(await(await this.getDb()).get("events",t))?.event}async replaceable(t,e,n){return this.event([t,e,n??""].join(":"))}async count(t){const e=Array.isArray(t)?t:[t],n=await this.getDb();return await KD(n,e)}async query(t){const e=Array.isArray(t)?t:[t],n=await this.getDb(),r=(await this.getWriteQueue()).matchPending(e),i=await GD(n,e,this.indexCache,this.eventMap);this.addToEventMaps(i);const s=new Set(r.map(t=>FD(t)));return r.length>0?[...i.filter(t=>!s.has(FD(t))),...r].sort(zD):i}async*subscribe(t){const e=Array.isArray(t)?t:[t],n=[],r=new Set;let i=null,s=!1;const o=this.subscribeInternal(e,{event:t=>{const e=FD(t);if(!r.has(e)&&(r.add(e),n.push(t),i)){const t=i;i=null,t()}},complete:()=>{if(s=!0,i){const t=i;i=null,t()}}});try{for(;;){for(;n.length>0;)yield n.shift();if(s)break;await new Promise(t=>{i=t})}}finally{o.close()}}async supports(){return[]}async deleteEvent(t){const e=await this.getDb(),n=await XD(e,t,this.indexCache);return this.eventMap.delete(t),n}async deleteReplaceable(t,e,n){const r=await this.getDb(),i=await async function(t,e,n,r,i){if(!SD(n)&&!ED(n))throw new Error(`Kind ${n} is not replaceable`);return await XD(t,`${n}:${e}:${r??""}`,i)}(r,t,e,n,this.indexCache);if(i){const r=`${e}:${t}:${n??""}`;this.eventMap.delete(r)}return i}async deleteByFilters(t){const e=Array.isArray(t)?t:[t],n=await this.getDb(),r=await this.getEventIdsForFilters(e),i=await async function(t,e,n){const r=await HD(t,e,n);return await async function(t,e,n){if(0===e.length)return 0;const r=t.transaction("events","readwrite"),i=r.objectStore("events");let s=0;const o=[];for(const a of e){const t=await i.get(a);t&&(o.push(t.event),await i.delete(a),s++)}if(await r.commit(),n&&o.length>0)for(const a of o)n.removeEvent(a);return s}(t,Array.from(r),n)}(n,e,this.indexCache);if(i>0)for(const s of r)this.eventMap.delete(s);return i}async deleteAllEvents(){const t=await this.getDb();await async function(t,e){const n=t.transaction("events","readwrite");await n.objectStore("events").clear(),await n.commit(),e&&e.clear()}(t,this.indexCache),this.eventMap.clear()}async getEventIdsForFilters(t){const e=await this.getDb(),{getIdsForFilters:n}=await ij(async()=>{const{getIdsForFilters:t}=await Promise.resolve().then(()=>DD);return{getIdsForFilters:t}},void 0),r=await n(e,t,this.indexCache);return Array.from(r)}addToEventMaps(t){for(const e of t)this.eventMap.set(FD(e),e)}subscribeInternal(t,e){const n=((t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((t,e)=>t+((e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e>62?"-":"_"),""))(),r={id:n,filters:t,closed:!1,close:()=>this.unsubscribe(n),...e};return this.subscriptions.set(n,r),this.executeSubscription(r),r}async executeSubscription(t){const e=(new Date).valueOf();oj(`Running ${t.id}`,t.filters);const n=(await this.getWriteQueue()).matchPending(t.filters);return new Promise(async r=>{const i=await this.getDb(),s=setTimeout(()=>{t.eose&&!t.closed&&t.eose(),r()},this.baseEoseTimeout);GD(i,t.filters,this.indexCache,this.eventMap).then(i=>{if(clearTimeout(s),this.addToEventMaps(i),t.event&&!t.closed){const r=new Set(n.map(t=>FD(t))),s=n.length>0?[...i.filter(t=>!r.has(FD(t))),...n].sort(zD):i;for(const e of s)try{t.event(e)}catch(Z4){oj("event handler failed with error",Z4)}const o=(new Date).valueOf()-e;oj(`Finished ${t.id} took ${o}ms and got ${s.length} events`)}t.eose&&!t.closed&&t.eose(),r()})})}unsubscribe(t){const e=this.subscriptions.get(t);e&&(oj(`Closing ${t}`),e.closed=!0,e.complete?.(),this.subscriptions.delete(t))}},lj=a({excludeRequiredRelays:()=>dj,mergeRequiredRelays:()=>hj,normalizeRelayUrl:()=>cj,parsePlacePhotos:()=>pj,uniqNormalizedRelays:()=>uj});function cj(t){if(!t)return"";let e=t.trim().toLowerCase();if(!e)return"";for(e.startsWith("ws://")||e.startsWith("wss://")||(e="wss://"+e);e.endsWith("/");)e=e.slice(0,-1);return e}function uj(t=[]){return Array.from(new Set(t.map(cj).filter(Boolean)))}function hj(t=[],e=[]){const n=new Set(t.filter(Boolean)),r=[...t.filter(Boolean)];for(const i of uj(e))n.has(i)||r.push(i);return r}function dj(t=[],e=[]){const n=new Set(e.filter(Boolean));return uj(t).filter(t=>!n.has(t))}function pj(t){if(!t||0===t.length)return[];const e=[...t].sort((t,e)=>t.created_at-e.created_at),n=[];for(const i of e){const t=i.tags.filter(t=>"t"===t[0]).map(t=>t[1]).filter(Boolean),e=i.tags.filter(t=>"imeta"===t[0]);for(const r of e){let e=null,s=null,o=null,a=!1,l=16/9,c=null,u=i.tags.find(t=>"i"===t[0])?.[1];for(const t of r.slice(1))if(t.startsWith("url "))e=t.substring(4);else if(t.startsWith("thumb "))s=t.substring(6);else if(t.startsWith("blurhash "))o=t.substring(9);else if(t.startsWith("dim ")){const[e,n]=t.substring(4).split("x").map(Number);e&&n&&(l=e/n,e>n&&(a=!0))}else if(t.startsWith("alt ")){const e=t.substring(4).trim();c="A photo of a place"===e?null:e||null}e&&n.push({eventId:i.id,pubkey:i.pubkey,createdAt:i.created_at,url:e,thumbUrl:s,blurhash:o,isLandscape:a,aspectRatio:l,placeIdentifier:u,tags:t,alt:c})}}if(0===n.length)return[];const r=n.findIndex(t=>t.isLandscape);if(r>0){const[t]=n.splice(r,1);n.unshift(t)}return n}var fj="0123456789bcdefghjkmnpqrstuvwxyz",gj=class t{static encode(e,n,r){if(void 0===r){for(let r=1;r<=12;r++){const i=t.encode(e,n,r),s=t.decode(i);if(s.lat==e&&s.lon==n)return i}r=12}if(e=Number(e),n=Number(n),r=Number(r),isNaN(e)||isNaN(n)||isNaN(r))throw new Error("Invalid geohash");let i=0,s=0,o=!0,a="",l=-90,c=90,u=-180,h=180;for(;a.length=t?(i=2*i+1,u=t):(i*=2,h=t)}else{const t=(l+c)/2;e>=t?(i=2*i+1,l=t):(i*=2,c=t)}o=!o,5==++s&&(a+=fj.charAt(i),s=0,i=0)}return a}static decode(e){const n=t.bounds(e),r=n.sw.lat,i=n.sw.lon,s=n.ne.lat,o=n.ne.lon;let a=(r+s)/2,l=(i+o)/2;return a=a.toFixed(Math.floor(2-Math.log(s-r)/Math.LN10)),l=l.toFixed(Math.floor(2-Math.log(o-i)/Math.LN10)),{lat:Number(a),lon:Number(l)}}static bounds(t){if(0==t.length)throw new Error("Invalid geohash");t=t.toLowerCase();let e=!0,n=-90,r=90,i=-180,s=180;for(let o=0;o=0;t--){const o=l>>t&1;if(e){const t=(i+s)/2;1==o?i=t:s=t}else{const t=(n+r)/2;1==o?n=t:r=t}e=!e}}return{sw:{lat:n,lon:i},ne:{lat:r,lon:s}}}static adjacent(e,n){if(e=e.toLowerCase(),n=n.toLowerCase(),0==e.length)throw new Error("Invalid geohash");if(-1=="nsew".indexOf(n))throw new Error("Invalid direction");const r=e.slice(-1);let i=e.slice(0,-1);const s=e.length%2;return-1!={n:["prxz","bcfguvyz"],s:["028b","0145hjnp"],e:["bcfguvyz","prxz"],w:["0145hjnp","028b"]}[n][s].indexOf(r)&&""!=i&&(i=t.adjacent(i,n)),i+fj.charAt({n:["p0r21436x8zb9dcf5h7kjnmqesgutwvy","bc01fg45238967deuvhjyznpkmstqrwx"],s:["14365h7k9dcfesgujnmqp0r2twvyx8zb","238967debc01fg45kmstqrwxuvhjyznp"],e:["bc01fg45238967deuvhjyznpkmstqrwx","p0r21436x8zb9dcf5h7kjnmqesgutwvy"],w:["238967debc01fg45kmstqrwxuvhjyznp","14365h7k9dcfesgujnmqp0r2twvyx8zb"]}[n][s].indexOf(r))}static neighbours(e){return{n:t.adjacent(e,"n"),ne:t.adjacent(t.adjacent(e,"n"),"e"),e:t.adjacent(e,"e"),se:t.adjacent(t.adjacent(e,"s"),"e"),s:t.adjacent(e,"s"),sw:t.adjacent(t.adjacent(e,"s"),"w"),w:t.adjacent(e,"w"),nw:t.adjacent(t.adjacent(e,"n"),"w")}}},mj=a({getGeohashPrefixesInBbox:()=>yj});function yj(t){const{minLat:e,minLon:n,maxLat:r,maxLon:i}=t,s=new Set;if(Math.abs(r-e)>20||Math.abs(i-n)>20)return console.debug("BBox too large for 4-char geohash scanning, aborting fine scan."),[];for(let a=e;a<=r+.1;a+=.1)for(let t=n;t<=i+.1;t+=.1){const e=Math.min(a,r),n=Math.min(t,i);try{const t=gj.encode(e,n,4);s.add(t)}catch(o){}}try{s.add(gj.encode(e,n,4))}catch(o){}try{s.add(gj.encode(r,i,4))}catch(o){}try{s.add(gj.encode(e,i,4))}catch(o){}try{s.add(gj.encode(r,n,4))}catch(o){}return Array.from(s)}var vj=a({default:()=>xj}),bj=["wss://purplepag.es","wss://relay.damus.io","wss://nos.lol"],wj=["wss://nostr.kosmos.org"],_j=[],xj=class extends dp{static{oN(this.prototype,"nostrRelay",[hp])}#it=void lN(this,"nostrRelay");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");store=new FF;static{oN(this.prototype,"profile",[qr],function(){return null})}#ct=void lN(this,"profile");static{oN(this.prototype,"mailboxes",[qr],function(){return null})}#ut=void lN(this,"mailboxes");static{oN(this.prototype,"blossomServers",[qr],function(){return[]})}#ht=void lN(this,"blossomServers");static{oN(this.prototype,"placePhotos",[qr],function(){return[]})}#dt=void lN(this,"placePhotos");static{oN(this.prototype,"myContributionEvents",[qr],function(){return[]})}#pt=void lN(this,"myContributionEvents");_profileSub=null;_mailboxesSub=null;_blossomSub=null;_photosSub=null;_contributionsSub=null;_requestSub=null;_cachePromise=null;loadedGeohashPrefixes=new Set;constructor(){super(...arguments),this._cachePromise=ND("applesauce-events").then(async t=>{this.cache=new aj(t,{cacheIndexes:1e3,maxEvents:1e4}),await this.cache.start(),this._stopPersisting=function(t,e,n){const r=n?.batchTime??5e3,i=t.insert$.pipe(dO(t=>{return e=t,!(!0===Reflect.get(e,RI));var e}),n?.maxBatchSize?pO(r,void 0,n?.maxBatchSize??100):pO(r),dO(t=>t.length>0)).subscribe(t=>{e(t).then(()=>qO(`Saved ${t.length} events to cache`)).catch(e=>qO(`Failed to save ${t.length} events to cache`,e))});return()=>i.unsubscribe()}(this.store,async t=>{const e=t.filter(t=>0===t.kind||5===t.kind||10002===t.kind||10063===t.kind||360===t.kind);e.length>0&&await Promise.all(e.map(t=>this.cache.add(t)))},{batchTime:1e3,maxBatchSize:100})}),this.nostrRelay.pool.relays$.subscribe(()=>{})}get requiredReadRelays(){return wj}get requiredWriteRelays(){return _j}get mailboxReadRelays(){return(this.mailboxes?.inboxes||[]).map(cj).filter(Boolean)}get mailboxWriteRelays(){return(this.mailboxes?.outboxes||[]).map(cj).filter(Boolean)}get configuredReadRelays(){return dj(uj([...this.mailboxReadRelays,...this.settings.nostrReadRelays||[]]),this.settings.nostrReadRelayExclusions||[])}get configuredWriteRelays(){return dj(uj([...this.mailboxWriteRelays,...this.settings.nostrWriteRelays||[]]),this.settings.nostrWriteRelayExclusions||[])}get activeReadRelays(){return hj(this.requiredReadRelays,this.configuredReadRelays)}get activeWriteRelays(){return hj(this.requiredWriteRelays,this.configuredWriteRelays)}async loadPlacesInBounds(t){const e=yj(t).filter(t=>!this.loadedGeohashPrefixes.has(t));if(0!==e.length){console.debug("[nostr-data] Loading place photos for prefixes:",e);try{await this._cachePromise;const t=await this.cache.query([{kinds:[360],"#g":e}]);if(t&&t.length>0)for(const e of t)this.store.add(e)}catch(n){console.warn("[nostr-data] Failed to read photos from local Nostr IDB cache",n)}this.nostrRelay.pool.request(this.activeReadRelays,[{kinds:[360],"#g":e}]).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("[nostr-data] Error fetching place photos by geohash:",t)}});for(const t of e)this.loadedGeohashPrefixes.add(t)}}async loadPhotosForPlace(t){if(this._photosSub&&(this._photosSub.unsubscribe(),this._photosSub=null),this.placePhotos=[],!t||!t.osmId||!t.osmType)return;const e=`osm:${t.osmType}:${t.osmId}`;this._photosSub=this.store.timeline([{kinds:[360],"#i":[e]}]).subscribe(t=>{this.placePhotos=t});try{await this._cachePromise;const t=await this.cache.query([{kinds:[360,5],"#i":[e]}]);if(t&&t.length>0)for(const e of t)this.store.add(e)}catch(n){console.warn("[nostr-data] Failed to read photos for place from local Nostr IDB cache",n)}this.nostrRelay.pool.request(this.activeReadRelays,[{kinds:[360,5],"#i":[e]}]).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("[nostr-data] Error fetching place photos for place:",t)}})}async loadMyContributions(t){if(!t)return;this.myContributionEvents=[],this._contributionsSub&&(this._contributionsSub.unsubscribe(),this._contributionsSub=null);const e=[{kinds:[360,5],authors:[t]}];this._contributionsSub=this.store.timeline(e).subscribe(t=>{this.myContributionEvents=t});try{await this._cachePromise;const t=await this.cache.query(e);if(t&&t.length>0)for(const e of t)this.store.add(e)}catch(n){console.warn("[nostr-data] Failed to read my contributions from local Nostr IDB cache",n)}this.nostrRelay.pool.request(this.activeReadRelays,e).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("[nostr-data] Error fetching my contribution events:",t)}})}async loadProfile(t){if(!t)return;this.profile=null,this.mailboxes=null,this.blossomServers=[],this._cleanupSubscriptions(),this._profileSub=this.store.model(MF,t).subscribe(t=>{this.profile=t}),this._mailboxesSub=this.store.model(IF,t).subscribe(t=>{this.mailboxes=t}),this._blossomSub=this.store.replaceable(10063,t).subscribe(t=>{t&&t.tags?this.blossomServers=t.tags.filter(t=>"server"===t[0]&&t[1]).map(t=>t[1]):this.blossomServers=[]});try{await this._cachePromise;const e=await this.cache.query([{authors:[t],kinds:[0,10002,10063]}]);if(e&&e.length>0)for(const t of e)this.store.add(t)}catch(n){console.warn("Failed to read from local Nostr IDB cache",n)}const e=Array.from(new Set([...bj,...this.activeWriteRelays]));this._requestSub=this.nostrRelay.pool.request(e,[{authors:[t],kinds:[0,10002,10063]}]).subscribe({next:t=>{this.store.add(t)},error:t=>{console.error("Error fetching profile events:",t)}})}get userDisplayName(){if(this.profile){if(this.profile.nip05)return this.profile.nip05;if(this.profile.displayName||this.profile.display_name)return this.profile.displayName||this.profile.display_name;if(this.profile.name)return this.profile.name}if(this.nostrAuth.pubkey)try{const t=function(t,e){return function(t,e){let n=vS.toWords(e);return vS.encode("npub",n,YI)}(0,e)}(0,Lk(this.nostrAuth.pubkey));return`${t.slice(0,9)}...${t.slice(-4)}`}catch{return this.nostrAuth.pubkey}return"Not connected"}async clearCache(){await this._cachePromise,this.cache&&await this.cache.deleteAllEvents()}_cleanupSubscriptions(){this._requestSub&&(this._requestSub.unsubscribe(),this._requestSub=null),this._profileSub&&(this._profileSub.unsubscribe(),this._profileSub=null),this._mailboxesSub&&(this._mailboxesSub.unsubscribe(),this._mailboxesSub=null),this._blossomSub&&(this._blossomSub.unsubscribe(),this._blossomSub=null),this._photosSub&&(this._photosSub.unsubscribe(),this._photosSub=null),this._contributionsSub&&(this._contributionsSub.unsubscribe(),this._contributionsSub=null)}willDestroy(){super.willDestroy(...arguments),this._cleanupSubscriptions(),this._stopPersisting&&this._stopPersisting(),this.cache&&this.cache.stop()}};function Cj(t,e=t=>!!t){return vO(n=>{const r=e?n.pipe(t,dO(e),bO(1)):n.pipe(t,bO(1));return n.pipe(FO(r))})}function kj(t){return fO(e=>jA({ok:!1,from:t.url,message:e?.message||"Unknown error"}))}var Sj,Ej=class t{relays$=new lA([]);status$;get relays(){if(this.relays$ instanceof lA)return this.relays$.value;throw new Error("This group was created with an observable, relays are not available")}constructor(t){this.relays$=Array.isArray(t)?new lA(t):t,this.status$=this.relays$.pipe(OO(t=>0===t.length?jA({}):lO(...t.map(t=>t.status$)).pipe(LO((t,e)=>({...t,[e.url]:e}),{}),AO({}))),MO(1))}get controlled(){return this.relays$ instanceof lA==0}has(t){if(this.controlled)throw new Error("This group was created with an observable, relays are not available");return"string"==typeof t?this.relays.some(e=>e.url===t):this.relays.includes(t)}add(t){this.has(t)||this.relays$.next([...this.relays,t])}remove(t){this.has(t)&&this.relays$.next(this.relays.filter(e=>e!==t))}internalSubscription(t){const e=new WeakMap;return this.relays$.pipe(function(t){return nA((e,n)=>{let r=null,i=!1;const s=()=>{i&&!r&&n.complete()};e.subscribe(rA(n,e=>{const i=r,o=r=rA(n,t=>n.next(t),()=>{r!==o&&null!==r||(r=null,s())});DA(t(e)).subscribe(r),i?.unsubscribe()},()=>{i=!0,s()}))})}(n=>{const r=[];for(const i of n){if(e.has(i)){r.push(e.get(i));continue}const n=t(i).pipe(fO(t=>jA({type:"ERROR",from:i.url,error:t})));r.push(n),e.set(i,n)}return lO(...r)}),PO())}internalPublish(t){const e=new WeakMap;return this.relays$.pipe(bO(1),OO(n=>{const r=[];for(const i of n){if(e.has(i)){r.push(e.get(i));continue}const n=t(i).pipe(kj(i));r.push(n),e.set(i,n)}return lO(...r)}),PO())}req(t,e){return this.internalSubscription(n=>n.req(t,e))}event(t){return this.internalPublish(e=>e.event(t))}async negentropy(t,e,n,r){const i=(await Promise.all(this.relays.map(async t=>[t,await t.getSupported()]))).filter(([t,e])=>e?.includes(77)).map(([t])=>t);if(0===i.length)throw new Error("No relays support NIP-77 negentropy sync");if(!r?.parallel)throw new Error("Negentropy sync must be parallel (for now)");return await Promise.allSettled(i.map(i=>i.negentropy(t,e,n,r))),!0}publish(t,e){return qA(this.internalPublish(n=>DA(n.publish(t,e))).pipe(nA(function(t,e){(function(t,e){return nA(gO(t,e,arguments.length>=2,!1,!0))})(mO,[])(t).subscribe(e)}),(n=[],nA(function(t,e){var r=!1;t.subscribe(rA(e,function(t){r=!0,e.next(t)},function(){r||e.next(n),e.complete()}))}))));var n}request(e,n){const r=n?.complete??t.completeOnAny(t.completeAfterFirstRelay(5e3),t.completeOnAllEose());return this.internalSubscription(t=>t.req(e,{...n,reconnect:n?.reconnect??t.requestReconnect})).pipe(r?Cj(r):QM,GA({first:n?.timeout??3e4}),dO(t=>"EVENT"===t.type),ZA(t=>t.event),null===n?.eventStore?QM:zF(n?.eventStore??new xF),PO())}subscription(t,e){return this.internalSubscription(n=>n.req(t,{...e,reconnect:e?.reconnect??n.subscriptionReconnect})).pipe(dO(t=>"EVENT"===t.type),ZA(t=>t.event),null===e?.eventStore?QM:zF(e?.eventStore??new xF),PO())}count(t,e=$I()){return this.relays$.pipe(OO(n=>eO(Object.fromEntries(n.map(n=>[n.url,n.count(t,e)])))),PO())}sync(t,e,n){return oO(async()=>{const t=(await Promise.all(this.relays.map(async t=>[t,await t.getSupported()]))).filter(([t,e])=>e?.includes(77)).map(([t])=>t);if(0===t.length)throw new Error("No relays support NIP-77 negentropy sync");return t}).pipe(OO(r=>lO(...r.map(r=>r.sync(t,e,n)))),PO())}static completeAfterFirstRelay(t=5e3){return e=>e.pipe(dO(t=>"EOSE"===t.type)).pipe(bO(1),OO(()=>aO(t)),ZA(()=>!0))}static completeOnAllEose(){return t=>t.pipe(dO(t=>"OPEN"===t.type||"EOSE"===t.type||"ERROR"===t.type),LO((t,e)=>t.set(e.from,e.type),new Map),ZA(t=>Array.from(t.values()).every(t=>"OPEN"!==t)))}static completeOnAny(...t){return vO(e=>lO(...t.map(t=>e.pipe(t))))}static completeOnAll(...t){return vO(e=>eO(t.map(t=>e.pipe(t))).pipe(ZA(t=>t.every(t=>!!t))))}},Rj={url:"",deserializer:function(t){return JSON.parse(t.data)},serializer:function(t){return JSON.stringify(t)}},Tj=function(t){function e(e,n){var r=t.call(this)||this;if(r._socket=null,e instanceof tA)r.destination=n,r.source=e;else{var i=r._config=EM({},Rj);if(r._output=new oA,"string"==typeof e)i.url=e;else for(var s in e)e.hasOwnProperty(s)&&(i[s]=e[s]);if(!i.WebSocketCtor&&WebSocket)i.WebSocketCtor=WebSocket;else if(!i.WebSocketCtor)throw new Error("no WebSocket constructor can be found");r.destination=new uA}return r}return SM(e,t),e.prototype.lift=function(t){var n=new e(this._config,this.destination);return n.operator=t,n.source=this,n},e.prototype._resetState=function(){this._socket=null,this.source||(this.destination=new uA),this._output=new oA},e.prototype.multiplex=function(t,e,n){var r=this;return new tA(function(i){try{r.next(t())}catch(mz){i.error(mz)}var s=r.subscribe({next:function(t){try{n(t)&&i.next(t)}catch(mz){i.error(mz)}},error:function(t){return i.error(t)},complete:function(){return i.complete()}});return function(){try{r.next(e())}catch(mz){i.error(mz)}s.unsubscribe()}})},e.prototype._connectSocket=function(){var t=this,e=this._config,n=e.WebSocketCtor,r=e.protocol,i=e.url,s=e.binaryType,o=this._output,a=null;try{a=r?new n(i,r):new n(i),this._socket=a,s&&(this._socket.binaryType=s)}catch(c){return void o.error(c)}var l=new NM(function(){t._socket=null,a&&1===a.readyState&&a.close()});a.onopen=function(e){if(!t._socket)return a.close(),void t._resetState();var n=t._config.openObserver;n&&n.next(e);var r=t.destination;t.destination=HM.create(function(e){if(1===a.readyState)try{var n=t._config.serializer;a.send(n(e))}catch(c){t.destination.error(c)}},function(e){var n=t._config.closingObserver;n&&n.next(void 0),e&&e.code?a.close(e.code,e.reason):o.error(new TypeError("WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }")),t._resetState()},function(){var e=t._config.closingObserver;e&&e.next(void 0),a.close(),t._resetState()}),r&&r instanceof uA&&l.add(r.subscribe(t.destination))},a.onerror=function(e){t._resetState(),o.error(e)},a.onclose=function(e){a===t._socket&&t._resetState();var n=t._config.closeObserver;n&&n.next(e),e.wasClean?o.complete():o.error(e)},a.onmessage=function(e){try{var n=t._config.deserializer;o.next(n(e))}catch(mz){o.error(mz)}}},e.prototype._subscribe=function(t){var e=this,n=this.source;return n?n.subscribe(t):(this._socket||this._connectSocket(),this._output.subscribe(t),t.add(function(){var t=e._socket;0===e._output.observers.length&&(!t||1!==t.readyState&&0!==t.readyState||t.close(),e._resetState())}),t)},e.prototype.unsubscribe=function(){var e=this._socket;!e||1!==e.readyState&&0!==e.readyState||e.close(),this._resetState(),t.prototype.unsubscribe.call(this)},e}(aA),Lj="auth-required:",Pj={count:3,delay:(t,e)=>aO(1e3*e),resetOnSuccess:!0};function Ij(t){return"number"==typeof t?{...Pj,count:t}:{...Pj,...t??{}}}!function(t){t[t.RECEIVE=1]="RECEIVE",t[t.SEND=2]="SEND",t[t.BOTH=3]="BOTH"}(Sj||(Sj={}));var Mj=class extends Error{reason;constructor(t){super(t),this.reason=t,this.name="RelayClosedError"}},Aj=class extends Mj{constructor(t){super(t),this.name="AuthRequiredError"}},Oj={"auth-required":Aj,unsupported:Mj,error:Mj,blocked:Mj,restricted:Mj,"rate-limited":Mj,pow:Mj,invalid:Mj,duplicate:Mj,mute:Mj};function Fj(t){const e=Oj[t.split(":")[0]];return e?new e(t):null}var Nj={ids:["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],limit:0},zj=class t{url;log=$O.extend("Relay");socket;_ready$=new lA(!0);ready$=this._ready$.asObservable();reconnectTimer;attempts$=new lA(0);connected$=new lA(!1);challenge$=new lA(null);authenticated$;authenticatedAs$;authentication$=new lA(null);authenticationResponse$=new lA(null);notices$=new lA([]);error$=new lA(null);message$;notice$;lastMessageReceivedAt=0;_lastMessageAt$=new lA(0);lastMessageAt$=this._lastMessageAt$.asObservable();status$;information$;_nip11=null;icon$;limitations$;supported$;open$=new oA;close$=new oA;closing$=new oA;reqs$=new lA({});get ready(){return this._ready$.value}get connected(){return this.connected$.value}get challenge(){return this.challenge$.value}get notices(){return this.notices$.value}get authenticated(){return!0===this.authenticationResponse?.ok}get authentication(){return this.authentication$.value}get authenticatedAs(){return this.authenticated?this.authentication?.pubkey??null:null}get authenticationResponse(){return this.authenticationResponse$.value}get information(){return this._nip11}get lastMessageAt(){return this._lastMessageAt$.value}get reqs(){return this.reqs$.value}eventTimeout=1e4;publishTimeout=3e4;keepAlive=3e4;enablePing=!1;pingFrequency=29e3;pingTimeout=2e4;subscriptionReconnect;requestReconnect;publishRetry;onUnresponsive;receivedAuthRequiredForReq=new lA(!1);receivedAuthRequiredForEvent=new lA(!1);authRequiredForRead$;authRequiredForPublish$;resetState(){null!==this.challenge$.value&&this.challenge$.next(null),this.authenticationResponse$.value&&this.authenticationResponse$.next(null),null!==this.authentication$.value&&this.authentication$.next(null),this.notices$.value.length>0&&this.notices$.next([]),this.receivedAuthRequiredForReq.value&&this.receivedAuthRequiredForReq.next(!1),this.receivedAuthRequiredForEvent.value&&this.receivedAuthRequiredForEvent.next(!1)}watchTower;internalSubscriptions=new NM;reconnectSubscription=null;destroy$=new uA(1);constructor(e,n){var r;this.url=e,this.log=this.log.extend(e),void 0!==n?.eventTimeout&&(this.eventTimeout=n.eventTimeout),void 0!==n?.publishTimeout&&(this.publishTimeout=n.publishTimeout),void 0!==n?.keepAlive&&(this.keepAlive=n.keepAlive),void 0!==n?.enablePing&&(this.enablePing=n.enablePing),void 0!==n?.pingFrequency&&(this.pingFrequency=n.pingFrequency),void 0!==n?.pingTimeout&&(this.pingTimeout=n.pingTimeout),void 0!==n?.onUnresponsive&&(this.onUnresponsive=n.onUnresponsive),this.subscriptionReconnect=Ij(n?.subscriptionReconnect),this.requestReconnect=Ij(n?.requestReconnect),this.publishRetry={...Pj,...n?.publishRetry??{}},this.authenticated$=this.authenticationResponse$.pipe(ZA(t=>!0===t?.ok)),this.authenticatedAs$=eO([this.authenticated$,this.authentication$]).pipe(ZA(([t,e])=>t&&e?e.pubkey:null)),this.reconnectTimer=t.createReconnectTimer(e),this.internalSubscriptions.add(this.open$.subscribe(()=>{this.log("Connected"),this.connected$.next(!0),this.attempts$.next(0),this.error$.next(null),this.resetState()})),this.internalSubscriptions.add(this.close$.subscribe(t=>{this.connected$.value?this.log("Disconnected"):this.log("Failed to connect"),this.connected$.value&&this.connected$.next(!1),this.attempts$.next(this.attempts$.value+1),this.resetState(),t.wasClean||this.startReconnectTimer(t)})),this.socket=(r={url:e,openObserver:this.open$,closeObserver:this.close$,closingObserver:this.closing$,WebSocketCtor:n?.WebSocket},new Tj(r)),this.information$=oO(()=>(this.log("Fetching NIP-11 information document"),t.fetchInformationDocument(this.url))).pipe(fO(()=>jA(null)),zO(t=>this._nip11=t),MO(1)),this.limitations$=this.information$.pipe(ZA(t=>t?t.limitation:null)),this.supported$=this.information$.pipe(ZA(t=>t&&Array.isArray(t.supported_nips)?t.supported_nips.filter(t=>"number"==typeof t):null)),this.icon$=this.information$.pipe(ZA(t=>t?.icon||new URL("/favicon.ico",JI(this.url)).toString())),this.authRequiredForRead$=this.receivedAuthRequiredForReq,this.authRequiredForPublish$=this.receivedAuthRequiredForEvent,this.internalSubscriptions.add(this.authRequiredForRead$.pipe(dO(t=>!0===t),bO(1)).subscribe(()=>this.log("Auth required for REQ"))),this.internalSubscriptions.add(this.authRequiredForPublish$.pipe(dO(t=>!0===t),bO(1)).subscribe(()=>this.log("Auth required for EVENT"))),this.status$=eO({url:jA(this.url),connected:this.connected$,authenticated:this.authenticated$,authenticatedAs:this.authenticatedAs$,ready:this._ready$,authRequiredForRead:this.authRequiredForRead$,authRequiredForPublish:this.authRequiredForPublish$,challenge:this.challenge$.asObservable()}).pipe(MO(1));const i=this.socket.pipe(dO(t=>Array.isArray(t)&&"NOTICE"===t[0]),ZA(t=>t[1]),LO((t,e)=>[...t,e],[]),zO(t=>this.notices$.next(t))),s=this.socket.pipe(dO(t=>"AUTH"===t[0]),ZA(t=>t[1]),zO(t=>{this.log("Received AUTH challenge",t),this.challenge$.next(t)})),o=new oA,a=this.socket.pipe(zO(t=>{const e=Date.now();this.lastMessageReceivedAt=e,this._lastMessageAt$.next(e),o.next(t)}));this.message$=o.asObservable(),this.notice$=this.message$.pipe(dO(t=>Array.isArray(t)&&"NOTICE"===t[0]),ZA(t=>t[1]));const l=this.connected$.pipe(OO(t=>t&&this.enablePing?aO(this.pingFrequency,this.pingFrequency).pipe(rO(()=>{if(Date.now()-this.lastMessageReceivedAtArray.isArray(e)&&("EOSE"===e[0]||"CLOSED"===e[0])&&e[1]===t),bO(1),GA({first:this.pingTimeout,with:()=>{const t=Date.now(),e=this.onUnresponsive?.({url:this.url,lastMessageAt:this.lastMessageReceivedAt,now:t,attempts:this.attempts$.value})??"reconnect",n=new Error(`Relay ping timeout after ${this.pingTimeout}ms`);return"reconnect"===e?(this.log("Relay connection has become unresponsive, triggering reconnect"),this.startReconnectTimer(n)):"close"===e?(this.log("Relay connection has become unresponsive, closing connection"),this.error$.next(n),this.socket.complete()):this.log("Relay connection has become unresponsive (ignoring per policy)"),cO}}),kO(()=>this.send(["CLOSE",t])))})):cO),fO(()=>cO));this.watchTower=this.ready$.pipe(OO(t=>t?lO(a,i,s,l).pipe(wO(),fO(t=>(this.startReconnectTimer(t instanceof Error?t:new Error("Connection error")),cO)),PO({resetOnRefCountZero:()=>aO(this.keepAlive).pipe(FO(this.destroy$))})):cO),PO())}startReconnectTimer(t){this.ready&&(this.error$.next(t instanceof Error?t:new Error("Connection error")),this._ready$.next(!1),this.reconnectSubscription?.unsubscribe(),this.reconnectSubscription=this.reconnectTimer(t,this.attempts$.value).pipe(bO(1)).subscribe(()=>{this.reconnectSubscription=null,this._ready$.next(!0)}))}waitForAuth(t,e){return eO([t,this.authenticated$]).pipe(EO(this.watchTower),dO(([t,e])=>!t||e),bO(1),OO(()=>e))}waitForReady(t){return this.ready?t:this.ready$.pipe(dO(t=>t),bO(1),OO(()=>t))}multiplex(t,e,n){return this.socket.multiplex(t,e,n)}send(t){this.socket.next(t)}req(t,e){const n=e?.id??$I(),r=e?.waitForAuth??!0;let i;if("function"==typeof t){const e=t(this);i=(BA(e)?e:lO(jA(e),cO)).pipe(ZA(t=>Array.isArray(t)?t:[t]))}else i=(BA(t)?t:lO(jA(t),cO)).pipe(ZA(t=>Array.isArray(t)?t:[t]));const s=i.pipe(wO(),CO(!0));let o=!1,a=!1;const l=this.socket.pipe(dO(t=>Array.isArray(t)&&("EVENT"===t[0]||"CLOSED"===t[0]||"EOSE"===t[0])&&t[1]===n),ZA(t=>"EVENT"===t[0]&&"object"==typeof t[2]?{type:"EVENT",from:this.url,id:t[1],event:t[2]}:"CLOSED"===t[0]?{type:"CLOSED",from:this.url,id:t[1],reason:t[2]??""}:{type:"EOSE",from:this.url,id:t[1]}),zO(t=>{if("CLOSED"===t.type){o=!0;const e=Fj(t.reason);if(e)throw e;a=!0}}),NO(t=>"CLOSED"!==t.type,!0),PO()),c=i.pipe(ZA(t=>(o=!1,a=!1,this.socket.next(["REQ",n,...t]),this.reqs$.next({...this.reqs$.value,[n]:t}),{type:"OPEN",id:n,filters:t,from:this.url})),kO(()=>{o||this.socket.next(["CLOSE",n]);const{[n]:t,...e}=this.reqs$.value;this.reqs$.next(e)}),OO(t=>l.pipe(AO(t)))),u=lO(this.watchTower,c).pipe(FO(l.pipe(wO(),CO(!0))),FO(s),zO(t=>{"EVENT"===t.type&&eM(t.event,this.url)}),PO()),h=r?this.waitForAuth(this.authRequiredForRead$,u):u;return oO(()=>this.waitForReady(h)).pipe(TO({delay:t=>t instanceof Aj?(this.log("Auth required for REQ"),this.receivedAuthRequiredForReq.next(!0),r?this.authenticated$.pipe(dO(t=>t),bO(1)):UA(()=>t)):UA(()=>t)}),this.customConnectionRetryOperator(e?.reconnect),this.customRepeatOperator(e?.resubscribe,()=>a),PO())}count(t,e=$I()){let n=!1;const r=this.socket.pipe(dO(t=>Array.isArray(t)&&("COUNT"===t[0]||"CLOSED"===t[0])&&t[1]===e),ZA(t=>{if("COUNT"===t[0])return t[2];if("CLOSED"===t[0]){n=!0;const e=Fj(t[2]??"");if(e)throw e}return null}),NO(t=>null!==t,!0),dO(t=>null!==t),PO()),i=oO(()=>(n=!1,this.socket.next(Array.isArray(t)?["COUNT",e,...t]:["COUNT",e,t]),r)).pipe(kO(()=>{n||this.socket.next(["CLOSE",e])})),s=lO(this.watchTower,i).pipe(FO(r.pipe(wO(),CO(!0))),bO(1),fO(t=>(t instanceof Aj&&!this.receivedAuthRequiredForReq.value&&(this.log("Auth required for COUNT"),this.receivedAuthRequiredForReq.next(!0)),UA(()=>t))),GA({first:1e4,with:()=>UA(()=>new Error("COUNT timeout"))}));return this.waitForReady(this.waitForAuth(this.authRequiredForRead$,s)).pipe(PO())}event(t,e="EVENT"){const n=oO(()=>(this.socket.next([e,t]),this.socket.pipe(dO(e=>"OK"===e[0]&&e[1]===t.id),ZA(t=>({ok:t[2],message:t[3],from:this.url}))))).pipe(PO()),r=lO(this.watchTower,n).pipe(FO(n.pipe(wO(),CO(!0))),bO(1),zO(({ok:t,message:e})=>{!1===t&&e?.startsWith(Lj)&&!this.receivedAuthRequiredForEvent.value&&(this.log("Auth required for publish"),this.receivedAuthRequiredForEvent.next(!0))}),GA({first:this.eventTimeout,with:()=>jA({ok:!1,from:this.url,message:"Timeout"})}));return"AUTH"===e?this.waitForReady(r).pipe(PO()):this.waitForReady(this.waitForAuth(this.authRequiredForPublish$,r)).pipe(PO())}auth(t){return this.authentication$.next(t),qA(this.event(t,"AUTH").pipe(zO(t=>this.authenticationResponse$.next(t))))}async negentropy(t,e,n,r){if(!1===(await this.getSupported())?.includes(77))throw new Error("Relay does not support NIP-77");const{buildStorageVector:i,buildStorageFromFilter:s,negentropySync:o}=await ij(async()=>{const{buildStorageVector:t,buildStorageFromFilter:e,negentropySync:n}=await import("./negentropy-BmwO83Nu.js");return{buildStorageVector:t,buildStorageFromFilter:e,negentropySync:n}},[]);return o(Array.isArray(t)?i(t):await s(t,e),this.socket,e,n,r)}authenticate(t){if(!this.challenge)throw new Error("Have not received authentication challenge");const e=t.signEvent(function(t,e){return{kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}(this.url,this.challenge));return qA((e instanceof Promise?DA(e):jA(e)).pipe(OO(t=>this.auth(t))))}customRetryOperator(t,e){return!1===t||void 0===t?QM:"number"==typeof t?TO({...e,count:t}):!0===t?e?TO(e):TO():TO({...e,...t})}customConnectionRetryOperator(t,e){if(!1===t||void 0===t)return QM;const n="number"==typeof t?{...e,count:t}:!0===t?e??{}:{...e,...t};return TO({...n,delay:(t,e)=>t instanceof Mj?UA(()=>t):"number"==typeof n.delay?aO(n.delay):"function"==typeof n.delay?n.delay(t,e):jA(null)})}customRepeatOperator(t,e){if(!1===t||void 0===t)return QM;const n=n=>{if(e&&!e())return vA;if("object"==typeof t){if("number"==typeof t.delay)return aO(t.delay);if("function"==typeof t.delay)return t.delay(n)}return jA(null)};return RO(!0===t?{delay:n}:"number"==typeof t?{count:t,delay:n}:{...t,delay:n})}customTimeoutOperator(t,e){return!1===t?QM:jF(!0===t?e:t??e)}subscription(t,e){return this.req(t,{...e,reconnect:e?.reconnect??this.subscriptionReconnect}).pipe(dO(t=>"EOSE"===t.type||"EVENT"===t.type),ZA(t=>"EOSE"===t.type?"EOSE":t.event),PO())}request(t,e){return this.req(t,{...e,reconnect:e?.reconnect??this.requestReconnect}).pipe(e?.complete?Cj(e?.complete):QM,GA({first:e?.timeout??3e4}),NO(t=>"EOSE"!==t.type),dO(t=>"EVENT"===t.type),ZA(t=>t.event),PO())}publish(t,e){return qA(this.event(t).pipe(rO(t=>!1===t.ok&&t.message?.startsWith(Lj)?UA(()=>new Aj(t.message??"")):jA(t)),this.customRetryOperator(e?.retries??e?.reconnect??!0,this.publishRetry),this.customTimeoutOperator(e?.timeout,this.publishTimeout)))}sync(t,e,n=Sj.RECEIVE){return new tA(r=>{const i=new AbortController;let s=!1;return this.negentropy(t,e,async(e,i)=>{if(n&Sj.SEND&&e.length>0){const n=await(async e=>Array.isArray(t)?t.filter(t=>e.includes(t.id)):t.getByFilters({ids:e}))(e);await Promise.allSettled(n.map(async t=>{const e=await qA(this.event(t));return e.ok&&eM(t,this.url),e}))}n&Sj.RECEIVE&&i.length>0&&await qA(this.req({ids:i}).pipe(NO(t=>"EOSE"!==t.type),dO(t=>"EVENT"===t.type),ZA(t=>t.event),Reflect.has(t,"add")?NF(t):QM,zO(t=>r.next(t))))},{signal:i.signal}).then(()=>{s||r.complete()}).catch(t=>{s||r.error(t)}),()=>{s||(s=!0,i.abort())}}).pipe(PO())}close(){this.destroy$.next(),this.destroy$.complete(),this.reconnectSubscription?.unsubscribe(),this.reconnectSubscription=null,this.internalSubscriptions.unsubscribe(),this.connected$.value&&this.connected$.next(!1),this._ready$.next(!1),this._ready$.complete(),this.socket.unsubscribe()}async getInformation(){return VA(this.information$)}async getLimitations(){return VA(this.limitations$)}async getSupported(){return VA(this.supported$)}static fetchInformationDocument(t){return DA(fetch(JI(t),{headers:{Accept:"application/nostr+json"}}).then(t=>t.json())).pipe(fO(()=>jA(null)),jF(1e4))}static createReconnectTimer(t){return(t,e=0)=>aO(Math.min(1e3*Math.pow(1.5,e),3e5))}static afterOpen(t){return e=>e.pipe(dO(t=>"OPEN"===t.type),OO(()=>e.pipe(t)))}static completeOr(...t){return e=>eO(t.map(t=>e.pipe(t,AO(!1)))).pipe(ZA(t=>t.some(t=>!!t)))}static completeAnd(...t){return e=>eO(t.map(t=>e.pipe(t,AO(!1)))).pipe(ZA(t=>t.every(t=>!!t)))}static defaultComplete(t,e=1e4){return this.completeOr(()=>aO(t),this.afterOpen(()=>aO(e)))}},Dj=class{options;relays$=new lA(new Map);get relays(){return this.relays$.value}status$;ignoreOffline=!1;add$=new oA;remove$=new oA;constructor(t){this.options=t,this.status$=this.relays$.pipe(ZA(t=>Array.from(t.values())),OO(t=>0===t.length?jA({}):lO(...t.map(t=>t.status$)).pipe(LO((t,e)=>({...t,[e.url]:e}),{}),AO({}))),MO(1))}relay(t){t=QI(t);let e=this.relays.get(t);return e||(e=new zj(t,this.options),this.relays.set(t,e),this.relays$.next(this.relays),this.add$.next(e),e)}group(t,e=this.ignoreOffline){let n=Array.isArray(t)?t.map(t=>this.relay(t)):t.pipe(ZA(t=>t.map(t=>this.relay(t))));return e&&(n=(Array.isArray(n)?jA(n):n).pipe(OO(t=>0===t.length?jA([]):eO(t.map(t=>t.ready$.pipe(dO(t=>t),bO(1),ZA(()=>t),AO(null)))).pipe(ZA(t=>t.filter(t=>null!==t)))))),new Ej(n)}remove(t,e=!0){let n;if("string"==typeof t){if(n=this.relays.get(t),!n)return}else{if(!Array.from(this.relays.values()).some(e=>e===t))return;n=t}e&&n?.close(),this.relays.delete(n.url),this.relays$.next(this.relays),this.remove$.next(n)}close(){for(const t of[...this.relays.values()])this.remove(t,!0)}req(t,e,n){return this.group(t).req(e,n)}event(t,e){return this.group(t).event(e)}negentropy(t,e,n,r,i){return this.group(t).negentropy(e,n,r,i)}publish(t,e,n){return this.group(t).publish(e,n)}request(t,e,n){return this.group(t).request(e,n)}subscription(t,e,n){return this.group(t).subscription(e,n)}subscriptionMap(t,e){const n=BA(t)?t:jA(t);return this.group(n.pipe(ZA(t=>Object.keys(t)))).subscription(t=>n.pipe(ZA(e=>e[t.url]),_O(tF)),e)}outboxSubscription(t,e,n){const r=BA(t)?t.pipe(ZA(t=>cF(t,e))):cF(t,e);return this.subscriptionMap(r,n)}count(t,e,n){return this.group(t,!1).count(e,n)}sync(t,e,n,r){return this.group(t,!1).sync(e,n,r)}},jj=a({default:()=>Uj}),Uj=class extends dp{pool=new Dj({enablePing:!0});async publish(t,e){if(!t||0===t.length)throw new Error("No relays provided to publish the event.");const n=await this.pool.publish(t,e);if(!n.some(t=>t.ok))throw new Error(`Failed to publish event. Responses: ${JSON.stringify(n)}`);return n}},Bj=class{},$j=class extends Bj{constructor(t){super(),this.message=t}},qj=class extends Bj{},Vj=class extends Bj{},Wj=class extends Bj{},Hj=class extends Bj{},Gj=class extends Bj{},Kj=class extends Bj{},Zj={invalid_request:class extends Bj{},invalid_grant:class extends Gj{},unauthorized_client:class extends Hj{},access_denied:class extends Hj{},unsupported_response_type:class extends Hj{},invalid_scope:class extends Bj{},server_error:class extends Hj{},temporarily_unavailable:class extends Hj{},invalid_client:class extends Gj{},unsupported_grant_type:class extends Gj{},invalid_token:class extends Bj{}},Yj=t=>{const e=Zj[t];return e?new e:new $j(t)},Xj="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",Jj=t=>{const e=t.slice(7).replace(/"/g,"").split(",").map(t=>{const[e,n]=t.trim().split("=");return{[e]:n}}).reduce((t,e)=>({...t,...e}),{});return{realm:e.realm,error:e.error,errorDescription:e.error_description,errorUri:e.error_uri}},Qj=t=>{let e=btoa(t);return e=e.replace(/\+/g,"-"),e=e.replace(/\//g,"_"),e=e.replace(/=/g,""),e},tU=(t,e)=>{let n=e.split("?");if(n.length<2)return;n=n[1].split("#");const r=n[0].split("&");for(const i of r){const[e,n]=i.split("=");if(e===t)return decodeURIComponent(n)}},eU=t=>Object.entries(t).map(([t,e])=>`${t}=${encodeURIComponent(e)}`).join("&"),nU="WWW-Authenticate",rU=class{constructor(t,e){this.state={},this.config=t,this.storage=e||sU,this.ready=new Promise(t=>this.setReady=t),this.recoverState()}async reset(){this.state={},await this.saveState(),this.authCodeForAccessTokenPromise=void 0,this.refreshTokenForAccessTokenPromise=void 0}async requestAuthorizationCode(t){const{clientId:e,extraAuthorizationParams:n,redirectUrl:r,scopes:i}=this.config,{codeChallenge:s,codeVerifier:o}=await(async()=>{const t=new Uint32Array(96);crypto.getRandomValues(t);const e=Qj(Array.from(t).map(t=>Xj[t%66]).join("")),n=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(e)),r=new Uint8Array(n);let i="";const s=r.byteLength;for(let o=0;o{const t=new Uint32Array(32);return crypto.getRandomValues(t),Array.from(t).map(t=>Xj[t%66]).join("")})();this.state={...this.state,codeChallenge:s,codeVerifier:o,stateQueryParam:a},await this.saveState();let l=this.config.authorizationUrl+`?response_type=code&client_id=${encodeURIComponent(e)}&redirect_uri=${encodeURIComponent(r)}&state=${a}&code_challenge=${encodeURIComponent(s)}&code_challenge_method=S256`;if(i&&(l+=`&scope=${encodeURIComponent(i.join(" "))}`),n||t){const e={...n,...t};l+=`&${eU(e)}`}location.replace(l)}isReturningFromAuthServer(){return!!tU("code",location.href)}async receiveCode(){await this.ready;const t=tU("error",location.href);if(t)throw Yj(t);if(tU("state",location.href)!==this.state.stateQueryParam)throw console.warn('"state" parameter doesn\'t match the one sent! Possible malicious activity.'),new Wj;if(this.state.authorizationCode=tU("code",location.href),!this.state.authorizationCode)throw new Vj;this.saveState()}async getTokens(t){const{accessToken:e,authorizationCode:n,idToken:r,refreshToken:i,scopes:s}=this.state;if(n)return this.exchangeAuthCodeForAccessToken(t);if(!e)throw new qj;if(this.isAccessTokenExpired()){if(this.config.onAccessTokenExpiry)return this.config.onAccessTokenExpiry();throw new Kj}return Promise.resolve({accessToken:e,idToken:r,refreshToken:i,scopes:s})}async exchangeAuthCodeForAccessToken(t){this.authCodeForAccessTokenPromise||(this.authCodeForAccessTokenPromise=this.fetchAccessTokenUsingCode(t));const e=await this.authCodeForAccessTokenPromise;return this.authCodeForAccessTokenPromise=void 0,this.state.authorizationCode=void 0,this.setTokens(e)}async exchangeRefreshTokenForAccessToken(){this.refreshTokenForAccessTokenPromise||(this.refreshTokenForAccessTokenPromise=this.fetchAccessTokenUsingRefreshToken());const t=await this.refreshTokenForAccessTokenPromise;return this.refreshTokenForAccessTokenPromise=void 0,this.setTokens(t)}makeRetryFetchFunction(t){return async(e,...n)=>{const r=await t(e,...n);if(401===r.status){const i=r.headers.get(nU.toLowerCase());if(i&&"invalid_token"===Jj(i).error)return await this.exchangeRefreshTokenForAccessToken(),e=await this.requestInterceptor(e),t(e,...n)}return r}}decorateFetchWithInterceptors(t){return async(e,...n)=>{"string"==typeof e&&(e=new Request(e)),e=await this.requestInterceptor(e);const r=await t(e,...n);return this.responseInterceptor(r)}}async requestInterceptor(t){const e=await this.getTokens();return t.headers.set("Authorization",`Bearer ${e.accessToken}`),t}async responseInterceptor(t){if(401!==t.status)return t;const e=t.headers.get(nU.toLowerCase());if(e){const t=Jj(e).error;throw"invalid_grant"===t&&this.config.onInvalidGrant&&await this.config.onInvalidGrant(),"invalid_token"===t&&this.config.onInvalidToken&&await this.config.onInvalidToken(),Yj(t)}return t}getGrantedScopes(){return this.state.scopes}isAuthorized(){return!!this.state.accessToken}isAccessTokenExpired(){const{accessTokenExpiry:t}=this.state;return Boolean(t&&new Date>=new Date(t))}async fetchAccessTokenUsingCode(t){const{authorizationCode:e,codeVerifier:n=""}=this.state,{clientId:r,redirectUrl:i}=this.config;n?e||console.warn("No authorization grant code is being passed."):console.warn("No code verifier is being sent.");const s=this.config.tokenUrl,o={grant_type:"authorization_code",code:e,redirect_uri:i,client_id:r,code_verifier:n,...t},a=new URLSearchParams(o).toString();return this.makeTokenRequest(s,a)}fetchAccessTokenUsingRefreshToken(){const{extraRefreshParams:t,clientId:e,tokenUrl:n}=this.config,{refreshToken:r}=this.state;r||console.warn("No refresh token is present.");const i=n;let s=`grant_type=refresh_token&refresh_token=${r}&client_id=${e}`;return t&&(s=`${s}&${eU(t)}`),this.makeTokenRequest(i,s)}async makeTokenRequest(t,e){const n=await fetch(t,{method:"POST",body:e,headers:{"Content-Type":"application/x-www-form-urlencoded"}}),r=await n.json();if(!n.ok)throw"invalid_grant"===r.error&&this.config.onInvalidGrant&&await this.config.onInvalidGrant(),Yj(r.error);const{access_token:i,expires_in:s,id_token:o,refresh_token:a,scope:l}=r;return{accessToken:i,expiresIn:s,idToken:o,refreshToken:a,scope:l}}async setTokens(t){const{accessToken:e,expiresIn:n,idToken:r,refreshToken:i,scope:s}=t;return this.state.accessToken=e,n&&(this.state.accessTokenExpiry=new Date(Date.now()+1e3*parseInt(n,10)).toString()),r&&(this.state.idToken=r),i&&(this.state.refreshToken=i),s&&(this.state.scopes=s.split(" ")),await this.saveState(),{accessToken:this.state.accessToken,idToken:this.state.idToken,refreshToken:this.state.refreshToken,scopes:s?this.state.scopes:[]}}async recoverState(){this.state=JSON.parse(await this.storage.loadState()||"{}"),this.setReady(),this.config.storeRefreshToken||(this.state.refreshToken=this.refreshToken)}async saveState(){this.refreshToken=this.state.refreshToken;const t={...this.state};this.config.storeRefreshToken||delete t.refreshToken,await this.storage.saveState(JSON.stringify(t))}},iU="oauth2authcodepkce-state",sU={saveState:t=>localStorage.setItem(iU,t),loadState:()=>localStorage.getItem(iU)},oU=a({default:()=>lU}),aU=class{saveState(t){localStorage.setItem("marco:osm_auth_state",t)}loadState(){const t=localStorage.getItem("marco:osm_auth_state");if(!t)return!1;try{return JSON.parse(t),t}catch(e){return console.warn("Failed to parse OSM auth state",e),!1}}},lU=class extends dp{static{oN(this.prototype,"isConnected",[qr],function(){return!1})}#ft=void lN(this,"isConnected");static{oN(this.prototype,"userDisplayName",[qr],function(){return null})}#gt=void lN(this,"userDisplayName");oauthClient;constructor(){super(...arguments);const t="https://www.openstreetmap.org",e=`${window.location.origin}/oauth/osm/callback`;this.oauthClient=new rU({scopes:["read_prefs","write_api"],authorizationUrl:`${t}/oauth2/authorize`,tokenUrl:`${t}/oauth2/token`,clientId:"jIn8l5mT8FZOGYiIYXG1Yvj_2FZKB9TJ1edZwOJPsRU",redirectUrl:e,storeRefreshToken:!0,onAccessTokenExpiry(){return this.exchangeRefreshTokenForAccessToken()}},new aU),this.restoreSession()}async restoreSession(){try{await this.oauthClient.ready}catch(t){console.warn("oauthClient.ready failed",t)}if(await this.oauthClient.isAuthorized()){this.isConnected=!0;const t=localStorage.getItem("marco:osm_user_display_name");t?this.userDisplayName=t:await this.fetchUserInfo()}}async login(){await this.oauthClient.requestAuthorizationCode()}async handleCallback(){await this.oauthClient.receiveCode(),await this.oauthClient.getTokens(),this.isConnected=!0,await this.fetchUserInfo()}async logout(){await this.oauthClient.reset(),this.isConnected=!1,this.userDisplayName=null,localStorage.removeItem("marco:osm_user_display_name")}async fetchUserInfo(){try{const t=await this.oauthClient.getTokens(),e=await fetch("https://api.openstreetmap.org/api/0.6/user/details.json",{headers:{Authorization:`Bearer ${t.accessToken}`}});if(e.ok){const t=await e.json();console.debug("OSM data:",t);const n=t.user.display_name;this.userDisplayName=n,localStorage.setItem("marco:osm_user_display_name",n)}else console.error("Failed to fetch OSM user info",e.status)}catch(t){console.error("Error fetching OSM user info",t)}}},cU=a({capitalize:()=>hU,formatRelativeDate:()=>dU,humanizeOsmTag:()=>uU});function uU(t){return"string"==typeof t&&t?t.replace(/[_-]/g," ").replace(/\w\S*/g,t=>t.replace(/^\w/,t=>t.toUpperCase())):""}function hU(t){return"string"==typeof t&&t?t.charAt(0).toUpperCase()+t.slice(1):""}function dU(t){if(!t)return"";const e=new Date(1e3*t),n=new Date-e,r=Math.floor(n/6e4),i=Math.floor(r/60),s=Math.floor(i/24);return r<1?"just now":r<60?`${r} min ago`:i<24?`${i} hr ago`:s<7?`${s} day${1===s?"":"s"} ago`:e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}var pU=a({getLocalizedName:()=>fU,getPlaceType:()=>mU});function fU(t,e="Untitled Place"){if(!t)return e;const n=navigator.languages||[navigator.language||"en"];for(const r of n){if(!r)continue;const e=`name:${r.split("-")[0]}`;if(t[e])return t[e]}return t.name?t.name:t["name:en"]?t["name:en"]:e}var gU=["amenity","shop","tourism","historic","leisure","office","craft","building","landuse","public_transport","highway","aeroway","waterway","natural","place","border_type","admin_title"];function mU(t){if(!t)return null;let e=null;for(const n of gU){const r=t[n];if(r){if("yes"===r){e||(e=n);continue}return uU(r)}}return e?uU(e):null}var yU=a({POI_CATEGORIES:()=>vU,getCategoryById:()=>bU}),vU=[{id:"restaurants",label:"Restaurants",icon:"fork-and-knife",filter:['["amenity"~"^(restaurant|fast_food|food_court|pub|cafe)$"]["cuisine"!~"coffee"]'],types:["node","way"]},{id:"coffee",label:"Coffee",icon:"cup-and-saucer",filter:['["amenity"~"^(cafe|ice_cream)$"]','["shop"~"^(coffee|tea)$"]','["cuisine"~"coffee_shop"]'],types:["node","way"]},{id:"groceries",label:"Groceries",icon:"shopping-basket",filter:['["shop"~"^(supermarket|convenience|grocery|greengrocer|bakery|butcher|deli|farm|seafood)$"]'],types:["node","way"]},{id:"things-to-do",label:"Things to do",icon:"feather-camera",filter:['["tourism"~"^(museum|gallery|attraction|viewpoint|zoo|theme_park|aquarium|artwork|information)$"]','["amenity"~"^(cinema|theatre|arts_centre|planetarium)$"]','["leisure"~"^(sports_centre|stadium|water_park)$"]','["historic"]','["shop"="flea_market"]'],types:["node","way","relation"]},{id:"accommodation",label:"Hotels",icon:"person-sleeping-in-bed",filter:['["tourism"~"^(hotel|hostel|motel|chalet|guest_house)$"]'],types:["node","way","relation"]}];function bU(t){return vU.find(e=>e.id===t)}var wU,_U=a({default:()=>xU}),xU=class t extends dp{static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");controller=null;cachedResults=null;lastQueryKey=null;cachedPlaces=new Map;static CACHE_KEY_PREFIX="marco:osm_cache:";static CACHE_TTL_MS=6048e5;static IN_MEMORY_TTL_MS=1e4;_buildCacheKey(t,e){return`${t}:${e}`}_readLocalCache(e,n){if("undefined"==typeof localStorage)return null;const r=`${t.CACHE_KEY_PREFIX}${e}:${n}`;try{const e=localStorage.getItem(r);if(!e)return null;const n=JSON.parse(e);return!n||"number"!=typeof n.timestamp||Date.now()-n.timestamp>t.CACHE_TTL_MS?(localStorage.removeItem(r),null):n.data}catch{try{localStorage.removeItem(`${t.CACHE_KEY_PREFIX}${e}:${n}`)}catch{}return null}}_writeLocalCache(e,n,r){if("undefined"==typeof localStorage||!r)return;const i=`${t.CACHE_KEY_PREFIX}${e}:${n}`;try{localStorage.setItem(i,JSON.stringify({data:r,timestamp:Date.now()}))}catch(s){console.debug("[osm] Failed to write localStorage cache entry",s)}}getCachedOsmObject(e,n){if(!e||!n)return null;const r=this._buildCacheKey(e,n),i=this.cachedPlaces.get(r);return i&&Date.now()-i.timestamp{this.cachedPlaces.delete(e)},t.IN_MEMORY_TTL_MS),this._writeLocalCache(n,r,i)):console.debug(`[osm] Skipping cache write for ${e}: data has no title`)}cancelAll(){this.controller&&(this.controller.abort(),this.controller=null)}async getNearbyPois(t,e,n=50){const r=`${t},${e},${n}`;if(this.lastQueryKey===r&&this.cachedResults)return console.debug("Returning cached Overpass results for:",r),this.cachedResults;this.controller&&this.controller.abort(),this.controller=new AbortController;const i=this.controller.signal,s=[`~"^(${["amenity","shop","tourism","historic","leisure","office","craft","building","landuse","public_transport","aeroway"].join("|")})$"~".*"`],o=Object.entries({public_transport:["stop_area","platform"]}).map(([t,e])=>`["${t}"!~"^(${e.join("|")})$"]`).join(""),a=`\n[out:json][timeout:25];\n(\n node(around:${n},${t},${e})\n [${s}]${o}[~"^name"~"."];\n way(around:${n},${t},${e})\n [${s}]${o}[~"^name"~"."];\n relation(around:${n},${t},${e})\n [${s}]${o}[~"^name"~"."];\n);\nout center;\n `.trim(),l=`${this.settings.overpassApi}?data=${encodeURIComponent(a)}`;try{const t=await this.fetchWithRetry(l,{signal:i});if(!t.ok)throw new Error("Overpass request failed");const e=(await t.json()).elements.map(this.normalizePoi);return this.lastQueryKey=r,this.cachedResults=e,e}catch(c){if("AbortError"===c.name)return console.debug("Overpass request aborted"),[];throw c}}async getCategoryPois(t,e,n,r){const i=bU(e);if(!i||!t)return[];const s=n&&r?`cat:${e}:${n}:${r}`:null;if(s&&this.lastQueryKey===s&&this.cachedResults)return console.debug("Returning cached category results for:",s),this.cachedResults;this.controller&&this.controller.abort(),this.controller=new AbortController;const o=this.controller.signal,{minLat:a,minLon:l,maxLat:c,maxLon:u}=t,h=[],d=i.types||["node","way","relation"];i.filter.forEach(t=>{d.forEach(e=>{h.push(`${e}${t}[~"^name"~"."];`)})});const p=`\n[out:json][timeout:25][bbox:${a},${l},${c},${u}];\n(\n ${h.join("\n ")}\n);\nout center;\n `.trim(),f=`${this.settings.overpassApi}?data=${encodeURIComponent(p)}`;try{const t=await this.fetchWithRetry(f,{signal:o});if(!t.ok)throw new Error("Overpass request failed");const e=(await t.json()).elements.map(this.normalizePoi);return s&&(this.lastQueryKey=s,this.cachedResults=e),e}catch(g){if("AbortError"===g.name)return console.debug("Category search aborted"),[];throw console.error("Category search failed",g),g}}normalizePoi(t){const e=t.tags||{},n=mU(e)||"Point of Interest";return{title:fU(e),lat:t.lat||t.center?.lat,lon:t.lon||t.center?.lon,url:e.website,osmId:String(t.id),osmType:t.type,osmTags:e,description:e.description,source:"osm",type:n}}async fetchWithRetry(t,e={},n=3){try{const r=await fetch(t,e);return!r.ok&&n>0&&[502,503,504,429].includes(r.status)?(console.warn(`Overpass request failed with ${r.status}. Retrying... (${n} left)`),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1)):r}catch(r){if(n>0&&"AbortError"!==r.name)return console.debug(`Retrying Overpass request... (${n} left)`),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1);throw r}}async getPoiById(t,e=null){let n;n="node"===e?`[out:json][timeout:25];node(${t});out center;`:"way"===e?`[out:json][timeout:25];way(${t});out center;`:`\n[out:json][timeout:25];\n(\n node(${t});\n way(${t});\n);\nout center;\n `.trim();const r=`${this.settings.overpassApi}?data=${encodeURIComponent(n)}`,i=await this.fetchWithRetry(r);if(!i.ok)throw new Error("Overpass request failed");const s=await i.json();return s.elements[0]?this.normalizePoi(s.elements[0]):null}async fetchOsmObject(e,n){if(!e||!n)return null;const r=this._buildCacheKey(n,e),i=this.cachedPlaces.get(r);if(i&&Date.now()-i.timestamp{console.debug("[osm] Background refresh failed for",r,t)}),s):this._fetchAndCacheOsmObject(e,n,r)}async _refreshOsmObject(t,e,n){const r=await this._fetchOsmObjectFromApi(t,e);return r&&this._storeInMemoryAndLocalStorage(n,e,t,r),r}async _fetchAndCacheOsmObject(t,e,n){const r=await this._fetchOsmObjectFromApi(t,e);return r&&this._storeInMemoryAndLocalStorage(n,e,t,r),r}async _fetchOsmObjectFromApi(t,e){let n;if("node"===e)n=`https://www.openstreetmap.org/api/0.6/node/${t}.json`;else if("way"===e)n=`https://www.openstreetmap.org/api/0.6/way/${t}/full.json`;else{if("relation"!==e)return console.error("Unknown OSM type:",e),null;n=`https://www.openstreetmap.org/api/0.6/relation/${t}/full.json`}try{const r=await this.fetchWithRetry(n);if(!r.ok){if(410===r.status)return console.warn("OSM object has been deleted"),null;throw new Error(`OSM API request failed: ${r.status}`)}const i=await r.json();return this.normalizeOsmApiData(i.elements,t,e)}catch(r){return console.error("Failed to fetch OSM object:",r),null}}async fetchOsmObjectsBatch(t){const e=new Map;if(!t||0===t.length)return e;const n=[];for(const{osmType:s,osmId:o}of t){if(!s||!o)continue;const t=this._buildCacheKey(s,o),r=this.getCachedOsmObject(s,o);r?e.set(t,r):n.push({osmType:s,osmId:o,cacheKey:t})}if(0===n.length)return e;const r=new Map;for(const s of n)r.has(s.osmType)||r.set(s.osmType,[]),r.get(s.osmType).push(s);const i=[];for(const[s,o]of r)i.push(this._fetchOsmObjectsByType(s,o,e));return await Promise.allSettled(i),e}async _fetchOsmObjectsByType(t,e,n){for(let i=0;it.osmId).join(","),a="way"===t?"ways":t+"s",l=`https://www.openstreetmap.org/api/0.6/${a}.json?${a}=${o}`;try{const e=await this.fetchWithRetry(l);if(!e.ok){console.warn(`[osm] Batch fetch failed for ${t} (${e.status})`,o);continue}const r=await e.json();for(const i of s){const e=this.normalizeOsmApiData(r.elements,i.osmId,t);e&&n.set(i.cacheKey,e)}}catch(r){console.error(`[osm] Batch fetch error for ${t}:`,r)}}}normalizeOsmApiData(t,e,n){if(!t||0===t.length)return null;let r=t.find(t=>String(t.id)===String(e)&&t.type===n);if(!r)return null;let i=r;if("relation"===n&&r.members){const e=r.members.find(t=>"label"===t.role&&"node"===t.type),n=r.members.find(t=>"admin_centre"===t.role&&"node"===t.type),s=e||n;if(s){const e=t.find(t=>String(t.id)===String(s.ref)&&"node"===t.type);e&&(i=e)}}let s=i.lat,o=i.lon,a=null,l=null;if("way"===n&&r.nodes){const e=new Map;t.forEach(t=>{"node"===t.type&&e.set(t.id,[t.lon,t.lat])});const n=r.nodes.map(t=>e.get(t)).filter(Boolean);if(n.length>0){if(i===r){const t=n.reduce((t,e)=>t+e[1],0),e=n.reduce((t,e)=>t+e[0],0);s=t/n.length,o=e/n.length}const t=n.map(t=>t[1]),e=n.map(t=>t[0]);if(a={minLat:Math.min(...t),maxLat:Math.max(...t),minLon:Math.min(...e),maxLon:Math.max(...e)},n.length>1){const t=n[0],e=n[n.length-1];l=t[0]===e[0]&&t[1]===e[1]?{type:"Polygon",coordinates:[n]}:{type:"LineString",coordinates:n}}}}else if("relation"===n&&r.members){const e=[],n=new Map;t.forEach(t=>{"node"===t.type&&n.set(t.id,t)});const c=[];if(r.members.forEach(r=>{if("node"===r.type){const t=n.get(r.ref);t&&e.push(t)}else if("way"===r.type){const i=t.find(t=>"way"===t.type&&t.id===r.ref);if(i&&i.nodes){const t=[];i.nodes.forEach(r=>{const i=n.get(r);i&&(e.push(i),t.push([i.lon,i.lat]))}),t.length>1&&c.push(t)}}}),e.length>0){if(i===r){const t=e.reduce((t,e)=>t+e.lat,0),n=e.reduce((t,e)=>t+e.lon,0);s=t/e.length,o=n/e.length}const t=e.map(t=>t.lat),n=e.map(t=>t.lon);a={minLat:Math.min(...t),maxLat:Math.max(...t),minLon:Math.min(...n),maxLon:Math.max(...n)}}c.length>0&&(l={type:"MultiLineString",coordinates:c})}const c=i.tags||{},u=mU(c)||"Point of Interest";return{title:fU(c),lat:s,lon:o,bbox:a,geojson:l,url:c.website,osmId:String(i.id),osmType:i.type,osmTags:c,description:c.description,source:"osm",type:u}}},CU=a({default:()=>kU}),kU=class extends dp{static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");controller=null;cancelAll(){this.controller&&(this.controller.abort(),this.controller=null)}get baseUrl(){return this.settings.photonApi}async search(t,e,n,r=10){if(!t||t.length<2)return[];this.controller&&this.controller.abort(),this.controller=new AbortController;const i=this.controller.signal,s=new URLSearchParams({q:t,limit:String(r)});e&&n&&(s.append("lat",parseFloat(e).toFixed(4)),s.append("lon",parseFloat(n).toFixed(4)));const o=`${this.baseUrl}?${s.toString()}`;try{const t=await this.fetchWithRetry(o,{signal:i});if(!t.ok)throw new Error(`Photon request failed with status ${t.status}`);const e=await t.json();return e.features?e.features.map(t=>this.normalizeFeature(t)):[]}catch(a){return"AbortError"===a.name||console.error("Photon search error:",a),[]}}normalizeFeature(t){const e=t.properties||{},n=(t.geometry||{}).coordinates||[],r=n[0],i=n[1],s=[];e.street&&s.push(e.housenumber?`${e.street} ${e.housenumber}`:e.street),e.city&&e.city!==e.name&&s.push(e.city),e.state&&e.state!==e.city&&s.push(e.state),e.country&&s.push(e.country);const o=s.join(", "),a=e.name||o||"Unknown Place",l={...e};e.osm_key&&e.osm_value&&(l[e.osm_key]=e.osm_value);const c=mU(l)||uU(e.osm_value);return{title:a,lat:i,lon:r,osmId:e.osm_id,osmType:{N:"node",W:"way",R:"relation"}[e.osm_type]||e.osm_type,osmTags:l,description:e.name?o:s.slice(1).join(", "),source:"photon",type:c}}async fetchWithRetry(t,e={},n=3){try{const r=await fetch(t,e);return!r.ok&&n>0&&[502,503,504,429].includes(r.status)?(console.warn(`Photon request failed with ${r.status}. Retrying... (${n} left)`),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1)):r}catch(r){if(n>0&&"AbortError"!==r.name)return console.debug(`Retrying Photon request... (${n} left)`,r),await new Promise(t=>setTimeout(t,1e3)),this.fetchWithRetry(t,e,n-1);throw r}}},SU=a({default:()=>RU}),EU={overpassApi:"https://overpass-api.de/api/interpreter",mapKinetic:!0,photonApi:"https://photon.komoot.io/api/",showQuickSearchButtons:!0,nostrPhotoFallbackUploads:!1,nostrReadRelays:null,nostrWriteRelays:null,nostrReadRelayExclusions:null,nostrWriteRelayExclusions:null,experimentalEnablePhotoDeletion:!1},RU=class extends dp{static{oN(this.prototype,"overpassApi",[qr],function(){return EU.overpassApi})}#mt=void lN(this,"overpassApi");static{oN(this.prototype,"mapKinetic",[qr],function(){return EU.mapKinetic})}#yt=void lN(this,"mapKinetic");static{oN(this.prototype,"photonApi",[qr],function(){return EU.photonApi})}#vt=void lN(this,"photonApi");static{oN(this.prototype,"showQuickSearchButtons",[qr],function(){return EU.showQuickSearchButtons})}#bt=void lN(this,"showQuickSearchButtons");static{oN(this.prototype,"nostrPhotoFallbackUploads",[qr],function(){return EU.nostrPhotoFallbackUploads})}#wt=void lN(this,"nostrPhotoFallbackUploads");static{oN(this.prototype,"nostrReadRelays",[qr],function(){return EU.nostrReadRelays})}#_t=void lN(this,"nostrReadRelays");static{oN(this.prototype,"nostrWriteRelays",[qr],function(){return EU.nostrWriteRelays})}#xt=void lN(this,"nostrWriteRelays");static{oN(this.prototype,"nostrReadRelayExclusions",[qr],function(){return EU.nostrReadRelayExclusions})}#Ct=void lN(this,"nostrReadRelayExclusions");static{oN(this.prototype,"nostrWriteRelayExclusions",[qr],function(){return EU.nostrWriteRelayExclusions})}#kt=void lN(this,"nostrWriteRelayExclusions");static{oN(this.prototype,"experimentalEnablePhotoDeletion",[qr],function(){return EU.experimentalEnablePhotoDeletion})}#St=void lN(this,"experimentalEnablePhotoDeletion");overpassApis=[{name:"overpass-api.de (DE)",url:"https://overpass-api.de/api/interpreter"},{name:"private.coffee (AT)",url:"https://overpass.private.coffee/api/interpreter"}];photonApis=[{name:"photon.komoot.io",url:"https://photon.komoot.io/api/"}];constructor(){super(...arguments),this.loadSettings()}loadSettings(){let t={};const e=localStorage.getItem("marco:settings");if(e)try{t=JSON.parse(e)}catch(r){console.error("Failed to parse settings from localStorage",r)}else{const e=localStorage.getItem("marco:overpass-api");e&&(t.overpassApi=e);const n=localStorage.getItem("marco:map-kinetic");null!==n&&(t.mapKinetic="true"===n);const r=localStorage.getItem("marco:show-quick-search");null!==r&&(t.showQuickSearchButtons="true"===r);const i=localStorage.getItem("marco:nostr-photo-fallback-uploads");null!==i&&(t.nostrPhotoFallbackUploads="true"===i);const s=localStorage.getItem("marco:photon-api");s&&(t.photonApi=s)}const n={...EU,...t};this.overpassApis.some(t=>t.url===n.overpassApi)||(n.overpassApi=EU.overpassApi),this.overpassApi=n.overpassApi,this.mapKinetic=n.mapKinetic,this.photonApi=n.photonApi,this.showQuickSearchButtons=n.showQuickSearchButtons,this.nostrPhotoFallbackUploads=n.nostrPhotoFallbackUploads,this.nostrReadRelays=n.nostrReadRelays,this.nostrWriteRelays=n.nostrWriteRelays,this.nostrReadRelayExclusions=n.nostrReadRelayExclusions,this.nostrWriteRelayExclusions=n.nostrWriteRelayExclusions,this.experimentalEnablePhotoDeletion=n.experimentalEnablePhotoDeletion,this.saveSettings()}saveSettings(){const t={overpassApi:this.overpassApi,mapKinetic:this.mapKinetic,photonApi:this.photonApi,showQuickSearchButtons:this.showQuickSearchButtons,nostrPhotoFallbackUploads:this.nostrPhotoFallbackUploads,nostrReadRelays:this.nostrReadRelays,nostrWriteRelays:this.nostrWriteRelays,nostrReadRelayExclusions:this.nostrReadRelayExclusions,nostrWriteRelayExclusions:this.nostrWriteRelayExclusions,experimentalEnablePhotoDeletion:this.experimentalEnablePhotoDeletion};localStorage.setItem("marco:settings",JSON.stringify(t))}update(t,e){t in EU&&(this[t]=e,this.saveSettings())}},TU=o((t,e)=>{var n,r;n=t,r=function(){return function(){var t={548:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Access=void 0;class n{constructor(t){this.rs=t,this.reset(!1)}get scopes(){return Object.keys(this.scopeModeMap).map(t=>({name:t,mode:this.scopeModeMap[t]}))}get scopeParameter(){return this.scopes.map(t=>`${this._scopeNameForParameter(t)}:${t.mode}`).join(" ")}claim(t,e){if("string"!=typeof t||-1!==t.indexOf("/")||0===t.length)throw new Error("Scope should be a non-empty string without forward slashes");if("string"!=typeof e||!e.match(/^rw?$/))throw new Error("Mode should be either 'r' or 'rw'");this._adjustRootPaths(t),this.scopeModeMap[t]=e,this._notifyChange()}get(t){return this.scopeModeMap[t]}remove(t){const e={};for(const n in this.scopeModeMap)e[n]=this.scopeModeMap[n];this.reset(!1),delete e[t];for(const n in e)this._adjustRootPaths(n),this.scopeModeMap[n]=e[n];this._notifyChange()}checkPermission(t,e){const n=this.get(t);return n&&("r"===e||"rw"===n)}checkPathPermission(t,e){if(this.checkPermission("*",e))return!0;const n=this._getModuleName(t);return!!this.checkPermission(n,e)}reset(t=!0){this.rootPaths=[],this.scopeModeMap={},t&&this._notifyChange()}_getModuleName(t){if("/"!==t[0])throw new Error("Path should start with a slash");const e=t.replace(/^\/public/,"").match(/^\/([^/]*)\//);return e?e[1]:"*"}_adjustRootPaths(t){"*"in this.scopeModeMap||"*"===t?this.rootPaths=["/"]:t in this.scopeModeMap||(this.rootPaths.push("/"+t+"/"),this.rootPaths.push("/public/"+t+"/"))}_scopeNameForParameter(t){if("*"===t.name&&this.storageType){if("2012.04"===this.storageType)return"";if(this.storageType.match(/remotestorage-0[01]/))return"root"}return t.name}setStorageType(t){this.storageType=t}_notifyChange(){this.rs&&"function"==typeof this.rs._checkScopeChange&&this.rs._checkScopeChange()}static _rs_init(){}}e.Access=n,e.default=n},275:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Authorize=void 0;const s=i(n(28)),o=i(n(334)),a=n(746),l=i(n(503)),c=n(368);let u;function h(t){const e=t||d.getLocation().href,n={};for(const[s,o]of new URL(e).searchParams)n[s]=o;const r=e.indexOf("#");if(-1===r)return n;const i=e.substring(r+1);return i.includes("=")?i.split("&").reduce(function(t,e){const n=e.split("=");if("state"===n[0]&&n[1].match(/rsDiscovery/)){let e=decodeURIComponent(n[1]);const r=e.substr(e.indexOf("rsDiscovery=")).split("&")[0].split("=")[1];t.rsDiscovery=JSON.parse(atob(r)),e=e.replace(new RegExp("&?rsDiscovery="+r),""),e.length>0&&(t.state=e)}else t[decodeURIComponent(n[0])]=decodeURIComponent(n[1]);return t},n):n}class d{static authorize(t,e){if((0,o.default)("[Authorize] authURL = ",e.authURL,"scope = ",e.scope,"redirectUri = ",e.redirectUri,"clientId = ",e.clientId,"response_type =",e.response_type),!e.scope)throw new Error("Cannot authorize due to undefined or empty scope; did you forget to access.claim()?");if("function"==typeof t._rememberPendingScope&&t._rememberPendingScope(e.scope),!(0,a.localStorageAvailable)()&&"remotestorage"===t.backend){e.redirectUri+=e.redirectUri.indexOf("#")>0?"&":"#";const n={userAddress:t.remote.userAddress,href:t.remote.href,storageApi:t.remote.storageApi,properties:t.remote.properties};e.redirectUri+="rsDiscovery="+(0,a.toBase64)(JSON.stringify(n))}const n=function(t){const e=new URL(t.redirectUri);t.state||(t.state=e.hash?e.hash.substring(1):""),t.response_type||(t.response_type="token");const n=new URL(t.authURL);n.searchParams.set("redirect_uri",t.redirectUri.replace(/#.*$/,"")),n.searchParams.set("scope",t.scope),n.searchParams.set("client_id",t.clientId);for(const r of["state","response_type","code_challenge","code_challenge_method","token_access_type"]){const e=t[r];e&&n.searchParams.set(r,e)}return n.href}(e);a.globalContext.cordova&&(d.getLocation().href.startsWith("file:")||"string"==typeof s.default.cordovaRedirectUri&&e.redirectUri===s.default.cordovaRedirectUri)?d.openWindow(n,e.redirectUri,"location=yes,clearsessioncache=yes,clearcache=yes").then(n=>{t.remote.configure({token:n.access_token}),"function"==typeof t._completeAuthorization&&t._completeAuthorization(n.scope||e.scope)}):d.setLocation(n)}static refreshAccessToken(t,e,n){return r(this,void 0,void 0,function*(){var t,r,i;yield e.configure({token:null,tokenType:null});const s=new URLSearchParams({grant_type:"refresh_token",client_id:e.clientId,refresh_token:n}),a=yield(0,c.requestWithTimeout)("POST",e.TOKEN_URL,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s.toString(),responseType:"json"});if(200!==(null==a?void 0:a.status))throw yield e.configure({refreshToken:null}),new l.default("refresh token rejected:"+JSON.stringify(a.response));{(0,o.default)(`[Authorize] access token good for ${null===(t=null==a?void 0:a.response)||void 0===t?void 0:t.expires_in} seconds`);const n={token:null===(r=null==a?void 0:a.response)||void 0===r?void 0:r.access_token,tokenType:null===(i=null==a?void 0:a.response)||void 0===i?void 0:i.token_type};if(!n.token)throw new Error(`no access_token in "successful" refresh: ${a.response}`);yield e.configure(n)}})}static setLocation(t){if("string"==typeof t)document.location.href=t;else{if("object"!=typeof t)throw"Invalid location "+t;document.location.href=t.href}}static _rs_supported(){return"undefined"!=typeof document}static _rs_cleanup(t){t.removeEventListener("features-loaded",u)}}e.Authorize=d,d.IMPLIED_FAKE_TOKEN=!1,d.getLocation=function(){return document.location},d.openWindow=function(t,e,n){return new Promise((r,i)=>{const s=open(t,"_blank",n);function o(){i("Authorization was canceled")}s&&!s.closed?(s.addEventListener("loadstart",function(t){if(0!==t.url.indexOf(e))return;s.removeEventListener("exit",o),s.close();const n=h(t.url);n?r(n):i("Authorization error")}),s.addEventListener("exit",o)):i("Authorization popup was blocked")})},d._rs_init=function(t){const e=h(),n=function(t){return"string"==typeof t.access_token||"string"==typeof t.code||"string"==typeof t.error||"string"==typeof t.remotestorage||"object"==typeof t.rsDiscovery}(e);let i;n&&(i=d.getLocation(),i.hash=""),u=function(){let s=!1;if(n){if(e.error)throw"function"==typeof t._forgetPendingScope&&t._forgetPendingScope(),"access_denied"===e.error?new l.default("Authorization failed: access denied",{code:"access_denied"}):new l.default(`Authorization failed: ${e.error}`);e.rsDiscovery&&t.remote.configure(e.rsDiscovery),e.access_token&&(t.remote.configure({token:e.access_token}),"function"==typeof t._completeAuthorization&&t._completeAuthorization(e.scope),s=!0),e.remotestorage&&(t.connect(e.remotestorage),s=!0),e.state&&(i=d.getLocation(),d.setLocation(i.href.split("#")[0]+"#"+e.state)),e.code&&(function(e){r(this,void 0,void 0,function*(){var n,r,s,a,l;const u=sessionStorage.getItem("remotestorage:codeVerifier");if(!u)return void(0,o.default)("[Authorize] Ignoring OAuth code parameter, because no PKCE code verifier found in sessionStorage");i=d.getLocation();let h=i.origin;"/"!==i.pathname&&(h+=i.pathname);const p=new URLSearchParams({code:e,grant_type:"authorization_code",client_id:t.remote.clientId,redirect_uri:h,code_verifier:u}),f=yield(0,c.requestWithTimeout)("POST",t.remote.TOKEN_URL,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:p.toString(),responseType:"json"});switch(f.status){case 200:{(0,o.default)(`[Authorize] access token good for ${null===(n=null==f?void 0:f.response)||void 0===n?void 0:n.expires_in} seconds`);const e={token:null===(r=null==f?void 0:f.response)||void 0===r?void 0:r.access_token,refreshToken:null===(s=null==f?void 0:f.response)||void 0===s?void 0:s.refresh_token,tokenType:null===(a=null==f?void 0:f.response)||void 0===a?void 0:a.token_type};e.token?(t.remote.configure(e),"function"==typeof t._completeAuthorization&&t._completeAuthorization(null===(l=null==f?void 0:f.response)||void 0===l?void 0:l.scope)):t._emit("error",new Error(`no access_token in "successful" response: ${f.response}`)),sessionStorage.removeItem("remotestorage:codeVerifier");break}default:"function"==typeof t._forgetPendingScope&&t._forgetPendingScope(),t._emit("error",new Error(`${f.statusText}: ${f.response}`))}})}(e.code),s=!0),s||t.remote.stopWaitingForToken()}else t.remote.stopWaitingForToken()},t.on("features-loaded",u)},e.default=d},424:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.BaseClient=void 0;const s=i(n(439)),o=i(n(613)),a=i(n(491)),l=i(n(93)),c=i(n(28)),u=n(746);class h{constructor(t,e){if(this.schemas={configurable:!0,get(){return h.Types.inScope(this.moduleName)}},"/"!==e[e.length-1])throw"Not a folder: "+e;"/"===e&&(this.makePath=t=>("/"===t[0]?"":"/")+t),this.storage=t,this.base=e,this.moduleName=function(t){const e=t.split("/");return t.length>2?e[1]:"root"}(this.base),this.addEvents(["change"]),this.on=this.on.bind(this),t.onChange(this.base,this._fireChange.bind(this))}scope(t){return new h(this.storage,this.makePath(t))}getListing(t,e){return r(this,void 0,void 0,function*(){if("string"!=typeof t)t="";else if(t.length>0&&!(0,u.isFolder)(t))return Promise.reject("Not a folder: "+t);return this.storage.get(this.makePath(t),e).then(t=>404===t.statusCode?{}:t.body)})}getAll(t,e){return r(this,void 0,void 0,function*(){if("string"!=typeof t)t="";else if(t.length>0&&!(0,u.isFolder)(t))return Promise.reject("Not a folder: "+t);return this.storage.get(this.makePath(t),e).then(n=>{if(404===n.statusCode)return{};if("object"==typeof n.body){const r=Object.keys(n.body);if(0===r.length)return{};const i=r.map(r=>this.storage.get(this.makePath(t+r),e).then(t=>{if("string"==typeof t.body)try{t.body=JSON.parse(t.body)}catch(t){}"object"==typeof t.body&&(n.body[r]=t.body)}));return Promise.all(i).then(()=>n.body)}})})}getFile(t,e){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.getFile must be a string"):this.storage.get(this.makePath(t),e).then(t=>({data:t.body,contentType:t.contentType,revision:t.revision}))})}storeFile(t,e,n){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'contentType' of baseClient.storeFile must be a string"):"string"!=typeof e?Promise.reject("Argument 'path' of baseClient.storeFile must be a string"):"string"!=typeof n&&"object"!=typeof n?Promise.reject("Argument 'body' of baseClient.storeFile must be a string, ArrayBuffer, or ArrayBufferView"):(this.storage.access.checkPathPermission(this.makePath(e),"rw")||console.warn("WARNING: Editing a document to which only read access ('r') was claimed"),this.storage.put(this.makePath(e),n,t).then(t=>200===t.statusCode||201===t.statusCode?t.revision:Promise.reject("Request (PUT "+this.makePath(e)+") failed with status: "+t.statusCode)))})}getObject(t,e){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.getObject must be a string"):this.storage.get(this.makePath(t),e).then(e=>{if("object"==typeof e.body)return e.body;if("string"==typeof e.body)try{return JSON.parse(e.body)}catch(e){throw new Error("Not valid JSON: "+this.makePath(t))}else if(void 0!==e.body&&200===e.statusCode)return Promise.reject("Not an object: "+this.makePath(t))})})}storeObject(t,e,n){return r(this,void 0,void 0,function*(){if("string"!=typeof t)return Promise.reject("Argument 'typeAlias' of baseClient.storeObject must be a string");if("string"!=typeof e)return Promise.reject("Argument 'path' of baseClient.storeObject must be a string");if("object"!=typeof n)return Promise.reject("Argument 'object' of baseClient.storeObject must be an object");this._attachType(n,t);try{const t=this.validate(n);if(!t.valid)return Promise.reject(t)}catch(t){return Promise.reject(t)}return this.storage.put(this.makePath(e),JSON.stringify(n),"application/json; charset=UTF-8").then(t=>200===t.statusCode||201===t.statusCode?t.revision:Promise.reject("Request (PUT "+this.makePath(e)+") failed with status: "+t.statusCode))})}remove(t){return r(this,void 0,void 0,function*(){return"string"!=typeof t?Promise.reject("Argument 'path' of baseClient.remove must be a string"):(this.storage.access.checkPathPermission(this.makePath(t),"rw")||console.warn("WARNING: Removing a document to which only read access ('r') was claimed"),this.storage.delete(this.makePath(t),this.storage.connected))})}getItemURL(t){return r(this,void 0,void 0,function*(){if("string"!=typeof t)throw"Argument 'path' of baseClient.getItemURL must be a string";if(this.storage.connected)return"function"==typeof this.storage.remote.getItemURL?this.storage.remote.getItemURL(this.makePath(t)):this.storage.remote.href+(0,u.cleanPath)(this.makePath(t))})}cache(t,e="ALL"){if("string"!=typeof t)throw"Argument 'path' of baseClient.cache must be a string";if("string"!=typeof e)throw"Argument 'strategy' of baseClient.cache must be a string or undefined";if("FLUSH"!==e&&"SEEN"!==e&&"ALL"!==e)throw'Argument \'strategy\' of baseclient.cache must be one of ["FLUSH", "SEEN", "ALL"]';return this.storage.caching.set(this.makePath(t),e),this}declareType(t,e,n){let r;if(n&&"string"==typeof e)r=e;else if(n||"string"==typeof e){if(!n&&"string"==typeof e)throw new Error("declareType() requires a JSON Schema object to be passed, in order to validate object types/formats")}else n=e,r=this._defaultTypeURI(t);h.Types.declare(this.moduleName,t,r,n)}validate(t){const e=h.Types.getSchema(t["@context"]);if(e)return s.default.validateResult(t,e);throw new a.default(t["@context"])}_defaultTypeURI(t){return"http://remotestorage.io/spec/modules/"+encodeURIComponent(this.moduleName)+"/"+encodeURIComponent(t)}_attachType(t,e){t["@context"]=h.Types.resolveAlias(this.moduleName+"/"+e)||this._defaultTypeURI(e)}makePath(t){return this.base+(t||"")}_fireChange(t){c.default.changeEvents[t.origin]&&(["new","old","lastCommon"].forEach(function(e){if((!t[e+"ContentType"]||/^application\/(.*)json(.*)/.exec(t[e+"ContentType"]))&&"string"==typeof t[e+"Value"])try{t[e+"Value"]=JSON.parse(t[e+"Value"])}catch(t){}}),this._emit("change",t))}static _rs_init(){}}e.BaseClient=h,h.Types=o.default,(0,u.applyMixins)(h,[l.default]),e.default=h},285:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Caching=void 0;const i=n(746),s=r(n(334));class o{constructor(t){this.pendingActivations=[],this._access=t.access,this.reset()}set(t,e){if("string"!=typeof t)throw new Error("path should be a string");if(!(0,i.isFolder)(t))throw new Error("path should be a folder");if(!this._access.checkPathPermission(t,"r"))throw new Error('No access to path "'+t+'". You must claim access to it first.');if(void 0===e||!e.match(/^(FLUSH|SEEN|ALL)$/))throw new Error("strategy should be 'FLUSH', 'SEEN', or 'ALL'");this._rootPaths[t]=e,"ALL"===e&&(this.activateHandler?this.activateHandler(t):this.pendingActivations.push(t))}enable(t){this.set(t,"ALL")}disable(t){this.set(t,"FLUSH")}onActivate(t){(0,s.default)("[Caching] Setting activate handler",t,this.pendingActivations),this.activateHandler=t;for(let e=0;e{this.emitChange(t.data)})}get(t,e,n){return r(this,void 0,void 0,function*(){return"number"==typeof e?this.getNodes((0,c.pathsFromRoot)(t)).then(r=>{const i=u(r[t]);return h(r,e)?n(t):i?{statusCode:200,body:i.body||i.itemsMap,contentType:(0,c.stripLegacyCharsetBinary)(i.contentType||null)}:{statusCode:404}}):this.getNodes([t]).then(e=>{const n=u(e[t]);if(n){if((0,c.isFolder)(t))for(const t in n.itemsMap)n.itemsMap.hasOwnProperty(t)&&!1===n.itemsMap[t]&&delete n.itemsMap[t];return{statusCode:200,body:n.body||n.itemsMap,contentType:(0,c.stripLegacyCharsetBinary)(n.contentType||null)}}return{statusCode:404}})})}put(t,e,n){return r(this,void 0,void 0,function*(){const r=(0,c.pathsFromRoot)(t);return this._updateNodes(r,function(t,r){try{for(let i=0,s=t.length;i0)break}else console.error("Cannot delete non-existing node "+i)}return n})})}flush(t){return this._getAllDescendentPaths(t).then(t=>this.getNodes(t)).then(t=>{for(const e in t){const n=t[e];n&&n.common&&n.local&&this.emitChange({path:n.path,origin:"local",oldValue:!1===n.local.body?void 0:n.local.body,newValue:!1===n.common.body?void 0:n.common.body}),t[e]=void 0}return this.setNodes(t)})}emitChange(t){a.default.changeEvents[t.origin]&&this._emit("change",t)}fireInitial(){a.default.changeEvents.local&&this.forAllNodes(t=>{if((0,c.isDocument)(t.path)){const e=u(t);e&&this.emitChange({path:t.path,origin:"local",oldValue:void 0,oldContentType:void 0,newValue:e.body,newContentType:e.contentType})}}).then(()=>{this._emit("local-events-done")})}onDiff(t){this.diffHandler=t}_updateNodes(t,e){return new Promise((n,r)=>{this._doUpdateNodes(t,e,{resolve:n,reject:r})})}_doUpdateNodes(t,e,n){return r(this,void 0,void 0,function*(){if(this._updateNodesRunning)return void this._updateNodesQueued.push({paths:t,cb:e,promise:n});this._updateNodesRunning=!0;try{let r=yield this.getNodes(t);const i=(0,c.deepClone)(r),s=[];r=e(t,r);for(const t in r){const e=r[t];(0,c.equal)(e,i[t])?delete r[t]:(0,c.isDocument)(t)&&((0,c.equal)(e.local.body,e.local.previousBody)&&e.local.contentType===e.local.previousContentType||s.push({path:t,origin:"window",oldValue:e.local.previousBody,newValue:!1===e.local.body?void 0:e.local.body,oldContentType:e.local.previousContentType,newContentType:e.local.contentType}),void 0===e.local.body?r[t]=void 0:(delete e.local.previousBody,delete e.local.previousContentType))}yield this.setNodes(r),this._emitChangeEvents(s),n.resolve({statusCode:200})}catch(t){n.reject(t)}this._updateNodesRunning=!1;const r=this._updateNodesQueued.shift();r&&(yield this._doUpdateNodes(r.paths,r.cb,r.promise))})}_emitChangeEvents(t){for(let e=0,n=t.length;e{const n=[t],r=u(e[t]),i=Object.keys(r.itemsMap).map(e=>this._getAllDescendentPaths(t+e).then(t=>{for(let e=0,r=t.length;en)}):Promise.resolve([t])}_getInternals(){return{getLatest:u,makeNode:d,isOutdated:h}}}(0,c.applyMixins)(f,[o.default]),t.exports=f},28:function(t){t.exports={cache:!0,changeEvents:{local:!0,window:!1,remote:!0,conflict:!0},cordovaRedirectUri:void 0,discovery:{allowPrivateAddresses:!0,timeout:5e3},logging:!1,modules:[],backgroundSyncInterval:6e4,disableFeatures:[],isBackground:!1,requestTimeout:3e4,syncInterval:1e4}},373:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(713)),s=r(n(28)),o=r(n(334)),a=n(746);let l;const c="remotestorage:discover";let u={};const h=function(t){if(t in u)return Promise.resolve(u[t]);const e=new i.default({tls_only:!1,uri_fallback:!0,request_timeout:s.default.discovery.timeout,allow_private_addresses:s.default.discovery.allowPrivateAddresses});let n;const r=new Promise((t,e)=>{n=setTimeout(()=>{e(new Error("timed out"))},s.default.discovery.timeout)});return Promise.race([e.lookup(t),r]).then(e=>{if(clearTimeout(n),"object"!=typeof e.idx.links.remotestorage||"number"!=typeof e.idx.links.remotestorage.length||e.idx.links.remotestorage.length<=0)throw(0,o.default)("[Discover] WebFinger record for "+t+" does not have remotestorage defined in the links section ",JSON.stringify(e.object)),new Error("WebFinger record for "+t+" does not have remotestorage defined in the links section.");const r=e.idx.links.remotestorage[0],i=r.properties||{},s=i["http://tools.ietf.org/html/rfc6749#section-4.2"]||i["auth-endpoint"],a=i["http://remotestorage.io/spec/version"]||r.type;return u[t]={href:r.href,storageApi:a,authURL:s,properties:i},l&&localStorage.setItem(c,JSON.stringify({cache:u})),u[t]}).catch(t=>{throw clearTimeout(n),t})};(h.DiscoveryError=function(t){this.name="DiscoveryError",this.message=t,this.stack=(new Error).stack}).prototype=Object.create(Error.prototype),h.DiscoveryError.prototype.constructor=h.DiscoveryError,h._rs_init=function(){if(l=(0,a.localStorageAvailable)(),l){const t=JSON.parse(localStorage.getItem(c));t&&(u=t.cache)}},h._rs_supported=function(){return Object.prototype.hasOwnProperty.call(a.globalContext,"fetch")||Object.prototype.hasOwnProperty.call(a.globalContext,"XMLHttpRequest")},h._rs_cleanup=function(){l&&localStorage.removeItem(c)},t.exports=h},706:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const s=i(n(93)),o=i(n(941)),a=i(n(982)),l=i(n(503)),c=n(746),u=n(368),h=n(684),d=i(n(275));let p;const f="remotestorage:dropbox",g="https://api.dropboxapi.com/2/files/list_folder",m="https://api.dropboxapi.com/2/files/list_folder/continue";function y(t){return("/remotestorage/"+t).replace(/\/+$/,"").replace(/\/+/g,"/")}const v=/[\u007f-\uffff]/g;function b(t){return JSON.stringify(t).replace(v,function(t){return"\\u"+("000"+t.charCodeAt(0).toString(16)).slice(-4)})}function w(t,e){return new RegExp("^"+e.join("\\/")+"(\\/|$)").test(t.error_summary)}class _ extends h.RemoteBase{constructor(t){if(super(t),this.online=!0,this.storageApi="draft-dejong-remotestorage-19",this._initialFetchDone=!1,this.addEvents(["connected","not-connected"]),this.clientId=t.apiKeys.dropbox.appKey,this.TOKEN_URL="https://api.dropboxapi.com/oauth2/token",this._revCache=new o.default("rev"),this._fetchDeltaCursor=null,this._fetchDeltaPromise=null,this._itemRefs={},p=(0,c.localStorageAvailable)(),p){const t=(0,c.getJSONFromLocalStorage)(f);t&&this.configure(t),this._itemRefs=(0,c.getJSONFromLocalStorage)(`${f}:shares`)||{}}this.connected&&setTimeout(this._emit.bind(this),0,"connected")}connect(){return r(this,void 0,void 0,function*(){try{if(this.rs.setBackend("dropbox"),this.token)k(this.rs);else{const{codeVerifier:t,codeChallenge:e,state:n}=yield(0,c.generateCodeVerifier)();sessionStorage.setItem("remotestorage:codeVerifier",t),sessionStorage.setItem("remotestorage:state",n),this.rs.authorize({authURL:"https://www.dropbox.com/oauth2/authorize",scope:"account_info.read files.content.read files.content.write files.metadata.read files.metadata.write sharing.read sharing.write",clientId:this.clientId,response_type:"code",state:n,code_challenge:e,code_challenge_method:"S256",token_access_type:"offline"})}}catch(t){throw this.rs._emit("error",t),this.rs.setBackend(void 0),t}})}configure(t){return r(this,void 0,void 0,function*(){void 0!==t.userAddress&&(this.userAddress=t.userAddress),void 0!==t.token&&(this.token=t.token),void 0!==t.refreshToken&&(this.refreshToken=t.refreshToken),void 0!==t.tokenType&&(this.tokenType=t.tokenType);const e=()=>{p&&localStorage.setItem(f,JSON.stringify({userAddress:this.userAddress,token:this.token,refreshToken:this.refreshToken,tokenType:this.tokenType}))};if(this.refreshToken||this.token)if(this.connected=!0,this.userAddress)this._emit("connected"),e();else try{const t=yield this.info();this.userAddress=t.email,this._emit("connected"),e()}catch(t){this.connected=!1,this.rs._emit("error",new Error("Could not fetch user info.")),e.apply(this)}else(()=>{this.connected=!1,p&&(localStorage.removeItem(f),localStorage.removeItem(`${f}:shares`)),this.rs.setBackend(void 0)})()})}_getFolder(t){const e=this._revCache,n=n=>{let i;if(200!==n.status&&409!==n.status)return Promise.reject("Unexpected response status: "+n.status);try{i=JSON.parse(n.responseText)}catch(t){return Promise.reject(t)}if(409===n.status)return w(i,["path","not_found"])?Promise.resolve({}):Promise.reject(new Error("API returned an error: "+i.error_summary));const s=i.entries.reduce((n,r)=>{try{const i="folder"===r[".tag"],s=r.path_display.split("/").slice(-1)[0]+(i?"/":"");if(i)n[s]={ETag:e.get(t+s)};else{const e=new Date(r.server_modified);n[s]={ETag:r.rev,"Content-Length":r.size,"Last-Modified":e.toUTCString()},this._revCache.set(t+s,r.rev)}}catch(e){console.error(`[Dropbox] folder “${t}” has entry ${JSON.stringify(r)}:`,e)}return n},{});return i.has_more?r(i.cursor).then(function(t){return Object.assign(s,t)}):Promise.resolve(s)},r=t=>{const e={body:{cursor:t}};return this._request("POST",m,e).then(n)};return this._request("POST",g,{body:{path:y(t)}}).then(n).then(function(n){return Promise.resolve({statusCode:200,body:n,contentType:"application/json; charset=UTF-8",revision:e.get(t)})})}get(t,e={}){if(!this.connected)return Promise.reject("not connected (path: "+t+")");const n=this._revCache.get(t);if(null===n)return Promise.resolve({statusCode:404});if(e&&e.ifNoneMatch){if(!this._initialFetchDone)return this.fetchDelta().then(()=>this.get(t,e));if(n&&n===e.ifNoneMatch)return Promise.resolve({statusCode:304})}if("/"===t.slice(-1))return this._getFolder(t);const r={headers:{"Dropbox-API-Arg":b({path:y(t)})},responseType:"arraybuffer"};return e&&e.ifNoneMatch&&(r.headers["If-None-Match"]=e.ifNoneMatch),this._request("GET","https://content.dropboxapi.com/2/files/download",r).then(e=>{const n=e.status;let r,i,s,o;return 200!==n&&409!==n?Promise.resolve({statusCode:n}):(r=e.getResponseHeader("Dropbox-API-Result"),(0,c.getTextFromArrayBuffer)(e.response,"UTF-8").then(a=>{i=a,409===n&&(r=i);try{r=JSON.parse(r)}catch(t){return Promise.reject(t)}if(409===n)return w(r,["path","not_found"])?{statusCode:404}:Promise.reject(new Error('API error while downloading file ("'+t+'"): '+r.error_summary));if(s=e.getResponseHeader("Content-Type"),o=r.rev,this._revCache.set(t,o),this._shareIfNeeded(t),(0,c.shouldBeTreatedAsBinary)(a,s))i=e.response;else try{i=JSON.parse(i),s="application/json; charset=UTF-8"}catch(t){}return{statusCode:n,body:i,contentType:(0,c.stripLegacyCharsetBinary)(s),revision:o}}))})}put(t,e,n){return r(this,arguments,void 0,function*(t,e,n,r={}){if(!this.connected)throw new Error("not connected (path: "+t+")");const i=this._revCache.get(t);if(r&&r.ifMatch&&i&&i!==r.ifMatch)return{statusCode:412,revision:i};if(r&&"*"===r.ifNoneMatch&&i&&"rev"!==i)return{statusCode:412,revision:i};if(e.length>157286400)throw new Error("Cannot upload file larger than 150MB");const s={body:e,contentType:n,path:t};if(r&&(r.ifMatch||"*"===r.ifNoneMatch)){const e=yield this._getMetadata(t);if(r&&"*"===r.ifNoneMatch&&e)return{statusCode:412,revision:e.rev};if(r&&r.ifMatch&&e&&e.rev!==r.ifMatch)return{statusCode:412,revision:e.rev}}const o=yield this._uploadSimple(s);return this._shareIfNeeded(t),o})}delete(t){return r(this,arguments,void 0,function*(t,e={}){if(!this.connected)throw new Error("not connected (path: "+t+")");const n=this._revCache.get(t);if((null==e?void 0:e.ifMatch)&&n&&e.ifMatch!==n)return{statusCode:412,revision:n};if(null==e?void 0:e.ifMatch){const n=yield this._getMetadata(t);if((null==e?void 0:e.ifMatch)&&n&&n.rev!==e.ifMatch)return{statusCode:412,revision:n.rev}}return this._deleteSimple(t)})}_shareIfNeeded(t){if(t.match(/^\/public\/.*[^/]$/)&&void 0===this._itemRefs[t])return this.share(t)}getItemURL(t){return r(this,void 0,void 0,function*(){if(t.match(/^\/public\/.*[^/]$/))return this._itemRefs[t]?this._itemRefs[t]:this.share(t)})}share(t){const e={body:{path:y(t)}};return this._request("POST","https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings",e).then(e=>{if(200!==e.status&&409!==e.status)return Promise.reject(new Error("Invalid response status:"+e.status));let n;try{n=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid response body: "+e.responseText))}return 409===e.status?w(n,["shared_link_already_exists"])?this._getSharedLink(t):Promise.reject(new Error("API error: "+n.error_summary)):Promise.resolve(n.url)}).then(e=>(this._itemRefs[t]=e,p&&localStorage.setItem("remotestorage:dropbox:shares",JSON.stringify(this._itemRefs)),Promise.resolve(e)),e=>(e.message='Sharing Dropbox file or folder ("'+t+'") failed: '+e.message,Promise.reject(e)))}info(){return this._request("POST","https://api.dropboxapi.com/2/users/get_current_account",{}).then(function(t){let e;try{const n=JSON.parse(t.responseText);e=null==n?void 0:n.email}catch(e){return Promise.reject(new Error("Could not query current account info: Invalid API response: "+t.responseText))}return Promise.resolve({email:e})})}_request(t,e,n){return r(this,arguments,void 0,function*(t,e,n,r=1){if(this.isForbiddenRequestMethod(t,e))throw`Don't use ${t} on directories!`;if(!this.token)throw new l.default("No access token");var i;n.headers||(n.headers={}),n.headers.Authorization="Bearer "+this.token,"object"!=typeof n.body||(i=n.body)instanceof ArrayBuffer||(0,u.isArrayBufferView)(i)||(n.body=JSON.stringify(n.body),n.headers["Content-Type"]="application/json; charset=UTF-8"),this.rs._emit("wire-busy",{method:t,isFolder:(0,c.isFolder)(e)});try{const i=yield(0,u.requestWithTimeout)(t,e,n);return this.online||(this.online=!0,this.rs._emit("network-online")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!0}),401===(null==i?void 0:i.status)&&this.refreshToken?r>=3?(console.error(`Abandoned after ${r} attempts: ${t} ${e}`),i):(this.rs._emit("wire-busy",{method:t,isFolder:(0,c.isFolder)(e)}),yield d.default.refreshAccessToken(this.rs,this,this.refreshToken),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!0}),this._request(t,e,n,r+1)):[503,429].includes(null==i?void 0:i.status)?(this.online&&(this.online=!1,this.rs._emit("network-offline")),r>=3?(console.warn(`Abandoned after ${r} attempts: ${t} ${e}`),i):(yield new Promise(t=>setTimeout(t,(0,u.retryAfterMs)(i))),this._request(t,e,n,r+1))):i}catch(n){throw this.online&&(this.online=!1,this.rs._emit("network-offline")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!1}),n}})}fetchDelta(...t){if(this._fetchDeltaPromise)return this._fetchDeltaPromise;const e=t=>r(this,void 0,void 0,function*(){let n,r;"string"==typeof t?(n=m,r={cursor:t}):(n=g,r={path:"/remotestorage",recursive:!0,include_deleted:!0});try{const i=yield this._request("POST",n,{body:r});if(401===i.status)throw new l.default;if(200!==i.status&&409!==i.status)throw new Error("Invalid response status: "+i.status);let s;try{s=JSON.parse(i.responseText)}catch(t){throw new Error("Invalid response body: "+i.responseText)}if(409===i.status){if(!w(s,["path","not_found"]))throw new Error("API returned an error: "+s.error_summary);s={cursor:null,entries:[],has_more:!1}}if(t||this._revCache.deactivatePropagation(),s.entries.forEach(t=>{const e=t.path_display.slice(14);"deleted"===t[".tag"]?(this._revCache.delete(e),this._revCache.delete(e+"/")):"file"===t[".tag"]&&this._revCache.set(e,t.rev)}),this._fetchDeltaCursor=s.cursor,s.has_more)return e(s.cursor);this._revCache.activatePropagation(),this._initialFetchDone=!0}catch(t){if("timeout"===t)return;throw t}});return this._fetchDeltaPromise=e(this._fetchDeltaCursor).catch(t=>("object"==typeof t&&"message"in t?t.message="Dropbox: fetchDelta: "+t.message:t=`Dropbox: fetchDelta: ${t}`,this.rs._emit("error",t),this._fetchDeltaPromise=null,Promise.reject(t))).then(()=>(this._fetchDeltaPromise=null,Promise.resolve(t))),this._fetchDeltaPromise}_getMetadata(t){const e={path:y(t)};return this._request("POST","https://api.dropboxapi.com/2/files/get_metadata",{body:e}).then(t=>{if(200!==t.status&&409!==t.status)return Promise.reject(new Error("Invalid response status:"+t.status));let e;try{e=JSON.parse(t.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+t.responseText))}return 409===t.status?w(e,["path","not_found"])?Promise.resolve():Promise.reject(new Error("API error: "+e.error_summary)):Promise.resolve(e)}).then(void 0,e=>(e.message='Could not load metadata for file or folder ("'+t+'"): '+e.message,Promise.reject(e)))}_uploadSimple(t){const e={path:y(t.path),mode:{".tag":"overwrite",update:void 0},mute:!0};return t.ifMatch&&(e.mode={".tag":"update",update:t.ifMatch}),this._request("POST","https://content.dropboxapi.com/2/files/upload",{body:t.body,headers:{"Content-Type":"application/octet-stream","Dropbox-API-Arg":b(e)}}).then(e=>{if(200!==e.status&&409!==e.status)return Promise.resolve({statusCode:e.status});let n;try{n=JSON.parse(e.responseText)}catch(t){return Promise.reject(new Error("Invalid API result: "+e.responseText))}return 409===e.status?w(n,["path","conflict"])?this._getMetadata(t.path).then(function(t){return Promise.resolve({statusCode:412,revision:t.rev})}):(this.rs._emit("error",new Error(n.error_summary)),Promise.resolve({statusCode:e.status})):(this._revCache.set(t.path,n.rev),Promise.resolve({statusCode:e.status,revision:n.rev}))})}_deleteSimple(t){const e={path:y(t)};return this._request("POST","https://api.dropboxapi.com/2/files/delete",{body:e}).then(t=>{if(200!==t.status&&409!==t.status)return Promise.resolve({statusCode:t.status});let e;try{e=JSON.parse(t.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+t.responseText))}if(409===t.status){if(w(e,["path_lookup","not_found"]))return Promise.resolve({statusCode:404});this.rs._emit("error",new Error(e.error_summary))}return Promise.resolve({statusCode:t.status,revision:200===t.status?e.rev:void 0})}).then(e=>(200!==e.statusCode&&404!==e.statusCode||(this._revCache.delete(t),delete this._itemRefs[t]),Promise.resolve(e)),e=>(e.message='Could not delete Dropbox file or folder ("'+t+'"): '+e.message,Promise.reject(e)))}_getSharedLink(t){return r(this,void 0,void 0,function*(){const e={body:{path:y(t),direct_only:!0}};return this._request("POST","https://api.dropboxapi.com/2/sharing/list_shared_links",e).then(t=>{if(200!==t.status&&409!==t.status)return Promise.reject(new Error("Invalid response status: "+t.status));let e;try{e=JSON.parse(t.responseText)}catch(e){return Promise.reject(new Error("Invalid response body: "+t.responseText))}return 409===t.status?Promise.reject(new Error("API error: "+(null==e?void 0:e.error_summary)||0)):e.links.length?Promise.resolve(e.links[0].url):Promise.reject(new Error("No links returned"))},e=>(e.message='Could not get link to a shared file or folder ("'+t+'"): '+e.message,Promise.reject(e)))})}static _rs_init(t){p=(0,c.localStorageAvailable)(),t.apiKeys.dropbox&&(t.dropbox=new _(t)),"dropbox"===t.backend&&k(t)}static _rs_supported(){return!0}static _rs_cleanup(t){(function(t){(function(t){t._origRemote&&(t.remote=t._origRemote,delete t._origRemote)})(t),function(t){t._dropboxOrigSync&&(t.sync.sync=t._dropboxOrigSync,delete t._dropboxOrigSync)}(t),C(t)})(t),p&&localStorage.removeItem(f),t.setBackend(void 0)}}function x(t,...e){t._dropboxOrigSync||(t._dropboxOrigSync=t.sync.sync.bind(t.sync),t.sync.sync=function(){return this.dropbox.fetchDelta(t,...e).then(t._dropboxOrigSync,function(e){t._emit("error",new a.default(e)),t._emit("sync-done",{completed:!1})})}.bind(t))}function C(t){t._dropboxOrigSyncCycle&&(t.syncCycle=t._dropboxOrigSyncCycle,delete t._dropboxOrigSyncCycle)}function k(t){(function(t){t._origRemote||(t._origRemote=t.remote,t.remote=t.dropbox)})(t),t.sync?x(t):function(t,...e){t._dropboxOrigSyncCycle||(t._dropboxOrigSyncCycle=t.syncCycle,t.syncCycle=()=>{if(!t.sync)throw new Error("expected sync to be initialized by now");x(t),t._dropboxOrigSyncCycle(t,...e),C(t)})}(t)}(0,c.applyMixins)(_,[s.default]),t.exports=_},451:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(93)),s=n(746),o=r(n(334));class a{constructor(){this.addEvents(["background","foreground"]),this.mode="undefined"!=typeof window?"browser":"node","browser"===this.mode&&(this.setBrowserPrefixedNames(),document.addEventListener(this.visibilityChangeEvent,this.setVisibility.bind(this),!1),this.setVisibility())}setBrowserPrefixedNames(){"browser"===this.mode&&(void 0!==document.hidden?(this.hiddenProperty="hidden",this.visibilityChangeEvent="visibilitychange"):void 0!==document.mozHidden?(this.hiddenProperty="mozHidden",this.visibilityChangeEvent="mozvisibilitychange"):void 0!==document.msHidden?(this.hiddenProperty="msHidden",this.visibilityChangeEvent="msvisibilitychange"):void 0!==document.webkitHidden&&(this.hiddenProperty="webkitHidden",this.visibilityChangeEvent="webkitvisibilitychange"))}setVisibility(){document[this.hiddenProperty]?((0,o.default)("[Env] Going into background mode"),this.goBackground()):((0,o.default)("[Env] Going into foreground mode"),this.goForeground())}isBrowser(){return"browser"===this.mode}isNode(){return"node"===this.mode}goBackground(){this._emit("background")}goForeground(){this._emit("foreground")}static _rs_init(){}static _rs_cleanup(){}}(0,s.applyMixins)(a,[i.default]),t.exports=a},93:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.EventHandling=void 0;const i=r(n(334));class s{addEvents(t){t.forEach(t=>this._addEvent(t))}addEventListener(t,e){if("string"!=typeof t)throw new Error("Argument eventName should be a string");if("function"!=typeof e)throw new Error("Argument handler should be a function");(0,i.default)("[EventHandling] Adding event listener",t),this._validateEvent(t),this._handlers[t].push(e)}on(t,e){return this.addEventListener(t,e)}removeEventListener(t,e){this._validateEvent(t);const n=this._handlers[t].length;for(let r=0;r{t(...e)})}_validateEvent(t){if(!(t in this._handlers))throw new Error("Unknown event: "+t)}_delegateEvent(t,e){e.on(t,e=>{this._emit(t,e)})}_addEvent(t){void 0===this._handlers&&(this._handlers={}),this._handlers[t]=[]}}e.EventHandling=s,e.default=s},545:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(28)),s=r(n(451)),o=r(n(334)),a=n(746),l=r(n(370)),c=r(n(548)),u=r(n(275)),h=r(n(373)),d=r(n(424)),p=r(n(801)),f=r(n(706)),g=r(n(600)),m=r(n(313)),y=r(n(285)),v=r(n(567)),b=r(n(794)),w=r(n(365));t.exports={features:[],featuresDone:0,readyFired:!1,loadFeatures(){this.features=[],this.featuresDone=0,this.readyFired=!1,this.featureModules={WireClient:g.default,Dropbox:f.default,GoogleDrive:p.default,Access:c.default,Discover:h.default,Authorize:u.default,BaseClient:d.default,Env:s.default},i.default.cache&&(0,a.extend)(this.featureModules,{Caching:y.default,IndexedDB:v.default,LocalStorage:b.default,InMemoryStorage:w.default,Sync:m.default}),i.default.disableFeatures.forEach(t=>{this.featureModules[t]&&delete this.featureModules[t]}),this._allLoaded=!1;for(const t in this.featureModules)this.loadFeature(t)},hasFeature(t){for(let e=this.features.length-1;e>=0;e--)if(this.features[e].name===t)return this.features[e].supported;return!1},loadFeature(t){const e=this.featureModules[t],n=!e._rs_supported||e._rs_supported();(0,o.default)(`[RemoteStorage] [FEATURE ${t}] initializing ...`),"object"==typeof n?n.then(()=>{this.featureSupported(t,!0),this.initFeature(t)},()=>{this.featureSupported(t,!1)}):"boolean"==typeof n?(this.featureSupported(t,n),n&&this.initFeature(t)):this.featureSupported(t,!1)},initFeature(t){const e=this.featureModules[t];let n;try{n=e._rs_init(this)}catch(e){return void this.featureFailed(t,e)}"object"==typeof n&&"function"==typeof n.then?n.then(()=>{this.featureInitialized(t)},e=>{this.featureFailed(t,e)}):this.featureInitialized(t)},featureFailed(t,e){(0,o.default)(`[RemoteStorage] [FEATURE ${t}] initialization failed (${e})`),this.featureDone()},featureSupported(t,e){(0,o.default)(`[RemoteStorage] [FEATURE ${t}]${e?"":"not "} supported`),e||this.featureDone()},featureInitialized(t){(0,o.default)(`[RemoteStorage] [FEATURE ${t}] initialized`),this.features.push({name:t,init:this.featureModules[t]._rs_init,supported:!0,cleanup:this.featureModules[t]._rs_cleanup}),this.featureDone()},featureDone(){this.featuresDone++,this.featuresDone===Object.keys(this.featureModules).length&&setTimeout(this.featuresLoaded.bind(this),0)},_setCachingModule(){["IndexedDB","LocalStorage","InMemoryStorage"].some(t=>{if(this.features.some(e=>e.name===t))return this.features.local=this.featureModules[t],!0})},_fireReady(){try{this.readyFired||(this._emit("ready"),this.readyFired=!0)}catch(t){console.error("'ready' failed: ",t,t.stack),this._emit("error",t)}},featuresLoaded(){(0,o.default)("[RemoteStorage] All features loaded"),this._setCachingModule(),this.local=i.default.cache&&this.features.local&&new this.features.local,this.local&&this.remote?(this._setGPD(l.default,this),this._bindChange(this.local)):this.remote&&this._setGPD(this.remote,this.remote),this.remote&&(this.remote.on("connected",()=>{this._fireReady(),this._emit("connected")}),this.remote.on("not-connected",()=>{this._fireReady(),this._emit("not-connected")}),this.remote.connected&&(this._fireReady(),this._emit("connected")),this.hasFeature("Authorize")||this.remote.stopWaitingForToken()),this._collectCleanupFunctions();try{this._allLoaded=!0,this._emit("features-loaded")}catch(t){(0,a.logError)(t),this._emit("error",t)}this._processPending()},_collectCleanupFunctions(){this._cleanups=[];for(let t=0;t=n-this.maxAge?e.v:void 0}set(t,e){this._items[t]={v:e,t:(new Date).getTime()}}}class m extends a.RemoteBase{constructor(t,e){if(super(t),this.online=!0,this.storageApi="draft-dejong-remotestorage-19",this.addEvents(["connected","not-connected"]),this.clientId=e,this._fileIdCache=new g(300),u=(0,s.localStorageAvailable)(),u){const t=(0,s.getJSONFromLocalStorage)(l);t&&this.configure(t)}}configure(t){void 0!==t.userAddress&&(this.userAddress=t.userAddress),void 0!==t.token&&(this.token=t.token);const e=function(){u&&localStorage.setItem(l,JSON.stringify({userAddress:this.userAddress,token:this.token}))},n=function(){this.connected=!1,delete this.token,u&&localStorage.removeItem(l)};this.token?(this.connected=!0,this.userAddress?(this._emit("connected"),e.apply(this)):this.info().then(t=>{this.userAddress=t.user.emailAddress,this._emit("connected"),e.apply(this)}).catch(()=>{n.apply(this),this.rs._emit("error",new Error("Could not fetch user info."))})):n.apply(this)}connect(){this.rs.setBackend("googledrive"),this.rs.authorize({authURL:"https://accounts.google.com/o/oauth2/auth",scope:"https://www.googleapis.com/auth/drive",clientId:this.clientId})}get(t,e={}){return(0,s.isFolder)(t)?this._getFolder(f(t)):this._getFile(f(t),e)}put(t,e,n,r={}){const i=f(t);function s(t){if(t.status>=200&&t.status<300){const e=JSON.parse(t.responseText),n=this.stripQuotes(e.etag);return Promise.resolve({statusCode:200,contentType:e.mimeType,revision:n})}return 412===t.status?Promise.resolve({statusCode:412,revision:"conflict"}):Promise.reject("PUT failed with status "+t.status+" ("+t.responseText+")")}return this._getFileId(i).then(t=>t?r&&"*"===r.ifNoneMatch?s({status:412}):this._updateFile(t,i,e,n,r).then(s):this._createFile(i,e,n).then(s))}delete(t,e={}){const n=f(t);return this._getFileId(n).then(t=>t?this._getMeta(t).then(n=>{let r;return"object"==typeof n&&"string"==typeof n.etag&&(r=this.stripQuotes(n.etag)),e&&e.ifMatch&&e.ifMatch!==r?{statusCode:412,revision:r}:this._request("DELETE","https://www.googleapis.com/drive/v2/files/"+t,{}).then(t=>200===t.status||204===t.status?{statusCode:200}:Promise.reject("Delete failed: "+t.status+" ("+t.responseText+")"))}):Promise.resolve({statusCode:200}))}info(){return this._request("GET","https://www.googleapis.com/drive/v2/about?fields=user",{}).then(function(t){try{const e=JSON.parse(t.responseText);return Promise.resolve(e)}catch(t){return Promise.reject(t)}})}_updateFile(t,e,n,r,i){const s={mimeType:r},o={"Content-Type":"application/json; charset=UTF-8"};return i&&i.ifMatch&&(o["If-Match"]=this.addQuotes(i.ifMatch)),this._request("PUT","https://www.googleapis.com/upload/drive/v2/files/"+t+"?uploadType=resumable",{body:JSON.stringify(s),headers:o}).then(t=>412===t.status?t:this._request("PUT",t.getResponseHeader("Location"),{body:r.match(/^application\/json/)?JSON.stringify(n):n}))}_createFile(t,e,n){return this._getParentId(t).then(r=>{const i={title:h(p(t)),mimeType:n,parents:[{kind:"drive#fileLink",id:r}]};return this._request("POST","https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable",{body:JSON.stringify(i),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(t=>this._request("POST",t.getResponseHeader("Location"),{body:n.match(/^application\/json/)?JSON.stringify(e):e}))})}_getFile(t,e){return this._getFileId(t).then(t=>this._getMeta(t).then(t=>{let n;if("object"==typeof t&&"string"==typeof t.etag&&(n=this.stripQuotes(t.etag)),e&&e.ifNoneMatch&&n===e.ifNoneMatch)return Promise.resolve({statusCode:304});if(!t.downloadUrl){if(!t.exportLinks||!t.exportLinks["text/html"])return Promise.resolve({statusCode:200,body:"",contentType:t.mimeType,revision:n});t.mimeType+=";export=text/html",t.downloadUrl=t.exportLinks["text/html"]}return this._request("GET",t.downloadUrl,{responseType:"arraybuffer"}).then(e=>(0,s.getTextFromArrayBuffer)(e.response,"UTF-8").then(function(r){let i=r;if(t.mimeType.match(/^application\/json/))try{i=JSON.parse(i)}catch(t){}else(0,s.shouldBeTreatedAsBinary)(r,t.mimeType)&&(i=e.response);return{statusCode:200,body:i,contentType:(0,s.stripLegacyCharsetBinary)(t.mimeType),revision:n}}))}))}_getFolder(t){return this._getFileId(t).then(e=>{let n,r,i;if(!e)return Promise.resolve({statusCode:404});const o="'"+e+"' in parents";return this._request("GET","https://www.googleapis.com/drive/v2/files?q="+encodeURIComponent(o)+"&fields=items(downloadUrl%2Cetag%2CfileSize%2Cid%2CmimeType%2Ctitle%2Clabels)&maxResults=1000&trashed=false",{}).then(e=>{var o;if(200!==e.status)return Promise.reject("request failed or something: "+e.status);try{n=JSON.parse(e.responseText)}catch(t){return Promise.reject("non-JSON response from GoogleDrive")}i={};for(const a of n.items)null!==(o=a.labels)&&void 0!==o&&o.trashed||(r=this.stripQuotes(a.etag),a.mimeType===c?(this._fileIdCache.set(t+(0,s.cleanPath)(a.title)+"/",a.id),i[a.title+"/"]={ETag:r}):(this._fileIdCache.set(t+(0,s.cleanPath)(a.title),a.id),i[a.title]={ETag:r,"Content-Type":a.mimeType,"Content-Length":a.fileSize}));return Promise.resolve({statusCode:200,body:i,contentType:"application/json; charset=UTF-8",revision:void 0})})})}_getParentId(t){const e=d(t);return this._getFileId(e).then(t=>t?Promise.resolve(t):this._createFolder(e))}_createFolder(t){return this._getParentId(t).then(e=>this._request("POST","https://www.googleapis.com/drive/v2/files",{body:JSON.stringify({title:h(p(t)),mimeType:c,parents:[{id:e}]}),headers:{"Content-Type":"application/json; charset=UTF-8"}}).then(t=>{const e=JSON.parse(t.responseText);return Promise.resolve(e.id)}))}_getFileId(t){let e;return"/"===t?Promise.resolve("root"):(e=this._fileIdCache.get(t))?Promise.resolve(e):this._getFolder(d(t)).then(()=>(e=this._fileIdCache.get(t),e?Promise.resolve(e):"/"===t.substr(-1)?this._createFolder(t).then(()=>this._getFileId(t)):Promise.resolve()))}_getMeta(t){return this._request("GET","https://www.googleapis.com/drive/v2/files/"+t,{}).then(function(e){return 200===e.status?Promise.resolve(JSON.parse(e.responseText)):Promise.reject("request (getting metadata for "+t+") failed with status: "+e.status)})}_request(t,e,n){return this.isForbiddenRequestMethod(t,e)?Promise.reject(`Don't use ${t} on directories!`):(n.headers||(n.headers={}),n.headers.Authorization="Bearer "+this.token,this.rs._emit("wire-busy",{method:t,isFolder:(0,s.isFolder)(e)}),(0,o.requestWithTimeout)(t,e,n).then(n=>n&&401===n.status?void this.connect():(this.online||(this.online=!0,this.rs._emit("network-online")),this.rs._emit("wire-done",{method:t,isFolder:(0,s.isFolder)(e),success:!0}),Promise.resolve(n)),n=>(this.online&&(this.online=!1,this.rs._emit("network-offline")),this.rs._emit("wire-done",{method:t,isFolder:(0,s.isFolder)(e),success:!1}),Promise.reject(n))))}getItemURL(t){return r(this,void 0,void 0,function*(){throw new Error("getItemURL is not implemented for Google Drive yet")})}static _rs_init(t){const e=t.apiKeys.googledrive;e&&(t.googledrive=new m(t,e.clientId),"googledrive"===t.backend&&(t._origRemote=t.remote,t.remote=t.googledrive))}static _rs_supported(){return!0}static _rs_cleanup(t){t.setBackend(void 0),t._origRemote&&(t.remote=t._origRemote,delete t._origRemote)}}(0,s.applyMixins)(m,[i.default]),t.exports=m},567:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const s=i(n(93)),o=i(n(496)),a=i(n(334)),l=n(746),c="remotestorage";let u;class h extends o.default{constructor(t){super(),this.addEvents(["change","local-events-done"]),this.db=t||u,this.db?(this.getsRunning=0,this.putsRunning=0,this.changesQueued={},this.changesRunning={},this.commitSlownessWarning=null):(0,a.default)("[IndexedDB] Failed to open DB")}getNodes(t){return r(this,void 0,void 0,function*(){const e=[],n={};for(let r=0,i=t.length;r0?this.getNodesFromDb(e).then(function(t){for(const e in n)t[e]=n[e];return t}):n})}setNodes(t){return r(this,void 0,void 0,function*(){for(const e in t)this.changesQueued[e]=t[e]||!1;this.maybeFlush()})}maybeFlush(){0===this.putsRunning?this.flushChangesQueued():this.commitSlownessWarning||(this.commitSlownessWarning=n.g.setInterval(function(){console.warn("WARNING: waited more than 10 seconds for previous commit to finish")},1e4))}flushChangesQueued(){this.commitSlownessWarning&&(clearInterval(this.commitSlownessWarning),this.commitSlownessWarning=null),Object.keys(this.changesQueued).length>0&&(this.changesRunning=this.changesQueued,this.changesQueued={},this.setNodesInDb(this.changesRunning).then(this.flushChangesQueued.bind(this)))}getNodesFromDb(t){return new Promise((e,n)=>{const r=this.db.transaction(["nodes"],"readonly"),i=r.objectStore("nodes"),s={};this.getsRunning++,t.map(t=>{i.get(t).onsuccess=e=>{s[t]=e.target.result}}),r.oncomplete=()=>{e(s),this.getsRunning--},r.onerror=r.onabort=()=>{n("get transaction error/abort"),this.getsRunning--}})}setNodesInDb(t){return r(this,void 0,void 0,function*(){return new Promise((e,n)=>{const r=this.db.transaction(["nodes"],"readwrite"),i=r.objectStore("nodes"),s=(new Date).getTime();this.putsRunning++,(0,a.default)("[IndexedDB] Starting puts",t,this.putsRunning);for(const o in t){const e=t[o];if("object"==typeof e)try{i.put(e)}catch(t){throw(0,a.default)("[IndexedDB] Error while putting",e,t),t}else try{i.delete(o)}catch(t){throw(0,a.default)("[IndexedDB] Error while removing",i,e,t),t}}r.oncomplete=()=>{this.putsRunning--,(0,a.default)("[IndexedDB] Finished puts",t,this.putsRunning,(new Date).getTime()-s+"ms"),e()},r.onerror=()=>{this.putsRunning--,n("transaction error")},r.onabort=()=>{n("transaction abort"),this.putsRunning--}})})}reset(t){const e=this.db.name;this.db.close(),h.clean(e,()=>{h.open(e,(n,r)=>{n?(0,a.default)(`[IndexedDB] Error while resetting database ${e}:`,n):this.db=r,"function"==typeof t&&t(self)})})}forAllNodes(t){return r(this,void 0,void 0,function*(){return new Promise(e=>{this.db.transaction(["nodes"],"readonly").objectStore("nodes").openCursor().onsuccess=n=>{const r=n.target.result;r?(t(r.value),r.continue()):e()}})})}closeDB(){0===this.putsRunning?this.db.close():setTimeout(this.closeDB.bind(this),100)}static open(t,e){const n=setTimeout(function(){e("timeout trying to open db")},1e4);try{const r=indexedDB.open(t,2);r.onerror=function(){(0,a.default)("[IndexedDB] Opening DB failed",r),clearTimeout(n),e(r.error)},r.onupgradeneeded=function(t){const e=r.result;(0,a.default)("[IndexedDB] Upgrade: from ",t.oldVersion," to ",t.newVersion),e.objectStoreNames.contains("nodes")||((0,a.default)("[IndexedDB] Creating object store: nodes"),e.createObjectStore("nodes",{keyPath:"path"})),e.objectStoreNames.contains("changes")||((0,a.default)("[IndexedDB] Creating object store: changes"),e.createObjectStore("changes",{keyPath:"path"}))},r.onsuccess=function(){clearTimeout(n);const i=r.result;if(!i.objectStoreNames.contains("nodes")||!i.objectStoreNames.contains("changes"))return(0,a.default)("[IndexedDB] Missing object store. Resetting the database."),i.close(),void h.clean(t,function(){h.open(t,e)});e(null,r.result)}}catch(r){(0,a.default)("[IndexedDB] Failed to open database: "+r),(0,a.default)("[IndexedDB] Resetting database and trying again."),clearTimeout(n),h.clean(t,function(){h.open(t,e)})}}static clean(t,e){const n=indexedDB.deleteDatabase(t);n.onblocked=function(e){console.warn(`Deleting IndexedDB database "${t}" is blocked by another open connection`,e)},n.onsuccess=function(){(0,a.default)(`[IndexedDB] Deleted database "${t}"`),e()},n.onerror=n.onabort=function(e){console.error('Failed to remove database "'+t+'"',e)}}static _rs_init(t){return new Promise((e,n)=>{h.open(c,function(r,i){if(r)n(r);else{if(!i)return void n(new Error("IndexedDB opened without a database instance"));u=i,i.onerror=e=>{t._emit("error",h.eventToError(e))},e()}})})}static _rs_supported(){return new Promise((t,e)=>{const n=(0,l.getGlobalContext)();let r=!1;if("undefined"!=typeof navigator&&navigator.userAgent.match(/Android (2|3|4\.[0-3])/)&&(navigator.userAgent.match(/Chrome|Firefox/)||(r=!0)),"indexedDB"in n&&!r)try{const n=indexedDB.open("rs-check");n.onerror=function(){e()},n.onsuccess=function(){n.result.close(),indexedDB.deleteDatabase("rs-check"),t()}}catch(t){e()}else e()})}static _rs_cleanup(t){return new Promise(e=>{t.local instanceof h&&t.local.closeDB(),h.clean(c,e)})}static eventToError(t){var e;const n=null==t?void 0:t.target,r=null==n?void 0:n.error;if(r)return r;if(null===(e=null==n?void 0:n.db)||void 0===e?void 0:e.name){const t=n.objectStoreNames,e=t?Array.from(t).join(", "):"";return new Error(`Error in store(s) “${e}” in database “${n.db.name}”`)}return new Error("Unknown IndexedDB error")}diffHandler(){}}(0,l.applyMixins)(h,[s.default]),t.exports=h},365:function(t,e,n){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const i=r(n(93)),s=r(n(496)),o=n(746);class a extends s.default{constructor(){super(),this._storage={},this.addEvents(["change","local-events-done"])}getNodes(t){const e={};for(let n=0,r=t.length;n=2e3&&t<=36e5}var M;!function(t){t.GOOGLE="googledrive",t.DROPBOX="dropbox"}(M||(M={}));class A{constructor(t){if(this._pending=[],this._cleanups=[],this._pathHandlers={change:{}},this.apiKeys={},this._init=x.default.loadFeatures,this.features=x.default.features,this.loadFeature=x.default.loadFeature,this.featureSupported=x.default.featureSupported,this.featureDone=x.default.featureDone,this.featuresDone=x.default.featuresDone,this.featuresLoaded=x.default.featuresLoaded,this.featureInitialized=x.default.featureInitialized,this.featureFailed=x.default.featureFailed,this.hasFeature=x.default.hasFeature,this._setCachingModule=x.default._setCachingModule,this._collectCleanupFunctions=x.default._collectCleanupFunctions,this._fireReady=x.default._fireReady,this.initFeature=x.default.initFeature,"object"==typeof t&&null!==t){const e=t,{discovery:n}=e,r=a(e,["discovery"]);Object.assign(c.default,r),n&&"object"==typeof n&&Object.assign(c.default.discovery,n)}if(this.addEvents(["ready","authing","connecting","connected","disconnected","not-connected","conflict","error","features-loaded","scope-change-required","sync-interval-change","sync-started","sync-req-done","sync-done","wire-busy","wire-done","network-offline","network-online"]),this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")}),S=(0,h.localStorageAvailable)(),S){this.apiKeys=(0,h.getJSONFromLocalStorage)("remotestorage:api-keys")||{};const t=localStorage.getItem("remotestorage:backend");"dropbox"===t||"googledrive"===t?this.setBackend(t):this.setBackend("remotestorage")}this._authorizedScope=this._loadAuthorizedScope(),this._scopeChangeRequired=!1,this._scopeChangeEvent=null;const e=this.on;this.on=function(t,n){const r=e.call(this,t,n);if("scope-change-required"===t&&this._scopeChangeRequired&&this._scopeChangeEvent&&setTimeout(()=>{n(this._scopeChangeEvent)},0),this._allLoaded)switch(t){case"features-loaded":setTimeout(n,0);break;case"ready":this.remote&&setTimeout(n,0);break;case"connected":this.remote&&this.remote.connected&&setTimeout(n,0);break;case"not-connected":this.remote&&!this.remote.connected&&setTimeout(n,0)}return r},this._init(),this.fireInitial=function(){this.local&&setTimeout(this.local.fireInitial.bind(this.local),0)}.bind(this),this.on("ready",this.fireInitial.bind(this)),this.loadModules()}get connected(){return this.remote.connected}get scopeChangeRequired(){return this._scopeChangeRequired}loadModules(){c.default.modules.forEach(this.addModule.bind(this))}authorize(t){if(this.access.setStorageType(this.remote.storageApi),void 0===t.scope&&(t.scope=this.access.scopeParameter),k.cordova&&"string"==typeof c.default.cordovaRedirectUri)t.redirectUri=c.default.cordovaRedirectUri;else{const e=p.default.getLocation();let n=e.origin;"/"!==e.pathname&&(n+=e.pathname),t.redirectUri=n}void 0===t.clientId&&(t.clientId=t.redirectUri.match(/^(https?:\/\/[^/]+)/)[0]),p.default.authorize(this,t)}impliedauth(t,e){t=t||this.remote.storageApi,e=e||String(document.location),(0,u.default)("ImpliedAuth proceeding due to absent authURL; storageApi = "+t+" redirectUri = "+e),this.remote.configure({token:p.default.IMPLIED_FAKE_TOKEN}),document.location.href=e}connect(t,e){if(this.setBackend("remotestorage"),t.indexOf("@")<0&&!t.match(/^(https?:\/\/)?[^\s\/$\.?#]+\.[^\s]*$/))this._emit("error",new A.DiscoveryError("Not a valid user address or URL."));else{if(t.indexOf("@")<0&&!t.match(/^https?:\/\//)&&(t=`https://${t}`),k.cordova){if("string"!=typeof c.default.cordovaRedirectUri)return void this._emit("error",new A.DiscoveryError("Please supply a custom HTTPS redirect URI for your Cordova app"));if(!k.cordova.InAppBrowser)return void this._emit("error",new A.DiscoveryError("Please include the InAppBrowser Cordova plugin to enable OAuth"))}this.remote.configure({userAddress:t}),this._emit("connecting"),A.Discover(t).then(n=>{if(this._emit("authing"),n.userAddress=t,this.remote.configure(n),!this.remote.connected)if(n.authURL)if(void 0===e)this.authorize({authURL:n.authURL});else{if("string"!=typeof e)throw new Error("Supplied bearer token must be a string");(0,u.default)("Skipping authorization sequence and connecting with known token"),this.remote.configure({token:e}),this._rememberAuthorizedScope(this.access.scopeParameter)}else this.impliedauth()},()=>{this._emit("error",new A.DiscoveryError("No storage information found for this user address."))})}}reconnect(){this.remote.configure({token:null}),"remotestorage"===this.backend?this.connect(this.remote.userAddress):this.remote.connect()}reauthorize(){this.reconnect()}disconnect(){this.remote&&this.remote.configure({userAddress:null,href:null,storageApi:null,token:null,refreshToken:null,properties:null}),this._forgetPendingScope(),this._rememberAuthorizedScope(null),this._setGPD({get:this._pendingGPD("get"),put:this._pendingGPD("put"),delete:this._pendingGPD("delete")});const t=this._cleanups.length;let e=0;const n=()=>{e++,e>=t&&(this._init(),(0,u.default)('Cleanups done, emitting "disconnected" event'),this._emit("disconnected"))};t>0?this._cleanups.forEach(t=>{const e=t(this);"object"==typeof e&&"function"==typeof e.then?e.then(n):n()}):n()}setBackend(t){if(this.backend=t,S&&(void 0!==t?localStorage.setItem("remotestorage:backend",t):localStorage.removeItem("remotestorage:backend")),void 0===t)return this._authorizedScope=null,this._scopeChangeRequired=!1,void(this._scopeChangeEvent=null);this._authorizedScope=this._loadAuthorizedScope(),this._checkScopeChange()}_rememberPendingScope(t){const e=T(t);S&&(e&&this.backend?localStorage.setItem(R,JSON.stringify({backend:this.backend,scope:e})):localStorage.removeItem(R))}_forgetPendingScope(){S&&localStorage.removeItem(R)}_rememberAuthorizedScope(t){const e=T(t);S?e&&this.backend?(localStorage.setItem(E,JSON.stringify({backend:this.backend,scope:e})),this._authorizedScope=e,this._checkScopeChange()):(localStorage.removeItem(E),this._authorizedScope=null,this._checkScopeChange()):(this._authorizedScope=e,this._checkScopeChange())}_completeAuthorization(t){const e=this._loadPendingScope()||T(t);this._forgetPendingScope(),e?this._rememberAuthorizedScope(e):this._checkScopeChange()}_checkScopeChange(){const t=T(this.access.scopeParameter),e=this._authorizedScope||this._loadAuthorizedScope(),n=!(!t||!e||t===e),r=n&&(!this._scopeChangeRequired||!this._scopeChangeEvent||this._scopeChangeEvent.requestedScope!==t||this._scopeChangeEvent.authorizedScope!==e);this._scopeChangeRequired=n,n?(this._scopeChangeEvent=this._buildScopeChangeEvent(t,e),r&&this._emit("scope-change-required",this._scopeChangeEvent)):this._scopeChangeEvent=null}_loadAuthorizedScope(){if(!S||!this.backend)return null;const t=L(E);return t&&t.backend===this.backend?T(t.scope):null}_loadPendingScope(){if(!S||!this.backend)return null;const t=L(R);return t&&t.backend===this.backend?T(t.scope):null}_buildScopeChangeEvent(t=T(this.access.scopeParameter),e=this._authorizedScope){return{requestedScope:t||"",authorizedScope:e||"",reauthorize:this.reauthorize.bind(this)}}onChange(t,e){this._pathHandlers.change[t]||(this._pathHandlers.change[t]=[]),this._pathHandlers.change[t].push(e)}enableLog(){c.default.logging=!0}disableLog(){c.default.logging=!1}log(...t){u.default.apply(A,t)}setApiKeys(t){const e=[M.GOOGLE,M.DROPBOX];if("object"!=typeof t||!Object.keys(t).every(t=>e.includes(t)))return console.error("setApiKeys() was called with invalid arguments"),!1;Object.keys(t).forEach(e=>{const n=t[e];if(n){switch(e){case M.DROPBOX:this.apiKeys[M.DROPBOX]={appKey:n},void 0!==this.dropbox&&this.dropbox.clientId===n||v.default._rs_init(this);break;case M.GOOGLE:this.apiKeys[M.GOOGLE]={clientId:n},void 0!==this.googledrive&&this.googledrive.clientId===n||y.default._rs_init(this)}return!0}delete this.apiKeys[e]}),S&&localStorage.setItem("remotestorage:api-keys",JSON.stringify(this.apiKeys))}setCordovaRedirectUri(t){if("string"!=typeof t||!t.match(/http(s)?:\/\//))throw new Error("Cordova redirect URI must be a URI string");c.default.cordovaRedirectUri=t}_setGPD(t,e){function n(t){return function(...n){return t.apply(e,n).then(P.bind(this))}}this.get=n(t.get),this.put=n(t.put),this.delete=n(t.delete)}_pendingGPD(t){return(...e)=>{const n=Array.prototype.slice.call(e);return new Promise((e,r)=>{this._pending.push({method:t,args:n,promise:{resolve:e,reject:r}})})}}_processPending(){this._pending.forEach(t=>{try{this[t.method](...t.args).then(t.promise.resolve,t.promise.reject)}catch(e){t.promise.reject(e)}}),this._pending=[]}_bindChange(t){t.on("change",this._dispatchEvent.bind(this,"change"))}_dispatchEvent(t,e){Object.keys(this._pathHandlers[t]).forEach(n=>{const r=n.length;e.path.substr(0,r)===n&&this._pathHandlers[t][n].forEach(t=>{const r={};for(const n in e)r[n]=e[n];r.relativePath=e.path.replace(new RegExp("^"+n),"");try{t(r)}catch(t){console.error("'change' handler failed: ",t,t.stack),this._emit("error",t)}})})}scope(t){if("string"!=typeof t)throw"Argument 'path' of baseClient.scope must be a string";return this.access.checkPathPermission(t,"r")||console.warn("WARNING: Please use remoteStorage.access.claim() to ask for access permissions first: https://remotestorage.io/rs.js/docs/api/access/classes/Access.html#claim"),new f.default(this,t)}getSyncInterval(){return c.default.syncInterval}setSyncInterval(t){if(!I(t))throw t+" is not a valid sync interval";const e=c.default.syncInterval;c.default.syncInterval=t,this._emit("sync-interval-change",{oldValue:e,newValue:t})}getBackgroundSyncInterval(){return c.default.backgroundSyncInterval}setBackgroundSyncInterval(t){if(!I(t))throw t+" is not a valid sync interval";const e=c.default.backgroundSyncInterval;c.default.backgroundSyncInterval=t,this._emit("sync-interval-change",{oldValue:e,newValue:t})}getCurrentSyncInterval(){return c.default.isBackground?c.default.backgroundSyncInterval:c.default.syncInterval}getRequestTimeout(){return c.default.requestTimeout}setRequestTimeout(t){if("number"!=typeof t)throw t+" is not a valid request timeout";c.default.requestTimeout=t}setupSyncCycle(){this.sync&&!this.sync.stopped&&((0,u.default)("[Sync] Setting up sync cycle"),this.on("sync-done",()=>{(0,u.default)("[Sync] Sync done. Setting timer to",this.getCurrentSyncInterval()),this.sync&&!this.sync.stopped&&(this._syncTimer&&clearTimeout(this._syncTimer),this._syncTimer=setTimeout(this.sync.sync.bind(this.sync),this.getCurrentSyncInterval()))}),this.sync.sync())}startSync(){return c.default.cache?(this.sync.stopped=!1,this.syncStopped=!1,this.sync.sync()):(console.warn("Nothing to sync, because caching is disabled."),Promise.resolve())}stopSync(){clearTimeout(this._syncTimer),this._syncTimer=void 0,this.sync?((0,u.default)("[Sync] Stopping sync"),this.sync.stopped=!0):((0,u.default)("[Sync] Will instantiate sync stopped"),this.syncStopped=!0)}addModule(t){const e=t.name,n=t.builder;if(Object.defineProperty(this,e,{configurable:!0,get:function(){const t=this._loadModule(e,n);return Object.defineProperty(this,e,{value:t}),t}}),-1!==e.indexOf("-")){const t=e.replace(/\-[a-z]/g,function(t){return t[1].toUpperCase()});Object.defineProperty(this,t,{get:function(){return this[e]}})}}_loadModule(t,e){if(e)return e(new f.default(this,"/"+t+"/"),new f.default(this,"/public/"+t+"/")).exports;throw"Unknown module: "+t}}e.RemoteStorage=A,A.SyncError=w.default,A.Unauthorized=_.default,A.Discover=b.default,A.DiscoveryError=b.default.DiscoveryError,A.util=C,Object.defineProperty(A.prototype,"access",{configurable:!0,get:function(){const t=new d.default(this);return Object.defineProperty(this,"access",{value:t,writable:!0,configurable:!0}),t}}),Object.defineProperty(A.prototype,"caching",{configurable:!0,get:function(){const t=new g.default(this);return Object.defineProperty(this,"caching",{value:t,writable:!0,configurable:!0}),t}}),(0,h.applyMixins)(A,[m.EventHandling]),e.default=A},368:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.isArrayBufferView=void 0,e.retryAfterMs=function(t){const e=1e3*parseInt(t.getResponseHeader("Retry-After"));return e>=1e3?e:Math.max(1500,Math.min(6e4,Math.round(o.default.syncInterval/(2.9+.2*Math.random()))))},e.requestWithTimeout=function(t,n,i){return r(this,void 0,void 0,function*(){return"function"==typeof fetch?function(t,e,n){return r(this,void 0,void 0,function*(){const r="function"==typeof AbortController?new AbortController:null;let i;const a=new Promise((t,e)=>{i=setTimeout(()=>{r&&r.abort(),e("timeout")},o.default.requestTimeout)});let l;const c={},u=fetch(e,{method:t,headers:n.headers,body:n.body,signal:r?r.signal:void 0}).then(t=>{switch((0,s.default)("[requests fetch]",t),t.headers.forEach((t,e)=>{c[e.toUpperCase()]=t}),l={readyState:4,status:t.status,statusText:t.statusText,response:void 0,getResponseHeader:t=>c[t.toUpperCase()]||null,responseType:n.responseType,responseURL:e},n.responseType){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"json":return t.json();case void 0:case"":case"text":return t.text();default:throw new Error("responseType 'document' is not currently supported using fetch")}}).then(t=>(l.response=t,n.responseType&&"text"!==n.responseType||(l.responseText=t),l)).finally(()=>{clearTimeout(i)});return Promise.race([u,a])})}(t,n,i):"function"==typeof XMLHttpRequest?function(t,n,i){return r(this,void 0,void 0,function*(){return new Promise((r,a)=>{(0,s.default)("[requests XHR]",t,n);let l=!1;const c=setTimeout(()=>{l=!0,a("timeout")},o.default.requestTimeout),u=new XMLHttpRequest;if(u.open(t,n,!0),i.responseType&&(u.responseType=i.responseType),i.headers)for(const t in i.headers)u.setRequestHeader(t,i.headers[t]);u.onload=()=>{l||(clearTimeout(c),r(u))},u.onerror=t=>{l||(clearTimeout(c),a(t))};let h=i.body;"object"==typeof h&&!(0,e.isArrayBufferView)(h)&&h instanceof ArrayBuffer&&(h=new Uint8Array(h)),u.send(h)})})}(t,n,i):Promise.reject("[Requests] You need to add a polyfill for fetch or XMLHttpRequest")})};const s=i(n(334)),o=i(n(28));if("function"==typeof(n.g||window).ArrayBufferView)e.isArrayBufferView=function(t){return t&&t instanceof(n.g||window).ArrayBufferView};else{const t=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];e.isArrayBufferView=function(e){for(let n=0;n<8;n++)if(e instanceof t[n])return!0;return!1}}},941:function(t){t.exports=class{constructor(t){this._itemsRev={},this._storage={},this._canPropagate=!1,this.defaultValue=t,this.activatePropagation()}get(t){t=t.toLowerCase();let e=this._storage[t];return void 0===e&&(e=this.defaultValue,this._storage[t]=e),e}set(t,e){return t=t.toLowerCase(),this._storage[t]===e||(this._storage[t]=e,e||delete this._itemsRev[t],this._updateParentFolderItemRev(t,e),this._canPropagate&&this._propagate(t)),e}delete(t){return this.set(t,null)}deactivatePropagation(){return this._canPropagate=!1,!0}activatePropagation(){return this._canPropagate||(this._generateFolderRev("/"),this._canPropagate=!0),!0}_hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n0&&(n=this._generateHash(t))}return this.set(t,n),n}}},491:function(t){class e extends Error{constructor(t){super();const e=new Error("Schema not found: "+t);return e.name="SchemaNotFound",e}}t.exports=e},982:function(t){class e extends Error{constructor(t){super(),this.name="SyncError",this.message="Sync failed: ","string"==typeof t?this.message+=t:(this.message+=t.message,this.stack=t.stack,this.originalError=t)}}t.exports=e},313:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Sync=void 0;const s=i(n(28)),o=i(n(451)),a=i(n(93)),l=i(n(334)),c=i(n(275)),u=i(n(982)),h=i(n(503)),d=n(746);let p,f;function g(t,e,n){return{action:t,path:e,promise:n}}function m(t,e){return t.common.revision!==e&&(!t.remote||t.remote.revision!==e)}function y(t){return!!t.common&&!!t.common.revision}class v{constructor(t){this.numThreads=10,this._tasks={},this._running={},this._timeStarted={},this._finishedTasks=[],this.rs=t,this.rs.local.onDiff(t=>{this.addTask(t),this.doTasks()}),this.rs.caching.onActivate(t=>{this.addTask(t),this.doTasks()}),this.addEvents(["done","req-done"])}now(){return(new Date).getTime()}queueGetRequest(t){return r(this,void 0,void 0,function*(){return new Promise((e,n)=>{this.rs.remote.connected?this.rs.remote.online?(this.addTask(t,function(){this.rs.local.get(t).then(t=>e(t))}.bind(this)),this.doTasks()):n("cannot fulfill maxAge requirement - remote is not online"):n("cannot fulfill maxAge requirement - remote is not connected")})})}corruptServerItemsMap(t){if("object"!=typeof t||Array.isArray(t))return!0;for(const e in t){const n=t[e];if("object"!=typeof n)return!0;if("string"!=typeof n.ETag)return!0;if((0,d.isFolder)(e)){if(-1!==e.substring(0,e.length-1).indexOf("/"))return!0}else if(-1!==e.indexOf("/"))return!0}return!1}corruptItemsMap(t){if("object"!=typeof t||Array.isArray(t))return!0;for(const e in t)if("boolean"!=typeof t[e])return!0;return!1}corruptRevision(t){return"object"!=typeof t||Array.isArray(t)||t.revision&&"string"!=typeof t.revision||t.body&&"string"!=typeof t.body&&"object"!=typeof t.body||t.contentType&&"string"!=typeof t.contentType||t.contentLength&&"number"!=typeof t.contentLength||t.timestamp&&"number"!=typeof t.timestamp||t.itemsMap&&this.corruptItemsMap(t.itemsMap)}isCorrupt(t){return"object"!=typeof t||Array.isArray(t)||"string"!=typeof t.path||this.corruptRevision(t.common)||t.local&&this.corruptRevision(t.local)||t.remote&&this.corruptRevision(t.remote)||t.push&&this.corruptRevision(t.push)}hasTasks(){return Object.keys(this._tasks).length>0}collectDiffTasks(){return r(this,void 0,void 0,function*(){let t=0;return this.rs.local.forAllNodes(e=>{t>100||(this.isCorrupt(e)?((0,l.default)("[Sync] WARNING: corrupt node in local cache",e),"object"==typeof e&&e.path&&(this.addTask(e.path),t++)):(this.needsFetch(e)&&this.rs.access.checkPathPermission(e.path,"r")||(0,d.isDocument)(e.path)&&this.needsPush(e)&&this.rs.access.checkPathPermission(e.path,"rw"))&&(this.addTask(e.path),t++))}).then(()=>t)})}inConflict(t){return!(!t.local||!t.remote||void 0===t.remote.body&&!t.remote.itemsMap)}needsRefresh(t){return!!t.common&&(!t.common.timestamp||this.now()-t.common.timestamp>s.default.syncInterval)}needsFetch(t){return!!this.inConflict(t)||!(!t.common||void 0!==t.common.itemsMap||void 0!==t.common.body)||!(!t.remote||void 0!==t.remote.itemsMap||void 0!==t.remote.body)}needsPush(t){return!this.inConflict(t)&&(!(!t.local||t.push)||void 0)}needsRemotePut(t){return!(!t.local||void 0===t.local.body||!1===t.local.body)}needsRemoteDelete(t){return t.local&&!1===t.local.body}getParentPath(t){const e=t.match(/^(.*\/)([^\/]+\/?)$/);if(e)return e[1];throw new Error('Not a valid path: "'+t+'"')}deleteChildPathsFromTasks(){for(const t in this._tasks){const e=(0,d.pathsFromRoot)(t);for(let n=1;n{let e;if(this.needsRefresh(t)){try{e=this.getParentPath(t.path)}catch(t){}e&&this.rs.access.checkPathPermission(e,"r")?this.addTask(e):this.rs.access.checkPathPermission(t.path,"r")&&this.addTask(t.path)}}),this.deleteChildPathsFromTasks()})}flush(t){for(const e in t)"FLUSH"===this.rs.caching.checkPath(e)&&t[e]&&!t[e].local&&((0,l.default)("[Sync] Flushing",e),t[e]=void 0);return t}doTask(t){return r(this,void 0,void 0,function*(){return this.rs.local.getNodes([t]).then(e=>{const n=e[t];return void 0===n||function(t){return!(!t.remote||!t.remote.revision||t.remote.itemsMap||t.remote.body)}(n)?g("get",t,this.rs.remote.get(t)):this.needsRemotePut(n)?(n.push=(0,d.deepClone)(n.local),n.push.timestamp=this.now(),this.rs.local.setNodes(this.flush(e)).then(()=>{let e;return e=y(n)?{ifMatch:n.common.revision}:{ifNoneMatch:"*"},g("put",t,this.rs.remote.put(t,n.push.body,n.push.contentType,e))})):this.needsRemoteDelete(n)?(n.push={body:!1,timestamp:this.now()},this.rs.local.setNodes(this.flush(e)).then(()=>y(n)?g("delete",t,this.rs.remote.delete(t,{ifMatch:n.common.revision})):g("get",t,this.rs.remote.get(t)))):y(n)?g("get",t,this.rs.remote.get(t,{ifNoneMatch:n.common.revision})):g("get",t,this.rs.remote.get(t))})})}autoMergeFolder(t){if(t.remote.itemsMap&&(t.common=t.remote,delete t.remote,t.common.itemsMap)){for(const e in t.common.itemsMap)t.local.itemsMap[e]||(t.local.itemsMap[e]=!1);for(const e in t.local.itemsMap)t.common.itemsMap[e]||this.addTask(t.path+e);(0,d.equal)(t.local.itemsMap,t.common.itemsMap)&&delete t.local}return t}autoMergeDocument(t){var e;return function(t){return(!t.remote||!t.remote.revision||t.remote.revision===t.common.revision)&&(void 0===t.common.body&&!1===t.remote.body||t.remote.body===t.common.body&&t.remote.contentType===t.common.contentType)}(t)?delete(t=function(t){return t.remote&&!1===t.remote.body&&t.local&&!1===t.local.body&&delete t.local,t}(t)).remote:void 0!==t.remote.body&&(!1===t.remote.body&&!1===(null===(e=t.local)||void 0===e?void 0:e.body)||((0,l.default)("[Sync] Emitting conflict event"),setTimeout(this.rs.local.emitChange.bind(this.rs.local),10,{origin:"conflict",path:t.path,oldValue:t.local.body,newValue:t.remote.body,lastCommonValue:t.common.body,oldContentType:t.local.contentType,newContentType:t.remote.contentType,lastCommonContentType:t.common.contentType})),!1===t.remote.body?t.common={}:t.common=t.remote,delete t.remote,delete t.local),t}autoMerge(t){if(t.remote){if(t.local)return(0,d.isFolder)(t.path)?this.autoMergeFolder(t):this.autoMergeDocument(t);if((0,d.isFolder)(t.path))void 0!==t.remote.itemsMap&&(t.common=t.remote,delete t.remote);else if(void 0!==t.remote.body){const e={origin:"remote",path:t.path,oldValue:!1===t.common.body?void 0:t.common.body,newValue:!1===t.remote.body?void 0:t.remote.body,oldContentType:t.common.contentType,newContentType:t.remote.contentType};if(void 0===e.oldValue&&void 0===e.newValue||this.rs.local.emitChange(e),!1===t.remote.body)return;t.common=t.remote,delete t.remote}return t}t.common.body&&this.rs.local.emitChange({origin:"remote",path:t.path,oldValue:t.common.body,newValue:void 0,oldContentType:t.common.contentType,newContentType:void 0})}updateCommonTimestamp(t,e){return r(this,void 0,void 0,function*(){return this.rs.local.getNodes([t]).then(n=>(n[t]&&n[t].common&&n[t].common.revision===e&&(n[t].common.timestamp=this.now()),this.rs.local.setNodes(this.flush(n))))})}markChildren(t,e,n,i){return r(this,void 0,void 0,function*(){const r=[],s={},o={};for(const n in e)r.push(t+n),s[t+n]=e[n];for(const e in i)r.push(t+e);const a=yield this.rs.local.getNodes(r);let l,c;for(const e in a)if(c=a[e],s[e])c&&c.common?m(c,s[e].ETag)&&(n[e]=(0,d.deepClone)(c),n[e].remote={revision:s[e].ETag,timestamp:this.now()},n[e]=this.autoMerge(n[e])):(l=this.rs.caching.checkPath(e),"ALL"===l&&(n[e]={path:e,common:{timestamp:this.now()},remote:{revision:s[e].ETag,timestamp:this.now()}})),n[e]&&s[e]["Content-Type"]&&(n[e].remote.contentType=s[e]["Content-Type"]),n[e]&&s[e]["Content-Length"]&&(n[e].remote.contentLength=s[e]["Content-Length"]);else if(i[e.substring(t.length)]&&c&&c.common){if(c.common.itemsMap)for(const t in c.common.itemsMap)o[e+t]=!0;if(c.local&&c.local.itemsMap)for(const t in c.local.itemsMap)o[e+t]=!0;if(c.remote||(0,d.isFolder)(e))n[e]=void 0;else if(n[e]=this.autoMerge(c),void 0===n[e]){const r=n[this.getParentPath(e)],i=e.substring(t.length);r&&r.local&&(delete r.local.itemsMap[i],(0,d.equal)(r.local.itemsMap,r.common.itemsMap)&&delete r.local)}}const u=yield this.markRemoteDeletions(Object.keys(o),n);u&&(yield this.rs.local.setNodes(this.flush(u)))})}markRemoteDeletions(t,e){return r(this,void 0,void 0,function*(){if(0===t.length)return e;const n=yield this.rs.local.getNodes(t),r={};function i(t,e){if(t&&t.itemsMap)for(const n in t.itemsMap)r[e+n]=!0}for(const t in n){const r=n[t];r&&((0,d.isFolder)(t)?(i(r.common,t),i(r.local,t)):r.common&&void 0!==r.common.body&&(e[t]=(0,d.deepClone)(r),e[t].remote={body:!1,timestamp:this.now()},e[t]=this.autoMerge(e[t])))}const s=yield this.markRemoteDeletions(Object.keys(r),e);s&&(yield this.rs.local.setNodes(this.flush(s)))})}completeFetch(t,e,n,i){return r(this,void 0,void 0,function*(){let r,s;const o=(0,d.pathsFromRoot)(t);(0,d.isFolder)(t)?r=[t]:(s=o[1],r=[t,s]);const a=yield this.rs.local.getNodes(r),l=a[s],c={};let u,h=a[t];function p(t){if(t&&t.itemsMap)for(u in t.itemsMap)e[u]||(c[u]=!0)}if("object"==typeof h&&h.path===t&&"object"==typeof h.common||(h={path:t,common:{}},a[t]=h),h.remote={revision:i,timestamp:this.now()},(0,d.isFolder)(t))for(u in p(h.common),p(h.remote),h.remote.itemsMap={},e)h.remote.itemsMap[u]=!0;else h.remote.body=e,h.remote.contentType=n,l&&l.local&&l.local.itemsMap&&(u=t.substring(s.length),!1!==e?l.local.itemsMap[u]=!0:l.local.itemsMap[u]&&delete l.local.itemsMap[u],(0,d.equal)(l.local.itemsMap,l.common.itemsMap)&&delete l.local);return a[t]=this.autoMerge(h),{toBeSaved:a,missingChildren:c}})}completePush(t,e,n,i){return r(this,void 0,void 0,function*(){const r=yield this.rs.local.getNodes([t]),s=r[t];if(!s.push)throw this.stopped=!0,new Error("completePush called but no push version!");n?((0,l.default)("[Sync] We have a conflict"),s.remote&&s.remote.revision===i||(s.remote={revision:i||"conflict",timestamp:this.now()},delete s.push),r[t]=this.autoMerge(s)):(s.common={revision:i,timestamp:this.now()},"put"===e?(s.common.body=s.push.body,s.common.contentType=s.push.contentType,(0,d.equal)(s.local.body,s.push.body)&&s.local.contentType===s.push.contentType&&delete s.local,delete s.push):"delete"===e&&(!1===s.local.body?r[t]=void 0:delete s.push)),yield this.rs.local.setNodes(this.flush(r))})}dealWithFailure(t){return r(this,void 0,void 0,function*(){const e=yield this.rs.local.getNodes([t]);if(e[t])return delete e[t].push,this.rs.local.setNodes(this.flush(e))})}interpretStatus(t){const e={statusCode:t,successful:void 0,conflict:void 0,unAuth:void 0,notFound:void 0,changed:void 0,networkProblems:void 0};return"string"!=typeof t||"offline"!==t&&"timeout"!==t?"number"==typeof t?(e.successful=2===Math.floor(t/100)||304===t||412===t||404===t,e.conflict=412===t,e.unAuth=401===t&&this.rs.remote.token!==c.default.IMPLIED_FAKE_TOKEN||402===t||403===t,e.notFound=404===t,e.changed=304!==t,e):void 0:(e.successful=!1,e.networkProblems=!0,e)}handleGetResponse(t,e,n,i,s){return r(this,void 0,void 0,function*(){if(e.notFound&&(n=!!(0,d.isFolder)(t)&&{}),e.changed){const e=yield this.completeFetch(t,n,i,s);if((0,d.isFolder)(t)){if(this.corruptServerItemsMap(n))return(0,l.default)("[Sync] WARNING: Discarding corrupt folder description from server for "+t),!1;yield this.markChildren(t,n,e.toBeSaved,e.missingChildren)}else yield this.rs.local.setNodes(this.flush(e.toBeSaved))}else yield this.updateCommonTimestamp(t,s);return!0})}handleResponse(t,e,n){return r(this,void 0,void 0,function*(){const r=this.interpretStatus(n.statusCode);if(r.successful){if("get"===e)return this.handleGetResponse(t,r,n.body,n.contentType,n.revision);if("put"===e||"delete"===e)return this.completePush(t,e,r.conflict,n.revision).then(function(){return!0});throw new Error(`cannot handle response for unknown action ${e}`)}{let e;return e=r.unAuth?new h.default:r.networkProblems?new u.default("Network request failed."):new Error("HTTP response code "+r.statusCode+" received."),this.dealWithFailure(t).then(()=>{throw this.rs._emit("error",e),e})}})}finishTask(t){return r(this,arguments,void 0,function*(t,e=!0){if(void 0===t.action)return void delete this._running[t.path];if(e&&((0,l.default)("[Sync] queue finished task:",t.path),this._finishedTasks.push(t),this._finishedTasks.length>1))return void(0,l.default)("[Sync] delaying finished task:",t.path);let n;(0,l.default)("[Sync] run task:",t.path);try{n=yield t.promise}catch(e){(0,l.default)("[Sync] wire client rejects its promise",t.path,t.action,e),n={statusCode:"offline"}}try{const e=yield this.handleResponse(t.path,t.action,n);this.finishSuccessfulTask(t,e)}catch(e){this.finishUnsuccessfulTask(t,e)}})}finishSuccessfulTask(t,e){return r(this,void 0,void 0,function*(){if(this._finishedTasks.shift(),delete this._timeStarted[t.path],delete this._running[t.path],e&&this._tasks[t.path]){for(let e=0;e0?yield this.finishTask(this._finishedTasks[0],!1):yield this.collectTasks(!1).then(()=>{!this.hasTasks()||this.stopped?(this.done||(this.done=!0),this.rs._emit("sync-done",{completed:!0})):setTimeout(()=>{this.doTasks()},10)})})}finishUnsuccessfulTask(t,e){return r(this,void 0,void 0,function*(){(0,l.default)("[Sync]",e.message),this._finishedTasks.shift(),delete this._timeStarted[t.path],delete this._running[t.path],this.rs._emit("sync-req-done",{tasksRemaining:Object.keys(this._tasks).length}),this._finishedTasks.length>0?yield this.finishTask(this._finishedTasks[0],!1):this.done||(this.done=!0,this.rs._emit("sync-done",{completed:!1}))})}tasksWanted(){return this.rs.remote.connected?this.rs.remote.online?this.numThreads:1:0}doTasks(){const t=this.tasksWanted()-Object.keys(this._running).length;if(t<=0)return!0;this.hasTasks()&&!this.done&&this.rs._emit("sync-started");let e,n=0;for(e in this._tasks)if(!this._running[e]&&(this._timeStarted[e]=this.now(),this._running[e]=this.doTask(e).then(this.finishTask.bind(this)),n++,n>=t))break;return n>=t}collectTasks(){return r(this,arguments,void 0,function*(t=!0){if(!this.hasTasks()&&!this.stopped)return(yield this.collectDiffTasks())>0?void 0:t?this.collectRefreshTasks():void 0})}addTask(t,e){this._tasks[t]||(this._tasks[t]=[]),"function"==typeof e&&this._tasks[t].push(e)}sync(){return r(this,void 0,void 0,function*(){if(this.done=!1,!this.doTasks()){try{yield this.collectTasks()}catch(t){throw(0,l.default)("[Sync] Sync error",t),new Error("Local cache unavailable")}this.doTasks()}})}static _rs_init(t){p=function(){const e=new o.default;e.isBrowser()&&function(t,e){function n(t){const n=e.getCurrentSyncInterval();s.default.isBackground=!t;const r=e.getCurrentSyncInterval();e._emit("sync-interval-change",{oldValue:n,newValue:r})}t.on("background",()=>n(!1)),t.on("foreground",()=>n(!0))}(e,t),t.sync||(t.sync=new v(t),t.syncStopped&&((0,l.default)("[Sync] Initializing with sync stopped"),t.sync.stopped=!0,delete t.syncStopped)),t.setupSyncCycle()},f=function(){t.removeEventListener("connected",f),t.startSync()},t.on("ready",p),t.on("connected",f)}static _rs_cleanup(t){t.stopSync(),t.removeEventListener("ready",p),t.removeEventListener("connected",f),t.caching.resetActivationHandler(),t.sync=void 0,delete t.sync}}e.Sync=v,(0,d.applyMixins)(v,[a.default]),e.default=v},370:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})};const i=(this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(n(334));function s(t){return"dropbox"===this.backend&&!!t.match(/^\/public\/.*[^\/]$/)}const o={get:function(t,e){if(this.local){if(void 0===e)e="object"==typeof(n=this).remote&&n.remote.connected&&n.remote.online?2*n.getSyncInterval():((0,i.default)("Not setting default maxAge, because remote is offline or not connected"),!1);else if("number"!=typeof e&&!1!==e)return Promise.reject("Argument 'maxAge' must be 'false' or a number");return this.local.get(t,e,this.sync.queueGetRequest.bind(this.sync))}return this.remote.get(t);var n},put:function(t,e,n){return s.bind(this)(t)?o._wrapBusyDone.call(this,this.remote.put(t,e,n)):this.local?this.local.put(t,e,n):o._wrapBusyDone.call(this,this.remote.put(t,e,n))},delete:function(t,e){return this.local?this.local.delete(t,e):o._wrapBusyDone.call(this,this.remote.delete(t,e))},_wrapBusyDone:function(t){return r(this,void 0,void 0,function*(){return this._emit("wire-busy"),t.then(t=>(this._emit("wire-done",{success:!0}),Promise.resolve(t)),t=>(this._emit("wire-done",{success:!1}),Promise.reject(t)))})}};t.exports=o},613:function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BaseClientTypes=void 0;class n{constructor(){this.uris={},this.schemas={},this.aliases={}}declare(t,e,n,r){const i=t+"/"+e;if(r.extends){const e=r.extends.split("/"),n=1===e.length?t+"/"+e.shift():e.join("/"),s=this.uris[n];if(!s)throw"Type '"+i+"' tries to extend unknown schema '"+n+"'";r.extends=this.schemas[s]}this.uris[i]=n,this.aliases[n]=i,this.schemas[n]=r}resolveAlias(t){return this.uris[t]}getSchema(t){return this.schemas[t]}inScope(t){const e=t.length,n={};for(const r in this.uris)if(r.substr(0,e+1)===t+"/"){const t=this.uris[r];n[t]=this.schemas[t]}return n}}e.BaseClientTypes=n,e.default=new n},503:function(t){class e extends Error{constructor(t,e={}){super(),this.name="Unauthorized",this.message=void 0===t?"App authorization expired or revoked.":t,void 0!==e.code&&(this.code=e.code),this.stack=(new Error).stack}}t.exports=e},746:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0}),e.toBase64=e.getTextFromArrayBuffer=e.stripLegacyCharsetBinary=e.shouldBeTreatedAsBinary=e.getJSONFromLocalStorage=e.localStorageAvailable=e.pathsFromRoot=e.deepClone=e.equal=e.bindAll=e.cleanPath=e.baseName=e.isDocument=e.isFolder=e.containingFolder=e.extend=e.getGlobalContext=e.globalContext=e.logError=void 0,e.generateCodeVerifier=function(){return r(this,arguments,void 0,function*(t=128){const e=new Uint8Array(t);crypto.getRandomValues(e);const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=Array.from(e).map(t=>n[t%66]),i=r.join(""),s=Uint8Array.from(r.map(t=>t.charCodeAt(0))),o=(a=yield crypto.subtle.digest("SHA-256",s),btoa(String.fromCharCode.apply(null,new Uint8Array(a))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""));var a;return crypto.getRandomValues(e),{codeVerifier:i,codeChallenge:o,state:Array.from(e).map(t=>n[t%66]).join("")}})},e.applyMixins=function(t,e){e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{Object.defineProperty(t.prototype,n,Object.getOwnPropertyDescriptor(e.prototype,n))})})},e.logError=t=>{"string"==typeof t?console.error(t):console.error(t.message,t.stack)},e.globalContext="undefined"!=typeof window?window:"object"==typeof self?self:n.g,e.getGlobalContext=()=>"undefined"!=typeof window?window:"object"==typeof self?self:n.g,e.extend=(...t)=>{const e=t[0];return Array.prototype.slice.call(t,1).forEach(function(t){for(const n in t)e[n]=t[n]}),e},e.containingFolder=t=>{if(""===t)return"/";if(!t)throw"Path not given!";return t.replace(/\/+/g,"/").replace(/[^\/]+\/?$/,"")},e.isFolder=t=>"/"===t.slice(-1),e.isDocument=t=>!(0,e.isFolder)(t),e.baseName=t=>{const n=t.split("/");return(0,e.isFolder)(t)?n[n.length-2]+"/":n[n.length-1]},e.cleanPath=t=>t.replace(/\/+/g,"/").split("/").map(encodeURIComponent).join("/").replace(/'/g,"%27"),e.bindAll=t=>{for(const e in this)"function"==typeof t[e]&&(t[e]=t[e].bind(t))},e.equal=(t,n,r=[])=>{let i;if(typeof t!=typeof n)return!1;if("number"==typeof t||"boolean"==typeof t||"string"==typeof t)return t===n;if("function"==typeof t)return t.toString()===n.toString();if(t instanceof ArrayBuffer&&n instanceof ArrayBuffer&&(t=new Uint8Array(t),n=new Uint8Array(n)),null===t||null===n)return t===n;if(t instanceof Array){if(t.length!==n.length)return!1;for(let i=0,s=t.length;i=0)continue;s=r.slice(),s.push(n[i])}if(!(0,e.equal)(t[i],n[i],s))return!1}}return!0},e.deepClone=t=>void 0===t?void 0:"function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t)),e.pathsFromRoot=t=>{const e=[t],n=t.replace(/\/$/,"").split("/");for(;n.length>1;)n.pop(),e.push(n.join("/")+"/");return e},e.localStorageAvailable=()=>{const t=(0,e.getGlobalContext)();if(!("localStorage"in t))return!1;try{return t.localStorage.setItem("rs-check","1"),t.localStorage.removeItem("rs-check"),!0}catch(t){return!1}},e.getJSONFromLocalStorage=t=>{const n=(0,e.getGlobalContext)();try{return JSON.parse(n.localStorage.getItem(t))}catch(t){}},e.shouldBeTreatedAsBinary=(t,e)=>!!(e&&e.match(/charset=binary/)||/[\x00-\x08\x0E-\x1F\x80-\x9F\uFFFD]/.test(t)),e.stripLegacyCharsetBinary=t=>t?t.replace(/\s*;\s*charset=binary\b/i,""):t,e.getTextFromArrayBuffer=(t,n)=>new Promise(r=>{if("undefined"==typeof Blob||"undefined"==typeof FileReader)r(Buffer.from(t).toString(n));else{let i;const s=e.globalContext;if(s.BlobBuilder=s.BlobBuilder||s.WebKitBlobBuilder,void 0!==s.BlobBuilder){const e=new s.BlobBuilder;e.append(t),i=e.getBlob()}else i=new Blob([t]);const o=new FileReader;"function"==typeof o.addEventListener?o.addEventListener("loadend",function(t){r(t.target.result)}):o.onloadend=function(t){r(t.target.result)},o.readAsText(i,n)}}),e.toBase64=t=>{const n=(0,e.getGlobalContext)();return"btoa"in n?n.btoa(t):Buffer.from(t).toString("base64")}},600:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,s){function o(t){try{l(r.next(t))}catch(t){s(t)}}function a(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(o,a)}l((r=r.apply(t,e||[])).next())})},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};const s=i(n(275)),o=i(n(93)),a=i(n(503)),l=i(n(334)),c=n(746),u=n(368),h=n(684);let d;const p="remotestorage:wireclient",f={"draft-dejong-remotestorage-00":2,"draft-dejong-remotestorage-01":3,"draft-dejong-remotestorage-02":4,"https://www.w3.org/community/rww/wiki/read-write-web-00#simple":1};class g extends h.RemoteBase{constructor(t){if(super(t),this._revisionCache={},d=(0,c.localStorageAvailable)(),this.addEvents(["connected","not-connected"]),d){const t=function(){const{userAddress:t,href:e,storageApi:n,token:r,properties:i}=(0,c.getJSONFromLocalStorage)(p)||{};return{userAddress:t,href:e,storageApi:n,token:r,properties:i}}();t&&setTimeout(()=>{this.configure(t)},0)}this.connected&&setTimeout(this._emit.bind(this),0,"connected")}_request(t,e,n,i,o,h,d){return r(this,void 0,void 0,function*(){if(this.isForbiddenRequestMethod(t,e))return Promise.reject(`Don't use ${t} on directories!`);let r;return n!==s.default.IMPLIED_FAKE_TOKEN&&(i.Authorization="Bearer "+n),this.rs._emit("wire-busy",{method:t,isFolder:(0,c.isFolder)(e)}),(0,u.requestWithTimeout)(t,e,{body:o,headers:i,responseType:"arraybuffer"}).then(n=>{if(this.online||(this.online=!0,this.rs._emit("network-online")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!0}),i=n.status,[401,403,404,412].indexOf(i)>=0)return(0,l.default)("[WireClient] Error response status",n.status),r=h?this.stripQuotes(n.getResponseHeader("ETag")):void 0,401===n.status&&this.rs._emit("error",new a.default),Promise.resolve({statusCode:n.status,revision:r});if(function(t){return[201,204,304].indexOf(t)>=0}(n.status)||200===n.status&&"GET"!==t)return r=this.stripQuotes(n.getResponseHeader("ETag")),(0,l.default)("[WireClient] Successful request",r),Promise.resolve({statusCode:n.status,revision:r});{const t=n.getResponseHeader("Content-Type");r=h?this.stripQuotes(n.getResponseHeader("ETag")):200===n.status?d:void 0;const e=function(t){let e,n="utf-8";return t&&(e=t.match(/charset=(.+)$/),e&&(n=e[1])),n}(t);return(0,c.shouldBeTreatedAsBinary)(n.response,t)?((0,l.default)("[WireClient] Successful request with unknown or binary mime-type",r),Promise.resolve({statusCode:n.status,body:n.response,contentType:(0,c.stripLegacyCharsetBinary)(t),revision:r})):(0,c.getTextFromArrayBuffer)(n.response,e).then(e=>((0,l.default)("[WireClient] Successful request",r),Promise.resolve({statusCode:n.status,body:e,contentType:(0,c.stripLegacyCharsetBinary)(t),revision:r})))}var i},n=>(this.online&&(this.online=!1,this.rs._emit("network-offline")),this.rs._emit("wire-done",{method:t,isFolder:(0,c.isFolder)(e),success:!1}),Promise.reject(n)))})}configure(t){if("object"!=typeof t)throw new Error("WireClient configure settings parameter should be an object");if(void 0!==t.userAddress&&(this.userAddress=t.userAddress),void 0!==t.href&&(this.href=t.href),void 0!==t.storageApi&&(this.storageApi=t.storageApi),void 0!==t.token&&(this.token=t.token),void 0!==t.properties&&(this.properties=t.properties),"string"==typeof this.storageApi){const t=f[this.storageApi]||5;this.supportsRevs=t>=2}this.href&&this.token?(this.connected=!0,this.online=!0,this._emit("connected")):this.connected=!1,d&&localStorage.setItem(p,JSON.stringify({userAddress:this.userAddress,href:this.href,storageApi:this.storageApi,token:this.token,properties:this.properties}))}get(t,e={}){if(!this.connected)return Promise.reject("not connected (path: "+t+")");const n={};return this.supportsRevs&&e.ifNoneMatch&&(n["If-None-Match"]=this.addQuotes(e.ifNoneMatch)),this._request("GET",this.href+(0,c.cleanPath)(t),this.token,n,void 0,this.supportsRevs,this._revisionCache[t]).then(e=>{if(!(0,c.isFolder)(t))return Promise.resolve(e);let n={};if(void 0!==e.body)try{e.body=JSON.parse(e.body)}catch(e){return Promise.reject("Folder description at "+this.href+(0,c.cleanPath)(t)+" is not JSON")}if(200===e.statusCode&&"object"==typeof e.body){if(0===Object.keys(e.body).length)e.statusCode=404;else if("http://remotestorage.io/spec/folder-description"===(r=e.body)["@context"]&&"object"==typeof r.items){for(const n in e.body.items)this._revisionCache[t+n]=e.body.items[n].ETag;n=e.body.items}else Object.keys(e.body).forEach(r=>{this._revisionCache[t+r]=e.body[r],n[r]={ETag:e.body[r]}});return e.body=n,Promise.resolve(e)}return Promise.resolve(e);var r})}put(t,e,n,r={}){if(!this.connected)return Promise.reject("not connected (path: "+t+")");const i={"Content-Type":n};return this.supportsRevs&&(r.ifMatch&&(i["If-Match"]=this.addQuotes(r.ifMatch)),r.ifNoneMatch&&(i["If-None-Match"]=this.addQuotes(r.ifNoneMatch))),this._request("PUT",this.href+(0,c.cleanPath)(t),this.token,i,e,this.supportsRevs)}delete(t,e={}){if(!this.connected)throw new Error("not connected (path: "+t+")");e||(e={});const n={};return this.supportsRevs&&e.ifMatch&&(n["If-Match"]=this.addQuotes(e.ifMatch)),this._request("DELETE",this.href+(0,c.cleanPath)(t),this.token,n,void 0,this.supportsRevs)}static _rs_init(t){t.remote=new g(t),t.remote.online=!0}static _rs_supported(){return"function"==typeof fetch||"function"==typeof XMLHttpRequest}static _rs_cleanup(){d&&delete localStorage[p]}}(0,c.applyMixins)(g,[o.default]),t.exports=g},439:function(t,e){var n;void 0===(n=function(){var t,e,n,r;Object.keys||(Object.keys=(t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),r=(n=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]).length,function(i){if("object"!=typeof i&&"function"!=typeof i||null===i)throw new TypeError("Object.keys called on non-object");var s=[];for(var o in i)t.call(i,o)&&s.push(o);if(e)for(var a=0;a>>0;if(0===n)return-1;var r=0;if(arguments.length>1&&((r=Number(arguments[1]))!=r?r=0:0!==r&&r!==1/0&&r!==-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=n)return-1;for(var i=r>=0?r:Math.max(n-Math.abs(r),0);i0&&(e+=u.suffices["*"]&&n||",",u.suffices["*"]&&l&&(e+=u.name+"=")),e+=a?encodeURIComponent(h[p]).replace(/!/g,"%21"):o(h[p])}else if("object"==typeof h){l&&!u.suffices["*"]&&(e+=u.name+"=");var f=!0;for(var g in h)f||(e+=u.suffices["*"]&&n||","),f=!1,e+=a?encodeURIComponent(g).replace(/!/g,"%21"):o(g),e+=u.suffices["*"]?"=":",",e+=a?encodeURIComponent(h[g]).replace(/!/g,"%21"):o(h[g])}else l&&(e+=u.name,c&&""===h||(e+="=")),null!=u.truncate&&(h=h.substring(0,u.truncate)),e+=a?encodeURIComponent(h).replace(/!/g,"%21"):o(h)}return e};return w.varNames=u,{prefix:r,substitution:w}}function l(t){if(!(this instanceof l))return new l(t);for(var e=t.split("{"),n=[e.shift()],r=[],i=[],s=[];e.length>0;){var o=e.shift(),c=o.split("}")[0],u=o.substring(c.length+1),h=a(c);i.push(h.substitution),r.push(h.prefix),n.push(u),s=s.concat(h.substitution.varNames)}this.fill=function(t){for(var e=n[0],r=0;r0&&"/"===e.charAt(t.length-1)||"#"===n.charAt(0)||"?"===n.charAt(0))return!0}return!1}(e,t.id)&&void 0===this.schemas[t.id]&&(this.schemas[t.id]=t),t)if("enum"!==r)if("object"==typeof t[r])this.searchSchemas(t[r],e);else if("$ref"===r){var i=g(t[r]);i&&void 0===this.schemas[i]&&void 0===this.missingMap[i]&&(this.missingMap[i]=i)}},c.prototype.addSchema=function(t,e){if("string"!=typeof t||void 0===e){if("object"!=typeof t||"string"!=typeof t.id)return;t=(e=t).id}t===g(t)+"#"&&(t=g(t)),this.schemas[t]=e,delete this.missingMap[t],m(e,t),this.searchSchemas(e,t)},c.prototype.getSchemaMap=function(){var t={};for(var e in this.schemas)t[e]=this.schemas[e];return t},c.prototype.getSchemaUris=function(t){var e=[];for(var n in this.schemas)t&&!t.test(n)||e.push(n);return e},c.prototype.getMissingUris=function(t){var e=[];for(var n in this.missingMap)t&&!t.test(n)||e.push(n);return e},c.prototype.dropSchemas=function(){this.schemas={},this.reset()},c.prototype.reset=function(){this.missing=[],this.missingMap={},this.errors=[]},c.prototype.validateAll=function(t,e,n,r,i){var s;if(!(e=this.resolveRefs(e)))return null;if(e instanceof x)return this.errors.push(e),e;var o,a=this.errors.length,l=null,c=null;if(this.checkRecursive&&t&&"object"==typeof t){if(s=!this.scanned.length,t[this.validatedSchemasKey]){var u=t[this.validatedSchemasKey].indexOf(e);if(-1!==u)return this.errors=this.errors.concat(t[this.validationErrorsKey][u]),null}if(Object.isFrozen(t)&&-1!==(o=this.scannedFrozen.indexOf(t))){var h=this.scannedFrozenSchemas[o].indexOf(e);if(-1!==h)return this.errors=this.errors.concat(this.scannedFrozenValidationErrors[o][h]),null}if(this.scanned.push(t),Object.isFrozen(t))-1===o&&(o=this.scannedFrozen.length,this.scannedFrozen.push(t),this.scannedFrozenSchemas.push([])),l=this.scannedFrozenSchemas[o].length,this.scannedFrozenSchemas[o][l]=e,this.scannedFrozenValidationErrors[o][l]=[];else{if(!t[this.validatedSchemasKey])try{Object.defineProperty(t,this.validatedSchemasKey,{value:[],configurable:!0}),Object.defineProperty(t,this.validationErrorsKey,{value:[],configurable:!0})}catch(e){t[this.validatedSchemasKey]=[],t[this.validationErrorsKey]=[]}c=t[this.validatedSchemasKey].length,t[this.validatedSchemasKey][c]=e,t[this.validationErrorsKey][c]=[]}}var d=this.errors.length,p=this.validateBasic(t,e,i)||this.validateNumeric(t,e,i)||this.validateString(t,e,i)||this.validateArray(t,e,i)||this.validateObject(t,e,i)||this.validateCombinations(t,e,i)||this.validateHypermedia(t,e,i)||this.validateFormat(t,e,i)||this.validateDefinedKeywords(t,e,i)||null;if(s){for(;this.scanned.length;)delete this.scanned.pop()[this.validatedSchemasKey];this.scannedFrozen=[],this.scannedFrozenSchemas=[]}if(p||d!==this.errors.length)for(;n&&n.length||r&&r.length;){var f=n&&n.length?""+n.pop():null,g=r&&r.length?""+r.pop():null;p&&(p=p.prefixWith(f,g)),this.prefixErrors(d,f,g)}return null!==l?this.scannedFrozenValidationErrors[o][l]=this.errors.slice(a):null!==c&&(t[this.validationErrorsKey][c]=this.errors.slice(a)),this.handleError(p)},c.prototype.validateFormat=function(t,e){if("string"!=typeof e.format||!this.formatValidators[e.format])return null;var n=this.formatValidators[e.format].call(null,t,e);return"string"==typeof n||"number"==typeof n?this.createError(v.FORMAT_CUSTOM,{message:n},"","/format",null,t,e):n&&"object"==typeof n?this.createError(v.FORMAT_CUSTOM,{message:n.message||"?"},n.dataPath||"",n.schemaPath||"/format",null,t,e):null},c.prototype.validateDefinedKeywords=function(t,e,n){for(var r in this.definedKeywords)if(void 0!==e[r])for(var i=this.definedKeywords[r],s=0;s=h&&re.maximum)return this.createError(v.NUMBER_MAXIMUM,{value:t,maximum:e.maximum},"","/maximum",null,t,e);if(e.exclusiveMaximum&&t===e.maximum)return this.createError(v.NUMBER_MAXIMUM_EXCLUSIVE,{value:t,maximum:e.maximum},"","/exclusiveMaximum",null,t,e)}return null},c.prototype.validateNaN=function(t,e){return"number"!=typeof t?null:!0===isNaN(t)||t===1/0||t===-1/0?this.createError(v.NUMBER_NOT_A_NUMBER,{value:t},"","/type",null,t,e):null},c.prototype.validateString=function(t,e,n){return this.validateStringLength(t,e,n)||this.validateStringPattern(t,e,n)||null},c.prototype.validateStringLength=function(t,e){return"string"!=typeof t?null:void 0!==e.minLength&&t.lengthe.maxLength?this.createError(v.STRING_LENGTH_LONG,{length:t.length,maximum:e.maxLength},"","/maxLength",null,t,e):null},c.prototype.validateStringPattern=function(t,e){if("string"!=typeof t||"string"!=typeof e.pattern&&!(e.pattern instanceof RegExp))return null;var n;if(e.pattern instanceof RegExp)n=e.pattern;else{var r,i="",s=e.pattern.match(/^\/(.+)\/([img]*)$/);s?(r=s[1],i=s[2]):r=e.pattern,n=new RegExp(r,i)}return n.test(t)?null:this.createError(v.STRING_PATTERN,{pattern:e.pattern},"","/pattern",null,t,e)},c.prototype.validateArray=function(t,e,n){return Array.isArray(t)&&(this.validateArrayLength(t,e,n)||this.validateArrayUniqueItems(t,e,n)||this.validateArrayItems(t,e,n))||null},c.prototype.validateArrayLength=function(t,e){var n;return void 0!==e.minItems&&t.lengthe.maxItems&&(n=this.createError(v.ARRAY_LENGTH_LONG,{length:t.length,maximum:e.maxItems},"","/maxItems",null,t,e),this.handleError(n))?n:null},c.prototype.validateArrayUniqueItems=function(t,e){if(e.uniqueItems)for(var n=0;ne.maxProperties&&(n=this.createError(v.OBJECT_PROPERTIES_MAXIMUM,{propertyCount:r.length,maximum:e.maxProperties},"","/maxProperties",null,t,e),this.handleError(n))?n:null},c.prototype.validateObjectRequiredProperties=function(t,e){if(void 0!==e.required)for(var n=0;n 10000");if(void 0!==v[t])throw new Error("Error already defined: "+t+" as "+v[t]);if(void 0!==b[e])throw new Error("Error code already used: "+b[e]+" as "+e);for(var r in v[t]=e,b[e]=t,_[t]=_[e]=n,C){var i=C[r];i[t]&&(i[e]=i[e]||i[t])}},reset:function(){i.reset(),this.error=null,this.missing=[],this.valid=!0},missing:[],error:null,valid:!0,normSchema:m,resolveUrl:f,getDocumentUri:g,errorCodes:v};return s.language(e||"en"),s}();return k.addLanguage("en-gb",_),k.tv4=k,k}.apply(e,[]))||(t.exports=n)},713:function(t){!function(){{const e=function(){var t={"http://webfinger.net/rel/avatar":"avatar",remotestorage:"remotestorage","http://tools.ietf.org/id/draft-dejong-remotestorage":"remotestorage",remoteStorage:"remotestorage","http://www.packetizer.com/rel/share":"share","http://webfinger.net/rel/profile-page":"profile",me:"profile",vcard:"vcard",blog:"blog","http://packetizer.com/rel/blog":"blog","http://schemas.google.com/g/2010#updates-from":"updates","https://camlistore.org/rel/server":"camilstore"},e={avatar:[],remotestorage:[],blog:[],vcard:[],updates:[],share:[],profile:[],camlistore:[]},n=["webfinger","host-meta","host-meta.json"],r="(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)",i=new RegExp(`^(?:${r}\\.){3}${r}$`),s=new RegExp(`^(${r})\\.(${r})\\.(${r})\\.(${r})$`),o=/^localhost(?:\.localdomain)?(?::\d+)?$/,a=/^\d+$/,l=/^[a-zA-Z0-9.-]+$/,c=/^127\.(?:\d{1,3}\.){2}\d{1,3}$/;function u(t){const e=t.match(s);return e?e.slice(1).map(Number):null}function h(t){const[e,n]=t;return 0===e||10===e||127===e||172===e&&n>=16&&n<=31||192===e&&168===n||169===e&&254===n||e>=224&&e<=239||e>=240}class d extends Error{status;constructor(t,e){super(t),this.name="WebFingerError",this.status=e}}class p{static default;config;constructor(t={}){this.config={tls_only:void 0===t.tls_only||t.tls_only,uri_fallback:void 0!==t.uri_fallback&&t.uri_fallback,request_timeout:void 0!==t.request_timeout?t.request_timeout:1e4,allow_private_addresses:void 0!==t.allow_private_addresses&&t.allow_private_addresses}}async fetchJRD(t,e=0){if(e>3)throw new d("too many redirects");const n=new AbortController,r=setTimeout(()=>{n.abort()},this.config.request_timeout);try{const i=await fetch(t,{headers:{Accept:"application/jrd+json, application/json"},redirect:"manual",signal:n.signal});if(i.status>=300&&i.status<400){const n=i.headers.get("location");if(!n)throw new d("redirect without location header");let s;try{s=new URL(n,t)}catch{throw new d("invalid redirect URL")}try{await this.resolveAndValidateHost(s.host)}catch(t){if(t instanceof d)throw new d("redirect to private or internal address blocked");throw t}return clearTimeout(r),this.fetchJRD(s.toString(),e+1)}if(404===i.status)throw new d("resource not found",404);if(!i.ok)throw new d("error during request",i.status);const s=i.headers.get("content-type")||"",o=s.toLowerCase().split(";")[0].trim();"application/jrd+json"===o||("application/json"===o?console.debug('WebFinger: Server uses "application/json" instead of RFC 7033 recommended "application/jrd+json".'):console.warn(`WebFinger: Server returned unexpected content-type "${s}". Expected "application/jrd+json" per RFC 7033.`));const a=await i.text();if(p.isValidJSON(a))return a;throw new d("invalid json")}catch(t){if(n.signal.aborted)throw new d("request timed out");throw t}finally{clearTimeout(r)}}static isValidJSON(t){try{JSON.parse(t)}catch{return!1}return!0}static isLocalhost(t){return o.test(t)}static isPrivateAddress(t){let e=t;if(e.startsWith("[")&&e.includes("]:"))e=e.substring(1,e.lastIndexOf("]:"));else if(e.startsWith("[")&&e.endsWith("]"))e=e.substring(1,e.length-1);else if(e.includes(":")&&1===(e.match(/:/g)||[]).length){const t=e.split(":"),n=t[0],r=t[1];if(r&&!a.test(r))throw new d("invalid host format");(n.match(i)||n.match(l))&&(e=n)}if("localhost"===e||"127.0.0.1"===e||e.match(c)||"::1"===e||"localhost.localdomain"===e)return!0;const n=u(e);if(n)return h(n);const r=function(t){let e=t.toLowerCase();const n=u(e.substring(e.lastIndexOf(":")+1));if(n&&(e=`${e.substring(0,e.lastIndexOf(":"))}:${(n[0]<<8|n[1]).toString(16)}:${(n[2]<<8|n[3]).toString(16)}`),!/^[0-9a-f:]+$/.test(e)||e.indexOf("::")!==e.lastIndexOf("::"))return null;const r=e.includes("::"),[i="",s=""]=e.split("::"),o=i?i.split(":"):[],a=r&&s?s.split(":"):[],l=8-o.length-a.length;if(!r&&8!==o.length||r&&l<1)return null;const c=(r?[...o,...Array(l).fill("0"),...a]:o).map(t=>Number.parseInt(t,16));return 8===c.length&&c.every(t=>t>=0&&t<=65535)?c:null}(e);if(r){const t=r.slice(0,5).every(t=>0===t)&&65535===r[5],e=r.slice(0,6).every(t=>0===t);if(t||e)return h([r[6]>>8,255&r[6],r[7]>>8,255&r[7]]);const n=r[0];return 64512==(65024&n)||65152==(65472&n)||!(65280&~n)}return!1}static getExplicitPort(t){if(t.startsWith("[")){const e=t.lastIndexOf("]:");if(-1!==e){const n=t.substring(e+2);if(!a.test(n))throw new d("invalid host format");return n}return}if(1===(t.match(/:/g)||[]).length){const[,e=""]=t.split(":");if(!e||!a.test(e))throw new d("invalid host format");return e}}static parseAddress(t){const e=t.replace(/ /g,"");if(e.includes("://")){let t;try{t=new URL(e)}catch{throw new d("invalid URI format")}if(!t.hostname)throw new d("could not determine host from address");return{host:t.host}}const n=e.split("@");if(2!==n.length||!n[1])throw new d("invalid useraddress format");return{host:n[1]}}async resolveAndValidateHost(t){const e=p.normalizeHost(t);if(!this.config.allow_private_addresses){if(p.isPrivateAddress(e.host))throw new d("private or internal addresses are not allowed");await this.validateDNSResolution(e.hostname)}return e}static normalizeHost(t){const e=t.split("/")[0];if(!e||0===e.length)throw new d("invalid host format");if(/[?# @]/.test(e))throw new d("invalid characters in host");const n=p.getExplicitPort(e);let r;try{r=new URL(`http://${e}`)}catch{throw new d("invalid host format")}const i=r.hostname;return{host:n?`${i}:${n}`:r.host||i,hostname:i}}static async processJRD(n,r){const i=JSON.parse(r);if("object"!=typeof i||"object"!=typeof i.links)throw void 0!==i.error?new d(i.error):new d("unknown response from server");const s={object:i,idx:{properties:{name:void 0},links:JSON.parse(JSON.stringify(e))}};(Array.isArray(i.links)?i.links:[]).map(function(e){if(Object.prototype.hasOwnProperty.call(t,String(e.rel))){const n=t[String(e.rel)];if(s.idx.links[n]){const t={href:String(e.href||""),rel:String(e.rel||"")};Object.keys(e).map(function(n){"object"==typeof e[n]&&null!==e[n]?t[n]=e[n]:t[n]=String(e[n])}),s.idx.links[n].push(t)}}});const o=i.properties||{};for(const t in o)Object.prototype.hasOwnProperty.call(o,t)&&"http://packetizer.com/ns/name"===t&&(s.idx.properties.name=o[t]);return s}async validateDNSResolution(t){if(!t.match(i)&&!t.includes(":")&&"localhost"!==t&&"undefined"!=typeof process&&process.versions?.node){const e="function"==typeof process.getBuiltinModule?process.getBuiltinModule("node:dns")?.promises:null;if(e)try{const[n,r]=await Promise.allSettled([e.resolve4(t).catch(()=>[]),e.resolve6(t).catch(()=>[])]),i="fulfilled"===n.status?n.value:[],s="fulfilled"===r.status?r.value:[];for(const e of[...i,...s])if(p.isPrivateAddress(e))throw new d(`hostname ${t} resolves to private address ${e}`)}catch(t){if(t instanceof d)throw t}}}async lookup(t){if(!t)throw new d("address is required");const{host:e}=p.parseAddress(t),{host:r}=await this.resolveAndValidateHost(e);let i=0,s="https";p.isLocalhost(r)&&(s="http");const o=async t=>{if(this.config.uri_fallback&&i!==n.length-1)return i+=1,a();if(this.config.tls_only||"https"!==s)throw t instanceof Error?t:new d(String(t));return i=0,s="http",a()},a=async()=>{const e=(()=>{let e="";return t.split("://")[1]||(e="acct:"),s+"://"+r+"/.well-known/"+n[i]+"?resource="+e+t})();try{const t=await this.fetchJRD(e);return p.processJRD(e,t)}catch(t){return await o(t)}};return a()}async lookupLink(t,n){if(Object.prototype.hasOwnProperty.call(e,n)){const e=(await this.lookup(t)).idx.links[n];return 0===e.length?Promise.reject('no links found with rel="'+n+'"'):Promise.resolve(e[0])}return Promise.reject("unsupported rel "+n)}}return p.default=p,p}();t.exports=e,t.exports.default=e}}("undefined"!=typeof self&&self)}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n(423).default}()},"object"==typeof t&&"object"==typeof e?e.exports=r():"function"==typeof define&&define.amd?define("RemoteStorage",[],r):"object"==typeof t?t.RemoteStorage=r():n.RemoteStorage=r()}),LU=l(TU(),1),PU="0123456789ABCDEFGHJKMNPQRSTVWXYZ";!function(t){t.Base32IncorrectEncoding="B32_ENC_INVALID",t.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",t.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",t.EncodeTimeNegative="ENC_TIME_NEG",t.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",t.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",t.PRNGDetectFailure="PRNG_DETECT",t.ULIDInvalid="ULID_INVALID",t.Unexpected="UNEXPECTED",t.UUIDInvalid="UUID_INVALID"}(wU||(wU={}));var IU=class extends Error{constructor(t,e){super(`${e} (${t})`),this.name="ULIDError",this.code=t}};function MU(t){const e=Math.floor(32*t())%32;return PU.charAt(e)}var AU={type:"object",properties:{id:{type:"string"},title:{type:"string"},lat:{type:"number"},lon:{type:"number"},geohash:{type:"string"},zoom:{type:"number"},url:{type:"string"},osmId:{type:"string"},osmType:{type:"string"},osmTags:{type:"object",additionalProperties:{type:"string"}},description:{type:"string"},tags:{type:"array",items:{type:"string"},default:[]},createdAt:{type:"string",format:"date-time"},updatedAt:{type:"string",format:"date-time"}},required:["id","title","lat","lon","geohash","createdAt"]},OU={type:"object",properties:{id:{type:"string"},title:{type:"string"},color:{type:"string"},placeRefs:{type:"array",items:{type:"object",properties:{id:{type:"string"},geohash:{type:"string"}},required:["id","geohash"]},default:[]},createdAt:{type:"string",format:"date-time"},updatedAt:{type:"string",format:"date-time"}},required:["id","title","placeRefs","createdAt"]},FU={name:"places",builder:function(t){function e(t,e){return`${t.substring(0,2)}/${t.substring(2,4)}/${e}`}t.declareType("place",AU),t.declareType("list",OU);const n={async getAll(){const e=await t.getAll("_lists/");return e?Object.values(e):[]},async get(e){const n=`_lists/${e}`;return t.getObject(n)},async getPlaces(n){const r=await this.get(n);if(!r)throw new Error(`List not found: ${n}`);if(!r.placeRefs||!Array.isArray(r.placeRefs))return[];const i=r.placeRefs.map(async n=>{if(!n.id||!n.geohash)return null;const r=e(n.geohash,n.id);return await t.getObject(r)});return(await Promise.all(i)).filter(t=>!!t)},async create(e,n,r){const i=`_lists/${e}`;let s=await t.getObject(i);const o=(new Date).toISOString();return s?(s.title=n,r&&(s.color=r),s.updatedAt=o):s={id:e,title:n,color:r,placeRefs:[],createdAt:o,updatedAt:o},await t.storeObject("list",i,s),s},async delete(e){await t.remove(`_lists/${e}`)},async addPlace(e,n,r){const i=`_lists/${e}`,s=await t.getObject(i);if(!s)throw new Error(`List not found: ${e}`);return-1===s.placeRefs.findIndex(t=>t.id===n)&&(s.placeRefs.push({id:n,geohash:r}),s.updatedAt=(new Date).toISOString(),await t.storeObject("list",i,s)),s},async removePlace(e,n){const r=`_lists/${e}`,i=await t.getObject(r);if(!i)throw new Error(`List not found: ${e}`);const s=i.placeRefs.findIndex(t=>t.id===n);return-1!==s&&(i.placeRefs.splice(s,1),i.updatedAt=(new Date).toISOString(),await t.storeObject("list",r,i)),i},async initDefaults(){for(const t of[{id:"to-go",title:"Want to go",color:"#2e9e4f"},{id:"to-do",title:"To do",color:"#2a7fff"}])await this.get(t.id)||await this.create(t.id,t.title,t.color)}};return{exports:{lists:n,store:async function(n){const r=function(t){const e=(new Date).toISOString(),n=t.id||function(t,e){const n=e||function(){const t="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:null,e=t&&(t.crypto||t.msCrypto)||null;if("function"==typeof e?.getRandomValues)return()=>{const t=new Uint8Array(1);return e.getRandomValues(t),t[0]/256};if("function"==typeof e?.randomBytes)return()=>e.randomBytes(1).readUInt8()/256;throw new IU(wU.PRNGDetectFailure,"Failed to find a reliable PRNG")}();return function(t,e=10){if(isNaN(t))throw new IU(wU.EncodeTimeValueMalformed,`Time must be a number: ${t}`);if(t>0xffffffffffff)throw new IU(wU.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${t}`);if(t<0)throw new IU(wU.EncodeTimeNegative,`Time must be positive: ${t}`);if(!1===Number.isInteger(t))throw new IU(wU.EncodeTimeValueMalformed,`Time must be an integer: ${t}`);let n,r="";for(let i=e;i>0;i--)n=t%32,r=PU.charAt(n)+r,t=(t-n)/32;return r}(!t||isNaN(t)?Date.now():t,10)+function(t,e){let n="";for(;t>0;t--)n=MU(e)+n;return n}(16,n)}(),r="number"==typeof t.lat?t.lat:0,i="number"==typeof t.lon?t.lon:0,s=t.title||"Untitled Place",o=t.geohash||gj.encode(r,i,10),a={...t,id:n,lat:r,lon:i,geohash:o,title:s,tags:t.tags||[],createdAt:t.createdAt||e,updatedAt:t.id?e:void 0};return Object.keys(a).forEach(t=>{void 0===a[t]&&delete a[t]}),a}(n),i=e(r.geohash,r.id);return await t.storeObject("place",i,r),r},remove:async function(r,i){if(!r||!i)throw new Error("Both id and geohash are required to remove a place");const s=await n.getAll();await Promise.all(s.map(async e=>{const n=e.placeRefs.findIndex(t=>t.id===r);-1!==n&&(e.placeRefs.splice(n,1),e.updatedAt=(new Date).toISOString(),await t.storeObject("list",`_lists/${e.id}`,e))}));const o=e(i,r);return t.remove(o)},get:async function(n,r){if(!n||!r)throw new Error("Both id and geohash are required to get a place");const i=e(r,n);return t.getObject(i)},listByPrefix:async function(e){let n="";return e.length>=2&&(n+=e.substring(0,2)+"/"),e.length>=4&&(n+=e.substring(2,4)+"/"),t.getAll(n)},getPlaces:async function(e){const n=[],r=async e=>{const r=await t.getAll(e,!1);r&&Object.values(r).forEach(t=>{t&&"object"==typeof t&&!t.toString().endsWith("/")&&n.push(t)})};if(e&&e.length>0){const t=e.map(async t=>{if(t.length<4)return;const e=t.substring(0,2),n=t.substring(2,4);await r(`${e}/${n}/`)});await Promise.all(t)}else{const e=t=>{if(!t||"object"!=typeof t)return[];let e=t;return t.items&&"object"==typeof t.items&&(e=t.items),Object.keys(e).filter(t=>t.endsWith("/")&&!t.startsWith("@"))},n=e(await t.getListing("",!1));await Promise.all(n.map(async n=>{const i=await t.getListing(n,!1),s=e(i);await Promise.all(s.map(async t=>{await r(n+t)}))}))}return n}}}}},NU=o((t,e)=>{var n,r;n=self,r=()=>(()=>{var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function r(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}t.d(e,{default:()=>i});const i=function(){return t=function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.rs=e,this.leaveOpen=!!n.leaveOpen&&n.leaveOpen,this.autoCloseAfter=n.autoCloseAfter?n.autoCloseAfter:1500,this.skipInitial=!!n.skipInitial&&n.skipInitial,this.logging=!!n.logging&&n.logging,this.parentContainerEl=null,n.hasOwnProperty("modalBackdrop")){if("boolean"!=typeof n.modalBackdrop&&"onlySmallScreens"!==n.modalBackdrop)throw'options.modalBackdrop has to be true/false or "onlySmallScreens"';this.modalBackdrop=n.modalBackdrop}else this.modalBackdrop="onlySmallScreens";this.active=!1,this.online=!1,this.closed=!1,this.lastSynced=null,this.lastSyncedUpdateLoop=null},e=[{key:"log",value:function(){if(this.logging){for(var t,e=arguments.length,n=new Array(e),r=0;r

Connect your storage

To sync data with your account
';var e=document.createElement("style");return e.innerHTML='#remotestorage-widget {\n z-index: 21000000;\n}\n\n.rs-widget {\n box-sizing: border-box;\n overflow: hidden;\n max-width: 350px;\n padding: 10px;\n margin: 10px;\n border-radius: 3px;\n background-color: #fff;\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n font-family: arial, sans-serif;\n font-size: 16px;\n color: #333;\n will-change: max-height, height, width, opacity, max-width, background, box-shadow;\n transition-property: width, height, opacity, max-width, max-height, background, box-shadow;\n transition-duration: 300ms;\n}\n\n.rs-widget * {\n box-sizing: border-box;\n}\n\n.rs-widget .rs-hidden {\n display: none;\n}\n\n.rs-box {\n overflow: hidden;\n will-change: height;\n transition-property: height, width, max-height;\n transition-duration: 300ms;\n transition-timing-function: ease-in;\n opacity: 0;\n max-height: 0px;\n}\n\n.rs-box.rs-selected:not([aria-hidden=true]) {\n opacity: 1;\n max-height: 420px;\n}\n\n/* Main logo */\n.rs-main-logo {\n float: left;\n height: 36px;\n width: 36px;\n margin-top: 1px;\n margin-right: 0.625em;\n transition: margin-left 300ms ease-out, transform 300ms ease-out;\n cursor: pointer;\n}\n.rs-widget .rs-backend-remotestorage svg#rs-main-logo-remotestorage {\n display: block;\n}\n.rs-widget[class*="rs-backend-"]:not(.rs-backend-remotestorage) svg#rs-main-logo-remotestorage {\n display: none;\n}\n.rs-widget.rs-backend-dropbox svg#rs-main-logo-dropbox {\n display: block;\n}\n.rs-widget:not(.rs-backend-dropbox) svg#rs-main-logo-dropbox {\n display: none;\n}\n.rs-widget.rs-backend-googledrive svg#rs-main-logo-googledrive {\n display: block;\n}\n.rs-widget:not(.rs-backend-googledrive) svg#rs-main-logo-googledrive {\n display: none;\n}\n\npolygon.rs-logo-shape {\n fill: #FF4B03;\n}\n\npolygon.rs-logo-shape,\n#rs-main-logo-dropbox path,\n#rs-main-logo-googledrive path {\n transition-property: fill;\n transition-duration: 0.5s;\n}\n\n.rs-offline polygon.rs-logo-shape,\n.rs-offline #rs-main-logo-dropbox path,\n.rs-offline #rs-main-logo-googledrive path {\n fill: #888;\n transition-property: fill;\n transition-duration: 0.5s;\n}\n\n/* Hide everything except logo when connected and clicked outside of box */\n.rs-closed {\n max-width: 56px;\n background-color: transparent;\n box-shadow: none;\n opacity: 0.5;\n\n transition: max-height 100ms ease-out 0ms, max-width 300ms ease-out 300ms, background 300ms ease-in 200ms, opacity 300ms ease 200ms;\n}\n\n.rs-closed:hover {\n cursor: pointer;\n opacity: 1;\n}\n\n.rs-box-initial {\n transition-duration: 0ms;\n}\n\n.rs-box-initial:hover {\n cursor: pointer;\n}\n\n.rs-widget a {\n color: #0093cc;\n}\n\n/* HEADLINE */\n.rs-small-headline {\n font-size: 1em;\n font-weight: bold;\n margin: 0;\n margin-bottom: 2px;\n height: 1.2em;\n word-break: break-all;\n overflow: hidden;\n line-height: 1em;\n}\n\n.rs-sub-headline {\n word-break: break-all;\n overflow: hidden;\n color: #666;\n font-size: 0.92em;\n height: 1.2em;\n}\n.rs-big-headline {\n font-size: 1.625em;\n font-weight: normal;\n text-align: center;\n margin-top: 20px;\n margin-bottom: 20px;\n}\n\n/* BUTTONS */\n.rs-button {\n font: inherit;\n color: inherit;\n background-color: transparent;\n border: 1px solid #dcdcdc;\n border-radius: 3px;\n cursor: pointer;\n}\n.rs-button-small {\n padding: 0.6em 0.7em;\n margin-left: 0.2em;\n transition: border-color 300ms ease-out;\n}\n.rs-button-small svg {\n vertical-align: top;\n}\n.rs-button-wrap {\n margin-top: 10px;\n}\n\n.rs-button-wrap img,\n.rs-button-wrap svg {\n float: left;\n margin-right: 0.6em;\n width: 40px;\n height: 40px;\n}\n\n.rs-button-big {\n padding: 15px 10px;\n margin-bottom: 10px;\n display: block;\n width: 100%;\n text-align: left;\n transition: box-shadow 200ms;\n}\n.rs-button-big > div {\n font-size: 1.125em;\n padding: 10px 0;\n}\n.rs-button-big:hover {\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n}\n.rs-button-big:active {\n background-color: #eee;\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n}\n.rs-button-big:last-child {\n margin-bottom: 0;\n}\n\n.rs-content {\n padding: 0 10px 10px 10px;\n}\n\n\n.rs-state-choose .rs-main-logo,\n.rs-state-sign-in .rs-main-logo {\n margin-left: 45%;\n float: none;\n}\n\n.rs-sign-in-form input[type=text] {\n padding: 15px 10px;\n display: block;\n width: 100%;\n font: inherit;\n height: 52px;\n border: 1px solid #aaa;\n border-radius: 0;\n box-shadow: none;\n}\n.rs-sign-in-form button.rs-connect {\n padding: 15px 10px;\n margin-top: 20px;\n margin-bottom: 15px;\n display: block;\n width: 100%;\n border: none;\n border-radius: 3px;\n background-color: #3fb34f;\n font: inherit;\n color: #fff;\n transition: box-shadow 200ms, background-color 200ms;\n}\n\n.rs-sign-in-form button.rs-connect:hover {\n cursor: pointer;\n background-color: #4BCB5D;\n box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1), 0 3px 8px 0 rgba(0,0,0,0.2);\n}\n\n.rs-sign-in-form button.rs-connect:active {\n background-color: #3fb34f;\n}\n\n.rs-sign-in-form button.rs-connect:disabled,\n.rs-sign-in-form button.rs-connect:disabled:hover {\n background-color: #aaa;\n}\n\n.rs-sign-in-form button.rs-connecting svg {\n height: 1em;\n width: auto;\n vertical-align: middle;\n margin-left: 0.5em;\n animation: rs-spin 1s linear infinite;\n}\n\n.rs-sign-in-error.rs-hidden,\n.rs-box-error.rs-hidden {\n height: 0;\n}\n\n.rs-sign-in-error.rs-visible,\n.rs-box-error.rs-visible {\n height: auto;\n border-radius: 3px;\n padding: 0.5em 0.5em;\n margin-top: 0.5em;\n text-align: center;\n background-color: rgba(255,0,0,0.1);\n color: darkred;\n}\n\n.rs-box-error {\n display: flex;\n flex-direction: row;\n}\n\n.rs-box-error .rs-error-message {\n flex: auto;\n}\n\n /*Choose provider box */\n.rs-box-choose {\n text-align: center;\n overflow: hidden;\n}\n\n.rs-box-choose p {\n margin-top: 0;\n margin-bottom: 20px;\n line-height: 1.4em;\n}\n\n/*Connected box */\n.rs-box-connected {\n display: flex;\n flex-direction: row;\n height: 40px;\n transition: height 0s;\n}\n.rs-connected-text {\n flex: auto;\n min-width: 0;\n}\n.rs-box-connected .rs-user {\n font-weight: bold;\n text-overflow: ellipsis;\n overflow: hidden;\n word-break: keep-all;\n}\n.rs-connected-buttons, .rs-error-buttons {\n flex: none;\n}\n.rs-disconnect:hover {\n border-color: #FF2D2D;\n}\n.rs-disconnect:hover .rs-icon{\n fill: #FF2D2D;\n}\n.rs-sync:hover {\n border-color: #FFBB0C;\n}\n.rs-sync:hover .rs-icon {\n fill: #FFBB0C;\n}\n.rs-sync.rs-rotate {\n border-color: #FFBB0C;\n}\n.rs-sync.rs-rotate .rs-icon {\n fill: #FFBB0C;\n animation: rs-spin 1s linear infinite;\n}\n\n/* Floating widget styles (top right corner) */\n.rs-floating {\n position: fixed;\n top: 0;\n right: 0;\n}\n\n@keyframes rs-spin {\n 100% {\n transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n/* Small/mobile screens */\n@media screen and (max-width: 420px) {\n .rs-widget {\n font-size: 100%;\n transition: all 300ms ease-out;\n max-width: 400px;\n }\n .rs-floating {\n position: relative;\n top: auto;\n right: auto\n }\n .rs-closed {\n max-width: 56px;\n }\n .rs-state-choose,\n .rs-state-sign-in {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n max-width: 100%;\n }\n}\n\n/* remove dotted outline border on Firefox */\n.rs-widget a:focus,\n.rs-widget a:active,\n.rs-widget button:focus,\n.rs-widget input:focus {\n outline:none;\n}\n.rs-widget button::-moz-focus-inner,\n.rs-widget input[type="button"]::-moz-focus-inner {\n border:0;\n}\n\n/* prevent rounded buttons on mobile Safari */\n.rs-widget button,\n.rs-widget input[type="button"] {\n -webkit-appearance: none;\n}\n\n.remotestorage-widget-modal-backdrop {\n display: none;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: rgba(0, 0, 0, 0.5);\n opacity: 0;\n transition: opacity 0.3s linear;\n}\n\n.remotestorage-widget-modal-backdrop.visible {\n opacity: 1;\n transition: opacity 0.3s linear;\n}\n',t.appendChild(e),t}},{key:"setModalClass",value:function(){if(this.modalBackdrop){if("onlySmallScreens"===this.modalBackdrop&&!this.isSmallScreen())return;this.rsWidget.classList.add("rs-modal")}}},{key:"setupElements",value:function(){if(!this.parentContainerEl)throw new Error("Parent container element not found");this.rsWidget=this.parentContainerEl.querySelector(".rs-widget"),this.rsBackdrop=this.parentContainerEl.querySelector(".remotestorage-widget-modal-backdrop"),this.rsInitial=this.parentContainerEl.querySelector(".rs-box-initial"),this.rsChoose=this.parentContainerEl.querySelector(".rs-box-choose"),this.rsConnected=this.parentContainerEl.querySelector(".rs-box-connected"),this.rsSignIn=this.parentContainerEl.querySelector(".rs-box-sign-in"),this.rsConnectedLabel=this.parentContainerEl.querySelector(".rs-box-connected .rs-sub-headline"),this.rsChooseRemoteStorageButton=this.parentContainerEl.querySelector("button.rs-choose-rs"),this.rsChooseDropboxButton=this.parentContainerEl.querySelector("button.rs-choose-dropbox"),this.rsChooseGoogleDriveButton=this.parentContainerEl.querySelector("button.rs-choose-googledrive"),this.rsErrorBox=this.parentContainerEl.querySelector(".rs-box-error .rs-error-message"),this.rs.apiKeys.hasOwnProperty("googledrive")||this.rsChooseGoogleDriveButton.parentNode.removeChild(this.rsChooseGoogleDriveButton),this.rs.apiKeys.hasOwnProperty("dropbox")||this.rsChooseDropboxButton.parentNode.removeChild(this.rsChooseDropboxButton),this.rsSignInForm=this.parentContainerEl.querySelector(".rs-sign-in-form"),this.rsAddressInput=this.rsSignInForm.querySelector("input[name=rs-user-address]"),this.rsConnectButton=this.parentContainerEl.querySelector(".rs-connect"),this.rsDisconnectButton=this.parentContainerEl.querySelector(".rs-disconnect"),this.rsSyncButton=this.parentContainerEl.querySelector(".rs-sync"),this.rsLogo=this.parentContainerEl.querySelector(".rs-widget-icon"),this.rsErrorReconnectLink=this.parentContainerEl.querySelector(".rs-box-error a.rs-reconnect"),this.rsErrorDisconnectButton=this.parentContainerEl.querySelector(".rs-box-error button.rs-disconnect"),this.rsConnectedUser=this.parentContainerEl.querySelector(".rs-connected-text h1.rs-user")}},{key:"setupHandlers",value:function(){var t=this;this.rs.on("connected",function(){return t.eventHandler("connected")}),this.rs.on("ready",function(){return t.eventHandler("ready")}),this.rs.on("disconnected",function(){return t.eventHandler("disconnected")}),this.rs.on("network-online",function(){return t.eventHandler("network-online")}),this.rs.on("network-offline",function(){return t.eventHandler("network-offline")}),this.rs.on("error",function(e){return t.eventHandler("error",e)}),this.setEventListeners(),this.setClickHandlers()}},{key:"attach",value:function(t){var e=this.createHtmlTemplate(t);if(this.parentContainerEl,t instanceof HTMLElement)this.parentContainerEl=t;else if("string"==typeof t){if(this.parentContainerEl=document.getElementById(t),!this.parentContainerEl)throw new Error('Failed to find target DOM element with id="'+t+'"')}else{if(t)throw new Error("Unknown element type. Expected instance of HTMLElement or type of string.");this.parentContainerEl=document.body}this.parentContainerEl.appendChild(e),this.setupElements(),this.setupHandlers(),this.setInitialState(),this.setModalClass()}},{key:"setEventListeners",value:function(){var t=this;this.rsSignInForm.addEventListener("submit",function(e){e.preventDefault();var n=t.parentContainerEl.querySelector("input[name=rs-user-address]").value.trim();t.disableConnectButton(),t.rs.connect(n)})}},{key:"showChooseOrSignIn",value:function(){this.rsWidget.classList.contains("rs-modal")&&(this.rsBackdrop.style.display="block",this.rsBackdrop.classList.add("visible")),this.rs.apiKeys&&Object.keys(this.rs.apiKeys).length>0?this.setState("choose"):this.setState("sign-in")}},{key:"setClickHandlers",value:function(){var t=this;this.rsInitial.addEventListener("click",function(){return t.showChooseOrSignIn()}),this.rsChooseRemoteStorageButton.addEventListener("click",function(){t.setState("sign-in"),t.rsAddressInput.focus()}),this.rsChooseDropboxButton.addEventListener("click",function(){return t.rs.dropbox.connect()}),this.rsChooseGoogleDriveButton.addEventListener("click",function(){return t.rs.googledrive.connect()}),this.rsDisconnectButton.addEventListener("click",function(){return t.rs.disconnect()}),this.rsErrorReconnectLink.addEventListener("click",function(){return t.rs.reconnect()}),this.rsErrorDisconnectButton.addEventListener("click",function(){return t.rs.disconnect()}),this.rs.hasFeature("Sync")&&this.rsSyncButton.addEventListener("click",function(){t.rsSyncButton.classList.contains("rs-rotate")?(t.rs.stopSync(),t.rsSyncButton.classList.remove("rs-rotate")):(t.rsConnectedLabel.textContent="Synchronizing",t.rs.startSync(),t.rsSyncButton.classList.add("rs-rotate"))}),document.addEventListener("click",function(){return t.close()}),this.rsWidget.addEventListener("click",function(t){return t.stopPropagation()}),this.rsLogo.addEventListener("click",function(){return t.toggle()})}},{key:"toggle",value:function(){this.closed?this.open():"initial"===this.state?this.showChooseOrSignIn():this.close()}},{key:"open",value:function(){this.closed=!1,this.rsWidget.classList.remove("rs-closed"),this.shouldCloseWhenSyncDone=!1;var t=this.parentContainerEl.querySelector(".rs-box.rs-selected");t&&t.setAttribute("aria-hidden","false")}},{key:"close",value:function(){var t=this;if("error"!==this.state){if(!this.leaveOpen&&this.active){this.closed=!0,this.rsWidget.classList.add("rs-closed");var e=this.parentContainerEl.querySelector(".rs-box.rs-selected");e&&e.setAttribute("aria-hidden","true")}else this.active?this.setState("connected"):this.setInitialState();this.rsWidget.classList.contains("rs-modal")&&(this.rsBackdrop.classList.remove("visible"),setTimeout(function(){t.rsBackdrop.style.display="none"},300))}}},{key:"disableConnectButton",value:function(){this.rsConnectButton.disabled=!0,this.rsConnectButton.classList.add("rs-connecting"),this.rsConnectButton.innerHTML="Connecting ".concat('\n \n \n \n \n \n \n\n')}},{key:"enableConnectButton",value:function(){this.rsConnectButton.disabled=!1,this.rsConnectButton.textContent="Connect",this.rsConnectButton.classList.remove("rs-connecting")}},{key:"setOffline",value:function(){this.online&&(this.rsWidget.classList.add("rs-offline"),this.rsConnectedLabel.textContent="Offline",this.online=!1)}},{key:"setOnline",value:function(){this.online||(this.rsWidget.classList.remove("rs-offline"),this.active&&(this.rsConnectedLabel.textContent="Connected")),this.online=!0}},{key:"setBackendClass",value:function(t){this.rsWidget.classList.remove("rs-backend-remotestorage"),this.rsWidget.classList.remove("rs-backend-dropbox"),this.rsWidget.classList.remove("rs-backend-googledrive"),t&&this.rsWidget.classList.add("rs-backend-".concat(t))}},{key:"showErrorBox",value:function(t){this.rsErrorBox.innerHTML=t,this.setState("error")}},{key:"hideErrorBox",value:function(){this.rsErrorBox.innerHTML="",this.close()}},{key:"handleSyncStarted",value:function(){var t=this;this.syncInProgress=!0,this.rsSyncButton.classList.add("rs-rotate"),setTimeout(function(){t.syncInProgress&&(t.rsConnectedLabel.textContent="Synchronizing")},1e3)}},{key:"handleDiscoveryError",value:function(t){var e=this.parentContainerEl.querySelector(".rs-sign-in-error");e.innerHTML=t.message,e.classList.remove("rs-hidden"),e.classList.add("rs-visible"),this.enableConnectButton()}},{key:"handleSyncError",value:function(){this.setOffline()}},{key:"handleUnauthorized",value:function(t){t.code&&"access_denied"===t.code?this.rs.disconnect():(this.open(),this.showErrorBox(t.message+" "),this.rsErrorBox.appendChild(this.rsErrorReconnectLink),this.rsErrorReconnectLink.classList.remove("rs-hidden"))}},{key:"updateLastSyncedStatus",value:function(){var t=new Date;this.online?(this.lastSynced=t,this.rsConnectedLabel.textContent="Synced"):this.rsWidget.classList.contains("rs-state-unauthorized")||(this.rsConnectedLabel.textContent="Offline")}},{key:"isSmallScreen",value:function(){return window.innerWidth<421}}],e&&function(t,e){for(var n=0;nIs(t.cancelId))}))),s=r.has(e)?r.get(e).debouncedTask:(...n)=>{r.delete(e),t[e](...n)};let o=Ms(t,s,...n);r.set(e,{debouncedTask:s,cancelId:o})}var UU=a({default:()=>BU}),BU=class extends dp{static{oN(this.prototype,"osm",[hp])}#j=void lN(this,"osm");static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");rs;widget;static{oN(this.prototype,"placesInView",[qr],function(){return[]})}#Rt=void lN(this,"placesInView");static{oN(this.prototype,"savedPlaces",[qr],function(){return[]})}#Tt=void lN(this,"savedPlaces");static{oN(this.prototype,"loadedPrefixes",[qr],function(){return[]})}#Lt=void lN(this,"loadedPrefixes");static{oN(this.prototype,"currentBbox",[qr],function(){return null})}#Pt=void lN(this,"currentBbox");static{oN(this.prototype,"lists",[qr],function(){return[]})}#It=void lN(this,"lists");static{oN(this.prototype,"version",[qr],function(){return 0})}#Mt=void lN(this,"version");static{oN(this.prototype,"initialSyncDone",[qr],function(){return!1})}#At=void lN(this,"initialSyncDone");static{oN(this.prototype,"connected",[qr],function(){return!1})}#Ot=void lN(this,"connected");static{oN(this.prototype,"userAddress",[qr],function(){return null})}#Ft=void lN(this,"userAddress");static{oN(this.prototype,"isWidgetOpen",[qr],function(){return!1})}#Nt=void lN(this,"isWidgetOpen");isNewConnection=!0;constructor(){super(...arguments),this.checkInitialConnectionState(),this.rs=new LU.default({modules:[FU]}),this.rs.access.claim("places","rw"),this.rs.caching.enable("/places/"),window.remoteStorage=this.rs,this.widget=new zU.default(this.rs,{leaveOpen:!0,skipInitial:!0}),this.rs.on("ready",()=>{}),this.rs.on("error",t=>{t&&(console.info("[rs] Error —",`${t.name}: ${t.message}`),"Unauthorized"===t.name&&this.showConnectWidget())}),this.rs.on("connected",()=>{this.connected=!0,this.userAddress=this.rs.remote.userAddress,this.isNewConnection&&(this.toast.show("Remote storage connected",3e3),this.isNewConnection=!1),this.loadLists()}),this.rs.on("not-connected",()=>{this.loadLists()}),this.rs.on("disconnected",()=>{this.connected=!1,this.userAddress=null,this.placesInView=[],this.savedPlaces=[],this.loadedPrefixes=[],this.lists=[],this.initialSyncDone=!1,this.isNewConnection=!0}),this.rs.on("sync-done",()=>{this.initialSyncDone||(this.initialSyncDone=!0,this.loadLists())}),this.rs.scope("/places/").on("change",t=>{t.relativePath.startsWith("_lists/")?this.loadLists():(this.handlePlaceChange(t),jU(this,"reloadCurrentView",200))})}checkInitialConnectionState(){this.isNewConnection=!0;try{if(window.localStorage)for(const t of["remotestorage:wireclient","remotestorage:dropbox","remotestorage:googledrive"]){const e=window.localStorage.getItem(t);if(e){const t=JSON.parse(e);if(t&&t.token){this.isNewConnection=!1;break}}}}catch(t){console.warn("Failed to check localStorage for existing connection:",t)}}handlePlaceChange(t){const{newValue:e,relativePath:n}=t,r=n.split("/"),i=r[r.length-1];if(e){const t={...e,id:i},n=this.savedPlaces.findIndex(t=>t.id===i);if(-1!==n){const e=[...this.savedPlaces];e[n]=t,this.savedPlaces=e}else this.savedPlaces=[...this.savedPlaces,t]}else this.savedPlaces=this.savedPlaces.filter(t=>t.id!==i)}get places(){return this.rs.places}notifyChange(){this.version++,jU(this,"reloadCurrentView",200)}reloadCurrentView(){if(!this.currentBbox)return;const t=yj(this.currentBbox);console.debug("Reloading view due to changes, prefixes:",t),this.loadAllPlaces(t)}async loadLists(){try{if(!this.places.lists)return;await this.places.lists.initDefaults();const t=await this.places.lists.getAll();this.lists=t||[],this.lists.forEach(t=>{"to-go"===t.id?t.icon="bookmark":"to-do"===t.id&&(t.icon="check-square")}),this.refreshPlaceListAssociations()}catch(t){console.error("Failed to load lists:",t)}}refreshPlaceListAssociations(){const t=new Map;this.lists.forEach(e=>{e.placeRefs&&Array.isArray(e.placeRefs)&&e.placeRefs.forEach(n=>{n.id&&(t.has(n.id)||t.set(n.id,[]),t.get(n.id).push(e.id))})});const e=e=>(e._listIds=t.get(e.id)||[],e);this.savedPlaces=this.savedPlaces.map(t=>e({...t})),this.placesInView=this.placesInView.map(t=>e({...t}))}async togglePlaceList(t,e,n){if(!t)return;let r=t;if(!t.id||!t.geohash){if(!n)return;r=await this.storePlace(t)}try{return n?await this.places.lists.addPlace(e,r.id,r.geohash):await this.places.lists.removePlace(e,r.id),await this.loadLists(),this.findPlaceById(r.id)}catch(i){throw console.error("Failed to toggle place in list:",i),i}}async getPlacesInList(t){return this.places&&this.places.lists?this.places.lists.getPlaces(t):[]}async loadPlacesInBounds(t){const e=yj(t).filter(t=>!this.loadedPrefixes.includes(t));0!==e.length&&(console.debug("Loading new prefixes:",e),await this.loadAllPlaces(e),this.loadedPrefixes=[...this.loadedPrefixes,...e],this.currentBbox=t)}async loadAllPlaces(t=null){try{const e=await this.places.getPlaces(t);if(e&&Array.isArray(e)){if(t){const n=new Set(t),r=this.placesInView.filter(t=>{if(!t.lat||!t.lon)return!1;try{const e=gj.encode(t.lat,t.lon,4);return!n.has(e)}catch{return!0}});this.placesInView=[...r,...e]}else this.placesInView=e;this.refreshPlaceListAssociations()}else t||(this.placesInView=[]);console.debug("Loaded saved places:",this.placesInView.length)}catch(e){console.error("Failed to load places:",e)}}findPlaceById(t){if(!t)return;const e=String(t);let n=this.savedPlaces.find(t=>t.id&&String(t.id)===e);return n||(n=this.placesInView.find(t=>t.id&&String(t.id)===e),n||(n=this.savedPlaces.find(t=>t.osmId&&String(t.osmId)===e),n||(n=this.placesInView.find(t=>t.osmId&&String(t.osmId)===e),n)))}isPlaceSaved(t){return!!this.findPlaceById(t)}async storePlace(t){const e=await this.places.store(t);return this.savedPlaces.some(t=>t.id===e.id)?this.savedPlaces=this.savedPlaces.map(t=>t.id===e.id?e:t):this.savedPlaces=[...this.savedPlaces,e],this.placesInView.some(t=>t.id===e.id)?this.placesInView=this.placesInView.map(t=>t.id===e.id?e:t):this.placesInView=[...this.placesInView,e],e}async updatePlace(t){const e=await this.places.store(t),n=this.savedPlaces.findIndex(t=>t.id===e.id);if(-1!==n){const t=[...this.savedPlaces];t[n]=e,this.savedPlaces=t}return this.placesInView=this.placesInView.map(t=>t.id===e.id?e:t),e}async removePlace(t){await this.places.remove(t.id,t.geohash),this.savedPlaces=this.savedPlaces.filter(e=>e.id!==t.id),this.placesInView.length>0&&(this.placesInView=this.placesInView.filter(e=>e.id!==t.id))}async refreshPlace(t){if(!(t&&t.id&&t.osmId&&t.osmType))return null;try{console.debug(`Checking for updates for ${t.title} (${t.osmId})`);const e=await this.osm.fetchOsmObject(t.osmId,t.osmType);if(!e)return console.warn("Could not fetch fresh data for",t.osmId),null;let n=!1;const r={},i=Math.abs(t.lat-e.lat),s=Math.abs(t.lon-e.lon);(i>1e-5||s>1e-5)&&(n=!0,r.lat=e.lat,r.lon=e.lon);const o=t.osmTags||{},a=e.osmTags||{},l=new Set([...Object.keys(o),...Object.keys(a)]);for(const t of l)if(o[t]!==a[t]){n=!0,r.osmTags=a;break}if(!n)return console.debug("No changes detected for",t.title),null;console.debug("Changes detected:",r);const c={...t,...r},u=fU(o),h=fU(a);return t.title===u&&u!==h&&(c.title=h),await this.updatePlace(c)}catch(e){return console.error("Failed to refresh place:",e),null}}showConnectWidget(){this.isWidgetOpen=!0,document.querySelector(".rs-widget")||this.widget.attach("rs-widget-container")}static{aN(this.prototype,"showConnectWidget",[$l])}closeWidget(){this.isWidgetOpen=!1}static{aN(this.prototype,"closeWidget",[$l])}disconnect(){this.rs.disconnect(),this.isWidgetOpen=!1}static{aN(this.prototype,"disconnect",[$l])}},$U=a({default:()=>qU}),qU=class extends dp{static{oN(this.prototype,"message",[qr],function(){return null})}#zt=void lN(this,"message");static{oN(this.prototype,"isVisible",[qr],function(){return!1})}#Dt=void lN(this,"isVisible");timeoutId=null;show(t,e=3e3){this.message=t,this.isVisible=!0,this.timeoutId&&clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isVisible=!1},e)}},VU=a({getDistance:()=>WU});function WU(t,e,n,r){const i=t*Math.PI/180,s=n*Math.PI/180,o=(n-t)*Math.PI/180,a=(r-e)*Math.PI/180,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(s)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3}var HU=a({getIcon:()=>ZU,isIconFilled:()=>YU}),GU={activity:'',angelfish:'\n \n',"arrow-left":'',barbell:'\n \n',banknote:'\n \n',"badge-shield-with-fire":'\n \n',"beach-umbrella-in-ground":'\n \n',"beer-mug-with-foam":'\n \n',bookmark:'',"boxing-glove-up":'\n \n',"burger-and-drink-cup-with-straw":'\n \n',bridge:'\n \n',bus:'\n \n',camera:'\n \n',"feather-camera":'',"check-square":'',"chevron-left":'',"chevron-right":'',"cigarette-with-smoke-curl":'\n \n',"city-gate":'\n \n',climbing_wall:'\n \n',check:'',"alert-circle":'',"alert-triangle":'',"classical-building":'\n \n',"classical-building-with-clock":'\n \n',"classical-building-with-dome-and-flag":'\n \n',"classical-building-with-flag":'\n \n',"commercial-building":'\n \n',"clothes-hanger":'\n \n',cleaver:'\n \n',cloth:'\n \n',cocktail:'\n \n',clock:'',"coffee-bean":'\n \n',"comedy-mask-and-tragedy-mask":'\n \n',croissant:'\n \n',"cup-and-saucer":'\n \n',database:'',donut:'\n \n',edit:'',eyeglasses:'\n \n',facebook:'',"fancy-mirror-with-reflection-and-stars":'\n \n',"family-restroom-symbol":'\n \n',film:'\n \n',"fingernail-polished":'\n \n',fish:'\n \n',"flag-checkered":'\n \n',"flower-bouquet":'\n \n',"fork-and-knife":'\n \n',fort:'\n \n',gift:'',globe:'',gravestone:'\n \n',"grecian-vase":'\n \n',"greek-cross":'\n \n',heart:'',home:'',"ice-cream-on-cone":'\n \n',"industrial-building":'\n \n',info:'',"info-i":'\n \n',instagram:'',jewel:'\n \n',"log-in":'',"log-out":'',"lowrise-building":'\n \n',mail:'',map:'',"map-pin":'',"market-stall":'\n \n',"memorial-stone-with-inscription":'\n \n',menu:'',"mobile-phone-with-keypad-and-antenna":'\n \n',"molar-tooth":'\n \n',"more-horizontal":'',"more-vertical":'',navigation:'',"needle-and-spool-of-thread":'\n \n',nostrich:'\n \n\n',"open-book":'\n \n',palace:'\n \n',"person-cricket-batting-at-cricket-ball":'\n \n',"person-boarding-tram-with-destination-display-and-pantograph-on-tram-track":'\n \n',"person-jockeying-racehorse":'\n \n',"person-playing-tennis":'\n \n',"person-running":'\n \n',"person-sleeping-in-bed":'\n \n',"person-swimming-in-water":'\n \n',"person-swinging-golf-club":'\n \n',phone:'',"plane-top-right":'\n \n',"plant-in-raised-planter":'\n \n',"place-of-worship-building":'\n \n',"play-structure-with-slide":'\n \n',"police-officer-with-stop-arm":'\n \n',plus:'',"round-structure-with-flag":'\n \n',remotestorage:'\n\x3c!-- Creator: CorelDRAW X7 --\x3e\n\n \n',"sailing-ship-in-water":'\n \n',"scissors-open":'\n \n',"shipwreck-in-water":'\n \n',"steam-train-on-railway-track":'\n \n',"shopping-bag":'\n \n',search:'',server:'',settings:'',"shopping-basket":'\n \n',"shopping-cart":'\n \n',"table-tennis-paddle":'\n \n',"tattoo-machine":'\n \n',toolbox:'\n \n',target:'',"trash-2":'',"upload-cloud":'',"tree-and-bench-with-backrest":'\n \n',user:'',"village-buildings":'\n \n',"wall-hanging-with-mountains-and-sun":'\n \n',"womens-and-mens-restroom-symbol":'\n \n',whatsapp:'\n\n \n\n',wikipedia:'\n\n\n',winding_way_wide:'\n \n',parking_p:'\n \n',car:'\n \n',"car-and-wrench":'\n \n',"castle-keep":'\n \n',x:'',zap:'',"loading-ring":''},KU=["fork-and-knife","wikipedia","whatsapp","cup-and-saucer","coffee-bean","shopping-basket","person-sleeping-in-bed","loading-ring","nostrich"];function ZU(t){return GU[t]}function YU(t){return KU.includes(t)}var XU=a({POI_ICON_RULES:()=>JU,getIconNameForTags:()=>QU,getIconSvgForTags:()=>tB}),JU=[{tags:{cuisine:"donut"},icon:"donut"},{tags:{cuisine:"doughnut"},icon:"donut"},{tags:{cuisine:"coffee_shop"},icon:"coffee-bean"},{tags:{cuisine:"coffee"},icon:"coffee-bean"},{tags:{amenity:"ice_cream"},icon:"ice-cream-on-cone"},{tags:{cuisine:"ice_cream"},icon:"ice-cream-on-cone"},{tags:{shop:"ice_cream"},icon:"ice-cream-on-cone"},{tags:{amenity:"cafe"},icon:"cup-and-saucer"},{tags:{amenity:"restaurant"},icon:"fork-and-knife"},{tags:{amenity:"fast_food"},icon:"burger-and-drink-cup-with-straw"},{tags:{amenity:"pub"},icon:"beer-mug-with-foam"},{tags:{amenity:"bar"},icon:"cocktail"},{tags:{amenity:"food_court"},icon:"fork-and-knife"},{tags:{amenity:"childcare"},icon:"family-restroom-symbol"},{tags:{amenity:"community_centre"},icon:"family-restroom-symbol"},{tags:{amenity:"social_centre"},icon:"family-restroom-symbol"},{tags:{amenity:"social_facility"},icon:"family-restroom-symbol"},{tags:{amenity:"bank"},icon:"banknote"},{tags:{amenity:"place_of_worship"},icon:"place-of-worship-building"},{tags:{amenity:"townhall"},icon:"classical-building-with-clock"},{tags:{building:"townhall"},icon:"classical-building-with-clock"},{tags:{amenity:"fire_station"},icon:"badge-shield-with-fire"},{tags:{amenity:"police"},icon:"police-officer-with-stop-arm"},{tags:{amenity:"toilets"},icon:"womens-and-mens-restroom-symbol"},{tags:{amenity:"school"},icon:"open-book"},{tags:{amenity:"driving_school"},icon:"car"},{tags:{shop:"coffee"},icon:"coffee-bean"},{tags:{shop:"tea"},icon:"coffee-bean"},{tags:{shop:"pastry"},icon:"donut"},{tags:{shop:"supermarket"},icon:"shopping-cart"},{tags:{shop:"convenience"},icon:"shopping-basket"},{tags:{shop:"grocery"},icon:"shopping-basket"},{tags:{shop:"greengrocer"},icon:"shopping-basket"},{tags:{shop:"bakery"},icon:"croissant"},{tags:{shop:"butcher"},icon:"cleaver"},{tags:{shop:"seafood"},icon:"fish"},{tags:{shop:"deli"},icon:"shopping-basket"},{tags:{shop:"clothes"},icon:"clothes-hanger"},{tags:{shop:"clothing"},icon:"clothes-hanger"},{tags:{shop:"hairdresser"},icon:"scissors-open"},{tags:{shop:"optician"},icon:"eyeglasses"},{tags:{shop:"fabric"},icon:"cloth"},{tags:{shop:"flea_market"},icon:"market-stall"},{tags:{shop:"kiosk"},icon:"shopping-basket"},{tags:{shop:"leather"},icon:"shopping-bag"},{tags:{shop:"tailor"},icon:"needle-and-spool-of-thread"},{tags:{shop:"jewelry"},icon:"jewel"},{tags:{shop:"jewellery"},icon:"jewel"},{tags:{shop:"tobacco"},icon:"cigarette-with-smoke-curl"},{tags:{shop:"cannabis"},icon:"cigarette-with-smoke-curl"},{tags:{shop:"florist"},icon:"flower-bouquet"},{tags:{shop:"garden_centre"},icon:"plant-in-raised-planter"},{tags:{shop:"estate_agent"},icon:"village-buildings"},{tags:{shop:"mobile_phone"},icon:"mobile-phone-with-keypad-and-antenna"},{tags:{beauty:"nails"},icon:"fingernail-polished"},{tags:{shop:"tattoo"},icon:"tattoo-machine"},{tags:{shop:"beauty"},icon:"fancy-mirror-with-reflection-and-stars"},{tags:{shop:"car_repair"},icon:"car-and-wrench"},{tags:{craft:"tailor"},icon:"needle-and-spool-of-thread"},{tags:{office:"estate_agent"},icon:"village-buildings"},{tags:{office:!0},icon:"commercial-building"},{tags:{craft:!0},icon:"toolbox"},{tags:{shop:!0},icon:"shopping-bag"},{tags:{natural:"beach"},icon:"beach-umbrella-in-ground"},{tags:{leisure:"park"},icon:"tree-and-bench-with-backrest"},{tags:{leisure:"playground"},icon:"play-structure-with-slide"},{tags:{aeroway:"aerodrome"},icon:"plane-top-right"},{tags:{aeroway:"heliport"},icon:"plane-top-right"},{tags:{aeroway:"helipad"},icon:"plane-top-right"},{tags:{highway:"bus_stop"},icon:"bus"},{tags:{bus:!0},icon:"bus"},{tags:{railway:"tram_stop"},icon:"person-boarding-tram-with-destination-display-and-pantograph-on-tram-track"},{tags:{tourism:"museum"},icon:"classical-building"},{tags:{tourism:"gallery"},icon:"wall-hanging-with-mountains-and-sun"},{tags:{tourism:"aquarium"},icon:"angelfish"},{tags:{tourism:"theme_park"},icon:"camera"},{tags:{tourism:"attraction"},icon:"camera"},{tags:{tourism:"viewpoint"},icon:"camera"},{tags:{tourism:"zoo"},icon:"camera"},{tags:{tourism:"artwork"},icon:"camera"},{tags:{tourism:"information"},icon:"info-i"},{tags:{amenity:"cinema"},icon:"film"},{tags:{amenity:"theatre"},icon:"camera"},{tags:{amenity:"arts_centre"},icon:"comedy-mask-and-tragedy-mask"},{tags:{amenity:"arts_center"},icon:"comedy-mask-and-tragedy-mask"},{tags:{historic:"canal"},icon:"winding_way_wide"},{tags:{historic:"bridge"},icon:"bridge"},{tags:{historic:"bridge_site"},icon:"bridge"},{tags:{historic:"fort"},icon:"fort"},{tags:{historic:"city_gate"},icon:"city-gate"},{tags:{historic:"castle"},icon:"palace"},{tags:{building:"tower",historic:"yes"},icon:"castle-keep"},{tags:{historic:"building"},icon:"classical-building-with-flag"},{tags:{historic:"archaeological_site"},icon:"grecian-vase"},{tags:{historic:"memorial"},icon:"memorial-stone-with-inscription"},{tags:{historic:"tomb"},icon:"gravestone"},{tags:{historic:"monument"},icon:"classical-building-with-dome-and-flag"},{tags:{historic:"folly"},icon:"classical-building"},{tags:{historic:"industrial"},icon:"industrial-building"},{tags:{historic:"railway_station"},icon:"steam-train-on-railway-track"},{tags:{historic:"ship"},icon:"sailing-ship-in-water"},{tags:{historic:"wreck"},icon:"shipwreck-in-water"},{tags:{historic:"ruins"},icon:"camera"},{tags:{historic:"ruin"},icon:"camera"},{tags:{historic:"yes"},icon:"camera"},{tags:{tourism:"hotel"},icon:"person-sleeping-in-bed"},{tags:{tourism:"hostel"},icon:"person-sleeping-in-bed"},{tags:{tourism:"motel"},icon:"person-sleeping-in-bed"},{tags:{tourism:"guest_house"},icon:"person-sleeping-in-bed"},{tags:{sport:"motor"},icon:"flag-checkered"},{tags:{sport:"karting"},icon:"flag-checkered"},{tags:{sport:"motocross"},icon:"flag-checkered"},{tags:{sport:"cricket"},icon:"person-cricket-batting-at-cricket-ball"},{tags:{sport:"boxing"},icon:"boxing-glove-up"},{tags:{sport:"martial_arts"},icon:"boxing-glove-up"},{tags:{sport:"tennis"},icon:"person-playing-tennis"},{tags:{sport:"squash"},icon:"person-playing-tennis"},{tags:{sport:"padel"},icon:"person-playing-tennis"},{tags:{sport:"table_tennis"},icon:"table-tennis-paddle"},{tags:{sport:"climbing"},icon:"climbing_wall"},{tags:{leisure:"water_park"},icon:"person-swimming-in-water"},{tags:{sport:"swimming"},icon:"person-swimming-in-water"},{tags:{sport:"golf"},icon:"person-swinging-golf-club"},{tags:{leisure:"golf_course"},icon:"person-swinging-golf-club"},{tags:{sport:"horse_racing"},icon:"person-jockeying-racehorse"},{tags:{sport:"fitness"},icon:"barbell"},{tags:{sport:"fitness_centre"},icon:"barbell"},{tags:{leisure:"fitness_centre"},icon:"barbell"},{tags:{sport:"stadium"},icon:"round-structure-with-flag"},{tags:{leisure:"stadium"},icon:"round-structure-with-flag"},{tags:{leisure:"sports_centre"},icon:"person-running"},{tags:{leisure:"pitch"},icon:"person-running"},{tags:{sport:!0},icon:"person-running"},{tags:{amenity:"dentist"},icon:"molar-tooth"},{tags:{healthcare:"dentist"},icon:"molar-tooth"},{tags:{healthcare:!0},icon:"greek-cross"},{tags:{amenity:"parking"},icon:"parking_p"},{tags:{building:"commercial"},icon:"commercial-building"},{tags:{building:"apartments"},icon:"lowrise-building"}];function QU(t){if(!t)return null;for(const e of JU){let n=!0;for(const[r,i]of Object.entries(e.tags)){const e=t[r];if(!e){n=!1;break}const s=e.split(";").map(t=>t.trim());if(!0!==i&&!s.includes(i)){n=!1;break}}if(n)return e.icon}return null}function tB(t){const e=QU(t);return e?ZU(e):null}var eB=a({getMatchingPoiCategories:()=>nB,getMatchingPoiCategoryIds:()=>rB});function nB(t,e){return Array.isArray(e)&&t?e.filter(e=>!!Array.isArray(e.filter)&&e.filter.some(e=>function(t,e){const n=function(t){if(!t)return[];const e=t.match(/\[[^\]]+\]/g);return e?e.map(t=>function(t){const e=t.match(/^"([^"]+)"$/);if(e)return{type:"presence",key:e[1]};const n=t.match(/^"([^"]+)"\s*=\s*"([^"]*)"$/);if(n)return{type:"equals",key:n[1],value:n[2]};const r=t.match(/^"([^"]+)"\s*~\s*"([^"]*)"$/);if(r)return{type:"regex",key:r[1],pattern:r[2],regex:new RegExp(r[2])};const i=t.match(/^"([^"]+)"\s*!~\s*"([^"]*)"$/);return i?{type:"not-regex",key:i[1],pattern:i[2],regex:new RegExp(i[2])}:null}(t.slice(1,-1).trim())).filter(Boolean):[]}(e);return 0!==n.length&&n.every(e=>function(t,e){const n=function(t,e){if(!t||!e)return[];const n=t[e];return null==n?[]:String(n).split(";").map(t=>t.trim()).filter(Boolean)}(t,e.key);switch(e.type){case"presence":return n.length>0;case"equals":return n.some(t=>t===e.value);case"regex":return n.some(t=>e.regex.test(t));case"not-regex":return 0===n.length||!n.some(t=>e.regex.test(t));default:return!1}}(t,e))}(t,e))):[]}function rB(t,e){return nB(t,e).map(t=>t.id)}var iB=a({CATEGORY_TAGS:()=>sB,getSuggestedPhotoTags:()=>oB}),sB={restaurants:["food","menu","vibe","front"],coffee:["food","menu","vibe","front"],groceries:["front","food"],"things-to-do":["architecture","amenities","vibe","front"],accommodation:["rooms","amenities","food","vibe","front"]};function oB(t){const e=rB(t?.osmTags||t?.tags||{},vU),n=[];for(const r of e){const t=sB[r];if(Array.isArray(t))for(const e of t)n.includes(e)||n.push(e)}return 0===n.length?[]:n}var aB=a({mapToStorageSchema:()=>lB});function lB(t){return{title:t.title||fU(t.osmTags,"Untitled Place"),lat:t.lat,lon:t.lon,tags:[],url:t.osmTags?.website,osmId:String(t.osmId||t.id),osmType:t.osmType,osmTags:t.osmTags||{},description:t.description}}var cB=a({getSocialInfo:()=>hB}),uB=(t,...e)=>{for(const n of e)if(t[n])return t[n];return null};function hB(t,e){if(!t)return null;const n=`${e}.com`,r=uB(t,`contact:${e}`,e);if(!r)return null;if(r.startsWith("http"))try{const t=new URL(r);return"facebook"===e&&"/profile.php"===t.pathname&&t.searchParams.has("id")?{url:r,username:t.searchParams.get("id")}:{url:r,username:t.pathname.replace(/^\/|\/$/g,"")||r}}catch{return{url:r,username:r}}const i=r.replace(/^@/,"");return{url:`https://${n}/${i}`,username:i}}var dB,pB,fB,gB,mB,yB=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","#","$","%","*","+",",","-",".",":",";","=","?","@","[","]","^","_","{","|","}","~"],vB=t=>{let e=0;for(let n=0;n{var n="";for(let r=1;r<=e;r++){let i=Math.floor(t)/Math.pow(83,e-r)%83;n+=yB[Math.floor(i)]}return n},wB=t=>{let e=t/255;return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)},_B=t=>{let e=Math.max(0,Math.min(1,t));return e<=.0031308?Math.trunc(12.92*e*255+.5):Math.trunc(255*(1.055*Math.pow(e,.4166666666666667)-.055)+.5)},xB=(t,e)=>(t=>t<0?-1:1)(t)*Math.pow(Math.abs(t),e),CB=class extends Error{constructor(t){super(t),this.name="ValidationError",this.message=t}},kB=t=>{let e=t>>8&255,n=255&t;return[wB(t>>16),wB(e),wB(n)]},SB=(t,e)=>{let n=Math.floor(t/361),r=Math.floor(t/19)%19,i=t%19;return[xB((n-9)/9,2)*e,xB((r-9)/9,2)*e,xB((i-9)/9,2)*e]},EB=(t,e,n,r)=>{let i=0,s=0,o=0,a=4*e;for(let c=0;c{if("PROCESS_IMAGE"!==t.data?.type)return;const{id:e,file:n,targetWidth:r,targetHeight:i,quality:s,computeBlurhash:o}=t.data;try{let t,c;try{const e=await createImageBitmap(n,{resizeWidth:r,resizeHeight:i,resizeQuality:"high"});if(t=new OffscreenCanvas(r,i),c=t.getContext("2d"),!c)throw new Error("Failed to get 2d context from OffscreenCanvas");c.drawImage(e,0,0,r,i),e.close()}catch(a){console.warn("Hardware resize failed, falling back to stepped software scaling:",a);const e=await n.arrayBuffer(),s=new Blob([e],{type:n.type}),o=await createImageBitmap(s);let l=o.width,u=o.height,h=new OffscreenCanvas(l,u),d=h.getContext("2d");for(d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(o,0,0);.5*h.width>r&&.5*h.height>i;){const t=new OffscreenCanvas(Math.floor(.5*h.width),Math.floor(.5*h.height)),e=t.getContext("2d");e.imageSmoothingEnabled=!0,e.imageSmoothingQuality="high",e.drawImage(h,0,0,t.width,t.height),h=t}t=new OffscreenCanvas(r,i),c=t.getContext("2d"),c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high",c.drawImage(h,0,0,r,i),o.close()}let u=null;if(o)try{u=((t,e,n)=>{if(e*n*4!==t.length)throw new CB("Width and height must match the pixels array");let r=[];for(let l=0;l<3;l++)for(let i=0;i<4;i++){let s=0==i&&0==l?1:2,o=EB(t,e,n,(t,r)=>s*Math.cos(Math.PI*i*t/e)*Math.cos(Math.PI*l*r/n));r.push(o)}let i,s=r[0],o=r.slice(1),a="";if(a+=bB(21,1),o.length>0){let t=Math.max(...o.map(t=>Math.max(...t))),e=Math.floor(Math.max(0,Math.min(82,Math.floor(166*t-.5))));i=(e+1)/166,a+=bB(e,1)}else i=1,a+=bB(0,1);return a+=bB((t=>(_B(t[0])<<16)+(_B(t[1])<<8)+_B(t[2]))(s),4),o.forEach(t=>{a+=bB(((t,e)=>19*Math.floor(Math.max(0,Math.min(18,Math.floor(9*xB(t[0]/e,.5)+9.5))))*19+19*Math.floor(Math.max(0,Math.min(18,Math.floor(9*xB(t[1]/e,.5)+9.5))))+Math.floor(Math.max(0,Math.min(18,Math.floor(9*xB(t[2]/e,.5)+9.5)))))(t,i),2)}),a})(c.getImageData(0,0,r,i).data,r,i)}catch(l){console.warn("Could not generate blurhash (possible canvas fingerprinting protection):",l)}const h=await t.convertToBlob({type:"image/jpeg",quality:s}),d=`${r}x${i}`;self.postMessage({id:e,success:!0,blob:h,dim:d,blurhash:u})}catch(Z4){self.postMessage({id:e,success:!1,error:Z4.message})}};var IB="undefined"!=typeof FastBoot,MB="routeDidChange",AB=["separator","prepend","replace"],OB=(dB=hp("router"),pB=hp("-document"),fB=class extends dp{constructor(t){if(super(t),LB(this,"router",gB,this),LB(this,"document",mB,this),TB(this,"tokens",[]),TB(this,"_defaultConfig",{separator:" | ",prepend:!0,replace:null}),TB(this,"scheduleTitleUpdate",()=>{Ls("afterRender",this,this._updateTitle)}),this._validateExistingTitleElement(),function(t){return"resolveRegistration"in t}(t)){const n=t.resolveRegistration("config:environment");"object"==typeof(e=n)&&null!==e&&"pageTitle"in e&&AB.forEach(t=>{if(!function(t){if(null==t)return!0;if(!lr(t)&&"number"==typeof t.size)return!t.size;if("object"==typeof t){let e=cr(t,"size");if("number"==typeof e)return!e;let n=cr(t,"length");if("number"==typeof n)return!n}return"number"==typeof t.length&&"function"!=typeof t&&!t.length}(n.pageTitle[t])){const e=n.pageTitle[t];this._defaultConfig[t]=e}})}var e;this.router.on(MB,this.scheduleTitleUpdate)}applyTokenDefaults(t){const e=this._defaultConfig.separator,n=this._defaultConfig.prepend,r=this._defaultConfig.replace;t.previous??=null,t.next??=null,null==t.separator&&(t.separator=e),null==t.prepend&&null!=n&&(t.prepend=n),null==t.replace&&null!=r&&(t.replace=r)}inheritFromPrevious(t){const e=t.previous;e&&(null==t.separator&&(t.separator=e.separator),null==t.prepend&&(t.prepend=e.prepend))}push(t){const e=this._findTokenById(t.id);if(e){const n=this.tokens.indexOf(e),r=[...this.tokens];return t.previous=e.previous,t.next=e.next,this.inheritFromPrevious(t),this.applyTokenDefaults(t),r.splice(n,1,t),void(this.tokens=r)}const n=this.tokens.slice(-1)[0];n&&(t.previous=n??null,n.next=t,this.inheritFromPrevious(t)),this.applyTokenDefaults(t),this.tokens=[...this.tokens,t]}remove(t){const e=this._findTokenById(t);if(!e)return;const{next:n,previous:r}=e;n&&(n.previous=r),r&&(r.next=n),e.previous=e.next=null;const i=[...this.tokens];i.splice(i.indexOf(e),1),this.tokens=i}get visibleTokens(){const t=this.tokens;let e=t?t.length:0;const n=[];for(;e--;){const r=t[e];if(r){if(r.replace){n.unshift(r);break}n.unshift(r)}}return n}get sortedTokens(){const t=this.visibleTokens;if(!t)return[];let e=!0,n=[];const r=[n],i=[];return t.forEach(t=>{t.front?i.unshift(t):t.prepend?(e&&(e=!1,n=[],r.push(n)),n.unshift(t)):(e||(e=!0,n=[],r.push(n)),n.push(t))}),i.concat(r.reduce((t,e)=>t.concat(e),[]))}toString(){const t=this.sortedTokens,e=[];for(let n=0,r=t.length;ne.id===t)}updateFastbootTitle(t){if(!IB)return;const e=this.document.head,n=e.childNodes;for(let s=0;sOB}),NB=gb,zB=bl.create({target:null,action:null,actionContext:null,actionContextObject:Zn("actionContext",function(){let t=cr(this,"actionContext");if("string"==typeof t){let e=cr(this,t);return void 0===e&&(e=cr(Yr.lookup,t)),e}return t}),triggerAction(t={}){let{action:e,target:n,actionContext:r}=t;e=e||cr(this,"action"),n=n||function(t){let e=cr(t,"target");if(e){if("string"==typeof e){let n=cr(t,e);return void 0===n&&(n=cr(Yr.lookup,e)),n}return e}return t._target?t._target:null}(this),void 0===r&&(r=cr(this,"actionContextObject")||this);let i=Array.isArray(r)?r:[r];if(n&&e){let t;if(t=null!=(s=n)&&"object"==typeof s&&"function"==typeof s.send?n.send(e,...i):n[e](...i),!1!==t)return!0}var s;return!1}}),DB=bl.create({send(t,...e){let n=this.actions&&this.actions[t];if(n&&!0!==n.apply(this,e))return;let r=cr(this,"target");r&&r.send(...arguments)}}),jB=Object.freeze({appendChild(){throw new Error("You can't use appendChild outside of the rendering process")},handleEvent:()=>!0,rerender(){},destroy(){}}),UB=Object.freeze({...jB}),BB=Object.freeze({...jB,rerender(t){t.renderer.rerender()},destroy(t){t.renderer.remove(t)},handleEvent:(t,e,n)=>!t.has(e)||lv(0,0,()=>ws(t,t.trigger,e,n))}),$B=Object.freeze({...BB,enter(t){t.renderer.register(t)}}),qB=Object.freeze({...jB,appendChild(){throw new Error("You can't call appendChild on a view being destroyed")},rerender(){throw new Error("You can't call rerender on a view being destroyed")}}),VB=Object.freeze({preRender:UB,inDOM:$B,hasElement:BB,destroying:qB}),WB=class extends(Zc.extend(yc,Cl)){isView=!0;_superTrigger;_superHas;init(t){super.init(t),this._superTrigger=this.trigger,this.trigger=this._trigger,this._superHas=this.has,this.has=this._has,this.parentView??=null,this._state="preRender",this._currentState=this._states.preRender}static{Hh(this.prototype,"renderer",[Br("renderer","-dom")])}#jt=void Kh(this,"renderer");instrumentDetails(t){return t.object=this.toString(),t.containerKey=this._debugContainerKey,t.view=this,t}_trigger(t,...e){this._superTrigger(t,...e);let n=this[t];if("function"==typeof n)return n.apply(this,e)}_has(t){return"function"==typeof this[t]||this._superHas(t)}static isViewFactory=!0};WB.prototype._states=VB;var HB=a({Input:()=>a_,Textarea:()=>u_,capabilities:()=>ab,default:()=>ZB,getComponentTemplate:()=>Ap,setComponentManager:()=>YB,setComponentTemplate:()=>Mp}),GB=new WeakMap,KB=Object.freeze([]),ZB=class extends(WB.extend(zB,DB,{didReceiveAttrs(){},didRender(){},didUpdate(){},didUpdateAttrs(){},willRender(){},willUpdate(){}},{concatenatedProperties:["attributeBindings","classNames","classNameBindings"],classNames:KB,classNameBindings:KB})){isComponent=!0;init(t){super.init(t),this._superRerender=this.rerender,this.rerender=this._rerender,this[Rv]=!1,this[Ev]=pt(),this[Tv]=null;const e=this._dispatcher;if(e){let t=GB.get(e);t||(t=new WeakSet,GB.set(e,t));let n=Object.getPrototypeOf(this);t.has(n)||(e.lazyEvents.forEach((t,n)=>{null!==t&&"function"==typeof this[t]&&e.setupHandlerForBrowserEvent(n)}),t.add(n))}this.elementId||""===this.tagName||(this.elementId=ol(this))}__dispatcher;get _dispatcher(){if(void 0===this.__dispatcher){let t=jr(this);if(t.lookup("-environment:main").isInteractive){let e=t.lookup("event_dispatcher:main");this.__dispatcher=e}else this.__dispatcher=null}return this.__dispatcher}on(t,e,n){return this._dispatcher?.setupHandlerForEmberEvent(t),super.on(t,e,n)}_rerender(){ht(this[Ev]),this._superRerender()}[jn](t,e){if(this[Rv])return;let n=Sv.get(this),r=void 0!==n?n[t]:void 0;void 0!==r&&ve(r)&&we(r,2===arguments.length?e:cr(this,t))}getAttr(t){return this.get(t)}readDOMAttr(t){let e=Xl(this),n="http://www.w3.org/2000/svg"===e.namespaceURI,{type:r,normalized:i}=xg(e,t);return n||"attr"===r?e.getAttribute(i):e[i]}get childViews(){return rc(this)}static{Gh(this.prototype,"childViews",[x({configurable:!1,enumerable:!1})])}appendChild(t){ic(this,t)}_transitionTo(t){let e=this._currentState,n=this._currentState=this._states[t];this._state=t,e&&e.exit&&e.exit(this),n.enter&&n.enter(this)}nearestOfType(t){let e=this.parentView;for(;e;){if(t.detect(e.constructor))return e;e=e.parentView}}nearestWithProperty(t){let e=this.parentView;for(;e;){if(t in e)return e;e=e.parentView}}rerender(){return this._currentState.rerender(this)}get element(){return this.renderer.getElement(this)}static{Gh(this.prototype,"element",[x({configurable:!1,enumerable:!1})])}appendTo(t){let e;return e=Io&&"string"==typeof t?document.querySelector(t):t,this.renderer.appendTo(this,e),this}append(){return this.appendTo(document.body)}willInsertElement(){return this}didInsertElement(){return this}willClearRender(){return this}destroy(){return super.destroy(),this._currentState.destroy(this),this}willDestroyElement(){return this}didDestroyElement(){return this}parentViewDidChange(){return this}handleEvent(t,e){return this._currentState.handleEvent(this,t,e)}static isComponentFactory=!0;static toString(){return"@ember/component"}};function YB(t,e){return fb(t,e)}ZB.reopenClass({positionalParams:[]}),Ou(Ov,ZB);var XB=a({default:()=>s$}),JB=new WeakMap,QB=new WeakMap,t$=class{constructor(t,e){this.args=e,JB.set(this,!1),QB.set(this,!1)}args;get isDestroying(){return JB.get(this)||!1}get isDestroyed(){return QB.get(this)||!1}willDestroy(){}},e$=class{owner;constructor(t){this.owner=t}createComponent(t,e){return new t(this.owner,e.named)}getContext(t){return t}},n$=ab(0,{destructor:!0,asyncLifecycleCallbacks:!1,updateHook:!1});function r$(t){t.isDestroyed||(tt(t),function(t){QB.set(t,!0)}(t))}var i$=class extends e${capabilities=n$;destroyComponent(t){t.isDestroying||(function(t){JB.set(t,!0)}(t),ks("actions",t,t.willDestroy),ks("destroy",this,r$,t))}},s$=class extends t${constructor(t,e){super(t,e),Ur(this,t)}};YB(t=>new i$(t),s$);var o$=class extends s${get svg(){return ZU(this.args.name)}get size(){return this.args.size||16}get color(){return this.args.color||"#898989"}get style(){return Bv(`width:${this.size}px;height:${this.size}px;color:${this.color}`)}get title(){return this.args.title||""}get isFilled(){return this.args.filled||YU(this.args.name)}static{Mp(ng({id:null,block:'[[[41,[30,0,["svg"]],[[[1," "],[10,1],[15,0,[29,["icon ",[52,[30,0,["isFilled"]],"icon-filled"]]]],[15,5,[30,0,["style"]]],[15,"title",[30,0,["title"]]],[12],[1,"\\n "],[1,[28,[32,0],[[30,0,["svg"]]],null]],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({htmlSafe:Bv}),isStrictMode:!0}),this)}};function a$(t){return Ut(t.argsCache)}var l$=class{argsCache;constructor(t,e=()=>oy){let n=jt(()=>e(t));this.argsCache=n}get named(){return a$(this).named||iy}get positional(){return a$(this).positional||sy}};function c$(t,e,n){const r=Dr(t),i=Au(e).getDelegateFor(r);let s,o=new l$(t,n),a=i.createHelper(e,o);if(!bu(i))throw new Error("TODO: unreachable, to be implemented with hasScheduledEffect");return s=jt(()=>i.getValue(a)),J(t,s),wu(i)&&J(s,i.getDestroyable(a)),s}function u$(t,e){return t===e}function h$(t,e){return t!==e}function d$(t,e){return t>e}function p$(t,e){return t>=e}function f$(t,e){return tpe(()=>{let e;for(let n=0;npe(()=>{let e;for(let n=0;n!j(t[0]),b$={createInstance:!0,wrapped:!0},w$=new class{getCapabilities(){return b$}getDebugName(t){return`(element "${t.tagName}")`}getSelf(){return le}getDestroyable(){return null}didCreateElement(){}create(t,e){return e.tagName||null}getTagName(t){return t}didRenderLayout(){}didUpdateLayout(){}didCreate(){}didUpdate(){}},_$=class{constructor(t){this.tagName=t}toString(){return`(element "${this.tagName}")`}};Ou(w$,_$.prototype);var x$=new Map;jv(({positional:t,named:e})=>pe(()=>function(t){let e=x$.get(t);return void 0===e&&(e=new _$(t),x$.set(t,e)),e}(be(t[0])),null));var C$=Vv,k$=d$;function S$(t){return"object"==typeof t&&t&&"isTruthy"in t&&"boolean"==typeof t.isTruthy?t.isTruthy:Lc(t)?0!==t.length:!!t}var E$=class extends bb{compute(t){for(let e=0,n=t.length;et.tags||[]);return[...new Set(t)]}static{Mp(ng({id:null,block:'[[[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"contribution-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,1],[[30,1],[30,2]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"contribution-thumb"],[12],[1,"\\n"],[41,[30,0,["primaryPhoto"]],[[[1," "],[10,"img"],[15,"src",[28,[32,2],[[30,0,["primaryPhoto","thumbUrl"]],[30,0,["primaryPhoto","url"]]],null]],[15,"alt",[28,[32,2],[[30,0,["primaryPhoto","alt"]],"Place photo"],null]],[14,"loading","lazy"],[12],[13],[1,"\\n"]],[]],null],[41,[28,[32,3],[[30,0,["extraPhotoCount"]],0],null],[[[1," "],[10,1],[14,0,"contribution-thumb-badge"],[12],[1,"+"],[1,[30,0,["extraPhotoCount"]]],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"contribution-info"],[12],[1,"\\n "],[10,0],[14,0,"contribution-place"],[12],[1,"\\n"],[41,[30,0,["placeName"]],[[[1," "],[1,[30,0,["placeName"]]],[1,"\\n"]],[]],[[[41,[30,0,["isNameLoading"]],[[[1," "],[10,1],[14,0,"contribution-name-loading"],[12],[1,"Loading…"],[13],[1,"\\n"]],[]],[[[1," "],[10,1],[14,0,"contribution-name-loading"],[12],[1,"Unnamed place"],[13],[1,"\\n "]],[]]]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"contribution-meta"],[12],[1,"\\n "],[1,[28,[32,4],[[30,2,["createdAt"]]],null]],[1,"\\n"],[41,[28,[32,3],[[30,0,["item","photos","length"]],1],null],[[[1," ·\\n "],[1,[30,0,["item","photos","length"]]],[1,"\\n photos\\n"]],[]],[[[1," · 1 photo\\n"]],[]]],[1," "],[13],[1,"\\n"],[41,[30,0,["tags","length"]],[[[1," "],[10,0],[14,0,"contribution-tags"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["tags"]]],null]],null],null,[[[1," "],[10,1],[14,0,"contribution-tag"],[12],[1,[30,3]],[13],[1,"\\n"]],[3]],null],[1," "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onSelect","@item","tag"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,fn:C$,or:E$,__keyword__gt:k$,formatRelativeDate:R$}),isStrictMode:!0}),this)}};function L$(t,e){return t===e}function P$(...t){return t.every(t=>!S$(t))}var I$=class{capabilities=db();constructor(t){this.owner=t}createModifier(t,e){return{instance:new t(this.owner,e),element:null}}installModifier(t,e,n){(function(t,e){const n=t;return n.element=e,n})(t,e).instance.modify(e,n.positional,n.named)}updateModifier(t,e){t.instance.modify(t.element,e.positional,e.named)}destroyModifier({instance:t}){tt(t)}};NB(t=>new I$(t),class{constructor(t,e){Z_(this,t)}modify(t,e,n){}});var M$=new class{capabilities=db();createModifier(t){return{element:null,instance:t}}installModifier(t,e,n){const r=function(t,e){const n=t;return n.element=e,n}(t,e),{positional:i,named:s}=n,o=t.instance(e,i,s);"function"==typeof o&&(r.teardown=o)}updateModifier(t,e){"function"==typeof t.teardown&&t.teardown();const n=t.instance(t.element,e.positional,e.named);"function"==typeof n&&(t.teardown=n)}destroyModifier(t){"function"==typeof t.teardown&&t.teardown()}getDebugName(t){return t.instance.toString()}getDebugInstance(t){return t}};function A$(t,e){return t.toString=()=>e?.name||t.name,NB(()=>M$,t)}var O$=A$((t,[e])=>{t&&"number"==typeof e&&e>0&&requestAnimationFrame(()=>{t.scrollTop=e})}),F$=sb,N$=Mp(ng({id:null,block:'[[[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"\\n "],[10,1],[14,0,"sidebar-header-icon-wrapper"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["activity",20,"#898989"]],null],[1,"\\n "],[13],[1,"\\n My Contributions\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[11,0],[24,0,"sidebar-content"],[4,[32,2],[[30,3]],null],[12],[1,"\\n"],[41,[30,4],[[[1," "],[10,0],[14,0,"sidebar-loading"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["loading-ring",24,"#898989"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],[[[41,[28,[32,3],[[30,5]],null],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"\\n Connect your Nostr account to see your contributions.\\n "],[13],[1,"\\n"]],[]],[[[41,[28,[32,3],[[30,6,["length"]]],null],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"No contributions yet."],[13],[1,"\\n"]],[]],[[[1," "],[10,"ul"],[14,0,"contributions-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,6]],null]],null],null,[[[41,[28,[32,4],[[30,7,["type"]],"photo"],null],[[[1," "],[8,[32,5],null,[["@item","@onSelect"],[[30,7],[30,8]]],null],[1,"\\n"]],[]],null]],[7]],null],[1," "],[13],[1,"\\n "]],[]]]],[]]]],[]]],[1," "],[13],[1,"\\n"],[13]],["@onBack","@onClose","@scrollTop","@isLoading","@isConnected","@items","item","@onSelect"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,Icon:o$,restoreScroll:O$,not:P$,eq:L$,ContributionPhoto:T$}),isStrictMode:!0}),F$()),z$=a({default:()=>D$}),D$=Mp(ng({id:null,block:'[[[41,[30,1,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@items","@isLoading","@isConnected","@scrollTop","@onSelect","@onBack","@onClose"],[[30,1,["items"]],[30,1,["loadContributionsTask","isRunning"]],[30,1,["isConnected"]],[30,1,["scrollTop"]],[30,1,["selectContribution"]],[30,1,["backToMenu"]],[30,1,["close"]]]],null],[1,"\\n"]],[]],null]],["@controller"],["if"]]',moduleName:"(unknown template module)",scope:()=>({ContributionsTimeline:N$}),isStrictMode:!0}),F$()),j$=class{assert(){}async(t){Promise.resolve().then(t)}reportUncaughtRejection(){this.async(t=>{throw t})}defer(){let t={promise:null,resolve:null,reject:null};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}globalDebuggingEnabled(){return!1}},U$=new j$,B$=class{constructor(t){this.maxConcurrency=t||1}},$$="CANCELLED",q$="STARTED",V$="QUEUED",W$={type:q$},H$={type:V$},G$=t=>({type:$$,reason:t}),K$=G$("it belongs to a 'drop' Task that was already running"),Z$=class{constructor(t){this.remainingSlots=t}step(){return this.remainingSlots>0?(this.remainingSlots--,W$):K$}},Y$=class extends B${makeReducer(){return new Z$(this.maxConcurrency)}},X$=class{constructor(t){this.remainingSlots=t}step(){return this.remainingSlots>0?(this.remainingSlots--,W$):H$}},J$=class extends B${makeReducer(){return new X$(this.maxConcurrency)}},Q$=G$("it belongs to a 'keepLatest' Task that was already running"),tq=class{constructor(t,e){this.remainingSlots=t,this.numToCancel=e}step(){return this.remainingSlots>0?(this.remainingSlots--,W$):this.numToCancel>0?(this.numToCancel--,Q$):H$}},eq=class extends B${makeReducer(t,e){let n=t+e;return new tq(this.maxConcurrency,n-this.maxConcurrency-1)}},nq=G$("it belongs to a 'restartable' Task that was .perform()ed again"),rq=class{constructor(t){this.numToCancel=t}step(){return this.numToCancel>0?(this.numToCancel--,nq):W$}},iq=class extends B${makeReducer(t,e){return new rq(t+e-this.maxConcurrency)}},sq=new class{step(){return W$}},oq=class{makeReducer(){return sq}},aq=new Map,lq=class{constructor(t,e,n){this.stateTracker=e,this.schedulerPolicy=t,this.initialTaskInstances=n,this.startingInstances=[]}process(){let[t,e,n]=this.filterFinishedTaskInstances(),r=this.schedulerPolicy.makeReducer(e,n),i=t.filter(t=>this.setTaskInstanceExecutionState(t,r.step()));return this.stateTracker.computeFinalStates(t=>this.applyState(t)),this.startingInstances.forEach(t=>t.start()),i}filterFinishedTaskInstances(){let t=0,e=0;return[this.initialTaskInstances.filter(n=>{let r=this.stateTracker.stateFor(n.task),i=n.executor.state;return i.isFinished?(r.onCompletion(n),!1):(i.hasStarted?t+=1:e+=1,!0)}),t,e]}setTaskInstanceExecutionState(t,e){let n=this.stateTracker.stateFor(t.task);switch(t.executor.counted||(t.executor.counted=!0,n.onPerformed(t)),e.type){case $$:return t.cancel(e.reason),!1;case q$:return t.executor.state.hasStarted||(this.startingInstances.push(t),n.onStart(t)),n.onRunning(t),!0;case V$:return n.onQueued(t),!0}}applyState(t){let{taskable:e}=t;if(!e.onState)return;const{guid:n}=e;if(aq.has(n)&&t.tagt(e))}forEachState(t){this.states.forEach(e=>t(e))}},dq=new class{onCompletion(){}onPerformed(){}onStart(){}onRunning(){}onQueued(){}},pq=class{stateFor(){return dq}computeFinalStates(){}},fq=class{constructor(t,e){this.schedulerPolicy=t,this.stateTrackingEnabled=e,this.taskInstances=[]}cancelAll(t,e){let n=this.taskInstances.map(n=>{n.task.guids[t]&&n.executor.cancel(e)}).filter(t=>!!t);return Promise.all(n)}perform(t){t.onFinalize(()=>this.scheduleRefresh()),this.taskInstances.push(t),this.refresh()}scheduleRefresh(){Promise.resolve().then(()=>this.refresh())}refresh(){let t=this.stateTrackingEnabled?new hq:new pq,e=new lq(this.schedulerPolicy,t,this.taskInstances);this.taskInstances=e.process()}},gq=class{constructor(t,e,n){this.value=t,this.done=e,this.errored=n}},mq=class{constructor(t){this.done=!1,this.generatorFactory=t,this.iterator=null}step(t,e){try{let{value:n,done:r}=this.getIterator()[e](t);return r?this.finalize(n,!1):new gq(n,!1,!1)}catch(n){return this.finalize(n,!0)}}getIterator(){return this.iterator||this.done||(this.iterator=this.generatorFactory()),this.iterator}finalize(t,e){return this.done=!0,this.iterator=null,new gq(t,!0,e)}},yq="__ec_cancel__",vq="__ec_yieldable__",bq="next",wq="throw",_q="return",xq="cancel",Cq=class{constructor(t,e){this._taskInstance=t,this._resumeIndex=e}getTaskInstance(){return this._taskInstance}cancel(){let t=this._taskInstance;t.proceed.call(t,this._resumeIndex,xq)}next(t){let e=this._taskInstance;e.proceed.call(e,this._resumeIndex,bq,t)}return(t){let e=this._taskInstance;e.proceed.call(e,this._resumeIndex,_q,t)}throw(t){let e=this._taskInstance;e.proceed.call(e,this._resumeIndex,wq,t)}},kq=class{constructor(){this[vq]=this[vq].bind(this)}onYield(){}_deferable(){let t={resolve:void 0,reject:void 0};return t.promise=new Promise((e,n)=>{t.resolve=e,t.reject=n}),t}_toPromise(){let t=this._deferable(),e=this[vq]({proceed(e,n,r){"next"==n||"return"==n?t.resolve(r):t.reject(r)}},0);return t.promise[yq]=e,t.promise}then(...t){return this._toPromise().then(...t)}catch(...t){return this._toPromise().catch(...t)}finally(...t){return this._toPromise().finally(...t)}[vq](t,e){let n=new Cq(t,e);return this.onYield(n)}},Sq=(new class extends kq{onYield(){}},{completionState:0,value:null,error:null,isSuccessful:!1,isError:!1,isCanceled:!1,hasStarted:!1,isFinished:!1}),Eq=class{constructor(t,e){this.kind=t,this.reason=e,this.promise=new Promise(t=>{this.finalize=t})}},Rq={},Tq=[],Lq=class{constructor({generatorFactory:t,env:e,debug:n}){this.generatorState=new mq(t),this.state=Object.assign({},Sq),this.index=1,this.disposers=[],this.finalizeCallbacks=[],this.env=e,this.debug=n,this.cancelRequest=null}start(){this.state.hasStarted||this.cancelRequest||(this.setState({hasStarted:!0}),this.proceedSync(bq,void 0))}cancel(t){return this.requestCancel(t)?(this.state.hasStarted?this.proceedWithCancelAsync():this.finalizeWithCancel(),this.cancelRequest.promise):(t.finalize(),t.promise)}setState(t){Object.assign(this.state,t),this.taskInstance.setState(this.state)}proceedChecked(t,e,n){this.state.isFinished||this.advanceIndex(t)&&("cancel"===e?(this.requestCancel(new Eq("yielded"),n),this.proceedWithCancelAsync()):this.proceedAsync(e,n))}proceedWithCancelAsync(){this.proceedAsync(_q,Rq)}proceedAsync(t,e){this.advanceIndex(this.index),this.env.async(()=>this.proceedSync(t,e))}proceedSync(t,e){this.state.isFinished||(this.dispose(),this.generatorState.done?this.handleResolvedReturnedValue(t,e):this.handleResolvedContinueValue(t,e))}handleResolvedContinueValue(t,e){let n=this.index,r=this.generatorStep(e,t);this.advanceIndex(n)&&(r.errored?this.finalize(r.value,2):this.handleYieldedValue(r))}handleResolvedReturnedValue(t,e){switch(t){case bq:case _q:this.finalize(e,1);break;case wq:this.finalize(e,2)}}handleYieldedUnknownThenable(t){let e=this.index;t.then(t=>{this.proceedChecked(e,bq,t)},t=>{this.proceedChecked(e,wq,t)})}advanceIndex(t){if(this.index===t)return++this.index}handleYieldedValue(t){let e=t.value;e?(this.addDisposer(e[yq]),e.__ec_yieldable__?this.invokeYieldable(e):"function"==typeof e.then?this.handleYieldedUnknownThenable(e):this.proceedWithSimpleValue(e)):this.proceedWithSimpleValue(e)}proceedWithSimpleValue(t){this.proceedAsync(bq,t)}addDisposer(t){"function"==typeof t&&this.disposers.push(t)}dispose(){let t=this.disposers;0!==t.length&&(this.disposers=[],t.forEach(t=>t()))}generatorStep(t,e){Tq.push(this);let n=this.generatorState.step(t,e);if(Tq.pop(),this._expectsLinkedYield){let t=n.value;t&&"PERFORM_TYPE_LINKED"===t.performType||console.warn("You performed a .linked() task without immediately yielding/returning it. This is currently unsupported (but might be supported in future version of ember-concurrency)."),this._expectsLinkedYield=!1}return n}maybeResolveDefer(){this.defer&&this.state.isFinished&&(1===this.state.completionState?this.defer.resolve(this.state.value):this.defer.reject(this.state.error))}onFinalize(t){this.finalizeCallbacks.push(t),this.state.isFinished&&this.runFinalizeCallbacks()}runFinalizeCallbacks(){this.finalizeCallbacks.forEach(t=>t()),this.finalizeCallbacks=[],this.maybeResolveDefer(),this.maybeThrowUnhandledTaskErrorLater()}promise(){return this.defer||(this.defer=this.env.defer(),this.asyncErrorsHandled=!0,this.maybeResolveDefer()),this.defer.promise}maybeThrowUnhandledTaskErrorLater(){var t;this.asyncErrorsHandled||2!==this.state.completionState||(t=this.state.error)&&"TaskCancelation"===t.name||this.env.async(()=>{this.asyncErrorsHandled||this.env.reportUncaughtRejection(this.state.error)})}requestCancel(t){return!this.cancelRequest&&!this.state.isFinished&&(this.cancelRequest=t,!0)}finalize(t,e){if(this.cancelRequest)return this.finalizeWithCancel();let n={completionState:e};1===e?(n.isSuccessful=!0,n.value=t):2===e?(n.isError=!0,n.error=t):3===e&&(n.error=t),this.finalizeShared(n)}finalizeWithCancel(){let t=this.taskInstance.formatCancelReason(this.cancelRequest.reason),e=new Error(t);this.debugEnabled()&&console.log(t),e.name="TaskCancelation",this.finalizeShared({isCanceled:!0,completionState:3,error:e,cancelReason:t}),this.cancelRequest.finalize()}debugEnabled(){return this.debug||this.env.globalDebuggingEnabled()}finalizeShared(t){this.index++,t.isFinished=!0,this.setState(t),this.runFinalizeCallbacks()}invokeYieldable(t){try{let e=t[vq](this.taskInstance,this.index);this.addDisposer(e)}catch(e){this.env.reportUncaughtRejection(e)}}onYielded(t,e){this.asyncErrorsHandled=!0,this.onFinalize(()=>{let n=this.state.completionState;1===n?t.proceed(e,bq,this.state.value):2===n?t.proceed(e,wq,this.state.error):3===n&&t.proceed(e,xq,null)});let n=this.getPerformType();if("PERFORM_TYPE_UNLINKED"!==n)return()=>{this.detectSelfCancelLoop(n,t),this.cancel(new Eq("parent_cancel"))}}getPerformType(){return this.taskInstance.performType||"PERFORM_TYPE_DEFAULT"}detectSelfCancelLoop(t,e){if("PERFORM_TYPE_DEFAULT"!==t)return;let n=e.executor&&e.executor.cancelRequest;!n||"lifespan_end"!==n.kind||this.cancelRequest||this.state.isFinished||this.taskInstance.selfCancelLoopWarning(e)}},Pq={last:null,lastRunning:null,lastPerformed:null,lastSuccessful:null,lastComplete:null,lastErrored:null,lastCanceled:null,lastIncomplete:null,performCount:0};Object.freeze(Pq);var Iq=0,Mq=class{constructor(t){this.context=t.context,this.debug=t.debug||!1,this.enabledModifiers=t.enabledModifiers,this.env=t.env,this.group=t.group,this.hasEnabledEvents=t.hasEnabledEvents,this.modifierOptions=t.modifierOptions,this.name=t.name,this.onStateCallback=t.onStateCallback,this.scheduler=t.scheduler,this.guid="ec_"+Iq++,this.guids={},this.guids[this.guid]=!0,this.group&&Object.assign(this.guids,this.group.guids)}cancelAll(t){let{reason:e,cancelRequestKind:n,resetState:r}=t||{};e=e||".cancelAll() was explicitly called on the Task";let i=new Eq(n||"explicit",e);return this.scheduler.cancelAll(this.guid,i).then(()=>{r&&this._resetState()})}get _isAlive(){return!0}_resetState(){this.setState(Pq)}setState(){}};Object.assign(Mq.prototype,Pq),Object.assign(Mq.prototype,{numRunning:0,numQueued:0,isRunning:!1,isQueued:!1,isIdle:!0,state:"idle"});var Aq,Oq,Fq=class{constructor(t,e,n){this.task=t,this.performType=e,this.linkedObject=n}perform(...t){return this.task._performShared(t,this.performType,this.linkedObject)}},Nq=class t extends Mq{constructor(t){super(t),this.generatorFactory=t.generatorFactory,this.perform=this._perform.bind(this)}linked(){let t=Tq[Tq.length-1];if(!t)throw new Error("You can only call .linked() from within a task.");return new Fq(this,"PERFORM_TYPE_LINKED",t)}unlinked(){return new Fq(this,"PERFORM_TYPE_UNLINKED",null)}toString(){return``}_clone(){return new t({context:this.context,debug:this.debug,env:this.env,generatorFactory:this.generatorFactory,group:this.group,hasEnabledEvents:this.hasEnabledEvents,name:this.name,onStateCallback:this.onStateCallback,scheduler:this.scheduler})}_curry(...t){let e=this._clone();return e._curryArgs=[...this._curryArgs||[],...t],e}_perform(...t){return this._performShared(t,"PERFORM_TYPE_DEFAULT",null)}_performShared(t,e,n){let r=this._curryArgs?[...this._curryArgs,...t]:t,i=this._taskInstanceFactory(r,e,n);return"PERFORM_TYPE_LINKED"===e&&(n._expectsLinkedYield=!0),this._isAlive||i.cancel(),this.scheduler.perform(i),i}_taskInstanceOptions(t,e,n){return{args:t,executor:new Lq({generatorFactory:()=>this.generatorFactory(t),env:this.env,debug:this.debug}),performType:e,hasEnabledEvents:this.hasEnabledEvents}}},zq={enqueue:(t,e)=>e&&t.setBufferPolicy(J$),debug:(t,e)=>e&&t.setDebug(e),drop:(t,e)=>e&&t.setBufferPolicy(Y$),keepLatest:(t,e)=>e&&t.setBufferPolicy(eq),maxConcurrency:(t,e)=>t.setMaxConcurrency(e),onState:(t,e)=>t.setOnState(e),restartable:(t,e)=>e&&t.setBufferPolicy(iq)},Dq=class{env=U$;_debug=null;_enabledModifiers=[];_hasSetConcurrencyConstraint=!1;_hasSetBufferPolicy=!1;_hasEnabledEvents=!1;_maxConcurrency=null;_onStateCallback=(t,e)=>e.setState(t);_schedulerPolicyClass=oq;constructor(t="",e=null,n={}){this.name=t,this.taskDefinition=e,this.options=n,this._processModifierOptions(n)}createTask(t){let e=this.getTaskOptions(t);return new Nq(Object.assign({generatorFactory:e=>this.taskDefinition.apply(t,e)},e))}getModifier(t){if(function(t){return t in zq}(t))return zq[t].bind(null,this)}getOptions(){return this.options}getScheduler(t,e){return new fq(t,e)}getTaskOptions(t){let e,n=this._onStateCallback,r=new this._schedulerPolicyClass(this._maxConcurrency);return e=this.getScheduler(r,n&&"function"==typeof n),{context:t,debug:this._debug,env:this.env,name:this.name,group:void 0,scheduler:e,hasEnabledEvents:this._hasEnabledEvents,onStateCallback:n,enabledModifiers:this._enabledModifiers,modifierOptions:this.getOptions()}}setBufferPolicy(t){return function(t){if(t._hasSetBufferPolicy)throw new Error(`Cannot set multiple buffer policies on a task. ${t._schedulerPolicyClass} has already been set for task '${t.name}'`)}(this),this._hasSetBufferPolicy=!0,this._hasSetConcurrencyConstraint=!0,this._schedulerPolicyClass=t,this}setDebug(t){return this._debug=t,this}setEvented(t){return this._hasEnabledEvents=t,this}setMaxConcurrency(t){return this._hasSetConcurrencyConstraint=!0,this._maxConcurrency=t,this}setName(t){return this.name=t,this}setOnState(t){return this._onStateCallback=t,this}setTaskDefinition(t){return this.taskDefinition=t,this}_processModifierOptions(t){if(t)for(let e of Object.keys(t)){let n=t[e],r=this.getModifier(e);"function"==typeof r&&r(n)&&this._enabledModifiers.push(e)}}},jq=a({EventTarget:()=>Ao,Promise:()=>na,all:()=>oa,allSettled:()=>la,asap:()=>Sa,async:()=>Na,cast:()=>Fa,configure:()=>Fo,default:()=>ja,defer:()=>ga,denodeify:()=>ia,filter:()=>xa,hash:()=>ha,hashSettled:()=>pa,map:()=>ya,off:()=>Da,on:()=>za,race:()=>ca,reject:()=>ba,resolve:()=>va,rethrow:()=>fa}),Uq=new class extends j${assert(...t){}async(t){ws(()=>ks("actions",t))}reportUncaughtRejection(t){Ps(null,function(){throw t})}defer(){return ga()}globalDebuggingEnabled(){return!1}},Bq=class extends fq{scheduleRefresh(){Ts(this,this.refresh)}},$q=class{constructor({task:t,args:e,executor:n,performType:r,hasEnabledEvents:i}){this.task=t,this.args=e,this.performType=r,this.executor=n,this.executor.taskInstance=this,this.hasEnabledEvents=i}setState(){}formatCancelReason(){}selfCancelLoopWarning(){}onFinalize(t){this.executor.onFinalize(t)}proceed(t,e,n){this.executor.proceedChecked(t,e,n)}[vq](t,e){return this.executor.onYielded(t,e)}cancel(t=".cancel() was explicitly called"){this.executor.cancel(new Eq("explicit",t))}then(...t){return this.executor.promise().then(...t)}catch(...t){return this.executor.promise().catch(...t)}finally(...t){return this.executor.promise().finally(...t)}toString(){return`${this.task} TaskInstance`}start(){return this.executor.start(),this}};function qq(t,e){return Object.keys(t).reduce((e,n)=>function(t,e,n){const r=Object.getOwnPropertyDescriptor(t,n);return r.initializer=r.initializer||(()=>t[n]),delete r.value,e[n]=qr(e,n,r),e}(t,e,n),e)}Object.assign($q.prototype,Sq),Object.assign($q.prototype,{state:"waiting",isDropped:!1,isRunning:!0}),Aq=qq(Pq,{}),Aq=qq({numRunning:0,numQueued:0,isRunning:!1,isQueued:!1,isIdle:!0,state:"idle"},Aq),Oq=qq(Sq,{}),Oq=qq({state:"waiting",isDropped:!1,isRunning:!1},Oq),Object.freeze(Aq),Object.freeze(Oq);var Vq=class extends $q{setState(t){let e=this._recomputeState(t);Object.assign(this,{...t,isRunning:!t.isFinished,isDropped:"dropped"===e,state:e})}_recomputeState(t){return t.isDropped?"dropped":t.isCanceled?t.hasStarted?"canceled":"dropped":t.isFinished?"finished":t.hasStarted?"running":"waiting"}formatCancelReason(t){return`TaskInstance '${this.getName()}' was canceled because ${t}. For more information, see: http://ember-concurrency.com/docs/task-cancelation-help`}getName(){return this.name||(this.name=this.task&&this.task.name||""),this.name}selfCancelLoopWarning(t){let e=`\`${t.getName()}\``,n=`\`${this.getName()}\``;console.warn(`ember-concurrency detected a potentially hazardous "self-cancel loop" between parent task ${e} and child task ${n}. If you want child task ${n} to be canceled when parent task ${e} is canceled, please change \`.perform()\` to \`.linked().perform()\`. If you want child task ${n} to keep running after parent task ${e} is canceled, change it to \`.unlinked().perform()\``)}triggerEvent(...t){if(!this.hasEnabledEvents)return;let e=this.task,n=e.context,r=e&&e.name;if(n&&n.trigger&&r){let[e,...i]=t;n.trigger(`${r}:${e}`,...i)}}};Oq&&Object.defineProperties(Vq.prototype,Oq);var Wq={_performCount:0,setState(t){this._performCount=this._performCount+(t.numPerformedInc||0);let e=t.numRunning>0,n=t.numQueued>0,r=Object.assign({},t,{performCount:this._performCount,isRunning:e,isQueued:n,isIdle:!e&&!n,state:e?"running":"idle"});Object.assign(this,r)},onState(t,e){e.onStateCallback&&e.onStateCallback(t,e)}},Hq=class t extends Nq{constructor(t){super(t),nt(this.context)||Sx(this.context,()=>{this.cancelAll({reason:"the object it lives on was destroyed or unrendered",cancelRequestKind:"lifespan_end"})})}get _isAlive(){return!nt(this.context)}_taskInstanceFactory(t,e,n){let r=this._taskInstanceOptions(t,e,n);return r.task=this,new Vq(r)}_clone(){return new t({context:this.context,debug:this.debug,env:this.env,generatorFactory:this.generatorFactory,group:this.group,hasEnabledEvents:this.hasEnabledEvents,name:this.name,onStateCallback:this.onStateCallback,scheduler:this.scheduler})}};Aq&&Object.defineProperties(Hq.prototype,Aq),Object.assign(Hq.prototype,Wq);var Gq=class extends Dq{env=Uq;createTask(t){this.taskDefinition;let e=this.getTaskOptions(t);return new Hq(Object.assign({generatorFactory:e=>this.taskDefinition.apply(t,e)},e))}getModifier(t){return super.getModifier(t)}getScheduler(t,e){return new Bq(t,e)}get taskFn(){return this.taskDefinition}set taskFn(t){this.setTaskDefinition(t)}};function Kq(t,e,n,r){let i=e;r&&(i=Object.assign({},i),i[r]=!0);const s=t();return new Gq(n||"",s.generator,i).createTask(s.context)}var Zq=a({default:()=>Yq}),Yq=class extends Qc{static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"contributions",[hp])}#$t=void lN(this,"contributions");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");loadContributionsTask=Kq(()=>({context:this,generator:function*(t){t&&(yield this.contributions.load(t))}}),{restartable:!0},"loadContributionsTask",null);get scrollTop(){return this.mapUi.getScrollPosition("contributions")}get items(){return this.contributions.items}get isConnected(){return this.nostrAuth.isConnected}selectContribution(t){if(!t)return;const e=document.querySelector(".sidebar-content");e&&this.mapUi.saveScrollPosition("contributions",e.scrollTop),this.mapUi.returnToRoute={name:"contributions"},this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!0,this.router.transitionTo(`/place/${t.placeIdentifier}`)}static{aN(this.prototype,"selectContribution",[$l])}backToMenu(){this.router.transitionTo("menu")}static{aN(this.prototype,"backToMenu",[$l])}close(){this.router.transitionTo("index")}static{aN(this.prototype,"close",[$l])}},Xq=a({default:()=>Jq}),Jq=class extends Xh{static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"contributions",[hp])}#$t=void lN(this,"contributions");activate(){this.mapUi.showSidebar()}setupController(t,e){super.setupController(t,e),t&&t.loadContributionsTask&&t.loadContributionsTask.perform(this.nostrAuth.pubkey)}deactivate(){this.contributions.stop()}},Qq=a({default:()=>tV}),tV=Mp(ng({id:null,block:'[[[46,[28,[31,1],null,null],null,null,null]],[],["component","-outlet"]]',moduleName:"(unknown template module)",isStrictMode:!0}),F$()),eV=a({default:()=>nV}),nV=class extends Xh{static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");activate(){this.mapUi.showSidebar()}},rV=class extends bb{compute(t){for(let e=0,n=t.length;e768}handleSubmit(t){t.preventDefault(),this.args.onSave&&this.args.onSave({title:this.title,description:this.description})}static{aN(this.prototype,"handleSubmit",[$l])}updateTitle(t){this.title=t.target.value}static{aN(this.prototype,"updateTitle",[$l])}updateDescription(t){this.description=t.target.value}static{aN(this.prototype,"updateDescription",[$l])}static{Mp(ng({id:null,block:'[[[11,"form"],[24,0,"edit-form"],[4,[32,0],["submit",[30,0,["handleSubmit"]]],null],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","edit-title"],[12],[1,"Title"],[13],[1,"\\n"],[1," "],[11,"input"],[24,1,"edit-title"],[16,2,[30,0,["title"]]],[24,0,"form-control"],[24,"placeholder","Name of the place"],[16,"autofocus",[30,0,["shouldAutofocus"]]],[24,4,"text"],[4,[32,0],["input",[30,0,["updateTitle"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","edit-desc"],[12],[1,"Description"],[13],[1,"\\n "],[11,"textarea"],[24,1,"edit-desc"],[16,2,[30,0,["description"]]],[24,0,"form-control"],[24,"rows","3"],[24,"placeholder","Add some details..."],[4,[32,0],["input",[30,0,["updateDescription"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"edit-actions"],[12],[1,"\\n "],[10,"button"],[14,0,"btn btn-blue"],[14,4,"submit"],[12],[1,"Save"],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"Cancel"],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onCancel"],[]]',moduleName:"(unknown template module)",scope:()=>({on:Vw}),isStrictMode:!0}),this)}},sV=A$((t,[e])=>{const n=n=>{t&&!t.contains(n.target)&&e(n)},r=setTimeout(()=>{document.addEventListener("click",n)},0);return()=>{clearTimeout(r),document.removeEventListener("click",n)}}),oV=class extends s${static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"_forceClear",[qr],function(){return!1})}#Wt=void lN(this,"_forceClear");get isSaved(){return this.args.isSaved}get placeListIds(){return this._forceClear?[]:this.args.place._listIds||[]}styleFor(t){return Bv(`background-color: ${t}`)}isInList(t){return!!this.placeListIds&&this.placeListIds.includes(t.id)}static{aN(this.prototype,"isInList",[$l])}async toggleSaved(){if(this.isSaved){const{osmId:t,osmType:e}=this.args.place;if(await this.storage.removePlace(this.args.place),this.args.place&&(this.args.place.id=null,this.args.place.createdAt=null,this.args.place._listIds=[],this._forceClear=!0),t&&e){const t={...this.args.place};delete t.id,delete t.createdAt,delete t._listIds,this.router.transitionTo("place",t)}else this.router.transitionTo("index");this.args.onClose&&this.args.onClose()}else await this.storage.storePlace(this.args.place)}static{aN(this.prototype,"toggleSaved",[$l])}async toggleList(t){const e=!this.placeListIds.includes(t.id);e&&!this.isSaved&&await this.storage.storePlace(this.args.place);try{await this.storage.togglePlaceList(this.args.place,t.id,e)}catch(n){console.error(n),alert("Failed to update list: "+n.message)}}static{aN(this.prototype,"toggleList",[$l])}static{Mp(ng({id:null,block:'[[[11,0],[24,0,"place-lists-manager"],[4,[32,0],[[30,1]],null],[12],[1,"\\n "],[10,0],[14,0,"list-item master-toggle"],[12],[1,"\\n "],[10,"label"],[12],[1,"\\n "],[11,"input"],[16,"checked",[30,0,["isSaved"]]],[24,4,"checkbox"],[4,[32,1],["change",[30,0,["toggleSaved"]]],null],[12],[13],[1,"\\n "],[10,1],[14,0,"list-color-dot"],[12],[13],[1,"\\n "],[10,1],[14,0,"list-name"],[12],[1,"Saved places"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"divider"],[12],[13],[1,"\\n\\n "],[10,0],[14,0,"lists-container"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["storage","lists"]]],null]],null],null,[[[1," "],[10,0],[14,0,"list-item"],[12],[1,"\\n "],[10,"label"],[12],[1,"\\n "],[11,"input"],[16,"checked",[28,[30,0,["isInList"]],[[30,2]],null]],[16,"disabled",[52,[51,[30,0,["isSaved"]]],true]],[24,4,"checkbox"],[4,[32,1],["change",[28,[32,2],[[30,0,["toggleList"]],[30,2]],null]],null],[12],[13],[1,"\\n"],[1," "],[10,1],[14,0,"list-color-dot"],[15,5,[28,[30,0,["styleFor"]],[[30,2,["color"]]],null]],[12],[13],[1,"\\n "],[10,1],[14,0,"list-name"],[12],[1,[30,2,["title"]]],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n"],[13]],["@onClose","list"],["each","-track-array","unless"]]',moduleName:"(unknown template module)",scope:()=>({onClickOutside:sV,on:Vw,fn:C$}),isStrictMode:!0}),this)}},aV=class extends s${renderBlurhash=A$((t,[e,n,r])=>{if(!e||!t)return;const i=n||32,s=r||18;t.width=i,t.height=s;const o=t.getContext("2d");if(o)try{const t=((t,e,n)=>{(t=>{if(!t||t.length<6)throw new CB("The blurhash string must be at least 6 characters");let e=vB(t[0]),n=Math.floor(e/9)+1,r=e%9+1;if(t.length!==4+2*r*n)throw new CB(`blurhash length mismatch: length is ${t.length} but it should be ${4+2*r*n}`)})(t);let r=vB(t[0]),i=Math.floor(r/9)+1,s=r%9+1,o=(vB(t[1])+1)/166,a=new Array(s*i);for(let u=0;u({context:this,generator:function*(t){this.error="",this.statusText="Processing";try{const e=yield this.imageProcessor.process(t,1920,.9,!0);this.blurhash=e.blurhash;const n=yield this.imageProcessor.process(t,350,.9,!1);let r,i;const s=Zz(),o=t=>{"signing"===t&&(this.statusText="Signing photo upload"),"uploading"===t&&(this.statusText="Uploading photo")},a=t=>{"signing"===t&&(this.statusText="Signing thumbnail upload"),"uploading"===t&&(this.statusText="Uploading thumbnail")};if(s)r=yield this.blossom.upload(e.blob,{sequential:!0,onProgress:o}),i=yield this.blossom.upload(n.blob,{sequential:!0,onProgress:a});else{const t=this.blossom.upload(e.blob,{onProgress:o}),s=this.blossom.upload(n.blob,{onProgress:a});[r,i]=yield Promise.all([t,s])}this.args.onSuccess&&this.args.onSuccess({file:t,url:r.url,fallbackUrls:r.fallbackUrls,thumbUrl:i.url,blurhash:e.blurhash,type:"image/jpeg",dim:e.dim,hash:r.hash,thumbHash:i.hash})}catch(e){this.error=e.message}}}),null,"uploadTask",null);static{Mp(ng({id:null,block:'[[[10,0],[15,0,[29,["photo-upload-item\\n ",[52,[30,0,["uploadTask","isRunning"]],"is-uploading"],"\\n ",[52,[30,0,["error"]],"has-error"]]]],[12],[1,"\\n"],[41,[30,0,["blurhash"]],[[[1," "],[8,[32,0],[[24,0,"place-header-photo-blur"]],[["@hash"],[[30,0,["blurhash"]]]],null],[1,"\\n"]],[]],null],[1," "],[10,"img"],[15,"src",[30,0,["thumbnailUrl"]]],[14,"alt","thumbnail"],[12],[13],[1,"\\n\\n"],[41,[30,0,["uploadTask","isRunning"]],[[[1," "],[10,0],[14,0,"overlay"],[12],[1,"\\n "],[8,[32,1],[[24,0,"spin-animation"]],[["@name","@size","@color"],["loading-ring",24,"white"]],null],[1,"\\n"],[41,[30,0,["statusText"]],[[[1," "],[10,1],[14,0,"upload-status-text"],[12],[1,[30,0,["statusText"]]],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["error"]],[[[1," "],[11,"button"],[24,0,"overlay error-overlay"],[16,"title",[30,0,["error"]]],[24,4,"button"],[4,[32,2],["click",[30,0,["showErrorToast"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["alert-circle",24,"white"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[11,"button"],[24,0,"btn-remove-photo"],[24,"title","Remove photo"],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,1],[30,2]],null]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",16,"white"]],null],[1,"\\n "],[13],[1,"\\n"],[13]],["@onRemove","@file"],["if"]]',moduleName:"(unknown template module)",scope:()=>({Blurhash:aV,Icon:o$,on:Vw,fn:C$}),isStrictMode:!0}),this)}},cV=kb(function([t]){return hU(t)}),uV=kb(function([t,e]){return!!Array.isArray(t)&&t.includes(e)}),hV=class extends s${static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"nostrRelay",[hp])}#it=void lN(this,"nostrRelay");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"blossom",[hp])}#Ht=void lN(this,"blossom");static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");static{oN(this.prototype,"file",[qr],function(){return null})}#Jt=void lN(this,"file");static{oN(this.prototype,"uploadedPhoto",[qr],function(){return null})}#Qt=void lN(this,"uploadedPhoto");static{oN(this.prototype,"error",[qr],function(){return""})}#Yt=void lN(this,"error");static{oN(this.prototype,"isPublishing",[qr],function(){return!1})}#te=void lN(this,"isPublishing");static{oN(this.prototype,"isDragging",[qr],function(){return!1})}#ee=void lN(this,"isDragging");static{oN(this.prototype,"selectedTags",[qr],function(){return[]})}#ne=void lN(this,"selectedTags");static{oN(this.prototype,"altText",[qr],function(){return""})}#re=void lN(this,"altText");get place(){return this.args.place||{}}get title(){return this.place.title||"this place"}get allUploaded(){return this.file&&this.uploadedPhoto&&this.file===this.uploadedPhoto.file}get suggestedTags(){return oB(this.place)}handleFileSelect(t){this.addFile(t.target.files[0]),t.target.value=""}static{aN(this.prototype,"handleFileSelect",[$l])}handleDragOver(t){t.preventDefault(),this.isDragging=!0}static{aN(this.prototype,"handleDragOver",[$l])}handleDragLeave(t){t.preventDefault(),this.isDragging=!1}static{aN(this.prototype,"handleDragLeave",[$l])}handleDrop(t){t.preventDefault(),this.isDragging=!1,t.dataTransfer.files.length>0&&this.addFile(t.dataTransfer.files[0])}static{aN(this.prototype,"handleDrop",[$l])}addFile(t){t&&t.type.startsWith("image/")?(this.error="",this.uploadedPhoto&&this.deletePhotoTask.perform(this.uploadedPhoto),this.file=t,this.uploadedPhoto=null,this.args.onUploadStateChange&&this.args.onUploadStateChange(!0)):this.error="Please select a valid image file."}handleUploadSuccess(t){this.uploadedPhoto=t}static{aN(this.prototype,"handleUploadSuccess",[$l])}removeFile(){this.uploadedPhoto&&this.deletePhotoTask.perform(this.uploadedPhoto),this.file=null,this.uploadedPhoto=null,this.selectedTags=[],this.altText="",this.args.onUploadStateChange&&this.args.onUploadStateChange(!1)}static{aN(this.prototype,"removeFile",[$l])}toggleTag(t){this.selectedTags.includes(t)?this.selectedTags=[]:this.selectedTags=[t]}static{aN(this.prototype,"toggleTag",[$l])}updateAltText(t){this.altText=t.target.value}static{aN(this.prototype,"updateAltText",[$l])}deletePhotoTask=Kq(()=>({context:this,generator:function*(t){try{t.hash&&(yield this.blossom.delete(t.hash)),t.thumbHash&&(yield this.blossom.delete(t.thumbHash))}catch(e){this.toast.show(`Failed to delete photo from server: ${e.message}`,5e3)}}}),null,"deletePhotoTask",null);async publish(){if(!this.nostrAuth.isConnected)return void(this.error="You must connect Nostr first.");if(!this.allUploaded)return void(this.error="Please wait for all photos to finish uploading.");const{osmId:t,lat:e,lon:n}=this.place,r=this.place.osmType||"node";if(t){this.error="",this.isPublishing=!0;try{const i=[["i",`osm:${r}:${t}`]];for(const t of this.selectedTags)i.push(["t",t]);e&&n&&(i.push(["g",gj.encode(e,n,4)]),i.push(["g",gj.encode(e,n,6)]),i.push(["g",gj.encode(e,n,7)]),i.push(["g",gj.encode(e,n,9)]));const s=this.uploadedPhoto,o=["imeta",`url ${s.url}`];o.push(`m ${s.type}`),s.dim&&o.push(`dim ${s.dim}`);const a=this.altText.trim();if(a&&o.push(`alt ${a}`),s.fallbackUrls&&s.fallbackUrls.length>0)for(const t of s.fallbackUrls)o.push(`fallback ${t}`);s.thumbUrl&&o.push(`thumb ${s.thumbUrl}`),s.blurhash&&o.push(`blurhash ${s.blurhash}`),i.push(o);const l=await vF.fromKind(360).content("").modifyPublicTags(()=>i).as(this.nostrAuth.signer).sign();await this.nostrRelay.publish(this.nostrData.activeWriteRelays,l),this.nostrData.store.add(l),this.toast.show("Photo published successfully"),this.file=null,this.uploadedPhoto=null,this.altText="",this.args.onUploadStateChange&&this.args.onUploadStateChange(!1),this.args.onClose&&this.args.onClose(l.id)}catch(i){this.error="Failed to publish: "+i.message}finally{this.isPublishing=!1}}else this.error="This place does not have a valid OSM ID."}static{aN(this.prototype,"publish",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"place-photo-upload"],[12],[1,"\\n "],[10,"h2"],[12],[1,"Add Photo for "],[1,[30,0,["title"]]],[13],[1,"\\n\\n"],[41,[30,0,["error"]],[[[1," "],[10,0],[14,0,"alert alert-error"],[12],[1,"\\n "],[1,[30,0,["error"]]],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["file"]],[[[1," "],[8,[32,0],null,[["@file","@onSuccess","@onRemove"],[[30,0,["file"]],[30,0,["handleUploadSuccess"]],[30,0,["removeFile"]]]],null],[1,"\\n\\n"],[41,[30,0,["suggestedTags","length"]],[[[1," "],[10,0],[14,0,"photo-tag-suggestions"],[12],[1,"\\n "],[10,2],[14,0,"photo-tag-suggestions-title"],[12],[1,"\\n Choose a tag/category (optional):\\n "],[13],[1,"\\n "],[10,0],[14,0,"photo-tag-suggestions-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["suggestedTags"]]],null]],null],null,[[[1," "],[11,"button"],[16,0,[29,["photo-tag-chip\\n ",[52,[28,[32,1],[[30,0,["selectedTags"]],[30,1]],null],"is-selected"]]]],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["toggleTag"]],[30,1]],null]],null],[12],[1,"\\n "],[1,[28,[32,4],[[30,1]],null]],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","photo-alt-input"],[12],[1,"Description (optional):"],[13],[1,"\\n "],[11,"input"],[24,1,"photo-alt-input"],[24,0,"form-control"],[24,"placeholder","Describe this photo"],[16,2,[30,0,["altText"]]],[16,"disabled",[30,0,["isPublishing"]]],[24,4,"text"],[4,[32,2],["input",[30,0,["updateAltText"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n\\n "],[11,"button"],[24,0,"btn btn-primary btn-publish"],[16,"disabled",[28,[32,5],[[28,[32,6],[[30,0,["allUploaded"]]],null],[30,0,["isPublishing"]]],null]],[24,4,"button"],[4,[32,2],["click",[30,0,["publish"]]],null],[12],[1,"\\n"],[41,[30,0,["isPublishing"]],[[[1," Publishing...\\n"]],[]],[[[1," Publish Photo\\n"]],[]]],[1," "],[13],[1,"\\n"]],[]],[[[1," "],[11,0],[16,0,[29,["dropzone ",[52,[30,0,["isDragging"]],"is-dragging"]]]],[4,[32,2],["dragover",[30,0,["handleDragOver"]]],null],[4,[32,2],["dragleave",[30,0,["handleDragLeave"]]],null],[4,[32,2],["drop",[30,0,["handleDrop"]]],null],[12],[1,"\\n "],[10,"label"],[14,"for","photo-upload-input"],[14,0,"dropzone-label"],[12],[1,"\\n "],[8,[32,7],null,[["@name","@size","@color"],["upload-cloud",48,"#ccc"]],null],[1,"\\n "],[10,2],[12],[1,"Drag and drop a photo here, or click to browse"],[13],[1,"\\n "],[13],[1,"\\n "],[11,"input"],[24,1,"photo-upload-input"],[24,"accept","image/*"],[24,0,"file-input-hidden"],[16,"disabled",[30,0,["isPublishing"]]],[24,4,"file"],[4,[32,2],["change",[30,0,["handleFileSelect"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n"]],[]]],[13]],["tag"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({PlacePhotoUploadItem:lV,includes:uV,on:Vw,fn:C$,capitalize:cV,or:E$,not:P$,Icon:o$}),isStrictMode:!0}),this)}},dV=o((t,e)=>{e.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}}),pV=o(t=>{var e,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];t.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return 4*t+17},t.getSymbolTotalCodewords=function(t){return n[t]},t.getBCHDigit=function(t){let e=0;for(;0!==t;)e++,t>>>=1;return e},t.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');e=t},t.isKanjiModeEnabled=function(){return void 0!==e},t.toSJIS=function(t){return e(t)}}),fV=o(t=>{t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},t.from=function(e,n){if(t.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(r){return n}}}),gV=o((t,e)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(t){const e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(let n=0;n>>e-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},e.exports=n}),mV=o((t,e)=>{function n(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}n.prototype.set=function(t,e,n,r){const i=t*this.size+e;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(t,e){return this.data[t*this.size+e]},n.prototype.xor=function(t,e,n){this.data[t*this.size+e]^=n},n.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]},e.exports=n}),yV=o(t=>{var e=pV().getSymbolSize;t.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,r=e(t),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),s=[r-7];for(let e=1;e{var e=pV().getSymbolSize;t.getPositions=function(t){const n=e(t);return[[0,0],[n-7,0],[0,n-7]]}}),bV=o(t=>{function e(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}}t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},t.isValid=function(t){return null!=t&&""!==t&&!isNaN(t)&&t>=0&&t<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(t){const e=t.size;let n=0,r=0,i=0,s=null,o=null;for(let a=0;a=5&&(n+=r-5+3),s=e,r=1),e=t.get(l,a),e===o?i++:(i>=5&&(n+=i-5+3),o=e,i=1)}r>=5&&(n+=r-5+3),i>=5&&(n+=i-5+3)}return n},t.getPenaltyN2=function(t){const e=t.size;let n=0;for(let r=0;r=10&&(1488===r||93===r)&&n++,i=i<<1&2047|t.get(o,s),o>=10&&(1488===i||93===i)&&n++}return 40*n},t.getPenaltyN4=function(t){let e=0;const n=t.data.length;for(let r=0;r{var e=fV(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];t.getBlocksCount=function(t,r){switch(r){case e.L:return n[4*(t-1)+0];case e.M:return n[4*(t-1)+1];case e.Q:return n[4*(t-1)+2];case e.H:return n[4*(t-1)+3];default:return}},t.getTotalCodewordsCount=function(t,n){switch(n){case e.L:return r[4*(t-1)+0];case e.M:return r[4*(t-1)+1];case e.Q:return r[4*(t-1)+2];case e.H:return r[4*(t-1)+3];default:return}}}),_V=o(t=>{var e=new Uint8Array(512),n=new Uint8Array(256);!function(){let t=1;for(let r=0;r<255;r++)e[r]=t,n[t]=r,t<<=1,256&t&&(t^=285);for(let n=255;n<512;n++)e[n]=e[n-255]}(),t.log=function(t){if(t<1)throw new Error("log("+t+")");return n[t]},t.exp=function(t){return e[t]},t.mul=function(t,r){return 0===t||0===r?0:e[n[t]+n[r]]}}),xV=o(t=>{var e=_V();t.mul=function(t,n){const r=new Uint8Array(t.length+n.length-1);for(let i=0;i=0;){const t=r[0];for(let s=0;s{var n=xV();function r(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(t){this.degree=t,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const e=new Uint8Array(t.length+this.degree);e.set(t);const r=n.mod(e,this.genPoly),i=this.degree-r.length;if(i>0){const t=new Uint8Array(this.degree);return t.set(r,i),t}return r},e.exports=r}),kV=o(t=>{t.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}}),SV=o(t=>{var e="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",n="(?:(?![A-Z0-9 $%*+\\-./:]|"+(e=e.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";t.KANJI=new RegExp(e,"g"),t.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),t.BYTE=new RegExp(n,"g"),t.NUMERIC=new RegExp("[0-9]+","g"),t.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var r=new RegExp("^"+e+"$"),i=new RegExp("^[0-9]+$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");t.testKanji=function(t){return r.test(t)},t.testNumeric=function(t){return i.test(t)},t.testAlphanumeric=function(t){return s.test(t)}}),EV=o(t=>{var e=kV(),n=SV();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(t,n){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!e.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?t.ccBits[0]:n<27?t.ccBits[1]:t.ccBits[2]},t.getBestModeForData=function(e){return n.testNumeric(e)?t.NUMERIC:n.testAlphanumeric(e)?t.ALPHANUMERIC:n.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},t.isValid=function(t){return t&&t.bit&&t.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+e)}}(e)}catch(r){return n}}}),RV=o(t=>{var e=pV(),n=wV(),r=fV(),i=EV(),s=kV(),o=e.getBCHDigit(7973);function a(t,e){return i.getCharCountIndicator(t,e)+4}function l(t,e){let n=0;return t.forEach(function(t){const r=a(t.mode,e);n+=r+t.getBitsLength()}),n}t.from=function(t,e){return s.isValid(t)?parseInt(t,10):e},t.getCapacity=function(t,r,o){if(!s.isValid(t))throw new Error("Invalid QR Code version");void 0===o&&(o=i.BYTE);const l=8*(e.getSymbolTotalCodewords(t)-n.getTotalCodewordsCount(t,r));if(o===i.MIXED)return l;const c=l-a(o,t);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},t.getBestVersionForData=function(e,n){let s;const o=r.from(n,r.M);if(Array.isArray(e)){if(e.length>1)return function(e,n){for(let r=1;r<=40;r++)if(l(e,r)<=t.getCapacity(r,n,i.MIXED))return r}(e,o);if(0===e.length)return 1;s=e[0]}else s=e;return function(e,n,r){for(let i=1;i<=40;i++)if(n<=t.getCapacity(i,r,e))return i}(s.mode,s.getLength(),o)},t.getEncodedBits=function(t){if(!s.isValid(t)||t<7)throw new Error("Invalid QR Code version");let n=t<<12;for(;e.getBCHDigit(n)-o>=0;)n^=7973<{var e=pV(),n=e.getBCHDigit(1335);t.getEncodedBits=function(t,r){const i=t.bit<<3|r;let s=i<<10;for(;e.getBCHDigit(s)-n>=0;)s^=1335<{var n=EV();function r(t){this.mode=n.NUMERIC,this.data=t.toString()}r.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){let e,n,r;for(e=0;e+3<=this.data.length;e+=3)n=this.data.substr(e,3),r=parseInt(n,10),t.put(r,10);const i=this.data.length-e;i>0&&(n=this.data.substr(e),r=parseInt(n,10),t.put(r,3*i+1))},e.exports=r}),PV=o((t,e)=>{var n=EV(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(t){this.mode=n.ALPHANUMERIC,this.data=t}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=45*r.indexOf(this.data[e]);n+=r.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(r.indexOf(this.data[e]),6)},e.exports=i}),IV=o((t,e)=>{var n=EV();function r(t){this.mode=n.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}r.getBitsLength=function(t){return 8*t},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(t){for(let e=0,n=this.data.length;e{var n=EV(),r=pV();function i(t){this.mode=n.KANJI,this.data=t}i.getBitsLength=function(t){return 13*t},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let e;for(e=0;e=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[e]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13)}},e.exports=i}),AV=o((t,e)=>{var n={single_source_shortest_paths:function(t,e,r){var i={},s={};s[e]=0;var o,a,l,c,u,h,d,p=n.PriorityQueue.make();for(p.push(e,0);!p.empty();)for(l in a=(o=p.pop()).value,c=o.cost,u=t[a]||{})u.hasOwnProperty(l)&&(h=c+u[l],d=s[l],(void 0===s[l]||d>h)&&(s[l]=h,p.push(l,h),i[l]=a));if(void 0!==r&&void 0===s[r]){var f=["Could not find a path from ",e," to ",r,"."].join("");throw new Error(f)}return i},extract_shortest_path_from_predecessor_list:function(t,e){for(var n=[],r=e;r;)n.push(r),t[r],r=t[r];return n.reverse(),n},find_path:function(t,e,r){var i=n.single_source_shortest_paths(t,e,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(t){var e,r=n.PriorityQueue,i={};for(e in t=t||{},r)r.hasOwnProperty(e)&&(i[e]=r[e]);return i.queue=[],i.sorter=t.sorter||r.default_sorter,i},default_sorter:function(t,e){return t.cost-e.cost},push:function(t,e){var n={value:t,cost:e};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==e&&(e.exports=n)}),OV=o(t=>{var e=EV(),n=LV(),r=PV(),i=IV(),s=MV(),o=SV(),a=pV(),l=AV();function c(t){return unescape(encodeURIComponent(t)).length}function u(t,e,n){const r=[];let i;for(;null!==(i=t.exec(n));)r.push({data:i[0],index:i.index,mode:e,length:i[0].length});return r}function h(t){const n=u(o.NUMERIC,e.NUMERIC,t),r=u(o.ALPHANUMERIC,e.ALPHANUMERIC,t);let i,s;return a.isKanjiModeEnabled()?(i=u(o.BYTE,e.BYTE,t),s=u(o.KANJI,e.KANJI,t)):(i=u(o.BYTE_KANJI,e.BYTE,t),s=[]),n.concat(r,i,s).sort(function(t,e){return t.index-e.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function d(t,o){switch(o){case e.NUMERIC:return n.getBitsLength(t);case e.ALPHANUMERIC:return r.getBitsLength(t);case e.KANJI:return s.getBitsLength(t);case e.BYTE:return i.getBitsLength(t)}}function p(t,o){let l;const c=e.getBestModeForData(t);if(l=e.from(o,c),l!==e.BYTE&&l.bit=0?t[t.length-1]:null;return n&&n.mode===e.mode?(t[t.length-1].data+=e.data,t):(t.push(e),t)},[]))},t.rawSplit=function(e){return t.fromArray(h(e,a.isKanjiModeEnabled()))}}),FV=o(t=>{var e=pV(),n=fV(),r=gV(),i=mV(),s=yV(),o=vV(),a=bV(),l=wV(),c=CV(),u=RV(),h=TV(),d=EV(),p=OV();function f(t,e,n){const r=t.size,i=h.getEncodedBits(e,n);let s,o;for(s=0;s<15;s++)o=1==(i>>s&1),s<6?t.set(s,8,o,!0):s<8?t.set(s+1,8,o,!0):t.set(r-15+s,8,o,!0),s<8?t.set(8,r-s-1,o,!0):s<9?t.set(8,15-s-1+1,o,!0):t.set(8,15-s-1,o,!0);t.set(r-8,8,1,!0)}t.create=function(t,h){if(void 0===t||""===t)throw new Error("No input text");let g,m,y=n.M;return void 0!==h&&(y=n.from(h.errorCorrectionLevel,n.M),g=u.from(h.version),m=a.from(h.maskPattern),h.toSJISFunc&&e.setToSJISFunction(h.toSJISFunc)),function(t,n,h,g){let m;if(Array.isArray(t))m=p.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");{let e=n;if(!e){const n=p.rawSplit(t);e=u.getBestVersionForData(n,h)}m=p.fromString(t,e||40)}}const y=u.getBestVersionForData(m,h);if(!y)throw new Error("The amount of data is too big to be stored in a QR Code");if(n){if(n=0&&r<=6&&(0===i||6===i)||i>=0&&i<=6&&(0===r||6===r)||r>=2&&r<=4&&i>=2&&i<=4?t.set(e+r,s+i,!0,!0):t.set(e+r,s+i,!1,!0))}}(w,n),function(t){const e=t.size;for(let n=8;n=7&&function(t,e){const n=t.size,r=u.getEncodedBits(e);let i,s,o;for(let a=0;a<18;a++)i=Math.floor(a/3),s=a%3+n-8-3,o=1==(r>>a&1),t.set(i,s,o,!0),t.set(s,i,o,!0)}(w,n),function(t,e){const n=t.size;let r=-1,i=n-1,s=7,o=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!t.isReserved(i,a-n)){let r=!1;o>>s&1)),t.set(i,a-n,r),s--,-1===s&&(o++,s=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(w,v),isNaN(g)&&(g=a.getBestMask(w,f.bind(null,w,h))),a.applyMask(g,w),f(w,h,g),{modules:w,version:n,errorCorrectionLevel:h,maskPattern:g,segments:m}}(t,g,y,m)}}),NV=o(t=>{function e(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");let e=t.slice().replace("#","").split("");if(e.length<3||5===e.length||e.length>8)throw new Error("Invalid hex color: "+t);3!==e.length&&4!==e.length||(e=Array.prototype.concat.apply([],e.map(function(t){return[t,t]}))),6===e.length&&e.push("F","F");const n=parseInt(e.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+e.slice(0,6).join("")}}t.getOptions=function(t){t||(t={}),t.color||(t.color={});const n=void 0===t.margin||null===t.margin||t.margin<0?4:t.margin,r=t.width&&t.width>=21?t.width:void 0,i=t.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:e(t.color.dark||"#000000ff"),light:e(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}},t.getScale=function(t,e){return e.width&&e.width>=t+2*e.margin?e.width/(t+2*e.margin):e.scale},t.getImageWidth=function(e,n){const r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){const i=n.modules.size,s=n.modules.data,o=t.getScale(i,r),a=Math.floor((i+2*r.margin)*o),l=r.margin*o,c=[r.color.light,r.color.dark];for(let t=0;t=l&&n>=l&&t{var e=NV();t.render=function(t,n,r){let i=r,s=n;void 0!==i||n&&n.getContext||(i=n,n=void 0),n||(s=function(){try{return document.createElement("canvas")}catch(t){throw new Error("You need to specify a canvas element")}}()),i=e.getOptions(i);const o=e.getImageWidth(t.modules.size,i),a=s.getContext("2d"),l=a.createImageData(o,o);return e.qrToImageData(l.data,t,i),function(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+"px",e.style.width=n+"px"}(a,s,o),a.putImageData(l,0,0),s},t.renderToDataURL=function(e,n,r){let i=r;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});const s=t.render(e,n,i),o=i.type||"image/png",a=i.rendererOpts||{};return s.toDataURL(o,a.quality)}}),DV=o(t=>{var e=NV();function n(t,e){const n=t.a/255,r=e+'="'+t.hex+'"';return n<1?r+" "+e+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function r(t,e,n){let r=t+e;return void 0!==n&&(r+=" "+n),r}t.render=function(t,i,s){const o=e.getOptions(i),a=t.modules.size,l=t.modules.data,c=a+2*o.margin,u=o.color.light.a?"':"",h="0&&c>0&&t[l-1]||(i+=o?r("M",c+n,.5+u+n):r("m",s,0),s=0,o=!1),c+1',d='viewBox="0 0 '+c+" "+c+'"',p=''+u+h+"\n";return"function"==typeof s&&s(null,p),p}}),jV=o(t=>{var e=dV(),n=FV(),r=zV(),i=DV();function s(t,r,i,s,o){const a=[].slice.call(arguments,1),l=a.length,c="function"==typeof a[l-1];if(!c&&!e())throw new Error("Callback required as last argument");if(!c){if(l<1)throw new Error("Too few arguments provided");return 1===l?(i=r,r=s=void 0):2!==l||r.getContext||(s=i,i=r,r=void 0),new Promise(function(e,o){try{e(t(n.create(i,s),r,s))}catch(a){o(a)}})}if(l<2)throw new Error("Too few arguments provided");2===l?(o=i,i=r,r=s=void 0):3===l&&(r.getContext&&void 0===o?(o=s,s=void 0):(o=s,s=i,i=r,r=void 0));try{const e=n.create(i,s);o(null,t(e,r,s))}catch(u){o(u)}}t.create=n.create,t.toCanvas=s.bind(null,r.render),t.toDataURL=s.bind(null,r.renderToDataURL),t.toString=s.bind(null,function(t,e,n){return i.render(t,n)})}),UV=l(jV(),1),BV=A$((t,[e])=>{e&&UV.toCanvas(t,e,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).catch(t=>{console.error("Failed to generate QR code",t)})}),$V=class extends s${static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");get hasExtension(){return"undefined"!=typeof window&&void 0!==window.nostr}async connectExtension(){try{await this.nostrAuth.connectWithExtension(),this.toast.show("Nostr connected successfully"),this.args.onConnect&&this.args.onConnect()}catch(t){console.error(t),alert(t.message)}}static{aN(this.prototype,"connectExtension",[$l])}async connectApp(){try{await this.nostrAuth.connectWithApp(),this.toast.show("Nostr connected successfully"),this.args.onConnect&&this.args.onConnect()}catch(t){console.error(t),alert(t.message)}}static{aN(this.prototype,"connectApp",[$l])}async copyConnectUri(){const t=this.nostrAuth.connectUri;try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.opacity="0",document.body.appendChild(e),e.focus(),e.select();const n=document.execCommand("copy");if(document.body.removeChild(e),!n)throw new Error("Fallback copy failed")}this.toast.show("Connection link copied to clipboard")}catch(mz){console.error("Failed to copy text: ",mz),alert("Failed to copy link")}}static{aN(this.prototype,"copyConnectUri",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"nostr-connect-modal"],[12],[1,"\\n "],[10,"h2"],[12],[1,"Connect with Nostr"],[13],[1,"\\n\\n "],[10,0],[14,0,"nostr-connect-options"],[12],[1,"\\n"],[41,[30,0,["hasExtension"]],[[[1," "],[11,"button"],[24,0,"btn btn-primary"],[24,4,"button"],[4,[32,0],["click",[30,0,["connectExtension"]]],null],[12],[1,"\\n Browser Extension (nos2x, Alby)\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,"button"],[14,0,"btn btn-outline"],[14,"disabled",""],[14,"title","No Nostr extension found in your browser"],[14,4,"button"],[12],[1,"\\n Browser Extension (Not Found)\\n "],[13],[1,"\\n"]],[]]],[1,"\\n "],[11,"button"],[24,0,"btn btn-primary"],[24,4,"button"],[4,[32,0],["click",[30,0,["connectApp"]]],null],[12],[1,"\\n Mobile Signer App (Amber, etc.)\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n"],[41,[28,[32,1],[[30,0,["nostrAuth","connectStatus"]],"waiting"],null],[[[1," "],[10,0],[14,0,"nostr-connect-status"],[12],[1,"\\n"],[41,[30,0,["nostrAuth","isMobile"]],[[[1," "],[10,2],[12],[1,"Waiting for you to approve the connection in your mobile signer\\n app..."],[13],[1,"\\n "],[10,0],[14,0,"mobile-connect-actions"],[12],[1,"\\n "],[10,3],[15,6,[30,0,["nostrAuth","connectUri"]]],[14,0,"btn btn-primary"],[12],[1,"\\n Open Signer App\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline"],[24,4,"button"],[4,[32,0],["click",[30,0,["copyConnectUri"]]],null],[12],[1,"\\n Copy Connection Link\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," "],[10,2],[12],[1,"Scan this QR code with a Nostr signer app (like Amber):"],[13],[1,"\\n "],[10,0],[14,0,"qr-code-container"],[12],[1,"\\n "],[11,"canvas"],[4,[32,2],[[30,0,["nostrAuth","connectUri"]]],null],[12],[13],[1,"\\n "],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n"]],[]],null],[13]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,eq:L$,qrCode:BV}),isStrictMode:!0}),this)}},qV=Mp(ng({id:null,block:'[[[11,0],[24,0,"modal-overlay"],[24,"role","dialog"],[24,"tabindex","-1"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[11,0],[24,0,"modal-content"],[24,"role","document"],[24,"tabindex","0"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[11,"button"],[16,0,[29,["close-modal-btn btn-text ",[52,[30,3],"disabled"]]]],[16,"disabled",[30,3]],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",24,"currentColor"]],null],[1,"\\n "],[13],[1,"\\n "],[18,4,null],[1,"\\n "],[13],[1,"\\n"],[13]],["@close","@stopProp","@disableClose","&default"],["if","yield"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,Icon:o$}),isStrictMode:!0}),F$()),VV=class extends s${get isTesting(){return"test"===nx.environment}get destinationElement(){return document.getElementById("modal-portal")||document.body}stopProp(t){t.stopPropagation()}static{aN(this.prototype,"stopProp",[$l])}close(){this.args.disableClose||this.args.onClose&&this.args.onClose()}static{aN(this.prototype,"close",[$l])}static{Mp(ng({id:null,block:'[[[41,[30,0,["isTesting"]],[[[1," "],[8,[32,0],null,[["@close","@stopProp","@disableClose"],[[30,0,["close"]],[30,0,["stopProp"]],[30,1]]],[["default"],[[[[1,"\\n "],[18,2,null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],[[[40,[[[1," "],[8,[32,0],null,[["@close","@stopProp","@disableClose"],[[30,0,["close"]],[30,0,["stopProp"]],[30,1]]],[["default"],[[[[1,"\\n "],[18,2,null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],"%cursor:0%",[28,[31,3],[[30,0,["destinationElement"]]],null]]],[]]]],["@disableClose","&default"],["if","yield","in-element","-in-el-null"]]',moduleName:"(unknown template module)",scope:()=>({ModalContent:qV}),isStrictMode:!0}),this)}},WV=A$((t,[e])=>{if(!e)return;let n;t.classList.remove("loaded"),t.classList.remove("loaded-instant");const r=()=>{const e=t.parentElement,n=e&&"PICTURE"===e.tagName?e.parentElement:e;if(n&&n.closest(".photo-carousel.gallery-main")){const t=n.querySelector(".place-header-photo-blur");t&&(t.style.opacity="0")}},i=()=>{t.classList.contains("loaded-instant")||t.classList.add("loaded"),r()};return t.addEventListener("load",i),n=new IntersectionObserver((n,i)=>{n.forEach(n=>{if(n.isIntersecting){i.unobserve(t);const n=new Image;n.src=e,n.complete&&(t.classList.add("loaded-instant"),r());const s=t.parentElement;s&&"PICTURE"===s.tagName&&s.querySelectorAll("source").forEach(t=>{t.dataset.srcset&&(t.srcset=t.dataset.srcset)}),t.dataset.src?t.src=t.dataset.src:t.src=e}})},{root:null,rootMargin:"100px 100%",threshold:0}),n.observe(t),()=>{t.removeEventListener("load",i),n&&n.disconnect()}}),HV=class extends s${static{oN(this.prototype,"canScrollLeft",[qr],function(){return!1})}#ie=void lN(this,"canScrollLeft");static{oN(this.prototype,"canScrollRight",[qr],function(){return!1})}#se=void lN(this,"canScrollRight");internalEventId=null;carouselElement=null;get photos(){return this.args.photos||[]}get showChevrons(){return this.photos.length>1}get cannotScrollLeft(){return!this.canScrollLeft}get cannotScrollRight(){return!this.canScrollRight}get isGalleryMain(){return"gallery-main"===this.args.variant}get isGalleryThumbnails(){return"gallery-thumbnails"===this.args.variant}get variantClass(){return this.args.variant||"inline"}lastResetKey=null;resetScrollPosition=A$((t,[e])=>{void 0!==e&&e!==this.lastResetKey&&(this.lastResetKey=e,t.scrollLeft=0,setTimeout(()=>this.updateScrollState(),50))});isProgrammaticScroll=!1;scrollToNewPhoto=A$((t,[e])=>{if(e&&e!==this.lastEventId){const n=!this.lastEventId;if(this.lastEventId=e,this.internalEventId===e)return;this.internalEventId=e,this.isProgrammaticScroll=!0;const r=()=>{const r=t.querySelector(`[data-event-id="${e}"]`);if(r)if(n){const e=t.style.scrollBehavior;t.style.scrollBehavior="auto",t.scrollLeft=r.offsetLeft,setTimeout(()=>{t.style.scrollBehavior=e,this.isProgrammaticScroll=!1},50)}else t.scrollLeft=r.offsetLeft,setTimeout(()=>{this.isProgrammaticScroll=!1},500);else this.isProgrammaticScroll=!1};n?r():setTimeout(r,100)}});setupCarousel=A$(t=>{let e,n;return this.carouselElement=t,setTimeout(()=>{this.updateScrollState()},50),window.ResizeObserver&&(e=new ResizeObserver(()=>this.updateScrollState()),e.observe(t)),this.args.onVisiblePhotoChange&&window.IntersectionObserver&&"test"!==nx.environment&&(n=new IntersectionObserver(t=>{if(!this.isProgrammaticScroll)for(let e of t)if(e.isIntersecting&&e.intersectionRatio>=.5){const t=e.target.dataset.eventId;this.internalEventId=t;const n=this.photos.find(e=>e.eventId===t);n&&this.args.onVisiblePhotoChange(n)}},{root:t,threshold:.5}),t.querySelectorAll(".carousel-slide").forEach(t=>n.observe(t))),()=>{e&&e.unobserve(t),n&&n.disconnect()}});updateScrollState(){if(!this.carouselElement)return;const{scrollLeft:t,scrollWidth:e,clientWidth:n}=this.carouselElement;this.canScrollLeft=t>1,this.canScrollRight=t+n({on:Vw,and:rV,eq:L$,fn:C$,Blurhash:aV,fadeInImage:WV,Icon:o$}),isStrictMode:!0}),this)}},GV=class extends s${static{oN(this.prototype,"isOpen",[qr],function(){return!1})}#oe=void lN(this,"isOpen");toggleMenu(t){t?.stopPropagation(),this.isOpen=!this.isOpen}static{aN(this.prototype,"toggleMenu",[$l])}closeMenu(t){t?.stopPropagation(),this.isOpen=!1}static{aN(this.prototype,"closeMenu",[$l])}get triggerIcon(){return this.args.triggerIcon||"more-vertical"}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"dropdown-menu-container"],[12],[1,"\\n "],[11,"button"],[24,0,"dropdown-trigger-btn btn-press"],[16,"title",[30,1]],[24,4,"button"],[4,[32,0],["click",[30,0,["toggleMenu"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],[[30,0,["triggerIcon"]],[30,2],[30,3]]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["isOpen"]],[[[1," "],[10,0],[15,0,[29,["dropdown-popover ",[30,4]]]],[12],[1,"\\n "],[18,5,[[30,0,["closeMenu"]]]],[1,"\\n "],[13],[1,"\\n "],[11,0],[24,0,"menu-backdrop"],[24,"role","button"],[4,[32,0],["click",[30,0,["closeMenu"]]],null],[12],[13],[1,"\\n"]],[]],null],[13]],["@triggerTitle","@iconSize","@iconColor","@popoverClass","&default"],["if","yield"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,Icon:o$}),isStrictMode:!0}),this)}},KV=Mp(ng({id:null,block:'[[[11,0],[24,0,"photo-gallery-overlay"],[24,"role","dialog"],[24,"tabindex","-1"],[4,[32,0],["click",[30,1]],null],[4,[30,2],[[30,3]],null],[12],[1,"\\n"],[1," "],[10,0],[14,0,"photo-gallery-content"],[15,"data-current-event-id",[30,4,["eventId"]]],[12],[1,"\\n "],[10,0],[14,0,"actions-btn-container"],[12],[1,"\\n "],[8,[32,1],null,[["@iconSize","@triggerIcon","@iconColor"],[24,"more-horizontal","white"]],[["default"],[[[[1,"\\n "],[11,"button"],[24,0,"dropdown-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,2],[[30,6],[30,5]],null]],null],[12],[1,"Copy Photo Event ID"],[13],[1,"\\n"],[41,[30,7],[[[1," "],[11,"button"],[24,0,"dropdown-item text-danger"],[24,4,"button"],[4,[32,0],["click",[28,[32,2],[[30,8,["perform"]],[30,5]],null]],null],[12],[1,"Delete Photo"],[13],[1,"\\n"]],[]],null],[1," "]],[5]]]]],[1,"\\n "],[13],[1,"\\n\\n "],[11,"button"],[24,0,"close-btn btn-text"],[24,"aria-label","Close gallery"],[24,"title","Close"],[24,4,"button"],[4,[32,0],["click",[30,9]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["x",24,"white"]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"main-photo-container"],[12],[1,"\\n "],[8,[32,4],null,[["@variant","@photos","@scrollToEventId","@onVisiblePhotoChange","@name"],["gallery-main",[30,10],[30,4,["eventId"]],[30,11],[30,12]]],null],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"thumbnail-strip-container"],[12],[1,"\\n "],[8,[32,4],null,[["@variant","@photos","@scrollToEventId","@onPhotoClick","@name"],["gallery-thumbnails",[30,10],[30,4,["eventId"]],[30,13],[30,12]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@handleBackgroundClick","@bindKeyboard","@handleKeydown","@currentPhoto","closeMenu","@copyEventId","@canDeletePhoto","@deletePhotoTask","@handleClose","@photos","@handleVisiblePhotoChange","@placeName","@selectPhoto"],["if"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,DropdownMenu:GV,fn:C$,Icon:o$,PhotoCarousel:HV}),isStrictMode:!0}),F$()),ZV=class extends s${get isTesting(){return"test"===nx.environment}get destinationElement(){return document.getElementById("modal-portal")||document.body}static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"nostrRelay",[hp])}#it=void lN(this,"nostrRelay");static{oN(this.prototype,"blossom",[hp])}#Ht=void lN(this,"blossom");static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");static{oN(this.prototype,"currentPhoto",[qr],function(){return this.args.selectedPhoto||this.args.photos?.[0]})}#ae=void lN(this,"currentPhoto");get isCreator(){return this.currentPhoto?.pubkey&&this.nostrAuth.pubkey&&this.currentPhoto.pubkey===this.nostrAuth.pubkey}get canDeletePhoto(){return this.isCreator&&!0===this.settings.experimentalEnablePhotoDeletion}bindKeyboard=A$((t,[e])=>(document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)));handleClose(){this.args.onClose&&this.args.onClose()}static{aN(this.prototype,"handleClose",[$l])}handleBackgroundClick(t){t.target.closest(".thumbnail-strip-container")||t.target.closest(".carousel-nav-btn")||t.target.closest(".close-btn")||t.target.closest(".actions-btn-container")||this.handleClose()}static{aN(this.prototype,"handleBackgroundClick",[$l])}selectPhoto(t){this.currentPhoto=t}static{aN(this.prototype,"selectPhoto",[$l])}handleVisiblePhotoChange(t){this.currentPhoto!==t&&(this.currentPhoto=t)}static{aN(this.prototype,"handleVisiblePhotoChange",[$l])}handleKeydown(t){if(!this.args.photos||0===this.args.photos.length)return;if("Escape"===t.key)return void this.handleClose();const e=this.args.photos.indexOf(this.currentPhoto);-1!==e&&("ArrowLeft"===t.key&&e>0?this.currentPhoto=this.args.photos[e-1]:"ArrowRight"===t.key&&e({context:this,generator:function*(t){if(confirm("Are you sure you want to delete this photo? This cannot be undone."))try{const n=[["e",this.currentPhoto.eventId]];this.currentPhoto.placeIdentifier&&n.push(["i",this.currentPhoto.placeIdentifier]);const r=yield vF.fromKind(5).content("Deleted photo").modifyPublicTags(()=>n).as(this.nostrAuth.signer).sign();yield this.nostrRelay.publish(this.nostrData.activeWriteRelays,r),this.nostrData.store.add(r);const i=/[0-9a-f]{64}/i;if(this.currentPhoto.url){const t=this.currentPhoto.url.match(i);if(t)try{yield this.blossom.delete(t[0])}catch(e){console.warn("Failed to delete main image from blossom:",e)}}if(this.currentPhoto.thumbUrl){const t=this.currentPhoto.thumbUrl.match(i);if(t)try{yield this.blossom.delete(t[0])}catch(e){console.warn("Failed to delete thumb image from blossom:",e)}}this.toast.show("Photo deleted successfully"),t&&t(),this.handleClose()}catch(e){console.error("Failed to delete photo:",e),this.toast.show("Failed to delete photo: "+e.message),t&&t()}else t&&t()}}),null,"deletePhotoTask",null);static{Mp(ng({id:null,block:'[[[41,[30,0,["isTesting"]],[[[1," "],[8,[32,0],null,[["@handleBackgroundClick","@bindKeyboard","@handleKeydown","@copyEventId","@canDeletePhoto","@deletePhotoTask","@handleClose","@photos","@currentPhoto","@handleVisiblePhotoChange","@placeName","@selectPhoto"],[[30,0,["handleBackgroundClick"]],[30,0,["bindKeyboard"]],[30,0,["handleKeydown"]],[30,0,["copyEventId"]],[30,0,["canDeletePhoto"]],[30,0,["deletePhotoTask"]],[30,0,["handleClose"]],[30,1],[30,0,["currentPhoto"]],[30,0,["handleVisiblePhotoChange"]],[30,2],[30,0,["selectPhoto"]]]],null],[1,"\\n"]],[]],[[[40,[[[1," "],[8,[32,0],null,[["@handleBackgroundClick","@bindKeyboard","@handleKeydown","@copyEventId","@canDeletePhoto","@deletePhotoTask","@handleClose","@photos","@currentPhoto","@handleVisiblePhotoChange","@placeName","@selectPhoto"],[[30,0,["handleBackgroundClick"]],[30,0,["bindKeyboard"]],[30,0,["handleKeydown"]],[30,0,["copyEventId"]],[30,0,["canDeletePhoto"]],[30,0,["deletePhotoTask"]],[30,0,["handleClose"]],[30,1],[30,0,["currentPhoto"]],[30,0,["handleVisiblePhotoChange"]],[30,2],[30,0,["selectPhoto"]]]],null],[1,"\\n"]],[]],"%cursor:0%",[28,[31,2],[[30,0,["destinationElement"]]],null]]],[]]]],["@photos","@placeName"],["if","in-element","-in-el-null"]]',moduleName:"(unknown template module)",scope:()=>({GalleryContent:KV}),isStrictMode:!0}),this)}},YV=class extends s${static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"isEditing",[qr],function(){return!1})}#le=void lN(this,"isEditing");static{oN(this.prototype,"showLists",[qr],function(){return!1})}#ce=void lN(this,"showLists");static{oN(this.prototype,"isPhotoUploadActive",[qr],function(){return!1})}#ue=void lN(this,"isPhotoUploadActive");static{oN(this.prototype,"isConnectingNostr",[qr],function(){return!1})}#he=void lN(this,"isConnectingNostr");static{oN(this.prototype,"isGalleryOpen",[qr],function(){return!1})}#de=void lN(this,"isGalleryOpen");static{oN(this.prototype,"selectedGalleryPhoto",[qr],function(){return null})}#pe=void lN(this,"selectedGalleryPhoto");static{oN(this.prototype,"isPhotoUploadModalOpen",[qr],function(){return!1})}#fe=void lN(this,"isPhotoUploadModalOpen");static{oN(this.prototype,"isNostrConnectModalOpen",[qr],function(){return!1})}#ge=void lN(this,"isNostrConnectModalOpen");static{oN(this.prototype,"newlyUploadedPhotoId",[qr],function(){return null})}#me=void lN(this,"newlyUploadedPhotoId");handleUploadStateChange(t){this.isPhotoUploadActive=t}static{aN(this.prototype,"handleUploadStateChange",[$l])}openPhotoUploadModal(t){t&&t.preventDefault(),this.nostrAuth.isConnected?this.isPhotoUploadModalOpen=!0:this.isNostrConnectModalOpen=!0}static{aN(this.prototype,"openPhotoUploadModal",[$l])}closePhotoUploadModal(t){this.isPhotoUploadActive||(this.isPhotoUploadModalOpen=!1,"string"==typeof t&&(this.newlyUploadedPhotoId=t,setTimeout(()=>{const t=document.querySelector(".sidebar-content");t&&(t.scrollTop=0)},50)))}static{aN(this.prototype,"closePhotoUploadModal",[$l])}closeNostrConnectModal(){this.isNostrConnectModalOpen=!1}static{aN(this.prototype,"closeNostrConnectModal",[$l])}onNostrConnected(){this.isNostrConnectModalOpen=!1,this.isPhotoUploadModalOpen=!0}static{aN(this.prototype,"onNostrConnected",[$l])}get isSaved(){return this.storage.isPlaceSaved(this.place.id||this.place.osmId)}get place(){return this.args.place||{}}get saveablePlace(){return this.place.createdAt?this.place:lB(this.place)}get tags(){return this.place.osmTags||{}}get name(){return this.place.title||fU(this.tags)||"Unnamed Place"}get photos(){return pj(this.nostrData.placePhotos).map(t=>({...t,style:Bv(`--slide-ratio: ${t.aspectRatio};`)}))}startEditing(){this.isSaved&&(this.isEditing=!0)}static{aN(this.prototype,"startEditing",[$l])}cancelEditing(){this.isEditing=!1}static{aN(this.prototype,"cancelEditing",[$l])}toggleLists(t){t&&t.stopPropagation(),this.showLists=!this.showLists}static{aN(this.prototype,"toggleLists",[$l])}closeLists(){this.showLists=!1}static{aN(this.prototype,"closeLists",[$l])}async saveChanges(t){this.args.onSave&&await this.args.onSave({...this.place,...t}),this.isEditing=!1}static{aN(this.prototype,"saveChanges",[$l])}get type(){return mU(this.tags)}get address(){const t=this.tags,e=[],n=(...e)=>{for(const n of e)if(t[n])return t[n];return null};let r=n("addr:street","street");const i=n("addr:housenumber","housenumber");r&&(i&&(r=`${r} ${i}`),e.push(r));let s=n("addr:city","city");const o=n("addr:postcode","postcode");s&&(o&&(s=`${o} ${s}`),e.push(s));const a=n("addr:state","state"),l=n("addr:country","country");return a&&a!==s&&e.push(a),l&&e.push(l),0===e.length?null:e.join(", ")}formatMultiLine(t,e){if(!t)return null;const n=[...new Set(t.split(";").map(t=>t.trim()).filter(Boolean))];return 0===n.length?null:Bv("phone"===e?n.map(t=>`${t}`).join("
"):"email"===e?n.map(t=>`${t}`).join("
"):"whatsapp"===e?n.map(t=>`${t}`).join("
"):"url"===e?n.map(t=>`${this.getDomain(t)}`).join("
"):n.join("
"))}get phone(){const t=[this.tags.phone,this.tags["contact:phone"],this.tags.mobile,this.tags["contact:mobile"]].filter(Boolean);return 0===t.length?null:this.formatMultiLine(t.join(";"),"phone")}get whatsapp(){const t=[this.tags.whatsapp,this.tags["contact:whatsapp"]].filter(Boolean);return 0===t.length?null:this.formatMultiLine(t.join(";"),"whatsapp")}get email(){const t=this.tags.email||this.tags["contact:email"];return this.formatMultiLine(t,"email")}get website(){const t=this.place.url||this.tags.website||this.tags["contact:website"];return this.formatMultiLine(t,"url")}getDomain(t){try{return new URL(t).hostname}catch{return t}}get openingHours(){const t=this.tags.opening_hours;return this.formatMultiLine(t)}get cuisine(){return this.tags.cuisine?this.tags.cuisine.split(";").map(t=>uU(t)).join(", "):null}get facebook(){return hB(this.tags,"facebook")}get instagram(){return hB(this.tags,"instagram")}get wikipedia(){const t=this.tags.wikipedia;return t?t.split(";").map(t=>t.trim()).filter(Boolean)[0]:null}get geoLink(){const t=this.place.lat,e=this.place.lon;return t&&e?`geo:${t},${e}?q=${t},${e}(${encodeURIComponent(this.name)})`:"#"}get visibleGeoLink(){const t=this.place.lat,e=this.place.lon;return t&&e?`${Number(t).toFixed(6)}, ${Number(e).toFixed(6)}`:""}get osmUrl(){const t=this.place.osmId;if(t)return`https://www.openstreetmap.org/${this.place.osmType||"node"}/${t}`;const e=this.place.lat,n=this.place.lon;if(!e||!n)return null;const r=this.mapUi.currentCenter?.lat??e,i=this.mapUi.currentCenter?.lon??n,s=this.mapUi.currentZoom??17,o=Math.round(s);return`https://www.openstreetmap.org/search?lat=${e}&lon=${n}&zoom=${o}#map=${o}/${Number(r).toFixed(5)}/${Number(i).toFixed(5)}`}get gmapsUrl(){return this.place.gmapsId||this.place.osmId?`https://www.google.com/maps/search/?api=1&query=${this.name}&query=${this.place.lat},${this.place.lon}`:null}get showDescription(){return"photon"!==this.place.source&&!!this.place.description}openGallery(t){this.selectedGalleryPhoto=t,this.isGalleryOpen=!0}static{aN(this.prototype,"openGallery",[$l])}closeGallery(){this.isGalleryOpen=!1,this.selectedGalleryPhoto=null}static{aN(this.prototype,"closeGallery",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"place-details"],[12],[1,"\\n"],[41,[30,0,["isEditing"]],[[[1," "],[8,[32,0],null,[["@place","@onSave","@onCancel"],[[30,0,["place"]],[30,0,["saveChanges"]],[30,0,["cancelEditing"]]]],null],[1,"\\n"]],[]],[[[1," "],[8,[32,1],null,[["@variant","@photos","@name","@resetKey","@scrollToEventId","@onPhotoClick"],["inline",[30,0,["photos"]],[30,0,["name"]],[30,0,["place","osmId"]],[30,0,["newlyUploadedPhotoId"]],[30,0,["openGallery"]]]],null],[1,"\\n "],[10,"h3"],[12],[1,[30,0,["name"]]],[13],[1,"\\n "],[10,2],[14,0,"place-type"],[12],[1,"\\n "],[1,[30,0,["type"]]],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["showDescription"]],[[[1," "],[10,2],[14,0,"place-description"],[12],[1,"\\n "],[1,[30,0,["place","description"]]],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[]]],[1,"\\n "],[10,0],[14,0,"actions"],[12],[1,"\\n "],[10,0],[14,0,"save-button-wrapper"],[12],[1,"\\n "],[11,"button"],[16,0,[52,[30,0,["isSaved"]],"btn btn-secondary","btn btn-outline"]],[24,4,"button"],[4,[32,2],["click",[30,0,["toggleLists"]]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@color"],["bookmark",[52,[30,0,["isSaved"]],"currentColor","var(--link-color)"]]],null],[1,"\\n "],[1,[52,[30,0,["isSaved"]],"Saved","Save"]],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["showLists"]],[[[1," "],[8,[32,4],null,[["@place","@onClose","@isSaved"],[[30,0,["saveablePlace"]],[30,0,["closeLists"]],[30,0,["isSaved"]]]],null],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["isSaved"]],[[[1," "],[11,"button"],[24,0,"btn btn-outline"],[24,"title","Edit"],[16,"disabled",[30,0,["isEditing"]]],[24,4,"button"],[4,[32,2],["click",[30,0,["startEditing"]]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@color"],["edit","var(--link-color)"]],null],[1,"\\n Edit\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"meta-info"],[12],[1,"\\n\\n"],[41,[30,0,["cuisine"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["fork-and-knife","Cuisine"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["cuisine"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["openingHours"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["clock","Opening hours"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["openingHours"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["phone"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["phone","Phone"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["phone"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["whatsapp"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["whatsapp","WhatsApp"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["whatsapp"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["website"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["globe","Website"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["website"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["email"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["mail","Email"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[1,[30,0,["email"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["facebook"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["facebook","Facebook"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["facebook","url"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n "],[1,[30,0,["facebook","username"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["instagram"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["instagram","Instagram"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["instagram","url"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n "],[1,[30,0,["instagram","username"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["wikipedia"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["wikipedia","Wikipedia"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[29,["https://wikipedia.org/wiki/",[30,0,["wikipedia"]]]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n Wikipedia\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"meta-info"],[12],[1,"\\n\\n"],[41,[30,0,["address"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["home","Address"]],null],[1,"\\n "],[10,1],[12],[1,[30,0,["address"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@title"],["map-pin","Geo link"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["geoLink"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n "],[1,[30,0,["visibleGeoLink"]]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["osmUrl"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name"],["map"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["osmUrl"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n OpenStreetMap\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["gmapsUrl"]],[[[1," "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name"],["map"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[10,3],[15,6,[30,0,["gmapsUrl"]]],[14,"target","_blank"],[14,"rel","noopener noreferrer"],[12],[1,"\\n Google Maps\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["place","osmId"]],[[[1," "],[10,0],[14,0,"meta-info"],[12],[1,"\\n "],[10,2],[14,0,"content-with-icon"],[12],[1,"\\n "],[8,[32,3],null,[["@name"],["feather-camera"]],null],[1,"\\n "],[10,1],[12],[1,"\\n "],[11,"button"],[24,0,"btn-link"],[24,4,"button"],[4,[32,2],["click",[30,0,["openPhotoUploadModal"]]],null],[12],[1,"\\n Add a photo\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[13],[1,"\\n\\n"],[41,[30,0,["isPhotoUploadModalOpen"]],[[[1," "],[8,[32,5],null,[["@onClose","@disableClose"],[[30,0,["closePhotoUploadModal"]],[30,0,["isPhotoUploadActive"]]]],[["default"],[[[[1,"\\n "],[8,[32,6],null,[["@place","@onClose","@onUploadStateChange"],[[30,0,["saveablePlace"]],[30,0,["closePhotoUploadModal"]],[30,0,["handleUploadStateChange"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["isNostrConnectModalOpen"]],[[[1," "],[8,[32,5],null,[["@onClose"],[[30,0,["closeNostrConnectModal"]]]],[["default"],[[[[1,"\\n "],[8,[32,7],null,[["@onConnect"],[[30,0,["onNostrConnected"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null],[1,"\\n"],[41,[30,0,["isGalleryOpen"]],[[[1," "],[8,[32,8],null,[["@photos","@selectedPhoto","@placeName","@onClose"],[[30,0,["photos"]],[30,0,["selectedGalleryPhoto"]],[30,0,["name"]],[30,0,["closeGallery"]]]],null],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlaceEditForm:iV,PhotoCarousel:HV,on:Vw,Icon:o$,PlaceListsManager:oV,Modal:VV,PlacePhotoUpload:hV,NostrConnect:$V,PhotoGallery:ZV}),isStrictMode:!0}),this)}},XV=kb(function([t]){return uU(t)}),JV=class extends s${static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");createNewPlace(){const t=this.router.currentRoute.queryParams,e=t.lat,n=t.lon;e&&n?this.router.transitionTo("place.new",{queryParams:{lat:e,lon:n}}):this.router.transitionTo("place.new",{queryParams:{lat:0,lon:0}})}static{aN(this.prototype,"createNewPlace",[$l])}selectPlace(t){this.args.onSelect&&this.args.onSelect(t)}static{aN(this.prototype,"selectPlace",[$l])}clearSelection(){this.args.onSelect&&this.args.onSelect(null)}static{aN(this.prototype,"clearSelection",[$l])}async toggleSave(t){if(t)if(t.createdAt)try{if(await this.storage.removePlace(t),console.debug("Place deleted:",t.title),this.args.onBookmarkChange&&this.args.onBookmarkChange(),this.args.onUpdate){const e={...t,id:void 0,geohash:void 0,createdAt:void 0};this.args.onUpdate(e)}this.args.onSelect&&this.args.onSelect(null),this.args.onClose&&this.args.onClose()}catch(e){console.error("Failed to delete:",e),alert("Failed to delete: "+e.message)}else{const e={title:fU(t.osmTags,"Untitled Place"),lat:t.lat,lon:t.lon,tags:[],url:t.osmTags.website,osmId:String(t.osmId||t.id),osmType:t.osmType,osmTags:t.osmTags};try{const t=await this.storage.storePlace(e);console.debug("Place saved:",e.title),this.args.onBookmarkChange&&this.args.onBookmarkChange(),this.args.onUpdate&&this.args.onUpdate(t),this.args.onSelect&&this.args.onSelect(t)}catch(Z4){console.error("Failed to save place:",Z4),alert("Failed to save place: "+Z4.message)}}}static{aN(this.prototype,"toggleSave",[$l])}async updateBookmark(t){try{const e=await this.storage.updatePlace(t);console.debug("Place updated:",e.title),this.args.onBookmarkChange&&this.args.onBookmarkChange(),this.args.onUpdate&&this.args.onUpdate(e)}catch(e){console.error("Failed to update place:",e),alert("Failed to update place: "+e.message)}}static{aN(this.prototype,"updateBookmark",[$l])}get isNearbySearch(){const t=this.router.currentRoute.queryParams;return!t.q&&!t.category&&t.lat&&t.lon}get hasHeaderPhoto(){return this.args.selectedPlace&&this.nostrData.placePhotos&&this.nostrData.placePhotos.length>0}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[15,0,[29,["sidebar-header\\n ",[52,[30,0,["hasHeaderPhoto"]],"no-border"],"\\n ",[52,[28,[32,0],[[28,[32,1],[[30,1]],null],[30,2]],null],"has-back-btn"]]]],[12],[1,"\\n"],[41,[30,1],[[[1," "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,2],["click",[30,0,["clearSelection"]]],null],[12],[8,[32,3],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[13],[1,"\\n"]],[]],[[[41,[30,2],[[[1," "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,2],["click",[30,2]],null],[12],[8,[32,3],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[13],[1,"\\n"]],[]],null],[41,[30,2],[[[1," "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"\\n "],[10,1],[14,0,"sidebar-header-icon-wrapper"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["bookmark",20,[28,[32,4],[[30,3],"#898989"],null]]],null],[1,"\\n "],[13],[1,"\\n "],[1,[30,4]],[1,"\\n "],[13],[1,"\\n"]],[]],[[[41,[30,0,["isNearbySearch"]],[[[1," "],[10,"h2"],[12],[8,[32,3],null,[["@name","@size","@color"],["target",20,"#ea4335"]],null],[1,"\\n Nearby"],[13],[1,"\\n"]],[]],[[[1," "],[10,"h2"],[12],[8,[32,3],null,[["@name","@size","@color"],["search",20,"#333"]],null],[1,"\\n Results"],[13],[1,"\\n"]],[]]]],[]]]],[]]],[1," "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,2],["click",[30,5]],null],[12],[8,[32,3],null,[["@name","@size","@color"],["x",20,"#333"]],null],[13],[1,"\\n "],[13],[1,"\\n\\n "],[11,0],[24,0,"sidebar-content"],[4,[32,5],[[30,6]],null],[12],[1,"\\n"],[41,[30,1],[[[1," "],[8,[32,6],null,[["@place","@onToggleSave","@onSave"],[[30,1],[30,0,["toggleSave"]],[30,0,["updateBookmark"]]]],null],[1,"\\n"]],[]],[[[41,[30,7],[[[1," "],[10,0],[14,0,"sidebar-loading"],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["loading-ring",24,"#898989"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],[[[41,[30,8],[[[1," "],[10,"ul"],[14,0,"places-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,8]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"place-item"],[24,4,"button"],[4,[32,2],["click",[28,[32,7],[[30,0,["selectPlace"]],[30,9]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"place-name"],[12],[1,[28,[32,4],[[30,9,["title"]],[30,9,["osmTags","name"]],[30,9,["osmTags","name:en"]],"Unnamed Place"],null]],[13],[1,"\\n "],[10,0],[14,0,"place-type"],[12],[1,"\\n"],[41,[28,[32,8],[[30,9,["source"]],"osm"],null],[[[1," "],[1,[28,[32,9],[[30,9,["type"]]],null]],[1,"\\n"]],[]],[[[41,[28,[32,8],[[30,9,["source"]],"photon"],null],[[[1," "],[1,[30,9,["description"]]],[1,"\\n"]],[]],[[[41,[28,[32,10],[[30,9,["osmTags"]]],null],[[[1," "],[1,[28,[32,10],[[30,9,["osmTags"]]],null]],[1,"\\n"]],[]],[[[1," Saved place\\n "]],[]]]],[]]]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[9]],null],[1," "],[13],[1,"\\n"]],[]],[[[41,[30,0,["isNearbySearch"]],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"No places found nearby."],[13],[1,"\\n"]],[]],[[[1," "],[10,2],[14,0,"empty-state"],[12],[1,"No results found."],[13],[1,"\\n"]],[]]]],[]]],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline create-place"],[24,4,"button"],[4,[32,2],["click",[30,0,["createNewPlace"]]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["plus",18,"var(--link-color)"]],null],[1,"\\n Create new place\\n "],[13],[1,"\\n"]],[]]]],[]]],[1," "],[13],[1,"\\n"],[13]],["@selectedPlace","@onBack","@color","@title","@onClose","@scrollTop","@isLoading","@places","place"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({and:rV,not:P$,on:Vw,Icon:o$,or:E$,restoreScroll:O$,PlaceDetails:YV,fn:C$,eq:L$,humanizeOsmTag:XV,getPlaceType:mU}),isStrictMode:!0}),this)}},QV=a({default:()=>tW}),tW=Mp(ng({id:null,block:'[[[41,[30,1,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@places","@title","@color","@scrollTop","@isLoading","@onSelect","@onClose","@onBack"],[[30,1,["places"]],[30,1,["listTitle"]],[30,1,["listColor"]],[30,1,["scrollTop"]],[30,1,["loadPlacesTask","isRunning"]],[30,1,["selectPlace"]],[30,1,["close"]],[30,1,["backToLists"]]]],null],[1,"\\n"]],[]],null]],["@controller"],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlacesSidebar:JV}),isStrictMode:!0}),F$()),eW=a({default:()=>oW});function nW(t){const e=t.createdAt;if(!e)return 0;if("number"==typeof e)return e;const n=Date.parse(e);return isNaN(n)?0:n}var rW,iW,sW,oW=class extends Qc{static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"model",[qr])}#ye=void lN(this,"model");static{oN(this.prototype,"loadedPlaces",[qr],function(){return[]})}#ve=void lN(this,"loadedPlaces");get listId(){return this.model?.list_id}loadPlacesTask=Kq(()=>({context:this,generator:function*(t){this.loadedPlaces=[];try{this.loadedPlaces=yield this.storage.getPlacesInList(t)}catch(e){console.error("Failed to load places in list",t,e),this.loadedPlaces=[]}}}),{restartable:!0},"loadPlacesTask",null);get scrollTop(){return this.mapUi.getScrollPosition(`list-${this.listId}`)}get listColor(){const t=this.storage.lists.find(t=>t.id===this.listId);return t&&t.color?t.color:getComputedStyle(document.documentElement).getPropertyValue("--default-list-color").trim()}get listTitle(){const t=this.storage.lists.find(t=>t.id===this.listId);return t?t.title:"Collections"}get places(){const t=this.storage.lists.find(t=>t.id===this.listId),e=new Set(t?.placeRefs?.map(t=>t.id)||[]),n=this.storage.savedPlaces.filter(t=>e.has(t.id)),r=[],i=new Set;return n.forEach(t=>{r.push(t),i.add(t.id)}),this.loadedPlaces.forEach(t=>{e.has(t.id)&&!i.has(t.id)&&(r.push(t),i.add(t.id))}),r.sort((t,e)=>nW(e)-nW(t))}selectPlace(t){if(t){const e=document.querySelector(".sidebar-content");e&&this.mapUi.saveScrollPosition(`list-${this.listId}`,e.scrollTop),this.mapUi.returnToRoute={name:"lists.list",model:this.listId},this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!0,this.router.transitionTo("place",t)}}static{aN(this.prototype,"selectPlace",[$l])}close(){this.router.transitionTo("index")}static{aN(this.prototype,"close",[$l])}backToLists(){this.router.transitionTo("lists.index")}static{aN(this.prototype,"backToLists",[$l])}},aW=a({default:()=>lW}),lW=class extends Xh{static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");model(t){return{list_id:t.list_id}}setupController(t,e){console.debug("DEBUG: setupController controller is:",t),console.debug("DEBUG: controller.loadPlacesTask is:",t?.loadPlacesTask),t.model=e,super.setupController(t,e),t&&t.loadPlacesTask?t.loadPlacesTask.perform(e.list_id):console.error("DEBUG: ERROR! controller.loadPlacesTask is undefined!")}},cW=a({default:()=>uW}),uW=class extends s${static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");styleFor(t){const e=t||getComputedStyle(document.documentElement).getPropertyValue("--default-list-color").trim();return Bv(`background-color: ${e}`)}selectList(t){this.router.transitionTo("lists.list",t)}static{aN(this.prototype,"selectList",[$l])}close(){this.router.transitionTo("index")}static{aN(this.prototype,"close",[$l])}backToMenu(){this.router.transitionTo("menu")}static{aN(this.prototype,"backToMenu",[$l])}static{Mp(ng({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,0,["backToMenu"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"\\n "],[10,1],[14,0,"sidebar-header-icon-wrapper"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["bookmark",20,"#898989"]],null],[1,"\\n "],[13],[1,"\\n Collections\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,0,["close"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"ul"],[14,0,"places-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["storage","lists"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"lists-index-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,2],[[30,0,["selectList"]],[30,1,["id"]]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"lists-index-item-left"],[12],[1,"\\n"],[1," "],[10,1],[14,0,"list-color-dot"],[15,5,[28,[30,0,["styleFor"]],[[30,1,["color"]]],null]],[12],[13],[1,"\\n "],[10,0],[14,0,"lists-index-name"],[12],[1,[30,1,["title"]]],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"lists-index-count"],[12],[1,"\\n"],[41,[30,1,["placeRefs","length"]],[[[1," "],[1,[30,1,["placeRefs","length"]]],[1,"\\n places\\n"]],[]],[[[1," empty\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null]],["list"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,Icon:o$,fn:C$}),isStrictMode:!0}),this)}},hW=a({default:()=>dW}),dW=class extends Xh{},pW=a({default:()=>fW}),fW=class extends s${static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");selectPlace(t){if(t){const e=document.querySelector(".sidebar-content");e&&this.mapUi.saveScrollPosition("search",e.scrollTop),this.mapUi.returnToSearch=!0,this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!0,this.router.transitionTo("place",t)}}static{aN(this.prototype,"selectPlace",[$l])}close(){this.mapUi.hideSidebar()}static{aN(this.prototype,"close",[$l])}static{Mp(ng({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@places","@scrollTop","@onSelect","@onClose"],[[30,0,["mapUi","searchResults"]],[28,[30,0,["mapUi","getScrollPosition"]],["search"],null],[30,0,["selectPlace"]],[30,0,["close"]]]],null],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlacesSidebar:JV}),isStrictMode:!0}),this)}},gW=a({default:()=>mW}),mW=class extends Qc{static{oN(this.prototype,"osm",[hp])}#j=void lN(this,"osm");static{oN(this.prototype,"photon",[hp])}#be=void lN(this,"photon");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");queryParams=["lat","lon","q","selected","category"];lat=null;lon=null;q=null;selected=null;category=null;fetchResultsTask=Kq(()=>({context:this,generator:function*(t){const e=this.mapUi.currentSearch&&t.q===this.mapUi.currentSearch.q&&t.category===this.mapUi.currentSearch.category&&t.lat===this.mapUi.currentSearch.lat&&t.lon===this.mapUi.currentSearch.lon,n=this.mapUi.searchResults&&this.mapUi.searchResults.length>0;if(e&&n)return void(this.mapUi.isSidebarVisible&&this.mapUi.showSidebar());this.mapUi.hideSidebar(),this.mapUi.clearSearchResults();const r=t.lat?parseFloat(t.lat):null,i=t.lon?parseFloat(t.lon):null;let s=[],o=null,a=null;try{if(t.category&&r&&i){o="category",a=t.category,this.mapUi.startLoading(o,a);let e=this.mapUi.currentBounds;if(!e){const t=.01;e={minLat:r-t,maxLat:r+t,minLon:i-t,maxLon:i+t}}s=yield this.osm.getCategoryPois(e,t.category,r,i),s=s.map(t=>({...t,_distance:WU(r,i,t.lat,t.lon)})).sort((t,e)=>t._distance-e._distance)}else if(t.q){o="text",a=t.q,this.mapUi.startLoading(o,a),s=yield this.photon.search(t.q,r,i);const e=t.q.toLowerCase();let n=[];e.length>=3&&(n=this.storage.savedPlaces.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))),n.forEach(t=>{s.find(e=>t.osmId&&e.osmId===t.osmId||e.id&&e.id===t.id)||s.push(t)})}else if(r&&i){const t=50;s=yield this.osm.getNearbyPois(r,i,t),this.storage.savedPlaces.filter(e=>WU(r,i,e.lat,e.lon)<=t).forEach(t=>{s.find(e=>t.osmId&&e.osmId===t.osmId||e.id&&e.id===t.id)||s.push(t)}),s=s.map(t=>({...t,_distance:WU(r,i,t.lat,t.lon)})).sort((t,e)=>t._distance-e._distance)}}catch(Z4){return console.error("Search request failed.",Z4),this.toast.show("Search request failed. Please try again."),void this.mapUi.stopSearch()}finally{o&&a&&this.mapUi.stopLoading(o,a)}s=s.map(t=>this.storage.findPlaceById(t.osmId)||t);const l=t.selected||t.q;if(l&&s.length>0){let t=s.find(t=>t.osmTags&&(t.osmTags.name===l||t.osmTags["name:en"]===l));if(!t){const e=s[0];e._distance<=10&&(t=e)}if(t)return this.router.replaceWith("place",t),void this.mapUi.stopSearch()}this.mapUi.setSearchResults(s),this.mapUi.showSidebar(),this.mapUi.stopSearch()}}),{restartable:!0},"fetchResultsTask",null)},yW=a({default:()=>vW}),vW=class extends Xh{static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");queryParams={lat:{refreshModel:!0},lon:{refreshModel:!0},q:{refreshModel:!0},selected:{refreshModel:!0},category:{refreshModel:!0}};model(t){return t}setupController(t,e){super.setupController(t,e),t.fetchResultsTask.perform(e);const{q:n,category:r,lat:i,lon:s}=this.paramsFor("search");this.mapUi.currentSearch={q:n,category:r,lat:i,lon:s}}resetController(t,e){e&&(t.fetchResultsTask.cancelAll(),this.mapUi.stopSearch())}error(t,e){return this.mapUi.stopSearch(),this.toast.show("Search request failed. Please try again."),e&&e.abort(),!1}static{aN(this.prototype,"error",[$l])}},bW=a({cacheFor:()=>Jn,guidFor:()=>ol}),wW=(rW=hp("page-title"),sW=PB((iW=class extends bb{constructor(t){super(t),LB(this,"tokens",sW,this),TB(this,"tokenId",ol(this)),this.tokens.push({id:this.tokenId})}compute(t,e){const n={...e,id:this.tokenId,title:t.join("")};return this.tokens.push(n),this.tokens.scheduleTitleUpdate(),""}willDestroy(){super.willDestroy(),this.tokens.remove(this.tokenId),this.tokens.scheduleTitleUpdate()}}).prototype,"tokens",[rW],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),iW),_W="add",xW="remove",CW="propertychange";function kW(t){for(const e in t)delete t[e]}function SW(t){let e;for(e in t)return!1;return!e}function EW(t,e,n,r,i){if(i){const i=n;n=function(s){return t.removeEventListener(e,n),i.call(r??this,s)}}else r&&r!==t&&(n=n.bind(r));const s={target:t,type:e,listener:n};return t.addEventListener(e,n),s}function RW(t,e,n,r){return EW(t,e,n,r,!0)}function TW(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),kW(t))}var LW="change",PW="contextmenu",IW="click",MW="keydown",AW="keypress",OW="touchmove",FW="wheel",NW=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function zW(t,e){return t>e?1:te?-1:0}function jW(t,e,n){if(t[0]<=e)return 0;const r=t.length;if(e<=t[r-1])return r-1;if("function"==typeof n){for(let i=1;i0?i-1:i}return r-1}if(n>0){for(let n=1;n0)}removeEventListener(t,e){if(!this.listeners_)return;const n=this.listeners_[t];if(!n)return;const r=n.indexOf(e);-1!==r&&(this.pendingRemovals_&&t in this.pendingRemovals_?(n[r]=WW,++this.pendingRemovals_[t]):(n.splice(r,1),0===n.length&&delete this.listeners_[t]))}},YW=class extends ZW{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(LW)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const n=t.length,r=new Array(n);for(let i=0;i0;)this.pop()}extend(t){for(let e=0,n=t.length;ethis.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new rH(_W,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let n=0,r=e.length;n=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new rH(xW,e,t)),e}setAt(t,e){if(t>=this.getLength())return void this.insertAt(t,e);if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new rH(xW,n,t)),this.dispatchEvent(new rH(_W,e,t))}updateLength_(){this.set(nH,this.array_.length)}assertUnique_(t,e){const n=this.array_;for(let r=0,i=n.length;r{this.clickTimeoutId_=void 0;const e=new oH(aH.SINGLECLICK,this.map_,t);this.dispatchEvent(e)},250)}updateActivePointers_(t){const e=t,n=e.pointerId;if(e.type==aH.POINTERUP||e.type==aH.POINTERCANCEL){delete this.trackedTouches_[n];for(const t in this.trackedTouches_)if(this.trackedTouches_[t].target!==e.target){delete this.trackedTouches_[t];break}}else e.type!=aH.POINTERDOWN&&e.type!=aH.POINTERMOVE||(this.trackedTouches_[n]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new oH(aH.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),0===this.activePointers_.length&&(this.dragListenerKeys_.forEach(TW),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return 0===t.button}handlePointerDown_(t){this.emulateClicks_=0===this.activePointers_.length,this.updateActivePointers_(t);const e=new oH(aH.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),0===this.dragListenerKeys_.length){const t=this.map_.getOwnerDocument();this.dragListenerKeys_.push(EW(t,aH.POINTERMOVE,this.handlePointerMove_,this),EW(t,aH.POINTERUP,this.handlePointerUp_,this),EW(this.element_,aH.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push(EW(this.element_.getRootNode(),aH.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new oH(aH.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!(!this.down_||!this.isMoving_(t));this.dispatchEvent(new oH(aH.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;e&&!e.defaultPrevented||"boolean"==typeof t.cancelable&&!0!==t.cancelable||t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(TW(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(OW,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(TW(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(TW),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},vH="postrender",bH="loadstart",wH="loadend",_H="layergroup",xH="size",CH="target",kH="view";function SH(t,e){if(!t)throw new Error(e)}var EH=1/0,RH=class{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,kW(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,n=t[0];1==t.length?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const r=this.keyFunction_(n);return delete this.queuedElements_[r],n}enqueue(t){SH(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=1/0&&(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0)}getCount(){return this.elements_.length}getLeftChildIndex_(t){return 2*t+1}getRightChildIndex_(t){return 2*t+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return 0===this.elements_.length}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,n=this.priorities_,r=e.length,i=e[t],s=n[t],o=t;for(;t>1;){const i=this.getLeftChildIndex_(t),s=this.getRightChildIndex_(t),o=st;){const t=this.getParentIndex_(e);if(!(r[t]>s))break;n[e]=n[t],r[e]=r[t],e=t}n[e]=i,r[e]=s}reprioritize(){const t=this.priorityFunction_,e=this.elements_,n=this.priorities_;let r=0;const i=e.length;let s,o,a;for(o=0;ot.apply(null,e),t=>t[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(LW,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,n=e.getState();if(2===n||3===n||4===n){3!==n&&e.removeEventListener(LW,this.boundHandleTileChange_);const t=e.getKey();t in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[t],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let n=0;for(;this.tilesLoading_0;){const t=this.dequeue()[0],e=t.getKey();0!==t.getState()||e in this.tilesLoadingKeys_||(this.tilesLoadingKeys_[e]=!0,++this.tilesLoading_,++n,t.load())}}},LH={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function PH(t,e,n){return Math.min(Math.max(t,e),n)}function IH(t,e,n,r,i,s){const o=i-n,a=s-r;if(0!==o||0!==a){const l=((t-n)*o+(e-r)*a)/(o*o+a*a);l>1?(n=i,r=s):l>0&&(n+=o*l,r+=a*l)}return MH(t,e,n,r)}function MH(t,e,n,r){const i=n-t,s=r-e;return i*i+s*s}function AH(t){return 180*t/Math.PI}function OH(t){return t*Math.PI/180}function FH(t,e){const n=t%e;return n*e<0?n+e:n}function NH(t,e,n){return t+n*(e-t)}function zH(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function DH(t,e){return Math.floor(zH(t,e))}function jH(t,e){return Math.ceil(zH(t,e))}function UH(t,e,n){if(t>=e&&tp&&(d=(p+d)/2,p=d),f>g&&(f=(g+f)/2,g=f);let m=PH(r[0],d,p),y=PH(r[1],f,g);if(o&&n&&i){const t=30*i;m+=-t*Math.log(1+Math.max(0,d-r[0])/t)+t*Math.log(1+Math.max(0,r[0]-p)/t),y+=-t*Math.log(1+Math.max(0,f-r[1])/t)+t*Math.log(1+Math.max(0,r[1]-g)/t)}return[m,y]}}function $H(t){return t}function qH(t){const e=[1/0,1/0,-1/0,-1/0];for(let n=0,r=t.length;ni&&(l|=4),as&&(l|=2),0===l&&(l=1),l}function XH(t,e,n,r,i){return i?(i[0]=t,i[1]=e,i[2]=n,i[3]=r,i):[t,e,n,r]}function JH(t){return XH(1/0,1/0,-1/0,-1/0,t)}function QH(t,e){const n=t[0],r=t[1];return XH(n,r,n,r,e)}function tG(t,e,n,r,i){return iG(JH(i),t,e,n,r)}function eG(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function nG(t,e){return e[0]t[2]&&(t[2]=e[2]),e[1]t[3]&&(t[3]=e[3]),t}function rG(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function iG(t,e,n,r,i){for(;ne[0]?r[0]=t[0]:r[0]=e[0],t[1]>e[1]?r[1]=t[1]:r[1]=e[1],t[2]n&&u.push([n,r,o,s]),lr&&u.push([o,r,l,a]),c=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function _G(t){return t[2]1){const e=t[2]-t[0],n=t[3]-t[1];for(let s=0;s=n[2])){const e=bG(n),i=Math.floor((r[0]-n[0])/e)*e;t[0]-=i,t[2]-=i}return t}function kG(t,e,n){if(e.canWrapX()){const r=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[r[0],t[1],r[2],t[3]]];CG(t,e);const i=bG(r);if(bG(t)>i&&!n)return[[r[0],t[1],r[2],t[3]]];if(t[0]r[2])return[[t[0],t[1],r[2],t[3]],[r[0],t[1],t[2]-i,t[3]]]}return[t]}function SG(t,e){let n=[t];for(let r=0,i=e.length;r0;++r){const t=[];for(let i=0,s=n.length;i=0;--r)if(t[r]!=e[r]){n=!1;break}return n}function RG(t,e){const n=Math.cos(e),r=Math.sin(e),i=t[0]*n-t[1]*r,s=t[1]*n+t[0]*r;return t[0]=i,t[1]=s,t}function TG(t,e){if(e.canWrapX()){const n=bG(e.getExtent()),r=function(t,e,n){const r=e.getExtent();let i=0;return e.canWrapX()&&(t[0]r[2])&&(n=n||bG(r),i=Math.floor((t[0]-r[0])/n)),i}(t,e,n);r&&(t[0]-=r*n)}return t}function LG(t){return Math.pow(t,3)}function PG(t){return 1-LG(1-t)}function IG(t){return 3*t*t-2*t*t*t}function MG(t){return t}function AG(t,e,n){n=n||6371008.8;const r=OH(t[1]),i=OH(e[1]),s=(i-r)/2,o=OH(e[0]-t[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(r)*Math.cos(i);return 2*n*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function OG(t,e,n,r){r=r||6371008.8;const i=OH(t[1]),s=OH(t[0]),o=e/r,a=Math.asin(Math.sin(i)*Math.cos(o)+Math.cos(i)*Math.sin(o)*Math.cos(n));return[AH(s+Math.atan2(Math.sin(n)*Math.sin(o)*Math.cos(i),Math.cos(o)-Math.sin(i)*Math.sin(a))),AH(a)]}function FG(...t){console.warn(...t)}var NG={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937},zG=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||NG[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}},DG=6378137,jG=Math.PI*DG,UG=[-jG,-jG,jG,jG],BG=[-180,-85,180,85],$G=DG*Math.log(Math.tan(Math.PI/2)),qG=class extends zG{constructor(t){super({code:t,units:"m",extent:UG,global:!0,worldExtent:BG,getPointResolution:function(t,e){return t/Math.cosh(e[1]/DG)}})}},VG=[new qG("EPSG:3857"),new qG("EPSG:102100"),new qG("EPSG:102113"),new qG("EPSG:900913"),new qG("http://www.opengis.net/def/crs/EPSG/0/3857"),new qG("http://www.opengis.net/gml/srs/epsg.xml#3857")],WG=[-180,-90,180,90],HG=6378137*Math.PI/180,GG=class extends zG{constructor(t,e){super({code:t,units:"degrees",extent:WG,axisOrientation:e,global:!0,metersPerUnit:HG,worldExtent:WG})}},KG=[new GG("CRS:84"),new GG("EPSG:4326","neu"),new GG("urn:ogc:def:crs:OGC:1.3:CRS84"),new GG("urn:ogc:def:crs:OGC:2:84"),new GG("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new GG("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new GG("http://www.opengis.net/def/crs/EPSG/0/4326","neu")],ZG={},YG={};function XG(t,e,n){const r=t.getCode(),i=e.getCode();r in YG||(YG[r]={}),YG[r][i]=n}function JG(t,e){return t in YG&&e in YG[t]?YG[t][e]:null}var QG=.9996,tK=.00669438,eK=tK*tK*tK,nK=tK/.99330562,rK=Math.sqrt(.99330562),iK=(1-rK)/(1+rK),sK=iK*iK,oK=sK*iK,aK=oK*iK,lK=aK*iK,cK=.9983242984503243,uK=35*eK/3072,hK=1.5*iK-27/32*oK+269/512*lK,dK=21/16*sK-55/32*aK,pK=151/96*oK-417/128*lK,fK=1097/512*aK,gK=6378137;function mK(t,e,n){const r=t-5e5,i=(n.north?e:e-1e7)/QG/(gK*cK),s=i+hK*Math.sin(2*i)+dK*Math.sin(4*i)+pK*Math.sin(6*i)+fK*Math.sin(8*i),o=Math.sin(s),a=o*o,l=Math.cos(s),c=o/l,u=c*c,h=u*u,d=1-tK*a,p=Math.sqrt(1-tK*a),f=nK*l**2,g=f*f,m=r/(gK/p*QG),y=m*m,v=y*m,b=v*m,w=b*m,_=s-c/(.99330562/d)*(y/2-b/24*(5+3*u+10*f-4*g-9*nK))+w*m/720*(61+90*u+298*f+45*h-252*nK-3*g);let x=(m-v/6*(1+2*u+f)+w/120*(5-2*f+28*u-3*g+8*nK+24*h))/l;return x=UH(x+OH(vK(n.number)),-Math.PI,Math.PI),[AH(x),AH(_)]}function yK(t,e,n){t=UH(t,-180,180),e<-80?e=-80:e>84&&(e=84);const r=OH(e),i=Math.sin(r),s=Math.cos(r),o=i/s,a=o*o,l=a*a,c=OH(t),u=OH(vK(n.number)),h=gK/Math.sqrt(1-tK*i**2),d=nK*s**2,p=s*UH(c-u,-Math.PI,Math.PI),f=p*p,g=f*p,m=g*p,y=m*p,v=y*p,b=gK*(cK*r-.002514607064228144*Math.sin(2*r)+26390466021299826e-22*Math.sin(4*r)-uK*Math.sin(6*r)),w=QG*h*(p+g/6*(1-a+d)+y/120*(5-18*a+l+72*d-58*nK))+5e5;let _=QG*(b+h*o*(f/2+m/24*(5-a+9*d+4*d**2)+v/720*(61-58*a+l+600*d-330*nK)));return n.north||(_+=1e7),[w,_]}function vK(t){return 6*(t-1)-180+3}var bK=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function wK(t){let e=0;for(const i of bK){const n=t.match(i);if(n){e=parseInt(n[1]);break}}if(!e)return null;let n=0,r=!1;return e>32700&&e<32761?n=e-32700:e>32600&&e<32661&&(r=!0,n=e-32600),n?{number:n,north:r}:null}function _K(t,e){return function(n,r,i,s){const o=n.length;i=i>1?i:2,s=s??i,r||(r=i>2?n.slice():new Array(o));for(let a=0;a180)&&(n[0]=FH(r+180,360)-180),n}function DK(t,e){if(t===e)return!0;const n=t.getUnits()===e.getUnits();return(t.getCode()===e.getCode()||jK(t,e)===LK)&&n}function jK(t,e){const n=t.getCode(),r=e.getCode();let i=JG(n,r);if(i)return i;let s=null,o=null;for(const l of SK)s||(s=l(t)),o||(o=l(e));if(!s&&!o)return null;const a="EPSG:4326";if(o)if(s)i=UK(s.inverse,o.forward);else{const t=JG(n,a);t&&(i=UK(t,o.forward))}else{const t=JG(a,r);t&&(i=UK(s.inverse,t))}return i&&(IK(t),IK(e),XG(t,e,i)),i}function UK(t,e){return function(n,r,i,s){return r=t(n,r,i,s),e(r,r,i,s)}}function BK(t,e){return jK(MK(t),MK(e))}function $K(t,e,n){const r=BK(e,n);if(!r){const t=MK(e).getCode(),r=MK(n).getCode();throw new Error(`No transform available between ${t} and ${r}`)}return r(t,void 0,t.length)}function qK(t,e,n,r){return xG(t,BK(e,n),void 0,r)}function VK(t){return t}function WK(t){return RK&&!EG(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(RK=!1,FG("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t}function HK(t){return t}OK(VG),OK(KG),xK=VG,CK=function(t,e,n,r){const i=t.length;n=n>1?n:2,r=r??n,void 0===e&&(e=n>2?t.slice():new Array(i));for(let s=0;s$G?n=$G:n<-$G&&(n=-$G),e[s+1]=n}return e},kK=function(t,e,n,r){const i=t.length;n=n>1?n:2,r=r??n,void 0===e&&(e=n>2?t.slice():new Array(i));for(let s=0;s{if(!n)return this.getSimplifiedGeometry(e);const r=this.clone();return r.applyTransform(n),r.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return XW()}closestPointXY(t,e,n,r){return XW()}containsXY(t,e){return 0===this.closestPointXY(t,e,lZ,Number.MIN_VALUE)}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return XW()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&JH(t),this.extentRevision_=this.getRevision()}return function(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t}(this.extent_,t)}rotate(t,e){XW()}scale(t,e,n){XW()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return XW()}getType(){return XW()}applyTransform(t){XW()}intersectsExtent(t){return XW()}translate(t,e){XW()}transform(t,e){const n=MK(t),r="tile-pixels"==n.getUnits()?function(t,r,i){const s=n.getExtent(),o=n.getWorldExtent(),a=fG(o)/fG(s);eZ(aZ,o[0],o[3],a,-a,0,0,0);const l=sZ(t,0,t.length,i,aZ,r),c=BK(n,e);return c?c(l,l,i):l}:BK(n,e);return this.applyTransform(r),this}},uZ=class extends cZ{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return tG(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return XW()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length1)h=n;else{if(d>0){for(let i=0;ii&&(i=a),s=n,o=r}return i}function yZ(t,e,n,r,i){for(let s=0,o=n.length;ss&&(n-a)*(s-l)-(i-a)*(r-l)>0&&o++:r<=s&&(n-a)*(s-l)-(i-a)*(r-l)<0&&o--,a=n,l=r}return 0!==o}function TZ(t,e,n,r,i,s){if(0===n.length)return!1;if(!RZ(t,e,n[0],r,i,s))return!1;for(let o=1,a=n.length;o=i[0]&&s[2]<=i[2]||s[1]>=i[1]&&s[3]<=i[3]||LZ(t,e,n,r,function(t,e){return function(t,e,n){let r=!1;const i=YH(t,e),s=YH(t,n);if(1===i||1===s)r=!0;else{const o=t[0],a=t[1],l=t[2],c=t[3],u=e[0],h=e[1],d=n[0],p=n[1],f=(p-h)/(d-u);let g,m;2&s&&!(2&i)&&(g=d-(p-c)/f,r=g>=o&&g<=l),r||!(4&s)||4&i||(m=p-(d-l)*f,r=m>=a&&m<=c),r||!(8&s)||8&i||(g=d-(p-a)/f,r=g>=o&&g<=l),r||!(16&s)||16&i||(m=p-(d-o)*f,r=m>=a&&m<=c)}return r}(i,t,e)}))}function IZ(t,e,n,r,i){return!!(PZ(t,e,n,r,i)||RZ(t,e,n,r,i[0],i[1])||RZ(t,e,n,r,i[0],i[3])||RZ(t,e,n,r,i[2],i[1])||RZ(t,e,n,r,i[2],i[3]))}function MZ(t,e,n,r,i){if(!IZ(t,e,n[0],r,i))return!1;if(1===n.length)return!0;for(let s=1,o=n.length;s0;){const n=c.pop(),s=c.pop();let o=0;const a=t[s],h=t[s+1],d=t[n],p=t[n+1];for(let e=s+r;eo&&(u=e,o=n)}o>i&&(l[(u-e)/r]=1,s+r0&&f>d)&&(p<0&&g0&&g>p)?(a=n,l=h):(s[o++]=a,s[o++]=l,c=a,u=l,a=n,l=h)}return s[o++]=a,s[o++]=l,o}function zZ(t,e,n,r,i,s,o,a){for(let l=0,c=n.length;ly&&(c=(u+h)/2,TZ(t,e,n,r,c,f)&&(m=c,y=i)),u=h}return isNaN(m)&&(m=i[s]),o?(o.push(m,f,y),o):[m,f,y]}function BZ(t,e,n,r,i){let s=[];for(let o=0,a=n.length;o0}function VZ(t,e,n,r,i){i=void 0!==i&&i;for(let s=0,o=n.length;su&&h1&&"function"==typeof arguments[n-1]&&(e=arguments[n-1],--n);let r=0;for(;r0}getInteracting(){return this.hints_[1]>0}cancelAnimations(){let t;this.setHint(0,-this.hints_[0]);for(let e=0,n=this.animations_.length;e=0;--n){const r=this.animations_[n];let i=!0;for(let n=0,s=r.length;n0?o/s.duration:1;a>=1?(s.complete=!0,a=1):i=!1;const l=s.easing(a);if(s.sourceCenter){const t=s.sourceCenter[0],e=s.sourceCenter[1],n=s.targetCenter[0],r=s.targetCenter[1];this.nextCenter_=s.targetCenter;const i=t+l*(n-t),o=e+l*(r-e);this.targetCenter_=[i,o]}if(s.sourceResolution&&s.targetResolution){const t=1===l?s.targetResolution:s.sourceResolution+l*(s.targetResolution-s.sourceResolution);if(s.anchor){const e=this.getViewportSize_(this.getRotation()),n=this.constraints_.resolution(t,0,e,!0);this.targetCenter_=this.calculateCenterZoom(n,s.anchor)}this.nextResolution_=s.targetResolution,this.targetResolution_=t,this.applyTargetState_(!0)}if(void 0!==s.sourceRotation&&void 0!==s.targetRotation){const t=1===l?FH(s.targetRotation+Math.PI,2*Math.PI)-Math.PI:s.sourceRotation+l*(s.targetRotation-s.sourceRotation);if(s.anchor){const e=this.constraints_.rotation(t,!0);this.targetCenter_=this.calculateCenterRotate(e,s.anchor)}this.nextRotation_=s.targetRotation,this.targetRotation_=t}if(this.applyTargetState_(!0),e=!0,!s.complete)break}if(i){this.animations_[n]=null,this.setHint(0,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=r[0].callback;t&&rY(t,!0)}}this.animations_=this.animations_.filter(Boolean),e&&void 0===this.updateAnimationKey_&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let n;const r=this.getCenterInternal();var i,s;return void 0!==r&&(n=[r[0]-e[0],r[1]-e[1]],RG(n,t-this.getRotation()),s=e,(i=n)[0]+=+s[0],i[1]+=+s[1]),n}calculateCenterZoom(t,e){let n;const r=this.getCenterInternal(),i=this.getResolution();return void 0!==r&&void 0!==i&&(n=[e[0]-t*(e[0]-r[0])/i,e[1]-t*(e[1]-r[1])/i]),n}getViewportSize_(t){const e=this.viewportSize_;if(t){const n=e[0],r=e[1];return[Math.abs(n*Math.cos(t))+Math.abs(r*Math.sin(t)),Math.abs(n*Math.sin(t))+Math.abs(r*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t?VK(t,this.getProjection()):t}getCenterInternal(){return this.get(LH.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return void 0!==t?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){return e=this.calculateExtentInternal(t),this.getProjection(),e;var e}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();SH(e,"The view center is not defined");const n=this.getResolution();SH(void 0!==n,"The view resolution is not defined");const r=this.getRotation();return SH(void 0!==r,"The view rotation is not defined"),dG(e,n,r,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(LH.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(HK(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=bG(t)/e[0],r=fG(t)/e[1];return Math.max(n,r)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(e/n)/Math.log(t);return function(n){return e/Math.pow(t,n*r)}}getRotation(){return this.get(LH.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),n=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,i=Math.log(n/r)/e;return function(t){return Math.log(n/t)/e/i}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const n=this.padding_;return n&&(e=[e[0]-n[1]-n[3],e[1]-n[0]-n[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),n=this.getRotation();let r=this.getCenterInternal();const i=this.padding_;if(i){const t=this.getViewportSizeMinusPadding_();r=sY(r,this.getViewportSize_(),[t[0]/2+i[3],t[1]/2+i[0]],e,n)}return{center:r.slice(0),projection:void 0!==t?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return void 0!==e&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e,n,r=this.minZoom_||0;if(this.resolutions_){const i=jW(this.resolutions_,t,1);r=i,e=this.resolutions_[i],n=i==this.resolutions_.length-1?2:e/this.resolutions_[i+1]}else e=this.maxResolution_,n=this.zoomFactor_;return r+Math.log(e/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(1===this.resolutions_.length)return this.resolutions_[0];const e=PH(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,PH(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(SH(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t))SH(!_G(t),"Cannot fit empty extent provided as `geometry`"),n=YZ(HK(t,this.getProjection()));else if("Circle"===t.getType()){const e=HK(t.getExtent(),this.getProjection());n=YZ(e),n.rotate(this.getRotation(),uG(e))}else{const e=null;n=e?t.clone().transform(e,this.getProjection()):t}this.fitInternal(n,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),n=Math.cos(e),r=Math.sin(-e),i=t.getFlatCoordinates(),s=t.getStride();let o=1/0,a=1/0,l=-1/0,c=-1/0;for(let u=0,h=i.length;ut.trim().replace(/^['"]|['"]$/g,"")),n};function gY(t,e,n,r){let i;return i=n&&n.length?n.shift():dH?new class extends OffscreenCanvas{style={}}(t??300,e??150):document.createElement("canvas"),t&&(i.width=t),e&&(i.height=e),i.getContext("2d",r)}function mY(){return oY||(oY=gY(1,1)),oY}function yY(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}function vY(t){let e=t.offsetWidth;const n=getComputedStyle(t);return e+=parseInt(n.marginLeft,10)+parseInt(n.marginRight,10),e}function bY(t){let e=t.offsetHeight;const n=getComputedStyle(t);return e+=parseInt(n.marginTop,10)+parseInt(n.marginBottom,10),e}function wY(t,e){const n=e.parentNode;n&&n.replaceChild(t,e)}function _Y(t){for(;t.lastChild;)t.lastChild.remove()}function xY(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const e=this.childNodes.indexOf(t);if(-1===e)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){const n=this.childNodes.indexOf(e);if(-1===n)throw new Error("Reference node not found");return this.childNodes.splice(n,0,t),t},style:{}},{get:(t,e,n)=>"firstElementChild"===e?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,n)})}function CY(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas}var kY=class extends eH{constructor(t){super();const e=t.element;!e||t.target||e.style.pointerEvents||(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,n=this.listenerKeys.length;ee.getAttributions(t)));if(void 0!==this.attributions_&&(Array.isArray(this.attributions_)?this.attributions_.forEach(t=>n.add(t)):n.add(this.attributions_)),!this.overrideCollapsible_){const t=!e.some(t=>!1===t.getSource()?.getAttributionsCollapsible());this.setCollapsible(t)}return Array.from(n)}async updateElement_(t){if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=await Promise.all(this.collectSourceAttributions_(t).map(t=>GW(()=>t))),n=e.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!$W(e,this.renderedAttributions_)){_Y(this.ulElement_);for(let t=0,n=e.length;t0&&e%(2*Math.PI)!=0?t.animate({rotation:0,duration:this.duration_,easing:PG}):t.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const n=e.viewState.rotation;if(n!=this.rotation_){const t="rotate("+n+"rad)";if(this.autoHide_){const t=this.element.classList.contains(aY);t||0!==n?t&&0!==n&&this.element.classList.remove(aY):this.element.classList.add(aY)}this.label_.style.transform=t}this.rotation_=n}},RY=class extends kY{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=void 0!==t.className?t.className:"ol-zoom",n=void 0!==t.delta?t.delta:1,r=void 0!==t.zoomInClassName?t.zoomInClassName:e+"-in",i=void 0!==t.zoomOutClassName?t.zoomOutClassName:e+"-out",s=void 0!==t.zoomInLabel?t.zoomInLabel:"+",o=void 0!==t.zoomOutLabel?t.zoomOutLabel:"–",a=void 0!==t.zoomInTipLabel?t.zoomInTipLabel:"Zoom in",l=void 0!==t.zoomOutTipLabel?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=a,c.appendChild("string"==typeof s?document.createTextNode(s):s),c.addEventListener(IW,this.handleClick_.bind(this,n),!1);const u=document.createElement("button");u.className=i,u.setAttribute("type","button"),u.title=l,u.appendChild("string"==typeof o?document.createTextNode(o):o),u.addEventListener(IW,this.handleClick_.bind(this,-n),!1);const h=e+" "+lY+" "+cY,d=this.element;d.className=h,d.appendChild(c),d.appendChild(u),this.duration_=void 0!==t.duration?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const e=this.getMap().getView();if(!e)return;const n=e.getZoom();if(void 0!==n){const r=e.getConstrainedZoom(n+t);this.duration_>0?(e.getAnimating()&&e.cancelAnimations(),e.animate({zoom:r,duration:this.duration_,easing:PG})):e.setZoom(r)}}};function TY(t){t=t||{};const e=new iH;return(void 0===t.zoom||t.zoom)&&e.push(new RY(t.zoomOptions)),(void 0===t.rotate||t.rotate)&&e.push(new EY(t.rotateOptions)),(void 0===t.attribution||t.attribution)&&e.push(new SY(t.attributionOptions)),e}var LY=class{constructor(t,e,n){this.decay_=t,this.minVelocity_=e,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]0&&this.points_[n+2]>t;)n-=3;const r=this.points_[e+2]-this.points_[n+2];if(r<1e3/60)return!1;const i=this.points_[e]-this.points_[n],s=this.points_[e+1]-this.points_[n+1];return this.angle_=Math.atan2(s,i),this.initialVelocity_=Math.sqrt(i*i+s*s)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}},PY="active",IY=class extends eH{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(PY)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(PY,t)}setMap(t){this.map_=t}};function MY(t,e,n,r){const i=t.getZoom();if(void 0===i)return;const s=t.getConstrainedZoom(i+e),o=t.getResolutionForZoom(s);t.getAnimating()&&t.cancelAnimations(),t.animate({resolution:o,anchor:n,duration:void 0!==r?r:250,easing:PG})}var AY=class extends IY{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:250}handleEvent(t){let e=!1;if(t.type==aH.DBLCLICK){const n=t.originalEvent,r=t.map,i=t.coordinate,s=n.shiftKey?-this.delta_:this.delta_;MY(r.getView(),s,i,this.duration_),n.preventDefault(),e=!0}return!e}};function OY(t){const e=arguments;return function(t){let n=!0;for(let r=0,i=e.length;r0}}else if(t.type==aH.POINTERDOWN){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==aH.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function WY(t){const e=t.length;let n=0,r=0;for(let i=0;i0&&this.condition_(t)){const e=t.map.getView();return this.lastCentroid=null,e.getAnimating()&&e.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}},GY=class extends VY{constructor(t){t=t||{},super({stopDown:VW}),this.condition_=t.condition?t.condition:FY,this.lastAngle_=void 0,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){if(!$Y(t))return;const e=t.map,n=e.getView();if(n.getConstraints().rotation===tY)return;const r=e.getSize(),i=t.pixel,s=Math.atan2(r[1]/2-i[1],i[0]-r[0]/2);if(void 0!==this.lastAngle_){const t=s-this.lastAngle_;n.adjustRotationInternal(-t)}this.lastAngle_=s}handleUpEvent(t){return!$Y(t)||(t.map.getView().endInteraction(this.duration_),!1)}handleDownEvent(t){return!(!$Y(t)||!DY(t)||!this.condition_(t)||(t.map.getView().beginInteraction(),this.lastAngle_=void 0,0))}},KY=class extends NW{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,n="px",r=this.element_.style;r.left=Math.min(t[0],e[0])+n,r.top=Math.min(t[1],e[1])+n,r.width=Math.abs(e[0]-t[0])+n,r.height=Math.abs(e[1]-t[1])+n}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,n=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new ZZ([n])}getGeometry(){return this.geometry_}},ZY="boxcancel",YY=class extends KW{constructor(t,e,n){super(t),this.coordinate=e,this.mapBrowserEvent=n}},XY=class extends VY{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new KY(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??DY,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,n){const r=n[0]-e[0],i=n[1]-e[1];return r*r+i*i>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new YY("boxdrag",t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new YY(e?"boxend":ZY,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return!!this.condition_(t)&&(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new YY("boxstart",t.coordinate,t)),!0)}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new YY(ZY,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new YY(ZY,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}},JY=class extends XY{constructor(t){super({condition:(t=t||{}).condition?t.condition:UY,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=void 0!==t.duration?t.duration:200,this.out_=void 0!==t.out&&t.out}onBoxEnd(t){const e=this.getMap().getView();let n=this.getGeometry();if(this.out_){const t=e.rotatedExtentForGeometry(n),r=e.getResolutionForExtentInternal(t),i=e.getResolution()/r;n=n.clone(),n.scale(i*i)}e.fitInternal(n,{duration:this.duration_,easing:PG})}},QY="ArrowLeft",tX="ArrowRight",eX="ArrowDown",nX=class extends IY{constructor(t){super(),t=t||{},this.defaultCondition_=function(t){return jY(t)&&BY(t)},this.condition_=void 0!==t.condition?t.condition:this.defaultCondition_,this.duration_=void 0!==t.duration?t.duration:100,this.pixelDelta_=void 0!==t.pixelDelta?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==MW){const n=t.originalEvent,r=n.key;if(this.condition_(t)&&(r==eX||r==QY||r==tX||"ArrowUp"==r)){const i=t.map.getView(),s=i.getResolution()*this.pixelDelta_;let o=0,a=0;r==eX?a=-s:r==QY?o=-s:r==tX?o=s:a=s;const l=[o,a];RG(l,i.getRotation()),function(t,e,n){const r=t.getCenterInternal();if(r){const i=[r[0]+e[0],r[1]+e[1]];t.animateInternal({duration:void 0!==n?n:250,easing:MG,center:t.getConstrainedCenter(i)})}}(i,l,this.duration_),n.preventDefault(),e=!0}}return!e}},rX=class extends IY{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(t){return!function(t){const e=t.originalEvent;return uH?e.metaKey:e.ctrlKey}(t)&&BY(t)},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:100}handleEvent(t){let e=!1;if(t.type==MW||t.type==AW){const n=t.originalEvent,r=n.key;if(this.condition_(t)&&("+"===r||"-"===r)){const i=t.map,s="+"===r?this.delta_:-this.delta_;MY(i.getView(),s,void 0,this.duration_),n.preventDefault(),e=!0}}return!e}},iX=class extends IY{constructor(t){super(t=t||{}),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=void 0!==t.maxDelta?t.maxDelta:1,this.duration_=void 0!==t.duration?t.duration:250,this.timeout_=void 0!==t.timeout?t.timeout:80,this.useAnchor_=void 0===t.useAnchor||t.useAnchor,this.constrainResolution_=void 0!==t.constrainResolution&&t.constrainResolution;const e=t.condition?t.condition:zY;this.condition_=t.onFocusOnly?OY(NY,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(t){if(this.ctrlKeyListenerKeys_.forEach(TW),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){const e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push(EW(e,"keydown",t=>{"Control"===t.key&&(this.ctrlKeyPressed_=!0)}),EW(e,"keyup",t=>{"Control"===t.key&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;const e=t.getView(),n=this.lastDelta_?this.lastDelta_>0?1:-1:0;e.endInteraction(this.constrainResolution_||e.getConstrainResolution()?100:void 0,n,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t))return!0;if(t.type!==FW)return!0;const e=t.map,n=t.originalEvent;n.preventDefault();const r=n.ctrlKey&&!this.ctrlKeyPressed_;n.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=t.pixel);let i=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:i*=40;break;case WheelEvent.DOM_DELTA_PAGE:i*=300}if(0===i)return!1;this.lastDelta_=i;const s=Date.now();void 0===this.startTime_&&(this.startTime_=s),(!this.mode_||s-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(i)<4?"trackpad":"wheel");const o=e.getView();if("trackpad"===this.mode_)return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(o.getAnimating()&&o.cancelAnimations(),o.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),r&&(i*=3),o.adjustZoom(-i/this.deltaPerZoom_,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=s,!1;this.totalDelta_+=i;const a=Math.max(this.timeout_-(s-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,e),a),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let n=-PH(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),MY(e,n,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}},sX=class extends VY{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=VW),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=void 0!==t.threshold?t.threshold:.3,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){let e=0;const n=this.targetPointers[0],r=this.targetPointers[1],i=Math.atan2(r.clientY-n.clientY,r.clientX-n.clientX);if(void 0!==this.lastAngle_){const t=i-this.lastAngle_;this.rotationDelta_+=t,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=t}this.lastAngle_=i;const s=t.map,o=s.getView();o.getConstraints().rotation!==tY&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(WY(this.targetPointers))),this.rotating_&&(s.render(),o.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return!(this.targetPointers.length<2&&(t.map.getView().endInteraction(this.duration_),1))}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}},oX=class extends VY{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=VW),super(e),this.anchor_=null,this.duration_=void 0!==t.duration?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const n=this.targetPointers[0],r=this.targetPointers[1],i=n.clientX-r.clientX,s=n.clientY-r.clientY,o=Math.sqrt(i*i+s*s);void 0!==this.lastDistance_&&(e=this.lastDistance_/o),this.lastDistance_=o;const a=t.map,l=a.getView();1!=e&&(this.lastScaleDelta_=e),this.anchor_=a.getCoordinateFromPixelInternal(a.getEventPixel(WY(this.targetPointers))),a.render(),l.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const e=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,n),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}};function aX(t){t=t||{};const e=new iH,n=new LY(-.005,.05,100);return(void 0===t.altShiftDragRotate||t.altShiftDragRotate)&&e.push(new GY),(void 0===t.doubleClickZoom||t.doubleClickZoom)&&e.push(new AY({delta:t.zoomDelta,duration:t.zoomDuration})),(void 0===t.dragPan||t.dragPan)&&e.push(new HY({onFocusOnly:t.onFocusOnly,kinetic:n})),(void 0===t.pinchRotate||t.pinchRotate)&&e.push(new sX),(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new oX({duration:t.zoomDuration})),(void 0===t.keyboard||t.keyboard)&&(e.push(new nX),e.push(new rX({delta:t.zoomDelta,duration:t.zoomDuration}))),(void 0===t.mouseWheelZoom||t.mouseWheelZoom)&&e.push(new iX({onFocusOnly:t.onFocusOnly,duration:t.zoomDuration})),(void 0===t.shiftDragZoom||t.shiftDragZoom)&&e.push(new JY({duration:t.zoomDuration})),e}var lX="opacity",cX="visible",uX="extent",hX="zIndex",dX="maxResolution",pX="minResolution",fX="maxZoom",gX="minZoom",mX="source",yX=class extends eH{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);"object"==typeof t.properties&&(delete e.properties,Object.assign(e,t.properties)),e[lX]=void 0!==t.opacity?t.opacity:1,SH("number"==typeof e[lX],"Layer opacity must be a number"),e[cX]=void 0===t.visible||t.visible,e[hX]=t.zIndex,e[dX]=void 0!==t.maxResolution?t.maxResolution:1/0,e[pX]=void 0!==t.minResolution?t.minResolution:0,e[gX]=void 0!==t.minZoom?t.minZoom:-1/0,e[fX]=void 0!==t.maxZoom?t.maxZoom:1/0,this.className_=void 0!==e.className?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:void 0===t||t},n=this.getZIndex();return e.opacity=PH(Math.round(100*this.getOpacity())/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=void 0!==n||e.managed?n:1/0,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return XW()}getLayerStatesArray(t){return XW()}getExtent(){return this.get(uX)}getMaxResolution(){return this.get(dX)}getMinResolution(){return this.get(pX)}getMinZoom(){return this.get(gX)}getMaxZoom(){return this.get(fX)}getOpacity(){return this.get(lX)}getSourceState(){return XW()}getVisible(){return this.get(cX)}getZIndex(){return this.get(hX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(uX,t)}setMaxResolution(t){this.set(dX,t)}setMinResolution(t){this.set(pX,t)}setMaxZoom(t){this.set(fX,t)}setMinZoom(t){this.set(gX,t)}setOpacity(t){SH("number"==typeof t,"Layer opacity must be a number"),this.set(lX,t)}setVisible(t){this.set(cX,t)}setZIndex(t){this.set(hX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},vX="addlayer",bX="removelayer",wX=class extends KW{constructor(t,e){super(t),this.layer=e}},_X="layers",xX=class t extends yX{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let n=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(_X,this.handleLayersChanged_),n?Array.isArray(n)?n=new iH(n.slice(),{unique:!0}):SH("function"==typeof n.getArray,"Expected `layers` to be an array or a `Collection`"):n=new iH(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(TW),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(EW(t,_W,this.handleLayersAdd_,this),EW(t,xW,this.handleLayersRemove_,this));for(const n in this.listenerKeys_)this.listenerKeys_[n].forEach(TW);kW(this.listenerKeys_);const e=t.getArray();for(let n=0,r=e.length;n{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const n=this.getMapInternal();let r;if(!t&&n&&(t=n.getView()),e=t instanceof nY?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&n&&(e.layerStatesArray=n.getLayerGroup().getLayerStatesArray()),e.layerStatesArray){if(r=e.layerStatesArray.find(t=>t.layer===this),!r)return!1}else r=this.getLayerState();const i=this.getExtent();return TX(r,e.viewState)&&(!i||wG(i,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let n=e(t instanceof nY?t.getViewStateAndExtent():t);return Array.isArray(n)||(n=[n]),n}render(t,e){const n=this.getRenderer();return n.prepareFrame(t)?(this.rendered=!0,n.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set("map",t)}getMapInternal(){return this.get("map")}setMap(t){this.mapPrecomposeKey_&&(TW(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(TW(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=EW(t,SX,this.handlePrecompose_,this),this.mapRenderKey_=EW(this,LW,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,n=this.getLayerState(!1);SH(!e.some(t=>t.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(n)}setSource(t){this.set(mX,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function TX(t,e){if(!t.visible)return!1;const n=e.resolution;if(n=t.maxResolution)return!1;const r=e.zoom;return r>t.minZoom&&r<=t.maxZoom}function LX(t,e,n=0,r=t.length-1,i=IX){for(;r>n;){if(r-n>600){const s=r-n+1,o=e-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);LX(t,e,Math.max(n,Math.floor(e-o*l/s+c)),Math.min(r,Math.floor(e+(s-o)*l/s+c)),i)}const s=t[e];let o=n,a=r;for(PX(t,n,e),i(t[r],s)>0&&PX(t,n,r);o0;)a--}0===i(t[n],s)?PX(t,n,a):(a++,PX(t,a,r)),a<=e&&(n=a+1),e<=a&&(r=a-1)}}function PX(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function IX(t,e){return te?1:0}var MX=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!VX(t,e))return n;const r=this.toBBox,i=[];for(;e;){for(let s=0;s=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)}_split(t,e){const n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);const s=this._chooseSplitIndex(n,i,r),o=WX(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,OX(n,this.toBBox),OX(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(n,o)}_splitRoot(t,e){this.data=WX([t,e]),this.data.height=t.height+1,this.data.leaf=!1,OX(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let r,i=1/0,s=1/0;for(let o=e;o<=n-e;o++){const e=FX(t,0,o,this.toBBox),a=FX(t,o,n,this.toBBox),l=$X(e,a),c=jX(e)+jX(a);l=e;l--){const e=t.children[l];NX(o,t.leaf?i(e):e),a+=UX(o)}return a}_adjustParentBBoxes(t,e,n){for(let r=n;r>=0;r--)NX(e[r],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():OX(t[n],this.toBBox)}};function AX(t,e,n){if(!n)return e.indexOf(t);for(let r=0;r=t.minX&&e.maxY>=t.minY}function WX(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function HX(t,e,n,r,i){const s=[e,n];for(;s.length;){if((n=s.pop())-(e=s.pop())<=r)continue;const o=e+Math.ceil((n-e)/r/2)*r;LX(t,o,e,n,i),s.push(e,o,o,n)}}var GX,KX=[NaN,NaN,NaN,0],ZX=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,YX=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,XX=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,JX=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function QX(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function tJ(t){throw new Error('failed to parse "'+t+'" as color')}function eJ(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(YX)||t.match(ZX)||t.match(XX);if(e){const t=e[4],n=100/255;return[PH(QX(e[1],n)+.5|0,0,255),PH(QX(e[2],n)+.5|0,0,255),PH(QX(e[3],n)+.5|0,0,255),void 0!==t?PH(QX(t,100),0,1):1]}tJ(t)}if(t.startsWith("#")){if(JX.test(t)){const e=t.substring(1),n=e.length<=4?1:2,r=[0,0,0,255];for(let t=0,i=e.length;t.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function oJ(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function aJ(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function lJ(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function cJ(t){const e=aJ(t[0]),n=aJ(t[1]),r=aJ(t[2]),i=lJ(.222488403*e+.716873169*n+.06060791*r),s=500*(lJ(.452247074*e+.399439023*n+.148375274*r)-i),o=200*(i-lJ(.016863605*e+.117638439*n+.865350722*r)),a=Math.atan2(o,s)*(180/Math.PI);return[116*i-16,Math.sqrt(s*s+o*o),a<0?a+360:a,t[3]]}function uJ(t){if("none"===t)return KX;if(nJ.hasOwnProperty(t))return nJ[t];if(rJ>=1024){let t=0;for(const e in nJ)3&t++||(delete nJ[e],--rJ)}const e=eJ(t);4!==e.length&&tJ(t);for(const n of e)isNaN(n)&&tJ(t);return nJ[t]=e,++rJ,e}function hJ(t){return Array.isArray(t)?t:uJ(t)}function dJ(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let n=t[1];n!=(0|n)&&(n=n+.5|0);let r=t[2];return r!=(0|r)&&(r=r+.5|0),"rgba("+e+","+n+","+r+","+(void 0===t[3]?1:Math.round(1e3*t[3])/1e3)+")"}function pJ(t){return t[0]>0&&t[1]>0}function fJ(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}var gJ=0,mJ=1<e)throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${r}, got ${i}`)}}function IQ(t,e,n){const r=t.length-1,i=new Array(r);for(let s=0;s{for(let e=0;e{for(let e=0;e{const r=t.args;let i=n.properties[e];for(let t=1,e=r.length;tt.variables[e];case SQ:return n=>{const r=t.args;if(!(e in n.properties))return!1;let i=n.properties[e];for(let t=1,e=r.length;tt.featureId;case NJ:return t=>t.geometryType;case FJ:{const n=t.args.map(t=>DQ(t,e));return t=>"".concat(...n.map(e=>e(t).toString()))}case BJ:return t=>t.resolution;case DJ:case jJ:case dQ:case mQ:case"!":return function(t,e){const n=t.operator,r=t.args.length,i=new Array(r);for(let s=0;s{for(let e=0;e{for(let e=0;e{const e=i[0](t),n=i[1](t),r=i[2](t);return e>=n&&e<=r};case mQ:return t=>{const e=i[0](t);for(let n=1;n!i[0](t);default:throw new Error(`Unsupported logical operator ${n}`)}}(t,e);case VJ:case WJ:case"<":case ZJ:case">":case GJ:return function(t,e){const n=t.operator,r=DQ(t.args[0],e),i=DQ(t.args[1],e);switch(n){case VJ:return t=>r(t)===i(t);case WJ:return t=>r(t)!==i(t);case"<":return t=>r(t)r(t)<=i(t);case">":return t=>r(t)>i(t);case GJ:return t=>r(t)>=i(t);default:throw new Error(`Unsupported comparison operator ${n}`)}}(t,e);case"*":case"/":case"+":case"-":case tQ:case"%":case"^":case rQ:case iQ:case sQ:case oQ:case aQ:case lQ:case cQ:case uQ:return function(t,e){const n=t.operator,r=t.args.length,i=new Array(r);for(let s=0;s{let e=1;for(let n=0;ni[0](t)/i[1](t);case"+":return t=>{let e=0;for(let n=0;ni[0](t)-i[1](t);case tQ:return t=>{const e=i[0](t),n=i[1](t);if(er?r:e};case"%":return t=>i[0](t)%i[1](t);case"^":return t=>Math.pow(i[0](t),i[1](t));case rQ:return t=>Math.abs(i[0](t));case iQ:return t=>Math.floor(i[0](t));case sQ:return t=>Math.ceil(i[0](t));case oQ:return t=>Math.round(i[0](t));case aQ:return t=>Math.sin(i[0](t));case lQ:return t=>Math.cos(i[0](t));case cQ:return 2===r?t=>Math.atan2(i[0](t),i[1](t)):t=>Math.atan(i[0](t));case uQ:return t=>Math.sqrt(i[0](t));default:throw new Error(`Unsupported numeric operator ${n}`)}}(t,e);case gQ:return function(t,e){const n=t.args.length,r=new Array(n);for(let i=0;i{for(let e=0;e{const e=r[0](t);for(let i=1;i{const e=r[0](t),i=r[1](t);let s,o;for(let a=2;a=i)return 2===a?l:c?UQ(e,i,s,o,n,l):jQ(e,i,s,o,n,l);s=n,o=l}return o}}(t,e);case kQ:return function(t,e){const n=t.operator,r=t.args.length,i=new Array(r);for(let s=0;s{const n=i[0](e);return t.args[0].type===bJ?dJ(n):n.toString()};throw new Error(`Unsupported convert operator ${n}`)}(t,e);default:throw new Error(`Unsupported operator ${n}`)}}function jQ(t,e,n,r,i,s){const o=i-n;if(0===o)return r;const a=e-n;return r+(1===t?a/o:(Math.pow(t,a)-1)/(Math.pow(t,o)-1))*(s-r)}function UQ(t,e,n,r,i,s){if(i-n===0)return r;const o=cJ(r),a=cJ(s);let l=a[2]-o[2];return l>180?l-=360:l<-180&&(l+=360),function(t){const e=(t[0]+16)/116,n=t[1],r=t[2]*Math.PI/180,i=oJ(e),s=oJ(e+n/500*Math.cos(r)),o=oJ(e-n/200*Math.sin(r)),a=sJ(3.021973625*s-1.617392459*i-.404875592*o),l=sJ(-.943766287*s+1.916279586*i+.027607165*o),c=sJ(.069407491*s-.22898585*i+1.159737864*o);return[PH(a+.5|0,0,255),PH(l+.5|0,0,255),PH(c+.5|0,0,255),t[3]]}([jQ(t,e,n,o[0],i,a[0]),jQ(t,e,n,o[1],i,a[1]),o[2]+jQ(t,e,n,0,i,l),jQ(t,e,n,r[3],i,s[3])])}var BQ=class extends ZW{constructor(t,e,n,r){super(),this.extent=t,this.pixelRatio_=n,this.resolution=e,this.state="function"==typeof r?0:r,this.image_=null,this.loader="function"==typeof r?r:null}changed(){this.dispatchEvent(LW)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(0==this.state&&this.loader){this.state=1,this.changed();const t=this.getResolution(),e=Array.isArray(t)?t[0]:t;GW(()=>this.loader(this.getExtent(),e,this.getPixelRatio())).then(t=>{"image"in t&&(this.image_=t.image),"extent"in t&&(this.extent=t.extent),"resolution"in t&&(this.resolution=t.resolution),"pixelRatio"in t&&(this.pixelRatio_=t.pixelRatio),(t instanceof HTMLImageElement||fH&&t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)&&(this.image_=t),this.state=2}).catch(t=>{this.state=3,console.error(t)}).finally(()=>this.changed())}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}};function $Q(t,e){return t+":"+(e?hJ(e):"null")}var qQ=new class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const n=this.cache_[e];3&t++||n.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){const n=$Q(t,e);return n in this.cache_?this.cache_[n]:null}getPattern(t,e){const n=$Q(t,e);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,n,r){const i=$Q(t,e),s=i in this.cache_;this.cache_[i]=n,r&&(0===n.getImageState()&&n.load(),1===n.getImageState()?n.ready().then(()=>{this.patternCache_[i]=mY().createPattern(n.getImage(1),"repeat")}):this.patternCache_[i]=mY().createPattern(n.getImage(1),"repeat")),s||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}},VQ=null,WQ=class extends ZW{constructor(t,e,n,r,i){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.canvas_={},this.color_=i,this.imageState_=void 0===r?0:r,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(void 0===this.tainted_&&2===this.imageState_){VQ||(VQ=gY(1,1,void 0,{willReadFrequently:!0})),VQ.drawImage(this.image_,0,0);try{VQ.getImageData(0,0,1,1),this.tainted_=!1}catch{VQ=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(LW)}handleImageError_(){this.imageState_=3,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=2,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}setImage(t){this.image_=t}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],n=gY(t,e);n.fillRect(0,0,t,e),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(0===this.imageState_){this.image_||this.initializeImage_(),this.imageState_=1;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&(t=this.image_,e=this.src_,e&&(t.src=e),t.src&&pH?new Promise((e,n)=>t.decode().then(()=>e(t)).catch(r=>t.complete&&t.width?e(t):n(r))):function(t){return new Promise((e,n)=>{function r(){s(),e(t)}function i(){s(),n(new Error("Image load error"))}function s(){t.removeEventListener("load",r),t.removeEventListener("error",i)}t.addEventListener("load",r),t.addEventListener("error",i)})}(t)).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}var t,e}replaceColor_(t){if(!this.color_||this.canvas_[t]||2!==this.imageState_)return;const e=this.image_,n=gY(Math.ceil(e.width*t),Math.ceil(e.height*t)),r=n.canvas;var i;n.scale(t,t),n.drawImage(e,0,0),n.globalCompositeOperation="multiply",n.fillStyle="string"==typeof(i=this.color_)?i:dJ(i),n.fillRect(0,0,r.width/t,r.height/t),n.globalCompositeOperation="destination-in",n.drawImage(e,0,0),this.canvas_[t]=r}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(2===this.imageState_||3===this.imageState_)t();else{const e=()=>{2!==this.imageState_&&3!==this.imageState_||(this.removeEventListener(LW,e),t())};this.addEventListener(LW,e)}})),this.ready_}};function HQ(t,e,n,r,i,s){let o=void 0===e?void 0:qQ.get(e,i);return o||(o=new WQ(t,t&&"src"in t?t.src||void 0:e,n,r,i),qQ.set(e,i,o,s)),s&&o&&!qQ.getPattern(e,i)&&qQ.set(e,i,o,s),o}function GQ(t){return t?Array.isArray(t)?dJ(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return qQ.getPattern(t.src,t.color);const e=t.src+":"+t.offset,n=qQ.getPattern(e,t.color);if(n)return n;const r=qQ.get(t.src,null);if(2!==r.getImageState())return null;const i=gY(t.size[0],t.size[1]);return i.drawImage(r.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),HQ(i.canvas,e,void 0,2,t.color,!0),qQ.getPattern(e,t.color)}(t):t:null}var KQ,ZQ="#000",YQ="round",XQ=[],JQ="round",QQ="#000",t0="center",e0=[0,0,0,0],n0=new eH,r0=null,i0={},s0=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function o0(t,e,n){return`${t} ${e} 16px "${n}"`}var a0=function(){const t=100;let e,n;async function r(t){await n.ready;const e=fY(t),r=e.families[0].toLowerCase(),i=e.weight,s=[];return n.forEach(t=>{const n=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),o=pY[t.weight]||t.weight;n===r&&t.style===e.style&&o==i&&s.push(t)}),0!==s.length&&(await Promise.all(s.map(t=>t.load().then(()=>!0,()=>!1)))).some(t=>t)}async function i(){await n.ready;let s=!0;const o=n0.getProperties(),a=Object.keys(o).filter(e=>o[e]=0;--e){const n=a[e];let i=o[n];iMath.max(e,u0(t,n)),0);return n[e]=r,r}var d0=class t{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=fJ(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const e=this.getScale();return new t({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return XW()}getImage(t){return XW()}getHitDetectionImage(){return XW()}getPixelRatio(t){return 1}getImageState(){return XW()}getImageSize(){return XW()}getOrigin(){return XW()}getSize(){return XW()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=fJ(t)}listenImageChange(t){XW()}load(){XW()}unlistenImageChange(t){XW()}ready(){return Promise.resolve()}},p0=class t extends d0{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?1:2,1===this.imageState_&&this.ready().then(()=>this.imageState_=2),this.render()}clone(){const e=this.getScale(),n=new t({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return n.setOpacity(this.getOpacity()),n}getAnchor(){const t=this.size_,e=this.getDisplacement(),n=this.getScaleArray();return[t[0]/2-e[0]/n[0],t[1]/2+e[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),n=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let r=qQ.get(n,null)?.getImage(1);if(!r){const e=this.renderOptions_,i=Math.ceil(e.size*t),s=gY(i,i);this.draw_(e,s,t),r=s.canvas;const o=new WQ(r,void 0,null,2,null);qQ.set(n,null,o),createImageBitmap(r).then(t=>{o.setImage(t)})}return r}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,n){if(0===e||this.points_===1/0||"bevel"!==t&&"miter"!==t)return e;let r=this.radius,i=void 0===this.radius2_?r:this.radius2_;if(r{this.patternImage_=null}),0===e.getImageState()&&e.load(),1===e.getImageState()&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?QW(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:hJ(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}};function m0(t,e,n,r){return void 0!==n&&void 0!==r?[n/t,r/e]:void 0!==n?n/t:void 0!==r?r/e:1}var y0=class t extends d0{constructor(t){const e=void 0!==(t=t||{}).opacity?t.opacity:1,n=void 0!==t.rotation?t.rotation:0,r=void 0!==t.scale?t.scale:1,i=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:e,rotation:n,scale:r,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:i,declutterMode:t.declutterMode}),this.anchor_=void 0!==t.anchor?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==t.anchorOrigin?t.anchorOrigin:"top-left",this.anchorXUnits_=void 0!==t.anchorXUnits?t.anchorXUnits:"fraction",this.anchorYUnits_=void 0!==t.anchorYUnits?t.anchorYUnits:"fraction",this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;const s=void 0!==t.img?t.img:null;let o,a=t.src;if(SH(!(void 0!==a&&s),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!s||(a=s.src||QW(s)),SH(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),SH(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),"`width` or `height` cannot be provided together with `scale`"),void 0!==t.src?o=0:void 0!==s&&(o="complete"in s?s.complete?s.src?2:0:1:2),this.color_=void 0!==t.color?hJ(t.color):null,this.iconImage_=HQ(s,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},o,this.color_),this.offset_=void 0!==t.offset?t.offset:[0,0],this.offsetOrigin_=void 0!==t.offsetOrigin?t.offsetOrigin:"top-left",this.origin_=null,this.size_=void 0!==t.size?t.size:null,this.initialOptions_,void 0!==t.width||void 0!==t.height){let e,n;if(t.size)[e,n]=t.size;else{const r=this.getImage(1);if(r.width&&r.height)e=r.width,n=r.height;else if(r instanceof HTMLImageElement){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const n=this.iconImage_.getSize();this.setScale(m0(n[0],n[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(m0(e,n,t.width,t.height))}}clone(){let e,n,r;return this.initialOptions_?(n=this.initialOptions_.width,r=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new t({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:n,height:r,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const e=this.getSize();if("fraction"==this.anchorXUnits_||"fraction"==this.anchorYUnits_){if(!e)return null;t=this.anchor_.slice(),"fraction"==this.anchorXUnits_&&(t[0]*=e[0]),"fraction"==this.anchorYUnits_&&(t[1]*=e[1])}if("top-left"!=this.anchorOrigin_){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),"top-right"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[0]=-t[0]+e[0]),"bottom-left"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),n=this.getScaleArray();return[t[0]-e[0]/n[0],t[1]+e[1]/n[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){const e=t?hJ(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((t,n)=>t===e[n]))return;this.color_=e;const n=this.getSrc(),r=void 0!==n?null:this.getHitDetectionImage(),i=void 0!==n?0:this.iconImage_.getImageState();this.iconImage_=HQ(r,n,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},i,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if("top-left"!=this.offsetOrigin_){const e=this.getSize(),n=this.iconImage_.getSize();if(!e||!n)return null;t=t.slice(),"top-right"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[0]=n[0]-e[0]-t[0]),"bottom-left"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[1]=n[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=HQ(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},0,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();return this.size_?this.size_[0]*t[0]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:2==this.iconImage_.getImageState()?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(LW,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(LW,t)}ready(){return this.iconImage_.ready()}},v0=class t{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){const e=this.getColor();return new t({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}},b0=class t{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=x0,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let e=this.getGeometry();return e&&"object"==typeof e&&(e=e.clone()),new t({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=x0,this.geometry_=t}setZIndex(t){this.zIndex_=t}},w0=null;function _0(){if(!w0){const t=new g0({color:"rgba(255,255,255,0.4)"}),e=new v0({color:"#3399CC",width:1.25});w0=[new b0({image:new f0({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return w0}function x0(t){return t.getGeometry()}var C0=class t{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=fJ(void 0!==t.scale?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=void 0!==t.fill?t.fill:new g0({color:"#333"}),this.maxAngle_=void 0!==t.maxAngle?t.maxAngle:Math.PI/4,this.placement_=void 0!==t.placement?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=void 0!==t.stroke?t.stroke:null,this.offsetX_=void 0!==t.offsetX?t.offsetX:0,this.offsetY_=void 0!==t.offsetY?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=void 0===t.padding?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const e=this.getScale();return new t({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof g0?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=fJ(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}};function k0(){return!0}function S0(t,e){e=e??IJ();const n=t.length,r=new Array(n);for(let o=0;o0&&"string"==typeof p[0]?g=A0(t,"icon-color",e):f=H0(p,"icon-color"));const m=function(t,e){const n=t[e];if(void 0!==n){if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);return n}}(t,"icon-cross-origin"),y=function(t,e){const n=t[e];if(void 0!==n)return q0(n,e)}(t,"icon-offset"),v=U0(t,"icon-offset-origin"),b=D0(t,"icon-width"),w={src:r,anchorOrigin:u,anchorXUnits:h,anchorYUnits:d,crossOrigin:m,offset:y,offsetOrigin:v,height:D0(t,"icon-height"),width:b,size:j0(t,"icon-size"),declutterMode:$0(t,"icon-declutter-mode")};let _=null;return function(t){if(_)g&&_.setColor(g(t));else{const e=g?g(t):f;_=new y0(void 0!==e?Object.assign({},w,{color:e}):Object.assign({},w))}return o&&_.setOpacity(o(t)),a&&_.setDisplacement(a(t)),l&&_.setRotation(l(t)),c&&_.setRotateWithView(c(t)),s&&_.setScale(s(t)),i&&_.setAnchor(i(t)),_}}(t,e):"shape-points"in t?function(t,e){const n="shape-",r="shape-points",i="shape-radius",s=W0(t[r],r);if(!(i in t))throw new Error(`Expected a number for ${i}`);const o=P0(t,i,e),a="number"==typeof t[i]?t[i]:5,l="shape-radius2",c=P0(t,l,e),u="number"==typeof t[l]?t[l]:void 0,h=R0(t,n,e),d=T0(t,n,e),p=z0(t,"shape-scale",e),f=F0(t,"shape-displacement",e),g=P0(t,"shape-rotation",e),m=M0(t,"shape-rotate-with-view",e),y=D0(t,"shape-angle"),v=$0(t,"shape-declutter-mode"),b=new p0({points:s,radius:a,radius2:u,angle:y,declutterMode:v});return function(t){return o&&b.setRadius(o(t)),c&&b.setRadius2(c(t)),h&&b.setFill(h(t)),d&&b.setStroke(d(t)),f&&b.setDisplacement(f(t)),g&&b.setRotation(g(t)),m&&b.setRotateWithView(m(t)),p&&b.setScale(p(t)),b}}(t,e):"circle-radius"in t?function(t,e){const n="circle-",r=R0(t,n,e),i=T0(t,n,e),s=P0(t,"circle-radius",e),o=z0(t,"circle-scale",e),a=F0(t,"circle-displacement",e),l=P0(t,"circle-rotation",e),c=M0(t,"circle-rotate-with-view",e),u=$0(t,"circle-declutter-mode"),h=new f0({radius:5,declutterMode:u});return function(t){return s&&h.setRadius(s(t)),r&&h.setFill(r(t)),i&&h.setStroke(i(t)),a&&h.setDisplacement(a(t)),l&&h.setRotation(l(t)),c&&h.setRotateWithView(c(t)),o&&h.setScale(o(t)),h}}(t,e):null}(t,e),o=P0(t,"z-index",e);if(!(n||r||i||s||SW(t)))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(t));const a=new b0;return function(t){let e=!0;if(n){const r=n(t);r&&(e=!1),a.setFill(r)}if(r){const n=r(t);n&&(e=!1),a.setStroke(n)}if(i){const n=i(t);n&&(e=!1),a.setText(n)}if(s){const n=s(t);n&&(e=!1),a.setImage(n)}return o&&a.setZIndex(o(t)),e?null:a}}function R0(t,e,n){let r;if(e+"fill-pattern-src"in t)r=function(t,e,n){const r=I0(t,e+"pattern-src",n),i=N0(t,e+"pattern-offset",n),s=N0(t,e+"pattern-size",n),o=A0(t,e+"color",n);return function(t){return{src:r(t),offset:i&&i(t),size:s&&s(t),color:o&&o(t)}}}(t,e+"fill-",n);else{if("none"===t[e+"fill-color"])return()=>null;r=A0(t,e+"fill-color",n)}if(!r)return null;const i=new g0;return function(t){const e=r(t);return e===KX?null:(i.setColor(e),i)}}function T0(t,e,n){const r=P0(t,e+"stroke-width",n),i=A0(t,e+"stroke-color",n);if(!r&&!i)return null;const s=I0(t,e+"stroke-line-cap",n),o=I0(t,e+"stroke-line-join",n),a=O0(t,e+"stroke-line-dash",n),l=P0(t,e+"stroke-line-dash-offset",n),c=P0(t,e+"stroke-miter-limit",n),u=P0(t,e+"stroke-offset",n),h=new v0;return function(t){if(i){const e=i(t);if(e===KX)return null;h.setColor(e)}if(r&&h.setWidth(r(t)),s){const e=s(t);if("butt"!==e&&"round"!==e&&"square"!==e)throw new Error("Expected butt, round, or square line cap");h.setLineCap(e)}if(o){const e=o(t);if("bevel"!==e&&"round"!==e&&"miter"!==e)throw new Error("Expected bevel, round, or miter line join");h.setLineJoin(e)}return a&&h.setLineDash(a(t)),l&&h.setLineDashOffset(l(t)),c&&h.setMiterLimit(c(t)),u&&h.setOffset(u(t)),h}}function L0(t,e){if(!(e in t))return;const n=t[e];return void 0===n?void 0:n}function P0(t,e,n){const r=L0(t,e);if(void 0===r)return;const i=zQ(r,yJ,n);return function(t){return W0(i(t),e)}}function I0(t,e,n){const r=L0(t,e);if(void 0===r)return null;const i=zQ(r,vJ,n);return function(t){return V0(i(t),e)}}function M0(t,e,n){const r=L0(t,e);if(void 0===r)return null;const i=zQ(r,mJ,n);return function(t){const n=i(t);if("boolean"!=typeof n)throw new Error(`Expected a boolean for ${e}`);return n}}function A0(t,e,n){const r=L0(t,e);if(void 0===r)return null;const i=zQ(r,bJ,n);return function(t){return H0(i(t),e)}}function O0(t,e,n){const r=L0(t,e);if(void 0===r)return null;if(Array.isArray(r)&&(0===r.length||"string"!=typeof r[0])){const t=r.map((t,r)=>{if("number"==typeof t)return()=>t;const i=zQ(t,yJ,n);return function(t){return W0(i(t),`${e}[${r}]`)}});return function(e){const n=new Array(t.length);for(let r=0;r4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return n}function G0(t,e){const n=q0(t,e);if(2!==n.length)throw new Error(`Expected an array of two numbers for ${e}`);return n}var K0="renderOrder",Z0=class extends RX{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=void 0!==t.renderBuffer?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=void 0!==t.updateWhileAnimating&&t.updateWhileAnimating,this.updateWhileInteracting_=void 0!==t.updateWhileInteracting&&t.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(K0)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const n=this.getDeclutter();n in t.declutter==0&&(t.declutter[n]=new MX(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(K0,t)}setStyle(t){this.style_=void 0===t?_0:t;const e=function(t){if(void 0===t)return _0;if(!t)return null;if("function"==typeof t)return t;if(t instanceof b0)return t;if(Array.isArray(t)&&0===t.length)return[];if(Array.isArray(t)&&t[0]instanceof b0){const e=t.length,n=new Array(e);for(let r=0;r=0;--r){const i=f[r],s=i.layer;if(s.hasRenderer()&&TX(i,c)&&o.call(a,s)){const r=s.getRenderer(),o=s.getSource();if(r&&o){const s=o.getWrapX()?d:t,a=u.bind(null,i.managed);y[0]=s[0]+p[b][0],y[1]=s[1]+p[b][1],l=r.forEachFeatureAtCoordinate(y,e,n,a,m)}if(l)return l}}if(0===m.length)return;const v=1/m.length;return m.forEach((t,e)=>t.distanceSq+=e*v),m.sort((t,e)=>t.distanceSq-e.distanceSq),m.some(t=>l=t.callback(t.feature,t.layer,t.geometry)),l}hasFeatureAtCoordinate(t,e,n,r,i,s){return void 0!==this.forEachFeatureAtCoordinate(t,e,n,r,qW,this,i,s)}getMap(){return this.map_}renderFrame(t){XW()}scheduleExpireIconCache(t){qQ.canExpireCache()&&t.postRenderFunctions.push(J0)}};function J0(){qQ.expire()}var Q0=class extends X0{constructor(t){super(t),this.fontChangeListenerKey_=EW(n0,CW,t.redrawText,t),this.element_=dH?xY():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=lY+" ol-layers";const n=t.getViewport();n&&n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const n=this.getMap();if(n.hasListener(t)){const r=new Y0(t,void 0,e);n.dispatchEvent(r)}}disposeInternal(){TW(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t)return void(this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1));this.calculateMatrices2D(t),this.dispatchRenderEvent(SX,t);const e=t.layerStatesArray.sort((t,e)=>t.zIndex-e.zIndex);e.some(t=>t.layer instanceof Z0&&t.layer.getDeclutter())&&(t.declutter={});const n=t.viewState;this.children_.length=0;const r=this.getMap().getTargetElement();let i;CY(r)&&(i=r.getContext("2d"),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,r.width,r.height));const s=[];let o=i?r:null;for(let a=0,l=e.length;a0)&&(i.fillStyle=e,i.fillRect(0,0,i.canvas.width,i.canvas.height)),!CY(t)||0===t.width)continue;i.save();const n=a.style.opacity||t.style.opacity;i.globalAlpha=""===n?1:Number(n);const r=t.style.transform;if(r)i.transform(...iZ(r));else{const e=parseFloat(t.style.width)/t.width,n=parseFloat(t.style.height)/t.height;i.transform(e,0,0,n,0,0)}i.drawImage(t,0,0),i.restore()}this.dispatchRenderEvent("postcompose",t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let n=e.length-1;n>=0;--n){const r=e[n],i=r.layer;i.getDeclutter()&&i.renderDeclutter(t,r)}e.forEach(e=>e.layer.renderDeferred(t))}}};function t1(t){t instanceof RX?t.setMapInternal(null):t instanceof xX&&t.getLayers().forEach(t1)}function e1(t,e){if(t instanceof RX)t.setMapInternal(e);else if(t instanceof xX){const n=t.getLayers().getArray();for(let t=0,r=n.length;tthis.updateSize())),this.controls=e.controls||(dH?new iH:TY()),this.interactions=e.interactions||(dH?new iH:aX({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new TH(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(_H,this.handleLayerGroupChanged_),this.addChangeListener(kH,this.handleViewChanged_),this.addChangeListener(xH,this.handleSizeChanged_),this.addChangeListener(CH,this.handleTargetChanged_),this.setProperties(e.values);const n=this;!t.view||t.view instanceof nY||t.view.then(function(t){n.setView(new nY(t))}),this.controls.addEventListener(_W,t=>{t.element.setMap(this)}),this.controls.addEventListener(xW,t=>{t.element.setMap(null)}),this.interactions.addEventListener(_W,t=>{t.element.setMap(this)}),this.interactions.addEventListener(xW,t=>{t.element.setMap(null)}),this.overlays_.addEventListener(_W,t=>{this.addOverlayInternal_(t.element)}),this.overlays_.addEventListener(xW,t=>{const e=t.element.getId();void 0!==e&&delete this.overlayIdIndex_[e.toString()],t.element.setMap(null)}),this.controls.forEach(t=>{t.setMap(this)}),this.interactions.forEach(t=>{t.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){e1(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();void 0!==e&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,n){if(!this.frameState_||!this.renderer_)return;const r=this.getCoordinateFromPixelInternal(t),i=void 0!==(n=void 0!==n?n:{}).hitTolerance?n.hitTolerance:0,s=void 0!==n.layerFilter?n.layerFilter:qW,o=!1!==n.checkWrapped;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,i,o,e,null,s,null)}getFeaturesAtPixel(t,e){const n=[];return this.forEachFeatureAtPixel(t,function(t){n.push(t)},e),n}getAllLayers(){const t=[];return function e(n){n.forEach(function(n){n instanceof xX?e(n.getLayers()):t.push(n)})}(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const n=this.getCoordinateFromPixelInternal(t),r=void 0!==(e=void 0!==e?e:{}).layerFilter?e.layerFilter:qW,i=void 0!==e.hitTolerance?e.hitTolerance:0,s=!1!==e.checkWrapped;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,i,s,r,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const e=this.viewport_.getBoundingClientRect(),n=this.getSize(),r=e.width/n[0],i=e.height/n[1],s="changedTouches"in t?t.changedTouches[0]:t;return[(s.clientX-e.left)/r,(s.clientY-e.top)/i]}getTarget(){return this.get(CH)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return VK(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?QK(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return void 0!==e?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(_H)}setLayers(t){const e=this.getLayerGroup();if(t instanceof iH)return void e.setLayers(t);const n=e.getLayers();n.clear(),n.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,n=t.length;e=0;n--){const r=e[n];if(r.getMap()===this&&r.getActive()&&this.getTargetElement()&&(!r.handleEvent(t)||t.propagationStopped))break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let n=this.maxTilesLoading_,r=n;const i=t?t.viewHints:void 0,s=!!i&&(i[0]||i[1]);if(s){const e=Date.now()-t.time>8;n=e?0:8,r=e?0:2}e.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new wX("removelayer",e)),this.set(_H,t)}setSize(t){this.set(xH,t)}setTarget(t){this.set(CH,t)}setView(t){if(!t||t instanceof nY)return void this.set(kH,t);this.set(kH,new nY);const e=this;t.then(function(t){e.setView(new nY(t))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,r;if(CY(t)){const e=t.getContext("2d").getTransform();n=t.width/e.a,r=t.height/e.d}else{const e=getComputedStyle(t);n=t.offsetWidth-parseFloat(e.borderLeftWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderRightWidth),r=t.offsetHeight-parseFloat(e.borderTopWidth)-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderBottomWidth)}isNaN(n)||isNaN(r)||(e=[Math.max(0,n),Math.max(0,r)],!pJ(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&FG("No map visible because the map container's width or height are 0."))}const n=this.getSize();!e||n&&$W(e,n)||(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}},r1="element",i1="map",s1="offset",o1="position",a1="positioning",l1=class extends eH{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=void 0===t.insertFirst||t.insertFirst,this.stopEvent=void 0===t.stopEvent||t.stopEvent,this.element=document.createElement("div"),this.element.className=void 0!==t.className?t.className:"ol-overlay-container ol-selectable",this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=!0===t.autoPan?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(r1,this.handleElementChanged),this.addChangeListener(i1,this.handleMapChanged),this.addChangeListener(s1,this.handleOffsetChanged),this.addChangeListener(o1,this.handlePositionChanged),this.addChangeListener(a1,this.handlePositioningChanged),void 0!==t.element&&this.setElement(t.element),this.setOffset(void 0!==t.offset?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),void 0!==t.position&&this.setPosition(t.position)}getElement(){return this.get(r1)}getId(){return this.id}getMap(){return this.get(i1)||null}getOffset(){return this.get(s1)}getPosition(){return this.get(o1)}getPositioning(){return this.get(a1)}handleElementChanged(){_Y(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),TW(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=EW(t,vH,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(r1,t)}setMap(t){this.set(i1,t)}setOffset(t){this.set(s1,t)}setPosition(t){this.set(o1,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(o1))return;const n=this.getRect(e.getTargetElement(),e.getSize()),r=this.getElement(),i=this.getRect(r,[vY(r),bY(r)]),s=void 0===(t=t||{}).margin?20:t.margin;if(!KH(n,i)){const r=i[0]-n[0],o=n[2]-i[2],a=i[1]-n[1],l=n[3]-i[3],c=[0,0];if(r<0?c[0]=r-s:o<0&&(c[0]=Math.abs(o)+s),a<0?c[1]=a-s:l<0&&(c[1]=Math.abs(l)+s),0!==c[0]||0!==c[1]){const n=e.getView().getCenterInternal(),r=e.getPixelFromCoordinateInternal(n);if(!r)return;const i=[r[0]+c[0],r[1]+c[1]],s=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(i),duration:s.duration,easing:s.easing})}}}getRect(t,e){const n=t.getBoundingClientRect(),r=n.left+window.pageXOffset,i=n.top+window.pageYOffset;return[r,i,r+e[0],i+e[1]]}setPositioning(t){this.set(a1,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e)return void this.setVisible(!1);const n=t.getPixelFromCoordinate(e),r=t.getSize();this.updateRenderedPosition(n,r)}updateRenderedPosition(t,e){const n=this.element.style,r=this.getOffset(),i=this.getPositioning();this.setVisible(!0);let s="0%",o="0%";"bottom-right"==i||"center-right"==i||"top-right"==i?s="-100%":"bottom-center"!=i&&"center-center"!=i&&"top-center"!=i||(s="-50%"),"bottom-left"==i||"bottom-center"==i||"bottom-right"==i?o="-100%":"center-left"!=i&&"center-center"!=i&&"center-right"!=i||(o="-50%");const a=`translate(${s}, ${o}) translate(${t[0]+r[0]}px, ${t[1]+r[1]}px)`;this.rendered.transform_!=a&&(this.rendered.transform_=a,n.transform=a)}getOptions(){return this.options}},c1=class t extends eH{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if("function"==typeof t.getSimplifiedGeometry){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const e=new t,n=this.geometryName_;e.setGeometryName(n);const r=this.getPropertiesInternal();if(r){const t=this.getGeometry();for(const i in r)i===n&&t?e.set(i,t.clone()):e.set(i,r[i],!0)}const i=this.getStyle();return i&&e.setStyle(i),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(TW(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=EW(t,LW,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?function(t){if("function"==typeof t)return t;let e;return Array.isArray(t)?e=t:(SH("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[t]),function(){return e}}(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}};function u1(t,e,n,r,i,s,o){let a,l;const c=(n-e)/r;if(1===c)a=e;else if(2===c)a=e,l=i;else if(0!==c){let s=t[e],o=t[e+1],c=0;const u=[0];for(let i=e+r;i>1),i=+n(t[r],e),i<0?s=r+1:(o=r,a=!i);return a?s:~s}(u,h);d<0?(l=(h-u[-d-2])/(u[-d-1]-u[-d-2]),a=e+(-d-2)*r):a=e+d*r}o=o>1?o:2,s=s||new Array(o);for(let u=0;u>1;ia&&(this.instructions.push([4,a,c,t,n,CZ,i]),this.hitDetectionInstructions.push([4,a,c,t,r||n,CZ,i]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),c=this.coordinates.length,this.instructions.push([4,a,c,t,n,void 0,i]),this.hitDetectionInstructions.push([4,a,c,t,r||n,void 0,i])}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[0,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[0,e,0,t,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;let e;t.reverse();const n=t.length;let r,i,s=-1;for(e=0;ethis.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){const n=this.state;this.fillStyleToState(t,n),this.strokeStyleToState(e,n)}createFill(t){const e=t.fillStyle,n=[10,e];return"string"!=typeof e&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[b1,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const n=t.fillStyle;(void 0!==n&&"string"!=typeof n||t.currentFillStyle!=n)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=n)}updateStrokeStyle(t,e){const n=t.strokeStyle,r=t.lineCap,i=t.lineDash,s=t.lineDashOffset,o=t.lineJoin,a=t.lineWidth,l=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=n||t.currentLineCap!=r||i!=t.currentLineDash&&!$W(t.currentLineDash,i)||t.currentLineDashOffset!=s||t.currentLineJoin!=o||t.currentLineWidth!=a||t.currentMiterLimit!=l||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=n,t.currentLineCap=r,t.currentLineDash=i,t.currentLineDashOffset=s,t.currentLineJoin=o,t.currentLineWidth=a,t.currentMiterLimit=l,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[7,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=WH(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;VH(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},S1=class extends k1{constructor(t,e,n,r){super(t,e,n,r)}drawFlatCoordinatess_(t,e,n,r,i){const s=this.state,o=void 0!==s.fillStyle,a=void 0!==s.strokeStyle,l=n.length;this.instructions.push(x1),this.hitDetectionInstructions.push(x1);for(let c=0;cthis.drawCircle(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==r.fillStyle&&this.hitDetectionInstructions.push([10,ZQ]),void 0!==r.strokeStyle&&this.hitDetectionInstructions.push([b1,QQ,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,XQ,0]);const a=t.getFlatCoordinates(),l=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const u=[2,c,o];this.instructions.push(x1,u),this.hitDetectionInstructions.push(x1,u),void 0!==r.fillStyle&&(this.instructions.push(w1),this.hitDetectionInstructions.push(w1)),void 0!==r.strokeStyle&&(this.instructions.push(_1),this.hitDetectionInstructions.push(_1)),this.endGeometry(e)}drawPolygon(t,e,n){const r=this.state,i=r.fillStyle,s=r.strokeStyle,o=r.strokeOffset;if(void 0===i&&void 0===s)return;if(this.handleStrokeOffset_(()=>this.drawPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==r.fillStyle&&this.hitDetectionInstructions.push([10,ZQ]),void 0!==r.strokeStyle&&this.hitDetectionInstructions.push([b1,QQ,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,XQ,0]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(l,0,a,c,o),this.endGeometry(e)}drawMultiPolygon(t,e,n){const r=this.state,i=r.fillStyle,s=r.strokeStyle,o=r.strokeOffset;if(void 0===i&&void 0===s)return;if(this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==r.fillStyle&&this.hitDetectionInstructions.push([10,ZQ]),void 0!==r.strokeStyle&&this.hitDetectionInstructions.push([b1,QQ,r.lineWidth,r.lineCap,r.lineJoin,r.miterLimit,XQ,0]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),c=t.getStride();let u=0;for(let h=0,d=a.length;h0&&void 0!==n&&void 0!==r&&(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=r,e.strokeOffset=i,t(),e.fillStyle=n,!0)}},E1=0,R1=1;function T1(t,e,n,r,i,s,o,a){const l=o-i,c=a-s;let u=0,h=1;if(0===l){if(in)return!1}else{let e=(t-i)/l,r=(n-i)/l;if(e>r){const t=e;e=r,r=t}if(e>u&&(u=e),rh)return!1}if(0===c){if(sr)return!1}else{let t=(e-s)/c,n=(r-s)/c;if(t>n){const e=t;t=n,n=e}if(t>u&&(u=t),nh)return!1}return E1=u,R1=h,!0}function L1(t,e,n,r,i){const s=[];let o=n,a=0,l=e.slice(n,2);for(;a=t){const e=(t-a+h)/h,d=NH(n,c,e),p=NH(r,u,e);l.push(d,p),s.push(l),l=[d,p],a==t&&(o+=i),a=0}else if(a0&&s.push(l),s}function P1(t,e,n,r,i){let s,o,a,l,c,u,h,d,p,f,g=n,m=n,y=0,v=0,b=n;for(o=n;ot&&(v>y&&(y=v,g=b,m=o),v=0,b=o-i)),a=l,h=p,d=f),c=n,u=r}return v+=l,v>y?[b,o]:[g,m]}var I1,M1={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},A1={Circle:S1,Default:k1,Image:class extends k1{constructor(t,e,n,r){super(t,e,n,r),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,n){if(!this.image_||this.maxExtent&&!GH(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,n);const r=t.getFlatCoordinates(),i=t.getStride(),s=this.coordinates.length,o=this.appendFlatPointCoordinates(r,i);this.instructions.push([6,s,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([6,s,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,n){if(!this.image_)return;this.beginGeometry(t,e,n);const r=t.getFlatCoordinates(),i=[];for(let a=0,l=r.length;a{const r=o[2*(t+n)]===c[n*u]&&o[2*(t+n)+1]===c[n*u+1];return r||--t,r})}this.saveTextStates_();const h=s.backgroundFill?this.createFill(this.fillStyleToState(s.backgroundFill)):null,d=s.backgroundStroke?this.createStroke(this.strokeStyleToState(s.backgroundStroke)):null;this.beginGeometry(t,e,n);let p=s.padding;if(p!=e0&&(s.scale[0]<0||s.scale[1]<0)){let t=s.padding[0],e=s.padding[1],n=s.padding[2],r=s.padding[3];s.scale[0]<0&&(e=-e,r=-r),s.scale[1]<0&&(t=-t,n=-n),p=[t,e,n,r]}const f=this.pixelRatio;this.instructions.push([6,a,i,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,p==e0?e0:p.map(function(t){return t*f}),h,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,r]);const g=1/f,m=h?h.slice(0):null;m&&(m[1]=ZQ),this.hitDetectionInstructions.push([6,a,i,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[g,g],NaN,this.declutterMode_,this.declutterImageWithText_,p,m,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ZQ:this.fillKey_,this.textOffsetX_,this.textOffsetY_,r]),this.endGeometry(e)}else{const r=t.getExtent();if(!wG(this.maxExtent,r))return;let i;if(c=t.getFlatCoordinates(),"LineString"==l)i=[c.length];else if("MultiLineString"==l)i=t.getEnds();else if("Polygon"==l)i=t.getEnds().slice(0,1);else if("MultiPolygon"==l){const e=t.getEndss();i=[];for(let t=0,n=e.length;t0?l:2*Math.PI-l}([t,e],[n,r],[i,s]);if(Math.cos(d)>.998)return[t+u*o,e+h*o];const p=Math.cos(d/2),f=Math.sin(d/2);return[t+1/f*(f*a+p*l)*o,e+1/f*(-p*a+f*l)*o]}function z1(t,e,n=!1){for(let r=0,i=t.length-2;rr+e;s-=e){const n=t[r],i=t[r+1],o=t[r+e],a=t[r+e+1],l=t[s],c=t[s+1],u=t[s+e],h=t[s+e+1],d=(h-c)*(o-n)-(u-l)*(a-i);if(0===d)continue;const p=((u-l)*(i-c)-(h-c)*(n-l))/d,f=((o-n)*(i-c)-(a-i)*(n-l))/d;if(p>0&&p<1&&f>0&&f<1){const l=n+p*(o-n),c=i+p*(a-i);t[r+e]=l,t[r+e+1]=c,t.splice(r+2*e,s-r-e);break}}return t}function D1(t,e,n,r,i,s,o,a,l,c,u,h,d=!0){let p=t[e],f=t[e+1],g=0,m=0,y=0,v=0;function b(){g=p,m=f,p=t[e+=r],f=t[e+1],v+=y,y=Math.sqrt((p-g)*(p-g)+(f-m)*(f-m))}do{b()}while(et[2]}else T=_>E;const L=Math.PI,P=[],I=C+r===e;let M;if(y=0,v=k,p=t[e=C],f=t[e+1],I)return b(),M=Math.atan2(f-m,p-g),T&&(M+=M>0?-L:L),P[0]=[(E+_)/2,(R+x)/2,(S-s)/2,M,i],P;i=i.replace(/\n/g," ");const A=Array.from((I1||(I1=new Intl.Segmenter(void 0,{granularity:"grapheme"})),I1).segment(i),t=>t.segment);for(let O=0,F=A.length;O0?-L:L),void 0!==M){let e=t-M;if(e+=e>L?-2*L:e<-L?2*L:0,Math.abs(e)>o)return null}M=t;const i=O;let h=0;for(;O{if("function"==typeof t[e])return this.pendingMethod_=e,this.pushMethodArgs_},set:(t,e,n)=>(this.push_(e,n),!0)})}push_(...t){const e=this.instructions_,n=this.zIndex+this.offset_;e[n]||(e[n]=[]),e[n].push(...t)}pushMethodArgs_=(...t)=>{this.push_(this.pendingMethod_,t)};pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let n=0,r=e.length;n0&&t.push("\n",""),t.push(e,""),t}function Z1(t,e,n){return n%2==0&&(t+=e),t}var Y1=class{constructor(t,e,n,r,i){this.overlaps=n,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=ZK(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=i?new j1:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,n,r){const i=t+e+n+r;if(this.labels_[i])return this.labels_[i];const s=r?this.strokeStates[r]:null,o=n?this.fillStates[n]:null,a=this.textStates[e],l=this.pixelRatio,c=[a.scale[0]*l,a.scale[1]*l],u=a.justify?M1[a.justify]:G1(Array.isArray(t)?t[0]:t,a.textAlign||"center"),h=r&&s.lineWidth?s.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(K1,[]),{width:p,height:f,widths:g,heights:m,lineWidths:y}=function(t,e){const n=[],r=[],i=[];let s=0,o=0,a=0,l=0;for(let c=0,u=e.length;c<=u;c+=2){const h=e[c];if("\n"===h||c===u){s=Math.max(s,o),i.push(o),o=0,a+=l,l=0;continue}const d=e[c+1]||t.font,p=u0(d,h);n.push(p),o+=p;const f=l0(d);r.push(f),l=Math.max(l,f)}return{width:s,height:a,widths:n,heights:r,lineWidths:i}}(a,d),v=p+h,b=[],w=(v+2)*c[0],_=(f+h)*c[1],x={width:w<0?Math.floor(w):Math.ceil(w),height:_<0?Math.floor(_):Math.ceil(_),contextInstructions:b};1==c[0]&&1==c[1]||b.push("scale",c),r&&(b.push("strokeStyle",s.strokeStyle),b.push("lineWidth",h),b.push("lineCap",s.lineCap),b.push("lineJoin",s.lineJoin),b.push("miterLimit",s.miterLimit),b.push("setLineDash",[s.lineDash]),b.push("lineDashOffset",s.lineDashOffset)),n&&b.push("fillStyle",o.fillStyle),b.push("textBaseline","middle"),b.push("textAlign","center");const C=.5-u;let k=u*v+C*h;const S=[],E=[];let R,T=0,L=0,P=0,I=0;for(let M=0,A=d.length;Mt?t-l:i,b=s+c>e?e-c:s,w=p[3]+v*h[0]+p[1],_=p[0]+b*h[1]+p[2],x=m-p[3],C=y-p[0];let k;return(f||0!==u)&&(B1[0]=x,V1[0]=x,B1[1]=C,$1[1]=C,$1[0]=x+w,q1[0]=$1[0],q1[1]=C+_,V1[1]=q1[1]),0!==u?(k=eZ(ZK(),n,r,1,1,u,-n,-r),QK(k,B1),QK(k,$1),QK(k,q1),QK(k,V1),XH(Math.min(B1[0],$1[0],q1[0],V1[0]),Math.min(B1[1],$1[1],q1[1],V1[1]),Math.max(B1[0],$1[0],q1[0],V1[0]),Math.max(B1[1],$1[1],q1[1],V1[1]),U1)):XH(Math.min(x,x+w),Math.min(C,C+_),Math.max(x,x+w),Math.max(C,C+_),U1),d&&(m=Math.round(m),y=Math.round(y)),{drawImageX:m,drawImageY:y,drawImageW:v,drawImageH:b,originX:l,originY:c,declutterBox:{minX:U1[0],minY:U1[1],maxX:U1[2],maxY:U1[3],value:g},canvasTransform:k,scale:h}}replayImageOrLabel_(t,e,n,r,i,s,o){const a=!(!s&&!o),l=r.declutterBox,c=o?o[2]*r.scale[0]/2:0;return l.minX-c<=e[0]&&l.maxX+c>=0&&l.minY-c<=e[1]&&l.maxY+c>=0&&(a&&this.replayTextBackground_(t,B1,$1,q1,V1,s,o),function(t,e,n,r,i,s,o,a,l,c,u){t.save(),1!==n&&(void 0===t.globalAlpha?t.globalAlpha=t=>t.globalAlpha*=n:t.globalAlpha*=n),e&&t.transform.apply(t,e),r.contextInstructions?(t.translate(l,c),t.scale(u[0],u[1]),function(t,e){const n=t.contextInstructions;for(let r=0,i=n.length;rN&&(this.fill_(t),P=0),I>N&&(t.stroke(),I=0),P||I||(t.beginPath(),_=NaN,x=NaN),++d;break;case 2:g=n[1],b=n[2]??0;const r=c[g],u=c[g+1],h=c[g+2]-b-r,p=c[g+3]-b-u,B=Math.sqrt(h*h+p*p);t.moveTo(r+B,u),t.arc(r,u,B,0,2*Math.PI,!0),++d;break;case 3:t.closePath(),++d;break;case 4:g=n[1],f=n[2];const $=n[3],q=n[4],V=n[5];F.geometry=$,F.feature=z,d in M||(M[d]=[]);const W=M[d];V?V(c,g,f,2,W):(W[0]=c[g],W[1]=c[g+1],W.length=2),l&&(l.zIndex=n[6]),q(W,F),++d;break;case 6:g=n[1],f=n[2],S=n[3],y=n[4],v=n[5];let H=n[6];const G=n[7],K=n[8],Z=n[9],Y=n[10];let X=n[11];const J=n[12];let Q=n[13];w=n[14]||"declutter";const tt=n[15];if(!S&&n.length>=20){E=n[19],R=n[20],T=n[21],L=n[22];const t=this.drawLabelWithPointPlacement_(E,R,T,L);S=t.label,n[3]=S;const e=n[23];y=(t.anchorX-e)*this.pixelRatio,n[4]=y;const r=n[24];v=(t.anchorY-r)*this.pixelRatio,n[5]=v,H=S.height,n[6]=H,Q=S.width,n[13]=Q}let et,nt,rt,it;n.length>25&&(et=n[25]),n.length>17?(nt=n[16],rt=n[17],it=n[18]):(nt=e0,rt=null,it=null),Y&&O?X+=A:Y||O||(X-=A);let st=0;for(;g!J1.includes(t)),t2=!1,e2=!1,n2=class{constructor(t,e,n,r,i,s,o){this.maxExtent_=t,this.overlaps_=r,this.pixelRatio_=n,this.resolution_=e,this.renderBuffer_=s,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=ZK(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(i,o)}clip(t,e){const n=this.getClipCoords(e);t.beginPath(),t.moveTo(n[0],n[1]),t.lineTo(n[2],n[3]),t.lineTo(n[4],n[5]),t.lineTo(n[6],n[7]),t.clip()}createExecutors_(t,e){for(const n in t){let r=this.executorsByZIndex_[n];void 0===r&&(r={},this.executorsByZIndex_[n]=r);const i=t[n];for(const t in i){const n=i[t];r[t]=new Y1(this.resolution_,this.pixelRatio_,this.overlaps_,n,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const n=this.executorsByZIndex_[e];for(let e=0,r=t.length;e{const n=gY(1,1,null,{willReadFrequently:e});let r=0;const i=performance.now();for(;performance.now()-i<50;++r)n.fillStyle=`rgba(255,0,${r%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return t=r>t?r:t,r};t2={[e(!0)]:!0,[e(!1)]:!1,[e(void 0)]:void 0}[t],e2=!0}();const o=2*(r=Math.round(r))+1,a=eZ(this.hitDetectionTransform_,r+.5,r+.5,1/e,-1/e,-n,-t[0],-t[1]),l=!this.hitDetectionContext_;l&&(this.hitDetectionContext_=gY(o,o,null,{willReadFrequently:t2}));const c=this.hitDetectionContext_;let u;c.canvas.width!==o||c.canvas.height!==o?(c.canvas.width=o,c.canvas.height=o):l||c.clearRect(0,0,o,o),void 0!==this.renderBuffer_&&(u=[1/0,1/0,-1/0,-1/0],rG(u,t),VH(u,e*(this.renderBuffer_+r),u));const h=function(t){if(void 0!==r2[t])return r2[t];const e=2*t+1,n=t*t,r=new Array(n+1);for(let s=0;s<=t;++s)for(let i=0;i<=t;++i){const o=s*s+i*i;if(o>n)break;let a=r[o];a||(a=[],r[o]=a),a.push(4*((t+s)*e+(t+i))+3),s>0&&a.push(4*((t-s)*e+(t+i))+3),i>0&&(a.push(4*((t+s)*e+(t-i))+3),s>0&&a.push(4*((t-s)*e+(t-i))+3))}const i=[];for(let s=0,o=r.length;s0){if(!s||"none"===n||"Image"!==d&&"Text"!==d||s.includes(t)){const n=(h[l]-3)/4,s=r-n%o,a=r-(n/o|0),c=i(t,e,s*s+a*a);if(c)return c}c.clearRect(0,0,o,o);break}}const f=Object.keys(this.executorsByZIndex_).map(Number);let g,m,y,v,b;for(f.sort(zW),g=f.length-1;g>=0;--g){const t=f[g].toString();for(y=this.executorsByZIndex_[t],m=X1.length-1;m>=0;--m)if(d=X1[m],v=y[d],void 0!==v&&(b=v.executeHitDetection(c,a,n,p,u),b))return b}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const n=e[0],r=e[1],i=e[2],s=e[3],o=[n,r,n,s,i,s,i,r];return sZ(o,0,8,2,t,o),o}isEmpty(){return SW(this.executorsByZIndex_)}execute(t,e,n,r,i,s,o){const a=Object.keys(this.executorsByZIndex_).map(Number);a.sort(o?DW:zW),s=s||X1;const l=X1.length;for(let c=0,u=a.length;cp.execute(t,e,n,r,i,o)):p.execute(h,e,n,r,i,o),d&&h.restore(),s){s.offset();const t=a[c]*l+X1.indexOf(u);this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(s)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(zW);for(let n=0,r=e.length;n{t.draw(this.renderedContext_),t.clear()}),t[e[n]].length=0}},r2={},i2=class extends v1{constructor(t,e,n,r,i,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=n,this.transform_=r,this.transformRotation_=r?zH(Math.atan2(r[1],r[0]),10):0,this.viewRotation_=i,this.squaredTolerance_=s,this.userTransform_=o,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=ZK()}drawImages_(t,e,n,r){if(!this.image_)return;const i=sZ(t,e,n,r,this.transform_,this.pixelCoordinates_),s=this.context_,o=this.tmpLocalTransform_,a=s.globalAlpha;1!=this.imageOpacity_&&(s.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;0===this.transformRotation_&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let c=0,u=i.length;c0){const t=a.length,e=i||Math.abs(a[0]-a[t-2])<1e-6&&Math.abs(a[1]-a[t-1])<1e-6;a=F1(a,0,t,2,s,e,a),z1(a,2,e)}o.moveTo(a[0],a[1]);let l=a.length;i&&(l-=2);for(let c=2;ct*this.pixelRatio_),lineDashOffset:(i||0)*this.pixelRatio_,lineJoin:void 0!==s?s:JQ,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:GQ(t||QQ),strokeOffset:(c??0)*this.pixelRatio_}}else this.strokeState_=null}setImageStyle(t){let e;if(!t||!(e=t.getSize()))return void(this.image_=null);const n=t.getPixelRatio(this.pixelRatio_),r=t.getAnchor(),i=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*n,this.imageAnchorY_=r[1]*n,this.imageHeight_=e[1]*n,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=i[0],this.imageOriginY_=i[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const s=t.getScaleArray();this.imageScale_=[s[0]*this.pixelRatio_/n,s[1]*this.pixelRatio_/n],this.imageWidth_=e[0]*n}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:GQ(t||ZQ)}}else this.textFillState_=null;const n=t.getStroke();if(n){const t=n.getColor(),e=n.getLineCap(),r=n.getLineDash(),i=n.getLineDashOffset(),s=n.getLineJoin(),o=n.getWidth(),a=n.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:YQ,lineDash:r||XQ,lineDashOffset:i||0,lineJoin:void 0!==s?s:JQ,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:10,strokeStyle:GQ(t||QQ)}}else this.textStrokeState_=null;const r=t.getFont(),i=t.getOffsetX(),s=t.getOffsetY(),o=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),h=t.getTextBaseline();this.textState_={font:void 0!==r?r:"10px sans-serif",textAlign:void 0!==u?u:t0,textBaseline:void 0!==h?h:"middle"},this.text_=void 0!==c?Array.isArray(c)?c.reduce((t,e,n)=>t+(n%2?" ":e),""):c:"",this.textOffsetX_=void 0!==i?this.pixelRatio_*i:0,this.textOffsetY_=void 0!==s?this.pixelRatio_*s:0,this.textRotateWithView_=void 0!==o&&o,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}},s2=.5;function o2(t,e,n,r,i,s,o,a,l){const c=i,u=gY(t[0]*s2,t[1]*s2);u.imageSmoothingEnabled=!1;const h=u.canvas,d=new i2(u,s2,i,null,o,a,l?jK(null,l):null),p=n.length,f=Math.floor(16777215/p),g={};for(let y=1;y<=p;++y){const t=n[y-1],e=t.getStyleFunction()||r;if(!e)continue;let i=e(t,s);if(!i)continue;Array.isArray(i)||(i=[i]);const o=(y*f).toString(16).padStart(7,"#00000");for(let n=0,r=i.length;n0;return h&&Promise.all(l).then(()=>i(null)),function(t,e,n,r,i,s,o){const a=n.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(r,i);n.getRenderer()?p2(t,l,n,e,o):(0,l2[l.getType()])(t,l,n,e,o,s)}(t,e,n,r,s,o,a),h}function p2(t,e,n,r,i){if("GeometryCollection"==e.getType()){const s=e.getGeometries();for(let e=0,o=s.length;ethis.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}updateStaleKeys(t){this.renderedSourceKey_?this.renderedSourceKey_!==t&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=t):this.renderedSourceKey_=t}getFeatures(t){return XW()}getData(t){return null}prepareFrame(t){return XW()}renderFrame(t,e){return XW()}forEachFeatureAtCoordinate(t,e,n,r,i){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;2!==e.getState()&&3!==e.getState()||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return 2!=e&&3!=e&&t.addEventListener(LW,this.boundHandleImageChange_),0==e&&(t.load(),e=t.getState()),2==e}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},g2=[],m2=null,y2=class extends f2{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=ZK(),this.pixelTransform=ZK(),this.inversePixelTransform=ZK(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,n){let r;m2||(m2=gY(1,1,void 0,{willReadFrequently:!0})),m2.clearRect(0,0,1,1);try{m2.drawImage(t,e,n,1,1,0,0,1,1),r=m2.getImageData(0,0,1,1).data}catch{return m2=null,null}return r}getBackground(t){let e=this.getLayer().getBackground();return"function"==typeof e&&(e=e(t.viewState.resolution)),e||void 0}useContainer(t,e,n,r,i){if(CY(t)&&0===this.pixelTransform[1]&&0===this.pixelTransform[2]&&0===this.pixelTransform[4]&&0===this.pixelTransform[5]&&t.width===r&&t.height===i){const e=t,r=e.getContext("2d");if(r)return this.container=t,this.context=r,this.containerReused=!0,void(n&&(r.fillStyle=n,r.fillRect(0,0,e.width,e.height)))}const s=this.getLayer().getClassName();let o,a;if(t&&t.className===s&&(!n||t&&t.style.backgroundColor&&$W(hJ(t.style.backgroundColor),hJ(n)))){const e=t.firstElementChild;CY(e)&&(a=e.getContext("2d"))}if(a&&function(t,e){const n=iZ(t),r=iZ(e);for(let i=0;i<6;++i)if(0!==Math.round((n[i]-r[i])*rZ[i]))return!1;return!0}(a.canvas.style.transform,e)?(this.container=t,this.context=a,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){o=dH?xY():document.createElement("div"),o.className=s;let t=o.style;t.position="absolute",t.width="100%",t.height="100%",a=gY();const e=a.canvas;o.appendChild(e),t=e.style,t.position="absolute",t.left="0",t.transformOrigin="top left",this.container=o,this.context=a}this.containerReused||!n||this.container.style.backgroundColor||(this.container.style.backgroundColor=n)}clipUnrotated(t,e,n){const r=yG(n),i=vG(n),s=cG(n),o=lG(n);QK(e.coordinateToPixelTransform,r),QK(e.coordinateToPixelTransform,i),QK(e.coordinateToPixelTransform,s),QK(e.coordinateToPixelTransform,o);const a=this.inversePixelTransform;QK(a,r),QK(a,i),QK(a,s),QK(a,o),t.save(),t.beginPath(),t.moveTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(i[0]),Math.round(i[1])),t.lineTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.clip()}prepareContainer(t,e){const n=t.extent,r=t.viewState.resolution,i=t.viewState.rotation,s=t.pixelRatio,o=Math.round(bG(n)/r*s),a=Math.round(fG(n)/r*s);eZ(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/s,1/s,i,-o/2,-a/2),nZ(this.inversePixelTransform,this.pixelTransform);const l="matrix("+this.pixelTransform.join(", ")+")",c=this.getBackground(t);if(this.useContainer(e,l,c,o,a),!this.containerReused){const t=this.context.canvas;t.width!=o||t.height!=a?(t.width=o,t.height=a):this.context.clearRect(0,0,o,a),l!==t.style.transform&&(t.style.transform=l)}}dispatchRenderEvent_(t,e,n){const r=this.getLayer();if(r.hasListener(t)){const i=new Y0(t,this.inversePixelTransform,n,e);r.dispatchEvent(i)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(CX,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(kX,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new j1),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(CX,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(kX,this.context,t))}getRenderTransform(t,e,n,r,i,s,o){const a=i/2,l=s/2,c=r/e,u=-c,h=-t[0]+o,d=-t[1];return eZ(this.tempTransform,a,l,c,u,-n,h,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}},v2=class extends y2{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=[1/0,1/0,-1/0,-1/0],this.wrappedRenderedExtent_=[1/0,1/0,-1/0,-1/0],this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,n){const r=e.extent,i=e.viewState,s=i.center,o=i.resolution,a=i.projection,l=i.rotation,c=a.getExtent(),u=this.getLayer().getSource(),h=this.getLayer().getDeclutter(),d=e.pixelRatio,p=e.viewHints,f=!(p[0]||p[1]),g=this.context,m=Math.round(bG(r)/o*d),y=Math.round(fG(r)/o*d),v=u.getWrapX()&&a.canWrapX(),b=v?bG(c):null,w=v?Math.ceil((r[2]-c[2])/b)+(this.extendX_?2:1):1;let _=v?Math.floor((r[0]-c[0])/b)-(this.extendX_?1:0):0;do{let r=this.getRenderTransform(s,o,0,d,m,y,_*b);e.declutter&&(r=r.slice(0)),t.execute(g,[g.canvas.width,g.canvas.height],r,l,f,void 0===n?X1:n?J1:Q1,n?h&&e.declutter[h]:void 0)}while(++_{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=this.frameState.size.slice(),e=this.renderedCenter_,n=this.renderedResolution_,r=this.renderedRotation_,i=this.renderedProjection_,s=this.wrappedRenderedExtent_,o=this.getLayer(),a=[],l=t[0]*s2,c=t[1]*s2;a.push(this.getRenderTransform(e,n,r,s2,l,c,0).slice());const u=o.getSource(),h=i.getExtent();if(u.getWrapX()&&i.canWrapX()&&!KH(h,s)){let t=s[0];const i=bG(h);let o,u=0;for(;th[2];)++u,o=i*u,a.push(this.getRenderTransform(e,n,r,s2,l,c,o).slice()),t-=i}const d=null;this.hitDetectionImageData_=o2(t,a,this.renderedFeatures_,o.getStyleFunction(),s,n,r,u2(n,this.renderedPixelRatio_),d?i:null)}e(a2(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,n,r,i){if(!this.replayGroup_)return;const s=e.viewState.resolution,o=e.viewState.rotation,a=this.getLayer(),l={},c=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,s,o,n,function(t,e,n){const s=QW(t),o=l[s];if(o){if(!0!==o&&nt.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),n=e.getSource();if(!n)return!1;const r=t.viewHints[0],i=t.viewHints[1],s=e.getUpdateWhileAnimating(),o=e.getUpdateWhileInteracting();if(this.ready&&!s&&r||!o&&i)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,l=t.viewState,c=l.projection,u=l.resolution,h=t.pixelRatio,d=e.getRevision(),p=e.getRenderBuffer();let f=e.getRenderOrder();void 0===f&&(f=c2);const g=l.center.slice(),m=VH(a,p*u),y=m.slice(),v=[m.slice()],b=c.getExtent(),w=n.getWrapX()&&c.canWrapX();if(this.extendX_=!1,w){const t=n.getExtent();t&&!_G(t)&&(this.extendX_=t[0]b[2])}if(w&&(!KH(b,t.extent)||this.extendX_)){const t=bG(b),e=Math.max(bG(m)/2,t);let n=b[0],r=b[2];this.extendX_&&(n-=t,r+=t),m[0]=n-e,m[2]=r+e,TG(g,c);const i=CG(v[0],c);i[0]b[0]&&i[2]>b[2]&&v.push([i[0]-t,i[1],i[2]-t,i[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===h&&this.renderedRevision_==d&&this.renderedRenderOrder_==f&&this.renderedFrameDeclutter_===!!t.declutter&&KH(this.wrappedRenderedExtent_,m))return $W(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=g,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const _=new O1(h2(u,h),m,u,h);for(let L=0,P=v.length;L{let r;const i=t.getStyleFunction()||e.getStyleFunction();if(i&&(r=i(t,u)),r){const e=this.renderFeature(t,x,r,_,undefined,this.getLayer().getDeclutter(),n);C=C&&!e}},S=m,E=n.getFeaturesInExtent(S);f&&E.sort(f);for(let L=0,P=E.length;L=200&&a.status<300){const t=e.getType();try{let r;"text"==t||"json"==t?r=a.responseText:"xml"==t?r=a.responseXML||a.responseText:"arraybuffer"==t&&(r=a.response),r?s(e.readFeatures(r,{extent:n,featureProjection:i}),e.readProjection(r)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function _2(t,e){return function(n,r,i,s,o){w2(t,e,n,r,i,t=>{this.addFeatures(t),void 0!==s&&s(t)},()=>{this.changed(),void 0!==o&&o()})}}function x2(){return[[-1/0,-1/0,1/0,1/0]]}function C2(t){return[t]}var k2=ZK(),S2=class t{constructor(t,e,n,r,i,s){this.styleFunction,this.extent_,this.id_=s,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=n||null,this.properties_=i,this.squaredTolerance_,this.stride_=r,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_="Point"===this.type_?QH(this.flatCoordinates_):tG(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=uG(this.getExtent());this.flatInteriorPoints_=UZ(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=KZ(this.flatCoordinates_,this.ends_),e=m1(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=BZ(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=u1(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const n=this.ends_;for(let r=0,i=n.length;r{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),n&&this.simplifiedGeometry_.applyTransform(n);const r=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":r.length=AZ(r,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,r,0),i=[r.length];break;case"MultiLineString":i=[],r.length=OZ(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,r,0,i);break;case"Polygon":i=[],r.length=zZ(r,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),r,0,i)}return i&&(this.simplifiedGeometry_=new t(this.type_,r,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};S2.prototype.getFlatCoordinates=S2.prototype.getOrientedFlatCoordinates;var E2=class{constructor(t){this.rbush_=new MX(t),this.items_={}}insert(t,e){const n={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(n),this.items_[QW(e)]=n}load(t,e){const n=new Array(e.length);for(let r=0,i=e.length;r{const n=()=>{const r=this.getState();"ready"===r?(this.un("change",n),t()):"error"===r&&(this.un("change",n),e(new Error("Source failed to load")))};this.on("change",n)})}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=T2(t),this.changed()}setState(t){this.state_=t,this.changed()}};function T2(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),()=>t):null}var L2="addfeature",P2="removefeature",I2=class extends KW{constructor(t,e,n){super(t),this.feature=e,this.features=n}},M2=class extends R2{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===t.wrapX||t.wrapX}),this.on,this.once,this.un,this.loader_=WW,this.format_=t.format||null,this.overlaps_=void 0===t.overlaps||t.overlaps,this.url_=t.url,void 0!==t.loader?this.loader_=t.loader:void 0!==this.url_&&(SH(this.format_,"`format` must be set when `url` is set"),this.loader_=_2(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:x2;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let n,r;this.featuresRtree_=e?new E2:null,this.loadedExtentsRtree_=new E2,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(t.features)?r=t.features:t.features&&(n=t.features,r=n.getArray()),e||void 0!==n||(n=new iH(r)),void 0!==r&&this.addFeaturesInternal(r),void 0!==n&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=QW(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const n=t.getGeometry();if(n){const e=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new I2(L2,t))}setupChangeEvents_(t,e){e instanceof S2||(this.featureChangeKeys_[t]=[EW(e,LW,this.handleFeatureChange_,this),EW(e,CW,this.handleFeatureChange_,this)])}addToIndex_(t,e){let n=!0;if(void 0!==e.getId()){const t=String(e.getId());if(t in this.idIndex_)if(e instanceof S2){const r=this.idIndex_[t];r instanceof S2?Array.isArray(r)?r.push(e):this.idIndex_[t]=[r,e]:n=!1}else n=!1;else this.idIndex_[t]=e}return n&&(SH(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),n}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],n=[],r=[];for(let i=0,s=t.length;i{e||(e=!0,this.addFeature(t.element),e=!1)}),t.addEventListener(xW,t=>{e||(e=!0,this.removeFeature(t.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_)this.featureChangeKeys_[t].forEach(TW);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(t=>{this.removeFeatureInternal(t)});for(const t in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[t])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new I2("clear");this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const n=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(n,function(n){const r=n.getGeometry();if(r instanceof S2||r.intersectsCoordinate(t))return e(n)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(n){const r=n.getGeometry();if(r instanceof S2||r.intersectsExtent(t)){const t=e(n);if(t)return t}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),SW(this.nullGeometryFeatures_)||BW(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(t){e.push(t)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const n=kG(t,e);return[].concat(...n.map(t=>this.featuresRtree_.getInExtent(t)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const n=t[0],r=t[1];let i=null;const s=[NaN,NaN];let o=1/0;const a=[-1/0,-1/0,1/0,1/0];return e=e||qW,this.featuresRtree_.forEachInExtent(a,function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e instanceof S2?0:e.closestPointXY(n,r,s,o),o{this.loading=Number(this.loading)-1,this.dispatchEvent(new I2("featuresloadend",void 0,t))},s=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new I2("featuresloaderror"))};let o=!1;const a=this.loader_.call(this,t,e,n,t=>o||i(t),()=>o||s());a instanceof Promise?(o=!0,a.then(t=>{this.addFeatures(t),i(t)}).catch(s)):this.loader_.length<4&&(this.loading=!1),r.insert(t,{extent:t.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,n=[];e.forEachInExtent(t,function(t){n.push(t)}),n.forEach(n=>{e.remove(n);const r=mG(n.extent,t);for(const t of r)e.insert(t,{extent:t})})}removeFeatures(t){let e=!1;for(let n=0,r=t.length;nt.clone())}var F2=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=c1,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?MK(e.dataProjection):this.readProjection(t);e.extent&&n&&"tile-pixels"===n.getUnits()&&(n=MK(n),n.setWorldExtent(e.extent)),e={dataProjection:n,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return XW()}readFeature(t,e){return XW()}readFeatures(t,e){return XW()}readGeometry(t,e){return XW()}readProjection(t){return XW()}writeFeature(t,e){return XW()}writeFeatures(t,e){return XW()}writeGeometry(t,e){return XW()}};function N2(t,e,n){const r=n?MK(n.featureProjection):null,i=n?MK(n.dataProjection):null;let s=t;if(r&&i&&!DK(r,i)){e&&(s=t.clone());const n=e?r:i,o=e?i:r;"tile-pixels"===n.getUnits()?s.transform(n,o):s.applyTransform(BK(n,o))}if(e&&n&&void 0!==n.decimals){const e=Math.pow(10,n.decimals),r=function(t){for(let n=0,r=t.length;nD2({...t,geometry:e})).flat();const r="MultiPolygon"===n.type?"Polygon":n.type;if("GeometryCollection"===r||"Circle"===r)throw new Error("Unsupported geometry type: "+r);const i=n.layout.length;return N2(new S2(r,"Polygon"===r?function(t,e,n){return Array.isArray(e[0])?(WZ(t,0,e,n)||GZ(t=t.slice(),0,e,n),t):(VZ(t,0,e,n)||HZ(t=t.slice(),0,e,n),t)}(n.flatCoordinates,n.ends,i):n.flatCoordinates,n.ends?.flat(),i,t.properties||{},t.id).enableSimplifyTransformed(),!1,e)}function j2(t,e){if(!t)return null;if(Array.isArray(t)){const n=t.map(t=>j2(t,e));return new A2(n)}return N2(new(0,z2[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}var U2=class extends F2{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(B2(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(B2(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return XW()}readFeaturesFromObject(t,e){return XW()}readGeometry(t,e){return this.readGeometryFromObject(B2(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return XW()}readProjection(t){return this.readProjectionFromObject(B2(t))}readProjectionFromObject(t){return XW()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return XW()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return XW()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return XW()}};function B2(t){return"string"==typeof t?JSON.parse(t)||null:null!==t?t:null}var $2=class extends U2{constructor(t){t=t||{},super(),this.dataProjection=MK(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=MK(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let n=null;n="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const r=q2(n.geometry);if(this.featureClass===S2)return D2({geometry:r,id:n.id,properties:n.properties},e);const i=new(0,this.featureClass);return this.geometryName_?i.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&i.setGeometryName(n.geometry_name),i.setGeometry(j2(r,e)),"id"in n&&i.setId(n.id),n.properties&&i.setProperties(n.properties,!0),i}readFeaturesFromObject(t,e){let n=null;if("FeatureCollection"===t.type){n=[];const r=t.features;for(let t=0,i=r.length;t":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}},i3=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function s3(t,e){const n={};for(const r in t)"ref"!==r&&(n[r]=t[r]);return i3.forEach(t=>{t in e&&(n[t]=e[t])}),n}function o3(t){t=t.slice();const e=Object.create(null);for(let n=0;n`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}var T3=[h3,d3,p3,f3,g3,m3,w3,y3,E3(v3),_3,C3,x3,k3,S3];function L3(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!L3(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of T3)if(!L3(t,e))return null}return`Expected ${R3(t)} but found ${R3(e)} instead.`}function P3(t,e){return e.some(e=>e.kind===t.kind)}function I3(t,e){return e.some(e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t)}function M3(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}var A3=.96422,O3=.82521,F3=4/29,N3=6/29,z3=3*N3*N3,D3=N3*N3*N3,j3=Math.PI/180,U3=180/Math.PI;function B3(t){return(t%=360)<0&&(t+=360),t}function $3([t,e,n,r]){let i,s;const o=V3((.2225045*(t=q3(t))+.7168786*(e=q3(e))+.0606169*(n=q3(n)))/1);t===e&&e===n?i=s=o:(i=V3((.4360747*t+.3850649*e+.1430804*n)/A3),s=V3((.0139322*t+.0971045*e+.7141733*n)/O3));const a=116*o-16;return[a<0?0:a,500*(i-o),200*(o-s),r]}function q3(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function V3(t){return t>D3?Math.pow(t,1/3):t/z3+F3}function W3([t,e,n,r]){let i=(t+16)/116,s=isNaN(e)?i:i+e/500,o=isNaN(n)?i:i-n/200;return i=1*G3(i),s=A3*G3(s),o=O3*G3(o),[H3(3.1338561*s-1.6168667*i-.4906146*o),H3(-.9787684*s+1.9161415*i+.033454*o),H3(.0719453*s-.2289914*i+1.4052427*o),r]}function H3(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function G3(t){return t>N3?t*t*t:z3*(t-F3)}var K3=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function Z3(t,e){return K3(t,e)?t[e]:void 0}function Y3(t){return parseInt(t.padEnd(2,t),16)/255}function X3(t,e){return J3(e?t/100:t,0,1)}function J3(t,e,n){return Math.min(Math.max(e,t),n)}function Q3(t){return!t.some(Number.isNaN)}var t5={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function e5(t,e,n){return t+n*(e-t)}function n5(t,e,n){return t.map((t,r)=>e5(t,e[r],n))}var r5=class t{constructor(t,e,n,r=1,i=!0){this.r=t,this.g=e,this.b=n,this.a=r,i||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,n,r]))}static{this.black=new t(0,0,0,1)}static{this.white=new t(1,1,1,1)}static{this.transparent=new t(0,0,0,0)}static{this.red=new t(1,0,0,1)}static parse(e){if(e instanceof t)return e;if("string"!=typeof e)return;const n=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=Z3(t5,t);if(e){const[t,n,r]=e;return[t/255,n/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let n=1;return[Y3(t.slice(n,n+=e)),Y3(t.slice(n,n+=e)),Y3(t.slice(n,n+=e)),Y3(t.slice(n,n+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,n,r,i,s,o,a,l,c,u,h,d]=e,p=[i||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const t=[r,o,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[J3(+n/e,0,1),J3(+s/e,0,1),J3(+l/e,0,1),h?X3(+h,d):1];if(Q3(t))return t}}return}}const n=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){const[t,e,r,i,s,o,a,l,c]=n,u=[r||" ",s||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const t=[+e,J3(+i,0,100),J3(+o,0,100),l?X3(+l,c):1];if(Q3(t))return function([t,e,n,r]){function i(r){const i=(r+t/30)%12,s=e*Math.min(n,1-n);return n-s*Math.max(-1,Math.min(i-3,9-i,1))}return t=B3(t),e/=100,n/=100,[i(0),i(8),i(4),r]}(t)}}}(e);return n?new t(...n,!1):void 0}get rgb(){const{r:t,g:e,b:n,a:r}=this,i=r||1/0;return this.overwriteGetter("rgb",[t/i,e/i,n/i,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,n,r,i]=$3(t),s=Math.sqrt(n*n+r*r);return[Math.round(1e4*s)?B3(Math.atan2(r,n)*U3):NaN,s,e,i]}(this.rgb))}get lab(){return this.overwriteGetter("lab",$3(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,n,r]=this.rgb;return`rgba(${[t,e,n].map(t=>Math.round(255*t)).join(",")},${r})`}static interpolate(e,n,r,i="rgb"){switch(i){case"rgb":{const[i,s,o,a]=n5(e.rgb,n.rgb,r);return new t(i,s,o,a,!1)}case"hcl":{const[i,s,o,a]=e.hcl,[l,c,u,h]=n.hcl;let d,p;if(isNaN(i)||isNaN(l))isNaN(i)?isNaN(l)?d=NaN:(d=l,1!==o&&0!==o||(p=c)):(d=i,1!==u&&0!==u||(p=s));else{let t=l-i;l>i&&t>180?t-=360:l180&&(t+=360),d=i+r*t}const[f,g,m,y]=function([t,e,n,r]){return t=isNaN(t)?0:t*j3,W3([n,Math.cos(t)*e,Math.sin(t)*e,r])}([d,p??e5(s,c,r),e5(o,u,r),e5(a,h,r)]);return new t(f,g,m,y,!1)}case"lab":{const[i,s,o,a]=W3(n5(e.lab,n.lab,r));return new t(i,s,o,a,!1)}}}},i5=class{constructor(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}},s5=["bottom","center","top"],o5=class{constructor(t,e,n,r,i,s){this.text=t,this.image=e,this.scale=n,this.fontStack=r,this.textColor=i,this.verticalAlign=s}},a5=class t{constructor(t){this.sections=t}static fromString(e){return new t([new o5(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(t=>0!==t.text.length||t.image&&0!==t.image.name.length)}static factory(e){return e instanceof t?e:t.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(t=>t.text).join("")}},l5=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,n,r){return new t(n5(e.values,n.values,r))}},c5=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,n,r){return new t(n5(e.values,n.values,r))}},u5=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("string"==typeof e){const n=r5.parse(e);if(!n)return;return new t([n])}if(!Array.isArray(e))return;const n=[];for(const t of e){if("string"!=typeof t)return;const e=r5.parse(t);if(!e)return;n.push(e)}return new t(n)}toString(){return JSON.stringify(this.values)}static interpolate(e,n,r,i="rgb"){const s=[];if(e.values.length!=n.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${n.values.length}), cannot interpolate.`);for(let t=0;t=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function y5(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof g5||t instanceof r5||t instanceof i5||t instanceof a5||t instanceof l5||t instanceof c5||t instanceof u5||t instanceof p5||t instanceof f5)return!0;if(Array.isArray(t)){for(const e of t)if(!y5(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!y5(t[e]))return!1;return!0}return!1}function v5(t){if(null===t)return h3;if("string"==typeof t)return p3;if("boolean"==typeof t)return f3;if("number"==typeof t)return d3;if(t instanceof r5)return g3;if(t instanceof g5)return m3;if(t instanceof i5)return b3;if(t instanceof a5)return w3;if(t instanceof l5)return _3;if(t instanceof c5)return C3;if(t instanceof u5)return x3;if(t instanceof p5)return S3;if(t instanceof f5)return k3;if(Array.isArray(t)){const e=t.length;let n;for(const r of t){const t=v5(r);if(n){if(n===t)continue;n=v3;break}n=t}return E3(n||v3,e)}return y3}function b5(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof r5||t instanceof g5||t instanceof a5||t instanceof l5||t instanceof c5||t instanceof u5||t instanceof p5||t instanceof f5?t.toString():JSON.stringify(t)}var w5=class t{constructor(t,e){this.type=t,this.value=e}static parse(e,n){if(2!==e.length)return n.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!y5(e[1]))return n.error("invalid value");const r=e[1];let i=v5(r);const s=n.expectedType;return"array"!==i.kind||0!==i.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(i=s),new t(i,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}},_5={string:p3,number:d3,boolean:f3,object:y3},x5=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");let r,i=1;const s=e[0];if("array"===s){let t,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in _5)||"object"===r)return n.error('The item type argument of "array" must be one of string, number, boolean',1);t=_5[r],i++}else t=v3;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return n.error('The length argument to "array" must be a positive integer literal',2);s=e[2],i++}r=E3(t,s)}else{if(!_5[s])throw new Error(`Types doesn't contain name = ${s}`);r=_5[s]}const o=[];for(;it.outputDefined())}},C5={"to-boolean":f3,"to-color":g3,"to-number":d3,"to-string":p3},k5=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");const r=e[0];if(!C5[r])throw new Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return n.error("Expected one argument.");const i=C5[r],s=[];for(let t=1;t4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:m5(e[0],e[1],e[2],e[3]),!n))return new r5(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new h5(n||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const n of this.args){e=n.evaluate(t);const r=l5.parse(e);if(r)return r}throw new h5(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"numberArray":{let e;for(const n of this.args){e=n.evaluate(t);const r=c5.parse(e);if(r)return r}throw new h5(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"colorArray":{let e;for(const n of this.args){e=n.evaluate(t);const r=u5.parse(e);if(r)return r}throw new h5(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const n of this.args){e=n.evaluate(t);const r=p5.parse(e);if(r)return r}throw new h5(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const n of this.args){if(e=n.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new h5(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return a5.fromString(b5(this.args[0].evaluate(t)));case"resolvedImage":return f5.fromString(b5(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return b5(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}},S5=["Unknown","Point","LineString","Polygon"],E5=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?S5[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=r5.parse(t),this._parseColorCache.set(t,e)),e}},R5=class t{constructor(t,e,n=[],r,i=new u3,s=[]){this.registry=t,this.path=n,this.key=n.map(t=>`[${t}]`).join(""),this.scope=i,this.errors=s,this.expectedType=r,this._isConstant=e}parse(t,e,n,r,i={}){return e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)}_parse(t,e){function n(t,e,n){return"assert"===n?new x5(e,[t]):"coerce"===n?new k5(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const i=t[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[i];if(s){let i=s.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,r=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==r.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===t.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(r.kind))i=n(i,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,r))return null}else i=n(i,t,e.typeAnnotation||"assert")}if(!(i instanceof w5)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){const t=new E5;try{i=new w5(i.type,i.evaluate(t))}catch(r){return this.error(r.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof t} instead.`)}concat(e,n,r){const i="number"==typeof e?this.path.concat(e):this.path,s=r?this.scope.concat(r):this.scope;return new t(this.registry,this._isConstant,i,n||null,s,this.errors)}error(t,...e){const n=`${this.key}${e.map(t=>`[${t}]`).join("")}`;this.errors.push(new c3(n,t))}checkSubtype(t,e){const n=L3(t,e);return n&&this.error(n),n}},T5=class t{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(e,n){if(e.length<4)return n.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let t=1;te))throw new h5("Input is not a number.");o=a-1}return 0}var I5=class t{constructor(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[r,i]of n)this.labels.push(r),this.outputs.push(i)}static parse(e,n){if(e.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return n.error("Expected an even number of arguments.");const r=n.parse(e[1],1,d3);if(!r)return null;const i=[];let s=null;n.expectedType&&"value"!==n.expectedType.kind&&(s=n.expectedType);for(let t=1;t=r)return n.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=n.parse(o,l,s);if(!c)return null;s=s||c.type,i.push([r,c])}return new t(s,r,i)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);const i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[P5(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}},M5=class t{constructor(t,e,n,r,i){this.type=t,this.operator=e,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[s,o]of i)this.labels.push(s),this.outputs.push(o)}static interpolationFactor(t,e,n,r){let i=0;if("exponential"===t.name)i=A5(e,t.base,n,r);else if("linear"===t.name)i=A5(e,1,n,r);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=function(t,e,n,r){const i=3*t,s=3*(n-t)-i,o=1-i-s,a=3*e,l=3*(r-e)-a,c=1-a-l;return function(t,e=1e-6){if(t<=0)return 0;if(t>=1)return 1;let n=t;for(let h=0;h<8;h++){const r=((o*n+s)*n+i)*n-t;if(Math.abs(r)a?r=n:u=n,n=.5*(r+u)}return((c*n+l)*n+a)*n}}(s[0],s[1],s[2],s[3])(A5(e,1,n,r))}return i}static parse(e,n){let[r,i,s,...o]=e;if(!Array.isArray(i)||0===i.length)return n.error("Expected an interpolation type expression.",1);if("linear"===i[0])i={name:"linear"};else if("exponential"===i[0]){const t=i[1];if("number"!=typeof t)return n.error("Exponential interpolation requires a numeric base.",1,1);i={name:"exponential",base:t}}else{if("cubic-bezier"!==i[0])return n.error(`Unknown interpolation type ${String(i[0])}`,1,0);{const t=i.slice(1);if(4!==t.length||t.some(t=>"number"!=typeof t||t<0||t>1))return n.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);i={name:"cubic-bezier",controlPoints:t}}}if(e.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return n.error("Expected an even number of arguments.");if(s=n.parse(s,2,d3),!s)return null;const a=[];let l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||n.expectedType==x3?n.expectedType&&"value"!==n.expectedType.kind&&(l=n.expectedType):l=g3;for(let t=0;t=e)return n.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const c=n.parse(r,s,l);if(!c)return null;l=l||c.type,a.push([e,c])}return M3(l,d3)||M3(l,m3)||M3(l,g3)||M3(l,_3)||M3(l,C3)||M3(l,x3)||M3(l,S3)||M3(l,E3(d3))?new t(l,r,i,s,a):n.error(`Type ${R3(l)} is not interpolatable.`)}evaluate(e){const n=this.labels,r=this.outputs;if(1===n.length)return r[0].evaluate(e);const i=this.input.evaluate(e);if(i<=n[0])return r[0].evaluate(e);const s=n.length;if(i>=n[s-1])return r[s-1].evaluate(e);const o=P5(n,i),a=n[o],l=n[o+1],c=t.interpolationFactor(this.interpolation,i,a,l),u=r[o].evaluate(e),h=r[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return e5(u,h,c);case"color":return r5.interpolate(u,h,c);case"padding":return l5.interpolate(u,h,c);case"colorArray":return u5.interpolate(u,h,c);case"numberArray":return c5.interpolate(u,h,c);case"variableAnchorOffsetCollection":return p5.interpolate(u,h,c);case"array":return n5(u,h,c);case"projectionDefinition":return g5.interpolate(u,h,c)}case"interpolate-hcl":switch(this.type.kind){case"color":return r5.interpolate(u,h,c,"hcl");case"colorArray":return u5.interpolate(u,h,c,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return r5.interpolate(u,h,c,"lab");case"colorArray":return u5.interpolate(u,h,c,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function A5(t,e,n,r){const i=r-n,s=t-n;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}r5.interpolate,l5.interpolate,c5.interpolate,u5.interpolate,p5.interpolate;var O5=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");let r=null;const i=n.expectedType;i&&"value"!==i.kind&&(r=i);const s=[];for(const t of e.slice(1)){const e=n.parse(t,1+s.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r=r||e.type,s.push(e)}if(!r)throw new Error("No output type");return i&&s.some(t=>L3(i,t.type))?new t(v3,s):new t(r,s)}evaluate(t){let e,n=null,r=0;for(const i of this.args)if(r++,n=i.evaluate(t),n&&n instanceof f5&&!n.available&&(e||(e=n.name),n=null,r===this.args.length&&(n=e)),null!==n)break;return n}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function F5(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function N5(t,e,n,r){return 0===r.compare(e,n)}function z5(t,e,n){const r="=="!==t&&"!="!==t;return class i{constructor(t,e,n){this.type=f3,this.lhs=t,this.rhs=e,this.collator=n,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const n=t[0];let s=e.parse(t[1],1,v3);if(!s)return null;if(!F5(n,s.type))return e.concat(1).error(`"${n}" comparisons are not supported for type '${R3(s.type)}'.`);let o=e.parse(t[2],2,v3);if(!o)return null;if(!F5(n,o.type))return e.concat(2).error(`"${n}" comparisons are not supported for type '${R3(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${R3(s.type)}' and '${R3(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new x5(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new x5(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,b3),!a)return null}return new i(s,o,a)}evaluate(i){const s=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const e=v5(s),n=v5(o);if(e.kind!==n.kind||"string"!==e.kind&&"number"!==e.kind)throw new h5(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=v5(s),n=v5(o);if("string"!==t.kind||"string"!==n.kind)return e(i,s,o)}return this.collator?n(i,s,o,this.collator.evaluate(i)):e(i,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}var D5=z5("==",function(t,e,n){return e===n},N5),j5=z5("!=",function(t,e,n){return e!==n},function(t,e,n,r){return!N5(0,e,n,r)}),U5=z5("<",function(t,e,n){return e",function(t,e,n){return e>n},function(t,e,n,r){return r.compare(e,n)>0}),$5=z5("<=",function(t,e,n){return e<=n},function(t,e,n,r){return r.compare(e,n)<=0}),q5=z5(">=",function(t,e,n){return e>=n},function(t,e,n,r){return r.compare(e,n)>=0}),V5=class t{constructor(t,e,n){this.type=b3,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e}static parse(e,n){if(2!==e.length)return n.error("Expected one argument.");const r=e[1];if("object"!=typeof r||Array.isArray(r))return n.error("Collator options argument must be an object.");const i=n.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,f3);if(!i)return null;const s=n.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,f3);if(!s)return null;let o=null;return r.locale&&(o=n.parse(r.locale,1,p3),!o)?null:new t(i,s,o)}evaluate(t){return new i5(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}},W5=8192;function H5(t,e){const n=(180+t[0])/360,r=(i=t[1],(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360);var i;const s=Math.pow(2,e.z);return[Math.round(n*s*W5),Math.round(r*s*W5)]}function G5(t,e){const n=Math.pow(2,e.z);return[(i=(t[0]/W5+e.x)/n,360*i-180),(r=(t[1]/W5+e.y)/n,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,i}function K5(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Z5(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Y5(t,e,n){return e[1]>t[1]!=n[1]>t[1]&&t[0]<(n[0]-e[0])*(t[1]-e[1])/(n[1]-e[1])+e[0]}function X5(t,e,n){const r=t[0]-e[0],i=t[1]-e[1],s=t[0]-n[0],o=t[1]-n[1];return r*o-s*i===0&&r*s<=0&&i*o<=0}function J5(t,e,n,r){const i=[e[0]-t[0],e[1]-t[1]];return 0!==function(t,e){return t[0]*e[1]-t[1]*e[0]}([r[0]-n[0],r[1]-n[1]],i)&&!(!i4(t,e,n,r)||!i4(n,r,t,e))}function Q5(t,e,n){for(const r of n)for(let n=0;n0&&h<0||u<0&&h>0}function s4(t,e,n){const r=[];for(let i=0;in[2]){const e=.5*r;let i=t[0]-n[0]>e?-r:n[0]-t[0]>e?r:0;0===i&&(i=t[0]-n[2]>e?-r:n[2]-t[0]>e?r:0),t[0]+=i}K5(e,t)}function l4(t,e,n,r){const i=Math.pow(2,r.z)*W5,s=[r.x*W5,r.y*W5],o=[];for(const a of t)for(const t of a){const r=[t.x+s[0],t.y+s[1]];a4(r,e,n,i),o.push(r)}return o}function c4(t,e,n,r){const i=Math.pow(2,r.z)*W5,s=[r.x*W5,r.y*W5],o=[];for(const a of t){const t=[];for(const n of a){const r=[n.x+s[0],n.y+s[1]];K5(e,r),t.push(r)}o.push(t)}if(e[2]-e[0]<=i/2){!function(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}(e);for(const t of o)for(const r of t)a4(r,e,n,i)}return o}var u4=class t{constructor(t,e){this.type=f3,this.geojson=t,this.geometries=e}static parse(e,n){if(2!==e.length)return n.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(y5(e[1])){const n=e[1];if("FeatureCollection"===n.type){const e=[];for(const t of n.features){const{type:n,coordinates:r}=t.geometry;"Polygon"===n&&e.push(r),"MultiPolygon"===n&&e.push(...r)}if(e.length)return new t(n,{type:"MultiPolygon",coordinates:e})}else if("Feature"===n.type){const e=n.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new t(n,n.geometry)}else if("Polygon"===n.type||"MultiPolygon"===n.type)return new t(n,n)}return n.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=s4(e.coordinates,r,i),o=l4(t.geometry(),n,r,i);if(!Z5(n,r))return!1;for(const t of o)if(!t4(t,s))return!1}if("MultiPolygon"===e.type){const s=o4(e.coordinates,r,i),o=l4(t.geometry(),n,r,i);if(!Z5(n,r))return!1;for(const t of o)if(!e4(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if("Polygon"===e.type){const s=s4(e.coordinates,r,i),o=c4(t.geometry(),n,r,i);if(!Z5(n,r))return!1;for(const t of o)if(!n4(t,s))return!1}if("MultiPolygon"===e.type){const s=o4(e.coordinates,r,i),o=c4(t.geometry(),n,r,i);if(!Z5(n,r))return!1;for(const t of o)if(!r4(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},h4=class{constructor(t=[],e=(t,e)=>te?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(n(r,s)>=0)break;e[t]=s,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[r],t=r}e[t]=i}};function d4(t){let e=0;for(let n,r,i=0,s=t.length,o=s-1;i1?(l=t[a+1][0],c=t[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(e[0]-l)*this.kx,h=(e[1]-c)*this.ky;const p=u*u+h*h;p180;)t-=360;return t}};function g4(t,e){return e[0]-t[0]}function m4(t){return t[1]-t[0]+1}function y4(t,e){return t[1]>=t[0]&&t[1]t[1])return[null,null];const n=m4(t);if(e){if(2===n)return[t,null];const e=Math.floor(n/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===n)return[t,null];const r=Math.floor(n/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function b4(t,e){if(!y4(e,t.length))return[1/0,1/0,-1/0,-1/0];const n=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)K5(n,t[r]);return n}function w4(t){const e=[1/0,1/0,-1/0,-1/0];for(const n of t)for(const t of n)K5(e,t);return e}function _4(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function x4(t,e,n){if(!_4(t)||!_4(e))return NaN;let r=0,i=0;return t[2]e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=r)return r;if(Z5(i,s)){if(L4(t,e))return 0}else if(L4(e,t))return 0;let o=1/0;for(const a of t)for(let t=0,r=a.length,i=r-1;t0;){const i=o.pop();if(i[0]>=s)continue;const l=i[1],c=e?50:100;if(m4(l)<=c){if(!y4(l,t.length))return NaN;if(e){const e=T4(t,l,n,r);if(isNaN(e)||0===e)return e;s=Math.min(s,e)}else for(let e=l[0];e<=l[1];++e){const i=R4(t[e],n,r);if(s=Math.min(s,i),0===s)return 0}}else{const n=v4(l,e);I4(o,s,r,t,a,n[0]),I4(o,s,r,t,a,n[1])}}return s}function O4(t,e,n,r,i,s=1/0){let o=Math.min(s,i.distance(t[0],n[0]));if(0===o)return o;const a=new h4([[0,[0,t.length-1],[0,n.length-1]]],g4);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],c=s[2],u=e?50:100,h=r?50:100;if(m4(l)<=u&&m4(c)<=h){if(!y4(l,t.length)&&y4(c,n.length))return NaN;let s;if(e&&r)s=S4(t,l,n,c,i),o=Math.min(o,s);else if(e&&!r){const e=t.slice(l[0],l[1]+1);for(let t=c[0];t<=c[1];++t)if(s=C4(n[t],e,i),o=Math.min(o,s),0===o)return o}else if(!e&&r){const e=n.slice(c[0],c[1]+1);for(let n=l[0];n<=l[1];++n)if(s=C4(t[n],e,i),o=Math.min(o,s),0===o)return o}else s=E4(t,l,n,c,i),o=Math.min(o,s)}else{const s=v4(l,e),u=v4(c,r);M4(a,o,i,t,n,s[0],u[0]),M4(a,o,i,t,n,s[0],u[1]),M4(a,o,i,t,n,s[1],u[0]),M4(a,o,i,t,n,s[1],u[1])}}return o}function F4(t){return"MultiPolygon"===t.type?t.coordinates.map(t=>({type:"Polygon",coordinates:t})):"MultiLineString"===t.type?t.coordinates.map(t=>({type:"LineString",coordinates:t})):"MultiPoint"===t.type?t.coordinates.map(t=>({type:"Point",coordinates:t})):[t]}var N4=class t{constructor(t,e){this.type=d3,this.geojson=t,this.geometries=e}static parse(e,n){if(2!==e.length)return n.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(y5(e[1])){const n=e[1];if("FeatureCollection"===n.type)return new t(n,n.features.map(t=>F4(t.geometry)).flat());if("Feature"===n.type)return new t(n,F4(n.geometry));if("type"in n&&"coordinates"in n)return new t(n,F4(n))}return n.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=t.geometry(),r=n.flat().map(e=>G5([e.x,e.y],t.canonical));if(0===n.length)return NaN;const i=new f4(r[0][1]);let s=1/0;for(const o of e){switch(o.type){case"Point":s=Math.min(s,O4(r,!1,[o.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,O4(r,!1,o.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,A4(r,!1,o.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=t.geometry(),r=n.flat().map(e=>G5([e.x,e.y],t.canonical));if(0===n.length)return NaN;const i=new f4(r[0][1]);let s=1/0;for(const o of e){switch(o.type){case"Point":s=Math.min(s,O4(r,!0,[o.coordinates],!1,i,s));break;case"LineString":s=Math.min(s,O4(r,!0,o.coordinates,!0,i,s));break;case"Polygon":s=Math.min(s,A4(r,!0,o.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const n=t.geometry();if(0===n.length||0===n[0].length)return NaN;const r=function(t){if(t.length<=1)return[t];const e=[];let n,r;for(const i of t){const t=d4(i);0!==t&&(i.area=Math.abs(t),void 0===r&&(r=t<0),r===t<0?(n&&e.push(n),n=[i]):n.push(i))}return n&&e.push(n),e}(n).map(e=>e.map(e=>e.map(e=>G5([e.x,e.y],t.canonical)))),i=new f4(r[0][0][0][1]);let s=1/0;for(const o of e)for(const t of r){switch(o.type){case"Point":s=Math.min(s,A4([o.coordinates],!1,t,i,s));break;case"LineString":s=Math.min(s,A4(o.coordinates,!0,t,i,s));break;case"Polygon":s=Math.min(s,P4(t,o.coordinates,i,s))}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},z4=class t{constructor(t){this.type=v3,this.key=t}static parse(e,n){if(2!==e.length)return n.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=e[1];return null==r?n.error("Global state property must be defined."):"string"!=typeof r?n.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new t(r)}evaluate(t){const e=t.globals?.globalState;return e&&0!==Object.keys(e).length?Z3(e,this.key)??null:null}eachChild(){}outputDefined(){return!1}},D4={"==":D5,"!=":j5,">":B5,"<":U5,">=":q5,"<=":$5,array:x5,at:class t{constructor(t,e,n){this.type=t,this.index=e,this.input=n}static parse(e,n){if(3!==e.length)return n.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,d3),i=n.parse(e[2],2,E3(n.expectedType||v3));if(!r||!i)return null;const s=i.type;return new t(s.itemType,r,i)}evaluate(t){const e=this.index.evaluate(t),n=this.input.evaluate(t);if(e<0)throw new h5(`Array index out of bounds: ${e} < 0.`);if(e>=n.length)throw new h5(`Array index out of bounds: ${e} > ${n.length-1}.`);if(e!==Math.floor(e))throw new h5(`Array index must be an integer, but found ${e} instead.`);return n[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},boolean:x5,case:class t{constructor(t,e,n){this.type=t,this.branches=e,this.otherwise=n}static parse(e,n){if(e.length<4)return n.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return n.error("Expected an odd number of arguments.");let r;n.expectedType&&"value"!==n.expectedType.kind&&(r=n.expectedType);const i=[];for(let t=1;te.outputDefined())&&this.otherwise.outputDefined()}},coalesce:O5,collator:V5,format:class t{constructor(t){this.type=w3,this.sections=t}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return n.error("First argument must be an image or text section.");const i=[];let s=!1;for(let t=1;t<=e.length-1;++t){const r=e[t];if(s&&"object"==typeof r&&!Array.isArray(r)){s=!1;let t=null;if(r["font-scale"]&&(t=n.parse(r["font-scale"],1,d3),!t))return null;let e=null;if(r["text-font"]&&(e=n.parse(r["text-font"],1,E3(p3)),!e))return null;let o=null;if(r["text-color"]&&(o=n.parse(r["text-color"],1,g3),!o))return null;let a=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!s5.includes(r["vertical-align"]))return n.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(a=n.parse(r["vertical-align"],1,p3),!a)return null}const l=i[i.length-1];l.scale=t,l.font=e,l.textColor=o,l.verticalAlign=a}else{const r=n.parse(e[t],1,v3);if(!r)return null;const o=r.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return n.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,i.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new t(i)}evaluate(t){return new a5(this.sections.map(e=>{const n=e.content.evaluate(t);return v5(n)===k3?new o5("",n,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new o5(b5(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}},image:class t{constructor(t){this.type=k3,this.input=t}static parse(e,n){if(2!==e.length)return n.error("Expected two arguments.");const r=n.parse(e[1],1,p3);return r?new t(r):n.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),n=f5.fromString(e);return n&&t.availableImages&&(n.available=t.availableImages.indexOf(e)>-1),n}eachChild(t){t(this.input)}outputDefined(){return!1}},in:class t{constructor(t,e){this.type=f3,this.needle=t,this.haystack=e}static parse(e,n){if(3!==e.length)return n.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,v3),i=n.parse(e[2],2,v3);return r&&i?P3(r.type,[f3,p3,d3,h3,v3])?new t(r,i):n.error(`Expected first argument to be of type boolean, string, number or null, but found ${R3(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!n)return!1;if(!I3(e,["boolean","string","number","null"]))throw new h5(`Expected first argument to be of type boolean, string, number or null, but found ${R3(v5(e))} instead.`);if(!I3(n,["string","array"]))throw new h5(`Expected second argument to be of type array or string, but found ${R3(v5(n))} instead.`);return n.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},"index-of":class t{constructor(t,e,n){this.type=d3,this.needle=t,this.haystack=e,this.fromIndex=n}static parse(e,n){if(e.length<=2||e.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,v3),i=n.parse(e[2],2,v3);if(!r||!i)return null;if(!P3(r.type,[f3,p3,d3,h3,v3]))return n.error(`Expected first argument to be of type boolean, string, number or null, but found ${R3(r.type)} instead`);if(4===e.length){const s=n.parse(e[3],3,d3);return s?new t(r,i,s):null}return new t(r,i)}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!I3(e,["boolean","string","number","null"]))throw new h5(`Expected first argument to be of type boolean, string, number or null, but found ${R3(v5(e))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(t)),I3(n,["string"])){const t=n.indexOf(e,r);return-1===t?-1:[...n.slice(0,t)].length}if(I3(n,["array"]))return n.indexOf(e,r);throw new h5(`Expected second argument to be of type array or string, but found ${R3(v5(n))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},interpolate:M5,"interpolate-hcl":M5,"interpolate-lab":M5,length:class t{constructor(t){this.type=d3,this.input=t}static parse(e,n){if(2!==e.length)return n.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=n.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?n.error(`Expected argument of type string or array, but found ${R3(r.type)} instead.`):new t(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new h5(`Expected value to be of type string or array, but found ${R3(v5(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}},let:T5,literal:w5,match:class t{constructor(t,e,n,r,i,s){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=s}static parse(e,n){if(e.length<5)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return n.error("Expected an even number of arguments.");let r,i;n.expectedType&&"value"!==n.expectedType.kind&&(i=n.expectedType);const s={},o=[];for(let t=2;tNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,v5(t)))return null}else r=v5(t);if(void 0!==s[String(t)])return c.error("Branch labels must be unique.");s[String(t)]=o.length}const u=n.parse(l,t,i);if(!u)return null;i=i||u.type,o.push(u)}const a=n.parse(e[1],1,v3);if(!a)return null;const l=n.parse(e[e.length-1],e.length-1,i);return l?"value"!==a.type.kind&&n.concat(1).checkSubtype(r,a.type)?null:new t(r,i,a,s,o,l):null}evaluate(t){const e=this.input.evaluate(t);return(v5(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}},number:x5,"number-format":class t{constructor(t,e,n,r,i,s){this.type=p3,this.number=t,this.locale=e,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=s}static parse(e,n){if(3!==e.length)return n.error("Expected two arguments.");const r=n.parse(e[1],1,d3);if(!r)return null;const i=e[2];if("object"!=typeof i||Array.isArray(i))return n.error("NumberFormat options argument must be an object.");let s=null;if(i.locale&&(s=n.parse(i.locale,1,p3),!s))return null;let o=null;if(i.currency&&(o=n.parse(i.currency,1,p3),!o))return null;let a=null;if(i.unit&&(a=n.parse(i.unit,1,p3),!a))return null;if(o&&a)return n.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(i["min-fraction-digits"]&&(l=n.parse(i["min-fraction-digits"],1,d3),!l))return null;let c=null;return i["max-fraction-digits"]&&(c=n.parse(i["max-fraction-digits"],1,d3),!c)?null:new t(r,s,o,a,l,c)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}},object:x5,slice:class t{constructor(t,e,n,r){this.type=t,this.input=e,this.beginIndex=n,this.endIndex=r}static parse(e,n){if(e.length<=2||e.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const r=n.parse(e[1],1,v3),i=n.parse(e[2],2,d3);if(!r||!i)return null;if(!P3(r.type,[E3(v3),p3,v3]))return n.error(`Expected first argument to be of type array or string, but found ${R3(r.type)} instead`);if(4===e.length){const s=n.parse(e[3],3,d3);return s?new t(r.type,r,i,s):null}return new t(r.type,r,i)}evaluate(t){const e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);let r;if(this.endIndex&&(r=this.endIndex.evaluate(t)),I3(e,["string"]))return[...e].slice(n,r).join("");if(I3(e,["array"]))return e.slice(n,r);throw new h5(`Expected first argument to be of type array or string, but found ${R3(v5(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},step:I5,string:x5,"to-boolean":k5,"to-color":k5,"to-number":k5,"to-string":k5,var:L5,within:u4,distance:N4,"global-state":z4},j4=class t{constructor(t,e,n,r){this.name=t,this.type=e,this._evaluate=n,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(e,n){const r=e[0],i=t.definitions[r];if(!i)return n.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(i)?i[0]:i.type,o=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,a=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let l=null;for(const[c,u]of a){l=new R5(n.registry,V4,n.path,null,n.scope);const i=[];let o=!1;for(let t=1;t{return e=t,Array.isArray(e)?`(${e.map(R3).join(", ")})`:`(${R3(e.type)}...)`;var e}).join(" | "),r=[];for(let i=1;i{n=e?n&&V4(t):n&&t instanceof w5}),!!n&&W4(t)&&G4(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function W4(t){if(t instanceof j4){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof u4)return!1;if(t instanceof N4)return!1;let e=!0;return t.eachChild(t=>{e&&!W4(t)&&(e=!1)}),e}function H4(t){if(t instanceof j4&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild(t=>{e&&!H4(t)&&(e=!1)}),e}function G4(t,e){if(t instanceof j4&&e.indexOf(t.name)>=0)return!1;let n=!0;return t.eachChild(t=>{n&&!G4(t,e)&&(n=!1)}),n}function K4(t){return{result:"success",value:t}}function Z4(t){return{result:"error",value:t}}function Y4(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function X4(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function J4(t){return!!t.expression&&t.expression.interpolated}function Q4(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function t6(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&v5(t)===y3}j4.register(D4,{error:[{kind:"error"},[p3],(t,[e])=>{throw new h5(e.evaluate(t))}],typeof:[p3,[v3],(t,[e])=>R3(v5(e.evaluate(t)))],"to-rgba":[E3(d3,4),[g3],(t,[e])=>{const[n,r,i,s]=e.evaluate(t).rgb;return[255*n,255*r,255*i,s]}],rgb:[g3,[d3,d3,d3],U4],rgba:[g3,[d3,d3,d3,d3],U4],has:{type:f3,overloads:[[[p3],(t,[e])=>B4(e.evaluate(t),t.properties())],[[p3,y3],(t,[e,n])=>B4(e.evaluate(t),n.evaluate(t))]]},get:{type:v3,overloads:[[[p3],(t,[e])=>$4(e.evaluate(t),t.properties())],[[p3,y3],(t,[e,n])=>$4(e.evaluate(t),n.evaluate(t))]]},"feature-state":[v3,[p3],(t,[e])=>$4(e.evaluate(t),t.featureState||{})],properties:[y3,[],t=>t.properties()],"geometry-type":[p3,[],t=>t.geometryType()],id:[v3,[],t=>t.id()],zoom:[d3,[],t=>t.globals.zoom],"heatmap-density":[d3,[],t=>t.globals.heatmapDensity||0],elevation:[d3,[],t=>t.globals.elevation||0],"line-progress":[d3,[],t=>t.globals.lineProgress||0],accumulated:[v3,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[d3,q4(d3),(t,e)=>{let n=0;for(const r of e)n+=r.evaluate(t);return n}],"*":[d3,q4(d3),(t,e)=>{let n=1;for(const r of e)n*=r.evaluate(t);return n}],"-":{type:d3,overloads:[[[d3,d3],(t,[e,n])=>e.evaluate(t)-n.evaluate(t)],[[d3],(t,[e])=>-e.evaluate(t)]]},"/":[d3,[d3,d3],(t,[e,n])=>e.evaluate(t)/n.evaluate(t)],"%":[d3,[d3,d3],(t,[e,n])=>e.evaluate(t)%n.evaluate(t)],ln2:[d3,[],()=>Math.LN2],pi:[d3,[],()=>Math.PI],e:[d3,[],()=>Math.E],"^":[d3,[d3,d3],(t,[e,n])=>Math.pow(e.evaluate(t),n.evaluate(t))],sqrt:[d3,[d3],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[d3,[d3],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[d3,[d3],(t,[e])=>Math.log(e.evaluate(t))],log2:[d3,[d3],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[d3,[d3],(t,[e])=>Math.sin(e.evaluate(t))],cos:[d3,[d3],(t,[e])=>Math.cos(e.evaluate(t))],tan:[d3,[d3],(t,[e])=>Math.tan(e.evaluate(t))],asin:[d3,[d3],(t,[e])=>Math.asin(e.evaluate(t))],acos:[d3,[d3],(t,[e])=>Math.acos(e.evaluate(t))],atan:[d3,[d3],(t,[e])=>Math.atan(e.evaluate(t))],min:[d3,q4(d3),(t,e)=>Math.min(...e.map(e=>e.evaluate(t)))],max:[d3,q4(d3),(t,e)=>Math.max(...e.map(e=>e.evaluate(t)))],abs:[d3,[d3],(t,[e])=>Math.abs(e.evaluate(t))],round:[d3,[d3],(t,[e])=>{const n=e.evaluate(t);return n<0?-Math.round(-n):Math.round(n)}],floor:[d3,[d3],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[d3,[d3],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[f3,[p3,v3],(t,[e,n])=>t.properties()[e.value]===n.value],"filter-id-==":[f3,[v3],(t,[e])=>t.id()===e.value],"filter-type-==":[f3,[p3],(t,[e])=>t.geometryType()===e.value],"filter-<":[f3,[p3,v3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r{const n=t.id(),r=e.value;return typeof n==typeof r&&n":[f3,[p3,v3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[f3,[v3],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>r}],"filter-<=":[f3,[p3,v3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[f3,[v3],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n<=r}],"filter->=":[f3,[p3,v3],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[f3,[v3],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>=r}],"filter-has":[f3,[v3],(t,[e])=>e.value in t.properties()],"filter-has-id":[f3,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[f3,[E3(p3)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[f3,[E3(v3)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[f3,[p3,E3(v3)],(t,[e,n])=>n.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[f3,[p3,E3(v3)],(t,[e,n])=>function(t,e,n,r){for(;n<=r;){const i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[e.value],n.value,0,n.value.length-1)],all:{type:f3,overloads:[[[f3,f3],(t,[e,n])=>e.evaluate(t)&&n.evaluate(t)],[q4(f3),(t,e)=>{for(const n of e)if(!n.evaluate(t))return!1;return!0}]]},any:{type:f3,overloads:[[[f3,f3],(t,[e,n])=>e.evaluate(t)||n.evaluate(t)],[q4(f3),(t,e)=>{for(const n of e)if(n.evaluate(t))return!0;return!1}]]},"!":[f3,[f3],(t,[e])=>!e.evaluate(t)],"is-supported-script":[f3,[p3],(t,[e])=>{const n=t.globals&&t.globals.isSupportedScript;return!n||n(e.evaluate(t))}],upcase:[p3,[p3],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[p3,[p3],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[p3,q4(v3),(t,e)=>e.map(e=>b5(e.evaluate(t))).join("")],split:[E3(p3),[p3,p3],(t,[e,n])=>e.evaluate(t).split(n.evaluate(t))],join:[p3,[E3(p3),p3],(t,[e,n])=>e.evaluate(t).join(n.evaluate(t))],"resolved-locale":[p3,[b3],(t,[e])=>e.evaluate(t).resolvedLocale()]});var e6=class{constructor(t,e,n){this.expression=t,this._warningHistory={},this._evaluator=new E5,this._defaultValue=e?function(t){if("color"===t.type&&t6(t.default))return new r5(0,0,0,0);switch(t.type){case"color":return r5.parse(t.default)||null;case"padding":return l5.parse(t.default)||null;case"numberArray":return c5.parse(t.default)||null;case"colorArray":return u5.parse(t.default)||null;case"variableAnchorOffsetCollection":return p5.parse(t.default)||null;case"projectionDefinition":return g5.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this._globalState=n}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=c6(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,n,r,i,s){this._globalState&&(t=c6(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new h5(`Expected value to be one of ${Object.keys(this._enumValues).map(t=>JSON.stringify(t)).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(o){return this._warningHistory[o.message]||(this._warningHistory[o.message]=!0,"undefined"!=typeof console&&console.warn(o.message)),this._defaultValue}}};function n6(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in D4}function r6(t,e,n){const r=new R5(D4,V4,[],e?function(t){const e={color:g3,string:p3,number:d3,enum:p3,boolean:f3,formatted:w3,padding:_3,numberArray:C3,colorArray:x3,projectionDefinition:m3,resolvedImage:k3,variableAnchorOffsetCollection:S3};return"array"===t.type?E3(e[t.value]||v3,t.length):e[t.type]}(e):void 0),i=r.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return i?K4(new e6(i,e,n)):Z4(r.errors)}var i6=class{constructor(t,e,n){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!H4(e.expression),this.globalStateRefs=l6(e.expression),this._globalState=n}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=c6(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._globalState&&(t=c6(t,this._globalState)),this._styleExpression.evaluate(t,e,n,r,i,s)}},s6=class{constructor(t,e,n,r,i){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!H4(e.expression),this.globalStateRefs=l6(e.expression),this.interpolationType=r,this._globalState=i}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._globalState&&(t=c6(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._globalState&&(t=c6(t,this._globalState)),this._styleExpression.evaluate(t,e,n,r,i,s)}interpolationFactor(t,e,n){return this.interpolationType?M5.interpolationFactor(this.interpolationType,t,e,n):0}};function o6(t,e,n){const r=r6(t,e,n);if("error"===r.result)return r;const i=r.value.expression,s=W4(i);if(!s&&!Y4(e))return Z4([new c3("","data expressions not supported")]);const o=G4(i,["zoom"]);if(!o&&!X4(e))return Z4([new c3("","zoom expressions not supported")]);const a=a6(i);if(!a&&!o)return Z4([new c3("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(a instanceof c3)return Z4([a]);if(a instanceof M5&&!J4(e))return Z4([new c3("",'"interpolate" expressions cannot be used with this property')]);if(!a)return K4(new i6(s?"constant":"source",r.value,n));const l=a instanceof M5?a.interpolation:void 0;return K4(new s6(s?"camera":"composite",r.value,a.labels,l,n))}function a6(t){let e=null;if(t instanceof T5)e=a6(t.result);else if(t instanceof O5){for(const n of t.args)if(e=a6(n),e)break}else(t instanceof I5||t instanceof M5)&&t.input instanceof j4&&"zoom"===t.input.name&&(e=t);return e instanceof c3||t.eachChild(t=>{const n=a6(t);n instanceof c3?e=n:!e&&n?e=new c3("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new c3("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function l6(t,e=new Set){return t instanceof z4&&e.add(t.key),t.eachChild(t=>{l6(t,e)}),e}function c6(t,e){const{zoom:n,heatmapDensity:r,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a}=t??{};return{zoom:n,heatmapDensity:r,elevation:i,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:e}}function u6(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!u6(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}var h6={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function d6(t,e){return te?1:0}function p6(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?g6(t[1],t[2],e):"any"===e?(n=t.slice(1),["any"].concat(n.map(f6))):"all"===e?["all"].concat(t.slice(1).map(f6)):"none"===e?["all"].concat(t.slice(1).map(f6).map(v6)):"in"===e?m6(t[1],t.slice(2)):"!in"===e?v6(m6(t[1],t.slice(2))):"has"===e?y6(t[1]):"!has"!==e||v6(y6(t[1]));var n}function g6(t,e,n){switch(t){case"$type":return[`filter-type-${n}`,e];case"$id":return[`filter-id-${n}`,e];default:return[`filter-${n}`,t,e]}}function m6(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(t=>typeof t!=typeof e[0])?["filter-in-large",t,["literal",e.sort(d6)]]:["filter-in-small",t,["literal",e]]}}function y6(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function v6(t){return["!",t]}function b6(t){return"object"==typeof t?["literal",t]:t}function w6(t,e){let n=t.stops;if(!n)return function(t,e){const n=["get",t.property];if(void 0===t.default)return"string"===e.type?["string",n]:n;if("enum"===e.type)return["match",n,Object.keys(e.values),n,t.default];{const r=["color"===e.type?"to-color":e.type,n,b6(t.default)];return"array"===e.type&&r.splice(1,0,e.value,e.length||null),r}}(t,e);const r=n&&"object"==typeof n[0][0],i=r||void 0!==t.property,s=r||!i;return n=n.map(t=>!i&&e.tokens&&"string"==typeof t[1]?[t[0],R6(t[1])]:[t[0],b6(t[1])]),r?function(t,e,n){const r={},i={},s=[];for(let o=0;o3&&e===t[t.length-2]||(r&&2===t.length||t.push(e),t.push(n))}function E6(t,e){return t.type?t.type:e.expression.interpolated?"exponential":"interval"}function R6(t){const e=["concat"],n=/{([^{}]+)}/g;let r=0;for(let i=n.exec(t);null!==i;i=n.exec(t)){const s=t.slice(r,n.lastIndex-i[0].length);r=n.lastIndex,s.length>0&&e.push(s),e.push(["get",i[1]])}if(1===e.length)return t;if(rr.maximum?[new a3(e,n,`${n} is greater than the maximum value ${r.maximum}`)]:[]}function O6(t){const e=t.valueSpec,n=L6(t.value.type);let r,i,s,o={};const a="categorical"!==n&&void 0===t.value.property,l=!a,c="array"===Q4(t.value.stops)&&"array"===Q4(t.value.stops[0])&&"object"===Q4(t.value.stops[0][0]),u=I6({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===n)return[new a3(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(M6({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:h})),"array"===Q4(r)&&0===r.length&&e.push(new a3(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===n&&a&&u.push(new a3(t.key,t.value,'missing required property "property"')),"identity"===n||t.value.stops||u.push(new a3(t.key,t.value,'missing required property "stops"')),"exponential"===n&&t.valueSpec.expression&&!J4(t.valueSpec)&&u.push(new a3(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Y4(t.valueSpec)?u.push(new a3(t.key,t.value,"property functions not supported")):a&&!X4(t.valueSpec)&&u.push(new a3(t.key,t.value,"zoom functions not supported"))),"categorical"!==n&&!c||void 0!==t.value.property||u.push(new a3(t.key,t.value,'"property" property is required')),u;function h(t){let n=[];const r=t.value,a=t.key;if("array"!==Q4(r))return[new a3(a,r,`array expected, ${Q4(r)} found`)];if(2!==r.length)return[new a3(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Q4(r[0]))return[new a3(a,r,`object expected, ${Q4(r[0])} found`)];if(void 0===r[0].zoom)return[new a3(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new a3(a,r,"object stop key must have value")];if(s&&s>L6(r[0].zoom))return[new a3(a,r[0].zoom,"stop zoom values must appear in ascending order")];L6(r[0].zoom)!==s&&(s=L6(r[0].zoom),i=void 0,o={}),n=n.concat(I6({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:A6,value:d}}))}else n=n.concat(d({key:`${a}[0]`,value:r[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return n6(P6(r[1]))?n.concat([new a3(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):n.concat(t.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function d(t,s){const a=Q4(t.value),l=L6(t.value),c=null!==t.value?t.value:s;if(r){if(a!==r)return[new a3(t.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new a3(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==n){let r=`number expected, ${a} found`;return Y4(e)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new a3(t.key,c,r)]}return"categorical"!==n||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===a&&void 0!==i&&lnew a3(`${t.key}${e.key}`,t.value,e.message));const n=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new a3(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!H4(n))return[new a3(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!H4(n))return[new a3(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!G4(n,["zoom","feature-state"]))return[new a3(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!W4(n))return[new a3(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function N6(t){const e=t.key,n=t.value,r=Q4(n);return"string"!==r?[new a3(e,n,`color expected, ${r} found`)]:r5.parse(String(n))?[]:[new a3(e,n,`color expected, "${n}" found`)]}function z6(t){const e=t.key,n=t.value,r=t.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(L6(n))&&i.push(new a3(e,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(L6(n))&&i.push(new a3(e,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function D6(t){return u6(P6(t.value))?F6(l3({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):j6(t)}function j6(t){const e=t.value,n=t.key;if("array"!==Q4(e))return[new a3(n,e,`array expected, ${Q4(e)} found`)];const r=t.styleSpec;let i,s=[];if(e.length<1)return[new a3(n,e,"filter array must have at least 1 element")];switch(s=s.concat(z6({key:`${n}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),L6(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===L6(e[1])&&s.push(new a3(n,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new a3(n,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(i=Q4(e[1]),"string"!==i&&s.push(new a3(`${n}[1]`,e[1],`string expected, ${i} found`)));for(let o=2;o{t in n&&e.push(new a3(r,n[t],`"${t}" is prohibited for ref layers`))}),i.layers.forEach(e=>{L6(e.id)===a&&(t=e)}),t?t.ref?e.push(new a3(r,n.ref,"ref cannot reference another ref layer")):o=L6(t.type):e.push(new a3(r,n.ref,`ref layer "${a}" not found`))}else if("background"!==o)if(n.source){const t=i.sources&&i.sources[n.source],s=t&&L6(t.type);t?"vector"===s&&"raster"===o?e.push(new a3(r,n.source,`layer "${n.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===o||"raster-dem"!==s&&"color-relief"===o?e.push(new a3(r,n.source,`layer "${n.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==o?e.push(new a3(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==s||n["source-layer"]?"raster-dem"===s&&"hillshade"!==o&&"color-relief"!==o?e.push(new a3(r,n.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==o||!n.paint||!n.paint["line-gradient"]||"geojson"===s&&t.lineMetrics||e.push(new a3(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new a3(r,n,`layer "${n.id}" must specify a "source-layer"`)):e.push(new a3(r,n.source,`source "${n.source}" not found`))}else e.push(new a3(r,n,'missing required property "source"'));return"raster"===o&&n.paint?.resampling&&n.paint?.["raster-resampling"]&&e.push(new a3(r,n.paint,`layer "${n.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),e=e.concat(I6({key:r,value:n,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:n.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:n,objectKey:"type"}),filter:D6,layout:t=>I6({layer:n,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>$6(l3({layerType:o},t))}}),paint:t=>I6({layer:n,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>B6(l3({layerType:o},t))}})}})),e}function V6(t){const e=t.value,n=t.key,r=Q4(e);return"string"!==r?[new a3(n,e,`string expected, ${r} found`)]:[]}var W6={promoteId:function({key:t,value:e}){if("string"===Q4(e))return V6({key:t,value:e});{const n=[];for(const r in e)n.push(...V6({key:`${t}.${r}`,value:e[r]}));return n}}};function H6(t){const e=t.value,n=t.key,r=t.styleSpec,i=t.style,s=t.validateSpec;if(!e.type)return[new a3(n,e,'"type" is required')];const o=L6(e.type);let a;switch(o){case"vector":case"raster":return a=I6({key:n,value:e,valueSpec:r[`source_${o.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:W6,validateSpec:s}),a;case"raster-dem":return a=function(t){const e=t.sourceName??"",n=t.value,r=t.styleSpec,i=r.source_raster_dem,s=t.style;let o=[];const a=Q4(n);if(void 0===n)return o;if("object"!==a)return o.push(new a3("source_raster_dem",n,`object expected, ${a} found`)),o;const l="custom"===L6(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const h in n)!l&&c.includes(h)?o.push(new a3(h,n[h],`In "${e}": "${h}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):i[h]?o=o.concat(t.validateSpec({key:h,value:n[h],valueSpec:i[h],validateSpec:t.validateSpec,style:s,styleSpec:r})):o.push(new a3(h,n[h],`unknown property "${h}"`));return o}({sourceName:n,value:e,style:t.style,styleSpec:r,validateSpec:s}),a;case"geojson":if(a=I6({key:n,value:e,valueSpec:r.source_geojson,style:i,styleSpec:r,validateSpec:s,objectElementValidators:W6}),e.cluster)for(const t in e.clusterProperties){const[r,i]=e.clusterProperties[t],o="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...F6({key:`${n}.${t}.map`,value:i,validateSpec:s,expressionContext:"cluster-map"})),a.push(...F6({key:`${n}.${t}.reduce`,value:o,validateSpec:s,expressionContext:"cluster-reduce"}))}return a;case"video":return I6({key:n,value:e,valueSpec:r.source_video,style:i,validateSpec:s,styleSpec:r});case"image":return I6({key:n,value:e,valueSpec:r.source_image,style:i,validateSpec:s,styleSpec:r});case"canvas":return[new a3(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return z6({key:`${n}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,validateSpec:s,styleSpec:r})}}function G6(t){const e=t.value,n=t.styleSpec,r=n.light,i=t.style;let s=[];const o=Q4(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new a3("light",e,`object expected, ${o} found`)]),s;for(const a in e){const o=a.match(/^(.*)-transition$/);s=o&&r[o[1]]&&r[o[1]].transition?s.concat(t.validateSpec({key:a,value:e[a],valueSpec:n.transition,validateSpec:t.validateSpec,style:i,styleSpec:n})):r[a]?s.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:i,styleSpec:n})):s.concat([new a3(a,e[a],`unknown property "${a}"`)])}return s}function K6(t){const e=t.value,n=t.styleSpec,r=n.sky,i=t.style,s=Q4(e);if(void 0===e)return[];if("object"!==s)return[new a3("sky",e,`object expected, ${s} found`)];let o=[];for(const a in e)o=r[a]?o.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],style:i,styleSpec:n})):o.concat([new a3(a,e[a],`unknown property "${a}"`)]);return o}function Z6(t){const e=t.value,n=t.styleSpec,r=n.terrain,i=t.style;let s=[];const o=Q4(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new a3("terrain",e,`object expected, ${o} found`)]),s;for(const a in e)s=r[a]?s.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:i,styleSpec:n})):s.concat([new a3(a,e[a],`unknown property "${a}"`)]);return s}function Y6(t){let e=[];const n=t.value,r=t.key;if(Array.isArray(n)){const i=[],s=[];for(const o in n)n[o].id&&i.includes(n[o].id)&&e.push(new a3(r,n,`all the sprites' ids must be unique, but ${n[o].id} is duplicated`)),i.push(n[o].id),n[o].url&&s.includes(n[o].url)&&e.push(new a3(r,n,`all the sprites' URLs must be unique, but ${n[o].url} is duplicated`)),s.push(n[o].url),e=e.concat(I6({key:`${r}[${o}]`,value:n[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return V6({key:r,value:n})}function X6(t){return Boolean(t)&&t.constructor===Object}function J6(t){return X6(t.value)?[]:[new a3(t.key,t.value,`object expected, ${Q4(t.value)} found`)]}var Q6={"*":()=>[],array:M6,boolean:function(t){const e=t.value,n=t.key,r=Q4(e);return"boolean"!==r?[new a3(n,e,`boolean expected, ${r} found`)]:[]},number:A6,color:N6,constants:T6,enum:z6,filter:D6,function:O6,layer:q6,object:I6,source:H6,light:G6,sky:K6,terrain:Z6,projection:function(t){const e=t.value,n=t.styleSpec,r=n.projection,i=t.style,s=Q4(e);if(void 0===e)return[];if("object"!==s)return[new a3("projection",e,`object expected, ${s} found`)];let o=[];for(const a in e)o=r[a]?o.concat(t.validateSpec({key:a,value:e[a],valueSpec:r[a],style:i,styleSpec:n})):o.concat([new a3(a,e[a],`unknown property "${a}"`)]);return o},projectionDefinition:function(t){const e=t.key;let n=t.value;n=n instanceof String?n.valueOf():n;const r=Q4(n);return"array"!==r||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(n)||function(t){return!!["interpolate","step","literal"].includes(t[0])}(n)?["array","string"].includes(r)?[]:[new a3(e,n,`projection expected, invalid type "${r}" found`)]:[new a3(e,n,`projection expected, invalid array ${JSON.stringify(n)} found`)]},string:V6,formatted:function(t){return 0===V6(t).length?[]:F6(t)},resolvedImage:function(t){return 0===V6(t).length?[]:F6(t)},padding:function(t){const e=t.key,n=t.value;if("array"===Q4(n)){if(n.length<1||n.length>4)return[new a3(e,n,`padding requires 1 to 4 values; ${n.length} values found`)];const r={type:"number"};let i=[];for(let s=0;s[]}})),t.constants&&(n=n.concat(T6({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:t8}))),i8(n)}function r8(t){return function(e){return t(Object.assign({},e,{validateSpec:t8}))}}function i8(t){return[].concat(t).sort((t,e)=>t.line-e.line)}function s8(t){return function(...e){return i8(t.apply(this,e))}}n8.source=s8(r8(H6)),n8.sprite=s8(r8(Y6)),n8.glyphs=s8(r8(e8)),n8.light=s8(r8(G6)),n8.sky=s8(r8(K6)),n8.terrain=s8(r8(Z6)),n8.state=s8(r8(J6)),n8.layer=s8(r8(q6)),n8.filter=s8(r8(D6)),n8.paintProperty=s8(r8(B6)),n8.layoutProperty=s8(r8($6));var o8=r3,a8=4294967296,l8="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8"),c8=class{constructor(t){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(t,e,n=this.length){let r;for(;r=this.nextField(n);)t(r,e,this);return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*a8;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*a8;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf,n=e[this.pos++];if(n<128)return n;let r,i=127&n;return r=e[this.pos++],i|=(127&r)<<7,r<128?i:(r=e[this.pos++],i|=(127&r)<<14,r<128?i:(r=e[this.pos++],i|=(127&r)<<21,r<128?i:(r=e[this.pos],i|=(15&r)<<28,function(t,e,n){const r=n.buf;let i,s;if(s=r[n.pos++],i=(112&s)>>4,s<128)return u8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<3,s<128)return u8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<10,s<128)return u8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<17,s<128)return u8(t,i,e);if(s=r[n.pos++],i|=(127&s)<<24,s<128)return u8(t,i,e);if(s=r[n.pos++],i|=(1&s)<<31,s<128)return u8(t,i,e);throw new Error("Expected varint not more than 10 bytes")}(i,t,this))))}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&l8?l8.decode(this.buf.subarray(e,t)):function(t,e,n){let r="",i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+c>n)break;1===c?e<128&&(l=e):2===c?(s=t[i+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===c?(s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),i+=c}return r}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos=t)return 0;const e=this.readVarint();return this.type=7&e,this._valueStart=this.pos,e>>>3}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}};function u8(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}var h8=class extends F2{constructor(t){super(),t=t||{},this.dataProjection=new zG({code:"",units:"tile-pixels"}),this.featureClass=t.featureClass?t.featureClass:S2,this.geometryName_=t.geometryName,this.layerName_=t.layerName?t.layerName:"layer",this.layers_=t.layers?t.layers:null,this.idProperty_=t.idProperty,this.supportedMediaTypes=["application/vnd.mapbox-vector-tile","application/x-protobuf"]}readRawGeometry_(t,e,n,r){t.pos=e.geometry;const i=t.readVarint()+t.pos;let s=1,o=0,a=0,l=0,c=0,u=0;for(;t.pos>3}if(o--,1===s||2===s)a+=t.readSVarint(),l+=t.readSVarint(),1===s&&c>u&&(r.push(c),u=c),n.push(a,l),c+=2;else{if(7!==s)throw new Error("Invalid command found in the PBF");c>u&&(n.push(n[u],n[u+1]),c+=2)}}c>u&&(r.push(c),u=c)}createFeature_(t,e,n){const r=e.type;if(0===r)return null;let i;const s=e.properties;let o;this.idProperty_?(o=s[this.idProperty_],delete s[this.idProperty_]):o=e.id,s[this.layerName_]=e.layer.name;const a=[],l=[];this.readRawGeometry_(t,e,a,l);const c=function(t,e){let n;return 1===t?n=1===e?"Point":"MultiPoint":2===t?n=1===e?"LineString":"MultiLineString":3===t&&(n="Polygon"),n}(r,l.length);if(this.featureClass===S2)i=new this.featureClass(c,a,l,2,s,o),i.transform(n.dataProjection);else{let t;if("Polygon"==c){const e=KZ(a,l);t=e.length>1?new y1(a,"XY",e):new ZZ(a,"XY",l)}else t="Point"===c?new jZ(a,"XY"):"LineString"===c?new p1(a,"XY"):"MultiPoint"===c?new g1(a,"XY"):"MultiLineString"===c?new f1(a,"XY",l):null;i=new(0,this.featureClass),this.geometryName_&&i.setGeometryName(this.geometryName_);const e=N2(t,!1,n);i.setGeometry(e),void 0!==o&&i.setId(o),i.setProperties(s,!0)}return i}getType(){return"arraybuffer"}readFeatures(t,e){const n=this.layers_,r=MK((e=this.adaptOptions(e)).dataProjection);r.setWorldExtent(e.extent),e.dataProjection=r;const i=new c8(t),s=i.readFields(d8,{}),o=[];for(const a in s){if(n&&!n.includes(a))continue;const t=s[a],l=t?[0,0,t.extent,t.extent]:null;r.setExtent(l);for(let n=0,r=t.length;n>3)?n.readString():2===t?n.readFloat():3===t?n.readDouble():4===t?n.readVarint(!0):5===t?n.readVarint():6===t?n.readSVarint():7===t?n.readBoolean():null;e.values.push(r)}}function f8(t,e,n){if(1==t)e.id=n.readVarint();else if(2==t){const t=n.readVarint()+n.pos;for(;n.post)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){XW()}getAlpha(t,e){if(!this.transition_)return 1;let n=this.transitionStarts_[t];if(n){if(-1===n)return 1}else n=e,this.transitionStarts_[t]=n;const r=e-n+1e3/60;return r>=this.transition_?1:LG(r/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}};function y8(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}var v8,b8=new Error("disposed"),w8=[256,256],_8=class extends m8{constructor(t){super(t.tileCoord,0,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=y8(this.data_);return t?[t.width,t.height]:w8}getData(){return this.data_}getError(){return this.error_}load(){if(0!==this.state&&3!==this.state)return;this.state=1,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=2,t.changed()}).catch(function(e){t.error_=e,t.state=3,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(b8),this.controller_=null),super.disposeInternal()}},x8=class extends m8{constructor(t,e,n,r,i,s){super(t,e,s),this.crossOrigin_=r?.crossOrigin,this.referrerPolicy_=r?.referrerPolicy,this.src_=n,this.key=n,this.image_,dH?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=i}getImage(){return this.image_}setImage(t){this.image_=t,this.state=2,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=3,this.unlistenImage_(),this.image_=function(){const t=gY(1,1);return t.fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas}(),this.changed()}handleImageLoad_(){if(dH)this.state=2;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=2:this.state=4}this.unlistenImage_(),this.changed()}load(){3==this.state&&(this.state=0,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),0==this.state&&(this.state=1,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=function(t,e,n){const r=t;let i=!0,s=!1,o=!1;const a=[RW(r,"load",function(){o=!0,s||e()})];return r.src&&pH?(s=!0,r.decode().then(function(){i&&e()}).catch(function(){i&&(o?e():n())})):a.push(RW(r,"error",n)),function(){i=!1,a.forEach(TW)}}(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}},C8=class{constructor(t,e,n,r){this.minX=t,this.maxX=e,this.minY=n,this.maxY=r}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minXthis.maxX&&(this.maxX=t.maxX),t.minYthis.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}};function k8(t,e,n,r,i){return void 0!==i?(i.minX=t,i.maxX=e,i.minY=n,i.maxY=r,i):new C8(t,e,n,r)}var S8=[];function E8(t,e,n,r,i){t.beginPath(),t.moveTo(0,0),t.lineTo(e,n),t.lineTo(r,i),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,r)+1,Math.max(n,i)),t.restore()}function R8(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function T8(t,e,n,r){const i=$K(n,e,t);let s=AK(e,r,n);const o=e.getMetersPerUnit();void 0!==o&&(s*=o);const a=t.getMetersPerUnit();void 0!==a&&(s/=a);const l=t.getExtent();if(!l||GH(l,i)){const e=AK(t,s,i)/s;isFinite(e)&&e>0&&(s/=e)}return s}function L8(t,e,n,r,i,s,o,a,l,c,u,h,d,p){const f=gY(Math.round(n*t),Math.round(n*e),S8);if(h||(f.imageSmoothingEnabled=!1),0===l.length)return f.canvas;function g(t){return Math.round(t*n)/n}f.scale(n,n),f.globalCompositeOperation="lighter";const m=[1/0,1/0,-1/0,-1/0];let y;l.forEach(function(t){nG(m,t.extent)});const v=n/r,b=(h?1:1+Math.pow(2,-24))/v;if(!d||1!==l.length||0!==c){if(y=gY(Math.round(bG(m)*v),Math.round(fG(m)*v),S8),h||(y.imageSmoothingEnabled=!1),i&&p){const t=(i[0]-m[0])*v,e=-(i[3]-m[3])*v,n=bG(i)*v,r=fG(i)*v;y.rect(t,e,n,r),y.clip()}l.forEach(function(t){if(t.image.width>0&&t.image.height>0){if(t.clipExtent){y.save();const e=(t.clipExtent[0]-m[0])*v,n=-(t.clipExtent[3]-m[3])*v,r=bG(t.clipExtent)*v,i=fG(t.clipExtent)*v;y.rect(h?e:Math.round(e),h?n:Math.round(n),h?r:Math.round(e+r)-Math.round(e),h?i:Math.round(n+i)-Math.round(n)),y.clip()}const e=(t.extent[0]-m[0])*v,n=-(t.extent[3]-m[3])*v,r=bG(t.extent)*v,i=fG(t.extent)*v;y.drawImage(t.image,c,c,t.image.width-2*c,t.image.height-2*c,h?e:Math.round(e),h?n:Math.round(n),h?r:Math.round(e+r)-Math.round(e),h?i:Math.round(n+i)-Math.round(n)),t.clipExtent&&y.restore()}})}const w=yG(o);return a.getTriangles().forEach(function(t){const e=t.source,n=t.target;let r=e[0][0],i=e[0][1],o=e[1][0],a=e[1][1],c=e[2][0],u=e[2][1];const d=g((n[0][0]-w[0])/s),p=g(-(n[0][1]-w[1])/s),v=g((n[1][0]-w[0])/s),_=g(-(n[1][1]-w[1])/s),x=g((n[2][0]-w[0])/s),C=g(-(n[2][1]-w[1])/s),k=r,S=i;r=0,i=0,o-=k,a-=S,c-=k,u-=S;const E=function(t){const e=t.length;for(let r=0;ri&&(i=e,n=o)}if(0===i)return null;const s=t[n];t[n]=t[r],t[r]=s;for(let o=r+1;o=0;r--){n[r]=t[r][e]/t[r][r];for(let i=r-1;i>=0;i--)t[i][e]-=t[i][r]*n[r]}return n}([[o,a,0,0,v-d],[c,u,0,0,x-d],[0,0,o,a,_-p],[0,0,c,u,C-p]]);if(!E)return;if(f.save(),f.beginPath(),function(){if(void 0===v8){const t=gY(6,6,S8);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",E8(t,4,5,4,0),E8(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;v8=R8(e,0)||R8(e,4)||R8(e,8),yY(t),S8.push(t.canvas)}return v8}()||!h){f.moveTo(v,_);const t=4,e=d-v,n=p-_;for(let r=0;rQK(o,$K(t,this.targetProj_,this.sourceProj_)),function(t,e,n,r){const i=t.length;n=void 0!==n?n:2,r=r??n,e=void 0!==e?e:new Array(i);for(let s=0;s=o?t[s+n]:i[n]}return e}):BK(this.targetProj_,this.sourceProj_);var c;this.transformInv_=function(t){const e=t[0]+"/"+t[1];return a[e]||(a[e]=l(t)),a[e]},this.maxSourceExtent_=r,this.errorThresholdSquared_=i*i,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&bG(r)>=bG(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?bG(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?bG(this.targetProj_.getExtent()):null;const u=yG(n),h=vG(n),d=cG(n),p=lG(n),f=this.transformInv_(u),g=this.transformInv_(h),m=this.transformInv_(d),y=this.transformInv_(p),v=10+(s?Math.max(0,Math.ceil(Math.log2(aG(n)/(s*s*256*256)))):0);if(this.addQuad_(u,h,d,p,f,g,m,y,v),this.wrapsXInSource_){let t=1/0;this.triangles_.forEach(function(e){t=Math.min(t,e.source[0][0],e.source[1][0],e.source[2][0])}),this.triangles_.forEach(e=>{if(Math.max(e.source[0][0],e.source[1][0],e.source[2][0])-t>this.sourceWorldWidth_/2){const n=[[e.source[0][0],e.source[0][1]],[e.source[1][0],e.source[1][1]],[e.source[2][0],e.source[2][1]]];n[0][0]-t>this.sourceWorldWidth_/2&&(n[0][0]-=this.sourceWorldWidth_),n[1][0]-t>this.sourceWorldWidth_/2&&(n[1][0]-=this.sourceWorldWidth_),n[2][0]-t>this.sourceWorldWidth_/2&&(n[2][0]-=this.sourceWorldWidth_);const r=Math.min(n[0][0],n[1][0],n[2][0]);Math.max(n[0][0],n[1][0],n[2][0])-r.5&&u<1;let p=!1;if(l>0&&(this.targetProj_.isGlobal()&&this.targetWorldWidth_&&(p=bG(qH([t,e,n,r]))/this.targetWorldWidth_>.25||p),!d&&this.sourceProj_.isGlobal()&&u&&(p=u>.25||p)),!p&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!wG(c,this.maxSourceExtent_))return;let f=0;if(!(p||isFinite(i[0])&&isFinite(i[1])&&isFinite(s[0])&&isFinite(s[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(a[0])&&isFinite(a[1])))if(l>0)p=!0;else if(f=(isFinite(i[0])&&isFinite(i[1])?0:8)+(isFinite(s[0])&&isFinite(s[1])?0:4)+(isFinite(o[0])&&isFinite(o[1])?0:2)+(isFinite(a[0])&&isFinite(a[1])?0:1),1!=f&&2!=f&&4!=f&&8!=f)return;if(l>0){if(!p){const e=[(t[0]+n[0])/2,(t[1]+n[1])/2],r=this.transformInv_(e);let s;s=d?(FH(i[0],h)+FH(o[0],h))/2-FH(r[0],h):(i[0]+o[0])/2-r[0];const a=(i[1]+o[1])/2-r[1];p=s*s+a*a>this.errorThresholdSquared_}if(p){if(Math.abs(t[0]-n[0])<=Math.abs(t[1]-n[1])){const c=[(e[0]+n[0])/2,(e[1]+n[1])/2],u=this.transformInv_(c),h=[(r[0]+t[0])/2,(r[1]+t[1])/2],d=this.transformInv_(h);this.addQuad_(t,e,c,h,i,s,u,d,l-1),this.addQuad_(h,c,n,r,d,u,o,a,l-1)}else{const c=[(t[0]+e[0])/2,(t[1]+e[1])/2],u=this.transformInv_(c),h=[(n[0]+r[0])/2,(n[1]+r[1])/2],d=this.transformInv_(h);this.addQuad_(t,c,h,r,i,u,d,a,l-1),this.addQuad_(c,e,n,h,u,s,o,d,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}11&f||this.addTriangle_(t,n,r,i,o,a),14&f||this.addTriangle_(t,n,e,i,o,s),f&&(13&f||this.addTriangle_(e,r,t,s,a,i),7&f||this.addTriangle_(e,r,n,s,a,o))}calculateSourceExtent(){const t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach(function(e){const n=e.source;rG(t,n[0]),rG(t,n[1]),rG(t,n[2])}),t}getTriangles(){return this.triangles_}},I8=class extends m8{constructor(t,e,n,r,i,s,o,a,l,c,u,h){super(i,0,h),this.renderEdges_=void 0!==u&&u,this.pixelRatio_=o,this.gutter_=a,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=r,this.wrappedTileCoord_=s||i,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const d=r.getTileCoordExtent(this.wrappedTileCoord_),p=this.targetTileGrid_.getExtent();let f=this.sourceTileGrid_.getExtent();const g=p?gG(d,p):d;if(0===aG(g))return void(this.state=4);const m=t.getExtent();m&&(f=f?gG(f,m):m);const y=r.getResolution(this.wrappedTileCoord_[0]),v=function(t,e,n,r){let i=T8(t,e,uG(n),r);return(!isFinite(i)||i<=0)&&oG(n,function(n){return i=T8(t,e,n,r),isFinite(i)&&i>0}),i}(t,n,g,y);if(!isFinite(v)||v<=0)return void(this.state=4);const b=void 0!==c?c:.5;if(this.triangulation_=new P8(t,n,g,f,v*b,y),0===this.triangulation_.getTriangles().length)return void(this.state=4);this.sourceZ_=e.getZForResolution(v);let w=this.triangulation_.calculateSourceExtent();if(f&&(t.canWrapX()?(w[1]=PH(w[1],f[1],f[3]),w[3]=PH(w[3],f[1],f[3])):w=gG(w,f)),aG(w)){let n=0,r=0;t.canWrapX()&&(n=bG(m),r=Math.floor((w[0]-m[0])/n)),kG(w.slice(),t,!0).forEach(t=>{const i=e.getTileRangeForExtentAndZ(t,this.sourceZ_);for(let e=i.minX;e<=i.maxX;e++)for(let t=i.minY;t<=i.maxY;t++){const i=r*n;this.sourceTiles_.push({getTile:()=>l(this.sourceZ_,e,t,o),offset:i})}++r}),0===this.sourceTiles_.length&&(this.state=4)}else this.state=4}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const n=e.tile;if(n&&2==n.getState()){const r=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);r[0]+=e.offset,r[2]+=e.offset;const i=this.clipExtent_?.slice();i&&(i[0]+=e.offset,i[2]+=e.offset),t.push({extent:r,clipExtent:i,image:n.getImage()})}}),this.sourceTiles_.length=0,0===t.length)this.state=3;else{const e=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(e),r="number"==typeof n?n:n[0],i="number"==typeof n?n:n[1],s=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=L8(r,i,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=2}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(0==this.state){this.state=1,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const n=e.getState();if(0==n||1==n){t++;const n=EW(e,LW,()=>{const r=e.getState();2!=r&&3!=r&&4!=r||(TW(n),t--,0===t&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t}){0==t.getState()&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(TW),this.sourcesListenerKeys_=null}release(){this.canvas_&&(yY(this.canvas_.getContext("2d")),S8.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}},M8=class{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof NW&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const n=this.entries_[t];return SH(void 0!==n,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(t){const e=this.entries_[t];return SH(void 0!==e,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.key_;return t}getValues(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){SH(!(t in this.entries_),"Tried to set a value for a key that is used already");const n={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[t]=n,++this.count_}setSize(t){this.highWaterMark=t}};function A8(t,e,n,r){return void 0!==r?(r[0]=t,r[1]=e,r[2]=n,r):[t,e,n]}function O8(t,e,n,r,i){return`${QW(t)},${e},${function(t,e,n){return t+"/"+e+"/"+n}(n,r,i)}`}function F8(t,e,n){if(!(n in t))return t[n]=new Set([e]),!0;const r=t[n],i=r.has(e);return i||r.add(e),!i}function N8(t,e,n){const r=t[n];return!!r&&r.delete(e)}function z8(t,e){const n=t.layerStatesArray[t.layerIndex];n.extent&&(e=gG(e,HK(n.extent,t.viewState.projection)));const r=n.layer.getRenderSource();if(!r.getWrapX()){const n=r.getTileGridForProjection(t.viewState.projection).getExtent();n&&(e=gG(e,n))}return e}var D8=class extends y2{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new C8(0,0,0,0),this.tempTileCoord_=A8(0,0,0);const n=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new M8(n),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=.5*n}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new M8(512)),this.sourceTileCache_}getOrCreateTile(t,e,n,r){const i=this.tileCache_,s=this.getLayer().getSource(),o=O8(s,s.getKey(),t,e,n);let a;if(i.containsKey(o))a=i.get(o);else{const l=r.viewState.projection,c=s.getProjection();if(a=s.getTile(t,e,n,r.pixelRatio,l,!c||DK(c,l)?void 0:this.getSourceTileCache()),!a)return null;i.set(o,a)}return a}getTile(t,e,n,r){return this.getOrCreateTile(t,e,n,r)||null}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),r=QK(e.pixelToCoordinateTransform,t.slice()),i=n.getExtent();if(i&&!GH(i,r))return null;const s=e.viewState,o=n.getRenderSource(),a=o.getTileGridForProjection(s.projection),l=o.getTilePixelRatio(e.pixelRatio);for(let c=a.getZForResolution(s.resolution);c>=a.getMinZoom();--c){const t=a.getTileCoordForCoordAndZ(r,c),n=this.getTile(c,t[1],t[2],e);if(!n||2!==n.getState())continue;const i=a.getOrigin(c),u=fJ(a.getTileSize(c)),h=a.getResolution(c);let d;if(n instanceof x8||n instanceof I8)d=n.getImage();else{if(!(n instanceof _8))continue;if(d=y8(n.getData()),!d)continue}const p=Math.floor(l*((r[0]-i[0])/h-t[1]*u[0])),f=Math.floor(l*((i[1]-r[1])/h-t[2]*u[1])),g=Math.round(l*o.getGutterForProjection(s.projection));return this.getImageData(d,p+g,f+g)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const n=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,n,r,i){const s=t.viewState,o=this.getLayer(),a=o.getRenderSource(),l=a.getTileGridForProjection(s.projection),c=QW(a);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],h=o.getMapInternal(),d=Math.max(n-i,l.getMinZoom(),l.getZForResolution(Math.min(o.getMaxResolution(),h?h.getView().getResolutionForZoom(Math.max(o.getMinZoom(),0)):l.getResolution(0)),a.zDirection)),p=s.rotation,f=p?pG(s.center,s.resolution,p,t.size):void 0;for(let g=n;g>=d;--g){const n=l.getTileRangeForExtentAndZ(e,g,this.tempTileRange_),i=l.getResolution(g);for(let e=n.minX;e<=n.maxX;++e)for(let s=n.minY;s<=n.maxY;++s){if(p&&!l.tileCoordIntersectsViewport([g,e,s],f))continue;const n=this.getTile(g,e,s,t);if(!n)continue;if(!F8(r,n,g))continue;const o=n.getKey();if(u[o]=!0,0===n.getState()&&!t.tileQueue.isKeyQueued(o)){const r=A8(g,e,s,this.tempTileCoord_);t.tileQueue.enqueue([n,c,l.getTileCoordCenter(r),i])}}}}findStaleTile_(t,e){const n=this.tileCache_,r=t[0],i=t[1],s=t[2],o=this.getStaleKeys();for(let a=0;a0&&setTimeout(()=>{this.enqueueTiles(t,x,h-1,w,_-1)},0),!(h in w))return this.container;const C=QW(this),k=t.time;for(const I of w[h]){const e=I.getState();if(4===e)continue;const n=I.tileCoord;if(2===e&&1===I.getAlpha(C,k)){I.endTransition(C);continue}if(3!==e&&(this.renderComplete=!1),this.findStaleTile_(n,w)){N8(w,I,h),t.animate=!0;continue}if(this.findAltTiles_(u,n,h+1,w))continue;const r=u.getMinZoom();for(let t=h-1;t>=r&&!this.findAltTiles_(u,n,t,w);--t);}const S=d/s*a/f,E=this.getRenderContext(t);eZ(this.tempTransform,g/2,m/2,S,S,0,-g/2,-m/2),this.layerExtent&&this.clipUnrotated(E,t,this.layerExtent),c.getInterpolate()||(E.imageSmoothingEnabled=!1),this.preRender(E,t);const R=Object.keys(w).map(Number);R.sort(zW);const T=[],L=[],P=[];for(let I=R.length-1;I>=0;--I){const e=R[I],n=c.getTilePixelSize(e,a,i),r=u.getResolution(e)/d,s=n[0]*r*S,o=n[1]*r*S,l=u.getTileCoordForCoordAndZ(yG(b),e),p=u.getTileCoordExtent(l),g=QK(this.tempTransform,[f*(p[0]-b[0])/d,f*(b[3]-p[3])/d]),m=f*c.getGutterForProjection(i);for(const i of w[e]){if(2!==i.getState())continue;const n=i.tileCoord,r=l[1]-n[1],a=Math.round(g[0]-(r-1)*s),u=l[2]-n[2],d=Math.round(g[1]-(u-1)*o),p=Math.round(g[0]-r*s),f=Math.round(g[1]-u*o),y=a-p,v=d-f,b=e===h;if(b&&i.inTransition(C)){P.push({tile:i,x:p,y:f,w:y,h:v,gutter:m}),this.renderedTiles.unshift(i),this.updateUsedTiles(t.usedTiles,c,i);continue}const w=[p,f,p+y,f+v],_=[];for(let t=0,i=T.length;t0&&(x=SG(w,_)),T.push(w),L.push(e),this.drawTile(i,t,p,f,y,v,m,b,x),this.renderedTiles.unshift(i),this.updateUsedTiles(t.usedTiles,c,i)}}for(let I=0,M=P.length;I{const n=QW(c),r=e.wantedTiles[n],i=r?Object.keys(r).length:0;this.updateCacheSize(i),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(e)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,n,r,i,s,o,a,l){let c;if(t instanceof _8){if(c=y8(t.getData()),!c)throw new Error("Rendering array data is not yet supported")}else c=this.getTileImage(t);if(!c)return;const u=this.getRenderContext(e),h=QW(this),d=e.layerStatesArray[e.layerIndex],p=d.opacity*(a?t.getAlpha(h,e.time):1),f=p!==u.globalAlpha;f&&(u.save(),u.globalAlpha=p);const g=c.width-2*o,m=c.height-2*o;if(l){const t=g/i,e=m/s;for(let i=0,s=l.length;it.value):null;let y;t:for(let v=p.length-1;v>=0;--v){const e=p[v];if(!wG(l.getTileCoordExtent(e.wrappedTileCoord),u))continue;const r=e.executorGroups[f];for(let i=0,a=r.length;i{const n=this.getLayer(),r=n.getSource(),i=this.renderedProjection,s=i.getExtent(),o=this.renderedResolution,a=r.getTileGridForProjection(i),l=QK(this.renderedPixelToCoordinateTransform_,t.slice()),c=a.getTileCoordForCoordAndResolution(l,o).toString(),u=this.renderedTiles.find(t=>t.tileCoord.toString()===c&&2===t.getState());if(!u||u.loadingSourceTiles>0)return void e([]);r.getWrapX()&&i.canWrapX()&&!KH(s,a.getTileCoordExtent(u.tileCoord))&&TG(l,i);const h=QW(n),d=yG(a.getTileCoordExtent(u.wrappedTileCoord)),p=[(l[0]-d[0])/o,(d[1]-l[1])/o],f=u.getSourceTiles().reduce((t,e)=>t.concat(e.getFeatures()),[]);let g=u.hitDetectionImageData[h];if(!g){const t=fJ(a.getTileSize(a.getZForResolution(o,r.zDirection))),e=this.renderedRotation_;g=o2(t,[this.getRenderTransform(a.getTileCoordCenter(u.wrappedTileCoord),o,0,s2,t[0]*s2,t[1]*s2,0)],f,n.getStyleFunction(),a.getTileCoordExtent(u.wrappedTileCoord),u.getReplayState(n).renderedResolution,e),u.hitDetectionImageData[h]=g}e(a2(p,f,g))})}getFeaturesInExtent(t){const e=[],n=this.getTileCache();if(0===n.getCount())return e;const r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),i=r.getZForResolution(this.renderedResolution),s={};return n.forEach(n=>{if(n.tileCoord[0]!==i||2!==n.getState())return;const o=n.getSourceTiles();for(let i=0,a=o.length;i=0;--r)n[r].execute(this.context,o,this.getTileRenderTransform(e,t),t.viewState.rotation,s,J1,l)}n.globalAlpha=r}renderDeferredInternal(t){const e=this.renderedTiles,n=QW(this.getLayer()),r=e.reduce((t,e,r)=>(e.executorGroups[n].forEach(e=>t.push({executorGroup:e,index:r})),t),[]),i=r.map(({executorGroup:t})=>t.getDeferredZIndexContexts()),s={};for(let a=0,l=r.length;a{i.forEach((e,n)=>{e[t]&&(e[t].forEach(t=>{const{executorGroup:e,index:i}=r[n],s=e.getRenderedContext(),o=s.globalAlpha;s.globalAlpha=this.renderedOpacity_;const a=this.tileClipContexts_[i];a&&a.draw(s),t.draw(s),a&&s.restore(),s.globalAlpha=o,t.clear()}),e[t].length=0)})}),this.layerExtent&&this.context.restore()}getTileRenderTransform(t,e){const n=e.pixelRatio,r=e.viewState,i=r.center,s=r.resolution,o=r.rotation,a=e.size,l=Math.round(a[0]*n),c=Math.round(a[1]*n),u=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),h=t.tileCoord,d=u.getTileCoordExtent(t.wrappedTileCoord),p=u.getTileCoordExtent(h,this.tempExtent)[0]-d[0];return XK(tZ(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(i,s,o,n,l,c,p))}clipTileContext_(t,e,n,r,i,s){const o=[];for(let l=0,c=n.length;l!J1.includes(t)):V8[s],c=e.viewState,u=c.rotation;this.layerExtent&&this.clipUnrotated(t,e,this.layerExtent);const h=i.getSource(),d=h.getTileGridForProjection(c.projection).getZForResolution(c.resolution,h.zDirection),p=this.renderedTiles,f=[],g=[],m=[],y=QW(i);let v=!0;for(let b=p.length-1;b>=0;--b){const n=p[b];v=v&&!n.getReplayState(i).dirty;const s=n.executorGroups[y].filter(t=>t.hasExecutors(l));if(0===s.length)continue;const o=this.getTileRenderTransform(n,e),c=n.tileCoord[0];let h=!1;const w=s[0].getClipCoords(GK);let _,x=t;if(w){const t=[w[0],w[1],w[4],w[5]];_=new j1,x=_.getContext(),d!==c&&(h=this.clipTileContext_(x,t,f,g,c,o)),f.push(t),g.push(c)}for(let i=0,d=s.length;ivoid 0!==t)),this.minZoom=void 0!==e?e:0,this.resolutions_=n,SH(function(t){const e=((t,e)=>e-t)||zW;return t.every(function(n,r){if(0===r)return!0;const i=e(t[r-1],n);return!(i>0||0===i)})}(this.resolutions_),"`resolutions` must be sorted in descending order"),!t.origins)for(let s=0,o=this.resolutions_.length-1;s{const n=new C8(Math.min(0,t[0]),Math.max(t[0]-1,-1),Math.min(0,t[1]),Math.max(t[1]-1,-1));if(i){const t=this.getTileRangeForExtentAndZ(i,e);n.minX=Math.max(t.minX,n.minX),n.maxX=Math.min(t.maxX,n.maxX),n.minY=Math.max(t.minY,n.minY),n.maxY=Math.min(t.maxY,n.maxY)}return n}):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,n){const r=this.getTileRangeForExtentAndZ(t,e);for(let i=r.minX,s=r.maxX;i<=s;++i)for(let t=r.minY,o=r.maxY;t<=o;++t)n([e,i,t])}forEachTileCoordParentTileRange(t,e,n,r){let i,s,o,a=null,l=t[0]-1;for(2===this.zoomFactor_?(s=t[1],o=t[2]):a=this.getTileCoordExtent(t,r);l>=this.minZoom;){if(void 0!==s&&void 0!==o?(s=Math.floor(s/2),o=Math.floor(o/2),i=k8(s,s,o,o,n)):i=this.getTileRangeForExtentAndZ(a,l,n),e(l,i))return!0;--l}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,n){if(t[0]this.maxZoom||e0?r:Math.max(s/n[0],i/n[1]);const o=e+1,a=new Array(o);for(let l=0;ln||n>e.getMaxZoom())return!1;const s=e.getFullTileRange(n);return!s||s.containsXY(r,i)}(t,r)?t:null}clear(){}refresh(){this.clear(),super.refresh()}},o7=class extends KW{constructor(t,e){super(t),this.tile=e}},a7=class t extends s7{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tilePixelRatio:e.tilePixelRatio,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===t.prototype.tileUrlFunction,this.tileLoadFunction=e.tileLoadFunction,e.tileUrlFunction&&(this.tileUrlFunction=e.tileUrlFunction),this.urls=null,e.urls?this.setUrls(e.urls):e.url&&this.setUrl(e.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,n=QW(e),r=e.getState();let i;1==r?(this.tileLoadingKeys_[n]=!0,i="tileloadstart"):n in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[n],i=3==r?"tileloaderror":2==r?"tileloadend":void 0),null!=i&&this.dispatchEvent(new o7(i,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,void 0!==e?this.setKey(e):this.changed()}setUrl(t){const e=function(t){const e=[];let n=/\{([a-z])-([a-z])\}/.exec(t);if(n){const r=n[1].charCodeAt(0),i=n[2].charCodeAt(0);let s;for(s=r;s<=i;++s)e.push(t.replace(n[0],String.fromCharCode(s)));return e}if(n=/\{(\d+)-(\d+)\}/.exec(t),n){const r=parseInt(n[2],10);for(let i=parseInt(n[1],10);i<=r;i++)e.push(t.replace(n[0],i.toString()));return e}return e.push(t),e}(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join("\n");this.generateTileUrlFunction_?this.setTileUrlFunction(i7(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,n){}},l7=class extends a7{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:c7,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:void 0===t.interpolate||t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy=t.referrerPolicy,this.tileClass=void 0!==t.tileClass?t.tileClass:x8,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!DK(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||DK(e,t)))return this.tileGrid;const n=QW(t);return n in this.tileGridForProjection||(this.tileGridForProjection[n]=Z8(t)),this.tileGridForProjection[n]}createTile_(t,e,n,r,i,s){const o=[t,e,n],a=this.getTileCoordForTileUrlFunction(o,i),l=a?this.tileUrlFunction(a,r,i):void 0,c=new this.tileClass(o,void 0!==l?0:4,void 0!==l?l:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return c.key=s,c.addEventListener(LW,this.handleTileChange.bind(this)),c}getTile(t,e,n,r,i,s){const o=this.getProjection();if(!o||!i||DK(o,i))return this.getTileInternal(t,e,n,r,o||i);const a=[t,e,n],l=this.getKey(),c=this.getTileGridForProjection(o),u=this.getTileGridForProjection(i),h=this.getTileCoordForTileUrlFunction(a,i),d=new I8(o,c,i,u,a,h,this.getTilePixelRatio(r),this.getGutter(),(t,e,n,r)=>this.getTileInternal(t,e,n,r,o,s),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(t,e,n,r,i,s){const o=this.getKey(),a=O8(this,o,t,e,n);if(s&&s.containsKey(a))return s.get(a);const l=this.createTile_(t,e,n,r,i,o);return s?.set(a,l),l}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const n=MK(t);if(n){const t=QW(n);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}};function c7(t,e){if(dH){const n=t.getCrossOrigin();let r="same-origin",i="same-origin";"anonymous"===n||""===n?(r="cors",i="omit"):"use-credentials"===n&&(r="cors",i="include");const s={mode:r,credentials:i,referrerPolicy:t.getReferrerPolicy()};return void fetch(e,s).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.blob()}).then(t=>createImageBitmap(t)).then(e=>{const n=t.getImage();n.width=e.width,n.height=e.height,n.getContext("2d").drawImage(e,0,0),e.close?.(),n.dispatchEvent(new Event("load"))}).catch(()=>{t.getImage().dispatchEvent(new Event("error"))})}t.getImage().src=e}var u7=class extends l7{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:MK("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.tileJSON_=null,this.tileSize_=t.tileSize,t.url)if(t.jsonp)!function(t,e,n){const r=document.createElement("script"),i="olc_"+QW(e);function s(){delete window[i],r.parentNode.removeChild(r)}r.async=!0,r.src=t+(t.includes("?")?"&":"?")+"callback="+i;const o=setTimeout(function(){s(),n&&n()},1e4);window[i]=function(t){clearTimeout(o),s(),e(t)},document.head.appendChild(r)}(t.url,this.handleTileJSONResponse.bind(this),this.handleTileJSONError.bind(this));else{const e=new XMLHttpRequest;e.addEventListener("load",this.onXHRLoad_.bind(this)),e.addEventListener("error",this.onXHRError_.bind(this)),e.open("GET",t.url),e.send()}else{if(!t.tileJSON)throw new Error("Either `url` or `tileJSON` options must be provided");this.handleTileJSONResponse(t.tileJSON)}}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch{return void this.handleTileJSONError()}this.handleTileJSONResponse(t)}else this.handleTileJSONError()}onXHRError_(t){this.handleTileJSONError()}getTileJSON(){return this.tileJSON_}handleTileJSONResponse(t){const e=MK("EPSG:4326"),n=this.getProjection();let r;if(void 0!==t.bounds){const i=jK(e,n);r=xG(t.bounds,i)}const i=J8(n),s=t.minzoom||0,o=Y8({extent:i,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=i7(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==r?r:i;this.setAttributions(function(n){return wG(e,n.extent)?[t.attribution]:null})}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}},h7=[],d7=class extends m8{constructor(t,e,n,r,i){super(t,e,{transition:0}),this.context_=null,this.executorGroups={},this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=r.bind(void 0,this),this.removeSourceTiles_=i,this.wrappedTileCoord=n}getContext(){return this.context_||(this.context_=gY(1,1,h7)),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(t){const e=QW(t);return e in this.replayState_||(this.replayState_[e]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedPixelRatio:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[e]}load(){this.getSourceTiles()}release(){this.context_&&(yY(this.context_),h7.push(this.context_.canvas),this.context_=null),this.removeSourceTiles_(this),this.sourceTiles.length=0,super.release()}},p7=class extends m8{constructor(t,e,n,r,i,s){super(t,e,s),this.extent=null,this.format_=r,this.features_=null,this.loader_,this.projection=null,this.resolution,this.tileLoadFunction_=i,this.url_=n,this.key=n}getTileUrl(){return this.url_}getFormat(){return this.format_}getFeatures(){return this.features_}load(){0==this.state&&(this.setState(1),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(t,e){this.setFeatures(t)}onError(){this.setState(3)}setFeatures(t){this.features_=t,this.setState(2)}setLoader(t){this.loader_=t}},f7=class extends a7{constructor(t){const e=t.projection||"EPSG:3857",n=t.extent||J8(e),r=t.tileGrid||Y8({extent:n,maxResolution:t.maxResolution,maxZoom:void 0!==t.maxZoom?t.maxZoom:22,minZoom:t.minZoom,tileSize:t.tileSize||512});super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,interpolate:!0,projection:e,state:t.state,tileGrid:r,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:g7,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:void 0===t.zDirection?1:t.zDirection}),this.format_=t.format?t.format:null,this.tileKeysBySourceTileUrl_={},this.sourceTiles_={},this.overlaps_=null==t.overlaps||t.overlaps,this.tileClass=t.tileClass?t.tileClass:p7,this.tileGrids_={}}getOverlaps(){return this.overlaps_}getSourceZ_(t,e,n){const r=this.projection,i=e&&r&&!DK(e,r)?t/r.getMetersPerUnit()*e.getMetersPerUnit():t;return this.tileGrid.getZForResolution(i,n)}getSourceTiles(t,e,n,r){if(0===n.getState()){n.setState(1);const i=n.wrappedTileCoord,s=this.getTileGridForProjection(e);let o=s.getTileCoordExtent(i);const a=i[0],l=s.getResolution(a);VH(o,-l,o);const c=this.projection;e&&this.projection&&!DK(e,c)&&(o=qK(o,e,c));const u=this.tileGrid,h=u.getExtent();h&&gG(o,h,o);const d=this.getSourceZ_(l,e,this.zDirection),p=r||this.tileUrlFunction;u.forEachTileCoord(o,d,r=>{const i=p(r,t,e);this.sourceTiles_[i]||(this.sourceTiles_[i]=new this.tileClass(r,i?0:4,i,this.format_,this.tileLoadFunction));const s=this.sourceTiles_[i];n.sourceTiles.push(s),this.tileKeysBySourceTileUrl_[i]||(this.tileKeysBySourceTileUrl_[i]=[]),this.tileKeysBySourceTileUrl_[i].push(n.getKey());const o=s.getState();if(o<2){const t=e=>{this.handleTileChange(e);const r=s.getState();if(2===r||3===r){const e=s.getKey();e in n.errorTileKeys?2===s.getState()&&delete n.errorTileKeys[e]:n.loadingSourceTiles--,3===r?n.errorTileKeys[e]=!0:s.removeEventListener(LW,t),0===n.loadingSourceTiles&&n.setState(SW(n.errorTileKeys)?2:3)}};s.addEventListener(LW,t),n.loadingSourceTiles++}0===o&&(s.extent=u.getTileCoordExtent(r),s.projection=this.projection,s.resolution=u.getResolution(r[0]),s.load())}),n.loadingSourceTiles||n.setState(n.sourceTiles.some(t=>3===t.getState())?3:2)}return n.sourceTiles}removeSourceTiles(t){const e=t.getKey(),n=t.sourceTiles;for(let r=0,i=n.length;r{u=u&&!this.tileUrlFunction(t,r,l)})}const h=this.tileUrlFunction,d=new d7(s,u?4:0,o,t=>this.getSourceTiles(r,i,t,h),this.removeSourceTiles.bind(this));return d.key=this.getKey(),d}getTileGridForProjection(t){const e=t.getCode();let n=this.tileGrids_[e];if(!n){const r=this.projection;if(null!==r&&!DK(r,t))return Z8(t);const i=this.tileGrid,s=i.getResolutions().slice(),o=s.map(function(t,e){return i.getOrigin(e)}),a=s.map(function(t,e){return i.getTileSize(e)}),l=43;for(let t=s.length;tb7.pitch||0],"distance-from-center":[{kind:"number"},[],()=>b7.distanceFromCenter||0],"to-hsla":[{kind:"array",itemType:{kind:"number"},N:4},[{kind:"string"}],(t,[e])=>function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=t[3],s=Math.max(e,n,r),o=Math.min(e,n,r),a=(s+o)/2;let l,c;if(s===o)l=0,c=0;else{const t=s-o;switch(c=a>.5?t/(2-s-o):t/(s+o),s){case e:l=(n-r)/t+(ne.evaluate(t)],"measure-light":[{kind:"number"},[{kind:"value"}],()=>1],config:[{kind:"value"},[{kind:"string"}],(t,[e])=>{const n=v7[e.evaluate(t)];return void 0===n?{}:n}]});var w7="https://api.mapbox.com";function _7(t){return 0!==t.indexOf("mapbox://")?"":t.slice(9)}function x7(t,e,n){const r=_7(t);if(!e||!r)return decodeURI(new URL(t,n).href);if(0!==r.indexOf("sprites/"))throw new Error(`unexpected sprites url: ${t}`);const i=r.slice(8);return`${w7}/styles/v1/${i}/sprite?access_token=${e}`}function C7(t,e){const n=_7(t);if(!n||!e)return decodeURI(new URL(t,location.href).href);if(0!==n.indexOf("styles/"))throw new Error(`unexpected style url: ${t}`);const r=n.slice(7);return`${w7}/styles/v1/${r}?&access_token=${e}`}var k7=["a","b","c","d"];function S7(t,e,n,r){const i=new URL(t,r||location.href),s=_7(t);return s?"mapbox.satellite"===s?[`https://api.mapbox.com/v4/${s}/{z}/{x}/{y}${window.devicePixelRatio>=1.5?"@2x":""}.webp?access_token=${e}`]:k7.map(t=>`https://${t}.tiles.mapbox.com/v4/${s}/{z}/{x}/{y}.vector.pbf?access_token=${e}`):e?(i.searchParams.has(n)||i.searchParams.set(n,e),[decodeURI(i.href)]):[decodeURI(i.href)]}var E7=class extends y2{constructor(t){super(t),this.image=null,this.renderedSourceRevision_=0}getImage(){return this.image?this.image.getImage():null}prepareFrame(t){const e=t.layerStatesArray[t.layerIndex],n=t.pixelRatio,r=t.viewState,i=r.resolution,s=this.getLayer().getSource(),o=t.viewHints;let a=t.extent;if(void 0!==e.extent&&(a=gG(a,HK(e.extent,r.projection))),!o[0]&&!o[1]&&!_G(a))if(s){this.getLayer().rendered||this.renderedSourceRevision_===s.getRevision()||(this.image=null),this.renderedSourceRevision_=s.getRevision();const t=r.projection,e=s.getImage(a,i,n,t);e&&(this.loadImage(e)?this.image=e:4===e.getState()&&(this.image=null))}else this.image=null;return!!this.image}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),r=QK(e.pixelToCoordinateTransform,t.slice()),i=n.getExtent();if(i&&!GH(i,r))return null;const s=this.image.getExtent(),o=this.image.getImage(),a=bG(s),l=Math.floor(o.width*((r[0]-s[0])/a));if(l<0||l>=o.width)return null;const c=fG(s),u=Math.floor(o.height*((s[3]-r[1])/c));return u<0||u>=o.height?null:this.getImageData(o,l,u)}renderFrame(t,e){const n=this.image,r=n.getExtent(),i=n.getResolution(),[s,o]=Array.isArray(i)?i:[i,i],a=n.getPixelRatio(),l=t.layerStatesArray[t.layerIndex],c=t.pixelRatio,u=t.viewState,h=u.center,d=u.resolution,p=c*s/(d*a),f=c*o/(d*a);this.prepareContainer(t,e);const g=this.context.canvas.width,m=this.context.canvas.height,y=this.getRenderContext(t);let v=!1,b=!0;if(l.extent){const e=HK(l.extent,u.projection);b=wG(e,t.extent),v=b&&!KH(e,t.extent),v&&this.clipUnrotated(y,t,e)}const w=n.getImage(),_=eZ(this.tempTransform,g/2,m/2,p,f,0,a*(r[0]-h[0])/s,a*(h[1]-r[3])/o);this.renderedResolution=o*c/a;const x=w.width*_[0],C=w.height*_[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,t),b&&x>=.5&&C>=.5){const t=_[4],e=_[5],n=l.opacity;1!==n&&(y.save(),y.globalAlpha=n),y.drawImage(w,0,0,+w.width,+w.height,t,e,x,C),1!==n&&y.restore()}return this.postRender(this.context,t),v&&y.restore(),y.imageSmoothingEnabled=!0,this.container}},R7=class extends RX{constructor(t){super(t=t||{})}},T7=class extends R7{constructor(t){super(t)}createRenderer(){return new E7(this)}getData(t){return super.getData(t)}},L7=class extends BQ{constructor(t,e,n,r,i){super(t,e,n,void 0!==i?0:2),this.loader_=void 0!==i?i:null,this.canvas_=r,this.error_=null}getError(){return this.error_}handleLoad_(t){t?(this.error_=t,this.state=3):this.state=2,this.changed()}load(){0==this.state&&(this.state=1,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}};function P7(t){return Array.isArray(t)?Math.min(...t):t}var I7=class extends BQ{constructor(t,e,n,r,i,s,o){let a=t.getExtent();a&&t.canWrapX()&&(a=a.slice(),a[0]=-1/0,a[2]=1/0);let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);const c=l?gG(n,l):n,u=T8(t,e,uG(c),r),h=new P8(t,e,c,a,.5*u,r),d=h.calculateSourceExtent(),p=_G(d)?null:s(d,u,i),f=p?0:4,g=p?p.getPixelRatio():1;super(n,r,g,f),this.targetProj_=e,this.maxSourceExtent_=a,this.triangulation_=h,this.targetResolution_=r,this.targetExtent_=n,this.sourceImage_=p,this.sourcePixelRatio_=g,this.interpolate_=o,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){1==this.state&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(2==t){const t=bG(this.targetExtent_)/this.targetResolution_,e=fG(this.targetExtent_)/this.targetResolution_;this.canvas_=L8(t,e,this.sourcePixelRatio_,P7(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=t,this.changed()}load(){if(0==this.state){this.state=1,this.changed();const t=this.sourceImage_.getState();2==t||3==t?this.reproject_():(this.sourceListenerKey_=EW(this.sourceImage_,LW,()=>{const t=this.sourceImage_.getState();2!=t&&3!=t||(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){TW(this.sourceListenerKey_),this.sourceListenerKey_=null}},M7=class extends KW{constructor(t,e){super(t),this.image=e}},A7=class extends R2{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:void 0===t.interpolate||t.interpolate}),this.on,this.once,this.un,this.loader=t.loader||null,this.resolutions_=void 0!==t.resolutions?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=!!t.loader&&0===t.loader.length,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();return e&&(t=e[jW(e,t,0)]),t}getImage(t,e,n,r){const i=this.getProjection();if(!i||!r||DK(i,r))return i&&(r=i),this.getImageInternal(t,e,n,r);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&DK(this.reprojectedImage_.getProjection(),r)&&this.reprojectedImage_.getResolution()==e&&eG(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new I7(i,r,t,e,n,(t,e,n)=>this.getImageInternal(t,e,n,i),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,n,r){if(this.loader){const i=function(t,e,n){const r=e/n,i=uG(t),s=jH(bG(t)/r,4),o=jH(fG(t)/r,4);return dG(i,r,0,[s+2*jH(0*s/2,4),o+2*jH(0*o/2,4)])}(t,e,n),s=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===r&&(this.wantedExtent_&&KH(this.wantedExtent_,i)||KH(this.image.getExtent(),i))&&(this.wantedResolution_&&P7(this.wantedResolution_)===s||P7(this.image.getResolution())===s)))return this.image;this.wantedProjection_=r,this.wantedExtent_=i,this.wantedResolution_=s,this.image=new BQ(i,s,n,this.loader),this.image.addEventListener(LW,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const e=t.target;let n;switch(e.getState()){case 1:this.loading=!0,n="imageloadstart";break;case 2:this.loading=!1,n="imageloadend";break;case 3:this.loading=!1,n="imageloaderror";break;default:return}this.hasListener(n)&&this.dispatchEvent(new M7(n,e))}};function O7(t){return function(e){const n=e.buffers,r=e.meta,i=e.imageOps,s=e.width,o=e.height,a=n.length,l=n[0].byteLength;if(i){const e=new Array(a);for(let t=0;tthis.maxQueueLength_;)this.queue_.shift().callback(null,null)}dispatch_(){if(this.running_||0===this.queue_.length)return;const t=this.queue_.shift();this.job_=t;const e=t.inputs[0].width,n=t.inputs[0].height,r=t.inputs.map(function(t){return t.data.buffer}),i=this.workers_.length;if(this.running_=i,1===i)return void this.workers_[0].postMessage({buffers:r,meta:t.meta,imageOps:this.imageOps_,width:e,height:n},r);const s=t.inputs[0].data.length,o=4*Math.ceil(s/4/i);for(let a=0;at*h/180),w=(e.altitudes||[45]).map(t=>t*h/180),_=Math.min(b.length,w.length,y.length,v.length,4),x=f<2?.4:f<4.5?.35:.3,C=f<15?Math.pow(2,(15-f)*x):1;function k(t,e="mapbox"){return"mapbox"===e?.1*(256*t[0]*256+256*t[1]+t[2])-1e4:"terrarium"===e?256*t[0]+t[1]+t[2]/256-32768:0}function S(t,e){return 0!==t?Math.atan2(e,-t):h/2*(e>0?1:-1)}const E="igor"===g?function(t,e){const n=S(t*=2*p,e*=2*p),r=b[0]+h,i=Math.atan(Math.sqrt(t*t+e*e))*(2/h);let s=(n+r)/h+.5;s%=2,s<0&&(s+=2);const o=1-Math.abs(s-1),a=i*o,l=i*(1-o),c=y[0],u=v[0];return[c.r*a+u.r*l,c.g*a+u.g*l,c.b*a+u.b*l,c.a*a+u.a*l]}:"basic"===g?function(t,e){t*=2*p,e*=2*p;const n=b[0]+h,r=Math.cos(n),i=Math.sin(n),s=Math.cos(w[0]),o=(Math.sin(w[0])-(e*r*s-t*i*s))/Math.sqrt(1+t*t+e*e),a=Math.max(0,Math.min(1,o));if(a>.5){const t=2*a-1,e=v[0];return[e.r*t,e.g*t,e.b*t,e.a*t]}const l=1-2*a,c=y[0];return[c.r*l,c.g*l,c.b*l,c.a*l]}:"combined"===g?function(t,e){t*=2*p,e*=2*p;const n=b[0]+h,r=Math.cos(n),i=Math.sin(n),s=Math.cos(w[0]),o=Math.sin(w[0]);let a=Math.acos((o-(e*r*s-t*i*s))/Math.sqrt(1+t*t+e*e));a=Math.max(0,Math.min(h/2,a));const l=Math.atan(Math.sqrt(t*t+e*e))*(4/h/h),c=a*l,u=(h/2-a)*l,d=y[0],f=v[0];return[d.r*c+f.r*u,d.g*c+f.g*u,d.b*c+f.b*u,d.a*c+f.a*u]}:"multidirectional"===g?function(t,e){const n=(t*=2*p)*t+(e*=2*p)*e,r=Math.sqrt(1+n);let i=0,s=0,o=0,a=0;for(let l=0;l<_;l++){const n=Math.cos(w[l]),c=(Math.sin(w[l])-(e*-Math.cos(b[l])*n-t*-Math.sin(b[l])*n))/r,u=Math.max(0,Math.min(1,c)),h=y[Math.min(l,y.length-1)],d=v[Math.min(l,v.length-1)];if(u>.5){const t=(2*u-1)/_;i+=d.r*t,s+=d.g*t,o+=d.b*t,a+=d.a*t}else{const t=(1-2*u)/_;i+=h.r*t,s+=h.g*t,o+=h.b*t,a+=h.a*t}}return[i,s,o,a]}:function(t,e){const n=b[0]+h,r=Math.atan(.625*Math.sqrt(t*t+e*e)),i=S(t,e),s=1.875-1.75*p,o=.5*h,a=.5!==p?(Math.pow(s,r)-1)/(Math.pow(s,o)-1)*o:r,l=Math.cos(a),c=Math.min(Math.max(2*p,0),1),u=(1-l)*c,d=m,f=d.r*u,g=d.g*u,w=d.b*u,_=d.a*u;let x=(i+n)/h+.5;x%=2,x<0&&(x+=2);const C=Math.abs(x-1),k=Math.sin(a)*c,E=y[0],R=v[0],T=(E.r*(1-C)+R.r*C)*k,L=(E.g*(1-C)+R.g*C)*k,P=(E.b*(1-C)+R.b*C)*k,I=(E.a*(1-C)+R.a*C)*k;return[f*(1-I)+T,g*(1-I)+L,w*(1-I)+P,_*(1-I)+I]};let R,T,L,P,I,M,A,O,F,N,z;for(T=0;T<=c;++T)for(I=0===T?0:T-1,M=T===c?c:T+1,R=0;R<=l;++R){L=0===R?0:R-1,P=R===l?l:R+1,A=4*(T*r+L),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],O=k(u,d),A=4*(T*r+P),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],F=k(u,d),N=(F-O)/a*C,A=4*(I*r+R),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],O=k(u,d),A=4*(M*r+R),u[0]=s[A],u[1]=s[A+1],u[2]=s[A+2],u[3]=s[A+3],F=k(u,d),z=(F-O)/a*C;const t=E(N,z),e=t[3];A=4*(T*r+R),e>0&&(o[A]=t[0]/e*255,o[A+1]=t[1]/e*255,o[A+2]=t[2]/e*255),o[A+3]=255*e}return new ImageData(o,r,i)}function q7(t,e){const n=t[0],r=n.width,i=n.height,s=n.data,o=new Uint8ClampedArray(s.length),a=r-1,l=i-1,c=[0,0,0,0];let u,h,d;const p=(f=e.saturation)>0?1-1/(1.001-f):-f;var f;const g=(m=e.contrast)>0?1/(1-m):1+m;var m;const y=function(t){t*=Math.PI/180;const e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}(e.hueRotate),v=y,b=[y[2],y[0],y[1]],w=[y[1],y[2],y[0]],_=e.brightnessLow,x=e.brightnessHigh;for(h=0;h<=l;++h)for(u=0;u<=a;++u){d=4*(h*r+u),c[0]=s[d],c[1]=s[d+1],c[2]=s[d+2],c[3]=s[d+3];const t=c[0],e=c[1],n=c[2],i=(t,e)=>{let n=0;for(let r=0;r1?h[h.length-2].toLowerCase():"";if(d==p||d==p.replace("-","")||f+"-"+d==p){o=i?o:V7[p],h.pop(),f&&p.startsWith(f)&&h.pop();break}}i||"number"!=typeof d||(o=d,i=!0);var g=h.join(W7).replace("Klokantech Noto Sans","Noto Sans").replace("DIN Pro","Barlow").replace("Arial Unicode MS","Arial");-1!==g.indexOf(W7)&&(g='"'+g+'"'),l.push(g)}r=G7[t]=[a,o,l]}return r[0]+W7+r[1]+W7+e+"px"+(n?"/"+n:"")+W7+r[2]}var Z7=Object.freeze({}),Y7={},X7={},J7=0;function Q7(t){return t.id||(t.id=J7++),t.id}function t9(t){let e=Y7[t.id];return e||(e={},Y7[Q7(t)]=e),e}function e9(t){return t*Math.PI/180}var n9=function(){const t=[];for(let e=78271.51696402048;t.length<=24;e/=2)t.push(e);return t}();function r9(t,e){if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,e);const n=document.createElement("canvas");return n.width=t,n.height=e,n}function i9(t,e){let n=0;const r=e.length;for(;ni).then(t=>t instanceof Response?(r&&(r.url=t.url),o(t)):(t instanceof Request||(t=new Request(t)),t.headers.get("Accept")||t.headers.set("Accept","application/json"),r&&(r.url=t.url),fetch(t).then(o).catch(s))).catch(s);return o9[e]=[i,a],a}function l9(t,e){if("string"!=typeof t)return Promise.resolve(t);if(!t.trim().startsWith("{"))return a9("Style",t=C7(t,e.accessToken),e);try{const e=JSON.parse(t);return Promise.resolve(e)}catch(Z4){return Promise.reject(Z4)}}var c9={};function u9(t,e,n={}){const r=[e,JSON.stringify(t)].toString();let i=c9[r];if(!i||n.transformRequest){let s;n.transformRequest&&(s=(t,e)=>{const r=n.transformRequest&&n.transformRequest(e,"Tiles")||e;if(t instanceof p7)t.setLoader((e,n,i)=>{const s=function(n){n.arrayBuffer().then(n=>{const r=t.getFormat().readFeatures(n,{extent:e,featureProjection:i});t.setFeatures(r)})};GW(()=>r).then(e=>{if(e instanceof Response)return s(e);fetch(e).then(s).catch(()=>t.setState(3))}).catch(()=>t.setState(3))});else{const e=t.getImage();GW(()=>r).then(n=>{if("string"==typeof n)return void(e.src=n);const r=t=>t.blob().then(t=>{const n=URL.createObjectURL(t);e.addEventListener("load",()=>URL.revokeObjectURL(n)),e.addEventListener("error",()=>URL.revokeObjectURL(n)),e.src=n});if(n instanceof Response)return r(n);fetch(n).then(r).catch(()=>t.setState(3))}).catch(()=>t.setState(3))}});const o=t.url;if(o&&!t.tiles){const r=S7(o,n.accessToken,n.accessTokenParam||"access_token",e||location.href);if(o.startsWith("mapbox://"))i=Promise.resolve({tileJson:Object.assign({},t,{url:void 0,tiles:r}),tileLoadFunction:s});else{const t={};i=a9("Source",r[0],n,t).then(function(e){return e.tiles=e.tiles.map(function(r){return"tms"===e.scheme&&(r=r.replace("{y}","{-y}")),S7(r,n.accessToken,n.accessTokenParam||"access_token",t.url)[0]}),Promise.resolve({tileJson:e,tileLoadFunction:s})})}}else t.tiles?(t=Object.assign({},t,{tiles:t.tiles.map(function(r){return"tms"===t.scheme&&(r=r.replace("{y}","{-y}")),S7(r,n.accessToken,n.accessTokenParam||"access_token",e||location.href)[0]})}),i=Promise.resolve({tileJson:Object.assign({},t),tileLoadFunction:s})):i=Promise.reject(new Error("source has no `tiles` nor `url`"));c9[r]=i}return i}function h9(t,e,n,r){const i=[2*n*e.pixelRatio+e.width,2*n*e.pixelRatio+e.height],s=r9(i[0],i[1]),o=s.getContext("2d");o.drawImage(t,e.x,e.y,e.width,e.height,n*e.pixelRatio,n*e.pixelRatio,e.width,e.height);const a=o.getImageData(0,0,i[0],i[1]);o.globalCompositeOperation="destination-over",o.fillStyle=`rgba(${255*r.r},${255*r.g},${255*r.b},${r.a})`;const l=a.data;for(let c=0,u=a.width;c0&&o.arc(c,t,n*e.pixelRatio,0,2*Math.PI);return o.fill(),s}function d9(t,e,n){const r=Math.max(0,Math.min(1,(n-t)/(e-t)));return r*r*(3-2*r)}function p9(t,e,n){const r=r9(e.width,e.height),i=r.getContext("2d");i.drawImage(t,e.x,e.y,e.width,e.height,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),o=s.data;for(let a=0,l=s.width;a0?(o[e+0]=Math.round(255*n.r*r),o[e+1]=Math.round(255*n.g*r),o[e+2]=Math.round(255*n.b*r),o[e+3]=Math.round(255*r)):o[e+3]=0}return i.putImageData(s,0,0),r}var f9,g9=Array(256).join(" ");function m9(t,e){if(e>=.05){let n="";const r=t.split("\n"),i=g9.slice(0,Math.round(e/.1));for(let t=0,e=r.length;t0&&(n+="\n"),n+=r[t].split("").join(i);return n}return t}function y9(){return f9||(f9=r9(1,1).getContext("2d")),f9}function v9(t,e){if(/\d+ \d+/.test(t)){const[n,r]=t.split(" ").map(Number);return n<=e&&e<=r}return t==e}function b9(t,e){return y9().measureText(t).width+(t.length-1)*e}var w9={};function _9(t,e,n,r){if(-1!==t.indexOf("\n")){const i=t.split("\n"),s=[];for(let t=0,o=i.length;t1){const t=y9();t.font=e;const i=t.measureText("M").width*n;let a="";const l=[];for(let e=0,n=o.length;e1;++e){const t=l[e];if(b9(t,r)<.35*i){const i=e>0?b9(l[e-1],r):1/0,s=e.7*i&&b9(s,r)<.6*i){const o=t.split(" "),a=o.pop();b9(a,r)<.2*i&&(l[e]=o.join(" "),l[e+1]=a+" "+s),n-=1}}s=l.join("\n")}else s=t;s=m9(s,r),w9[i]=s}return s}n0.on("propertychange",()=>{for(const t in w9)delete w9[t]});var x9,C9,k9=["Arial","Courier New","Times New Roman","Verdana","sans-serif","serif","monospace","cursive","fantasy"],S9={},E9={Point:1,MultiPoint:1,LineString:2,MultiLineString:2,Polygon:3,MultiPolygon:3},R9={center:[.5,.5],left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],"top-left":[0,0],"top-right":[1,0],"bottom-left":[0,1],"bottom-right":[1,1]},T9=function(t,e){let n=o6(t,e);if("error"===n.result){const r=y7(t);r!==t&&(n=o6(r,e))}if("error"===n.result){const r=n.value[0];return console.error("Error parsing expression:",t,r.key,r.message),{evaluate:()=>e.default}}return n.value};function L9(t,e,n,r,i,s){const o=t.id;i||(i={},console.warn("No functionCache provided to getValue()")),i[o]||(i[o]={});const a=i[o];if(!a[n]){let r=(t[e]||Z7)[n];const i=o8[`${e}_${t.type}`]&&o8[`${e}_${t.type}`][n];void 0===r&&i&&(r=i.default);let s=n6(r);if(!s&&t6(r)&&(r=w6(r,i),s=!0),s){const t=T9(r,i);a[n]=t.evaluate.bind(t)}else{const t=i?i.type:typeof r;"color"!==t&&"colorArray"!==t||(r=r5.parse(r));let e=!1;if("array"===t)for(let n=0;n!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};u6(t)||(t=f6(t));const e=r6(t,h6,void 0);if("error"===e.result)throw new Error(e.value.map(t=>`${t.key}: ${t.message}`).join(", "));return{filter:(t,n,r)=>e.value.evaluate(t,n,{},r),needGeometry:p6(t),getGlobalStateRefs:()=>l6(e.value.expression)}}(e).filter}catch(i){console.warn("Filter will evaluate to false: "+i.message),r[t]=function(){return!1}}return r[t](b7,n)}function M9(t,e){if(t){if(0===t.a||0===e)return;const n=t.a;return e=void 0===e?1:e,0===n?"transparent":"rgba("+Math.round(255*t.r/n)+","+Math.round(255*t.g/n)+","+Math.round(255*t.b/n)+","+n*e+")"}return t}var A9=/\{[^{}}]*\}/g;function O9(t,e){return t.replace(A9,function(t){return e[t.slice(1,-1)]||""})}function F9(t,e){let n=t.split(":")[0];return n===t&&(n="default"),e[n]}var N9={},z9=r5.parse("#000000"),D9=r5.parse("#FFFFFF"),j9=r5.parse("#000000"),U9=["raster-saturation","raster-contrast","raster-brightness-max","raster-brightness-min","raster-hue-rotate"],B9=["background","circle","fill","fill-extrusion","line","symbol","raster","hillshade"];function $9(t,e=512){return t.getExtent()?Y8({extent:t.getExtent(),tileSize:e,maxZoom:22}).getResolutions():n9}function q9(t,e){return e.accessToken||(e=Object.assign({},e),new URL(t).searchParams.forEach((t,n)=>{e.accessToken=t,e.accessTokenParam=n})),e}var V9=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function W9(t,e){if(!e.ref)return e;const n=t.find(t=>t.id===e.ref);if(!n)return e;const r=Object.assign({},e);for(const i of V9)!(i in r)&&i in n&&(r[i]=n[i]);return r}function H9(t,e,n){const r=new u7({tileJSON:e,tileSize:t.tileSize||e.tileSize||512}),i=r.getTileJSON(),s=r.getTileGrid(),o=MK(n.projection||"EPSG:3857"),a=function(t,e){const n=t.bounds;if(n){const t=NK([n[0],n[1]],e),r=NK([n[2],n[3]],e);return[t[0],t[1],r[0],r[1]]}return MK(e).getExtent()}(i,o),l=o.getExtent(),c=i.minzoom||0,u=i.maxzoom||22,h={attributions:r.getAttributions(),projection:o,tileGrid:new K8({origin:l?yG(l):s.getOrigin(0),extent:a||s.getExtent(),minZoom:c,resolutions:$9(o,e.tileSize).slice(0,u+1),tileSize:s.getTileSize(0)})};return Array.isArray(i.tiles)?h.urls=i.tiles:h.url=i.tiles,h}function G9(t,e,n){return new Promise(function(r,i){u9(t,e,n).then(function({tileJson:e,tileLoadFunction:i}){const s=H9(t,e,n);s.tileLoadFunction=i,s.format=new h8({layerName:"mvt:layer"});const o=new f7(s);o.set("mapbox-source",t),r(o)}).catch(i)})}function K9(t){return`{bbox-${(t?t.getCode():"EPSG:3857").toLowerCase().replace(/[^a-z0-9]/g,"-")}}`}function Z9(t,e,n){const r=new $8;return function(t,e,n){return new Promise(function(r,i){u9(t,e,n).then(function({tileJson:e,tileLoadFunction:i}){const s=new u7({interpolate:void 0===n.interpolate||n.interpolate,transition:0,crossOrigin:"anonymous",tileJSON:e});s.tileGrid=H9(t,e,n).tileGrid,n.projection&&(s.projection=MK(n.projection));const o=s.getTileUrlFunction();i&&s.setTileLoadFunction(i),s.setTileUrlFunction(function(t,e,n){const r=K9(n);let i=o(t,e,n);if(-1!=i.indexOf(r)){const e=s.getTileGrid().getTileCoordExtent(t);i=i.replace(r,e.toString())}return i}),s.set("mapbox-source",t),r(s)}).catch(function(t){i(t)})})}(t,e,n).then(function(t){r.setSource(t)}).catch(function(){r.setSource(void 0)}),r}function Y9(t,e,n){const r=n.projection?new $2({dataProjection:n.projection}):new $2,i=t.data,s={};if("string"==typeof i){const[s]=S7(i,n.accessToken,n.accessTokenParam||"access_token",e||location.href);if(/\{bbox-[0-9a-z-]+\}/.test(s)){const e=(t,e,n)=>{const r=K9(n);return s.replace(r,`${t.join(",")}`)},i=new M2({attributions:t.attribution,format:r,loader:(t,r,s,o,a)=>{a9("GeoJSON","function"==typeof e?e(t,r,s):e,n).then(t=>{const e=i.getFormat().readFeatures(t,{featureProjection:s});i.addFeatures(e),o(e)}).catch(()=>{i.removeLoadedExtent(t),a()})},strategy:C2});return i.set("mapbox-source",t),i}const o=new M2({attributions:t.attribution,format:r,url:s,loader:(t,e,r,i,a)=>{a9("GeoJSON",s,n).then(t=>{const e=o.getFormat().readFeatures(t,{featureProjection:r});o.addFeatures(e),i(e)}).catch(()=>{o.removeLoadedExtent(t),a()})}});return o}s.features=r.readFeatures(i,{featureProjection:"EPSG:3857"});const o=new M2(Object.assign({attributions:t.attribution,format:r},s));return o.set("mapbox-source",t),o}function X9(t,e,n,r){n=W9(t.layers,n);const i=t9(t),s=n.type;let o=n.source;const a=t.sources[o];let l;var c;return"background"==s?(l=function(t,e,n){const r=dH?{style:{}}:document.createElement("div");return r.className="ol-mapbox-style-background",r.style.position="absolute",r.style.width="100%",r.style.height="100%",new RX({source:new R2({}),render(i){const s=function(t,e,n,r){const i={id:t.id,type:t.type},s=t.paint||{};let o;i.paint=s,b7.zoom=i9(e,n.resolutions||n9),b7.distanceFromCenter=0;const a=L9(i,"paint","background-color",Z7,r);return void 0!==s["background-opacity"]&&(o=L9(i,"paint","background-opacity",Z7,r)),"none"===L9(i,"layout","visibility",Z7,r)?void 0:M9(a,o)}(t,i.viewState.resolution,e,n);return r.style.backgroundColor=s,r}})}(n,r,i),o=void 0):"vector"==a.type?l=function(t,e,n){const r=new H8({declutter:!0,visible:!1});return G9(t,e,n).then(function(t){r.setSource(t)}).catch(function(){r.setSource(void 0)}),r}(a,e,r):"raster"==a.type?(Object.keys(n.paint||{}).find(t=>U9.includes(t))?(c=Z9(a,e,r),l=new T7({source:new D7({operationType:"image",operation:q7,sources:[c]})}),function(t,e,n,r){t.getSource().on("beforeoperations",function(t){b7.zoom=i9(t.resolution,n.resolutions||n9),b7.distanceFromCenter=0;const i=t.data;i.saturation=L9(e,"paint","raster-saturation",Z7,r),i.contrast=L9(e,"paint","raster-contrast",Z7,r),i.brightnessHigh=L9(e,"paint","raster-brightness-max",Z7,r),i.brightnessLow=L9(e,"paint","raster-brightness-min",Z7,r),i.hueRotate=L9(e,"paint","raster-hue-rotate",Z7,r)})}(l,n,r,i)):l=Z9(a,e,r),l.setVisible(!n.layout||"none"!==L9(n,"layout","visibility",Z7,i)),l.on("prerender",function(t,e,n){let r=null;return function(i){t.paint&&"raster-opacity"in t.paint&&i.frameState.viewState.zoom!==r&&(r=i.frameState.viewState.zoom,delete n[t.id],function(t,e,n,r){b7.zoom=n,b7.distanceFromCenter=0;const i=L9(t,"paint","raster-opacity",Z7,r);e.setOpacity(i)}(t,e,r,n))}}(n,l,i))):"geojson"==a.type?l=function(t,e,n){return new b2({declutter:!0,source:Y9(t,e,n),visible:!1})}(a,e,r):"raster-dem"==a.type&&"hillshade"==n.type&&(l=function(t){return new T7({source:new D7({operationType:"image",operation:$7,sources:[t]})})}(Z9(a,e,r)),function(t,e,n,r,i){t.getSource().on("beforeoperations",function(t){const s=t.data;s.resolution=AK(r.projection||"EPSG:3857",t.resolution,uG(t.extent),"m");const o=i9(t.resolution,r.resolutions||n9);b7.zoom=o,b7.distanceFromCenter=0,s.zoom=o,s.encoding=e.encoding,s.method=L9(n,"paint","hillshade-method",Z7,i)||"standard",s.exaggeration=L9(n,"paint","hillshade-exaggeration",Z7,i);let a=L9(n,"paint","hillshade-illumination-direction",Z7,i);null==a&&(a=335),s.azimuths=Array.isArray(a)?a:[a],s.sunAz=s.azimuths[0];let l=L9(n,"paint","hillshade-illumination-altitude",Z7,i);function c(t){return t&&t.values?t.values[0]:t}function u(t){const e=n.paint?.[t];if(Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&void 0!==r5.parse(e[0]))return e.map(t=>r5.parse(t));let r=L9(n,"paint",t,Z7,i);return r=c(r),r?[r]:void 0}null==l&&(l=45),s.altitudes=Array.isArray(l)?l:[l],s.highlightColors=u("hillshade-highlight-color"),s.highlightColor=s.highlightColors?.[0]||D9,s.highlightColors||(s.highlightColors=[s.highlightColor]),s.shadowColors=u("hillshade-shadow-color"),s.shadowColor=s.shadowColors?.[0]||z9,s.shadowColors||(s.shadowColors=[s.shadowColor]),s.accentColor=c(L9(n,"paint","hillshade-accent-color",Z7,i))||j9})}(l,a,n,r,i),l.setVisible(!n.layout||"none"!==L9(n,"layout","visibility",Z7,i))),l&&l.set("mapbox-source",o),l}function J9(t,e,n,r){t.schema&&Object.assign(v7,Object.keys(t.schema).reduce((e,n)=>(e[n]=t.schema[n]?.default,e),{}));const i=[];let s=null;if(e instanceof n1){if(s=e.getView(),!s.isDef()&&!s.getRotation()&&!s.getResolutions()){const t=r.projection?MK(r.projection):s.getProjection();s=new nY(Object.assign(s.getProperties(),{maxResolution:n9[0]/NG[t.getUnits()],projection:r.projection||s.getProjection()})),e.setView(s)}"center"in t&&!s.getCenter()&&s.setCenter(NK(t.center,s.getProjection())),"zoom"in t&&void 0===s.getZoom()&&s.setResolution(n9[0]/NG[s.getProjection().getUnits()]/Math.pow(2,t.zoom)),s.getCenter()&&void 0!==s.getZoom()||s.fit(s.getProjection().getExtent(),{nearest:!0,size:e.getSize()})}e.set("mapbox-style",t),e.set("mapbox-metadata",{styleUrl:n,options:r});const o=t.layers;let a,l,c,u=[];for(let h=0,d=o.length;h0||n>0)&&t.setMaxResolution(Math.min(s9(Math.max(0,o-1e-12),n9),s9(Math.max(0,n-1e-12),e.getResolutions()))),a<24&&t.setMinResolution(s9(a,n9))}}else o>0&&t.setMaxResolution(s9(Math.max(0,o-1e-12),n9));u instanceof M2||u instanceof f7?function(t,e,n="",r={},i){let s,o,a,l,c=!0;return"string"==typeof n||Array.isArray(n)?l=n:(a=n,l=a.source||a.layers,r=a),"string"==typeof r?(s=r,a={}):(s=r.styleUrl,a=r),!1===a.updateSource&&(c=!1),i||(i=a.resolutions),s||"string"!=typeof e||e.trim().startsWith("{")||(s=e),s&&(s=s.startsWith("data:")?location.href:C7(s,a.accessToken),a=q9(s,a)),new Promise(function(n,r){l9(e,a).then(function(e){if(8!=e.version)return r(new Error("glStyle version 8 required."));if(!(t instanceof b2||t instanceof H8))return r(new Error("Can only apply to VectorLayer or VectorTileLayer"));const u=t instanceof H8?"vector":"geojson";if(l?o=Array.isArray(l)?e.layers.find(function(t){return t.id===l[0]}).source:l:(o=e.layers.find(function(t){return t.source&&e.sources[t.source].type===u}).source,l=o),!o)return r(new Error(`No ${u} source found in the glStyle.`));function h(){if(!c)return Promise.resolve();if(t instanceof H8)return G9(e.sources[o],s,a).then(function(e){const n=t.getSource();n?e!==n&&(n.setTileUrlFunction(e.getTileUrlFunction()),"function"==typeof n.setUrls&&"function"==typeof e.getUrls&&n.setUrls(e.getUrls()),n.format_||(n.format_=e.format_),n.getAttributions()||n.setAttributions(e.getAttributions()),n.getTileLoadFunction()===g7&&n.setTileLoadFunction(e.getTileLoadFunction()),DK(n.getProjection(),e.getProjection())&&(n.tileGrid=e.getTileGrid())):t.setSource(e);const r=t.getSource().getTileGrid();!isFinite(t.getMaxResolution())&&!isFinite(t.getMinZoom())&&r.getMinZoom()>0&&t.setMaxResolution(s9(Math.max(0,r.getMinZoom()-1e-12),r.getResolutions()))});const n=e.sources[o];let r=t.getSource();r&&r.get("mapbox-source")===n||(r=Y9(n,s,a));const i=t.getSource();return i?r!==i&&(i.getAttributions()||i.setAttributions(r.getAttributions()),i.format_||(i.format_=r.getFormat()),i.url_=r.getUrl()):t.setSource(r),Promise.resolve()}let d,p;const f={},g={};function m(){if(p||e.sprite&&!f)p?(t.setStyle(p),h().then(n).catch(r)):r(new Error("Something went wrong trying to apply style."));else{if(a.projection&&!i){const t=MK(a.projection).getUnits();"m"!==t&&(i=n9.map(e=>e/NG[t]))}let s;const c=t.getSource();c instanceof f7&&c.format_ instanceof h8&&(s=c.format_.layerName_),p=function(t,e,n,r=n9,i,s,o,a){if("string"==typeof e&&(e=JSON.parse(e)),e.schema)for(const b in e.schema){const t=e.schema[b];"default"in t&&(v7[b]=t.default)}if(8!=e.version)throw new Error("glStyle version 8 required.");N9[function(t,e){return Q7(t)+"."+QW(e)}(e,t)]=Array.from(arguments);const l={};("string"==typeof s||s instanceof Request||s instanceof Response||s instanceof Promise)&&(s={default:s});for(const b in s){const e=s[b];GW(()=>e).then(async e=>{let n;if("undefined"!=typeof Image){const r=new Image;if("string"==typeof e)r.crossOrigin="anonymous",r.src=e;else{let t;e instanceof Request?t=await fetch(e):e instanceof Response&&(t=e);const i=await t.blob();n=URL.createObjectURL(i),r.src=n}r.addEventListener("load",function e(){r.removeEventListener("load",e),l[b]={image:r,size:[r.width,r.height]},t.changed(),n&&URL.revokeObjectURL(n)}),r.addEventListener("error",function t(){URL.revokeObjectURL(n),r.removeEventListener("error",t)})}else if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){const t=self;t.postMessage({action:"loadImage",src:e}),t.addEventListener("message",function(t){"imageLoaded"===t.data.action&&t.data.src===e&&(l[b]={image:t.data.image,size:[t.data.image.width,t.data.image.height]})})}})}const c=o3(e.layers),u={},h=[],d={},p={},f=t9(e),g=function(t){let e=X7[t.id];return e||(e={},X7[Q7(t)]=e),e}(e);let m;for(let b=0,w=c.length;b=h.maxzoom)continue;const k=h.filter;if(!k||I9(w,k,S,g)){let r,c,g,v,b,w;R=h;const k=u.index;if(3==_&&("fill"==h.type||"fill-extrusion"==h.type))if(c=L9(h,"paint",h.type+"-opacity",S,f,E),h.type+"-pattern"in C){const t=L9(h,"paint",h.type+"-pattern",S,f,E);if(t){const e="string"==typeof t?O9(t,m):t.toString(),n=F9(e,l);if(i&&i[e]&&n){++T,w=y[T],w&&w.getFill()&&!w.getStroke()&&!w.getText()||(w=new b0({fill:new g0}),y[T]=w),g=w.getFill(),w.setZIndex(k);const t=e+"."+c;let r=p[t];if(!r){const s=i[e],o=r9(s.width,s.height),a=o.getContext("2d");a.globalAlpha=c,a.drawImage(n.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),r=a.createPattern(o,"repeat"),p[t]=r}g.setColor(r)}}}else if(r=M9(L9(h,"paint",h.type+"-color",S,f,E),c),h.type+"-outline-color"in C&&(b=M9(L9(h,"paint",h.type+"-outline-color",S,f,E),c)),b||(b=r),r||b){if(++T,w=y[T],(!w||r&&!w.getFill()||!r&&w.getFill()||b&&!w.getStroke()||!b&&w.getStroke()||w.getText())&&(w=new b0({fill:r?new g0:void 0,stroke:b?new v0:void 0}),y[T]=w),r&&(g=w.getFill(),g.setColor(r)),"fill-extrusion"===h.type){const t=L9(h,"paint","fill-extrusion-height",S,f,E);if(t>0){const e=Math.max(.1,.9-Math.min(t,225)/280);if(b&&"transparent"!==b){const t=r5.parse(b);b=`rgba(${Math.round(255*t.r*e)},${Math.round(255*t.g*e)},${Math.round(255*t.b*e)},${t.a})`}}}b&&(v=w.getStroke(),v.setColor(b),v.setWidth(.5)),w.setZIndex(k)}if(1!=_&&"line"==h.type){r="line-pattern"in C?void 0:M9(L9(h,"paint","line-color",S,f,E),L9(h,"paint","line-opacity",S,f,E));const t=L9(h,"paint","line-width",S,f,E);r&&t>0&&(++T,w=y[T],w&&w.getStroke()&&!w.getFill()&&!w.getText()||(w=new b0({stroke:new v0}),y[T]=w),v=w.getStroke(),v.setLineCap(L9(h,"layout","line-cap",S,f,E)),v.setLineJoin(L9(h,"layout","line-join",S,f,E)),v.setMiterLimit(L9(h,"layout","line-miter-limit",S,f,E)),v.setColor(r),v.setWidth(t),v.setLineDash(C["line-dasharray"]?L9(h,"paint","line-dasharray",S,f,E).map(function(e){return e*t}):null),"function"==typeof v.setOffset&&v.setOffset(L9(h,"paint","line-offset",S,f,E)),w.setZIndex(k))}let L,P,I,M,A,O,F,N,z,D=!1,j=null,U=0;if((1==_||2==_)&&"icon-image"in x){const e=L9(h,"layout","icon-image",S,f,E);if(e){let r;L="string"==typeof e?O9(e,m):e.toString();const o=a?a(t,L):void 0,c=F9(L,l);if(i&&i[L]&&c||o){const t=L9(h,"layout","icon-rotation-alignment",S,f,E);if(2==_){const e=n.getGeometry();if(e.getFlatMidpoint||e.getFlatMidpoints){const n=e.getExtent();if(Math.sqrt(Math.max(Math.pow((n[2]-n[0])/s,2),Math.pow((n[3]-n[1])/s,2)))>150){const n="MultiLineString"===e.getType()?e.getFlatMidpoints():e.getFlatMidpoint();if(C9||(C9=new S2("Point",x9=[NaN,NaN],[],2,{},void 0)),r=C9,x9[0]=n[0],x9[1]=n[1],"line"===L9(h,"layout","symbol-placement",S,f,E)&&"map"===t){const t=e.getStride(),r=e.getFlatCoordinates();for(let e=0,i=r.length-t;e=l){U=Math.atan2(s-a,o-i);break}}}}}}if(2!==_||r){const e=L9(h,"layout","icon-size",S,f,E),n=void 0!==C["icon-color"]?L9(h,"paint","icon-color",S,f,E):null;if(!n||0!==n.a){const r=L9(h,"paint","icon-halo-color",S,f,E),s=L9(h,"paint","icon-halo-width",S,f,E);let a=`${L}.${e}.${s}.${r}`;if(null!==n&&(a+=`.${n}`),P=d[a],!P){const l=P9(h,S,"icon",f);let u;"icon-offset"in x&&(u=L9(h,"layout","icon-offset",S,f,E).slice(0),u[0]*=e,u[1]*=-e);let p=n?[255*n.r,255*n.g,255*n.b,n.a]:void 0;if(o){const n={color:p,rotateWithView:"map"===t,displacement:u,declutterMode:l,scale:e};"string"==typeof o?n.src=o:(n.img=o,n.imgSize=[o.width,o.height]),P=new y0(n)}else{const o=i[L];let a,h,d;s?o.sdf?(a=h9(p9(c.image,o,n||[0,0,0,1]),{x:0,y:0,width:o.width,height:o.height,pixelRatio:o.pixelRatio},s,r),p=void 0):a=h9(c.image,o,s,r):(o.sdf&&(c.unSDFed||(c.image=p9(c.image,{x:0,y:0,width:c.size[0],height:c.size[1]},{r:1,g:1,b:1,a:1}),c.unSDFed=!0)),a=c.image,h=[o.width,o.height],d=[o.x,o.y]),P=new y0({color:p,img:a,imgSize:c.size,size:h,offset:d,rotateWithView:"map"===t,scale:e/o.pixelRatio,displacement:u,declutterMode:l})}d[a]=P}}P&&(++T,w=y[T],w&&w.getImage()&&!w.getFill()&&!w.getStroke()||(w=new b0,y[T]=w),w.setGeometry(r),P.setRotation(U+e9(L9(h,"layout","icon-rotate",S,f,E))),P.setOpacity(L9(h,"paint","icon-opacity",S,f,E)),P.setAnchor(R9[L9(h,"layout","icon-anchor",S,f,E)]),w.setImage(P),j=w.getText(),w.setText(void 0),w.setZIndex(k),D=!0,I=!1)}else I=!0}}}if(1==_&&"circle"===h.type){++T,w=y[T],w&&w.getImage()&&!w.getFill()&&!w.getStroke()||(w=new b0,y[T]=w);const t="circle-radius"in C?L9(h,"paint","circle-radius",S,f,E):5,e=M9(L9(h,"paint","circle-stroke-color",S,f,E),L9(h,"paint","circle-stroke-opacity",S,f,E)),n=L9(h,"paint","circle-translate",S,f,E),r=M9(L9(h,"paint","circle-color",S,f,E),L9(h,"paint","circle-opacity",S,f,E)),i=L9(h,"paint","circle-stroke-width",S,f,E),s=t+"."+e+"."+r+"."+i+"."+n[0]+"."+n[1];P=d[s],P||(P=new f0({radius:t,displacement:[n[0],-n[1]],stroke:e&&i>0?new v0({width:i,color:e}):void 0,fill:r?new g0({color:r}):void 0,declutterMode:"none"}),d[s]=P),w.setImage(P),j=w.getText(),w.setText(void 0),w.setGeometry(void 0),w.setZIndex(k),D=!0}if("text-field"in x){F=Math.round(L9(h,"layout","text-size",S,f,E));const t=L9(h,"layout","text-font",S,f,E);O=L9(h,"layout","text-line-height",S,f,E),A=K7(o?o(t,e.metadata?e.metadata["ol:webfonts"]:void 0):t,F,O),A.includes("sans-serif")||(A+=",sans-serif"),N=L9(h,"layout","text-letter-spacing",S,f,E),z=L9(h,"layout","text-max-width",S,f,E);const n=L9(h,"layout","text-field",S,f,E);M="object"==typeof n&&n.sections?1===n.sections.length?n.toString():n.sections.reduce((e,n)=>{const r=n.fontStack?n.fontStack.split(","):t,i=K7(o?o(r):r,F*(n.scale||1),O);let s=n.text;if("\n"===s)return e.push("\n",""),e;if(2==_)return e.push(m9(s,N),i),e;s=_9(s,i,z,N).split("\n");for(let t=0,o=s.length;t0&&e.push("\n",""),e.push(s[t],i);return e},[]):O9(n,m).trim(),c=L9(h,"paint","text-opacity",S,f,E)}if(M&&c&&!I){D||(++T,w=y[T],w&&w.getText()&&!w.getFill()&&!w.getStroke()||(w=new b0,y[T]=w),w.setImage(void 0),w.setGeometry(void 0));const t=P9(h,S,"text",f);w.getText()||w.setText(j),j=w.getText(),(!j||"getDeclutterMode"in j&&j.getDeclutterMode()!==t)&&(j=new C0({padding:[2,2,2,2],declutterMode:t}),w.setText(j));const e=L9(h,"layout","text-transform",S,f,E);"uppercase"==e?M=Array.isArray(M)?M.map((t,e)=>e%2?t:t.toUpperCase()):M.toUpperCase():"lowercase"==e&&(M=Array.isArray(M)?M.map((t,e)=>e%2?t:t.toLowerCase()):M.toLowerCase());const n=Array.isArray(M)?M:2==_?m9(M,N):_9(M,A,z,N);if(j.setText(n),j.setFont(A),j.setRotation(e9(L9(h,"layout","text-rotate",S,f,E))),"function"==typeof j.setKeepUpright){const t=L9(h,"layout","text-keep-upright",S,f,E);j.setKeepUpright(t)}const r=L9(h,"layout","text-anchor",S,f,E),i=D||1==_?"point":L9(h,"layout","symbol-placement",S,f,E);let s;if("line-center"===i?(j.setPlacement("line"),s="center"):j.setPlacement(i),"line"===i&&"function"==typeof j.setRepeat){const t=L9(h,"layout","symbol-spacing",S,f,E);j.setRepeat(2*t)}j.setOverflow("point"===i);let o=L9(h,"paint","text-halo-width",S,f,E);const a=L9(h,"layout","text-offset",S,f,E),l=L9(h,"paint","text-translate",S,f,E);let u=0,d=0;if("point"==i){s="center",-1!==r.indexOf("left")?(s="left",d=o):-1!==r.indexOf("right")&&(s="right",d=-o);const t=L9(h,"layout","text-rotation-alignment",S,f,E);j.setRotateWithView("map"==t)}else j.setMaxAngle(e9(L9(h,"layout","text-max-angle",S,f,E))*M.length/n.length),j.setRotateWithView(!1);j.setTextAlign(s);let p="middle";0==r.indexOf("bottom")?(p="bottom",u=-o-.5*(O-1)*F):0==r.indexOf("top")&&(p="top",u=o+.5*(O-1)*F),j.setTextBaseline(p);const g=L9(h,"layout","text-justify",S,f,E);j.setJustify("auto"===g?void 0:g),j.setOffsetX(a[0]*F+d+l[0]),j.setOffsetY(a[1]*F+u+l[1]);const m=j.getFill()||new g0;m.setColor(M9(L9(h,"paint","text-color",S,f,E),c)),j.setFill(m);const v=M9(L9(h,"paint","text-halo-color",S,f,E),c);if(v&&o>0){const t=j.getStroke()||new v0;t.setColor(v),o*=2;const e=.5*F;t.setWidth(o<=e?o:e),j.setStroke(t)}else j.setStroke(void 0);const b=L9(h,"layout","text-padding",S,f,E),x=j.getPadding();b!==x[0]&&(x[0]=b,x[1]=b,x[2]=b,x[3]=b),w.setZIndex(k)}}}return T>-1?(y.length=T+1,y):void 0};return t.setStyle(v),t.set("mapbox-layers",h),t.set("mapbox-source",m),t.set("mapbox-featurestate",t.get("mapbox-featurestate")||{}),v}(t,e,l,i,f,g,(t,e=a.webfonts)=>function(t,e="https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css"){if(dH)return t;let n;for(let r=0,i=t.length;r{await document.fonts.ready;for(let t=0,r=n.length;tt.family.replace(/^['"]|['"]$/g,"").toLowerCase()===i.toLowerCase()&&v9(t.weight,s)&&t.style===o)){const t=e.replace("{font-family}",i.replace(/ /g,"-").toLowerCase()).replace("{Font+Family}",i.replace(/ /g,"+")).replace("{fontweight}",s).replace("{-fontstyle}",o.replace("normal","").replace(/(.+)/,"-$1")).replace("{fontstyle}",o);if(!document.querySelector('link[href="'+t+'"]')){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}}}})(),t):t}(t,e),a.getImage,s),t.getStyle()?h().then(n).catch(r):r(new Error(`Nothing to show for source [${o}]`))}}if(e.sprite){const t=function(t,e,n){if("string"==typeof t)return[{id:"default",url:x7(t,e,n)}];for(const r of t)r.url=x7(r.url,e,n);return t}(e.sprite,a.accessToken,s||location.href);d=dH?1:window.devicePixelRatio>=1.5?.5:1;const n=.5==d?"@2x":"";Promise.all(t.map(function(t){const e=new URL(t.url);let i=e.origin+e.pathname+n+".json"+e.search;return new Promise(function(t,n){a9("Sprite",i,a).then(t).catch(function(){i=e.origin+e.pathname+".json"+e.search,a9("Sprite",i,a).then(t).catch(n)})}).then(function(i){let s;if(void 0===i&&r(new Error("No sprites found.")),s=e.origin+e.pathname+n+".png"+e.search,a.transformRequest){const t=a.transformRequest(s,"SpriteImage")||s;(t instanceof Request||t instanceof Promise)&&(s=t)}g[t.id]=s;for(const e in i){const n="default"==t.id?e:`${t.id}:${e}`;f[n]=i[e]}}).catch(function(t){r(new Error(`Sprites cannot be loaded: ${i}: ${t.message}`))})})).then(m).catch(r)}else m()}).catch(r)})}(t,n,e,Object.assign({styleUrl:r},s)).then(function(){!function(t,e,n){function r(){const r=e.get("mapbox-style");if(!r)return;const i=o3(r.layers),s=t.get("mapbox-layers"),o=i.filter(function(t){return s.includes(t.id)}).some(function(t){return!t.layout||"visible"===L9(t,"layout","visibility",Z7,n)});t.get("visible")!==o&&t.setVisible(o)}t.on("change",r),r()}(t,i,t9(n)),l()}).catch(c):l()}else c(new Error("Error accessing data for source "+t.get("mapbox-source")))};t.set("mapbox-layers",e);const h=i.getLayers();-1===h.getArray().indexOf(t)&&h.push(t),t.getSource()?u():t.once("change:source",u)})}var ttt=class extends s${static{oN(this.prototype,"osm",[hp])}#j=void lN(this,"osm");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");mapInstance;bookmarkSource;searchResultsSource;selectedShapeSource;searchOverlay;searchOverlayElement;selectedPinOverlay;selectedPinElement;crosshairElement;crosshairOverlay;ignoreNextMapClick=!1;setupMap=A$(t=>{if(this.mapInstance)return;const e=new xX;this.selectedShapeSource=new M2;const n=new b2({source:this.selectedShapeSource,style:new b0({stroke:new v0({color:"#3388ff",width:4}),fill:new g0({color:"rgba(51, 136, 255, 0.1)"})}),zIndex:5});this.bookmarkSource=new M2;const r=new b2({source:this.bookmarkSource,style:t=>{const e=t.get("originalPlace");let n=getComputedStyle(document.documentElement).getPropertyValue("--default-list-color").trim()||"#000000";if(e&&e._listIds&&e._listIds.length>0){const t=e._listIds[0],r=this.storage.lists.find(e=>e.id===t);r&&r.color&&(n=r.color)}return[new b0({image:new f0({radius:10,fill:new g0({color:"rgba(0, 0, 0, 0.2)"}),displacement:[0,-2]})}),new b0({image:new f0({radius:9,fill:new g0({color:n}),stroke:new v0({color:"#fff",width:2})})})]},zIndex:10});this.searchResultsSource=new M2;const i=new Map,s=new b2({source:this.searchResultsSource,style:t=>{const e=t.get("originalPlace"),n=this.mapUi.selectedPlace;if(n){const t=e.osmId&&n.osmId&&e.osmId===n.osmId,r=e.id&&n.id&&e.id===n.id,i=e.lat===n.lat&&e.lon===n.lon;if(t||r||i)return new b0({})}const r=QU(e.osmTags||e),s=r||"default";if(!i.has(s)){const t=getComputedStyle(document.documentElement).getPropertyValue("--marker-color-primary").trim()||"#ea4335";let e=``;if(r){const n=ZU(r);if(n){let r=n.trim();const i=r.indexOf("",i)+1,o=r.lastIndexOf("");-1!==i&&-1!==o&&(r=r.substring(s,o)),e=`\n \n \n ${r}\n \n `}}const n=`\n \n \n \n \n \n \n \n ${e}\n \n `;i.set(s,"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(n.trim()))}return new b0({image:new y0({src:i.get(s),anchor:[.5,.65],scale:1})})},zIndex:11});let o=[14.21683569,27.060114248],a=2.661,l=!1;try{const t=localStorage.getItem("marco:map-view");if(t){const e=JSON.parse(t);e.center&&Array.isArray(e.center)&&2===e.center.length&&"number"==typeof e.zoom&&(o=e.center,a=e.zoom,l=!0)}}catch(S){console.warn("Failed to restore map view:",S)}const c=new nY({center:NK(o),zoom:a,projection:"EPSG:3857"});this.mapInstance=new n1({target:t,layers:[e,n,s,r],view:c,controls:TY({zoom:!0,rotate:!0,attribution:!0}),interactions:aX({dragPan:!1})});const u=zK(c.getCenter());this.mapUi.updateCenter(u[1],u[0]),this.mapUi.updateZoom(c.getZoom()),function(t,e,n={}){let r,i;if(dH){if(!(t instanceof n1||t instanceof xX))throw new Error("ol-mapbox-style in a web worker requires a Map or a LayerGroup as first argument");i=t}else i="string"==typeof t||t instanceof HTMLElement?new n1({target:t}):t;if("string"==typeof e){const t=e.startsWith("data:")?location.href:C7(e,n.accessToken);n=q9(t,n),r=new Promise(function(r,s){l9(e,n).then(function(e){J9(e,i,t,n).then(function(){r(i)}).catch(s)}).catch(function(t){s(new Error(`Could not load ${e}: ${t.message}`))})})}else r=new Promise(function(t,r){J9(e,i,!n.styleUrl||n.styleUrl.startsWith("data:")?location.href:C7(n.styleUrl,n.accessToken),n).then(function(){t(i)}).catch(r)})}(this.mapInstance,"https://tiles.openfreemap.org/styles/liberty",{webfonts:"data:text/css,"}),this.searchOverlayElement=document.createElement("div"),this.searchOverlayElement.className="search-pulse",this.searchOverlay=new l1({element:this.searchOverlayElement,positioning:"center-center",stopEvent:!1}),this.mapInstance.addOverlay(this.searchOverlay),this.selectedPinElement=document.createElement("div"),this.selectedPinElement.className="selected-pin-container";const h=document.createElement("div");h.className="selected-pin",h.innerHTML='';const d=document.createElement("div");d.className="selected-pin-shadow",this.selectedPinElement.appendChild(h),this.selectedPinElement.appendChild(d),this.selectedPinOverlay=new l1({element:this.selectedPinElement,positioning:"bottom-center",stopEvent:!1}),this.mapInstance.addOverlay(this.selectedPinOverlay),this.crosshairElement=document.createElement("div"),this.crosshairElement.className="map-crosshair",this.crosshairElement.innerHTML='\n \n \n \n \n ',t.appendChild(this.crosshairElement),this.locationOverlayElement=document.createElement("div"),this.locationOverlayElement.className="search-pulse blue",this.locationOverlay=new l1({element:this.locationOverlayElement,positioning:"center-center",stopEvent:!1}),this.mapInstance.addOverlay(this.locationOverlay),t.addEventListener("pointerdown",()=>{this.mapUi.searchBoxHasFocus&&(this.ignoreNextMapClick=!0)},!0);const p=new n3({trackingOptions:{enableHighAccuracy:!0},projection:c.getProjection()}),f=new c1;f.setStyle(new b0({image:new f0({radius:6,fill:new g0({color:"#3399CC"}),stroke:new v0({color:"#fff",width:2})})}));const g=new M2({features:[f]}),m=new b2({source:g,zIndex:15});p.on("change:position",function(){const t=p.getPosition();f.setGeometry(t?new jZ(t):null)});const y=document.createElement("div");y.className="ol-control ol-locate";const v=document.createElement("button");let b,w;v.style.display="flex",v.style.alignItems="center",v.style.justifyContent="center",v.innerHTML=`${ZU("navigation")}`,v.title="Locate Me",y.appendChild(v);const _=()=>{b&&(clearTimeout(b),b=null);try{w&&(p.un("change:position",x),w=null)}catch{}this.locationOverlayElement&&this.locationOverlayElement.classList.remove("active")},x=()=>{const t=p.getPosition(),e=p.getAccuracyGeometry(),n=p.getAccuracy();if(console.debug("Geolocation change:",{coordinates:t,accuracy:n}),!t)return;const r=this.mapInstance.getSize(),i=this.mapInstance.getView();let s=null;if(this.locationOverlayElement){const e=i.getResolution(),r=2*(n||50)/AK(i.getProjection(),e,t);this.locationOverlayElement.style.width=`${r}px`,this.locationOverlayElement.style.height=`${r}px`,this.locationOverlay.setPosition(t)}if(n&&n<=20&&_(),e){const t=e.getExtent();s=3.162*i.getResolutionForExtent(t,r)}else n&&(s=6.325*n/Math.min(r[0],r[1])/AK(i.getProjection(),1,t));let o={center:t,duration:1e3};if(s){const t=i.getResolutionForZoom(17);o.resolution=Math.max(s,t)}else o.zoom=16;this.mapInstance.getView().animate(o)},C=()=>{console.debug("Getting current geolocation..."),_(),p.setTracking(!0);const t=p.getPosition();this.locationOverlayElement&&this.locationOverlayElement.classList.add("active"),t&&x(),w=p.on("change:position",x),b=setTimeout(()=>{_()},1e4)};v.addEventListener("click",C);const k=new kY({element:y});this.mapInstance.addLayer(m),this.mapInstance.addControl(k),l||"index"!==this.router.currentRouteName||C(),this.mapInstance.on("singleclick",this.handleMapClick),this.mapInstance.on("moveend",this.handleMapMove),this.mapInstance.on("pointermove",t=>{const e=this.mapInstance.getEventPixel(t.originalEvent),n=this.mapInstance.hasFeatureAtPixel(e,{hitTolerance:10});this.mapInstance.getTarget().style.cursor=n?"pointer":""}),this.storage.rs.on("ready",()=>{this.handleMapMove()})});updateInteractions=A$(()=>{if(!this.mapInstance)return;this.mapInstance.getInteractions().getArray().slice().forEach(t=>{t instanceof HY&&this.mapInstance.removeInteraction(t)});const t=!!this.settings.mapKinetic&&new LY(-.005,.05,100);this.settings.mapKinetic&&window.innerWidth<=768&&(t.minVelocity_=.25),this.mapInstance.addInteraction(new HY({kinetic:t}))});updateSearchResults=A$(()=>{if(!this.searchResultsSource)return;this.searchResultsSource.clear();const t=this.mapUi.searchResults;if(!t||0===t.length)return;const e=[];t.forEach(t=>{if(t.lat&&t.lon){const n=new c1({geometry:new jZ(NK([t.lon,t.lat])),name:t.title,id:t.id,isSearchResult:!0,originalPlace:t});e.push(n)}}),e.length>0&&this.searchResultsSource.addFeatures(e)});updateSelectedPin=A$(()=>{const t=this.mapUi.selectedPlace,e=this.mapUi.selectionOptions||{};if(this.searchResultsSource&&this.searchResultsSource.changed(),this.selectedPinOverlay&&this.selectedPinElement)if(this.selectedShapeSource&&this.selectedShapeSource.clear(),t&&t.lat&&t.lon){const r=NK([t.lon,t.lat]);if(this.selectedPinOverlay.setPosition(r),this.selectedPinElement.classList.remove("active"),this.selectedPinElement.offsetWidth,this.selectedPinElement.classList.add("active"),t.geojson&&this.selectedShapeSource)try{const e=(new $2).readFeature(t.geojson,{featureProjection:"EPSG:3857"});this.selectedShapeSource.addFeature(e)}catch(n){console.warn("Failed to render selected place shape:",n)}e.preventZoom?t.bbox&&!this.bboxFitsInView(t.bbox)?this.zoomToBbox(t.bbox):this.handlePinVisibility(r,{maintainZoom:!0}):t.bbox?this.zoomToBbox(t.bbox):this.handlePinVisibility(r)}else this.selectedPinElement.classList.remove("active"),this.selectedPinOverlay.setPosition(void 0)});bboxFitsInView(t){if(!this.mapInstance||!t)return!0;const e=this.mapInstance.getView(),n=this.mapInstance.getSize();return KH(e.calculateExtent(n),[...NK([t.minLon,t.minLat]),...NK([t.maxLon,t.maxLat])])}zoomToBbox(t){if(!this.mapInstance||!t)return;const e=this.mapInstance.getView(),n=this.mapInstance.getSize(),r=[...NK([t.minLon,t.minLat]),...NK([t.maxLon,t.maxLat])];let i=[.15*n[1],.15*n[0],.15*n[1],.15*n[0]];if(n[0]<=768){const t=.5*n[1],e=.15*t,r=.5*n[1]+.15*t;i[0]=e,i[2]=r}else if(this.args.isSidebarOpen){const t=getComputedStyle(document.documentElement).getPropertyValue("--sidebar-width").trim(),e=parseInt(t,10)||360,r=n[0]-e;i[3]=e+.15*r,i[1]=.15*r}const s=e.getZoom();e.fit(r,{padding:i,duration:1e3,easing:t=>t*(2-t),maxZoom:Math.max(s,18)})}handlePinVisibility(t,e={}){if(!this.mapInstance)return;const n=this.mapInstance.getView().getZoom();if(!e.maintainZoom&&n<16)return void this.animateToSmartCenter(t,16);const r=this.mapInstance.getPixelFromCoordinate(t),i=this.mapInstance.getSize();if(!r||r[0]<0||r[0]>i[0]||r[1]<0||r[1]>i[1]){const n=e.maintainZoom?null:16;this.animateToSmartCenter(t,n)}else this.panIfObscured(t)}animateToSmartCenter(t,e=null){if(!this.mapInstance)return;const n=this.mapInstance.getSize(),r=this.mapInstance.getView();let i=r.getResolution();null!==e&&(i=r.getResolutionForZoom(e));let s=t;if(n[0]<=768){const e=n[1],r=document.querySelector(".app-header"),o=r?r.offsetHeight:60,a=(e/2-(o+(e/2-o)/2))*i;s=[t[0],t[1]-a]}else if(this.args.isSidebarOpen){const e=getComputedStyle(document.documentElement).getPropertyValue("--sidebar-width").trim(),n=(parseInt(e,10)||360)/2*i;s=[t[0]-n,t[1]]}const o={center:s,duration:1e3,easing:t=>t*(2-t)};null!==e&&(o.zoom=e),r.animate(o)}panIfObscured(t){if(!this.mapInstance)return;const e=this.mapInstance.getSize(),n=this.mapInstance.getPixelFromCoordinate(t);if(!n)return;const r=this.mapInstance.getView(),i=r.getCenter(),s=r.getResolution();let o=n[0],a=n[1],l=!1;const c=document.querySelector(".app-header"),u=c?c.offsetHeight:60;if(e[0]<=768){const t=e[1],r=t/2;n[1]>r&&(a=u+(t/2-u)/2,l=!0)}else if(this.args.isSidebarOpen){const t=getComputedStyle(document.documentElement).getPropertyValue("--sidebar-width").trim(),r=parseInt(t,10)||360;n[0]t*(2-t)})}}updateBookmarks=A$(()=>{const t=this.storage.placesInView;this.loadBookmarks(t)});async loadBookmarks(t=[]){try{if(!this.bookmarkSource)return;t&&0!==t.length||(t=this.storage.placesInView),this.bookmarkSource.clear(),t&&Array.isArray(t)&&t.forEach(t=>{if(t.lat&&t.lon){const e=new c1({geometry:new jZ(NK([t.lon,t.lat])),name:t.title,id:t.id,isBookmark:!0,originalPlace:t});this.bookmarkSource.addFeature(e)}})}catch(e){console.error("Failed to load bookmarks:",e)}}syncPulse=A$(()=>{this.searchOverlayElement&&(this.mapUi.isSearching?this.searchOverlayElement.classList.add("active"):this.searchOverlayElement.classList.remove("active"))});syncCreationMode=A$(()=>{if(this.crosshairElement&&this.mapInstance)if(this.mapUi.isCreating){this.crosshairElement.classList.add("visible");const t=this.mapUi.creationCoordinates;if(t&&t.lat&&t.lon){const e=NK([t.lon,t.lat]);this.animateToCrosshair(e)}}else this.crosshairElement.classList.remove("visible")});animateToCrosshair(t){if(!this.mapInstance||!this.crosshairElement)return;const e=this.mapInstance.getTargetElement().getBoundingClientRect(),n=this.crosshairElement.getBoundingClientRect(),r=n.left+n.width/2-e.left,i=n.top+n.height/2-e.top,s=this.mapInstance.getSize(),o=r-s[0]/2,a=i-s[1]/2,l=this.mapInstance.getView(),c=l.getResolution(),u=o*c,h=-a*c,d=t[0]-u,p=t[1]-h,f=l.getCenter();Math.sqrt(Math.pow(f[0]-d,2)+Math.pow(f[1]-p,2))>5*c&&l.animate({center:[d,p],duration:800,easing:t=>t*(2-t)})}handleMapMove=async()=>{if(!this.mapInstance||this.isDestroying||this.isDestroyed)return;const t=this.mapInstance.getView(),e=zK(t.getCenter());if(this.mapUi.updateCenter(e[1],e[0]),this.mapUi.updateZoom(t.getZoom()),this.mapUi.isCreating){const t=this.mapInstance.getTargetElement().getBoundingClientRect(),e=this.crosshairElement.getBoundingClientRect(),n=e.left+e.width/2-t.left,r=e.top+e.height/2-t.top,i=zK(this.mapInstance.getCoordinateFromPixel([n,r])),s=parseFloat(i[1].toFixed(6)),o=parseFloat(i[0].toFixed(6));this.mapUi.updateCreationCoordinates(s,o),this.router.replaceWith("place.new",{queryParams:{lat:s,lon:o}})}const n=this.mapInstance.getSize(),r=this.mapInstance.getView().calculateExtent(n),[i,s]=zK([r[0],r[1]]),[o,a]=zK([r[2],r[3]]),l={minLat:s,minLon:i,maxLat:a,maxLon:o};if(this.mapUi.updateBounds(l),await this.storage.loadPlacesInBounds(l),!this.isDestroying&&!this.isDestroyed){this.nostrData.loadPlacesInBounds(l),this.loadBookmarks(this.storage.placesInView);try{const t=this.mapInstance.getView(),e={center:zK(t.getCenter()),zoom:t.getZoom()};localStorage.setItem("marco:map-view",JSON.stringify(e))}catch(c){console.warn("Failed to save map view:",c)}}};handleMapClick=async t=>{if(this.ignoreNextMapClick)return void(this.ignoreNextMapClick=!1);const e=this.mapInstance.getFeaturesAtPixel(t.pixel,{hitTolerance:10});let n=null,r=null,i=null;if(e&&e.length>0){console.debug(`Found ${e.length} features in map layer:`);for(const n of e)console.debug(n);const t=e.find(t=>t.get("isBookmark")),s=e.find(t=>t.get("isSearchResult"));t?n=t.get("originalPlace"):s&&(r=s.get("originalPlace"));const o=e[0].getProperties();o.name&&(i=o.name)}const s=t=>{("search"===this.router.currentRouteName||this.mapUi.currentSearch&&this.mapUi.searchResults.length>0)&&(this.mapUi.returnToSearch=!0),this.mapUi.preventNextZoom=!0,this.mapUi.selectPlace(t,{preventZoom:!0}),this.mapUi.showSidebar(),this.router.transitionTo("place",t)};if(this.args.isSidebarOpen){const t=n||r;return t?(console.debug("Clicked feature while sidebar open (switching):",t),void s(t)):void(this.args.onOutsideClick&&this.args.onOutsideClick())}if(n)return console.debug("Clicked bookmark:",n),void s(n);if(r)return console.debug("Clicked search result:",r),void s(r);if(this.mapUi.searchResults&&this.mapUi.searchResults.length>0)return console.debug("Clearing active search and markers on map click"),void this.router.transitionTo("index");if(this.mapInstance.getView().getZoom()<16)return;const[o,a]=zK(t.coordinate),l=i?30:50;if(this.searchOverlayElement){const e=this.mapInstance.getView(),n=2*l/AK(e.getProjection(),e.getResolution(),t.coordinate);this.searchOverlayElement.style.width=`${n}px`,this.searchOverlayElement.style.height=`${n}px`,this.searchOverlay.setPosition(t.coordinate)}this.mapUi.startSearch();const c={lat:a.toFixed(6),lon:o.toFixed(6),q:null,category:null,selected:i||null};this.router.transitionTo("search",{queryParams:c})};static{Mp(ng({id:null,block:'[[[11,0],[16,0,[29,["map-container ",[52,[30,1],"sidebar-open"]]]],[4,[30,0,["setupMap"]],null,null],[4,[30,0,["updateInteractions"]],null,null],[4,[30,0,["updateBookmarks"]],null,null],[4,[30,0,["updateSearchResults"]],null,null],[4,[30,0,["updateSelectedPin"]],null,null],[4,[30,0,["syncPulse"]],null,null],[4,[30,0,["syncCreationMode"]],null,null],[12],[13]],["@isSidebarOpen"],["if"]]',moduleName:"(unknown template module)",isStrictMode:!0}),this)}},ett=class extends s${static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"osmAuth",[hp])}#we=void lN(this,"osmAuth");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"isNostrConnectModalOpen",[qr],function(){return!1})}#ge=void lN(this,"isNostrConnectModalOpen");connectRS(){this.args.onClose(),this.args.storage.showConnectWidget()}static{aN(this.prototype,"connectRS",[$l])}disconnectRS(){this.args.storage.disconnect()}static{aN(this.prototype,"disconnectRS",[$l])}connectOsm(){this.args.onClose(),this.osmAuth.login()}static{aN(this.prototype,"connectOsm",[$l])}disconnectOsm(){this.osmAuth.logout()}static{aN(this.prototype,"disconnectOsm",[$l])}openNostrConnectModal(){this.isNostrConnectModalOpen=!0}static{aN(this.prototype,"openNostrConnectModal",[$l])}closeNostrConnectModal(){this.isNostrConnectModalOpen=!1}static{aN(this.prototype,"closeNostrConnectModal",[$l])}disconnectNostr(){this.nostrAuth.disconnect()}static{aN(this.prototype,"disconnectNostr",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"user-menu-popover"],[12],[1,"\\n "],[10,"ul"],[14,0,"account-list"],[12],[1,"\\n "],[10,"li"],[14,0,"account-item"],[12],[1,"\\n "],[10,0],[14,0,"account-header"],[12],[1,"\\n "],[10,0],[14,0,"account-info"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["remotestorage",18]],null],[1,"\\n "],[10,1],[12],[1,"RemoteStorage"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,1,["connected"]],[[[1," "],[11,"button"],[24,0,"btn-text text-danger"],[24,4,"button"],[4,[32,1],["click",[30,0,["disconnectRS"]]],null],[12],[1,"Disconnect"],[13],[1,"\\n"]],[]],[[[1," "],[11,"button"],[24,0,"btn-text text-primary"],[24,4,"button"],[4,[32,1],["click",[30,0,["connectRS"]]],null],[12],[1,"Connect"],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"account-status"],[12],[1,"\\n"],[41,[30,1,["connected"]],[[[1," "],[10,"strong"],[12],[1,[30,1,["userAddress"]]],[13],[1,"\\n"]],[]],[[[1," Not connected\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,"li"],[14,0,"account-item"],[12],[1,"\\n "],[10,0],[14,0,"account-header"],[12],[1,"\\n "],[10,0],[14,0,"account-info"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["map",18]],null],[1,"\\n "],[10,1],[12],[1,"OpenStreetMap"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["osmAuth","isConnected"]],[[[1," "],[11,"button"],[24,0,"btn-text text-danger"],[24,4,"button"],[4,[32,1],["click",[30,0,["disconnectOsm"]]],null],[12],[1,"Disconnect"],[13],[1,"\\n"]],[]],[[[1," "],[11,"button"],[24,0,"btn-text text-primary"],[24,4,"button"],[4,[32,1],["click",[30,0,["connectOsm"]]],null],[12],[1,"Connect"],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"account-status"],[12],[1,"\\n"],[41,[30,0,["osmAuth","isConnected"]],[[[1," "],[10,"strong"],[12],[1,[30,0,["osmAuth","userDisplayName"]]],[13],[1,"\\n"]],[]],[[[1," Not connected\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,"li"],[14,0,"account-item"],[12],[1,"\\n "],[10,0],[14,0,"account-header"],[12],[1,"\\n "],[10,0],[14,0,"account-info"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["zap",18]],null],[1,"\\n "],[10,1],[12],[1,"Nostr"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["nostrAuth","isConnected"]],[[[1," "],[11,"button"],[24,0,"btn-text text-danger"],[24,4,"button"],[4,[32,1],["click",[30,0,["disconnectNostr"]]],null],[12],[1,"Disconnect"],[13],[1,"\\n"]],[]],[[[1," "],[11,"button"],[24,0,"btn-text text-primary"],[24,4,"button"],[4,[32,1],["click",[30,0,["openNostrConnectModal"]]],null],[12],[1,"Connect"],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n "],[10,0],[14,0,"account-status"],[12],[1,"\\n"],[41,[30,0,["nostrAuth","isConnected"]],[[[1," "],[10,"strong"],[15,"title",[30,0,["nostrAuth","pubkey"]]],[12],[1,"\\n "],[1,[30,0,["nostrData","userDisplayName"]]],[1,"\\n "],[13],[1,"\\n"]],[]],[[[1," Not connected\\n"]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[41,[30,0,["isNostrConnectModalOpen"]],[[[1," "],[8,[32,2],null,[["@onClose"],[[30,0,["closeNostrConnectModal"]]]],[["default"],[[[[1,"\\n "],[8,[32,3],null,[["@onConnect"],[[30,0,["closeNostrConnectModal"]]]],null],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null]],["@storage"],["if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:o$,on:Vw,Modal:VV,NostrConnect:$V}),isStrictMode:!0}),this)}};function ntt(t){return t}function rtt(t){return Object.keys(t).map(e=>t[e])}function itt(t){if(t)if(t instanceof Vq)t.executor.asyncErrorsHandled=!0;else if(t instanceof kq)return t._toPromise();return t}function stt(t,e,n){return function(r){let i=function(t,e){if(Array.isArray(t))return t.map(e);if("object"==typeof t&&null!==t){let n={};return Object.keys(t).forEach(r=>{n[r]=e(t[r])}),n}return t}(r,itt),s=n(i);Array.isArray(s);let o=ja.defer();t[e](i).then(o.resolve,o.reject);let a=!1,l=()=>{a||(a=!0,s.forEach(t=>{t&&(t instanceof Vq?t.cancel():"function"==typeof t.__ec_cancel__&&t[yq]())}))},c=o.promise.finally(l);return c[yq]=l,c}}stt(ja.Promise,"all",ntt),stt(ja,"allSettled",ntt),stt(na,"race",ntt),stt(ja,"hash",rtt),stt(ja,"hashSettled",rtt);var ott=class extends kq{_deferable(){return Uq.defer()}},att=class extends ott{constructor(t){super(),this.ms=t}onYield(t){let e=Rs(()=>t.next(),this.ms);return()=>Is(e)}},ltt=class extends s${static{oN(this.prototype,"photon",[hp])}#be=void lN(this,"photon");static{oN(this.prototype,"osm",[hp])}#j=void lN(this,"osm");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"map",[hp])}#_e=void lN(this,"map");static{oN(this.prototype,"_internalQuery",[qr],function(){return""})}#xe=void lN(this,"_internalQuery");static{oN(this.prototype,"results",[qr],function(){return[]})}#Ce=void lN(this,"results");static{oN(this.prototype,"isFocused",[qr],function(){return!1})}#ke=void lN(this,"isFocused");static{oN(this.prototype,"isLoading",[qr],function(){return!1})}#Se=void lN(this,"isLoading");get query(){return this.args.query??this._internalQuery}set query(t){this._internalQuery=t}get showPopover(){return this.isFocused&&this.results.length>0}handleInput(t){const e=t.target.value;this.query=e,this.args.onQueryChange&&this.args.onQueryChange(e),e.length<2?this.results=[]:this.searchTask.perform(e)}static{aN(this.prototype,"handleInput",[$l])}formatSavedPlace(t){const e=(t._listIds||[]).map(t=>this.storage.lists?.find(e=>e.id===t)?.title).filter(Boolean).join(", "),n=e?`Saved place (${e})`:"Saved place";return{source:"saved",id:t.id,title:t.title,icon:"bookmark",description:n,osmId:t.osmId,osmType:t.osmType,lat:t.lat,lon:t.lon}}searchTask=Kq(()=>({context:this,generator:function*(t){yield new att(300);const e="string"==typeof t?t:this.query;if(!(e.length<2)){this.isLoading=!0;try{let t,n;this.mapUi.currentCenter&&({lat:t,lon:n}=this.mapUi.currentCenter);const r=e.toLowerCase(),i=vU.filter(t=>t.label.toLowerCase().includes(r)).map(t=>({source:"category",title:t.label,id:t.id,icon:"search"}));let s=[];r.length>=3&&(s=this.storage.savedPlaces.filter(t=>t.title&&t.title.toLowerCase().includes(r)).map(t=>this.formatSavedPlace(t)));const o=yield this.photon.search(e,t,n),a=new Set(s.map(t=>t.osmId).filter(Boolean)),l=o.filter(t=>!a.has(t.osmId));this.results=[...i,...s,...l]}catch(n){console.error("Search failed",n),this.results=[]}finally{this.isLoading=!1}}}}),{restartable:!0},"searchTask",null);handleFocus(){this.isFocused=!0,this.mapUi.setSearchBoxFocus(!0),this.query.length>=2&&0===this.results.length&&this.searchTask.perform()}static{aN(this.prototype,"handleFocus",[$l])}handleBlur(){setTimeout(()=>{this.isFocused=!1,this.mapUi.setSearchBoxFocus(!1)},300)}static{aN(this.prototype,"handleBlur",[$l])}handleSubmit(t){if(t.preventDefault(),!this.query)return;let e={q:this.query,selected:null,category:null};if(this.mapUi.currentCenter){const{lat:t,lon:n}=this.mapUi.currentCenter;e.lat=parseFloat(t).toFixed(4),e.lon=parseFloat(n).toFixed(4)}this.router.transitionTo("search",{queryParams:e}),this.isFocused=!1}static{aN(this.prototype,"handleSubmit",[$l])}selectResult(t){if("category"===t.source){this.query=t.title,this.args.onQueryChange&&this.args.onQueryChange(t.title),this.results=[];let e=null,n=null;return this.mapUi.currentCenter&&(({lat:e,lon:n}=this.mapUi.currentCenter),e=e?.toString(),n=n?.toString()),void this.router.transitionTo("search",{queryParams:{q:t.title,category:t.id,selected:null,lat:e,lon:n}})}if(this.query=t.title,this.args.onQueryChange&&this.args.onQueryChange(t.title),this.results=[],"saved"===t.source&&t.id&&!t.osmId)this.router.transitionTo("place",t.id);else if(t.osmId){const e=`osm:${t.osmType}:${t.osmId}`;this.router.transitionTo("place",e)}else this.router.transitionTo("search",{queryParams:{q:t.title,lat:t.lat,lon:t.lon,selected:null,category:null}})}static{aN(this.prototype,"selectResult",[$l])}clear(){this.searchTask.cancelAll(),this.mapUi.stopLoading(),this.osm.cancelAll(),this.photon.cancelAll(),this.query="",this.results=[],this.args.onQueryChange&&this.args.onQueryChange(""),this.router.transitionTo("index")}static{aN(this.prototype,"clear",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"search-box"],[12],[1,"\\n "],[11,"form"],[24,0,"search-form"],[4,[32,0],["submit",[30,0,["handleSubmit"]]],null],[12],[1,"\\n "],[11,"button"],[24,0,"menu-btn-integrated"],[24,"aria-label","Menu"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["menu",20,"#5f6368"]],null],[1,"\\n "],[13],[1,"\\n\\n "],[11,"input"],[24,0,"search-input"],[24,"placeholder","Search places..."],[24,"aria-label","Search places"],[16,2,[30,0,["query"]]],[24,"autocomplete","off"],[24,4,"search"],[4,[32,0],["input",[30,0,["handleInput"]]],null],[4,[32,0],["focus",[30,0,["handleFocus"]]],null],[4,[32,0],["blur",[30,0,["handleBlur"]]],null],[12],[13],[1,"\\n\\n "],[10,"button"],[14,0,"search-submit-btn"],[14,"aria-label","Search"],[14,4,"submit"],[12],[1,"\\n"],[41,[28,[32,2],[[28,[32,3],[[30,0,["mapUi","loadingState","type"]],"text"],null],[28,[32,3],[[30,0,["mapUi","loadingState","type"]],"category"],null]],null],[[[1," "],[8,[32,1],null,[["@name","@size"],["loading-ring",20]],null],[1,"\\n"]],[]],[[[1," "],[8,[32,1],null,[["@name","@size","@color"],["search",20,"#5f6368"]],null],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["query"]],[[[1," "],[11,"button"],[24,0,"search-clear-btn"],[24,"aria-label","Clear"],[24,4,"button"],[4,[32,0],["click",[30,0,["clear"]]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#5f6368"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["showPopover"]],[[[1," "],[10,0],[14,0,"search-results-popover"],[12],[1,"\\n "],[10,"ul"],[14,0,"search-results-list"],[12],[1,"\\n"],[42,[28,[31,2],[[28,[31,2],[[30,0,["results"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,0,"search-result-item"],[24,4,"button"],[4,[32,0],["click",[28,[32,4],[[30,0,["selectResult"]],[30,2]],null]],null],[12],[1,"\\n "],[10,0],[14,0,"result-icon"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],[[52,[30,2,["icon"]],[30,2,["icon"]],"map-pin"],16,"#666"]],null],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"result-info"],[12],[1,"\\n "],[10,1],[14,0,"result-title"],[12],[1,[30,2,["title"]]],[13],[1,"\\n"],[41,[28,[32,3],[[30,2,["source"]],"osm"],null],[[[1," "],[10,1],[14,0,"result-desc"],[12],[1,[28,[32,5],[[30,2,["type"]]],null]],[13],[1,"\\n"]],[]],[[[41,[30,2,["description"]],[[[1," "],[10,1],[14,0,"result-desc"],[12],[1,[30,2,["description"]]],[13],[1,"\\n"]],[]],null]],[]]],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null],[13]],["@onToggleMenu","result"],["if","each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,Icon:o$,or:E$,eq:L$,fn:C$,humanizeOsmTag:XV}),isStrictMode:!0}),this)}},ctt=class extends s${static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");get categories(){return vU}searchCategory(t){this.args.onSelect&&this.args.onSelect(t);let e={category:t.id,q:null};if(this.mapUi.currentCenter){const{lat:t,lon:n}=this.mapUi.currentCenter;e.lat=parseFloat(t).toFixed(4),e.lon=parseFloat(n).toFixed(4)}this.router.transitionTo("search",{queryParams:e})}static{aN(this.prototype,"searchCategory",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"category-chips-scroll"],[12],[1,"\\n "],[10,0],[14,0,"category-chips-container"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["categories"]]],null]],null],null,[[[1," "],[11,"button"],[24,0,"category-chip"],[16,"aria-label",[30,1,["label"]]],[16,"disabled",[28,[32,0],[[28,[32,1],[[30,0,["mapUi","loadingState","type"]],"category"],null],[28,[32,1],[[30,0,["mapUi","loadingState","value"]],[30,1,["id"]]],null]],null]],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["searchCategory"]],[30,1]],null]],null],[12],[1,"\\n "],[8,[32,4],null,[["@name","@size"],[[30,1,["icon"]],16]],null],[1,"\\n "],[10,1],[12],[1,[30,1,["label"]]],[13],[1,"\\n "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n"],[13]],["category"],["each","-track-array"]]',moduleName:"(unknown template module)",scope:()=>({and:rV,eq:L$,on:Vw,fn:C$,Icon:o$}),isStrictMode:!0}),this)}},utt=A$((t,[e])=>{let n=null;return async function(){if(e)try{const r=await caches.open("nostr-image-cache-v1"),i=await r.match(e);if(i){const e=await i.blob();return n=URL.createObjectURL(e),void(t.src=n)}const s=await fetch(e,{mode:"cors",credentials:"omit"});if(s.ok){const i=s.clone();await r.put(e,i);const o=await s.blob();n=URL.createObjectURL(o),t.src=n}else t.src=e}catch(Z4){console.warn(`Failed to cache image ${e}, falling back to standard src`,Z4),t.src=e}else t.src=""}(),()=>{n&&(URL.revokeObjectURL(n),n=null)}}),htt=class extends s${static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");static{oN(this.prototype,"nostrAuth",[hp])}#F=void lN(this,"nostrAuth");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"isUserMenuOpen",[qr],function(){return!1})}#Ee=void lN(this,"isUserMenuOpen");static{oN(this.prototype,"searchQuery",[qr],function(){return""})}#Re=void lN(this,"searchQuery");constructor(){super(...arguments),this.router&&"function"==typeof this.router.on&&this.router.on("routeDidChange",this.syncSearchQuery),this.syncSearchQuery()}willDestroy(){this.router&&"function"==typeof this.router.off&&this.router.off("routeDidChange",this.syncSearchQuery),super.willDestroy(...arguments)}syncSearchQuery(){const t=this.mapUi.currentSearch||this.router?.currentRoute?.queryParams;if(t?.q)this.searchQuery=t.q;else if(t?.category){const e=vU.find(e=>e.id===t.category);this.searchQuery=e?e.label:t.category}else this.searchQuery=""}static{aN(this.prototype,"syncSearchQuery",[$l])}get isSearching(){return!(!this.mapUi.searchBoxHasFocus||!this.searchQuery)||("search"===this.router?.currentRouteName?!this.mapUi.loadingState&&this.mapUi.searchResults&&this.mapUi.searchResults.length>0:!("search"===this.router?.currentRouteName||!this.searchQuery))}get showQuickSearch(){const t=this.mapUi.currentZoom??13;return this.settings.showQuickSearchButtons&&t>=12}toggleUserMenu(){this.isUserMenuOpen=!this.isUserMenuOpen}static{aN(this.prototype,"toggleUserMenu",[$l])}closeUserMenu(){this.isUserMenuOpen=!1}static{aN(this.prototype,"closeUserMenu",[$l])}handleQueryChange(t){this.searchQuery=t}static{aN(this.prototype,"handleQueryChange",[$l])}handleChipSelect(t){this.searchQuery=t.label}static{aN(this.prototype,"handleChipSelect",[$l])}static{Mp(ng({id:null,block:'[[[10,"header"],[14,0,"app-header"],[12],[1,"\\n "],[10,0],[14,0,"header-left"],[12],[1,"\\n "],[8,[32,0],null,[["@query","@onToggleMenu","@onQueryChange"],[[30,0,["searchQuery"]],[30,1],[30,0,["handleQueryChange"]]]],null],[1,"\\n "],[13],[1,"\\n\\n"],[41,[30,0,["showQuickSearch"]],[[[1," "],[10,0],[15,0,[29,["header-center ",[52,[30,0,["isSearching"]],"searching"]]]],[12],[1,"\\n "],[8,[32,1],null,[["@onSelect"],[[30,0,["handleChipSelect"]]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1,"\\n "],[10,0],[14,0,"header-right"],[12],[1,"\\n "],[10,0],[14,0,"user-menu-container"],[12],[1,"\\n "],[11,"button"],[24,0,"user-btn btn-press"],[24,"aria-label","User Menu"],[24,4,"button"],[4,[32,2],["click",[30,0,["toggleUserMenu"]]],null],[12],[1,"\\n"],[41,[28,[32,3],[[30,0,["nostrAuth","isConnected"]],[30,0,["nostrData","profile","picture"]]],null],[[[1," "],[11,"img"],[24,0,"user-avatar"],[24,"alt","User Avatar"],[4,[32,4],[[30,0,["nostrData","profile","picture"]]],null],[12],[13],[1,"\\n"]],[]],[[[1," "],[10,0],[14,0,"user-avatar-placeholder"],[12],[1,"\\n "],[8,[32,5],null,[["@name","@size","@color"],["user",20,"white"]],null],[1,"\\n "],[13],[1,"\\n"]],[]]],[1," "],[13],[1,"\\n\\n"],[41,[30,0,["isUserMenuOpen"]],[[[1," "],[8,[32,6],null,[["@storage","@onClose"],[[30,0,["storage"]],[30,0,["closeUserMenu"]]]],null],[1,"\\n "],[11,0],[24,0,"menu-backdrop"],[24,"role","button"],[4,[32,2],["click",[30,0,["closeUserMenu"]]],null],[12],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onToggleMenu"],["if"]]',moduleName:"(unknown template module)",scope:()=>({SearchBox:ltt,CategoryChips:ctt,on:Vw,and:rV,cachedImage:utt,Icon:o$,UserMenu:ett}),isStrictMode:!0}),this)}},dtt=class extends s${static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");static{Mp(ng({id:null,block:'[[[41,[30,0,["toast","isVisible"]],[[[1," "],[10,0],[14,0,"toast-notification"],[12],[1,"\\n "],[1,[30,0,["toast","message"]]],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",isStrictMode:!0}),this)}},ptt=a({default:()=>ftt}),ftt=class extends s${static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");get isSidebarOpen(){const t=this.router.currentRouteName;return this.mapUi.isSidebarVisible&&("place"===t||"place.new"===t||"search"===t||"menu"===t||"contributions"===t||t.startsWith("lists"))}constructor(){super(...arguments),console.debug("Application component constructed"),this.storage}toggleAppMenu(){"menu"===this.router.currentRouteName?this.router.transitionTo("index"):this.router.transitionTo("menu")}static{aN(this.prototype,"toggleAppMenu",[$l])}handleOutsideClick(){const t=this.router.currentRouteName;("search"===t||"place"===t||"menu"===t||"contributions"===t||t.startsWith("lists"))&&(this.mapUi.clearSelection(),this.mapUi.hideSidebar(),"menu"===t||"contributions"===t||t.startsWith("lists")?this.router.transitionTo("index"):"place"===t&&(this.mapUi.returnToSearch&&this.mapUi.currentSearch?this.router.transitionTo("search",{queryParams:this.mapUi.currentSearch}):this.router.transitionTo("index")))}static{aN(this.prototype,"handleOutsideClick",[$l])}refreshBookmarks(){this.storage.notifyChange()}static{aN(this.prototype,"refreshBookmarks",[$l])}static{Mp(ng({id:null,block:'[[[1,[28,[32,0],["Marco"],null]],[1,"\\n\\n"],[10,0],[15,0,[52,[30,0,["mapUi","isSidebarOpening"]],"sidebar-opening"]],[12],[1,"\\n "],[8,[32,1],null,[["@onToggleMenu"],[[30,0,["toggleAppMenu"]]]],null],[1,"\\n\\n "],[10,0],[14,1,"rs-widget-container"],[15,0,[52,[30,0,["storage","isWidgetOpen"]],"visible"]],[12],[13],[1,"\\n\\n"],[41,[30,0,["storage","isWidgetOpen"]],[[[1," "],[11,0],[24,0,"rs-backdrop"],[24,"role","button"],[4,[32,2],["click",[30,0,["storage","closeWidget"]]],null],[12],[13],[1,"\\n"]],[]],null],[1,"\\n "],[8,[32,3],null,[["@isSidebarOpen","@onOutsideClick"],[[30,0,["isSidebarOpen"]],[30,0,["handleOutsideClick"]]]],null],[1,"\\n\\n "],[8,[32,4],null,null,null],[1,"\\n\\n "],[46,[28,[31,2],null,null],null,null,null],[1,"\\n"],[13]],[],["if","component","-outlet"]]',moduleName:"(unknown template module)",scope:()=>({pageTitle:wW,AppHeader:htt,on:Vw,Map:ttt,Toast:dtt}),isStrictMode:!0}),this)}},gtt=a({default:()=>mtt}),mtt=class extends Xh{static{oN(this.prototype,"osm",[hp])}#j=void lN(this,"osm");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage")},ytt=a({default:()=>vtt}),vtt=class extends Xh{static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");activate(){this.mapUi.clearSearchResults(),this.mapUi.hideSidebar()}},btt=Mp(ng({id:null,block:'[[[10,0],[14,0,"sidebar-header"],[12],[1,"\\n "],[10,"h2"],[12],[1,"\\n "],[10,1],[14,0,"app-logo-icon"],[12],[1,"\\n "],[1,[28,[32,0],[[32,1]],null]],[1,"\\n "],[13],[1,"\\n Marco\\n "],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,2],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"ul"],[14,0,"app-menu"],[12],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["bookmark",20]],null],[1,"\\n "],[10,1],[12],[1,"Collections"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[30,3]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["activity",20]],null],[1,"\\n "],[10,1],[12],[1,"My Contributions"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[28,[32,4],[[30,4],"settings"],null]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["settings",20]],null],[1,"\\n "],[10,1],[12],[1,"Settings"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"li"],[12],[1,"\\n "],[11,"button"],[24,4,"button"],[4,[32,2],["click",[28,[32,4],[[30,4],"about"],null]],null],[12],[1,"\\n "],[8,[32,3],null,[["@name","@size"],["info",20]],null],[1,"\\n "],[10,1],[12],[1,"About"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onClose","@onSavedPlaces","@onContributions","@onNavigate"],[]]',moduleName:"(unknown template module)",scope:()=>({htmlSafe:Bv,iconRounded:'\n \x3c!-- Background --\x3e\n \n\n \x3c!-- Subtle map grid (kept well outside safe zone) --\x3e\n \n \n \n \n\n \n \n \n \n\n \x3c!-- Location pin (exact app shape, larger, centered, safe-zone compliant) --\x3e\n \x3c!-- Safe zone target: ~680px diameter --\x3e\n \n \n \n \n\n',on:Vw,Icon:o$,fn:C$}),isStrictMode:!0}),F$()),wtt=class extends s${static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");static{Mp(ng({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["map",20]],null],[1,"\\n "],[10,1],[12],[1,"Map & UI"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","show-quick-search"],[12],[1,"Quick search buttons visible"],[13],[1,"\\n "],[11,"select"],[24,1,"show-quick-search"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"showQuickSearchButtons"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","showQuickSearchButtons"]],"selected"]],[12],[1,"\\n Yes\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","showQuickSearchButtons"]]],"selected"]],[12],[1,"\\n No\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","map-kinetic"],[12],[1,"Map Inertia (Kinetic Panning)"],[13],[1,"\\n "],[11,"select"],[24,1,"map-kinetic"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"mapKinetic"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","mapKinetic"]],"selected"]],[12],[1,"\\n On\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","mapKinetic"]]],"selected"]],[12],[1,"\\n Off\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onChange"],["if","unless"]]',moduleName:"(unknown template module)",scope:()=>({Icon:o$,on:Vw,fn:C$}),isStrictMode:!0}),this)}},_tt=class extends s${static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");static{Mp(ng({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["server",20]],null],[1,"\\n "],[10,1],[12],[1,"API Providers"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","overpass-api"],[12],[1,"Overpass API Provider"],[13],[1,"\\n "],[11,"select"],[24,1,"overpass-api"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"overpassApi"],null]],null],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["settings","overpassApis"]]],null]],null],null,[[[1," "],[10,"option"],[15,2,[30,2,["url"]]],[15,"selected",[52,[28,[32,3],[[30,2,["url"]],[30,0,["settings","overpassApi"]]],null],"selected"]],[12],[1,"\\n "],[1,[30,2,["name"]]],[1,"\\n "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","photon-api"],[12],[1,"Photon API Provider"],[13],[1,"\\n "],[11,"select"],[24,1,"photon-api"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"photonApi"],null]],null],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["settings","photonApis"]]],null]],null],null,[[[1," "],[10,"option"],[15,2,[30,3,["url"]]],[15,"selected",[52,[28,[32,3],[[30,3,["url"]],[30,0,["settings","photonApi"]]],null],"selected"]],[12],[1,"\\n "],[1,[30,3,["name"]]],[1,"\\n "],[13],[1,"\\n"]],[3]],null],[1," "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onChange","api","api"],["each","-track-array","if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:o$,on:Vw,fn:C$,eq:L$}),isStrictMode:!0}),this)}},xtt=t=>t?t.replace(/^wss?:\/\//,""):"",Ctt=class extends s${static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");static{oN(this.prototype,"nostrData",[hp])}#N=void lN(this,"nostrData");static{oN(this.prototype,"toast",[hp])}#Et=void lN(this,"toast");static{oN(this.prototype,"newReadRelay",[qr],function(){return""})}#Te=void lN(this,"newReadRelay");static{oN(this.prototype,"newWriteRelay",[qr],function(){return""})}#Le=void lN(this,"newWriteRelay");get customReadRelays(){return dj(this.settings.nostrReadRelays||[],this.nostrData.requiredReadRelays)}get customWriteRelays(){return dj(this.settings.nostrWriteRelays||[],this.nostrData.requiredWriteRelays)}get readRelayExclusions(){return this.settings.nostrReadRelayExclusions||[]}get writeRelayExclusions(){return this.settings.nostrWriteRelayExclusions||[]}get requiredReadRelaySet(){return new Set(this.nostrData.requiredReadRelays.filter(Boolean))}get requiredWriteRelaySet(){return new Set(this.nostrData.requiredWriteRelays.filter(Boolean))}get mailboxReadRelaySet(){return new Set(this.nostrData.mailboxReadRelays)}get mailboxWriteRelaySet(){return new Set(this.nostrData.mailboxWriteRelays)}get hasReadOverrides(){return this.customReadRelays.length>0||this.readRelayExclusions.length>0}get hasWriteOverrides(){return this.customWriteRelays.length>0||this.writeRelayExclusions.length>0}get readRelaysForDisplay(){return this.nostrData.activeReadRelays.map(t=>({url:t,isRequired:this.requiredReadRelaySet.has(t)}))}get writeRelaysForDisplay(){return this.nostrData.activeWriteRelays.map(t=>({url:t,isRequired:this.requiredWriteRelaySet.has(t)}))}updateNewReadRelay(t){this.newReadRelay=t.target.value}static{aN(this.prototype,"updateNewReadRelay",[$l])}updateNewWriteRelay(t){this.newWriteRelay=t.target.value}static{aN(this.prototype,"updateNewWriteRelay",[$l])}addReadRelay(){const t=cj(this.newReadRelay);if(!t)return;const e=dj(hj(this.nostrData.requiredReadRelays,[...this.customReadRelays,t]),this.nostrData.requiredReadRelays),n=this.readRelayExclusions.filter(e=>cj(e)!==t);this.settings.update("nostrReadRelays",e.length>0?e:null),this.settings.update("nostrReadRelayExclusions",n.length>0?n:null),this.newReadRelay=""}static{aN(this.prototype,"addReadRelay",[$l])}removeReadRelay(t){if(this.requiredReadRelaySet.has(t))return;const e=cj(t),n=this.customReadRelays.filter(t=>cj(t)!==e),r=this.mailboxReadRelaySet.has(e)?Array.from(new Set([...this.readRelayExclusions,e])):this.readRelayExclusions;this.settings.update("nostrReadRelays",n.length>0?n:null),this.settings.update("nostrReadRelayExclusions",r.length>0?r:null)}static{aN(this.prototype,"removeReadRelay",[$l])}handleReadRelayKeydown(t){"Enter"===t.key&&this.addReadRelay()}static{aN(this.prototype,"handleReadRelayKeydown",[$l])}handleWriteRelayKeydown(t){"Enter"===t.key&&this.addWriteRelay()}static{aN(this.prototype,"handleWriteRelayKeydown",[$l])}resetReadRelays(){this.settings.update("nostrReadRelays",null),this.settings.update("nostrReadRelayExclusions",null)}static{aN(this.prototype,"resetReadRelays",[$l])}addWriteRelay(){const t=cj(this.newWriteRelay);if(!t)return;const e=dj(hj(this.nostrData.requiredWriteRelays,[...this.customWriteRelays,t]),this.nostrData.requiredWriteRelays),n=this.writeRelayExclusions.filter(e=>cj(e)!==t);this.settings.update("nostrWriteRelays",e.length>0?e:null),this.settings.update("nostrWriteRelayExclusions",n.length>0?n:null),this.newWriteRelay=""}static{aN(this.prototype,"addWriteRelay",[$l])}removeWriteRelay(t){if(this.requiredWriteRelaySet.has(t))return;const e=cj(t),n=this.customWriteRelays.filter(t=>cj(t)!==e),r=this.mailboxWriteRelaySet.has(e)?Array.from(new Set([...this.writeRelayExclusions,e])):this.writeRelayExclusions;this.settings.update("nostrWriteRelays",n.length>0?n:null),this.settings.update("nostrWriteRelayExclusions",r.length>0?r:null)}static{aN(this.prototype,"removeWriteRelay",[$l])}resetWriteRelays(){this.settings.update("nostrWriteRelays",null),this.settings.update("nostrWriteRelayExclusions",null)}static{aN(this.prototype,"resetWriteRelays",[$l])}async clearCache(){try{await this.nostrData.clearCache(),this.toast.show("Nostr cache cleared")}catch(t){this.toast.show(`Failed to clear Nostr cache: ${t.message}`)}}static{aN(this.prototype,"clearCache",[$l])}static{Mp(ng({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["zap",20]],null],[1,"\\n "],[10,1],[12],[1,"Nostr"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","new-read-relay"],[12],[1,"Read Relays"],[13],[1,"\\n "],[10,"ul"],[14,0,"relay-list"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["readRelaysForDisplay"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[10,1],[12],[1,[28,[32,1],[[30,1,["url"]]],null]],[13],[1,"\\n"],[41,[51,[30,1,["isRequired"]]],[[[1," "],[11,"button"],[24,0,"btn-remove-relay"],[24,"title","Remove relay"],[24,"aria-label","Remove"],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["removeReadRelay"]],[30,1,["url"]]],null]],null],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size","@color"],["x",14,"currentColor"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[1]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"add-relay-input"],[12],[1,"\\n "],[11,"input"],[24,1,"new-read-relay"],[24,0,"form-control"],[24,"placeholder","relay.example.com"],[16,2,[30,0,["newReadRelay"]]],[24,4,"text"],[4,[32,2],["input",[30,0,["updateNewReadRelay"]]],null],[4,[32,2],["keydown",[30,0,["handleReadRelayKeydown"]]],null],[12],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-secondary"],[24,4,"button"],[4,[32,2],["click",[30,0,["addReadRelay"]]],null],[12],[1,"Add"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["hasReadOverrides"]],[[[1," "],[11,"button"],[24,0,"btn-link reset-relays"],[24,4,"button"],[4,[32,2],["click",[30,0,["resetReadRelays"]]],null],[12],[1,"\\n Reset to Defaults\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","new-write-relay"],[12],[1,"Write Relays"],[13],[1,"\\n "],[10,"ul"],[14,0,"relay-list"],[12],[1,"\\n"],[42,[28,[31,1],[[28,[31,1],[[30,0,["writeRelaysForDisplay"]]],null]],null],null,[[[1," "],[10,"li"],[12],[1,"\\n "],[10,1],[12],[1,[28,[32,1],[[30,2,["url"]]],null]],[13],[1,"\\n"],[41,[51,[30,2,["isRequired"]]],[[[1," "],[11,"button"],[24,0,"btn-remove-relay"],[24,"title","Remove relay"],[24,"aria-label","Remove"],[24,4,"button"],[4,[32,2],["click",[28,[32,3],[[30,0,["removeWriteRelay"]],[30,2,["url"]]],null]],null],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size","@color"],["x",14,"currentColor"]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n"]],[2]],null],[1," "],[13],[1,"\\n "],[10,0],[14,0,"add-relay-input"],[12],[1,"\\n "],[11,"input"],[24,1,"new-write-relay"],[24,0,"form-control"],[24,"placeholder","relay.example.com"],[16,2,[30,0,["newWriteRelay"]]],[24,4,"text"],[4,[32,2],["input",[30,0,["updateNewWriteRelay"]]],null],[4,[32,2],["keydown",[30,0,["handleWriteRelayKeydown"]]],null],[12],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-secondary"],[24,4,"button"],[4,[32,2],["click",[30,0,["addWriteRelay"]]],null],[12],[1,"Add"],[13],[1,"\\n "],[13],[1,"\\n"],[41,[30,0,["hasWriteOverrides"]],[[[1," "],[11,"button"],[24,0,"btn-link reset-relays"],[24,4,"button"],[4,[32,2],["click",[30,0,["resetWriteRelays"]]],null],[12],[1,"\\n Reset to Defaults\\n "],[13],[1,"\\n"]],[]],null],[1," "],[13],[1,"\\n\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","nostr-photo-fallback-uploads"],[12],[1,"Upload photos to fallback\\n servers"],[13],[1,"\\n "],[11,"select"],[24,1,"nostr-photo-fallback-uploads"],[24,0,"form-control"],[4,[32,2],["change",[28,[32,3],[[30,3],"nostrPhotoFallbackUploads"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","nostrPhotoFallbackUploads"]],"selected"]],[12],[1,"\\n Yes\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","nostrPhotoFallbackUploads"]]],"selected"]],[12],[1,"\\n No\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[12],[1,"Cached data"],[13],[1,"\\n "],[11,"button"],[24,0,"btn btn-outline btn-full"],[24,4,"button"],[4,[32,2],["click",[30,0,["clearCache"]]],null],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size","@color"],["database",18,"var(--danger-color)"]],null],[1,"\\n Clear profiles, photos, and reviews\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["relay","relay","@onChange"],["each","-track-array","unless","if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:o$,stripProtocol:xtt,on:Vw,fn:C$}),isStrictMode:!0}),this)}},ktt=class extends s${static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");static{Mp(ng({id:null,block:'[[[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,0],null,[["@name","@size"],["alert-triangle",20]],null],[1,"\\n "],[10,1],[12],[1,"Experimental"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content form-layout"],[12],[1,"\\n "],[10,0],[14,0,"form-group"],[12],[1,"\\n "],[10,"label"],[14,"for","experimental-enable-photo-deletion"],[12],[1,"Enable photo deletion\\n (own photos)"],[13],[1,"\\n "],[11,"select"],[24,1,"experimental-enable-photo-deletion"],[24,0,"form-control"],[4,[32,1],["change",[28,[32,2],[[30,1],"experimentalEnablePhotoDeletion"],null]],null],[12],[1,"\\n "],[10,"option"],[14,2,"true"],[15,"selected",[52,[30,0,["settings","experimentalEnablePhotoDeletion"]],"selected"]],[12],[1,"\\n On\\n "],[13],[1,"\\n "],[10,"option"],[14,2,"false"],[15,"selected",[52,[51,[30,0,["settings","experimentalEnablePhotoDeletion"]]],"selected"]],[12],[1,"\\n Off\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onChange"],["if","unless"]]',moduleName:"(unknown template module)",scope:()=>({Icon:o$,on:Vw,fn:C$}),isStrictMode:!0}),this)}},Stt=class extends s${static{oN(this.prototype,"settings",[hp])}#z=void lN(this,"settings");updateSetting(t,e){let n=e.target.value;"true"===n&&(n=!0),"false"===n&&(n=!1),this.settings.update(t,n)}static{aN(this.prototype,"updateSetting",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"Settings"],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"section"],[14,0,"settings-section"],[12],[1,"\\n "],[8,[32,2],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[8,[32,3],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[8,[32,4],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[8,[32,5],null,[["@onChange"],[[30,0,["updateSetting"]]]],null],[1,"\\n "],[13],[1,"\\n"],[13]],["@onBack","@onClose"],[]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,Icon:o$,AppMenuSettingsMapUi:wtt,AppMenuSettingsApis:_tt,AppMenuSettingsNostr:Ctt,AppMenuSettingsExperimental:ktt}),isStrictMode:!0}),this)}},Ett=Mp(ng({id:null,block:'[[[10,0],[14,0,"sidebar-header has-back-btn"],[12],[1,"\\n "],[11,"button"],[24,0,"back-btn"],[24,4,"button"],[4,[32,0],["click",[30,1]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["arrow-left",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n "],[10,"h2"],[14,0,"sidebar-header-text-centered"],[12],[1,"About"],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,0],["click",[30,2]],null],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["x",20,"#333"]],null],[1,"\\n "],[13],[1,"\\n"],[13],[1,"\\n\\n"],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,"section"],[14,0,"about-section"],[12],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Marco"],[13],[1,"\\n (as in\\n "],[10,3],[14,6,"https://en.wikipedia.org/wiki/Marco_Polo"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"Marco Polo"],[13],[1,") is an unhosted maps application that respects your\\n privacy and choices.\\n "],[13],[1,"\\n "],[10,2],[12],[1,"\\n Connect your own\\n "],[10,3],[14,6,"https://remotestorage.io/"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"remote storage"],[13],[1,"\\n to sync place bookmarks across apps and devices.\\n "],[13],[1,"\\n\\n "],[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size"],["gift",20]],null],[1,"\\n "],[10,1],[12],[1,"Open Source"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content"],[12],[1,"\\n "],[10,"table"],[12],[1,"\\n "],[10,"thead"],[12],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"th"],[12],[1,"Source"],[13],[1,"\\n "],[10,"th"],[12],[1,"License"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tbody"],[12],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://gitea.kosmos.org/raucao/marco"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Marco App\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n "],[10,"abbr"],[14,"title","GNU Affero General Public License"],[12],[1,"AGPL"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://openstreetmap.org/copyright"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Map Data\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://opendatacommons.org/licenses/odbl/"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n "],[10,"abbr"],[14,"title","Open Data Commons Open Database License"],[12],[1,"ODbL"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://github.com/feathericons/feather"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Feather Icons\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://en.wikipedia.org/wiki/MIT_License"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n "],[10,"abbr"],[14,"title","MIT License"],[12],[1,"MIT"],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"tr"],[12],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://pinhead.ink/"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Pinhead Icons\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"td"],[12],[1,"\\n "],[10,3],[14,6,"https://github.com/waysidemapping/pinhead?tab=readme-ov-file#where-the-icons-are-from"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"\\n Various\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[10,"details"],[12],[1,"\\n "],[10,"summary"],[12],[1,"\\n "],[8,[32,1],null,[["@name","@size","@color"],["heart",20,"#e5533d"]],null],[1,"\\n "],[10,1],[12],[1,"Contribute"],[13],[1,"\\n "],[13],[1,"\\n "],[10,0],[14,0,"details-content"],[12],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Most impactful:"],[13],[1,"\\n Add and improve data for points of interest in\\n "],[10,3],[14,6,"https://www.openstreetmap.org"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"OpenStreetMap"],[13],[1,".\\n "],[13],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Most appreciated:"],[13],[1,"\\n Use this app as much as you can and\\n "],[10,3],[14,6,"https://community.remotestorage.io/t/marco-an-unhosted-maps-app/941"],[14,"target","_blank"],[14,"rel","noopener"],[12],[1,"submit feedback"],[13],[1,"\\n about your experience, problems, feature wishes, etc.\\n "],[13],[1,"\\n "],[10,2],[12],[1,"\\n "],[10,"strong"],[12],[1,"Most supportive:"],[13],[1,"\\n Tell others about this app, on social media, in blog posts,\\n educational videos, etc.\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],["@onBack","@onClose"],[]]',moduleName:"(unknown template module)",scope:()=>({on:Vw,Icon:o$}),isStrictMode:!0}),F$()),Rtt=class extends s${static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"currentView",[qr],function(){return"menu"})}#Pe=void lN(this,"currentView");setView(t){this.currentView=t}static{aN(this.prototype,"setView",[$l])}goToSavedPlaces(){this.router.transitionTo("lists.index")}static{aN(this.prototype,"goToSavedPlaces",[$l])}goToContributions(){this.router.transitionTo("contributions")}static{aN(this.prototype,"goToContributions",[$l])}static{Mp(ng({id:null,block:'[[[10,0],[14,0,"sidebar app-menu-pane"],[12],[1,"\\n"],[41,[28,[32,0],[[30,0,["currentView"]],"menu"],null],[[[1," "],[8,[32,1],null,[["@onNavigate","@onClose","@onSavedPlaces","@onContributions"],[[30,0,["setView"]],[30,1],[30,0,["goToSavedPlaces"]],[30,0,["goToContributions"]]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["currentView"]],"settings"],null],[[[1," "],[8,[32,2],null,[["@onBack","@onClose"],[[28,[32,3],[[30,0,["setView"]],"menu"],null],[30,1]]],null],[1,"\\n\\n"]],[]],[[[41,[28,[32,0],[[30,0,["currentView"]],"about"],null],[[[1," "],[8,[32,4],null,[["@onBack","@onClose"],[[28,[32,3],[[30,0,["setView"]],"menu"],null],[30,1]]],null],[1,"\\n "]],[]],null]],[]]]],[]]],[13]],["@onClose"],["if"]]',moduleName:"(unknown template module)",scope:()=>({eq:L$,AppMenuHome:btt,AppMenuSettings:Stt,fn:C$,AppMenuAbout:Ett}),isStrictMode:!0}),this)}},Ttt=a({default:()=>Ltt}),Ltt=class extends s${static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");close(){this.router.transitionTo("index")}static{aN(this.prototype,"close",[$l])}static{Mp(ng({id:null,block:'[[[8,[32,0],null,[["@onClose"],[[30,0,["close"]]]],null]],[],[]]',moduleName:"(unknown template module)",scope:()=>({AppMenu:Rtt}),isStrictMode:!0}),this)}},Ptt=a({default:()=>Itt}),Itt=class extends Xh{static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");activate(){this.mapUi.showSidebar()}},Mtt=a({default:()=>Att}),Att=class extends Xh{static{oN(this.prototype,"osmAuth",[hp])}#we=void lN(this,"osmAuth");static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");async model(){try{await this.osmAuth.handleCallback()}catch(t){console.error("Failed to handle OSM OAuth callback",t)}finally{this.router.transitionTo("index")}}},Ott=a({default:()=>Ftt}),Ftt=class extends s${static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");static{oN(this.prototype,"localPlace",[qr],function(){return null})}#Ie=void lN(this,"localPlace");constructor(){super(...arguments),this.localPlace=this.args.model}get place(){const t=this.args.model,e=t.osmId||t.id;return this.storage.findPlaceById(e)||(!this.localPlace||this.localPlace.osmId!==e&&this.localPlace.id!==e?t.createdAt?{...t,id:void 0,createdAt:void 0,geohash:void 0}:t:this.localPlace)}handleUpdate(t){console.debug("Updating local place state:",t),this.localPlace=t,this.storage.notifyChange()}static{aN(this.prototype,"handleUpdate",[$l])}refreshMap(){this.storage.notifyChange()}static{aN(this.prototype,"refreshMap",[$l])}navigateBack(t){if(null===t)if(this.mapUi.returnToRoute){this.mapUi.showSidebar();const{name:t,model:e}=this.mapUi.returnToRoute;void 0!==e?this.router.transitionTo(t,e):this.router.transitionTo(t)}else this.mapUi.returnToSearch&&this.mapUi.currentSearch?(this.mapUi.showSidebar(),this.router.transitionTo("search",{queryParams:this.mapUi.currentSearch})):this.router.transitionTo("index");else this.mapUi.showSidebar(),this.router.transitionTo("place",t)}static{aN(this.prototype,"navigateBack",[$l])}close(){this.mapUi.clearSelection(),this.mapUi.hideSidebar(),this.mapUi.returnToSearch&&this.mapUi.currentSearch?this.router.transitionTo("search",{queryParams:this.mapUi.currentSearch}):this.router.transitionTo("index")}static{aN(this.prototype,"close",[$l])}static{Mp(ng({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[8,[32,0],null,[["@selectedPlace","@onClose","@onSelect","@onBookmarkChange","@onUpdate"],[[30,0,["place"]],[30,0,["close"]],[30,0,["navigateBack"]],[30,0,["refreshMap"]],[30,0,["handleUpdate"]]]],null],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({PlacesSidebar:JV}),isStrictMode:!0}),this)}},Ntt=a({default:()=>ztt}),ztt=class extends Xh{static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"osm",[hp])}#j=void lN(this,"osm");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");async model(t){const e=t.place_id;let n,r,i=!1;(e.startsWith("osm:node:")||e.startsWith("osm:way:")||e.startsWith("osm:relation:"))&&(i=!0,[,n,r]=e.split(":"),console.debug(`Fetching explicit OSM ${n}:`,r));let s=null;i&&(s=this.loadOsmPlace(r,n)),await this.waitForSync();let o=i?r:e,a=this.storage.findPlaceById(o);return a&&i&&a.osmType!==n&&(a=null),a?(console.debug("Found in bookmarks:",a.title),a):i?(console.debug(`Not in bookmarks, using explicitly fetched OSM ${n}:`,r),await s):(console.warn("Not in bookmarks:",e),null)}async waitForSync(){if(this.storage.initialSyncDone)return;console.debug("Waiting for initial storage sync...");const t=Date.now();for(;!this.storage.initialSyncDone;){if(Date.now()-t>5e3){console.warn("Timed out waiting for initial sync");break}await new Promise(t=>setTimeout(t,100))}}async afterModel(t){if(t&&t.osmId&&t.osmType&&"node"!==t.osmType&&!t.geojson){console.debug("Model missing geometry, fetching full OSM details...");const e=await this.loadOsmPlace(t.osmId,t.osmType);e&&(Object.assign(t,e),console.debug("Enriched model with full OSM details",t))}if(t){const e={preventZoom:this.mapUi.preventNextZoom};this.mapUi.selectPlace(t,e),this.mapUi.showSidebar(),this.mapUi.preventNextZoom=!1}this.mapUi.stopSearch()}deactivate(){this.mapUi.clearSelection(),this.mapUi.returnToSearch=!1,this.mapUi.returnToRoute=null}async loadOsmPlace(t,e=null){try{const n=await this.osm.fetchOsmObject(t,e);if(n)return console.debug("Found OSM POI:",n),n}catch(n){console.error("Failed to fetch POI",n)}return null}setupController(t,e){super.setupController(t,e),this.checkUpdates(e)}async checkUpdates(t){if(t&&t.id&&t.osmId&&t.osmType){const e=await this.storage.refreshPlace(t);e&&this.mapUi.selectPlace(e,{preventZoom:!0})}}serialize(t){return t.osmId&&t.osmType?{place_id:`osm:${t.osmType}:${t.osmId}`}:t.id?{place_id:t.id}:{place_id:t.osmId}}},Dtt=a({default:()=>jtt}),jtt=class extends s${static{oN(this.prototype,"router",[hp])}#Ut=void lN(this,"router");static{oN(this.prototype,"storage",[hp])}#D=void lN(this,"storage");static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");get initialPlace(){return{title:"",description:""}}close(){this.router.transitionTo("index")}static{aN(this.prototype,"close",[$l])}async savePlace(t){try{const e=this.mapUi.creationCoordinates||{lat:this.args.model.lat,lon:this.args.model.lon},n=parseFloat(e.lat.toFixed(6)),r=parseFloat(e.lon.toFixed(6)),i={title:t.title||"Untitled Place",description:t.description,lat:n,lon:r,tags:[],osmTags:{}},s=await this.storage.storePlace(i);console.debug("Created private place:",s.title),this.router.replaceWith("place",s)}catch(e){console.error("Failed to create place:",e),alert("Failed to create place: "+e.message)}}static{aN(this.prototype,"savePlace",[$l])}static{Mp(ng({id:null,block:'[[[41,[30,0,["mapUi","isSidebarVisible"]],[[[1," "],[10,0],[14,0,"sidebar"],[12],[1,"\\n "],[10,0],[14,0,"sidebar-header"],[12],[1,"\\n "],[10,"h2"],[12],[8,[32,0],null,[["@name","@size","@color"],["plus-circle",20,"#ea4335"]],null],[1,"\\n New Place"],[13],[1,"\\n "],[11,"button"],[24,0,"close-btn"],[24,4,"button"],[4,[32,1],["click",[30,0,["close"]]],null],[12],[8,[32,0],null,[["@name","@size","@color"],["x",20,"#333"]],null],[13],[1,"\\n "],[13],[1,"\\n\\n "],[10,0],[14,0,"sidebar-content"],[12],[1,"\\n "],[10,2],[14,0,"helper-text"],[12],[1,"\\n Drag the map to position the crosshair.\\n "],[13],[1,"\\n\\n "],[8,[32,2],null,[["@place","@onSave","@onCancel"],[[30,0,["initialPlace"]],[30,0,["savePlace"]],[30,0,["close"]]]],null],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[],["if"]]',moduleName:"(unknown template module)",scope:()=>({Icon:o$,on:Vw,PlaceEditForm:iV}),isStrictMode:!0}),this)}},Utt=a({default:()=>Btt}),Btt=class extends Xh{static{oN(this.prototype,"mapUi",[hp])}#Bt=void lN(this,"mapUi");queryParams={lat:{refreshModel:!0},lon:{refreshModel:!0}};model(t){return{lat:parseFloat(t.lat),lon:parseFloat(t.lon)}}setupController(t,e){super.setupController(t,e),e.lat&&e.lon&&this.mapUi.updateCreationCoordinates(e.lat,e.lon),this.mapUi.startCreating(),this.mapUi.showSidebar()}deactivate(){this.mapUi.stopCreating()}},$tt=Object.assign({},X_,{"marco/config/environment":ex,"marco/deprecation-workflow":wx,"marco/router":Tx,"marco/services/blossom":cN,"marco/services/contributions":vN,"marco/services/image-processor":xN,"marco/services/map-ui":kN,"marco/services/nostr-auth":Jz,"marco/services/nostr-data":vj,"marco/services/nostr-relay":jj,"marco/services/osm-auth":oU,"marco/services/osm":_U,"marco/services/photon":CU,"marco/services/settings":SU,"marco/services/storage":UU,"marco/services/toast":$U,"marco/utils/contributions":pN,"marco/utils/device":Kz,"marco/utils/format-text":cU,"marco/utils/geo":VU,"marco/utils/geohash-coverage":mj,"marco/utils/icons":HU,"marco/utils/nostr":lj,"marco/utils/osm-icons":XU,"marco/utils/osm":pU,"marco/utils/photo-tag-suggestions":iB,"marco/utils/place-mapping":aB,"marco/utils/poi-categories":yU,"marco/utils/poi-category-matcher":eB,"marco/utils/social-links":cB,"marco/workers/image-processor":RB,"marco/services/page-title":FB,"marco/templates/contributions":z$,"marco/controllers/contributions":Zq,"marco/routes/contributions":Xq,"marco/templates/lists":Qq,"marco/routes/lists":eV,"marco/templates/lists/list":QV,"marco/controllers/lists/list":eW,"marco/routes/lists/list":aW,"marco/templates/lists/index":cW,"marco/routes/lists/index":hW,"marco/templates/search":pW,"marco/controllers/search":gW,"marco/routes/search":yW,"marco/templates/application":ptt,"marco/routes/application":gtt,"marco/routes/index":ytt,"marco/templates/menu":Ttt,"marco/routes/menu":Ptt,"marco/routes/oauth/osm-callback":Mtt,"marco/templates/place":Ott,"marco/routes/place":Ntt,"marco/templates/place/new":Dtt,"marco/routes/place/new":Utt},{}),qtt=class{constructor(t,e,n){this.limit=t,this.func=e,this.store=n,this.size=0,this.misses=0,this.hits=0,this.store=n||new Map}get(t){let e=this.store.get(t);return this.store.has(t)?(this.hits++,this.store.get(t)):(this.misses++,e=this.set(t,this.func(t)),e)}set(t,e){return this.limit>this.size&&(this.size++,this.store.set(t,e)),e}purge(){this.store.clear(),this.size=0,this.hits=0,this.misses=0}},Vtt=/[ _]/g,Wtt=new qtt(1e3,t=>{return(e=t,tet.get(e)).replace(Vtt,"-");var e}),Htt=/^(\-|_)+(.)?/,Gtt=/(.)(\-|\_|\.|\s)+(.)?/g,Ktt=/(^|\/|\.)([a-z])/g,Ztt=new qtt(1e3,t=>{const e=(t,e,n)=>n?`_${n.toUpperCase()}`:"",n=(t,e,n,r)=>e+(r?r.toUpperCase():""),r=t.split("/");for(let i=0;it.toUpperCase())}),Ytt=/([a-z\d])([A-Z]+)/g,Xtt=/\-|\s+/g,Jtt=new qtt(1e3,t=>t.replace(Ytt,"$1_$2").replace(Xtt,"_").toLowerCase()),Qtt=/([a-z\d])([A-Z])/g,tet=new qtt(1e3,t=>t.replace(Qtt,"$1_$2").toLowerCase()),eet=class{constructor(t){this._entries=t||globalThis.requirejs.entries}moduleNames(){return Object.keys(this._entries)}has(t){return t in this._entries}get(...t){return globalThis.require(...t)}},net=class{static moduleBasedResolver=!0;moduleBasedResolver=!0;_deprecatedPodModulePrefix=!1;_normalizeCache=Object.create(null);static create(t){return new this(t)}moduleNameLookupPatterns=[this.podBasedModuleName,this.podBasedComponentsInSubdir,this.mainModuleName,this.defaultModuleName,this.nestedColocationComponentModuleName];static withModules(t){return class extends(this){static explicitModules=t}}constructor(t){if(Object.assign(this,t),!this._moduleRegistry){let t=this.constructor.explicitModules;t?this._moduleRegistry={moduleNames:()=>Object.keys(t),has:e=>Boolean(t[e]),get:e=>t[e],addModules(e){t=Object.assign({},t,e)}}:(void 0===globalThis.requirejs.entries&&(globalThis.requirejs.entries=globalThis.requirejs._eak_seen),this._moduleRegistry=new eet)}this.pluralizedTypes=this.pluralizedTypes||Object.create(null),this.pluralizedTypes.config||(this.pluralizedTypes.config="config")}makeToString(t,e){return this.namespace.modulePrefix+"@"+e+":"}shouldWrapInClassFactory(){return!1}parseName(t){if(!0===t.parsedName)return t;let e,n,r,i=t.split("@");if(3===i.length){if(0===i[0].length){e=`@${i[1]}`;let t=i[2].split(":");n=t[0],r=t[1]}else e=`@${i[1]}`,n=i[0].slice(0,-1),r=i[2];"template:components"===n&&(r=`components/${r}`,n="template")}else if(2===i.length){let t=i[0].split(":");if(2===t.length)0===t[1].length?(n=t[0],r=`@${i[1]}`):(e=t[1],n=t[0],r=i[1]);else{let t=i[1].split(":");e=i[0],n=t[0],r=t[1]}"template"===n&&0===e.lastIndexOf("components/",0)&&(r=`components/${r}`,e=e.slice(11))}else i=t.split(":"),n=i[0],r=i[1];let s=r,o=this.namespace;return{parsedName:!0,fullName:t,prefix:e||this.prefix({type:n}),type:n,fullNameWithoutType:s,name:r,root:o,resolveMethodName:"resolve"+(a=n,Ztt.get(a))};var a}resolveOther(t){ret("`modulePrefix` must be defined",this.namespace.modulePrefix);let e=this.findModuleName(t);if(e){let r=this._extractDefaultExport(e,t);if(void 0===r)throw new Error(` Expected to find: '${t.fullName}' within '${e}' but got 'undefined'. Did you forget to 'export default' within '${e}'?`);return this.shouldWrapInClassFactory(r,t)&&(n=r,r={create:t=>"function"==typeof n.extend?n.extend(t):n}),r}var n}normalize(t){return this._normalizeCache[t]||(this._normalizeCache[t]=this._normalize(t))}resolve(t){if("resolver:current"===t)return{create:()=>this};let e,n=this.parseName(t),r=n.resolveMethodName;return"function"==typeof this[r]&&(e=this[r](n)),null==e&&(e=this.resolveOther(n)),e}addModules(t){if(!this._moduleRegistry.addModules)throw new Error("addModules is only supported when your Resolver has been configured to use static modules via Resolver.withModules()");this._moduleRegistry.addModules(t)}_normalize(t){let e=t.split(":");if(e.length>1){let t=e[0];return"component"===t||"helper"===t||"modifier"===t||"template"===t&&0===e[1].indexOf("components/")?t+":"+e[1].replace(/_/g,"-"):t+":"+(n=e[1].replace(/\./g,"/"),Wtt.get(n))}return t;var n}pluralize(t){return this.pluralizedTypes[t]||(this.pluralizedTypes[t]=t+"s")}podBasedLookupWithPrefix(t,e){let n=e.fullNameWithoutType;return"template"===e.type&&(n=n.replace(/^components\//,"")),t+"/"+n+"/"+e.type}podBasedModuleName(t){let e=this.namespace.podModulePrefix||this.namespace.modulePrefix;return this.podBasedLookupWithPrefix(e,t)}podBasedComponentsInSubdir(t){let e=this.namespace.podModulePrefix||this.namespace.modulePrefix;if(e+="/components","component"===t.type||/^components/.test(t.fullNameWithoutType))return this.podBasedLookupWithPrefix(e,t)}resolveEngine(t){let e=t.fullNameWithoutType+"/engine";if(this._moduleRegistry.has(e))return this._extractDefaultExport(e)}resolveRouteMap(t){let e=t.fullNameWithoutType,n=e+"/routes";if(this._moduleRegistry.has(n)){let t=this._extractDefaultExport(n);return ret(`The route map for ${e} should be wrapped by 'buildRoutes' before exporting.`,t.isRouteMap),t}}resolveTemplate(t){return this.resolveOther(t)}mainModuleName(t){if("main"===t.fullNameWithoutType)return t.prefix+"/"+t.type}defaultModuleName(t){return t.prefix+"/"+this.pluralize(t.type)+"/"+t.fullNameWithoutType}nestedColocationComponentModuleName(t){if("component"===t.type)return t.prefix+"/"+this.pluralize(t.type)+"/"+t.fullNameWithoutType+"/index"}prefix(t){let e=this.namespace.modulePrefix;return this.namespace[t.type+"Prefix"]&&(e=this.namespace[t.type+"Prefix"]),e}findModuleName(t){let e,n=this.moduleNameLookupPatterns;for(let r=0,i=n.length;rr.length+i.length)return t+":"+e.slice(s+r.length,o);let a=n+"/"+this.pluralize(t)+"/";return 0===e.indexOf(a)&&e.length>a.length?t+":"+e.slice(a.length):void 0}_extractDefaultExport(t){let e=this._moduleRegistry.get(t,null,null,!0);return e&&e.default&&(e=e.default),e}};function ret(t,e){if(!e)throw new Error(t)}(class extends Y_{modulePrefix=nx.modulePrefix;podModulePrefix=nx.podModulePrefix;Resolver=net.withModules($tt);inspector=function(t){!function(t){globalThis.emberInspectorApps||(globalThis.emberInspectorApps=[]),globalThis.emberInspectorApps.push({app:t,name:`app-${globalThis.emberInspectorApps.length}`,loadCompatInspector:()=>ij(()=>import("./modules-4-12-DwNz3ZLx.js"),[])}),globalThis.dispatchEvent&&globalThis.dispatchEvent(new Event("Ember"))}(t)}(this)}).create(nx.APP);export{Vv as $,sl as $n,nt as $r,zp as $t,ax as A,uc as An,Ze as Ar,am as At,db as B,ac as Bn,Qt as Br,pg as Bt,ZA as C,Zc as Cn,ir as Cr,iy as Ct,tA as D,wc as Dn,Zn as Dr,Jm as Dt,rA as E,kc as En,jn as Er,wm as Et,M_ as F,rc as Fn,Me as Fr,qg as Ft,rb as G,Ql as Gn,Kt as Gr,jp as Gt,mb as H,Gl as Hn,ee as Hr,Dp as Ht,Dw as I,Yl as In,ke as Ir,rm as It,sb as J,Nl as Jn,Ot as Jr,qp as Jt,ib as K,jl as Kn,Gt as Kr,Vp as Kt,ub as L,Hl as Ln,Se as Lr,Ug as Lt,C_ as M,tc as Mn,Ye as Mr,Jg as Mt,w_ as N,ec as Nn,Qe as Nr,tm as Nt,$I as O,bc as On,Ve as Or,Ym as Ot,__ as P,Wl as Pn,Pe as Pr,em as Pt,qv as Q,il as Qn,rt as Qr,Np as Qt,pb as R,lc as Rn,re as Rr,xg as Rt,hO as S,Yc as Sn,cr as Sr,oy as St,MA as T,Pc as Tn,er as Tr,Zm as Tt,gb as U,Vl as Un,ne as Ur,Bp as Ut,fb as V,Xl as Vn,Jt as Vr,mg as Vt,Qv as W,Jl as Wn,Xt as Wr,Up as Wt,Gv as X,Cl as Xn,at as Xr,Wp as Xt,tb as Y,El as Yn,lt as Yr,Hp as Yt,Kv as Z,bl as Zn,tt as Zr,Op as Zt,DB as _,fu as _n,xr as _r,jy as _t,d$ as a,v as ai,Fu as an,Po as ar,ky as at,$O as b,au as bn,yr as br,ay as bt,g$ as c,wu as cn,ps as cr,Ry as ct,y$ as d,Du as dn,ti as dr,$y as dt,Q as ei,Fp as en,ol as er,Wv as et,c$ as f,bu as fn,Gr as fr,Ly as ft,VB as g,Lu as gn,Cr as gr,tv as gt,WB as h,Iu as hn,Lr as hr,ev as ht,u$ as i,b as ii,_u as in,Ua as ir,rv as it,G_ as j,ic as jn,Xe as jr,$g as jt,kx as k,mc as kn,$e as kr,Xm as kt,h$ as l,Nu as ln,_i as lr,By as lt,HB as m,Ou as mn,Ir as mr,nv as mt,jq as n,h as ni,Mp as nn,Ja as nr,Nv as nt,p$ as o,y as oi,Au as on,To as or,Cy as ot,XB as p,vu as pn,Nr as pr,xy as pt,nb as q,Dl as qn,_t as qr,$p as qt,m$ as r,c as ri,cp as rn,Ba as rr,fv as rt,f$ as s,a as si,Pu as sn,Ws as sr,by as st,bW as t,f as ti,Ap as tn,tl as tr,Dv as tt,v$ as u,zu as un,ei as ur,wy as ut,zB as v,yu as vn,Pr as vr,Ty as vt,VA as w,Wc as wn,tr as wr,sy as wt,PO as x,ou as xn,pr as xr,vm as xt,iN as y,mu as yn,Sr as yr,Dy as yt,ab as z,sc as zn,te as zr,fg as zt}; \ No newline at end of file diff --git a/release/assets/main-P9lvOtv_.css b/release/assets/main-P9lvOtv_.css new file mode 100644 index 0000000..adde480 --- /dev/null +++ b/release/assets/main-P9lvOtv_.css @@ -0,0 +1 @@ +:root{--body-text-color:#333;--primary-background-color:#fff;--hover-bg:#f8f9fa;--divider-color:#eee;--sidebar-width:350px;--link-color:#2a7fff;--link-color-visited:#6a4fbf;--marker-color-primary:#ea4335;--marker-color-dark:#b31412;--danger-color:var(--marker-color-primary);--danger-color-dark:var(--marker-color-dark);--default-list-color:#fc3}html,body{overscroll-behavior:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;height:100%}button{-webkit-tap-highlight-color:transparent}body{color:var(--body-text-color);margin:0;font-family:Noto Sans,sans-serif;font-size:16px;font-weight:400}#root,#ember-testing{height:100%}.map-container{-webkit-tap-highlight-color:transparent;background:#f8f9fa;outline:none;position:absolute;inset:0}#rs-widget-container{z-index:4000;display:none;position:absolute;top:60px;right:10px}#rs-widget-container.visible{display:block}.rs-backdrop{z-index:3999;position:fixed;inset:0}.app-header{z-index:3000;pointer-events:none;grid-template-columns:1fr auto 1fr;grid-template-areas:"search chips user";align-items:center;gap:1rem;height:60px;padding:.5rem 1rem;display:grid;position:absolute;top:0;left:0;right:0}@media (width<=768px){.app-header{grid-template-columns:1fr auto;grid-template-areas:"search user""chips chips";row-gap:8px;height:auto;padding:.5rem .5rem 0}}.header-left,.header-right,.header-center{pointer-events:auto}.header-left{grid-area:search;justify-self:start;align-items:center;width:100%;display:flex}@media (width>768px){.header-left{min-width:300px;max-width:350px}}.header-right{grid-area:user;justify-self:end}.header-center{grid-area:chips;justify-content:center;min-width:0;display:flex}@media (width>768px){.header-center .category-chips-scroll{width:auto;max-width:100%}}@media (width<=768px){.header-center{justify-content:start;width:100%;overflow:hidden}.header-center.searching{display:none}}.btn-press{transition:transform .1s}.btn-press:active{transform:scale(.95)}.user-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.user-avatar-placeholder{background:#2a3743;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:40px;height:40px;display:flex}.user-avatar{object-fit:cover;border-radius:50%;flex-shrink:0;width:40px;height:40px;display:block}.photo-preview-img{max-width:100%;height:auto}.dropzone{text-align:center;cursor:pointer;aspect-ratio:4/3;background-color:#ffffff05;border:2px dashed #ccc;border-radius:8px;margin:1.5rem 0 1rem;transition:all .2s}.dropzone.is-dragging{background-color:#61afef0d;border-color:#61afef}.dropzone-label{cursor:pointer;color:#898989;flex-direction:column;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;display:flex}.dropzone-label p{margin:0}.file-input-hidden{display:none}.photo-upload-item{aspect-ratio:4/3;background:#1e262e;border-radius:6px;width:100%;margin-bottom:1.25rem;position:relative;overflow:hidden}.photo-upload-item img{object-fit:contain;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.photo-upload-item .overlay,.photo-upload-item .btn-remove-photo{z-index:2}.photo-upload-item .overlay{background:#0009;flex-direction:column;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.upload-status-text{color:#fff;text-shadow:0 1px 3px #000c;text-align:center;margin-top:1rem;padding:0 1rem;font-size:.9rem}.photo-upload-item .error-overlay{cursor:pointer;background:#e06c75cc;border:none;width:100%;margin:0;padding:0}.photo-upload-item .btn-remove-photo{cursor:pointer;color:#fff;background:#000000b3;border:none;border-radius:50%;justify-content:center;align-items:center;width:24px;height:24px;padding:0;display:flex;position:absolute;top:4px;right:4px}.photo-upload-item .btn-remove-photo:hover{background:var(--danger-color)}.spin-animation{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-publish{width:100%}.user-menu-container{position:relative}.user-menu-popover{z-index:3001;background:#fff;border-radius:8px;width:280px;margin-top:10px;padding:1rem;position:absolute;top:100%;right:0;box-shadow:0 4px 12px #00000026}.menu-backdrop{z-index:3000;position:fixed;inset:0}.account-list{margin:0;padding:0;list-style:none}.account-item{border-bottom:1px solid var(--divider-color);flex-direction:column;padding:1rem 0;display:flex}.account-item:last-child{border-bottom:none;padding-bottom:0}.account-item:first-child{padding-top:0}.account-header{justify-content:space-between;align-items:center;display:flex}.account-status{color:#898989;white-space:nowrap;text-overflow:ellipsis;margin-top:.35rem;margin-left:calc(18px + .75rem);font-size:.85rem;overflow:hidden}.account-status strong{font-weight:600}.account-item.disabled{opacity:.5;pointer-events:none}.account-info{align-items:center;gap:.75rem;display:flex}.btn-text{cursor:pointer;background:0 0;border:none;padding:0;font-size:.9rem;font-weight:600}.text-primary{color:var(--link-color)}.text-danger{color:#dc3545}.btn-text:hover{text-decoration:underline}.sidebar{width:var(--sidebar-width);z-index:3100;will-change:transform;background:#fff;flex-direction:column;display:flex;position:absolute;top:0;bottom:0;left:0;overflow:hidden;box-shadow:2px 0 5px #0000001a}.sidebar-opening .sidebar{animation:.18s cubic-bezier(.16,1,.3,1) forwards sidebar-slide-in-left}.sidebar.app-menu-pane{z-index:3200}@media (width<=768px){.sidebar.app-menu-pane{border-radius:16px 16px 0 0;width:100%;height:66vh;top:auto;bottom:0;right:0}}.sidebar-header{border-bottom:1px solid var(--divider-color);box-sizing:border-box;justify-content:space-between;align-items:center;height:56px;padding:0 1rem;display:flex}.sidebar-header.no-border{border-bottom-color:#0000}.sidebar-header h2{align-items:center;gap:.5rem;margin:0;font-size:1.1rem;display:flex}.sidebar-content{-webkit-overflow-scrolling:touch;touch-action:pan-y;overscroll-behavior:contain;flex:1;min-height:0;padding:1rem;overflow-y:auto}.app-menu-pane .sidebar-content{padding-top:.5rem}.app-menu{margin:0 -1rem;padding:0;list-style:none}.app-menu button{width:100%;color:var(--body-text-color);cursor:pointer;text-align:left;background:0 0;border:none;align-items:center;gap:.8rem;padding:1rem 1rem 1rem 1.4rem;font-family:inherit;font-size:.95rem;transition:background-color .2s;display:flex}.app-menu button:hover{background-color:var(--hover-bg)}.app-menu .icon{color:#666;width:20px;height:20px}.sidebar-content details{margin:0 -1rem}.sidebar-content details summary{cursor:pointer;color:var(--body-text-color);align-items:center;gap:.8rem;padding:1rem 1rem 1rem 1.4rem;font-size:.95rem;list-style:none;transition:background-color .2s;display:flex}.sidebar-content details summary::-webkit-details-marker{display:none}.sidebar-content details summary:hover{background-color:var(--hover-bg)}.sidebar-content details summary .icon{width:20px;height:20px}.sidebar-content details summary:after{content:"";background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");background-position:50%;background-repeat:no-repeat;background-size:20px 20px;width:20px;height:20px;margin-left:auto;transition:transform .2s}.sidebar-content details[open] summary:after{transform:rotate(90deg)}.sidebar-content details .details-content{padding:0 1.4rem 1rem;font-size:.9rem;animation:.2s ease-out details-slide-down}.sidebar-content details .details-content.form-layout{flex-direction:column;gap:16px;display:flex}.relay-list{flex-direction:column;gap:4px;margin:0 0 .75rem;padding:0;list-style:none;display:flex}.relay-list li{word-break:break-all;border-radius:4px;justify-content:space-between;align-items:center;padding:.25rem 0;font-size:.9rem;display:flex}.btn-remove-relay{background-color:var(--primary-background-color);border:1px solid var(--danger-color);width:24px;height:24px;color:var(--danger-color);cursor:pointer;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;padding:0;transition:all .1s;display:flex}.btn-remove-relay svg{stroke:currentColor}.btn-remove-relay:hover,.btn-remove-relay:active{background-color:var(--danger-color);color:var(--primary-background-color)}.add-relay-input{gap:.5rem;display:flex}.btn-link.reset-relays{margin-top:.75rem;font-size:.85rem}@keyframes details-slide-down{0%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translateY(0)}}.edit-form{background:var(--hover-bg);border-bottom:1px solid var(--divider-color);margin:-1rem -1rem 1rem;padding:1rem}.form-group{margin-bottom:.75rem}.form-group label{color:#666;margin-bottom:.5rem;font-size:.85rem;display:block}.form-control{box-sizing:border-box;width:100%;color:var(--body-text-color);background-color:var(--primary-background-color);border:1px solid #ddd;border-radius:4px;padding:.5rem;font-family:inherit;font-size:1rem}.form-control:focus{border-color:var(--link-color);outline:none;box-shadow:0 0 0 2px #2a7fff1a}select.form-control{appearance:none;background-color:var(--primary-background-color);cursor:pointer;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-position:right .75rem center;background-repeat:no-repeat;background-size:16px 16px;padding-right:2.5rem}.edit-actions{justify-content:flex-end;gap:.5rem;display:flex}.settings-section{margin-bottom:2rem;font-size:.95rem}.settings-section .form-group{margin-top:.5rem;margin-bottom:0}.settings-section .form-group:first-of-type{margin-top:1rem}.about-section{margin-bottom:2rem}.about-section a{color:var(--link-color);text-decoration:none}.about-section a:visited{color:var(--link-color-visited)}.about-section a:hover{text-decoration:underline}.about-section p+ul{margin-top:.25rem}.about-section ul{margin:.5rem 0 0;padding-inline-start:1.2em}.about-section li{margin-block:.15rem;padding-inline-start:.5rem}.about-section li::marker{content:"♥";color:#898989}.btn-full{width:100%}.btn-primary{background:var(--link-color);color:#fff;cursor:pointer;border:none;border-radius:4px;padding:.75rem;font-weight:500}.btn-primary:hover{background:#0069d9}.meta-info{font-size:.9rem}.meta-info p{margin-top:1rem;margin-bottom:1rem}.meta-info p:first-child{border-top:1px solid var(--divider-color);margin-top:1.2rem;padding-top:1.2rem}.meta-info a,.meta-info .btn-link{color:var(--link-color);font:inherit;cursor:pointer;background:0 0;border:none;padding:0;text-decoration:none}.meta-info a:hover,.meta-info .btn-link:hover{text-decoration:underline}.sidebar-content table{border-collapse:collapse;width:100%}.sidebar-content table th,.sidebar-content table td{text-align:left;padding:.5rem 0}.sidebar-content table th{text-transform:uppercase;color:#898989;font-size:.75rem;font-weight:700}.sidebar-content table td{border-bottom:1px solid #f9f9f9}.sidebar-content table tr:last-child td{border-bottom:none}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.places-list{margin:-1rem -1rem 0;padding:0;list-style:none}.place-item{text-align:left;border:none;border-bottom:1px solid var(--divider-color);background:var(--primary-background-color);width:100%;color:var(--body-text-color);cursor:pointer;padding:1rem;font-family:inherit;transition:background .2s}.place-item:hover{background:var(--hover-bg)}.place-name{margin-bottom:.25rem;font-size:1rem;font-weight:700}.place-type{color:#666;font-size:.85rem}.back-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin-left:-.5rem;padding:0 .5rem;display:flex}.close-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin-right:-.5rem;padding:0 .5rem;display:flex}.place-details{padding-bottom:2rem}.photo-carousel{position:relative}.photo-carousel.inline{margin:-1rem -1rem 1rem}.photo-carousel-track{scroll-behavior:smooth;scroll-snap-type:x mandatory;scrollbar-width:none;background-color:var(--hover-bg);display:flex;overflow-x:auto}.photo-carousel-track::-webkit-scrollbar{display:none}.carousel-slide{cursor:pointer;scroll-snap-align:start;aspect-ratio:16/9;flex:0 0 100%;justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.carousel-placeholder{display:none}.place-header-photo-blur{object-fit:cover;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.place-header-photo{opacity:0;z-index:1;width:100%;height:100%;transition:opacity .3s ease-in-out;display:block;position:absolute;top:0;left:0}.place-header-photo.landscape{object-fit:cover}.place-header-photo.portrait{object-fit:contain}.place-header-photo.loaded{opacity:1}.place-header-photo.loaded-instant{opacity:1;transition:none}.carousel-nav-btn{color:#fff;cursor:pointer;z-index:2;opacity:0;background:#00000080;border:none;border-radius:50%;justify-content:center;align-items:center;width:36px;height:36px;padding:0;transition:opacity .2s,background-color .2s;display:flex;position:absolute;top:50%;transform:translateY(-50%)}.photo-carousel:hover .carousel-nav-btn:not(.disabled){opacity:1}.carousel-nav-btn:not(.disabled):hover{background:#000c}.carousel-nav-btn.disabled{opacity:0;pointer-events:none}.carousel-nav-btn.prev{left:.5rem}.carousel-nav-btn.next{right:.5rem}@media (width<=768px){.photo-carousel.inline .photo-carousel-track{scroll-snap-type:none;background-color:var(--primary-background-color);gap:2px}.photo-carousel.inline .carousel-slide{scroll-snap-align:none;flex:none;width:auto;height:100px}.photo-carousel.inline .carousel-slide.landscape{aspect-ratio:var(--slide-ratio,16 / 9)}.photo-carousel.inline .carousel-slide.portrait{aspect-ratio:1}.photo-carousel.inline .carousel-placeholder{background-color:var(--hover-bg);flex:1;min-width:0;display:block}.photo-carousel.inline .place-header-photo.landscape,.photo-carousel.inline .place-header-photo.portrait{object-fit:cover}.photo-carousel.inline .carousel-nav-btn{display:none}}.place-details h3{margin-top:0;margin-bottom:.5rem;font-size:1.2rem}.place-details .place-type{color:#666;margin:0 0 1rem;font-size:.9rem}.place-details p.place-description{line-height:1.4}.place-details .actions{flex-direction:row;gap:1rem;margin-top:1.5rem;padding-bottom:.3rem;display:flex}.btn{cursor:pointer;border-radius:4px;justify-content:center;align-items:center;gap:.5rem;padding:.6rem 1.2rem;font-size:.9rem;text-decoration:none;display:flex}.btn:disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.btn-outline{color:var(--body-text-color);background:0 0;border:1px solid #ccc}.btn-outline:hover{border:1px solid #898989}.btn-secondary{color:var(--body-text-color);background:#ffcc334d;border:1px solid #fc33}.btn-secondary:hover{background:#fc36}.btn-blue{background:var(--link-color);color:#fff;border:none}.btn-blue:hover{background:#0056b3}.btn-green{color:#fff;background:#198754;border:none}.btn-green:hover{background:#157347}.search-pulse{pointer-events:none;box-sizing:border-box;will-change:transform, opacity;backface-visibility:hidden;background:#fc33;border:2px solid #fc3c;border-radius:50%;animation:1.5s ease-out infinite pulse;display:none;position:absolute;transform:translate(-50%,-50%)}.search-pulse.active{display:block}.search-pulse.blue{background:#39c3;border-color:#39cc}@keyframes pulse{0%{opacity:.8;transform:translate(-50%,-50%)scale(.8)}to{opacity:0;transform:translate(-50%,-50%)scale(1.4)}}.ol-control.ol-attribution{bottom:1rem}.ol-touch .ol-control.ol-attribution{bottom:.5rem}.ol-control.ol-zoom{bottom:3rem}.ol-touch .ol-control.ol-zoom{bottom:3.5rem}.ol-control.ol-locate{bottom:6.5rem}.ol-touch .ol-control.ol-locate{bottom:8.5rem}.ol-control.ol-rotate{bottom:9rem}.ol-touch .ol-control.ol-rotate{bottom:11.5rem}.ol-control.ol-attribution,.ol-control.ol-zoom,.ol-control.ol-locate,.ol-control.ol-rotate{top:auto;left:auto;right:1rem}.ol-touch .ol-control.ol-attribution,.ol-touch .ol-control.ol-zoom,.ol-touch .ol-control.ol-locate,.ol-touch .ol-control.ol-rotate{right:.5rem}.app-logo-icon{width:32px;height:32px;margin:-6px 0;display:inline-flex}.app-logo-icon svg{width:100%;height:100%}span.icon{display:inline-block}.icon{flex-shrink:0}.icon svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:100%;height:100%}.icon-filled svg{stroke:none;fill:currentColor}.content-with-icon{flex-direction:row;align-items:flex-start;gap:.5rem;display:flex}.content-with-icon>span:not(.icon){flex:1;min-width:0}.content-with-icon>span:not(.icon) a{text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom;max-width:100%;display:inline-block;overflow:hidden}.content-with-icon .icon{margin-top:.15rem}.selected-pin-container{pointer-events:none;display:none;position:absolute;transform:translate(-50%,-100%)}.selected-pin-container.active{animation:.5s cubic-bezier(.175,.885,.32,1.275) forwards drop-in;display:block}.selected-pin{width:40px;height:40px;color:var(--marker-color-primary);filter:drop-shadow(0 4px 6px #0000004d)}.selected-pin svg{width:100%;height:100%;fill:var(--marker-color-primary);stroke:var(--marker-color-dark);stroke-width:1px}.selected-pin-shadow{z-index:-1;opacity:0;background:#0000004d;border-radius:50%;width:10px;height:4px;animation:.5s .2s forwards shadow-fade;position:absolute;bottom:0;left:50%;transform:translate(-50%)}@keyframes drop-in{0%{opacity:0;transform:translate(-50%,-200%)scale(0)}60%{opacity:1}to{opacity:1;transform:translate(-50%,-100%)scale(1)}}@keyframes shadow-fade{to{opacity:1}}.map-crosshair{width:24px;height:24px;color:var(--body-text-color);pointer-events:none;z-index:2000;transition:top .3s,left .3s;display:none;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.map-crosshair.visible{display:block}.map-container.sidebar-open .map-crosshair{left:calc(50% + var(--sidebar-width) / 2)}@media (width<=768px){.map-container.sidebar-open .map-crosshair{top:calc(25% + 30px);left:50%}}.helper-text{color:#1a5c9b;background:#eef4fc;border-radius:4px;align-items:center;gap:.5rem;margin-top:0;margin-bottom:1rem;padding:.75rem;font-size:.9rem;display:flex}button.create-place{width:100%;margin:1.5rem auto}@media (width<=768px){.sidebar{border-top-left-radius:16px;border-top-right-radius:16px;width:100%;height:50vh;inset:auto 0 0;box-shadow:0 -2px 10px #0000001a}.sidebar-opening .sidebar{animation:.18s cubic-bezier(.16,1,.3,1) forwards sidebar-slide-up-bottom}.sidebar-content{padding-bottom:env(safe-area-inset-bottom,20px);overflow-y:auto}}.search-box{z-index:3002;width:100%;max-width:400px;margin-left:0;position:relative}@media (width<=768px){.search-box{max-width:calc(100vw - 65px)}}.search-form{background:#fff;border-radius:24px;align-items:center;height:48px;padding:0 .5rem;transition:box-shadow .2s;display:flex;box-shadow:0 2px 5px #00000026}.search-form:focus-within{box-shadow:0 4px 12px #00000026}.menu-btn-integrated{cursor:pointer;color:#5f6368;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;margin-right:4px;padding:8px;display:flex}.menu-btn-integrated:hover{background:#0000000d}.search-icon{color:#5f6368;justify-content:center;align-items:center;margin-right:.5rem;padding:8px;display:flex}.search-input{min-width:0;height:100%;color:var(--body-text-color);-webkit-appearance:none;background:0 0;border:none;outline:none;flex:1;width:100%;padding:0 4px;font-size:1rem}.search-input::-webkit-search-cancel-button{-webkit-appearance:none}.search-submit-btn{cursor:pointer;color:#5f6368;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;margin-left:4px;padding:8px;display:flex}.search-submit-btn:hover{color:var(--body-text-color);background:#0000000d}.search-clear-btn{cursor:pointer;color:#5f6368;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;margin-left:2px;padding:8px;display:flex}.search-clear-btn:hover{color:var(--body-text-color);background:#0000000d}.search-results-popover{z-index:3002;background:#fff;border-radius:8px;max-height:400px;margin-top:8px;position:absolute;top:100%;left:0;right:0;overflow:hidden auto;box-shadow:0 4px 12px #00000026}.search-results-list{margin:0;padding:0;list-style:none}.search-result-item{text-align:left;cursor:pointer;background:#fff;border:none;border-bottom:1px solid #f0f0f0;align-items:center;gap:.75rem;width:100%;padding:.75rem 1rem;transition:background .1s;display:flex}.search-result-item:last-child{border-bottom:none}.search-result-item:hover,.search-result-item:focus{background:var(--hover-bg);outline:none}.result-icon{color:#666;background:#f0f0f0;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;display:flex}.result-info{flex-direction:column;display:flex;overflow:hidden}.result-title{color:var(--body-text-color);white-space:nowrap;text-overflow:ellipsis;font-size:.95rem;font-weight:500;overflow:hidden}.result-desc{color:#777;white-space:nowrap;text-overflow:ellipsis;margin-top:2px;font-size:.8rem;overflow:hidden}.save-button-wrapper{position:relative}.place-lists-manager{z-index:10;background:#fff;border-radius:8px;width:220px;margin-top:.5rem;padding:.5rem 0;position:absolute;top:100%;left:0;box-shadow:0 4px 12px #00000026}.place-lists-manager .list-item{align-items:center;padding:.5rem 1rem;display:flex}.place-lists-manager .list-item:hover{background:var(--hover-bg)}.place-lists-manager label{cursor:pointer;width:100%;color:var(--body-text-color);align-items:center;gap:.75rem;margin:0;font-size:.95rem;display:flex}.place-lists-manager input[type=checkbox]{accent-color:var(--link-color);cursor:pointer;width:16px;height:16px}.list-color-dot{background-color:var(--default-list-color);border:1px solid #0000001a;border-radius:50%;flex-shrink:0;width:12px;height:12px}.place-lists-manager .divider{background:var(--divider-color);height:1px;margin:.5rem 0}.category-chips-scroll{-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none;width:100%;margin-top:0;padding:4px 0;overflow-x:auto}.category-chips-scroll::-webkit-scrollbar{display:none}.category-chips-container{gap:8px;width:max-content;padding:0 4px;display:flex}.category-chip{color:var(--body-text-color);cursor:pointer;white-space:nowrap;background:#fff;border:1px solid #ddd;border-radius:16px;align-items:center;gap:6px;padding:6px 12px;font-size:.9rem;transition:background-color .2s;display:flex;box-shadow:0 1px 3px #0000001a}.category-chip:hover{background:var(--hover-bg)}.category-chip:active{background:var(--divider-color)}.category-chip:disabled{opacity:.75;cursor:not-allowed;pointer-events:none}.toast-notification{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);color:#fff;z-index:9999;text-align:center;pointer-events:none;background-color:#333333d9;border-radius:999px;max-width:90%;padding:.75rem 1.5rem;font-size:.9rem;font-weight:500;animation:.3s ease-out forwards fade-in-up;position:fixed;bottom:2rem;left:50%;transform:translate(-50%);box-shadow:0 4px 12px #00000026}@keyframes fade-in-up{0%{opacity:0;transform:translate(-50%,1rem)}to{opacity:1;transform:translate(-50%)}}.nostr-connect-modal h2{margin-top:0}.nostr-connect-options{flex-direction:column;gap:1rem;margin-top:1.5rem;display:flex}.mobile-connect-actions{flex-direction:column;gap:.5rem;margin-top:1rem;display:flex}.nostr-connect-status{text-align:center;margin-top:1.5rem}.qr-code-container{justify-content:center;margin-top:1rem;display:flex}.qr-code-container canvas{background:#fff;border-radius:8px}.modal-overlay{z-index:9999;background:#00000080;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.modal-content{background:#fff;border-radius:8px;width:450px;max-width:90vw;padding:1.5rem;position:relative;box-shadow:0 4px 12px #00000026}.close-modal-btn{cursor:pointer;color:#898989;position:absolute;top:1rem;right:1rem}.close-modal-btn.disabled{color:#ccc;cursor:not-allowed}.place-photo-upload h2{margin-top:0;font-size:1.2rem}.place-photo-upload .form-group{margin-bottom:1.5rem}.photo-tag-suggestions{margin-bottom:1.25rem}.photo-tag-suggestions-title{color:#898989;margin:0 0 .75rem;font-size:.9rem;font-weight:400}.photo-tag-suggestions-list{flex-wrap:wrap;gap:.5rem;display:flex}.photo-tag-chip{color:var(--body-text-color);cursor:pointer;background:#f8f9fa;border:none;border-radius:16px;padding:6px 12px;font-size:.9rem;transition:background-color .1s}.photo-tag-chip:hover{background:var(--divider-color)}.photo-tag-chip.is-selected{background:#ffcc334d}.alert{border-radius:.25rem;margin-bottom:1rem;padding:.5rem}.alert-error{color:#c00;background:#fee}.preview-group{margin-bottom:1rem}.preview-group p{margin-bottom:.25rem;font-weight:700}.preview-group img{border-radius:.25rem;max-width:100%}.btn-link{color:var(--link-color);cursor:pointer;font:inherit;background:0 0;border:none;padding:0;text-decoration:none}.btn-link:hover{text-decoration:underline}.photo-gallery-overlay{z-index:9999;background:#000000e6;flex-direction:column;display:flex;position:fixed;inset:0}.photo-gallery-overlay .photo-gallery-content{flex-direction:column;width:100%;height:100%;display:flex;position:relative}.photo-gallery-overlay .close-btn{z-index:10;color:#fff;background:0 0;border-radius:50%;justify-content:center;align-items:center;width:48px;height:48px;transition:background-color .2s;display:flex;position:absolute;top:.5rem;right:1rem}@media (width<=768px){.photo-gallery-overlay .close-btn{right:.5rem}}.photo-gallery-overlay .main-photo-container{flex:1;justify-content:center;align-items:center;padding:2rem;display:flex;overflow:hidden}@media (width<=768px){.photo-gallery-overlay .main-photo-container{padding:2rem 0}}.photo-gallery-overlay .main-photo-container img{object-fit:contain;max-width:100%;max-height:100%}.photo-carousel.gallery-main{flex-direction:column;width:100%;height:100%;display:flex}.photo-carousel.gallery-main .photo-carousel-track{background:0 0;height:100%}.photo-carousel.gallery-main .carousel-slide{aspect-ratio:auto;cursor:default;flex:0 0 100%;height:100%}.photo-carousel.gallery-main .carousel-nav-btn{width:48px;height:48px}.photo-carousel.gallery-main .place-header-photo-blur,.photo-carousel.gallery-main .place-header-photo.landscape,.photo-carousel.gallery-main .place-header-photo.portrait{object-fit:contain}@media (width<=768px){.photo-carousel.gallery-main .carousel-nav-btn{display:none}}.photo-carousel.gallery-thumbnails{width:100%;height:100px;padding-bottom:env(safe-area-inset-bottom,0);background:#00000080}.photo-carousel.gallery-thumbnails .photo-carousel-track{scroll-snap-type:none;background:0 0;gap:4px;height:100%;padding:0}.photo-carousel.gallery-thumbnails .carousel-slide{scroll-snap-align:none;opacity:.6;flex:none;width:auto;height:100%;transition:opacity .2s}.photo-carousel.gallery-thumbnails .carousel-slide.landscape{aspect-ratio:var(--slide-ratio,16 / 9)}.photo-carousel.gallery-thumbnails .carousel-slide.portrait{aspect-ratio:1}.photo-carousel.gallery-thumbnails .carousel-slide:hover,.photo-carousel.gallery-thumbnails .carousel-slide.active{opacity:1}.photo-carousel.gallery-thumbnails .place-header-photo.landscape,.photo-carousel.gallery-thumbnails .place-header-photo.portrait{object-fit:cover;height:100%}.photo-carousel.gallery-thumbnails .carousel-nav-btn{display:none}.dropdown-menu-container{display:inline-block;position:relative}.dropdown-trigger-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.dropdown-popover{z-index:3001;background:#fff;border-radius:8px;flex-direction:column;gap:.25rem;min-width:150px;margin-top:5px;padding:.5rem 0;display:flex;position:absolute;top:100%;left:0;box-shadow:0 4px 12px #00000026}.dropdown-item{text-align:left;cursor:pointer;color:var(--body-text-color);white-space:nowrap;background:0 0;border:none;padding:.5rem 1rem;font-size:.95rem}.dropdown-item:hover{background:#f0f0f0}.photo-gallery-overlay .actions-btn-container{z-index:10;justify-content:center;align-items:center;width:48px;height:48px;display:flex;position:absolute;top:.5rem;left:.5rem}@keyframes sidebar-slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes sidebar-slide-up-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}.lists-index-item{text-align:left;border:none;border-bottom:1px solid var(--divider-color);background:var(--primary-background-color);width:100%;color:var(--body-text-color);cursor:pointer;justify-content:space-between;align-items:center;padding:1rem;font-family:inherit;transition:background .2s;display:flex}.lists-index-item:hover{background:var(--hover-bg)}.lists-index-item-left{align-items:center;gap:12px;min-width:0;display:flex}.lists-index-name{text-overflow:ellipsis;white-space:nowrap;font-size:.95rem;font-weight:400;overflow:hidden}.lists-index-count{color:#666;white-space:nowrap;flex-shrink:0;margin:0;font-size:.85rem}.sidebar-header.has-back-btn{justify-content:center;position:relative}.sidebar-header.has-back-btn .back-btn{z-index:10;position:absolute;left:1rem}.sidebar-header.has-back-btn .close-btn{z-index:10;position:absolute;right:1rem}.sidebar-header-text-centered{text-align:center;justify-content:center;align-items:center;max-width:60%;margin:0;font-size:1.2rem;font-weight:700;display:inline-flex;position:relative}.sidebar-header-icon-wrapper{align-items:center;margin-right:.5rem;display:flex;position:absolute;right:100%}.sidebar-loading{justify-content:center;align-items:center;padding:4rem 1rem;display:flex}.contributions-list{margin:-1rem -1rem 0;padding:0;list-style:none}.contribution-item{text-align:left;border:none;border-bottom:1px solid var(--divider-color);background:var(--primary-background-color);width:100%;color:var(--body-text-color);cursor:pointer;align-items:flex-start;gap:12px;padding:.75rem 1rem;font-family:inherit;transition:background .2s;display:flex}.contribution-item:hover{background:var(--hover-bg)}.contribution-thumb{background:#f0f0f0;border-radius:6px;flex-shrink:0;width:56px;height:56px;position:relative;overflow:hidden}.contribution-thumb img{object-fit:cover;width:100%;height:100%;display:block}.contribution-thumb-badge{color:#fff;background:#000000a6;border-radius:4px;padding:1px 4px;font-size:.7rem;font-weight:700;position:absolute;bottom:2px;right:2px}.contribution-info{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.contribution-place{text-overflow:ellipsis;white-space:nowrap;font-size:1rem;font-weight:700;overflow:hidden}.contribution-name-loading{color:#999;font-style:italic;font-weight:400}.contribution-meta{color:#666;font-size:.85rem}.contribution-tags{flex-wrap:wrap;gap:4px;margin-top:4px;display:flex}.contribution-tag{color:#555;background:#f0f0f0;border-radius:10px;padding:2px 6px;font-size:.72rem}:root,:host{--ol-background-color:white;--ol-accent-background-color:#f5f5f5;--ol-subtle-background-color:#80808040;--ol-partial-background-color:#ffffffbf;--ol-foreground-color:#333;--ol-subtle-foreground-color:#666;--ol-brand-color:#0af}.ol-box{box-sizing:border-box;border:1.5px solid var(--ol-background-color);background-color:var(--ol-partial-background-color);border-radius:2px}.ol-mouse-position{position:absolute;top:8px;right:8px}.ol-scale-line{background:var(--ol-partial-background-color);border-radius:4px;padding:2px;position:absolute;bottom:8px;left:8px}.ol-scale-line-inner{border:1px solid var(--ol-subtle-foreground-color);color:var(--ol-foreground-color);text-align:center;will-change:contents, width;border-top:none;margin:1px;font-size:10px;transition:all .25s}.ol-scale-bar{position:absolute;bottom:8px;left:8px}.ol-scale-bar-inner{display:flex}.ol-scale-step-marker{background-color:var(--ol-foreground-color);float:right;z-index:10;width:1px;height:15px}.ol-scale-step-text{z-index:11;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color);font-size:10px;position:absolute;bottom:-5px}.ol-scale-text{text-align:center;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color);font-size:12px;position:absolute;bottom:25px}.ol-scale-singlebar{z-index:9;box-sizing:border-box;border:1px solid var(--ol-foreground-color);height:10px;position:relative}.ol-scale-singlebar-even{background-color:var(--ol-subtle-foreground-color)}.ol-scale-singlebar-odd{background-color:var(--ol-background-color)}.ol-unsupported{display:none}.ol-viewport,.ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-viewport canvas{all:unset;overflow:hidden}.ol-viewport{touch-action:pan-x pan-y}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:text;user-select:text}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.ol-control{background-color:var(--ol-subtle-background-color);border-radius:4px;position:absolute}.ol-zoom{top:.5em;left:.5em}.ol-rotate{transition:opacity .25s linear,visibility linear;top:.5em;right:.5em}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{top:.5em;right:.5em}.ol-control button{color:var(--ol-subtle-foreground-color);font-weight:700;font-size:inherit;text-align:center;background-color:var(--ol-background-color);border:none;border-radius:2px;width:1.375em;height:1.375em;margin:1px;padding:0;line-height:.4em;text-decoration:none;display:block}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{will-change:transform;font-weight:400;display:block}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:hover,.ol-control button:focus{outline:1px solid var(--ol-subtle-foreground-color);color:var(--ol-foreground-color);text-decoration:none}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;flex-flow:row-reverse;align-items:center;max-width:calc(100% - 1.3em);display:flex;bottom:.5em;right:.5em}.ol-attribution a{color:var(--ol-subtle-foreground-color);text-decoration:none}.ol-attribution ul{color:var(--ol-foreground-color);text-shadow:0 0 2px var(--ol-background-color);margin:0;padding:1px .5em;font-size:12px}.ol-attribution li{list-style:none;display:inline}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button{flex-shrink:0}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution:not(.ol-collapsed){background:var(--ol-partial-background-color)}.ol-attribution.ol-uncollapsible{border-radius:4px 0 0;bottom:0;right:0}.ol-attribution.ol-uncollapsible img{max-height:1.6em;margin-top:-.2em}.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{height:200px;top:4.5em;left:.5em}.ol-zoomslider button{height:10px;position:relative}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{bottom:.5em;left:.5em}.ol-overviewmap.ol-uncollapsible{border-radius:0 4px 0 0;bottom:0;left:0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:block}.ol-overviewmap .ol-overviewmap-map{border:1px solid var(--ol-subtle-foreground-color);width:150px;height:150px}.ol-overviewmap:not(.ol-collapsed) button{position:absolute;bottom:0;left:0}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:var(--ol-subtle-background-color)}.ol-overviewmap-box{border:1.5px dotted var(--ol-subtle-foreground-color)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}.ol-overviewmap .ol-viewport:hover{cursor:pointer} diff --git a/release/assets/main-sIiovt6q.css b/release/assets/main-sIiovt6q.css deleted file mode 100644 index 7ef2b51..0000000 --- a/release/assets/main-sIiovt6q.css +++ /dev/null @@ -1 +0,0 @@ -:root{--body-text-color:#333;--primary-background-color:#fff;--hover-bg:#f8f9fa;--divider-color:#eee;--sidebar-width:350px;--link-color:#2a7fff;--link-color-visited:#6a4fbf;--marker-color-primary:#ea4335;--marker-color-dark:#b31412;--danger-color:var(--marker-color-primary);--danger-color-dark:var(--marker-color-dark);--default-list-color:#fc3}html,body{overscroll-behavior:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;height:100%}button{-webkit-tap-highlight-color:transparent}body{color:var(--body-text-color);margin:0;font-family:Noto Sans,sans-serif;font-size:16px;font-weight:400}#root,#ember-testing{height:100%}.map-container{-webkit-tap-highlight-color:transparent;background:#f8f9fa;outline:none;position:absolute;inset:0}#rs-widget-container{z-index:4000;display:none;position:absolute;top:60px;right:10px}#rs-widget-container.visible{display:block}.rs-backdrop{z-index:3999;position:fixed;inset:0}.app-header{z-index:3000;pointer-events:none;grid-template-columns:1fr auto 1fr;grid-template-areas:"search chips user";align-items:center;gap:1rem;height:60px;padding:.5rem 1rem;display:grid;position:absolute;top:0;left:0;right:0}@media (width<=768px){.app-header{grid-template-columns:1fr auto;grid-template-areas:"search user""chips chips";row-gap:8px;height:auto;padding:.5rem .5rem 0}}.header-left,.header-right,.header-center{pointer-events:auto}.header-left{grid-area:search;justify-self:start;align-items:center;width:100%;display:flex}@media (width>768px){.header-left{min-width:300px;max-width:350px}}.header-right{grid-area:user;justify-self:end}.header-center{grid-area:chips;justify-content:center;min-width:0;display:flex}@media (width>768px){.header-center .category-chips-scroll{width:auto;max-width:100%}}@media (width<=768px){.header-center{justify-content:start;width:100%;overflow:hidden}.header-center.searching{display:none}}.btn-press{transition:transform .1s}.btn-press:active{transform:scale(.95)}.user-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.user-avatar-placeholder{background:#2a3743;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:40px;height:40px;display:flex}.user-avatar{object-fit:cover;border-radius:50%;flex-shrink:0;width:40px;height:40px;display:block}.photo-preview-img{max-width:100%;height:auto}.dropzone{text-align:center;cursor:pointer;aspect-ratio:4/3;background-color:#ffffff05;border:2px dashed #ccc;border-radius:8px;margin:1.5rem 0 1rem;transition:all .2s}.dropzone.is-dragging{background-color:#61afef0d;border-color:#61afef}.dropzone-label{cursor:pointer;color:#898989;flex-direction:column;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;display:flex}.dropzone-label p{margin:0}.file-input-hidden{display:none}.photo-upload-item{aspect-ratio:4/3;background:#1e262e;border-radius:6px;width:100%;margin-bottom:1.25rem;position:relative;overflow:hidden}.photo-upload-item img{object-fit:contain;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.photo-upload-item .overlay,.photo-upload-item .btn-remove-photo{z-index:2}.photo-upload-item .overlay{background:#0009;flex-direction:column;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.upload-status-text{color:#fff;text-shadow:0 1px 3px #000c;text-align:center;margin-top:1rem;padding:0 1rem;font-size:.9rem}.photo-upload-item .error-overlay{cursor:pointer;background:#e06c75cc;border:none;width:100%;margin:0;padding:0}.photo-upload-item .btn-remove-photo{cursor:pointer;color:#fff;background:#000000b3;border:none;border-radius:50%;justify-content:center;align-items:center;width:24px;height:24px;padding:0;display:flex;position:absolute;top:4px;right:4px}.photo-upload-item .btn-remove-photo:hover{background:var(--danger-color)}.spin-animation{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-publish{width:100%}.user-menu-container{position:relative}.user-menu-popover{z-index:3001;background:#fff;border-radius:8px;width:280px;margin-top:10px;padding:1rem;position:absolute;top:100%;right:0;box-shadow:0 4px 12px #00000026}.menu-backdrop{z-index:3000;position:fixed;inset:0}.account-list{margin:0;padding:0;list-style:none}.account-item{border-bottom:1px solid var(--divider-color);flex-direction:column;padding:1rem 0;display:flex}.account-item:last-child{border-bottom:none;padding-bottom:0}.account-item:first-child{padding-top:0}.account-header{justify-content:space-between;align-items:center;display:flex}.account-status{color:#898989;white-space:nowrap;text-overflow:ellipsis;margin-top:.35rem;margin-left:calc(18px + .75rem);font-size:.85rem;overflow:hidden}.account-status strong{font-weight:600}.account-item.disabled{opacity:.5;pointer-events:none}.account-info{align-items:center;gap:.75rem;display:flex}.btn-text{cursor:pointer;background:0 0;border:none;padding:0;font-size:.9rem;font-weight:600}.text-primary{color:var(--link-color)}.text-danger{color:#dc3545}.btn-text:hover{text-decoration:underline}.sidebar{width:var(--sidebar-width);z-index:3100;will-change:transform;background:#fff;flex-direction:column;display:flex;position:absolute;top:0;bottom:0;left:0;overflow:hidden;box-shadow:2px 0 5px #0000001a}.sidebar-opening .sidebar{animation:.18s cubic-bezier(.16,1,.3,1) forwards sidebar-slide-in-left}.sidebar.app-menu-pane{z-index:3200}@media (width<=768px){.sidebar.app-menu-pane{border-radius:16px 16px 0 0;width:100%;height:66vh;top:auto;bottom:0;right:0}}.sidebar-header{border-bottom:1px solid var(--divider-color);box-sizing:border-box;justify-content:space-between;align-items:center;height:56px;padding:0 1rem;display:flex}.sidebar-header.no-border{border-bottom-color:#0000}.sidebar-header h2{align-items:center;gap:.5rem;margin:0;font-size:1.1rem;display:flex}.sidebar-content{-webkit-overflow-scrolling:touch;touch-action:pan-y;overscroll-behavior:contain;flex:1;min-height:0;padding:1rem;overflow-y:auto}.app-menu-pane .sidebar-content{padding-top:.5rem}.app-menu{margin:0 -1rem;padding:0;list-style:none}.app-menu button{width:100%;color:var(--body-text-color);cursor:pointer;text-align:left;background:0 0;border:none;align-items:center;gap:.8rem;padding:1rem 1rem 1rem 1.4rem;font-family:inherit;font-size:.95rem;transition:background-color .2s;display:flex}.app-menu button:hover{background-color:var(--hover-bg)}.app-menu .icon{color:#666;width:20px;height:20px}.sidebar-content details{margin:0 -1rem}.sidebar-content details summary{cursor:pointer;color:var(--body-text-color);align-items:center;gap:.8rem;padding:1rem 1rem 1rem 1.4rem;font-size:.95rem;list-style:none;transition:background-color .2s;display:flex}.sidebar-content details summary::-webkit-details-marker{display:none}.sidebar-content details summary:hover{background-color:var(--hover-bg)}.sidebar-content details summary .icon{width:20px;height:20px}.sidebar-content details summary:after{content:"";background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");background-position:50%;background-repeat:no-repeat;background-size:20px 20px;width:20px;height:20px;margin-left:auto;transition:transform .2s}.sidebar-content details[open] summary:after{transform:rotate(90deg)}.sidebar-content details .details-content{padding:0 1.4rem 1rem;font-size:.9rem;animation:.2s ease-out details-slide-down}.sidebar-content details .details-content.form-layout{flex-direction:column;gap:16px;display:flex}.relay-list{flex-direction:column;gap:4px;margin:0 0 .75rem;padding:0;list-style:none;display:flex}.relay-list li{word-break:break-all;border-radius:4px;justify-content:space-between;align-items:center;padding:.25rem 0;font-size:.9rem;display:flex}.btn-remove-relay{background-color:var(--primary-background-color);border:1px solid var(--danger-color);width:24px;height:24px;color:var(--danger-color);cursor:pointer;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;padding:0;transition:all .1s;display:flex}.btn-remove-relay svg{stroke:currentColor}.btn-remove-relay:hover,.btn-remove-relay:active{background-color:var(--danger-color);color:var(--primary-background-color)}.add-relay-input{gap:.5rem;display:flex}.btn-link.reset-relays{margin-top:.75rem;font-size:.85rem}@keyframes details-slide-down{0%{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:translateY(0)}}.edit-form{background:var(--hover-bg);border-bottom:1px solid var(--divider-color);margin:-1rem -1rem 1rem;padding:1rem}.form-group{margin-bottom:.75rem}.form-group label{color:#666;margin-bottom:.5rem;font-size:.85rem;display:block}.form-control{box-sizing:border-box;width:100%;color:var(--body-text-color);background-color:var(--primary-background-color);border:1px solid #ddd;border-radius:4px;padding:.5rem;font-family:inherit;font-size:1rem}.form-control:focus{border-color:var(--link-color);outline:none;box-shadow:0 0 0 2px #2a7fff1a}select.form-control{appearance:none;background-color:var(--primary-background-color);cursor:pointer;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-position:right .75rem center;background-repeat:no-repeat;background-size:16px 16px;padding-right:2.5rem}.edit-actions{justify-content:flex-end;gap:.5rem;display:flex}.settings-section{margin-bottom:2rem;font-size:.95rem}.settings-section .form-group{margin-top:.5rem;margin-bottom:0}.settings-section .form-group:first-of-type{margin-top:1rem}.about-section{margin-bottom:2rem}.about-section a{color:var(--link-color);text-decoration:none}.about-section a:visited{color:var(--link-color-visited)}.about-section a:hover{text-decoration:underline}.btn-full{width:100%}.btn-primary{background:var(--link-color);color:#fff;cursor:pointer;border:none;border-radius:4px;padding:.75rem;font-weight:500}.btn-primary:hover{background:#0069d9}.meta-info{font-size:.9rem}.meta-info p{margin-top:1rem;margin-bottom:1rem}.meta-info p:first-child{border-top:1px solid var(--divider-color);margin-top:1.2rem;padding-top:1.2rem}.meta-info a,.meta-info .btn-link{color:var(--link-color);font:inherit;cursor:pointer;background:0 0;border:none;padding:0;text-decoration:none}.meta-info a:hover,.meta-info .btn-link:hover{text-decoration:underline}.sidebar-content table{border-collapse:collapse;width:100%}.sidebar-content table th,.sidebar-content table td{text-align:left;padding:.5rem 0}.sidebar-content table th{text-transform:uppercase;color:#898989;font-size:.75rem;font-weight:700}.sidebar-content table td{border-bottom:1px solid #f9f9f9}.sidebar-content table tr:last-child td{border-bottom:none}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.places-list{margin:-1rem -1rem 0;padding:0;list-style:none}.place-item{text-align:left;border:none;border-bottom:1px solid var(--divider-color);background:var(--primary-background-color);width:100%;color:var(--body-text-color);cursor:pointer;padding:1rem;font-family:inherit;transition:background .2s}.place-item:hover{background:var(--hover-bg)}.place-name{margin-bottom:.25rem;font-size:1rem;font-weight:700}.place-type{color:#666;font-size:.85rem}.back-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin-left:-.5rem;padding:0 .5rem;display:flex}.close-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;margin-right:-.5rem;padding:0 .5rem;display:flex}.place-details{padding-bottom:2rem}.photo-carousel{position:relative}.photo-carousel.inline{margin:-1rem -1rem 1rem}.photo-carousel-track{scroll-behavior:smooth;scroll-snap-type:x mandatory;scrollbar-width:none;background-color:var(--hover-bg);display:flex;overflow-x:auto}.photo-carousel-track::-webkit-scrollbar{display:none}.carousel-slide{cursor:pointer;scroll-snap-align:start;aspect-ratio:16/9;flex:0 0 100%;justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.carousel-placeholder{display:none}.place-header-photo-blur{object-fit:cover;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.place-header-photo{opacity:0;z-index:1;width:100%;height:100%;transition:opacity .3s ease-in-out;display:block;position:absolute;top:0;left:0}.place-header-photo.landscape{object-fit:cover}.place-header-photo.portrait{object-fit:contain}.place-header-photo.loaded{opacity:1}.place-header-photo.loaded-instant{opacity:1;transition:none}.carousel-nav-btn{color:#fff;cursor:pointer;z-index:2;opacity:0;background:#00000080;border:none;border-radius:50%;justify-content:center;align-items:center;width:36px;height:36px;padding:0;transition:opacity .2s,background-color .2s;display:flex;position:absolute;top:50%;transform:translateY(-50%)}.photo-carousel:hover .carousel-nav-btn:not(.disabled){opacity:1}.carousel-nav-btn:not(.disabled):hover{background:#000c}.carousel-nav-btn.disabled{opacity:0;pointer-events:none}.carousel-nav-btn.prev{left:.5rem}.carousel-nav-btn.next{right:.5rem}@media (width<=768px){.photo-carousel.inline .photo-carousel-track{scroll-snap-type:none;background-color:var(--primary-background-color);gap:2px}.photo-carousel.inline .carousel-slide{scroll-snap-align:none;flex:none;width:auto;height:100px}.photo-carousel.inline .carousel-slide.landscape{aspect-ratio:var(--slide-ratio,16 / 9)}.photo-carousel.inline .carousel-slide.portrait{aspect-ratio:1}.photo-carousel.inline .carousel-placeholder{background-color:var(--hover-bg);flex:1;min-width:0;display:block}.photo-carousel.inline .place-header-photo.landscape,.photo-carousel.inline .place-header-photo.portrait{object-fit:cover}.photo-carousel.inline .carousel-nav-btn{display:none}}.place-details h3{margin-top:0;margin-bottom:.5rem;font-size:1.2rem}.place-details .place-type{color:#666;margin:0 0 1rem;font-size:.9rem}.place-details p.place-description{line-height:1.4}.place-details .actions{flex-direction:row;gap:1rem;margin-top:1.5rem;padding-bottom:.3rem;display:flex}.btn{cursor:pointer;border-radius:4px;justify-content:center;align-items:center;gap:.5rem;padding:.6rem 1.2rem;font-size:.9rem;text-decoration:none;display:flex}.btn:disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.btn-outline{color:var(--body-text-color);background:0 0;border:1px solid #ccc}.btn-outline:hover{border:1px solid #898989}.btn-secondary{color:var(--body-text-color);background:#ffcc334d;border:1px solid #fc33}.btn-secondary:hover{background:#fc36}.btn-blue{background:var(--link-color);color:#fff;border:none}.btn-blue:hover{background:#0056b3}.btn-green{color:#fff;background:#198754;border:none}.btn-green:hover{background:#157347}.search-pulse{pointer-events:none;box-sizing:border-box;will-change:transform, opacity;backface-visibility:hidden;background:#fc33;border:2px solid #fc3c;border-radius:50%;animation:1.5s ease-out infinite pulse;display:none;position:absolute;transform:translate(-50%,-50%)}.search-pulse.active{display:block}.search-pulse.blue{background:#39c3;border-color:#39cc}@keyframes pulse{0%{opacity:.8;transform:translate(-50%,-50%)scale(.8)}to{opacity:0;transform:translate(-50%,-50%)scale(1.4)}}.ol-control.ol-attribution{bottom:1rem}.ol-touch .ol-control.ol-attribution{bottom:.5rem}.ol-control.ol-zoom{bottom:3rem}.ol-touch .ol-control.ol-zoom{bottom:3.5rem}.ol-control.ol-locate{bottom:6.5rem}.ol-touch .ol-control.ol-locate{bottom:8.5rem}.ol-control.ol-rotate{bottom:9rem}.ol-touch .ol-control.ol-rotate{bottom:11.5rem}.ol-control.ol-attribution,.ol-control.ol-zoom,.ol-control.ol-locate,.ol-control.ol-rotate{top:auto;left:auto;right:1rem}.ol-touch .ol-control.ol-attribution,.ol-touch .ol-control.ol-zoom,.ol-touch .ol-control.ol-locate,.ol-touch .ol-control.ol-rotate{right:.5rem}.app-logo-icon{width:32px;height:32px;margin:-6px 0;display:inline-flex}.app-logo-icon svg{width:100%;height:100%}span.icon{display:inline-block}.icon{flex-shrink:0}.icon svg{stroke:currentColor;fill:none;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;width:100%;height:100%}.icon-filled svg{stroke:none;fill:currentColor}.content-with-icon{flex-direction:row;align-items:flex-start;gap:.5rem;display:flex}.content-with-icon>span:not(.icon){flex:1;min-width:0}.content-with-icon>span:not(.icon) a{text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom;max-width:100%;display:inline-block;overflow:hidden}.content-with-icon .icon{margin-top:.15rem}.selected-pin-container{pointer-events:none;display:none;position:absolute;transform:translate(-50%,-100%)}.selected-pin-container.active{animation:.5s cubic-bezier(.175,.885,.32,1.275) forwards drop-in;display:block}.selected-pin{width:40px;height:40px;color:var(--marker-color-primary);filter:drop-shadow(0 4px 6px #0000004d)}.selected-pin svg{width:100%;height:100%;fill:var(--marker-color-primary);stroke:var(--marker-color-dark);stroke-width:1px}.selected-pin-shadow{z-index:-1;opacity:0;background:#0000004d;border-radius:50%;width:10px;height:4px;animation:.5s .2s forwards shadow-fade;position:absolute;bottom:0;left:50%;transform:translate(-50%)}@keyframes drop-in{0%{opacity:0;transform:translate(-50%,-200%)scale(0)}60%{opacity:1}to{opacity:1;transform:translate(-50%,-100%)scale(1)}}@keyframes shadow-fade{to{opacity:1}}.map-crosshair{width:24px;height:24px;color:var(--body-text-color);pointer-events:none;z-index:2000;transition:top .3s,left .3s;display:none;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.map-crosshair.visible{display:block}.map-container.sidebar-open .map-crosshair{left:calc(50% + var(--sidebar-width) / 2)}@media (width<=768px){.map-container.sidebar-open .map-crosshair{top:calc(25% + 30px);left:50%}}.helper-text{color:#1a5c9b;background:#eef4fc;border-radius:4px;align-items:center;gap:.5rem;margin-top:0;margin-bottom:1rem;padding:.75rem;font-size:.9rem;display:flex}button.create-place{width:100%;margin:1.5rem auto}@media (width<=768px){.sidebar{border-top-left-radius:16px;border-top-right-radius:16px;width:100%;height:50vh;inset:auto 0 0;box-shadow:0 -2px 10px #0000001a}.sidebar-opening .sidebar{animation:.18s cubic-bezier(.16,1,.3,1) forwards sidebar-slide-up-bottom}.sidebar-content{padding-bottom:env(safe-area-inset-bottom,20px);overflow-y:auto}}.search-box{z-index:3002;width:100%;max-width:400px;margin-left:0;position:relative}@media (width<=768px){.search-box{max-width:calc(100vw - 65px)}}.search-form{background:#fff;border-radius:24px;align-items:center;height:48px;padding:0 .5rem;transition:box-shadow .2s;display:flex;box-shadow:0 2px 5px #00000026}.search-form:focus-within{box-shadow:0 4px 12px #00000026}.menu-btn-integrated{cursor:pointer;color:#5f6368;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;margin-right:4px;padding:8px;display:flex}.menu-btn-integrated:hover{background:#0000000d}.search-icon{color:#5f6368;justify-content:center;align-items:center;margin-right:.5rem;padding:8px;display:flex}.search-input{min-width:0;height:100%;color:var(--body-text-color);-webkit-appearance:none;background:0 0;border:none;outline:none;flex:1;width:100%;padding:0 4px;font-size:1rem}.search-input::-webkit-search-cancel-button{-webkit-appearance:none}.search-submit-btn{cursor:pointer;color:#5f6368;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;margin-left:4px;padding:8px;display:flex}.search-submit-btn:hover{color:var(--body-text-color);background:#0000000d}.search-clear-btn{cursor:pointer;color:#5f6368;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;margin-left:2px;padding:8px;display:flex}.search-clear-btn:hover{color:var(--body-text-color);background:#0000000d}.search-results-popover{z-index:3002;background:#fff;border-radius:8px;max-height:400px;margin-top:8px;position:absolute;top:100%;left:0;right:0;overflow:hidden auto;box-shadow:0 4px 12px #00000026}.search-results-list{margin:0;padding:0;list-style:none}.search-result-item{text-align:left;cursor:pointer;background:#fff;border:none;border-bottom:1px solid #f0f0f0;align-items:center;gap:.75rem;width:100%;padding:.75rem 1rem;transition:background .1s;display:flex}.search-result-item:last-child{border-bottom:none}.search-result-item:hover,.search-result-item:focus{background:var(--hover-bg);outline:none}.result-icon{color:#666;background:#f0f0f0;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;display:flex}.result-info{flex-direction:column;display:flex;overflow:hidden}.result-title{color:var(--body-text-color);white-space:nowrap;text-overflow:ellipsis;font-size:.95rem;font-weight:500;overflow:hidden}.result-desc{color:#777;white-space:nowrap;text-overflow:ellipsis;margin-top:2px;font-size:.8rem;overflow:hidden}.save-button-wrapper{position:relative}.place-lists-manager{z-index:10;background:#fff;border-radius:8px;width:220px;margin-top:.5rem;padding:.5rem 0;position:absolute;top:100%;left:0;box-shadow:0 4px 12px #00000026}.place-lists-manager .list-item{align-items:center;padding:.5rem 1rem;display:flex}.place-lists-manager .list-item:hover{background:var(--hover-bg)}.place-lists-manager label{cursor:pointer;width:100%;color:var(--body-text-color);align-items:center;gap:.75rem;margin:0;font-size:.95rem;display:flex}.place-lists-manager input[type=checkbox]{accent-color:var(--link-color);cursor:pointer;width:16px;height:16px}.list-color-dot{background-color:var(--default-list-color);border:1px solid #0000001a;border-radius:50%;flex-shrink:0;width:12px;height:12px}.place-lists-manager .divider{background:var(--divider-color);height:1px;margin:.5rem 0}.category-chips-scroll{-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none;width:100%;margin-top:0;padding:4px 0;overflow-x:auto}.category-chips-scroll::-webkit-scrollbar{display:none}.category-chips-container{gap:8px;width:max-content;padding:0 4px;display:flex}.category-chip{color:var(--body-text-color);cursor:pointer;white-space:nowrap;background:#fff;border:1px solid #ddd;border-radius:16px;align-items:center;gap:6px;padding:6px 12px;font-size:.9rem;transition:background-color .2s;display:flex;box-shadow:0 1px 3px #0000001a}.category-chip:hover{background:var(--hover-bg)}.category-chip:active{background:var(--divider-color)}.category-chip:disabled{opacity:.75;cursor:not-allowed;pointer-events:none}.toast-notification{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);color:#fff;z-index:9999;text-align:center;pointer-events:none;background-color:#333333d9;border-radius:999px;max-width:90%;padding:.75rem 1.5rem;font-size:.9rem;font-weight:500;animation:.3s ease-out forwards fade-in-up;position:fixed;bottom:2rem;left:50%;transform:translate(-50%);box-shadow:0 4px 12px #00000026}@keyframes fade-in-up{0%{opacity:0;transform:translate(-50%,1rem)}to{opacity:1;transform:translate(-50%)}}.nostr-connect-modal h2{margin-top:0}.nostr-connect-options{flex-direction:column;gap:1rem;margin-top:1.5rem;display:flex}.mobile-connect-actions{flex-direction:column;gap:.5rem;margin-top:1rem;display:flex}.nostr-connect-status{text-align:center;margin-top:1.5rem}.qr-code-container{justify-content:center;margin-top:1rem;display:flex}.qr-code-container canvas{background:#fff;border-radius:8px}.modal-overlay{z-index:9999;background:#00000080;justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.modal-content{background:#fff;border-radius:8px;width:450px;max-width:90vw;padding:1.5rem;position:relative;box-shadow:0 4px 12px #00000026}.close-modal-btn{cursor:pointer;color:#898989;position:absolute;top:1rem;right:1rem}.close-modal-btn.disabled{color:#ccc;cursor:not-allowed}.place-photo-upload h2{margin-top:0;font-size:1.2rem}.place-photo-upload .form-group{margin-bottom:1.5rem}.photo-tag-suggestions{margin-bottom:1.25rem}.photo-tag-suggestions-title{color:#898989;margin:0 0 .75rem;font-size:.9rem;font-weight:400}.photo-tag-suggestions-list{flex-wrap:wrap;gap:.5rem;display:flex}.photo-tag-chip{color:var(--body-text-color);cursor:pointer;background:#f8f9fa;border:none;border-radius:16px;padding:6px 12px;font-size:.9rem;transition:background-color .1s}.photo-tag-chip:hover{background:var(--divider-color)}.photo-tag-chip.is-selected{background:#ffcc334d}.alert{border-radius:.25rem;margin-bottom:1rem;padding:.5rem}.alert-error{color:#c00;background:#fee}.preview-group{margin-bottom:1rem}.preview-group p{margin-bottom:.25rem;font-weight:700}.preview-group img{border-radius:.25rem;max-width:100%}.btn-link{color:var(--link-color);cursor:pointer;font:inherit;background:0 0;border:none;padding:0;text-decoration:none}.btn-link:hover{text-decoration:underline}.photo-gallery-overlay{z-index:9999;background:#000000e6;flex-direction:column;display:flex;position:fixed;inset:0}.photo-gallery-overlay .photo-gallery-content{flex-direction:column;width:100%;height:100%;display:flex;position:relative}.photo-gallery-overlay .close-btn{z-index:10;color:#fff;background:0 0;border-radius:50%;justify-content:center;align-items:center;width:48px;height:48px;transition:background-color .2s;display:flex;position:absolute;top:.5rem;right:1rem}@media (width<=768px){.photo-gallery-overlay .close-btn{right:.5rem}}.photo-gallery-overlay .main-photo-container{flex:1;justify-content:center;align-items:center;padding:2rem;display:flex;overflow:hidden}@media (width<=768px){.photo-gallery-overlay .main-photo-container{padding:2rem 0}}.photo-gallery-overlay .main-photo-container img{object-fit:contain;max-width:100%;max-height:100%}.photo-carousel.gallery-main{flex-direction:column;width:100%;height:100%;display:flex}.photo-carousel.gallery-main .photo-carousel-track{background:0 0;height:100%}.photo-carousel.gallery-main .carousel-slide{aspect-ratio:auto;cursor:default;flex:0 0 100%;height:100%}.photo-carousel.gallery-main .carousel-nav-btn{width:48px;height:48px}.photo-carousel.gallery-main .place-header-photo-blur,.photo-carousel.gallery-main .place-header-photo.landscape,.photo-carousel.gallery-main .place-header-photo.portrait{object-fit:contain}@media (width<=768px){.photo-carousel.gallery-main .carousel-nav-btn{display:none}}.photo-carousel.gallery-thumbnails{width:100%;height:100px;padding-bottom:env(safe-area-inset-bottom,0);background:#00000080}.photo-carousel.gallery-thumbnails .photo-carousel-track{scroll-snap-type:none;background:0 0;gap:4px;height:100%;padding:0}.photo-carousel.gallery-thumbnails .carousel-slide{scroll-snap-align:none;opacity:.6;flex:none;width:auto;height:100%;transition:opacity .2s}.photo-carousel.gallery-thumbnails .carousel-slide.landscape{aspect-ratio:var(--slide-ratio,16 / 9)}.photo-carousel.gallery-thumbnails .carousel-slide.portrait{aspect-ratio:1}.photo-carousel.gallery-thumbnails .carousel-slide:hover,.photo-carousel.gallery-thumbnails .carousel-slide.active{opacity:1}.photo-carousel.gallery-thumbnails .place-header-photo.landscape,.photo-carousel.gallery-thumbnails .place-header-photo.portrait{object-fit:cover;height:100%}.photo-carousel.gallery-thumbnails .carousel-nav-btn{display:none}.dropdown-menu-container{display:inline-block;position:relative}.dropdown-trigger-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.dropdown-popover{z-index:3001;background:#fff;border-radius:8px;flex-direction:column;gap:.25rem;min-width:150px;margin-top:5px;padding:.5rem 0;display:flex;position:absolute;top:100%;left:0;box-shadow:0 4px 12px #00000026}.dropdown-item{text-align:left;cursor:pointer;color:var(--body-text-color);white-space:nowrap;background:0 0;border:none;padding:.5rem 1rem;font-size:.95rem}.dropdown-item:hover{background:#f0f0f0}.photo-gallery-overlay .actions-btn-container{z-index:10;justify-content:center;align-items:center;width:48px;height:48px;display:flex;position:absolute;top:.5rem;left:.5rem}@keyframes sidebar-slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes sidebar-slide-up-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}.lists-index-item{text-align:left;border:none;border-bottom:1px solid var(--divider-color);background:var(--primary-background-color);width:100%;color:var(--body-text-color);cursor:pointer;justify-content:space-between;align-items:center;padding:1rem;font-family:inherit;transition:background .2s;display:flex}.lists-index-item:hover{background:var(--hover-bg)}.lists-index-item-left{align-items:center;gap:12px;min-width:0;display:flex}.lists-index-name{text-overflow:ellipsis;white-space:nowrap;font-size:.95rem;font-weight:400;overflow:hidden}.lists-index-count{color:#666;white-space:nowrap;flex-shrink:0;margin:0;font-size:.85rem}.sidebar-header.has-back-btn{justify-content:center;position:relative}.sidebar-header.has-back-btn .back-btn{z-index:10;position:absolute;left:1rem}.sidebar-header.has-back-btn .close-btn{z-index:10;position:absolute;right:1rem}.sidebar-header-text-centered{text-align:center;justify-content:center;align-items:center;max-width:60%;margin:0;font-size:1.2rem;font-weight:700;display:inline-flex;position:relative}.sidebar-header-icon-wrapper{align-items:center;margin-right:.5rem;display:flex;position:absolute;right:100%}.sidebar-loading{justify-content:center;align-items:center;padding:4rem 1rem;display:flex}.contributions-list{margin:-1rem -1rem 0;padding:0;list-style:none}.contribution-item{text-align:left;border:none;border-bottom:1px solid var(--divider-color);background:var(--primary-background-color);width:100%;color:var(--body-text-color);cursor:pointer;align-items:flex-start;gap:12px;padding:.75rem 1rem;font-family:inherit;transition:background .2s;display:flex}.contribution-item:hover{background:var(--hover-bg)}.contribution-thumb{background:#f0f0f0;border-radius:6px;flex-shrink:0;width:56px;height:56px;position:relative;overflow:hidden}.contribution-thumb img{object-fit:cover;width:100%;height:100%;display:block}.contribution-thumb-badge{color:#fff;background:#000000a6;border-radius:4px;padding:1px 4px;font-size:.7rem;font-weight:700;position:absolute;bottom:2px;right:2px}.contribution-info{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.contribution-place{text-overflow:ellipsis;white-space:nowrap;font-size:1rem;font-weight:700;overflow:hidden}.contribution-name-loading{color:#999;font-style:italic;font-weight:400}.contribution-meta{color:#666;font-size:.85rem}.contribution-tags{flex-wrap:wrap;gap:4px;margin-top:4px;display:flex}.contribution-tag{color:#555;background:#f0f0f0;border-radius:10px;padding:2px 6px;font-size:.72rem}:root,:host{--ol-background-color:white;--ol-accent-background-color:#f5f5f5;--ol-subtle-background-color:#80808040;--ol-partial-background-color:#ffffffbf;--ol-foreground-color:#333;--ol-subtle-foreground-color:#666;--ol-brand-color:#0af}.ol-box{box-sizing:border-box;border:1.5px solid var(--ol-background-color);background-color:var(--ol-partial-background-color);border-radius:2px}.ol-mouse-position{position:absolute;top:8px;right:8px}.ol-scale-line{background:var(--ol-partial-background-color);border-radius:4px;padding:2px;position:absolute;bottom:8px;left:8px}.ol-scale-line-inner{border:1px solid var(--ol-subtle-foreground-color);color:var(--ol-foreground-color);text-align:center;will-change:contents, width;border-top:none;margin:1px;font-size:10px;transition:all .25s}.ol-scale-bar{position:absolute;bottom:8px;left:8px}.ol-scale-bar-inner{display:flex}.ol-scale-step-marker{background-color:var(--ol-foreground-color);float:right;z-index:10;width:1px;height:15px}.ol-scale-step-text{z-index:11;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color);font-size:10px;position:absolute;bottom:-5px}.ol-scale-text{text-align:center;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color);font-size:12px;position:absolute;bottom:25px}.ol-scale-singlebar{z-index:9;box-sizing:border-box;border:1px solid var(--ol-foreground-color);height:10px;position:relative}.ol-scale-singlebar-even{background-color:var(--ol-subtle-foreground-color)}.ol-scale-singlebar-odd{background-color:var(--ol-background-color)}.ol-unsupported{display:none}.ol-viewport,.ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-viewport canvas{all:unset;overflow:hidden}.ol-viewport{touch-action:pan-x pan-y}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:text;user-select:text}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.ol-control{background-color:var(--ol-subtle-background-color);border-radius:4px;position:absolute}.ol-zoom{top:.5em;left:.5em}.ol-rotate{transition:opacity .25s linear,visibility linear;top:.5em;right:.5em}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{top:.5em;right:.5em}.ol-control button{color:var(--ol-subtle-foreground-color);font-weight:700;font-size:inherit;text-align:center;background-color:var(--ol-background-color);border:none;border-radius:2px;width:1.375em;height:1.375em;margin:1px;padding:0;line-height:.4em;text-decoration:none;display:block}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{will-change:transform;font-weight:400;display:block}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:hover,.ol-control button:focus{outline:1px solid var(--ol-subtle-foreground-color);color:var(--ol-foreground-color);text-decoration:none}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;flex-flow:row-reverse;align-items:center;max-width:calc(100% - 1.3em);display:flex;bottom:.5em;right:.5em}.ol-attribution a{color:var(--ol-subtle-foreground-color);text-decoration:none}.ol-attribution ul{color:var(--ol-foreground-color);text-shadow:0 0 2px var(--ol-background-color);margin:0;padding:1px .5em;font-size:12px}.ol-attribution li{list-style:none;display:inline}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button{flex-shrink:0}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution:not(.ol-collapsed){background:var(--ol-partial-background-color)}.ol-attribution.ol-uncollapsible{border-radius:4px 0 0;bottom:0;right:0}.ol-attribution.ol-uncollapsible img{max-height:1.6em;margin-top:-.2em}.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{height:200px;top:4.5em;left:.5em}.ol-zoomslider button{height:10px;position:relative}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{bottom:.5em;left:.5em}.ol-overviewmap.ol-uncollapsible{border-radius:0 4px 0 0;bottom:0;left:0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:block}.ol-overviewmap .ol-overviewmap-map{border:1px solid var(--ol-subtle-foreground-color);width:150px;height:150px}.ol-overviewmap:not(.ol-collapsed) button{position:absolute;bottom:0;left:0}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:var(--ol-subtle-background-color)}.ol-overviewmap-box{border:1.5px dotted var(--ol-subtle-foreground-color)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}.ol-overviewmap .ol-viewport:hover{cursor:pointer} diff --git a/release/assets/modules-4-12-DwNz3ZLx.js b/release/assets/modules-4-12-7mlk2oAE.js similarity index 99% rename from release/assets/modules-4-12-DwNz3ZLx.js rename to release/assets/modules-4-12-7mlk2oAE.js index 434ad1b..9233538 100644 --- a/release/assets/modules-4-12-DwNz3ZLx.js +++ b/release/assets/modules-4-12-7mlk2oAE.js @@ -1 +1 @@ -import{$ as e,$n as t,$r as a,$t as n,A as s,An as r,Ar as i,At as o,B as l,Bn as g,Br as d,Bt as h,Cn as c,Cr as u,Ct as p,Dn as _,Dr as m,Dt as y,En as C,Er as b,Et as f,F as A,Fn as M,Fr as I,Ft as D,G as T,Gn as v,Gr as O,Gt as E,H as S,Hn as R,Hr as j,Ht as x,I as w,In as P,Ir as N,It as V,J as F,Jn as G,Jr as L,Jt as k,K as U,Kn as Y,Kr as B,Kt as H,L as $,Ln as z,Lr as W,Lt as q,M as Z,Mn as J,Mr as K,Mt as Q,N as X,Nn as ee,Nr as te,Nt as ae,On as ne,Or as se,Ot as re,P as ie,Pn as oe,Pr as le,Pt as ge,Q as de,Qn as he,Qr as ce,Qt as ue,R as pe,Rn as _e,Rr as me,Rt as ye,Sn as Ce,Sr as be,St as fe,Tn as Ae,Tr as Me,Tt as Ie,U as De,Un as Te,Ur as ve,Ut as Oe,V as Ee,Vn as Se,Vr as Re,Vt as je,W as xe,Wn as we,Wr as Pe,Wt as Ne,X as Ve,Xn as Fe,Xr as Ge,Xt as Le,Y as ke,Yn as Ue,Yr as Ye,Yt as Be,Z as He,Zn as $e,Zr as ze,Zt as We,_ as qe,_n as Ze,_r as Je,_t as Ke,a as Qe,ai as Xe,an as et,ar as tt,at,bn as nt,br as st,bt as rt,c as it,cn as ot,cr as lt,ct as gt,d as dt,dn as ht,dr as ct,dt as ut,ei as pt,en as _t,er as mt,et as yt,f as Ct,fn as bt,fr as ft,ft as At,g as Mt,gn as It,gr as Dt,gt as Tt,h as vt,hn as Ot,hr as Et,ht as St,i as Rt,ii as jt,in as xt,ir as wt,it as Pt,j as Nt,jn as Vt,jr as Ft,jt as Gt,k as Lt,kn as kt,kr as Ut,kt as Yt,l as Bt,ln as Ht,lr as $t,lt as zt,m as Wt,mn as qt,mr as Zt,mt as Jt,n as Kt,ni as Qt,nn as Xt,nr as ea,nt as ta,o as aa,oi as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,ri as ma,rn as ya,rr as Ca,rt as ba,s as fa,si as Aa,sn as Ma,sr as Ia,st as Da,t as Ta,ti as va,tn as Oa,tr as Ea,tt as Sa,u as Ra,un as ja,ur as xa,ut as wa,v as Pa,vn as Na,vr as Va,vt as Fa,wn as Ga,wr as La,wt as ka,xn as Ua,xr as Ya,xt as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-MT6QR2E9.js";var Ka=Aa({default:()=>Ga}),Qa=Aa({default:()=>tn}),Xa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):B(e,t)}var tn=class extends Y{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),W(this,en)}[b](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=be(this,"arrangedContent");return le(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=be(this,"content");$a(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=be(this,"arrangedContent");if(e){let t=this._objects.length=be(e,"length");for(let e=this._objectsDirtyIndex;es)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,Dt(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Ye(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=B(this,"arrangedContent");this._arrangedContentRevision=Ge(this._arrangedContentTag),O(e)?(this._lengthTag=ua([t,I(e,"length")]),this._arrTag=ua([t,I(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Ga,{arrangedContent:st("content")});var an=Aa({Meta:()=>va,UNDEFINED:()=>Qt,counters:()=>ma,meta:()=>jt,peekMeta:()=>Xe,setMeta:()=>na}),nn=Aa({ActionHandler:()=>Fe,Comparable:()=>C,ContainerProxyMixin:()=>Ua,MutableEnumerable:()=>_,RSVP:()=>wt,RegistryProxyMixin:()=>nt,TargetActionSupport:()=>Pa,_ProxyMixin:()=>Sa,_contentFor:()=>ta,onerrorDefault:()=>Ca}),sn=Aa({Cache:()=>u,GUID_KEY:()=>he,ROOT:()=>se,canInvoke:()=>gn,checkHasSuper:()=>Ut,dictionary:()=>tt,generateGuid:()=>t,getDebugName:()=>xe,getName:()=>xa,guidFor:()=>mt,intern:()=>ea,isObject:()=>O,isProxy:()=>La,lookupDescriptor:()=>Ya,observerListenerMetaFor:()=>i,setListeners:()=>Ft,setName:()=>ct,setObservers:()=>K,setProxy:()=>Me,setWithMandatorySetter:()=>{},setupMandatorySetter:()=>{},teardownMandatorySetter:()=>{},toString:()=>ln,uuid:()=>Ea,wrap:()=>te}),rn=Object.prototype.toString;function on(e){return null==e}function ln(e){if("string"==typeof e)return e;if(null===e)return"null";if(void 0===e)return"undefined";if(Array.isArray(e)){let t="";for(let a=0;a0&&(t+=","),on(e[a])||(t+=ln(e[a]));return t}return"function"==typeof e.toString?e.toString():rn.call(e)}function gn(e,t){return null!=e&&"function"==typeof e[t]}var dn=Aa({ActionSupport:()=>qe,CoreView:()=>vt,EventDispatcher:()=>r,MUTABLE_CELL:()=>ba,ViewStates:()=>Mt,addChildView:()=>Vt,clearElementView:()=>J,clearViewElement:()=>ee,constructStyleDeprecationMessage:()=>oe,getChildViews:()=>M,getElementView:()=>P,getRootViews:()=>z,getViewBoundingClientRect:()=>_e,getViewBounds:()=>qa,getViewClientRects:()=>g,getViewElement:()=>Se,getViewId:()=>R,isSimpleClick:()=>Te,setElementView:()=>we,setViewElement:()=>v}),hn=Aa({default:()=>cn}),cn=$e.create({reason:null,isPending:m("isSettled",function(){return!be(this,"isSettled")}).readOnly(),isSettled:m("isRejected","isFulfilled",function(){return be(this,"isRejected")||be(this,"isFulfilled")}).readOnly(),isRejected:!1,isFulfilled:!1,promise:m({get(){throw new Error("PromiseProxy's promise must be set")},set(e,t){return function(e,t){return ga(e,{isFulfilled:!1,isRejected:!1}),t.then(t=>(e.isDestroyed||e.isDestroying||ga(e,{content:t,isFulfilled:!0}),t),t=>{throw e.isDestroyed||e.isDestroying||ga(e,{reason:t,isRejected:!0}),t},"Ember: PromiseProxy")}(this,t)}}),then:un("then"),catch:un("catch"),finally:un("finally")});function un(e){return function(...t){return be(this,"promise")[e](...t)}}var pn=Aa({default:()=>_n}),_n=class extends c{};_n.PrototypeMixin.reopen(Sa);var mn=Aa({CustomComponentManager:()=>$,CustomHelperManager:()=>xt,CustomModifierManager:()=>pe,capabilityFlagsFrom:()=>Ze,componentCapabilities:()=>Wa,getComponentTemplate:()=>Oa,getCustomTagFor:()=>N,getInternalComponentManager:()=>et,getInternalHelperManager:()=>sa,getInternalModifierManager:()=>Ma,hasCapability:()=>Na,hasDestroyable:()=>ot,hasInternalComponentManager:()=>Ht,hasInternalHelperManager:()=>ja,hasInternalModifierManager:()=>ht,hasValue:()=>bt,helperCapabilities:()=>la,managerHasCapability:()=>Ha,modifierCapabilities:()=>l,setComponentManager:()=>Ee,setComponentTemplate:()=>Xt,setCustomTagFor:()=>W,setHelperManager:()=>S,setInternalComponentManager:()=>qt,setInternalHelperManager:()=>Ot,setInternalModifierManager:()=>It,setModifierManager:()=>De}),yn=Aa({ConcreteBounds:()=>Ja,CurriedValue:()=>Ba,CursorImpl:()=>h,DOMChanges:()=>at,DOMTreeConstruction:()=>o,DynamicAttribute:()=>Gt,DynamicScopeImpl:()=>Da,EMPTY_ARGS:()=>fe,EMPTY_NAMED:()=>p,EMPTY_POSITIONAL:()=>ka,EnvironmentImpl:()=>gt,IDOMChanges:()=>ia,LowLevelVM:()=>zt,NewTreeBuilder:()=>Q,RehydrateTree:()=>Z,RemoteBlock:()=>ae,ResettableBlockImpl:()=>ge,SERIALIZATION_FIRST_NODE_STRING:()=>X,ScopeImpl:()=>wa,SimpleDynamicAttribute:()=>D,TEMPLATE_ONLY_COMPONENT_MANAGER:()=>T,TemplateOnlyComponent:()=>U,TemplateOnlyComponentManager:()=>ha,UpdatingVM:()=>ut,and:()=>_a,array:()=>de,clear:()=>je,clientBuilder:()=>V,concat:()=>Ve,createCapturedArgs:()=>Ie,curry:()=>f,destroy:()=>ze,dynamicAttribute:()=>q,eq:()=>Rt,fn:()=>e,get:()=>He,gt:()=>Qe,gte:()=>aa,hash:()=>yt,inTransaction:()=>At,invokeHelper:()=>Ct,isDestroyed:()=>ce,isDestroying:()=>a,isSerializationFirstNode:()=>ie,isWhitespace:()=>da,lt:()=>fa,lte:()=>it,neq:()=>Bt,normalizeProperty:()=>ye,not:()=>Ra,on:()=>ke,or:()=>dt,registerDestructor:()=>pt,rehydrationBuilder:()=>A,reifyArgs:()=>y,reifyNamed:()=>re,reifyPositional:()=>Yt,renderComponent:()=>Jt,renderMain:()=>St,renderSync:()=>Tt,resetDebuggerCallback:()=>Ke,runtimeOptions:()=>Fa,setDebuggerCallback:()=>za,templateOnlyComponent:()=>F}),Cn=Aa({EMPTY_ARRAY:()=>x,EMPTY_NUMBER_ARRAY:()=>Oe,EMPTY_STRING_ARRAY:()=>Ne,LOCAL_LOGGER:()=>bn,LOGGER:()=>fn,SERIALIZATION_FIRST_NODE_STRING:()=>In,Stack:()=>me,assertNever:()=>vn,assign:()=>We,beginTestSteps:()=>{},clearElement:()=>An,dict:()=>Za,emptyArray:()=>E,endTestSteps:()=>{},entries:()=>ue,enumerate:()=>H,intern:()=>Mn,isDict:()=>j,isEmptyArray:()=>pa,isIndexable:()=>ve,isSerializationFirstNode:()=>Dn,keys:()=>n,logStep:()=>{},reverse:()=>k,strip:()=>Tn,values:()=>_t,verifySteps:()=>{},zipArrays:()=>Be,zipTuples:()=>Le}),bn=console,fn=console;function An(e){let t=e.firstChild;for(;t;){let a=t.nextSibling;e.removeChild(t),t=a}}function Mn(e){let t={};t[e]=1;for(let a in t)if(a===e)return a;return e}var In="%+b:0%";function Dn(e){return e.nodeValue===In}function Tn(e,...t){let a="";for(const[i,o]of H(e))a+=`${o}${void 0!==t[i]?String(t[i]):""}`;let n=a.split("\n");for(;Pe(n)&&/^\s*$/u.test(d(n));)n.shift();for(;Pe(n)&&/^\s*$/u.test(Re(n));)n.pop();let s=1/0;for(let i of n){let e=/^\s*/u.exec(i)[0].length;s=Math.min(s,e)}let r=[];for(let i of n)r.push(i.slice(s));return r.join("\n")}function vn(e,t="unexpected unreachable branch"){throw fn.log("unreachable",e),fn.log(`${t} :: ${JSON.stringify(e)} (${e})`),new Error("code reached unreachable")}export{Nt as Application,w as ApplicationNamespace,Ae as Array,Ka as ArrayMutable,Qa as ArrayProxy,Wt as Component,Ce as Controller,s as Debug,Lt as EmberDestroyable,ca as EmberObject,ca as Object,ne as EnumerableMutable,oa as GlimmerComponent,mn as GlimmerManager,rt as GlimmerReference,yn as GlimmerRuntime,Cn as GlimmerUtil,Ia as GlimmerValidator,Pt as Instrumentation,ft as InternalsEnvironment,an as InternalsMeta,$t as InternalsMetal,nn as InternalsRuntime,sn as InternalsUtils,dn as InternalsViews,Ue as ObjectCore,kt as ObjectEvented,Ta as ObjectInternals,G as ObjectObservable,hn as ObjectPromiseProxyMixin,pn as ObjectProxy,ra as Owner,Kt as RSVP,lt as Runloop,ya as Service,Zt as VERSION}; \ No newline at end of file +import{$ as e,$n as t,$r as a,$t as n,A as s,An as r,Ar as i,At as o,B as l,Bn as g,Br as d,Bt as h,Cn as c,Cr as u,Ct as p,Dn as _,Dr as m,Dt as y,En as C,Er as b,Et as f,F as A,Fn as M,Fr as I,Ft as D,G as T,Gn as v,Gr as O,Gt as E,H as S,Hn as R,Hr as j,Ht as x,I as w,In as P,Ir as N,It as V,J as F,Jn as G,Jr as L,Jt as k,K as U,Kn as Y,Kr as B,Kt as H,L as $,Ln as z,Lr as W,Lt as q,M as Z,Mn as J,Mr as K,Mt as Q,N as X,Nn as ee,Nr as te,Nt as ae,On as ne,Or as se,Ot as re,P as ie,Pn as oe,Pr as le,Pt as ge,Q as de,Qn as he,Qr as ce,Qt as ue,R as pe,Rn as _e,Rr as me,Rt as ye,Sn as Ce,Sr as be,St as fe,Tn as Ae,Tr as Me,Tt as Ie,U as De,Un as Te,Ur as ve,Ut as Oe,V as Ee,Vn as Se,Vr as Re,Vt as je,W as xe,Wn as we,Wr as Pe,Wt as Ne,X as Ve,Xn as Fe,Xr as Ge,Xt as Le,Y as ke,Yn as Ue,Yr as Ye,Yt as Be,Z as He,Zn as $e,Zr as ze,Zt as We,_ as qe,_n as Ze,_r as Je,_t as Ke,a as Qe,ai as Xe,an as et,ar as tt,at,bn as nt,br as st,bt as rt,c as it,cn as ot,cr as lt,ct as gt,d as dt,dn as ht,dr as ct,dt as ut,ei as pt,en as _t,er as mt,et as yt,f as Ct,fn as bt,fr as ft,ft as At,g as Mt,gn as It,gr as Dt,gt as Tt,h as vt,hn as Ot,hr as Et,ht as St,i as Rt,ii as jt,in as xt,ir as wt,it as Pt,j as Nt,jn as Vt,jr as Ft,jt as Gt,k as Lt,kn as kt,kr as Ut,kt as Yt,l as Bt,ln as Ht,lr as $t,lt as zt,m as Wt,mn as qt,mr as Zt,mt as Jt,n as Kt,ni as Qt,nn as Xt,nr as ea,nt as ta,o as aa,oi as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,ri as ma,rn as ya,rr as Ca,rt as ba,s as fa,si as Aa,sn as Ma,sr as Ia,st as Da,t as Ta,ti as va,tn as Oa,tr as Ea,tt as Sa,u as Ra,un as ja,ur as xa,ut as wa,v as Pa,vn as Na,vr as Va,vt as Fa,wn as Ga,wr as La,wt as ka,xn as Ua,xr as Ya,xt as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-D3dQ-CGf.js";var Ka=Aa({default:()=>Ga}),Qa=Aa({default:()=>tn}),Xa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):B(e,t)}var tn=class extends Y{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),W(this,en)}[b](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=be(this,"arrangedContent");return le(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=be(this,"content");$a(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=be(this,"arrangedContent");if(e){let t=this._objects.length=be(e,"length");for(let e=this._objectsDirtyIndex;es)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,Dt(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Ye(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=B(this,"arrangedContent");this._arrangedContentRevision=Ge(this._arrangedContentTag),O(e)?(this._lengthTag=ua([t,I(e,"length")]),this._arrTag=ua([t,I(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Ga,{arrangedContent:st("content")});var an=Aa({Meta:()=>va,UNDEFINED:()=>Qt,counters:()=>ma,meta:()=>jt,peekMeta:()=>Xe,setMeta:()=>na}),nn=Aa({ActionHandler:()=>Fe,Comparable:()=>C,ContainerProxyMixin:()=>Ua,MutableEnumerable:()=>_,RSVP:()=>wt,RegistryProxyMixin:()=>nt,TargetActionSupport:()=>Pa,_ProxyMixin:()=>Sa,_contentFor:()=>ta,onerrorDefault:()=>Ca}),sn=Aa({Cache:()=>u,GUID_KEY:()=>he,ROOT:()=>se,canInvoke:()=>gn,checkHasSuper:()=>Ut,dictionary:()=>tt,generateGuid:()=>t,getDebugName:()=>xe,getName:()=>xa,guidFor:()=>mt,intern:()=>ea,isObject:()=>O,isProxy:()=>La,lookupDescriptor:()=>Ya,observerListenerMetaFor:()=>i,setListeners:()=>Ft,setName:()=>ct,setObservers:()=>K,setProxy:()=>Me,setWithMandatorySetter:()=>{},setupMandatorySetter:()=>{},teardownMandatorySetter:()=>{},toString:()=>ln,uuid:()=>Ea,wrap:()=>te}),rn=Object.prototype.toString;function on(e){return null==e}function ln(e){if("string"==typeof e)return e;if(null===e)return"null";if(void 0===e)return"undefined";if(Array.isArray(e)){let t="";for(let a=0;a0&&(t+=","),on(e[a])||(t+=ln(e[a]));return t}return"function"==typeof e.toString?e.toString():rn.call(e)}function gn(e,t){return null!=e&&"function"==typeof e[t]}var dn=Aa({ActionSupport:()=>qe,CoreView:()=>vt,EventDispatcher:()=>r,MUTABLE_CELL:()=>ba,ViewStates:()=>Mt,addChildView:()=>Vt,clearElementView:()=>J,clearViewElement:()=>ee,constructStyleDeprecationMessage:()=>oe,getChildViews:()=>M,getElementView:()=>P,getRootViews:()=>z,getViewBoundingClientRect:()=>_e,getViewBounds:()=>qa,getViewClientRects:()=>g,getViewElement:()=>Se,getViewId:()=>R,isSimpleClick:()=>Te,setElementView:()=>we,setViewElement:()=>v}),hn=Aa({default:()=>cn}),cn=$e.create({reason:null,isPending:m("isSettled",function(){return!be(this,"isSettled")}).readOnly(),isSettled:m("isRejected","isFulfilled",function(){return be(this,"isRejected")||be(this,"isFulfilled")}).readOnly(),isRejected:!1,isFulfilled:!1,promise:m({get(){throw new Error("PromiseProxy's promise must be set")},set(e,t){return function(e,t){return ga(e,{isFulfilled:!1,isRejected:!1}),t.then(t=>(e.isDestroyed||e.isDestroying||ga(e,{content:t,isFulfilled:!0}),t),t=>{throw e.isDestroyed||e.isDestroying||ga(e,{reason:t,isRejected:!0}),t},"Ember: PromiseProxy")}(this,t)}}),then:un("then"),catch:un("catch"),finally:un("finally")});function un(e){return function(...t){return be(this,"promise")[e](...t)}}var pn=Aa({default:()=>_n}),_n=class extends c{};_n.PrototypeMixin.reopen(Sa);var mn=Aa({CustomComponentManager:()=>$,CustomHelperManager:()=>xt,CustomModifierManager:()=>pe,capabilityFlagsFrom:()=>Ze,componentCapabilities:()=>Wa,getComponentTemplate:()=>Oa,getCustomTagFor:()=>N,getInternalComponentManager:()=>et,getInternalHelperManager:()=>sa,getInternalModifierManager:()=>Ma,hasCapability:()=>Na,hasDestroyable:()=>ot,hasInternalComponentManager:()=>Ht,hasInternalHelperManager:()=>ja,hasInternalModifierManager:()=>ht,hasValue:()=>bt,helperCapabilities:()=>la,managerHasCapability:()=>Ha,modifierCapabilities:()=>l,setComponentManager:()=>Ee,setComponentTemplate:()=>Xt,setCustomTagFor:()=>W,setHelperManager:()=>S,setInternalComponentManager:()=>qt,setInternalHelperManager:()=>Ot,setInternalModifierManager:()=>It,setModifierManager:()=>De}),yn=Aa({ConcreteBounds:()=>Ja,CurriedValue:()=>Ba,CursorImpl:()=>h,DOMChanges:()=>at,DOMTreeConstruction:()=>o,DynamicAttribute:()=>Gt,DynamicScopeImpl:()=>Da,EMPTY_ARGS:()=>fe,EMPTY_NAMED:()=>p,EMPTY_POSITIONAL:()=>ka,EnvironmentImpl:()=>gt,IDOMChanges:()=>ia,LowLevelVM:()=>zt,NewTreeBuilder:()=>Q,RehydrateTree:()=>Z,RemoteBlock:()=>ae,ResettableBlockImpl:()=>ge,SERIALIZATION_FIRST_NODE_STRING:()=>X,ScopeImpl:()=>wa,SimpleDynamicAttribute:()=>D,TEMPLATE_ONLY_COMPONENT_MANAGER:()=>T,TemplateOnlyComponent:()=>U,TemplateOnlyComponentManager:()=>ha,UpdatingVM:()=>ut,and:()=>_a,array:()=>de,clear:()=>je,clientBuilder:()=>V,concat:()=>Ve,createCapturedArgs:()=>Ie,curry:()=>f,destroy:()=>ze,dynamicAttribute:()=>q,eq:()=>Rt,fn:()=>e,get:()=>He,gt:()=>Qe,gte:()=>aa,hash:()=>yt,inTransaction:()=>At,invokeHelper:()=>Ct,isDestroyed:()=>ce,isDestroying:()=>a,isSerializationFirstNode:()=>ie,isWhitespace:()=>da,lt:()=>fa,lte:()=>it,neq:()=>Bt,normalizeProperty:()=>ye,not:()=>Ra,on:()=>ke,or:()=>dt,registerDestructor:()=>pt,rehydrationBuilder:()=>A,reifyArgs:()=>y,reifyNamed:()=>re,reifyPositional:()=>Yt,renderComponent:()=>Jt,renderMain:()=>St,renderSync:()=>Tt,resetDebuggerCallback:()=>Ke,runtimeOptions:()=>Fa,setDebuggerCallback:()=>za,templateOnlyComponent:()=>F}),Cn=Aa({EMPTY_ARRAY:()=>x,EMPTY_NUMBER_ARRAY:()=>Oe,EMPTY_STRING_ARRAY:()=>Ne,LOCAL_LOGGER:()=>bn,LOGGER:()=>fn,SERIALIZATION_FIRST_NODE_STRING:()=>In,Stack:()=>me,assertNever:()=>vn,assign:()=>We,beginTestSteps:()=>{},clearElement:()=>An,dict:()=>Za,emptyArray:()=>E,endTestSteps:()=>{},entries:()=>ue,enumerate:()=>H,intern:()=>Mn,isDict:()=>j,isEmptyArray:()=>pa,isIndexable:()=>ve,isSerializationFirstNode:()=>Dn,keys:()=>n,logStep:()=>{},reverse:()=>k,strip:()=>Tn,values:()=>_t,verifySteps:()=>{},zipArrays:()=>Be,zipTuples:()=>Le}),bn=console,fn=console;function An(e){let t=e.firstChild;for(;t;){let a=t.nextSibling;e.removeChild(t),t=a}}function Mn(e){let t={};t[e]=1;for(let a in t)if(a===e)return a;return e}var In="%+b:0%";function Dn(e){return e.nodeValue===In}function Tn(e,...t){let a="";for(const[i,o]of H(e))a+=`${o}${void 0!==t[i]?String(t[i]):""}`;let n=a.split("\n");for(;Pe(n)&&/^\s*$/u.test(d(n));)n.shift();for(;Pe(n)&&/^\s*$/u.test(Re(n));)n.pop();let s=1/0;for(let i of n){let e=/^\s*/u.exec(i)[0].length;s=Math.min(s,e)}let r=[];for(let i of n)r.push(i.slice(s));return r.join("\n")}function vn(e,t="unexpected unreachable branch"){throw fn.log("unreachable",e),fn.log(`${t} :: ${JSON.stringify(e)} (${e})`),new Error("code reached unreachable")}export{Nt as Application,w as ApplicationNamespace,Ae as Array,Ka as ArrayMutable,Qa as ArrayProxy,Wt as Component,Ce as Controller,s as Debug,Lt as EmberDestroyable,ca as EmberObject,ca as Object,ne as EnumerableMutable,oa as GlimmerComponent,mn as GlimmerManager,rt as GlimmerReference,yn as GlimmerRuntime,Cn as GlimmerUtil,Ia as GlimmerValidator,Pt as Instrumentation,ft as InternalsEnvironment,an as InternalsMeta,$t as InternalsMetal,nn as InternalsRuntime,sn as InternalsUtils,dn as InternalsViews,Ue as ObjectCore,kt as ObjectEvented,Ta as ObjectInternals,G as ObjectObservable,hn as ObjectPromiseProxyMixin,pn as ObjectProxy,ra as Owner,Kt as RSVP,lt as Runloop,ya as Service,Zt as VERSION}; \ No newline at end of file diff --git a/release/assets/negentropy-BmwO83Nu.js b/release/assets/negentropy-C2aqP_zP.js similarity index 99% rename from release/assets/negentropy-BmwO83Nu.js rename to release/assets/negentropy-C2aqP_zP.js index 978c8c9..7f4f246 100644 --- a/release/assets/negentropy-BmwO83Nu.js +++ b/release/assets/negentropy-C2aqP_zP.js @@ -1 +1 @@ -import{C as t,D as e,E as i,O as r,S as n,T as s,b as a,w as o,x as h,y as u}from"./main-MT6QR2E9.js";function l(){for(var t=[],r=0;r>>=7;e.reverse();for(let i=0;iu.create().update(t).digest()}setToZero(){this.buf=new Uint8Array(d)}add(t){let e=0,i=0,r=new DataView(this.buf.buffer),n=new DataView(t.buffer);for(let s=0;s<8;s++){let t=4*s,a=r.getUint32(t,!0);a+=e,a+=n.getUint32(t,!0),a>4294967295&&(i=1),r.setUint32(t,4294967295&a,!0),e=i,i=0}}negate(){let t=new DataView(this.buf.buffer);for(let i=0;i<8;i++){let e=4*i;t.setUint32(e,~t.getUint32(e,!0))}let e=new Uint8Array(d);e[0]=1,this.add(e)}async getFingerprint(t){let e=new c;return e.extend(this.buf),e.extend(m(t)),(await this.sha256(e.unwrap())).subarray(0,16)}},w=class{items;sealed;constructor(){this.items=[],this.sealed=!1}insert(t,e){if(this.sealed)throw Error("already sealed");if((e=y(e)).byteLength!==d)throw Error("bad id size for added item");this.items.push({timestamp:t,id:e})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(A);for(let t=1;t=this.items.length)throw Error("out of range");return this.items[t]}iterate(t,e,i){this._checkSealed(),this._checkBounds(t,e);for(let r=t;rA(t,i)<0)}async fingerprint(t,e){let i=new p;return i.setToZero(),this.iterate(t,e,t=>(i.add(t.id),!0)),await i.getFingerprint(e-t)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(t,e){if(t>e||e>this.items.length)throw Error("bad range")}_binarySearch(t,e,i,r){let n=i-e;for(;n>0;){let i=e,s=Math.floor(n/2);i+=s,r(t[i])?(e=++i,n-=s+1):n=s}return e}},b=class{storage;frameSizeLimit;lastTimestampIn;lastTimestampOut;isInitiator;wantUint8ArrayOutput;constructor(t,e=0){if(0!==e&&e<4096)throw Error("frameSizeLimit too small");this.storage=t,this.frameSizeLimit=e,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(t,e){return{timestamp:t,id:e||new Uint8Array(0)}}async initiate(){if(this.isInitiator)throw Error("already initiated");this.isInitiator=!0;let t=new c;return t.extend([97]),await this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),t),this._renderOutput(t)}setInitiator(){this.isInitiator=!0}async reconcile(t){let e=[],i=[],r=new c(y(t));this.lastTimestampIn=this.lastTimestampOut=0;let n=new c;n.extend([97]);let s=g(r,1)[0];if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(97!==s){if(this.isInitiator)throw Error("unsupported negentropy protocol version requested: "+(s-96));return[this._renderOutput(n),e,i]}let a=this.storage.size(),o=this._bound(0),h=0,u=!1;for(;0!==r.length;){let t=new c,s=()=>{u&&(u=!1,t.extend(this.encodeBound(o)),t.extend(m(0)))},l=this.decodeBound(r),p=f(r),w=h,b=this.storage.findLowerBound(h,a,l);if(0===p)u=!0;else if(1===p)0!==E(g(r,16),await this.storage.fingerprint(w,b))?(s(),await this.splitRange(w,b,l,t)):u=!0;else{if(2!==p)throw Error("unexpected mode");{let a=f(r),o={};for(let t=0;t{let i=t.id;return o[i]?delete o[i]:this.isInitiator&&e.push(this.wantUint8ArrayOutput?i:x(i)),!0});for(let t of Object.values(o))i.push(this.wantUint8ArrayOutput?t:x(t))}else{s();let e=new c,i=0,r=l;this.storage.iterate(w,b,(t,s)=>this.exceededFrameSizeLimit(n.length+e.length)?(r=t,b=s,!1):(e.extend(t.id),i++,!0)),t.extend(this.encodeBound(r)),t.extend(m(2)),t.extend(m(i)),t.extend(e),n.extend(t),t=new c}}}if(this.exceededFrameSizeLimit(n.length+t.length)){let t=await this.storage.fingerprint(b,a);n.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),n.extend(m(1)),n.extend(t);break}n.extend(t),h=b,o=l}return[1===n.length&&this.isInitiator?null:this._renderOutput(n),e,i]}async splitRange(t,e,i,r){let n=e-t;if(n<32)r.extend(this.encodeBound(i)),r.extend(m(2)),r.extend(m(n)),this.storage.iterate(t,e,t=>(r.extend(t.id),!0));else{let s=Math.floor(n/16),a=n%16,o=t;for(let t=0;t<16;t++){let n,h=s+(t(r===o-1?t=i:e=i,!0)),n=this.getMinimalBound(t,e)}r.extend(this.encodeBound(n)),r.extend(m(1)),r.extend(u)}}}_renderOutput(t){let e=t.unwrap();return this.wantUint8ArrayOutput?e:x(e)}exceededFrameSizeLimit(t){return this.frameSizeLimit&&t>this.frameSizeLimit-200}decodeTimestampIn(t){let e=f(t);return e=0===e?Number.MAX_VALUE:e-1,this.lastTimestampIn===Number.MAX_VALUE||e===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(e+=this.lastTimestampIn,this.lastTimestampIn=e,e)}decodeBound(t){let e=this.decodeTimestampIn(t),i=f(t);if(i>d)throw Error("bound key too long");return{timestamp:e,id:g(t,i)}}encodeTimestampOut(t){if(t===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,m(0);let e=t;return t-=this.lastTimestampOut,this.lastTimestampOut=e,m(t+1)}encodeBound(t){let e=new c;return e.extend(this.encodeTimestampOut(t.timestamp)),e.extend(m(t.id.length)),e.extend(t.id),e}getMinimalBound(t,e){if(e.timestamp!==t.timestamp)return this._bound(e.timestamp);{let i=0,r=e.id,n=t.id;for(let t=0;t>>4&15]+t[15&e]}function x(t){let e="";for(let i=0,r=t.length;ie[i])return 1}return t.byteLength>e.byteLength?1:t.byteLength(L("Sending initial message",d,s,f),["NEG-OPEN",d,s,f]),()=>(L("Closing sync",d),["NEG-CLOSE",d]),t=>("NEG-MSG"===t[0]||"NEG-ERR"===t[0])&&t[1]===d).pipe(t(t=>{if("NEG-ERR"===t[0])throw new Error(t[2]);return t[2]}),h());if(u?.signal?.aborted)return!1;const p=new e(t=>{if(u?.signal?.aborted)return t.next("abort"),void t.complete();const e=()=>{t.next("abort"),t.complete()};return u?.signal?.addEventListener("abort",e),()=>u?.signal?.removeEventListener("abort",e)}),w=g.subscribe({next:t=>L(t),error:()=>{}});try{for(;m&&!0!==u?.signal?.aborted;)try{const e=await o(l(g.pipe(t(t=>({type:"message",data:t}))),p.pipe(t(()=>({type:"abort"})))));if("abort"===e.type||u?.signal?.aborted)return w.unsubscribe(),!1;const[i,r,n]=await c.reconcile(e.data);await a(r,n),m=i}catch(y){if(u?.signal?.aborted)return w.unsubscribe(),!1;throw y}}catch(y){throw w.unsubscribe(),y}finally{w.unsubscribe()}return!0}export{U as buildStorageFromFilter,I as buildStorageVector,O as negentropySync}; \ No newline at end of file +import{C as t,D as e,E as i,O as r,S as n,T as s,b as a,w as o,x as h,y as u}from"./main-D3dQ-CGf.js";function l(){for(var t=[],r=0;r>>=7;e.reverse();for(let i=0;iu.create().update(t).digest()}setToZero(){this.buf=new Uint8Array(d)}add(t){let e=0,i=0,r=new DataView(this.buf.buffer),n=new DataView(t.buffer);for(let s=0;s<8;s++){let t=4*s,a=r.getUint32(t,!0);a+=e,a+=n.getUint32(t,!0),a>4294967295&&(i=1),r.setUint32(t,4294967295&a,!0),e=i,i=0}}negate(){let t=new DataView(this.buf.buffer);for(let i=0;i<8;i++){let e=4*i;t.setUint32(e,~t.getUint32(e,!0))}let e=new Uint8Array(d);e[0]=1,this.add(e)}async getFingerprint(t){let e=new c;return e.extend(this.buf),e.extend(m(t)),(await this.sha256(e.unwrap())).subarray(0,16)}},w=class{items;sealed;constructor(){this.items=[],this.sealed=!1}insert(t,e){if(this.sealed)throw Error("already sealed");if((e=y(e)).byteLength!==d)throw Error("bad id size for added item");this.items.push({timestamp:t,id:e})}seal(){if(this.sealed)throw Error("already sealed");this.sealed=!0,this.items.sort(A);for(let t=1;t=this.items.length)throw Error("out of range");return this.items[t]}iterate(t,e,i){this._checkSealed(),this._checkBounds(t,e);for(let r=t;rA(t,i)<0)}async fingerprint(t,e){let i=new p;return i.setToZero(),this.iterate(t,e,t=>(i.add(t.id),!0)),await i.getFingerprint(e-t)}_checkSealed(){if(!this.sealed)throw Error("not sealed")}_checkBounds(t,e){if(t>e||e>this.items.length)throw Error("bad range")}_binarySearch(t,e,i,r){let n=i-e;for(;n>0;){let i=e,s=Math.floor(n/2);i+=s,r(t[i])?(e=++i,n-=s+1):n=s}return e}},b=class{storage;frameSizeLimit;lastTimestampIn;lastTimestampOut;isInitiator;wantUint8ArrayOutput;constructor(t,e=0){if(0!==e&&e<4096)throw Error("frameSizeLimit too small");this.storage=t,this.frameSizeLimit=e,this.lastTimestampIn=0,this.lastTimestampOut=0}_bound(t,e){return{timestamp:t,id:e||new Uint8Array(0)}}async initiate(){if(this.isInitiator)throw Error("already initiated");this.isInitiator=!0;let t=new c;return t.extend([97]),await this.splitRange(0,this.storage.size(),this._bound(Number.MAX_VALUE),t),this._renderOutput(t)}setInitiator(){this.isInitiator=!0}async reconcile(t){let e=[],i=[],r=new c(y(t));this.lastTimestampIn=this.lastTimestampOut=0;let n=new c;n.extend([97]);let s=g(r,1)[0];if(s<96||s>111)throw Error("invalid negentropy protocol version byte");if(97!==s){if(this.isInitiator)throw Error("unsupported negentropy protocol version requested: "+(s-96));return[this._renderOutput(n),e,i]}let a=this.storage.size(),o=this._bound(0),h=0,u=!1;for(;0!==r.length;){let t=new c,s=()=>{u&&(u=!1,t.extend(this.encodeBound(o)),t.extend(m(0)))},l=this.decodeBound(r),p=f(r),w=h,b=this.storage.findLowerBound(h,a,l);if(0===p)u=!0;else if(1===p)0!==E(g(r,16),await this.storage.fingerprint(w,b))?(s(),await this.splitRange(w,b,l,t)):u=!0;else{if(2!==p)throw Error("unexpected mode");{let a=f(r),o={};for(let t=0;t{let i=t.id;return o[i]?delete o[i]:this.isInitiator&&e.push(this.wantUint8ArrayOutput?i:x(i)),!0});for(let t of Object.values(o))i.push(this.wantUint8ArrayOutput?t:x(t))}else{s();let e=new c,i=0,r=l;this.storage.iterate(w,b,(t,s)=>this.exceededFrameSizeLimit(n.length+e.length)?(r=t,b=s,!1):(e.extend(t.id),i++,!0)),t.extend(this.encodeBound(r)),t.extend(m(2)),t.extend(m(i)),t.extend(e),n.extend(t),t=new c}}}if(this.exceededFrameSizeLimit(n.length+t.length)){let t=await this.storage.fingerprint(b,a);n.extend(this.encodeBound(this._bound(Number.MAX_VALUE))),n.extend(m(1)),n.extend(t);break}n.extend(t),h=b,o=l}return[1===n.length&&this.isInitiator?null:this._renderOutput(n),e,i]}async splitRange(t,e,i,r){let n=e-t;if(n<32)r.extend(this.encodeBound(i)),r.extend(m(2)),r.extend(m(n)),this.storage.iterate(t,e,t=>(r.extend(t.id),!0));else{let s=Math.floor(n/16),a=n%16,o=t;for(let t=0;t<16;t++){let n,h=s+(t(r===o-1?t=i:e=i,!0)),n=this.getMinimalBound(t,e)}r.extend(this.encodeBound(n)),r.extend(m(1)),r.extend(u)}}}_renderOutput(t){let e=t.unwrap();return this.wantUint8ArrayOutput?e:x(e)}exceededFrameSizeLimit(t){return this.frameSizeLimit&&t>this.frameSizeLimit-200}decodeTimestampIn(t){let e=f(t);return e=0===e?Number.MAX_VALUE:e-1,this.lastTimestampIn===Number.MAX_VALUE||e===Number.MAX_VALUE?(this.lastTimestampIn=Number.MAX_VALUE,Number.MAX_VALUE):(e+=this.lastTimestampIn,this.lastTimestampIn=e,e)}decodeBound(t){let e=this.decodeTimestampIn(t),i=f(t);if(i>d)throw Error("bound key too long");return{timestamp:e,id:g(t,i)}}encodeTimestampOut(t){if(t===Number.MAX_VALUE)return this.lastTimestampOut=Number.MAX_VALUE,m(0);let e=t;return t-=this.lastTimestampOut,this.lastTimestampOut=e,m(t+1)}encodeBound(t){let e=new c;return e.extend(this.encodeTimestampOut(t.timestamp)),e.extend(m(t.id.length)),e.extend(t.id),e}getMinimalBound(t,e){if(e.timestamp!==t.timestamp)return this._bound(e.timestamp);{let i=0,r=e.id,n=t.id;for(let t=0;t>>4&15]+t[15&e]}function x(t){let e="";for(let i=0,r=t.length;ie[i])return 1}return t.byteLength>e.byteLength?1:t.byteLength(L("Sending initial message",d,s,f),["NEG-OPEN",d,s,f]),()=>(L("Closing sync",d),["NEG-CLOSE",d]),t=>("NEG-MSG"===t[0]||"NEG-ERR"===t[0])&&t[1]===d).pipe(t(t=>{if("NEG-ERR"===t[0])throw new Error(t[2]);return t[2]}),h());if(u?.signal?.aborted)return!1;const p=new e(t=>{if(u?.signal?.aborted)return t.next("abort"),void t.complete();const e=()=>{t.next("abort"),t.complete()};return u?.signal?.addEventListener("abort",e),()=>u?.signal?.removeEventListener("abort",e)}),w=g.subscribe({next:t=>L(t),error:()=>{}});try{for(;m&&!0!==u?.signal?.aborted;)try{const e=await o(l(g.pipe(t(t=>({type:"message",data:t}))),p.pipe(t(()=>({type:"abort"})))));if("abort"===e.type||u?.signal?.aborted)return w.unsubscribe(),!1;const[i,r,n]=await c.reconcile(e.data);await a(r,n),m=i}catch(y){if(u?.signal?.aborted)return w.unsubscribe(),!1;throw y}}catch(y){throw w.unsubscribe(),y}finally{w.unsubscribe()}return!0}export{U as buildStorageFromFilter,I as buildStorageVector,O as negentropySync}; \ No newline at end of file diff --git a/release/index.html b/release/index.html index cf3fd6a..27b93fe 100644 --- a/release/index.html +++ b/release/index.html @@ -39,8 +39,8 @@ - - + +