@but212/atom-effect-jquery 0.30.1 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -28
- package/dist/atom-effect-jquery.min.js +9 -10
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/bindings/chainable.d.ts +2 -0
- package/dist/bindings/chainable.d.ts.map +1 -0
- package/dist/bindings/form.d.ts +29 -0
- package/dist/bindings/form.d.ts.map +1 -0
- package/dist/bindings/input-binding.d.ts +31 -0
- package/dist/bindings/input-binding.d.ts.map +1 -0
- package/dist/bindings/list/context.d.ts +61 -0
- package/dist/bindings/list/context.d.ts.map +1 -0
- package/dist/bindings/list/diff.d.ts +32 -0
- package/dist/bindings/list/diff.d.ts.map +1 -0
- package/dist/bindings/list/dom.d.ts +63 -0
- package/dist/bindings/list/dom.d.ts.map +1 -0
- package/dist/bindings/list/index.d.ts +2 -0
- package/dist/bindings/list/index.d.ts.map +1 -0
- package/dist/bindings/list/types.d.ts +93 -0
- package/dist/bindings/list/types.d.ts.map +1 -0
- package/dist/bindings/list/utils.d.ts +33 -0
- package/dist/bindings/list/utils.d.ts.map +1 -0
- package/dist/bindings/mount.d.ts +2 -0
- package/dist/bindings/mount.d.ts.map +1 -0
- package/dist/bindings/unified.d.ts +135 -0
- package/dist/bindings/unified.d.ts.map +1 -0
- package/dist/constants.d.ts +108 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core/dom.d.ts +26 -0
- package/dist/core/dom.d.ts.map +1 -0
- package/dist/core/effect-factory.d.ts +34 -0
- package/dist/core/effect-factory.d.ts.map +1 -0
- package/dist/core/jquery-patch.d.ts +12 -0
- package/dist/core/jquery-patch.d.ts.map +1 -0
- package/dist/core/namespace.d.ts +11 -0
- package/dist/core/namespace.d.ts.map +1 -0
- package/dist/core/navigation.d.ts +172 -0
- package/dist/core/navigation.d.ts.map +1 -0
- package/dist/core/registry.d.ts +189 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/symbols.d.ts +33 -0
- package/dist/core/symbols.d.ts.map +1 -0
- package/dist/features/fetch.d.ts +2 -0
- package/dist/features/fetch.d.ts.map +1 -0
- package/dist/features/nav.d.ts +23 -0
- package/dist/features/nav.d.ts.map +1 -0
- package/dist/features/route/core.d.ts +83 -0
- package/dist/features/route/core.d.ts.map +1 -0
- package/dist/features/route/index.d.ts +43 -0
- package/dist/features/route/index.d.ts.map +1 -0
- package/dist/features/route/router.d.ts +74 -0
- package/dist/features/route/router.d.ts.map +1 -0
- package/dist/features/route/types.d.ts +60 -0
- package/dist/features/route/types.d.ts.map +1 -0
- package/dist/features/route/view.d.ts +116 -0
- package/dist/features/route/view.d.ts.map +1 -0
- package/dist/features/web-component/index.d.ts +33 -0
- package/dist/features/web-component/index.d.ts.map +1 -0
- package/dist/features/web-component/setup.d.ts +77 -0
- package/dist/features/web-component/setup.d.ts.map +1 -0
- package/dist/features/web-component/state.d.ts +47 -0
- package/dist/features/web-component/state.d.ts.map +1 -0
- package/dist/features/web-component/utils.d.ts +13 -0
- package/dist/features/web-component/utils.d.ts.map +1 -0
- package/dist/index.cjs +9 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +30 -232
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +3129 -2726
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +476 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/debug.d.ts +40 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/index.d.ts +51 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/sanitize.d.ts +52 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -4,11 +4,19 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Reactive DOM bindings for jQuery, implemented as an integration layer for the `atom-effect` core.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
This package enables declarative synchronization between reactive state and the DOM using jQuery selectors and chainable methods. It enforces automatic resource management via `MutationObserver` and provides specialized support for complex state flows, including IME composition and list reconciliation.
|
|
12
|
+
|
|
13
|
+
- **Target**: ES2021+
|
|
14
|
+
- **Compatibility**: jQuery 3.x+
|
|
15
|
+
- **Environment**: Modern browsers (legacy environments such as IE11 are not supported).
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### Package Manager
|
|
12
20
|
|
|
13
21
|
```bash
|
|
14
22
|
npm install @but212/atom-effect-jquery jquery
|
|
@@ -17,60 +25,56 @@ npm install @but212/atom-effect-jquery jquery
|
|
|
17
25
|
### CDN
|
|
18
26
|
|
|
19
27
|
```html
|
|
20
|
-
<!--
|
|
28
|
+
<!-- jQuery -->
|
|
21
29
|
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
22
30
|
<!-- atom-effect-jquery -->
|
|
23
|
-
<script src="https://cdn.jsdelivr.net/npm/@but212/atom-effect-jquery@0.
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/npm/@but212/atom-effect-jquery@0.32.0"></script>
|
|
24
32
|
|
|
25
33
|
<script>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* 2. It automatically extends jQuery ($), so methods like $.atom() are available.
|
|
30
|
-
* 3. Manual cleanup initialization: If the library is loaded dynamically,
|
|
31
|
-
* ensure auto-cleanup is enabled for the target container.
|
|
32
|
-
*/
|
|
33
|
-
AtomEffectJQuery.enableAutoCleanup(document.body);
|
|
34
|
+
// Initializing global state
|
|
35
|
+
const { initAEJ } = AtomEffectJQuery;
|
|
36
|
+
initAEJ({ autoCleanup: true });
|
|
34
37
|
</script>
|
|
35
38
|
```
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
## Usage
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
Bindings allow for declarative relationship definitions between reactive atoms and DOM elements.
|
|
40
43
|
|
|
41
44
|
```javascript
|
|
42
45
|
import $ from 'jquery';
|
|
43
46
|
import '@but212/atom-effect-jquery';
|
|
44
47
|
|
|
45
|
-
// 1.
|
|
48
|
+
// 1. Initialize State
|
|
46
49
|
const count = $.atom(0);
|
|
47
50
|
|
|
48
|
-
// 2.
|
|
51
|
+
// 2. Declarative Binding
|
|
49
52
|
$('#count-display').atomText(count);
|
|
53
|
+
|
|
54
|
+
// 3. Interaction
|
|
50
55
|
$('#btn-increment').on('click', () => count.value++);
|
|
51
56
|
|
|
52
|
-
//
|
|
53
|
-
const
|
|
54
|
-
$('#warning-msg').atomShow(
|
|
57
|
+
// 4. Derived State
|
|
58
|
+
const isThresholdReached = $.computed(() => count.value > 10);
|
|
59
|
+
$('#warning-msg').atomShow(isThresholdReached);
|
|
55
60
|
```
|
|
56
61
|
|
|
57
|
-
## Security
|
|
62
|
+
## Security
|
|
58
63
|
|
|
59
|
-
|
|
60
|
-
For production applications dealing with user-generated content, use **[DOMPurify](https://github.com/cure53/DOMPurify)**.
|
|
64
|
+
The `atomHtml` method renders raw HTML strings. To mitigate XSS risks, ensure input is sanitized before synchronization.
|
|
61
65
|
|
|
62
66
|
```javascript
|
|
63
67
|
import DOMPurify from 'dompurify';
|
|
64
|
-
|
|
68
|
+
|
|
69
|
+
// Sanitize before binding to the DOM
|
|
65
70
|
$('#content').atomHtml($.computed(() => DOMPurify.sanitize(rawHTML.value)));
|
|
66
71
|
```
|
|
67
72
|
|
|
68
73
|
## Documentation
|
|
69
74
|
|
|
70
|
-
- [**API Reference**](./docs/API.md):
|
|
71
|
-
- [**Architecture**](./docs/ARCHITECTURE.md): Internal
|
|
72
|
-
- [**Security
|
|
73
|
-
- [**Common Patterns**](./docs/PATTERNS.md): How to handle async loading, modals, and legacy plugins.
|
|
75
|
+
- [**API Reference**](./docs/API.md): Detailed specification of reactive methods (`atomText`, `atomVal`, `atomList`, etc.).
|
|
76
|
+
- [**Architecture**](./docs/ARCHITECTURE.md): Internal implementation details including the binding pipeline and memory management.
|
|
77
|
+
- [**Security**](./docs/SECURITY.md): Protocols for HTML sanitization and secure data flow.
|
|
74
78
|
|
|
75
79
|
## License
|
|
76
80
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`jquery`)):typeof define==`function`&&define.amd?define([`exports`,`jquery`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.AtomEffectJQuery={},e.jQuery))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),c(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t,1);var l={DISPOSED:1,IS_COMPUTED:2,DIRTY:256,RECOMPUTING:512,HAS_ERROR:1024,FORCE_COMPUTE:2048,IDLE:65536,PENDING:131072,RESOLVED:262144,REJECTED:524288,ATOM_SYNC:16777216,ATOM_NOTIFICATION_SCHEDULED:33554432,EFFECT_EXECUTING:268435456};Object.freeze({ASYNC_STATE:l.IDLE|l.PENDING|l.RESOLVED|l.REJECTED,COMPUTED_DIRTY_MASK:l.DIRTY|l.RECOMPUTING|l.FORCE_COMPUTE});var u=Object.freeze({IDLE:`idle`,PENDING:`pending`,RESOLVED:`resolved`,REJECTED:`rejected`}),d=Object.freeze({DISPOSED:l.DISPOSED,EXECUTING:l.EFFECT_EXECUTING}),f=Object.freeze({DISPOSED:l.DISPOSED,IS_COMPUTED:l.IS_COMPUTED,DIRTY:l.DIRTY,IDLE:l.IDLE,PENDING:l.PENDING,RESOLVED:l.RESOLVED,REJECTED:l.REJECTED,RECOMPUTING:l.RECOMPUTING,HAS_ERROR:l.HAS_ERROR,FORCE_COMPUTE:l.FORCE_COMPUTE}),p=Object.freeze({DISPOSED:l.DISPOSED,SYNC:l.ATOM_SYNC,NOTIFICATION_SCHEDULED:l.ATOM_NOTIFICATION_SCHEDULED}),m=Object.freeze({MAX_EXECUTIONS_PER_SECOND:1e3,MAX_EXECUTIONS_PER_EFFECT:100,MAX_EXECUTIONS_PER_FLUSH:1e4,MAX_FLUSH_ITERATIONS:1e3,MIN_FLUSH_ITERATIONS:10,BATCH_QUEUE_SHRINK_THRESHOLD:1e3}),h=1073741823,g=Object.freeze({WARN_INFINITE_LOOP:!0,EFFECT_FREQUENCY_WINDOW:1e3,LOOP_THRESHOLD:100}),ee=Object.freeze({MAX_PROMISE_ID:h}),_=Object.freeze({UNINITIALIZED:-1,MIN:1}),v=!1;try{v=!!(typeof globalThis<`u`&&globalThis.__ATOM_DEBUG__||typeof sessionStorage<`u`&&sessionStorage.getItem(`__ATOM_DEBUG__`)===`true`)}catch{}var y=(typeof process<`u`&&process.env,typeof __DEV__<`u`&&!!__DEV__||v),b=Object.freeze([]),x=class e extends Error{constructor(e,t=null,n=!0,r){super(e),this.cause=t,this.recoverable=n,this.code=r,this.name=`AtomError`,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}getChain(){if(this.cause===null||this.cause===void 0)return[this];let t=[this],n=new Set([this]),r=this.cause;for(;r!=null;){let i=n.has(r);if(t.push(r),i)break;if(n.add(r),r instanceof e)r=r.cause;else if(r instanceof Error&&`cause`in r)r=r.cause;else break}return t}toJSON(t=new Set){if(t.has(this))return{name:this.name,message:`[Circular Reference]`,recoverable:this.recoverable,code:this.code};t.add(this);let n=this.cause;return this.cause instanceof e?n=this.cause.toJSON(t):this.cause instanceof Error&&(n={name:this.cause.name,message:this.cause.message,stack:this.cause.stack,cause:this.cause.cause}),{name:this.name,message:this.message,code:this.code,recoverable:this.recoverable,stack:this.stack,cause:n}}static format(e,t,n){return`${e} (${t}): ${n}`}},S=class extends x{constructor(...e){super(...e),this.name=`ComputedError`}},C=class extends x{constructor(e,t=null,n=!1,r){super(e,t,n,r),this.name=`EffectError`}},w=class extends x{constructor(e,t=null,n=!1,r){super(e,t,n,r),this.name=`SchedulerError`}},T={COMPUTED_MUST_BE_FUNCTION:`Computed target must be a function`,COMPUTED_ASYNC_PENDING_NO_DEFAULT:`Async computation pending with no default value`,COMPUTED_COMPUTATION_FAILED:`Computation execution failed`,COMPUTED_ASYNC_COMPUTATION_FAILED:`Async computation execution failed`,COMPUTED_CIRCULAR_DEPENDENCY:`Circular dependency detected`,COMPUTED_DISPOSED:`Attempted to access disposed computed`,ATOM_SUBSCRIBER_MUST_BE_FUNCTION:`Subscriber must be a function or Subscriber object`,ATOM_INDIVIDUAL_SUBSCRIBER_FAILED:`Subscriber execution failed`,EFFECT_MUST_BE_FUNCTION:`Effect target must be a function`,EFFECT_EXECUTION_FAILED:`Effect execution failed`,EFFECT_CLEANUP_FAILED:`Effect cleanup failed`,EFFECT_DISPOSED:`Attempted to run disposed effect`,SCHEDULER_FLUSH_OVERFLOW:(e,t)=>`Maximum flush iterations (${e}) exceeded. ${t} jobs dropped. Possible infinite loop.`,CALLBACK_ERROR_IN_ERROR_HANDLER:`Exception encountered in onError handler`,EFFECT_FREQUENCY_LIMIT_EXCEEDED:`Effect executed too frequently within 1 second. Suspected infinite loop.`,SCHEDULER_CALLBACK_MUST_BE_FUNCTION:`Scheduler callback must be a function`,SCHEDULER_END_BATCH_WITHOUT_START:`endBatch() called without matching startBatch(). Ignoring.`,BATCH_CALLBACK_MUST_BE_FUNCTION:`Batch callback must be a function`};function E(e,t,n){if(e instanceof x)return new t(x.format(e.name,n,e.message),e,e.recoverable,e.code);if(e instanceof Error){let r=e.name||e.constructor.name||`Error`;return new t(x.format(r,n,e.message),e)}return new t(x.format(`Unexpected error`,n,String(e)),e)}var te=Symbol(`AtomEffect.DebugName`),ne=Symbol(`AtomEffect.Id`),re=Symbol(`AtomEffect.Type`),ie=Symbol(`AtomEffect.NoDefaultValue`),ae=`[Atom Effect]`,D=y?new class{constructor(){this.enabled=!0,this.warnInfiniteLoop=g.WARN_INFINITE_LOOP,this._updateCounts=new Map,this._nodeRegistry=new Map,this._threshold=g.LOOP_THRESHOLD,this._cleanupScheduled=!1,this.warn=(e,t)=>{this.enabled&&e&&console.warn(`${ae} ${t}`)},this.registerNode=e=>{this._nodeRegistry.set(e.id,new WeakRef(e))},this.attachDebugInfo=(e,t,n,r)=>{this.enabled&&(Object.defineProperties(e,{[te]:{value:r??`${t}_${n}`,configurable:!0},[ne]:{value:n,configurable:!0},[re]:{value:t,configurable:!0}}),this.registerNode(e))},this.trackUpdate=(e,t)=>{if(!this.enabled||!this.warnInfiniteLoop)return;let n=this._updateCounts,r=(n.get(e)??0)+1;r>this._threshold?this.warn(!0,`Infinite loop detected for ${t??`dependency ${e}`}. Over ${this._threshold} updates in a single execution scope.`):n.set(e,r),this._cleanupScheduled||(this._cleanupScheduled=!0,Promise.resolve().then(()=>{this._updateCounts.clear(),this._cleanupScheduled=!1}))},this.dumpGraph=()=>{let e=[];for(let[t,n]of this._nodeRegistry){let r=n.deref();r?e.push({id:t,name:this.getDebugName(r),type:this.getDebugType(r),updateCount:this._updateCounts.get(t)??0}):(this._nodeRegistry.delete(t),this._updateCounts.delete(t))}return e},this.getDebugName=e=>{if(e)return e[te]},this.getDebugType=e=>{if(e)return e[re]}}}:{enabled:!1,warnInfiniteLoop:!1,warn:()=>{},registerNode:()=>{},attachDebugInfo:()=>{},trackUpdate:()=>{},dumpGraph:()=>[],getDebugName:()=>{},getDebugType:()=>{}},oe=1,se=()=>oe++|0,ce=class{constructor(){this._s0=null,this._s1=null,this._s2=null,this._s3=null,this._count=0,this._actualCount=0,this._overflow=null,this._freeIndices=null}_rawWrite(e,t){if(e<4)e===0?this._s0=t:e===1?this._s1=t:e===2?this._s2=t:this._s3=t;else{this._overflow===null&&(this._overflow=[]);let n=this._overflow,r=e-4;n[r]=t}}_rawAdd(e){if(this._s0===null)return this._s0=e,0;if(this._s1===null)return this._s1=e,1;if(this._s2===null)return this._s2=e,2;if(this._s3===null)return this._s3=e,3;this._overflow===null&&(this._overflow=[]);let t=this._overflow,n=this._freeIndices;if(n!==null&&n.length>0){let r=n.pop();return t[r]=e,r+4}return t.push(e),4+t.length-1}_rawSwap(e,t){if(e===t)return;let n=this.getAt(e),r=this.getAt(t);this._rawWrite(e,r),this._rawWrite(t,n)}get size(){return this._actualCount}get physicalSize(){return this._count}getAt(e){return e<4?e===0?this._s0:e===1?this._s1:e===2?this._s2:this._s3:this._overflow?.[e-4]??null}setAt(e,t){let n=this.getAt(e);n!==t&&(this._rawWrite(e,t),n===null?this._actualCount++:t===null&&this._actualCount--,t!==null&&e>=this._count?this._count=e+1:t===null&&this._shrinkPhysicalSizeFrom(e))}_shrinkPhysicalSizeFrom(e){if(e===this._count-1)for(this._count--;this._count>0&&this.getAt(this._count-1)==null;)this._count--}truncateFrom(e){e<=3&&(e<=0&&this._s0!==null&&(this._onItemRemoved(this._s0),this._s0=null,this._actualCount--),e<=1&&this._s1!==null&&(this._onItemRemoved(this._s1),this._s1=null,this._actualCount--),e<=2&&this._s2!==null&&(this._onItemRemoved(this._s2),this._s2=null,this._actualCount--),e<=3&&this._s3!==null&&(this._onItemRemoved(this._s3),this._s3=null,this._actualCount--));let t=this._overflow;if(t!==null){let n=e>4?e-4:0,r=t.length;for(let e=n;e<r;e++){let n=t[e];n!=null&&(this._onItemRemoved(n),t[e]=null,this._actualCount--)}e<=4?this._overflow=null:t.length=e-4}this._count=e,this._actualCount<0&&(this._actualCount=0),this._freeIndices=null}_onItemRemoved(e){}add(e){let t=this._rawAdd(e);return t>=this._count&&(this._count=t+1),this._actualCount++,t}remove(e){let t=-1;if(this._s0===e)t=0;else if(this._s1===e)t=1;else if(this._s2===e)t=2;else if(this._s3===e)t=3;else{let n=this._overflow;n!==null&&(t=n.indexOf(e),t!==-1&&(t+=4))}return t===-1?!1:(this._rawWrite(t,null),this._shrinkPhysicalSizeFrom(t),this._actualCount--,t>=4&&(this._freeIndices===null&&(this._freeIndices=[]),this._freeIndices.push(t-4)),!0)}has(e){if(this._actualCount===0)return!1;if(this._s0===e||this._s1===e||this._s2===e||this._s3===e)return!0;let t=this._overflow;return t===null?!1:t.indexOf(e)!==-1}forEach(e){let t=this._actualCount;if(t===0)return;if(t===this._count){this._s0!=null&&e(this._s0),this._s1!=null&&e(this._s1),this._s2!=null&&e(this._s2),this._s3!=null&&e(this._s3);let t=this._overflow;if(t!==null)for(let n=0,r=t.length;n<r;n++){let r=t[n];r!=null&&e(r)}return}let n=0,r=this._count;for(let i=0;i<r;i++){let r=this.getAt(i);if(r!=null&&(e(r),++n>=t))break}}compact(){if(this._actualCount===this._count)return;let e=0,t=this._count;for(let n=0;n<t;n++){let t=this.getAt(n);t!=null&&(n!==e&&(this._rawWrite(e,t),this._rawWrite(n,null)),e++)}this._count=this._actualCount,this._overflow!==null&&(e<=4?this._overflow=null:this._overflow.length=e-4),this._freeIndices=null}clear(){this._s0=this._s1=this._s2=this._s3=null,this._count=0,this._actualCount=0,this._overflow=null,this._freeIndices=null}dispose(){this.clear()}},le=class extends ce{constructor(...e){super(...e),this._map=null,this._SCAN_THRESHOLD=32,this.hasComputeds=!1}prepareTracking(){this.hasComputeds=!1}_onItemRemoved(e){e.unsub?.()}setAt(e,t){let n=this.getAt(e);super.setAt(e,t),this._map!==null&&(n?.unsub&&this._map.delete(n.node),t?.unsub&&this._map.set(t.node,e))}claimExisting(e,t){let n=this._count;if(n<=t)return!1;let r=this.getAt(t);if(r&&r.node===e&&r.unsub)return r.version=e.version,!0;if(this._map!==null||n-t>this._SCAN_THRESHOLD)return this._claimViaMap(e,t);for(let r=t+1;r<n;r++){let n=this.getAt(r);if(n&&n.node===e&&n.unsub)return n.version=e.version,this._rawSwap(r,t),!0}return!1}_claimViaMap(e,t){this._map===null&&(this._map=this._initMap());let n=this._map,r=n.get(e);if(r===void 0||r<t)return!1;let i=this.getAt(r);if(i==null||!i.unsub)return!1;if(i.version=e.version,r!==t){let i=this.getAt(t);this._rawSwap(r,t),n.set(e,t),i?.unsub&&n.set(i.node,r)}return!0}_initMap(){let e=new Map;for(let t=0;t<this._count;t++){let n=this.getAt(t);n?.unsub&&e.set(n.node,t)}return e}insertNew(e,t){let n=this.getAt(e);if(n!==null){let e=this._rawAdd(n);e>=this._count&&(this._count=e+1),this._map!==null&&n.unsub&&this._map.set(n.node,e)}this._rawWrite(e,t),e>=this._count&&(this._count=e+1),this._actualCount++,this._map!==null&&t.unsub&&this._map.set(t.node,e)}add(e){let t=super.add(e);return this._map!==null&&e.unsub&&this._map.set(e.node,t),t}remove(e){throw Error(`remove() prohibited`)}compact(){}truncateFrom(e){super.truncateFrom(e),this._map!==null&&(this._map=null)}disposeAll(){this.truncateFrom(0),this.hasComputeds=!1}},ue=Symbol.for(`atom-effect/brand`),O={Atom:1,Writable:2,Computed:4,Effect:8};function de(e,t){if(!e)return!1;let n=typeof e;return(n===`object`||n===`function`)&&!!((e[ue]??0)&t)}function fe(e){return de(e,O.Atom)}function pe(e){return de(e,O.Computed)}function me(e){if(e instanceof Promise)return!0;if(!e)return!1;let t=typeof e;return(t===`object`||t===`function`)&&typeof e.then==`function`}var he=class{constructor(e,t,n=void 0){this.node=e,this.version=t,this.unsub=n}},ge=class{constructor(e=void 0,t=void 0){this.fn=e,this.sub=t}notify(e,t){A(()=>{let n=this.fn;n!==void 0&&n(e,t);let r=this.sub;r!==void 0&&r.execute()})}},k=new class{constructor(){this.current=null}run(e,t){if(this.current===e)return t();let n=this.current;this.current=e;try{let e=t();return y&&D.warn(me(e),`Detected Promise returned within tracking context. Dependencies accessed after "await" will NOT be tracked. Consider using synchronous tracking before the async boundary.`),e}finally{this.current=n}}};function A(e){let t=k,n=t.current;if(n===null)return e();t.current=null;try{return e()}finally{t.current=n}}var _e=class{constructor(){this.flags=0,this.version=0,this._lastSeenEpoch=_.UNINITIALIZED,this._nextEpoch=void 0,this._notifying=0,this._hotIndex=-1,this._slots=null,this._deps=null,this.id=se()&h}get isDisposed(){return(this.flags&f.DISPOSED)!==0}get isComputed(){return(this.flags&f.IS_COMPUTED)!==0}get hasError(){return!1}subscribe(e){let t=typeof e==`function`;if(!t&&(!e||typeof e.execute!=`function`))throw E(TypeError(`Invalid subscriber`),x,T.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);let n=this._slots;n||(n=new ce,this._slots=n);let r=!1;if(n._s0!=null&&(t?n._s0.fn===e:n._s0.sub===e))r=!0;else if(n._s1!=null&&(t?n._s1.fn===e:n._s1.sub===e))r=!0;else if(n._s2!=null&&(t?n._s2.fn===e:n._s2.sub===e))r=!0;else if(n._s3!=null&&(t?n._s3.fn===e:n._s3.sub===e))r=!0;else{let i=n._overflow;if(i!=null)for(let n=0,a=i.length;n<a;n++){let a=i[n];if(a!=null&&(t?a.fn===e:a.sub===e)){r=!0;break}}}if(r)return y&&console.warn(`[atom-effect] Duplicate subscription ignored on node ${this.id}`),()=>{};let i=new ge(t?e:void 0,t?void 0:e);return n.add(i),()=>this._unsubscribe(i)}_unsubscribe(e){let t=this._slots;t&&(t.remove(e),this._notifying===0&&t.compact())}subscriberCount(){let e=this._slots;return e===null?0:e.size}_notifySubscribers(e,t){let n=this._slots;if(!(n===null||n.size===0)){this._notifying++;try{let r=n._s0;if(r!=null)try{r.notify(e,t)}catch(e){this._logNotifyError(e)}if(r=n._s1,r!=null)try{r.notify(e,t)}catch(e){this._logNotifyError(e)}if(r=n._s2,r!=null)try{r.notify(e,t)}catch(e){this._logNotifyError(e)}if(r=n._s3,r!=null)try{r.notify(e,t)}catch(e){this._logNotifyError(e)}let i=n._overflow;if(i!=null)for(let n=0,r=i.length;n<r;n++){let r=i[n];if(r!=null)try{r.notify(e,t)}catch(e){this._logNotifyError(e)}}}finally{--this._notifying===0&&n.compact()}}}_logNotifyError(e){console.error(E(e,x,T.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED))}_isDirty(){let e=this._deps;if(e===null||e.size===0)return!1;let t=this._hotIndex;if(t!==-1){let n=e.getAt(t);if(n!=null&&n.node.version!==n.version)return!0}return this._deepDirtyCheck()}},ve=0;function ye(){let e=ve+1&h;return ve=e===0?1:e,ve}function be(e){let t=e+1&h;return t===0?1:t}var xe=0,Se=!1,Ce=0;function we(){return Ce}function Te(){return Se?(y&&console.warn(`startFlush() called during flush - ignored`),!1):(Se=!0,Ce=ye(),xe=0,!0)}function Ee(){Se=!1}function De(){if(!Se)return 0;let e=++xe;if(e<=m.MAX_EXECUTIONS_PER_FLUSH)return e;throw Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${m.MAX_EXECUTIONS_PER_FLUSH}`)}var j=new class{constructor(){this._queueBuffer=[[],[]],this._bufferIndex=0,this._size=0,this._epoch=0,this._isProcessing=!1,this._isFlushingSync=!1,this._batchDepth=0,this._batchQueue=[],this._batchQueueSize=0,this._maxFlushIterations=m.MAX_FLUSH_ITERATIONS,this.onOverflow=null,this._boundRunLoop=this._runLoop.bind(this)}get queueSize(){return this._size+this._batchQueueSize}get isBatching(){return this._batchDepth>0}schedule(e){if(y&&typeof e!=`function`&&(!e||typeof e.execute!=`function`))throw new w(T.SCHEDULER_CALLBACK_MUST_BE_FUNCTION);let t=this._epoch;if(e._nextEpoch===t)return;if(e._nextEpoch=t,this._batchDepth>0||this._isFlushingSync){this._batchQueue[this._batchQueueSize++]=e;return}let n=this._queueBuffer[this._bufferIndex];n[this._size++]=e,this._isProcessing||this._flush()}_flush(){this._isProcessing||this._size===0||(this._isProcessing=!0,queueMicrotask(this._boundRunLoop))}_runLoop(){try{if(this._size===0&&this._batchQueueSize===0)return;let e=Te();this._drainQueue(),e&&Ee()}finally{this._isProcessing=!1}}_flushSync(){if(this._size===0&&this._batchQueueSize===0)return;let e=this._isFlushingSync;this._isFlushingSync=!0;let t=Te();try{this._mergeBatchQueue(),this._drainQueue()}finally{this._isFlushingSync=e,t&&Ee()}}_mergeBatchQueue(){let e=this._batchQueueSize;if(e===0)return;this._epoch=this._epoch+1|0;let t=this._epoch,n=this._batchQueue,r=this._queueBuffer[this._bufferIndex],i=this._size;for(let a=0;a<e;a++){let e=n[a];e._nextEpoch!==t&&(e._nextEpoch=t,r[i++]=e),n[a]=void 0}this._size=i,this._batchQueueSize=0,n.length>m.BATCH_QUEUE_SHRINK_THRESHOLD&&(n.length=0)}_drainQueue(){let e=0;for(;this._size>0||this._batchQueueSize>0;){if(++e>this._maxFlushIterations){this._handleFlushOverflow();return}this._batchQueueSize>0&&this._mergeBatchQueue(),this._size>0&&this._processQueue()}}_processQueue(){let e=this._bufferIndex,t=this._queueBuffer[e],n=this._size;this._bufferIndex=e^1,this._size=0,this._epoch=this._epoch+1|0;for(let e=0;e<n;e++){let n=t[e];t[e]=void 0;try{typeof n==`function`?n():n.execute()}catch(e){console.error(new w(`Error occurred during scheduler execution`,e))}}}_handleFlushOverflow(){let e=this._size+this._batchQueueSize;console.error(new w(T.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations,e))),this._size=0,this._queueBuffer[0].length=0,this._queueBuffer[1].length=0,this._batchQueueSize=0,this._batchQueue.length=0;let t=this.onOverflow;if(t)try{t(e)}catch{}}startBatch(){this._batchDepth++}endBatch(){if(this._batchDepth===0){y&&console.warn(T.SCHEDULER_END_BATCH_WITHOUT_START);return}--this._batchDepth===0&&(this._isFlushingSync||this._flushSync())}setMaxFlushIterations(e){if(e<m.MIN_FLUSH_ITERATIONS)throw new w(`Max iterations must be at least ${m.MIN_FLUSH_ITERATIONS}`);this._maxFlushIterations=e}};function Oe(e){if(y&&typeof e!=`function`)throw TypeError(T.BATCH_CALLBACK_MUST_BE_FUNCTION);j.startBatch();try{return e()}finally{j.endBatch()}}var ke=class extends _e{constructor(e,t){super(),this[ue]=O.Atom|O.Writable,this._value=e,this._equal=t.equal??Object.is,t.sync&&(this.flags|=p.SYNC),D.attachDebugInfo(this,`atom`,this.id,t.name)}get isNotificationScheduled(){return(this.flags&p.NOTIFICATION_SCHEDULED)!==0}get isSync(){return(this.flags&p.SYNC)!==0}get value(){return k.current?.addDependency(this),this._value}set value(e){let t=this._value;if(this._equal(t,e)||(this._value=e,this.version=be(this.version),D.trackUpdate(this.id,D.getDebugName(this)),(this.flags&p.NOTIFICATION_SCHEDULED)!==0))return;let n=this._slots;n==null||n.size===0||(this._pendingOldValue=t,this.flags|=p.NOTIFICATION_SCHEDULED,(this.flags&p.SYNC)!==0&&!j.isBatching?this._notifying===0&&this._flushNotifications():j.schedule(this))}execute(){this._flushNotifications()}_flushNotifications(){let e=p.NOTIFICATION_SCHEDULED,t=p.DISPOSED,n=p.SYNC;for(;(this.flags&(e|t))===e;){let t=this._pendingOldValue;if(this._pendingOldValue=void 0,this.flags&=~e,this._equal(this._value,t)||this._notifySubscribers(this._value,t),(this.flags&n)===0||j.isBatching)break}}peek(){return this._value}dispose(){let e=this.flags;(e&p.DISPOSED)===0&&(this._slots?.clear(),this.flags=e|p.DISPOSED,this._value=void 0,this._pendingOldValue=void 0,this._equal=Object.is)}_deepDirtyCheck(){return!1}[Symbol.dispose](){this.dispose()}};function Ae(e,t={}){return new ke(e,t)}var{IDLE:M,DIRTY:N,PENDING:P,RESOLVED:F,REJECTED:I,HAS_ERROR:je,RECOMPUTING:L,DISPOSED:Me,IS_COMPUTED:R,FORCE_COMPUTE:Ne}=f,Pe=class extends _e{constructor(e,t={}){if(typeof e!=`function`)throw new S(T.COMPUTED_MUST_BE_FUNCTION);if(super(),this[ue]=O.Atom|O.Computed,this._error=null,this._promiseId=0,this._deps=new le,this._trackEpoch=_.UNINITIALIZED,this._trackCount=0,this._value=void 0,this.flags=R|N|M,this._equal=t.equal??Object.is,this._fn=e,this._defaultValue=`defaultValue`in t?t.defaultValue:ie,this._onError=t.onError??null,D.attachDebugInfo(this,`computed`,this.id,t.name),t.lazy===!1)try{this._recompute()}catch{}}get isDirty(){return(this.flags&N)!==0}get isRejected(){return(this.flags&I)!==0}get isRecomputing(){return(this.flags&L)!==0}get _hasErrorInternal(){return(this.flags&je)!==0}_track(){k.current?.addDependency(this)}get value(){k.current?.addDependency(this);let e=this.flags;if((e&(F|N|M))===F)return this._value;if((e&Me)!==0)throw new S(T.COMPUTED_DISPOSED);if((e&L)!==0){let e=this._defaultValue;if(e!==ie)return e;throw new S(T.COMPUTED_CIRCULAR_DEPENDENCY)}if((e&(N|M))!==0){let t=this._deps;if((e&M)===0&&(e&Ne)===0&&t.size>0&&!this._isDirty()?e=this.flags&=~N:(this._recompute(),e=this.flags),(e&F)!==0)return this._value}let t=this._defaultValue,n=t!==ie;if((e&P)!==0){if(n)return t;throw new S(T.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}if((e&I)!==0){if(n)return t;throw this._error}return this._value}peek(){return this._value}get state(){k.current?.addDependency(this);let e=this.flags;return(e&F)===0?(e&P)===0?(e&I)===0?u.IDLE:u.REJECTED:u.PENDING:u.RESOLVED}get hasError(){if(k.current?.addDependency(this),(this.flags&(I|je))!==0)return!0;let e=this._deps;return e.hasComputeds?A(()=>{let t=e.size;for(let n=0;n<t;n++)if(e.getAt(n)?.node.hasError)return!0;return!1}):!1}get isValid(){return!this.hasError}get errors(){k.current?.addDependency(this);let e=this._error,t=this._deps;if(!t.hasComputeds)return e==null?b:Object.freeze([e]);let n=[];return e!=null&&n.push(e),A(()=>{let e=t.size;for(let r=0;r<e;r++){let e=t.getAt(r)?.node;e!=null&&(e.flags&R)!==0&&this._accumulateErrors(e,n)}}),n.length===0?b:Object.freeze(n)}_accumulateErrors(e,t){let n=e._error;n!=null&&!t.includes(n)&&t.push(n);let r=e._deps;if(!r.hasComputeds)return;let i=r.size;for(let e=0;e<i;e++){let n=r.getAt(e)?.node;n!=null&&(n.flags&R)!==0&&this._accumulateErrors(n,t)}}get lastError(){return k.current?.addDependency(this),this._error}get isPending(){return k.current?.addDependency(this),(this.flags&P)!==0}get isResolved(){return k.current?.addDependency(this),(this.flags&F)!==0}invalidate(){this.flags|=Ne,this._markDirty()}dispose(){(this.flags&Me)===0&&(this._deps.disposeAll(),this._slots!=null&&this._slots.clear(),this.flags=Me|N|M,this._error=null,this._value=void 0,this._hotIndex=-1)}[Symbol.dispose](){this.dispose()}addDependency(e){let t=this._trackEpoch;if(e._lastSeenEpoch===t)return;e._lastSeenEpoch=t;let n=this._trackCount++,r=this._deps,i=r.getAt(n);if(i!=null&&i.node===e)i.version=e.version;else if(!r.claimExisting(e,n)){let t=new he(e,e.version,e.subscribe(this));r.insertNew(n,t)}(e.flags&R)!==0&&(r.hasComputeds=!0)}_recompute(){if(this.isRecomputing)return;this.flags=(this.flags|L)&~Ne,this._trackEpoch=ye(),this._trackCount=0,this._deps.prepareTracking(),this._hotIndex=-1;let e=!1;try{let t=k.run(this,this._fn);this._deps.truncateFrom(this._trackCount),e=!0,me(t)?this._handleAsyncComputation(t):this._finalizeResolution(t)}catch(t){if(!e)try{this._deps.truncateFrom(this._trackCount)}catch(e){y&&console.warn(`[atom-effect] _commitDeps failed during error recovery:`,e)}this._handleError(t,T.COMPUTED_COMPUTATION_FAILED,!0)}finally{this._trackEpoch=_.UNINITIALIZED,this._trackCount=0,this.flags&=~L}}_handleAsyncComputation(e){this.flags=(this.flags|P)&~(M|N|F|I),this._notifySubscribers(void 0,void 0),this._promiseId=(this._promiseId+1)%ee.MAX_PROMISE_ID;let t=this._promiseId;e.then(e=>{if(t===this._promiseId){if(this._isDirty())return this._markDirty();this._finalizeResolution(e),this._notifySubscribers(e,void 0)}},e=>t===this._promiseId&&this._handleError(e,T.COMPUTED_ASYNC_COMPUTATION_FAILED))}_handleError(e,t,n=!1){let r=E(e,S,t);if((!this.isRejected||this._error!==r)&&(this.version=be(this.version)),this._error=r,this.flags=this.flags&~(M|N|P|F)|I|je,this._onError)try{this._onError(r)}catch(e){console.error(T.CALLBACK_ERROR_IN_ERROR_HANDLER,e)}if(this._notifySubscribers(void 0,void 0),n)throw r}_finalizeResolution(e){let t=this.flags;((t&F)===0||!this._equal(this._value,e))&&(this.version=be(this.version)),this._value=e,this._error=null,this.flags=(t|F)&~(M|N|P|I|je)}execute(){this._markDirty()}_markDirty(){let e=this.flags;(e&(L|N))===0&&(this.flags=e|N,D.trackUpdate(this.id,D.getDebugName(this)),this._notifySubscribers(void 0,void 0))}_deepDirtyCheck(){let e=this._deps;return A(()=>{let t=e.size;for(let n=0;n<t;n++){let t=e.getAt(n);if(t==null)continue;let r=t.node;if((r.flags&R)!==0)try{r.value}catch{y&&console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`)}if(r.version!==t.version)return this._hotIndex=n,!0}return this._hotIndex=-1,!1})}};function Fe(e,t={}){return new Pe(e,t)}var Ie=class extends _e{constructor(e,t={}){super(),this[ue]=O.Effect,this._cleanup=null,this._deps=new le,this._currentEpoch=_.UNINITIALIZED,this._lastFlushEpoch=_.UNINITIALIZED,this._fn=e,this._onError=t.onError??null,this._sync=t.sync??!1,this._maxExecutions=t.maxExecutionsPerSecond??m.MAX_EXECUTIONS_PER_SECOND,this._maxExecutionsPerFlush=t.maxExecutionsPerFlush??m.MAX_EXECUTIONS_PER_EFFECT,this._executionsInEpoch=0,this._executionCount=0,this._windowStart=0,this._windowCount=0,this._execId=0,this._trackCount=0,this._sync?this._notifyCallback=()=>this.execute():this._notifyCallback=()=>j.schedule(this),D.attachDebugInfo(this,`effect`,this.id,t.name)}run(){if(this.isDisposed)throw new C(T.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.isDisposed||(this.flags|=d.DISPOSED,this._execCleanup(),this._deps?.disposeAll())}[Symbol.dispose](){this.dispose()}addDependency(e){if((this.flags&d.EXECUTING)===0)return;let t=this._currentEpoch;if(e._lastSeenEpoch===t)return;e._lastSeenEpoch=t;let n=this._trackCount++,r=this._deps,i;switch(n){case 0:i=r._s0;break;case 1:i=r._s1;break;case 2:i=r._s2;break;case 3:i=r._s3;break;default:i=r.getAt(n)}i!=null&&i.node===e?i.version=e.version:r.claimExisting(e,n)||this._insertNewDependency(e,n),e.isComputed&&(r.hasComputeds=!0)}_insertNewDependency(e,t){let n;try{let t=e.subscribe(this._notifyCallback);n=new he(e,e.version,t)}catch(t){let r=E(t,C,T.EFFECT_EXECUTION_FAILED);if(console.error(r),this._onError)try{this._onError(r)}catch{}n=new he(e,e.version,void 0)}this._deps.insertNew(t,n)}execute(e=!1){let t=this.flags;if((t&(d.DISPOSED|d.EXECUTING))!==0)return;let n=this._deps;if(!e&&n.size>0&&!this._isDirty())return;this._checkInfiniteLoops(),D.trackUpdate(this.id,D.getDebugName(this)),this.flags=t|d.EXECUTING,this._execCleanup(),this._currentEpoch=ye(),this._trackCount=0,n.prepareTracking(),this._hotIndex=-1;let r=!1;try{let e=k.run(this,this._fn);n.truncateFrom(this._trackCount),r=!0,me(e)?this._handleAsyncResult(e):this._cleanup=typeof e==`function`?e:null}catch(e){if(!r)try{n.truncateFrom(this._trackCount)}catch(e){y&&console.warn(`[atom-effect] _commitDeps failed during error recovery:`,e)}this._handleExecutionError(e),this._cleanup=null}finally{this.flags&=~d.EXECUTING}}_handleAsyncResult(e){let t=++this._execId;e.then(e=>{if(t!==this._execId||this.isDisposed){if(typeof e==`function`)try{e()}catch(e){this._handleExecutionError(e,T.EFFECT_CLEANUP_FAILED)}return}typeof e==`function`&&(this._cleanup=e)},e=>t===this._execId&&this._handleExecutionError(e))}_deepDirtyCheck(){let e=k.current;k.current=null;let t=this._deps;try{let e=t.size;for(let n=0;n<e;n++){let e=t.getAt(n);if(e==null)continue;let r=e.node;if(r.isComputed&&this._tryPullComputed(r),r.version!==e.version)return this._hotIndex=n,!0}return!1}finally{k.current=e}}_tryPullComputed(e){try{e.value}catch{y&&console.warn(`[atom-effect] Dependency #${e.id} threw during dirty check`)}}_execCleanup(){let e=this._cleanup;if(e!=null){this._cleanup=null;try{e()}catch(e){this._handleExecutionError(e,T.EFFECT_CLEANUP_FAILED)}}}_checkInfiniteLoops(){let e=we();this._lastFlushEpoch!==e&&(this._lastFlushEpoch=e,this._executionsInEpoch=0),++this._executionsInEpoch>this._maxExecutionsPerFlush&&this._throwInfiniteLoopError(`per-effect`),De()>m.MAX_EXECUTIONS_PER_FLUSH&&this._throwInfiniteLoopError(`global`),this._executionCount++,y&&this._checkFrequencyLimit()}_checkFrequencyLimit(){if(!Number.isFinite(this._maxExecutions))return;let e=Date.now();if(e-this._windowStart>=g.EFFECT_FREQUENCY_WINDOW){this._windowStart=e,this._windowCount=1;return}if(++this._windowCount>this._maxExecutions){let e=new C(T.EFFECT_FREQUENCY_LIMIT_EXCEEDED);throw this.dispose(),this._handleExecutionError(e),e}}get executionCount(){return this._executionCount}get isExecuting(){return(this.flags&d.EXECUTING)!==0}_throwInfiniteLoopError(e){let t=new C(`Infinite loop detected (${e}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${xe}`);throw this.dispose(),console.error(t),t}_handleExecutionError(e,t=T.EFFECT_EXECUTION_FAILED){let n=E(e,C,t);if(console.error(n),this._onError)try{this._onError(n)}catch(e){console.error(E(e,C,T.CALLBACK_ERROR_IN_ERROR_HANDLER))}}};function z(e,t={}){if(typeof e!=`function`)throw new C(T.EFFECT_MUST_BE_FUNCTION);let n=new Ie(e,t);return n.execute(),n}var Le=/^(?:__proto__|constructor|prototype)$/;function Re(e,t,n,r){if(n===t.length)return r;let i=t[n];if(Le.test(i))return e;let a=typeof e==`object`&&e?e:{},o=a[i],s=Re(o,t,n+1,r);if(Object.is(o,s))return e;if(Array.isArray(a)){let e=a.slice(),t=Number(i);return i.trim()!==``&&Number.isInteger(t)&&t>=0?e[t]=s:e[i]=s,e}return{...a,[i]:s}}function B(e,t){let n=e,r=t.length;for(let e=0;e<r;e++){if(n==null)return;let r=t[e];if(Le.test(r))return;n=n[r]}return n}function ze(e,t){let n=t.includes(`.`)?t.split(`.`):[t],r=new Set,i=()=>{r.forEach(e=>e()),r.clear()};return{get value(){return B(e.value,n)},set value(t){let r=e.peek(),i=Re(r,n,0,t);i!==r&&(e.value=i)},peek:()=>B(e.peek(),n),subscribe(t){let i=e.subscribe((e,r)=>{let i=B(e,n),a=B(r,n);Object.is(i,a)||t(i,a)});return r.add(i),()=>{i(),r.delete(i)}},subscriberCount:()=>r.size,dispose:i,[Symbol.dispose]:i,[ue]:O.Atom|O.Writable}}var Be=(e,t)=>ze(e,t),Ve=e=>t=>ze(e,t),He=e=>typeof e==`object`&&!!e,Ue=e=>fe(e),We=e=>(He(e)||typeof e==`function`)&&typeof e.then==`function`;function Ge(e){let{localName:t,id:n,className:r}=e,i=t;n&&(i+=`#${n}`);let a=typeof r==`string`?r:r.baseVal;if(typeof a==`string`){let e=a.trim();e&&(i+=`.${e.replace(/\s+/g,`.`)}`)}let o=e.type;return o&&typeof o==`string`&&o!==`text`&&(i+=`.${o}`),i}var V=Object.prototype.hasOwnProperty;function Ke(e,t){if(e===t)return!0;if(!He(e)||!He(t))return!1;let n=e,r=t,i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(!V.call(r,e)||!Object.is(n[e],r[e]))return!1;return!0}var H={ROUTE:`[atom-route]`,BINDING:`[atom-binding]`,LIST:`[atom-list]`,MOUNT:`[atom-mount]`},qe=Object.freeze({mode:`hash`,basePath:``,autoBindLinks:!1,activeClass:`active`}),Je=Object.freeze({EVENT:`input`,DEBOUNCE:0}),Ye=Object.freeze({HIGHLIGHT_DURATION_MS:500}),Xe=new Set([`input`,`select`,`textarea`]),Ze=new Set([`innerHTML`,`outerHTML`,`srcdoc`,`__proto__`,`constructor`,`prototype`]),Qe=`(?:j\\s*a\\s*v\\s*a\\s*s\\s*c\\s*r\\s*i\\s*p\\s*t|v\\s*b\\s*s\\s*c\\s*r\\s*i\\s*p\\s*t)`,U={ROUTE:{NOT_FOUND:e=>`Route "${e}" not found and no notFound route configured`,TEMPLATE_NOT_FOUND:e=>`Template "${e}" not found`,TARGET_NOT_FOUND:e=>`Target element "${e}" not found`,MALFORMED_URI:e=>`Malformed URI component: ${e}`},SECURITY:{UNSAFE_CONTENT:()=>`Unsafe content neutralized during sanitization.`,BLOCKED_CSS_VALUE:e=>`Blocked dangerous value in CSS style property "${e}".`,BLOCKED_EVENT_HANDLER:e=>`Blocked setting dangerous event handler attribute/property "${e}".`,BLOCKED_PROTOCOL:e=>`Blocked dangerous protocol in "${e}".`,BLOCKED_PROP:e=>`Blocked setting dangerous property "${e}". Use html binding for sanitized HTML.`},BINDING:{INVALID_INPUT_ELEMENT:e=>`Val binding used on non-input element <${e}>.`,MISSING_SOURCE:e=>`[${e}] source is required when prop/name is a string.`,MISSING_CONDITION:e=>`[${e}] condition is required when className is a string.`,UPDATER_ERROR:(e,t)=>`Updater threw in binding "${e}"${t?` (static)`:``}`,CLEANUP_ERROR:e=>`Binding cleanup error${e?`: ${e}`:``}`,PARSE_ERROR:e=>`parse() threw during DOM→Atom sync${e?`: ${e}`:``}`},LIST:{DUPLICATE_KEY:(e,t,n)=>`Duplicate key "${e}" at index ${t} in atomList <${n}>.`},MOUNT:{ERROR:e=>`Mount error${e?` in component <${e}>`:``}`,CLEANUP_ERROR:e=>`Cleanup error${e?` in component <${e}>`:``}`},CORE:{EFFECT_DISPOSE_ERROR:e=>`Effect dispose error${e?`: ${e}`:``}`}},$e=`atom-debug-highlight`,W=`data-atom-debug`,et=typeof window<`u`,tt=new WeakMap,nt=new WeakMap,rt=!1,it=()=>`${Ye.HIGHLIGHT_DURATION_MS/1e3}s`,at=()=>`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
outline-offset: 1px;
|
|
8
|
-
}
|
|
9
|
-
`.replace(/\s+/g,` `);function ot(){if(rt||!et)return;if(document.querySelector(`style[${W}]`)){rt=!0;return}let e=document.createElement(`style`);e.setAttribute(W,``),e.textContent=at(),document.head.appendChild(e),rt=!0}function st(){let e=globalThis;if(e.__ATOM_DEBUG__!==void 0)return!!e.__ATOM_DEBUG__;try{if(typeof sessionStorage<`u`&&sessionStorage.getItem(`__ATOM_DEBUG__`)===`true`)return!0}catch{}return e.process?.env?.NODE_ENV!==`production`&&e.process?.env?.NODE_ENV!==void 0?!0:e.__DEV__===void 0?!1:!!e.__DEV__}var ct=class{constructor(){this.enabled=!0}log(e,...t){this.enabled&&console.log(e,...t)}atomChanged(e,t,n,r){this.enabled&&console.log(`${e} Atom "${t??`anonymous`}" changed:`,n,`→`,r)}cleanup(e,t){this.enabled&&console.log(`${e} Cleanup: ${t}`)}warn(e,t,...n){console.warn(`${e} ${t}`,...n)}error(e,t,n){console.error(`${e} ${t}`,n)}domUpdated(e,t,n,r){if(!this.enabled)return;let i=`jquery`in t?t[0]:t;i&&i.nodeType===1&&i.isConnected&&(console.log(`${e} DOM updated: ${Ge(i)}.${n} =`,r),this._triggerVisualHighlight(i))}_triggerVisualHighlight(e){let t=globalThis,n=t.requestAnimationFrame,r=t.cancelAnimationFrame;if(!et||typeof n!=`function`)return;ot();let i=nt.get(e),a=tt.get(e);i!==void 0&&typeof r==`function`&&r(i),a!==void 0&&(clearTimeout(a),tt.delete(e)),e.hasAttribute(W)||e.setAttribute(W,``),nt.set(e,n(()=>{nt.delete(e),e.isConnected&&(e.classList.add($e),tt.set(e,setTimeout(()=>{e.classList.remove($e),tt.delete(e)},Ye.HIGHLIGHT_DURATION_MS)))}))}},G=st()?new ct:{enabled:!1,log:()=>{},atomChanged:()=>{},domUpdated:()=>{},cleanup:()=>{},warn:(e,t,...n)=>console.warn(`${e} ${t}`,...n),error:(e,t,n)=>console.error(`${e} ${t}`,n)};function lt(e,t){return Ae(e,t)}Object.defineProperty(lt,`debug`,{enumerable:!0,configurable:!0,get:()=>G.enabled,set:e=>{G.enabled=e}});var ut=()=>Promise.resolve();t.default.extend({atom:lt,computed:Fe,effect:z,batch:Oe,untracked:A,isAtom:fe,isComputed:pe,isReactive:Ue,nextTick:ut,atomLens:ze,composeLens:Be,lensFor:Ve});var dt=class{constructor(e=50,t=256){this.limit=e,this.capacity=t,this.pool=[]}acquire(){return this.pool.pop()??[]}release(e){if(Object.isFrozen(e))return;let t=e.length;e.length=0,this.pool.length<this.limit&&t<=this.capacity&&this.pool.indexOf(e)===-1&&this.pool.push(e)}reset(){this.pool.length=0}},ft=class{constructor(e,t,n=64){this.factory=e,this.reset=t,this.limit=n,this.pool=[]}acquire(){return this.pool.pop()??this.factory()}release(e){Object.isFrozen(e)||(this.reset(e),this.pool.length<this.limit&&this.pool.indexOf(e)===-1&&this.pool.push(e))}drain(){this.pool.length>0&&(this.pool.length=0)}get size(){return this.pool.length}},pt=128,mt=new dt(pt),ht=new dt(pt),gt=new ft(()=>({effects:void 0,cleanups:void 0,componentCleanup:void 0}),e=>{if(e.effects){let t=e.effects.length;for(let n=0;n<t;n++)try{e.effects[n].dispose()}catch{}mt.release(e.effects),e.effects=void 0}if(e.cleanups){let t=e.cleanups.length;for(let n=0;n<t;n++)try{e.cleanups[n]()}catch{}ht.release(e.cleanups),e.cleanups=void 0}if(e.componentCleanup){try{e.componentCleanup()}catch{}e.componentCleanup=void 0}},pt),_t=!1;function vt(){_t||typeof document<`u`&&document.body&&(_t=!0,bt(document.body))}var K=`_aes-bound`,q=new class{constructor(){this.records=new WeakMap,this.preservedNodes=new WeakSet,this.ignoredNodes=new WeakSet}keep(e){this.preservedNodes.add(e)}isKept(e){return this.preservedNodes.has(e)}markIgnored(e){this.ignoredNodes.add(e)}isIgnored(e){return this.ignoredNodes.has(e)}getOrCreateRecord(e){vt();let t=this.records.get(e);return t||(t=gt.acquire(),this.records.set(e,t),e.classList.add(K)),t}trackEffect(e,t){let n=this.getOrCreateRecord(e);n.effects||=mt.acquire(),n.effects.push(t)}trackCleanup(e,t){let n=this.getOrCreateRecord(e);n.cleanups||=ht.acquire(),n.cleanups.push(t)}setComponentCleanup(e,t){this.getOrCreateRecord(e).componentCleanup=t}hasBind(e){return this.records.has(e)}cleanup(e){if(this.preservedNodes.delete(e),this.ignoredNodes.delete(e),e.nodeType!==1)return;let t=e,n=this.records.get(t);if(!n){t.classList.remove(K);return}this.records.delete(t),t.classList.remove(K);let r=Ge(t);if(G.cleanup(H.BINDING,r),n.componentCleanup){try{n.componentCleanup()}catch(e){G.error(H.MOUNT,U.MOUNT.CLEANUP_ERROR(r),e)}n.componentCleanup=void 0}if(n.effects){for(let e of n.effects)try{e.dispose()}catch(e){G.error(H.BINDING,U.CORE.EFFECT_DISPOSE_ERROR(r),e)}mt.release(n.effects),n.effects=void 0}if(n.cleanups){for(let e of n.cleanups)try{e()}catch(e){G.error(H.BINDING,U.BINDING.CLEANUP_ERROR(r),e)}ht.release(n.cleanups),n.cleanups=void 0}gt.release(n)}cleanupDescendants(e){let t=`getElementsByClassName`in e?e.getElementsByClassName(K):e.querySelectorAll(`.${K}`),n=t.length;if(n===0)return;let r=Array(n);for(let e=0;e<n;e++)r[e]=t[e];for(let e=n-1;e>=0;e--){let t=r[e];this.records.has(t)?this.cleanup(t):t.classList.remove(K)}}cleanupTree(e){(e.nodeType===1||e.nodeType===11)&&this.cleanupDescendants(e),this.cleanup(e)}},yt=new Map;function bt(e){if(yt.has(e))return;let t=new MutationObserver(e=>{let t=q;for(let n=0,r=e.length;n<r;n++){let r=e[n].removedNodes;for(let e=0,n=r.length;e<n;e++){let n=r[e];if(n.nodeType!==1||n.isConnected)continue;let i=n;t.isKept(i)||t.isIgnored(i)||t.cleanupTree(i)}}});t.observe(e,{childList:!0,subtree:!0}),yt.set(e,t)}function xt(){yt.forEach(e=>e.disconnect()),yt.clear()}function St(e){return{el:e,trackCleanup:t=>q.trackCleanup(e,t)}}function J(e,t,n={}){let r=!!n.needsCtx,i=e.length;for(let n=0;n<i;n++){let i=e[n];if(i?.nodeType===1){let e=i;t(r?St(e):null,e)}else i&&G.log(H.BINDING,`Skipping non-Element node (nodeType=${i.nodeType})`)}return e}function Ct(e){if(!Array.isArray(e)||e.length!==2)return[e];let t=e[1];return typeof t==`function`||typeof t==`object`&&t&&!Array.isArray(t)&&!(`value`in t)&&!(`then`in t)?e:[e]}var Y=Symbol.for(`atom-effect-internal`),wt=Symbol.for(`atom-effect-wrapped`),Tt=new WeakMap,X=null,Et=e=>{let t=e;if(t[Y])return e;let n=t[wt];if(n)return n;if(n=Tt.get(e),!n){n=function(...t){return Oe(()=>e.apply(this,t))},n[Y]=!0,Tt.set(e,n);try{t[wt]=n}catch{}}return n},Dt=e=>e[wt]??Tt.get(e)??e;function Ot(e){let t={};for(let n in e){let r=e[n];typeof r==`function`?t[n]=Et(r):r!==void 0&&(t[n]=r)}return t}function kt(e){let t={};for(let n in e){let r=e[n];typeof r==`function`?t[n]=Dt(r):t[n]=r}return t}function At(e,t,n){let r=e[0];if(r&&typeof r==`object`)e[0]=t(r);else for(let t=1;t<e.length;t++)typeof e[t]==`function`&&(e[t]=n(e[t]))}function jt(e){return function(...t){return At(t,Ot,Et),e.apply(this,t)??this}}function Mt(){if(X!==null)return;X={on:t.default.fn.on,one:t.default.fn.one,off:t.default.fn.off,remove:t.default.fn.remove,empty:t.default.fn.empty,detach:t.default.fn.detach};let e=X;t.default.fn.remove=function(t){let n=t?this.filter(t):this,r=n.length;for(let e=0;e<r;e++){let t=n[e];t&&(q.markIgnored(t),q.cleanupTree(t))}return e.remove.call(this,t)??this},t.default.fn.empty=function(){let t=this.length;for(let e=0;e<t;e++){let t=this[e];t?.hasChildNodes()&&q.cleanupDescendants(t)}return e.empty.call(this)??this},t.default.fn.detach=function(t){let n=t?this.filter(t):this,r=n.length;for(let e=0;e<r;e++){let t=n[e];t&&q.keep(t)}return e.detach.call(this,t)??this},t.default.fn.on=jt(e.on),t.default.fn.one=jt(e.one),t.default.fn.off=function(...t){return At(t,kt,Dt),e.off.apply(this,t)??this}}function Nt(){X!==null&&(t.default.fn.on=X.on,t.default.fn.one=X.one,t.default.fn.off=X.off,t.default.fn.remove=X.remove,t.default.fn.empty=X.empty,t.default.fn.detach=X.detach,X=null)}var Z=function(e){return e[e.None=0]=`None`,e[e.Focused=1]=`Focused`,e[e.Composing=2]=`Composing`,e[e.SyncingToAtom=4]=`SyncingToAtom`,e[e.SyncingToDom=8]=`SyncingToDom`,e[e.Busy=14]=`Busy`,e}({}),Pt=0;function Ft(e){e[Y]=!0}var It=class{constructor(e,t,n){this.flags=0,this.timeoutId=void 0,this.handleCompositionStart=()=>{this.flags|=Z.Composing},this.handleCompositionEnd=()=>{this.flags&=~Z.Composing,this.handleInput()},this.handleFocus=()=>{this.flags|=Z.Focused},this.handleBlur=()=>{this.flags&=~Z.Focused;let e=!!(this.flags&Z.Composing);this.flags&=~Z.Composing;let t=this.flushPendingDebounce();e&&!t&&this.syncAtomFromDom(),this.normalizeDomValue()},this.syncDomFromAtom=()=>{let e=this.atom.value;this.flags&Z.Busy||A(()=>{if(this.isDomUpToDate(e))return;let t=this.format(e);this.flags|=Z.SyncingToDom;try{this.writeDom(e,t),G.domUpdated(H.BINDING,this.$el,`val`,t)}finally{this.flags&=~Z.SyncingToDom}})},this.cleanup=()=>{this.$el.off(this.ns),clearTimeout(this.timeoutId),this.timeoutId=void 0},this.$el=e,this.el=e[0],this.atom=t;let r=this.el.tagName;this.isMultipleSelect=r===`SELECT`&&this.el.multiple,this.isTextControl=r===`INPUT`||r===`TEXTAREA`,this.ns=`.atomBind-${++Pt}`;let{parse:i,format:a,equal:o,readDom:s,getRawDom:c,writeDom:l}=this.initStrategies(n);this.parse=i,this.format=a,this.equal=o,this.readDom=s,this.getRawDom=c,this.writeDom=l;let u=n.debounce??0;u>0?this.handleInput=()=>{this.flags&Z.Composing||(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>this.syncAtomFromDom(),u))}:this.handleInput=()=>{this.flags&Z.Composing||this.syncAtomFromDom()},[this.handleFocus,this.handleBlur,this.handleCompositionStart,this.handleCompositionEnd,this.handleInput].forEach(Ft),this.bindEvents(n.event??Je.EVENT)}initStrategies(e){let t=e.parse??(e=>e),n=e.equal??Object.is;return this.isMultipleSelect?{parse:t,format:e.format??(e=>(Array.isArray(e)?e:e?[String(e)]:[]).join(`,`)),getRawDom:()=>this.$el.val()||[],readDom:()=>this.$el.val()||[],writeDom:e=>{this.$el.val(e)},equal:(e,t)=>{if(n(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t)){let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!Object.is(e[r],t[r]))return!1;return!0}return!1}}:{parse:t,format:e.format??(e=>String(e??``)),equal:n,readDom:()=>t(this.el.value),getRawDom:()=>this.el.value,writeDom:this.isTextControl?(e,t)=>this.writeTextValue(t):(e,t)=>{this.el.value=t}}}writeTextValue(e){let t=this.el;if(this.flags&Z.Focused)try{let n=t.selectionStart,r=t.selectionEnd;t.value=e;let i=e.length;n!==null&&r!==null&&t.setSelectionRange(Math.min(n,i),Math.min(r,i))}catch{t.value=e}else t.value=e}flushPendingDebounce(){return this.timeoutId===void 0?!1:(clearTimeout(this.timeoutId),this.timeoutId=void 0,this.syncAtomFromDom(),!0)}normalizeDomValue(){let e=this.atom.peek(),t=this.format(e),n=this.getRawDom();this.isMultipleSelect?this.equal(n,e)||this.writeDom(e,t):n!==t&&this.writeDom(e,t)}syncAtomFromDom(){if(!(this.flags&Z.Busy)){this.flags|=Z.SyncingToAtom;try{let e=this.readDom();this.equal(this.atom.peek(),e)||(this.atom.value=e)}catch(e){G.warn(H.BINDING,U.BINDING.PARSE_ERROR(e instanceof Error?e.message:String(e)),e)}finally{this.flags&=~Z.SyncingToAtom}}}isDomUpToDate(e){let t=this.getRawDom();if(this.isMultipleSelect)return this.equal(t,e);if(t===this.format(e))return!0;if(this.flags&Z.Focused)try{return this.equal(this.readDom(),e)}catch{}return!1}bindEvents(e){let t=this.ns,n=e.trim().split(/\s+/).map(e=>`${e}${t}`).join(` `);this.$el.on(`focus${t}`,this.handleFocus).on(`blur${t}`,this.handleBlur).on(`compositionstart${t}`,this.handleCompositionStart).on(`compositionend${t}`,this.handleCompositionEnd).on(n,this.handleInput)}};function Lt(e,t,n){let r=new It(e,t,n);return{fx:z(r.syncDomFromAtom),cleanup:()=>{r&&=(r.cleanup(),null)}}}function Rt(e,t,n,r){let i={latestId:0,isDisposed:!1};q.trackCleanup(e,()=>{i.isDisposed=!0});let a=t=>{if(!We(t)){i.latestId++,A(()=>{try{n(t),G.domUpdated(H.BINDING,e,r,t)}catch(e){G.error(H.BINDING,U.BINDING.UPDATER_ERROR(r,!0),e)}});return}let a=++i.latestId;t.then(t=>{a===i.latestId&&!i.isDisposed&&A(()=>{try{n(t),G.domUpdated(H.BINDING,e,`${r} (async)`,t)}catch(e){G.error(H.BINDING,U.BINDING.UPDATER_ERROR(r),e)}})}).catch(e=>{a===i.latestId&&!i.isDisposed&&G.error(H.BINDING,U.BINDING.UPDATER_ERROR(r),e)})},o=Ue(t);o||typeof t==`function`?q.trackEffect(e,z(()=>{a(o?t.value:t())},{name:r})):a(t)}function zt(e,t,n,r){let i=Object.keys(t),a=[],o=[],s=[],c={};for(let e=0,n=i.length;e<n;e++){let n=i[e],r=t[n],l=Ue(r);l||typeof r==`function`?(a.push(n),o.push(r),s.push(l)):c[n]=r}let l={latestId:0,isDisposed:!1,cache:{}};q.trackCleanup(e,()=>{l.isDisposed=!0});let u=t=>{let a=[],o={},s=i.length;for(let e=0;e<s;e++){let n=i[e],r=t[n];if(We(r)&&V.call(l.cache,n)){let e=l.cache[n];if(e.p===r){o[n]=e.v;continue}}We(r)?a.push(r.then(e=>(l.cache[n]={p:r,v:e},{key:n,val:e}))):o[n]=r}if(a.length>0){let t=++l.latestId;Promise.all(a).then(i=>{if(t===l.latestId&&!l.isDisposed){for(let e=0,t=i.length;e<t;e++){let t=i[e];o[t.key]=t.val}A(()=>{try{n(o),G.domUpdated(H.BINDING,e,`${r} (async)`,o)}catch(e){G.error(H.BINDING,U.BINDING.UPDATER_ERROR(r),e)}})}},e=>{t===l.latestId&&!l.isDisposed&&G.error(H.BINDING,U.BINDING.UPDATER_ERROR(r),e)})}else l.latestId++,A(()=>{try{n(o),G.domUpdated(H.BINDING,e,r,o)}catch(e){G.error(H.BINDING,U.BINDING.UPDATER_ERROR(r,!0),e)}})};a.length>0?q.trackEffect(e,z(()=>{let e={...c};for(let t=0,n=a.length;t<n;t++){let n=o[t];e[a[t]]=s[t]?n.value:n()}u(e)},{name:r})):u(c)}var Bt=new Set([`href`,`src`,`action`,`formaction`,`xlink:href`,`data`,`poster`,`background`,`cite`,`longdesc`,`profile`,`usemap`,`classid`,`codebase`,`fill`,`filter`,`mask`,`marker-start`,`marker-mid`,`marker-end`,`clip-path`,`srcdoc`]),Vt={colon:`:`,tab:` `,newline:`
|
|
10
|
-
`},Ht=/&#x([0-9a-f]+);?|&#([0-9]+);?/gi,Ut=/&(colon|tab|newline);?/gi,Wt=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,Gt=/[<&\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,Kt=/<\?[\s\S]*?\?>/g,qt=/(<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript|form|style|link)\b[^>]*\/?>)/gi,Jt=/\bon\w+\s*=/gim,Yt=`${Qe}\\s*:`,Xt=new RegExp(Yt,`gi`),Zt=RegExp(`(?:^|url\\s*\\(\\s*["']?)\\s*${Yt}`,`i`),Qt=/data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/gi,$t=`(?:expression\\s*\\(|behavior\\s*:|-moz-binding\\s*:|url\\s*\\(\\s*["']?\\s*${Yt}(?!image\\/)|data\\s*:\\s*(?!image\\/))`,en=new RegExp($t,`gim`),tn=new RegExp($t,`im`);function nn(e){return typeof e==`string`?e.replace(Ht,(e,t,n)=>{let r=t?parseInt(t,16):parseInt(n,10);return r>=0&&r<=1114111?String.fromCodePoint(r):``}).replace(Ut,(e,t)=>Vt[t.toLowerCase()]??``).replace(Wt,``):``}function rn(e){return Zt.test(e)||Qt.test(e)}function an(e){return qt.test(e)||Jt.test(e)||Xt.test(e)}function on(e){if(Gt.test(e)||e.includes(`:`))return!0;let t=e.toLowerCase(),n=t.indexOf(`on`);for(;n!==-1&&n<e.length-2;){let e=t.charCodeAt(n+2);if(e>=97&&e<=122)return!0;n=t.indexOf(`on`,n+1)}return!1}function Q(e){if(!e)return``;let t=String(e);if(!on(t))return t;let n=nn(t);if(n.includes(`<`)){n=n.replace(Kt,``);let e;do e=n,n=n.replace(qt,``);while(n!==e)}return n.replace(en,`data-unsafe-css:`).replace(Xt,`data-unsafe-protocol:`).replace(Qt,`data-unsafe-protocol:`).replace(Jt,`data-unsafe-attr=`)}var sn=(e,t)=>{let n=e.toLowerCase();if(!Bt.has(n))return!1;let r=nn(t);return n===`srcdoc`?an(r):rn(r)},cn=e=>tn.test(nn(e)),ln=new Map;function un(e){let t=ln.get(e);return t===void 0?(t=e.includes(`-`)?e.replace(/-./g,e=>e[1].toUpperCase()):e,ln.set(e,t),t):t}var dn=new WeakMap;function fn(e){let t=dn.get(e);return t||(t=Fe(()=>{let t=e.value;return We(t)?t.then(e=>Q(e)):Q(t)}),dn.set(e,t)),t}function pn(e,t){return e.toLowerCase().startsWith(`on`)?(console.warn(`${H.BINDING} ${U.SECURITY.BLOCKED_EVENT_HANDLER(e)}`),!1):t&&Ze.has(e)?(console.warn(`${H.BINDING} ${U.SECURITY.BLOCKED_PROP(e)}`),!1):!0}function mn({el:e},t,n){Rt(e,t,t=>{let r=n?n(t):String(t??``);e.textContent!==r&&(e.textContent=r)},`text`)}function hn({el:e},t){let n=fe(t)?fn(t):t,r=null;Rt(e,n,i=>{let a=n===t?Q(i):i;r!==a&&(q.cleanupDescendants(e),e.innerHTML=a,r=a)},`html`)}function gn({el:e},t){let n={},r={};for(let e in t)if(V.call(t,e)){let t=e.trim();n[e]=/\s/.test(t)?t.split(/\s+/).filter(Boolean):[t]}zt(e,t,t=>{for(let i in t){let a=!!t[i];if(r[i]===a)continue;let o=n[i];if(a)e.classList.add(...o);else for(let r of o){let a=!1;for(let e in t)if(e!==i&&t[e]&&n[e].includes(r)){a=!0;break}a||e.classList.remove(r)}r[i]=a}},`class`)}function _n({el:e},t){let n=e.style,r={},i={},a={};for(let e in t)if(V.call(t,e)){let n=t[e],[a,o]=Array.isArray(n)?n:[n,``];r[e]=a,i[e]={camel:un(e),unit:o}}zt(e,r,e=>{for(let t in e){let r=i[t],o=e[t],s=r.unit?`${o}${r.unit}`:String(o),c=r.camel;a[t]!==s&&(cn(s)||(n[c]=s),a[t]=s)}},`css`)}function vn({el:e},t){let n={},r={},i={};for(let a in t){if(!V.call(t,a)||!pn(a,!1))continue;let o=a.toLowerCase();n[a]=t[a],r[a]={isAria:o.startsWith(`aria-`)},i[a]=e.getAttribute(a)}zt(e,n,t=>{for(let n in t){let a=r[n],o=t[n];if(o==null||o===!1&&!a.isAria){i[n]!==null&&e.removeAttribute(n),i[n]=null;continue}let s=o===!0?a.isAria?`true`:n:String(o);if(sn(n,s)){console.warn(`${H.BINDING} ${U.SECURITY.BLOCKED_PROTOCOL(n)}`);continue}i[n]!==s&&(e.setAttribute(n,s),i[n]=s)}},`attr`)}function yn(e,t){let n=e.el,r={},i={};for(let e in t)V.call(t,e)&&pn(e,!0)&&(r[e]=t[e]);zt(e.el,r,e=>{for(let t in e){let r=e[t];if(i[t]!==r){if(typeof r==`string`&&sn(t,r)){console.warn(`${H.BINDING} ${U.SECURITY.BLOCKED_PROTOCOL(t)}`);continue}n[t]=r,i[t]=r}}},`prop`)}function bn({el:e},t,n){let r=e.style.display===`none`?``:e.style.display;Rt(e,t,t=>{n===!!t?e.style.display!==`none`&&(r=e.style.display,e.style.display=`none`):e.style.display===`none`&&(e.style.display=r)},n?`hide`:`show`)}function xn(e,n,r={}){let i=e.el.tagName.toLowerCase();if(!Xe.has(i)){console.warn(`${H.BINDING} ${U.BINDING.INVALID_INPUT_ELEMENT(i)}`);return}let{fx:a,cleanup:o}=Lt((0,t.default)(e.el),n,r);q.trackEffect(e.el,a),e.trackCleanup(o)}function Sn(e){e.type===`radio`&&e.name&&(e.form?(0,t.default)(e.form):(0,t.default)(document)).find(`input[type="radio"][name="${t.default.escapeSelector(e.name)}"]`).not(e).trigger(`change.atomRadioSync`)}function Cn(e,n){let r=e.el,i=(0,t.default)(r),a=()=>{n.peek()!==r.checked&&(n.value=r.checked,Sn(r))};a[Y]=!0,i.on(`change change.atomRadioSync`,a),e.trackCleanup(()=>i.off(`change change.atomRadioSync`,a)),q.trackEffect(r,z(()=>{let e=!!n.value;A(()=>{r.checked!==e&&(r.checked=e,G.domUpdated(H.BINDING,r,`checked`,e),e&&Sn(r))})}))}function wn(e,n){let r=(0,t.default)(e.el);r.on(n),e.trackCleanup(()=>r.off(n))}function Tn({el:e,trackCleanup:n},r,i){let a=(0,t.default)(e);a.on(r,i),n(()=>a.off(r,i))}function En(e){q.cleanupTree(e)}var Dn=`input, select, textarea`,On=class{constructor(e,t,n={}){this.form=e,this.atom=t,this.options=n,this.fieldMap=new Map,this.fields=[],this.elementNames=new WeakMap,this.isSyncingFromLeaf=!1,this.init()}init(){let e=z(()=>{let e=this.atom.value;this.isSyncingFromLeaf||!this.fields.length||Oe(()=>{A(()=>{for(let t=0;t<this.fields.length;t++){let n=this.fields[t],r=B(e,n.parts);Object.is(n.atom.peek(),r)||(n.atom.value=r)}})})});q.trackEffect(this.form,e),this.bindElement(this.form),this.setupObserver()}bindElement(e){let t=e.matches?.(Dn)?[e]:e.querySelectorAll?.(Dn)||[];for(let e=0,n=t.length;e<n;e++)this.bindControl(t[e])}bindControl(e){if(!(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement))return;let t=e,n=t.name;if(!n)return;let r=this.elementNames.get(t);if(r!==void 0&&r!==n&&q.cleanup(t),this.elementNames.has(t)&&r===n)return;let i=this.acquireField(n);this.elementNames.set(t,n);let a=St(t);a.trackCleanup(()=>this.releaseField(t,n)),t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`)?this.bindToggle(a,i.atom,t.value,t.type===`checkbox`):xn(a,i.atom,this.options)}bindToggle(e,n,r,i){let a=e.el,o=()=>{let e=n.peek();if(i&&Array.isArray(e)){let t=new Set(e.map(String));a.checked?t.add(r):t.delete(r),n.value=Array.from(t)}else n.value=i?a.checked:r};o[Y]=!0,(0,t.default)(a).on(`change`,o),e.trackCleanup(()=>(0,t.default)(a).off(`change`,o)),q.trackEffect(a,z(()=>{let e=n.value,t=i?Array.isArray(e)?e.some(e=>String(e)===r):!!e:String(e)===r;a.checked!==t&&(a.checked=t)}))}acquireField(e){let t=this.fieldMap.get(e);if(t)return t.refCount++,t;let n=e.replace(/\[(\w+)\]/g,`.$1`).split(`.`).filter(Boolean),r=Ae(B(this.atom.peek(),n));return t={atom:r,parts:n,name:e,refCount:1,effect:null},t.effect=z(()=>{let t=r.value;this.options.transform&&(t=this.options.transform(e,t));let i=this.atom.peek(),a=Re(i,n,0,t);if(a!==i){this.isSyncingFromLeaf=!0;try{this.atom.value=a,this.options.onChange&&A(()=>this.options.onChange(e,t))}finally{this.isSyncingFromLeaf=!1}}}),this.fieldMap.set(e,t),this.fields.push(t),t}releaseField(e,t){let n=this.fieldMap.get(t);if(n&&--n.refCount<=0){let e=this.fields.indexOf(n);e!==-1&&this.fields.splice(e,1),n.effect?.dispose(),this.fieldMap.delete(t)}q.cleanup(e)}setupObserver(){let e=new MutationObserver(e=>{for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n.type===`childList`)for(let e=0;e<n.addedNodes.length;e++){let t=n.addedNodes[e];t.nodeType===1&&this.bindElement(t)}else n.attributeName===`name`&&this.bindElement(n.target)}});e.observe(this.form,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`name`]}),q.trackCleanup(this.form,()=>e.disconnect())}};function kn(e,t,n={}){new On(e,t,n)}t.default.fn.atomText=function(e,t){return J(this,n=>mn(n,e,t),{needsCtx:!0})},t.default.fn.atomHtml=function(e){return J(this,t=>hn(t,e),{needsCtx:!0})},t.default.fn.atomClass=function(e,t){let n=typeof e==`string`?t===void 0?null:{[e]:t}:e;return n?J(this,e=>gn(e,n),{needsCtx:!0}):(console.warn(`${H.BINDING} ${U.BINDING.MISSING_CONDITION(`atomClass`)}`),this)},t.default.fn.atomCss=function(e,t,n){let r=typeof e==`string`?t===void 0?null:{[e]:n?[t,n]:t}:e;return r?J(this,e=>_n(e,r),{needsCtx:!0}):(console.warn(`${H.BINDING} ${U.BINDING.MISSING_SOURCE(`atomCss`)}`),this)},t.default.fn.atomAttr=function(e,t){let n=typeof e==`string`?t===void 0?null:{[e]:t}:e;return n?J(this,e=>vn(e,n),{needsCtx:!0}):(console.warn(`${H.BINDING} ${U.BINDING.MISSING_SOURCE(`atomAttr`)}`),this)},t.default.fn.atomProp=function(e,t){let n=typeof e==`string`?t===void 0?null:{[e]:t}:e;return n?J(this,e=>yn(e,n),{needsCtx:!0}):(console.warn(`${H.BINDING} ${U.BINDING.MISSING_SOURCE(`atomProp`)}`),this)},t.default.fn.atomShow=function(e){return J(this,t=>bn(t,e,!1),{needsCtx:!0})},t.default.fn.atomHide=function(e){return J(this,t=>bn(t,e,!0),{needsCtx:!0})},t.default.fn.atomVal=function(e,t={}){return J(this,n=>xn(n,e,t),{needsCtx:!0})},t.default.fn.atomChecked=function(e){return J(this,t=>Cn(t,e),{needsCtx:!0})},t.default.fn.atomForm=function(e,t={}){return J(this,(n,r)=>{r instanceof HTMLFormElement?kn(r,e,t):G.log(H.BINDING,`Skipping non-Form element for atomForm`)},{needsCtx:!1})},t.default.fn.atomOn=function(e,t){return J(this,n=>Tn(n,e,t),{needsCtx:!0})};var An=[(e,t)=>mn(e,...Ct(t.text)),(e,t)=>hn(e,t.html),(e,t)=>gn(e,t.class),(e,t)=>_n(e,t.css),(e,t)=>vn(e,t.attr),(e,t)=>yn(e,t.prop),(e,t)=>bn(e,t.show,!1),(e,t)=>bn(e,t.hide,!0),(e,t)=>xn(e,...Ct(t.val)),(e,t)=>Cn(e,t.checked),(e,t)=>{e.el instanceof HTMLFormElement&&kn(e.el,...Ct(t.form))},(e,t)=>wn(e,t.on)];t.default.fn.atomBind=function(e){let t=0;return e.text!==void 0&&(t|=1),e.html!==void 0&&(t|=2),e.class!==void 0&&(t|=4),e.css!==void 0&&(t|=8),e.attr!==void 0&&(t|=16),e.prop!==void 0&&(t|=32),e.show!==void 0&&(t|=64),e.hide!==void 0&&(t|=128),e.val!==void 0&&(t|=256),e.checked!==void 0&&(t|=512),e.form!==void 0&&(t|=1024),e.on!==void 0&&(t|=2048),t===0?this:J(this,n=>{let r=t;for(;r>0;){let t=r&-r;An[31-Math.clz32(t)](n,e),r^=t}},{needsCtx:!0})},t.default.fn.atomUnbind=function(){return J(this,(e,t)=>En(t),{needsCtx:!1})};function jn(e){return e instanceof Element?(0,t.default)(e):e}function Mn(e,t){if(e instanceof Element)t===null?e.removeAttribute(`data-atom-key`):e.setAttribute(`data-atom-key`,t);else if(!e.nodeType){let n=e;for(let e=0,r=n.length;e<r;e++){let r=n[e];r instanceof Element&&(t===null?r.removeAttribute(`data-atom-key`):r.setAttribute(`data-atom-key`,t))}}}function Nn(e){if(e instanceof Element)q.cleanupTree(e);else for(let t=0,n=e.length;t<n;t++){let n=e[t];n instanceof Element&&q.cleanupTree(n)}}var Pn=class{constructor(e,t,n){this.$container=e,this.containerSelector=t,this.onRemove=n,this.oldKeys=[],this.oldItems=[],this.oldNodes=[],this.removingKeys=new Set,this.$emptyEl=null,this.keyToIndex=new Map,this.statesBuffer=new Uint8Array(256),this.indicesBuffer=new Int32Array(256)}scheduleRemoval(e,t){let n=()=>{this.fx?.isDisposed||t[0]instanceof Element&&t[0].hasAttribute(`data-atom-key`)||(t[0]?.isConnected&&t.remove(),this.removingKeys.delete(e),G.log(H.LIST,`${this.containerSelector} removed item:`,e))},r=this.onRemove?.(t);r instanceof Promise?r.then(n,n):n()}removeItem(e,t){Mn(t,null),this.removingKeys.add(e),this.scheduleRemoval(e,t)}dispose(){this.removingKeys.clear(),this.oldKeys.length=0,this.oldItems.length=0,this.oldNodes.length=0,this.keyToIndex.clear(),this.$emptyEl?.remove(),this.$container.off(`.atomList`),this.statesBuffer=new Uint8Array,this.indicesBuffer=new Int32Array}ensureBuffers(e){this.statesBuffer.length<e&&(this.statesBuffer=new Uint8Array(Math.max(e,this.statesBuffer.length*2))),this.indicesBuffer.length<e&&(this.indicesBuffer=new Int32Array(Math.max(e,this.indicesBuffer.length*2)))}};function Fn(e,t,n,r,i,a,o){let{oldKeys:s,oldItems:c,oldNodes:l,removingKeys:u,keyToIndex:d}=e,f=s.length,p=0,m=f-1,h=n-1,g=a||Ke;for(;p<=m&&p<=h;){let e=t[p],n=r(e,p);if(s[p]!==n||!g(c[p],e)||!l[p])break;d.set(n,p++)}for(;m>=p&&h>=p;){let e=t[h],n=r(e,h);if(s[m]!==n||!g(c[m],e)||!l[m])break;d.set(n,h--),m--}let ee=o.map.acquire();for(let e=p;e<=m;e++)ee.set(s[e],e);let _=o.set.acquire();e.ensureBuffers(n);let v=o.array.acquire();v.length=n;let y=o.array.acquire();y.length=n;let b=o.array.acquire();b.length=n;let x=e.statesBuffer,S=e.indicesBuffer,C=o.array.acquire(),w=o.array.acquire(),T=o.array.acquire();for(let e=0;e<p;e++){let n=s[e];v[e]=n,y[e]=t[e],b[e]=l[e],x[e]=3,S[e]=e,_.add(n)}for(let e=f-1,r=n-1;r>h;r--,e--){let n=s[e];v[r]=n,y[r]=t[r],b[r]=l[e],x[r]=3,S[r]=e,_.add(n)}for(let n=p;n<=h;n++){let o=t[n],s=r(o,n);if(v[n]=s,y[n]=o,d.set(s,n),_.has(s)){G.warn(H.LIST,U.LIST.DUPLICATE_KEY(s,n,e.containerSelector)),S[n]=-1;continue}_.add(s);let f=ee.get(s);if(f===void 0){C.push(s),w.push(o),T.push(n),S[n]=-1,x[n]=1;continue}let p=c[f];b[n]=l[f],!i&&p!==o&&!(a?a(p,o):Ke(p,o))?(C.push(s),w.push(o),T.push(n),x[n]=2):x[n]=0,S[n]=u.has(s)?-1:f}return o.map.release(ee),{newKeys:v,newKeySet:_,newItems:y,newNodes:b,newStates:x,newIndices:S,trKeys:C,trItems:w,trIdxs:T,startIndex:p,oldEndIndex:m,newEndIndex:h}}var In=0;function Ln(e,t,n){if(!e)return;if(e instanceof Element){n.insertBefore(e,t);return}let r=e.length;for(let i=0;i<r;i++){let r=e[i];r&&n.insertBefore(r,t)}}function Rn(e,n,r,i,a){if(e.$emptyEl&&n>0&&(e.$emptyEl.remove(),e.$emptyEl=null),n!==0)return;let{oldKeys:o,oldNodes:s,onRemove:c}=e;if(c)for(let t=0,n=o.length;t<n;t++){let n=o[t];s[t]&&e.removeItem(n,jn(s[t]))}else{for(let t=0,n=o.length;t<n;t++)e.removingKeys.delete(o[t]);r.empty()}i&&!e.$emptyEl&&(e.$emptyEl=typeof i==`string`?(0,t.default)(Q(i)):(0,t.default)(i),e.$emptyEl.appendTo(r)),a.release(e.oldKeys),a.release(e.oldItems),a.release(e.oldNodes),e.oldKeys=[],e.oldItems=[],e.oldNodes=[]}function zn(e,n,r){let{trKeys:i,trItems:a,trIdxs:o,newNodes:s,newStates:c}=e,l=i.length,u=Array(l),d=[],f=0;for(let e=0;e<l;e++){let t=n.render(a[e],o[e]);u[e]=t,typeof t==`string`&&(d.push(t),f++)}let p=null;if(d.length>0)if(d.length===1)p=[Q(d[0])];else{let e=`<template data-atom-sep="${(In++).toString(36)}"></template>`;p=Q(d.join(e)).split(e)}if(r&&p&&f===l&&!n.bind&&!n.onAdd&&!n.onRemove&&!n.events&&t.default.parseHTML(p.join(``)).length===l)return p;let m=0;for(let e=0;e<l;e++){let n=u[e],r=typeof n==`string`?(0,t.default)(t.default.parseHTML(p[m++])):(0,t.default)(n),a=o[e];if(Mn(r,String(i[e])),c[a]===2&&s[a]){let e=s[a];Nn(e);let t=jn(e);t.first().before(r),t.remove()}s[a]=r.length===1?r[0]:r}return null}function Bn(e,t){let{startIndex:n,oldEndIndex:r,newKeySet:i}=t;for(let t=n;t<=r;t++){let n=e.oldKeys[t];!i.has(n)&&e.oldNodes[t]&&e.removeItem(n,jn(e.oldNodes[t]))}}function Vn(e,n,r,i,a){let{newKeys:o,newItems:s,newNodes:c,newStates:l,newIndices:u}=n,d=o.length;if(a!==null){r.innerHTML=a.join(``);let n=r.firstElementChild;for(let r=0;r<d&&n;r++)n.setAttribute(`data-atom-key`,String(o[r])),c[r]=n,l[r]=0,e.removingKeys.delete(o[r]),G.domUpdated(H.LIST,(0,t.default)(n),`list.add`,s[r]),n=n.nextElementSibling;return}if(e.oldKeys.length===0&&e.removingKeys.size===0){let e=document.createDocumentFragment();for(let t=0;t<d;t++){let n=c[t];if(n)if(n instanceof Element)e.appendChild(n);else for(let t=0;t<n.length;t++)e.appendChild(n[t])}r.innerHTML=``,r.appendChild(e)}else{let e=null,t=2147483647;for(let n=d-1;n>=0;n--){let i=u[n],a=c[n];a&&(i!==-1&&i<t?t=i:Ln(a,e,r),e=a instanceof Element?a:a[0]??null)}}for(let t=0;t<d;t++){let n=l[t];if(n!==3){let r=c[t];if(!r)continue;let a=jn(r),l=s[t];n===0?i.update?.(a,l,t):i.bind?.(a,l,t),n===1&&(i.onAdd?.(a),e.removingKeys.delete(o[t]),G.domUpdated(H.LIST,a,`list.add`,l))}}}var Hn=new WeakMap,Un=new ft(()=>new Map,e=>e.clear()),Wn=new ft(()=>new Set,e=>e.clear()),$=new dt(100,1024),Gn={map:Un,set:Wn,array:$};function Kn(e,n){let r=typeof n.key==`function`?n.key:e=>e[n.key],i={bind:n.bind,update:n.update,onAdd:n.onAdd,onRemove:n.onRemove,events:n.events};for(let a=0,o=this.length;a<o;a++){let o=this[a],s=(0,t.default)(o);s.off(`.atomList`);let c=Hn.get(o);c&&(c.fx.dispose(),c.ctx.dispose());let l=new Pn(s,Ge(o),n.onRemove),u=z(()=>{let t=e.value,a=t.length;A(()=>{if(Rn(l,a,s,n.empty,$),a===0)return;G.log(H.LIST,`${l.containerSelector} updating with ${a} items`);let e=Fn(l,t,a,r,n.update,n.isEqual,Gn),c=zn(e,n,l.oldKeys.length===0);if(Bn(l,e),Vn(l,e,o,i,c),n.events)for(let t=e.startIndex;t<=e.oldEndIndex;t++)e.newKeySet.has(l.oldKeys[t])||l.keyToIndex.delete(l.oldKeys[t]);$.release(l.oldKeys),$.release(l.oldItems),$.release(l.oldNodes),l.oldKeys=e.newKeys,l.oldItems=e.newItems,l.oldNodes=e.newNodes,Wn.release(e.newKeySet),$.release(e.trKeys),$.release(e.trItems),$.release(e.trIdxs)})});if(l.fx=u,n.events)for(let e in n.events){if(!V.call(n.events,e))continue;let t=e.indexOf(` `),r=t===-1?e:e.slice(0,t),i=t===-1?`> *`:e.slice(t+1).trim(),a=n.events[e];s.on(`${r}.atomList`,i,function(e){let t=e.target.closest?.(`[data-atom-key]`),n=t?.getAttribute(`data-atom-key`);if(n==null)return;let r=n;if(!l.keyToIndex.has(n)){let e=Number(n);!Number.isNaN(e)&&l.keyToIndex.has(e)&&(r=e)}let i=l.keyToIndex.get(r);i!==void 0&&a.call(t,l.oldItems[i],i,e)})}q.trackEffect(o,u),Hn.set(o,{fx:u,ctx:l}),q.trackCleanup(o,()=>{l.dispose(),Hn.delete(o)})}return this}t.default.fn.atomList=Kn;var qn=Object.freeze({});t.default.fn.atomMount=function(e,n){let r=n??qn,i=e.name||`Component`;return J(this,(n,a)=>{q.cleanupTree(a);try{let n=A(()=>Oe(()=>e((0,t.default)(a),r)));typeof n==`function`&&q.setComponentCleanup(a,n)}catch(e){G.error(H.MOUNT,U.MOUNT.ERROR(i),e)}})},t.default.fn.atomUnmount=function(){return J(this,(e,t)=>En(t))};function Jn(e,t){try{history.pushState(e,``,t)}catch(e){G.warn(H.ROUTE,`PushState failed (likely file:// protocol or security restriction). UI will update, but URL will not.`,e)}}var Yn=class{parseQueryParams(e){let t={};return e&&new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}constructor(e){this.isDestroyed=!1,this.previousRoute=``,this.cleanups=[],this.templateCache=new Map,this.routeCleanups=[],this.lastRawQuery=``,this.cachedParams={},this.config={mode:qe.mode,basePath:qe.basePath,autoBindLinks:qe.autoBindLinks,activeClass:qe.activeClass,notFound:e.notFound||``,beforeTransition:e.beforeTransition||(()=>{}),afterTransition:e.afterTransition||(()=>{}),...e},this.isHistoryMode=this.config.mode===`history`,this.basePath=this.config.basePath.replace(/\/$/,``),this.activeClass=this.config.activeClass,this.$target=(0,t.default)(this.config.target),this.previousUrl=this.isHistoryMode?location.pathname+location.search:location.hash,this.currentRouteAtom=Ae(this.getRouteName()),this.currentRoute=this.currentRouteAtom,this.queryParamsAtom=Ae(this.getQueryParams()),this.queryParams=Fe(()=>this.queryParamsAtom.value),this.init()}init(){let e=this.isHistoryMode?`popstate`:`hashchange`,t=this.handleUrlChange.bind(this);window.addEventListener(e,t),this.cleanups.push(()=>window.removeEventListener(e,t));let n=z(()=>{let e=this.currentRouteAtom.value;A(()=>{for(let e of this.routeCleanups)try{e()}catch{}this.routeCleanups.length=0}),this.renderRoute(e)});this.cleanups.push(()=>n.dispose()),this.setupAutoBindLinks(),this.$target[0]&&q.trackCleanup(this.$target[0],()=>this.destroy())}getRouteName(){let{default:e}=this.config;if(this.isHistoryMode){let t=this.basePath,n=location.pathname;return t&&(n===t||n.startsWith(`${t}/`))&&(n=n.substring(t.length)),n.replace(/^\/+/,``)||e}let t=location.hash,{route:n}=this.splitPath(t.startsWith(`#`)?t.substring(1):t);return n||e}getQueryParams(){let e=this.getCurrentRawQuery();if(e===this.lastRawQuery)return this.cachedParams;this.lastRawQuery=e;let t=this.parseQueryParams(e);return this.areParamsEqual(t,this.cachedParams)?this.cachedParams:(e.indexOf(`%`),this.cachedParams=t,t)}getCurrentRawQuery(){if(this.isHistoryMode)return location.search.substring(1);let e=location.hash,t=e.indexOf(`?`);return t===-1?``:e.substring(t+1)}areParamsEqual(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}splitPath(e){let t=e.indexOf(`?`),n=t===-1?e:e.slice(0,t),r=t===-1?void 0:e.slice(t+1);return{route:n.replace(/^\/+/,``),query:r}}setUrl(e){let{route:t,query:n}=this.splitPath(e),r=n?`${t}?${n}`:t,i=this.isHistoryMode?`${this.basePath}/${r}`:`#${r}`;this.isHistoryMode?Jn(null,i):location.hash=i,this.previousUrl=this.isHistoryMode?i:location.hash}restoreUrl(){try{this.isHistoryMode?history.replaceState(null,``,this.previousUrl):location.hash=this.previousUrl}catch(e){G.warn(H.ROUTE,`Restore URL failed`,e)}}renderRoute(e){if(this.isDestroyed||!this.$target[0])return;let{routes:t,notFound:n,beforeTransition:r,afterTransition:i}=this.config,a=t[e]??(n?t[n]:void 0);if(!a){G.warn(H.ROUTE,U.ROUTE.NOT_FOUND(e));return}let o=this.getQueryParams(),s=this.previousRoute;r&&A(()=>r(s,e)),this.$target.empty();let c=o;if(a.onEnter){let e=A(()=>a.onEnter(o,this));e&&(c={...o,...e})}let l=e=>this.routeCleanups.push(e);if(a.render)a.render(this.$target[0],e,c,l,this);else if(a.template){let e=this.templateCache.get(a.template);if(!e){let t=document.querySelector(a.template);if(t instanceof HTMLTemplateElement)e=t,this.templateCache.set(a.template,e);else{G.warn(H.ROUTE,U.ROUTE.TEMPLATE_NOT_FOUND(a.template));return}}this.$target.append(e.content.cloneNode(!0)),a.onMount&&a.onMount(this.$target.children(),l,this)}i&&A(()=>i(s,e)),this.previousRoute=e}handleUrlChange(){if(this.isDestroyed)return;let e=this.isHistoryMode?location.pathname+location.search:location.hash;if(e===this.previousUrl)return;let t=this.getRouteName(),n=this.currentRouteAtom.peek();if(n!==t){if(A(()=>this.config.routes[n]?.onLeave?.(this))===!1){this.restoreUrl();return}this.currentRouteAtom.value=t}this.queryParamsAtom.value=this.getQueryParams(),this.previousUrl=e}setupAutoBindLinks(){if(!this.config.autoBindLinks)return;let e=e=>{e.preventDefault();let t=e.currentTarget.dataset.route;t!=null&&this.navigate(t)};(0,t.default)(document).on(`click`,`[data-route]`,e),this.cleanups.push(()=>(0,t.default)(document).off(`click`,`[data-route]`,e));let n=[],r=z(()=>{let e=this.currentRouteAtom.value,t=this.activeClass;A(()=>{for(let e of n)e.classList.remove(t),e.removeAttribute(`aria-current`);try{let r=`[data-route="${e.replace(/"/g,`\\"`)}"]`,i=Array.from(document.querySelectorAll(r));for(let e of i)e.classList.add(t),e.setAttribute(`aria-current`,`page`);n=i}catch{n=[]}})});this.cleanups.push(()=>{r.dispose(),n.length=0})}navigate(e){if(this.isDestroyed)return;let n=this.currentRouteAtom.peek();if(this.config.routes[n]?.onLeave?.(this)===!1)return;let{route:r,query:i}=this.splitPath(e),a=r||this.config.default||``;a&&t.default.batch(()=>{this.setUrl(e);let t=i?this.parseQueryParams(i):{};this.areParamsEqual(t,this.queryParamsAtom.peek())||(this.queryParamsAtom.value=t),this.currentRouteAtom.value=a})}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(let e of this.cleanups)try{e()}catch{}this.cleanups.length=0,this.templateCache.clear()}}};function Xn(e){return new Yn(e)}t.default.extend({route:Xn});var Zn=class{constructor(e,n){this.abortController=null,this.execute=async()=>{this.abort();let e=new AbortController;this.abortController=e;let{signal:n}=e,r;try{let e=this.prepareSettings(),i=t.default.ajax(e);r=()=>i.abort(),n.addEventListener(`abort`,r),n.aborted&&i.abort();let a=await i;return this.transformFn?this.transformFn(a):a}catch(e){if(n.aborted)throw this.createAbortError();return this.handleError(e)}finally{r&&n.removeEventListener(`abort`,r),this.abortController===e&&(this.abortController=null)}};let r=typeof e==`string`;this.isStaticUrl=r,r?(this.staticUrl=e,this.getUrl=()=>this.staticUrl):this.getUrl=e,this.ajaxOptionsFn=typeof n.ajaxOptions==`function`?n.ajaxOptions:void 0;let i=typeof n.ajaxOptions==`object`?n.ajaxOptions:{};this.staticOptions={...i,headers:{...i?.headers,...n.headers}},n.method&&(this.staticOptions.method=n.method),this.transformFn=n.transform,this.onErrorFn=n.onError}abort(){this.abortController?.abort()}handleError(e){let t;if(e&&e.readyState!==void 0){let n=e;t=Error(`Network Error: ${n.statusText||`Unknown`} (${n.status})`),t.jqXHR=n}else t=e instanceof Error?e:Error(String(e??`Unknown error`));if(this.onErrorFn)try{this.onErrorFn(t)}catch{}throw t}prepareSettings(){let e=this.ajaxOptionsFn?.()??{};return{...this.staticOptions,...e,headers:{...this.staticOptions.headers,...e.headers},url:this.isStaticUrl?this.staticUrl:this.getUrl(),success:void 0,error:void 0,complete:void 0}}createAbortError(){let e=Error(`AbortError`);return e.name=`AbortError`,e}};t.default.extend({atomFetch(e,t){let n=new Zn(e,t),r=Fe(n.execute,{defaultValue:t.defaultValue,lazy:t.eager===!1}),i=r.dispose.bind(r);return r.dispose=()=>{n.abort(),i()},Object.assign(r,{abort:()=>n.abort()})}}),(0,t.default)(()=>{Mt(),document.body&&bt(document.body)}),e.default=t.default,e.disableAutoCleanup=xt,e.disablejQueryOverrides=Nt,e.enableAutoCleanup=bt,e.enablejQueryOverrides=Mt,e.isReactive=Ue,e.nextTick=ut,e.registry=q});
|
|
1
|
+
(function(M,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("jquery"),require("@but212/atom-effect")):typeof define=="function"&&define.amd?define(["exports","jquery","@but212/atom-effect"],f):(M=typeof globalThis<"u"?globalThis:M||self,f(M.AtomEffectJQuery={},M.jQuery,M.AtomEffect))})(this,function(M,f,d){Object.defineProperties(M,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var je=Object.create,Yt=Object.defineProperty,We=Object.getOwnPropertyDescriptor,ze=Object.getOwnPropertyNames,Ge=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,Qe=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(var s=ze(e),o=0,i=s.length,a;o<i;o++)a=s[o],!Ye.call(t,a)&&a!==n&&Yt(t,a,{get:(l=>e[l]).bind(null,a),enumerable:!(r=We(e,a))||r.enumerable});return t},Je=(t,e,n)=>(n=t!=null?je(Ge(t)):{},Qe(e||!t||!t.__esModule?Yt(n,"default",{value:t,enumerable:!0}):n,t));f=Je(f,1);var Ze={ERRORS:{EFFECT_DISPOSE_ERROR:t=>`Dispose error${t?`: ${t}`:""}`}},q={PREFIX:"[atom-route]",DEFAULTS:Object.freeze({mode:"hash",basePath:"",autoBindLinks:!1,activeClass:"active"}),ERRORS:{NOT_FOUND:t=>`Route "${t}" not found`,TEMPLATE_NOT_FOUND:t=>`Template "${t}" not found`,TARGET_NOT_FOUND:t=>`Target "${t}" not found`,MALFORMED_URI:t=>`Malformed URI: ${t}`}},R={PREFIX:"[atom-binding]",INPUT_DEFAULTS:Object.freeze({event:"input change",debounce:0}),VALID_INPUT_TAGS:["input","select","textarea"],ERRORS:{INVALID_INPUT_ELEMENT:t=>`Invalid element <${t}> for val.`,MISSING_SOURCE:t=>`[${t}] source required.`,MISSING_CONDITION:t=>`[${t}] condition required.`,UPDATER_ERROR:(t,e)=>`Updater failed: "${t}"${e?" (static)":""}`,CLEANUP_ERROR:t=>`Binding cleanup error${t?`: ${t}`:""}`,PARSE_ERROR:t=>`Parse error${t?`: ${t}`:""}`}},tt={DANGEROUS_PROPS:["innerHTML","outerHTML","srcdoc","__proto__","constructor","prototype"],URL_PROPS:["src","href","action","formaction","data","poster","background","cite","longdesc","profile","usemap","classid","codebase","xlink:href"],DANGEROUS_PROTOCOL_PATTERN:"(?:javascript|vbscript)",ERRORS:{UNSAFE_CONTENT:()=>"Unsafe content neutralized.",BLOCKED_CSS_VALUE:t=>`Blocked CSS: "${t}".`,BLOCKED_EVENT_HANDLER:t=>`Blocked handler: "${t}".`,BLOCKED_PROTOCOL:t=>`Blocked protocol: "${t}".`,BLOCKED_PROP:t=>`Blocked prop: "${t}".`}},ht={PREFIX:"[atom-list]",ERRORS:{DUPLICATE_KEY:(t,e)=>`Duplicate key "${t}" at index ${e}.`}},Qt={PREFIX:"[atom-mount]",ERRORS:{ERROR:t=>`Mount error${t?` in <${t}>`:""}`,CLEANUP_ERROR:t=>`Cleanup error${t?` in <${t}>`:""}`}},Y={PREFIX:"[atom-component]",ATTRS:{BIND:"data-aej-bind",PART:"data-aej-part",LEGACY_BIND:"data-bind"},ERRORS:{NOT_REGISTERED:t=>`Custom Element <${t}> is not registered.`}},qe={DEFAULTS:{HIGHLIGHT_DURATION_MS:500}},Jt=t=>t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function";function it(t){const{localName:e,id:n,className:r}=t;let s=e;n&&(s+=`#${n}`);const o=typeof r=="string"?r:r?.baseVal;if(o){const a=o.trim().replace(/\s+/g,".");a&&(s+=`.${a}`)}const i=t.type;return i&&i!=="text"&&(s+=`.${i}`),s}function Zt(t,e,n){if(typeof n=="object"&&n!==null&&!(n instanceof File)&&!(n instanceof Blob))for(const[r,s]of Object.entries(n))Zt(t,e?`${e}[${r}]`:r,s);else t.append(e,n instanceof Blob?n:String(n??""))}var pt="data-atom-debug",qt=typeof window<"u",Nt=new WeakMap,te=!1;function tn(){if(te||!qt)return;const t=`
|
|
2
|
+
[${pt}] { outline: 0px solid transparent; transition: outline 0.1s ease-out; }
|
|
3
|
+
@keyframes atom-flash {
|
|
4
|
+
0% { outline: 2px solid rgba(255, 68, 68, 0.9); outline-offset: 1px; }
|
|
5
|
+
100% { outline: 0px solid transparent; outline-offset: 1px; }
|
|
6
|
+
}
|
|
7
|
+
`.replace(/\s+/g," ");if("adoptedStyleSheets"in document&&"replaceSync"in CSSStyleSheet.prototype){const e=new CSSStyleSheet;e.replaceSync(t),document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]}else{const e=document.createElement("style");e.setAttribute(pt,""),e.textContent=t,document.head.appendChild(e)}te=!0}function en(){const t=globalThis;return t.__ATOM_DEBUG__!=null?!!t.__ATOM_DEBUG__:t.process?.env?.NODE_ENV!=="production"&&t.process?.env?.NODE_ENV!=null}var nn=en(),C={enabled:nn,warn:(t,e,...n)=>console.warn(`${t} ${e}`,...n),error:(t,e,n)=>console.error(`${t} ${e}`,n),domUpdated(t,e,n,r){if(!this.enabled)return;const s="jquery"in e?e[0]:e;s?.nodeType===1&&s.isConnected&&(console.log(`${t} DOM updated: ${it(s)}.${n} =`,r),rn(s))}};function rn(t){if(!qt||typeof t.animate!="function")return;tn(),Nt.get(t)?.cancel(),t.hasAttribute(pt)||t.setAttribute(pt,"");const e=t.animate([{outline:"2px solid rgba(255, 68, 68, 0.9)",outlineOffset:"1px"},{outline:"0px solid transparent",outlineOffset:"1px"}],{duration:qe.DEFAULTS.HIGHLIGHT_DURATION_MS,easing:"ease-out"});Nt.set(t,e),e.onfinish=()=>Nt.delete(t)}var sn=()=>(0,d.aeNextTick)();f.default.extend({atom:d.atom,computed:d.computed,effect:d.effect,batch:d.batch,untracked:d.untracked,isAtom:d.isAtom,isComputed:d.isComputed,nextTick:sn,atomLens:d.atomLens,composeLens:d.composeLens,lensFor:d.lensFor,mergeAtoms:d.mergeAtoms,mergeLenses:d.mergeLenses,debug:C});var ee=Symbol.for("atom-effect.Option"),It=Symbol.for("atom-effect.Result"),Lt=Object.freeze({ok:!1,value:void 0,[ee]:!0}),h={some:t=>({ok:!0,value:t,[ee]:!0}),none:Lt,isSome:t=>t.ok,isNone:t=>!t.ok,expect:(t,e)=>{if(t.ok)return t.value;throw new Error(e)},unwrap:t=>{if(!t.ok)throw new Error("Option.unwrap() on None");return t.value},unwrapOr:(t,e)=>t.ok?t.value:e,unwrapOrElse:(t,e)=>t.ok?t.value:e(),map:(t,e)=>{if(!t.ok)return t;const n=e(t.value);return n===t.value?t:h.some(n)},andThen:(t,e)=>t.ok?e(t.value):t,fromNullable:t=>t==null?Lt:h.some(t),match:(t,e)=>t.ok?e.some(t.value):e.none(),filter:(t,e)=>t.ok&&e(t.value)?t:Lt,equals:(t,e)=>t===e?!0:t.ok!==e.ok?!1:!t.ok||t.value===e.value,toNullable:t=>t.ok?t.value:null,toUndefined:t=>t.ok?t.value:void 0},on=Object.freeze({ok:!0,value:void 0,error:void 0,[It]:!0});function Pt(t){return t instanceof Error?t:new Error(typeof t=="string"?t:String(t??"Unknown error"))}var O={ok:t=>t===void 0?on:{ok:!0,value:t,error:void 0,[It]:!0},err:t=>({ok:!1,value:void 0,error:t,[It]:!0}),isOk:t=>t.ok,isErr:t=>!t.ok,match:(t,e)=>t.ok?e.ok(t.value):e.err(t.error),unwrap:t=>{if(!t.ok)throw t.error;return t.value},expect:(t,e)=>{if(!t.ok)throw new Error(e);return t.value},unwrapOr:(t,e)=>t.ok?t.value:e,unwrapOrElse:(t,e)=>t.ok?t.value:e(t.error),map:(t,e)=>{if(!t.ok)return t;const n=e(t.value);return n===t.value?t:O.ok(n)},mapErr:(t,e)=>t.ok?t:O.err(e(t.error)),andThen:(t,e)=>t.ok?e(t.value):t,tryCatch:t=>{try{return O.ok(t())}catch(e){return O.err(Pt(e))}},tryAsync:t=>{try{const e=t();return Promise.resolve(e).then(n=>O.ok(n),n=>O.err(Pt(n)))}catch(e){return Promise.resolve(O.err(Pt(e)))}},toOption:t=>t.ok?h.some(t.value):h.none},an=[0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,-1],_=4,ln=15,mt=class{constructor(){this._count=0,this._actualCount=0,this._mask=0,this._s0=null,this._s1=null,this._s2=null,this._s3=null,this._overflow=null,this._freeIndices=null,this._lockCount=0,this._pendingCompact=!1}_firstFreeSlot(t){return an[t&ln]}_rawWrite(t,e){if(t<_){const n=1<<t;e===null?this._mask&=~n:this._mask|=n,t===0?this._s0=e:t===1?this._s1=e:t===2?this._s2=e:t===3&&(this._s3=e)}else this._overflow||(this._overflow=[]),this._overflow[t-_]=e}_rawAdd(t){const e=this._mask,n=this._firstFreeSlot(e);if(n!==-1)return this._mask=e|1<<n,n===0?this._s0=t:n===1?this._s1=t:n===2?this._s2=t:this._s3=t,n;this._overflow||(this._overflow=[]);const r=this._overflow,s=this._freeIndices;if(s?.length){const o=s.pop();return r[o]=t,o+_}return r.push(t),_-1+r.length}_rawSwap(t,e){if(t===e)return;const n=this.at(t),r=this.at(e);this._rawWrite(t,r),this._rawWrite(e,n)}get length(){return this._count}get size(){return this._actualCount}at(t){if(t<_)return t===0?this._s0:t===1?this._s1:t===2?this._s2:t===3?this._s3:null;const e=this._overflow;return e?e[t-_]??null:null}setAt(t,e){const n=this.at(t);n!==e&&(this._rawWrite(t,e),n===null?this._actualCount++:e===null&&this._actualCount--,e!==null?t>=this._count&&(this._count=t+1):this._shrinkPhysicalSizeFrom(t))}_shrinkPhysicalSizeFrom(t){if(t===this._count-1){if(this._count--,this._count>_){const e=this._overflow;for(;this._count>_&&e[this._count-(_+1)]==null;)this._count--}this._count<=_&&(this._count=32-Math.clz32(this._mask))}}truncateFrom(t){const e=this._count;if(!(t>=e)){for(let n=t;n<e;n++)this.at(n)!==null&&this._actualCount--;t<_?(this._mask&=(1<<t)-1,t<=0&&(this._s0=null),t<=1&&(this._s1=null),t<=2&&(this._s2=null),t<=3&&(this._s3=null),this._overflow=null):this._overflow&&(this._overflow.length=t-_),this._count=t,this._freeIndices=null}}push(t){const e=this._rawAdd(t);return e>=this._count&&(this._count=e+1),this._actualCount++,e}remove(t){if(this._actualCount===0)return!1;const e=this._mask;if(e&1&&this._s0===t)return this._removeAt(0);if(e&2&&this._s1===t)return this._removeAt(1);if(e&4&&this._s2===t)return this._removeAt(2);if(e&8&&this._s3===t)return this._removeAt(3);const n=this._overflow;if(n){for(let r=0,s=n.length;r<s;r++)if(n[r]===t)return n[r]=null,this._actualCount--,this._shrinkPhysicalSizeFrom(r+_),this._freeIndices||(this._freeIndices=[]),this._freeIndices.push(r),!0}return!1}_removeAt(t){return this._rawWrite(t,null),this._actualCount--,this._shrinkPhysicalSizeFrom(t),!0}has(t){if(this._actualCount===0)return!1;const e=this._mask;if(e&1&&this._s0===t||e&2&&this._s1===t||e&4&&this._s2===t||e&8&&this._s3===t)return!0;const n=this._overflow;if(n){for(let r=0,s=n.length;r<s;r++)if(n[r]===t)return!0}return!1}forEach(t){if(this._actualCount===0)return;const e=this._mask;e&1&&t(this._s0),e&2&&t(this._s1),e&4&&t(this._s2),e&8&&t(this._s3);const n=this._overflow;if(n)for(let r=0,s=n.length;r<s;r++){const o=n[r];o!=null&&t(o)}}some(t){if(this._actualCount===0)return!1;const e=this._mask;if(e&1&&t(this._s0)||e&2&&t(this._s1)||e&4&&t(this._s2)||e&8&&t(this._s3))return!0;const n=this._overflow;if(n)for(let r=0,s=n.length;r<s;r++){const o=n[r];if(o!=null&&t(o))return!0}return!1}compact(){if(this._lockCount>0){this._pendingCompact=!0;return}const t=this._actualCount,e=this._count;if(t===e)return;if(t===0){this.clear();return}let n=0;const r=this._overflow;for(let s=0;s<e;s++){const o=this.at(s);if(o!==null&&(s!==n&&(this._rawWrite(n,o),this._rawWrite(s,null)),++n===t))break}this._count=t,r!==null&&(n<=_?this._overflow=null:r.length=n-_),this._freeIndices=null,this._pendingCompact=!1}lock(){this._lockCount++}unlock(){--this._lockCount===0&&this._pendingCompact&&this.compact()}clear(){this._s0=this._s1=this._s2=this._s3=null,this._count=0,this._actualCount=0,this._mask=0,this._overflow=null,this._freeIndices=null,this._pendingCompact=!1}dispose(){this.clear()}get isLocked(){return this._lockCount>0}},cn=Object.prototype.hasOwnProperty;function _t(t,e){if(t===e)return!0;if(t===null||e===null||typeof t!="object"||typeof e!="object")return!1;const n=t,r=e,s=Object.keys(n);if(s.length!==Object.keys(r).length)return!1;for(const o of s)if(!cn.call(r,o)||!Object.is(n[o],r[o]))return!1;return!0}var ne=!0;function re(t){ne=t}var vt="_aes-bound",se="_aes-has-shadow",un=class{constructor(){this.records=new WeakMap,this.kept=new WeakSet,this.ignored=new WeakSet,this.shadows=new WeakMap,this.autoCleanupScheduled=!1}keep(t){this.kept.add(t)}isKept(t){return this.kept.has(t)}markIgnored(t){this.ignored.add(t)}isIgnored(t){return this.ignored.has(t)}unmarkIgnored(t){this.ignored.delete(t)}isAutoCleanupScheduled(){return this.autoCleanupScheduled}setAutoCleanupScheduled(t){this.autoCleanupScheduled=t}deferCleanup(t){this.ignored.add(t),queueMicrotask(()=>{t.isConnected?this.ignored.delete(t):this.cleanupTree(t)})}registerShadow(t,e){this.shadows.set(t,e)}safeMark(t,e){t.isConnected?t.classList.add(e):queueMicrotask(()=>t.classList.add(e))}markHost(t){this.safeMark(t,se)}getShadow(t){return h.unwrapOr(h.fromNullable(t.shadowRoot),h.toNullable(h.fromNullable(this.shadows.get(t))))}getOrCreateRecord(t){return ne&&!this.autoCleanupScheduled&&typeof document<"u"&&document.body&&(this.autoCleanupScheduled=!0,gt(document.body)),h.unwrapOrElse(h.fromNullable(this.records.get(t)),()=>{const e={};return this.records.set(t,e),this.safeMark(t,vt),e})}addCleanup(t,e){const n=this.getOrCreateRecord(t);n.tasks||(n.tasks=new mt),n.tasks.push(e)}trackEffect(t,e){const n=it(t);this.addCleanup(t,()=>{const r=O.tryCatch(()=>e.dispose());r.ok||C.error(R.PREFIX,Ze.ERRORS.EFFECT_DISPOSE_ERROR(n),r.error)})}onCleanup(t,e){const n=it(t);this.addCleanup(t,()=>{const r=O.tryCatch(()=>e());r.ok||C.error(R.PREFIX,R.ERRORS.CLEANUP_ERROR(n),r.error)})}setTeardown(t,e){this.getOrCreateRecord(t).teardown=e}hasBind(t){return this.records.has(t)}cleanup(t){if(this.kept.delete(t),this.ignored.delete(t),t.nodeType!==1)return;const e=t,n=h.fromNullable(this.records.get(e));if(h.isSome(n)){const r=n.value;this.records.delete(e),e.classList.remove(vt),h.match(h.fromNullable(r.teardown),{some:s=>{const o=O.tryCatch(()=>s());if(!o.ok){const i=it(e);C.error(Qt.PREFIX,Qt.ERRORS.CLEANUP_ERROR(i),o.error)}},none:()=>{}}),h.match(h.fromNullable(r.tasks),{some:s=>{s.forEach(o=>o()),s.dispose()},none:()=>{}})}else e.classList.remove(vt)}cleanupDescendants(t){const e=t.querySelectorAll(`.${vt}`);for(let r=0,s=e.length;r<s;r++){const o=e[r];o&&this.cleanup(o)}const n=t.querySelectorAll(`.${se}`);for(let r=0,s=n.length;r<s;r++){const o=n[r],i=this.getShadow(o);i&&this.cleanupTree(i)}}cleanupTree(t){if(t.nodeType===1||t.nodeType===11){const e=t;if(this.cleanupDescendants(e),t.nodeType===1){const n=this.getShadow(t);n&&this.cleanupTree(n)}}this.cleanup(t)}},y=new un,et=new Map;function gt(t){if(et.has(t))return;const e=new MutationObserver(n=>{for(let r=0,s=n.length;r<s;r++){const o=n[r].removedNodes;for(let i=0,a=o.length;i<a;i++){const l=o[i];if(l.nodeType!==1||l.isConnected)continue;const u=l;y.isKept(u)||y.isIgnored(u)||y.cleanupTree(u)}}});e.observe(t,{childList:!0,subtree:!0}),et.set(t,e)}function oe(){et.forEach(t=>t.disconnect()),et.clear(),y.setAutoCleanupScheduled(!1)}function fn(t){const e=et.get(t);e&&(e.disconnect(),et.delete(t))}var Dt=Symbol.for("aej:hydrated"),Et=Symbol.for("aej:cleanup-enabled"),ie="aej:context-request",at=Symbol.for("atom-effect-internal"),B=(function(t){return t[t.None=0]="None",t[t.Focused=1]="Focused",t[t.Composing=2]="Composing",t[t.SyncingToAtom=4]="SyncingToAtom",t[t.SyncingToDom=8]="SyncingToDom",t[t.Busy=t.Composing|t.SyncingToAtom|t.SyncingToDom]="Busy",t})({}),dn=0;function hn(t){t[at]=!0}var ae={multipleSelect:{read:t=>{if(!(t instanceof HTMLSelectElement))return[];const e=t.selectedOptions,n=[];for(let r=0,s=e.length;r<s;r++)n.push(e[r].value);return n},write:(t,e,n)=>{e.val(n)},equal:(t,e,n)=>{if(n(t,e))return!0;if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0,s=t.length;r<s;r++)if(!Object.is(t[r],e[r]))return!1;return!0},format:(t,e)=>e?e(t):Array.isArray(t)?t.join(","):String(t??"")},default:{read:(t,e,n)=>n?n(t.value):t.value,write:(t,e,n,r)=>{if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&document.activeElement===t){const s=t;try{const{selectionStart:o,selectionEnd:i}=s;if(s.value=r,o!==null&&i!==null){const a=r.length;s.setSelectionRange(Math.min(o,a),Math.min(i,a))}}catch{s.value=r}}else t.value=r},equal:(t,e,n)=>n(t,e),format:(t,e)=>e?e(t):String(t??"")}},pn=class{constructor(t,e,n){this.atom=e,this.options=n,this.abortController=new AbortController,this.flags=B.None,this.syncToDom=()=>{const a=this.atom.value;this.flags&B.Busy||(0,d.untracked)(()=>{if(!this.isDomUpToDate(a)){this.flags|=B.SyncingToDom;try{const l=this.formatValue(a);this.writeToDom(a,l),C.domUpdated(R.PREFIX,this.$element,"val",l)}catch(l){C.warn(R.PREFIX,"syncToDom failed:",l)}this.flags&=~B.SyncingToDom}})},this.atom=e,this.options=n,this.$element=t,this.eventNamespace=`.atomBind-${++dn}`;const r=t[0],s=r.tagName==="SELECT"&&r.multiple?ae.multipleSelect:ae.default,o=n.parse,i=n.equal??Object.is;this.readValue=()=>s.read(r,this.$element,o),this.writeToDom=(a,l)=>s.write(r,this.$element,a,l),this.areEqual=(a,l)=>s.equal(a,l,i),this.formatValue=a=>s.format(a,n.format),this.initializeEvents()}initializeEvents(){const t=this.eventNamespace,e=this.options.debounce??R.INPUT_DEFAULTS.debounce,n=l=>{(l&&"originalEvent"in l?l.originalEvent:l)?.isComposing||this.syncToAtom()},r=e>0?l=>{clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>n(l),e)}:n,s=()=>this.flags|=B.Focused,o=()=>this.handleBlur();[s,o,r].forEach(hn);const i=(this.options.event??R.INPUT_DEFAULTS.event).trim().split(/\s+/);let a="";for(let l=0,u=i.length;l<u;l++)a+=(l>0?" ":"")+i[l]+t;this.$element.on(`focus${t}`,s).on(`blur${t}`,o).on(a,r)}handleBlur(){this.flags&=~B.Focused,this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=void 0),this.syncToAtom();const t=this.atom.peek();this.isDomUpToDate(t)||this.writeToDom(t,this.formatValue(t))}syncToAtom(){if(!(this.flags&B.Busy)){this.flags|=B.SyncingToAtom;try{const t=this.readValue();this.areEqual(this.atom.peek(),t)||(this.atom.value=t)}catch(t){C.warn(R.PREFIX,"syncToAtom failed:",t)}this.flags&=~B.SyncingToAtom}}isDomUpToDate(t){if(!this.areEqual(this.readValue(),t))return!1;if(this.flags&B.Focused)return!0;const e=this.$element[0];return this.formatValue(t)===e.value}cleanup(){this.$element.off(this.eventNamespace),this.abortController.abort(),this.debounceTimer&&clearTimeout(this.debounceTimer)}};function mn(t,e,n){const r=new pn(t,e,n);return{reactiveEffect:(0,d.effect)(r.syncToDom),cleanup:()=>r.cleanup()}}function le(t,e,n){let r=0,s=!1;return y.onCleanup(t,()=>{s=!0}),o=>{const i=++r;if(!Jt(o)){if(s||i!==r)return;(0,d.untracked)(()=>{try{n(o),C.domUpdated(R.PREFIX,t,e,o)}catch(a){C.error(R.PREFIX,R.ERRORS.UPDATER_ERROR(e,!0),a)}});return}o.then(a=>{s||i!==r||(0,d.untracked)(()=>{try{n(a),C.domUpdated(R.PREFIX,t,`${e} (async)`,a)}catch(l){C.error(R.PREFIX,R.ERRORS.UPDATER_ERROR(e,!1),l)}})},a=>{i===r&&!s&&C.error(R.PREFIX,R.ERRORS.UPDATER_ERROR(e),a)})}}function Mt(t,e,n,r){const s=le(t,r,n),o=(0,d.isAtom)(e);o||typeof e=="function"?y.trackEffect(t,(0,d.effect)(()=>{s(o?e.value:e())},{name:r})):s(e)}function yt(t,e,n,r){const s=le(t,r,n),o=Object.keys(e),i=o.length;let a=!1;for(let u=0;u<i;u++){const c=e[o[u]];if((0,d.isAtom)(c)||typeof c=="function"){a=!0;break}}const l=()=>{const u={},c=[];for(let p=0;p<i;p++){const m=o[p],v=e[m];let E;(0,d.isAtom)(v)?E=v.value:typeof v=="function"?E=v():E=v,Jt(E)?c.push(E.then(A=>({key:m,value:A}))):u[m]=E}return c.length>0?Promise.all(c).then(p=>{for(let m=0,v=p.length;m<v;m++){const E=p[m];u[E.key]=E.value}return u}):u};a?y.trackEffect(t,(0,d.effect)(()=>s(l()),{name:r})):s(l())}var ce={urlAttributes:["href","src","action","formaction","xlink:href","data","poster","background","cite","longdesc","profile","usemap","classid","codebase","fill","filter","mask","marker-start","marker-mid","marker-end","clip-path"],blacklistedTags:["script","iframe","object","embed","base","meta","applet","noscript","form","style","link","title","isindex","body"]},lt={ENTITIES:{colon:":",tab:" ",newline:`
|
|
8
|
+
`,lt:"<",gt:">",amp:"&",quot:'"',apos:"'"},CLOBBER:{ATTRS:["id","name"],VALUES:["attributes","tagname","nodename","innerhtml","parentnode","childnodes","lastchild","firstchild","nextsibling","previoussibling"]},SENSITIVE:["attributename","from","to","values"]},nt={NUMERIC_ENTITY:/&#x([0-9a-f]+);?|&#([0-9]+);?/gi,NAMED_ENTITY:new RegExp(`&(${Object.keys(lt.ENTITIES).join("|")});?`,"gi"),CONTROL_CHARS:/[\x00-\x1f\x7f\ufffd\u0000]/g,DATA_URI:/data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/i,PROTOCOL:new RegExp(`(?:^|url\\s*\\(\\s*["']?)\\s*${tt.DANGEROUS_PROTOCOL_PATTERN}\\s*:`,"i"),CSS_CLEAN:/\/\*[\s\S]*?\*\//g},At=Function.prototype.call.bind(Function.prototype.call),Ut=(t,e)=>Object.getOwnPropertyDescriptor(t,e)?.get,L={getAttributes:t=>{const e=Ut(Element.prototype,"attributes");return Array.from(e?At(e,t):t.attributes)},setAttribute:(t,e,n)=>At(Element.prototype.setAttribute,t,e,n),removeAttribute:(t,e)=>At(Element.prototype.removeAttribute,t,e),replaceNode:(t,e)=>t.parentNode?(t.parentNode.replaceChild(e,t),!0):!1,getLocalName:t=>{if(t.nodeType!==Node.ELEMENT_NODE)return"";const e=t,n=Ut(Element.prototype,"localName")??Ut(Node.prototype,"nodeName");return(n?At(n,e):e.localName??"").toLowerCase()},createElement:t=>document.createElement(t)},K={decodeEntities(t){return t.replace(nt.NUMERIC_ENTITY,(e,n,r)=>{const s=n?parseInt(n,16):parseInt(r,10);return s>=0&&s<=1114111?String.fromCodePoint(s):""}).replace(nt.NAMED_ENTITY,(e,n)=>lt.ENTITIES[n.toLowerCase()]??"")},normalize(t){return typeof t!="string"?"":this.decodeEntities(this.decodeEntities(t)).replace(nt.CONTROL_CHARS,"")},isDangerousUri(t){const e=this.normalize(t).replace(/\s+/g,"");return nt.PROTOCOL.test(e)||nt.DATA_URI.test(e)},isDangerousCss(t){const e=this.normalize(t).replace(nt.CSS_CLEAN,"").toLowerCase();if(["javascript:","expression(","-moz-binding"].some(r=>e.includes(r)))return!0;const n=e.match(/url\s*\(\s*["']?([^"')]*)["']?\s*\)/i)?.[1];return!!n&&this.isDangerousUri(n)}};function ue(t,e){const n=L.createElement("template"),r=document.createElement("div");return n.innerHTML=t,de(n.content,e),r.innerHTML="",r.appendChild(n.content),r.innerHTML}var vn=[{match:(t,e,n)=>t==="style",action:(t,e,n)=>{const r=n.split(";").map(s=>s.trim()).filter(s=>s&&!K.isDangerousCss(s));L.setAttribute(t,e,r.length?`${r.join("; ")};`:"data-unsafe-css:")}},{match:t=>t==="srcdoc",action:(t,e,n,r)=>L.setAttribute(t,e,ue(n,r))},{match:t=>t==="srcset",action:(t,e,n)=>{const r=n.split(",").map(s=>{const o=s.trim();if(!o)return s;const[i,...a]=o.split(/\s+/);return K.isDangerousUri(i)?["data-unsafe-protocol:",...a].join(" "):[K.normalize(i),...a].join(" ")});L.setAttribute(t,e,r.join(", "))}},{match:(t,e,n)=>n.urlAttributes.includes(t)&&K.isDangerousUri(e),action:(t,e)=>L.setAttribute(t,e,"data-unsafe-protocol:")},{match:(t,e,n)=>lt.SENSITIVE.includes(t)&&(e.startsWith("on")||K.isDangerousUri(e))||lt.CLOBBER.ATTRS.includes(t)&<.CLOBBER.VALUES.includes(e.toLowerCase()),action:(t,e)=>L.removeAttribute(t,e)},{match:(t,e,n)=>t.startsWith("on"),action:(t,e)=>L.removeAttribute(t,e)},{match:(t,e,n)=>t.includes("javascript")||t.includes("expression")||K.isDangerousUri(e)||e.includes("javascript")||e.includes("expression"),action:(t,e)=>L.removeAttribute(t,e)}];function fe(t,e){const n=L.getAttributes(t),r=n.filter(s=>s.name.toLowerCase().startsWith("on")).map(s=>s.name);for(const{name:s,value:o}of n){const i=s.toLowerCase();for(const a of vn)if(a.match(i,o,e)){a.action(t,s,o,e);break}}r.length&&L.setAttribute(t,"data-unsafe-attr",r.join(","))}function gn(t,e){if(t.nodeType===Node.TEXT_NODE){const s=t.textContent??"";if(e.blacklistedTags.some(o=>K.normalize(s).toLowerCase().includes(`<${o}`))){const o=L.createElement("span");return o.textContent=s.replace(/</g,"[").replace(/>/g,"]"),L.replaceNode(t,o)?o:t}return t}if(t.nodeType!==Node.ELEMENT_NODE)return t;const n=t,r=L.getLocalName(n);if(fe(n,e),e.blacklistedTags.includes(r)){const s=L.createElement("span");if(L.getAttributes(n).forEach(o=>s.setAttribute(o.name,o.value)),fe(s,e),r==="style"&&K.isDangerousCss(n.textContent??""))s.textContent="/* blocked */";else for(;n.firstChild;)s.appendChild(n.firstChild);return L.replaceNode(n,s)?s:n}return n}function de(t,e){const n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);let r=t;for(;r;){const s=n.nextNode();gn(r,e),r.nodeType===Node.ELEMENT_NODE&&L.getLocalName(r)==="template"&&de(r.content,e),r=s}}function ct(t,e=ce){return t?ue(String(t),e):""}var he=(t,e,n=ce)=>{const r=t.toLowerCase();return(r==="srcdoc"||n.urlAttributes.includes(r))&&K.isDangerousUri(e)},En=t=>K.isDangerousCss(t);function yn(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function pe(t,e){return t.toLowerCase().startsWith("on")?(console.warn(`${R.PREFIX} ${tt.ERRORS.BLOCKED_EVENT_HANDLER(t)}`),!1):e&&tt.DANGEROUS_PROPS.includes(t)?(console.warn(`${R.PREFIX} ${tt.ERRORS.BLOCKED_PROP(t)}`),!1):!0}function me(t,e,n){Mt(t,e,r=>{const s=h.unwrapOr(h.map(h.fromNullable(n),o=>o(r)),String(r??""));t.textContent!==s&&(t.textContent=s)},"text")}function ve(t,e){let n=null;Mt(t,e,r=>{const s=ct(r);n!==s&&(y.cleanupDescendants(t),t.innerHTML=s,n=s)},"html")}function ge(t,e){const n=new Map;Object.keys(e).forEach(r=>{const s=r.trim();n.set(r,s.includes(" ")?s.split(/\s+/).filter(Boolean):[s])}),yt(t,e,r=>{const s=new Set;for(const[o,i]of Object.entries(r))i&&n.get(o)?.forEach(a=>s.add(a));Array.from(n.values()).flat().forEach(o=>{t.classList.toggle(o,s.has(o))})},"class")}function Ee(t,e){const{style:n}=t,r={},s={},o=new Map;Object.entries(e).forEach(([i,a])=>{const[l,u]=Array.isArray(a)?a:[a,""];r[i]=l,s[i]=u}),yt(t,r,i=>{Object.entries(i).forEach(([a,l])=>{const u=s[a]??"",c=u?`${l}${u}`:String(l);o.get(a)!==c&&(En(c)||n.setProperty(yn(a),c),o.set(a,c))})},"css")}function ye(t,e){const n=Object.entries(e).filter(([i])=>pe(i,!1)),r=Object.fromEntries(n),s={},o={};for(const[i]of n)s[i]={isAria:i.toLowerCase().startsWith("aria-")},o[i]=t.getAttribute(i);yt(t,r,i=>{for(const[a,l]of Object.entries(i)){const u=s[a];if(!u)continue;const c=h.unwrapOr(h.map(h.fromNullable(l),p=>p===!0?u.isAria?"true":a:p===!1?u.isAria?"false":null:String(p)),null);if(c!==null&&he(a,c)){console.warn(`${R.PREFIX} ${tt.ERRORS.BLOCKED_PROTOCOL(a)}`);continue}o[a]!==c&&(c===null?t.removeAttribute(a):t.setAttribute(a,c),o[a]=c)}},"attr")}function Ae(t,e){const n=t,r=Object.entries(e).filter(([i])=>pe(i,!0)),s=Object.fromEntries(r),o={};yt(t,s,i=>{for(const[a,l]of Object.entries(i))if(o[a]!==l){if(typeof l=="string"&&he(a,l)){console.warn(`${R.PREFIX} ${tt.ERRORS.BLOCKED_PROTOCOL(a)}`);continue}n[a]=l,o[a]=l}},"prop")}function St(t,e,n){let r=t.style.display==="none"?"":t.style.display;Mt(t,e,s=>{const o=n!==!!s,i=t.style.display;o?i==="none"&&(t.style.display=r):i!=="none"&&(r=i,t.style.display="none")},n?"hide":"show")}function $t(t,e,n={}){const r=t.tagName.toLowerCase();if(!(R.VALID_INPUT_TAGS.includes(r)||r.includes("-"))){console.warn(`${R.PREFIX} ${R.ERRORS.INVALID_INPUT_ELEMENT(r)}`);return}const{reactiveEffect:s,cleanup:o}=mn((0,f.default)(t),e,n);y.trackEffect(t,s),y.onCleanup(t,o)}function Se(t){t.type==="radio"&&t.name&&(t.form?(0,f.default)(t.form):(0,f.default)(document)).find(`input[type="radio"][name="${f.default.escapeSelector(t.name)}"]`).not(t).trigger("change.atomRadioSync")}function be(t,e){if(!(t instanceof HTMLInputElement)){console.warn(`${R.PREFIX} atomChecked called on non-input element`);return}const n=t,r=(0,f.default)(n),s=()=>{e.peek()!==n.checked&&(e.value=n.checked,Se(n))};s[at]=!0,r.on("change change.atomRadioSync",s),y.onCleanup(n,()=>r.off("change change.atomRadioSync",s)),y.trackEffect(n,(0,d.effect)(()=>{const o=!!e.value;(0,d.untracked)(()=>{n.checked!==o&&(n.checked=o,C.domUpdated(R.PREFIX,n,"checked",o),o&&Se(n))})}))}function An(t,e){const n=(0,f.default)(t);n.on(e),y.onCleanup(t,()=>n.off(e))}function Sn(t,e,n){const r=(0,f.default)(t);r.on(e,n),y.onCleanup(t,()=>r.off(e,n))}var Re="input, select, textarea, [name]",bn=class{constructor(t,e,n={}){this.form=t,this.atom=e,this.options=n,this.entries=new Map,this.names=new WeakMap,this.init()}init(){this.bindSubtree(this.form),this.observe()}bindSubtree(t){if(t===this.form){const e=this.form.elements;for(let n=0,r=e.length;n<r;n++)this.bindField(e[n])}else if(t.matches?.(Re))this.bindField(t);else{const e=t.querySelectorAll?.(Re);if(e)for(let n=0,r=e.length;n<r;n++)this.bindField(e[n])}}bindField(t){const e=t,n=e.name||t.getAttribute("name");if(!n)return;const r=this.names.get(e);if(r!==void 0&&r!==n&&y.cleanup(e),this.names.has(e)&&this.names.get(e)===n)return;const s=this.ensureField(n);this.names.set(e,n),y.onCleanup(e,()=>this.unbindField(e,n)),e instanceof HTMLInputElement&&(e.type==="radio"||e.type==="checkbox")?this.bindToggle(e,s.atom,e.value,e.type==="checkbox"):$t(e,s.atom,this.options),this.applyValidation(e,n,s.atom)}applyValidation(t,e,n){const r=this.options.validation?.[e];r&&y.trackEffect(t,(0,d.effect)(()=>{try{const s=r(n.value);let o="";typeof s=="string"?o=s:s===!1&&(o="Invalid"),t.setCustomValidity?.(o)}catch(s){console.error(`Validation error in field "${e}":`,s),t.setCustomValidity?.("Validation failed")}}))}bindToggle(t,e,n,r){const s=()=>{const o=e.peek();if(r&&Array.isArray(o)){const i=new Set(o.map(String));t.checked?i.add(n):i.delete(n),e.value=Array.from(i)}else e.value=r?t.checked:n};s[at]=!0,(0,f.default)(t).on("change",s),y.onCleanup(t,()=>(0,f.default)(t).off("change",s)),y.trackEffect(t,(0,d.effect)(()=>{const o=e.value,i=r?Array.isArray(o)?o.some(a=>String(a)===n):!!o:String(o)===n;t.checked!==i&&(t.checked=i)}))}ensureField(t){let e=this.entries.get(t);if(e)return e.refCount++,e;const n=t.replace(/\[(\w+)\]/g,".$1").replace(/^\./,""),r=(0,d.atomLens)(this.atom,n),s=Object.create(r),{transform:o,onChange:i}=this.options;return Object.defineProperty(s,"value",{get(){return r.value},set(a){const l=o?o(t,a):a;r.value=l,i&&(0,d.untracked)(()=>i(t,l))}}),e={atom:s,name:t,refCount:1},this.entries.set(t,e),e}unbindField(t,e){const n=this.entries.get(e);if(n&&--n.refCount<=0){const r=n.atom;typeof r.dispose=="function"&&r.dispose(),this.entries.delete(e)}y.cleanup(t)}observe(){const t=new MutationObserver(e=>{for(let n=0,r=e.length;n<r;n++){const s=e[n];if(s.type==="childList"){const o=s.addedNodes;for(let i=0,a=o.length;i<a;i++){const l=o[i];l.nodeType===Node.ELEMENT_NODE&&this.bindSubtree(l)}}else s.attributeName==="name"&&this.bindSubtree(s.target)}});t.observe(this.form,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["name"]}),y.onCleanup(this.form,()=>t.disconnect())}};function we(t,e,n={}){y.cleanup(t),new bn(t,e,n)}function U(t,e){for(let n=0,r=t.length;n<r;n++){const s=t[n];s&&s.nodeType===Node.ELEMENT_NODE&&e(s)}return t}function Ft(t){if(!Array.isArray(t)||t.length!==2)return[t];const e=t[1];return e==null?[t]:typeof e=="function"||typeof e=="object"&&!("value"in e)&&!("then"in e)?t:[t]}function Te(t,e){return typeof t=="object"&&t!==null?t:typeof t=="string"&&e!==void 0?{[t]:e}:null}f.default.fn.atomText=function(t,e){return U(this,n=>me(n,t,e))},f.default.fn.atomHtml=function(t){return U(this,e=>ve(e,t))};function xt(t,e){return function(n,r){const s=Te(n,r);return s?U(this,o=>t(o,s)):(console.warn(`${R.PREFIX} ${e}`),this)}}f.default.fn.atomClass=xt(ge,R.ERRORS.MISSING_CONDITION("atomClass")),f.default.fn.atomAttr=xt(ye,R.ERRORS.MISSING_SOURCE("atomAttr")),f.default.fn.atomProp=xt(Ae,R.ERRORS.MISSING_SOURCE("atomProp")),f.default.fn.atomCss=function(t,e,n){const r=Te(t,e!==void 0&&n?[e,n]:e);return r?U(this,s=>Ee(s,r)):(console.warn(`${R.PREFIX} ${R.ERRORS.MISSING_SOURCE("atomCss")}`),this)},f.default.fn.atomShow=function(t){return U(this,e=>St(e,t,!1))},f.default.fn.atomHide=function(t){return U(this,e=>St(e,t,!0))},f.default.fn.atomVal=function(t,e={}){return U(this,n=>$t(n,t,e))},f.default.fn.atomChecked=function(t){return U(this,e=>be(e,t))},f.default.fn.atomForm=function(t,e={}){return U(this,n=>{n instanceof HTMLFormElement?we(n,t,e):C.warn(R.PREFIX,"Skipping non-Form element for atomForm")})},f.default.fn.atomOn=function(t,e){return U(this,n=>Sn(n,t,e))};var ke=[{key:"text",run:(t,e)=>me(t,...Ft(e))},{key:"html",run:(t,e)=>ve(t,e)},{key:"class",run:(t,e)=>ge(t,e)},{key:"css",run:(t,e)=>Ee(t,e)},{key:"attr",run:(t,e)=>ye(t,e)},{key:"prop",run:(t,e)=>Ae(t,e)},{key:"show",run:(t,e)=>St(t,e,!1)},{key:"hide",run:(t,e)=>St(t,e,!0)},{key:"val",run:(t,e)=>$t(t,...Ft(e))},{key:"checked",run:(t,e)=>be(t,e)},{key:"form",run:(t,e)=>{t instanceof HTMLFormElement&&we(t,...Ft(e))}},{key:"on",run:(t,e)=>An(t,e)}];f.default.fn.atomBind=function(t){const e=t,n=[];for(let r=0,s=ke.length;r<s;r++){const o=ke[r];e[o.key]!==void 0&&n.push(o)}return n.length===0?this:U(this,r=>{for(let s=0,o=n.length;s<o;s++){const i=n[s];i.run(r,e[i.key])}})},f.default.fn.atomUnbind=function(){return U(this,t=>y.cleanupTree(t))};function bt(t){return t instanceof Element?(0,f.default)(t):t}function Ce(t,e){if(t instanceof Element)e===null?t.removeAttribute("data-atom-key"):t.setAttribute("data-atom-key",e);else if(!t.nodeType){const n=t;for(let r=0,s=n.length;r<s;r++){const o=n[r];o instanceof Element&&(e===null?o.removeAttribute("data-atom-key"):o.setAttribute("data-atom-key",e))}}}function Rn(t){if(t instanceof Element)y.cleanupTree(t);else{const e=t;for(let n=0,r=e.length;n<r;n++){const s=e[n];s instanceof Element&&y.cleanupTree(s)}}}var wn=class{constructor(t,e,n){this.$container=t,this.containerSelector=e,this.onRemove=n,this._oldKeys=[],this._oldItems=[],this._oldNodes=[],this._removingKeys=new Set,this._emptyEl=null,this._keyToIndex=new Map}get oldKeys(){return this._oldKeys}set oldKeys(t){this._oldKeys=t}get oldItems(){return this._oldItems}set oldItems(t){this._oldItems=t}get oldNodes(){return this._oldNodes}set oldNodes(t){this._oldNodes=t}get removingKeys(){return this._removingKeys}get keyToIndex(){return this._keyToIndex}get $emptyEl(){return this._emptyEl}set $emptyEl(t){this._emptyEl=t}getIndex(t){const e=this._keyToIndex.get(t);if(e!==void 0)return e;if(typeof t=="string"){const n=Number(t);if(!Number.isNaN(n))return this._keyToIndex.get(n)}}scheduleRemoval(t,e){const n=()=>{this.fx?.isDisposed||e[0]instanceof Element&&e[0].hasAttribute("data-atom-key")||(e[0]?.isConnected&&e.remove(),this._removingKeys.delete(t))},r=this.onRemove?.(e);r instanceof Promise?r.then(n,n):n()}removeItem(t,e){Ce(e,null),this._removingKeys.add(t),this.scheduleRemoval(t,e)}dispose(){this._removingKeys.clear(),this._oldKeys=[],this._oldItems=[],this._oldNodes=[],this._keyToIndex.clear(),this._emptyEl?.remove(),this.$container.off(".atomList")}},x={Unchanged:0,Existing:1,New:2,ForceReplace:4};function Tn(t,e,n,r,s,o){const{oldKeys:i,oldItems:a,oldNodes:l,removingKeys:u,keyToIndex:c}=t,p=i.length,m=o||_t;let v=0,E=p-1,A=n-1;const w=new Set,T=new Array(n),N=new Array(n),I=new Array(n),V=new Array(n),$=new Array(n),Q=[];for(;v<=E&&v<=A;){const g=e[v],S=r(g,v);if(i[v]!==S||!m(a[v],g)||!l[v])break;c.set(S,v++)}for(;E>=v&&A>=v;){const g=e[A],S=r(g,A);if(i[E]!==S||!m(a[E],g)||!l[E])break;c.set(S,A--),E--}for(let g=0;g<v;g++){const S=i[g];T[g]=S,N[g]=e[g],I[g]=l[g],V[g]=x.Unchanged,$[g]=g,w.add(S)}for(let g=p-1,S=n-1;S>A;S--,g--){const k=i[g];T[S]=k,N[S]=e[S],I[S]=l[g],V[S]=x.Unchanged,$[S]=g,w.add(k)}const b=new Map;for(let g=v;g<=E;g++)b.set(i[g],g);for(let g=v;g<=A;g++){const S=e[g],k=r(S,g);if(T[g]=k,N[g]=S,c.set(k,g),w.has(k)){C.warn(ht.PREFIX,ht.ERRORS.DUPLICATE_KEY(k,g)),$[g]=-1;continue}w.add(k);const D=b.get(k),P=D!==void 0&&!u.has(k)?D:void 0;if(P===void 0){Q.push({key:k,item:S,index:g}),$[g]=-1,V[g]=x.New;continue}I[g]=l[P],!s&&!m(a[P],S)?(Q.push({key:k,item:S,index:g}),V[g]=x.ForceReplace):V[g]=x.Existing,$[g]=P}return{newKeys:T,newKeySet:w,newItems:N,newNodes:I,newStates:V,newIndices:$,toRender:Q,startIndex:v,oldEndIndex:E,newEndIndex:A}}function kn(t,e,n){if(t)if(t instanceof Element)n.insertBefore(t,e);else for(let r=0,s=t.length;r<s;r++){const o=t[r];o&&n.insertBefore(o,e)}}function Cn(t,e,n,r){if(t.$emptyEl&&e>0&&(t.$emptyEl.remove(),t.$emptyEl=null),e!==0)return;const{onRemove:s}=t;s?t.oldKeys.forEach((o,i)=>{const a=t.oldNodes[i];a&&t.removeItem(o,bt(a))}):n.empty(),r&&!t.$emptyEl&&(t.$emptyEl=(0,f.default)(typeof r=="string"?f.default.parseHTML(ct(r)):r),t.$emptyEl.appendTo(n)),t.oldKeys=[],t.oldItems=[],t.oldNodes=[]}function On(t,e,n){const{toRender:r,newNodes:s,newStates:o}=t,i=r.length;if(i===0)return null;const a=r.map(m=>e.render(m.item,m.index)),l=a.filter(m=>typeof m=="string"),u=l.length===i;let c=null;if(l.length>0&&(c=Nn(l)),n&&u&&c&&!e.bind&&!e.onAdd&&!e.events&&f.default.parseHTML(c.join("")).length===i)return c;let p=0;for(let m=0,v=r.length;m<v;m++){const{key:E,index:A}=r[m],w=a[m],T=typeof w=="string"?(0,f.default)(f.default.parseHTML(c[p++])):(0,f.default)(w);if(Ce(T,String(E)),o[A]===x.ForceReplace&&s[A]){const N=s[A];Rn(N);const I=bt(N);I.first().before(T),I.remove()}s[A]=T.length===1?T[0]:T}return null}function Nn(t){if(t.length===1)return[ct(t[0])];const e=`<template data-atom-sep="s${Math.random().toString(36).slice(2)}"></template>`;return ct(t.join(e)).split(e)}function In(t,e){const{startIndex:n,oldEndIndex:r,newKeySet:s}=e;for(let o=n;o<=r;o++){const i=t.oldKeys[o];!s.has(i)&&t.oldNodes[o]&&t.removeItem(i,bt(t.oldNodes[o]))}}var Ln={[x.Unchanged]:[],[x.Existing]:["update"],[x.New]:["bind","onAdd"],[x.ForceReplace]:["bind"]};function Pn(t,e,n,r,s){const{newKeys:o,newItems:i,newNodes:a,newStates:l,newIndices:u}=e,c=o.length;if(s){n.innerHTML=s.join("");let E=n.firstElementChild;o.forEach((A,w)=>{if(!E)return;const T=(0,f.default)(E);E.setAttribute("data-atom-key",String(A)),a[w]=E,l[w]=x.Existing,C.domUpdated(ht.PREFIX,T,"list.add",i[w]),E=E.nextElementSibling});return}if(t.oldKeys.length===0&&t.removingKeys.size===0){const E=document.createDocumentFragment();for(let A=0;A<c;A++){const w=a[A];if(w)if(w instanceof Element)E.appendChild(w);else for(let T=0,N=w.length;T<N;T++){const I=w[T];I&&E.appendChild(I)}}n.innerHTML="",n.appendChild(E)}else{let E=null,A=1/0;for(let w=c-1;w>=0;w--){const T=u[w],N=a[w];if(!N)continue;const I=N instanceof Element?N:N[0];I&&(T!==-1&&T<A?A=T:kn(N,E,n),E=I)}}const{onAdd:p,bind:m,update:v}=r;for(let E=0;E<c;E++){const A=Ln[l[E]]??[],w=a[E];if(A.length===0||!w)continue;const T=bt(w),N=i[E];for(let I=0,V=A.length;I<V;I++){const $=A[I];$==="onAdd"&&p?(p(T),t.removingKeys.delete(o[E]),C.domUpdated(ht.PREFIX,T,"list.add",N)):$==="bind"&&m?m(T,N,E):$==="update"&&v&&v(T,N,E)}}}var Ht=new WeakMap;function _n(t,e){const n=typeof e.key=="function"?e.key:o=>o[e.key],r={bind:e.bind,update:e.update,onAdd:e.onAdd,onRemove:e.onRemove,events:e.events},s=e.events?Object.entries(e.events).map(([o,i])=>{const[a,...l]=o.trim().split(/\s+/);return{type:a,selector:l.length>0?l.join(" "):"> *",callback:i}}):[];for(let o=0,i=this.length;o<i;o++){const a=this[o],l=(0,f.default)(a),u=Ht.get(a);u&&(u.fx.dispose(),u.ctx.dispose());const c=new wn(l,it(a),e.onRemove),p=(0,d.effect)(()=>{const m=t.value,v=m.length;(0,d.untracked)(()=>{if(Cn(c,v,l,e.empty),v===0)return;const E=c.oldKeys.length===0&&c.removingKeys.size===0;c.keyToIndex.clear();const A=Tn(c,m,v,n,e.update,e.isEqual),w=On(A,e,E);In(c,A),Pn(c,A,a,r,w),c.oldKeys=A.newKeys,c.oldItems=A.newItems,c.oldNodes=A.newNodes})});c.fx=p,s.length>0&&Dn(c,l,s),y.trackEffect(a,p),Ht.set(a,{fx:p,ctx:c}),y.onCleanup(a,()=>{c.dispose(),Ht.delete(a)})}return this}function Dn(t,e,n){for(let r=0,s=n.length;r<s;r++){const{type:o,selector:i,callback:a}=n[r];e.on(`${o}.atomList`,i,function(l){const u=l.target.closest?.("[data-atom-key]");if(!u)return;const c=u.getAttribute("data-atom-key");if(c===null)return;const p=t.getIndex(c);p!==void 0&&a.call(u,t.oldItems[p],p,l)})}}f.default.fn.atomList=_n;var Mn=Object.freeze({});f.default.fn.atomMount=function(t,e){const n=e??Mn;return U(this,r=>{y.cleanupTree(r);const s=(0,d.untracked)(()=>(0,d.batch)(()=>t((0,f.default)(r),n)));if(s){const o=typeof s=="function"?s:s.unmount;y.setTeardown(r,o)}})},f.default.fn.atomUnmount=function(){return U(this,t=>y.cleanupTree(t))};var Un=new Set(["id","data-atom-nav-target"]),$n=new Set(["id"]),Fn=new DOMParser,F=t=>{const e=t.length;if(e===0)return t;let n=0;for(;n<e&&t[n]==="/";)n++;let r=e;for(;r>n&&t[r-1]==="/";)r--;return n===0&&r===e?t:t.slice(n,r)},J=t=>{const e=t.indexOf("?");return e===-1?{route:F(t),query:h.none}:{route:F(t.substring(0,e)),query:h.some(t.substring(e+1))}},Rt=t=>Object.fromEntries(new URLSearchParams(t)),wt=(t,e)=>O.tryCatch(()=>new URL(t,e)),Vt=[{selector:'meta[name="description"]',tag:"meta",attr:"content",key:"description",staticAttrs:{name:"description"}},{selector:'meta[name="keywords"]',tag:"meta",attr:"content",key:"keywords",staticAttrs:{name:"keywords"}},{selector:'link[rel="canonical"]',tag:"link",attr:"href",key:"canonical",staticAttrs:{rel:"canonical"}}];function Oe(t,e){const n=t.document,r=n.head;for(let s=0;s<Vt.length;s++){const o=Vt[s];if(!o)continue;const i=e?e[o.key]:void 0,a=r.querySelector(o.selector);if(i===void 0){a&&a.remove();continue}const l=a||r.appendChild(n.createElement(o.tag));if(!a){const u=o.staticAttrs;for(const c in u){const p=u[c];p!==void 0&&l.setAttribute(c,p)}}l.getAttribute(o.attr)!==i&&l.setAttribute(o.attr,i)}}function xn(t,e){const n=t.attributes;for(let r=n.length-1;r>=0;r--){const s=n[r];if(!s)continue;const o=s.name;!Un.has(o)&&!(o in e)&&t.removeAttribute(o)}for(const r in e){const s=e[r];s!==void 0&&t.getAttribute(r)!==s&&t.setAttribute(r,s)}}function Tt(t,e,n=!1){const r=decodeURIComponent(e||""),s=r?t.document.getElementById(r):null;s?s.scrollIntoView({behavior:"auto",block:"start"}):(!e||n)&&t.scrollTo(0,0)}function Ne(t){const e=t,n=e.originalEvent||e;return e.defaultPrevented||e.isDefaultPrevented?.()||n.defaultPrevented||n.ctrlKey||n.metaKey||n.altKey||n.shiftKey?!1:n.button===0||n.button===void 0}var Hn=[{match:t=>t.getAttribute("data-nav")==="false",result:!1},{match:t=>["data-ignore","download"].some(e=>t.hasAttribute(e)),result:!1},{match:t=>t.getAttribute("rel")==="external"||t.rel==="external",result:!1},{match:t=>["data-route","data-path"].some(e=>t.hasAttribute(e)),result:!0},{match:t=>!!t.getAttribute("target")&&t.getAttribute("target")!=="_self",result:!1},{match:t=>t.tagName.toUpperCase()!=="A",result:!1},{match:(t,e)=>{const n=t,r=n.getAttribute("href");if(!r||r[0]==="#")return!0;const s=e.location;return n.origin!==s.origin||!/^https?:/.test(n.protocol)?!0:n.pathname===s.pathname&&n.search===s.search&&n.hash.startsWith("#")},result:!1}];function Ie(t,e=window){for(const n of Hn)if(n.match(t,e))return n.result;return!0}function Le(t,e){const n=wt(t,e);if(O.isErr(n))return{pathAndSearch:t,hash:""};const r=O.unwrap(n);return{pathAndSearch:r.pathname+r.search,hash:r.hash.slice(1)}}function Vn(t){const{hash:e,type:n,isNewTarget:r,prevHash:s,scrollToTop:o}=t,i=n==="pop";return{shouldScroll:!!e||!i&&(!e&&s!==""||r&&o),resetScroll:!i&&r&&o}}function Bn(t){const e={};for(const n of Vt){if(!n)continue;const r=t.querySelector(n.selector)?.getAttribute(n.attr);r&&(e[n.key]=r)}return e}function Kn(t,e){const n=t.getAttribute("href")||t.getAttribute("xlink:href")||"";if(n.startsWith("#"))return F(n.substring(1));let r,s;if(t instanceof HTMLAnchorElement&&t.href)r=t.pathname,s=t.search;else{const o=wt(n,location.href.startsWith("http")?`${location.origin}/`:"http://localhost/");if(O.isErr(o))return"";const i=O.unwrap(o);r=i.pathname,s=i.search}if(r.startsWith("/")||(r=`/${r}`),e){const o=e.endsWith("/")?e:`${e}/`;(r.endsWith("/")?r:`${r}/`).startsWith(o)&&(r=r.substring(e.length))}return F(r)+s}function Xn(t){const{html:e,selector:n,redirectUrl:r}=t,s=Fn.parseFromString(e,"text/html"),o=s.querySelector("title"),i=o?o.textContent?.trim()??null:null,a=Bn(s),l=n?s.querySelector(n):null,u=l?l.innerHTML:s.body?.innerHTML??e,c={};if(l){const p=l.attributes;for(let m=0,v=p.length;m<v;m++){const E=p[m];E&&!$n.has(E.name)&&(c[E.name]=E.value)}}return{html:u.trim(),title:i,attributes:c,redirectUrl:r,meta:a}}function jn(t){const{el:e,active:n,activeClass:r}=t;e.classList.toggle(r,n),n?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current")}var rt={selectors:"a, [data-route]",attributes:["href","data-route","xlink:href"]},Wn=class{constructor(){this.managers=new Map}register(t,e,n){const r=this.managers.get(t);r&&r.type!==e&&C.warn("[atom-navigation]",`Target collision detected! Element is already managed by ${r.type}. Mixing atomNav and $.route on the same container leads to unpredictable state.`),this.managers.set(t,{type:e,canLeave:n}),y.onCleanup(t,()=>{this.managers.delete(t)})}canLeaveWithin(t){if(this.managers.size===0)return!0;for(const[e,n]of this.managers)if(n.canLeave&&t.contains(e)&&n.canLeave()===!1)return!1;return!0}isNestedIn(t,e){let n=t.parentElement;for(;n;){if(this.managers.get(n)?.type===e)return!0;n=n.parentElement}return!1}getManagerType(t){return this.managers.get(t)?.type}},kt=new Wn,Pe={get:t=>{let e=location.pathname;return t&&e.startsWith(t)&&(e=e.substring(t.length)),{path:F(e),query:Rt(location.search.substring(1)),url:location.pathname+location.search}},commit:(t,e)=>{const{route:n,query:r}=J(t),s=new URL(n,`${location.origin}${e}/`.replace(/\/+$/,"/"));h.map(r,i=>s.search=i);const o=s.pathname+s.search;return O.tryCatch(()=>history.pushState(null,"",o)),{path:F(n),query:Object.fromEntries(s.searchParams),url:o}},revert:t=>{location.pathname+location.search!==t&&O.tryCatch(()=>history.replaceState(null,"",t))},resolveAnchor:(t,e)=>Kn(t,e),setupListener:t=>(window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t))},zn={get:()=>{const{route:t,query:e}=J(location.hash.slice(1));return{path:t,query:Rt(h.unwrapOr(e,"")),url:location.hash}},commit:t=>{const{route:e,query:n}=J(t),r=`#${h.isSome(n)?`${e}?${h.unwrap(n)}`:e}`;return location.hash=r,{path:F(e),query:Rt(h.unwrapOr(n,"")),url:r}},revert:t=>{location.hash!==t&&(location.hash=t)},resolveAnchor:(t,e)=>Pe.resolveAnchor(t,e),setupListener:t=>(window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t))},Gn=(t,e)=>{const n=t==="history"?Pe:zn,r=e?`/${F(e)}`:"";return{get:()=>n.get(r),commit:s=>n.commit(s,r),revert:s=>n.revert(s),resolveAnchor:s=>n.resolveAnchor(s,r),setupListener:s=>n.setupListener(s)}},Yn=typeof URLPattern<"u",Ct=[{test:t=>!t.includes(":"),compile:(t,e)=>{const n=h.some({route:{pattern:t,def:e},params:{}});return{pattern:t,def:e,match:r=>r===t?n:h.none}}},{test:()=>Yn,compile:(t,e)=>{const n=new URLPattern({pathname:`/${t}`});return{pattern:t,def:e,match:r=>{const s=n.exec({pathname:`/${r}`});if(!s)return h.none;const o={},i=s.pathname.groups;for(const a in i){const l=i[a];l!=null&&(o[a]=l)}return h.some({route:{pattern:t,def:e},params:o})}}}},{test:()=>!0,compile:(t,e)=>{const n=[],r=new RegExp(`^${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:(\w+)/g,(s,o)=>(n.push(o),"([^/]+)"))}$`);return{pattern:t,def:e,match:s=>{const o=s.match(r);if(!o)return h.none;const i={};for(let a=0,l=n.length;a<l;a++){const u=o[a+1]||"";if(u.indexOf("%")!==-1)try{i[n[a]]=decodeURIComponent(u);continue}catch{}i[n[a]]=u}return h.some({route:{pattern:t,def:e},params:i})}}}}];function Qn(t,e){for(let n=0,r=Ct.length;n<r;n++){const s=Ct[n];if(s.test(t))return s.compile(t,e)}return Ct[Ct.length-1].compile(t,e)}function Jn(t){const e=new Map,n=[];for(const r in t){const s=t[r];if(s===void 0)continue;const o=F(r),i=Qn(o,s);o.includes(":")?n.push(i):e.set(o,i)}return{exact:e,dynamic:n}}function _e(t,e){const n=t.exact.get(e);if(n)return n.match(e);for(let r=0,s=t.dynamic.length;r<s;r++){const o=t.dynamic[r].match(e);if(h.isSome(o))return o}return h.none}function Bt(t,e){return h.unwrapOr(h.map(_e(t,e),n=>n.route.pattern),"")}function De(t,e,n,r){const s=F(e),o=_e(t,s);if(h.isSome(o)){const i=h.unwrap(o);return{def:i.route.def,pattern:i.route.pattern,params:i.params,isMatch:!0}}return{def:r?n[r]:void 0,pattern:s,params:{},isMatch:!1}}function Kt(t,e,n,r,s){const{def:o,pattern:i,params:a,isMatch:l}=De(t,n||e.default,e.routes,e.notFound),u={...r,...a};if(!o&&!l)return{success:!0,path:i,query:r,params:u,def:void 0};if(o?.onEnter){const c=(0,d.untracked)(()=>o.onEnter(u,s));if(c===!1)return{success:!1};c&&Object.assign(u,c)}return{success:!0,path:!n||n==="/"?i:n,query:r,params:u,def:o}}var Zn={render:(t,e,n,r,s,o)=>{e.render?.(t,n,r,s,o)},template:(t,e,n,r,s,o)=>{if(!e.template)return;const i=document.querySelector(e.template);i instanceof HTMLTemplateElement&&(t.appendChild(i.content.cloneNode(!0)),e.onMount?.((0,f.default)(t).children(),s,o))}};function qn(t,e,n){return{$target:t,config:e,urlAdapter:n,cleanups:new mt,previousPath:""}}function tr(t,e,n,r,s){const o=t.$target[0];if(!o)return;(0,d.untracked)(()=>t.config.beforeTransition(t.previousPath,n)),e.title&&(document.title=e.title),e.meta&&Oe(window,e.meta),o.replaceChildren();const i=c=>t.cleanups.push(c),a=e.render?"render":e.template?"template":null,l=a?Zn[a]:null;l&&l(o,e,n,r,i,s),C.enabled&&typeof customElements<"u"&&o.querySelectorAll(":not(:defined)").forEach(c=>{const p=c.tagName.toLowerCase();p.includes("-")&&C.warn(Y.PREFIX,Y.ERRORS.NOT_REGISTERED(p))}),(0,d.untracked)(()=>t.config.afterTransition(t.previousPath,n)),window.dispatchEvent(new CustomEvent("route-change",{detail:{from:t.previousPath,to:n,params:r}}));const u=t.previousPath===""&&kt.isNestedIn(o,"nav");if(!u){const c=o.querySelector('h1, [role="heading"]')||o;c.tabIndex=-1,c.focus()}t.previousPath=n,u||(location.hash?Tt(window,location.hash.substring(1)):window.scrollTo(0,0))}function Me(t){t.cleanups.forEach(e=>O.tryCatch(e)),t.cleanups.clear()}function er(t,e,n,r){return{config:t,matcher:e,urlAdapter:n,activeClass:r,trackedLinks:new Set,pathCache:new WeakMap,activeStateCache:new WeakMap}}function nr(t,e){const n=(a,l=!1)=>{const u=a.getAttribute("data-route")||t.urlAdapter.resolveAnchor(a);return u?l?J(u).route:u:""},r=(0,d.computed)(()=>Bt(t.matcher,e.value)),s=(a,l,u)=>{const c=t.pathCache.get(a)||n(a,!0),p=c===l||c===u;t.activeStateCache.get(a)!==p&&(t.activeStateCache.set(a,p),jn({el:a,active:p,activeClass:t.activeClass}))},o=a=>{const l=n(a,!0);if(t.pathCache.set(a,l),t.trackedLinks.has(a)){s(a,e.peek(),r.peek());return}t.trackedLinks.add(a);const u=(0,d.effect)(()=>{s(a,e.value,r.value)});y.onCleanup(a,()=>{t.trackedLinks.delete(a),u.dispose()})},i=()=>document.querySelectorAll(rt.selectors).forEach(o);return t.linkObserver=new MutationObserver(a=>{for(const l of a)l.type==="childList"?l.addedNodes.forEach(u=>{if(u.nodeType===1){const c=u;c.matches(rt.selectors)&&o(c),c.querySelectorAll(rt.selectors).forEach(p=>o(p))}}):l.type==="attributes"&&o(l.target)}),t.linkObserver.observe(document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:rt.attributes}),i(),{scan:i,resolvePath:n}}function rr(){const t={};let e;return document.querySelectorAll("template[data-path]").forEach(n=>{const r=F(n.getAttribute("data-path")??""),s=n.getAttribute("title")??n.getAttribute("data-title");t[r]?s&&!t[r].title&&(t[r].title=s):(n.id||=`route-${Math.random().toString(36).slice(2,11)}`,t[r]={template:`#${n.id}`,...s?{title:s}:{}}),n.hasAttribute("data-default")&&(e=r)}),{routes:t,default:e}}function sr(t,e,n,r){const s=(i,a)=>a instanceof HTMLAnchorElement&&(i.split("/").pop()??"").includes(".")&&!Bt(e,J(i).route)?!1:!!Bt(e,J(i).route)||!!t.notFound,o=i=>{if(i.isDefaultPrevented()||!Ne(i))return;const a=i.currentTarget;if(!Ie(a))return;const l=n(a);l&&s(l,a)&&(i.preventDefault(),r(l))};return(0,f.default)(document).on("click",rt.selectors,o),()=>(0,f.default)(document).off("click",rt.selectors,o)}var or=class{constructor(t){this.stateAtom=(0,d.atom)({isDestroyed:!1,isTransitioning:!1,previousUrl:"",currentDef:void 0}),this.cleanups=new mt,this.context={currentRoute:(0,d.computed)(()=>this.currentRouteAtom.value),queryParams:(0,d.computed)(()=>this.queryParamsAtom.value),params:(0,d.computed)(()=>this.paramsAtom.value),location:(0,d.computed)(()=>({path:this.currentRouteAtom.value,query:this.queryParamsAtom.value,params:this.paramsAtom.value})),navigate:i=>this.navigate(i),destroy:()=>this.destroy()},this.config={mode:q.DEFAULTS.mode,basePath:q.DEFAULTS.basePath,autoBindLinks:q.DEFAULTS.autoBindLinks,activeClass:q.DEFAULTS.activeClass,notFound:t.notFound??"",beforeTransition:t.beforeTransition??(()=>{}),afterTransition:t.afterTransition??(()=>{}),...t,routes:t.routes??{}};const e=this.config.target;this.$target=typeof e=="string"||e instanceof HTMLElement?(0,f.default)(e):e,this.urlAdapter=Gn(this.config.mode,this.config.basePath);const n=rr();for(const i in n.routes){const a=n.routes[i];if(this.config.routes[i]){const l=this.config.routes[i];!l.title&&a.title&&(l.title=a.title),!l.template&&a.template&&(l.template=a.template)}else this.config.routes[i]=a}this.config.default===void 0&&(this.config.default=n.default??""),this.matcher=Jn(this.config.routes),this.scanner=er(this.config,this.matcher,this.urlAdapter,this.config.activeClass),this.renderer=qn(this.$target,this.config,this.urlAdapter);const r=this.urlAdapter.get();this.stateAtom.value={...this.stateAtom.peek(),previousUrl:r.url};const s=Kt(this.matcher,this.config,F(r.path),r.query,this.context),o=s.success?s:{path:this.config.default,query:{},params:{}};this.currentRouteAtom=(0,d.atom)(o.path),this.currentRoute=this.currentRouteAtom,this.queryParamsAtom=(0,d.atom)(o.query),this.queryParams=(0,d.computed)(()=>this.queryParamsAtom.value),this.paramsAtom=(0,d.atom)(o.params),this.params=this.paramsAtom,this.location=(0,d.computed)(()=>({path:this.currentRouteAtom.value,query:this.queryParamsAtom.value,params:this.paramsAtom.value})),this.setupLifecycle()}setupLifecycle(){this.cleanups.push(this.urlAdapter.setupListener(()=>this.handleBrowserSync()));const t=(0,d.effect)(()=>{const n=this.currentRouteAtom.value;(0,d.untracked)(()=>{Me(this.renderer),this.render(n)})});this.cleanups.push(()=>t.dispose());const{resolvePath:e}=nr(this.scanner,this.currentRoute);this.cleanups.push(()=>this.scanner.linkObserver?.disconnect()),this.config.autoBindLinks&&this.cleanups.push(sr(this.config,this.matcher,e,n=>this.navigate(n))),this.$target[0]&&(kt.register(this.$target[0],"router",()=>this.canLeave()),y.onCleanup(this.$target[0],()=>this.destroy()))}updateState(t,e,n){(0,d.batch)(()=>{_t(this.paramsAtom.peek(),n)||(this.paramsAtom.value=n),_t(this.queryParamsAtom.peek(),e)||(this.queryParamsAtom.value=e),this.currentRouteAtom.peek()!==t&&(this.currentRouteAtom.value=t)})}async navigate(t,e={}){const n=this.stateAtom.peek();if(n.isDestroyed||!this.canLeave())return;let r,s=e;if(typeof t=="string"){const{route:a,query:l}=J(t);r=a||this.config.default,h.isSome(l)&&(s={...Rt(h.unwrap(l)),...e})}else r=t.path||this.currentRouteAtom.peek(),s={...t.query,...e};if(!r)return;const o=new URLSearchParams(s).toString(),i=o?`${r}?${o}`:r;this.stateAtom.value={...n,isTransitioning:!0};try{const a=this.urlAdapter.commit(i),l=Kt(this.matcher,this.config,a.path,a.query,this.context);l.success?this.updateState(l.path,l.query,l.params):this.urlAdapter.revert(n.previousUrl)}finally{this.stateAtom.value={...this.stateAtom.peek(),isTransitioning:!1}}}handleBrowserSync(){const t=this.stateAtom.peek();if(t.isDestroyed||t.isTransitioning)return;const e=this.urlAdapter.get();if(e.url===t.previousUrl)return;if(!this.canLeave()){this.stateAtom.value={...t,isTransitioning:!0};try{this.urlAdapter.revert(t.previousUrl)}finally{this.stateAtom.value={...this.stateAtom.peek(),isTransitioning:!1}}return}const n=Kt(this.matcher,this.config,F(e.path),e.query,this.context);(0,d.batch)(()=>{if(n.success)this.updateState(n.path,n.query,n.params);else{this.stateAtom.value={...t,isTransitioning:!0};try{this.urlAdapter.revert(t.previousUrl)}finally{this.stateAtom.value={...this.stateAtom.peek(),isTransitioning:!1}}}})}render(t){const{def:e,pattern:n}=De(this.matcher,t,this.config.routes,this.config.notFound);if(!e){C.warn(q.PREFIX,q.ERRORS.NOT_FOUND(t));return}this.stateAtom.value={...this.stateAtom.peek(),currentDef:e,previousUrl:this.urlAdapter.get().url},tr(this.renderer,e,n,this.paramsAtom.peek(),this.context)}canLeave(){const t=this.stateAtom.peek().currentDef||this.config.routes[this.config.notFound];return t?.onLeave?(0,d.untracked)(()=>t.onLeave(this.context))!==!1:!0}destroy(){const t=this.stateAtom.peek();t.isDestroyed||(this.stateAtom.value={...t,isDestroyed:!0},Me(this.renderer),this.cleanups.forEach(e=>O.tryCatch(e)),this.cleanups.dispose())}};function ir(t){return new or(t)}f.default.extend({route:ir});function ar(t,e){const{ajaxOptions:n,method:r,headers:s}=e,o=typeof n=="object"?n:{},i=typeof n=="function"?n():{};return{...o,...i,url:t,method:r||i.method||o.method,headers:{...o.headers,...i.headers,...s},success:void 0,error:void 0,complete:void 0}}function Ue(t){if(t&&typeof t=="object"&&"readyState"in t){const e=t,n=e.statusText||(e.status===0?"Network Error":"Request Failed"),r=new Error(`Network Error: ${n} (${e.status})`);return r.jqXHR=e,r}return t instanceof Error?t:new Error(String(t??"Unknown error"))}function lr(t,e){const n=typeof t=="string"?()=>t:t;let r=null;const s=async()=>{r?.abort();const a=new AbortController;r=a;let l;const u=()=>{l&&typeof l.abort=="function"&&l.abort()};a.signal.addEventListener("abort",u),a.signal.aborted&&u();try{let c;try{const m=ar(n(),e);l=f.default.ajax(m);const v=await l;c=O.ok(v)}catch(m){c=O.err(Ue(m))}if(!c.ok){const m=c.error;if(a.signal.aborted){const v=new Error("AbortError");throw v.name="AbortError",v}if(e.onError){const v=O.tryCatch(()=>e.onError(m));v.ok||console.error("atomFetch: onError hook threw an error",v.error)}throw m}const p=c.value;try{const m=e.transform?e.transform(p,l):p;return m instanceof Promise?await m:m}catch(m){const v=Ue(m);throw e.onError&&O.tryCatch(()=>e.onError(v)),v}}finally{a.signal.removeEventListener("abort",u),r===a&&(r=null)}},o=(0,d.computed)(s,{defaultValue:e.defaultValue,lazy:e.eager===!1,...e.name!==void 0?{name:e.name}:{}}),i=o.dispose.bind(o);return o.dispose=()=>{r?.abort(),i()},Object.assign(o,{abort:()=>r?.abort()})}f.default.extend({atomFetch:lr});var $e={push:{historyMethod:"pushState",isInitial:!1},replace:{historyMethod:"replaceState",isInitial:!1},init:{historyMethod:null,isInitial:!0},pop:{historyMethod:null,isInitial:!1}},cr=[{key:"title",apply:(t,e,n,r)=>{const s=n;r.syncTitle&&s!==null&&t.document.title!==s&&(t.document.title=s)}},{key:"meta",apply:(t,e,n)=>Oe(t,n)},{key:"attributes",apply:(t,e,n)=>{const r=e[0];r&&n&&xn(r,n)}},{key:"html",apply:(t,e,n)=>e.html(n)}];function ur(t){const{$target:e,state:n,url:r,previousUrl:s,win:o,syncTitle:i,onMount:a,onUnmount:l}=t;f.default.untracked(()=>{l?.(e,s),e.children().atomUnbind();for(const u of cr){const c=n[u.key];u.apply(o,e,c,{syncTitle:i})}a?.(e,r)})}function fr(t){const{url:e,type:n,win:r,state:s}=t,o=$e[n];o.historyMethod&&f.default.batch(()=>{r.history[o.historyMethod](null,"",e),s.value={url:e,type:n}})}function dr(t){const{target:e,selector:n="a[data-nav]",headers:r={},syncTitle:s=!0}=t,o=t.window??window,i=typeof e=="string"||e instanceof HTMLElement?(0,f.default)(e):e;i.attr("data-atom-nav-target","true");const a=new URL(o.location.href),l=a.pathname+a.search+a.hash,u=a.pathname+a.search,c={intent:f.default.atom({url:l,type:"init"},{name:"nav:intent"}),rendered:f.default.atom({url:l,path:u},{name:"nav:rendered"}),fetchVersion:f.default.atom(0,{name:"nav:version"}),pendingHooks:f.default.atom(0,{name:"nav:hook-pending"})},p=h.unwrapOr(h.map(h.fromNullable(typeof e=="string"?e:i.attr("id")),b=>b.startsWith("#")?b:`#${f.default.escapeSelector(b)}`),void 0),m=f.default.computed(()=>{const{url:b,type:g}=c.intent.value,{pathAndSearch:S,hash:k}=Le(b,o.location.href);return{url:b,pathAndSearch:S,hash:k,type:g}},{name:"nav:normalized"}),v=f.default.atomFetch(()=>(c.fetchVersion.value,m.value.pathAndSearch),{name:"nav:content",defaultValue:{html:"",title:null},headers:{"X-PJAX":"true",...r},eager:!1,transform:(b,g)=>{const S=g?.getResponseHeader?.("X-PJAX-URL")??void 0,k=Xn({html:String(b),selector:p,redirectUrl:S});return{...k,html:ct(k.html).trim()}}});let E=null;const A=new AbortController,w=()=>{E?.abort(),"abort"in v&&typeof v.abort=="function"&&v.abort();const b=new AbortController;return E=b,b},T=f.default.effect(()=>{const{url:b,pathAndSearch:g,hash:S,type:k}=m.value,D=f.default.untracked(()=>c.rendered.value),P=$e[k];if(g===D.path){f.default.untracked(()=>{S&&Tt(o,S),P.isInitial?(t.onMount?.(i,b),c.intent.value={...c.intent.peek(),type:"push"}):b!==D.url&&(c.rendered.value={...D,url:b})});return}const W=v.value;if(v.hasError){const dt=v.lastError;if(dt instanceof Error&&dt.name==="AbortError")return;(t.onError?.(dt,b)??!0)!==!1&&o.location.assign(b);return}if(!v.isResolved||v.isPending)return;const Z=!!(W.redirectUrl&&W.redirectUrl!==b),Ot=D.url;let z=Z?W.redirectUrl:b;Z&&S&&!z.includes("#")&&(z+=`#${S}`);const{pathAndSearch:G}=Le(z,o.location.href),ot=G!==D.path;f.default.batch(()=>{Z&&(o.history.replaceState(null,"",z),c.intent.value={url:z,type:"push"}),(ot||Z)&&ur({$target:i,state:W,url:z,previousUrl:Ot,win:o,syncTitle:s,onMount:t.onMount,onUnmount:t.onUnmount});const{shouldScroll:dt,resetScroll:wr}=Vn({hash:S,type:k,isNewTarget:ot,prevHash:O.unwrap(wt(D.url,o.location.href)).hash.slice(1),scrollToTop:t.scrollToTop??!0});dt&&Tt(o,S,wr),c.rendered.value={url:z,path:G}})},{name:"nav:sync-effect"}),N=()=>{w();const b=o.location;c.intent.value={url:b.pathname+b.search+b.hash,type:"pop"}};o.addEventListener("popstate",N,{signal:A.signal}),o.document.addEventListener("click",b=>{if(b.defaultPrevented)return;const g=b.target.closest(n);if(!g)return;const S=i.attr("id"),k=g.dataset.target,D=!!(k&&S&&k===`#${S}`);if(!(k&&!D)){if(!D){const P=(0,f.default)(g).closest('[data-atom-nav-target="true"]')[0];if(P&&P!==i[0])return}Ne(b)&&Ie(g,o)&&(b.preventDefault(),Q.navigate(g.href))}},{signal:A.signal});const I=f.default.computed(()=>v.isPending||c.pendingHooks.value>0?"pending":v.hasError?"error":"idle",{name:"nav:status"}),V=f.default.computed(()=>I.value==="pending",{name:"nav:isPending"}),$=f.default.computed(()=>I.value==="error",{name:"nav:hasError"}),Q={currentUrl:f.default.computed(()=>c.rendered.value.url,{name:"nav:public-url"}),isPending:V,hasError:$,async navigate(b,g={}){const{signal:S}=w(),k=g.replace?"replace":"push",D=wt(b,o.document.baseURI??o.location.href);if(O.isErr(D))return;const P=O.unwrap(D),W=new URL(o.location.href),Z=P.pathname+P.search,Ot=Z===W.pathname+W.search,z=[()=>P.origin!==W.origin?(o.location.assign(b),!1):!0,()=>Ot&&P.hash===(W.hash??"")&&k==="push"?($.peek()?c.fetchVersion.value++:b.includes("#")&&Tt(o,P.hash.slice(1),!0),!1):!0,()=>!Ot&&t.onBeforeLoad?(async()=>{c.pendingHooks.value++;try{const G=await t.onBeforeLoad(b,S);return!(S.aborted||G===!1)}finally{c.pendingHooks.value=Math.max(0,c.pendingHooks.value-1)}})():!0,()=>{const G=i[0];return!(G&&!kt.canLeaveWithin(G))}];for(const G of z){const ot=G();if(ot instanceof Promise){if(!await ot)return}else if(!ot)return}fr({url:Z+P.hash,type:k,win:o,state:c.intent})},destroy(){A.abort(),E?.abort(),T.dispose(),v.dispose(),i.removeAttr("data-atom-nav-target"),[c.intent,c.fetchVersion,c.pendingHooks,c.rendered,m,Q.currentUrl,I,V,$].forEach(b=>b.dispose?.())}};return i[0]&&(kt.register(i[0],"nav"),y.onCleanup(i[0],()=>Q.destroy())),Q}f.default.extend({atomNav:dr});var Fe=(t,e)=>e instanceof ShadowRoot?e:t.shadowRoot instanceof ShadowRoot?t.shadowRoot:null,hr=t=>(0,d.isAtom)(t)?t.value:typeof t=="function"?t():t,j={dispatch(t,e,n){for(const[r,s]of Object.entries(e))n.push(f.default.effect(()=>{const o=hr(s),i=typeof s=="function"&&typeof o=="object"&&o!==null?o:{value:o};t.dispatchEvent(new CustomEvent(r,{detail:i,bubbles:!0,composed:!0}))}))},styles(t,e){return t.adoptedStyleSheets=[...t.adoptedStyleSheets,...e],e},aria(t,e,n){for(const[r,s]of Object.entries(e))n.push(f.default.effect(()=>{const o=s.value;t[r]=o!=null?String(o):null}))},hydrate(t,e,n,r){const{BIND:s,LEGACY_BIND:o}=Y.ATTRS,i=`[${s}],[${o}]`,a=l=>{const u=l;if(u[Dt])return;const c=l.getAttribute(s)||l.getAttribute(o),p=c?e[c]:null;p&&(n.push(f.default.effect(()=>{const m=String(p.value??"");l.textContent!==m&&(l.textContent=m)})),u[Dt]=!0,r.add(l))};this.observe(t,i,a,n)},parts(t,e,n){const r=Y.ATTRS.PART,s=o=>{const i=o.getAttribute(r),a=i?e[i]:null;a&&n.push(f.default.effect(()=>{const l=a.value;let u;typeof l=="string"?u=l:Array.isArray(l)?u=l.join(" "):typeof l=="object"&&l!==null?u=Object.entries(l).filter(([,c])=>c).map(([c])=>c).join(" "):u="",o.getAttribute("part")!==u&&o.setAttribute("part",u)}))};this.observe(t,`[${r}]`,s,n)},observe(t,e,n,r){t instanceof Element&&t.matches(e)&&n(t);const s=t.querySelectorAll(e);for(let i=0;i<s.length;i++)n(s[i]);const o=new MutationObserver(i=>{for(let a=0;a<i.length;a++){const l=i[a].addedNodes;for(let u=0;u<l.length;u++){const c=l[u];if(c instanceof Element){c.matches(e)&&n(c);const p=c.querySelectorAll(e);for(let m=0;m<p.length;m++)n(p[m])}}}});o.observe(t,{childList:!0,subtree:!0}),r.push(f.default.effect(()=>()=>o.disconnect()))},form(t,e,n,r,s){const o=n&&((0,d.isAtom)(n)?n:n.val),i=n&&!(0,d.isAtom)(n)?n.state:null;s.push(f.default.effect(()=>{if(o){const a=o.value,l=i?i.value:null;if(typeof a=="object"&&a!==null&&!(a instanceof File)&&!(a instanceof Blob)){const u=new FormData;Zt(u,t.getAttribute("name")||"",a),e.setFormValue(u,l)}else e.setFormValue(a,l)}if(r){const a=o?o.value:void 0,l=(0,d.isAtom)(r)?r.value:r(a);typeof l=="string"?e.setValidity(l?{customError:!0}:{},l,t):e.setValidity(l,void 0,t)}}))},attributes(t){const e=()=>t.constructor.observedAttributes||[],n=()=>{const a=e(),l={};if(a.length>0)for(let u=0;u<a.length;u++){const c=a[u];l[c]=t.getAttribute(c)}else{const u=t.attributes;for(let c=0;c<u.length;c++){const p=u[c];l[p.name]=p.value}}return l},r=f.default.atom(n()),s=new MutationObserver(()=>{r.value=n()}),o={attributes:!0},i=e();return i.length>0&&(o.attributeFilter=i),s.observe(t,o),{atom:r,observer:s}},slots(t){const e=s=>{const o={};if(s){const i=s.querySelectorAll("slot");for(let a=0;a<i.length;a++){const l=i[a];o[l.name||""]=l.assignedNodes()}}return o},n=f.default.atom(e(t)),r=s=>{const o=s.target,i={...n.peek()};i[o.name||""]=o.assignedNodes(),n.value=i};return t&&(n.value=e(t),t.addEventListener("slotchange",r)),{atom:n,listener:r}}},pr=class{constructor(t){this.host=t,this.root=h.none,this.isInitialized=!1,this.effects=new mt,this.hydratedNodes=new Set,this.attributeAtom=null,this.attributeObserver=null,this.attributeLenses=new Map,this.slotsAtom=null,this.slotLenses=new Map,this.slotListeners=new Map,this.appliedStyles=[]}dispose(){this.effects.forEach(n=>n.dispose()),this.effects.dispose(),this.hydratedNodes.forEach(n=>{delete n[Dt]}),this.hydratedNodes.clear(),this.attributeObserver&&(this.attributeObserver.disconnect(),this.attributeObserver=null),this.attributeAtom=null,this.attributeLenses.clear();const t=Fe(this.host,h.toNullable(this.root));t&&this.slotListeners.forEach(n=>t.removeEventListener("slotchange",n)),this.slotListeners.clear(),this.slotsAtom=null,this.slotLenses.clear();const e=h.toNullable(this.root);if(e){this.appliedStyles.length>0&&(e instanceof ShadowRoot||e instanceof Document)&&(e.adoptedStyleSheets=e.adoptedStyleSheets.filter(r=>!this.appliedStyles.includes(r))),this.appliedStyles=[];const n=e;n[Et]&&(fn(e),n[Et]=!1)}this.root=h.none,this.isInitialized=!1}},ut=new WeakMap,st=new Map,mr=100;C.enabled&&typeof window<"u"&&(window.__AEJ_INTERNAL__={nodeStateMap:ut,sheetCache:st,version:"0.32.0"});var ft=new WeakMap,Xt=t=>{let e=ut.get(t);return e||(e={},ut.set(t,e)),e},vr=typeof window<"u"&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype,gr=typeof window<"u"&&"attachInternals"in HTMLElement.prototype,Er=t=>{if(t instanceof CSSStyleSheet)return t;let e=st.get(t);if(!e){if(e=new CSSStyleSheet,e.replaceSync(t),st.size>=mr){const n=st.keys().next().value;n!==void 0&&st.delete(n)}st.set(t,e)}return e},X=(()=>{const t=f.default.atom(0);let e=!1,n=null,r=0;const s=()=>{e||(e=!0,queueMicrotask(()=>{t.value++,e=!1}))},o=l=>{const u=ft.get(l);if(u){const c=ut.get(l)?.controller;c&&c.setup({...u.aejStyles&&{styles:u.aejStyles},...u.aejBind&&{bind:u.aejBind},...u.aejAria&&{aria:u.aejAria},...u.aejParts&&{parts:u.aejParts},...u.aejDispatch&&{dispatch:u.aejDispatch},...u.aejValue&&{value:u.aejValue},...u.aejValidation&&{validation:u.aejValidation}}),ft.delete(l),X.release()}},i=()=>{n||typeof document>"u"||(n=new MutationObserver(l=>{let u=!1;for(let c=0;c<l.length;c++){const p=l[c];if(p.addedNodes.length>0){u=!0;for(let m=0;m<p.addedNodes.length;m++){const v=p.addedNodes[m];if(v instanceof HTMLElement){o(v);const E=v.querySelectorAll("*");for(let A=0;A<E.length;A++)o(E[A])}}}p.removedNodes.length>0&&(u=!0)}u&&s()}),n.observe(document.documentElement,{childList:!0,subtree:!0}))},a=()=>{n&&(n.disconnect(),n=null)};return{get version(){return t},bump:s,retain(){r++,r===1&&i()},release(){r--,r===0&&a()},discover(l,u){let c=h.none;const p=new CustomEvent(ie,{detail:{key:u,callback:m=>{c=h.some(m)}},bubbles:!0,composed:!0});return l.dispatchEvent(p),c}}})();function yr(t,e){const n=i=>(i?X.version.peek():X.version.value,(0,d.untracked)(()=>X.discover(t,e))),r=i=>{const a=n(i);if(h.isNone(a))return null;const l=h.unwrap(a);return(0,d.isAtom)(l)?i?l.peek():l.value:l};let s=null;const o=()=>(s||(s=f.default.computed(()=>r(!1))),s);return{get value(){return r(!1)},set value(i){const a=n(!0);if(h.isSome(a)){const l=h.unwrap(a);(0,d.isWritable)(l)&&(l.value=i)}},peek(){return r(!0)},subscribe:i=>{X.retain();const a=o().subscribe(i);return()=>{a(),X.release()}},subscriberCount:()=>s?s.subscriberCount():0,dispose:()=>{s&&(s.dispose(),s=null)},[d.BRAND]:d.BrandFlags.Atom|d.BrandFlags.Writable}}function Ar(t){if(C.enabled&&typeof customElements<"u"){const i=t.tagName.toLowerCase();i.includes("-")&&!customElements.get(i)&&C.warn(Y.PREFIX,Y.ERRORS.NOT_REGISTERED(i))}const e=Xt(t);if(e.controller)return e.controller;let n;if(gr)try{n=t.attachInternals()}catch{}const r=new pr(t),s={host:t,get root(){return h.toNullable(r.root)},get internals(){return n},get attrs(){if(!r.attributeAtom){const{atom:i,observer:a}=j.attributes(t);r.attributeAtom=i,r.attributeObserver=a}return i=>{let a=r.attributeLenses.get(i);return a||(a=f.default.atomLens(r.attributeAtom,i),r.attributeLenses.set(i,a)),a}},get slots(){if(!r.slotsAtom){const i=Fe(t,h.toNullable(r.root)),{atom:a,listener:l}=j.slots(i);r.slotsAtom=a,i&&r.slotListeners.set("all",l)}return i=>{const a=i==="default"?"":i;let l=r.slotLenses.get(a);return l||(l=f.default.atomLens(r.slotsAtom,a),r.slotLenses.set(a,l)),l}},$:((i,a)=>{const l=a??h.toNullable(r.root)??t;return typeof i!="string"?(0,f.default)(i):l instanceof DocumentFragment?(0,f.default)(l.querySelectorAll(i)):(0,f.default)(i,l)}),provideAtom:(i,a)=>xe(t,i,a),injectAtom:i=>He(t,i),setup(i){if(r.isInitialized){const c=i instanceof Node?i:i?.shadowRoot;if(c&&c!==h.toNullable(r.root))throw new Error("Call teardown() first to change the root.");return}const a=i instanceof Node?{shadowRoot:i}:i??{},l=h.fromNullable(a.shadowRoot??t.shadowRoot);h.map(l,c=>{y.markHost(t),y.registerShadow(t,c)});const u=h.unwrapOr(l,t);if(r.root=h.some(u),u[Et]||(gt(u),u[Et]=!0),!r.slotsAtom){const c=h.toNullable(l),{atom:p,listener:m}=j.slots(c);r.slotsAtom=p,c&&r.slotListeners.set("all",m)}a.dispatch&&j.dispatch(t,a.dispatch,r.effects),a.bind&&j.hydrate(u,a.bind,r.effects,r.hydratedNodes),a.styles&&vr&&(u instanceof ShadowRoot||u instanceof Document)&&(r.appliedStyles=j.styles(u,a.styles.map(Er))),a.aria&&n&&j.aria(n,a.aria,r.effects),a.parts&&j.parts(u,a.parts,r.effects),(a.value||a.validation)&&n&&j.form(t,n,a.value,a.validation,r.effects),r.isInitialized=!0},teardown(){const i=ut.get(t);i&&(i.providers?.clear(),i.providerEffects?.forEach(a=>a.dispose()),i.providerEffects?.clear(),i.injects?.clear()),ft.has(t)&&(ft.delete(t),X.release()),X.bump(),r.dispose(),y.cleanupTree(t)}},o=t.constructor;return(o.aejStyles||o.aejBind||o.aejAria||o.aejParts||o.aejDispatch||o.aejValue||o.aejValidation)&&(t.isConnected?s.setup({...o.aejStyles&&{styles:o.aejStyles},...o.aejBind&&{bind:o.aejBind},...o.aejAria&&{aria:o.aejAria},...o.aejParts&&{parts:o.aejParts},...o.aejDispatch&&{dispatch:o.aejDispatch},...o.aejValue&&{value:o.aejValue},...o.aejValidation&&{validation:o.aejValidation}}):(ft.set(t,o),X.retain())),y.setTeardown(t,()=>s.teardown()),e.controller=s,s}function xe(t,e,n){const r=t instanceof HTMLElement?[t]:typeof t=="string"?Array.from(document.querySelectorAll(t)):t.toArray();for(let s=0;s<r.length;s++){const o=r[s],i=Xt(o);i.providers||(i.providers=new Map,o.addEventListener(ie,l=>{const{key:u,callback:c}=l.detail;i.providers?.has(u)&&(l.stopPropagation(),c(i.providers.get(u)))})),i.providers.set(e,n);const a=typeof e=="symbol"?e.description:String(e);if(a){const l=`--aej-${a}`,u=c=>o.style.setProperty(l,String(c??""));(0,d.isAtom)(n)?(i.providerEffects||(i.providerEffects=new Map),i.providerEffects.get(e)?.dispose(),i.providerEffects.set(e,f.default.effect(()=>{u(n.value)}))):u(n)}}X.bump()}function He(t,e){const n=t instanceof HTMLElement?t:typeof t=="string"?document.querySelector(t):t[0];if(!n)return null;if(C.enabled&&typeof customElements<"u"){const o=n.tagName.toLowerCase();o.includes("-")&&!customElements.get(o)&&C.warn(Y.PREFIX,Y.ERRORS.NOT_REGISTERED(o))}const r=Xt(n);r.injects||(r.injects=new Map);let s=r.injects.get(e);return s||(s=yr(n,e),r.injects.set(e,s)),s}f.default.extend({provideAtom:xe,injectAtom:He,useAtomComponent:Ar});var jt=new WeakMap,H=null,Wt=t=>{if(t[at])return t;const e=jt.get(t);if(e)return e;const n=function(...r){return(0,d.batch)(()=>t.apply(this,r))};return n[at]=!0,jt.set(t,n),n},Ve=t=>jt.get(t)??t;function Be(t){const e={};for(const n in t){const r=t[n];e[n]=typeof r=="function"?Wt(r):r}return e}function Sr(t){const e={};for(const n in t){const r=t[n];e[n]=typeof r=="function"?Ve(r):r}return e}function zt(t,e,n){const r=t[0];if(r&&typeof r=="object")t[0]=e(r);else for(let s=1;s<t.length;s++)typeof t[s]=="function"&&(t[s]=n(t[s]))}function Ke(t={}){if(H!==null)return;const{events:e=!0,lifecycle:n=!0}=t;H={on:f.default.fn.on,one:f.default.fn.one,off:f.default.fn.off,remove:f.default.fn.remove,empty:f.default.fn.empty,detach:f.default.fn.detach};const r=H;n&&(f.default.fn.remove=function(s){const o=s?this.filter(s):this,i=o.length;for(let a=0;a<i;a++){const l=o[a];l&&(y.markIgnored(l),y.cleanupTree(l))}return r.remove.call(this,s)},f.default.fn.empty=function(){const s=this.length;for(let o=0;o<s;o++){const i=this[o];i?.hasChildNodes()&&y.cleanupDescendants(i)}return r.empty.call(this)},f.default.fn.detach=function(s){const o=s?this.filter(s):this,i=o.length;for(let a=0;a<i;a++){const l=o[a];l&&y.keep(l)}return r.detach.call(this,s)}),e&&(f.default.fn.on=function(...s){return zt(s,Be,Wt),r.on.apply(this,s)},f.default.fn.one=function(...s){return zt(s,Be,Wt),r.one.apply(this,s)},f.default.fn.off=function(...s){return zt(s,Sr,Ve),r.off.apply(this,s)})}function Xe(){H!==null&&(f.default.fn.on=H.on,f.default.fn.one=H.one,f.default.fn.off=H.off,f.default.fn.remove=H.remove,f.default.fn.empty=H.empty,f.default.fn.detach=H.detach,H=null)}function Gt(t={}){const{patch:e=!0,autoCleanup:n=!0}=t;if(Xe(),e!==!1&&Ke(typeof e=="object"?e:{}),oe(),n!==!1){re(!0);const r=typeof n=="object"?n.root:document.body;r&&(gt(r),y.setAutoCleanupScheduled(!0))}else re(!1)}(0,f.default)(()=>{window.AEJ_NO_AUTO_INIT||Gt()});function br(t){t instanceof HTMLElement?y.cleanupTree(t):t.each((e,n)=>y.cleanupTree(n))}f.default.extend({initAEJ:Gt});var Rr=f.default;M.cleanup=br,M.default=Rr,M.disableAutoCleanup=oe,M.disablejQueryOverrides=Xe,M.enableAutoCleanup=gt,M.enablejQueryOverrides=Ke,M.initAEJ=Gt});
|
|
9
|
+
|
|
11
10
|
//# sourceMappingURL=atom-effect-jquery.min.js.map
|