@motifx/core 1.2.0-rc.1 → 1.2.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- function t(t){setTimeout(()=>{throw t},0)}class e{unexpectedErrorHandler=t;listeners=[];_isDevelopment=!1;_enableConsoleLogging=!0;setDevelopmentMode(t){this._isDevelopment=t}setConsoleLogging(t){this._enableConsoleLogging=t}isDevelopment(){return this._isDevelopment||!0===globalThis.__MOTIF_DEV__}reportSuppressed(t,e){this.logIfDev(t,e)}report(t){this._enableConsoleLogging&&(void 0!==t.cause?console.error(t.message,t.cause):console.error(t.message));try{const e=globalThis.__MOTIF_DEVTOOLS_BUS__;e&&"function"==typeof e.publish&&e.publish("error:caught",{context:t.code??t.name,error:this.serializeError(t)})}catch{}this.emit(t)}logIfDev(t,e){this.isDevelopment()&&this._enableConsoleLogging&&console.error(`[motifjs Error - ${t}]`,e);try{const s=globalThis.__MOTIF_DEVTOOLS_BUS__;s&&"function"==typeof s.publish&&s.publish("error:caught",{context:t,error:this.serializeError(e)})}catch{}}serializeError(t){if(!t)return{message:"Unknown error"};if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack,cause:t.cause?this.serializeError(t.cause):void 0};if("object"==typeof t)try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}return String(t)}addListener(t){return this.listeners.push(t),()=>{const e=this.listeners.indexOf(t);-1!==e&&this.listeners.splice(e,1)}}emit(t){for(const e of this.listeners.slice())e(t)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}safeCall(t,e,s){try{return t()}catch(t){return this.logIfDev(e,t),this.onUnexpectedError(t),s}}async safeCallAsync(t,e,s){try{return await t()}catch(t){return this.logIfDev(e,t),this.onUnexpectedError(t),s}}safeCallSilent(t,e){try{t()}catch(t){this.logIfDev(e,t)}}async safeCallSilentAsync(t,e){try{return await t()}catch(t){this.logIfDev(e,t)}}wrapSafe(t,e){return(...s)=>{try{return t(...s)}catch(t){return this.logIfDev(e,t),void this.onUnexpectedError(t)}}}wrapSafeAsync(t,e){return async(...s)=>{try{return await t(...s)}catch(t){return this.logIfDev(e,t),void this.onUnexpectedError(t)}}}}const s=new e;function i(t,e,i){return s.safeCall(t,e,i)}function n(t,e,i){return s.safeCallAsync(t,e,i)}function o(t,e){s.safeCallSilent(t,e)}function r(t){s.setUnexpectedErrorHandler(t)}const a={enabled:!1,listeners:new Set,warnings:[],routes:null};function c(){return a.enabled||!0===globalThis.__MOTIF_DEV__}function l(){try{if("undefined"==typeof window)return!1;return!0===window.__motif_DEVTOOLS||(!0===globalThis.__MOTIF_DEVTOOLS__||!0===globalThis.__MOTIF_DEVTOOLS_FLAG)}catch{return!1}}function h(t){try{t?window.__motifDevBus={on:p,emit:f,warn:m,getWarnings:_,isEnabled:d,setRoutes:g,getRoutes:y}:delete window.__motifDevBus}catch{}}function u(){a.enabled||(a.enabled=l(),a.enabled&&h(!0))}function d(){return a.enabled}function p(t){return a.listeners.add(t),()=>{a.listeners.delete(t)}}function f(t,e){const s={type:t,payload:e};for(const t of a.listeners)try{t(s)}catch{}try{const s=globalThis.__MOTIF_DEVTOOLS_BUS__;s&&"function"==typeof s.publish&&s.publish("devtools:"+t,e)}catch{}}function m(t,e,s){if(!c())return;const i={code:t,message:e,details:s};a.warnings.push(i);try{"undefined"!=typeof console&&(void 0===s?console.warn(`[motifjs] ${t}: ${e}`):console.warn(`[motifjs] ${t}: ${e}`,s))}catch{}f("warning",i)}function _(){return a.warnings.slice()}function g(t){a.routes=t}function y(){return a.routes}const v={MJX101:t=>`dom.createElement('${t}'): no document is available (no DOM environment).`,MJX102:t=>`Invalid element selector "${t}".`,MJX103:t=>`dom.createElementNS('${t}') failed.`,MJX104:()=>"Skipped inserting a component into the DOM because it contains its own parent.",MJX105:()=>"Applying router link classes failed.",MJX106:()=>"The placeholder parent changed; rebuilding the component.",MJX107:()=>"Disposing a child component failed.",MJX108:()=>"Component is disposed; the result of doWork was discarded.",MJX109:()=>"A content block child was removed because its content body is being disposed.",MJX110:t=>`Lazy timeout: the component did not load within ${t} ms.`,MJX111:()=>"Lazy aborted: loading the component was cancelled.",MJX112:t=>`resolveComponent: the factory chain exceeded ${t} levels; a factory may be returning itself.`,MJX113:()=>"The transport slot has no parent; mount the slot before transporting into it.",MJX114:()=>"Placing the navigation target into its host failed.",MJX115:()=>"Disposing the previous navigation target failed.",MJX116:t=>`Timeout: the listener guard did not settle within ${t} ms.`,MJX117:()=>"Detaching a control failed.",MJX118:()=>"The onRemove callback failed while detaching a control.",MJX119:()=>"Moving a fragment's DOM range stopped: its end marker was not found (possible infinite loop).",MJX120:()=>"Scanning a fragment's DOM range stopped: its end marker was not found (possible infinite loop).",MJX121:(t,e)=>`This code was compiled for compiler contract ${t}, but the @motifx/core runtime implements contract ${e}. Install matching versions of @motifx/compiler and @motifx/core, and rebuild packages that ship compiled JSX.`,MJX122:t=>`The component ${t} hook threw.`,MJX123:t=>`The '${t}' event handler threw.`,MJX124:t=>`A spread object on a DOM tag cannot set ${t}; the key was ignored. Write it on the tag, or use x-html, for HTML you trust.`,MJX125:t=>`A spread object on a DOM tag cannot set a javascript: URL on '${t}'; the value was ignored. Write the attribute on the tag if it is intended.`,MJX126:()=>"Lazy: loading the component failed and no Fallbackview is set; the host was cleared.",MJX127:t=>"module"===t?"The loaded module has no default export. Export the component as default, or map it: () => import('./X').then(m => m.X).":`The loaded value is not a component (got ${t}). Return a component class, a function component, an Options API factory or a component instance.`,MJX128:(t,e,s)=>"method"===s?`${t} overrides ${e} without calling super.${e}; MotifJS relies on this ComponentBase member. Rename your member, or call super.${e} in the override.`:"field"===s?`${t} defines '${e}' as an instance field, which hides the ComponentBase member MotifJS relies on. Rename your field.`:`${t} replaces '${e}', which MotifJS created for the component (a class field or an assignment with that name). Rename your member.`,MJX201:()=>"ListBinding: renderFn must return a component instance, a component class, or a factory function.",MJX202:(t,e)=>`ListBinding: duplicate key "${String(t)}" at index ${e}. Rows are matched by the item object, not by key, so rendering is not affected; keep keys unique so they identify items.`,MJX203:t=>`An effect ran ${t} times in one flush and keeps triggering itself; it is skipped for the rest of this flush. It probably writes a value it reads (for example state.n++). Wrap the write in untracked(...).`,MJX204:()=>"A component reached a text binding and was not written to the DOM. For a template prop that can change later, write a getter: {() => props.tpl}. Templates that are ready at setup also work as {props.tpl}.",MJX205:()=>"Virtualization: the watch callback threw.",MJX206:()=>"Virtualization: autoRefresh stopped; dataRequest may be changing the reactive data it reads on every refresh.",MJX207:()=>"Virtualization: loading data failed.",MJX208:()=>"An effect threw.",MJX301:(t,e)=>`RouterView outlet '${t}' was not built within ${e} ms, so the route chain cannot be mounted. Does the layout component render a <RouterView>?`,MJX302:t=>`Named route '${t}' was not found.`,MJX303:t=>`Redirect loop or too many redirects: ${t}`,MJX304:()=>"Route execution failed.",MJX305:()=>"The error fallback route failed.",MJX306:t=>`The ${t} hook threw.`,MJX307:()=>"Disposing a route component failed.",MJX308:()=>"The stack navigation transition failed.",MJX309:()=>"Router is not initialized. Call useRouter() before navigating.",MJX310:t=>`Route path cannot be empty; use '/' for the default child. Under parent "${t}".`,MJX311:(t,e)=>`Child route path should start with '/': "${t}" under parent "${e}".`,MJX312:t=>`Child route path resolves to the same full path as its parent: "${t}".`,MJX313:t=>`Multiple routes resolve to the same full path: "${t}".`,MJX314:(t,e)=>`Child route alias should start with '/': "${t}" under parent "${e}".`,MJX315:t=>`Route alias resolves to the route's own path: "${t}".`,MJX316:t=>`Multiple routes use the same alias: "${t}".`,MJX401:t=>`Service not registered for token: ${t}`,MJX402:t=>`Async factory used with get() for token ${t}; use getAsync().`,MJX403:()=>"Invalid service descriptor.",MJX404:t=>`Cyclic dependency detected: ${t}`,MJX405:()=>"Only one ApplicationBuilder instance is allowed.",MJX406:t=>`Application.run: host not found for selector: ${t}`,MJX407:t=>`getService: no ServiceProvider found for token '${t}'.`,MJX408:(t,e)=>`getService failed for token '${t}': ${e}`,MJX409:t=>`inject(${t}) was called outside a service construction; call it in a field initializer or constructor of a class the ServiceProvider creates.`,MJX410:(t,e)=>`Multiple sources provided for token '${t}': ${e}. Resolution order is useValue > useFactory > useClass.`,MJX411:t=>`'deps' must be an array for token '${t}'; the invalid deps are ignored.`,MJX413:t=>`Service '${t}' is registered with a function that cannot be constructed. Use { useValue: fn } to provide the function itself or { useFactory: fn } to create the service.`,MJX414:(t,e)=>`FromService failed for token '${t}': ${e}`,MJX501:()=>"Disposable already disposed.",MJX502:()=>"Cannot register a disposable on itself.",MJX503:()=>"Errors were thrown while disposing a store.",MJX504:()=>"A disposable was added to a DisposableStore that is already disposed; the added object will leak.",MJX505:()=>"Cannot dispose a disposable on itself.",MJX507:(t,e,s)=>`[${t}] potential listener LEAK: ${e} listeners already; most frequent stack (${s}):`,MJX601:()=>"Sequence contains no elements.",MJX602:()=>"Circuit is open.",MJX603:()=>"Bulkhead queue is full.",MJX604:()=>"Rate limit exceeded.",MJX605:()=>"Operation timed out.",MJX607:()=>"A history must be created with at least one entry.",MJX608:()=>"Method not implemented.",MJX609:()=>"OperationRunner: the operation threw.",MJX610:()=>"Matching the request path failed.",MJX611:()=>"The devtools panel failed to load."};class w extends Error{code;constructor(t,e,s){super(e,s),this.name="MotifError",this.code=t}}function b(t,...e){return`[motifjs] ${t}: ${v[t](...e)}`}function S(t,...e){return new w(t,b(t,...e))}function M(t,e,...i){s.report(new w(t,b(t,...i),{cause:e}))}function C(t,e,...s){try{const i=t();i&&"function"==typeof i.then&&i.then(void 0,t=>M(e,t,...s))}catch(t){M(e,t,...s)}}function A(t,e,s){m(t,v[t](...e),s)}const k=new class{disposableTracker=null;notifyCreated(t){return this.disposableTracker?.trackDisposable(t),t}notifyDisposed(t){this.disposableTracker?.markAsDisposed(t)}notifyOwner(t,e){this.disposableTracker?.setParent(t,e)}toDisposable(t){let e=!0;const s={dispose:()=>{e&&(e=!1,this.notifyDisposed(s),t())}};return this.notifyCreated(s)}};class D{_items=new Set;_closed=!1;constructor(){k.notifyCreated(this)}get isDisposed(){return this._closed}add(t){if(!t)return t;if(t===this)throw S("MJX502");return k.notifyOwner(t,this),this._closed?A("MJX504",[],(new Error).stack):this._items.add(t),t}delete(t){if(t){if(t===this)throw S("MJX505");this._items.delete(t),t.dispose()}}detach(t){t&&this._items.delete(t)&&k.notifyOwner(t,null)}clear(){if(0===this._items.size)return;const t=[];for(const e of this._items)try{e?.dispose()}catch(e){t.push(e)}if(this._items.clear(),1===t.length)throw t[0];if(t.length>1)throw new w("MJX503",b("MJX503"),{cause:new AggregateError(t)})}dispose(){this._closed||(k.notifyDisposed(this),this._closed=!0,this.clear())}}class E{_disposables=new D;constructor(){k.notifyCreated(this),k.notifyOwner(this._disposables,this)}dispose(){k.notifyDisposed(this);const t=this._disposables;t&&"function"==typeof t.dispose?t.dispose():A("MJX501",[],{disposable:this})}_register(t){if(t===this)throw S("MJX502");return this._disposables.add(t)}}const T={IS_REACTIVE:Symbol.for("motif.isReactive"),IS_READONLY:Symbol.for("motif.isReadonly"),IS_SUPERFICIAL:Symbol.for("motif.isSuperficial"),RAW:Symbol.for("motif.raw"),GET_SETUP:Symbol.for("motif.getSetup")},x=Symbol("");let O=!0,N={enabled:!1,key:""};function P(t){let e=t;for(;e&&e[T.RAW];)e=e[T.RAW];return e}function L(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function X(t){return"object"==typeof t&&null!==t}const R=new Set(Object.values(Object.getOwnPropertyDescriptors(Symbol)).map(t=>t.value).filter(t=>"symbol"==typeof t));function I(t){return"symbol"==typeof t&&R.has(t)}const J=new Map([["[object Object]",1],["[object Array]",1],["[object Map]",2],["[object Set]",2],["[object WeakMap]",2],["[object WeakSet]",2]]);const H=/^(?:0|[1-9]\d*)$/,j=[];let F=0;function B(t){j[F++]=O,O=t}function z(){B(!1)}function V(){O=!(F>0)||j[--F]}const W=[];class ${component;itemsFn;renderFn;options;propertyName="__list__";dataSource;dataMember;formatString;converter;converterBack;updateMode;_isActive=!1;_effectCleanup;_rendered=[];_identityMap=new WeakMap;container=ni("list-container");constructor(t,e,s,i){this.component=t,this.itemsFn=e,this.renderFn=s,this.options=i,this.component.controls.add(this.container)}activate(){this._isActive||(this._isActive=!0,this._setupBinding())}deactivate(){this._isActive&&(this._isActive=!1,this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0),this._disposeAll())}reActivate(){this.deactivate(),this.activate()}_disposeAll(){this._rendered.forEach(t=>{try{t.dispose&&t.dispose()}catch{}}),this._rendered=[],this._identityMap=new WeakMap}_toArray(t){return t?Array.isArray(t)?t:"function"==typeof t?this._toArray(t()):t[Symbol.iterator]?Array.from(t):[]:[]}_getComponentKey(t){try{const e=t.props;if(e&&"function"==typeof e.indexkey)return e.indexkey();if(e&&void 0!==e.indexkey&&null!==e.indexkey)return e.indexkey}catch{}try{const e=t.motif.options?.__key;if(void 0!==e)return e}catch{}}isPreCreated(t){return null!==t.element||null!==t.parent}_render(t,e){return Tt(()=>{const s=this.renderFn(t,e);return this.processRendered(s,t)})}processRendered(t,e){const s=Ws(t);if(!(s instanceof us))throw S("MJX201");try{s._base.itemRef=e}catch{}try{s.motif.options.__fromList=!0}catch{}return void 0===s.__listAdopted&&(s.__listAdopted=null!==s.parent&&void 0!==s.parent),s}olditems=[];get _indexSensitive(){try{return this.renderFn.length>=2}catch{return!0}}static _isPrimitive(t){return null===t||"object"!=typeof t}_setupBinding(){const t=()=>{const t=this._toArray(this.itemsFn()),e=P(t),s=t.length;let i;if(e===t)i=t;else{i=new Array(s);for(let n=0;n<s;n++)n in e?i[n]=t[n]:t[n]}const n=this.olditems,o=this._rendered;if(this.olditems.length>0){const t=new Set;for(let e=0;e<s;e++)t.add(P(i[e]));for(const e of this.olditems){const s=P(e);if(!t.has(s)){const t=this._identityMap.get(s);if(t){this._identityMap.delete(s);for(const e of t)try{e.dispose()}catch{}}}}}const r=[],a=new Set,c=new Map,l=new Set,h=new Map,u=t=>!(!t||t.isDisposed||l.has(t)||t.__listAdopted),d=Math.min(i.length,n.length);for(let t=0;t<d;t++){const e=i[t];if(!$._isPrimitive(e))continue;if(!Object.is(n[t],e))continue;const s=o[t];u(s)&&(h.set(t,s),l.add(s))}let p=null;if(!this._indexSensitive){p=new Map;for(let t=0;t<n.length;t++){const e=n[t];if(!$._isPrimitive(e))continue;const s=o[t];if(!u(s))continue;const i=p.get(e);i?i.push(s):p.set(e,[s])}}const f=new Map;return i.forEach((t,e)=>{let s;if("object"==typeof t&&null!==t){const i=P(t),n=f.get(i)??0;f.set(i,n+1);let o=this._identityMap.get(i);o||(o=[],this._identityMap.set(i,o));const r=o[n];r&&!r.isDisposed?s=r:(s=this._render(t,e),o[n]=s)}else{let i=h.get(e);if(!i&&p){const e=p.get(t);e&&e.length&&(i=e.shift(),l.add(i))}s=i||this._render(t,e)}const i=this._getComponentKey(s);null!=i&&(c.has(i)?A("MJX202",[i,e]):c.set(i,e)),r.push(s),a.add(s)}),f.forEach((t,e)=>{const s=this._identityMap.get(e);s&&s.length>t&&(s.length=t)}),this._rendered.forEach(t=>{if(!a.has(t)&&!t.__listAdopted)try{t.dispose()}catch{}}),this._syncContainer(r),this._rendered=r,this.olditems=i===t?t.slice():i,s};this._effectCleanup=At(()=>t())}_syncContainer(t){const e=this.container.controls,s=e.items;if(0===s.length){for(const s of t)try{e.add(s)}catch{}return}if(t.length>=s.length){let i=!0;for(let e=0;e<s.length;e++)if(t[e]!==s[e]){i=!1;break}if(i&&t.length>s.length){const e=new Set(s);for(let n=s.length;n<t.length;n++){if(e.has(t[n])){i=!1;break}e.add(t[n])}}if(i){for(let i=s.length;i<t.length;i++)try{e.add(t[i])}catch{}return}}const i=new Map;s.forEach((t,e)=>i.set(t,e));const n=t.map(t=>{const e=i.get(t);return void 0===e?-1:e}),o=new Set(function(t){const e=new Array(t.length).fill(-1),s=[];for(let i=0;i<t.length;i++){const n=t[i];if(-1===n)continue;if(0===s.length||t[s[s.length-1]]<n){e[i]=s.length>0?s[s.length-1]:-1,s.push(i);continue}let o=0,r=s.length-1;for(;o<r;){const e=o+r>>1;t[s[e]]<n?o=e+1:r=e}n<t[s[o]]&&(e[i]=o>0?s[o-1]:-1,s[o]=i)}const i=[];let n=s.length>0?s[s.length-1]:-1;for(;-1!==n;)i.push(n),n=e[n];return i.reverse()}(n));let r=null;for(let i=t.length-1;i>=0;i--){const a=t[i];try{if(-1===n[i])if(r){const t=s.indexOf(r);e.add(t>=0?t:s.length,a)}else e.add(a);else o.has(i)||e.move(a,r)}catch{}r=a}}}class U{Key;value}class q{ItemAdded;ItemAddedBefore;ItemSplice;__list=[];_map=new Set;Dispose(){this.__list=[]}Add(t){this._map.add(t);var e=this.__list.push(t)-1;return null!=this.ItemAdded&&this.ItemAdded(t),e}AddBefore(t){this._map.add(t);var e=this.__list.unshift(t)-1;return null!=this.ItemAddedBefore&&this.ItemAddedBefore(t),e}Insert(t,e){this._map.add(e);var s=this.__list.splice(t,0,e);return null!=this.ItemSplice&&this.ItemSplice(t,e),s}get items(){return this.__list}clear(){return this._map.clear(),this.__list.splice(0),this.__list=[],this.__list}get count(){return this.__list.length}remove(t){const e=this.__list.indexOf(t);return-1===e?[]:(this._map.delete(t),this.__list.splice(e,1))}indexOf(t){return this.__list.indexOf(t)}FindFromKey(t,e){return this.__list.filter(s=>s[t]===e)}removeIndex(t){var e=this.__list.splice(t,1);return e.forEach(t=>{this._map.delete(t)}),e}has(t){return this._map.has(t)}item(t){return this.__list[t]}forEach(t){this.__list?.forEach(t)}ReverseClone(){return this.__list.slice().reverse()}filter(t){return this.__list.filter(t)}}function G(t){let e=!0;return{dispose(){e&&(e=!1,t())}}}function K(t){return"/"+t.replace(/^\/+|\/+$/g,"")}function Y(t){try{if(t.isDisposed)return null;if(t.element.nodeType!==Node.COMMENT_NODE&&t.element.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.element.nodeType!==Node.TEXT_NODE)return t;if(t.parent)return Y(t.parent)}catch(t){throw t}return null}class Q{threshold;name;_origins=new Map;_quietChecks=0;constructor(t,e){this.threshold=t,this.name=e}check(t){if(this.threshold<=0||t<this.threshold)return;const e=(new Error).stack??"";if(this._origins.set(e,(this._origins.get(e)??0)+1),this._quietChecks--,this._quietChecks<=0){this._quietChecks=this.threshold/2;const[e,s]=this._busiestOrigin();A("MJX507",[this.name,t,s],e)}return()=>{this._origins.set(e,(this._origins.get(e)??0)-1)}}_busiestOrigin(){let t=["",0];for(const e of this._origins)e[1]>t[1]&&(t=e);return t}}class Z{__values=new q;Add(t,e){var s=new U;s.Key=t,s.value=e;var i=this.__values.Add(s);return null!=this.OnItemAdded&&this.OnItemAdded(s.Key,s.value),i}has(t){return!!this.filter(e=>e.Key==t)[0]}item(t){return this.filter(e=>e.Key==t)[0]}OnItemAdded;removeIndex(t){return this.__values.removeIndex(t)}remove(t){this.__values.filter(e=>e.Key==t).forEach(t=>{this.__values.remove(t)})}clear(){this.__values.clear()}forEach(t){this.__values.forEach(t)}get values(){return this.__values}filter(t){return this.__values.items.filter(t)}find(t,e){return this.__values.items.find(t)}}function tt(){const t={value:void 0,linked:!1};return t.before=t,t.after=t,t}class et{_ring=tt();_count=0;get size(){return this._count}isEmpty(){return 0===this._count}push(t){return this._link(t,this._ring.before)}unshift(t){return this._link(t,this._ring)}pop(){return this._take(this._ring.before)}shift(){return this._take(this._ring.after)}clear(){for(let t=this._ring.after;t!==this._ring;t=t.after)t.linked=!1;this._ring=tt(),this._count=0}*[Symbol.iterator](){const t=this._ring;for(let e=t.after;e!==t;e=e.after)yield e.value}_link(t,e){const s={value:t,before:e,after:e.after,linked:!0};return e.after.before=s,e.after=s,this._count++,()=>this._unlink(s)}_take(t){if(t===this._ring)return;const e=t.value;return this._unlink(t),e}_unlink(t){t.linked&&(t.linked=!1,t.before.after=t.after,t.after.before=t.before,this._count--)}}function st(t){return"function"==typeof t?t:()=>t}function it(t){return"function"==typeof t?t():t}function nt(t,e){return t>e?1:t<e?-1:0}class ot{source;constructor(t){this.source=Array.isArray(t)?t:Array.from(t)}static from(t){return new ot(t)}where(t){return new ot(this.source.filter(t))}select(t){return new ot(this.source.map(t))}orderBy(t){return new ot([...this.source].sort((e,s)=>nt(t(e),t(s))))}orderByDescending(t){return new ot([...this.source].sort((e,s)=>nt(t(s),t(e))))}distinctBy(t){const e=new Set;return new ot(this.source.filter(s=>{const i=t(s);return!e.has(i)&&(e.add(i),!0)}))}groupBy(t){const e=new Map;for(const s of this.source){const i=t(s),n=e.get(i);n?n.push(s):e.set(i,[s])}return new ot(Array.from(e,([t,e])=>({key:t,items:e})))}first(){if(0===this.source.length)throw S("MJX601");return this.source[0]}firstOrDefault(){return this.source[0]}any(t){return t?this.source.some(t):this.source.length>0}all(t){return this.source.every(t)}aggregate(t,e){return this.source.reduce(e,t)}toArray(){return[...this.source]}[Symbol.iterator](){return this.source[Symbol.iterator]()}}const rt=new Set,at=new Set;function ct(t){1===t||rt.has(t)||(c()?(at.delete(t),rt.add(t),A("MJX121",[t,1])):at.add(t))}var lt;!function(t){t[t.ELEMENT_NODE=1]="ELEMENT_NODE",t[t.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",t[t.TEXT_NODE=3]="TEXT_NODE",t[t.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",t[t.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",t[t.ENTITY_NODE=6]="ENTITY_NODE",t[t.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",t[t.COMMENT_NODE=8]="COMMENT_NODE",t[t.DOCUMENT_NODE=9]="DOCUMENT_NODE",t[t.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",t[t.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE",t[t.NOTATION_NODE=12]="NOTATION_NODE"}(lt||(lt={}));class ht{fn;callback;deps=[];active=!0;running=!1;scheduler;constructor(t,e){this.fn=t,this.callback=e}run(){let t;if(this.active&&!this.running){Ct(this),dt.push(this),this.running=!0;try{t=this.fn()}finally{dt.pop(),this.running=!1,this.callback&&this.callback(t)}}}stop(){this.active=!1,Ct(this)}}const ut=new WeakMap,dt=[],pt=new Set;let ft,mt=!1,_t=!1,gt=-1;const yt=new WeakMap;function vt(t={}){_t=!!t.enabled,gt="number"==typeof t.threshold?t.threshold:_t?200:-1,ft=_t&&gt>0?new Q(gt,t.name??"reactivity-core"):void 0}function wt(t,e){if(!O)return;const s=P(t),i=dt[dt.length-1];if(!i||!i.active)return;let n=ut.get(s);n||ut.set(s,n=new Map);let o=n.get(e);if(o||n.set(e,o=new Set),!o.has(i)&&(o.add(i),i.deps.push([s,e]),_t&&ft&&gt>0))try{const t=ft.check(o.size);if(t){let e=yt.get(o);e||(e=new Map,yt.set(o,e)),e.set(i,t)}}catch{}}function bt(t,e){const s=P(t),i=ut.get(s);if(!i)return;const n=i.get(e);if(!n)return;let o=!1;n.forEach(t=>{t.active&&(t.scheduler?St(t.scheduler):(pt.add(t),o=!0))}),o&&function(){if(mt)return;mt=!0,Promise.resolve().then(()=>{const t=new Map;try{for(;pt.size>0;){const e=Array.from(pt);pt.clear();for(const s of e){const e=(t.get(s)??0)+1;t.set(s,e),e>Mt?e===Mt+1&&A("MJX203",[Mt],{fn:String(s.fn).slice(0,200)}):St(()=>s.run())}}}finally{pt.clear(),mt=!1}})}()}function St(t){try{t()}catch(t){M("MJX208",t)}}const Mt=50;function Ct(t){for(const[e,s]of t.deps){const i=ut.get(e);if(!i)continue;const n=i.get(s);if(n){n.delete(t);try{const e=yt.get(n),s=e?.get(t);if(s){try{s()}catch{}e.delete(t)}}catch{}0===n.size&&i.delete(s),0===i.size&&ut.delete(e)}}t.deps=[]}function At(t,e){const s=new ht(t,e);return St(()=>s.run()),()=>s.stop()}function kt(t){if(!t.pushed)return;t.pushed=!1;const e=dt.lastIndexOf(t.effect);e>=0&&dt.splice(e,1)}const Dt={capture:()=>({effect:dt[dt.length-1],pushed:!1}),suspend:(t,e)=>(kt(t),e),resume:(t,e)=>(t.effect&&t.effect.active&&!t.pushed&&(dt.push(t.effect),t.pushed=!0),e),end(t){kt(t)}},Et=new ht(()=>{});function Tt(t){dt.push(Et);try{return t()}finally{dt.pop()}}function xt(t){if(!t||"INPUT"!==t.tagName)return!1;const e=String(t.type||"").toLowerCase();return"checkbox"===e||"radio"===e}function Ot(t){if(t){if(xt(t))return!!t.checked;if(function(t){if(!t||"INPUT"!==t.tagName)return!1;const e=String(t.type||"").toLowerCase();return"number"===e||"range"===e}(t)){const e=t.value;if(""===e||null==e)return null;const s="number"==typeof t.valueAsNumber?t.valueAsNumber:Number(e);return Number.isFinite(s)?s:null}return t.value}}Et.active=!1;class Nt{propertyName;dataSource;dataMember;formatString;converter;converterBack;setter;formatInfo;updateMode="onPropertyChanged";_isActive=!1;_component;_effectCleanup;_memberPath=null;_memberPathSource;constructor(t,e,s,i,n,o){this._component=t,this.propertyName=e,this.dataSource=s,this.dataMember=i,this.formatString=n,this.formatInfo=o,this._memberPath=i?i.split("."):null,this._memberPathSource=i}activate(){this._isActive||(this._isActive=!0,this._setupBinding())}deactivate(){this._isActive&&(this._isActive=!1,this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0))}reActivate(){this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0),this._setupBinding()}functional(t){return"function"==typeof t&&(t=this.functional(t())),t}_setupBinding(){const t=()=>{let t=this.dataSource;if(this.dataMember){this._memberPathSource!==this.dataMember&&(this._memberPath=this.dataMember.split("."),this._memberPathSource=this.dataMember);for(const e of this._memberPath)null!=t&&(t=t[e])}return t=this.functional(t),this.formatString&&null!=t&&(t=this._applyFormat(t,this.formatString)),this.converter&&(t=this.converter(t)),t},e=()=>{const e=t();return this._updateComponentProperty(e),e};this._effectCleanup=At(()=>e())}_updateComponentProperty(t){switch(this.propertyName.toLowerCase()){case"wait":{const e=this._component;if(!e||e.isDisposed)return;const s=!!t;e.isBuilt?e.isWait=!!s:e.isWait=s;break}case"display":{const e=this._component;if(!e||e.isDisposed)return;const s=t;e.isBuilt,e.isWait=!s;break}case"text":case"textcontent":this._component.setText(t);break;case"innerhtml":case"html":this._component.element.innerHTML=t,this._component.motif.trigger("htmlChanged",{value:t});break;case"visible":case"visibility":t?this._component.motif.show():this._component.motif.hide();break;case"style":"object"==typeof t&&this._component.style(t);break;case"model":{const e=this._component.element;if(!e)break;xt(e)?e.checked=!!t:e.value=null==t?"":t;break}case"when":break;default:this._component.element&&this.propertyName in this._component.element?this._component.element[this.propertyName]=t:this.propertyName in this._component&&(this._component[this.propertyName]=t)}}_applyFormat(t,e){const s=this.formatInfo?.locale,i=this.formatInfo?.currency;if("number"==typeof t){if(e.includes("C")||e.includes("c"))return i?new Intl.NumberFormat(s,{style:"currency",currency:i}).format(t):new Intl.NumberFormat(s,{minimumFractionDigits:2,maximumFractionDigits:2}).format(t);if(e.includes("P")||e.includes("p"))return new Intl.NumberFormat(s,{style:"percent"}).format(t);if(e.includes("N")||e.includes("n")){const i=parseInt(e.match(/\d+/)?.[0]||"2");return new Intl.NumberFormat(s,{minimumFractionDigits:i,maximumFractionDigits:i}).format(t)}}if(t instanceof Date){if(e.includes("d"))return t.toLocaleDateString(s);if(e.includes("t"))return t.toLocaleTimeString(s)}return t?.toString()||""}}const Pt=T.RAW;function Lt(t,e,s){let i=Object.getPrototypeOf(t);for(;i&&i!==e;){if(Object.prototype.hasOwnProperty.call(i,s))return!0;i=Object.getPrototypeOf(i)}return!1}function Xt(t,e){for(const s of e){let e=t[s];"function"==typeof e&&Object.defineProperty(t,s,{configurable:!0,enumerable:!1,get(){if(this===t||(i=this,Object.prototype.hasOwnProperty.call(i,"constructor")&&"function"==typeof i.constructor&&i.constructor.prototype===i))return e;var i;const n=this[Pt]??this,o=e.bind(n);if(!Lt(n,t,s))try{Object.defineProperty(n,s,{value:o,writable:!0,configurable:!0,enumerable:!0})}catch{}return o},set(i){this!==t||"function"!=typeof i?Object.defineProperty(this,s,{value:i,writable:!0,configurable:!0,enumerable:!0}):e=i}})}}function Rt(t){return"function"==typeof t?Rt(t()):t}function It(t,e){return"__proto__"!==e&&("constructor"!==e&&"prototype"!==e||Object.prototype.hasOwnProperty.call(t,e))}class Jt{_items=[];_component;_branchScope=null;constructor(t){this._component=t}_own(t){this._branchScope?this._branchScope.push(t):this._component.motif.register(G(()=>{try{t()}catch{}}))}when(t,e){var s=new bi;this._component.controls.add(s);let i,n=!1;const o=At(t,t=>{n&&(Object.is(i,t)||!i&&!t)||(n=!0,i=t,Tt(()=>{t?s.navigate(e(t)):s.navigate(ni())}))});return this._own(o),null}get items(){return[...this._items]}text(t){this.add("textContent",t)}value(t){this.add("value",t)}add(...t){let e;if(1===t.length&&"object"==typeof t[0]&&"propertyName"in t[0])e=t[0];else{const[s,i,n,o,r]=t;e=new Nt(this._component,s,i,n,o,r)}return this._items.push(e),this._component.isBuilt&&e.activate(),e}wait(t){const e=new Nt(this._component,"isWait",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}display(t){const e=new Nt(this._component,"isWait",()=>!Rt(t()));return this._items.push(e),this._component.isBuilt&&e.activate(),e}html(t){const e=new Nt(this._component,"innerHTML",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}list(t,e,s){const i=new $(this._component,t,e,s);return this._items.push(i),this._component.isBuilt&&i.activate(),i}loop(t,e,s){const i=new $(this._component,t,e,s);return this._items.push(i),this._component.isBuilt&&i.activate(),i}method(t){const e=this._component;let s=null,i=null;const n=(t,s)=>{s?(e.controls.insert(e.controls.items.indexOf(s),t),e.controls.remove(s)):e.controls.add(t)},o=At(t,t=>{if(e.isDisposed)return;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||s&&null==t)return s?void s.setText(t):(s=new Us(li.createTextNode(t)),n(s,i),void(i=null));i||(i=new bi,n(i,s),s=null),i.navigate(null==t?ni():t)});e.motif.register(G(()=>{try{o()}catch{}}))}ternary(t,e,s){const i=new bi;return this._component.controls.add(i),this._ternaryCallTop(t,()=>{e(i)},()=>{s(i)}),null}_ternarySchedule(t,e,s,i){let n,o=!0,r=!1,a=[];const c=()=>{const t=a;a=[];for(const e of t)try{e()}catch{}},l=At(t,t=>{if(!o&&Object.is(n,t))return;n=t;const l=()=>{c();const i=this._branchScope;this._branchScope=a;try{t?e():s()}finally{this._branchScope=i}};if(o)return o=!1,void Tt(l);i(()=>{r||this._component.isDisposed||l()})});this._own(()=>{r=!0,l(),c()})}ternaryCall(t,e,s){this._ternarySchedule(t,e,s,t=>queueMicrotask(t))}_ternaryCallTop(t,e,s){this._ternarySchedule(t,e,s,t=>setTimeout(t,0))}watch(t){const e=At(()=>{t()});this._component.motif.register(G(()=>{try{e()}catch{}}))}remove(t){const e=this._items.indexOf(t);e>-1&&(this._items.splice(e,1),t.deactivate())}clear(){this._items.forEach(t=>t.deactivate()),this._items=[]}activateAll(){this._items.forEach(t=>{t.activate()})}model(...t){var e="";this._component.element&&(e=this._component.element.tagName);var s="value";switch(e.toLowerCase()){case"input":s="model";break;case"select":case"textarea":s="value";break;case"img":case"audio":case"video":s="src"}let i;if(1===t.length&&"object"==typeof t[0])i=t[0];else if("function"==typeof t[0]&&"function"==typeof t[1])i=new Nt(this._component,s,t[0]),i.setter=t[1];else{const[e,n,o,r]=t;i=new Nt(this._component,s,e,n,o,r)}const n=e.toLowerCase();if("input"===n||"select"===n||"textarea"===n){const t=()=>{try{const t=this._component.element;if(!t)return;let e=Ot(t);const s=i;if("function"==typeof s.converterBack&&(e=s.converterBack(e)),"function"==typeof s.setter)return void s.setter(e);const n=s.dataMember,o=s.dataSource;if(n&&null!=o){const t=n.split(".");let s=o;for(let i=0;i<t.length&&null!=s;i++){const n=t[i];if(!It(s,n))return;i===t.length-1?s[n]=e:s=s[n]}}else null!=o&&"object"==typeof o&&"value"in o&&(o.value=e)}catch{}};this._component.motif.on("input",t),this._component.motif.on("change",t)}return this._items.push(i),this._component.isBuilt&&i.activate(),i}deactivateAll(){this._items.forEach(t=>t.deactivate()),this._items=[]}reActivateAll(){for(const t of[...this._items])if("function"==typeof t.reActivate)try{t.reActivate()}catch(t){M("MJX208",t)}}switchCase(t,e,s){const i=new bi;var n;this._component.controls.add(i);var o=!1;const r=At(t,t=>{if(n==t)return;n=t;const r=String(t);if(Object.prototype.hasOwnProperty.call(e,r))e[r](i),o=!1;else if(s){if(o)return;o=!0,s(i)}else{if(o)return;o=!0,i.navigate(ni())}});return this._component.motif.register(G(()=>{try{r()}catch{}})),null}}Xt(Jt.prototype,["add","remove","clear","activateAll","deactivateAll","reActivateAll","when","text","value","list","loop","method","watch","display","wait","ternaryCall","_ternaryCallTop"]);class Ht{_subscriptions=[];_delivery;_subscribe;_disposed=!1;get event(){return this._subscribe||(this._subscribe=(t,e,s)=>{if(this._disposed)return{dispose(){}};const i={handler:e?t.bind(e):t,active:!0};this._writable().push(i);const n={dispose:()=>this._unsubscribe(i)};return s instanceof D?s.add(n):Array.isArray(s)&&s.push(n),n}),this._subscribe}fire(t){this._resume(),0!==this._subscriptions.length&&(this._delivery={targets:this._subscriptions,value:t,next:0},this._resume())}dispose(){if(!this._disposed){this._disposed=!0;for(const t of this._subscriptions)t.active=!1;this._subscriptions=[],this._delivery=void 0}}_writable(){return this._delivery&&this._delivery.targets===this._subscriptions&&(this._subscriptions=this._subscriptions.slice()),this._subscriptions}_unsubscribe(t){if(!t.active)return;t.active=!1;const e=this._writable(),s=e.indexOf(t);-1!==s&&e.splice(s,1)}_resume(){const t=this._delivery;if(t){for(;t.next<t.targets.length;){const e=t.targets[t.next++];if(e.active)try{e.handler(t.value)}catch(t){s.onUnexpectedError(t)}}this._delivery===t&&(this._delivery=void 0)}}}class jt{component;_emitters;_sourceDisposables;_listenerDisposables;constructor(t){this.component=t}hasListeners(t){return void 0!==this._emitters&&this._emitters.has(t)}fire(t,e){try{const s=this._emitters?.get(t.toLowerCase());s&&s.fire(e)}catch{}}on(t,e){try{this.createEvent(t,e)}catch{}}off(t,e){const s=String(t).toLowerCase(),i=this._listenerDisposables?.get(s);if(!i)return this;const n=i.get(e);return i.delete(e),n?.forEach(t=>{try{t.dispose()}catch{}}),this}getOrCreateEmitter(t){const e=this._emitters??=new Map;let s=e.get(t);return s||(s=new Ht,e.set(t,s)),s}createEvent(t,e){const s=String(t).toLowerCase(),i=s.startsWith("on")?"x:"+s.slice(2):s,n=t=>{let s;return C(()=>(s=e.length<=1?e(t):e(this.component,t),s),"MJX122",i),s},o=this.getOrCreateEmitter(s).event(t=>n(t)),r=this._listenerDisposables??=new Map;let a=r.get(s);a||(a=new Map,r.set(s,a));const c=a.get(e);return c?c.push(o):a.set(e,[o]),this}addSource(t,e){const s=String(t).toLowerCase(),i=this.getOrCreateEmitter(s),n=t=>t(t=>i.fire(t));let o;try{o=n(e instanceof Ht?e.event:e)}catch{}if(o){const t=this._sourceDisposables??=new Map;let e=t.get(s);e||(e=new Set,t.set(s,e)),e.add(o),this.component.motif.register(k.toDisposable(()=>{try{o?.dispose()}catch{}try{e?.delete(o)}catch{}}))}return this}clear(t){if(t){const e=t.toLowerCase(),s=this._sourceDisposables?.get(e);s?.forEach(t=>{try{t.dispose()}catch{}}),this._sourceDisposables?.delete(e);const i=this._emitters?.get(e);try{i?.dispose()}catch{}this._emitters?.delete(e),this._listenerDisposables?.delete(e)}else if(this._emitters)for(const t of Array.from(this._emitters.keys()))this.clear(t);return this}}Xt(jt.prototype,["fire","on","off","createEvent","getOrCreateEmitter","addSource","clear"]);const Ft=new Set(["focus","blur","click","pause","submit","reset","scrollTo","scrollBy","select","scrollIntoView","requestFullscreen","exitFullscreen","requestPointerLock","exitPointerLock","play","requestPictureInPicture","exitPictureInPicture","show","showModal","close","showPopover","hidePopover","togglePopover","requestSubmit","checkValidity","reportValidity","showPicker","load","setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Bt={show:"close",showModal:"close",showPopover:"hidePopover"},zt=new Set(["close","hidePopover","requestSubmit","checkValidity","reportValidity","showPicker","load"]),Vt=new Set(["setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Wt=new Set(["checked","selected","muted","indeterminate","srcObject"]);class $t{_parent;_attrMapStore;_watchersStore;constructor(t){this._parent=t}get _attrMap(){return this._attrMapStore??=new Map}get _watchers(){return this._watchersStore??=new Map}get attributes(){return Array.from(this._attrMap.entries(),([t,e])=>({name:String(t),value:e}))}add(t){if(null!==t&&"object"==typeof t&&!Array.isArray(t)){const e=t;Reflect.ownKeys(e).forEach(t=>{this.parse(e[t],t)})}return this._parent}remove(t){const e=this._watchers.get(t);if(e){try{e.stop()}catch{}try{e.binding&&this._parent.bindings.remove(e.binding)}catch{}this._watchers.delete(t)}this._attrMap.delete(t);const s=this._getElement();if(s)try{s.removeAttribute(t)}catch{}return this._parent}has(t){return(this._parent.element instanceof HTMLElement||this._parent.element instanceof Element)&&this._parent.element.hasAttribute(t)}get(t){const e=this._getElement();if(e){const s=e.getAttribute(t);if(null!=s)return s}const s=this._attrMap.get(t);return null==s?null:String(s)}parse(t,e){if("function"==typeof t){const s=this._watchers.get(e);if(s){try{s.stop()}catch{}try{s.binding&&this._parent.bindings.remove(s.binding)}catch{}this._watchers.delete(e)}const i=()=>At(()=>{const s=t();this._applyValue(e,s)});let n=i();const o=()=>{try{n()}catch{}},r={propertyName:`__attr:${String(e)}`,dataSource:null,activate(){},deactivate(){o()},reActivate(){o(),n=i()}};try{this._parent.bindings.add(r)}catch{}this._watchers.set(e,{stop:o,binding:r})}else this._applyValue(e,t)}_applyValue(t,e){if(!t)return;const s=this._getElement();try{"function"==typeof e&&"function"==typeof(e=e())&&(e=e())}catch{}if(s&&"string"==typeof t&&Ft.has(t)){const i=t,n=s[i];if("function"==typeof n){const o=(t,e)=>{try{Array.isArray(e)?t.apply(s,e):void 0===e?t.call(s):t.call(s,e)}catch{}},r=t=>{try{queueMicrotask(t)}catch{try{setTimeout(t,0)}catch{}}},a=()=>{this._attrMap.set(t,e)};if("focus"===i){return r(()=>{if(!1===e){const t=s.blur;"function"==typeof t&&o(t)}else!0===e?o(n):("object"==typeof e&&null!=e&&!0!==e||Array.isArray(e),o(n,e))}),void a()}if("blur"===i||"click"===i||"pause"===i||"submit"===i||"reset"===i){return r(()=>{e&&o(n)}),void a()}if("scrollTo"===i||"scrollBy"===i){return r(()=>{(Array.isArray(e)||e&&"object"==typeof e)&&o(n,e)}),void a()}if("select"===i){return r(()=>{if(e)o(n);else{const t=s;if("function"==typeof t.setSelectionRange)try{t.setSelectionRange(0,0)}catch{}}}),void a()}if("scrollIntoView"===i){return r(()=>{!0===e||null==e?o(n):o(n,e)}),void a()}if("requestFullscreen"===i){return r(()=>{if(e)o(n);else try{const t=document;t&&t.fullscreenElement===s&&"function"==typeof t.exitFullscreen&&t.exitFullscreen()}catch{}}),void a()}if("exitFullscreen"===i){return r(()=>{if(e)try{const t=document;t&&"function"==typeof t.exitFullscreen&&t.exitFullscreen()}catch{}}),void a()}if("requestPointerLock"===i){return r(()=>{if(e)o(n);else try{const t=document;t&&"function"==typeof t.exitPointerLock&&t.exitPointerLock()}catch{}}),void a()}if("exitPointerLock"===i){return r(()=>{if(e)try{const t=document;t&&"function"==typeof t.exitPointerLock&&t.exitPointerLock()}catch{}}),void a()}if("play"===i){return r(()=>{if(e)try{const t=n.call(s);t&&"function"==typeof t.then&&t.catch(()=>{})}catch{}else{const t=s.pause;"function"==typeof t&&o(t)}}),void a()}if("requestPictureInPicture"===i){return r(()=>{if(e)try{const t=n.call(s);t&&"function"==typeof t.then&&t.catch(()=>{})}catch{}}),void a()}if("exitPictureInPicture"===i){return r(()=>{if(e)try{const t=document;if(t&&"function"==typeof t.exitPictureInPicture){const e=t.exitPictureInPicture();e&&"function"==typeof e.then&&e.catch(()=>{})}}catch{}}),void a()}if(i in Bt){return r(()=>{if(!1===e){const t=s[Bt[i]];"function"==typeof t&&o(t)}else e&&o(n)}),void a()}if("togglePopover"===i){return r(()=>{if("boolean"==typeof e)try{n.call(s,e)}catch{}else e&&o(n)}),void a()}if(zt.has(i)){return r(()=>{!0===e?o(n):e&&o(n,e)}),void a()}if(Vt.has(i)){return r(()=>{null!=e&&!1!==e&&o(n,e)}),void a()}return null==e||!1===e?void this._attrMap.delete(t):void a()}}if("string"==typeof t&&Wt.has(t)){const i=this._parent.element??s;if(i)try{"srcObject"===t?i.srcObject=e??null:i[t]=!!e}catch{}return void(null==e||!1===e?this._attrMap.delete(t):this._attrMap.set(t,e))}if("boolean"==typeof e&&"string"==typeof t&&(t.startsWith("aria-")||t.startsWith("data-"))){if(s)try{s.setAttribute(t,String(e))}catch{}return void this._attrMap.set(t,e)}const i="boolean"==typeof e;if(null==e||!1===e){if(s)try{s.removeAttribute(String(t))}catch{}this._attrMap.delete(t)}else{if("value"===t)try{const t=this._parent.element,s=String(e);t.value!==s&&(t.value=s)}catch{}else if("textContent"===t||"innerText"===t||"innerHTML"===t){if(Ms(e))return void this._parent.setText(e);try{this._parent.element[t]=e}catch{}}else if(s)try{i&&!0===e?s.setAttribute(String(t),""):s.setAttribute(String(t),e)}catch{}this._attrMap.set(t,e)}}_getElement(){const t=this._parent?.element;return t instanceof HTMLElement||t instanceof Element?t:null}hasMethodState(t){return!(!this._getElement()||!t)&&!!this.getMethodState(t)}getMethodState(t){const e=this._getElement();if(!e||!t)return!1;switch(String(t)){case"focus":case"blur":try{return(document&&document.activeElement)===e}catch{return!1}case"select":{const t=e;if("number"==typeof t.selectionStart&&"number"==typeof t.selectionEnd)try{return t.selectionEnd-t.selectionStart>0}catch{return!1}return!1}default:return!1}}}class Ut{_parent;constructor(t){this._parent=t}_countsStore;_staticSetStore;_watchersStore;_watcherSeq=0;get _counts(){return this._countsStore??=new Map}get _staticSet(){return this._staticSetStore??=new Set}get _watchers(){return this._watchersStore??=new Map}add(...t){for(const s of t)if("function"==typeof s)this._addReactive(s);else if(Array.isArray(s))this._addStaticFromArray(s);else if(s&&"object"==typeof s)this._addStaticFromObject(s);else{var e=String(s??"").trim();e.split(" ").length>1?this._addStaticFromArray(e.split(" ")):this._addStaticFromString(e)}return this._parent}remove(t){const e=this._getElement();if(Array.isArray(t)){const s=new Set(this._staticSet);for(const e of t)for(const t of this._splitClasses(String(e)))this._staticSet.delete(t);this._applySourceDiff("static",s,new Set(this._staticSet),e)}else if("**"===t){for(const[t,s]of Array.from(this._watchers.entries())){const i=new Set(s.set);this._applySourceDiff(t,i,new Set,e);try{s.binding&&this._parent.bindings.remove(s.binding)}catch{}try{s.stop()}catch{}this._watchers.delete(t)}const t=new Set(this._staticSet);if(this._staticSet.clear(),this._applySourceDiff("static",t,new Set,e),e)try{e.removeAttribute("class")}catch{}this._counts.clear()}else{const s=new Set(this._staticSet);for(const e of this._splitClasses(String(t)))this._staticSet.delete(e);this._applySourceDiff("static",s,new Set(this._staticSet),e)}return this._parent}has(t){const e=this._getElement(),s=String(t??"").trim();return!!s&&!(!e||!e.classList.contains(s))}_getElement(){const t=this._parent?.element;return t instanceof Element?t:null}_splitClasses(t){return(t||"").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}_normalizeToSet(t,e){const s=new Set;if(null==t)return s;if("string"==typeof t)for(const e of this._splitClasses(t))s.add(e);else if(Array.isArray(t)){for(const i of t)if(null!=i)if("string"==typeof i)for(const t of this._splitClasses(i))s.add(t);else if(Array.isArray(i))for(const t of this._normalizeToSet(i))s.add(t);else if("object"==typeof i){const t=i;for(const e of Object.keys(t)){if(t[e])for(const t of this._splitClasses(String(e)))s.add(t)}}else if("boolean"==typeof i){if(e&&i)for(const t of this._splitClasses(String(e)))s.add(t)}else for(const t of this._splitClasses(String(i)))s.add(t)}else if("object"==typeof t){const e=t;for(const t of Object.keys(e)){if(e[t])for(const e of this._splitClasses(String(t)))s.add(e)}}else if("boolean"==typeof t){if(e&&t)for(const t of this._splitClasses(String(e)))s.add(t)}else for(const e of this._splitClasses(String(t)))s.add(e);return s}_applySourceDiff(t,e,s,i){for(const t of e)if(!s.has(t)){const e=(this._counts.get(t)||0)-1;if(e<=0){if(this._counts.delete(t),i)try{i.classList.remove(t)}catch{}}else this._counts.set(t,e)}for(const t of s)if(!e.has(t)){const e=this._counts.get(t)||0,s=e+1;if(this._counts.set(t,s),0===e&&i)try{i.classList.add(t)}catch{}}}_addStaticFromString(t){if(!t)return;const e=this._getElement(),s=new Set(this._staticSet);for(const e of this._splitClasses(t))this._staticSet.add(e);this._applySourceDiff("static",s,new Set(this._staticSet),e)}_addStaticFromArray(t){const e=this._getElement(),s=new Set(this._staticSet);for(const e of t)if(null!=e)if("string"==typeof e)for(const t of this._splitClasses(e))this._staticSet.add(t);else if(Array.isArray(e)){const t=this._normalizeToSet(e);for(const e of t)this._staticSet.add(e)}else if("object"==typeof e){const t=e;for(const e of Object.keys(t)){const s=t[e];if("function"==typeof s){const s=this._splitClasses(String(e));for(const i of s)this._addReactive(t[e],i)}else{const t=this._splitClasses(String(e));if(s)for(const e of t)this._staticSet.add(e);else for(const e of t)this._staticSet.delete(e)}}}else{if("boolean"==typeof e)continue;if("function"==typeof e)this._addReactive(e);else for(const t of this._splitClasses(String(e)))this._staticSet.add(t)}this._applySourceDiff("static",s,new Set(this._staticSet),e)}_addStaticFromObject(t){const e=this._getElement(),s=new Set(this._staticSet);for(const e of Object.keys(t)){const s=t[e],i=this._splitClasses(String(e));if(s)for(const t of i)this._staticSet.add(t);else for(const t of i)this._staticSet.delete(t)}this._applySourceDiff("static",s,new Set(this._staticSet),e)}_addReactive(t,e){const s="fx#"+ ++this._watcherSeq,i={stop:()=>{},binding:void 0,set:new Set},n=this._getElement(),o=()=>At(()=>{let o;try{const s=t();o=this._normalizeToSet(s,e)}catch{o=new Set}const r=new Set(i.set);this._applySourceDiff(s,r,o,n),i.set=o});let r=o();const a=()=>{try{r()}catch{}},c={propertyName:`__class:${s}`,dataSource:null,activate(){},deactivate:()=>{a();const t=this._getElement(),e=new Set(i.set);this._applySourceDiff(s,e,new Set,t),i.set.clear()},reActivate:()=>{a(),r=o()}};try{this._parent.bindings.add(c)}catch{}i.stop=a,i.binding=c,this._watchers.set(s,i)}}const qt={cancel(){},addEventListener(){},removeEventListener(){},oncancel:null,playState:"finished"};function Gt(t){const e=t.substring(0,Math.max(0,t.length-1)).replace(",",".");return 1e3*Number(e)}function Kt(t,e){const s=s=>(t[`${e}-${s}`]||"").split(", "),i=s("delay"),n=s("duration");let o=-1/0;for(let t=0;t<n.length;t++){const e=Gt(n[t])+Gt(i[t%i.length]);o=Math.max(o,e)}return{kind:e,longest:o,tracks:n.length}}const Yt=/(?:^|\W)(?:transform|all)(?:,|$)/;function Qt(t,e){if(!t)return{type:"animation",timeout:0,propCount:0,hasTransform:!1};const s={transition:Kt(t,"transition"),animation:Kt(t,"animation")};let i,n;if("transition"===e||"animation"===e){const t=s[e];i=t.longest>0?t:null,n=i?i.longest:0}else{const{transition:t,animation:e}=s;n=Math.max(t.longest,e.longest),i=n>0?t.longest>e.longest?t:e:null}const o=i?i.kind:null;return{type:o,timeout:n,propCount:i?i.tracks:0,hasTransform:"transition"===o&&Yt.test(t.transitionProperty)}}function Zt(t,e,s){if(t.isConnected&&8!==t.nodeType)return Qt(li.window.getComputedStyle(t),s);const i=li.createElement("div");i.setAttribute("style","width:0!important;height:0!important;display:none"),li.body.appendChild(i),i.setAttribute("class",e);try{return Qt(li.window.getComputedStyle(i),s)}finally{i.remove()}}function te(t,e,s,i,n=!1){if(!1===e.css)return i(),()=>{};const o=function(t,e,s=!1){const i=t.name||"motif";if("enter"===e){const e={from:t.enterFromClass??`${i}-enter-from`,active:t.enterActiveClass??`${i}-enter-active`,to:t.enterToClass??`${i}-enter-to`};return s?{from:t.appearFromClass??e.from,active:t.appearActiveClass??e.active,to:t.appearToClass??e.to}:e}return{from:t.leaveFromClass??`${i}-leave-from`,active:t.leaveActiveClass??`${i}-leave-active`,to:t.leaveToClass??`${i}-leave-to`}}(e,s,n),r=e=>{e&&e.split(/\s+/).forEach(e=>{if(e)try{t.classList.add(e)}catch{}})},a=e=>{e&&e.split(/\s+/).forEach(e=>{if(e)try{t.classList.remove(e)}catch{}})};let c,l=!1,h=null,u=null;const d=()=>{if(!l){l=!0,(()=>{if(a(o.from),a(o.to),a(o.active),void 0!==c){try{clearTimeout(c)}catch{}c=void 0}if(h&&u){try{t.removeEventListener(h,u)}catch{}u=null}})();try{i()}catch{}}};r(o.from),r(o.active);try{t.offsetHeight}catch{}return(t=>{const e=globalThis.requestAnimationFrame;"function"==typeof e?e(()=>t()):setTimeout(t,16)})(()=>{if(l)return;a(o.from),r(o.to);let i=0,n=1;const p=e.duration;if("number"==typeof p)i=p,h="animation"===e.type?"animationend":"transitionend";else if(p&&"object"==typeof p)i=("enter"===s?p.enter:p.leave)??0,h="animation"===e.type?"animationend":"transitionend";else{const s=function(t,e){return Qt(li.window.getComputedStyle(t),e)}(t,e.type);i=s.timeout,n=s.propCount||1,h="animation"===s.type?"animationend":"transitionend"}if(!i||i<=0)return void d();let f=0;u=e=>{e&&e.target!==t||++f>=n&&d()};try{t.addEventListener(h,u)}catch{}c=setTimeout(d,i+60)}),d}class ee{_component;options;constructor(t,e){this._component=t,this.options=e}show(){return this._component._show()}hide(){return this._component._hide()}toggle(){this._component._toggle()}on(t,e,s=!0){return this._component._on(t,e,s)}off(t,e){return this._component._off(t,e)}trigger(t,e){return this._component._trigger(t,e)}addHandler(t,e){this._component._addHandler(t,e)}clear(){return this._component._clear()}register(t){this._component._register(t)}setDisposable(t){this._component._register(k.toDisposable(t))}stopAnimations(){return this._component._stopAnimations()}}const se=Symbol("SignalTarget"),ie=Symbol("SignalKey");class ne{_value;_target;_key;_equals;_disposed=!1;static create(t,e){return new ne(t,e)}constructor(t,e=Object.is){this._value=t,this._target={[se]:!0},this._key=ie,this._equals=e}get value(){return this._disposed||wt(this._target,this._key),this._value}set value(t){this._disposed||this._equals(this._value,t)||(this._value=t,bt(this._target,this._key))}peek(){return this._value}update(t){this.value=t(this._value)}mutate(t){this._disposed||(t(this._value),bt(this._target,this._key))}notify(){this._disposed||bt(this._target,this._key)}asReadonly(){const t=this;return{get value(){return t.value},peek:()=>t.peek(),valueOf:()=>t.valueOf(),toString:()=>t.toString()}}dispose(){this._disposed=!0}valueOf(){return this.value}toString(){return String(this.value)}}class oe{_value;_dirty=!0;_computing=!1;_target;_key;_getter;_cleanup;constructor(t){this._getter=t,this._target={[se]:!0},this._key=ie,this._cleanup=At(()=>{if(!this._computing){this._computing=!0;try{const t=this._getter(),e=this._dirty||!Object.is(this._value,t);this._value=t,this._dirty=!1,e&&bt(this._target,this._key)}finally{this._computing=!1}}})}get value(){if(wt(this._target,this._key),this._dirty){this._computing=!0,z();try{this._value=this._getter(),this._dirty=!1}finally{V(),this._computing=!1}}return this._value}peek(){if(this._dirty){z();try{this._value=this._getter(),this._dirty=!1}finally{V()}}return this._value}dispose(){this._cleanup&&(this._cleanup(),this._cleanup=void 0)}valueOf(){return this.value}toString(){return String(this.value)}}class re{_value;_dirty=!0;_disposed=!1;_target;_key;_getter;_runner;constructor(t){this._getter=t,this._target={[se]:!0},this._key=ie,this._runner=function(t,e){const s=new ht(t);return s.scheduler=e,{run:()=>{St(()=>s.run())},stop:()=>s.stop()}}(()=>{this._value=this._getter()},()=>{this._dirty||this._disposed||(this._dirty=!0,bt(this._target,this._key))})}get value(){return this._disposed||wt(this._target,this._key),this._refresh(),this._value}peek(){return this._refresh(),this._value}get isDirty(){return this._dirty}_refresh(){this._dirty&&(this._disposed?this._value=Tt(this._getter):this._runner.run(),this._dirty=!1)}dispose(){this._disposed||(this._disposed=!0,this._runner.stop())}valueOf(){return this.value}toString(){return String(this.value)}}let ae=null,ce=null,le=null,he=null,ue=null;const de=new WeakMap,pe=new WeakMap,fe=new WeakMap,me=new WeakMap,_e=new WeakMap;function ge(t,e){const s=ae;ae=t;try{return e()}finally{ae=s}}function ye(t,e,s){const i=ce,n=le;ce=t,le=e;try{return s()}finally{ce=i,le=n}}function ve(t){let e=t;for(;e;){const t=fe.get(e);if(t)return t.scope;const s=me.get(e);if(s&&s._pending)return s;e=e.parent}return null}function we(t){if(!ae)throw S("MJX409",function(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}(t));return ae(t)}function be(t){he&&he._pending&&me.set(t,he)}function Se(t){const e=ue;if(!e)return;if(fe.get(t)?.live)return;const s=ve(t)??e._currentScope();fe.set(t,{scope:s,live:!0}),s._livePins++}function Me(t){const e=fe.get(t);e?e.live&&(e.live=!1,e.scope._releaseLivePin()):ue&&de.has(t)&&fe.set(t,{scope:ve(t)??ue._currentScope(),live:!1})}class Ce{services;parent;root;scopeName;kind;singletonCache;scopedCache=new Map;transientSet=new Set;_autoDisposeTransients=!1;pendingSingleton;pendingScoped=new Map;_navigation;_ownerlessSlot={owner:null,ownerless:!0};_navigationDisposed=!1;_livePins=0;_pending=!1;constructor(t,e,s){this.services=t,this.parent=e,this.root=s??this,this.kind=this.root===this?"root":"user",this.singletonCache=this.root===this?new Map:this.root.singletonCache,this.pendingSingleton=this.root===this?new Map:this.root.pendingSingleton}createScope(t){const e=new Ce(this.services,this,this.root);return e.scopeName=t??this.scopeName,e._autoDisposeTransients=this._autoDisposeTransients,e}enableAutoDisposeTransients(t=!0){return this._autoDisposeTransients=t,this}get(t){const e=this.services.getDescriptor(t);if(!e)throw S("MJX401",this.describeToken(t));return this.resolveDescriptorSync(e,[t])}async getAsync(t){const e=this.services.getDescriptor(t);if(!e)throw S("MJX401",this.describeToken(t));return await this.resolveDescriptorAsync(e,[t])}_getFor(t,e){let s=de.get(t);return s||(s={owner:t},de.set(t,s)),ye(s,le,()=>this.get(e))}getAllServices(){return this.services}_beginNavigation(){const t=this.root,e=t._navigation??={current:t,version:new ne(0),scopes:new Set};ue=t;const s=new Ce(this.services,t,t);return s.kind="navigation",s.scopeName="navigation",s._pending=!0,s._autoDisposeTransients=t._autoDisposeTransients,e.scopes.add(s),s}_commitNavigation(t){const e=this.root._navigation;if(!e||e.current===t)return;t._pending=!1;const s=e.current;e.current=t,this._touch(),s!==this.root&&s._releaseIfUnused()}_abandonNavigation(t){t._pending=!1,t._releaseIfUnused()}_currentScope(){return this.root._navigation?.current??this.root}_touch(){const t=this.root._navigation;t&&(t.version.value=t.version.peek()+1)}_releaseLivePin(){this._livePins--,this._releaseIfUnused()}_releaseIfUnused(){const t=this.root._navigation;"navigation"!==this.kind||this._navigationDisposed||this._livePins>0||t&&t.current===this||(this._navigationDisposed=!0,t?.scopes.delete(this),this.dispose().catch(()=>{}))}_scopeFor(t){const e=this._navigation;if(e&&e.version.value,!t.ownerless){const e=ve(t.owner);if(e)return e;if(he&&he.root===this)return he}return e?e.current:this}_handle(t,e){const s=ce??this._ownerlessSlot;let i=pe.get(s);i||pe.set(s,i=new Map);let n=i.get(t.token);return n||(n=this._createHandle(t,s),i.set(t.token,n)),this._scopeFor(s)._scopedInstanceSync(t,e),n}async _handleAsync(t,e){const s=ce??this._ownerlessSlot;return await this._scopeFor(s)._scopedInstanceAsync(t,e),ye(s,null,()=>this._handle(t,e))}_createHandle(t,e){const s=this,i=()=>s._scopeFor(e)._scopedInstanceSync(t,[t.token]);return new Proxy(Object.create(null),{get(t,e){const s=i(),n=Reflect.get(s,e,s);return"function"==typeof n?function(t,e,s){let i=_e.get(t);i||_e.set(t,i=new Map);const n=i.get(e);if(n&&n.fn===s)return n.bound;const o=s.bind(t);return i.set(e,{fn:s,bound:o}),o}(s,e,n):n},set(t,e,s){const n=i();return Reflect.set(n,e,s,n)},has:(t,e)=>e in i(),getPrototypeOf:()=>Object.getPrototypeOf(i())})}_isSystemScope(){return"user"!==this.kind}_scopedInstanceSync(t,e){if(this.scopedCache.has(t.token))return this.scopedCache.get(t.token);const s=ye(null,this,()=>this.instantiateSync(t,e));return this.scopedCache.set(t.token,s),s}async _scopedInstanceAsync(t,e){if(this.scopedCache.has(t.token))return this.scopedCache.get(t.token);if(this.pendingScoped.has(t.token))return await this.pendingScoped.get(t.token);const s=(async()=>{const s=await this.instantiateAsyncIn(null,this,t,e);return this.scopedCache.set(t.token,s),this.pendingScoped.delete(t.token),s})();return this.pendingScoped.set(t.token,s),await s}resolveDescriptorSync(t,e){switch(this.checkCycle(t.token,e),t.lifetime){case"singleton":{if(this.singletonCache.has(t.token))return this.singletonCache.get(t.token);const s=ye(null,null,()=>this.instantiateSync(t,e));return this.singletonCache.set(t.token,s),s}case"scoped":return this._isSystemScope()&&le!==this?this.root._handle(t,e):this._scopedInstanceSync(t,e);default:{const s=this.instantiateSync(t,e);return this._autoDisposeTransients&&this.parent&&this.transientSet.add(s),s}}}async resolveDescriptorAsync(t,e){switch(this.checkCycle(t.token,e),t.lifetime){case"singleton":{if(this.singletonCache.has(t.token))return this.singletonCache.get(t.token);if(this.pendingSingleton.has(t.token))return await this.pendingSingleton.get(t.token);const s=(async()=>{const s=await this.instantiateAsyncIn(null,null,t,e);return this.singletonCache.set(t.token,s),this.pendingSingleton.delete(t.token),s})();return this.pendingSingleton.set(t.token,s),await s}case"scoped":return this._isSystemScope()&&le!==this?await this.root._handleAsync(t,e):await this._scopedInstanceAsync(t,e);default:{const s=await this.instantiateAsync(t,e);return this._autoDisposeTransients&&this.parent&&this.transientSet.add(s),s}}}construct(t){if(ce)return t();const e={owner:null},s=ye(e,le,t);return!s||"object"!=typeof s&&"function"!=typeof s||"function"==typeof s.then||(be(s),e.owner=s,de.has(s)||de.set(s,e)),s}instantiateSync(t,e){if(void 0!==t.useValue)return t.useValue;if(t.useFactory)return this.construct(()=>{const s=this.resolveDepsSync(t,e),i=ge(this.injectionResolver(e),()=>t.useFactory(...s,this));if(i&&"function"==typeof i.then){throw S("MJX402",this.describeTokenWithSource(t.token))}return i});if(t.useClass)return this.construct(()=>{const s=this.resolveDepsSync(t,e);return ge(this.injectionResolver(e),()=>new t.useClass(...s))});throw S("MJX403")}async instantiateAsyncIn(t,e,s,i){return await ye(t,e,()=>this.instantiateAsync(s,i))}async instantiateAsync(t,e){if(void 0!==t.useValue)return t.useValue;const s=ce,i=le;if(t.useFactory){const n=await this.resolveDepsAsyncIn(s,i,t,e);return await ye(s,i,()=>this.construct(()=>ge(this.injectionResolver(e),()=>t.useFactory(...n,this))))}if(t.useClass){const n=await this.resolveDepsAsyncIn(s,i,t,e);return ye(s,i,()=>this.construct(()=>ge(this.injectionResolver(e),()=>new t.useClass(...n))))}throw S("MJX403")}async dispose(){const t=new Set,e=async e=>{if(e&&!t.has(e)){t.add(e);try{"function"==typeof e.dispose&&await e.dispose()}catch{}try{"function"==typeof e.close&&await e.close()}catch{}try{const t=e[Symbol.dispose];"function"==typeof t&&await t.call(e)}catch{}try{const t=e[Symbol.asyncDispose];"function"==typeof t&&await t.call(e)}catch{}}};if(this.root===this){const t=this._navigation;if(t){const e=[...t.scopes];t.scopes.clear(),t.current=this,ue===this&&(ue=null),this._navigation=void 0;for(const t of e)t._navigationDisposed=!0,await t.dispose()}for(const t of this.singletonCache.values())await e(t);this.singletonCache.clear(),this.pendingSingleton.clear()}for(const t of this.scopedCache.values())await e(t);"navigation"!==this.kind&&this.scopedCache.clear(),this.pendingScoped.clear();for(const t of this.transientSet.values())await e(t);this.transientSet.clear()}resolveDepsSync(t,e){const s=this.getDeps(t);return s&&0!==s.length?s.map(t=>this.resolveTokenSync(t,e)):[]}async resolveDepsAsyncIn(t,e,s,i){const n=this.getDeps(s);if(!n||0===n.length)return[];const o=[];for(const s of n)o.push(await ye(t,e,()=>this.resolveTokenAsync(s,i)));return o}injectionResolver(t){return e=>this.resolveTokenSync(e,t)}getDeps(t){if(Array.isArray(t.deps))return t.deps;const e=t.useClass??t.useFactory;if(e){if(Array.isArray(e.inject))return e.inject;if(Array.isArray(e.dependencies))return e.dependencies}}resolveTokenSync(t,e){const s=this.services.getDescriptor(t);if(!s)throw S("MJX401",this.describeToken(t));const i=e.concat(t);return this.resolveDescriptorSync(s,i)}async resolveTokenAsync(t,e){const s=this.services.getDescriptor(t);if(!s)throw S("MJX401",this.describeToken(t));const i=e.concat(t);return await this.resolveDescriptorAsync(s,i)}checkCycle(t,e){const s=e.indexOf(t);if(-1!==s&&s!==e.length-1){throw S("MJX404",e.slice(s).concat([t]).map(t=>this.describeTokenWithSource(t)).join(" -> "))}}describeToken=t=>"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t);describeTokenWithSource(t){const e=this.describeToken(t),s=this.services.getDescriptor(t);if(!s)return e;return`${e}[${s.useClass?"useClass":s.useFactory?"useFactory":void 0!==s.useValue?"useValue":"unknown"}]`}}const Ae={live:0},ke=Symbol("motif.optionsOwner"),De=Symbol("motif.transition"),Ee={mode:"concurrent"},Te=()=>{};function xe(){const t=new WeakMap;return{track:function(e,s,i){const n=e?.parentNode??i?.parentNode;if(!n)return{done:s,release:Te};let o=t.get(n);o||t.set(n,o=new Set);let r=Te;const a={node:e,via:i??null,done:new Promise(t=>{r=t})};o.add(a);let c=!1;const l=()=>{c||(c=!0,o.delete(a),r())};return{done:()=>{const t=!c;l(),t&&s&&s()},release:l,finished:a.done}},pending:function(e,s){if(!e)return null;const i=t.get(e);if(!i||0===i.size)return null;let n=null;for(const t of i)t.node!==s&&(t.node.parentNode===e||t.via?.parentNode===e?(n??=[]).push(t.done):i.delete(t));return n?Promise.all(n).then(Te):null}}}const Oe=xe(),Ne=xe(),Pe=Oe.track,Le=Oe.pending,Xe=Ne.track,Re=Ne.pending;function Ie(t){return"concurrent"===t||"out-in"===t||"in-out"===t}function Je(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function He(t){return t?.motif?.options?.[De]}function je(t){const e=He(t);if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function Fe(t){let e=t;for(;e;){const t=He(e)?.mode;if(t)return t;const s=e.element;if(!s||s.nodeType!==Node.COMMENT_NODE)break;e=e.parent??e._base?._leaveContainer}return Ee.mode}function Be(t){const e=t?.motif?.options,s=e?.[De];return!!(e?.transitionIn||s&&(s.classes||s.name&&s.name.length>0))}function ze(t){const e=()=>t.motif.options?.[De]??s,s={transitionInfo:()=>{const s=e();return{in:Zt(t.element,`${s.name}-enter ${s.name}-enter-start`),out:Zt(t.element,`${s.name}-leave ${s.name}-leave-start`)}},name:"",mode:void 0,classes:void 0,activeCssCancel:null,activeCssPhase:null,cssProps:()=>{const t=e();return t.classes?{name:t.classes.name||t.name||"",...t.classes}:t.name&&t.name.length>0?{name:t.name}:null},skipNextLeave:!1,_suppressEnter:!1,_markedDirection:!1,in:e=>{t.motif.options.transitionIn=e},out:e=>{t.motif.options.transitionOut=e},enterTransition:s=>{const i=e(),n=t._base,o=!n._enterPlayed;if(n._enterPlayed=!0,n._enterSeq=(n._enterSeq??0)+1,i._suppressEnter)return s&&s(),qt;const r={};n._enterRun=r;const a=Xe(t.element,()=>{t._base?._enterRun===r&&(t._base._enterRun=null,je(t)),s&&s()},t.motif.options.placeholder),c=t.motif.options.transitionIn,l=c?i.run(c.keyframes,c.options,a.done):i._runCss("enter",a.done,o);return l&&l!==qt&&"function"==typeof l.addEventListener&&l.addEventListener("cancel",a.release),l},leaveTransition:s=>{const i=e(),n=t.element,o=Pe(n,s),r=()=>{const e=t.motif.options?.transitionOut,s=e?i.run(e.keyframes,e.options,o.done):i._runCss("leave",o.done);return s&&s!==qt&&"function"==typeof s.addEventListener&&s.addEventListener("cancel",o.release),s};return o.finished&&"in-out"===Fe((a=t).parent??a._base?._leaveContainer)?function(t,e,s){const i=t.parentNode,n={finished:e.finished??Promise.resolve(),playState:"pending",addEventListener:Te,removeEventListener:Te,cancel:Te};return queueMicrotask(()=>{const e=Re(i,t);e?e.then(()=>{s()}):s()}),n}(n,o,r):r();var a},_runCss:(s,i,n=!1)=>{const o=e();if("enter"===s&&"leave"===o.activeCssPhase)return i&&i(),qt;const r=o.cssProps(),a=t.element;if(r&&a&&1===a.nodeType&&a.classList){try{o.activeCssCancel?.()}catch{}const t=te(a,r,s,()=>{o.activeCssCancel=null,o.activeCssPhase=null,i&&i()},n);return o.activeCssCancel=t,o.activeCssPhase=s,qt}return i&&i(),qt},activeAnimations:[],run:(s,i,n)=>{const o=e();t.motif.stopAnimations();const r=t.element;if(r.animate){var a=r.animate(s,i);o.activeAnimations.push(a);let t=!1;const e=()=>{if(!t){t=!0;try{o.activeAnimations&&(o.activeAnimations=o.activeAnimations.filter(t=>t!==a))}catch{}}};return a.addEventListener("finish",()=>{n&&n(),e()}),a.oncancel=()=>{e()},a}{n&&n();const t=globalThis;if("function"==typeof t.Animation)try{return new t.Animation}catch{}return qt}}};return s}class Ve{[ke];[De];constructor(t){this[ke]=t}get transition(){return this[De]??=ze(this[ke])}set transition(t){this[De]=t}set enableRouterClassing(t){try{const e=this[ke],s=e.context.onRouterChanged(()=>{Ye.routerClassing.call(e,t)});e.motif.register(k.toDisposable(()=>{s()})),Ye.routerClassing.call(e,t)}catch(t){M("MJX105",t)}}getInstance(){return this[ke]}get display(){return this[ke].isVisible}set display(t){t?this[ke].motif.show():this[ke].motif.hide()}hasEvent(t){return!!this[ke]._eventHandlers?.has(t)}}function We(t,e,s){const i=t._base;i&&i.emiters.fire(e,s)}function $e(t,e,s,i,n){if(t[e])return!0;const o=t._base[s];return!!(Array.isArray(o)&&o.length>0)||(!(!n||!t[n])||t._base.emiters.hasListeners(i))}Xt(Ve.prototype,["getInstance","hasEvent"]);const Ue=["build","setState","reState","setText","style","dispose","disposeAsync","using","doWork","getService","$","useModel","context","siblings","serviceProvider","isWait"],qe=new WeakSet;function Ge(t,e){if("function"!=typeof t)return!1;const s=e.replace(/\$/g,"\\$");return new RegExp(`\\bsuper\\s*(\\.\\s*${s}(?![\\w$])|\\[)`).test(Function.prototype.toString.call(t))}function Ke(t){if(!c())return;const e=t?.constructor;if("function"!=typeof e||qe.has(e))return;qe.add(e);const s=e.name||"An anonymous component class";for(const[e,i]of function(t){const e=[],s=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);for(const i of Ue)if(s(t,i))e.push([i,"field"]);else for(let s=Object.getPrototypeOf(t);s&&s!==us.prototype;s=Object.getPrototypeOf(s)){const t=Object.getOwnPropertyDescriptor(s,i);if(t){("value"in t?[t.value]:[t.get,t.set].filter(Boolean)).some(t=>Ge(t,i))||e.push([i,"method"]);break}}const i=t;return i.motif instanceof ee||e.push(["motif","replaced"]),i.controls instanceof pi||e.push(["controls","replaced"]),i.class instanceof Ut||e.push(["class","replaced"]),i.attr instanceof $t||e.push(["attr","replaced"]),i.bindings instanceof Jt||e.push(["bindings","replaced"]),null==i.element||"undefined"==typeof Node||i.element instanceof Node||e.push(["element","replaced"]),null==i.parent||i.parent instanceof us||e.push(["parent","replaced"]),e}(t))A("MJX128",[s,e,i])}const Ye={callInitializeComponent(t){const e=t,s={cancel:!1};if(t&&!t.isDisposed){if("function"==typeof t.initializeComponent&&C(()=>t.initializeComponent(e,s),"MJX122","initializeComponent"),Array.isArray(t._base._initializeComponentHandlers)&&t._base._initializeComponentHandlers.length)for(const i of t._base._initializeComponentHandlers)C(()=>i(e,s),"MJX122","initializeComponent");if("function"==typeof t.oninitializeComponent&&C(()=>t.oninitializeComponent(e,s),"MJX122","oninitializeComponent"),Array.isArray(t._base._onInitializeComponentHandlers)&&t._base._onInitializeComponentHandlers.length)for(const i of t._base._onInitializeComponentHandlers)C(()=>i(e,s),"MJX122","oninitializeComponent")}},callDisposing(t){if(!t||t.isDisposed)return;if(!$e(t,"onDisposing","_onDisposingHandlers","ondisposing","ondisposing"))return;const e=t,s={cancel:!1};if(t.onDisposing&&C(()=>t.onDisposing(e,s),"MJX122","onDisposing"),Array.isArray(t._base._onDisposingHandlers))for(const i of t._base._onDisposingHandlers)C(()=>i(e,s),"MJX122","onDisposing");t.ondisposing&&C(()=>t.ondisposing(e,s),"MJX122","ondisposing"),We(t,"ondisposing",s)},callActivated(t){if(!t||t.isDisposed)return;const e=t,s={cancel:!1};if(t.onActivated&&C(()=>t.onActivated(e,s),"MJX122","onActivated"),Array.isArray(t._base._onActivatedHandlers))for(const i of t._base._onActivatedHandlers)C(()=>i(e,s),"MJX122","onActivated");We(t,"onactivated",s)},callDeactivated(t){if(!t||t.isDisposed)return;const e=t,s={cancel:!1};if(t.onDeactivated&&C(()=>t.onDeactivated(e,s),"MJX122","onDeactivated"),Array.isArray(t._base._onDeactivatedHandlers))for(const i of t._base._onDeactivatedHandlers)C(()=>i(e,s),"MJX122","onDeactivated");We(t,"ondeactivated",s)},deactivateTree(t,e=!0){if(t&&!t.isDisposed&&t.isBuilt&&t._base&&!t._base._inactive&&(t._base._inactive=!0,Ye.callDeactivated(t),e&&!t.isDisposed))for(const e of t.controls.items.slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&Ye.deactivateTree(e,!0)},activateTree(t,e=!0){if(t&&!t.isDisposed&&t._base&&t._base._inactive&&(t._base._inactive=!1,Ye.callActivated(t),e&&!t.isDisposed))for(const e of t.controls.items.slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&Ye.activateTree(e,!0)},callDisposed(t){if(t&&t._base&&!t._base._disposedFired){if(t._base._disposedFired=!0,$e(t,"onDisposed","_onDisposedHandlers","ondisposed","ondisposed")){const e=t,s={cancel:!1};if(t.onDisposed&&C(()=>t.onDisposed(e,s),"MJX122","onDisposed"),Array.isArray(t._base._onDisposedHandlers))for(const i of t._base._onDisposedHandlers)C(()=>i(e,s),"MJX122","onDisposed");t.ondisposed&&C(()=>t.ondisposed(e,s),"MJX122","ondisposed"),We(t,"ondisposed",s)}try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:disposed",{id:t.id,type:t.constructor?.name})}catch{}}},callBuilt(t){if(t&&!t.isDisposed){if($e(t,"onBuilt","_onBuiltHandlers","onbuilt","onbuilt")){const e=t,s={cancel:!1};if(t.onBuilt&&C(()=>t.onBuilt(e,s),"MJX122","onBuilt"),Array.isArray(t._base._onBuiltHandlers))for(const i of t._base._onBuiltHandlers)C(()=>i(e,s),"MJX122","onBuilt");t.onbuilt&&C(()=>t.onbuilt(e,s),"MJX122","onbuilt"),We(t,"onbuilt",s)}try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:mounted",{id:t.id,type:t.constructor?.name})}catch{}}},scheduleMounted(t){if(!t||t.isDisposed||t._base._mountedScheduled)return;if(!("function"==typeof t.onMounted||Array.isArray(t._base._onMountedHandlers)&&t._base._onMountedHandlers.length>0||"function"==typeof t.onmounted))return;t._base._mountedScheduled=!0;const e=t.element;if(!e||"number"!=typeof e.nodeType)return;const s=Fs(e,()=>{t.isDisposed||Ye.callMounted(t)});s&&t._register(k.toDisposable(s))},callMounted(t){if(!t||t.isDisposed||t._base._mountedFired)return;t._base._mountedFired=!0;const e=t,s={cancel:!1};if(t.onMounted&&C(()=>t.onMounted(e,s),"MJX122","onMounted"),Array.isArray(t._base._onMountedHandlers))for(const i of t._base._onMountedHandlers)C(()=>i(e,s),"MJX122","onMounted");t.onmounted&&C(()=>t.onmounted(e,s),"MJX122","onmounted"),We(t,"onmounted",s)},callBuilding(t){if(!t||t.isDisposed)return;if(!$e(t,"onBuilding","_onBuildingHandlers","onbuilding"))return;const e=t,s={cancel:!1};if(t.onBuilding&&C(()=>t.onBuilding(e,s),"MJX122","onBuilding"),Array.isArray(t._base._onBuildingHandlers))for(const i of t._base._onBuildingHandlers)C(()=>i(e,s),"MJX122","onBuilding");We(t,"onbuilding",s)},callConfig(t){if(!t||t.isDisposed||t.isConfigured)return;if(t.isConfigured=!0,t.motif.options._preconfig&&o(()=>t.motif.options._preconfig(t),"Component._preconfig"),!$e(t,"onConfig","_onConfigHandlers","onconfig"))return;const e=t,s={cancel:!1};if(t.onConfig&&C(()=>t.onConfig(e,s),"MJX122","onConfig"),Array.isArray(t._base._onConfigHandlers))for(const i of t._base._onConfigHandlers)C(()=>i(e,s),"MJX122","onConfig");We(t,"onconfig",s)},callConfigured(t){if(t.motif.options&&t.motif.options._postconfigdone)return;if(t?._base?._configDeferred&&!t.isConfigured&&Ye.callConfig(t),t.motif.options._postconfigdone=!0,!t||t.isDisposed)return;if(!$e(t,"onConfigured","_onConfiguredHandlers","onconfigured"))return;const e=t,s={cancel:!1};if(t.onConfigured&&C(()=>t.onConfigured(e,s),"MJX122","onConfigured"),Array.isArray(t._base._onConfiguredHandlers))for(const i of t._base._onConfiguredHandlers)C(()=>i(e,s),"MJX122","onConfigured");We(t,"onconfigured",s)},callOnInitialized(t){if(!t||t.isDisposed)return;if(t.isInitialized=!0,!$e(t,"onInitialized","_onInitializedHandlers","oninitialized"))return;const e=t,s={cancel:!1};if(t.onInitialized&&C(()=>t.onInitialized(e,s),"MJX122","onInitialized"),Array.isArray(t._base._onInitializedHandlers))for(const i of t._base._onInitializedHandlers)C(()=>i(e,s),"MJX122","onInitialized");We(t,"oninitialized",s)},callOnInitializing(t){if(!t||t.isDisposed)return;if(!$e(t,"onInitializing","_onInitializingHandlers","oninitializing"))return;const e=t,s={cancel:!1};if(t.onInitializing&&C(()=>t.onInitializing(e,s),"MJX122","onInitializing"),Array.isArray(t._base._onInitializingHandlers))for(const i of t._base._onInitializingHandlers)C(()=>i(e,s),"MJX122","onInitializing");We(t,"oninitializing",s)},callVisibilityChanged(t){if(!t||t.isDisposed)return;if(!$e(t,"onVisibilityChanged","_onVisibilityChangedHandlers","onvisibilitychanged"))return;const e=t,s={cancel:!1};if(t.onVisibilityChanged&&C(()=>t.onVisibilityChanged(e,s),"MJX122","onVisibilityChanged"),Array.isArray(t._base._onVisibilityChangedHandlers))for(const i of t._base._onVisibilityChangedHandlers)C(()=>i(e,s),"MJX122","onVisibilityChanged");We(t,"onvisibilitychanged",s)},findFragmentContent(t){const e=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;t.element.nodeType==Node.COMMENT_NODE&&0==e?.childNodes.length&&t.controls.length>0&&(t.motif.options.cache?.appendChild(t.element),t.controls.forEach(e=>{t.motif.options.cache?.appendChild(e.element)}),t.motif.options.cache?.appendChild(t.motif.options.closeFragment))},backgroundCallback(t){t()},internalBuild(t){if(this.isDisposed||t?.isDisposed)return;if(Ye.callConfigured(t),t.isDisposed)return;if(t._base._activatePreBindings(),t.isWait)return;const e=t.isBuilt;if(!this.isBuilt)return;if(t.isWait)return;const s=t._base._enterSeq;if(t.isBuilt){if(t.parent!=this){t.parent?.controls.detach(t),t.parent=this;const e=t.__pendingLeave;if(e)return void e.promise.then(()=>{this.isDisposed||t.isDisposed||t.parent!==this||Ye.internalBuild.call(this,t)})}}else t.build();if(t.isDisposed||this.isDisposed)return;t.parent=this;const i=this.controls.items,n=i.length>0&&i[i.length-1]===t?i.length-1:i.indexOf(t),o=js(this);var r=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;e&&t.element.nodeType==Node.COMMENT_NODE&&0==r?.childNodes.length&&t.controls.length>0&&(r=Ye.getContent.call(t));let a=null;const c=o?.element,l=t=>{if(!t||!t.isBuilt)return null;const e=t.isVisible?t.element:t.motif.options?.placeholder??null;return e&&c&&e.parentNode===c?e:null},h=this.controls.items;for(let t=n+1;t<h.length;t++){const e=l(h[t]);if(e){a=e;break}}if(!a)if(this.element.nodeType===Node.COMMENT_NODE){const t=this.motif.options.closeFragment;a=t&&c&&t.parentNode===c?t:null}else a=null;if(!t.isVisible){const e=t.motif.options?.hideStrategy??"auto",s=!(!t.motif.options?.__fromList&&void 0===t.motif.options?.indexkey&&void 0===t.motif.options?.__key);if("placeholder"!==("placeholder"===e?"placeholder":"detach"===e||s?"detach":"placeholder"))return;t.motif.options.placeholder||(t.motif.options.placeholder=li.createComment("h")),r=t.motif.options.placeholder}if(c&&"out-in"===Fe(this)){const e=Le(c,r);if(e)return t._base._enterSeq=(t._base._enterSeq??0)+1,void e.then(()=>{this.isDisposed||t.isDisposed||t.parent!==this||Ye.internalBuild.call(this,t)})}const u=o?.element;if(r&&u&&(r===u||r.contains(u)))A("MJX104",[]);else if(a)try{o?.element.insertBefore(r,a)}catch{o?.element.appendChild(r)}else o?.element.appendChild(r);if(t.isVisible){!(!e&&t._base._enterSeq!==s)&&Be(t)&&t.motif.options.transition.enterTransition(()=>{}),e&&Ye.activateTree(t)}},getContent(){return this.isDisposed||!this.element?null:this.element.nodeType==Node.COMMENT_NODE?(this.motif.options.cache?.appendChild(this.element),this.controls.forEach(t=>{this.motif.options.cache?.appendChild(Ye.getContent.call(t))}),this.motif.options.cache?.appendChild(this.motif.options.closeFragment),this.motif.options.cache):this.element},routerClassing(t){try{const e=t.to,s=t.path;if(this.isDisposed)return;const i=this.context?.router;if(!i)return;const n=i.uri.startsWith("/")?i.uri:"/"+i.uri,o=s??"",r=function(t,e){try{const s=t=>t.trim().split(/[?#]/)[0].replace(/\\/g,"/").replace(/\/{2,}/g,"/");return s(t)===s(e)}catch(t){return M("MJX610",t),!1}}(n,o),a=r||function(t,e){const s=K(t),i=K(e);return s===i||s.startsWith(i+"/")}(n,o);if(t.activeClass&&("all"===e||"active"===e)){t.activeClass.split(" ").filter(t=>t.trim().length).forEach(t=>this.element.classList.toggle(t,a))}if(!a||"all"!==e&&"active"!==e?"all"!==e&&"active"!==e||t.offActive?.():t.onActive?.(),t.exactClass&&("all"===e||"exact"===e)){t.exactClass.split(" ").filter(t=>t.trim().length).forEach(t=>this.element.classList.toggle(t,r))}!r||"all"!==e&&"exact"!==e?"all"!==e&&"exact"!==e||t.offExact?.():t.onExact?.()}catch(t){}}};function Qe(t,e,s){const i=t.motif?.options,n=e.parentNode;if(e.nodeType===Node.COMMENT_NODE){if(!n)return;const t=i?.closeFragment||null;if(t){let s=e;for(;s;){const e=s.nextSibling;try{n.removeChild(s)}catch{}if(s===t)break;s=e}}else try{n.removeChild(e)}catch{}if(!s)return}else if(n){try{n.removeChild(e)}catch{}if(!s)return}const o=i?.placeholder;if(o&&o.parentNode)try{o.parentNode.removeChild(o)}catch{}}function Ze(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const s=t.motif.options,i=s?.[De];try{if(!0===i?.skipNextLeave||!0===t._forceInstantDetach)return i&&(i.skipNextLeave=!1),t._forceInstantDetach=!1,void Qe(t,e,!0)}catch{}if(i||s?.transitionOut)try{s.transition.leaveTransition(()=>{Qe(t,e,!1)})}catch{Qe(t,e,!1)}else Qe(t,e,!1)}const ts=Promise.resolve();function es(t,e){if(!e&&t._disposing&&!t.isDisposed)return!1;if(t.disposeAsync!==us.prototype.disposeAsync)return!1;const s=t.motif?.options;if(s){if(s.transitionOut)return!1;const t=s[De];if(t){if(t.activeAnimations&&t.activeAnimations.length>0)return!1;if(t.activeCssCancel)return!1;if(t.classes||t.name&&t.name.length>0)return!1}}const i=t.controls?.items;if(i)for(let t=0;t<i.length;t++){const e=i[t];if(e&&!e.isDisposed&&!es(e,!1))return!1}return!0}const ss=new WeakMap;function is(t,e,s){const n=s?"disposeAsync":"dispose";if(Qn._disposingCount>0){const e=function(t){for(let e=t;e;e=e.parent){if(e.application)return e.application;const t=ss.get(e);if(t)return t}return Qn.main??null}(t);e&&"disposing"===e.state&&ss.set(t,e)}!s&&e?.skipLeaveTransition&&(t.motif.options.transition.skipNextLeave=!0),i(()=>{Ye.callDisposing.call(t,t)},n+".callDisposing"),t._base._offAll(),t._base._deactivateBindings(),i(()=>{t.parent?.controls?.silentDetach?.(t,!0)},n+".silentDetach")}function ns(t,e,s){if(t.isDisposed=!0,E.prototype.dispose.call(t),s)return t.controls.items=[],i(()=>{Ye.callDisposed.call(t,t)},"disposeAsync.callDisposed"),i(()=>{t._base.emiters.clear()},"disposeAsync.emiters"),void(e?.deep&&t._base._deepCleanup());t.element=null,i(()=>{Ye.callDisposed.call(t,t)},"dispose.callDisposed"),i(()=>{t._base.emiters.clear()},"dispose.emiters"),t._base._offAll(),t._base._deepCleanup()}async function os(t,e,s,i){i?await i:((s||He(t)?.skipNextLeave)&&await t.motif.stopAnimations(),await t._base._detachDomWithAnimationAsync()),s||"TransportTo"===t.constructor.name||await async function(t){if(0===Ae.live)return;const e=ds(t);return await Promise.all(e.map(async e=>{e.motif.options.transition.skipNextLeave=t.motif.options.transition.skipNextLeave;for(const t of e.controls.items)t.motif.options.transition.skipNextLeave=e.motif.options.transition.skipNextLeave,t.dispose({skipLeaveTransition:!0}),t.isDisposed=!0;await e.dispose()}))}(t);const o={deep:e?.deep};await n(async()=>{if(t.isDisposed)return;const e=Array.from(t.controls.items);e.length&&await Promise.all(e.map(t=>s?n(async()=>{await t.disposeAsync(o)},"disposeAsync.disposeAsyncChildren.handler"):(async()=>{try{await t.disposeAsync(o)}catch(t){M("MJX107",t)}})()))},s?"disposeAsync.disposeAsyncChildren":"dispose.disposeAsync"),!s&&t.isDisposed||ns(t,e,s)}const rs={_offAll(){const t=this.owner;if(t._eventHandlers){for(const[e,s]of t._eventHandlers){const i=e.split(":")[0],n=i.startsWith("on")?i.slice(2).toLowerCase():i.toLowerCase();for(const e of s){if(!e||!e.wrapped)continue;if(!1===e.domEvent)continue;const s=!0===e.capture;try{t.element.removeEventListener(n,e.wrapped,s)}catch{}try{void 0===e.capture&&t.element.removeEventListener(n,e.wrapped,!s)}catch{}}}t._eventHandlers.clear(),t._eventHandlers=void 0}},_deactivateBindings(){const t=this.owner;try{t.bindings?.deactivateAll()}catch{}},_activateBindings(){const t=this.owner;try{t.bindings?.activateAll()}catch{}},_reactivateBindings(){const t=this.owner;try{t.bindings?.reActivateAll()}catch{}},_activatePreBindings(){if(this.prebinding_Activated)return;const t=this.owner,e=t.bindings?._items;e&&e.length>0&&t.bindings.items.filter(t=>"isWait"==t.propertyName||"display"==t.propertyName).forEach(t=>{t.activate()}),this.prebinding_Activated=!0},_detachDomWithAnimation(){Ze(this.owner)},_detachDomWithAnimationAsync(){return async function(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const s=t.motif.options,i=s?.[De];try{if(!0===i?.skipNextLeave||!0===t._forceInstantDetach)return i&&(i.skipNextLeave=!1),t._forceInstantDetach=!1,void Qe(t,e,!0)}catch{}if(i||s?.transitionOut)return new Promise(i=>{try{s.transition.leaveTransition(()=>{Qe(t,e,!1),i()})}catch{Qe(t,e,!1),i()}});Qe(t,e,!1)}(this.owner)},_disposeShallow(){!function(t){if(!t.isDisposed){Ye.callDisposing.call(t,t);try{t._base._offAll()}catch{}if(t.motif.stopAnimations(),t._base._deactivateBindings(),t.controls?.items?.length)for(const e of t.controls.items)try{e._base._disposeShallow()}catch{}Ye.callDisposed.call(t,t),i(()=>{t._base.emiters.clear()},"disposeShallow.emiters"),t.isDisposed=!0,E.prototype.dispose.call(t)}}(this.owner)},_deepCleanup(){!function(t){try{t.parent=null}catch{}try{t._eventHandlers?.clear()}catch{}t._eventHandlers=void 0;try{t.class?._countsStore?.clear()}catch{}try{t.class?._watchersStore?.clear()}catch{}try{t.attr?._attrMapStore?.clear()}catch{}try{t.attr?._watchersStore?.clear()}catch{}try{t.motif.options&&(t.motif.options.cache=void 0,t.motif.options.closeFragment=void 0,t.motif.options.placeholder=void 0)}catch{}try{t.element=null}catch{}try{t.props=void 0}catch{}try{t.childs=void 0}catch{}try{t.class=void 0}catch{}try{t.attr=void 0}catch{}try{t.parent=null}catch{}try{t.motif.options=void 0}catch{}const e=Object.keys(t);for(let s=0;s<e.length;s++){const i=e[s];if("motif"!==i)try{t[i]=void 0}catch{}}t.isDisposed=!0}(this.owner)}};const as=new WeakMap,cs=new Set(["building","built","initializing","initialized","disposing","disposed","config","configured","visibilitychanged","activated","deactivated"]),ls=Symbol("motif.rawApplication"),hs=new Set(["on","onRouterChanged"]);class us extends E{motif=new ee(this,new Ve(this));element;props;isBuilt=!1;isInitialized=!1;isDisposed=!1;isConfigured=!1;isPainting=!1;isPainted=!1;isVisible=!0;controls=new pi(this);_eventHandlers;_isWait=!1;class=new Ut(this);attr=new $t(this);bindings=new Jt(this);_styleFx;useModel(t){return en(t)}_computeHideStrategy(){const t=this.motif.options?.hideStrategy??"auto";return"placeholder"===t?"placeholder":"detach"===t||this.motif.options?.__fromList||void 0!==this.motif.options?.indexkey||void 0!==this.motif.options?.__key?"detach":"placeholder"}_isInDom(){try{if(!this.element)return!1;const t=this.element;return t.nodeType,Node.COMMENT_NODE,!!t.parentNode}catch{return!1}}set isWait(t){this._isWait=t,this.isBuilt?t?this.motif.hide():this.motif.show():!1===t&&this.parent&&this.parent.isBuilt&&Ye.internalBuild.call(this.parent,this)}get isWait(){return this._isWait}constructor(t,e={}){if(super(),be(this),this.onElementCreating?this.element=this.onElementCreating.call(this):this.element=e?.onElementCreating?e.onElementCreating.call(this):t,e){const t=_s(e,this);if(t.length>0)for(const e of fs(this,t))C(()=>e(this),"MJX122","ref")}if(e&&vs(e,this),ks(e?.options,this),this.props=e,e){const t=new.target;t===us||Object.getPrototypeOf(t)===us?Ps(e,this):Js(e,this)}if(Ye.callOnInitializing(this),this.isDisposed)return;this.controls.onAdd=t=>{this._eventHandlers?.has("controladded")&&this.motif.trigger("controladded",{control:t}),this.isWait||this.parent?.isWait||Ye.internalBuild.call(this,t)},this.controls.onAddBeforeBuild=t=>{this._eventHandlers?.has("controladded")&&this.motif.trigger("controladded",{control:t})},this.controls.onRemove=t=>{this._eventHandlers?.has("controlremoved")&&this.motif.trigger("controlremoved",{control:t})},Ye.callOnInitialized(this);const s=new.target;s===us||Object.getPrototypeOf(s)===us?Ye.callConfig(this):this._base._configDeferred=!0}childs;_base=function(t){const e=Object.create(rs);return e.owner=t,e.prebinding_Activated=!1,e.emiters=new jt(t),e}(this);parent=null;_scopedContext;get context(){const t=this.parent?.context,e=t?.[ls]??t??ss.get(this)??Qn.main;return e?(this._scopedContext?.[ls]!==e&&(this._scopedContext=function(t,e){const s=new Map;return new Proxy(t,{get(t,i){if(i===ls)return t;const n=Reflect.get(t,i,t);if("function"!=typeof n)return n;const o=s.get(i);if(o&&o.fn===n)return o.bound;const r=hs.has(i)?(...s)=>e._trackContextSubscription(n.apply(t,s)):n.bind(t);return s.set(i,{fn:n,bound:r}),r},set:(t,e,s)=>Reflect.set(t,e,s,t)})}(e,this)),this._scopedContext):e}_trackContextSubscription(t){if("function"!=typeof t)return t;if(this.isDisposed)return t(),t;const e=this._register(k.toDisposable(t));return()=>{this._disposables.detach(e),t()}}build(t=!0){if(Ke(this),Ye.callConfigured(this),this._base._activatePreBindings(),this.isDisposed||!this.element||this.isWait)return;if(this.isBuilt||this.isWait)return;if(Ye.callBuilding(this),this.isDisposed)return;var e=this.element;t&&(e=li.createDocumentFragment());const s="string"!=typeof this.element&&this.element.nodeType===Node.COMMENT_NODE;if(s&&(this.motif.options.cache=li.createDocumentFragment(),this.element.textContent="[",this.motif.options.cache.appendChild(this.element)),this.isBuilt)return;if(Ye.callInitializeComponent(this),this.isDisposed)return;if(this.view){const t=this.view();if(this.controls.add(t),this.isDisposed)return}const i="SELECT"===this.element?.nodeName?this.bindings.items.filter(t=>"value"===t.propertyName):[];if(i.length)try{this.bindings.items.filter(t=>!i.includes(t)).forEach(t=>t.activate())}catch{}else this._base._activateBindings();for(const i of this.controls.items.filter(t=>!t.isWait))if(i.parent=this,i.build(!1),!i.isWait){var n=s?this.motif.options.cache:this.element;t?i.motif.options.cache?e.appendChild(i.motif.options.cache):e.appendChild(i.element):i.motif.options.cache?n.appendChild(i.motif.options.cache):n.appendChild(i.element),i._base?._inactive&&i.isVisible&&Ye.activateTree(i)}if(!this.isDisposed){if(Be(this)){const t=this.element;if(t&&t.isConnected)this.motif.options.transition.enterTransition(()=>{});else{const t=this._base._enterSeq;queueMicrotask(()=>{!this.isDisposed&&this.isVisible&&this.motif.options?.transition&&this._base._enterSeq===t&&this.motif.options.transition.enterTransition(()=>{})})}}else je(this);if(t)try{(n=s?this.motif.options.cache:this.element).nodeType===Node.TEXT_NODE?n.appendData(e.textContent):n.appendChild?n.appendChild(e):n.append(e)}catch(t){}if(i.length)try{i.forEach(t=>t.activate())}catch{}s&&(this.motif.options.closeFragment=li.createComment("]"),this.motif.options.cache.appendChild(this.motif.options.closeFragment),this.element.nodeType===Node.COMMENT_NODE&&this.motif.options.closeFragment&&as.set(this.element,this.motif.options.closeFragment)),this.isBuilt=!0,Ye.callBuilt(this),Ye.scheduleMounted(this)}}setState(){this.controls.forEach(t=>{t.setState()}),this._base._reactivateBindings()}reState(){this._base._reactivateBindings(),this.controls.forEach(t=>{t.reState()})}setText(t){!this.isDisposed&&this.element&&(Ms(t)?function(t,e){if(Cs.has(t))return;Cs.add(t),A("MJX204",[],{value:Array.isArray(e)?`ComponentBase[${e.length}]`:"ComponentBase"})}(this,t):this.element&&(this.element.textContent=t))}style(t){if(this.isDisposed)return this;const e=this.element?.style;if(!e)return this;if("function"==typeof t){this._stopStyleEffect();let e=[],s=!1;const i=()=>At(()=>{const i=t();if(this.isDisposed)return;const n=this.element?.style;if(n)if("string"==typeof i)n.cssText=i,e=[],s=!0;else if(i&&"object"==typeof i){s&&(n.cssText="",s=!1);for(const t of e)if(!(t in i))try{n[t]=""}catch{}Object.assign(n,i),e=Object.keys(i)}else{s&&(n.cssText="",s=!1);for(const t of e)try{n[t]=""}catch{}e=[]}});let n=i();const o=()=>{try{n()}catch{}},r={propertyName:"__style",dataSource:null,activate(){},reActivate(){o(),n=i()},deactivate(){o()}};try{this.bindings.add(r)}catch{}return this._styleFx={stop:o,binding:r},this}return"string"==typeof t?e.cssText=t:t&&"object"==typeof t&&Object.assign(e,t),this}_stopStyleEffect(){const t=this._styleFx;if(t){this._styleFx=void 0;try{t.stop()}catch{}try{this.bindings.remove(t.binding)}catch{}}}_addHandler(t,e){this.motif.on(t,e)}async _show(){if(this.isDisposed||!this.element)return;if(this.isVisible)return;if(this.parent&&"out-in"===Fe(this.parent)){const t=this.motif.options.placeholder?.parentNode??js(this.parent)?.element,e=Le(t,this.element);if(e){const t=this._base._showSeq=(this._base._showSeq??0)+1;return e.then(()=>{if(!this.isDisposed&&this._base._showSeq===t)return this._show()})}}He(this)?.activeAnimations?.length&&i(async()=>{await Promise.all(this.motif.options.transition.activeAnimations.map(t=>t.finished?.catch(()=>{})))},"show.waitForLeaveAnimations");if("detach"===this._computeHideStrategy()){if(Ye.callVisibilityChanged(this),this.isDisposed)return;const t=!this._isInDom()&&this.parent&&this.parent.isBuilt&&!this.isWait;return this.isVisible=!0,void(t&&Ye.internalBuild.call(this.parent,this))}{const e=this.motif.options.placeholder?.parentElement,s=js(this.parent)?.element;if(this.motif.options.placeholder&&e&&e!==s)return A("MJX106",[]),this.isVisible=!0,void(this.parent?.isBuilt&&Ye.internalBuild.call(this.parent,this));if(Be(this)&&this.motif.options.transition.enterTransition(()=>{}),Ye.callVisibilityChanged(this),this.isDisposed)return;if(this.element.nodeType===Node.COMMENT_NODE)return this.controls.forEach(t=>{t.motif.show()}),this.isVisible=!0,void Ye.activateTree(this,!1);var t=this.motif.options.placeholder?.parentElement;t&&(t.replaceChild(this.element,this.motif.options.placeholder),this.isVisible=!0,Ye.activateTree(this))}}async _hide(){if(this.isDisposed||!this.element)return;if(this._base._showSeq=(this._base._showSeq??0)+1,!this.isVisible)return;if("detach"===this._computeHideStrategy()){if(Ye.callVisibilityChanged(this),this.isDisposed)return;return await this._base._detachDomWithAnimationAsync(),this.isVisible=!1,void Ye.deactivateTree(this)}{const t=this.motif.options.transition,e=!0===t.skipNextLeave;e&&(t.skipNextLeave=!1);const s=()=>{if(Ye.callVisibilityChanged(this),!this.isDisposed){if(this.element.nodeType===Node.COMMENT_NODE)return this.controls.forEach(t=>{e&&t.isVisible&&t.element&&!t.isDisposed&&t.motif.options?.transition&&(t.motif.options.transition.skipNextLeave=!0),t.motif.hide()}),this.isVisible=!1,void Ye.deactivateTree(this,!1);var t=this.element.parentElement;t&&(this.motif.options.placeholder||(this.motif.options.placeholder=li.createComment("h")),t.replaceChild(this.motif.options.placeholder,this.element)),this.isVisible=!1,Ye.deactivateTree(this)}};return e?void s():t.leaveTransition(s).finished}}_toggle(){!this.isDisposed&&this.element&&(this.isVisible?this.motif.hide():this.motif.show())}async _on(t,e,s=!0){if(this.isDisposed||!this.element)return this;const i=String(t);if(i.startsWith("x:")){const t=i.slice(2).toLowerCase();if("mounted"===t){let t;const s=Fs(this.element,()=>{if(t&&(this._base._mountedSubs?.get(e)?.delete(t),this._disposables.detach(t)),this.isDisposed)return;const s={cancel:!1};C(()=>e.length<=1?e(s):e(this,s),"MJX122","x:mounted")});if(s){t=this._register(k.toDisposable(s));const i=this._base._mountedSubs??=new Map;let n=i.get(e);n||(n=new Set,i.set(e,n)),n.add(t)}return this}if(cs.has(t))return this._base.emiters.on("on"+t,e),this}const[n,...o]=i.split(":"),r=n.startsWith("on")?n.slice(2).toLowerCase():n.toLowerCase(),a={};o.includes("once")&&(a.once=!0),o.includes("passive")&&(a.passive=!0),o.includes("capture")&&(a.capture=!0);const c=t=>{if(o.includes("self")&&t.target!==this.element)return;if(o.includes("trusted")&&!t.isTrusted)return;let s;try{e&&e.length<=1?s=e(t):e&&(s=e(this,t))}catch(t){M("MJX123",t,r)}s&&"function"==typeof s.then&&s.then(void 0,t=>M("MJX123",t,r));const i=()=>{"function"==typeof t?.preventDefault&&t.preventDefault()},n=()=>{"function"==typeof t?.stopPropagation&&t.stopPropagation()};o.includes("prevent")&&i(),o.includes("stop")&&n(),s&&!0===s.cancel&&(i(),n())};s&&this.element.addEventListener(r,c,a),this._eventHandlers??=new Map;const l=i.toLowerCase(),h=this._eventHandlers.get(l)??new Set;return h.add({original:e,wrapped:c,capture:!!a.capture,domEvent:!!s,type:r}),this._eventHandlers.set(l,h),this._register(k.toDisposable(()=>{this.motif.off(t,e)})),this}async _trigger(t,e){if(this.isDisposed||!this.element)return this;const s=String(t).toLowerCase();return i(()=>{var t=this._eventHandlers?.get(s);t&&t.forEach(t=>{try{t.wrapped(e)}catch{}})},"trigger"),this}async _off(t,e){if(this.isDisposed||!this.element)return this;const s=String(t).toLowerCase();if(s.startsWith("x:")){const t=s.slice(2);if("mounted"===t){const t=this._base._mountedSubs?.get(e);if(t){this._base._mountedSubs.delete(e);for(const e of t)this._disposables.delete(e)}return this}return cs.has(t)&&this._base.emiters.off("on"+t,e),this}const n=s.split(":")[0],o=n.startsWith("on")?n.slice(2).toLowerCase():n.toLowerCase();if(!this._eventHandlers)return this;const r=this._eventHandlers.get(s);if(!r)return this;for(const t of Array.from(r))if(t.original===e){if(!1!==t.domEvent){const e=!0===t.capture;i(()=>{this.element.removeEventListener(o,t.wrapped,e)},"off.removeEventListener"),i(()=>{void 0===t.capture&&this.element.removeEventListener(o,t.wrapped,!e)},"off.removeEventListener.fallback")}r.delete(t);break}return 0===r.size&&this._eventHandlers.delete(s),this}_disposing;dispose(t={deep:!0}){return this.isDisposed?Promise.resolve():this._disposing?this._disposing:(Me(this),this._disposing=ts,this._disposing=this._disposeCore(t,!1))}async _disposeCore(t,e){let s;if(is(this,t,e),e||He(this)?.skipNextLeave||(s=this._base._detachDomWithAnimationAsync()),await void 0,0===Ae.live&&es(this,!0)){const i=function(t,e,s,i){const n={deep:e?.deep},o=[t],r=[-1];let a=null;i||Ze(t);for(let e=0;e<o.length;e++){const s=o[e];if(s.isDisposed)continue;const i=s.controls?.items;if(!i||0===i.length)continue;const c=Array.from(i);for(let s=0;s<c.length;s++){const i=c[s];if(!i.isDisposed)if(i._disposing)(a??=[]).push(i._disposing);else try{Me(i),i._disposing=t._disposing,is(i,n,!0),Ze(i),o.push(i),r.push(e)}catch(t){M("MJX107",t)}}}const c=o.length;if(c>1){const t=new Array(c).fill(0);for(let e=c-1;e>=1;e--){const s=r[e];t[e]+1>t[s]&&(t[s]=t[e]+1)}const e=[];for(let t=1;t<c;t++)e.push(t);e.sort((e,s)=>t[e]-t[s]||e-s);for(let t=0;t<e.length;t++)try{ns(o[e[t]],n,!0)}catch(t){M("MJX107",t)}}return a||(!s&&t.isDisposed||ns(t,e,s),null)}(this,t,e,void 0!==s);if(i){if(await Promise.all(i),!e&&this.isDisposed)return;ns(this,t,e)}return}await os(this,t,e,s)}disposeAsync(t={deep:!0}){return this.isDisposed?Promise.resolve():this._disposing?this._disposing:(Me(this),this._disposing=ts,this._disposing=this._disposeCore(t,!0))}async _clear(){1!=this.isDisposed&&(this.motif.options&&this.motif.options.disableDisposal||await this.controls.clearAsync())}using(t,e,s){t.then(t=>{this&&!this.isDisposed&&e&&e(t)},t=>{this&&!this.isDisposed&&s&&s(t)})}doWork(t){return Promise.resolve(t).then(t=>this&&!this.isDisposed?t:S("MJX108"))}_siblingsApi;_siblingsSet;get siblings(){return this._siblingsSet||this.isDisposed&&!this.motif?.options?this._siblingsApi:this._siblingsApi??=this._createSiblingsApi()}set siblings(t){this._siblingsApi=t,this._siblingsSet=!0}_createSiblingsApi(){return{all:()=>this.parent?.controls.items,next:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items[t+1]},prev:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items[t-1]},nextAll:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items.slice(t+1)},prevAll:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items.slice(0,t)}}}get serviceProvider(){let t=this;for(;t;){const e=t.provider;if(e)return e;const s=ss.get(t);if(s)return"disposed"===s.state?null:s.provider;t=t.parent}try{return Qn.main?.provider??null}catch{return null}}getService(t){try{const e=this.serviceProvider;if(e)return e._getFor(this,t);A("MJX407",[Je(t)],{token:t})}catch(e){A("MJX408",[Je(t),String(e?.message??e)],{token:t,error:e})}return null}$(t){return this.isDisposed||!this.element?{fromDom:()=>null,fromComponent:()=>[]}:{fromDom:()=>{var e,s=js(this)?.element;return(e=s||document)?e.querySelectorAll(t):null},fromComponent:()=>{const e=js(this),s=[],i=e=>{const n=e.element;if(n&&n.nodeType===Node.ELEMENT_NODE){const i=n.matches||n.msMatchesSelector||n.webkitMatchesSelector;if("function"==typeof i)try{i.call(n,t)&&s.push(e)}catch{}}if(e.controls&&e.controls.items&&e.controls.items.length)for(const t of e.controls.items)i(t)};return i(e??this),s}}}async _stopAnimations(){const t=He(this);try{t?.activeCssCancel?.()}catch{}try{if(t?.activeAnimations?.length)try{await Promise.all(t.activeAnimations.map(t=>t.finished?.catch(()=>{})))}catch{}}catch(t){}this.isDisposed||t&&(t.activeAnimations=[])}}function ds(t,e=[]){return!t||t.isDisposed||("TransportTo"===t.constructor.name&&e.push(t),t.controls&&t.controls.items&&t.controls.items.forEach(t=>ds(t,e))),e}const ps=new WeakMap;function fs(t,e){const s=(Array.isArray(e)?e:[e]).filter(t=>"function"==typeof t);if(0===s.length)return s;let i=ps.get(t);i||(i=new Set,ps.set(t,i));const n=[];for(const t of s)i.has(t)||(i.add(t),n.push(t));return n}const ms=t=>"function"==typeof t||Array.isArray(t);function _s(t,e){const s=[];if(!t||"object"!=typeof t)return s;Object.prototype.hasOwnProperty.call(t,"ref")&&(ms(t.ref)?(s.push(t.ref),delete t.ref):e&&t.ref&&"object"==typeof t.ref&&(t.ref=e));const i=t.runover;if(i&&"object"==typeof i&&Object.prototype.hasOwnProperty.call(i,"ref"))if(ms(i.ref)){s.push(i.ref);const e={...i};delete e.ref,t.runover=e}else e&&i.ref&&"object"==typeof i.ref&&(i.ref=e);return 0===s.length?s:[].concat(...s)}const gs={initializecomponent:"_initializeComponentHandlers",oninitializecomponent:"_onInitializeComponentHandlers",onbuilding:"_onBuildingHandlers",onbuilt:"_onBuiltHandlers",onmounted:"_onMountedHandlers",oninitializing:"_onInitializingHandlers",oninitialized:"_onInitializedHandlers",onconfig:"_onConfigHandlers",onconfigured:"_onConfiguredHandlers",onvisibilitychanged:"_onVisibilityChangedHandlers",onactivated:"_onActivatedHandlers",ondeactivated:"_onDeactivatedHandlers",ondisposing:"_onDisposingHandlers",ondisposed:"_onDisposedHandlers"};function ys(t,e,s){const i=Object.prototype.hasOwnProperty.call(gs,e)?gs[e]:void 0;if(!i)return!1;const n=Array.isArray(s)?s:[s];if(0===n.length||!n.every(t=>"function"==typeof t))return!1;t._base[i]??=[];const o=t._base[i];for(const t of n)o.includes(t)||o.push(t);return!0}function vs(t,e){if(t){e.motif.options.props||(e.motif.options.props={}),Object.assign(e.motif.options.props,t);var s=Object.keys(t);if(0===s.length)return;s.forEach(s=>{if("initializeComponent"==s||"oninitializeComponent"==s||s.startsWith("on")){if(ys(e,s.toLowerCase(),t[s]))return void delete t[s]}else if("childs"==s){const i=[].concat(...t[s]);e.childs=i,delete t[s]}else if("transition"===s)Ss(t[s],e),delete t[s];else if(Hs.hasOwnProperty(s.toLowerCase())||Hs.hasOwnProperty("on"+s.toLowerCase())){var i;i=s.toLowerCase().startsWith("on")||"initializecomponent"===s.toLowerCase()?s:"on"+s,e[i]=t[s],delete t[s]}else if(s.startsWith("on"))e.motif.on(s,t[s]);else if(s.startsWith("x-")){var n=s.replace("x-","on");if("x-wait"==s.toLowerCase())e.bindings.wait(t[s]);else if("x-display"==s.toLowerCase())e.bindings.display(t[s]);else if(ys(e,n.toLowerCase(),t[s]))return void delete t[s];delete t[s]}else s.startsWith("runover")?(vs(t[s],e),delete t[s]):s.startsWith("preconfig")&&(e.motif.options._preconfig=t[s],delete t[s])})}}const ws=new WeakMap;function bs(t,e,s){const i=t.motif.options.transition;if("string"==typeof e&&e.length>0)i.name=e,s&&(i.classes=void 0);else if(e&&"object"==typeof e)if("string"==typeof e.name&&e.name.length>0&&(i.name=e.name),"mode"in e){const{mode:t,...s}=e;Ie(t)&&(i.mode=t),Object.keys(s).length>0&&(i.classes=s)}else i.classes=e;else s&&(i.name="",i.classes=void 0)}function Ss(t,e){e&&!e.isDisposed&&null!=t&&ws.get(e)!==t&&(ws.set(e,t),"function"!=typeof t?bs(e,t,!1):e.bindings.watch(()=>{const s=t();e.isDisposed||bs(e,s,!0)}))}function Ms(t){return t instanceof us||Array.isArray(t)&&t.length>0&&t.every(t=>t instanceof us)}const Cs=new WeakSet;const As=["hideStrategy","disableDisposal"];function ks(t,e){if(t&&"object"==typeof t&&e&&!e.isDisposed)for(const s of As)void 0!==t[s]&&(e.motif.options[s]=t[s])}const Ds=new Set(["ref","key","indexkey","inject","options","props","settings","isSvg","childs","initializeComponent","runover","transition","preconfig","nodes","onElementCreating"]),Es=new Set(["innerhtml","srcdoc"]),Ts=new Set(["href","src","action","formaction","xlink:href"]),xs=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Os(t){if(null==t||"boolean"==typeof t)return!1;try{return xs.test(String(t))}catch{return!1}}function Ns(t,e){return()=>{let s=e();return"function"==typeof s&&(s=s()),"function"==typeof s&&(s=s()),Os(s)?(A("MJX125",[t]),null):s}}function Ps(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const s=Object.keys(t);if(0===s.length)return;let i=null,n=null;for(const o of s){if(Ds.has(o))continue;if(o.startsWith("x-")||o.startsWith("x:")||o.startsWith("__"))continue;let s=t[o];if(void 0===s)continue;if(/^on/i.test(o)){"function"==typeof s&&e.motif.on(o,s);continue}if("function"==typeof s&&s.length>0)continue;const r=o.toLowerCase();if(Es.has(r))A("MJX124",[o]);else{if(Ts.has(r))if("function"==typeof s)s=Ns(o,s);else if(Os(s)){A("MJX125",[o]);continue}(n??=Xs(e)).set(o,s),"class"===o||"className"===o?e.class.add(s&&"object"==typeof s&&!Array.isArray(s)?[s]:s):"style"===o?e.style(s):"value"===o||"checked"===o||"selected"===o?e.bindings.add(o,s):(i??={})[o]=s}}i&&e.attr.add(i)}const Ls=new WeakMap;function Xs(t){let e=Ls.get(t);return e||(e=new Map,Ls.set(t,e)),e}const Rs=new Set(["class","className","style","id","tabindex","role"]);function Is(t){return Rs.has(t)||t.startsWith("aria-")||t.startsWith("data-")}function Js(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const s=Ls.get(e);let i=null;for(const e of Object.keys(t)){if(!Is(e))continue;const n=t[e];null!=n&&("function"==typeof n&&n.length>0||s&&s.has(e)&&Object.is(s.get(e),n)||((i??={})[e]=n))}i&&Ps(i,e)}const Hs={oninitializecomponent:(t,e)=>{},initializecomponent:(t,e)=>{},onconfigured:(t,e)=>{},onconfig:(t,e)=>{},onbuilding:(t,e)=>{},onbuilt:(t,e)=>{},onmounted:(t,e)=>{},oninitializing:(t,e)=>{},oninitialized:(t,e)=>{},ondisposing:(t,e)=>{},ondisposed:(t,e)=>{},onvisibilitychanged:(t,e)=>{},ondeactivated:(t,e)=>{},onactivated:(t,e)=>{}};function js(t){return i(()=>!t||t.isDisposed?null:t.element.nodeType!==Node.COMMENT_NODE&&t.element.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.element.nodeType!==Node.TEXT_NODE?t:t.parent?js(t.parent):null,"findAppendableComponent",null)}function Fs(t,e){if(document.contains(t))return e(),null;let s=!1;const i=new MutationObserver(()=>{s||document.contains(t)&&(s=!0,i.disconnect(),e())});return i.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{if(!s){s=!0;try{i.disconnect()}catch{}}}}function Bs(t){!function(t){const e=fe.get(t);e&&(fe.delete(t),e.live&&e.scope._releaseLivePin(),ue?._touch())}(t),Ye.activateTree(t)}function zs(t){Se(t),Ye.deactivateTree(t)}const Vs=100;function Ws(t,e){let s=t,i=0;for(;"function"==typeof s;){if(s.prototype instanceof us)return new s(e);if(++i>Vs)return M("MJX112",void 0,Vs),s;s=s(e)}return s}const $s="http://www.w3.org/2000/svg";class Us extends us{static elementTag;static elementNamespace;constructor(){const t=new.target;var e,s,i=arguments;if(1===i.length?e=i[0]:2===i.length&&(e=i[0],s=i[1]),e instanceof Function&&Zs(e=Ws(e,s)))return ii(e,s);if(Array.isArray(e)){super(oi(),{});var n=Object.create(s||{});for(const t in e){const s=e[t];this.controls.add(new Us(s,n))}}else if("string"==typeof e&&e.trim().length>0)if(s||(s={}),s?.options&&s.options.isSvg||s?.__isSvgElement){const t=li.createElementNS("http://www.w3.org/2000/svg",e,s);s.isSvg=!0,super(t,s)}else{super(li.createElement(e,s),s)}else if(e instanceof Node)super(e,s);else{if(e instanceof us)return e;{const i=e&&"object"==typeof e?e:s,n=function(t){try{const e=t?.elementTag;if("string"==typeof e){const t=e.trim();if(t)return t}}catch{}}(t);if(n){super(function(t,e,s){const i="string"==typeof e?.elementNamespace&&e.elementNamespace?e.elementNamespace:void 0;return i===$s||!0===s?.options?.isSvg||!0===s?.__isSvgElement?(s&&"object"==typeof s&&(s.isSvg=!0),li.createElementNS(i||$s,t,s)):li.createElement(t,s)}(n,t,i),i??{})}else super(oi(),i??{});const o=this.childs;if(Array.isArray(o)&&o.length)for(const t of o)t&&this.controls.add(t)}}}}function qs(t){return e=>{var s=ni({...e});return s.controls.add(t(e)),s}}function Gs(t,e){if(t instanceof us)for(const s of fs(t,e))C(()=>s(t),"MJX122","ref");return t}function Ks(t,e){const s=t._base?.[e];return Array.isArray(s)?s.length:0}function Ys(t,e,s,i){const n=t._base?.[e];if(Array.isArray(n))for(let e=s;e<n.length;e++){if(t.isDisposed)return;const s=n[e];C(()=>s(t,{cancel:!1}),"MJX122",i)}}function Qs(t,e){if("string"==typeof t){if("text"===t&&e&&e.__childExpr){const t=function(t){if("function"!=typeof t)return;let e;try{e=Tt(t)}catch{return}return e instanceof us||Array.isArray(e)&&e.length>0&&e.every(t=>t instanceof us)?e:void 0}(e.__childExpr);if(void 0!==t)return t}return new Us(t,e)}if(t instanceof us||t instanceof Us)return t;if("function"==typeof t){const s=t.prototype instanceof us?[]:_s(e),i=Ws(t,e);return"object"==typeof i&&null!==i&&"el"in i?Gs(ii(i,e),s):function(t,e,s){if(!e||"object"!=typeof e)return t;if(!(t instanceof us))return t;Gs(t,s.concat(_s(e))),Js(e,t),ks(e.options,t),Object.prototype.hasOwnProperty.call(e,"transition")&&Ss(e.transition,t);const i=e.runover;if(!i||"object"!=typeof i)return t;const n=t._base?._onConfigHandlers,r=Array.isArray(n)?n.length:0,a=Ks(t,"_onInitializingHandlers"),c=Ks(t,"_onInitializedHandlers");if(vs(i,t),Ys(t,"_onInitializingHandlers",a,"onInitializing"),Ys(t,"_onInitializedHandlers",c,"onInitialized"),t.isConfigured){const e=t.motif.options?._preconfig;"function"==typeof e&&o(()=>e(t),"motifComponent.preconfig");const s=t._base?._onConfigHandlers;if(Array.isArray(s))for(let e=r;e<s.length;e++){const i=s[e];C(()=>i(t,{cancel:!1}),"MJX122","onConfig")}}return t}(i,e,s)}return"object"==typeof t&&null!==t&&"el"in t?ii(t,e):new Us(t,e)}function Zs(t){return"object"==typeof t&&null!==t&&!(t instanceof us)&&"el"in t}function ti(t){return!t||"object"!=typeof t||t instanceof us||null==t.default?t:t.default}function ei(t){if(null!==t&&"object"==typeof t&&!(t instanceof us||Array.isArray(t)||t instanceof Node)&&"function"!=typeof t.then)throw S("MJX127",function(t){return null===t?"null":Array.isArray(t)?"array":"object"!=typeof t||"[object Module]"!==Object.prototype.toString.call(t)&&!t.__esModule?typeof t:"module"}(t))}function si(t,e){const s=Ws(t,e);return Zs(s)?ii(s,void 0):s}function ii(t,e){const s=Qs(t.el,e);return Object.getOwnPropertyNames(t).forEach(e=>{"el"!==e&&"ctor"!==e&&(s[e]=t[e])}),"function"==typeof t.ctor&&C(()=>t.ctor.call(s,e),"MJX122","ctor"),s}function ni(t){return new ri(t)}function oi(){return li.createComment("")}class ri extends Us{constructor(t,e){super(oi(),arguments.length<=1?t:e)}initializeComponent(t){const e=this.childs;if(Array.isArray(e)&&e.length)for(const t of e)t&&this.controls.add(t);o(()=>{const t=this.motif.options?.props?.nodes;if(Array.isArray(t)&&t.length)for(const e of t)e&&this.controls.add(e)},"Fragment.initializeComponent.props.nodes")}}const ai=globalThis;function ci(){return ai&&ai.motifDom?ai.motifDom.window.document:ai.document}const li={get window(){return ai&&ai.window?ai.window:ai&&ai?ai.motifDom.window:ai},_created:new Map,document:ci(),createElement(t,e){const s=ci();if(!s)throw S("MJX101",t);if("text"===t)return s.createTextNode("");if(!this._created.has(t)){const i=s.createElement(t,e);this._created.set(t,i)}return this._created.get(t).cloneNode(!1)},createDocumentFragment(){try{var t=ci();if(t)return t.createDocumentFragment()}catch(t){s.reportSuppressed("dom.createDocumentFragment",t)}},createComment(t){try{return ci()?.createComment(t)}catch(t){s.reportSuppressed("dom.createComment",t)}},createTextNode(t){try{return ci()?.createTextNode(t)}catch(t){s.reportSuppressed("dom.createTextNode",t)}},querySelectorAll(t){try{return ci()?.querySelectorAll(t)}catch(t){s.reportSuppressed("dom.querySelectorAll",t)}},createElementNS(t,e,s){try{return ci()?.createElementNS(t,e,s)}catch(t){M("MJX103",t,e)}},convertToSvgElement(t){const e=t.tagName.toLowerCase(),s=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of t.attributes)s.setAttribute(e.name,e.value);for(;t.firstChild;)s.appendChild(t.firstChild);const i=t.parentNode;return i&&i.replaceChild(s,t),s},get body(){return ci()?.body}},hi=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;var ui;function di(t,e,...s){return function(t,e,s,...i){const n=hi.exec(e);if(!n)throw S("MJX102",e);const o=n[1]||"div";let r;return r=t!==ui.HTML?li.createElementNS(t,o):li.createElement(o),n[3]&&(r.id=n[3]),n[4]&&(r.className=n[4].replace(/\./g," ").trim()),s&&Object.entries(s).forEach(([t,e])=>{void 0!==e&&(/^on\w+$/.test(t)?r[t]=e:"selected"===t?e&&r.setAttribute(t,"true"):r.setAttribute(t,e))}),r.append(...i),r}(ui.HTML,t,e,...s)}!function(t){t.HTML="http://www.w3.org/1999/xhtml",t.SVG="http://www.w3.org/2000/svg"}(ui||(ui={}));class pi{owner;constructor(t){this.owner=t}items=[];add(){const t=arguments.length;if(0===t)return[];const e=arguments[0];if(1===t&&e instanceof us)return e.isDisposed?[]:[this._insertOne(void 0,e)];const s=Array.from(arguments);if("number"==typeof s[0]&&s.length>1){const t=s[0],e=[].concat(...s.slice(1));return this.insert(t,...e)}{const t=[].concat(...s);return this.insert(void 0,...t)}}insert(t,...e){return[].concat(...e).filter(t=>null!=t&&!t.isDisposed).map(e=>this._insertOne(t,e))}_insertOne(t,e){"string"!=typeof(e=Ws(e))&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e||(e=new Us(li.createTextNode(e),null)),Ke(e),e.parent&&e.parent.controls.detach(e),null!=t&&t>=0?this.items.splice(t,0,e):this.items.push(e),e.parent=this.owner;const s=e.__pendingLeave;return s?(this.onAddBeforeBuild&&!this.owner.isBuilt&&this.onAddBeforeBuild(e),s.promise.then(()=>{e.isDisposed||this.owner.isDisposed||e.parent!==this.owner||this.onAdd&&this.owner.isBuilt&&this.onAdd(e)}),e):(this.onAdd&&this.owner.isBuilt&&this.onAdd(e),this.onAddBeforeBuild&&!this.owner.isBuilt&&this.onAddBeforeBuild(e),e)}remove(t){var e=this.items.indexOf(t);if(e>-1){this.items.splice(e,1);try{t.dispose()}catch{}}}detach(t){const e=this.items.indexOf(t);return-1===e?Promise.resolve():(this.items.splice(e,1),t.isDisposed?Promise.resolve():(t._base&&(t._base._leaveContainer=this.owner),t.parent=null,function(t,e){let s=()=>{};const i=new Promise(t=>{s=t});let n=1,o=!1;const r=()=>{if(!o){if(o=!0,t.__pendingLeave?.promise===i&&delete t.__pendingLeave,!t.isDisposed){try{fi(t)}catch(t){M("MJX117",t)}zs(t)}try{e()}catch(t){M("MJX118",t)}s()}},a=()=>{n--,0===n&&r()},c=t=>{if(!t||t.isDisposed||!t.element||!t.isVisible||t.isWait)return;const e=t.element;if(e.nodeType===Node.COMMENT_NODE)return void t.controls.items.forEach(c);if(e.nodeType!==Node.ELEMENT_NODE)return;n++;let s=!1;const i=()=>{s||(s=!0,a())};try{const e=t.motif.options;if(!e[De]&&!e.transitionOut)return void i();e.transition.leaveTransition(i)}catch{i()}};return t.__pendingLeave={promise:i,finish:r},c(t),a(),i}(t,()=>{this.onRemove&&this.onRemove(t)})))}silentDetach(t,e=!1){if(e)return void this.silentUnlink(t);const s=this.items.indexOf(t);if(-1!==s&&(this.items.splice(s,1),!t.isDisposed)){t.parent=null;try{fi(t)}catch(t){M("MJX117",t)}zs(t)}}silentUnlink(t){const e=this.items.indexOf(t);-1!==e&&(this.items.splice(e,1),t._base&&(t._base._leaveContainer=this.owner),t.parent=null)}async clearAsync(){const t=this.items.splice(0,this.items.length);await Promise.all(t.map(t=>t.dispose()))}clear(){this.items.splice(0,this.items.length).forEach(t=>{try{t.dispose()}catch{}})}get length(){return this.items.length}forEach(t){this.items.forEach(t)}map(t){return this.items.map(t)}onAdd;onRemove;onAddBeforeBuild;move(t,e){if(!t||t.isDisposed)return;if(e===t)return;if(t.parent!==this.owner)return;if(e&&e.parent!==this.owner)return;const s=this.items.indexOf(t);if(-1===s)return;const i=e?this.items.indexOf(e):-1;if(e&&-1===i)return;if(e?i===s+1:s===this.items.length-1)return;if(this.items.splice(s,1),e){const s=this.items.indexOf(e),i=s>=0?s:this.items.length;this.items.splice(i,0,t)}else this.items.push(t);if(t.isWait)return;const n=function(t){let e=t;for(;e;){const t=e.element;if(t&&t.nodeType!==Node.COMMENT_NODE&&t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.nodeType!==Node.TEXT_NODE)return t;e=e.parent}return null}(this.owner);if(!n)return;!function(t,e,s){const i=t.element;if(!i)return;if(i.nodeType!==Node.COMMENT_NODE){try{e.insertBefore(i,s)}catch{}return}const n=i,o=t.motif.options?.closeFragment||null;if(!o){try{e.insertBefore(n,s)}catch{}return}s&&function(t,e,s){let i=t,n=1e4;for(;i&&n-- >0;){if(i===s)return!0;if(i===e)break;i=i.nextSibling}n<=0&&M("MJX120",void 0);return!1}(n,o,s)&&(s=o.nextSibling);const r=li.createDocumentFragment&&li.createDocumentFragment()||e.ownerDocument?.createDocumentFragment?.()||function(){try{return document.createDocumentFragment()}catch{return null}}();if(!r){let t=n,i=1e4;for(;t&&i-- >0;){const i=t.nextSibling;try{e.insertBefore(t,s)}catch{}if(t===o)break;t=i}return void(i<=0&&M("MJX119",void 0))}let a=n,c=1e4;for(;a&&c-- >0;){const t=a.nextSibling;try{r.appendChild(a)}catch{}if(a===o)break;a=t}c<=0&&M("MJX119",void 0);try{e.insertBefore(r,s)}catch{}}(t,n,e?e.element:function(t){const e=t.element;if(e&&e.nodeType===Node.COMMENT_NODE)return t.motif.options?.closeFragment||null;return null}(this.owner))}moveToIndex(t,e){if(!t||t.isDisposed)return;if(!Number.isFinite(e))return;if(e<0&&(e=0),e>this.items.length&&(e=this.items.length),-1===this.items.indexOf(t))return;const s=e>=this.items.length?null:this.items[e];this.move(t,s)}}function fi(t){const e=t.element;if(!e)return;const s=t.motif.options;if(e.nodeType===Node.COMMENT_NODE){if(!e.parentNode)return;const t=s?.closeFragment||null,i=s.cache??(s.cache=li.createDocumentFragment());let n=e,o=1e4;for(;n&&o-- >0;){const e=n.nextSibling;if(i.appendChild(n),!t||n===t)break;n=e}return}if(e.parentNode)return void e.parentNode.removeChild(e);const i=s?.placeholder;i&&i.parentNode&&i.parentNode.removeChild(i)}function mi(t){return ti(t)}function _i(t){const e=t&&t.options||{},s=new bi,i=new Set,n=t=>{try{i.add(t)}catch{}return t},o=()=>{try{i.forEach(t=>{try{clearTimeout(t)}catch{}})}catch{}try{i.clear()}catch{}};try{s.motif.register(k.toDisposable(()=>o()))}catch{}const r=e.Placeholderview??e.Loaderview;null!=r&&s.navigate(si(r));const a=()=>{if(!e.timeoutMs&&!e.signal)return t.caller();const s=[t.caller()];return e.timeoutMs&&e.timeoutMs>0&&s.push(new Promise((t,o)=>{const r=n(setTimeout(()=>o(S("MJX110",e.timeoutMs)),e.timeoutMs));if(s[0].finally(()=>{try{clearTimeout(r),i.delete(r)}catch{}}).catch(()=>{}),e.signal){const t=()=>{try{clearTimeout(r),i.delete(r)}catch{}};try{e.signal.addEventListener("abort",t,{once:!0})}catch{}}})),e.signal&&s.push(new Promise((t,s)=>{if(e.signal.aborted)return void s(S("MJX111"));const i=()=>{e.signal.removeEventListener("abort",i),o(),s(S("MJX111"))};e.signal.addEventListener("abort",i,{once:!0})})),Promise.race(s)},c=function(t){return"number"==typeof t?{count:Math.max(0,Math.floor(t)),delayMs:500,whenOnline:!0}:t&&"object"==typeof t?{count:Math.max(0,Math.floor(t.count||0)),delayMs:Math.max(0,t.delayMs??500),whenOnline:!1!==t.whenOnline}:{count:0,delayMs:0,whenOnline:!1}}(e.retry),l=new Set;try{s.motif.register(k.toDisposable(()=>{l.forEach(t=>{try{t()}catch{}}),l.clear()}))}catch{}const h=t=>new Promise(s=>{let o=!1;const r=t=>{if(!o){o=!0,l.delete(a);try{d&&window.removeEventListener("online",d)}catch{}try{void 0!==u&&(clearTimeout(u),i.delete(u))}catch{}try{e.signal?.removeEventListener("abort",h)}catch{}s(t)}},a=()=>r(!1),h=()=>r(!1);let u,d=null;l.add(a);try{e.signal?.addEventListener("abort",h,{once:!0})}catch{}const p=()=>{u=n(setTimeout(()=>r(!0),c.delayMs*t))};c.whenOnline&&"undefined"!=typeof navigator&&!1===navigator.onLine&&"undefined"!=typeof window?(d=()=>{try{window.removeEventListener("online",d)}catch{}d=null,p()},window.addEventListener("online",d)):p()}),u=c.count>0?(async()=>{let t=0;for(;;)try{return await a()}catch(i){if(e.signal?.aborted||s.isDisposed||t>=c.count)throw i;t++;try{e.onRetry?.(t,i)}catch{}if(!await h(t)||e.signal?.aborted||s.isDisposed)throw i}})():a(),d=Date.now(),p=t=>{try{e.onError?.(t)}catch{}if(!e.signal?.aborted)if(null!=e.Fallbackview)s.navigate(si(e.Fallbackview));else{M("MJX126",t);try{s.motif.clear().catch(()=>{})}catch{}}},f=t=>{let e;try{e=si(t),ei(e)}catch(t){return void p(t)}s.navigate(e)};return u.then(t=>{if(e.signal?.aborted)return;const s=(e.mapResult??mi)(t),o=Date.now()-d,r=Math.max(0,e.minDelayMs??0),a=Math.max(0,r-o);if(a>0){const t=n(setTimeout(()=>{e.signal?.aborted||f(s)},a));if(e.signal){const s=()=>{try{clearTimeout(t),i.delete(t)}catch{}};try{e.signal.addEventListener("abort",s,{once:!0})}catch{}}}else f(s)}).catch(p),s}function gi(t,e){const s=t?.motif?.options;if(!s)return!1;const i=s.transition;return!!(("enter"===e?s.transitionIn:s.transitionOut)||i&&(i.classes||i.name&&i.name.length>0))}function yi(t){if(t&&!t.isDisposed)if(Array.isArray(t))t.forEach(yi);else{try{t.motif.options?.transition?.activeCssCancel?.()}catch{}try{const e=t.motif.options?.transition?.activeAnimations;Array.isArray(e)&&(e.forEach(t=>{try{t&&"function"==typeof t.cancel&&t.cancel()}catch{}}),e.length=0)}catch{}try{if(t.controls&&t.controls.items)for(const e of t.controls.items)yi(e)}catch{}}}async function vi(t,e={deep:!0}){if(!t)return;const s=Array.isArray(t)?t:[t];await Promise.all(s.map(async t=>{if(t&&!t.isDisposed)try{await t.dispose(e)}catch(t){M("MJX115",t)}}))}async function wi(t,e,s=!1){if(t.isDisposed||null==e)return;if(null!==t.current&&t.current===e)return;const i=++t._latestNavigateId;t.isBusy=!0;const n=e=>{if(t.isDisposed)return;if(i!==t._latestNavigateId)return;const s=Ws(e);t.current=s;try{Array.isArray(s)?t.controls.add(...s):t.controls.add(s)}catch(t){M("MJX114",t)}t.isBusy=!1,t.previouspage=s};if(!(t._navPending||null!==t.current||e instanceof Promise)){try{n(e)}catch(e){M("MJX114",e),t.isBusy=!1}return}t._navPending=(t._navPending??0)+1;const o=t._navLock??Promise.resolve();t._navLock=(async()=>{try{await o;try{t._navAbort?.abort()}catch{}t._navAbort=new AbortController;const r=t.current;if(r&&!s){yi(r),yi(t);const e=!!(i=r)&&(Array.isArray(i)?i.some(t=>!!t&&!t.isDisposed&&gi(t,"leave")):!i.isDisposed&&gi(i,"leave")),s=vi(r);e?s.catch(()=>{}):await s}try{if(e instanceof Promise){const s=_i({caller:()=>e,options:{signal:t._navAbort?.signal}});n(s)}else n(e)}catch(e){M("MJX114",e),t.isBusy=!1}}finally{t._navPending=Math.max(0,(t._navPending??1)-1)}var i})(),await t._navLock}class bi extends Us{current=null;_latestNavigateId=0;_navLock=Promise.resolve();_navAbort;isBusy=!1;constructor(t){super(li.createComment(""),t),t&&t.childs&&Array.isArray(t.childs)&&t.childs.length>0&&this.controls.add(t.childs)}async dispose(t={deep:!0}){await vi(this.current,t),await super.dispose(t)}async flush(){await vi(this.current)}async _clear(){await vi(this.current)}previouspage;async navigate(t,e=!1){await wi(this,t,e)}async navigateLazy(t,e,s=!1){const i=_i({caller:t,options:e});await this.navigate(i,s)}}const Si=new Set;function Mi(t){Si.add(t),Si.forEach(t=>{t()})}const Ci=new Map,Ai=Symbol("changeBodyCollectionHandler");class ki extends Us{constructor(t){super(t);const e=t=>{this.motif.trigger("controladded",{control:t});var e=Ci.get(this.props.target);e&&(t.motif.options.ownerContentBlock=this,e.controls.add(t))};this.controls.onAdd=e,this.controls.onAddBeforeBuild=e,this.childs&&this.controls.add(...this.childs)}onConfigured(t,e){var s=Ci.get(this.props.target);s?(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),s.controls.add(...this.controls.items)):this.context.on(Ai,()=>{var t=Ci.get(this.props.target);t&&(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),t.controls.add(...this.controls.items))})}onDisposing(t,e){var s=Ci.get(this.props.target);if(s)for(const t of[...s.controls.items])t.motif.options.ownerContentBlock===this&&(s.controls.remove(t),A("MJX109",[],t))}ondisposing(t){}}class Di extends Us{constructor(t){super(t),Ci.set(this.props.name,this),this.context.fire(Ai)}ondisposing(t){Ci.get(this.props.name)===this&&Ci.delete(this.props.name)}}const Ei=Symbol("slotRegistered"),Ti=Symbol("slotUnregistered");class xi{static slots=new Map;static registerSlot(t,e){this.slots.set(t,e),Qn.main.fire(Ei,{name:t,slot:e})}static unregisterSlot(t,e){this.slots.get(t)===e&&(this.slots.delete(t),Qn.main.fire(Ti,{name:t,slot:e}))}static getSlot(t){return this.slots.get(t)}}class Oi extends Us{mode;constructor(t){super(t),this.mode=t.mode||"replace"}initializeComponent(t){xi.registerSlot(this.props.name,this),this.onDisposing=()=>{[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()}),xi.unregisterSlot(this.props.name,this)}}clearSlot(){[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()})}}class Ni{static transport(t,e,s={}){t&&e&&(t.parent===e&&e.controls.items.includes(t)||(t.parent&&t.parent!==e&&t.parent.controls.silentDetach(t,!0),s.owner&&(t.motif.options.ownerTransporter=s.owner),"number"==typeof s.index?e.controls.items.includes(t)||e.controls.items.splice(s.index,0,t):e.controls.items.includes(t)||e.controls.add(t),t.parent=e,s.keepState||t.reState()))}static transportMany(t,e,s={}){Array.isArray(t)&&t.forEach(t=>this.transport(t,e,s))}static createSlot(t,e){return{name:t,children:[],parent:e,mount(t,e={}){if(!this.parent)throw S("MJX113");this.children.includes(t)||(Ni.transport(t,this.parent,e),this.children.push(t))},unmount(t){if(!this.parent)throw S("MJX113");this.children=this.children.filter(e=>e!==t),this.parent.controls.remove(t)},detachAll(){this.parent&&(this.children.forEach(t=>{this.parent.controls.remove(t)}),this.children=[])}}}}class Pi extends Us{_onAddRef;_onRemoveRef;_slotRegisteredListener;_slotUnregisteredListener;_transported=[];_countedLive=!1;constructor(t){super("div",t),Ae.live++,this._countedLive=!0}_handleSlotChange=t=>{if(t.name===this.props.name){const e=t.slot;"merge"!==e.mode&&e.clearSlot?.();const s=[...this.childs||[],...this.controls.items];Ni.transportMany(s,e),this._rememberTransported(s)}};_rememberTransported(t){const e=this._transported.filter(t=>!t.isDisposed);for(const s of t)e.includes(s)||e.push(s);this._transported=e}_clearChildrenFromSlot=t=>{(this.childs||[]).forEach(e=>{t.controls.remove(e),e.dispose()}),(this.controls.items||[]).forEach(e=>{t.controls.remove(e),e.dispose()})};initializeComponent(t){let e=xi.getSlot(this.props.name);if(e){"merge"!==e.mode&&e.clearSlot?.();const t=[...this.childs||[],...this.controls.items];Ni.transportMany(t,e),this._rememberTransported(t)}this._slotRegisteredListener=Qn.main.on(Ei,this._handleSlotChange),this._slotUnregisteredListener=Qn.main.on(Ti,t=>{t.name===this.props.name&&this._clearChildrenFromSlot(t.slot)}),this._onAddRef=t=>{this.motif.trigger("controladded",{control:t});const e=xi.getSlot(this.props.name);e&&(Ni.transport(t,e),this._rememberTransported([t]))},this._onRemoveRef=t=>{const e=xi.getSlot(this.props.name);e&&e.controls.remove(t),this._transported=this._transported.filter(e=>e!==t)},this.controls.onAdd=this._onAddRef,this.controls.onRemove=this._onRemoveRef}onDisposing(t,e){this._countedLive&&(this._countedLive=!1,Ae.live--);const s=xi.getSlot(this.props.name);for(const t of this._transported||[])s?.controls.remove(t),t.dispose();this._slotRegisteredListener&&(Qn.main.off(Ei,this._handleSlotChange),this._slotRegisteredListener=void 0),this._slotUnregisteredListener&&(Qn.main.off(Ti,this._slotUnregisteredListener),this._slotUnregisteredListener=void 0),this.controls.onAdd===this._onAddRef&&(this.controls.onAdd=void 0),this.controls.onRemove===this._onRemoveRef&&(this.controls.onRemove=void 0),this._onAddRef=void 0,this._onRemoveRef=void 0,this._transported=[]}}const Li=new Set(["push","pop","shift","unshift","splice","reverse","sort"]),Xi=Symbol(""),Ri=new Map([[T.IS_REACTIVE,()=>!0],[T.IS_READONLY,t=>t.isReadonly],[T.IS_SUPERFICIAL,t=>t.superficial],[T.GET_SETUP,(t,e)=>e],[T.RAW,(t,e,s)=>t.ReactiveMap().get(e)===s?e:Xi]]);function Ii(t,e,s,i){if("symbol"!=typeof s)return Xi;const n=Ri.get(s);return void 0===n?Xi:n(t,e,i)}function Ji(t){return function(e,s,i){const n=Ii(t,e,s,i);if(n!==Xi)return n;if(Array.isArray(e)&&!t.isReadonly){const i=t.arrayMethods.get;if(L(i,s)){const t=i[s];return Li.has(s)?(o=s,W.push(N),N.enabled=!0,N.key=o):wt(e,s),t}}var o;const r=Reflect.get(e,s,i);return"__proto__"===s||I(s)?r:(t.isReadonly||wt(e,s),t.superficial||!X(r)?r:t.reactive(r))}}function Hi(t){return function(e,s,i,n){if(null!=(o=e)&&Boolean(o[T.IS_READONLY]))return!1;var o;const r=Array.isArray(e),a=e[s],c=r?e.length:0,l=r&&("string"==typeof(h=s)&&H.test(h)&&String(Number(h))===h);var h;const u=l?Number(s)<c:L(e,s),d=Reflect.set(e,s,i,n);if(t.onValueChanged)try{t.onValueChanged({raw:e,proxy:n},s)}catch{}if(P(e)!==P(n))return d;if(!r&&u&&Object.is(i,a))return d;if(bt(e,s),r||u||bt(e,x),l&&!u&&bt(e,"length"),r&&"length"===s){for(let t=Number(i);t<c;t++)bt(e,String(t))}return function(){const t=W.pop();N=W.length>0?void 0===t?{enabled:!1,key:""}:t:{enabled:!1,key:""}}(),d}}function ji(t){return function(t){return wt(t,Array.isArray(t)?"length":x),Reflect.ownKeys(t)}}function Fi(t){return function(t,e){const s=Reflect.has(t,e);return I(e)||wt(t,e),s}}function Bi(t){return function(t,e){z();try{const s=L(t,e),i=Reflect.deleteProperty(t,e);return s&&(Array.isArray(t)?bt(t,"length"):(bt(t,e),bt(t,x))),i}finally{V()}}}const zi=[["includes","lookup"],["indexOf","lookup"],["lastIndexOf","lookup"],["sort","order"],["concat","join"],["push","structural"],["pop","structural"],["shift","structural"],["unshift","structural"],["splice","structural"],["reverse","structural"]];class Vi{engine;constructor(t){this.engine=t}get=this.createArrayMethods();createArrayMethods(){const t={};for(const[e,s]of zi)t[e]=this.patch(e,s);return t}patch(t,e){const s=this;switch(e){case"lookup":return function(...e){const i=P(this);s.engine.track(i,"length");const n=i[t](...e);return!1!==(o=n)&&-1!==o?n:i[t](...e.map(t=>P(t)));var o};case"order":return function(...e){const i=P(this),n=this.length;for(let t=0;t<n;t++)s.engine.track(i,String(t));const o=i[t].apply(this,e);return s.engine.track(i,t),o};case"join":return function(...t){return Array.prototype.concat.apply(this,t)};default:return function(...e){z();const s=P(this);try{return s[t].apply(this,e)}finally{V()}}}}}const Wi=Symbol("");function $i(t,e,s){bt(t,e),bt(t,x),s&&bt(t,Wi)}function Ui(t,e){return t.has(e)?e:P(e)}function qi(t,e){return{next(){const s=t.next();return s.done?s:{value:e(s.value),done:!1}},[Symbol.iterator](){return this}}}function Gi(t){const e=function(t){const e=e=>X(e)?t.reactive(e):e,s=t=>t instanceof Map?([t,s])=>[t,e(s)]:([t])=>{const s=e(t);return[s,s]};return{get(t){const s=P(this),i=Ui(s,t);return wt(s,i),e(s.get(i))},has(t){const e=P(this),s=Ui(e,t);return wt(e,s),e.has(s)},set(t,e){const s=P(this),i=Ui(s,t),n=P(e),o=s.has(i),r=s.get(i);return s.set(i,n),o?Object.is(r,n)||$i(s,i,!1):$i(s,i,!0),this},add(t){const e=P(this),s=Ui(e,t);return e.has(s)||(e.add(s),$i(e,s,!0)),this},delete(t){const e=P(this),s=Ui(e,t),i=e.delete(s);return i&&$i(e,s,!0),i},clear(){const t=P(this);if(0===t.size)return;const e=Array.from(t.keys());t.clear();for(const s of e)bt(t,s);bt(t,x),bt(t,Wi)},forEach(t,s){const i=P(this);wt(i,x);const n=this,o=i instanceof Map;i.forEach((i,r)=>{const a=e(i);t.call(s,a,o?r:a,n)})},keys(){const t=P(this);return t instanceof Map?(wt(t,Wi),t.keys()):(wt(t,x),qi(t.keys(),e))},values(){const t=P(this);return wt(t,x),qi(t.values(),e)},entries(){const t=P(this);return wt(t,x),qi(t.entries(),s(t))},[Symbol.iterator](){const t=P(this);return wt(t,x),t instanceof Map?qi(t.entries(),s(t)):qi(t.values(),e)}}}(t);return{get(s,i,n){const o=Ii(t,s,i,n);if(o!==Xi)return o;if("size"===i)return wt(s,x),s.size;if(("string"==typeof i||i===Symbol.iterator)&&L(e,i)&&i in s)return e[i];const r=Reflect.get(s,i,s);return"function"==typeof r?r.bind(s):r}}}const Ki=new WeakSet,Yi=new WeakMap;const Qi=new class{_gci;startGc(t=1e4){}stopGc(){if(this._gci){try{clearInterval(this._gci)}catch{}this._gci=void 0}}constructor(){Ki.add(this),this.startGc()}DisposeMapper=new et;arrayTriggerCache=new Map;ReactiveMap=()=>Yi;activeCallback;isReadonly=!1;superficial=!1;arrayMethods=new Vi(this);arrayHandler={get:Ji(this),set:Hi(this),has:Fi(),deleteProperty:Bi(),ownKeys:ji()};deepHandler={get:Ji(this),set:Hi(this),has:Fi(),deleteProperty:Bi(),ownKeys:ji()};collectionHandler=Gi(this);reactive(t){X(t)||(t={value:t});const e=(s=t,i=Object.getPrototypeOf(s),n="",i&&i.constructor&&(n=i.constructor.name),"Control"===n||"RouteManager"==n||"ServiceManager"==n?0:Object.isExtensible(s)?J.get(Object.prototype.toString.call(s))??0:0);var s,i,n;if(0===e)return t;let o=Yi.get(t);if(o)return o;if(o=Yi.get(P(t)),o)return o;if(2===e){var r=new Proxy(t,this.collectionHandler);return Yi.set(t,r),r}if(Array.isArray(t)){r=new Proxy(t,this.arrayHandler);return Yi.set(t,r),r}r=new Proxy(t,this.deepHandler);return Yi.set(t,r),r}clearModel(t){null!=t&&null!=t&&(Object.keys(t).forEach(e=>{"object"==typeof t[e]&&(Yi.has(t[e])||Yi.has(P(t[e])))&&this.clearModel(t[e]),Yi.delete(P(t[e])),Yi.delete(t[e])}),Yi.delete(P(t)),Yi.delete(t))}track(t,e){wt(t,e)}trigger(t,e,s){bt(t,e)}ArrayTrigger(t,e,...s){this.trigger(t,e,s)}onValueChanged;toRaw(t){return JSON.parse(JSON.stringify(this.deepClone(t)))}deepClone(t){var e,s=this;if(!t)return t;if([Number,String,Boolean].forEach(function(s){t instanceof s&&(e=s(t))}),void 0===e)if("[object Array]"===Object.prototype.toString.call(t))e=[],t.forEach(function(t,i,n){e[i]=s.deepClone(t)});else if("object"==typeof t)if(t.nodeType&&"function"==typeof t.cloneNode)e=t.cloneNode(!0);else if(t.prototype)e=t;else if(t instanceof Date)e=new Date(t);else for(var i in e={},t)e[i]=s.deepClone(t[i]);else e=t;return e}pauseTracking(){z()}enableTracking(){B(!0)}resetTracking(){V()}dispose(){var t=!0;for(this.stopGc();1==t;)if(this.DisposeMapper.size>0){const t=this.DisposeMapper.pop();Yi.delete(t)}else t=!1;this.DisposeMapper.clear(),Ki.delete(this)}},Zi=[],tn=()=>{try{const t=globalThis;return!!t.__MOTIF_DEV__&&(t.__MOTIF_STORE_REGISTRY__!==Zi&&(t.__MOTIF_STORE_REGISTRY__=Zi),!0)}catch{return!1}};function en(t){const e=Qi.reactive(t);try{if(tn()){const s=t?.constructor?.name||"reactive";Zi.push({name:s,value:e,type:"reactive"}),Zi.length>200&&Zi.shift()}}catch{}return e}function sn(t){const e=Qi.reactive(t);try{if(tn()){const s=t?.constructor?.name||"useModel";Zi.push({name:s,value:e,type:"reactive"}),Zi.length>200&&Zi.shift()}}catch{}return e}function nn(t){return Qi.clearModel(t)}function on(t){return Qi.deepClone(t)}function rn(t){const e=new ne(t);try{if(tn()){const t=`signal_${Zi.length}`;Zi.push({name:t,value:e.value,type:"signal"}),Zi.length>200&&Zi.shift()}}catch{}return e}function an(t){const e=new oe(t);try{if(tn()){const t=`computed_${Zi.length}`;Zi.push({name:t,value:e.value,type:"computed"}),Zi.length>200&&Zi.shift()}}catch{}return e}function cn(t){const e=new re(t);try{if(tn()){const t=`lazyComputed_${Zi.length}`;Zi.push({name:t,value:void 0,type:"computed"}),Zi.length>200&&Zi.shift()}}catch{}return e}class ln extends Us{_state;_virtualContent;_topSpacer;_bottomSpacer;_cache=new Map;_view=[];_occurrence=[];_occurrenceKeys=new WeakMap;_isLoadingMore=!1;_emptyRendered=!1;_renderPending=!1;constructor(t){super("div",t),t.className&&this.class.add(t.className),t.style&&Object.assign(this.element.style,t.style),this._state=this.useModel({isLoading:!1,isInitialized:!1,currentPage:0,totalCount:0,hasMore:!0,error:void 0,data:[]}),this._loadMore=this._loadMore.bind(this),this._renderLoadingState=this._renderLoadingState.bind(this),this._renderErrorState=this._renderErrorState.bind(this),this._renderEmptyState=this._renderEmptyState.bind(this),this._loadInitial=this._loadInitial.bind(this),this.renderViewport=this.renderViewport.bind(this),this._makeView()}contentWrapper=new Us;wrapper;_makeView(){this._topSpacer=new Us("div"),this._topSpacer.element.style.cssText="height: 0px;",this._topSpacer.class.add("motif-virtualization-top-spacer"),this._bottomSpacer=new Us("div"),this._bottomSpacer.element.style.cssText="height: 0px;",this._bottomSpacer.class.add("motif-virtualization-bottom-spacer"),this._virtualContent=new Us(document.createComment("")),this.props.mainTemplate?(this.contentWrapper.controls.add(this._topSpacer,this._virtualContent,this._bottomSpacer),this.contentWrapper.onBuilding=t=>{var e=Y(t.parent);e&&(this.wrapper=e,this._loadInitial(),e.style({overflowY:"auto",position:"relative"}),e.motif.on("scroll",this._handleScroll))},this.controls.add(this.props.mainTemplate(this.contentWrapper,this._state))):(this.wrapper=this,this.element.style.cssText="overflow-y: auto; height: 100%; position: relative;",this.controls.add(this._topSpacer,this._virtualContent,this._bottomSpacer),this.motif.on("scroll",this._handleScroll))}_initialLoadStarted=!1;onBuilding(){this.props.mainTemplate||this._initialLoadStarted||(this._initialLoadStarted=!0,this._loadInitial())}onMounted(){this._observeResize(),this._renderPending&&this.renderViewport()}onDisposing(){this._stopResizeObserver(),this._stopDataWatch(),this._clearContent()}_offsets=null;_resizeObserver;_observed;_observedHeight=-1;_fixedHeight(){const t=this.props.itemHeight;return"function"==typeof t?null:t}_computeOffsets(){const t=this.props.itemHeight;if("function"!=typeof t)return void(this._offsets=null);const e=this._view,s=new Array(e.length+1);s[0]=0;for(let i=0;i<e.length;i++){let n=0;try{n=Number(t(e[i],i))}catch{n=0}s[i+1]=s[i]+(n>0&&Number.isFinite(n)?n:0)}this._offsets=s}_layoutOffsets(){return this._offsets&&this._offsets.length===this._view.length+1||this._computeOffsets(),this._offsets}_offsetOf(t){const e=this._fixedHeight();if(null!==e)return t*e;const s=this._layoutOffsets();return s[Math.min(Math.max(0,t),s.length-1)]}_indexAt(t,e){const s=e.length-1;if(s<=0)return 0;let i=0,n=s-1;for(;i<n;){const s=i+n+1>>1;e[s]<=t?i=s:n=s-1}return i}_observeResize(){const t=this.wrapper?.element;if(!t||this._observed===t||this.isDisposed)return;const e=globalThis.ResizeObserver;if("function"!=typeof e)return;this._stopResizeObserver(),this._observedHeight=t.clientHeight;const s=new e(()=>{if(this.isDisposed)return;const e=t.clientHeight;e!==this._observedHeight&&(this._observedHeight=e,this.renderViewport())});s.observe(t),this._resizeObserver=s,this._observed=t}_stopResizeObserver(){try{this._resizeObserver?.disconnect()}catch{}this._resizeObserver=void 0,this._observed=void 0}_loadSeq=0;_dataWatchStop;_reloadScheduled=!1;_reloadTimes=[];_stopDataWatch(){this._dataWatchStop?.(),this._dataWatchStop=void 0}_request(t,e){const s=()=>{try{return Promise.resolve(this.props.dataRequest(t))}catch(t){return Promise.reject(t)}};if(!e||!1===this.props.autoRefresh)return Tt(s);let i;this._stopDataWatch();let n=!0;return this._dataWatchStop=At(()=>{if(n){n=!1;try{this.props.watch?.()}catch(t){M("MJX205",t)}i=s()}else this._scheduleReload()}),i}_scheduleReload(){this._reloadScheduled||this.isDisposed||(this._reloadScheduled=!0,queueMicrotask(()=>{if(this._reloadScheduled=!1,this.isDisposed)return;const t=Date.now();if(this._reloadTimes=this._reloadTimes.filter(e=>t-e<1e3),this._reloadTimes.push(t),this._reloadTimes.length>30)return this._stopDataWatch(),void A("MJX206",[]);this._state.isInitialized?this._reloadLoaded():this._loadInitial()}))}async _reloadLoaded(){const t=++this._loadSeq,e=this.props.pageSize||50,s=this._state.currentPage+1;try{const i=await this._request({page:0,pageSize:e*s,scrollTop:this.wrapper?.element?.scrollTop??0},!0);if(this.isDisposed||t!==this._loadSeq)return;const n=this.wrapper?.element,o=n?.scrollTop??0;this._state.currentPage=s-1,this._state.totalCount=i.totalCount,this._state.hasMore=i.hasMore,this._state.error=void 0,this._state.data=i.items,this._rebuildView(),this._topSpacer.style({height:"0px"}),this._bottomSpacer.style({height:this._offsetOf(this._view.length)+"px"}),this._clearContent(),n&&n.scrollTop!==o&&(n.scrollTop=o),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.error=e,this._renderErrorState(e)}}_handleScroll=(t,e)=>{if(this.renderViewport(),!1===this.props.autoLoad)return;if(!this._state.hasMore||this._isLoadingMore||!this._state.isInitialized)return;const s=this.wrapper.element,i=this._fixedHeight();(null!==i?this._state.data.length*i:this._offsetOf(this._view.length))-(s.scrollTop+s.clientHeight)<(this.props.autoLoadThreshold??100)&&this._loadMore()};async _loadInitial(){const t=++this._loadSeq;this._state.isLoading=!0,this._renderLoadingState();try{const e=this.props.pageSize||50,s=await this._request({page:0,pageSize:e,scrollTop:0},!0);if(this.isDisposed||t!==this._loadSeq)return;this._state.currentPage=0,this._state.totalCount=s.totalCount,this._state.hasMore=s.hasMore,this._state.isInitialized=!0,this._state.isLoading=!1,this._state.error=void 0,this._state.data=s.items,this._clearContent(),this._rebuildView(),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.isLoading=!1,this._state.error=e,this._renderErrorState(e)}}async _loadMore(){if(this._isLoadingMore||!this._state.hasMore||!this._state.isInitialized)return;const t=this._loadSeq;try{this._isLoadingMore=!0;const e=this._state.currentPage+1,s=this.props.pageSize||50,i=await this._request({page:e,pageSize:s,scrollTop:this.wrapper?.element?.scrollTop??0},!1);if(this.isDisposed||t!==this._loadSeq)return;this._state.totalCount=i.totalCount,this._state.currentPage=e,this._state.hasMore=i.hasMore,this._state.error=void 0,this._state.data.push(...i.items),this._rebuildView(),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.error=e,M("MJX207",e)}finally{this._isLoadingMore=!1}}_rebuildView(){this._view=this.props.filter?this.props.filter(this._state.data):this._state.data;const t=new Map;this._occurrence=this._view.map(e=>{if("object"!=typeof e||null===e)return 0;const s=t.get(e)??0;return t.set(e,s+1),s}),"function"==typeof this.props.itemHeight?this._computeOffsets():this._offsets=null}_clearContent(){if(!this._virtualContent)return;const t=this._virtualContent.controls;for(const e of this._cache.values())t.silentUnlink(e),e.isDisposed||e.dispose();this._cache.clear(),t.clear(),this._emptyRendered=!1}renderViewport(){if(this.isDisposed||!this.wrapper||!this._state.isInitialized)return;const t=this.wrapper.element;this._observeResize();const e=this._view,s=e.length;if(0===s)return this._emptyRendered||(this._clearContent(),this._renderEmptyState()),this._topSpacer.style({height:"0px"}),void this._bottomSpacer.style({height:"0px"});this._emptyRendered&&this._clearContent();const i=this._fixedHeight();let n,o,r,a,c;if(null!==i){const e=Math.floor(t.clientHeight/i);if(e<=0)return void(this._renderPending=!t.isConnected);this._renderPending=!1,n=Math.max(0,this.props.overscan??e);const l=Math.min(Math.max(0,Math.floor(t.scrollTop/i)),s-1);o=Math.max(0,l-n),r=Math.min(s,l+e+n),a=o*i,c=Math.max(0,s-r)*i}else{if(t.clientHeight<=0)return void(this._renderPending=!t.isConnected);this._renderPending=!1;const e=this._layoutOffsets(),i=Math.max(0,t.scrollTop),l=i+t.clientHeight,h=this._indexAt(i,e);let u=h;for(;u<s&&e[u]<l;)u++;const d=Math.max(1,u-h);n=Math.max(0,this.props.overscan??d),o=Math.max(0,h-n),r=Math.min(s,Math.max(u,h+1)+n),a=e[o],c=Math.max(0,e[s]-e[r])}const l=new Array(r-o),h=new Set;for(let t=o;t<r;t++){const s=this._rowFor(e[t],t);l[t-o]=s,h.add(s)}const u=this._virtualContent.controls.items;for(const t of u.slice())h.has(t)||this._detachRow(t);for(let t=0;t<l.length;t++){const e=l[t];u[t]!==e&&(e.parent===this._virtualContent&&this._detachRow(e),this._virtualContent.controls.insert(t,e))}this._topSpacer.style({height:a+"px"}),this._bottomSpacer.style({height:c+"px"}),this._evictCache(Math.max(200,3*(r-o))),!1!==this.props.autoLoad&&this._state.hasMore&&!this._isLoadingMore&&s<r+n&&this._loadMore()}_occurrenceKey(t,e){let s=this._occurrenceKeys.get(t);return s||(s=[],this._occurrenceKeys.set(t,s)),s[e]??={}}_rowFor(t,e){const s=this._occurrence[e]??0,i="object"==typeof t&&null!==t?0===s?t:this._occurrenceKey(t,s):e;let n=this._cache.get(i);if(n&&n.isDisposed&&(this._cache.delete(i),n=void 0),n)return this._cache.delete(i),this._cache.set(i,n),n;const o=this.props.itemTemplate(t,e);return n=o instanceof us?o:new Us(o),n.__listItemRef=t,this._cache.set(i,n),n}_detachRow(t){const e=this._virtualContent.controls;if(t.isDisposed)return void e.silentUnlink(t);const s=t.element;if(s.nodeType===Node.COMMENT_NODE){e.silentUnlink(t);const i=t.motif.options.closeFragment,n=t.motif.options.cache??(t.motif.options.cache=document.createDocumentFragment());let o=s;for(;o;){const t=o.nextSibling;if(n.appendChild(o),o===i)break;o=t}zs(t)}else e.silentDetach(t)}_evictCache(t){const e=this.props.cacheSize??t;if(!(this._cache.size<=e))for(const[t,s]of this._cache){if(this._cache.size<=e)break;s.parent!==this._virtualContent&&(this._cache.delete(t),s.isDisposed||s.dispose())}}_renderLoadingState(){if(!this._virtualContent||!this.props.loadingTemplate)return;this._clearContent();const t=this.props.loadingTemplate(this._state);this._virtualContent.controls.add(t)}_renderEmptyState(){if(!this._virtualContent||!this.props.emptyTemplate)return;this._clearContent();const t=this.props.emptyTemplate();this._virtualContent.controls.add(t),this._emptyRendered=!0}_renderErrorState(t){if(this._virtualContent)if(this._clearContent(),this.props.errorTemplate){const e=this.props.errorTemplate(t);this._virtualContent.controls.add(e)}else M("MJX207",t);else M("MJX207",t)}refresh(){return this._state.data=[],this._state.currentPage=0,this._state.isInitialized=!1,this._state.hasMore=!0,this._rebuildView(),this._loadInitial()}setData(t){this._loadSeq++,this._stopDataWatch(),this._state.data=t,this._state.currentPage=0,this._state.totalCount=t.length,this._state.hasMore=!1,this._state.isInitialized=!0,this._state.isLoading=!1,this._state.error=void 0,this._clearContent(),this._rebuildView(),this.renderViewport()}scrollToIndex(t){if(!this.wrapper)return;const e=this._view.length,s=Math.min(Math.max(0,t),Math.max(0,e-1));this.wrapper.element.scrollTop=this._offsetOf(s),this.renderViewport()}getState(){return{...this._state}}}const hn=new Map;class un{descriptors=new Map;reset(){this.descriptors.clear()}addTransient(t,e){this._add(t,e,"transient")}addSingleton(t,e){this._add(t,e,"singleton")}addScoped(t,e){this._add(t,e,"scoped")}_add(t,e,s){const i={token:t,lifetime:s};if(e&&"object"==typeof e&&(e.useClass||e.useFactory||Object.prototype.hasOwnProperty.call(e,"useValue")||Array.isArray(e.deps))){i.useClass=e.useClass,i.useFactory=e.useFactory,i.useValue=e.useValue,i.deps=Array.isArray(e.deps)?e.deps:void 0;try{const s=[i.useClass?"useClass":null,i.useFactory?"useFactory":null,void 0!==i.useValue?"useValue":null].filter(Boolean);s.length>1&&A("MJX410",[this._tokenName(t),s.join(", ")],{token:t}),e.deps&&!Array.isArray(e.deps)&&A("MJX411",[this._tokenName(t)],{token:t})}catch{}if(i.useValue&&"function"==typeof i.useValue.then){const t=i.useValue;i.useFactory=async()=>await t,i.useValue=void 0}}else if("function"==typeof e){if(!function(t){try{return Reflect.construct(String,[],t),!0}catch{return!1}}(e))throw S("MJX413",this._tokenName(t));i.useClass=e}else if(e&&"function"==typeof e.then){const t=e;i.useFactory=async()=>await t}else i.useValue=e;this.descriptors.set(t,i)}_tokenName(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}getDescriptor(t){const e=this.descriptors.get(t);if(e)return e;const s=hn.get(t);return s?(this._add(t,{useClass:t,deps:s.deps,useValue:void 0,useFactory:void 0},s.lifetime||"transient"),this.descriptors.get(t)||null):null}canAutoRegister(t){return!this.descriptors.has(t)&&hn.has(t)}getService(t){return this.getDescriptor(t)}buildServiceProvider(){return new Ce(this)}has(t){return this.descriptors.has(t)}remove(t){return this.descriptors.delete(t)}replace(t,e,s){const i=this.descriptors.get(t),n=s??i?.lifetime??"transient";this._add(t,e,n)}tryAddTransient(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"transient"),!0)}tryAddSingleton(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"singleton"),!0)}tryAddScoped(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"scoped"),!0)}autoRegisterInjectables(){for(const[t,e]of hn.entries())this.descriptors.has(t)||this._add(t,{useClass:t,deps:e.deps,useValue:void 0,useFactory:void 0},e.lifetime||"transient")}}function dn(t,e){const s=(t||"").trim(),i=(e||"").trim(),n=s&&"/"!==s&&s.endsWith("/")?s.slice(0,-1):s;if("/"===i)return n||"/";const o=i?i.startsWith("/")?i:"/"+i:"";return n&&"/"!==n?n+o:o||"/"}let pn=null,fn=!1;function mn(){if(u(),l())try{pn||(pn=document.createElement("div"),pn.style.cssText="position:fixed; left:12px; bottom:12px; right:12px; z-index:2147483647; background:#111; color:#fff; border:1px solid #333; border-radius:8px; box-shadow:0 4px 14px rgba(0,0,0,0.4); display:none;",document.body.appendChild(pn),window.addEventListener("keydown",t=>{try{(t.ctrlKey||t.metaKey)&&"`"===t.key&&(t.preventDefault(),pn&&(fn=!fn,pn.style.display=fn?"block":"none"))}catch{}}),p(t=>{t.type}))}catch{}}class _n{static outlets=new Map;static register(t,e,s){this.outlets.has(t)||this.outlets.set(t,new Map),this.outlets.get(t).set(e,s)}static unregister(t,e){this.outlets.get(t)?.delete(e),0===this.outlets.get(t)?.size&&this.outlets.delete(t)}static find(t,e){if(e&&this.outlets.get(t)?.has(e))return this.outlets.get(t).get(e);const s=this.outlets.get(t);return s&&s.size>0?Array.from(s.values())[0]:null}static findAll(t){return Array.from(this.outlets.get(t)?.values()??[])}}const gn=Symbol.for("RouterView.built");class yn extends Us{constructor(t){super(t)}_navLock=Promise.resolve();_navAbort;get __isRouterView(){return!0}get scopeId(){let t=this.parent,e=[];for(;t;)e.push(t.constructor?.name??""),t=t.parent;return e.join(">")}disposingChilds=!1;previouspage;current=null;_latestNavigateId=0;isBusy=!1;async navigate(t,e=!1){await wi(this,t,e)}async disposeTarget(t){await vi(t)}onBuilt(){try{_n.register(this.props.name??"default",this.scopeId,this);let t=this.parent;for(;t;)t.motif.trigger(gn,this),t=t.parent}catch{}}onDisposed(){try{_n.unregister(this.props.name??"default",this.scopeId)}catch{}}}const vn="motifjs:scroll",wn=["wheel","touchstart","keydown","mousedown"];class bn{options;viewport;positions=new Map;currentKey="";visited=!1;restoring=!1;cancelFrame=null;disarmAbort=null;offs=[];locationAnchor=!0;constructor(t={},e){this.options=t,this.viewport=e??(t.container?function(t){const e=Sn(),s=()=>{try{return"string"==typeof t?document.querySelector(t):"function"==typeof t?t()??null:t}catch{return null}};return{scrollTop:()=>{const t=s();return t?t.scrollTop||0:e.scrollTop()},scrollTo:t=>{const i=s();if(i)try{i.scrollTop=t}catch{}else e.scrollTo(t)},scrollToAnchor:t=>e.scrollToAnchor(t)}}(t.container):Sn()),this.load();try{"undefined"!=typeof history&&"scrollRestoration"in history&&(history.scrollRestoration="manual")}catch{}"undefined"!=typeof window&&(this.offs.push(An(window,"pagehide",()=>this.persistNow())),this.offs.push(An(document,"visibilitychange",()=>{"hidden"===document.visibilityState&&this.persistNow()})))}leaving(){this.cancelRestore(),this.visited&&(this.remember(this.currentKey,this.viewport.scrollTop()),this.persist())}arrived(t){this.visited=!0;const{path:e,hash:s}=Mn(t);this.currentKey=this.keyOf(e),this.restore(this.currentKey,!1===this.options.anchor?"":s||(this.locationAnchor?function(){try{const t=location?.hash??"";return t.length>1?Cn(t.slice(1)):""}catch{return""}}():""))}saved(t){return this.positions.get(this.keyOf(Mn(t).path))??0}dispose(){this.cancelRestore(),this.persistNow();for(const t of this.offs.splice(0))t();this.positions.clear()}keyOf(t){return(this.options.key?this.options.key(t):t)||"/"}remember(t,e){const s=this.options.limit??60;for(this.positions.delete(t),this.positions.set(t,Math.max(0,Math.round(e)));this.positions.size>s;){const t=this.positions.keys().next();if(t.done)break;this.positions.delete(t.value)}}restore(t,e){this.cancelRestore();const s=this.positions.get(t)??0;if(!e&&s<=0)return void(!1!==this.options.top&&this.viewport.scrollTo(0));this.restoring=!0;const i=this.options.settleMs??1200,n=Date.now(),o=()=>{this.cancelFrame=null;if((e?this.viewport.scrollToAnchor(e):this.reached(s))||Date.now()-n>=i)return this.cancelRestore(),void this.remember(t,this.viewport.scrollTop());this.armAbort(),this.cancelFrame=function(t){if("function"!=typeof requestAnimationFrame){const e=setTimeout(t,16);return()=>clearTimeout(e)}const e=requestAnimationFrame(t);return()=>cancelAnimationFrame(e)}(o)};o()}reached(t){return this.viewport.scrollTo(t),this.viewport.scrollTop()>=t-1}armAbort(){if(this.disarmAbort||"undefined"==typeof window)return;const t=()=>this.cancelRestore(),e=wn.map(e=>An(window,e,t,{passive:!0}));this.disarmAbort=()=>{for(const t of e)t()}}cancelRestore(){this.cancelFrame?.(),this.cancelFrame=null,this.disarmAbort?.(),this.disarmAbort=null,this.restoring=!1}persistNow(){this.visited&&!this.restoring&&this.remember(this.currentKey,this.viewport.scrollTop()),this.persist()}get storage(){if(!1===this.options.persist)return null;try{return"undefined"==typeof sessionStorage?null:sessionStorage}catch{return null}}persist(){const t=this.storage;if(t)try{t.setItem(vn,JSON.stringify([...this.positions]))}catch{}}load(){const t=this.storage;if(t)try{const e=t.getItem(vn);if(!e)return;const s=JSON.parse(e);if(!Array.isArray(s))return;for(const t of s){if(!Array.isArray(t)||"string"!=typeof t[0])continue;const e=Number(t[1]);Number.isFinite(e)&&e>0&&this.positions.set(t[0],e)}}catch{}}}function Sn(){return{scrollTop:()=>{try{return window.scrollY||document.documentElement?.scrollTop||0}catch{return 0}},scrollTo:t=>{try{window.scrollTo(0,t)}catch{}},scrollToAnchor:t=>{try{const e=document.getElementById(t);return!!e&&(e.scrollIntoView(),!0)}catch{return!1}}}}function Mn(t){const e=t.indexOf("#");return e<0?{path:t,hash:""}:{path:t.slice(0,e)||"/",hash:Cn(t.slice(e+1))}}function Cn(t){try{return decodeURIComponent(t)}catch{return t}}function An(t,e,s,i){try{return t.addEventListener(e,s,i),()=>{try{t.removeEventListener(e,s,i)}catch{}}}catch{return()=>{}}}const kn="motifjs:stack",Dn=30,En=t=>!!t&&1===t.nodeType&&!!t.style;function Tn(t,e){const s=t?.element;if(t&&!t.isDisposed&&En(s)){try{s.setAttribute("data-nav-direction",e)}catch{}t.motif.options.transition._markedDirection=!0}}function xn(t){const e=t?.motif?.options?.transition;if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function On(t){return t.getAttribute("style")}function Nn(t,e){try{t.setAttribute("style",e??""),null===e&&t.removeAttribute("style")}catch{}}function Pn(t){const e=[];try{const s=t=>{const s=t.scrollTop||0,i=t.scrollLeft||0;(s||i)&&e.push([t,s,i])};s(t),t.querySelectorAll("*").forEach(s)}catch{}return e}function Ln(t){for(const[e,s,i]of t)try{e.scrollTop=s,e.scrollLeft=i}catch{}}function Xn(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function Rn(t,e,s,i){if("function"!=typeof t.animate||s<=0)return Promise.resolve();try{const n=t.animate(e,{duration:s,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)",fill:"forwards"});return i.push(n),n.finished.then(()=>{},()=>{})}catch{return Promise.resolve()}}function In(t,e,s){t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.margin="0px",t.style.boxSizing="border-box";const i=e.getBoundingClientRect(),n=t.getBoundingClientRect();if(t.style.top=i.top-n.top+"px",t.style.left=i.left-n.left+"px",t.style.width=i.width+"px",t.style.height=i.height+"px",t.style.pointerEvents="none",t.style.zIndex=s?"2":"0",!s){let t="";try{t=getComputedStyle(e).position}catch{}t&&"static"!==t||(e.style.position="relative"),e.style.zIndex="1"}}class Jn{retainAttached;depth;persist;animation;duration;swipe;session=null;entries=new Map;uris=new Map;loaded=null;current=null;currentTop=null;offs=[];gesture=null;gestureCommitted=!1;awaitingGestureResult=!1;disposed=!1;constructor(t){const e=!0===t?{}:t;this.retainAttached=!0===e.retain,this.depth=Math.max(0,Math.floor(e.depth??5)),this.persist=!0===e.persist,this.animation=e.animation??"none",this.duration=Math.max(0,e.duration??300);const s=e.swipeBack;this.swipe=s?{edge:"object"==typeof s&&"number"==typeof s.edge&&s.edge>0?s.edge:24,threshold:"object"==typeof s&&"number"==typeof s.threshold&&s.threshold>0?s.threshold:.35}:null,this.persist&&this.load(),this.swipe&&this.installSwipe()}get retainedCount(){return this.entries.size}isRetaining(t){return!!t.from&&!!t.to&&t.from.session===t.to.session&&t.to.index>t.from.index}begin(t){const e=t.to;if(e){if(this.session!==e.session){if(this.disposeAllEntries(),this.uris.clear(),this.session=e.session,this.loaded&&this.loaded.session===e.session)for(const[t,e]of this.loaded.uris)this.uris.set(t,e);this.loaded=null}if("push"===t.direction)this.truncate(e.index);else if("replace"===t.direction){const t=this.entries.get(e.index);t&&(this.entries.delete(e.index),this.disposeEntry(t))}}}take(t){if(!t||t.session!==this.session)return null;const e=this.entries.get(t.index);return e?(this.entries.delete(t.index),e.pendingDetach=!1,e):null}retain(t,e,s,i,n,o,r){const a=i[n],c=a.element,l={point:t,uri:e,chain:s.slice(),instances:i.slice(),top:a,topIndex:n,outlet:o,attached:!1,hidden:!1,pendingDetach:!1,saved:null,scroll:En(c)?Pn(c):[]};if(this.retainAttached&&En(c))l.attached=!0,r||this.hide(l);else if(r)l.pendingDetach=!0;else try{a.parent?.controls.silentDetach(a)}catch{}const h=this.entries.get(t.index);return h&&h!==l&&this.disposeEntry(h),this.entries.set(t.index,l),this.evict(),l}settle(t){if(!t.top.isDisposed&&this.entries.get(t.point.index)===t)if(t.attached)this.hide(t);else if(t.pendingDetach){t.pendingDetach=!1;try{t.top.parent?.controls.silentDetach(t.top)}catch{}}}hide(t){if(!t.attached||t.hidden)return;const e=t.top.element;if(En(e)){t.saved={style:On(e),inert:e.hasAttribute("inert"),ariaHidden:e.getAttribute("aria-hidden")};try{e.style.setProperty("display","none","important"),e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")}catch{}t.hidden=!0;try{zs(t.top)}catch{}}}reveal(t){const e=t.top.element;if(t.hidden&&t.saved&&En(e)){Nn(e,t.saved.style);try{t.saved.inert||e.removeAttribute("inert"),null===t.saved.ariaHidden?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",t.saved.ariaHidden)}catch{}}t.hidden=!1,t.saved=null}restoreScroll(t){Ln(t.scroll)}record(t,e){if(t.to&&t.to.session===this.session){if(this.uris.set(t.to.index,t.uri),"push"===t.direction)for(const e of Array.from(this.uris.keys()))e>t.to.index&&this.uris.delete(e);this.current=t.to}this.currentTop=e,this.save()}describe(){const t=this.current?.index;return Array.from(this.uris.entries()).sort((t,e)=>t[0]-e[0]).map(([e,s])=>({index:e,uri:s,current:e===t,retained:this.entries.has(e)}))}get gestureCommitPending(){return this.gestureCommitted}consumeGestureCommit(){const t=this.gestureCommitted;return this.gestureCommitted=!1,t}traversalSettled(t){if(!this.awaitingGestureResult)return;this.awaitingGestureResult=!1;const e=this.gesture;if(!t)return this.gesture=null,void(this.gestureCommitted=!1);this.gestureCommitted=!1,e&&this.settleGesture(e,!1)}async transition(t,e,s){if(this.consumeGestureCommit())return;if("none"===this.animation||!this.animation)return;if("push"!==t&&"back"!==t&&"forward"!==t)return;const i=e?.element,n=s?.element;if(!(En(i)&&En(n)&&i.isConnected&&n.isConnected))return;if(Xn())return;const o="back"===t,r=On(i),a=On(n),c=[];try{if(In(n,i,o),"function"==typeof this.animation){const e={direction:t,entering:i,leaving:n};await this.animation(e)}else{const t=this.duration;o?await Promise.all([Rn(n,[{transform:"translateX(0)"},{transform:"translateX(100%)"}],t,c),Rn(i,[{transform:"translateX(-30%)"},{transform:"translateX(0)"}],t,c)]):await Promise.all([Rn(i,[{transform:"translateX(100%)"},{transform:"translateX(0)"}],t,c),Rn(n,[{transform:"translateX(0)"},{transform:"translateX(-30%)"}],t,c)])}}catch(t){M("MJX308",t)}finally{for(const t of c)try{t.cancel()}catch{}Nn(i,r),Nn(n,a)}}async disposeEntry(t){const e=t.top;if(e&&!e.isDisposed)try{await vi(e,{deep:!0,skipLeaveTransition:!0})}catch(t){M("MJX307",t)}}async dispose(){if(!this.disposed){this.disposed=!0;for(const t of this.offs.splice(0))try{t()}catch{}this.gesture&&(this.endGestureListeners(this.gesture),this.gesture=null),await this.disposeAllEntries(),this.uris.clear(),this.current=null,this.currentTop=null}}async disposeAllEntries(){const t=Array.from(this.entries.values());this.entries.clear();for(const e of t)await this.disposeEntry(e)}truncate(t){for(const[e,s]of Array.from(this.entries))e>=t&&(this.entries.delete(e),this.disposeEntry(s))}evict(){for(;this.entries.size>this.depth;){let t=1/0;for(const e of this.entries.keys())e<t&&(t=e);const e=this.entries.get(t);this.entries.delete(t),e&&this.disposeEntry(e)}}load(){try{if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(kn);if(!t)return;const e=JSON.parse(t);if(!e||"string"!=typeof e.session||!Array.isArray(e.uris))return;const s=[];for(const t of e.uris)Array.isArray(t)&&"number"==typeof t[0]&&"string"==typeof t[1]&&s.push([t[0],t[1]]);this.loaded={session:e.session,uris:s}}catch{}}save(){if(this.persist&&this.session)try{if("undefined"==typeof sessionStorage)return;sessionStorage.setItem(kn,JSON.stringify({session:this.session,uris:Array.from(this.uris.entries())}))}catch{}}installSwipe(){if("undefined"==typeof document)return;const t=t=>this.onTouchStart(t);try{document.addEventListener("touchstart",t,{passive:!0}),this.offs.push(()=>{try{document.removeEventListener("touchstart",t)}catch{}})}catch{}}onTouchStart(t){if(this.disposed||this.gesture||this.awaitingGestureResult||!this.swipe)return;if(!t.touches||1!==t.touches.length)return;const e=t.touches[0];if(!e||e.clientX>this.swipe.edge)return;if(!this.current||this.current.index<=0)return;const s=this.currentTop?.element;if(!En(s)||!s.isConnected)return;const i={startX:e.clientX,startY:e.clientY,lastX:e.clientX,samples:[[e.clientX,Date.now()]],dragging:!1,width:0,top:s,topSaved:null,under:null,underSaved:null,offs:[]},n=t=>this.onTouchMove(i,t),o=()=>this.onTouchEnd(i);try{document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",o),document.addEventListener("touchcancel",o),i.offs.push(()=>{try{document.removeEventListener("touchmove",n)}catch{}try{document.removeEventListener("touchend",o)}catch{}try{document.removeEventListener("touchcancel",o)}catch{}})}catch{}this.gesture=i}endGestureListeners(t){for(const e of t.offs.splice(0))try{e()}catch{}}beginDrag(t){t.dragging=!0,t.width=t.top.getBoundingClientRect().width||("undefined"!=typeof window?window.innerWidth:0)||1,t.topSaved=On(t.top);const e=this.current,s=e?this.entries.get(e.index-1)??null:null;if(s&&s.attached&&En(s.top.element)&&s.top.element.isConnected){const e=s.top.element;t.under=s,t.underSaved=On(e),s.saved&&Nn(e,s.saved.style),In(e,t.top,!1),e.style.transform="translateX(-30%)",Ln(s.scroll)}t.top.style.willChange="transform"}applyDrag(t,e){const s=Math.min(1,Math.max(0,e/t.width));t.top.style.transform=`translateX(${Math.max(0,e)}px)`,t.under&&(t.under.top.element.style.transform=`translateX(-${Dn*(1-s)}%)`)}onTouchMove(t,e){const s=e.touches&&e.touches[0];if(!s)return;const i=s.clientX-t.startX,n=s.clientY-t.startY;if(!t.dragging){if(Math.abs(i)<8&&Math.abs(n)<8)return;if(i<=0||Math.abs(n)>Math.abs(i))return this.endGestureListeners(t),void(this.gesture=null);this.beginDrag(t)}if(e.cancelable)try{e.preventDefault()}catch{}const o=Date.now();for(t.lastX=s.clientX,t.samples.push([s.clientX,o]);t.samples.length>2&&o-t.samples[0][1]>100;)t.samples.shift();this.applyDrag(t,i)}onTouchEnd(t){if(this.endGestureListeners(t),!t.dragging)return void(this.gesture=null);const e=t.lastX-t.startX,s=e/t.width,i=t.samples[0],n=t.samples[t.samples.length-1],o=n&&i?n[1]-i[1]:0,r=n?Date.now()-n[1]:1/0,a=o>=16&&r<=50?(n[0]-i[0])/o:0,c=s>this.swipe.threshold||a>.5&&e>0;this.settleGesture(t,c)}async settleGesture(t,e){const s=[],i=t.top,n=t.under?t.under.top.element:null,o=Xn()?0:Math.max(0,Math.round(.6*this.duration)),r=i.style.transform||"translateX(0px)",a=n?.style.transform||"translateX(-30%)";if(e){await Promise.all([Rn(i,[{transform:r},{transform:"translateX(100%)"}],o,s),n?Rn(n,[{transform:a},{transform:"translateX(0)"}],o,s):Promise.resolve()]),i.style.transform="translateX(100%)",n&&(n.style.transform="translateX(0px)");for(const t of s)try{t.cancel()}catch{}this.gestureCommitted=!0,this.awaitingGestureResult=!0;try{window.history.back()}catch{this.traversalSettled(!0)}}else{await Promise.all([Rn(i,[{transform:r},{transform:"translateX(0)"}],o,s),n?Rn(n,[{transform:a},{transform:"translateX(-30%)"}],o,s):Promise.resolve()]);for(const t of s)try{t.cancel()}catch{}Nn(i,t.topSaved),n&&t.under&&Nn(n,t.underSaved),this.gesture===t&&(this.gesture=null)}}}class Hn{source;constructor(t){this.source=t,this.tokens=[]}currentColumn=0;tokens=[];addToken(t){this.tokens.push(t)}parse(){for(this.source.startsWith("/")||(this.source="/"+this.source);this.source.length>1&&this.source.endsWith("/");)this.source=this.source.slice(0,-1);var t="static",e=-1,s=0,i=-1;for(this.tokens=[],this.currentColumn=0;this.currentColumn<this.source.length;){var n=this.codePointAt(this.source,this.currentColumn),o=this.tokens[e];switch(n){case 47:i++,(void 0===o||o.input.length>1)&&(this.tokens.push({default:"",input:"/",isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:s,sectionIndex:i}),e=this.tokens.length-1);break;case 123:s++;let n,r,a=!1,c=!1;if(this.tokens.length>0){const t=this.tokens[this.tokens.length-1];t&&"static"===t.type&&"/"===t.input&&!t.consumed?(a=!0,n=this.tokens.length-1):t&&"static"===t.type&&"/"!==t.input&&t.sectionIndex===i&&!t.consumed&&(c=!0,r=this.tokens.length-1)}this.tokens.push({default:void 0,input:"",isOptinal:!1,regexs:[],type:"parameter",parameterName:"",parameterIndex:s,sectionIndex:i,hasLeadingSlash:a,leadingSlashTokenIndex:n,hasLeadingStatic:c,leadingStaticTokenIndex:r}),e=this.tokens.length-1,t="parameter";break;case 125:t="static",e=-1;break;case 58:t="defaultValue";break;case 63:o&&(o.isOptinal=!0);break;default:const l=this.source[this.currentColumn];o?"parameter"===t?o.parameterName=`${o.parameterName+l}`:"defaultValue"===t?o.default=`${(o.default??"")+l}`:"static"===o.type?o.input=`${o.input+l}`:(this.tokens.push({default:void 0,input:l,isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:s,sectionIndex:i}),e=this.tokens.length-1):(this.tokens.push({default:void 0,input:l,isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:s,sectionIndex:i}),e=this.tokens.length-1)}this.currentColumn++}const r=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(const t of this.tokens){if("parameter"===t.type&&t.isOptinal&&t.hasLeadingSlash&&"number"==typeof t.leadingSlashTokenIndex){const e=this.tokens[t.leadingSlashTokenIndex];e&&"static"===e.type&&"/"===e.input&&(e.consumed=!0)}if("parameter"===t.type&&t.isOptinal&&t.hasLeadingStatic&&"number"==typeof t.leadingStaticTokenIndex){const e=this.tokens[t.leadingStaticTokenIndex];e&&"static"===e.type&&e.input&&e.sectionIndex===t.sectionIndex&&(e.consumed=!0)}}const a=t=>{const e=this.tokens[t];for(let s=t+1;s<this.tokens.length;s++){const t=this.tokens[s];if("static"===t.type&&t.sectionIndex===e.sectionIndex&&t.input&&"/"!==t.input)return t.input[0];if("static"===t.type&&"/"===t.input)break}},c=(t,e)=>{const s=a(t);var i;return`(${s?`[^${i=r(s),i.replace(/[\\\]\^\-]/g,"\\$&")}]`:"[\\w\\d\\_\\-\\%\\&\\$\\+\\#\\,\\.\\{\\}\\(\\)\\[\\]\\?\\:\\=\\;\\'\\\"\\~\\\\]"}${e?"{0,255}":"{1,255}"})`};let l="^";for(let t=0;t<this.tokens.length;){const e=this.tokens[t];if("static"===e.type&&"/"===e.input){e.consumed||(l+="/"),t++;continue}const s=t;let i=t;for(;i<this.tokens.length;){const t=this.tokens[i];if("static"===t.type&&"/"===t.input&&i!==s)break;if("static"===t.type&&"/"===t.input&&i===s){i++;break}i++}const n={};let o=s;for(;o<i;){if(n[o]){o++;continue}const t=this.tokens[o];if("static"!==t.type){if(t.isOptinal&&!t.hasLeadingStatic){const e=o;let s=!1;for(let t=e+1;t<i;t++){const e=this.tokens[t],i=this.tokens[t+1];if(e&&"static"===e.type&&i&&"parameter"===i.type&&i.isOptinal&&i.hasLeadingStatic&&"number"==typeof i.leadingStaticTokenIndex&&i.leadingStaticTokenIndex===t){s=!0;break}if(e&&"static"===e.type&&"/"===e.input)break}let a="";t.hasLeadingSlash&&(a+="/"),a+=c(e,!s),n[e]=!0;let h=e+1;for(;h<i;){const t=this.tokens[h];if("static"===t.type&&this.tokens[h+1]&&"parameter"===this.tokens[h+1].type){const e=this.tokens[h+1];if(e.isOptinal&&e.hasLeadingStatic&&"number"==typeof e.leadingStaticTokenIndex&&e.leadingStaticTokenIndex===h){a+=`(?:${r(t.input)}${c(h+1,!0)})?`,n[h]=!0,n[h+1]=!0,h+=2;continue}}break}l+=`(?:${a})?`,o=h;continue}{const e=c(o,t.isOptinal);if(t.isOptinal)if(t.hasLeadingSlash)l+=`(?:/${e})?`;else if(t.hasLeadingStatic&&"number"==typeof t.leadingStaticTokenIndex){const s=this.tokens[t.leadingStaticTokenIndex];l+=`(?:${s&&"static"===s.type?r(s.input):""}${e})?`}else l+=`(?:${e})?`;else l+=e;n[o]=!0,o++}}else t.consumed||(l+=r(t.input)),n[o]=!0,o++}t=i}return l+="$",new RegExp(l,"i")}parameters={};exist(t,e){const s=t.indexOf("#"),i=s>=0?t.substring(0,s):t;let n=i,o="";const r=i.indexOf("?");for(r>=0&&(n=i.substring(0,r),o=i.substring(r+1));n.length>1&&n.endsWith("/");)n=n.slice(0,-1);var a=this.parse().exec(n);if(a){a&&a.length;var c=[];if(this.parameters={},a?.forEach((t,e)=>{c.push(t)}),o&&o.length){const t=new URLSearchParams(o),e=new Map;t.forEach((t,s)=>{const i=e.get(s)||[];i.push(t),e.set(s,i)}),e.forEach((t,e)=>{1===t.length?this.parameters[e]=t[0]:this.parameters[e]=t})}else if(e){const t=new URLSearchParams(e),s=new Map;t.forEach((t,e)=>{const i=s.get(e)||[];i.push(t),s.set(e,i)}),s.forEach((t,e)=>{1===t.length?this.parameters[e]=t[0]:this.parameters[e]=t})}if(a.input===c[0])return a?.forEach((t,e)=>{if(0!==e){var s=this.tokens.find(t=>t.parameterIndex==e);if(s){let e=t;if((void 0===e||""===e)&&s.isOptinal){e=void 0===s.default||""===s.default?void 0:s.default}this.parameters[s.parameterName]=void 0===e?void 0:e}}}),!0}return!1}codePointAt=String.prototype.codePointAt?(t,e)=>t.codePointAt(e):function(t,e){const s=t.length;if(e<0||e>=s)return;const i=t.charCodeAt(e);if(i>=55296&&i<=56319&&s>e+1){const s=t.charCodeAt(e+1);if(s>=56320&&s<=57343)return 1024*(i-55296)+s-56320+65536}return i}}function jn(t){let e=0,s=0;for(const i of(t||"").split("/"))i&&(i.startsWith("{")&&i.endsWith("}")?s++:e++);return{statics:e,params:s}}function Fn(t,e){const s=t.chain.length-e.chain.length;if(0!==s)return s;const i=jn(t.fullPath),n=jn(e.fullPath);return i.statics!==n.statics?n.statics-i.statics:i.params!==n.params?i.params-n.params:e.fullPath.length-t.fullPath.length}class Bn{routes;records=[];routesMap=new Map;constructor(t){this.routes=t,this.build()}build(){this.records=[],this.routesMap.clear();for(const t of this.routes)this.walk([],"",t);this.records.sort(Fn)}walk=(t,e,s,i=!1)=>{const n=this.joinPaths(e,s.path);if(!i){const t=s.fullPath;(null==t||"string"==typeof t&&""===t.trim())&&(s.fullPath=n),null!=s.name&&this.routesMap.set(s.name,s)}const o=[...t,s],r=[{path:n,isAlias:i},...(null==s.alias?[]:Array.isArray(s.alias)?s.alias:[s.alias]).map(t=>({path:this.joinPaths(e,t),isAlias:!0}))];for(const t of r)if(this.records.push({fullPath:t.path,chain:o,leaf:s,scanner:new Hn(t.path),aliasOf:t.isAlias?s.fullPath??null:null}),s.childs&&s.childs.length)for(const e of s.childs)this.walk(o,t.path,e,t.isAlias)};joinPaths(t,e){e=e||"";const s=(t=t||"")&&"/"!==t&&t.endsWith("/")?t.slice(0,-1):t;if("/"===e)return s||"/";const i=e?e.startsWith("/")?e:"/"+e:"";return s&&"/"!==s?s+i:i||"/"}}class zn{stack=null;_revealed=new Set;root;application;routingModule;_previousPath=null;_previousInstances=[];register(t,e,s){this.root=t,this.application=e,this.routingModule=s}controlCache=new Map;async evict(t){const e=t?[t]:Array.from(this.controlCache.keys());for(const t of e){const e=this.controlCache.get(t);if(e&&!e.isDisposed){if(!this._previousInstances.includes(e)){this.controlCache.delete(t);try{await e.dispose()}catch(t){M("MJX307",t)}}}else this.controlCache.delete(t)}}async dispose(){this._navVersion++,this._previousPath=null,this._previousInstances=[],this._revealed.clear();const t=this.stack;if(this.stack=null,t)try{await t.dispose()}catch{}await this.evict()}generatePathString(t,e){const s=t.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}")){const s=t.slice(1,-1);let[i,n]=s.split(":");i.endsWith("?")&&(i=i.slice(0,-1));const o=e[i];return null!=o&&""!==o?String(o):n??""}return t}).filter(t=>""!==t).join("/");return t.startsWith("/")?"/"+(s||""):s}_navVersion=0;_pendingActivate=new Set;async execute(t,e,s){s??={target:t,chain:t.chain.map(e=>this.generatePathString(e.path,t.params)||""),direction:void 0,state:void 0};const i=this._rootProvider(),n={provider:i,scope:i?._beginNavigation(),route:s,committed:!1,suppressed:[]};try{await this._execute(t,e,n)}finally{!n.committed&&n.scope&&i._abandonNavigation(n.scope);for(const t of n.suppressed)t.isDisposed||(t.motif.options.transition._suppressEnter=!1)}}_commitNavigation(t){t.committed||(t.committed=!0,t.scope&&t.provider._commitNavigation(t.scope),this.application?._routerState.commit(t.route))}async _execute(t,e,s){const i=++this._navVersion,n=this.stack&&e&&e.to?this.stack:null;n&&n.begin(e);const o=n?n.take(e.to):null,r=new Array(t.chain.length),a=!(!this._previousPath||this._previousPath.route!==t.route||null==this._previousPath.route&&this._previousPath.fullPath!==t.fullPath);var c=!(!this._previousPath||this._previousPath.uri!==t.uri);let l=!1;if(a&&t.route){const e=this._previousPath.params||{},s=t.params||{};let i=!1;const o=new Set([...Object.keys(e),...Object.keys(s)]);for(const t of o)if(e[t]!==s[t]){i=!0;break}if(i){l=!0;const i=t.route;if(i&&!i.keepAlive&&this.controlCache.has(i))if(n)this.controlCache.delete(i);else{const t=this.controlCache.get(i);if(t&&"function"==typeof t.dispose&&!t.isDisposed)try{await t.dispose()}catch{}this.controlCache.delete(i)}try{const i=this.routingModule.getHooks?.()||void 0,n=t.route.onUpdate||i?.onUpdate;if(n){const i={from:{path:this._previousPath.uri||this._previousPath.fullPath||"",params:e},to:{path:t.uri||t.fullPath||"",params:s},meta:t.meta??t.extend};await n(i)}}catch(t){M("MJX306",t,"onUpdate")}}}if((!a||l)&&t.route)try{const e=t.meta??t.extend,s={path:t.uri||t.fullPath||"",params:t.params,meta:e,to:{path:t.uri||t.fullPath||"",params:t.params,meta:e}},i=this.routingModule.getHooks?.()||void 0,n=t.route.onEntering||i?.onEntering;n&&await n(s)}catch(t){M("MJX306",t,"onEntering")}const h=[];for(let e=0;e<t.chain.length;e++){const i=t.chain[e],n=o&&o.chain[e]===i?o.instances[e]:void 0;if(!n||n.isDisposed||i.keepAlive)if(this.controlCache.has(i)){let t=this.controlCache.get(i);if(!t||t.isDisposed){this.controlCache.delete(i);const t=this.createInstance(i.control,s.scope,s.route).then(t=>{this.controlCache.set(i,t),r[e]=t});h.push(t)}else r[e]=t,i.keepAlive&&!this._previousInstances.includes(t)&&this._pendingActivate.add(t)}else{const t=this.createInstance(i.control,s.scope,s.route).then(t=>{this.controlCache.set(i,t),r[e]=t});h.push(t)}else r[e]=n,this.controlCache.set(i,n)}h.length&&await Promise.all(h);let u=null,d=null;const p=this._previousInstances;if(n){const s=!!n.animation&&"none"!==n.animation&&("push"===e.direction||"back"===e.direction||"forward"===e.direction);if(d={animate:s,pages:!s&&!n.gestureCommitPending,direction:e.direction},u=await this._stackLeave(t.chain,r,e,n,d),o){const t=o.top;!t.isDisposed&&o.outlet&&t.parent===o.outlet&&(n.reveal(o),o.outlet.current=t,o.outlet.previouspage=t,this._revealed.add(t)),t.isDisposed||this._pendingActivate.add(t)}}else await this.disposeFromDivergencePoint(t.chain,r);const f=d?r.filter(t=>t&&!p.includes(t)):[];if(d){for(const t of p)xn(t);for(const t of f)d.pages?Tn(t,d.direction):(t.motif.options.transition._suppressEnter=!0,s.suppressed.push(t))}if(i===this._navVersion&&this._commitNavigation(s),await this.mountChain(r,t.chain,this.root,i),d?.pages){o?.attached&&!o.top.isDisposed&&gi(o.top,"enter")&&o.top.motif.options.transition.enterTransition(()=>{});for(const t of f)t.isBuilt&&!gi(t,"enter")&&xn(t)}let m=null;if(n){o&&n.restoreScroll(o);for(let t=0;t<r.length;t++)if(r[t]&&r[t]!==p[t]){m=r[t];break}m||(m=r.length?r[r.length-1]:null),n.record(e,m)}if(!c&&t.route)try{const e=t.meta??t.extend,s={path:t.uri||t.fullPath||"",params:t.params,meta:e,to:{path:t.uri||t.fullPath||"",params:t.params,meta:e}},i=this.routingModule.getHooks?.()||void 0,n=t.route?.onEnter||i?.onEnter;n&&await n(s)}catch(t){M("MJX306",t,"onEnter")}if(this._previousPath=t,this._previousInstances=r.slice(),n&&u){u.top&&i===this._navVersion&&(u.retained||u.disposeAfter.length)&&await n.transition(e.direction,m,u.top),u.retained&&n.settle(u.retained);for(const t of u.disposeAfter)try{t.isDisposed||await t.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){M("MJX307",t)}}}async _stackLeave(t,e,s,i,n){const o={top:null,retained:null,disposeAfter:[]},r=this._previousPath?.chain??[],a=this._previousInstances;if(!a.length)return o;let c=-1;for(let t=0;t<a.length;t++){const s=a[t];if(s&&!e.includes(s)){c=t;break}}if(c<0)return o;a[c].isDisposed||Se(a[c]);const l=t=>{const e=t-1>=0?a[t-1]:this.root,s=r[t]?.extend?.targetOutlet||"default";try{return e&&!e.isDisposed?this.findRouterView(e,s):null}catch{return null}},h=a[c],u=r[c];if(i.isRetaining(s)&&h&&!h.isDisposed&&!u?.keepAlive){const t=l(c);t&&t.current===h&&(t.current=null,t.previouspage=null),yi(h),n.pages&&gi(h,"leave")&&(Tn(h,n.direction),await(d=h,new Promise(t=>{let e=!1;const s=()=>{e||(e=!0,t())};try{const t=d.motif.options.transition.leaveTransition(s);t&&"function"==typeof t.addEventListener&&t.addEventListener("cancel",s)}catch{s()}})),xn(h));for(let t=c;t<a.length;t++){const e=r[t];e&&!e.keepAlive&&this.controlCache.get(e)===a[t]&&this.controlCache.delete(e)}return o.top=h,o.retained=i.retain(s.from,this._previousPath?.uri??"",r,a,c,t,n.animate),o}var d;const p=n.animate&&!!h&&!h.isDisposed&&!u?.keepAlive;for(let t=a.length-1;t>=c;t--){const s=a[t],i=r[t];if(s&&!e.includes(s))if(s.isDisposed)i&&this.controlCache.get(i)===s&&this.controlCache.delete(i);else if(p&&t>c&&!i?.keepAlive)i&&this.controlCache.get(i)===s&&this.controlCache.delete(i);else try{const e=l(t);if(e&&e.current===s&&(e.current=null,e.previouspage=null),i?.keepAlive){yi(s);try{s.parent?.controls.silentDetach(s)}catch{}this.controlCache.has(i)||this.controlCache.set(i,s),zs(s)}else i&&this.controlCache.get(i)===s&&this.controlCache.delete(i),p&&t===c?(o.top=s,o.disposeAfter.push(s)):n.pages?(Tn(s,n.direction),await s.dispose()):await s.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){M("MJX307",t)}}return o}async disposeFromDivergencePoint(t,e){if(!this._previousPath||!this._previousInstances.length)return;const s=this._previousPath.chain,i=this._previousInstances;let n=0;const o=Math.min(s.length,t.length);for(let e=0;e<o&&s[e]===t[e];e++)n=e+1;for(let t=i.length-1;t>=n;t--){const e=i[t],n=s[t];if(e&&!e.isDisposed)try{const s=t-1,o=s>=0?i[s]:this.root,r=n?.extend?.targetOutlet||"default",a=this.findRouterView(o,r);if(a&&a.current===e&&(a.current=null,a.previouspage=null),n?.keepAlive){yi(e);try{e.parent?.controls.silentDetach(e)}catch{}this.controlCache.has(n)||this.controlCache.set(n,e),zs(e)}else this.controlCache.get(n)===e&&this.controlCache.delete(n),await e.dispose()}catch(t){M("MJX307",t)}else n&&this.controlCache.get(n)===e&&this.controlCache.delete(n)}}_construct(t,e,s){const i=this.application?._routerState;return function(t,e){const s=he;he=t??null;try{return e()}finally{he=s}}(t,()=>i?i.constructWith(e,s):s())}async parseControl(t,e,s){var i=this._construct(e,s,()=>this._resolveFrom(e,t));if(i)return i;let n=t;return n instanceof Promise&&(n=ti(await n)),(i=this._construct(e,s,()=>this._resolveFrom(e,n)))||("function"==typeof n?this.parseControl(this._construct(e,s,()=>si(n,this.application)),e,s):si(n))}_resolveFrom(t,e){const s=t??this._rootProvider();return s&&s.getAllServices().getDescriptor(e)?s.get(e):null}_rootProvider(){try{return this.application?.provider??Qn.main?.provider}catch{return}}async createInstance(t,e,s){return await this._instanceCreator(t,e,s)}async _instanceCreator(t,e,s){let i=await this.parseControl(t,e,s);return ei(i),i}async activator(t){}pendingMount=new WeakMap;pendingListeners=new WeakMap;static OUTLET_WARN_MS=3e3;async mountChain(t,e,s,i){for(let n=0;n<t.length;){if(i!==this._navVersion)return;let o=t[n];o?.isDisposed&&(o=await this.createInstance(e[n].control,this._rootProvider()?._currentScope()),t[n]=o);const r=e[n]&&e[n].extend&&e[n].extend.targetOutlet||"default",a=this.findRouterView(s,r);if(!a||!s.isBuilt)return void this._waitForOutlet(s,t.slice(n),e.slice(n),i,r);const c=this._revealed.delete(o),l=a.current===o&&!c;await a.navigate(o),this._pendingActivate.delete(o)&&Bs(o);const h=e[n]?.onShow;h&&!l&&a.current===o&&i===this._navVersion&&C(()=>h(o),"MJX306","onShow"),s=o,n++}}_waitForOutlet(t,e,i,n,o){const r=this.pendingListeners.get(t);if(r){try{r()}catch{}this.pendingListeners.delete(t)}let a,c=!1;const l=async(s,o)=>{c||(h(),n===this._navVersion&&await this.mountChain(e,i,t,n))},h=()=>{if(!c){c=!0,this.pendingListeners.delete(t);try{t.motif?.off?.(gn,l)}catch{}if(void 0!==a){try{clearTimeout(a)}catch{}a=void 0}}};t.motif.on(gn,l),this.pendingListeners.set(t,h),s.isDevelopment()&&(a=setTimeout(()=>{c||n!==this._navVersion||A("MJX301",[o,zn.OUTLET_WARN_MS])},zn.OUTLET_WARN_MS))}findRouterView(t,e="default"){const s=(t.controls?.items||[]).slice();for(;s.length;){const t=s.shift();if(t&&!t.isDisposed){if(t.__isRouterView){const s=t;if((s.props.name||"default")===e)return s}if(t.controls&&t.controls.items&&t.controls.items.length)for(const e of t.controls.items)s.push(e)}}if(!e||"default"===e)return null;const i="function"==typeof t.scopeId?t.scopeId():t.scopeId??"";var n=_n.find(e,i);if(n)return n;let o=t,r=o?.parent;for(;r;){const t=(r.controls?.items||[]).filter(t=>t!==o).slice();for(;t.length;){const s=t.shift();if(s&&!s.isDisposed){if(s.__isRouterView){const t=s;if((t.props.name||"default")===e)return t}if(s.controls&&s.controls.items&&s.controls.items.length)for(const e of s.controls.items)t.push(e)}}o=r,r=r.parent}return null}}class Vn extends Us{constructor(t){super(t.el??"a",t),!1!==t.showHref&&this.attr.add({href:t.to}),t.target&&this.attr.add({target:t.target}),this.motif.on("click",(e,s)=>{if(t.bypass)return;if(t.target&&"_self"!==t.target)return;if(s.metaKey||s.ctrlKey||s.shiftKey||s.altKey)return;s.preventDefault();const i=Qn.main.router;i&&i.navigate(t.to)}),this.childs&&this.childs.length?this.controls.add(...this.childs):null!=t.text&&this.attr.add({textContent:t.text})}onBuilt(t,e){this.motif.options.enableRouterClassing={to:"all",path:this.props.to,activeClass:this.props.activeClass,exactClass:this.props.exactClass,onActive:this.props.onActive,offActive:this.props.offActive,onExact:this.props.onExact,offExact:this.props.offExact}}}const Wn=t=>t.split("#")[0].split("?")[0],$n=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36);class Un{static MAX_REDIRECTS=10;_routerOptions;routingEngine;routeCollection;routesMap=new Map;mainApp;application;_suppressBeforeEachOnce=!1;_suppressMiddlewaresOnce=!1;_scroll=null;constructor(t,e){this._routerOptions=t,this.routeCollection=new Bn(t.RouteItems),this.routingEngine=new zn,this.application=e,this._installLinkInterceptor();const s=t.scrollMemory;s&&(this._scroll=new bn(!0===s?{}:s),this._scroll.locationAnchor="history"===this._addressMode()),t.stack&&"shell"!==t.mode&&(this._stack=new Jn(t.stack),this.routingEngine.stack=this._stack)}_stack=null;getHooks(){return this._routerOptions.hooks}_windowNavListener=null;start(t,e){this.mainApp=t,this.routingEngine.register(this.mainApp,this.application,this);const s="shell"===this._routerOptions.mode?e??"/":this._getCurrentUri();this._seedHistoryIndex(),this._suppressMiddlewaresOnce=!0,this.navigate(s),"shell"!==this._routerOptions.mode&&(this._windowNavListener=()=>{this._onHistoryTraversal()},window.addEventListener("hash"===this._routerOptions.mode||"file"===this._routerOptions.mode?"hashchange":"popstate",this._windowNavListener))}get shownUri(){return this._previousRoute?this._currentUri:void 0}_getCurrentUri(){try{const t=window,e=this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history");if("hash"===e||"file"===e){const e=t?.location?.hash||"";return e&&e.startsWith("#")&&e.slice(1)||"/"}return(t?.location?.pathname||"/")+(t?.location?.search||"")}catch{return"/"}}static HISTORY_STAMP_KEY="__motifHistory";_historyStamp=null;_addressMode(){const t=window;return this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history")}_readHistoryStamp(){try{const t=window?.history?.state,e=t&&"object"==typeof t?t[Un.HISTORY_STAMP_KEY]:null;if(e&&"object"==typeof e&&"number"==typeof e.index&&Number.isFinite(e.index)&&"string"==typeof e.session)return{index:e.index,session:e.session}}catch{}return null}static _isPlainObject(t){if(!t||"object"!=typeof t)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}_withHistoryStamp(t,e){return null==t?{[Un.HISTORY_STAMP_KEY]:e}:Un._isPlainObject(t)?{...t,[Un.HISTORY_STAMP_KEY]:e}:t}_routerState(t,e){return t?this._withHistoryStamp(t,{...e,hasState:!0}):this._withHistoryStamp(null,e)}_userStateOf(t){if(null==t)return;if(!Un._isPlainObject(t))return t;const e=Un.HISTORY_STAMP_KEY;if(!(e in t))return t;const s=t[e];if(!s||!0!==s.hasState)return;const{[e]:i,...n}=t;return n}_currentHistoryUserState(){if("shell"!==this._addressMode())try{return this._userStateOf(window?.history?.state)}catch{return}}_nextHistoryStamp(t){const e=this._historyStamp;return e?{index:t?e.index+1:e.index,session:e.session}:{index:0,session:$n()}}_stampCurrentEntry(t,e){try{const s=window;if(!s?.history||"function"!=typeof s.history.replaceState)return;const i=s.history.state;let n;if(e)n=this._routerState(e,t);else{const e=Un._isPlainObject(i)&&Object.keys(i).length>0;n=this._withHistoryStamp(i,e?{...t,hasState:!0}:t)}n!==i&&s.history.replaceState(n,"")}catch{}}_seedHistoryIndex(){if("shell"===this._addressMode())return;const t=this._readHistoryStamp();if(t)return void(this._historyStamp=t);const e={index:0,session:$n()};this._stampCurrentEntry(e),this._historyStamp=e}_pendingTraversal=null;async _onHistoryTraversal(){const t=this._historyStamp,e=this._readHistoryStamp();this._historyStamp=e;let s,i="traverse";t&&e&&t.session===e.session&&t.index!==e.index&&(i=e.index<t.index?"back":"forward"),this._pendingTraversal={direction:i,state:this._currentHistoryUserState(),from:t};try{s=await this.navigate(this._getCurrentUri())}finally{this._pendingTraversal=null}const n=!!s&&!0===s.cancelled;try{this._stack?.traversalSettled(n)}catch{}if(!n)return;const o=this._readHistoryStamp();if(this._historyStamp=o,!t||!o||o.session!==t.session)return;const r=t.index-o.index;if(0!==r)try{window.history.go(r)}catch{}}_currentUri="___startup___";_previousRoute=null;get currentUri(){return this._currentUri}async navigate(t,e){const i=this._pendingTraversal;return this._pendingTraversal=null,await(n=async()=>{try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-start",{uri:t})}catch{}const s=this._suppressBeforeEachOnce;s&&(this._suppressBeforeEachOnce=!1);const n=this._suppressMiddlewaresOnce;n&&(this._suppressMiddlewaresOnce=!1);const o=e||{},r=o.force||!1;if(t===this._currentUri&&!r)return{ok:!0,skipped:!0,uri:t};let a;if(a=n?{proceed:!0,uri:t}:await this._runMiddlewares(t),!a.proceed)return{ok:!1,uri:a.uri,cancelled:!0,reason:"middleware"};t=a.uri;let c,l,h=this.resolve(t),u="";if(h.ok&&h.route?.redirect){const e=t,s=[e];for(;h.ok&&h.route?.redirect;){const e=this._resolveRedirect(h,t);if(!e)break;if(s.length>Un.MAX_REDIRECTS||s.some(t=>Wn(t)===Wn(e))){u=[...s,e].join(" → "),l=S("MJX303",u);break}s.push(e),t=e,h=this.resolve(t)}if(l)A("MJX303",[u]),t=e,h=this._buildFallbackResult(t,"error",{path:t,error:l});else if(t!==e&&(c=e,t===this._currentUri&&!r))return{ok:!0,skipped:!0,uri:t}}const d=!this._previousRoute,p=d?"initial":i?i.direction:o.replace?"replace":"push",f=i?i.state:d&&void 0===o.state?this._currentHistoryUserState():o.state||void 0,m={path:h.uri||t,params:h.params,meta:h.meta??h.extend,options:e,redirectedFrom:c,direction:p,state:f},_=this._previousRoute?{path:this._previousRoute.path,params:this._previousRoute.params,meta:this._previousRoute.meta,options:this._previousRoute.options}:null;if(this._previousRoute&&this._previousRoute.routeItem){const t=this._previousRoute.routeItem.onLeave||this._routerOptions.hooks?.onLeave;if(t)try{const e={from:{path:this._previousRoute.path,params:this._previousRoute.params,meta:this._previousRoute.meta},to:m},s=await t(e);if(!1===s)return{ok:!1,cancelled:!0,reason:"onLeave"};if(s&&"object"==typeof s&&!0===s.cancel)return{ok:!1,cancelled:!0,reason:s.reason||"onLeave"}}catch(t){M("MJX306",t,"onLeave")}}let g=!0;if(s||(g=await this.application._runBeforeEachGuards(m,_)),!1===g)return{ok:!1,cancelled:!0,reason:"guard"};if("string"==typeof g){const s=this._addressShows(t,c);return await this.navigate(g,s?{...o,replace:!0}:e)}const y=t=>({target:t,chain:t.chain.map(e=>this.routingEngine.generatePathString(e.path,t.params)||""),direction:p,state:f});h.ok||l||(h=this._buildFallbackResult(t,"notFound",{path:t})),this._currentUri=t,this._previousRoute={path:h.uri,params:h.params,meta:h.meta??h.extend,routeItem:h.route};let v=h.uri;this._scroll?.leaving();const w=i?i.from:this._historyStamp;try{const t=!!c&&this._addressShows(c);this._applyUrl(v,t?{...o,replace:!0}:o)}catch{}const b=this._stack?{direction:p,from:w,to:this._historyStamp,uri:v}:void 0;try{await this.routingEngine.execute(h,b,y(h))}catch(e){M("MJX304",e),h=this._buildFallbackResult(t,"error",{path:t,error:e});try{await this.routingEngine.execute(h,b,y(h))}catch(t){M("MJX305",t)}}this._stack&&this.application._routerState.touch(),o.scroll?this._handleScrollBehavior(o.scroll):this._scroll?.arrived(this._uriWithHash(v,t)),this.application.fire?.("motifjs-router-navigated",{uri:v,params:h.params,meta:h.meta??h.extend,route:h.ok?h.route:null,ok:h.ok,initial:d,redirectedFrom:c,direction:p,state:f});try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-end",{uri:v,params:h.params})}catch{}return h},o="UrlRoutingModule.navigate",s.safeCallSilentAsync(n,o));var n,o}describeStack(){return this._stack?this._stack.describe():void 0}routeInfos(){const t=[],e=(s,i)=>{const n=[...i,s];t.push({fullPath:s.fullPath||s.path,name:s.name??null,meta:s.meta??s.extend??{},route:s,chain:n});for(const t of s.childs||[])e(t,n)};for(const t of this.routeCollection?.routes||[])e(t,[]);return t}href(t,e){const s=this.routeCollection.routesMap?.get(t);if(!s)throw S("MJX302",t);const i=s.fullPath||s.path;return this.routingEngine.generatePathString(i,e||{})||i}async evict(t){let e=null;if("string"==typeof t){if(e=this.routeCollection.routesMap?.get(t),!e)throw S("MJX302",String(t))}else e=t;await this.routingEngine.evict(e)}_fallbackRoutes={};_getFallbackRoute(t){const e=this._fallbackRoutes[t];if(e)return e;const s=this._routerOptions.fallbacks?.[t],i={path:"",fullPath:null,control:s??("notFound"===t?Un._builtinNotFound:Un._builtinError),name:"notFound"===t?"not-found":"error",childs:[],extend:{},meta:{},validate:void 0,keepAlive:!1};return this._fallbackRoutes[t]=i,i}_buildFallbackResult(t,e,s){const i=this._getFallbackRoute(e),n=this._findLayoutPrefix(t),o=[...n?.chain??[],i],r={},a={};for(const t of o)t?.extend&&"object"==typeof t.extend&&Object.assign(r,t.extend),t?.meta&&"object"==typeof t.meta&&Object.assign(a,t.meta);return{ok:!1,uri:t,fullPath:null,route:i,chain:o,params:{...n?.params??{},...s},extend:r,meta:a}}_findLayoutPrefix(t){const e=t.split("?")[0].split("#")[0].split("/").filter(Boolean);let s=null;for(const t of this.routeCollection?.records||[]){if(!t.leaf.childs||!t.leaf.childs.length)continue;const i=t.fullPath.split("/").filter(Boolean).length;if(i>e.length)continue;const n="/"+e.slice(0,i).join("/");let o=!1;try{o=t.scanner.exist(n,this._pageSearch())}catch{o=!1}if(!o)continue;const r={...t.scanner.parameters};this.validateChain(n,t,r)&&((!s||t.chain.length>s.rec.chain.length||t.chain.length===s.rec.chain.length&&i>s.depth)&&(s={rec:t,params:r,depth:i}))}return s?{chain:s.rec.chain,params:s.params}:null}static _builtinNotFound=()=>new Us("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(di("h2",{},"404 - Not Found")),t.element.appendChild(di("p",{},"The requested page was not found."))}});static _builtinError=()=>new Us("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(di("h2",{},"Error")),t.element.appendChild(di("p",{},"The requested page could not be loaded."))}});async navigateByName(t,e,s){return await this.navigate(this.href(t,e),s)}async _runMiddlewares(t){let e=t;const s={uri:e,rewritePath:t=>{e=t,s.uri=t},context:this.application};let i=!1;const n=this._routerOptions.middlewareCollections&&this._routerOptions.middlewareCollections()||[],o=async t=>{if(t===n.length)return void(i=!0);const e=n[t];await e(s,async()=>{await o(t+1)})};return 0===n.length?i=!0:await o(0),{proceed:i,uri:e}}resolve(t){const e=[],s=this._pageSearch();for(const i of this.routeCollection?.records||[]){if(!i.scanner.exist(t,s))continue;const n={...i.scanner.parameters};this.validateChain(t,i,n)&&e.push({rec:i,params:n})}if(0===e.length){const e=(this.routeCollection?.records||[]).find(t=>t.scanner.exist("/*"));if(e){const s={};try{for(const t of e.chain)t&&t.extend&&"object"==typeof t.extend&&Object.assign(s,t.extend)}catch{}return{ok:!0,uri:t,fullPath:e.fullPath,route:e.leaf,chain:e.chain,params:{},extend:s||{},meta:e.meta||{}}}return{ok:!1,uri:t,fullPath:null,route:null,chain:[],params:{},extend:{}}}let i=e[0];const n=new Map;for(const t of e){const e=t.rec.fullPath,s=n.get(e)||[];s.push(t),n.set(e,s)}let o=!1;for(const[t,e]of n)if(e.length>1){i=(e.some(t=>!t.rec.aliasOf)?e.filter(t=>!t.rec.aliasOf):e).reduce((t,e)=>t.rec.chain.length>=e.rec.chain.length?t:e),o=!0;break}o||(i=e.reduce((t,e)=>Fn(t.rec,e.rec)<=0?t:e,e[0]));const r=i.rec,a=i.params,c={};try{for(const t of r.chain)t&&t.extend&&"object"==typeof t.extend&&Object.assign(c,t.extend)}catch{}return{ok:!0,uri:t,fullPath:r.fullPath,aliasOf:r.aliasOf??null,route:r.leaf,chain:r.chain,params:a,extend:c,meta:(()=>{const t={};try{for(const e of r.chain)e&&e.meta&&"object"==typeof e.meta&&Object.assign(t,e.meta)}catch{}return t})()}}validateChain(t,e,s){for(const i of e.chain)if("function"==typeof i.validate){const n={uri:t,key:i.name??e.fullPath,routes:this.routesMap,params:s};if(!i.validate(n))return!1}return!0}_navHandler=null;_installLinkInterceptor(){try{if(this._navHandler)return;this._navHandler=t=>{const e=window,s=this._routerOptions.mode||("file:"===e?.location?.protocol?"hash":"history");let i=t.target;for(;i&&i!==document.body&&!(i instanceof HTMLAnchorElement);)i=i.parentElement;if(!(i&&i instanceof HTMLAnchorElement))return;const n=i.getAttribute("rel")||"";if(!("router"==i.getAttribute("x-command")||i.hasAttribute("data-router-link")||"router"===n.toLowerCase()))return;const o=i;if(o.target&&"_self"!==o.target)return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let r=o.getAttribute("href")||"";if(r||(r=o.getAttribute("x-to")||""),!r)return;if("history"===s){const s=new URL(r,e.location.href);if(s.origin!==e.location.origin)return;t.preventDefault();const i=s.pathname+s.search+s.hash;return void this.navigate(i)}t.preventDefault();const a=r.startsWith("#")?r.slice(1):r;this.navigate(a)},document.addEventListener("click",this._navHandler)}catch{}}_applyUrl(t,e={}){try{const s=window,i=this._routerOptions.mode||("file:"===s?.location?.protocol?"hash":"history");if("shell"===i)return;if("hash"===i||"file"===i){const i=t.startsWith("#")?t:"#"+t;if(s?.location?.hash!==i)if(e.replace&&s?.history&&"function"==typeof s.history.replaceState){const t=this._nextHistoryStamp(!1);s.history.replaceState(this._routerState(e.state,t),"",i),this._historyStamp=t}else{s.location.hash=i;const t=this._nextHistoryStamp(!0);this._stampCurrentEntry(t,e.state),this._historyStamp=t}return}if(s?.history&&"function"==typeof s.history.pushState){if((s.location.pathname||"/")+(s.location.search||"")!==t)if(e.replace){const i=this._nextHistoryStamp(!1);s.history.replaceState(this._routerState(e.state,i),"",t),this._historyStamp=i}else{const i=this._nextHistoryStamp(!0);s.history.pushState(this._routerState(e.state,i),"",t),this._historyStamp=i}}}catch{}}_resolveRedirect(t,e){const s=t.route?.redirect;if(!s)return null;if("function"==typeof s){const e=s({path:t.uri,params:t.params,meta:t.meta??t.extend});return"string"==typeof e&&e.length>0?e:null}const i=this.routingEngine.generatePathString(s,t.params||{}),n=e.indexOf("#"),o=n>=0?e.slice(n):"",r=n>=0?e.slice(0,n):e,a=r.indexOf("?"),c=a>=0?r.slice(a):"",l=i.indexOf("#"),h=l>=0?i.slice(l):"";let u=l>=0?i.slice(0,l):i;return c&&!u.includes("?")&&(u+=c),u+(h||o)}_pageSearch(){try{const t=window,e=this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history");if("history"===e||"shell"===e)return;return t?.location?.search||void 0}catch{return}}_addressShows(...t){const e=this._getCurrentUri().split("#")[0];return t.some(t=>!!t&&t.split("#")[0]===e)}_uriWithHash(t,e){const s=e.indexOf("#");return s<0||t.indexOf("#")>=0?t:t+e.slice(s)}_handleScrollBehavior(t){if(t)try{"top"===t?window.scrollTo({top:0,behavior:"auto"}):"smooth"===t?window.scrollTo({top:0,behavior:"smooth"}):"instant"===t?window.scrollTo({top:0,behavior:"instant"}):"object"==typeof t&&window.scrollTo({top:t.top||0,left:t.left||0,behavior:t.behavior||"auto"})}catch{}}dispose(){try{this._scroll?.dispose()}catch{}this._scroll=null,this._historyStamp=null;let t=Promise.resolve();try{try{t=this.routingEngine.dispose()}catch{}if(this._navHandler){try{document.removeEventListener("click",this._navHandler)}catch{}this._navHandler=null}if(this._windowNavListener){const t="hash"===this._routerOptions.mode||"file"===this._routerOptions.mode?"hashchange":"popstate";try{window.removeEventListener(t,this._windowNavListener)}catch{}this._windowNavListener=null}}catch{}return t}}class qn{version=new ne(0);_current=null;_constructing=null;read(){return this.version.value,this._constructing??this._current}commit(t){this._current=t,this.touch()}reset(){this._current=null,this.touch()}touch(){this.version.value=this.version.peek()+1}constructWith(t,e){if(!t)return e();const s=this._constructing;this._constructing=t;try{return e()}finally{this._constructing=s}}}let Gn=null,Kn=!1;class Yn{services=new un;constructor(){if(Gn&&"disposing"!==Gn.state||Kn)throw new w("MJX405",b("MJX405"),{cause:Gn});Kn=!0}build(){this.services.autoRegisterInjectables();const t=this.services.buildServiceProvider();this.services.addSingleton(Ce,t);var e=new Qn(t);return this.services.addSingleton(Qn,e),Gn=e,e}rebuild(){return Gn?(Gn.provider.dispose(),Gn.provider=this.services.buildServiceProvider(),Gn):this.build()}}class Qn{provider;static get main(){return Gn}constructor(t){this.provider=t}static _disposingCount=0;_state="initializing";_disposing;get state(){return this._state}_middlewares=[];_beforeEachGuards=[];_routerState=new qn;router=function(t,e){const s=()=>{const t=e();if(!t)throw S("MJX309");return t},i=()=>t.read()?.target;return{get params(){return i()?.params??{}},get route(){return i()?.route??null},get ok(){return i()?.ok??!1},get uri(){return i()?.uri??""},get fullPath(){return i()?.fullPath??null},get aliasOf(){return i()?.aliasOf??null},get extend(){return i()?.extend??{}},get meta(){const t=i();return t?t.meta??t.extend:{}},get chain(){return t.read()?.chain??[]},get direction(){return t.read()?.direction},get state(){return t.read()?.state},get stack(){return t.version.value,e()?.describeStack()},get routes(){return t.version.value,e()?.routeInfos()??[]},navigate:async(t,e)=>{await s().navigate(t,e)},navigateByName:async(t,e,i)=>{await s().navigateByName(t,e,i)},evict:async t=>{await s().evict(t)},resolve:t=>s().resolve(t),href:(t,e)=>s().href(t,e)}}(this._routerState,()=>this.urlRoutingModule);events=new Map;static CreateBuilder(){return new Yn}appShell;getAppShell(){return this.appShell}run(t,e){let s;if(o(()=>{Qi.startGc()},"Application.run.engine.startGc"),"string"==typeof t){if(s=document.querySelector(t),!s)throw S("MJX406",t)}else s=t;let i=e;this._state="running";const n=new Us(s);this.appShell=n,o(()=>{n._keepElementOnDispose=!0,n.application=this,n.provider=this.provider},"Application.run.setupAppShell"),i?(i.parent=n,n.controls.add(i)):(i=n,i.controls.add(new yn({name:"default"}))),n.build(),this._routerRoot=i,this.urlRoutingModule&&(this.urlRoutingModule.start(i),this._startedRouter=this.urlRoutingModule)}insert(t){this.appShell.controls.add(t)}remove(t){this.appShell.controls.remove(t)}attach(t){this.appShell.controls.add(t)}detach(t){this.appShell.controls.detach(t)}appendToMainHost(t){this.appShell.element?.appendChild(t)}dispose(){if(this._disposing)return this._disposing;let t;this._state="disposing",Qn._disposingCount++,Kn=!1,o(()=>{this._removeLifecycleListeners()},"Application.dispose.lifecycle"),o(()=>{t=this.urlRoutingModule?.dispose?.()},"Application.dispose.router"),o(()=>{Qi.stopGc()},"Application.dispose.gcStop"),o(()=>{try{const t=window;t&&t.history&&"function"==typeof t.history.replaceState&&t.history.replaceState({},"","/")}catch{}},"Application.dispose.resetUrl"),Ee.mode="concurrent";const e=this.appShell;return this._disposing=(async()=>{try{await t}catch(t){M("MJX307",t)}if(e&&!e.isDisposed)try{await e.dispose()}catch(t){M("MJX307",t)}try{await this.provider.dispose()}catch{}Gn===this&&(Gn=null),this._state="disposed",Qn._disposingCount--})()}useTransitions(t){return Ie(t?.mode)&&(Ee.mode=t.mode),this}use(t){return this._middlewares.push(t),this}useGuard(t){return this._beforeEachGuards.push(t),this}async _runBeforeEachGuards(t,e){const s={to:t,from:e};for(const t of this._beforeEachGuards){let e,i=!1;const n=t=>{i=!0,e=t};try{await t(s,n)}catch(t){return M("MJX306",t,"guard"),!1}if(!i)return!1;if(!1===e)return!1;if("string"==typeof e)return e}return!0}urlRoutingModule;_routerConfig=null;_routerRoot=null;_startedRouter=null;useRouter(t){let e,s,i,n,r,a;return Array.isArray(t)?e=t:(e=t.routes,s=t.mode,i=t.fallbacks,n=t.hooks,r=t.scrollMemory,a=t.stack),this.urlRoutingModule&&this.urlRoutingModule.dispose(),this._routerConfig={mode:s,fallbacks:i,middlewareCollections:()=>this._middlewares,RouteItems:e,hooks:n,scrollMemory:r,stack:a},this.urlRoutingModule=new Un(this._routerConfig,this),this._routerState.reset(),o(()=>{u(),mn(),g(e),(this._isDevelopment||!0===globalThis.__MOTIF_DEV__||d())&&function(t){const e=new Map,s=new Map;function i(t,n,o){const r=t.path??"",a=String(r),c=""===n?a:dn(n,a),l=o>0&&"/"===a.trim(),h=""===a.trim();h&&A("MJX310",[n||"/"],{parentPath:n,path:a}),o>0&&a.length>0&&"/"!==a&&!a.startsWith("/")&&!a.startsWith("*")&&A("MJX311",[a,n||"/"],{parentPath:n,path:a}),n&&c===n&&(l||h||A("MJX312",[c],{parentPath:n,childPath:a}));const u=(e.get(c)||0)+1;e.set(c,u),u>1&&(l||h||A("MJX313",[c],{full:c}));const d=null==t.alias?[]:Array.isArray(t.alias)?t.alias:[t.alias];for(const t of d){const e=String(t??"");o>0&&e.length>0&&"/"!==e&&!e.startsWith("/")&&!e.startsWith("*")&&A("MJX314",[e,n||"/"],{parentPath:n,alias:e});const i=""===n?e:dn(n,e);i===c&&A("MJX315",[i],{full:c,alias:e});const r=(s.get(i)||0)+1;s.set(i,r),r>1&&A("MJX316",[i],{aliasFull:i})}const p=t.childs;if(Array.isArray(p))for(const t of p)i(t,c,o+1)}for(const e of t)i(e,"",0)}(e)},"Application.useRouter.devtools"),this}restartRouter(){const t=this._routerRoot;if(!t||!this._routerConfig)return this;const e=this._startedRouter,s=e?.shownUri;let i=this.urlRoutingModule;return i&&i!==e||(e?.dispose(),i=new Un(this._routerConfig,this),this.urlRoutingModule=i),this._routerState.reset(),this._startedRouter=i,i.start(t,s),this}async navigate(t,e){if(this.urlRoutingModule)return await this.urlRoutingModule.navigate(t,e);throw S("MJX309")}async navigateByName(t,e,s){if(this.urlRoutingModule)return await this.urlRoutingModule.navigateByName(t,e,s);throw S("MJX309")}on(t,e){var s=this.events.get(t);return s||(this.events.set(t,new Set),s=this.events.get(t)),s&&s.add(e),()=>this.off(t,e)}off(t,e){var s=this.events.get(t);s&&s.delete(e)}fire(t,e){var s=this.events.get(t);s&&s.forEach(s=>{C(()=>s(e),"MJX123",String(t))})}onRouterChanged(t){return this.on("motifjs-router-navigated",t)}get isVisible(){try{return"undefined"==typeof document||"hidden"!==document.visibilityState}catch{return!0}}get isOnline(){try{return"undefined"==typeof navigator||!1!==navigator.onLine}catch{return!0}}_lifecycleOff=null;onLifecycle(t){return this._installLifecycleListeners(),this.on("motifjs-app-lifecycle",t)}_emitLifecycle(t){this.fire("motifjs-app-lifecycle",{state:t,visible:this.isVisible,online:this.isOnline})}_installLifecycleListeners(){if(this._lifecycleOff)return;const t=[],e=(e,s,i)=>{if(e)try{e.addEventListener(s,i),t.push(()=>{try{e.removeEventListener(s,i)}catch{}})}catch{}},s="undefined"!=typeof document?document:void 0,i="undefined"!=typeof window?window:void 0;e(s,"visibilitychange",()=>this._emitLifecycle(this.isVisible?"visible":"hidden")),e(s,"freeze",()=>this._emitLifecycle("frozen")),e(s,"resume",()=>this._emitLifecycle("resumed")),e(i,"pageshow",t=>{t&&t.persisted&&this._emitLifecycle("restored")}),e(i,"online",()=>this._emitLifecycle("online")),e(i,"offline",()=>this._emitLifecycle("offline")),this._lifecycleOff=t}_removeLifecycleListeners(){const t=this._lifecycleOff;if(this._lifecycleOff=null,t)for(const e of t)e()}_isDevelopment=!1;_enableErrorLogging=!0;get isDevelopmentModeEnabled(){return this._isDevelopment}useReactiveMonitor(t={}){return o(()=>{vt(t)},"Application.useReactiveMonitor.core"),this}useDevelopment(t=!0){return this._isDevelopment=t,s.setDevelopmentMode(t),o(()=>{globalThis.__MOTIF_DEV__=t},"Application.useDevelopment.flag"),o(()=>{var e;e=t,a.enabled=e||l(),h(a.enabled)},"Application.useDevelopment.devtools"),t&&function(){for(const t of Array.from(at))ct(t)}(),this}useLogging(t=!0){return this._enableErrorLogging=t,function(t){s.setConsoleLogging(t)}(t),this}}function Zn(){return Qn.main.router}function to(){return{application:Qn.main,services:Qn.main.provider,router:Qn.main.router,attach(...t){Qn.main&&Qn.main.getAppShell().controls.add(...t)}}}function eo(t){return e=>{hn.set(e,{lifetime:t?.lifetime??"transient",deps:t?.deps})}}function so(t){try{return Qn.main.provider.get(t)}catch(e){return A("MJX414",[io(t),String(e?.message??e)],{token:t,error:e}),null}}function io(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function no(t){return t&&"TimeoutError"===t.name}class oo extends w{constructor(){super("MJX605",b("MJX605")),this.name="TimeoutError"}}function ro(t){return new Promise(e=>setTimeout(e,t))}function ao(t,e=.1){const s=(2*Math.random()-1)*e*t;return Math.max(0,Math.floor(t+s))}class co{}class lo extends co{retries;backoff;delayMs;jitter;shouldHandle;onRetry;constructor(t={}){super(),this.retries=t.retries??3,this.backoff=t.backoff??"exponential",this.delayMs=t.delay??100,this.jitter=Math.min(Math.max(t.jitter??.1,0),1),this.shouldHandle=t.shouldHandle??(t=>!!t&&!no(t)),this.onRetry=t.onRetry}calcDelay(t){if("none"===this.backoff)return 0;if("fixed"===this.backoff)return ao(this.delayMs,this.jitter);return ao(this.delayMs*Math.pow(2,t-1),this.jitter)}async execute(t,e){let s;for(let i=1;i<=this.retries+1;i++)try{return await Promise.resolve(t(e))}catch(t){if(s=t,!this.shouldHandle(t)||i>this.retries)break;const n=this.calcDelay(i);this.onRetry&&await this.onRetry(i,t,n,e),n>0&&await ro(n)}throw s}}class ho extends co{timeoutMs;constructor(t){super(),this.timeoutMs=t.timeoutMs}async execute(t,e){let s;const i=Promise.resolve(t(e)),n=new Promise((t,e)=>{s=setTimeout(()=>e(new oo),this.timeoutMs)});try{return await Promise.race([i,n])}finally{clearTimeout(s)}}}class uo extends co{failureThreshold;successThreshold;durationOfBreakMs;shouldHandle;onStateChange;state="CLOSED";failureCount=0;successCount=0;nextAttemptTime=0;constructor(t={}){super(),this.failureThreshold=t.failureThreshold??5,this.successThreshold=t.successThreshold??2,this.durationOfBreakMs=t.durationOfBreakMs??6e4,this.shouldHandle=t.shouldHandle??(t=>!!t&&!no(t)),this.onStateChange=t.onStateChange}async changeState(t){const e=this.state;this.state=t,this.failureCount=0,this.successCount=0,"OPEN"===t&&(this.nextAttemptTime=Date.now()+this.durationOfBreakMs),this.onStateChange&&await this.onStateChange(e,t)}async execute(t,e){if("OPEN"===this.state){if(!(Date.now()>=this.nextAttemptTime))throw S("MJX602");await this.changeState("HALF_OPEN")}try{const s=await Promise.resolve(t(e));return"HALF_OPEN"===this.state?(this.successCount++,this.successCount>=this.successThreshold&&await this.changeState("CLOSED")):"CLOSED"===this.state&&(this.failureCount=0),s}catch(t){throw this.shouldHandle(t)&&(this.failureCount++,("HALF_OPEN"===this.state||"CLOSED"===this.state&&this.failureCount>=this.failureThreshold)&&await this.changeState("OPEN")),t}}getState(){return this.state}}class po extends co{maxConcurrent;maxQueue;active=0;queue=[];constructor(t={}){super(),this.maxConcurrent=t.maxConcurrent??10,this.maxQueue=t.maxQueue??50}dequeue(){if(0===this.queue.length)return;if(this.active>=this.maxConcurrent)return;this.queue.shift()()}async execute(t,e){if(this.active>=this.maxConcurrent){if(this.queue.length>=this.maxQueue)throw S("MJX603");await new Promise(t=>{this.queue.push(t)})}this.active++;try{return await Promise.resolve(t(e))}finally{this.active--,this.dequeue()}}}class fo extends co{tokensPerInterval;intervalMs;capacity;tokens;lastRefill;constructor(t={}){super(),this.tokensPerInterval=t.tokensPerInterval??1,this.intervalMs=t.intervalMs??1e3,this.capacity=t.capacity??this.tokensPerInterval,this.tokens=this.capacity,this.lastRefill=Date.now()}refill(){const t=Date.now(),e=t-this.lastRefill;if(e<=0)return;const s=Math.floor(e/this.intervalMs)*this.tokensPerInterval;s>0&&(this.tokens=Math.min(this.capacity,this.tokens+s),this.lastRefill=t)}async execute(t,e){if(this.refill(),this.tokens<=0)throw S("MJX604");return this.tokens-=1,Promise.resolve(t(e))}}class mo extends co{fallback;shouldHandle;constructor(t){super(),this.fallback=t.fallback,this.shouldHandle=t.shouldHandle??(()=>!0)}async execute(t,e){try{return await Promise.resolve(t(e))}catch(t){if(!this.shouldHandle(t))throw t;return await Promise.resolve(this.fallback(t,e))}}}class _o extends co{policies;constructor(...t){super(),this.policies=t}async execute(t,e){return this.policies.reduceRight((t,e)=>s=>e.execute(()=>t(s),s),t)(e)}}const go=t=>new lo(t),yo=t=>new ho(t),vo=t=>new uo(t),wo=t=>new po(t),bo=t=>new fo(t),So=t=>new mo(t),Mo=(...t)=>new _o(...t);function Co(t,e){return s=>t.execute(e,s)}class Ao{static get create(){return new Ao}resiliences=[];retry=t=>(this.resiliences.push(go(t)),this);timeout=t=>(this.resiliences.push(yo(t)),this);circuitBreaker=t=>(this.resiliences.push(vo(t)),this);bulkhead=t=>(this.resiliences.push(wo(t)),this);rateLimiter=t=>(this.resiliences.push(bo(t)),this);fallback=t=>(this.resiliences.push(So(t)),this);async execute(t,e){return Mo(...this.resiliences).execute(t,e)}}export{Qn as Application,Yn as ApplicationBuilder,Us as Component,us as ComponentBase,ee as ComponentMotif,oe as Computed,ki as ContentBlock,Di as ContentBody,pi as ControlCollection,Z as Dictionary,E as Disposable,D as DisposableStore,Ht as Emitter,e as ErrorHandler,qs as FNComponent,ri as FragmentNode,bi as Frame,so as FromService,eo as Injectable,_i as Lazy,re as LazyComputed,et as LinkedList,q as List,w as MotifError,U as NameValuePair,lt as NodeTypes,ot as Query,Ao as Resilience,Vn as RouterLink,yn as RouterView,un as ServiceCollection,Ce as ServiceProvider,ne as Signal,Oi as Transport,Pi as TransportTo,Ni as Transporter,ln as Virtualization,Dt as asyncTracking,nn as clearModel,vt as configureReactivityLeakMonitor,an as createComputed,cn as createLazyComputed,rn as createSignal,Co as decorate,on as deepClone,k as disposableCore,li as dom,At as effect,s as errorHandler,we as inject,ct as motifCompiled,Qs as motifComponent,ni as motifFragment,Mi as preProcessing,en as reactive,it as read,i as safeCall,n as safeCallAsync,o as safeCallSilent,r as setUnexpectedErrorHandler,G as toDisposable,st as toGetter,Tt as untracked,to as useApplication,sn as useModel,Zn as useNavigation};
1
+ function t(t){setTimeout(()=>{throw t},0)}class e{constructor(){this.unexpectedErrorHandler=t,this.listeners=[],this._isDevelopment=!1,this._enableConsoleLogging=!0}setDevelopmentMode(t){this._isDevelopment=t}setConsoleLogging(t){this._enableConsoleLogging=t}isDevelopment(){return this._isDevelopment||!0===globalThis.__MOTIF_DEV__}reportSuppressed(t,e){this.logIfDev(t,e)}report(t){this._enableConsoleLogging&&(void 0!==t.cause?console.error(t.message,t.cause):console.error(t.message));try{const e=globalThis.__MOTIF_DEVTOOLS_BUS__;e&&"function"==typeof e.publish&&e.publish("error:caught",{context:t.code??t.name,error:this.serializeError(t)})}catch{}this.emit(t)}logIfDev(t,e){this.isDevelopment()&&this._enableConsoleLogging&&console.error(`[motifjs Error - ${t}]`,e);try{const s=globalThis.__MOTIF_DEVTOOLS_BUS__;s&&"function"==typeof s.publish&&s.publish("error:caught",{context:t,error:this.serializeError(e)})}catch{}}serializeError(t){if(!t)return{message:"Unknown error"};if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack,cause:t.cause?this.serializeError(t.cause):void 0};if("object"==typeof t)try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}return String(t)}addListener(t){return this.listeners.push(t),()=>{const e=this.listeners.indexOf(t);-1!==e&&this.listeners.splice(e,1)}}emit(t){for(const e of this.listeners.slice())e(t)}setUnexpectedErrorHandler(t){this.unexpectedErrorHandler=t}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(t){this.unexpectedErrorHandler(t),this.emit(t)}safeCall(t,e,s){try{return t()}catch(t){return this.logIfDev(e,t),this.onUnexpectedError(t),s}}async safeCallAsync(t,e,s){try{return await t()}catch(t){return this.logIfDev(e,t),this.onUnexpectedError(t),s}}safeCallSilent(t,e){try{t()}catch(t){this.logIfDev(e,t)}}async safeCallSilentAsync(t,e){try{return await t()}catch(t){this.logIfDev(e,t)}}wrapSafe(t,e){return(...s)=>{try{return t(...s)}catch(t){return this.logIfDev(e,t),void this.onUnexpectedError(t)}}}wrapSafeAsync(t,e){return async(...s)=>{try{return await t(...s)}catch(t){return this.logIfDev(e,t),void this.onUnexpectedError(t)}}}}const s=new e;function i(t,e,i){return s.safeCall(t,e,i)}function n(t,e,i){return s.safeCallAsync(t,e,i)}function o(t,e){s.safeCallSilent(t,e)}function r(t){s.setUnexpectedErrorHandler(t)}const a={enabled:!1,listeners:new Set,warnings:[],routes:null};function c(){return a.enabled||!0===globalThis.__MOTIF_DEV__}function l(){try{if("undefined"==typeof window)return!1;return!0===window.__motif_DEVTOOLS||(!0===globalThis.__MOTIF_DEVTOOLS__||!0===globalThis.__MOTIF_DEVTOOLS_FLAG)}catch{return!1}}function h(t){try{t?window.__motifDevBus={on:p,emit:f,warn:m,getWarnings:_,isEnabled:d,setRoutes:g,getRoutes:y}:delete window.__motifDevBus}catch{}}function u(){a.enabled||(a.enabled=l(),a.enabled&&h(!0))}function d(){return a.enabled}function p(t){return a.listeners.add(t),()=>{a.listeners.delete(t)}}function f(t,e){const s={type:t,payload:e};for(const t of a.listeners)try{t(s)}catch{}try{const s=globalThis.__MOTIF_DEVTOOLS_BUS__;s&&"function"==typeof s.publish&&s.publish("devtools:"+t,e)}catch{}}function m(t,e,s){if(!c())return;const i={code:t,message:e,details:s};a.warnings.push(i);try{"undefined"!=typeof console&&(void 0===s?console.warn(`[motifjs] ${t}: ${e}`):console.warn(`[motifjs] ${t}: ${e}`,s))}catch{}f("warning",i)}function _(){return a.warnings.slice()}function g(t){a.routes=t}function y(){return a.routes}const v={MJX101:t=>`dom.createElement('${t}'): no document is available (no DOM environment).`,MJX102:t=>`Invalid element selector "${t}".`,MJX103:t=>`dom.createElementNS('${t}') failed.`,MJX104:()=>"Skipped inserting a component into the DOM because it contains its own parent.",MJX105:()=>"Applying router link classes failed.",MJX106:()=>"The placeholder parent changed; rebuilding the component.",MJX107:()=>"Disposing a child component failed.",MJX108:()=>"Component is disposed; the result of doWork was discarded.",MJX109:()=>"A content block child was removed because its content body is being disposed.",MJX110:t=>`Lazy timeout: the component did not load within ${t} ms.`,MJX111:()=>"Lazy aborted: loading the component was cancelled.",MJX112:t=>`resolveComponent: the factory chain exceeded ${t} levels; a factory may be returning itself.`,MJX113:()=>"The transport slot has no parent; mount the slot before transporting into it.",MJX114:()=>"Placing the navigation target into its host failed.",MJX115:()=>"Disposing the previous navigation target failed.",MJX116:t=>`Timeout: the listener guard did not settle within ${t} ms.`,MJX117:()=>"Detaching a control failed.",MJX118:()=>"The onRemove callback failed while detaching a control.",MJX119:()=>"Moving a fragment's DOM range stopped: its end marker was not found (possible infinite loop).",MJX120:()=>"Scanning a fragment's DOM range stopped: its end marker was not found (possible infinite loop).",MJX121:(t,e)=>`This code was compiled for compiler contract ${t}, but the @motifx/core runtime implements contract ${e}. Install matching versions of @motifx/compiler and @motifx/core, and rebuild packages that ship compiled JSX.`,MJX122:t=>`The component ${t} hook threw.`,MJX123:t=>`The '${t}' event handler threw.`,MJX124:t=>`A spread object on a DOM tag cannot set ${t}; the key was ignored. Write it on the tag, or use x-html, for HTML you trust.`,MJX125:t=>`A spread object on a DOM tag cannot set a javascript: URL on '${t}'; the value was ignored. Write the attribute on the tag if it is intended.`,MJX126:()=>"Lazy: loading the component failed and no Fallbackview is set; the host was cleared.",MJX127:t=>"module"===t?"The loaded module has no default export. Export the component as default, or map it: () => import('./X').then(m => m.X).":`The loaded value is not a component (got ${t}). Return a component class, a function component, an Options API factory or a component instance.`,MJX128:(t,e,s)=>"method"===s?`${t} overrides ${e} without calling super.${e}; MotifJS relies on this ComponentBase member. Rename your member, or call super.${e} in the override.`:"field"===s?`${t} defines '${e}' as an instance field, which hides the ComponentBase member MotifJS relies on. Rename your field.`:`${t} replaces '${e}', which MotifJS created for the component (a class field or an assignment with that name). Rename your member.`,MJX201:()=>"ListBinding: renderFn must return a component instance, a component class, or a factory function.",MJX202:(t,e)=>`ListBinding: duplicate key "${String(t)}" at index ${e}. Rows are matched by the item object, not by key, so rendering is not affected; keep keys unique so they identify items.`,MJX203:t=>`An effect ran ${t} times in one flush and keeps triggering itself; it is skipped for the rest of this flush. It probably writes a value it reads (for example state.n++). Wrap the write in untracked(...).`,MJX204:()=>"A component reached a text binding and was not written to the DOM. For a template prop that can change later, write a getter: {() => props.tpl}. Templates that are ready at setup also work as {props.tpl}.",MJX205:()=>"Virtualization: the watch callback threw.",MJX206:()=>"Virtualization: autoRefresh stopped; dataRequest may be changing the reactive data it reads on every refresh.",MJX207:()=>"Virtualization: loading data failed.",MJX208:()=>"An effect threw.",MJX301:(t,e)=>`RouterView outlet '${t}' was not built within ${e} ms, so the route chain cannot be mounted. Does the layout component render a <RouterView>?`,MJX302:t=>`Named route '${t}' was not found.`,MJX303:t=>`Redirect loop or too many redirects: ${t}`,MJX304:()=>"Route execution failed.",MJX305:()=>"The error fallback route failed.",MJX306:t=>`The ${t} hook threw.`,MJX307:()=>"Disposing a route component failed.",MJX308:()=>"The stack navigation transition failed.",MJX309:()=>"Router is not initialized. Call useRouter() before navigating.",MJX310:t=>`Route path cannot be empty; use '/' for the default child. Under parent "${t}".`,MJX311:(t,e)=>`Child route path should start with '/': "${t}" under parent "${e}".`,MJX312:t=>`Child route path resolves to the same full path as its parent: "${t}".`,MJX313:t=>`Multiple routes resolve to the same full path: "${t}".`,MJX314:(t,e)=>`Child route alias should start with '/': "${t}" under parent "${e}".`,MJX315:t=>`Route alias resolves to the route's own path: "${t}".`,MJX316:t=>`Multiple routes use the same alias: "${t}".`,MJX401:t=>`Service not registered for token: ${t}`,MJX402:t=>`Async factory used with get() for token ${t}; use getAsync().`,MJX403:()=>"Invalid service descriptor.",MJX404:t=>`Cyclic dependency detected: ${t}`,MJX405:()=>"Only one ApplicationBuilder instance is allowed.",MJX406:t=>`Application.run: host not found for selector: ${t}`,MJX407:t=>`getService: no ServiceProvider found for token '${t}'.`,MJX408:(t,e)=>`getService failed for token '${t}': ${e}`,MJX409:t=>`inject(${t}) was called outside a service construction; call it in a field initializer or constructor of a class the ServiceProvider creates.`,MJX410:(t,e)=>`Multiple sources provided for token '${t}': ${e}. Resolution order is useValue > useFactory > useClass.`,MJX411:t=>`'deps' must be an array for token '${t}'; the invalid deps are ignored.`,MJX413:t=>`Service '${t}' is registered with a function that cannot be constructed. Use { useValue: fn } to provide the function itself or { useFactory: fn } to create the service.`,MJX414:(t,e)=>`FromService failed for token '${t}': ${e}`,MJX501:()=>"Disposable already disposed.",MJX502:()=>"Cannot register a disposable on itself.",MJX503:()=>"Errors were thrown while disposing a store.",MJX504:()=>"A disposable was added to a DisposableStore that is already disposed; the added object will leak.",MJX505:()=>"Cannot dispose a disposable on itself.",MJX507:(t,e,s)=>`[${t}] potential listener LEAK: ${e} listeners already; most frequent stack (${s}):`,MJX601:()=>"Sequence contains no elements.",MJX602:()=>"Circuit is open.",MJX603:()=>"Bulkhead queue is full.",MJX604:()=>"Rate limit exceeded.",MJX605:()=>"Operation timed out.",MJX607:()=>"A history must be created with at least one entry.",MJX608:()=>"Method not implemented.",MJX609:()=>"OperationRunner: the operation threw.",MJX610:()=>"Matching the request path failed.",MJX611:()=>"The devtools panel failed to load."};class w extends Error{constructor(t,e,s){super(e,s),this.name="MotifError",this.code=t}}function b(t,...e){return`[motifjs] ${t}: ${v[t](...e)}`}function S(t,...e){return new w(t,b(t,...e))}function M(t,e,...i){s.report(new w(t,b(t,...i),{cause:e}))}function C(t,e,...s){try{const i=t();i&&"function"==typeof i.then&&i.then(void 0,t=>M(e,t,...s))}catch(t){M(e,t,...s)}}function k(t,e,s){m(t,v[t](...e),s)}const D=new class{constructor(){this.disposableTracker=null}notifyCreated(t){return this.disposableTracker?.trackDisposable(t),t}notifyDisposed(t){this.disposableTracker?.markAsDisposed(t)}notifyOwner(t,e){this.disposableTracker?.setParent(t,e)}toDisposable(t){let e=!0;const s={dispose:()=>{e&&(e=!1,this.notifyDisposed(s),t())}};return this.notifyCreated(s)}};class A{constructor(){this._closed=!1,D.notifyCreated(this)}get isDisposed(){return this._closed}add(t){if(!t)return t;if(t===this)throw S("MJX502");return D.notifyOwner(t,this),this._closed?k("MJX504",[],(new Error).stack):(this._items??=new Set).add(t),t}delete(t){if(t){if(t===this)throw S("MJX505");this._items?.delete(t),t.dispose()}}detach(t){t&&this._items?.delete(t)&&D.notifyOwner(t,null)}clear(){const t=this._items;if(!t||0===t.size)return;const e=[];for(const s of t)try{s?.dispose()}catch(t){e.push(t)}if(t.clear(),1===e.length)throw e[0];if(e.length>1)throw new w("MJX503",b("MJX503"),{cause:new AggregateError(e)})}dispose(){this._closed||(D.notifyDisposed(this),this._closed=!0,this.clear())}}let x;class E{get _disposables(){let t=this._store;return void 0===t&&(t=this._store=new A,D.notifyOwner(t,this)),t}constructor(){this._store=void 0,D.notifyCreated(this)}dispose(){D.notifyDisposed(this);const t=this._store;void 0===t?this._store=(void 0===x&&(x=new A,x.dispose()),x):t&&"function"==typeof t.dispose?t.dispose():k("MJX501",[],{disposable:this})}_register(t){if(t===this)throw S("MJX502");return this._disposables.add(t)}}const T={IS_REACTIVE:Symbol.for("motif.isReactive"),IS_READONLY:Symbol.for("motif.isReadonly"),IS_SUPERFICIAL:Symbol.for("motif.isSuperficial"),RAW:Symbol.for("motif.raw"),GET_SETUP:Symbol.for("motif.getSetup")},O=Symbol("");let N=!0,P={enabled:!1,key:""};function L(t){let e=t;for(;e&&e[T.RAW];)e=e[T.RAW];return e}function X(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function R(t){return"object"==typeof t&&null!==t}const I=new Set(Object.values(Object.getOwnPropertyDescriptors(Symbol)).map(t=>t.value).filter(t=>"symbol"==typeof t));function J(t){return"symbol"==typeof t&&I.has(t)}const j=new Map([["[object Object]",1],["[object Array]",1],["[object Map]",2],["[object Set]",2],["[object WeakMap]",2],["[object WeakSet]",2]]);const F=/^(?:0|[1-9]\d*)$/,H=[];let B=0;function z(t){H[B++]=N,N=t}function V(){z(!1)}function W(){N=!(B>0)||H[--B]}const $=[];class U{constructor(t,e,s,i){this.component=t,this.itemsFn=e,this.renderFn=s,this.options=i,this.propertyName="__list__",this._isActive=!1,this._rendered=[],this._identityMap=new WeakMap,this.container=zi("list-container"),this.olditems=[],this.component.controls.add(this.container)}activate(){this._isActive||(this._isActive=!0,this._setupBinding())}deactivate(){this._isActive&&(this._isActive=!1,this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0),this._disposeAll())}reActivate(){this.deactivate(),this.activate()}_disposeAll(){this._rendered.forEach(t=>{try{t.dispose&&t.dispose()}catch{}}),this._rendered=[],this._identityMap=new WeakMap}_toArray(t){return t?Array.isArray(t)?t:"function"==typeof t?this._toArray(t()):t[Symbol.iterator]?Array.from(t):[]:[]}_getComponentKey(t){try{const e=t.props;if(e&&"function"==typeof e.indexkey)return e.indexkey();if(e&&void 0!==e.indexkey&&null!==e.indexkey)return e.indexkey}catch{}try{const e=t.motif.options?.__key;if(void 0!==e)return e}catch{}}isPreCreated(t){return null!==t.element||null!==t.parent}_render(t,e){return Ot(()=>{const s=this.renderFn(t,e);return this.processRendered(s,t)})}processRendered(t,e){const s=Ei(t);if(!(s instanceof zs))throw S("MJX201");try{s._base.itemRef=e}catch{}try{s.motif.options.__fromList=!0}catch{}return void 0===s.__listAdopted&&(s.__listAdopted=null!==s.parent&&void 0!==s.parent),s}get _indexSensitive(){try{return this.renderFn.length>=2}catch{return!0}}static _isPrimitive(t){return null===t||"object"!=typeof t}_setupBinding(){const t=()=>{const t=this._toArray(this.itemsFn()),e=L(t),s=t.length;let i;if(e===t)i=t;else{i=new Array(s);for(let n=0;n<s;n++)n in e?i[n]=t[n]:t[n]}const n=this.olditems,o=this._rendered;if(this.olditems.length>0){const t=new Set;for(let e=0;e<s;e++)t.add(L(i[e]));for(const e of this.olditems){const s=L(e);if(!t.has(s)){const t=this._identityMap.get(s);if(t){this._identityMap.delete(s);for(const e of t)try{e.dispose()}catch{}}}}}const r=[],a=new Set,c=new Map,l=new Set,h=new Map,u=t=>!(!t||t.isDisposed||l.has(t)||t.__listAdopted),d=Math.min(i.length,n.length);for(let t=0;t<d;t++){const e=i[t];if(!U._isPrimitive(e))continue;if(!Object.is(n[t],e))continue;const s=o[t];u(s)&&(h.set(t,s),l.add(s))}let p=null;if(!this._indexSensitive){p=new Map;for(let t=0;t<n.length;t++){const e=n[t];if(!U._isPrimitive(e))continue;const s=o[t];if(!u(s))continue;const i=p.get(e);i?i.push(s):p.set(e,[s])}}const f=new Map;return i.forEach((t,e)=>{let s;if("object"==typeof t&&null!==t){const i=L(t),n=f.get(i)??0;f.set(i,n+1);let o=this._identityMap.get(i);o||(o=[],this._identityMap.set(i,o));const r=o[n];r&&!r.isDisposed?s=r:(s=this._render(t,e),o[n]=s)}else{let i=h.get(e);if(!i&&p){const e=p.get(t);e&&e.length&&(i=e.shift(),l.add(i))}s=i||this._render(t,e)}const i=this._getComponentKey(s);null!=i&&(c.has(i)?k("MJX202",[i,e]):c.set(i,e)),r.push(s),a.add(s)}),f.forEach((t,e)=>{const s=this._identityMap.get(e);s&&s.length>t&&(s.length=t)}),this._rendered.forEach(t=>{if(!a.has(t)&&!t.__listAdopted)try{t.dispose()}catch{}}),this._syncContainer(r),this._rendered=r,this.olditems=i===t?t.slice():i,s};this._effectCleanup=At(()=>t())}_syncContainer(t){const e=this.container.controls,s=e.items;if(0===s.length){for(const s of t)try{e.add(s)}catch{}return}if(t.length>=s.length){let i=!0;for(let e=0;e<s.length;e++)if(t[e]!==s[e]){i=!1;break}if(i&&t.length>s.length){const e=new Set(s);for(let n=s.length;n<t.length;n++){if(e.has(t[n])){i=!1;break}e.add(t[n])}}if(i){for(let i=s.length;i<t.length;i++)try{e.add(t[i])}catch{}return}}const i=new Map;s.forEach((t,e)=>i.set(t,e));const n=t.map(t=>{const e=i.get(t);return void 0===e?-1:e}),o=new Set(function(t){const e=new Array(t.length).fill(-1),s=[];for(let i=0;i<t.length;i++){const n=t[i];if(-1===n)continue;if(0===s.length||t[s[s.length-1]]<n){e[i]=s.length>0?s[s.length-1]:-1,s.push(i);continue}let o=0,r=s.length-1;for(;o<r;){const e=o+r>>1;t[s[e]]<n?o=e+1:r=e}n<t[s[o]]&&(e[i]=o>0?s[o-1]:-1,s[o]=i)}const i=[];let n=s.length>0?s[s.length-1]:-1;for(;-1!==n;)i.push(n),n=e[n];return i.reverse()}(n));if(t.length===s.length&&function(t,e,s){const i=new Uint8Array(t.length);for(let n=0;n<t.length;n++){const o=t[n];if(-1===o||i[o])return!1;i[o]=1;const r=e[n];if(r.isDisposed||r.parent!==s)return!1}return!0}(n,t,this.container))return void e._reorder(t,o);let r=null;for(let i=t.length-1;i>=0;i--){const a=t[i];try{if(-1===n[i])if(r){const t=s.indexOf(r);e.add(t>=0?t:s.length,a)}else e.add(a);else o.has(i)||e.move(a,r)}catch{}r=a}}}class q{}class G{constructor(){this.__list=[],this._map=new Set}Dispose(){this.__list=[]}Add(t){this._map.add(t);var e=this.__list.push(t)-1;return null!=this.ItemAdded&&this.ItemAdded(t),e}AddBefore(t){this._map.add(t);var e=this.__list.unshift(t)-1;return null!=this.ItemAddedBefore&&this.ItemAddedBefore(t),e}Insert(t,e){this._map.add(e);var s=this.__list.splice(t,0,e);return null!=this.ItemSplice&&this.ItemSplice(t,e),s}get items(){return this.__list}clear(){return this._map.clear(),this.__list.splice(0),this.__list=[],this.__list}get count(){return this.__list.length}remove(t){const e=this.__list.indexOf(t);return-1===e?[]:(this._map.delete(t),this.__list.splice(e,1))}indexOf(t){return this.__list.indexOf(t)}FindFromKey(t,e){return this.__list.filter(s=>s[t]===e)}removeIndex(t){var e=this.__list.splice(t,1);return e.forEach(t=>{this._map.delete(t)}),e}has(t){return this._map.has(t)}item(t){return this.__list[t]}forEach(t){this.__list?.forEach(t)}ReverseClone(){return this.__list.slice().reverse()}filter(t){return this.__list.filter(t)}}function K(t){let e=!0;return{dispose(){e&&(e=!1,t())}}}function Y(t){return"/"+t.replace(/^\/+|\/+$/g,"")}function Q(t){try{if(t.isDisposed)return null;if(t.element.nodeType!==Node.COMMENT_NODE&&t.element.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.element.nodeType!==Node.TEXT_NODE)return t;if(t.parent)return Q(t.parent)}catch(t){throw t}return null}class Z{constructor(t,e){this.threshold=t,this.name=e,this._origins=new Map,this._quietChecks=0}check(t){if(this.threshold<=0||t<this.threshold)return;const e=(new Error).stack??"";if(this._origins.set(e,(this._origins.get(e)??0)+1),this._quietChecks--,this._quietChecks<=0){this._quietChecks=this.threshold/2;const[e,s]=this._busiestOrigin();k("MJX507",[this.name,t,s],e)}return()=>{this._origins.set(e,(this._origins.get(e)??0)-1)}}_busiestOrigin(){let t=["",0];for(const e of this._origins)e[1]>t[1]&&(t=e);return t}}class tt{constructor(){this.__values=new G}Add(t,e){var s=new q;s.Key=t,s.value=e;var i=this.__values.Add(s);return null!=this.OnItemAdded&&this.OnItemAdded(s.Key,s.value),i}has(t){return!!this.filter(e=>e.Key==t)[0]}item(t){return this.filter(e=>e.Key==t)[0]}removeIndex(t){return this.__values.removeIndex(t)}remove(t){this.__values.filter(e=>e.Key==t).forEach(t=>{this.__values.remove(t)})}clear(){this.__values.clear()}forEach(t){this.__values.forEach(t)}get values(){return this.__values}filter(t){return this.__values.items.filter(t)}find(t,e){return this.__values.items.find(t)}}function et(){const t={value:void 0,linked:!1};return t.before=t,t.after=t,t}class st{constructor(){this._ring=et(),this._count=0}get size(){return this._count}isEmpty(){return 0===this._count}push(t){return this._link(t,this._ring.before)}unshift(t){return this._link(t,this._ring)}pop(){return this._take(this._ring.before)}shift(){return this._take(this._ring.after)}clear(){for(let t=this._ring.after;t!==this._ring;t=t.after)t.linked=!1;this._ring=et(),this._count=0}*[Symbol.iterator](){const t=this._ring;for(let e=t.after;e!==t;e=e.after)yield e.value}_link(t,e){const s={value:t,before:e,after:e.after,linked:!0};return e.after.before=s,e.after=s,this._count++,()=>this._unlink(s)}_take(t){if(t===this._ring)return;const e=t.value;return this._unlink(t),e}_unlink(t){t.linked&&(t.linked=!1,t.before.after=t.after,t.after.before=t.before,this._count--)}}function it(t){return"function"==typeof t?t:()=>t}function nt(t){return"function"==typeof t?t():t}function ot(t,e){return t>e?1:t<e?-1:0}class rt{constructor(t){this.source=Array.isArray(t)?t:Array.from(t)}static from(t){return new rt(t)}where(t){return new rt(this.source.filter(t))}select(t){return new rt(this.source.map(t))}orderBy(t){return new rt([...this.source].sort((e,s)=>ot(t(e),t(s))))}orderByDescending(t){return new rt([...this.source].sort((e,s)=>ot(t(s),t(e))))}distinctBy(t){const e=new Set;return new rt(this.source.filter(s=>{const i=t(s);return!e.has(i)&&(e.add(i),!0)}))}groupBy(t){const e=new Map;for(const s of this.source){const i=t(s),n=e.get(i);n?n.push(s):e.set(i,[s])}return new rt(Array.from(e,([t,e])=>({key:t,items:e})))}first(){if(0===this.source.length)throw S("MJX601");return this.source[0]}firstOrDefault(){return this.source[0]}any(t){return t?this.source.some(t):this.source.length>0}all(t){return this.source.every(t)}aggregate(t,e){return this.source.reduce(e,t)}toArray(){return[...this.source]}[Symbol.iterator](){return this.source[Symbol.iterator]()}}const at=[1,2],ct=new Set,lt=new Set;function ht(t){at.includes(t)||ct.has(t)||(c()?(lt.delete(t),ct.add(t),k("MJX121",[t,2])):lt.add(t))}var ut;!function(t){t[t.ELEMENT_NODE=1]="ELEMENT_NODE",t[t.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",t[t.TEXT_NODE=3]="TEXT_NODE",t[t.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",t[t.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",t[t.ENTITY_NODE=6]="ENTITY_NODE",t[t.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",t[t.COMMENT_NODE=8]="COMMENT_NODE",t[t.DOCUMENT_NODE=9]="DOCUMENT_NODE",t[t.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",t[t.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE",t[t.NOTATION_NODE=12]="NOTATION_NODE"}(ut||(ut={}));class dt{constructor(t,e){this.fn=t,this.callback=e,this.deps=[],this.active=!0,this.running=!1}run(){let t;if(this.active&&!this.running){Dt(this),ft.push(this),this.running=!0;try{t=this.fn()}finally{ft.pop(),this.running=!1,this.callback&&this.callback(t)}}}stop(){this.active=!1,Dt(this)}}const pt=new WeakMap,ft=[],mt=new Set;let _t,gt=!1,yt=!1,vt=-1;const wt=new WeakMap;function bt(t={}){yt=!!t.enabled,vt="number"==typeof t.threshold?t.threshold:yt?200:-1,_t=yt&&vt>0?new Z(vt,t.name??"reactivity-core"):void 0}function St(t,e){if(!N)return;const s=L(t),i=ft[ft.length-1];if(!i||!i.active)return;let n=pt.get(s);n||pt.set(s,n=new Map);let o=n.get(e);if(o||n.set(e,o=new Set),!o.has(i)&&(o.add(i),i.deps.push([s,e]),yt&&_t&&vt>0))try{const t=_t.check(o.size);if(t){let e=wt.get(o);e||(e=new Map,wt.set(o,e)),e.set(i,t)}}catch{}}function Mt(t,e){const s=L(t),i=pt.get(s);if(!i)return;const n=i.get(e);if(!n)return;let o=!1;n.forEach(t=>{t.active&&(t.scheduler?Ct(t.scheduler):(mt.add(t),o=!0))}),o&&function(){if(gt)return;gt=!0,Promise.resolve().then(()=>{const t=new Map;try{for(;mt.size>0;){const e=Array.from(mt);mt.clear();for(const s of e){const e=(t.get(s)??0)+1;t.set(s,e),e>kt?e===kt+1&&k("MJX203",[kt],{fn:String(s.fn).slice(0,200)}):Ct(()=>s.run())}}}finally{mt.clear(),gt=!1}})}()}function Ct(t){try{t()}catch(t){M("MJX208",t)}}const kt=50;function Dt(t){for(const[e,s]of t.deps){const i=pt.get(e);if(!i)continue;const n=i.get(s);if(n){n.delete(t);try{const e=wt.get(n),s=e?.get(t);if(s){try{s()}catch{}e.delete(t)}}catch{}0===n.size&&i.delete(s),0===i.size&&pt.delete(e)}}t.deps=[]}function At(t,e){const s=new dt(t,e);return Ct(()=>s.run()),()=>s.stop()}function xt(t){if(!t.pushed)return;t.pushed=!1;const e=ft.lastIndexOf(t.effect);e>=0&&ft.splice(e,1)}const Et={capture:()=>({effect:ft[ft.length-1],pushed:!1}),suspend:(t,e)=>(xt(t),e),resume:(t,e)=>(t.effect&&t.effect.active&&!t.pushed&&(ft.push(t.effect),t.pushed=!0),e),end(t){xt(t)}},Tt=new dt(()=>{});function Ot(t){ft.push(Tt);try{return t()}finally{ft.pop()}}function Nt(t){if(!t||"INPUT"!==t.tagName)return!1;const e=String(t.type||"").toLowerCase();return"checkbox"===e||"radio"===e}function Pt(t){if(t){if(Nt(t))return!!t.checked;if(function(t){if(!t||"INPUT"!==t.tagName)return!1;const e=String(t.type||"").toLowerCase();return"number"===e||"range"===e}(t)){const e=t.value;if(""===e||null==e)return null;const s="number"==typeof t.valueAsNumber?t.valueAsNumber:Number(e);return Number.isFinite(s)?s:null}return t.value}}Tt.active=!1;class Lt{constructor(t,e,s,i,n,o){this.updateMode="onPropertyChanged",this._isActive=!1,this._memberPath=null,this._component=t,this.propertyName=e,this.dataSource=s,this.dataMember=i,this.formatString=n,this.formatInfo=o,this._memberPath=i?i.split("."):null,this._memberPathSource=i}activate(){this._isActive||(this._isActive=!0,this._setupBinding())}deactivate(){this._isActive&&(this._isActive=!1,this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0))}reActivate(){this._effectCleanup&&(this._effectCleanup(),this._effectCleanup=void 0),this._setupBinding()}functional(t){return"function"==typeof t&&(t=this.functional(t())),t}_setupBinding(){const t=()=>{let t=this.dataSource;if(this.dataMember){this._memberPathSource!==this.dataMember&&(this._memberPath=this.dataMember.split("."),this._memberPathSource=this.dataMember);for(const e of this._memberPath)null!=t&&(t=t[e])}return t=this.functional(t),this.formatString&&null!=t&&(t=this._applyFormat(t,this.formatString)),this.converter&&(t=this.converter(t)),t},e=()=>{const e=t();return this._updateComponentProperty(e),e};this._effectCleanup=At(()=>e())}_updateComponentProperty(t){switch(this.propertyName.toLowerCase()){case"wait":{const e=this._component;if(!e||e.isDisposed)return;const s=!!t;e.isBuilt?e.isWait=!!s:e.isWait=s;break}case"display":{const e=this._component;if(!e||e.isDisposed)return;const s=t;e.isBuilt,e.isWait=!s;break}case"text":case"textcontent":this._component.setText(t);break;case"innerhtml":case"html":this._component.element.innerHTML=t,this._component.motif.trigger("htmlChanged",{value:t});break;case"visible":case"visibility":t?this._component.motif.show():this._component.motif.hide();break;case"style":"object"==typeof t&&this._component.style(t);break;case"model":{const e=this._component.element;if(!e)break;Nt(e)?e.checked=!!t:e.value=null==t?"":t;break}case"when":break;default:this._component.element&&this.propertyName in this._component.element?this._component.element[this.propertyName]=t:this.propertyName in this._component&&(this._component[this.propertyName]=t)}}_applyFormat(t,e){const s=this.formatInfo?.locale,i=this.formatInfo?.currency;if("number"==typeof t){if(e.includes("C")||e.includes("c"))return i?new Intl.NumberFormat(s,{style:"currency",currency:i}).format(t):new Intl.NumberFormat(s,{minimumFractionDigits:2,maximumFractionDigits:2}).format(t);if(e.includes("P")||e.includes("p"))return new Intl.NumberFormat(s,{style:"percent"}).format(t);if(e.includes("N")||e.includes("n")){const i=parseInt(e.match(/\d+/)?.[0]||"2");return new Intl.NumberFormat(s,{minimumFractionDigits:i,maximumFractionDigits:i}).format(t)}}if(t instanceof Date){if(e.includes("d"))return t.toLocaleDateString(s);if(e.includes("t"))return t.toLocaleTimeString(s)}return t?.toString()||""}}const Xt=T.RAW;function Rt(t,e,s){let i=Object.getPrototypeOf(t);for(;i&&i!==e;){if(Object.prototype.hasOwnProperty.call(i,s))return!0;i=Object.getPrototypeOf(i)}return!1}function It(t,e){for(const s of e){let e=t[s];"function"==typeof e&&Object.defineProperty(t,s,{configurable:!0,enumerable:!1,get(){if(this===t||(i=this,Object.prototype.hasOwnProperty.call(i,"constructor")&&"function"==typeof i.constructor&&i.constructor.prototype===i))return e;var i;const n=this[Xt]??this,o=e.bind(n);if(!Rt(n,t,s))try{Object.defineProperty(n,s,{value:o,writable:!0,configurable:!0,enumerable:!0})}catch{}return o},set(i){this!==t||"function"!=typeof i?Object.defineProperty(this,s,{value:i,writable:!0,configurable:!0,enumerable:!0}):e=i}})}}function Jt(t){return"function"==typeof t?Jt(t()):t}function jt(t,e){return"__proto__"!==e&&("constructor"!==e&&"prototype"!==e||Object.prototype.hasOwnProperty.call(t,e))}class Ft{constructor(t){this._items=[],this._branchScope=null,this._component=t}_own(t){this._branchScope?this._branchScope.push(t):this._component.motif.register(K(()=>{try{t()}catch{}}))}when(t,e){var s=new hn;this._component.controls.add(s);let i,n=!1;const o=At(t,t=>{n&&(Object.is(i,t)||!i&&!t)||(n=!0,i=t,Ot(()=>{t?s.navigate(e(t)):s.navigate(zi())}))});return this._own(o),null}get items(){return[...this._items]}text(t){this.add("textContent",t)}value(t){this.add("value",t)}add(...t){let e;if(1===t.length&&"object"==typeof t[0]&&"propertyName"in t[0])e=t[0];else{const[s,i,n,o,r]=t;e=new Lt(this._component,s,i,n,o,r)}return this._items.push(e),this._component.isBuilt&&e.activate(),e}wait(t){const e=new Lt(this._component,"isWait",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}display(t){const e=new Lt(this._component,"isWait",()=>!Jt(t()));return this._items.push(e),this._component.isBuilt&&e.activate(),e}html(t){const e=new Lt(this._component,"innerHTML",t);return this._items.push(e),this._component.isBuilt&&e.activate(),e}list(t,e,s){const i=new U(this._component,t,e,s);return this._items.push(i),this._component.isBuilt&&i.activate(),i}loop(t,e,s){const i=new U(this._component,t,e,s);return this._items.push(i),this._component.isBuilt&&i.activate(),i}method(t){const e=this._component;let s=null,i=null;const n=(t,s)=>{s?(e.controls.insert(e.controls.items.indexOf(s),t),e.controls.remove(s)):e.controls.add(t)},o=At(t,t=>{if(e.isDisposed)return;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||s&&null==t)return s?void s.setText(t):(s=new Oi(qi.createTextNode(t)),n(s,i),void(i=null));i||(i=new hn,n(i,s),s=null),i.navigate(null==t?zi():t)});e.motif.register(K(()=>{try{o()}catch{}}))}ternary(t,e,s){const i=new hn;return this._component.controls.add(i),this._ternaryCallTop(t,()=>{e(i)},()=>{s(i)}),null}_ternarySchedule(t,e,s,i){let n,o=!0,r=!1,a=[];const c=()=>{const t=a;a=[];for(const e of t)try{e()}catch{}},l=At(t,t=>{if(!o&&Object.is(n,t))return;n=t;const l=()=>{c();const i=this._branchScope;this._branchScope=a;try{t?e():s()}finally{this._branchScope=i}};if(o)return o=!1,void Ot(l);i(()=>{r||this._component.isDisposed||l()})});this._own(()=>{r=!0,l(),c()})}ternaryCall(t,e,s){this._ternarySchedule(t,e,s,t=>queueMicrotask(t))}_ternaryCallTop(t,e,s){this._ternarySchedule(t,e,s,t=>setTimeout(t,0))}watch(t){const e=At(()=>{t()});this._component.motif.register(K(()=>{try{e()}catch{}}))}remove(t){const e=this._items.indexOf(t);e>-1&&(this._items.splice(e,1),t.deactivate())}clear(){this._items.forEach(t=>t.deactivate()),this._items=[]}activateAll(){this._items.forEach(t=>{t.activate()})}model(...t){var e="";this._component.element&&(e=this._component.element.tagName);var s="value";switch(e.toLowerCase()){case"input":s="model";break;case"select":case"textarea":s="value";break;case"img":case"audio":case"video":s="src"}let i;if(1===t.length&&"object"==typeof t[0])i=t[0];else if("function"==typeof t[0]&&"function"==typeof t[1])i=new Lt(this._component,s,t[0]),i.setter=t[1];else{const[e,n,o,r]=t;i=new Lt(this._component,s,e,n,o,r)}const n=t=>{let e=t;const s=i;if("function"==typeof s.converterBack&&(e=s.converterBack(e)),"function"==typeof s.setter)return void s.setter(e);const n=s.dataMember,o=s.dataSource;if(n&&null!=o){const t=n.split(".");let s=o;for(let i=0;i<t.length&&null!=s;i++){const n=t[i];if(!jt(s,n))return;i===t.length-1?s[n]=e:s=s[n]}}else null!=o&&"object"==typeof o&&"value"in o&&(o.value=e)};(this._modelWriters??=new WeakMap).set(i,n);const o=e.toLowerCase();if("input"===o||"select"===o||"textarea"===o){const t=()=>{try{const t=this._component.element;if(!t)return;n(Pt(t))}catch{}};this._component.motif.on("input",t),this._component.motif.on("change",t)}return this._items.push(i),this._component.isBuilt&&i.activate(),i}writeModel(t){const e=this._modelWriters;if(!e)return!1;let s=!1;for(const i of this._items){const n=e.get(i);if(n)try{n(t),s=!0}catch{}}return s}deactivateAll(){this._items.forEach(t=>t.deactivate()),this._items=[]}reActivateAll(){for(const t of[...this._items])if("function"==typeof t.reActivate)try{t.reActivate()}catch(t){M("MJX208",t)}}switchCase(t,e,s){const i=new hn;var n;this._component.controls.add(i);var o=!1;const r=At(t,t=>{if(n==t)return;n=t;const r=String(t);if(Object.prototype.hasOwnProperty.call(e,r))e[r](i),o=!1;else if(s){if(o)return;o=!0,s(i)}else{if(o)return;o=!0,i.navigate(zi())}});return this._component.motif.register(K(()=>{try{r()}catch{}})),null}}It(Ft.prototype,["add","remove","clear","activateAll","deactivateAll","reActivateAll","when","text","value","list","loop","method","watch","display","wait","ternaryCall","_ternaryCallTop"]);class Ht{constructor(){this._subscriptions=[],this._disposed=!1}get event(){return this._subscribe||(this._subscribe=(t,e,s)=>{if(this._disposed)return{dispose(){}};const i={handler:e?t.bind(e):t,active:!0};this._writable().push(i);const n={dispose:()=>this._unsubscribe(i)};return s instanceof A?s.add(n):Array.isArray(s)&&s.push(n),n}),this._subscribe}fire(t){this._resume(),0!==this._subscriptions.length&&(this._delivery={targets:this._subscriptions,value:t,next:0},this._resume())}dispose(){if(!this._disposed){this._disposed=!0;for(const t of this._subscriptions)t.active=!1;this._subscriptions=[],this._delivery=void 0}}_writable(){return this._delivery&&this._delivery.targets===this._subscriptions&&(this._subscriptions=this._subscriptions.slice()),this._subscriptions}_unsubscribe(t){if(!t.active)return;t.active=!1;const e=this._writable(),s=e.indexOf(t);-1!==s&&e.splice(s,1)}_resume(){const t=this._delivery;if(t){for(;t.next<t.targets.length;){const e=t.targets[t.next++];if(e.active)try{e.handler(t.value)}catch(t){s.onUnexpectedError(t)}}this._delivery===t&&(this._delivery=void 0)}}}class Bt{constructor(t){this.component=t}hasListeners(t){return void 0!==this._emitters&&this._emitters.has(t)}fire(t,e){try{const s=this._emitters?.get(t.toLowerCase());s&&s.fire(e)}catch{}}on(t,e){try{this.createEvent(t,e)}catch{}}off(t,e){const s=String(t).toLowerCase(),i=this._listenerDisposables?.get(s);if(!i)return this;const n=i.get(e);return i.delete(e),n?.forEach(t=>{try{t.dispose()}catch{}}),this}getOrCreateEmitter(t){const e=this._emitters??=new Map;let s=e.get(t);return s||(s=new Ht,e.set(t,s)),s}createEvent(t,e){const s=String(t).toLowerCase(),i=s.startsWith("on")?"x:"+s.slice(2):s,n=t=>{let s;return C(()=>(s=e.length<=1?e(t):e(this.component,t),s),"MJX122",i),s},o=this.getOrCreateEmitter(s).event(t=>n(t)),r=this._listenerDisposables??=new Map;let a=r.get(s);a||(a=new Map,r.set(s,a));const c=a.get(e);return c?c.push(o):a.set(e,[o]),this}addSource(t,e){const s=String(t).toLowerCase(),i=this.getOrCreateEmitter(s),n=t=>t(t=>i.fire(t));let o;try{o=n(e instanceof Ht?e.event:e)}catch{}if(o){const t=this._sourceDisposables??=new Map;let e=t.get(s);e||(e=new Set,t.set(s,e)),e.add(o),this.component.motif.register(D.toDisposable(()=>{try{o?.dispose()}catch{}try{e?.delete(o)}catch{}}))}return this}clear(t){if(t){const e=t.toLowerCase(),s=this._sourceDisposables?.get(e);s?.forEach(t=>{try{t.dispose()}catch{}}),this._sourceDisposables?.delete(e);const i=this._emitters?.get(e);try{i?.dispose()}catch{}this._emitters?.delete(e),this._listenerDisposables?.delete(e)}else if(this._emitters)for(const t of Array.from(this._emitters.keys()))this.clear(t);return this}}It(Bt.prototype,["fire","on","off","createEvent","getOrCreateEmitter","addSource","clear"]);const zt=new Set(["focus","blur","click","pause","submit","reset","scrollTo","scrollBy","select","scrollIntoView","requestFullscreen","exitFullscreen","requestPointerLock","exitPointerLock","play","requestPictureInPicture","exitPictureInPicture","show","showModal","close","showPopover","hidePopover","togglePopover","requestSubmit","checkValidity","reportValidity","showPicker","load","setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Vt={show:"close",showModal:"close",showPopover:"hidePopover"},Wt=new Set(["close","hidePopover","requestSubmit","checkValidity","reportValidity","showPicker","load"]),$t=new Set(["setSelectionRange","setRangeText","setPointerCapture","releasePointerCapture","fastSeek"]),Ut=new Set(["checked","selected","muted","indeterminate","srcObject"]);class qt{constructor(t){this._parent=t}get _attrMap(){return this._attrMapStore??=new Map}get _watchers(){return this._watchersStore??=new Map}get attributes(){return Array.from(this._attrMap.entries(),([t,e])=>({name:String(t),value:e}))}add(t){if(null!==t&&"object"==typeof t&&!Array.isArray(t)){const e=t;Reflect.ownKeys(e).forEach(t=>{this.parse(e[t],t)})}return this._parent}remove(t){const e=this._watchers.get(t);if(e){try{e.stop()}catch{}try{e.binding&&this._parent.bindings.remove(e.binding)}catch{}this._watchers.delete(t)}this._attrMap.delete(t);const s=this._getElement();if(s)try{s.removeAttribute(t)}catch{}return this._parent}has(t){return(this._parent.element instanceof HTMLElement||this._parent.element instanceof Element)&&this._parent.element.hasAttribute(t)}get(t){const e=this._getElement();if(e){const s=e.getAttribute(t);if(null!=s)return s}const s=this._attrMap.get(t);return null==s?null:String(s)}parse(t,e){if("function"==typeof t){const s=this._watchers.get(e);if(s){try{s.stop()}catch{}try{s.binding&&this._parent.bindings.remove(s.binding)}catch{}this._watchers.delete(e)}const i=()=>At(()=>{const s=t();this._applyValue(e,s)});let n=i();const o=()=>{try{n()}catch{}},r={propertyName:`__attr:${String(e)}`,dataSource:null,activate(){},deactivate(){o()},reActivate(){o(),n=i()}};try{this._parent.bindings.add(r)}catch{}this._watchers.set(e,{stop:o,binding:r})}else this._applyValue(e,t)}_applyValue(t,e){if(!t)return;const s=this._getElement();try{"function"==typeof e&&"function"==typeof(e=e())&&(e=e())}catch{}if(s&&"string"==typeof t&&zt.has(t)){const i=t,n=s[i];if("function"==typeof n){const o=(t,e)=>{try{Array.isArray(e)?t.apply(s,e):void 0===e?t.call(s):t.call(s,e)}catch{}},r=t=>{try{queueMicrotask(t)}catch{try{setTimeout(t,0)}catch{}}},a=()=>{this._attrMap.set(t,e)};if("focus"===i){return r(()=>{if(!1===e){const t=s.blur;"function"==typeof t&&o(t)}else!0===e?o(n):("object"==typeof e&&null!=e&&!0!==e||Array.isArray(e),o(n,e))}),void a()}if("blur"===i||"click"===i||"pause"===i||"submit"===i||"reset"===i){return r(()=>{e&&o(n)}),void a()}if("scrollTo"===i||"scrollBy"===i){return r(()=>{(Array.isArray(e)||e&&"object"==typeof e)&&o(n,e)}),void a()}if("select"===i){return r(()=>{if(e)o(n);else{const t=s;if("function"==typeof t.setSelectionRange)try{t.setSelectionRange(0,0)}catch{}}}),void a()}if("scrollIntoView"===i){return r(()=>{!0===e||null==e?o(n):o(n,e)}),void a()}if("requestFullscreen"===i){return r(()=>{if(e)o(n);else try{const t=document;t&&t.fullscreenElement===s&&"function"==typeof t.exitFullscreen&&t.exitFullscreen()}catch{}}),void a()}if("exitFullscreen"===i){return r(()=>{if(e)try{const t=document;t&&"function"==typeof t.exitFullscreen&&t.exitFullscreen()}catch{}}),void a()}if("requestPointerLock"===i){return r(()=>{if(e)o(n);else try{const t=document;t&&"function"==typeof t.exitPointerLock&&t.exitPointerLock()}catch{}}),void a()}if("exitPointerLock"===i){return r(()=>{if(e)try{const t=document;t&&"function"==typeof t.exitPointerLock&&t.exitPointerLock()}catch{}}),void a()}if("play"===i){return r(()=>{if(e)try{const t=n.call(s);t&&"function"==typeof t.then&&t.catch(()=>{})}catch{}else{const t=s.pause;"function"==typeof t&&o(t)}}),void a()}if("requestPictureInPicture"===i){return r(()=>{if(e)try{const t=n.call(s);t&&"function"==typeof t.then&&t.catch(()=>{})}catch{}}),void a()}if("exitPictureInPicture"===i){return r(()=>{if(e)try{const t=document;if(t&&"function"==typeof t.exitPictureInPicture){const e=t.exitPictureInPicture();e&&"function"==typeof e.then&&e.catch(()=>{})}}catch{}}),void a()}if(i in Vt){return r(()=>{if(!1===e){const t=s[Vt[i]];"function"==typeof t&&o(t)}else e&&o(n)}),void a()}if("togglePopover"===i){return r(()=>{if("boolean"==typeof e)try{n.call(s,e)}catch{}else e&&o(n)}),void a()}if(Wt.has(i)){return r(()=>{!0===e?o(n):e&&o(n,e)}),void a()}if($t.has(i)){return r(()=>{null!=e&&!1!==e&&o(n,e)}),void a()}return null==e||!1===e?void this._attrMap.delete(t):void a()}}if("string"==typeof t&&Ut.has(t)){const i=this._parent.element??s;if(i)try{"srcObject"===t?i.srcObject=e??null:i[t]=!!e}catch{}return void(null==e||!1===e?this._attrMap.delete(t):this._attrMap.set(t,e))}if("boolean"==typeof e&&"string"==typeof t&&(t.startsWith("aria-")||t.startsWith("data-"))){if(s)try{s.setAttribute(t,String(e))}catch{}return void this._attrMap.set(t,e)}const i="boolean"==typeof e;if(null==e||!1===e){if(s)try{s.removeAttribute(String(t))}catch{}this._attrMap.delete(t)}else{if("value"===t)try{const t=this._parent.element,s=String(e);t.value!==s&&(t.value=s)}catch{}else if("textContent"===t||"innerText"===t||"innerHTML"===t){if(si(e))return void this._parent.setText(e);try{this._parent.element[t]=e}catch{}}else if(s)try{i&&!0===e?s.setAttribute(String(t),""):s.setAttribute(String(t),e)}catch{}this._attrMap.set(t,e)}}_getElement(){const t=this._parent?.element;return t instanceof HTMLElement||t instanceof Element?t:null}hasMethodState(t){return!(!this._getElement()||!t)&&!!this.getMethodState(t)}getMethodState(t){const e=this._getElement();if(!e||!t)return!1;switch(String(t)){case"focus":case"blur":try{return(document&&document.activeElement)===e}catch{return!1}case"select":{const t=e;if("number"==typeof t.selectionStart&&"number"==typeof t.selectionEnd)try{return t.selectionEnd-t.selectionStart>0}catch{return!1}return!1}default:return!1}}}class Gt{constructor(t){this._watcherSeq=0,this._parent=t}get _counts(){return this._countsStore??=new Map}get _staticSet(){return this._staticSetStore??=new Set}get _watchers(){return this._watchersStore??=new Map}add(...t){for(const e of t)"function"==typeof e?this._addReactive(e):Array.isArray(e)?this._addStaticFromArray(e):e&&"object"==typeof e?this._addStaticFromObject(e):this._addStaticNames(this._splitClasses(String(e??"")));return this._parent}remove(t){const e=this._getElement();if(Array.isArray(t)){const s=new Set(this._staticSet);for(const e of t)for(const t of this._splitClasses(String(e)))this._staticSet.delete(t);this._applySourceDiff("static",s,new Set(this._staticSet),e)}else if("**"===t){for(const[t,s]of Array.from(this._watchers.entries())){const i=new Set(s.set);this._applySourceDiff(t,i,new Set,e);try{s.binding&&this._parent.bindings.remove(s.binding)}catch{}try{s.stop()}catch{}this._watchers.delete(t)}const t=new Set(this._staticSet);if(this._staticSet.clear(),this._applySourceDiff("static",t,new Set,e),e)try{e.removeAttribute("class")}catch{}this._counts.clear()}else{const s=new Set(this._staticSet);for(const e of this._splitClasses(String(t)))this._staticSet.delete(e);this._applySourceDiff("static",s,new Set(this._staticSet),e)}return this._parent}has(t){const e=this._getElement(),s=String(t??"").trim();return!!s&&!(!e||!e.classList.contains(s))}_getElement(){const t=this._parent?.element;return t instanceof Element?t:null}_splitClasses(t){return t?/\s/.test(t)?t.split(/\s+/).filter(t=>t.length>0):[t]:[]}_normalizeToSet(t,e){const s=new Set;if(null==t)return s;if("string"==typeof t)for(const e of this._splitClasses(t))s.add(e);else if(Array.isArray(t)){for(const i of t)if(null!=i)if("string"==typeof i)for(const t of this._splitClasses(i))s.add(t);else if(Array.isArray(i))for(const t of this._normalizeToSet(i))s.add(t);else if("object"==typeof i){const t=i;for(const e of Object.keys(t)){if(t[e])for(const t of this._splitClasses(String(e)))s.add(t)}}else if("boolean"==typeof i){if(e&&i)for(const t of this._splitClasses(String(e)))s.add(t)}else for(const t of this._splitClasses(String(i)))s.add(t)}else if("object"==typeof t){const e=t;for(const t of Object.keys(e)){if(e[t])for(const e of this._splitClasses(String(t)))s.add(e)}}else if("boolean"==typeof t){if(e&&t)for(const t of this._splitClasses(String(e)))s.add(t)}else for(const e of this._splitClasses(String(t)))s.add(e);return s}_applySourceDiff(t,e,s,i){for(const t of e)if(!s.has(t)){const e=(this._counts.get(t)||0)-1;if(e<=0){if(this._counts.delete(t),i)try{i.classList.remove(t)}catch{}}else this._counts.set(t,e)}for(const t of s)if(!e.has(t)){const e=this._counts.get(t)||0,s=e+1;if(this._counts.set(t,s),0===e&&i)try{i.classList.add(t)}catch{}}}_addStaticNames(t){if(0===t.length)return;const e=this._getElement(),s=this._staticSet,i=e&&!e.hasAttribute("class")?[]:null;for(const n of t){if(s.has(n))continue;s.add(n);const t=this._counts.get(n)||0;if(this._counts.set(n,t+1),0===t&&e)if(i)i.push(n);else try{e.classList.add(n)}catch{}}i&&i.length>0&&e.setAttribute("class",i.join(" "))}_addStaticFromArray(t){const e=this._getElement(),s=new Set(this._staticSet);for(const e of t)if(null!=e)if("string"==typeof e)for(const t of this._splitClasses(e))this._staticSet.add(t);else if(Array.isArray(e)){const t=this._normalizeToSet(e);for(const e of t)this._staticSet.add(e)}else if("object"==typeof e){const t=e;for(const e of Object.keys(t)){const s=t[e];if("function"==typeof s){const s=this._splitClasses(String(e));for(const i of s)this._addReactive(t[e],i)}else{const t=this._splitClasses(String(e));if(s)for(const e of t)this._staticSet.add(e);else for(const e of t)this._staticSet.delete(e)}}}else{if("boolean"==typeof e)continue;if("function"==typeof e)this._addReactive(e);else for(const t of this._splitClasses(String(e)))this._staticSet.add(t)}this._applySourceDiff("static",s,new Set(this._staticSet),e)}_addStaticFromObject(t){const e=this._getElement(),s=new Set(this._staticSet);for(const e of Object.keys(t)){const s=t[e],i=this._splitClasses(String(e));if(s)for(const t of i)this._staticSet.add(t);else for(const t of i)this._staticSet.delete(t)}this._applySourceDiff("static",s,new Set(this._staticSet),e)}_addReactive(t,e){const s="fx#"+ ++this._watcherSeq,i={stop:()=>{},binding:void 0,set:new Set},n=this._getElement(),o=()=>At(()=>{let o;try{const s=t();o=this._normalizeToSet(s,e)}catch{o=new Set}const r=new Set(i.set);this._applySourceDiff(s,r,o,n),i.set=o});let r=o();const a=()=>{try{r()}catch{}},c={propertyName:`__class:${s}`,dataSource:null,activate(){},deactivate:()=>{a();const t=this._getElement(),e=new Set(i.set);this._applySourceDiff(s,e,new Set,t),i.set.clear()},reActivate:()=>{a(),r=o()}};try{this._parent.bindings.add(c)}catch{}i.stop=a,i.binding=c,this._watchers.set(s,i)}}const Kt={cancel(){},addEventListener(){},removeEventListener(){},oncancel:null,playState:"finished"};function Yt(t){const e=t.substring(0,Math.max(0,t.length-1)).replace(",",".");return 1e3*Number(e)}function Qt(t,e){const s=s=>(t[`${e}-${s}`]||"").split(", "),i=s("delay"),n=s("duration");let o=-1/0;for(let t=0;t<n.length;t++){const e=Yt(n[t])+Yt(i[t%i.length]);o=Math.max(o,e)}return{kind:e,longest:o,tracks:n.length}}const Zt=/(?:^|\W)(?:transform|all)(?:,|$)/;function te(t,e){if(!t)return{type:"animation",timeout:0,propCount:0,hasTransform:!1};const s={transition:Qt(t,"transition"),animation:Qt(t,"animation")};let i,n;if("transition"===e||"animation"===e){const t=s[e];i=t.longest>0?t:null,n=i?i.longest:0}else{const{transition:t,animation:e}=s;n=Math.max(t.longest,e.longest),i=n>0?t.longest>e.longest?t:e:null}const o=i?i.kind:null;return{type:o,timeout:n,propCount:i?i.tracks:0,hasTransform:"transition"===o&&Zt.test(t.transitionProperty)}}function ee(t,e,s){if(t.isConnected&&8!==t.nodeType)return te(qi.window.getComputedStyle(t),s);const i=qi.createElement("div");i.setAttribute("style","width:0!important;height:0!important;display:none"),qi.body.appendChild(i),i.setAttribute("class",e);try{return te(qi.window.getComputedStyle(i),s)}finally{i.remove()}}function se(t,e,s,i,n=!1){if(!1===e.css)return i(),()=>{};const o=function(t,e,s=!1){const i=t.name||"motif";if("enter"===e){const e={from:t.enterFromClass??`${i}-enter-from`,active:t.enterActiveClass??`${i}-enter-active`,to:t.enterToClass??`${i}-enter-to`};return s?{from:t.appearFromClass??e.from,active:t.appearActiveClass??e.active,to:t.appearToClass??e.to}:e}return{from:t.leaveFromClass??`${i}-leave-from`,active:t.leaveActiveClass??`${i}-leave-active`,to:t.leaveToClass??`${i}-leave-to`}}(e,s,n),r=e=>{e&&e.split(/\s+/).forEach(e=>{if(e)try{t.classList.add(e)}catch{}})},a=e=>{e&&e.split(/\s+/).forEach(e=>{if(e)try{t.classList.remove(e)}catch{}})};let c,l=!1,h=null,u=null;const d=()=>{if(!l){l=!0,(()=>{if(a(o.from),a(o.to),a(o.active),void 0!==c){try{clearTimeout(c)}catch{}c=void 0}if(h&&u){try{t.removeEventListener(h,u)}catch{}u=null}})();try{i()}catch{}}};r(o.from),r(o.active);try{t.offsetHeight}catch{}return(t=>{const e=globalThis.requestAnimationFrame;"function"==typeof e?e(()=>t()):setTimeout(t,16)})(()=>{if(l)return;a(o.from),r(o.to);let i=0,n=1;const p=e.duration;if("number"==typeof p)i=p,h="animation"===e.type?"animationend":"transitionend";else if(p&&"object"==typeof p)i=("enter"===s?p.enter:p.leave)??0,h="animation"===e.type?"animationend":"transitionend";else{const s=function(t,e){return te(qi.window.getComputedStyle(t),e)}(t,e.type);i=s.timeout,n=s.propCount||1,h="animation"===s.type?"animationend":"transitionend"}if(!i||i<=0)return void d();let f=0;u=e=>{e&&e.target!==t||++f>=n&&d()};try{t.addEventListener(h,u)}catch{}c=setTimeout(d,i+60)}),d}class ie{constructor(t,e){this._component=t,this.options=e}show(){return this._component._show()}hide(){return this._component._hide()}toggle(){this._component._toggle()}on(t,e,s=!0){return this._component._on(t,e,s)}off(t,e){return this._component._off(t,e)}trigger(t,e){return this._component._trigger(t,e)}addHandler(t,e){this._component._addHandler(t,e)}clear(){return this._component._clear()}register(t){this._component._register(t)}setDisposable(t){this._component._register(D.toDisposable(t))}stopAnimations(){return this._component._stopAnimations()}}const ne=Symbol("SignalTarget"),oe=Symbol("SignalKey");class re{static create(t,e){return new re(t,e)}constructor(t,e=Object.is){this._disposed=!1,this._value=t,this._target={[ne]:!0},this._key=oe,this._equals=e}get value(){return this._disposed||St(this._target,this._key),this._value}set value(t){this._disposed||this._equals(this._value,t)||(this._value=t,Mt(this._target,this._key))}peek(){return this._value}update(t){this.value=t(this._value)}mutate(t){this._disposed||(t(this._value),Mt(this._target,this._key))}notify(){this._disposed||Mt(this._target,this._key)}asReadonly(){const t=this;return{get value(){return t.value},peek:()=>t.peek(),valueOf:()=>t.valueOf(),toString:()=>t.toString()}}dispose(){this._disposed=!0}valueOf(){return this.value}toString(){return String(this.value)}}class ae{constructor(t){this._dirty=!0,this._computing=!1,this._getter=t,this._target={[ne]:!0},this._key=oe,this._cleanup=At(()=>{if(!this._computing){this._computing=!0;try{const t=this._getter(),e=this._dirty||!Object.is(this._value,t);this._value=t,this._dirty=!1,e&&Mt(this._target,this._key)}finally{this._computing=!1}}})}get value(){if(St(this._target,this._key),this._dirty){this._computing=!0,V();try{this._value=this._getter(),this._dirty=!1}finally{W(),this._computing=!1}}return this._value}peek(){if(this._dirty){V();try{this._value=this._getter(),this._dirty=!1}finally{W()}}return this._value}dispose(){this._cleanup&&(this._cleanup(),this._cleanup=void 0)}valueOf(){return this.value}toString(){return String(this.value)}}class ce{constructor(t){this._dirty=!0,this._disposed=!1,this._getter=t,this._target={[ne]:!0},this._key=oe,this._runner=function(t,e){const s=new dt(t);return s.scheduler=e,{run:()=>{Ct(()=>s.run())},stop:()=>s.stop()}}(()=>{this._value=this._getter()},()=>{this._dirty||this._disposed||(this._dirty=!0,Mt(this._target,this._key))})}get value(){return this._disposed||St(this._target,this._key),this._refresh(),this._value}peek(){return this._refresh(),this._value}get isDirty(){return this._dirty}_refresh(){this._dirty&&(this._disposed?this._value=Ot(this._getter):this._runner.run(),this._dirty=!1)}dispose(){this._disposed||(this._disposed=!0,this._runner.stop())}valueOf(){return this.value}toString(){return String(this.value)}}let le=null,he=null,ue=null,de=null,pe=null;const fe=new WeakMap,me=new WeakMap,_e=new WeakMap,ge=new WeakMap,ye=new WeakMap;function ve(t,e){const s=le;le=t;try{return e()}finally{le=s}}function we(t,e,s){const i=he,n=ue;he=t,ue=e;try{return s()}finally{he=i,ue=n}}function be(t){let e=t;for(;e;){const t=_e.get(e);if(t)return t.scope;const s=ge.get(e);if(s&&s._pending)return s;e=e.parent}return null}function Se(t){if(!le)throw S("MJX409",function(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}(t));return le(t)}function Me(t){de&&de._pending&&ge.set(t,de)}function Ce(t){const e=pe;if(!e)return;if(_e.get(t)?.live)return;const s=be(t)??e._currentScope();_e.set(t,{scope:s,live:!0}),s._livePins++}function ke(t){const e=_e.get(t);e?e.live&&(e.live=!1,e.scope._releaseLivePin()):pe&&fe.has(t)&&_e.set(t,{scope:be(t)??pe._currentScope(),live:!1})}class De{constructor(t,e,s){this.services=t,this.scopedCache=new Map,this.transientSet=new Set,this._autoDisposeTransients=!1,this.pendingScoped=new Map,this._ownerlessSlot={owner:null,ownerless:!0},this._navigationDisposed=!1,this._livePins=0,this._pending=!1,this.describeToken=t=>"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t),this.parent=e,this.root=s??this,this.kind=this.root===this?"root":"user",this.singletonCache=this.root===this?new Map:this.root.singletonCache,this.pendingSingleton=this.root===this?new Map:this.root.pendingSingleton}createScope(t){const e=new De(this.services,this,this.root);return e.scopeName=t??this.scopeName,e._autoDisposeTransients=this._autoDisposeTransients,e}enableAutoDisposeTransients(t=!0){return this._autoDisposeTransients=t,this}get(t){const e=this.services.getDescriptor(t);if(!e)throw S("MJX401",this.describeToken(t));return this.resolveDescriptorSync(e,[t])}async getAsync(t){const e=this.services.getDescriptor(t);if(!e)throw S("MJX401",this.describeToken(t));return await this.resolveDescriptorAsync(e,[t])}_getFor(t,e){let s=fe.get(t);return s||(s={owner:t},fe.set(t,s)),we(s,ue,()=>this.get(e))}getAllServices(){return this.services}_beginNavigation(){const t=this.root,e=t._navigation??={current:t,version:new re(0),scopes:new Set};pe=t;const s=new De(this.services,t,t);return s.kind="navigation",s.scopeName="navigation",s._pending=!0,s._autoDisposeTransients=t._autoDisposeTransients,e.scopes.add(s),s}_commitNavigation(t){const e=this.root._navigation;if(!e||e.current===t)return;t._pending=!1;const s=e.current;e.current=t,this._touch(),s!==this.root&&s._releaseIfUnused()}_abandonNavigation(t){t._pending=!1,t._releaseIfUnused()}_currentScope(){return this.root._navigation?.current??this.root}_touch(){const t=this.root._navigation;t&&(t.version.value=t.version.peek()+1)}_releaseLivePin(){this._livePins--,this._releaseIfUnused()}_releaseIfUnused(){const t=this.root._navigation;"navigation"!==this.kind||this._navigationDisposed||this._livePins>0||t&&t.current===this||(this._navigationDisposed=!0,t?.scopes.delete(this),this.dispose().catch(()=>{}))}_scopeFor(t){const e=this._navigation;if(e&&e.version.value,!t.ownerless){const e=be(t.owner);if(e)return e;if(de&&de.root===this)return de}return e?e.current:this}_handle(t,e){const s=he??this._ownerlessSlot;let i=me.get(s);i||me.set(s,i=new Map);let n=i.get(t.token);return n||(n=this._createHandle(t,s),i.set(t.token,n)),this._scopeFor(s)._scopedInstanceSync(t,e),n}async _handleAsync(t,e){const s=he??this._ownerlessSlot;return await this._scopeFor(s)._scopedInstanceAsync(t,e),we(s,null,()=>this._handle(t,e))}_createHandle(t,e){const s=this,i=()=>s._scopeFor(e)._scopedInstanceSync(t,[t.token]);return new Proxy(Object.create(null),{get(t,e){const s=i(),n=Reflect.get(s,e,s);return"function"==typeof n?function(t,e,s){let i=ye.get(t);i||ye.set(t,i=new Map);const n=i.get(e);if(n&&n.fn===s)return n.bound;const o=s.bind(t);return i.set(e,{fn:s,bound:o}),o}(s,e,n):n},set(t,e,s){const n=i();return Reflect.set(n,e,s,n)},has:(t,e)=>e in i(),getPrototypeOf:()=>Object.getPrototypeOf(i())})}_isSystemScope(){return"user"!==this.kind}_scopedInstanceSync(t,e){if(this.scopedCache.has(t.token))return this.scopedCache.get(t.token);const s=we(null,this,()=>this.instantiateSync(t,e));return this.scopedCache.set(t.token,s),s}async _scopedInstanceAsync(t,e){if(this.scopedCache.has(t.token))return this.scopedCache.get(t.token);if(this.pendingScoped.has(t.token))return await this.pendingScoped.get(t.token);const s=(async()=>{const s=await this.instantiateAsyncIn(null,this,t,e);return this.scopedCache.set(t.token,s),this.pendingScoped.delete(t.token),s})();return this.pendingScoped.set(t.token,s),await s}resolveDescriptorSync(t,e){switch(this.checkCycle(t.token,e),t.lifetime){case"singleton":{if(this.singletonCache.has(t.token))return this.singletonCache.get(t.token);const s=we(null,null,()=>this.instantiateSync(t,e));return this.singletonCache.set(t.token,s),s}case"scoped":return this._isSystemScope()&&ue!==this?this.root._handle(t,e):this._scopedInstanceSync(t,e);default:{const s=this.instantiateSync(t,e);return this._autoDisposeTransients&&this.parent&&this.transientSet.add(s),s}}}async resolveDescriptorAsync(t,e){switch(this.checkCycle(t.token,e),t.lifetime){case"singleton":{if(this.singletonCache.has(t.token))return this.singletonCache.get(t.token);if(this.pendingSingleton.has(t.token))return await this.pendingSingleton.get(t.token);const s=(async()=>{const s=await this.instantiateAsyncIn(null,null,t,e);return this.singletonCache.set(t.token,s),this.pendingSingleton.delete(t.token),s})();return this.pendingSingleton.set(t.token,s),await s}case"scoped":return this._isSystemScope()&&ue!==this?await this.root._handleAsync(t,e):await this._scopedInstanceAsync(t,e);default:{const s=await this.instantiateAsync(t,e);return this._autoDisposeTransients&&this.parent&&this.transientSet.add(s),s}}}construct(t){if(he)return t();const e={owner:null},s=we(e,ue,t);return!s||"object"!=typeof s&&"function"!=typeof s||"function"==typeof s.then||(Me(s),e.owner=s,fe.has(s)||fe.set(s,e)),s}instantiateSync(t,e){if(void 0!==t.useValue)return t.useValue;if(t.useFactory)return this.construct(()=>{const s=this.resolveDepsSync(t,e),i=ve(this.injectionResolver(e),()=>t.useFactory(...s,this));if(i&&"function"==typeof i.then){throw S("MJX402",this.describeTokenWithSource(t.token))}return i});if(t.useClass)return this.construct(()=>{const s=this.resolveDepsSync(t,e);return ve(this.injectionResolver(e),()=>new t.useClass(...s))});throw S("MJX403")}async instantiateAsyncIn(t,e,s,i){return await we(t,e,()=>this.instantiateAsync(s,i))}async instantiateAsync(t,e){if(void 0!==t.useValue)return t.useValue;const s=he,i=ue;if(t.useFactory){const n=await this.resolveDepsAsyncIn(s,i,t,e);return await we(s,i,()=>this.construct(()=>ve(this.injectionResolver(e),()=>t.useFactory(...n,this))))}if(t.useClass){const n=await this.resolveDepsAsyncIn(s,i,t,e);return we(s,i,()=>this.construct(()=>ve(this.injectionResolver(e),()=>new t.useClass(...n))))}throw S("MJX403")}async dispose(){const t=new Set,e=async e=>{if(e&&!t.has(e)){t.add(e);try{"function"==typeof e.dispose&&await e.dispose()}catch{}try{"function"==typeof e.close&&await e.close()}catch{}try{const t=e[Symbol.dispose];"function"==typeof t&&await t.call(e)}catch{}try{const t=e[Symbol.asyncDispose];"function"==typeof t&&await t.call(e)}catch{}}};if(this.root===this){const t=this._navigation;if(t){const e=[...t.scopes];t.scopes.clear(),t.current=this,pe===this&&(pe=null),this._navigation=void 0;for(const t of e)t._navigationDisposed=!0,await t.dispose()}for(const t of this.singletonCache.values())await e(t);this.singletonCache.clear(),this.pendingSingleton.clear()}for(const t of this.scopedCache.values())await e(t);"navigation"!==this.kind&&this.scopedCache.clear(),this.pendingScoped.clear();for(const t of this.transientSet.values())await e(t);this.transientSet.clear()}resolveDepsSync(t,e){const s=this.getDeps(t);return s&&0!==s.length?s.map(t=>this.resolveTokenSync(t,e)):[]}async resolveDepsAsyncIn(t,e,s,i){const n=this.getDeps(s);if(!n||0===n.length)return[];const o=[];for(const s of n)o.push(await we(t,e,()=>this.resolveTokenAsync(s,i)));return o}injectionResolver(t){return e=>this.resolveTokenSync(e,t)}getDeps(t){if(Array.isArray(t.deps))return t.deps;const e=t.useClass??t.useFactory;if(e){if(Array.isArray(e.inject))return e.inject;if(Array.isArray(e.dependencies))return e.dependencies}}resolveTokenSync(t,e){const s=this.services.getDescriptor(t);if(!s)throw S("MJX401",this.describeToken(t));const i=e.concat(t);return this.resolveDescriptorSync(s,i)}async resolveTokenAsync(t,e){const s=this.services.getDescriptor(t);if(!s)throw S("MJX401",this.describeToken(t));const i=e.concat(t);return await this.resolveDescriptorAsync(s,i)}checkCycle(t,e){const s=e.indexOf(t);if(-1!==s&&s!==e.length-1){throw S("MJX404",e.slice(s).concat([t]).map(t=>this.describeTokenWithSource(t)).join(" -> "))}}describeTokenWithSource(t){const e=this.describeToken(t),s=this.services.getDescriptor(t);if(!s)return e;return`${e}[${s.useClass?"useClass":s.useFactory?"useFactory":void 0!==s.useValue?"useValue":"unknown"}]`}}const Ae={live:0},xe=Symbol("motif.optionsOwner"),Ee=Symbol("motif.transition"),Te={mode:"concurrent"},Oe=()=>{};function Ne(){const t=new WeakMap;return{track:function(e,s,i){const n=e?.parentNode??i?.parentNode;if(!n)return{done:s,release:Oe};let o=t.get(n);o||t.set(n,o=new Set);let r=Oe;const a={node:e,via:i??null,done:new Promise(t=>{r=t})};o.add(a);let c=!1;const l=()=>{c||(c=!0,o.delete(a),r())};return{done:()=>{const t=!c;l(),t&&s&&s()},release:l,finished:a.done}},pending:function(e,s){if(!e)return null;const i=t.get(e);if(!i||0===i.size)return null;let n=null;for(const t of i)t.node!==s&&(t.node.parentNode===e||t.via?.parentNode===e?(n??=[]).push(t.done):i.delete(t));return n?Promise.all(n).then(Oe):null}}}const Pe=Ne(),Le=Ne(),Xe=Pe.track,Re=Pe.pending,Ie=Le.track,Je=Le.pending;function je(t){return"concurrent"===t||"out-in"===t||"in-out"===t}function Fe(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}const He=1024;function Be(t){return t?._motif?.options}function ze(t){return t?._motif?.options?.[Ee]}function Ve(t){const e=ze(t);if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function We(t){let e=t;for(;e;){const t=ze(e)?.mode;if(t)return t;const s=e.element;if(!s||s.nodeType!==Node.COMMENT_NODE)break;e=e.parent??e._leaveContainer}return Te.mode}function $e(t){const e=t?._motif?.options,s=e?.[Ee];return!!(e?.transitionIn||s&&(s.classes||s.name&&s.name.length>0))}function Ue(t){const e=()=>t.motif.options?.[Ee]??s,s={transitionInfo:()=>{const s=e();return{in:ee(t.element,`${s.name}-enter ${s.name}-enter-start`),out:ee(t.element,`${s.name}-leave ${s.name}-leave-start`)}},name:"",mode:void 0,classes:void 0,activeCssCancel:null,activeCssPhase:null,cssProps:()=>{const t=e();return t.classes?{name:t.classes.name||t.name||"",...t.classes}:t.name&&t.name.length>0?{name:t.name}:null},skipNextLeave:!1,_suppressEnter:!1,_markedDirection:!1,in:e=>{t.motif.options.transitionIn=e},out:e=>{t.motif.options.transitionOut=e},enterTransition:s=>{const i=e(),n=t._base,o=!n._enterPlayed;if(n._enterPlayed=!0,n._enterSeq=(n._enterSeq??0)+1,i._suppressEnter)return s&&s(),Kt;const r={};n._enterRun=r;const a=Ie(t.element,()=>{t._base?._enterRun===r&&(t._base._enterRun=null,Ve(t)),s&&s()},t.motif.options.placeholder),c=t.motif.options.transitionIn,l=c?i.run(c.keyframes,c.options,a.done):i._runCss("enter",a.done,o);return l&&l!==Kt&&"function"==typeof l.addEventListener&&l.addEventListener("cancel",a.release),l},leaveTransition:s=>{const i=e(),n=t.element,o=Xe(n,s),r=()=>{const e=t.motif.options?.transitionOut,s=e?i.run(e.keyframes,e.options,o.done):i._runCss("leave",o.done);return s&&s!==Kt&&"function"==typeof s.addEventListener&&s.addEventListener("cancel",o.release),s};return o.finished&&"in-out"===We((a=t).parent??a._leaveContainer)?function(t,e,s){const i=t.parentNode,n={finished:e.finished??Promise.resolve(),playState:"pending",addEventListener:Oe,removeEventListener:Oe,cancel:Oe};return queueMicrotask(()=>{const e=Je(i,t);e?e.then(()=>{s()}):s()}),n}(n,o,r):r();var a},_runCss:(s,i,n=!1)=>{const o=e();if("enter"===s&&"leave"===o.activeCssPhase)return i&&i(),Kt;const r=o.cssProps(),a=t.element;if(r&&a&&1===a.nodeType&&a.classList){try{o.activeCssCancel?.()}catch{}const t=se(a,r,s,()=>{o.activeCssCancel=null,o.activeCssPhase=null,i&&i()},n);return o.activeCssCancel=t,o.activeCssPhase=s,Kt}return i&&i(),Kt},activeAnimations:[],run:(s,i,n)=>{const o=e();t.motif.stopAnimations();const r=t.element;if(r.animate){var a=r.animate(s,i);o.activeAnimations.push(a);let t=!1;const e=()=>{if(!t){t=!0;try{o.activeAnimations&&(o.activeAnimations=o.activeAnimations.filter(t=>t!==a))}catch{}}};return a.addEventListener("finish",()=>{n&&n(),e()}),a.oncancel=()=>{e()},a}{n&&n();const t=globalThis;if("function"==typeof t.Animation)try{return new t.Animation}catch{}return Kt}}};return s}class qe{constructor(t){this[xe]=t}get transition(){return this[Ee]??=Ue(this[xe])}set transition(t){this[Ee]=t}set enableRouterClassing(t){try{const e=this[xe],s=e.context.onRouterChanged(()=>{ss.routerClassing.call(e,t)});e.motif.register(D.toDisposable(()=>{s()})),ss.routerClassing.call(e,t)}catch(t){M("MJX105",t)}}getInstance(){return this[xe]}get display(){return this[xe].isVisible}set display(t){t?this[xe].motif.show():this[xe].motif.hide()}hasEvent(t){return Ds(this[xe],t)}}function Ge(t,e,s){const i=t._baseCtx;i&&i._emiters?.fire(e,s)}function Ke(t,e,s,i,n){if(!t)return;let o=t[e];if(!o)return;let r=0;if("function"==typeof o){const a=o;if(C(()=>a(s,i),"MJX122",n),o=t[e],!Array.isArray(o))return;r=1}for(let t=r;t<o.length;t++){const e=o[t];C(()=>e(s,i),"MJX122",n)}}function Ye(t,e,s,i,n){if(t[e])return!0;const o=t._baseCtx;return!!o?.[s]||(!(!n||!t[n])||!!o?._emiters?.hasListeners(i))}It(qe.prototype,["getInstance","hasEvent"]);const Qe=["build","setState","reState","setText","style","dispose","disposeAsync","using","doWork","getService","$","useModel","context","siblings","serviceProvider","isWait"],Ze=new WeakSet;function ts(t,e){if("function"!=typeof t)return!1;const s=e.replace(/\$/g,"\\$");return new RegExp(`\\bsuper\\s*(\\.\\s*${s}(?![\\w$])|\\[)`).test(Function.prototype.toString.call(t))}function es(t){if(!c())return;const e=t?.constructor;if("function"!=typeof e||Ze.has(e))return;Ze.add(e);const s=e.name||"An anonymous component class";for(const[e,i]of function(t){const e=[],s=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);for(const i of Qe)if(s(t,i))e.push([i,"field"]);else for(let s=Object.getPrototypeOf(t);s&&s!==zs.prototype;s=Object.getPrototypeOf(s)){const t=Object.getOwnPropertyDescriptor(s,i);if(t){("value"in t?[t.value]:[t.get,t.set].filter(Boolean)).some(t=>ts(t,i))||e.push([i,"method"]);break}}const i=t;return i.motif instanceof ie||e.push(["motif","replaced"]),i.controls instanceof Qi||e.push(["controls","replaced"]),i.class instanceof Gt||e.push(["class","replaced"]),i.attr instanceof qt||e.push(["attr","replaced"]),i.bindings instanceof Ft||e.push(["bindings","replaced"]),null==i.element||"undefined"==typeof Node||i.element instanceof Node||e.push(["element","replaced"]),null==i.parent||i.parent instanceof zs||e.push(["parent","replaced"]),e}(t))k("MJX128",[s,e,i])}const ss={callInitializeComponent(t){const e=t,s={cancel:!1};if(!t||t.isDisposed)return;"function"==typeof t.initializeComponent&&C(()=>t.initializeComponent(e,s),"MJX122","initializeComponent");const i=t._init;i&&C(()=>i(e,s),"MJX122","initializeComponent"),Ke(t._baseCtx,"_initializeComponentHandlers",e,s,"initializeComponent"),"function"==typeof t.oninitializeComponent&&C(()=>t.oninitializeComponent(e,s),"MJX122","oninitializeComponent"),Ke(t._baseCtx,"_onInitializeComponentHandlers",e,s,"oninitializeComponent")},callDisposing(t){if(!t||t.isDisposed)return;if(!Ye(t,"onDisposing","_onDisposingHandlers","ondisposing","ondisposing"))return;const e=t,s={cancel:!1};t.onDisposing&&C(()=>t.onDisposing(e,s),"MJX122","onDisposing"),Ke(t._baseCtx,"_onDisposingHandlers",e,s,"onDisposing"),t.ondisposing&&C(()=>t.ondisposing(e,s),"MJX122","ondisposing"),Ge(t,"ondisposing",s)},callActivated(t){if(!t||t.isDisposed)return;const e=t,s={cancel:!1};t.onActivated&&C(()=>t.onActivated(e,s),"MJX122","onActivated"),Ke(t._baseCtx,"_onActivatedHandlers",e,s,"onActivated"),Ge(t,"onactivated",s)},callDeactivated(t){if(!t||t.isDisposed)return;const e=t,s={cancel:!1};t.onDeactivated&&C(()=>t.onDeactivated(e,s),"MJX122","onDeactivated"),Ke(t._baseCtx,"_onDeactivatedHandlers",e,s,"onDeactivated"),Ge(t,"ondeactivated",s)},deactivateTree(t,e=!0){if(t&&!t.isDisposed&&t.isBuilt&&t._base&&!t._base._inactive&&(t._base._inactive=!0,ss.callDeactivated(t),e&&!t.isDisposed))for(const e of Xs(t).slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&ss.deactivateTree(e,!0)},activateTree(t,e=!0){if(t&&!t.isDisposed&&t._base&&t._base._inactive&&(t._base._inactive=!1,ss.callActivated(t),e&&!t.isDisposed))for(const e of Xs(t).slice())e&&!e.isDisposed&&e.isVisible&&!e.isWait&&ss.activateTree(e,!0)},callDisposed(t){if(t&&0===(t._flags&He)&&(!t.isDisposed||t.element||void 0!==t._baseCtx)){if(t._flags|=He,Ye(t,"onDisposed","_onDisposedHandlers","ondisposed","ondisposed")){const e=t,s={cancel:!1};t.onDisposed&&C(()=>t.onDisposed(e,s),"MJX122","onDisposed"),Ke(t._baseCtx,"_onDisposedHandlers",e,s,"onDisposed"),t.ondisposed&&C(()=>t.ondisposed(e,s),"MJX122","ondisposed"),Ge(t,"ondisposed",s)}try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:disposed",{id:t.id,type:t.constructor?.name})}catch{}}},callBuilt(t){if(t&&!t.isDisposed){if(Ye(t,"onBuilt","_onBuiltHandlers","onbuilt","onbuilt")){const e=t,s={cancel:!1};t.onBuilt&&C(()=>t.onBuilt(e,s),"MJX122","onBuilt"),Ke(t._baseCtx,"_onBuiltHandlers",e,s,"onBuilt"),t.onbuilt&&C(()=>t.onbuilt(e,s),"MJX122","onbuilt"),Ge(t,"onbuilt",s)}try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("component:mounted",{id:t.id,type:t.constructor?.name})}catch{}}},scheduleMounted(t){if(!t||t.isDisposed||t._baseCtx?._mountedScheduled)return;if(!("function"==typeof t.onMounted||!!t._baseCtx?._onMountedHandlers||"function"==typeof t.onmounted))return;t._base._mountedScheduled=!0;const e=t.element;if(!e||"number"!=typeof e.nodeType)return;const s=ki(e,()=>{t.isDisposed||ss.callMounted(t)});s&&t._register(D.toDisposable(s))},callMounted(t){if(!t||t.isDisposed||t._base._mountedFired)return;t._base._mountedFired=!0;const e=t,s={cancel:!1};t.onMounted&&C(()=>t.onMounted(e,s),"MJX122","onMounted"),Ke(t._baseCtx,"_onMountedHandlers",e,s,"onMounted"),t.onmounted&&C(()=>t.onmounted(e,s),"MJX122","onmounted"),Ge(t,"onmounted",s)},callBuilding(t){if(!t||t.isDisposed)return;if(!Ye(t,"onBuilding","_onBuildingHandlers","onbuilding"))return;const e=t,s={cancel:!1};t.onBuilding&&C(()=>t.onBuilding(e,s),"MJX122","onBuilding"),Ke(t._baseCtx,"_onBuildingHandlers",e,s,"onBuilding"),Ge(t,"onbuilding",s)},callConfig(t){if(!t||t.isDisposed||t.isConfigured)return;t.isConfigured=!0;const e=t._motif?.options?._preconfig;if(e&&o(()=>e(t),"Component._preconfig"),!Ye(t,"onConfig","_onConfigHandlers","onconfig"))return;const s=t,i={cancel:!1};t.onConfig&&C(()=>t.onConfig(s,i),"MJX122","onConfig"),Ke(t._baseCtx,"_onConfigHandlers",s,i,"onConfig"),Ge(t,"onconfig",i)},callConfigured(t){if(256&t._flags)return;if(t?._baseCtx?._configDeferred&&!t.isConfigured&&ss.callConfig(t),t._flags|=256,!t||t.isDisposed)return;if(!Ye(t,"onConfigured","_onConfiguredHandlers","onconfigured"))return;const e=t,s={cancel:!1};t.onConfigured&&C(()=>t.onConfigured(e,s),"MJX122","onConfigured"),Ke(t._baseCtx,"_onConfiguredHandlers",e,s,"onConfigured"),Ge(t,"onconfigured",s)},callOnInitialized(t){if(!t||t.isDisposed)return;if(t.isInitialized=!0,!Ye(t,"onInitialized","_onInitializedHandlers","oninitialized"))return;const e=t,s={cancel:!1};t.onInitialized&&C(()=>t.onInitialized(e,s),"MJX122","onInitialized"),Ke(t._baseCtx,"_onInitializedHandlers",e,s,"onInitialized"),Ge(t,"oninitialized",s)},callOnInitializing(t){if(!t||t.isDisposed)return;if(!Ye(t,"onInitializing","_onInitializingHandlers","oninitializing"))return;const e=t,s={cancel:!1};t.onInitializing&&C(()=>t.onInitializing(e,s),"MJX122","onInitializing"),Ke(t._baseCtx,"_onInitializingHandlers",e,s,"onInitializing"),Ge(t,"oninitializing",s)},callVisibilityChanged(t,e){if(!t||t.isDisposed)return;if(!Ye(t,"onVisibilityChanged","_onVisibilityChangedHandlers","onvisibilitychanged"))return;const s=t,i={cancel:!1,visible:e};t.onVisibilityChanged&&C(()=>t.onVisibilityChanged(s,i),"MJX122","onVisibilityChanged"),Ke(t._baseCtx,"_onVisibilityChangedHandlers",s,i,"onVisibilityChanged"),Ge(t,"onvisibilitychanged",i)},findFragmentContent(t){const e=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;t.element.nodeType==Node.COMMENT_NODE&&0==e?.childNodes.length&&t.controls.length>0&&(t.motif.options.cache?.appendChild(t.element),t.controls.forEach(e=>{t.motif.options.cache?.appendChild(e.element)}),t.motif.options.cache?.appendChild(t.motif.options.closeFragment))},backgroundCallback(t){t()},internalBuild(t){if(this.isDisposed||t?.isDisposed)return;if(ss.callConfigured(t),t.isDisposed)return;if(Os(t),t.isWait)return void(this.isBuilt&&function(t,e){if(!is(e))return;const s=wi(t)?.element;if(!s)return;const i=e.element;if(i&&i.parentNode===s)return;const n=e.motif.options,o=n.placeholder??(n.placeholder=qi.createComment("h"));if(o.parentNode===s)return;s.insertBefore(o,os(t,t.controls.items.indexOf(e)+1,s))}(this,t));const e=t.isBuilt;if(!this.isBuilt)return;if(t.isWait)return;const s=t._baseCtx?._enterSeq;if(t.isBuilt){if(t.parent!=this){t.parent?.controls.detach(t),t.parent=this;const e=t.__pendingLeave;if(e)return void e.promise.then(()=>{this.isDisposed||t.isDisposed||t.parent!==this||ss.internalBuild.call(this,t)})}}else t.build();if(t.isDisposed||this.isDisposed)return;t.parent=this;const i=this.controls.items,n=i.length>0&&i[i.length-1]===t?i.length-1:i.indexOf(t),o=wi(this);var r=t.element.nodeType==Node.COMMENT_NODE?t.motif.options.cache:t.element;e&&t.element.nodeType==Node.COMMENT_NODE&&0==r?.childNodes.length&&t.controls.length>0&&(r=ss.getContent.call(t));const a=o?.element,c=t.motif.options.placeholder,l=t.isVisible&&c&&a&&c.parentNode===a?c:null,h=l??(a?os(this,n+1,a):null);if(!t.isVisible){if(!is(t))return;t.motif.options.placeholder||(t.motif.options.placeholder=qi.createComment("h")),r=t.motif.options.placeholder}if(a&&"out-in"===We(this)){const e=Re(a,r);if(e)return t._base._enterSeq=(t._base._enterSeq??0)+1,void e.then(()=>{this.isDisposed||t.isDisposed||t.parent!==this||ss.internalBuild.call(this,t)})}const u=o?.element;if(r&&u&&(r===u||r.contains(u)))k("MJX104",[]);else{if(h)try{o?.element.insertBefore(r,h)}catch{o?.element.appendChild(r)}else o?.element.appendChild(r);l&&l.parentNode&&l.parentNode.removeChild(l)}if(t.isVisible){!(!e&&t._baseCtx?._enterSeq!==s)&&$e(t)&&t.motif.options.transition.enterTransition(()=>{}),e&&ss.activateTree(t)}},getContent(){return this.isDisposed||!this.element?null:this.element.nodeType==Node.COMMENT_NODE?(this.motif.options.cache?.appendChild(this.element),this.controls.forEach(t=>{const e=t.isWait||!t.isVisible?is(t)?t.motif.options.placeholder??=qi.createComment("h"):void 0:ss.getContent.call(t);e&&this.motif.options.cache?.appendChild(e)}),this.motif.options.cache?.appendChild(this.motif.options.closeFragment),this.motif.options.cache):this.element},routerClassing(t){try{const e=t.to,s=t.path;if(this.isDisposed)return;const i=this.context?.router;if(!i)return;const n=i.uri.startsWith("/")?i.uri:"/"+i.uri,o=s??"",r=function(t,e){try{const s=t=>t.trim().split(/[?#]/)[0].replace(/\\/g,"/").replace(/\/{2,}/g,"/");return s(t)===s(e)}catch(t){return M("MJX610",t),!1}}(n,o),a=r||function(t,e){const s=Y(t),i=Y(e);return s===i||s.startsWith(i+"/")}(n,o);if(t.activeClass&&("all"===e||"active"===e)){t.activeClass.split(" ").filter(t=>t.trim().length).forEach(t=>this.element.classList.toggle(t,a))}if(!a||"all"!==e&&"active"!==e?"all"!==e&&"active"!==e||t.offActive?.():t.onActive?.(),t.exactClass&&("all"===e||"exact"===e)){t.exactClass.split(" ").filter(t=>t.trim().length).forEach(t=>this.element.classList.toggle(t,r))}!r||"all"!==e&&"exact"!==e?"all"!==e&&"exact"!==e||t.offExact?.():t.onExact?.()}catch(t){}}};function is(t){return"detach"!==Be(t)?.hideStrategy}function ns(t,e){const s=Be(t)?.placeholder;if(s&&s.parentNode===e)return s;const i=t.element;return i&&i.parentNode===e?i:null}function os(t,e,s){const i=t.controls.items;for(let t=e;t<i.length;t++){const e=i[t]?ns(i[t],s):null;if(e)return e}if(t.element.nodeType===Node.COMMENT_NODE){const e=Be(t)?.closeFragment;return e&&e.parentNode===s?e:null}return null}function rs(t,e,s){const i=Be(t),n=e.parentNode;if(e.nodeType===Node.COMMENT_NODE){if(n){const t=i?.closeFragment||null;if(t){let s=e;for(;s;){const e=s.nextSibling;try{n.removeChild(s)}catch{}if(s===t)break;s=e}}else try{n.removeChild(e)}catch{}if(!s)return}}else if(n){try{n.removeChild(e)}catch{}if(!s)return}const o=i?.placeholder;if(o&&o.parentNode)try{o.parentNode.removeChild(o)}catch{}}function as(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const s=t.motif.options,i=s?.[Ee];try{if(!0===i?.skipNextLeave||!0===t._forceInstantDetach)return i&&(i.skipNextLeave=!1),t._forceInstantDetach=!1,void rs(t,e,!0)}catch{}if(i||s?.transitionOut)try{s.transition.leaveTransition(()=>{rs(t,e,!1)})}catch{rs(t,e,!1)}else rs(t,e,!1)}async function cs(t){const e=t.element;if(!e||!0===t._keepElementOnDispose)return;const s=t.motif.options,i=s?.[Ee];try{if(!0===i?.skipNextLeave||!0===t._forceInstantDetach)return i&&(i.skipNextLeave=!1),t._forceInstantDetach=!1,void rs(t,e,!0)}catch{}if(i||s?.transitionOut)return new Promise(i=>{try{s.transition.leaveTransition(()=>{rs(t,e,!1),i()})}catch{rs(t,e,!1),i()}});rs(t,e,!1)}function ls(t){if(!t.isDisposed){ss.callDisposing.call(t,t);try{As(t)}catch{}if(t.motif.stopAnimations(),xs(t),Xs(t).length)for(const e of t._controls.items)try{ls(e)}catch{}ss.callDisposed.call(t,t),i(()=>{t._baseCtx?._emiters?.clear()},"disposeShallow.emiters"),t.isDisposed=!0,E.prototype.dispose.call(t)}}function hs(t){try{t.parent=null}catch{}t._eventHandlers=void 0;try{t._class?._countsStore?.clear()}catch{}try{t._class?._watchersStore?.clear()}catch{}try{t._attr?._attrMapStore?.clear()}catch{}try{t._attr?._watchersStore?.clear()}catch{}try{const e=t._motif?.options;e&&(e.cache=void 0,e.closeFragment=void 0,e.placeholder=void 0)}catch{}try{t.element=null}catch{}try{t.props=void 0}catch{}try{t.childs=void 0}catch{}try{t.class=void 0}catch{}try{t.attr=void 0}catch{}try{t.parent=null}catch{}try{t._motif&&(t._motif.options=void 0)}catch{}const e=Object.keys(t);for(let s=0;s<e.length;s++){const i=e[s];if("_motif"!==i&&"_flags"!==i)try{t[i]=void 0}catch{}}t._store=null,t._flags=1860}const us=Promise.resolve();function ds(t,e){if(!e&&t._disposing&&!t.isDisposed)return!1;if(t.disposeAsync!==zs.prototype.disposeAsync)return!1;const s=Be(t);if(s){if(s.transitionOut)return!1;const t=s[Ee];if(t){if(t.activeAnimations&&t.activeAnimations.length>0)return!1;if(t.activeCssCancel)return!1;if(t.classes||t.name&&t.name.length>0)return!1}}const i=Xs(t);if(i.length)for(let t=0;t<i.length;t++){const e=i[t];if(e&&!e.isDisposed&&!ds(e,!1))return!1}return!0}const ps=new WeakMap;function fs(t,e,s){const n=s?"disposeAsync":"dispose";if(Ho._disposingCount>0){const e=function(t){for(let e=t;e;e=e.parent){if(e.application)return e.application;const t=ps.get(e);if(t)return t}return Ho.main??null}(t);e&&"disposing"===e.state&&ps.set(t,e)}!s&&e?.skipLeaveTransition&&(t.motif.options.transition.skipNextLeave=!0),i(()=>{ss.callDisposing.call(t,t)},n+".callDisposing"),As(t),xs(t),i(()=>{t.parent?.controls?.silentDetach?.(t,!0)},n+".silentDetach")}function ms(t,e,s){if(t.isDisposed=!0,E.prototype.dispose.call(t),s)return t._controls&&(t._controls.items=[]),i(()=>{ss.callDisposed.call(t,t)},"disposeAsync.callDisposed"),i(()=>{t._baseCtx?._emiters?.clear()},"disposeAsync.emiters"),void(e?.deep&&hs(t));t.element=null,i(()=>{ss.callDisposed.call(t,t)},"dispose.callDisposed"),i(()=>{t._baseCtx?._emiters?.clear()},"dispose.emiters"),As(t),hs(t)}async function _s(t,e,s,i){i?await i:((s||ze(t)?.skipNextLeave)&&await t.motif.stopAnimations(),await cs(t)),s||"TransportTo"===t.constructor.name||await async function(t){if(0===Ae.live)return;const e=Vs(t);return await Promise.all(e.map(async e=>{e.motif.options.transition.skipNextLeave=t.motif.options.transition.skipNextLeave;for(const t of e.controls.items)t.motif.options.transition.skipNextLeave=e.motif.options.transition.skipNextLeave,t.dispose({skipLeaveTransition:!0}),t.isDisposed=!0;await e.dispose()}))}(t);const o={deep:e?.deep};await n(async()=>{if(t.isDisposed)return;const e=Array.from(Xs(t));e.length&&await Promise.all(e.map(t=>s?n(async()=>{await t.disposeAsync(o)},"disposeAsync.disposeAsyncChildren.handler"):(async()=>{try{await t.disposeAsync(o)}catch(t){M("MJX107",t)}})()))},s?"disposeAsync.disposeAsyncChildren":"dispose.disposeAsync"),!s&&t.isDisposed||ms(t,e,s)}const gs={get emiters(){return this._emiters??=new Bt(this.owner)},_offAll(){As(this.owner)},_deactivateBindings(){xs(this.owner)},_activateBindings(){Es(this.owner)},_reactivateBindings(){Ts(this.owner)},_activatePreBindings(){Os(this.owner)},_detachDomWithAnimation(){as(this.owner)},_detachDomWithAnimationAsync(){return cs(this.owner)},_disposeShallow(){ls(this.owner)},_deepCleanup(){hs(this.owner)}},ys=16,vs=32,ws=64,bs=[];let Ss=0;class Ms{constructor(t,e,s,i,n){this.owner=t,this.key=e,this.original=s,this.type=i,this.flags=n,this.next=void 0}handleEvent(t){const e=this.flags,s=this.owner;if(1&e&&t.target!==s.element)return;if(2&e&&!t.isTrusted)return;const i=this.original;let n;try{i&&i.length<=1?n=i(t):i&&(n=i(s,t))}catch(t){M("MJX123",t,this.type)}if(n&&"function"==typeof n.then){const t=this.type;n.then(void 0,e=>M("MJX123",e,t))}4&e&&Cs(t),8&e&&ks(t),n&&!0===n.cancel&&(Cs(t),ks(t))}}function Cs(t){"function"==typeof t?.preventDefault&&t.preventDefault()}function ks(t){"function"==typeof t?.stopPropagation&&t.stopPropagation()}function Ds(t,e){for(let s=t._eventHandlers;void 0!==s;s=s.next)if(0===(s.flags&ws)&&s.key===e)return!0;return!1}function As(t){const e=t._eventHandlers;if(void 0!==e){for(let s=e;void 0!==s;s=s.next)if((s.flags&(vs|ws))===vs)try{t.element.removeEventListener(s.type,s,0!==(s.flags&ys))}catch{}t._eventHandlers=void 0}}function xs(t){try{t._bindings?._items?.length&&t._bindings.deactivateAll()}catch{}}function Es(t){try{t._bindings?.activateAll()}catch{}}function Ts(t){try{t._bindings?.reActivateAll()}catch{}}function Os(t){if(512&t._flags)return;const e=t._bindings?._items;e&&e.length>0&&t._bindings.items.filter(t=>"isWait"==t.propertyName||"display"==t.propertyName).forEach(t=>{t.activate()}),t._flags|=512}function Ns(t){return t.owner}const Ps=Object.freeze([]),Ls=Object.freeze([]);function Xs(t){return t._controls?.items??Ps}function Rs(t){const e=Ns(this);Ds(e,"controladded")&&e.motif.trigger("controladded",{control:t}),(e.isVisible||e.element?.nodeType!==Node.COMMENT_NODE)&&ss.internalBuild.call(e,t)}function Is(t){const e=Ns(this);Ds(e,"controladded")&&e.motif.trigger("controladded",{control:t})}function Js(t){const e=Ns(this);Ds(e,"controlremoved")&&e.motif.trigger("controlremoved",{control:t})}const js=new WeakMap,Fs=new Set(["building","built","initializing","initialized","disposing","disposed","config","configured","visibilitychanged","activated","deactivated"]),Hs=Symbol("motif.rawApplication"),Bs=new Set(["on","onRouterChanged"]);class zs extends E{get motif(){return void 0!==this._motif?this._motif:this._motif=new ie(this,this.isDisposed&&!this.element?void 0:new qe(this))}set motif(t){this._motif=t}get isBuilt(){return!!(1&this._flags)}set isBuilt(t){this._flags=t?1|this._flags:-2&this._flags}get isInitialized(){return!!(2&this._flags)}set isInitialized(t){this._flags=t?2|this._flags:-3&this._flags}get isDisposed(){return!!(4&this._flags)}set isDisposed(t){this._flags=t?4|this._flags:-5&this._flags}get isConfigured(){return!!(8&this._flags)}set isConfigured(t){this._flags=t?8|this._flags:-9&this._flags}get isPainting(){return!!(16&this._flags)}set isPainting(t){this._flags=t?16|this._flags:-17&this._flags}get isPainted(){return!!(32&this._flags)}set isPainted(t){this._flags=t?32|this._flags:-33&this._flags}get isVisible(){return!(64&this._flags)}set isVisible(t){this._flags=t?-65&this._flags:64|this._flags}get controls(){return void 0!==this._controls||this.isDisposed&&!this.element?this._controls:this._controls=function(t){const e=new Qi(t);return e.onAdd=Rs,e.onAddBeforeBuild=Is,e.onRemove=Js,e}(this)}set controls(t){this._controls=t}get class(){return void 0!==this._class||this.isDisposed&&!this.element?this._class:this._class=new Gt(this)}set class(t){this._class=t}get attr(){return void 0!==this._attr||this.isDisposed&&!this.element?this._attr:this._attr=new qt(this)}set attr(t){this._attr=t}get bindings(){return void 0!==this._bindings||this.isDisposed&&!this.element?this._bindings:this._bindings=new Ft(this)}set bindings(t){this._bindings=t}useModel(t){return Vn(t)}_computeHideStrategy(){return is(this)?"placeholder":"detach"}_isInDom(){try{if(!this.element)return!1;const t=this.element;return t.nodeType,Node.COMMENT_NODE,!!t.parentNode}catch{return!1}}set isWait(t){this._flags=t?128|this._flags:-129&this._flags,this.isBuilt?t?this.motif.hide():this.motif.show():!1===t&&this.parent&&this.parent.isBuilt&&ss.internalBuild.call(this.parent,this)}get isWait(){return!!(128&this._flags)}constructor(t,e={}){super(),this._motif=void 0,this._flags=0,this._controls=void 0,this._class=void 0,this._attr=void 0,this._bindings=void 0,this._baseCtx=void 0,this._init=void 0,this._leaveContainer=void 0,this.parent=null;const s=gi;gi=!1,Me(this),this.onElementCreating?this.element=this.onElementCreating.call(this):this.element=e?.onElementCreating?e.onElementCreating.call(this):t,3!==this.element?.nodeType&&void 0===this._controls&&(this._controls=new Qi(this));const i=e?Gs(e,this):[];if(e&&Qs(e,this)&&(e={}),oi(e?.options,this),this.props=e,e){const t=new.target;!s&&(t===zs||Object.getPrototypeOf(t)===zs)?di(e,this):yi(e,this)}if(i.length>0)for(const t of $s(this,i))C(()=>t(this),"MJX122","ref");if(ss.callOnInitializing(this),this.isDisposed)return;const n=this._controls;n&&(n.onAdd=Rs,n.onAddBeforeBuild=Is,n.onRemove=Js),ss.callOnInitialized(this);const o=new.target;o===zs||Object.getPrototypeOf(o)===zs?ss.callConfig(this):this._base._configDeferred=!0}get _base(){return void 0!==this._baseCtx||this.isDisposed&&!this.element?this._baseCtx:this._baseCtx=function(t){const e=Object.create(gs);return e.owner=t,e}(this)}get context(){const t=this.parent?.context,e=t?.[Hs]??t??ps.get(this)??Ho.main;return e?(this._scopedContext?.[Hs]!==e&&(this._scopedContext=function(t,e){const s=new Map;return new Proxy(t,{get(t,i){if(i===Hs)return t;const n=Reflect.get(t,i,t);if("function"!=typeof n)return n;const o=s.get(i);if(o&&o.fn===n)return o.bound;const r=Bs.has(i)?(...s)=>e._trackContextSubscription(n.apply(t,s)):n.bind(t);return s.set(i,{fn:n,bound:r}),r},set:(t,e,s)=>Reflect.set(t,e,s,t)})}(e,this)),this._scopedContext):e}_trackContextSubscription(t){if("function"!=typeof t)return t;if(this.isDisposed)return t(),t;const e=this._register(D.toDisposable(t));return()=>{this._disposables.detach(e),t()}}build(t=!0){if(es(this),ss.callConfigured(this),Os(this),this.isDisposed||!this.element||this.isWait)return;if(this.isBuilt||this.isWait)return;if(ss.callBuilding(this),this.isDisposed)return;var e=this.element;t&&(e=qi.createDocumentFragment());const s="string"!=typeof this.element&&this.element.nodeType===Node.COMMENT_NODE;if(s&&(this.motif.options.cache=qi.createDocumentFragment(),this.element.textContent="[",this.motif.options.cache.appendChild(this.element)),this.isBuilt)return;if(ss.callInitializeComponent(this),this.isDisposed)return;if(this.view){const t=this.view();if(this.controls.add(t),this.isDisposed)return}const i="SELECT"===this.element?.nodeName?this.bindings.items.filter(t=>"value"===t.propertyName):Ls;if(i.length)try{this.bindings.items.filter(t=>!i.includes(t)).forEach(t=>t.activate())}catch{}else Es(this);const n=Xs(this);for(const i of n.length?n.slice():n){var o=s?this.motif.options.cache:this.element;if(i.isWait||(i.parent=this,i.build(!1)),i.isWait){if(is(i)){const s=i.motif.options;(t?e:o).appendChild(s.placeholder??(s.placeholder=qi.createComment("h")))}}else{if(t){const t=Be(i)?.cache;t?e.appendChild(t):e.appendChild(i.element)}else{const t=Be(i)?.cache;t?o.appendChild(t):o.appendChild(i.element)}i._baseCtx?._inactive&&i.isVisible&&ss.activateTree(i)}}if(!this.isDisposed){if($e(this)){const t=this.element;if(t&&t.isConnected)this.motif.options.transition.enterTransition(()=>{});else{const t=this._base._enterSeq;queueMicrotask(()=>{!this.isDisposed&&this.isVisible&&this.motif.options?.transition&&this._base._enterSeq===t&&this.motif.options.transition.enterTransition(()=>{})})}}else Ve(this);if(t)try{(o=s?this.motif.options.cache:this.element).nodeType===Node.TEXT_NODE?o.appendData(e.textContent):o.appendChild?o.appendChild(e):o.append(e)}catch(t){}if(i.length)try{i.forEach(t=>t.activate())}catch{}s&&(this.motif.options.closeFragment=qi.createComment("]"),this.motif.options.cache.appendChild(this.motif.options.closeFragment),this.element.nodeType===Node.COMMENT_NODE&&this.motif.options.closeFragment&&js.set(this.element,this.motif.options.closeFragment)),this.isBuilt=!0,ss.callBuilt(this),ss.scheduleMounted(this)}}setState(){this.controls.forEach(t=>{t.setState()}),Ts(this)}reState(){Ts(this),this.controls.forEach(t=>{t.reState()})}setText(t){!this.isDisposed&&this.element&&(si(t)?function(t,e){if(ii.has(t))return;ii.add(t),k("MJX204",[],{value:Array.isArray(e)?`ComponentBase[${e.length}]`:"ComponentBase"})}(this,t):this.element&&(this.element.textContent=t))}style(t){if(this.isDisposed)return this;const e=this.element?.style;if(!e)return this;if("function"==typeof t){this._stopStyleEffect();let e=[],s=!1;const i=()=>At(()=>{const i=t();if(this.isDisposed)return;const n=this.element?.style;if(n)if("string"==typeof i)n.cssText=i,e=[],s=!0;else if(i&&"object"==typeof i){s&&(n.cssText="",s=!1);for(const t of e)if(!(t in i))try{n[t]=""}catch{}Object.assign(n,i),e=Object.keys(i)}else{s&&(n.cssText="",s=!1);for(const t of e)try{n[t]=""}catch{}e=[]}});let n=i();const o=()=>{try{n()}catch{}},r={propertyName:"__style",dataSource:null,activate(){},reActivate(){o(),n=i()},deactivate(){o()}};try{this.bindings.add(r)}catch{}return this._styleFx={stop:o,binding:r},this}return"string"==typeof t?e.cssText=t:t&&"object"==typeof t&&Object.assign(e,t),this}_stopStyleEffect(){const t=this._styleFx;if(t){this._styleFx=void 0;try{t.stop()}catch{}try{this.bindings.remove(t.binding)}catch{}}}_addHandler(t,e){this.motif.on(t,e)}async _show(){if(this.isDisposed||!this.element)return;if(this.isVisible)return;if(this.isWait)return;if(this.parent&&"out-in"===We(this.parent)){const t=this.motif.options.placeholder?.parentNode??wi(this.parent)?.element,e=Re(t,this.element);if(e){const t=this._base._showSeq=(this._base._showSeq??0)+1;return e.then(()=>{if(!this.isDisposed&&this._base._showSeq===t)return this._show()})}}ze(this)?.activeAnimations?.length&&i(async()=>{await Promise.all(this.motif.options.transition.activeAnimations.map(t=>t.finished?.catch(()=>{})))},"show.waitForLeaveAnimations");if("detach"===this._computeHideStrategy()){if(ss.callVisibilityChanged(this,!0),this.isDisposed)return;const t=!this._isInDom()&&this.parent&&this.parent.isBuilt&&!this.isWait;return this.isVisible=!0,void(t&&ss.internalBuild.call(this.parent,this))}{const e=this.motif.options.placeholder?.parentElement,s=wi(this.parent)?.element;if(this.motif.options.placeholder&&e&&e!==s){if(k("MJX106",[]),ss.callVisibilityChanged(this,!0),this.isDisposed)return;return this.isVisible=!0,void(this.parent?.isBuilt&&ss.internalBuild.call(this.parent,this))}if($e(this)&&this.motif.options.transition.enterTransition(()=>{}),ss.callVisibilityChanged(this,!0),this.isDisposed)return;if(this.element.nodeType===Node.COMMENT_NODE)return this.controls.items.filter(t=>!t.isBuilt).forEach(t=>ss.internalBuild.call(this,t)),this.controls.forEach(t=>{t.motif.show()}),this.isVisible=!0,void ss.activateTree(this,!1);if(!this.isBuilt)return void(this.isVisible=!0);var t=this.motif.options.placeholder?.parentElement;t&&(t.replaceChild(this.element,this.motif.options.placeholder),this.isVisible=!0,ss.activateTree(this))}}async _hide(){if(this.isDisposed||!this.element)return;if(this._base._showSeq=(this._base._showSeq??0)+1,!this.isVisible)return;if("detach"===this._computeHideStrategy()){if(ss.callVisibilityChanged(this,!1),this.isDisposed)return;return await this._base._detachDomWithAnimationAsync(),this.isVisible=!1,void ss.deactivateTree(this)}{const t=this.motif.options.transition,e=!0===t.skipNextLeave;e&&(t.skipNextLeave=!1);const s=()=>{if(ss.callVisibilityChanged(this,!1),!this.isDisposed){if(this.element.nodeType===Node.COMMENT_NODE)return this.controls.forEach(t=>{e&&t.isVisible&&t.element&&!t.isDisposed&&t.motif.options?.transition&&(t.motif.options.transition.skipNextLeave=!0),t.motif.hide()}),this.isVisible=!1,void ss.deactivateTree(this,!1);var t=this.element.parentElement;t&&(this.motif.options.placeholder||(this.motif.options.placeholder=qi.createComment("h")),t.replaceChild(this.motif.options.placeholder,this.element)),this.isVisible=!1,ss.deactivateTree(this)}};return e?void s():t.leaveTransition(s).finished}}_toggle(){!this.isDisposed&&this.element&&(this.isVisible?this.motif.hide():this.motif.show())}async _on(t,e,s=!0){if(this.isDisposed||!this.element)return this;const i=String(t);if(i.startsWith("x:")){const t=i.slice(2).toLowerCase();if("mounted"===t){let t;const s=ki(this.element,()=>{if(t&&(this._base._mountedSubs?.get(e)?.delete(t),this._disposables.detach(t)),this.isDisposed)return;const s={cancel:!1};C(()=>e.length<=1?e(s):e(this,s),"MJX122","x:mounted")});if(s){t=this._register(D.toDisposable(s));const i=this._base._mountedSubs??=new Map;let n=i.get(e);n||(n=new Set,i.set(e,n)),n.add(t)}return this}if(Fs.has(t))return this._base.emiters.on("on"+t,e),this}const n=i.indexOf(":"),o=n<0?i:i.slice(0,n),r=n<0?bs:i.slice(n+1).split(":"),a=o.startsWith("on")?o.slice(2).toLowerCase():o.toLowerCase();let c,l=s?vs:0;r.length&&(c={},r.includes("once")&&(c.once=!0),r.includes("passive")&&(c.passive=!0),r.includes("capture")&&(c.capture=!0,l|=ys),r.includes("self")&&(l|=1),r.includes("trusted")&&(l|=2),r.includes("prevent")&&(l|=4),r.includes("stop")&&(l|=8));const h=new Ms(this,i.toLowerCase(),e,a,l);return s&&this.element.addEventListener(a,h,c),function(t,e){let s=t._eventHandlers;if(void 0!==s){for(;void 0!==s.next;)s=s.next;s.next=e}else t._eventHandlers=e}(this,h),this}async _trigger(t,e){if(this.isDisposed||!this.element)return this;const s=String(t).toLowerCase();return i(()=>{Ss++;try{for(let t=this._eventHandlers;void 0!==t;t=t.next)if(0===(t.flags&ws)&&t.key===s)try{t.handleEvent(e)}catch{}}finally{Ss--}},"trigger"),this}async _off(t,e){if(this.isDisposed||!this.element)return this;const s=String(t).toLowerCase();if(s.startsWith("x:")){const t=s.slice(2);if("mounted"===t){const t=this._base._mountedSubs?.get(e);if(t){this._base._mountedSubs.delete(e);for(const e of t)this._disposables.delete(e)}return this}return Fs.has(t)&&this._base._emiters?.off("on"+t,e),this}for(let t=this._eventHandlers;void 0!==t;t=t.next)if(0===(t.flags&ws)&&t.key===s&&t.original===e){if(0!==(t.flags&vs)){const e=t;i(()=>{this.element.removeEventListener(e.type,e,0!==(e.flags&ys))},"off.removeEventListener")}t.flags|=ws;break}return 0===Ss&&function(t){let e,s;for(let i=t._eventHandlers;void 0!==i;i=i.next)0===(i.flags&ws)&&(void 0===s?e=i:s.next=i,s=i);void 0!==s&&(s.next=void 0),t._eventHandlers=e}(this),this}dispose(t={deep:!0}){return this.isDisposed?Promise.resolve():this._disposing?this._disposing:(ke(this),this._disposing=us,this._disposing=this._disposeCore(t,!1))}async _disposeCore(t,e){let s;if(fs(this,t,e),e||ze(this)?.skipNextLeave||(s=this._base._detachDomWithAnimationAsync()),await void 0,0===Ae.live&&ds(this,!0)){const i=function(t,e,s,i){const n={deep:e?.deep},o=[t],r=[-1];let a=null;i||as(t);for(let e=0;e<o.length;e++){const s=o[e];if(s.isDisposed)continue;const i=Xs(s);if(0===i.length)continue;const c=Array.from(i);for(let s=0;s<c.length;s++){const i=c[s];if(!i.isDisposed)if(i._disposing)(a??=[]).push(i._disposing);else try{ke(i),i._disposing=t._disposing,fs(i,n,!0),!1!==i.element?.isConnected&&as(i),o.push(i),r.push(e)}catch(t){M("MJX107",t)}}}const c=o.length;if(c>1){const t=new Array(c).fill(0);for(let e=c-1;e>=1;e--){const s=r[e];t[e]+1>t[s]&&(t[s]=t[e]+1)}const e=[];for(let t=1;t<c;t++)e.push(t);e.sort((e,s)=>t[e]-t[s]||e-s);for(let t=0;t<e.length;t++)try{ms(o[e[t]],n,!0)}catch(t){M("MJX107",t)}}return a||(!s&&t.isDisposed||ms(t,e,s),null)}(this,t,e,void 0!==s);if(i){if(await Promise.all(i),!e&&this.isDisposed)return;ms(this,t,e)}return}await _s(this,t,e,s)}disposeAsync(t={deep:!0}){return this.isDisposed?Promise.resolve():this._disposing?this._disposing:(ke(this),this._disposing=us,this._disposing=this._disposeCore(t,!0))}async _clear(){1!=this.isDisposed&&(this.motif.options&&this.motif.options.disableDisposal||await this.controls.clearAsync())}using(t,e,s){t.then(t=>{this&&!this.isDisposed&&e&&e(t)},t=>{this&&!this.isDisposed&&s&&s(t)})}doWork(t){return Promise.resolve(t).then(t=>this&&!this.isDisposed?t:S("MJX108"))}get siblings(){return this._siblingsSet||this.isDisposed&&!this.motif?.options?this._siblingsApi:this._siblingsApi??=this._createSiblingsApi()}set siblings(t){this._siblingsApi=t,this._siblingsSet=!0}_createSiblingsApi(){return{all:()=>this.parent?.controls.items,next:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items[t+1]},prev:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items[t-1]},nextAll:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items.slice(t+1)},prevAll:()=>{if(!this.parent)return;const t=this.parent.controls.items.indexOf(this);return this.parent.controls.items.slice(0,t)}}}get serviceProvider(){let t=this;for(;t;){const e=t.provider;if(e)return e;const s=ps.get(t);if(s)return"disposed"===s.state?null:s.provider;t=t.parent}try{return Ho.main?.provider??null}catch{return null}}getService(t){try{const e=this.serviceProvider;if(e)return e._getFor(this,t);k("MJX407",[Fe(t)],{token:t})}catch(e){k("MJX408",[Fe(t),String(e?.message??e)],{token:t,error:e})}return null}$(t){return this.isDisposed||!this.element?{fromDom:()=>null,fromComponent:()=>[]}:{fromDom:()=>{var e,s=wi(this)?.element;return(e=s||document)?e.querySelectorAll(t):null},fromComponent:()=>{const e=wi(this),s=[],i=e=>{const n=e.element;if(n&&n.nodeType===Node.ELEMENT_NODE){const i=n.matches||n.msMatchesSelector||n.webkitMatchesSelector;if("function"==typeof i)try{i.call(n,t)&&s.push(e)}catch{}}if(e.controls&&e.controls.items&&e.controls.items.length)for(const t of e.controls.items)i(t)};return i(e??this),s}}}async _stopAnimations(){const t=ze(this);try{t?.activeCssCancel?.()}catch{}try{if(t?.activeAnimations?.length)try{await Promise.all(t.activeAnimations.map(t=>t.finished?.catch(()=>{})))}catch{}}catch(t){}this.isDisposed||t&&(t.activeAnimations=[])}}function Vs(t,e=[]){return!t||t.isDisposed||("TransportTo"===t.constructor.name&&e.push(t),t.controls&&t.controls.items&&t.controls.items.forEach(t=>Vs(t,e))),e}const Ws=new WeakMap;function $s(t,e){const s=(Array.isArray(e)?e:[e]).filter(t=>"function"==typeof t);if(0===s.length)return s;let i=Ws.get(t);i||(i=new Set,Ws.set(t,i));const n=[];for(const t of s)i.has(t)||(i.add(t),n.push(t));return n}function Us(t,e){Array.isArray(e)&&e.some(t=>t instanceof zs)&&t.motif.setDisposable(()=>{for(const t of e)t instanceof zs&&!t.isDisposed&&!t.parent&&t.dispose()})}const qs=t=>"function"==typeof t||Array.isArray(t);function Gs(t,e){const s=[];if(!t||"object"!=typeof t)return s;Object.prototype.hasOwnProperty.call(t,"ref")&&(qs(t.ref)?(s.push(t.ref),delete t.ref):e&&t.ref&&"object"==typeof t.ref&&(t.ref=e));const i=t.runover;if(i&&"object"==typeof i&&Object.prototype.hasOwnProperty.call(i,"ref"))if(qs(i.ref)){s.push(i.ref);const e={...i};delete e.ref,t.runover=e}else e&&i.ref&&"object"==typeof i.ref&&(i.ref=e);return 0===s.length?s:[].concat(...s)}const Ks={initializecomponent:"_initializeComponentHandlers",oninitializecomponent:"_onInitializeComponentHandlers",onbuilding:"_onBuildingHandlers",onbuilt:"_onBuiltHandlers",onmounted:"_onMountedHandlers",oninitializing:"_onInitializingHandlers",oninitialized:"_onInitializedHandlers",onconfig:"_onConfigHandlers",onconfigured:"_onConfiguredHandlers",onvisibilitychanged:"_onVisibilityChangedHandlers",onactivated:"_onActivatedHandlers",ondeactivated:"_onDeactivatedHandlers",ondisposing:"_onDisposingHandlers",ondisposed:"_onDisposedHandlers"};function Ys(t,e,s){const i=Object.prototype.hasOwnProperty.call(Ks,e)?Ks[e]:void 0;if(!i)return!1;const n=Array.isArray(s)?s:[s];if(0===n.length||!n.every(t=>"function"==typeof t))return!1;const o=t;let r=0;if("_initializeComponentHandlers"===i&&(void 0!==o._init||o._baseCtx?._initializeComponentHandlers||(o._init=n[0],r=1)),r>=n.length)return!0;const a=o._base;for(let t=r;t<n.length;t++){const e=n[t];if("_initializeComponentHandlers"===i&&e===o._init)continue;const s=a[i];void 0===s?a[i]=e:"function"==typeof s?s!==e&&(a[i]=[s,e]):s.includes(e)||s.push(e)}return!0}function Qs(t,e){if(t){var s=Object.keys(t);return 0!==s.length&&(s.forEach(s=>{if("initializeComponent"==s||"oninitializeComponent"==s||s.startsWith("on")){if(Ys(e,s.toLowerCase(),t[s]))return void delete t[s]}else if("childs"==s){const i=[].concat(...t[s]);e.childs=i,Us(e,i),delete t[s]}else if("transition"===s)ei(t[s],e),delete t[s];else if(vi.hasOwnProperty(s.toLowerCase())||vi.hasOwnProperty("on"+s.toLowerCase())){var i;i=s.toLowerCase().startsWith("on")||"initializecomponent"===s.toLowerCase()?s:"on"+s,e[i]=t[s],delete t[s]}else if(s.startsWith("on"))e.motif.on(s,t[s]);else if(s.startsWith("x-")){var n=s.replace("x-","on");if("x-wait"==s.toLowerCase())e.bindings.wait(t[s]);else if("x-display"==s.toLowerCase())e.bindings.display(t[s]);else if(Ys(e,n.toLowerCase(),t[s]))return void delete t[s];delete t[s]}else s.startsWith("runover")?(Qs(t[s],e),delete t[s]):s.startsWith("preconfig")?(e.motif.options._preconfig=t[s],delete t[s]):"__childExpr"===s&&delete t[s]}),"object"==typeof t&&0===Reflect.ownKeys(t).length)}return!1}const Zs=new WeakMap;function ti(t,e,s){const i=t.motif.options.transition;if("string"==typeof e&&e.length>0)i.name=e,s&&(i.classes=void 0);else if(e&&"object"==typeof e)if("string"==typeof e.name&&e.name.length>0&&(i.name=e.name),"mode"in e){const{mode:t,...s}=e;je(t)&&(i.mode=t),Object.keys(s).length>0&&(i.classes=s)}else i.classes=e;else s&&(i.name="",i.classes=void 0)}function ei(t,e){e&&!e.isDisposed&&null!=t&&Zs.get(e)!==t&&(Zs.set(e,t),"function"!=typeof t?ti(e,t,!1):e.bindings.watch(()=>{const s=t();e.isDisposed||ti(e,s,!0)}))}function si(t){return t instanceof zs||Array.isArray(t)&&t.length>0&&t.every(t=>t instanceof zs)}const ii=new WeakSet;const ni=["hideStrategy","disableDisposal"];function oi(t,e){if(t&&"object"==typeof t&&e&&!e.isDisposed)for(const s of ni)void 0!==t[s]&&(e.motif.options[s]=t[s])}const ri=new Set(["ref","key","indexkey","inject","options","props","settings","isSvg","childs","initializeComponent","runover","transition","preconfig","nodes","onElementCreating"]),ai=new Set(["innerhtml","srcdoc"]),ci=new Set(["href","src","action","formaction","xlink:href"]),li=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function hi(t){if(null==t||"boolean"==typeof t)return!1;try{return li.test(String(t))}catch{return!1}}function ui(t,e){return()=>{let s=e();return"function"==typeof s&&(s=s()),"function"==typeof s&&(s=s()),hi(s)?(k("MJX125",[t]),null):s}}function di(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const s=Object.keys(t);if(0===s.length)return;let i=null,n=null;for(const o of s){if(ri.has(o))continue;if(o.startsWith("x-")||o.startsWith("x:")||o.startsWith("__"))continue;let s=t[o];if(void 0===s)continue;if(/^on/i.test(o)){"function"==typeof s&&e.motif.on(o,s);continue}if("function"==typeof s&&s.length>0)continue;const r=o.toLowerCase();if(ai.has(r))k("MJX124",[o]);else{if(ci.has(r))if("function"==typeof s)s=ui(o,s);else if(hi(s)){k("MJX125",[o]);continue}(n??=fi(e)).set(o,s),"class"===o||"className"===o?e.class.add(s&&"object"==typeof s&&!Array.isArray(s)?[s]:s):"style"===o?e.style(s):"value"===o||"checked"===o||"selected"===o?e.bindings.add(o,s):(i??={})[o]=s}}i&&e.attr.add(i)}const pi=new WeakMap;function fi(t){let e=pi.get(t);return e||(e=new Map,pi.set(t,e)),e}const mi=new Set(["class","className","style","id","tabindex","role"]);function _i(t){return mi.has(t)||t.startsWith("aria-")||t.startsWith("data-")}let gi=!1;function yi(t,e){if(!t||"object"!=typeof t||e.isDisposed)return;const s=pi.get(e);let i=null;for(const e of Object.keys(t)){if(!_i(e))continue;const n=t[e];null!=n&&("function"==typeof n&&n.length>0||s&&s.has(e)&&Object.is(s.get(e),n)||((i??={})[e]=n))}i&&di(i,e)}const vi={oninitializecomponent:(t,e)=>{},initializecomponent:(t,e)=>{},onconfigured:(t,e)=>{},onconfig:(t,e)=>{},onbuilding:(t,e)=>{},onbuilt:(t,e)=>{},onmounted:(t,e)=>{},oninitializing:(t,e)=>{},oninitialized:(t,e)=>{},ondisposing:(t,e)=>{},ondisposed:(t,e)=>{},onvisibilitychanged:(t,e)=>{},ondeactivated:(t,e)=>{},onactivated:(t,e)=>{}};function wi(t){return i(()=>!t||t.isDisposed?null:t.element.nodeType!==Node.COMMENT_NODE&&t.element.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.element.nodeType!==Node.TEXT_NODE?t:t.parent?wi(t.parent):null,"findAppendableComponent",null)}const bi=new Set;let Si=null;function Mi(){if(!bi.size&&Si){try{Si.disconnect()}catch{}Si=null}}function Ci(){for(const t of[...bi])if(bi.has(t)&&document.contains(t.element)){bi.delete(t);try{t.callback()}catch(t){queueMicrotask(()=>{throw t})}}Mi()}function ki(t,e){if(document.contains(t))return e(),null;const s={element:t,callback:e};return bi.add(s),Si||(Si=new MutationObserver(Ci),Si.observe(document.documentElement,{childList:!0,subtree:!0})),()=>{bi.delete(s)&&Mi()}}function Di(t){!function(t){const e=_e.get(t);e&&(_e.delete(t),e.live&&e.scope._releaseLivePin(),pe?._touch())}(t),ss.activateTree(t)}function Ai(t){Ce(t),ss.deactivateTree(t)}const xi=100;function Ei(t,e){let s=t,i=0;for(;"function"==typeof s;){if(s.prototype instanceof zs)return new s(e);if(++i>xi)return M("MJX112",void 0,xi),s;s=s(e)}return s}const Ti="http://www.w3.org/2000/svg";class Oi extends zs{constructor(){const t=new.target;var e,s,i=arguments;if(1===i.length?e=i[0]:2===i.length&&(e=i[0],s=i[1]),e instanceof Function&&Ji(e=Ei(e,s)))return Bi(e,s);if(Array.isArray(e)){super(Vi(),{});var n=Object.create(s||{});for(const t in e){const s=e[t];this.controls.add(new Oi(s,n))}}else if("string"==typeof e&&e.trim().length>0)if(s||(s={}),s?.options&&s.options.isSvg||s?.__isSvgElement){const t=qi.createElementNS("http://www.w3.org/2000/svg",e,s);s.isSvg=!0,super(t,s)}else{super(qi.createElement(e,s),s)}else if(e instanceof Node)super(e,s);else{if(e instanceof zs)return e;{const i=e&&"object"==typeof e?e:s,n=function(t){try{const e=t?.elementTag;if("string"==typeof e){const t=e.trim();if(t)return t}}catch{}}(t);if(n){super(function(t,e,s){const i="string"==typeof e?.elementNamespace&&e.elementNamespace?e.elementNamespace:void 0;return i===Ti||!0===s?.options?.isSvg||!0===s?.__isSvgElement?(s&&"object"==typeof s&&(s.isSvg=!0),qi.createElementNS(i||Ti,t,s)):qi.createElement(t,s)}(n,t,i),i??{})}else super(Vi(),i??{});const o=this.childs;if(Array.isArray(o)&&o.length&&!0!==t?._placesChilds)for(const t of o)t&&this.controls.add(t)}}}}function Ni(t){return e=>{var s=zi({...e});return s.controls.add(t(e)),s}}function Pi(t,e){if(t instanceof zs)for(const s of $s(t,e))C(()=>s(t),"MJX122","ref");return t}function Li(t,e){const s=t._base?.[e];return s?"function"==typeof s?[s]:s:[]}function Xi(t,e){return Li(t,e).length}function Ri(t,e,s,i){for(let n=s;n<Xi(t,e);n++){if(t.isDisposed)return;const s=Li(t,e)[n];C(()=>s(t,{cancel:!1}),"MJX122",i)}}function Ii(t,e){if("string"==typeof t){if("function"==typeof e){const s=new Oi(t);return s._init=e,s}if("text"===t&&e&&e.__childExpr){const t=function(t){if("function"!=typeof t)return;let e;try{e=Ot(t)}catch{return}return e instanceof zs||Array.isArray(e)&&e.length>0&&e.every(t=>t instanceof zs)?e:void 0}(e.__childExpr);if(void 0!==t)return t}return new Oi(t,e)}if(t instanceof zs||t instanceof Oi)return t;if("function"==typeof t){const s=t.prototype instanceof zs?[]:Gs(e),i=Ei(t,e);return"object"==typeof i&&null!==i&&"el"in i?Pi(Bi(i,e),s):function(t,e,s){if(!e||"object"!=typeof e)return t;if(!(t instanceof zs))return t;Pi(t,s.concat(Gs(e))),Us(t,e.childs),yi(e,t),oi(e.options,t),Object.prototype.hasOwnProperty.call(e,"transition")&&ei(e.transition,t);const i=e.runover;if(!i||"object"!=typeof i)return t;const n=Xi(t,"_onConfigHandlers"),r=Xi(t,"_onInitializingHandlers"),a=Xi(t,"_onInitializedHandlers");if(Qs(i,t),Ri(t,"_onInitializingHandlers",r,"onInitializing"),Ri(t,"_onInitializedHandlers",a,"onInitialized"),t.isConfigured){const e=t.motif.options?._preconfig;"function"==typeof e&&o(()=>e(t),"motifComponent.preconfig");for(let e=n;e<Xi(t,"_onConfigHandlers");e++){const s=Li(t,"_onConfigHandlers")[e];C(()=>s(t,{cancel:!1}),"MJX122","onConfig")}}return t}(i,e,s)}return"object"==typeof t&&null!==t&&"el"in t?Bi(t,e):new Oi(t,e)}function Ji(t){return"object"==typeof t&&null!==t&&!(t instanceof zs)&&"el"in t}function ji(t){return!t||"object"!=typeof t||t instanceof zs||null==t.default?t:t.default}function Fi(t){if(null!==t&&"object"==typeof t&&!(t instanceof zs||Array.isArray(t)||t instanceof Node)&&"function"!=typeof t.then)throw S("MJX127",function(t){return null===t?"null":Array.isArray(t)?"array":"object"!=typeof t||"[object Module]"!==Object.prototype.toString.call(t)&&!t.__esModule?typeof t:"module"}(t))}function Hi(t,e){const s=Ei(t,e);return Ji(s)?Bi(s,void 0):s}function Bi(t,e){const s="string"==typeof t.el?function(t){gi=!0;try{return t()}finally{gi=!1}}(()=>Ii(t.el,e)):Ii(t.el,e);return Object.getOwnPropertyNames(t).forEach(e=>{"el"!==e&&"ctor"!==e&&(s[e]=t[e])}),"function"==typeof t.ctor&&C(()=>t.ctor.call(s,e),"MJX122","ctor"),s}function zi(t){return new Wi(t)}function Vi(){return qi.createComment("")}class Wi extends Oi{constructor(t,e){super(Vi(),arguments.length<=1?t:e)}initializeComponent(t){const e=this.childs;if(Array.isArray(e)&&e.length)for(const t of e)t&&this.controls.add(t);o(()=>{const t=this.props?.nodes;if(Array.isArray(t)&&t.length)for(const e of t)e&&this.controls.add(e)},"Fragment.initializeComponent.props.nodes")}}const $i=globalThis;function Ui(){return $i&&$i.motifDom?$i.motifDom.window.document:$i.document}const qi={get window(){return $i&&$i.window?$i.window:$i&&$i?$i.motifDom.window:$i},_created:new Map,document:Ui(),createElement(t,e){const s=Ui();if(!s)throw S("MJX101",t);if("text"===t)return s.createTextNode("");if(!this._created.has(t)){const i=s.createElement(t,e);this._created.set(t,i)}return this._created.get(t).cloneNode(!1)},createDocumentFragment(){try{var t=Ui();if(t)return t.createDocumentFragment()}catch(t){s.reportSuppressed("dom.createDocumentFragment",t)}},createComment(t){try{return Ui()?.createComment(t)}catch(t){s.reportSuppressed("dom.createComment",t)}},createTextNode(t){try{return Ui()?.createTextNode(t)}catch(t){s.reportSuppressed("dom.createTextNode",t)}},querySelectorAll(t){try{return Ui()?.querySelectorAll(t)}catch(t){s.reportSuppressed("dom.querySelectorAll",t)}},createElementNS(t,e,s){try{return Ui()?.createElementNS(t,e,s)}catch(t){M("MJX103",t,e)}},convertToSvgElement(t){const e=t.tagName.toLowerCase(),s=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of t.attributes)s.setAttribute(e.name,e.value);for(;t.firstChild;)s.appendChild(t.firstChild);const i=t.parentNode;return i&&i.replaceChild(s,t),s},get body(){return Ui()?.body}},Gi=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;var Ki;function Yi(t,e,...s){return function(t,e,s,...i){const n=Gi.exec(e);if(!n)throw S("MJX102",e);const o=n[1]||"div";let r;return r=t!==Ki.HTML?qi.createElementNS(t,o):qi.createElement(o),n[3]&&(r.id=n[3]),n[4]&&(r.className=n[4].replace(/\./g," ").trim()),s&&Object.entries(s).forEach(([t,e])=>{void 0!==e&&(/^on\w+$/.test(t)?r[t]=e:"selected"===t?e&&r.setAttribute(t,"true"):r.setAttribute(t,e))}),r.append(...i),r}(Ki.HTML,t,e,...s)}!function(t){t.HTML="http://www.w3.org/1999/xhtml",t.SVG="http://www.w3.org/2000/svg"}(Ki||(Ki={}));class Qi{constructor(t){this.owner=t,this.items=[]}add(){const t=arguments.length;if(0===t)return[];const e=arguments[0];if(1===t&&e instanceof zs)return e.isDisposed?[]:[this._insertOne(void 0,e)];const s=Array.from(arguments);if("number"==typeof s[0]&&s.length>1){const t=s[0],e=[].concat(...s.slice(1));return this.insert(t,...e)}{const t=[].concat(...s);return this.insert(void 0,...t)}}insert(t,...e){return[].concat(...e).filter(t=>null!=t&&!t.isDisposed).map(e=>this._insertOne(t,e))}_insertOne(t,e){"string"!=typeof(e=Ei(e))&&"number"!=typeof e&&"boolean"!=typeof e&&"bigint"!=typeof e||(e=new Oi(qi.createTextNode(e),null)),es(e),e.parent&&e.parent.controls.detach(e),null!=t&&t>=0?this.items.splice(t,0,e):this.items.push(e),e.parent=this.owner;const s=e.__pendingLeave;return s?(this.onAddBeforeBuild&&!this.owner.isBuilt&&this.onAddBeforeBuild(e),s.promise.then(()=>{e.isDisposed||this.owner.isDisposed||e.parent!==this.owner||this.onAdd&&this.owner.isBuilt&&this.onAdd(e)}),e):(this.onAdd&&this.owner.isBuilt&&this.onAdd(e),this.onAddBeforeBuild&&!this.owner.isBuilt&&this.onAddBeforeBuild(e),e)}remove(t){var e=this.items.indexOf(t);if(e>-1){this.items.splice(e,1);try{t.dispose()}catch{}}}detach(t){const e=this.items.indexOf(t);return-1===e?Promise.resolve():(this.items.splice(e,1),t.isDisposed?Promise.resolve():(t._leaveContainer=this.owner,t.parent=null,function(t,e){let s=()=>{};const i=new Promise(t=>{s=t});let n=1,o=!1;const r=()=>{if(!o){if(o=!0,t.__pendingLeave?.promise===i&&delete t.__pendingLeave,!t.isDisposed){try{sn(t)}catch(t){M("MJX117",t)}Ai(t)}try{e()}catch(t){M("MJX118",t)}s()}},a=()=>{n--,0===n&&r()},c=t=>{if(!t||t.isDisposed||!t.element||!t.isVisible||t.isWait)return;const e=t.element;if(e.nodeType===Node.COMMENT_NODE)return void t.controls.items.forEach(c);if(e.nodeType!==Node.ELEMENT_NODE)return;n++;let s=!1;const i=()=>{s||(s=!0,a())};try{const e=t.motif.options;if(!e[Ee]&&!e.transitionOut)return void i();e.transition.leaveTransition(i)}catch{i()}};return t.__pendingLeave={promise:i,finish:r},c(t),a(),i}(t,()=>{this.onRemove&&this.onRemove(t)})))}silentDetach(t,e=!1){if(e)return void this.silentUnlink(t);const s=this.items.indexOf(t);if(-1!==s&&(this.items.splice(s,1),!t.isDisposed)){t.parent=null;try{sn(t)}catch(t){M("MJX117",t)}Ai(t)}}silentUnlink(t){const e=this.items.indexOf(t);-1!==e&&(this.items.splice(e,1),t._leaveContainer=this.owner,t.parent=null)}async clearAsync(){const t=this.items.splice(0,this.items.length);await Promise.all(t.map(t=>t.dispose()))}clear(){this.items.splice(0,this.items.length).forEach(t=>{try{t.dispose()}catch{}})}get length(){return this.items.length}forEach(t){this.items.forEach(t)}map(t){return this.items.map(t)}move(t,e){if(!t||t.isDisposed)return;if(e===t)return;if(t.parent!==this.owner)return;if(e&&e.parent!==this.owner)return;const s=this.items.indexOf(t);if(-1===s)return;const i=e?this.items.indexOf(e):-1;if(e&&-1===i)return;if(e?i===s+1:s===this.items.length-1)return;if(this.items.splice(s,1),e){const s=this.items.indexOf(e),i=s>=0?s:this.items.length;this.items.splice(i,0,t)}else this.items.push(t);const n=Zi(this.owner);if(!n||!ns(t,n))return;const o=e?this.items.indexOf(e):-1;en(t,n,o>=0?function(t,e,s,i){for(let t=s;t<e.length;t++){const s=ns(e[t],i);if(s)return s}return tn(t)}(this.owner,this.items,o,n):tn(this.owner))}_reorder(t,e){const s=Zi(this.owner);if(s){let i=tn(this.owner);for(let n=t.length-1;n>=0;n--){const o=t[n],r=ns(o,s);r&&(e.has(n)||en(o,s,i),i=r)}}const i=this.items;for(let e=0;e<t.length;e++)i[e]=t[e]}moveToIndex(t,e){if(!t||t.isDisposed)return;if(!Number.isFinite(e))return;if(e<0&&(e=0),e>this.items.length&&(e=this.items.length),-1===this.items.indexOf(t))return;const s=e>=this.items.length?null:this.items[e];this.move(t,s)}}function Zi(t){let e=t;for(;e;){const t=e.element;if(t&&t.nodeType!==Node.COMMENT_NODE&&t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&t.nodeType!==Node.TEXT_NODE)return t;e=e.parent}return null}function tn(t){const e=t.element;return e&&e.nodeType===Node.COMMENT_NODE&&t.motif.options?.closeFragment||null}function en(t,e,s){const i=ns(t,e);if(!i)return;if(i.nodeType!==Node.COMMENT_NODE||i!==t.element){try{e.insertBefore(i,s)}catch{}return}const n=i,o=t.motif.options?.closeFragment||null;if(!o){try{e.insertBefore(n,s)}catch{}return}s&&function(t,e,s){let i=t,n=1e4;for(;i&&n-- >0;){if(i===s)return!0;if(i===e)break;i=i.nextSibling}n<=0&&M("MJX120",void 0);return!1}(n,o,s)&&(s=o.nextSibling);const r=qi.createDocumentFragment&&qi.createDocumentFragment()||e.ownerDocument?.createDocumentFragment?.()||function(){try{return document.createDocumentFragment()}catch{return null}}();if(!r){let t=n,i=1e4;for(;t&&i-- >0;){const i=t.nextSibling;try{e.insertBefore(t,s)}catch{}if(t===o)break;t=i}return void(i<=0&&M("MJX119",void 0))}let a=n,c=1e4;for(;a&&c-- >0;){const t=a.nextSibling;try{r.appendChild(a)}catch{}if(a===o)break;a=t}c<=0&&M("MJX119",void 0);try{e.insertBefore(r,s)}catch{}}function sn(t){const e=t.element;if(!e)return;const s=t.motif.options;if(e.nodeType===Node.COMMENT_NODE&&e.parentNode){const t=s?.closeFragment||null,i=s.cache??(s.cache=qi.createDocumentFragment());let n=e,o=1e4;for(;n&&o-- >0;){const e=n.nextSibling;if(i.appendChild(n),!t||n===t)break;n=e}return}if(e.parentNode)return void e.parentNode.removeChild(e);const i=s?.placeholder;i&&i.parentNode&&i.parentNode.removeChild(i)}function nn(t){return ji(t)}function on(t){const e=t&&t.options||{},s=new hn,i=new Set,n=t=>{try{i.add(t)}catch{}return t},o=()=>{try{i.forEach(t=>{try{clearTimeout(t)}catch{}})}catch{}try{i.clear()}catch{}};try{s.motif.register(D.toDisposable(()=>o()))}catch{}const r=e.Placeholderview??e.Loaderview;null!=r&&s.navigate(Hi(r));const a=()=>{if(!e.timeoutMs&&!e.signal)return t.caller();const s=[t.caller()];return e.timeoutMs&&e.timeoutMs>0&&s.push(new Promise((t,o)=>{const r=n(setTimeout(()=>o(S("MJX110",e.timeoutMs)),e.timeoutMs));if(s[0].finally(()=>{try{clearTimeout(r),i.delete(r)}catch{}}).catch(()=>{}),e.signal){const t=()=>{try{clearTimeout(r),i.delete(r)}catch{}};try{e.signal.addEventListener("abort",t,{once:!0})}catch{}}})),e.signal&&s.push(new Promise((t,s)=>{if(e.signal.aborted)return void s(S("MJX111"));const i=()=>{e.signal.removeEventListener("abort",i),o(),s(S("MJX111"))};e.signal.addEventListener("abort",i,{once:!0})})),Promise.race(s)},c=function(t){return"number"==typeof t?{count:Math.max(0,Math.floor(t)),delayMs:500,whenOnline:!0}:t&&"object"==typeof t?{count:Math.max(0,Math.floor(t.count||0)),delayMs:Math.max(0,t.delayMs??500),whenOnline:!1!==t.whenOnline}:{count:0,delayMs:0,whenOnline:!1}}(e.retry),l=new Set;try{s.motif.register(D.toDisposable(()=>{l.forEach(t=>{try{t()}catch{}}),l.clear()}))}catch{}const h=t=>new Promise(s=>{let o=!1;const r=t=>{if(!o){o=!0,l.delete(a);try{d&&window.removeEventListener("online",d)}catch{}try{void 0!==u&&(clearTimeout(u),i.delete(u))}catch{}try{e.signal?.removeEventListener("abort",h)}catch{}s(t)}},a=()=>r(!1),h=()=>r(!1);let u,d=null;l.add(a);try{e.signal?.addEventListener("abort",h,{once:!0})}catch{}const p=()=>{u=n(setTimeout(()=>r(!0),c.delayMs*t))};c.whenOnline&&"undefined"!=typeof navigator&&!1===navigator.onLine&&"undefined"!=typeof window?(d=()=>{try{window.removeEventListener("online",d)}catch{}d=null,p()},window.addEventListener("online",d)):p()}),u=c.count>0?(async()=>{let t=0;for(;;)try{return await a()}catch(i){if(e.signal?.aborted||s.isDisposed||t>=c.count)throw i;t++;try{e.onRetry?.(t,i)}catch{}if(!await h(t)||e.signal?.aborted||s.isDisposed)throw i}})():a(),d=Date.now(),p=t=>{try{e.onError?.(t)}catch{}if(!e.signal?.aborted)if(null!=e.Fallbackview)s.navigate(Hi(e.Fallbackview));else{M("MJX126",t);try{s.motif.clear().catch(()=>{})}catch{}}},f=t=>{let e;try{e=Hi(t),Fi(e)}catch(t){return void p(t)}s.navigate(e)};return u.then(t=>{if(e.signal?.aborted)return;const s=(e.mapResult??nn)(t),o=Date.now()-d,r=Math.max(0,e.minDelayMs??0),a=Math.max(0,r-o);if(a>0){const t=n(setTimeout(()=>{e.signal?.aborted||f(s)},a));if(e.signal){const s=()=>{try{clearTimeout(t),i.delete(t)}catch{}};try{e.signal.addEventListener("abort",s,{once:!0})}catch{}}}else f(s)}).catch(p),s}function rn(t,e){const s=t?.motif?.options;if(!s)return!1;const i=s.transition;return!!(("enter"===e?s.transitionIn:s.transitionOut)||i&&(i.classes||i.name&&i.name.length>0))}function an(t){if(t&&!t.isDisposed)if(Array.isArray(t))t.forEach(an);else{try{t.motif.options?.transition?.activeCssCancel?.()}catch{}try{const e=t.motif.options?.transition?.activeAnimations;Array.isArray(e)&&(e.forEach(t=>{try{t&&"function"==typeof t.cancel&&t.cancel()}catch{}}),e.length=0)}catch{}try{if(t.controls&&t.controls.items)for(const e of t.controls.items)an(e)}catch{}}}async function cn(t,e={deep:!0}){if(!t)return;const s=Array.isArray(t)?t:[t];await Promise.all(s.map(async t=>{if(t&&!t.isDisposed)try{await t.dispose(e)}catch(t){M("MJX115",t)}}))}async function ln(t,e,s=!1){if(t.isDisposed||null==e)return;if(null!==t.current&&t.current===e)return;const i=++t._latestNavigateId;t.isBusy=!0;const n=e=>{if(t.isDisposed)return;if(i!==t._latestNavigateId)return;const s=Ei(e);t.current=s;try{Array.isArray(s)?t.controls.add(...s):t.controls.add(s)}catch(t){M("MJX114",t)}t.isBusy=!1,t.previouspage=s};if(!(t._navPending||null!==t.current||e instanceof Promise)){try{n(e)}catch(e){M("MJX114",e),t.isBusy=!1}return}t._navPending=(t._navPending??0)+1;const o=t._navLock??Promise.resolve();t._navLock=(async()=>{try{await o;try{t._navAbort?.abort()}catch{}t._navAbort=new AbortController;const r=t.current;if(r&&!s){an(r),an(t);const e=!!(i=r)&&(Array.isArray(i)?i.some(t=>!!t&&!t.isDisposed&&rn(t,"leave")):!i.isDisposed&&rn(i,"leave")),s=cn(r);e?s.catch(()=>{}):await s}try{if(e instanceof Promise){const s=on({caller:()=>e,options:{signal:t._navAbort?.signal}});n(s)}else n(e)}catch(e){M("MJX114",e),t.isBusy=!1}}finally{t._navPending=Math.max(0,(t._navPending??1)-1)}var i})(),await t._navLock}class hn extends Oi{constructor(t){super(qi.createComment(""),t),this.current=null,this._latestNavigateId=0,this._navLock=Promise.resolve(),this.isBusy=!1,t&&t.childs&&Array.isArray(t.childs)&&t.childs.length>0&&this.controls.add(t.childs)}async dispose(t={deep:!0}){await cn(this.current,t),await super.dispose(t)}async flush(){await cn(this.current)}async _clear(){await cn(this.current)}async navigate(t,e=!1){await ln(this,t,e)}async navigateLazy(t,e,s=!1){const i=on({caller:t,options:e});await this.navigate(i,s)}}const un=new Set;function dn(t){un.add(t),un.forEach(t=>{t()})}const pn=new Map,fn=Symbol("changeBodyCollectionHandler");class mn extends Oi{constructor(t){super(t);const e=t=>{this.motif.trigger("controladded",{control:t});var e=pn.get(this.props.target);e&&(t.motif.options.ownerContentBlock=this,e.controls.add(t))};this.controls.onAdd=e,this.controls.onAddBeforeBuild=e,this.childs&&this.controls.add(...this.childs)}onConfigured(t,e){var s=pn.get(this.props.target);s?(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),s.controls.add(...this.controls.items)):this.context.on(fn,()=>{var t=pn.get(this.props.target);t&&(this.controls.items.forEach(t=>{t.motif.options.ownerContentBlock=this}),t.controls.add(...this.controls.items))})}onDisposing(t,e){var s=pn.get(this.props.target);if(s)for(const t of[...s.controls.items])t.motif.options.ownerContentBlock===this&&(s.controls.remove(t),k("MJX109",[],t))}ondisposing(t){}}class _n extends Oi{constructor(t){super(t),pn.set(this.props.name,this),this.context.fire(fn)}ondisposing(t){pn.get(this.props.name)===this&&pn.delete(this.props.name)}}const gn=Symbol("slotRegistered"),yn=Symbol("slotUnregistered");class vn{static{this.slots=new Map}static registerSlot(t,e){this.slots.set(t,e),Ho.main.fire(gn,{name:t,slot:e})}static unregisterSlot(t,e){this.slots.get(t)===e&&(this.slots.delete(t),Ho.main.fire(yn,{name:t,slot:e}))}static getSlot(t){return this.slots.get(t)}}class wn extends Oi{constructor(t){super(t),this.mode=t.mode||"replace"}initializeComponent(t){vn.registerSlot(this.props.name,this),this.onDisposing=()=>{[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()}),vn.unregisterSlot(this.props.name,this)}}clearSlot(){[...this.controls.items||[]].forEach(t=>{this.controls.remove(t),t.dispose?.()})}}class bn{static transport(t,e,s={}){t&&e&&(t.parent===e&&e.controls.items.includes(t)||(t.parent&&t.parent!==e&&t.parent.controls.silentDetach(t,!0),s.owner&&(t.motif.options.ownerTransporter=s.owner),"number"==typeof s.index?e.controls.items.includes(t)||e.controls.items.splice(s.index,0,t):e.controls.items.includes(t)||e.controls.add(t),t.parent=e,s.keepState||t.reState()))}static transportMany(t,e,s={}){Array.isArray(t)&&t.forEach(t=>this.transport(t,e,s))}static createSlot(t,e){return{name:t,children:[],parent:e,mount(t,e={}){if(!this.parent)throw S("MJX113");this.children.includes(t)||(bn.transport(t,this.parent,e),this.children.push(t))},unmount(t){if(!this.parent)throw S("MJX113");this.children=this.children.filter(e=>e!==t),this.parent.controls.remove(t)},detachAll(){this.parent&&(this.children.forEach(t=>{this.parent.controls.remove(t)}),this.children=[])}}}}class Sn extends Oi{constructor(t){super("div",t),this._transported=[],this._countedLive=!1,this._handleSlotChange=t=>{if(t.name===this.props.name){const e=t.slot;"merge"!==e.mode&&e.clearSlot?.();const s=[...this.childs||[],...this.controls.items];bn.transportMany(s,e),this._rememberTransported(s)}},this._clearChildrenFromSlot=t=>{(this.childs||[]).forEach(e=>{t.controls.remove(e),e.dispose()}),(this.controls.items||[]).forEach(e=>{t.controls.remove(e),e.dispose()})},Ae.live++,this._countedLive=!0}_rememberTransported(t){const e=this._transported.filter(t=>!t.isDisposed);for(const s of t)e.includes(s)||e.push(s);this._transported=e}initializeComponent(t){let e=vn.getSlot(this.props.name);if(e){"merge"!==e.mode&&e.clearSlot?.();const t=[...this.childs||[],...this.controls.items];bn.transportMany(t,e),this._rememberTransported(t)}this._slotRegisteredListener=Ho.main.on(gn,this._handleSlotChange),this._slotUnregisteredListener=Ho.main.on(yn,t=>{t.name===this.props.name&&this._clearChildrenFromSlot(t.slot)}),this._onAddRef=t=>{this.motif.trigger("controladded",{control:t});const e=vn.getSlot(this.props.name);e&&(bn.transport(t,e),this._rememberTransported([t]))},this._onRemoveRef=t=>{const e=vn.getSlot(this.props.name);e&&e.controls.remove(t),this._transported=this._transported.filter(e=>e!==t)},this.controls.onAdd=this._onAddRef,this.controls.onRemove=this._onRemoveRef}onDisposing(t,e){this._countedLive&&(this._countedLive=!1,Ae.live--);const s=vn.getSlot(this.props.name);for(const t of this._transported||[])s?.controls.remove(t),t.dispose();this._slotRegisteredListener&&(Ho.main.off(gn,this._handleSlotChange),this._slotRegisteredListener=void 0),this._slotUnregisteredListener&&(Ho.main.off(yn,this._slotUnregisteredListener),this._slotUnregisteredListener=void 0),this.controls.onAdd===this._onAddRef&&(this.controls.onAdd=void 0),this.controls.onRemove===this._onRemoveRef&&(this.controls.onRemove=void 0),this._onAddRef=void 0,this._onRemoveRef=void 0,this._transported=[]}}const Mn=new Set(["push","pop","shift","unshift","splice","reverse","sort"]),Cn=Symbol(""),kn=new Map([[T.IS_REACTIVE,()=>!0],[T.IS_READONLY,t=>t.isReadonly],[T.IS_SUPERFICIAL,t=>t.superficial],[T.GET_SETUP,(t,e)=>e],[T.RAW,(t,e,s)=>t.ReactiveMap().get(e)===s?e:Cn]]);function Dn(t,e,s,i){if("symbol"!=typeof s)return Cn;const n=kn.get(s);return void 0===n?Cn:n(t,e,i)}function An(t){return function(e,s,i){const n=Dn(t,e,s,i);if(n!==Cn)return n;if(Array.isArray(e)&&!t.isReadonly){const i=t.arrayMethods.get;if(X(i,s)){const t=i[s];return Mn.has(s)?(o=s,$.push(P),P.enabled=!0,P.key=o):St(e,s),t}}var o;const r=Reflect.get(e,s,i);return"__proto__"===s||J(s)?r:(t.isReadonly||St(e,s),t.superficial||!R(r)?r:t.reactive(r))}}function xn(t){return function(e,s,i,n){if(null!=(o=e)&&Boolean(o[T.IS_READONLY]))return!1;var o;const r=Array.isArray(e),a=e[s],c=r?e.length:0,l=r&&("string"==typeof(h=s)&&F.test(h)&&String(Number(h))===h);var h;const u=l?Number(s)<c:X(e,s),d=Reflect.set(e,s,i,n);if(t.onValueChanged)try{t.onValueChanged({raw:e,proxy:n},s)}catch{}if(L(e)!==L(n))return d;if(!r&&u&&Object.is(i,a))return d;if(Mt(e,s),r||u||Mt(e,O),l&&!u&&Mt(e,"length"),r&&"length"===s){for(let t=Number(i);t<c;t++)Mt(e,String(t))}return function(){const t=$.pop();P=$.length>0?void 0===t?{enabled:!1,key:""}:t:{enabled:!1,key:""}}(),d}}function En(t){return function(t){return St(t,Array.isArray(t)?"length":O),Reflect.ownKeys(t)}}function Tn(t){return function(t,e){const s=Reflect.has(t,e);return J(e)||St(t,e),s}}function On(t){return function(t,e){V();try{const s=X(t,e),i=Reflect.deleteProperty(t,e);return s&&(Array.isArray(t)?Mt(t,"length"):(Mt(t,e),Mt(t,O))),i}finally{W()}}}const Nn=[["includes","lookup"],["indexOf","lookup"],["lastIndexOf","lookup"],["sort","order"],["concat","join"],["push","structural"],["pop","structural"],["shift","structural"],["unshift","structural"],["splice","structural"],["reverse","structural"]];class Pn{constructor(t){this.engine=t,this.get=this.createArrayMethods()}createArrayMethods(){const t={};for(const[e,s]of Nn)t[e]=this.patch(e,s);return t}patch(t,e){const s=this;switch(e){case"lookup":return function(...e){const i=L(this);s.engine.track(i,"length");const n=i[t](...e);return!1!==(o=n)&&-1!==o?n:i[t](...e.map(t=>L(t)));var o};case"order":return function(...e){const i=L(this),n=this.length;for(let t=0;t<n;t++)s.engine.track(i,String(t));const o=i[t].apply(this,e);return s.engine.track(i,t),o};case"join":return function(...t){return Array.prototype.concat.apply(this,t)};default:return function(...e){V();const s=L(this);try{return s[t].apply(this,e)}finally{W()}}}}}const Ln=Symbol("");function Xn(t,e,s){Mt(t,e),Mt(t,O),s&&Mt(t,Ln)}function Rn(t,e){return t.has(e)?e:L(e)}function In(t,e){return{next(){const s=t.next();return s.done?s:{value:e(s.value),done:!1}},[Symbol.iterator](){return this}}}function Jn(t){const e=function(t){const e=e=>R(e)?t.reactive(e):e,s=t=>t instanceof Map?([t,s])=>[t,e(s)]:([t])=>{const s=e(t);return[s,s]};return{get(t){const s=L(this),i=Rn(s,t);return St(s,i),e(s.get(i))},has(t){const e=L(this),s=Rn(e,t);return St(e,s),e.has(s)},set(t,e){const s=L(this),i=Rn(s,t),n=L(e),o=s.has(i),r=s.get(i);return s.set(i,n),o?Object.is(r,n)||Xn(s,i,!1):Xn(s,i,!0),this},add(t){const e=L(this),s=Rn(e,t);return e.has(s)||(e.add(s),Xn(e,s,!0)),this},delete(t){const e=L(this),s=Rn(e,t),i=e.delete(s);return i&&Xn(e,s,!0),i},clear(){const t=L(this);if(0===t.size)return;const e=Array.from(t.keys());t.clear();for(const s of e)Mt(t,s);Mt(t,O),Mt(t,Ln)},forEach(t,s){const i=L(this);St(i,O);const n=this,o=i instanceof Map;i.forEach((i,r)=>{const a=e(i);t.call(s,a,o?r:a,n)})},keys(){const t=L(this);return t instanceof Map?(St(t,Ln),t.keys()):(St(t,O),In(t.keys(),e))},values(){const t=L(this);return St(t,O),In(t.values(),e)},entries(){const t=L(this);return St(t,O),In(t.entries(),s(t))},[Symbol.iterator](){const t=L(this);return St(t,O),t instanceof Map?In(t.entries(),s(t)):In(t.values(),e)}}}(t);return{get(s,i,n){const o=Dn(t,s,i,n);if(o!==Cn)return o;if("size"===i)return St(s,O),s.size;if(("string"==typeof i||i===Symbol.iterator)&&X(e,i)&&i in s)return e[i];const r=Reflect.get(s,i,s);return"function"==typeof r?r.bind(s):r}}}const jn=new WeakSet,Fn=new WeakMap;const Hn=new class{startGc(t=1e4){}stopGc(){if(this._gci){try{clearInterval(this._gci)}catch{}this._gci=void 0}}constructor(){this.DisposeMapper=new st,this.arrayTriggerCache=new Map,this.ReactiveMap=()=>Fn,this.isReadonly=!1,this.superficial=!1,this.arrayMethods=new Pn(this),this.arrayHandler={get:An(this),set:xn(this),has:Tn(),deleteProperty:On(),ownKeys:En()},this.deepHandler={get:An(this),set:xn(this),has:Tn(),deleteProperty:On(),ownKeys:En()},this.collectionHandler=Jn(this),jn.add(this),this.startGc()}reactive(t){R(t)||(t={value:t});const e=(s=t,i=Object.getPrototypeOf(s),n="",i&&i.constructor&&(n=i.constructor.name),"Control"===n||"RouteManager"==n||"ServiceManager"==n?0:Object.isExtensible(s)?j.get(Object.prototype.toString.call(s))??0:0);var s,i,n;if(0===e)return t;let o=Fn.get(t);if(o)return o;if(o=Fn.get(L(t)),o)return o;if(2===e){var r=new Proxy(t,this.collectionHandler);return Fn.set(t,r),r}if(Array.isArray(t)){r=new Proxy(t,this.arrayHandler);return Fn.set(t,r),r}r=new Proxy(t,this.deepHandler);return Fn.set(t,r),r}clearModel(t){null!=t&&null!=t&&(Object.keys(t).forEach(e=>{"object"==typeof t[e]&&(Fn.has(t[e])||Fn.has(L(t[e])))&&this.clearModel(t[e]),Fn.delete(L(t[e])),Fn.delete(t[e])}),Fn.delete(L(t)),Fn.delete(t))}track(t,e){St(t,e)}trigger(t,e,s){Mt(t,e)}ArrayTrigger(t,e,...s){this.trigger(t,e,s)}toRaw(t){return JSON.parse(JSON.stringify(this.deepClone(t)))}deepClone(t){var e,s=this;if(!t)return t;if([Number,String,Boolean].forEach(function(s){t instanceof s&&(e=s(t))}),void 0===e)if("[object Array]"===Object.prototype.toString.call(t))e=[],t.forEach(function(t,i,n){e[i]=s.deepClone(t)});else if("object"==typeof t)if(t.nodeType&&"function"==typeof t.cloneNode)e=t.cloneNode(!0);else if(t.prototype)e=t;else if(t instanceof Date)e=new Date(t);else for(var i in e={},t)e[i]=s.deepClone(t[i]);else e=t;return e}pauseTracking(){V()}enableTracking(){z(!0)}resetTracking(){W()}dispose(){var t=!0;for(this.stopGc();1==t;)if(this.DisposeMapper.size>0){const t=this.DisposeMapper.pop();Fn.delete(t)}else t=!1;this.DisposeMapper.clear(),jn.delete(this)}},Bn=[],zn=()=>{try{const t=globalThis;return!!t.__MOTIF_DEV__&&(t.__MOTIF_STORE_REGISTRY__!==Bn&&(t.__MOTIF_STORE_REGISTRY__=Bn),!0)}catch{return!1}};function Vn(t){const e=Hn.reactive(t);try{if(zn()){const s=t?.constructor?.name||"reactive";Bn.push({name:s,value:e,type:"reactive"}),Bn.length>200&&Bn.shift()}}catch{}return e}function Wn(t){const e=Hn.reactive(t);try{if(zn()){const s=t?.constructor?.name||"useModel";Bn.push({name:s,value:e,type:"reactive"}),Bn.length>200&&Bn.shift()}}catch{}return e}function $n(t){return Hn.clearModel(t)}function Un(t){return Hn.deepClone(t)}function qn(t){const e=new re(t);try{if(zn()){const t=`signal_${Bn.length}`;Bn.push({name:t,value:e.value,type:"signal"}),Bn.length>200&&Bn.shift()}}catch{}return e}function Gn(t){const e=new ae(t);try{if(zn()){const t=`computed_${Bn.length}`;Bn.push({name:t,value:e.value,type:"computed"}),Bn.length>200&&Bn.shift()}}catch{}return e}function Kn(t){const e=new ce(t);try{if(zn()){const t=`lazyComputed_${Bn.length}`;Bn.push({name:t,value:void 0,type:"computed"}),Bn.length>200&&Bn.shift()}}catch{}return e}class Yn extends Oi{constructor(t){super("div",t),this._cache=new Map,this._view=[],this._occurrence=[],this._occurrenceKeys=new WeakMap,this._isLoadingMore=!1,this._emptyRendered=!1,this._renderPending=!1,this.contentWrapper=new Oi,this._initialLoadStarted=!1,this._offsets=null,this._observedHeight=-1,this._loadSeq=0,this._reloadScheduled=!1,this._reloadTimes=[],this._handleScroll=(t,e)=>{if(this.renderViewport(),!1===this.props.autoLoad)return;if(!this._state.hasMore||this._isLoadingMore||!this._state.isInitialized)return;const s=this.wrapper.element,i=this._fixedHeight();(null!==i?this._state.data.length*i:this._offsetOf(this._view.length))-(s.scrollTop+s.clientHeight)<(this.props.autoLoadThreshold??100)&&this._loadMore()},t.className&&this.class.add(t.className),t.style&&Object.assign(this.element.style,t.style),this._state=this.useModel({isLoading:!1,isInitialized:!1,currentPage:0,totalCount:0,hasMore:!0,error:void 0,data:[]}),this._loadMore=this._loadMore.bind(this),this._renderLoadingState=this._renderLoadingState.bind(this),this._renderErrorState=this._renderErrorState.bind(this),this._renderEmptyState=this._renderEmptyState.bind(this),this._loadInitial=this._loadInitial.bind(this),this.renderViewport=this.renderViewport.bind(this),this._makeView()}_makeView(){this._topSpacer=new Oi("div"),this._topSpacer.element.style.cssText="height: 0px;",this._topSpacer.class.add("motif-virtualization-top-spacer"),this._bottomSpacer=new Oi("div"),this._bottomSpacer.element.style.cssText="height: 0px;",this._bottomSpacer.class.add("motif-virtualization-bottom-spacer"),this._virtualContent=new Oi(document.createComment("")),this.props.mainTemplate?(this.contentWrapper.controls.add(this._topSpacer,this._virtualContent,this._bottomSpacer),this.contentWrapper.onBuilding=t=>{var e=Q(t.parent);e&&(this.wrapper=e,this._loadInitial(),e.style({overflowY:"auto",position:"relative"}),e.motif.on("scroll",this._handleScroll))},this.controls.add(this.props.mainTemplate(this.contentWrapper,this._state))):(this.wrapper=this,this.element.style.cssText="overflow-y: auto; height: 100%; position: relative;",this.controls.add(this._topSpacer,this._virtualContent,this._bottomSpacer),this.motif.on("scroll",this._handleScroll))}onBuilding(){this.props.mainTemplate||this._initialLoadStarted||(this._initialLoadStarted=!0,this._loadInitial())}onMounted(){this._observeResize(),this._renderPending&&this.renderViewport()}onDisposing(){this._stopResizeObserver(),this._stopDataWatch(),this._clearContent()}_fixedHeight(){const t=this.props.itemHeight;return"function"==typeof t?null:t}_computeOffsets(){const t=this.props.itemHeight;if("function"!=typeof t)return void(this._offsets=null);const e=this._view,s=new Array(e.length+1);s[0]=0;for(let i=0;i<e.length;i++){let n=0;try{n=Number(t(e[i],i))}catch{n=0}s[i+1]=s[i]+(n>0&&Number.isFinite(n)?n:0)}this._offsets=s}_layoutOffsets(){return this._offsets&&this._offsets.length===this._view.length+1||this._computeOffsets(),this._offsets}_offsetOf(t){const e=this._fixedHeight();if(null!==e)return t*e;const s=this._layoutOffsets();return s[Math.min(Math.max(0,t),s.length-1)]}_indexAt(t,e){const s=e.length-1;if(s<=0)return 0;let i=0,n=s-1;for(;i<n;){const s=i+n+1>>1;e[s]<=t?i=s:n=s-1}return i}_observeResize(){const t=this.wrapper?.element;if(!t||this._observed===t||this.isDisposed)return;const e=globalThis.ResizeObserver;if("function"!=typeof e)return;this._stopResizeObserver(),this._observedHeight=t.clientHeight;const s=new e(()=>{if(this.isDisposed)return;const e=t.clientHeight;e!==this._observedHeight&&(this._observedHeight=e,this.renderViewport())});s.observe(t),this._resizeObserver=s,this._observed=t}_stopResizeObserver(){try{this._resizeObserver?.disconnect()}catch{}this._resizeObserver=void 0,this._observed=void 0}_stopDataWatch(){this._dataWatchStop?.(),this._dataWatchStop=void 0}_request(t,e){const s=()=>{try{return Promise.resolve(this.props.dataRequest(t))}catch(t){return Promise.reject(t)}};if(!e||!1===this.props.autoRefresh)return Ot(s);let i;this._stopDataWatch();let n=!0;return this._dataWatchStop=At(()=>{if(n){n=!1;try{this.props.watch?.()}catch(t){M("MJX205",t)}i=s()}else this._scheduleReload()}),i}_scheduleReload(){this._reloadScheduled||this.isDisposed||(this._reloadScheduled=!0,queueMicrotask(()=>{if(this._reloadScheduled=!1,this.isDisposed)return;const t=Date.now();if(this._reloadTimes=this._reloadTimes.filter(e=>t-e<1e3),this._reloadTimes.push(t),this._reloadTimes.length>30)return this._stopDataWatch(),void k("MJX206",[]);this._state.isInitialized?this._reloadLoaded():this._loadInitial()}))}async _reloadLoaded(){const t=++this._loadSeq,e=this.props.pageSize||50,s=this._state.currentPage+1;try{const i=await this._request({page:0,pageSize:e*s,scrollTop:this.wrapper?.element?.scrollTop??0},!0);if(this.isDisposed||t!==this._loadSeq)return;const n=this.wrapper?.element,o=n?.scrollTop??0;this._state.currentPage=s-1,this._state.totalCount=i.totalCount,this._state.hasMore=i.hasMore,this._state.error=void 0,this._state.data=i.items,this._rebuildView(),this._topSpacer.style({height:"0px"}),this._bottomSpacer.style({height:this._offsetOf(this._view.length)+"px"}),this._clearContent(),n&&n.scrollTop!==o&&(n.scrollTop=o),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.error=e,this._renderErrorState(e)}}async _loadInitial(){const t=++this._loadSeq;this._state.isLoading=!0,this._renderLoadingState();try{const e=this.props.pageSize||50,s=await this._request({page:0,pageSize:e,scrollTop:0},!0);if(this.isDisposed||t!==this._loadSeq)return;this._state.currentPage=0,this._state.totalCount=s.totalCount,this._state.hasMore=s.hasMore,this._state.isInitialized=!0,this._state.isLoading=!1,this._state.error=void 0,this._state.data=s.items,this._clearContent(),this._rebuildView(),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.isLoading=!1,this._state.error=e,this._renderErrorState(e)}}async _loadMore(){if(this._isLoadingMore||!this._state.hasMore||!this._state.isInitialized)return;const t=this._loadSeq;try{this._isLoadingMore=!0;const e=this._state.currentPage+1,s=this.props.pageSize||50,i=await this._request({page:e,pageSize:s,scrollTop:this.wrapper?.element?.scrollTop??0},!1);if(this.isDisposed||t!==this._loadSeq)return;this._state.totalCount=i.totalCount,this._state.currentPage=e,this._state.hasMore=i.hasMore,this._state.error=void 0,this._state.data.push(...i.items),this._rebuildView(),this.renderViewport()}catch(e){if(this.isDisposed||t!==this._loadSeq)return;this._state.error=e,M("MJX207",e)}finally{this._isLoadingMore=!1}}_rebuildView(){this._view=this.props.filter?this.props.filter(this._state.data):this._state.data;const t=new Map;this._occurrence=this._view.map(e=>{if("object"!=typeof e||null===e)return 0;const s=t.get(e)??0;return t.set(e,s+1),s}),"function"==typeof this.props.itemHeight?this._computeOffsets():this._offsets=null}_clearContent(){if(!this._virtualContent)return;const t=this._virtualContent.controls;for(const e of this._cache.values())t.silentUnlink(e),e.isDisposed||e.dispose();this._cache.clear(),t.clear(),this._emptyRendered=!1}renderViewport(){if(this.isDisposed||!this.wrapper||!this._state.isInitialized)return;const t=this.wrapper.element;this._observeResize();const e=this._view,s=e.length;if(0===s)return this._emptyRendered||(this._clearContent(),this._renderEmptyState()),this._topSpacer.style({height:"0px"}),void this._bottomSpacer.style({height:"0px"});this._emptyRendered&&this._clearContent();const i=this._fixedHeight();let n,o,r,a,c;if(null!==i){const e=Math.floor(t.clientHeight/i);if(e<=0)return void(this._renderPending=!t.isConnected);this._renderPending=!1,n=Math.max(0,this.props.overscan??e);const l=Math.min(Math.max(0,Math.floor(t.scrollTop/i)),s-1);o=Math.max(0,l-n),r=Math.min(s,l+e+n),a=o*i,c=Math.max(0,s-r)*i}else{if(t.clientHeight<=0)return void(this._renderPending=!t.isConnected);this._renderPending=!1;const e=this._layoutOffsets(),i=Math.max(0,t.scrollTop),l=i+t.clientHeight,h=this._indexAt(i,e);let u=h;for(;u<s&&e[u]<l;)u++;const d=Math.max(1,u-h);n=Math.max(0,this.props.overscan??d),o=Math.max(0,h-n),r=Math.min(s,Math.max(u,h+1)+n),a=e[o],c=Math.max(0,e[s]-e[r])}const l=new Array(r-o),h=new Set;for(let t=o;t<r;t++){const s=this._rowFor(e[t],t);l[t-o]=s,h.add(s)}const u=this._virtualContent.controls.items;for(const t of u.slice())h.has(t)||this._detachRow(t);for(let t=0;t<l.length;t++){const e=l[t];u[t]!==e&&(e.parent===this._virtualContent&&this._detachRow(e),this._virtualContent.controls.insert(t,e))}this._topSpacer.style({height:a+"px"}),this._bottomSpacer.style({height:c+"px"}),this._evictCache(Math.max(200,3*(r-o))),!1!==this.props.autoLoad&&this._state.hasMore&&!this._isLoadingMore&&s<r+n&&this._loadMore()}_occurrenceKey(t,e){let s=this._occurrenceKeys.get(t);return s||(s=[],this._occurrenceKeys.set(t,s)),s[e]??={}}_rowFor(t,e){const s=this._occurrence[e]??0,i="object"==typeof t&&null!==t?0===s?t:this._occurrenceKey(t,s):e;let n=this._cache.get(i);if(n&&n.isDisposed&&(this._cache.delete(i),n=void 0),n)return this._cache.delete(i),this._cache.set(i,n),n;const o=this.props.itemTemplate(t,e);return n=o instanceof zs?o:new Oi(o),n.__listItemRef=t,this._cache.set(i,n),n}_detachRow(t){const e=this._virtualContent.controls;if(t.isDisposed)return void e.silentUnlink(t);const s=t.element;if(s.nodeType===Node.COMMENT_NODE){e.silentUnlink(t);const i=t.motif.options.closeFragment,n=t.motif.options.cache??(t.motif.options.cache=document.createDocumentFragment());let o=s;for(;o;){const t=o.nextSibling;if(n.appendChild(o),o===i)break;o=t}Ai(t)}else e.silentDetach(t)}_evictCache(t){const e=this.props.cacheSize??t;if(!(this._cache.size<=e))for(const[t,s]of this._cache){if(this._cache.size<=e)break;s.parent!==this._virtualContent&&(this._cache.delete(t),s.isDisposed||s.dispose())}}_renderLoadingState(){if(!this._virtualContent||!this.props.loadingTemplate)return;this._clearContent();const t=this.props.loadingTemplate(this._state);this._virtualContent.controls.add(t)}_renderEmptyState(){if(!this._virtualContent||!this.props.emptyTemplate)return;this._clearContent();const t=this.props.emptyTemplate();this._virtualContent.controls.add(t),this._emptyRendered=!0}_renderErrorState(t){if(this._virtualContent)if(this._clearContent(),this.props.errorTemplate){const e=this.props.errorTemplate(t);this._virtualContent.controls.add(e)}else M("MJX207",t);else M("MJX207",t)}refresh(){return this._state.data=[],this._state.currentPage=0,this._state.isInitialized=!1,this._state.hasMore=!0,this._rebuildView(),this._loadInitial()}setData(t){this._loadSeq++,this._stopDataWatch(),this._state.data=t,this._state.currentPage=0,this._state.totalCount=t.length,this._state.hasMore=!1,this._state.isInitialized=!0,this._state.isLoading=!1,this._state.error=void 0,this._clearContent(),this._rebuildView(),this.renderViewport()}scrollToIndex(t){if(!this.wrapper)return;const e=this._view.length,s=Math.min(Math.max(0,t),Math.max(0,e-1));this.wrapper.element.scrollTop=this._offsetOf(s),this.renderViewport()}getState(){return{...this._state}}}const Qn=new Map;class Zn{constructor(){this.descriptors=new Map}reset(){this.descriptors.clear()}addTransient(t,e){this._add(t,e,"transient")}addSingleton(t,e){this._add(t,e,"singleton")}addScoped(t,e){this._add(t,e,"scoped")}_add(t,e,s){const i={token:t,lifetime:s};if(e&&"object"==typeof e&&(e.useClass||e.useFactory||Object.prototype.hasOwnProperty.call(e,"useValue")||Array.isArray(e.deps))){i.useClass=e.useClass,i.useFactory=e.useFactory,i.useValue=e.useValue,i.deps=Array.isArray(e.deps)?e.deps:void 0;try{const s=[i.useClass?"useClass":null,i.useFactory?"useFactory":null,void 0!==i.useValue?"useValue":null].filter(Boolean);s.length>1&&k("MJX410",[this._tokenName(t),s.join(", ")],{token:t}),e.deps&&!Array.isArray(e.deps)&&k("MJX411",[this._tokenName(t)],{token:t})}catch{}if(i.useValue&&"function"==typeof i.useValue.then){const t=i.useValue;i.useFactory=async()=>await t,i.useValue=void 0}}else if("function"==typeof e){if(!function(t){try{return Reflect.construct(String,[],t),!0}catch{return!1}}(e))throw S("MJX413",this._tokenName(t));i.useClass=e}else if(e&&"function"==typeof e.then){const t=e;i.useFactory=async()=>await t}else i.useValue=e;this.descriptors.set(t,i)}_tokenName(t){return"string"==typeof t?t:"symbol"==typeof t?t.toString():"function"==typeof t?t.name||"[AnonymousClass]":String(t)}getDescriptor(t){const e=this.descriptors.get(t);if(e)return e;const s=Qn.get(t);return s?(this._add(t,{useClass:t,deps:s.deps,useValue:void 0,useFactory:void 0},s.lifetime||"transient"),this.descriptors.get(t)||null):null}canAutoRegister(t){return!this.descriptors.has(t)&&Qn.has(t)}getService(t){return this.getDescriptor(t)}buildServiceProvider(){return new De(this)}has(t){return this.descriptors.has(t)}remove(t){return this.descriptors.delete(t)}replace(t,e,s){const i=this.descriptors.get(t),n=s??i?.lifetime??"transient";this._add(t,e,n)}tryAddTransient(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"transient"),!0)}tryAddSingleton(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"singleton"),!0)}tryAddScoped(t,e){return!this.descriptors.has(t)&&(this._add(t,e,"scoped"),!0)}autoRegisterInjectables(){for(const[t,e]of Qn.entries())this.descriptors.has(t)||this._add(t,{useClass:t,deps:e.deps,useValue:void 0,useFactory:void 0},e.lifetime||"transient")}}function to(t,e){const s=(t||"").trim(),i=(e||"").trim(),n=s&&"/"!==s&&s.endsWith("/")?s.slice(0,-1):s;if("/"===i)return n||"/";const o=i?i.startsWith("/")?i:"/"+i:"";return n&&"/"!==n?n+o:o||"/"}let eo=null,so=!1;function io(){if(u(),l())try{eo||(eo=document.createElement("div"),eo.style.cssText="position:fixed; left:12px; bottom:12px; right:12px; z-index:2147483647; background:#111; color:#fff; border:1px solid #333; border-radius:8px; box-shadow:0 4px 14px rgba(0,0,0,0.4); display:none;",document.body.appendChild(eo),window.addEventListener("keydown",t=>{try{(t.ctrlKey||t.metaKey)&&"`"===t.key&&(t.preventDefault(),eo&&(so=!so,eo.style.display=so?"block":"none"))}catch{}}),p(t=>{t.type}))}catch{}}class no{static{this.outlets=new Map}static register(t,e,s){this.outlets.has(t)||this.outlets.set(t,new Map),this.outlets.get(t).set(e,s)}static unregister(t,e){this.outlets.get(t)?.delete(e),0===this.outlets.get(t)?.size&&this.outlets.delete(t)}static find(t,e){if(e&&this.outlets.get(t)?.has(e))return this.outlets.get(t).get(e);const s=this.outlets.get(t);return s&&s.size>0?Array.from(s.values())[0]:null}static findAll(t){return Array.from(this.outlets.get(t)?.values()??[])}}const oo=Symbol.for("RouterView.built");class ro extends Oi{constructor(t){super(t),this._navLock=Promise.resolve(),this.disposingChilds=!1,this.current=null,this._latestNavigateId=0,this.isBusy=!1}get __isRouterView(){return!0}get scopeId(){let t=this.parent,e=[];for(;t;)e.push(t.constructor?.name??""),t=t.parent;return e.join(">")}async navigate(t,e=!1){await ln(this,t,e)}async disposeTarget(t){await cn(t)}onBuilt(){try{no.register(this.props.name??"default",this.scopeId,this);let t=this.parent;for(;t;)t.motif.trigger(oo,this),t=t.parent}catch{}}onDisposed(){try{no.unregister(this.props.name??"default",this.scopeId)}catch{}}}const ao="motifjs:scroll",co=["wheel","touchstart","keydown","mousedown"];class lo{constructor(t={},e){this.positions=new Map,this.currentKey="",this.currentPath=null,this.visited=!1,this.restoring=!1,this.cancelFrame=null,this.disarmAbort=null,this.offs=[],this.locationAnchor=!0,this.options=t,this.viewport=e??(t.container?function(t){const e=ho(),s=()=>{try{return"string"==typeof t?document.querySelector(t):"function"==typeof t?t()??null:t}catch{return null}};return{scrollTop:()=>{const t=s();return t?t.scrollTop||0:e.scrollTop()},scrollTo:t=>{const i=s();if(i)try{i.scrollTo({top:t,behavior:"instant"})}catch{try{i.scrollTop=t}catch{}}else e.scrollTo(t)},scrollToAnchor:(t,s)=>e.scrollToAnchor(t,s)}}(t.container):ho()),this.load();try{"undefined"!=typeof history&&"scrollRestoration"in history&&(history.scrollRestoration="manual")}catch{}"undefined"!=typeof window&&(this.offs.push(fo(window,"pagehide",()=>this.persistNow())),this.offs.push(fo(document,"visibilitychange",()=>{"hidden"===document.visibilityState&&this.persistNow()})))}leaving(){this.cancelRestore(),this.visited&&(this.remember(this.currentKey,this.viewport.scrollTop()),this.persist())}arrived(t,e){this.visited=!0;const{path:s,hash:i}=uo(t),n=!!i&&s===this.currentPath&&("push"===e||"replace"===e||"traverse"===e);this.currentPath=s,this.currentKey=this.keyOf(s),this.restore(this.currentKey,!1===this.options.anchor?"":i||(this.locationAnchor?function(){try{const t=location?.hash??"";return t.length>1?po(t.slice(1)):""}catch{return""}}():""),n)}saved(t){return this.positions.get(this.keyOf(uo(t).path))??0}dispose(){this.cancelRestore(),this.persistNow();for(const t of this.offs.splice(0))t();this.positions.clear()}keyOf(t){return(this.options.key?this.options.key(t):t)||"/"}remember(t,e){const s=this.options.limit??60;for(this.positions.delete(t),this.positions.set(t,Math.max(0,Math.round(e)));this.positions.size>s;){const t=this.positions.keys().next();if(t.done)break;this.positions.delete(t.value)}}restore(t,e,s){this.cancelRestore();const i=this.positions.get(t)??0;if(!e&&i<=0)return void(!1!==this.options.top&&this.viewport.scrollTo(0));this.restoring=!0;const n=this.options.settleMs??1200,o=Date.now(),r=()=>{this.cancelFrame=null;if((e?this.viewport.scrollToAnchor(e,s):this.reached(i))||Date.now()-o>=n)return this.cancelRestore(),void this.remember(t,this.viewport.scrollTop());this.armAbort(),this.cancelFrame=function(t){if("function"!=typeof requestAnimationFrame){const e=setTimeout(t,16);return()=>clearTimeout(e)}const e=requestAnimationFrame(t);return()=>cancelAnimationFrame(e)}(r)};r()}reached(t){return this.viewport.scrollTo(t),this.viewport.scrollTop()>=t-1}armAbort(){if(this.disarmAbort||"undefined"==typeof window)return;const t=()=>this.cancelRestore(),e=co.map(e=>fo(window,e,t,{passive:!0}));this.disarmAbort=()=>{for(const t of e)t()}}cancelRestore(){this.cancelFrame?.(),this.cancelFrame=null,this.disarmAbort?.(),this.disarmAbort=null,this.restoring=!1}persistNow(){this.visited&&!this.restoring&&this.remember(this.currentKey,this.viewport.scrollTop()),this.persist()}get storage(){if(!1===this.options.persist)return null;try{return"undefined"==typeof sessionStorage?null:sessionStorage}catch{return null}}persist(){const t=this.storage;if(t)try{t.setItem(ao,JSON.stringify([...this.positions]))}catch{}}load(){const t=this.storage;if(t)try{const e=t.getItem(ao);if(!e)return;const s=JSON.parse(e);if(!Array.isArray(s))return;for(const t of s){if(!Array.isArray(t)||"string"!=typeof t[0])continue;const e=Number(t[1]);Number.isFinite(e)&&e>0&&this.positions.set(t[0],e)}}catch{}}}function ho(){return{scrollTop:()=>{try{return window.scrollY||document.documentElement?.scrollTop||0}catch{return 0}},scrollTo:t=>{try{window.scrollTo({top:t,behavior:"instant"})}catch{try{window.scrollTo(0,t)}catch{}}},scrollToAnchor:(t,e)=>{try{const s=document.getElementById(t);if(!s)return!1;if(e)s.scrollIntoView();else try{s.scrollIntoView({behavior:"instant"})}catch{s.scrollIntoView()}return!0}catch{return!1}}}}function uo(t){const e=t.indexOf("#");return e<0?{path:t,hash:""}:{path:t.slice(0,e)||"/",hash:po(t.slice(e+1))}}function po(t){try{return decodeURIComponent(t)}catch{return t}}function fo(t,e,s,i){try{return t.addEventListener(e,s,i),()=>{try{t.removeEventListener(e,s,i)}catch{}}}catch{return()=>{}}}const mo="motifjs:stack",_o=30,go=t=>!!t&&1===t.nodeType&&!!t.style;function yo(t,e){const s=t?.element;if(t&&!t.isDisposed&&go(s)){try{s.setAttribute("data-nav-direction",e)}catch{}t.motif.options.transition._markedDirection=!0}}function vo(t){const e=t?.motif?.options?.transition;if(e?._markedDirection){e._markedDirection=!1;try{t.element?.removeAttribute?.("data-nav-direction")}catch{}}}function wo(t){return t.getAttribute("style")}function bo(t,e){try{t.setAttribute("style",e??""),null===e&&t.removeAttribute("style")}catch{}}function So(t){const e=[];try{const s=t=>{const s=t.scrollTop||0,i=t.scrollLeft||0;(s||i)&&e.push([t,s,i])};s(t),t.querySelectorAll("*").forEach(s)}catch{}return e}function Mo(t){for(const[e,s,i]of t)try{e.scrollTop=s,e.scrollLeft=i}catch{}}function Co(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function ko(t,e,s,i){if("function"!=typeof t.animate||s<=0)return Promise.resolve();try{const n=t.animate(e,{duration:s,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)",fill:"forwards"});return i.push(n),n.finished.then(()=>{},()=>{})}catch{return Promise.resolve()}}function Do(t,e,s){t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.margin="0px",t.style.boxSizing="border-box";const i=e.getBoundingClientRect(),n=t.getBoundingClientRect();if(t.style.top=i.top-n.top+"px",t.style.left=i.left-n.left+"px",t.style.width=i.width+"px",t.style.height=i.height+"px",t.style.pointerEvents="none",t.style.zIndex=s?"2":"0",!s){let t="";try{t=getComputedStyle(e).position}catch{}t&&"static"!==t||(e.style.position="relative"),e.style.zIndex="1"}}class Ao{constructor(t){this.session=null,this.entries=new Map,this.uris=new Map,this.loaded=null,this.current=null,this.currentTop=null,this.offs=[],this.gesture=null,this.gestureCommitted=!1,this.awaitingGestureResult=!1,this.disposed=!1;const e=!0===t?{}:t;this.retainAttached=!0===e.retain,this.depth=Math.max(0,Math.floor(e.depth??5)),this.persist=!0===e.persist,this.animation=e.animation??"none",this.duration=Math.max(0,e.duration??300);const s=e.swipeBack;this.swipe=s?{edge:"object"==typeof s&&"number"==typeof s.edge&&s.edge>0?s.edge:24,threshold:"object"==typeof s&&"number"==typeof s.threshold&&s.threshold>0?s.threshold:.35}:null,this.persist&&this.load(),this.swipe&&this.installSwipe()}get retainedCount(){return this.entries.size}isRetaining(t){return!!t.from&&!!t.to&&t.from.session===t.to.session&&t.to.index>t.from.index}begin(t){const e=t.to;if(e){if(this.session!==e.session){if(this.disposeAllEntries(),this.uris.clear(),this.session=e.session,this.loaded&&this.loaded.session===e.session)for(const[t,e]of this.loaded.uris)this.uris.set(t,e);this.loaded=null}if("push"===t.direction)this.truncate(e.index);else if("replace"===t.direction){const t=this.entries.get(e.index);t&&(this.entries.delete(e.index),this.disposeEntry(t))}}}take(t){if(!t||t.session!==this.session)return null;const e=this.entries.get(t.index);return e?(this.entries.delete(t.index),e.pendingDetach=!1,e):null}retain(t,e,s,i,n,o,r){const a=i[n],c=a.element,l={point:t,uri:e,chain:s.slice(),instances:i.slice(),top:a,topIndex:n,outlet:o,attached:!1,hidden:!1,pendingDetach:!1,saved:null,scroll:go(c)?So(c):[]};if(this.retainAttached&&go(c))l.attached=!0,r||this.hide(l);else if(r)l.pendingDetach=!0;else try{a.parent?.controls.silentDetach(a)}catch{}const h=this.entries.get(t.index);return h&&h!==l&&this.disposeEntry(h),this.entries.set(t.index,l),this.evict(),l}settle(t){if(!t.top.isDisposed&&this.entries.get(t.point.index)===t)if(t.attached)this.hide(t);else if(t.pendingDetach){t.pendingDetach=!1;try{t.top.parent?.controls.silentDetach(t.top)}catch{}}}hide(t){if(!t.attached||t.hidden)return;const e=t.top.element;if(go(e)){t.saved={style:wo(e),inert:e.hasAttribute("inert"),ariaHidden:e.getAttribute("aria-hidden")};try{e.style.setProperty("display","none","important"),e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")}catch{}t.hidden=!0;try{Ai(t.top)}catch{}}}reveal(t){const e=t.top.element;if(t.hidden&&t.saved&&go(e)){bo(e,t.saved.style);try{t.saved.inert||e.removeAttribute("inert"),null===t.saved.ariaHidden?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",t.saved.ariaHidden)}catch{}}t.hidden=!1,t.saved=null}restoreScroll(t){Mo(t.scroll)}record(t,e){if(t.to&&t.to.session===this.session){if(this.uris.set(t.to.index,t.uri),"push"===t.direction)for(const e of Array.from(this.uris.keys()))e>t.to.index&&this.uris.delete(e);this.current=t.to}this.currentTop=e,this.save()}describe(){const t=this.current?.index;return Array.from(this.uris.entries()).sort((t,e)=>t[0]-e[0]).map(([e,s])=>({index:e,uri:s,current:e===t,retained:this.entries.has(e)}))}get gestureCommitPending(){return this.gestureCommitted}consumeGestureCommit(){const t=this.gestureCommitted;return this.gestureCommitted=!1,t}traversalSettled(t){if(!this.awaitingGestureResult)return;this.awaitingGestureResult=!1;const e=this.gesture;if(!t)return this.gesture=null,void(this.gestureCommitted=!1);this.gestureCommitted=!1,e&&this.settleGesture(e,!1)}async transition(t,e,s){if(this.consumeGestureCommit())return;if("none"===this.animation||!this.animation)return;if("push"!==t&&"back"!==t&&"forward"!==t)return;const i=e?.element,n=s?.element;if(!(go(i)&&go(n)&&i.isConnected&&n.isConnected))return;if(Co())return;const o="back"===t,r=wo(i),a=wo(n),c=[];try{if(Do(n,i,o),"function"==typeof this.animation){const e={direction:t,entering:i,leaving:n};await this.animation(e)}else{const t=this.duration;o?await Promise.all([ko(n,[{transform:"translateX(0)"},{transform:"translateX(100%)"}],t,c),ko(i,[{transform:"translateX(-30%)"},{transform:"translateX(0)"}],t,c)]):await Promise.all([ko(i,[{transform:"translateX(100%)"},{transform:"translateX(0)"}],t,c),ko(n,[{transform:"translateX(0)"},{transform:"translateX(-30%)"}],t,c)])}}catch(t){M("MJX308",t)}finally{for(const t of c)try{t.cancel()}catch{}bo(i,r),bo(n,a)}}async disposeEntry(t){const e=t.top;if(e&&!e.isDisposed)try{await cn(e,{deep:!0,skipLeaveTransition:!0})}catch(t){M("MJX307",t)}}async dispose(){if(!this.disposed){this.disposed=!0;for(const t of this.offs.splice(0))try{t()}catch{}this.gesture&&(this.endGestureListeners(this.gesture),this.gesture=null),await this.disposeAllEntries(),this.uris.clear(),this.current=null,this.currentTop=null}}async disposeAllEntries(){const t=Array.from(this.entries.values());this.entries.clear();for(const e of t)await this.disposeEntry(e)}truncate(t){for(const[e,s]of Array.from(this.entries))e>=t&&(this.entries.delete(e),this.disposeEntry(s))}evict(){for(;this.entries.size>this.depth;){let t=1/0;for(const e of this.entries.keys())e<t&&(t=e);const e=this.entries.get(t);this.entries.delete(t),e&&this.disposeEntry(e)}}load(){try{if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(mo);if(!t)return;const e=JSON.parse(t);if(!e||"string"!=typeof e.session||!Array.isArray(e.uris))return;const s=[];for(const t of e.uris)Array.isArray(t)&&"number"==typeof t[0]&&"string"==typeof t[1]&&s.push([t[0],t[1]]);this.loaded={session:e.session,uris:s}}catch{}}save(){if(this.persist&&this.session)try{if("undefined"==typeof sessionStorage)return;sessionStorage.setItem(mo,JSON.stringify({session:this.session,uris:Array.from(this.uris.entries())}))}catch{}}installSwipe(){if("undefined"==typeof document)return;const t=t=>this.onTouchStart(t);try{document.addEventListener("touchstart",t,{passive:!0}),this.offs.push(()=>{try{document.removeEventListener("touchstart",t)}catch{}})}catch{}}onTouchStart(t){if(this.disposed||this.gesture||this.awaitingGestureResult||!this.swipe)return;if(!t.touches||1!==t.touches.length)return;const e=t.touches[0];if(!e||e.clientX>this.swipe.edge)return;if(!this.current||this.current.index<=0)return;const s=this.currentTop?.element;if(!go(s)||!s.isConnected)return;const i={startX:e.clientX,startY:e.clientY,lastX:e.clientX,samples:[[e.clientX,Date.now()]],dragging:!1,width:0,top:s,topSaved:null,under:null,underSaved:null,offs:[]},n=t=>this.onTouchMove(i,t),o=()=>this.onTouchEnd(i);try{document.addEventListener("touchmove",n,{passive:!1}),document.addEventListener("touchend",o),document.addEventListener("touchcancel",o),i.offs.push(()=>{try{document.removeEventListener("touchmove",n)}catch{}try{document.removeEventListener("touchend",o)}catch{}try{document.removeEventListener("touchcancel",o)}catch{}})}catch{}this.gesture=i}endGestureListeners(t){for(const e of t.offs.splice(0))try{e()}catch{}}beginDrag(t){t.dragging=!0,t.width=t.top.getBoundingClientRect().width||("undefined"!=typeof window?window.innerWidth:0)||1,t.topSaved=wo(t.top);const e=this.current,s=e?this.entries.get(e.index-1)??null:null;if(s&&s.attached&&go(s.top.element)&&s.top.element.isConnected){const e=s.top.element;t.under=s,t.underSaved=wo(e),s.saved&&bo(e,s.saved.style),Do(e,t.top,!1),e.style.transform="translateX(-30%)",Mo(s.scroll)}t.top.style.willChange="transform"}applyDrag(t,e){const s=Math.min(1,Math.max(0,e/t.width));t.top.style.transform=`translateX(${Math.max(0,e)}px)`,t.under&&(t.under.top.element.style.transform=`translateX(-${_o*(1-s)}%)`)}onTouchMove(t,e){const s=e.touches&&e.touches[0];if(!s)return;const i=s.clientX-t.startX,n=s.clientY-t.startY;if(!t.dragging){if(Math.abs(i)<8&&Math.abs(n)<8)return;if(i<=0||Math.abs(n)>Math.abs(i))return this.endGestureListeners(t),void(this.gesture=null);this.beginDrag(t)}if(e.cancelable)try{e.preventDefault()}catch{}const o=Date.now();for(t.lastX=s.clientX,t.samples.push([s.clientX,o]);t.samples.length>2&&o-t.samples[0][1]>100;)t.samples.shift();this.applyDrag(t,i)}onTouchEnd(t){if(this.endGestureListeners(t),!t.dragging)return void(this.gesture=null);const e=t.lastX-t.startX,s=e/t.width,i=t.samples[0],n=t.samples[t.samples.length-1],o=n&&i?n[1]-i[1]:0,r=n?Date.now()-n[1]:1/0,a=o>=16&&r<=50?(n[0]-i[0])/o:0,c=s>this.swipe.threshold||a>.5&&e>0;this.settleGesture(t,c)}async settleGesture(t,e){const s=[],i=t.top,n=t.under?t.under.top.element:null,o=Co()?0:Math.max(0,Math.round(.6*this.duration)),r=i.style.transform||"translateX(0px)",a=n?.style.transform||"translateX(-30%)";if(e){await Promise.all([ko(i,[{transform:r},{transform:"translateX(100%)"}],o,s),n?ko(n,[{transform:a},{transform:"translateX(0)"}],o,s):Promise.resolve()]),i.style.transform="translateX(100%)",n&&(n.style.transform="translateX(0px)");for(const t of s)try{t.cancel()}catch{}this.gestureCommitted=!0,this.awaitingGestureResult=!0;try{window.history.back()}catch{this.traversalSettled(!0)}}else{await Promise.all([ko(i,[{transform:r},{transform:"translateX(0)"}],o,s),n?ko(n,[{transform:a},{transform:"translateX(-30%)"}],o,s):Promise.resolve()]);for(const t of s)try{t.cancel()}catch{}bo(i,t.topSaved),n&&t.under&&bo(n,t.underSaved),this.gesture===t&&(this.gesture=null)}}}class xo{constructor(t){this.source=t,this.currentColumn=0,this.tokens=[],this.parameters={},this.codePointAt=String.prototype.codePointAt?(t,e)=>t.codePointAt(e):function(t,e){const s=t.length;if(e<0||e>=s)return;const i=t.charCodeAt(e);if(i>=55296&&i<=56319&&s>e+1){const s=t.charCodeAt(e+1);if(s>=56320&&s<=57343)return 1024*(i-55296)+s-56320+65536}return i},this.tokens=[]}addToken(t){this.tokens.push(t)}parse(){for(this.source.startsWith("/")||(this.source="/"+this.source);this.source.length>1&&this.source.endsWith("/");)this.source=this.source.slice(0,-1);var t="static",e=-1,s=0,i=-1;for(this.tokens=[],this.currentColumn=0;this.currentColumn<this.source.length;){var n=this.codePointAt(this.source,this.currentColumn),o=this.tokens[e];switch(n){case 47:i++,(void 0===o||o.input.length>1)&&(this.tokens.push({default:"",input:"/",isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:s,sectionIndex:i}),e=this.tokens.length-1);break;case 123:s++;let n,r,a=!1,c=!1;if(this.tokens.length>0){const t=this.tokens[this.tokens.length-1];t&&"static"===t.type&&"/"===t.input&&!t.consumed?(a=!0,n=this.tokens.length-1):t&&"static"===t.type&&"/"!==t.input&&t.sectionIndex===i&&!t.consumed&&(c=!0,r=this.tokens.length-1)}this.tokens.push({default:void 0,input:"",isOptinal:!1,regexs:[],type:"parameter",parameterName:"",parameterIndex:s,sectionIndex:i,hasLeadingSlash:a,leadingSlashTokenIndex:n,hasLeadingStatic:c,leadingStaticTokenIndex:r}),e=this.tokens.length-1,t="parameter";break;case 125:t="static",e=-1;break;case 58:t="defaultValue";break;case 63:o&&(o.isOptinal=!0);break;default:const l=this.source[this.currentColumn];o?"parameter"===t?o.parameterName=`${o.parameterName+l}`:"defaultValue"===t?o.default=`${(o.default??"")+l}`:"static"===o.type?o.input=`${o.input+l}`:(this.tokens.push({default:void 0,input:l,isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:s,sectionIndex:i}),e=this.tokens.length-1):(this.tokens.push({default:void 0,input:l,isOptinal:!1,regexs:[],type:"static",parameterName:"",parameterIndex:s,sectionIndex:i}),e=this.tokens.length-1)}this.currentColumn++}const r=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");for(const t of this.tokens){if("parameter"===t.type&&t.isOptinal&&t.hasLeadingSlash&&"number"==typeof t.leadingSlashTokenIndex){const e=this.tokens[t.leadingSlashTokenIndex];e&&"static"===e.type&&"/"===e.input&&(e.consumed=!0)}if("parameter"===t.type&&t.isOptinal&&t.hasLeadingStatic&&"number"==typeof t.leadingStaticTokenIndex){const e=this.tokens[t.leadingStaticTokenIndex];e&&"static"===e.type&&e.input&&e.sectionIndex===t.sectionIndex&&(e.consumed=!0)}}const a=t=>{const e=this.tokens[t];for(let s=t+1;s<this.tokens.length;s++){const t=this.tokens[s];if("static"===t.type&&t.sectionIndex===e.sectionIndex&&t.input&&"/"!==t.input)return t.input[0];if("static"===t.type&&"/"===t.input)break}},c=(t,e)=>{const s=a(t);var i;return`(${s?`[^${i=r(s),i.replace(/[\\\]\^\-]/g,"\\$&")}]`:"[\\w\\d\\_\\-\\%\\&\\$\\+\\#\\,\\.\\{\\}\\(\\)\\[\\]\\?\\:\\=\\;\\'\\\"\\~\\\\]"}${e?"{0,255}":"{1,255}"})`};let l="^";for(let t=0;t<this.tokens.length;){const e=this.tokens[t];if("static"===e.type&&"/"===e.input){e.consumed||(l+="/"),t++;continue}const s=t;let i=t;for(;i<this.tokens.length;){const t=this.tokens[i];if("static"===t.type&&"/"===t.input&&i!==s)break;if("static"===t.type&&"/"===t.input&&i===s){i++;break}i++}const n={};let o=s;for(;o<i;){if(n[o]){o++;continue}const t=this.tokens[o];if("static"!==t.type){if(t.isOptinal&&!t.hasLeadingStatic){const e=o;let s=!1;for(let t=e+1;t<i;t++){const e=this.tokens[t],i=this.tokens[t+1];if(e&&"static"===e.type&&i&&"parameter"===i.type&&i.isOptinal&&i.hasLeadingStatic&&"number"==typeof i.leadingStaticTokenIndex&&i.leadingStaticTokenIndex===t){s=!0;break}if(e&&"static"===e.type&&"/"===e.input)break}let a="";t.hasLeadingSlash&&(a+="/"),a+=c(e,!s),n[e]=!0;let h=e+1;for(;h<i;){const t=this.tokens[h];if("static"===t.type&&this.tokens[h+1]&&"parameter"===this.tokens[h+1].type){const e=this.tokens[h+1];if(e.isOptinal&&e.hasLeadingStatic&&"number"==typeof e.leadingStaticTokenIndex&&e.leadingStaticTokenIndex===h){a+=`(?:${r(t.input)}${c(h+1,!0)})?`,n[h]=!0,n[h+1]=!0,h+=2;continue}}break}l+=`(?:${a})?`,o=h;continue}{const e=c(o,t.isOptinal);if(t.isOptinal)if(t.hasLeadingSlash)l+=`(?:/${e})?`;else if(t.hasLeadingStatic&&"number"==typeof t.leadingStaticTokenIndex){const s=this.tokens[t.leadingStaticTokenIndex];l+=`(?:${s&&"static"===s.type?r(s.input):""}${e})?`}else l+=`(?:${e})?`;else l+=e;n[o]=!0,o++}}else t.consumed||(l+=r(t.input)),n[o]=!0,o++}t=i}return l+="$",new RegExp(l,"i")}exist(t,e){const s=t.indexOf("#"),i=s>=0?t.substring(0,s):t;let n=i,o="";const r=i.indexOf("?");for(r>=0&&(n=i.substring(0,r),o=i.substring(r+1));n.length>1&&n.endsWith("/");)n=n.slice(0,-1);var a=this.parse().exec(n);if(a){a&&a.length;var c=[];if(this.parameters={},a?.forEach((t,e)=>{c.push(t)}),o&&o.length){const t=new URLSearchParams(o),e=new Map;t.forEach((t,s)=>{const i=e.get(s)||[];i.push(t),e.set(s,i)}),e.forEach((t,e)=>{1===t.length?this.parameters[e]=t[0]:this.parameters[e]=t})}else if(e){const t=new URLSearchParams(e),s=new Map;t.forEach((t,e)=>{const i=s.get(e)||[];i.push(t),s.set(e,i)}),s.forEach((t,e)=>{1===t.length?this.parameters[e]=t[0]:this.parameters[e]=t})}if(a.input===c[0])return a?.forEach((t,e)=>{if(0!==e){var s=this.tokens.find(t=>t.parameterIndex==e);if(s){let e=t;if((void 0===e||""===e)&&s.isOptinal){e=void 0===s.default||""===s.default?void 0:s.default}this.parameters[s.parameterName]=void 0===e?void 0:e}}}),!0}return!1}}function Eo(t){let e=0,s=0;for(const i of(t||"").split("/"))i&&(i.startsWith("{")&&i.endsWith("}")?s++:e++);return{statics:e,params:s}}function To(t,e){const s=t.chain.length-e.chain.length;if(0!==s)return s;const i=Eo(t.fullPath),n=Eo(e.fullPath);return i.statics!==n.statics?n.statics-i.statics:i.params!==n.params?i.params-n.params:e.fullPath.length-t.fullPath.length}class Oo{constructor(t){this.routes=t,this.records=[],this.routesMap=new Map,this.walk=(t,e,s,i=!1)=>{const n=this.joinPaths(e,s.path);if(!i){const t=s.fullPath;(null==t||"string"==typeof t&&""===t.trim())&&(s.fullPath=n),null!=s.name&&this.routesMap.set(s.name,s)}const o=[...t,s],r=[{path:n,isAlias:i},...(null==s.alias?[]:Array.isArray(s.alias)?s.alias:[s.alias]).map(t=>({path:this.joinPaths(e,t),isAlias:!0}))];for(const t of r)if(this.records.push({fullPath:t.path,chain:o,leaf:s,scanner:new xo(t.path),aliasOf:t.isAlias?s.fullPath??null:null}),s.childs&&s.childs.length)for(const e of s.childs)this.walk(o,t.path,e,t.isAlias)},this.build()}build(){this.records=[],this.routesMap.clear();for(const t of this.routes)this.walk([],"",t);this.records.sort(To)}joinPaths(t,e){e=e||"";const s=(t=t||"")&&"/"!==t&&t.endsWith("/")?t.slice(0,-1):t;if("/"===e)return s||"/";const i=e?e.startsWith("/")?e:"/"+e:"";return s&&"/"!==s?s+i:i||"/"}}class No{constructor(){this.stack=null,this._revealed=new Set,this._previousPath=null,this._previousInstances=[],this.controlCache=new Map,this._navVersion=0,this._pendingActivate=new Set,this.pendingMount=new WeakMap,this.pendingListeners=new WeakMap}register(t,e,s){this.root=t,this.application=e,this.routingModule=s}async evict(t){const e=t?[t]:Array.from(this.controlCache.keys());for(const t of e){const e=this.controlCache.get(t);if(e&&!e.isDisposed){if(!this._previousInstances.includes(e)){this.controlCache.delete(t);try{await e.dispose()}catch(t){M("MJX307",t)}}}else this.controlCache.delete(t)}}async dispose(){this._navVersion++,this._previousPath=null,this._previousInstances=[],this._revealed.clear();const t=this.stack;if(this.stack=null,t)try{await t.dispose()}catch{}await this.evict()}generatePathString(t,e){const s=t.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}")){const s=t.slice(1,-1);let[i,n]=s.split(":");i.endsWith("?")&&(i=i.slice(0,-1));const o=e[i];return null!=o&&""!==o?String(o):n??""}return t}).filter(t=>""!==t).join("/");return t.startsWith("/")?"/"+(s||""):s}async execute(t,e,s){s??={target:t,chain:t.chain.map(e=>this.generatePathString(e.path,t.params)||""),direction:void 0,state:void 0};const i=this._rootProvider(),n={provider:i,scope:i?._beginNavigation(),route:s,committed:!1,suppressed:[]};try{await this._execute(t,e,n)}finally{!n.committed&&n.scope&&i._abandonNavigation(n.scope);for(const t of n.suppressed)t.isDisposed||(t.motif.options.transition._suppressEnter=!1)}}_commitNavigation(t){t.committed||(t.committed=!0,t.scope&&t.provider._commitNavigation(t.scope),this.application?._routerState.commit(t.route))}async _execute(t,e,s){const i=++this._navVersion,n=this.stack&&e&&e.to?this.stack:null;n&&n.begin(e);const o=n?n.take(e.to):null,r=new Array(t.chain.length),a=!(!this._previousPath||this._previousPath.route!==t.route||null==this._previousPath.route&&this._previousPath.fullPath!==t.fullPath);var c=!(!this._previousPath||this._previousPath.uri!==t.uri);let l=!1;if(a&&t.route){const e=this._previousPath.params||{},s=t.params||{};let i=!1;const o=new Set([...Object.keys(e),...Object.keys(s)]);for(const t of o)if(e[t]!==s[t]){i=!0;break}if(i){l=!0;const i=t.route;if(i&&!i.keepAlive&&this.controlCache.has(i))if(n)this.controlCache.delete(i);else{const t=this.controlCache.get(i);if(t&&"function"==typeof t.dispose&&!t.isDisposed)try{await t.dispose()}catch{}this.controlCache.delete(i)}try{const i=this.routingModule.getHooks?.()||void 0,n=t.route.onUpdate||i?.onUpdate;if(n){const i={from:{path:this._previousPath.uri||this._previousPath.fullPath||"",params:e},to:{path:t.uri||t.fullPath||"",params:s},meta:t.meta??t.extend};await n(i)}}catch(t){M("MJX306",t,"onUpdate")}}}if((!a||l)&&t.route)try{const e=t.meta??t.extend,s={path:t.uri||t.fullPath||"",params:t.params,meta:e,to:{path:t.uri||t.fullPath||"",params:t.params,meta:e}},i=this.routingModule.getHooks?.()||void 0,n=t.route.onEntering||i?.onEntering;n&&await n(s)}catch(t){M("MJX306",t,"onEntering")}const h=[];for(let e=0;e<t.chain.length;e++){const i=t.chain[e],n=o&&o.chain[e]===i?o.instances[e]:void 0;if(!n||n.isDisposed||i.keepAlive)if(this.controlCache.has(i)){let t=this.controlCache.get(i);if(!t||t.isDisposed){this.controlCache.delete(i);const t=this.createInstance(i.control,s.scope,s.route).then(t=>{this.controlCache.set(i,t),r[e]=t});h.push(t)}else r[e]=t,i.keepAlive&&!this._previousInstances.includes(t)&&this._pendingActivate.add(t)}else{const t=this.createInstance(i.control,s.scope,s.route).then(t=>{this.controlCache.set(i,t),r[e]=t});h.push(t)}else r[e]=n,this.controlCache.set(i,n)}h.length&&await Promise.all(h);let u=null,d=null;const p=this._previousInstances;if(n){const s=!!n.animation&&"none"!==n.animation&&("push"===e.direction||"back"===e.direction||"forward"===e.direction);if(d={animate:s,pages:!s&&!n.gestureCommitPending,direction:e.direction},u=await this._stackLeave(t.chain,r,e,n,d),o){const t=o.top;!t.isDisposed&&o.outlet&&t.parent===o.outlet&&(n.reveal(o),o.outlet.current=t,o.outlet.previouspage=t,this._revealed.add(t)),t.isDisposed||this._pendingActivate.add(t)}}else await this.disposeFromDivergencePoint(t.chain,r);const f=d?r.filter(t=>t&&!p.includes(t)):[];if(d){for(const t of p)vo(t);for(const t of f)d.pages?yo(t,d.direction):(t.motif.options.transition._suppressEnter=!0,s.suppressed.push(t))}if(i===this._navVersion&&this._commitNavigation(s),await this.mountChain(r,t.chain,this.root,i),d?.pages){o?.attached&&!o.top.isDisposed&&rn(o.top,"enter")&&o.top.motif.options.transition.enterTransition(()=>{});for(const t of f)t.isBuilt&&!rn(t,"enter")&&vo(t)}let m=null;if(n){o&&n.restoreScroll(o);for(let t=0;t<r.length;t++)if(r[t]&&r[t]!==p[t]){m=r[t];break}m||(m=r.length?r[r.length-1]:null),n.record(e,m)}if(!c&&t.route)try{const e=t.meta??t.extend,s={path:t.uri||t.fullPath||"",params:t.params,meta:e,to:{path:t.uri||t.fullPath||"",params:t.params,meta:e}},i=this.routingModule.getHooks?.()||void 0,n=t.route?.onEnter||i?.onEnter;n&&await n(s)}catch(t){M("MJX306",t,"onEnter")}if(this._previousPath=t,this._previousInstances=r.slice(),n&&u){u.top&&i===this._navVersion&&(u.retained||u.disposeAfter.length)&&await n.transition(e.direction,m,u.top),u.retained&&n.settle(u.retained);for(const t of u.disposeAfter)try{t.isDisposed||await t.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){M("MJX307",t)}}}async _stackLeave(t,e,s,i,n){const o={top:null,retained:null,disposeAfter:[]},r=this._previousPath?.chain??[],a=this._previousInstances;if(!a.length)return o;let c=-1;for(let t=0;t<a.length;t++){const s=a[t];if(s&&!e.includes(s)){c=t;break}}if(c<0)return o;a[c].isDisposed||Ce(a[c]);const l=t=>{const e=t-1>=0?a[t-1]:this.root,s=r[t]?.extend?.targetOutlet||"default";try{return e&&!e.isDisposed?this.findRouterView(e,s):null}catch{return null}},h=a[c],u=r[c];if(i.isRetaining(s)&&h&&!h.isDisposed&&!u?.keepAlive){const t=l(c);t&&t.current===h&&(t.current=null,t.previouspage=null),an(h),n.pages&&rn(h,"leave")&&(yo(h,n.direction),await(d=h,new Promise(t=>{let e=!1;const s=()=>{e||(e=!0,t())};try{const t=d.motif.options.transition.leaveTransition(s);t&&"function"==typeof t.addEventListener&&t.addEventListener("cancel",s)}catch{s()}})),vo(h));for(let t=c;t<a.length;t++){const e=r[t];e&&!e.keepAlive&&this.controlCache.get(e)===a[t]&&this.controlCache.delete(e)}return o.top=h,o.retained=i.retain(s.from,this._previousPath?.uri??"",r,a,c,t,n.animate),o}var d;const p=n.animate&&!!h&&!h.isDisposed&&!u?.keepAlive;for(let t=a.length-1;t>=c;t--){const s=a[t],i=r[t];if(s&&!e.includes(s))if(s.isDisposed)i&&this.controlCache.get(i)===s&&this.controlCache.delete(i);else if(p&&t>c&&!i?.keepAlive)i&&this.controlCache.get(i)===s&&this.controlCache.delete(i);else try{const e=l(t);if(e&&e.current===s&&(e.current=null,e.previouspage=null),i?.keepAlive){an(s);try{s.parent?.controls.silentDetach(s)}catch{}this.controlCache.has(i)||this.controlCache.set(i,s),Ai(s)}else i&&this.controlCache.get(i)===s&&this.controlCache.delete(i),p&&t===c?(o.top=s,o.disposeAfter.push(s)):n.pages?(yo(s,n.direction),await s.dispose()):await s.dispose({deep:!0,skipLeaveTransition:!0})}catch(t){M("MJX307",t)}}return o}async disposeFromDivergencePoint(t,e){if(!this._previousPath||!this._previousInstances.length)return;const s=this._previousPath.chain,i=this._previousInstances;let n=0;const o=Math.min(s.length,t.length);for(let e=0;e<o&&s[e]===t[e];e++)n=e+1;for(let t=i.length-1;t>=n;t--){const e=i[t],n=s[t];if(e&&!e.isDisposed)try{const s=t-1,o=s>=0?i[s]:this.root,r=n?.extend?.targetOutlet||"default",a=this.findRouterView(o,r);if(a&&a.current===e&&(a.current=null,a.previouspage=null),n?.keepAlive){an(e);try{e.parent?.controls.silentDetach(e)}catch{}this.controlCache.has(n)||this.controlCache.set(n,e),Ai(e)}else this.controlCache.get(n)===e&&this.controlCache.delete(n),await e.dispose()}catch(t){M("MJX307",t)}else n&&this.controlCache.get(n)===e&&this.controlCache.delete(n)}}_construct(t,e,s){const i=this.application?._routerState;return function(t,e){const s=de;de=t??null;try{return e()}finally{de=s}}(t,()=>i?i.constructWith(e,s):s())}async parseControl(t,e,s){var i=this._construct(e,s,()=>this._resolveFrom(e,t));if(i)return i;let n=t;return n instanceof Promise&&(n=ji(await n)),(i=this._construct(e,s,()=>this._resolveFrom(e,n)))||("function"==typeof n?this.parseControl(this._construct(e,s,()=>Hi(n,this.application)),e,s):Hi(n))}_resolveFrom(t,e){const s=t??this._rootProvider();return s&&s.getAllServices().getDescriptor(e)?s.get(e):null}_rootProvider(){try{return this.application?.provider??Ho.main?.provider}catch{return}}async createInstance(t,e,s){return await this._instanceCreator(t,e,s)}async _instanceCreator(t,e,s){let i=await this.parseControl(t,e,s);return Fi(i),i}async activator(t){}static{this.OUTLET_WARN_MS=3e3}async mountChain(t,e,s,i){for(let n=0;n<t.length;){if(i!==this._navVersion)return;let o=t[n];o?.isDisposed&&(o=await this.createInstance(e[n].control,this._rootProvider()?._currentScope()),t[n]=o);const r=e[n]&&e[n].extend&&e[n].extend.targetOutlet||"default",a=this.findRouterView(s,r);if(!a||!s.isBuilt)return void this._waitForOutlet(s,t.slice(n),e.slice(n),i,r);const c=this._revealed.delete(o),l=a.current===o&&!c;await a.navigate(o),this._pendingActivate.delete(o)&&Di(o);const h=e[n]?.onShow;h&&!l&&a.current===o&&i===this._navVersion&&C(()=>h(o),"MJX306","onShow"),s=o,n++}}_waitForOutlet(t,e,i,n,o){const r=this.pendingListeners.get(t);if(r){try{r()}catch{}this.pendingListeners.delete(t)}let a,c=!1;const l=async(s,o)=>{c||(h(),n===this._navVersion&&await this.mountChain(e,i,t,n))},h=()=>{if(!c){c=!0,this.pendingListeners.delete(t);try{t.motif?.off?.(oo,l)}catch{}if(void 0!==a){try{clearTimeout(a)}catch{}a=void 0}}};t.motif.on(oo,l),this.pendingListeners.set(t,h),s.isDevelopment()&&(a=setTimeout(()=>{c||n!==this._navVersion||k("MJX301",[o,No.OUTLET_WARN_MS])},No.OUTLET_WARN_MS))}findRouterView(t,e="default"){const s=(t.controls?.items||[]).slice();for(;s.length;){const t=s.shift();if(t&&!t.isDisposed){if(t.__isRouterView){const s=t;if((s.props.name||"default")===e)return s}if(t.controls&&t.controls.items&&t.controls.items.length)for(const e of t.controls.items)s.push(e)}}if(!e||"default"===e)return null;const i="function"==typeof t.scopeId?t.scopeId():t.scopeId??"";var n=no.find(e,i);if(n)return n;let o=t,r=o?.parent;for(;r;){const t=(r.controls?.items||[]).filter(t=>t!==o).slice();for(;t.length;){const s=t.shift();if(s&&!s.isDisposed){if(s.__isRouterView){const t=s;if((t.props.name||"default")===e)return t}if(s.controls&&s.controls.items&&s.controls.items.length)for(const e of s.controls.items)t.push(e)}}o=r,r=r.parent}return null}}class Po extends Oi{constructor(t){super(t.el??"a",t),!1!==t.showHref&&this.attr.add({href:t.to}),t.target&&this.attr.add({target:t.target}),this.motif.on("click",(e,s)=>{if(t.bypass)return;if(t.target&&"_self"!==t.target)return;if(s.metaKey||s.ctrlKey||s.shiftKey||s.altKey)return;s.preventDefault();const i=Ho.main.router;i&&i.navigate(t.to)}),this.childs&&this.childs.length?this.controls.add(...this.childs):null!=t.text&&this.attr.add({textContent:t.text})}onBuilt(t,e){this.motif.options.enableRouterClassing={to:"all",path:this.props.to,activeClass:this.props.activeClass,exactClass:this.props.exactClass,onActive:this.props.onActive,offActive:this.props.offActive,onExact:this.props.onExact,offExact:this.props.offExact}}}const Lo=t=>t.split("#")[0].split("?")[0],Xo=()=>Math.random().toString(36).slice(2,10)+Date.now().toString(36);class Ro{static{this.MAX_REDIRECTS=10}constructor(t,e){this.routesMap=new Map,this._suppressBeforeEachOnce=!1,this._suppressMiddlewaresOnce=!1,this._scroll=null,this._stack=null,this._windowNavListener=null,this._historyStamp=null,this._pendingTraversal=null,this._currentUri="___startup___",this._previousRoute=null,this._fallbackRoutes={},this._navHandler=null,this._routerOptions=t,this.routeCollection=new Oo(t.RouteItems),this.routingEngine=new No,this.application=e,this._installLinkInterceptor();const s=t.scrollMemory;s&&(this._scroll=new lo(!0===s?{}:s),this._scroll.locationAnchor="history"===this._addressMode()),t.stack&&"shell"!==t.mode&&(this._stack=new Ao(t.stack),this.routingEngine.stack=this._stack)}getHooks(){return this._routerOptions.hooks}start(t,e){this.mainApp=t,this.routingEngine.register(this.mainApp,this.application,this);const s="shell"===this._routerOptions.mode?e??"/":this._getCurrentUri();this._seedHistoryIndex(),this._suppressMiddlewaresOnce=!0,this.navigate(s),"shell"!==this._routerOptions.mode&&(this._windowNavListener=()=>{this._onHistoryTraversal()},window.addEventListener("hash"===this._routerOptions.mode||"file"===this._routerOptions.mode?"hashchange":"popstate",this._windowNavListener))}get shownUri(){return this._previousRoute?this._currentUri:void 0}_getCurrentUri(){try{const t=window,e=this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history");if("hash"===e||"file"===e){const e=t?.location?.hash||"";return e&&e.startsWith("#")&&e.slice(1)||"/"}return(t?.location?.pathname||"/")+(t?.location?.search||"")+(t?.location?.hash||"")}catch{return"/"}}static{this.HISTORY_STAMP_KEY="__motifHistory"}_addressMode(){const t=window;return this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history")}_readHistoryStamp(){try{const t=window?.history?.state,e=t&&"object"==typeof t?t[Ro.HISTORY_STAMP_KEY]:null;if(e&&"object"==typeof e&&"number"==typeof e.index&&Number.isFinite(e.index)&&"string"==typeof e.session)return{index:e.index,session:e.session}}catch{}return null}static _isPlainObject(t){if(!t||"object"!=typeof t)return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}_withHistoryStamp(t,e){return null==t?{[Ro.HISTORY_STAMP_KEY]:e}:Ro._isPlainObject(t)?{...t,[Ro.HISTORY_STAMP_KEY]:e}:t}_routerState(t,e){return t?this._withHistoryStamp(t,{...e,hasState:!0}):this._withHistoryStamp(null,e)}_userStateOf(t){if(null==t)return;if(!Ro._isPlainObject(t))return t;const e=Ro.HISTORY_STAMP_KEY;if(!(e in t))return t;const s=t[e];if(!s||!0!==s.hasState)return;const{[e]:i,...n}=t;return n}_currentHistoryUserState(){if("shell"!==this._addressMode())try{return this._userStateOf(window?.history?.state)}catch{return}}_nextHistoryStamp(t){const e=this._historyStamp;return e?{index:t?e.index+1:e.index,session:e.session}:{index:0,session:Xo()}}_stampCurrentEntry(t,e){try{const s=window;if(!s?.history||"function"!=typeof s.history.replaceState)return;const i=s.history.state;let n;if(e)n=this._routerState(e,t);else{const e=Ro._isPlainObject(i)&&Object.keys(i).length>0;n=this._withHistoryStamp(i,e?{...t,hasState:!0}:t)}n!==i&&s.history.replaceState(n,"")}catch{}}_seedHistoryIndex(){if("shell"===this._addressMode())return;const t=this._readHistoryStamp();if(t)return void(this._historyStamp=t);const e={index:0,session:Xo()};this._stampCurrentEntry(e),this._historyStamp=e}async _onHistoryTraversal(){const t=this._historyStamp,e=this._readHistoryStamp();this._historyStamp=e;let s,i="traverse";t&&e&&t.session===e.session&&t.index!==e.index&&(i=e.index<t.index?"back":"forward"),this._pendingTraversal={direction:i,state:this._currentHistoryUserState(),from:t};try{s=await this.navigate(this._getCurrentUri())}finally{this._pendingTraversal=null}const n=!!s&&!0===s.cancelled;try{this._stack?.traversalSettled(n)}catch{}if(!n)return;const o=this._readHistoryStamp();if(this._historyStamp=o,!t||!o||o.session!==t.session)return;const r=t.index-o.index;if(0!==r)try{window.history.go(r)}catch{}}get currentUri(){return this._currentUri}async navigate(t,e){const i=this._pendingTraversal;return this._pendingTraversal=null,await(n=async()=>{try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-start",{uri:t})}catch{}const s=this._suppressBeforeEachOnce;s&&(this._suppressBeforeEachOnce=!1);const n=this._suppressMiddlewaresOnce;n&&(this._suppressMiddlewaresOnce=!1);const o=e||{},r=o.force||!1;if(t===this._currentUri&&!r)return{ok:!0,skipped:!0,uri:t};let a;if(a=n?{proceed:!0,uri:t}:await this._runMiddlewares(t),!a.proceed)return{ok:!1,uri:a.uri,cancelled:!0,reason:"middleware"};t=a.uri;let c,l,h=this.resolve(t),u="";if(h.ok&&h.route?.redirect){const e=t,s=[e];for(;h.ok&&h.route?.redirect;){const e=this._resolveRedirect(h,t);if(!e)break;if(s.length>Ro.MAX_REDIRECTS||s.some(t=>Lo(t)===Lo(e))){u=[...s,e].join(" → "),l=S("MJX303",u);break}s.push(e),t=e,h=this.resolve(t)}if(l)k("MJX303",[u]),t=e,h=this._buildFallbackResult(t,"error",{path:t,error:l});else if(t!==e&&(c=e,t===this._currentUri&&!r))return{ok:!0,skipped:!0,uri:t}}const d=!this._previousRoute,p=d?"initial":i?i.direction:o.replace?"replace":"push",f=i?i.state:d&&void 0===o.state?this._currentHistoryUserState():o.state||void 0,m={path:h.uri||t,params:h.params,meta:h.meta??h.extend,options:e,redirectedFrom:c,direction:p,state:f},_=this._previousRoute?{path:this._previousRoute.path,params:this._previousRoute.params,meta:this._previousRoute.meta,options:this._previousRoute.options}:null;if(this._previousRoute&&this._previousRoute.routeItem){const t=this._previousRoute.routeItem.onLeave||this._routerOptions.hooks?.onLeave;if(t)try{const e={from:{path:this._previousRoute.path,params:this._previousRoute.params,meta:this._previousRoute.meta},to:m},s=await t(e);if(!1===s)return{ok:!1,cancelled:!0,reason:"onLeave"};if(s&&"object"==typeof s&&!0===s.cancel)return{ok:!1,cancelled:!0,reason:s.reason||"onLeave"}}catch(t){M("MJX306",t,"onLeave")}}let g=!0;if(s||(g=await this.application._runBeforeEachGuards(m,_)),!1===g)return{ok:!1,cancelled:!0,reason:"guard"};if("string"==typeof g){const s=this._addressShows(t,c);return await this.navigate(g,s?{...o,replace:!0}:e)}const y=t=>({target:t,chain:this.chainOf(t),direction:p,state:f});h.ok||l||(h=this._buildFallbackResult(t,"notFound",{path:t})),this._currentUri=t,this._previousRoute={path:h.uri,params:h.params,meta:h.meta??h.extend,routeItem:h.route};let v=h.uri;this._scroll?.leaving();const w=i?i.from:this._historyStamp;try{const t=!!c&&this._addressShows(c);this._applyUrl(v,t?{...o,replace:!0}:o)}catch{}const b=this._stack?{direction:p,from:w,to:this._historyStamp,uri:v}:void 0;try{await this.routingEngine.execute(h,b,y(h))}catch(e){M("MJX304",e),h=this._buildFallbackResult(t,"error",{path:t,error:e});try{await this.routingEngine.execute(h,b,y(h))}catch(t){M("MJX305",t)}}this._stack&&this.application._routerState.touch(),o.scroll?this._handleScrollBehavior(o.scroll):this._scroll?.arrived(this._uriWithHash(v,t),p),this.application.fire?.("motifjs-router-navigated",{uri:v,params:h.params,meta:h.meta??h.extend,route:h.ok?h.route:null,ok:h.ok,initial:d,redirectedFrom:c,direction:p,state:f});try{globalThis.__MOTIF_DEVTOOLS_BUS__?.publish?.("route:navigation-end",{uri:v,params:h.params})}catch{}return h},o="UrlRoutingModule.navigate",s.safeCallSilentAsync(n,o));var n,o}describeStack(){return this._stack?this._stack.describe():void 0}routeInfos(){const t=[],e=(s,i)=>{const n=[...i,s];t.push({fullPath:s.fullPath||s.path,name:s.name??null,meta:s.meta??s.extend??{},route:s,chain:n});for(const t of s.childs||[])e(t,n)};for(const t of this.routeCollection?.routes||[])e(t,[]);return t}href(t,e){const s=this.routeCollection.routesMap?.get(t);if(!s)throw S("MJX302",t);const i=s.fullPath||s.path;return this.routingEngine.generatePathString(i,e||{})||i}async evict(t){let e=null;if("string"==typeof t){if(e=this.routeCollection.routesMap?.get(t),!e)throw S("MJX302",String(t))}else e=t;await this.routingEngine.evict(e)}_getFallbackRoute(t){const e=this._fallbackRoutes[t];if(e)return e;const s=this._routerOptions.fallbacks?.[t],i={path:"",fullPath:null,control:s??("notFound"===t?Ro._builtinNotFound:Ro._builtinError),name:"notFound"===t?"not-found":"error",childs:[],extend:{},meta:{},validate:void 0,keepAlive:!1};return this._fallbackRoutes[t]=i,i}_buildFallbackResult(t,e,s){const i=this._getFallbackRoute(e),n=this._findLayoutPrefix(t),o=[...n?.chain??[],i],r={},a={};for(const t of o)t?.extend&&"object"==typeof t.extend&&Object.assign(r,t.extend),t?.meta&&"object"==typeof t.meta&&Object.assign(a,t.meta);return{ok:!1,uri:t,fullPath:null,route:i,chain:o,params:{...n?.params??{},...s},extend:r,meta:a}}_findLayoutPrefix(t){const e=t.split("?")[0].split("#")[0].split("/").filter(Boolean);let s=null;for(const t of this.routeCollection?.records||[]){if(!t.leaf.childs||!t.leaf.childs.length)continue;const i=t.fullPath.split("/").filter(Boolean).length;if(i>e.length)continue;const n="/"+e.slice(0,i).join("/");let o=!1;try{o=t.scanner.exist(n,this._pageSearch())}catch{o=!1}if(!o)continue;const r={...t.scanner.parameters};this.validateChain(n,t,r)&&((!s||t.chain.length>s.rec.chain.length||t.chain.length===s.rec.chain.length&&i>s.depth)&&(s={rec:t,params:r,depth:i}))}return s?{chain:s.rec.chain,params:s.params}:null}static{this._builtinNotFound=()=>new Oi("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(Yi("h2",{},"404 - Not Found")),t.element.appendChild(Yi("p",{},"The requested page was not found."))}})}static{this._builtinError=()=>new Oi("div",{initializeComponent(t){t.style({padding:"20px",fontFamily:"Arial, sans-serif",display:"flex","flex-direction":"column","align-items":"center"}),t.element.appendChild(Yi("h2",{},"Error")),t.element.appendChild(Yi("p",{},"The requested page could not be loaded."))}})}async navigateByName(t,e,s){return await this.navigate(this.href(t,e),s)}async _runMiddlewares(t){let e=t;const s={uri:e,rewritePath:t=>{e=t,s.uri=t},context:this.application};let i=!1;const n=this._routerOptions.middlewareCollections&&this._routerOptions.middlewareCollections()||[],o=async t=>{if(t===n.length)return void(i=!0);const e=n[t];await e(s,async()=>{await o(t+1)})};return 0===n.length?i=!0:await o(0),{proceed:i,uri:e}}chainOf(t){return t.chain.map(e=>this.routingEngine.generatePathString(e.path,t.params)||"")}resolve(t){const e=[],s=this._pageSearch();for(const i of this.routeCollection?.records||[]){if(!i.scanner.exist(t,s))continue;const n={...i.scanner.parameters};this.validateChain(t,i,n)&&e.push({rec:i,params:n})}if(0===e.length){const e=(this.routeCollection?.records||[]).find(t=>t.scanner.exist("/*"));if(e){const s={};try{for(const t of e.chain)t&&t.extend&&"object"==typeof t.extend&&Object.assign(s,t.extend)}catch{}return{ok:!0,uri:t,fullPath:e.fullPath,route:e.leaf,chain:e.chain,params:{},extend:s||{},meta:e.meta||{}}}return{ok:!1,uri:t,fullPath:null,route:null,chain:[],params:{},extend:{}}}let i=e[0];const n=new Map;for(const t of e){const e=t.rec.fullPath,s=n.get(e)||[];s.push(t),n.set(e,s)}let o=!1;for(const[t,e]of n)if(e.length>1){i=(e.some(t=>!t.rec.aliasOf)?e.filter(t=>!t.rec.aliasOf):e).reduce((t,e)=>t.rec.chain.length>=e.rec.chain.length?t:e),o=!0;break}o||(i=e.reduce((t,e)=>To(t.rec,e.rec)<=0?t:e,e[0]));const r=i.rec,a=i.params,c={};try{for(const t of r.chain)t&&t.extend&&"object"==typeof t.extend&&Object.assign(c,t.extend)}catch{}return{ok:!0,uri:t,fullPath:r.fullPath,aliasOf:r.aliasOf??null,route:r.leaf,chain:r.chain,params:a,extend:c,meta:(()=>{const t={};try{for(const e of r.chain)e&&e.meta&&"object"==typeof e.meta&&Object.assign(t,e.meta)}catch{}return t})()}}validateChain(t,e,s){for(const i of e.chain)if("function"==typeof i.validate){const n={uri:t,key:i.name??e.fullPath,routes:this.routesMap,params:s};if(!i.validate(n))return!1}return!0}_installLinkInterceptor(){try{if(this._navHandler)return;this._navHandler=t=>{const e=window,s=this._routerOptions.mode||("file:"===e?.location?.protocol?"hash":"history");let i=t.target;for(;i&&i!==document.body&&!(i instanceof HTMLAnchorElement);)i=i.parentElement;if(!(i&&i instanceof HTMLAnchorElement))return;const n=i.getAttribute("rel")||"";if(!("router"==i.getAttribute("x-command")||i.hasAttribute("data-router-link")||"router"===n.toLowerCase()))return;const o=i;if(o.target&&"_self"!==o.target)return;if(t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let r=o.getAttribute("href")||"";if(r||(r=o.getAttribute("x-to")||""),!r)return;if("history"===s){const s=new URL(r,e.location.href);if(s.origin!==e.location.origin)return;t.preventDefault();const i=s.pathname+s.search+s.hash;return void this.navigate(i)}t.preventDefault();const a=r.startsWith("#")?r.slice(1):r;this.navigate(a)},document.addEventListener("click",this._navHandler)}catch{}}_applyUrl(t,e={}){try{const s=window,i=this._routerOptions.mode||("file:"===s?.location?.protocol?"hash":"history");if("shell"===i)return;if("hash"===i||"file"===i){const i=t.startsWith("#")?t:"#"+t;if(s?.location?.hash!==i)if(e.replace&&s?.history&&"function"==typeof s.history.replaceState){const t=this._nextHistoryStamp(!1);s.history.replaceState(this._routerState(e.state,t),"",i),this._historyStamp=t}else{s.location.hash=i;const t=this._nextHistoryStamp(!0);this._stampCurrentEntry(t,e.state),this._historyStamp=t}return}if(s?.history&&"function"==typeof s.history.pushState){const i=(s.location.pathname||"/")+(s.location.search||"")+(s.location.hash||"");let n=t;try{const e=new URL(t,s.location.href);n=e.pathname+e.search+e.hash}catch{}if(i!==n)if(e.replace){const i=this._nextHistoryStamp(!1);s.history.replaceState(this._routerState(e.state,i),"",t),this._historyStamp=i}else{const i=this._nextHistoryStamp(!0);s.history.pushState(this._routerState(e.state,i),"",t),this._historyStamp=i}}}catch{}}_resolveRedirect(t,e){const s=t.route?.redirect;if(!s)return null;if("function"==typeof s){const e=s({path:t.uri,params:t.params,meta:t.meta??t.extend});return"string"==typeof e&&e.length>0?e:null}const i=this.routingEngine.generatePathString(s,t.params||{}),n=e.indexOf("#"),o=n>=0?e.slice(n):"",r=n>=0?e.slice(0,n):e,a=r.indexOf("?"),c=a>=0?r.slice(a):"",l=i.indexOf("#"),h=l>=0?i.slice(l):"";let u=l>=0?i.slice(0,l):i;return c&&!u.includes("?")&&(u+=c),u+(h||o)}_pageSearch(){try{const t=window,e=this._routerOptions.mode||("file:"===t?.location?.protocol?"hash":"history");if("history"===e||"shell"===e)return;return t?.location?.search||void 0}catch{return}}_addressShows(...t){const e=this._getCurrentUri().split("#")[0];return t.some(t=>!!t&&t.split("#")[0]===e)}_uriWithHash(t,e){const s=e.indexOf("#");return s<0||t.indexOf("#")>=0?t:t+e.slice(s)}_handleScrollBehavior(t){if(t)try{"top"===t?window.scrollTo({top:0,behavior:"auto"}):"smooth"===t?window.scrollTo({top:0,behavior:"smooth"}):"instant"===t?window.scrollTo({top:0,behavior:"instant"}):"object"==typeof t&&window.scrollTo({top:t.top||0,left:t.left||0,behavior:t.behavior||"auto"})}catch{}}dispose(){try{this._scroll?.dispose()}catch{}this._scroll=null,this._historyStamp=null;let t=Promise.resolve();try{try{t=this.routingEngine.dispose()}catch{}if(this._navHandler){try{document.removeEventListener("click",this._navHandler)}catch{}this._navHandler=null}if(this._windowNavListener){const t="hash"===this._routerOptions.mode||"file"===this._routerOptions.mode?"hashchange":"popstate";try{window.removeEventListener(t,this._windowNavListener)}catch{}this._windowNavListener=null}}catch{}return t}}class Io{constructor(){this.version=new re(0),this._current=null,this._constructing=null}read(){return this.version.value,this._constructing??this._current}commit(t){this._current=t,this.touch()}reset(){this._current=null,this.touch()}touch(){this.version.value=this.version.peek()+1}constructWith(t,e){if(!t)return e();const s=this._constructing;this._constructing=t;try{return e()}finally{this._constructing=s}}}let Jo=null,jo=!1;class Fo{constructor(){if(this.services=new Zn,Jo&&"disposing"!==Jo.state||jo)throw new w("MJX405",b("MJX405"),{cause:Jo});jo=!0}build(){this.services.autoRegisterInjectables();const t=this.services.buildServiceProvider();this.services.addSingleton(De,t);var e=new Ho(t);return this.services.addSingleton(Ho,e),Jo=e,e}rebuild(){return Jo?(Jo.provider.dispose(),Jo.provider=this.services.buildServiceProvider(),Jo):this.build()}}class Ho{static get main(){return Jo}constructor(t){this.provider=t,this._state="initializing",this._middlewares=[],this._beforeEachGuards=[],this._routerState=new Io,this.router=function(t,e){const s=()=>{const t=e();if(!t)throw S("MJX309");return t},i=()=>t.read()?.target;return{get params(){return i()?.params??{}},get route(){return i()?.route??null},get ok(){return i()?.ok??!1},get uri(){return i()?.uri??""},get fullPath(){return i()?.fullPath??null},get aliasOf(){return i()?.aliasOf??null},get extend(){return i()?.extend??{}},get meta(){const t=i();return t?t.meta??t.extend:{}},get chain(){return t.read()?.chain??[]},get direction(){return t.read()?.direction},get state(){return t.read()?.state},get stack(){return t.version.value,e()?.describeStack()},get routes(){return t.version.value,e()?.routeInfos()??[]},navigate:async(t,e)=>await s().navigate(t,e),navigateByName:async(t,e,i)=>await s().navigateByName(t,e,i),evict:async t=>{await s().evict(t)},resolve:t=>{const e=s(),i=e.resolve(t);return{chain:e.chainOf(i),result:i}},href:(t,e)=>s().href(t,e)}}(this._routerState,()=>this.urlRoutingModule),this.events=new Map,this._routerConfig=null,this._routerRoot=null,this._startedRouter=null,this._lifecycleOff=null,this._isDevelopment=!1,this._enableErrorLogging=!0}static{this._disposingCount=0}get state(){return this._state}static CreateBuilder(){return new Fo}getAppShell(){return this.appShell}run(t,e){let s;if(o(()=>{Hn.startGc()},"Application.run.engine.startGc"),"string"==typeof t){if(s=document.querySelector(t),!s)throw S("MJX406",t)}else s=t;let i=e;this._state="running";const n=new Oi(s);this.appShell=n,o(()=>{n._keepElementOnDispose=!0,n.application=this,n.provider=this.provider},"Application.run.setupAppShell"),i?(i.parent=n,n.controls.add(i)):(i=n,i.controls.add(new ro({name:"default"}))),n.build(),this._routerRoot=i,this.urlRoutingModule&&(this.urlRoutingModule.start(i),this._startedRouter=this.urlRoutingModule)}insert(t){this.appShell.controls.add(t)}remove(t){this.appShell.controls.remove(t)}attach(t){this.appShell.controls.add(t)}detach(t){this.appShell.controls.detach(t)}appendToMainHost(t){this.appShell.element?.appendChild(t)}dispose(){if(this._disposing)return this._disposing;let t;this._state="disposing",Ho._disposingCount++,jo=!1,o(()=>{this._removeLifecycleListeners()},"Application.dispose.lifecycle"),o(()=>{t=this.urlRoutingModule?.dispose?.()},"Application.dispose.router"),o(()=>{Hn.stopGc()},"Application.dispose.gcStop"),o(()=>{try{const t=window;t&&t.history&&"function"==typeof t.history.replaceState&&t.history.replaceState({},"","/")}catch{}},"Application.dispose.resetUrl"),Te.mode="concurrent";const e=this.appShell;return this._disposing=(async()=>{try{await t}catch(t){M("MJX307",t)}if(e&&!e.isDisposed)try{await e.dispose()}catch(t){M("MJX307",t)}try{await this.provider.dispose()}catch{}Jo===this&&(Jo=null),this._state="disposed",Ho._disposingCount--})()}useTransitions(t){return je(t?.mode)&&(Te.mode=t.mode),this}use(t){return this._middlewares.push(t),this}useGuard(t){return this._beforeEachGuards.push(t),this}async _runBeforeEachGuards(t,e){const s={to:t,from:e};for(const t of this._beforeEachGuards){let e,i=!1;const n=t=>{i=!0,e=t};try{await t(s,n)}catch(t){return M("MJX306",t,"guard"),!1}if(!i)return!1;if(!1===e)return!1;if("string"==typeof e)return e}return!0}useRouter(t){let e,s,i,n,r,a;return Array.isArray(t)?e=t:(e=t.routes,s=t.mode,i=t.fallbacks,n=t.hooks,r=t.scrollMemory,a=t.stack),this.urlRoutingModule&&this.urlRoutingModule.dispose(),this._routerConfig={mode:s,fallbacks:i,middlewareCollections:()=>this._middlewares,RouteItems:e,hooks:n,scrollMemory:r,stack:a},this.urlRoutingModule=new Ro(this._routerConfig,this),this._routerState.reset(),o(()=>{u(),io(),g(e),(this._isDevelopment||!0===globalThis.__MOTIF_DEV__||d())&&function(t){const e=new Map,s=new Map;function i(t,n,o){const r=t.path??"",a=String(r),c=""===n?a:to(n,a),l=o>0&&"/"===a.trim(),h=""===a.trim();h&&k("MJX310",[n||"/"],{parentPath:n,path:a}),o>0&&a.length>0&&"/"!==a&&!a.startsWith("/")&&!a.startsWith("*")&&k("MJX311",[a,n||"/"],{parentPath:n,path:a}),n&&c===n&&(l||h||k("MJX312",[c],{parentPath:n,childPath:a}));const u=(e.get(c)||0)+1;e.set(c,u),u>1&&(l||h||k("MJX313",[c],{full:c}));const d=null==t.alias?[]:Array.isArray(t.alias)?t.alias:[t.alias];for(const t of d){const e=String(t??"");o>0&&e.length>0&&"/"!==e&&!e.startsWith("/")&&!e.startsWith("*")&&k("MJX314",[e,n||"/"],{parentPath:n,alias:e});const i=""===n?e:to(n,e);i===c&&k("MJX315",[i],{full:c,alias:e});const r=(s.get(i)||0)+1;s.set(i,r),r>1&&k("MJX316",[i],{aliasFull:i})}const p=t.childs;if(Array.isArray(p))for(const t of p)i(t,c,o+1)}for(const e of t)i(e,"",0)}(e)},"Application.useRouter.devtools"),this}restartRouter(){const t=this._routerRoot;if(!t||!this._routerConfig)return this;const e=this._startedRouter,s=e?.shownUri;let i=this.urlRoutingModule;return i&&i!==e||(e?.dispose(),i=new Ro(this._routerConfig,this),this.urlRoutingModule=i),this._routerState.reset(),this._startedRouter=i,i.start(t,s),this}async navigate(t,e){if(this.urlRoutingModule)return await this.urlRoutingModule.navigate(t,e);throw S("MJX309")}async navigateByName(t,e,s){if(this.urlRoutingModule)return await this.urlRoutingModule.navigateByName(t,e,s);throw S("MJX309")}on(t,e){var s=this.events.get(t);return s||(this.events.set(t,new Set),s=this.events.get(t)),s&&s.add(e),()=>this.off(t,e)}off(t,e){var s=this.events.get(t);s&&s.delete(e)}fire(t,e){var s=this.events.get(t);s&&s.forEach(s=>{C(()=>s(e),"MJX123",String(t))})}onRouterChanged(t){return this.on("motifjs-router-navigated",t)}get isVisible(){try{return"undefined"==typeof document||"hidden"!==document.visibilityState}catch{return!0}}get isOnline(){try{return"undefined"==typeof navigator||!1!==navigator.onLine}catch{return!0}}onLifecycle(t){return this._installLifecycleListeners(),this.on("motifjs-app-lifecycle",t)}_emitLifecycle(t){this.fire("motifjs-app-lifecycle",{state:t,visible:this.isVisible,online:this.isOnline})}_installLifecycleListeners(){if(this._lifecycleOff)return;const t=[],e=(e,s,i)=>{if(e)try{e.addEventListener(s,i),t.push(()=>{try{e.removeEventListener(s,i)}catch{}})}catch{}},s="undefined"!=typeof document?document:void 0,i="undefined"!=typeof window?window:void 0;e(s,"visibilitychange",()=>this._emitLifecycle(this.isVisible?"visible":"hidden")),e(s,"freeze",()=>this._emitLifecycle("frozen")),e(s,"resume",()=>this._emitLifecycle("resumed")),e(i,"pageshow",t=>{t&&t.persisted&&this._emitLifecycle("restored")}),e(i,"online",()=>this._emitLifecycle("online")),e(i,"offline",()=>this._emitLifecycle("offline")),this._lifecycleOff=t}_removeLifecycleListeners(){const t=this._lifecycleOff;if(this._lifecycleOff=null,t)for(const e of t)e()}get isDevelopmentModeEnabled(){return this._isDevelopment}useReactiveMonitor(t={}){return o(()=>{bt(t)},"Application.useReactiveMonitor.core"),this}useDevelopment(t=!0){return this._isDevelopment=t,s.setDevelopmentMode(t),o(()=>{globalThis.__MOTIF_DEV__=t},"Application.useDevelopment.flag"),o(()=>{var e;e=t,a.enabled=e||l(),h(a.enabled)},"Application.useDevelopment.devtools"),t&&function(){for(const t of Array.from(lt))ht(t)}(),this}useLogging(t=!0){return this._enableErrorLogging=t,function(t){s.setConsoleLogging(t)}(t),this}}function Bo(){return Ho.main.router}function zo(){return{application:Ho.main,services:Ho.main.provider,router:Ho.main.router,attach(...t){Ho.main&&Ho.main.getAppShell().controls.add(...t)}}}function Vo(t){return e=>{Qn.set(e,{lifetime:t?.lifetime??"transient",deps:t?.deps})}}function Wo(t){try{return Ho.main.provider.get(t)}catch(e){return k("MJX414",[$o(t),String(e?.message??e)],{token:t,error:e}),null}}function $o(t){return"function"==typeof t?t.name||"[AnonymousClass]":String(t)}function Uo(t){return t&&"TimeoutError"===t.name}class qo extends w{constructor(){super("MJX605",b("MJX605")),this.name="TimeoutError"}}function Go(t){return new Promise(e=>setTimeout(e,t))}function Ko(t,e=.1){const s=(2*Math.random()-1)*e*t;return Math.max(0,Math.floor(t+s))}class Yo{}class Qo extends Yo{constructor(t={}){super(),this.retries=t.retries??3,this.backoff=t.backoff??"exponential",this.delayMs=t.delay??100,this.jitter=Math.min(Math.max(t.jitter??.1,0),1),this.shouldHandle=t.shouldHandle??(t=>!!t&&!Uo(t)),this.onRetry=t.onRetry}calcDelay(t){if("none"===this.backoff)return 0;if("fixed"===this.backoff)return Ko(this.delayMs,this.jitter);return Ko(this.delayMs*Math.pow(2,t-1),this.jitter)}async execute(t,e){let s;for(let i=1;i<=this.retries+1;i++)try{return await Promise.resolve(t(e))}catch(t){if(s=t,!this.shouldHandle(t)||i>this.retries)break;const n=this.calcDelay(i);this.onRetry&&await this.onRetry(i,t,n,e),n>0&&await Go(n)}throw s}}class Zo extends Yo{constructor(t){super(),this.timeoutMs=t.timeoutMs}async execute(t,e){let s;const i=Promise.resolve(t(e)),n=new Promise((t,e)=>{s=setTimeout(()=>e(new qo),this.timeoutMs)});try{return await Promise.race([i,n])}finally{clearTimeout(s)}}}class tr extends Yo{constructor(t={}){super(),this.state="CLOSED",this.failureCount=0,this.successCount=0,this.nextAttemptTime=0,this.failureThreshold=t.failureThreshold??5,this.successThreshold=t.successThreshold??2,this.durationOfBreakMs=t.durationOfBreakMs??6e4,this.shouldHandle=t.shouldHandle??(t=>!!t&&!Uo(t)),this.onStateChange=t.onStateChange}async changeState(t){const e=this.state;this.state=t,this.failureCount=0,this.successCount=0,"OPEN"===t&&(this.nextAttemptTime=Date.now()+this.durationOfBreakMs),this.onStateChange&&await this.onStateChange(e,t)}async execute(t,e){if("OPEN"===this.state){if(!(Date.now()>=this.nextAttemptTime))throw S("MJX602");await this.changeState("HALF_OPEN")}try{const s=await Promise.resolve(t(e));return"HALF_OPEN"===this.state?(this.successCount++,this.successCount>=this.successThreshold&&await this.changeState("CLOSED")):"CLOSED"===this.state&&(this.failureCount=0),s}catch(t){throw this.shouldHandle(t)&&(this.failureCount++,("HALF_OPEN"===this.state||"CLOSED"===this.state&&this.failureCount>=this.failureThreshold)&&await this.changeState("OPEN")),t}}getState(){return this.state}}class er extends Yo{constructor(t={}){super(),this.active=0,this.queue=[],this.maxConcurrent=t.maxConcurrent??10,this.maxQueue=t.maxQueue??50}dequeue(){if(0===this.queue.length)return;if(this.active>=this.maxConcurrent)return;this.queue.shift()()}async execute(t,e){if(this.active>=this.maxConcurrent){if(this.queue.length>=this.maxQueue)throw S("MJX603");await new Promise(t=>{this.queue.push(t)})}this.active++;try{return await Promise.resolve(t(e))}finally{this.active--,this.dequeue()}}}class sr extends Yo{constructor(t={}){super(),this.tokensPerInterval=t.tokensPerInterval??1,this.intervalMs=t.intervalMs??1e3,this.capacity=t.capacity??this.tokensPerInterval,this.tokens=this.capacity,this.lastRefill=Date.now()}refill(){const t=Date.now(),e=t-this.lastRefill;if(e<=0)return;const s=Math.floor(e/this.intervalMs)*this.tokensPerInterval;s>0&&(this.tokens=Math.min(this.capacity,this.tokens+s),this.lastRefill=t)}async execute(t,e){if(this.refill(),this.tokens<=0)throw S("MJX604");return this.tokens-=1,Promise.resolve(t(e))}}class ir extends Yo{constructor(t){super(),this.fallback=t.fallback,this.shouldHandle=t.shouldHandle??(()=>!0)}async execute(t,e){try{return await Promise.resolve(t(e))}catch(t){if(!this.shouldHandle(t))throw t;return await Promise.resolve(this.fallback(t,e))}}}class nr extends Yo{constructor(...t){super(),this.policies=t}async execute(t,e){return this.policies.reduceRight((t,e)=>s=>e.execute(()=>t(s),s),t)(e)}}const or=t=>new Qo(t),rr=t=>new Zo(t),ar=t=>new tr(t),cr=t=>new er(t),lr=t=>new sr(t),hr=t=>new ir(t),ur=(...t)=>new nr(...t);function dr(t,e){return s=>t.execute(e,s)}class pr{constructor(){this.resiliences=[],this.retry=t=>(this.resiliences.push(or(t)),this),this.timeout=t=>(this.resiliences.push(rr(t)),this),this.circuitBreaker=t=>(this.resiliences.push(ar(t)),this),this.bulkhead=t=>(this.resiliences.push(cr(t)),this),this.rateLimiter=t=>(this.resiliences.push(lr(t)),this),this.fallback=t=>(this.resiliences.push(hr(t)),this)}static get create(){return new pr}async execute(t,e){return ur(...this.resiliences).execute(t,e)}}export{Ho as Application,Fo as ApplicationBuilder,Oi as Component,zs as ComponentBase,ie as ComponentMotif,ae as Computed,mn as ContentBlock,_n as ContentBody,Qi as ControlCollection,tt as Dictionary,E as Disposable,A as DisposableStore,Ht as Emitter,e as ErrorHandler,Ni as FNComponent,Wi as FragmentNode,hn as Frame,Wo as FromService,Vo as Injectable,on as Lazy,ce as LazyComputed,st as LinkedList,G as List,w as MotifError,q as NameValuePair,ut as NodeTypes,rt as Query,pr as Resilience,Po as RouterLink,ro as RouterView,Zn as ServiceCollection,De as ServiceProvider,re as Signal,wn as Transport,Sn as TransportTo,bn as Transporter,Yn as Virtualization,Et as asyncTracking,$n as clearModel,bt as configureReactivityLeakMonitor,Gn as createComputed,Kn as createLazyComputed,qn as createSignal,dr as decorate,Un as deepClone,D as disposableCore,qi as dom,At as effect,s as errorHandler,Se as inject,ht as motifCompiled,Ii as motifComponent,zi as motifFragment,dn as preProcessing,Vn as reactive,nt as read,i as safeCall,n as safeCallAsync,o as safeCallSilent,r as setUnexpectedErrorHandler,K as toDisposable,it as toGetter,Ot as untracked,zo as useApplication,Wn as useModel,Bo as useNavigation};
2
2
  //# sourceMappingURL=index.esm.min.js.map