@but212/atom-effect-jquery 0.31.0 → 0.32.1

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.
Files changed (78) hide show
  1. package/README.md +32 -28
  2. package/dist/atom-effect-jquery.min.js +9 -5
  3. package/dist/atom-effect-jquery.min.js.map +1 -1
  4. package/dist/bindings/chainable.d.ts +2 -0
  5. package/dist/bindings/chainable.d.ts.map +1 -0
  6. package/dist/bindings/form.d.ts +33 -0
  7. package/dist/bindings/form.d.ts.map +1 -0
  8. package/dist/bindings/input-binding.d.ts +31 -0
  9. package/dist/bindings/input-binding.d.ts.map +1 -0
  10. package/dist/bindings/list/context.d.ts +82 -0
  11. package/dist/bindings/list/context.d.ts.map +1 -0
  12. package/dist/bindings/list/diff.d.ts +24 -0
  13. package/dist/bindings/list/diff.d.ts.map +1 -0
  14. package/dist/bindings/list/dom.d.ts +50 -0
  15. package/dist/bindings/list/dom.d.ts.map +1 -0
  16. package/dist/bindings/list/index.d.ts +19 -0
  17. package/dist/bindings/list/index.d.ts.map +1 -0
  18. package/dist/bindings/list/types.d.ts +100 -0
  19. package/dist/bindings/list/types.d.ts.map +1 -0
  20. package/dist/bindings/list/utils.d.ts +33 -0
  21. package/dist/bindings/list/utils.d.ts.map +1 -0
  22. package/dist/bindings/mount.d.ts +2 -0
  23. package/dist/bindings/mount.d.ts.map +1 -0
  24. package/dist/bindings/unified.d.ts +135 -0
  25. package/dist/bindings/unified.d.ts.map +1 -0
  26. package/dist/constants.d.ts +108 -0
  27. package/dist/constants.d.ts.map +1 -0
  28. package/dist/core/dom.d.ts +26 -0
  29. package/dist/core/dom.d.ts.map +1 -0
  30. package/dist/core/effect-factory.d.ts +34 -0
  31. package/dist/core/effect-factory.d.ts.map +1 -0
  32. package/dist/core/jquery-patch.d.ts +12 -0
  33. package/dist/core/jquery-patch.d.ts.map +1 -0
  34. package/dist/core/namespace.d.ts +11 -0
  35. package/dist/core/namespace.d.ts.map +1 -0
  36. package/dist/core/navigation.d.ts +172 -0
  37. package/dist/core/navigation.d.ts.map +1 -0
  38. package/dist/core/registry.d.ts +189 -0
  39. package/dist/core/registry.d.ts.map +1 -0
  40. package/dist/core/symbols.d.ts +33 -0
  41. package/dist/core/symbols.d.ts.map +1 -0
  42. package/dist/features/fetch.d.ts +2 -0
  43. package/dist/features/fetch.d.ts.map +1 -0
  44. package/dist/features/nav.d.ts +23 -0
  45. package/dist/features/nav.d.ts.map +1 -0
  46. package/dist/features/route/core.d.ts +83 -0
  47. package/dist/features/route/core.d.ts.map +1 -0
  48. package/dist/features/route/index.d.ts +43 -0
  49. package/dist/features/route/index.d.ts.map +1 -0
  50. package/dist/features/route/router.d.ts +74 -0
  51. package/dist/features/route/router.d.ts.map +1 -0
  52. package/dist/features/route/types.d.ts +60 -0
  53. package/dist/features/route/types.d.ts.map +1 -0
  54. package/dist/features/route/view.d.ts +116 -0
  55. package/dist/features/route/view.d.ts.map +1 -0
  56. package/dist/features/web-component/index.d.ts +33 -0
  57. package/dist/features/web-component/index.d.ts.map +1 -0
  58. package/dist/features/web-component/setup.d.ts +77 -0
  59. package/dist/features/web-component/setup.d.ts.map +1 -0
  60. package/dist/features/web-component/state.d.ts +47 -0
  61. package/dist/features/web-component/state.d.ts.map +1 -0
  62. package/dist/features/web-component/utils.d.ts +13 -0
  63. package/dist/features/web-component/utils.d.ts.map +1 -0
  64. package/dist/index.cjs +9 -5
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.ts +30 -230
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.mjs +4559 -2964
  69. package/dist/index.mjs.map +1 -1
  70. package/dist/types.d.ts +476 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/utils/debug.d.ts +40 -0
  73. package/dist/utils/debug.d.ts.map +1 -0
  74. package/dist/utils/index.d.ts +61 -0
  75. package/dist/utils/index.d.ts.map +1 -0
  76. package/dist/utils/sanitize.d.ts +52 -0
  77. package/dist/utils/sanitize.d.ts.map +1 -0
  78. package/package.json +10 -8
package/dist/index.cjs CHANGED
@@ -1,6 +1,10 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`jquery`);c=s(c,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}),_=Object.freeze({MAX_PROMISE_ID:h}),v=Object.freeze({UNINITIALIZED:-1,MIN:1}),y=!1;try{y=!!(typeof globalThis<`u`&&globalThis.__ATOM_DEBUG__||typeof sessionStorage<`u`&&sessionStorage.getItem(`__ATOM_DEBUG__`)===`true`)}catch{}var b=(typeof process<`u`&&process.env,typeof __DEV__<`u`&&!!__DEV__||y),x=Object.freeze([]),S=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(){let t=this.cause;if(t==null)return[this];let n=[this],r=t,i=null;for(;r!=null&&(n.push(r),!(r===this||i?.has(r)));){if(r instanceof e)r=r.cause;else if(r instanceof Error)r=r.cause;else break;n.length>3&&(i===null?i=new Set(n):i.add(r))}return n}toJSON(t){let n=t??new Set;if(n.has(this))return{name:this.name,message:`[Circular Reference]`,recoverable:this.recoverable,code:this.code};n.add(this);let r=this.cause;return r instanceof e?r=r.toJSON(n):r instanceof Error&&(r={name:r.name,message:r.message,stack:r.stack,cause:r.cause}),{name:this.name,message:this.message,code:this.code,recoverable:this.recoverable,stack:this.stack,cause:r}}static format(e,t,n){return`${e} (${t}): ${n}`}},C=class extends S{constructor(...e){super(...e),this.name=`ComputedError`}},w=class extends S{constructor(e,t=null,n=!1,r){super(e,t,n,r),this.name=`EffectError`}},ee=class extends S{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){return e instanceof S?new t(`${e.name} (${n}): ${e.message}`,e,e.recoverable,e.code):e instanceof Error?new t(`${e.name||`Error`} (${n}): ${e.message}`,e):new t(`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]`,oe=()=>{},D=b?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)=>{if(!this.enabled)return;let i=e;i[te]=r??`${t}_${n}`,i[ne]=n,i[re]=t,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,queueMicrotask(()=>{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!=null)return e[te]},this.getDebugType=e=>{if(e!=null)return e[re]}}}:{enabled:!1,warnInfiniteLoop:!1,warn:oe,registerNode:oe,attachDebugInfo:oe,trackUpdate:oe,dumpGraph:()=>[],getDebugName:()=>{},getDebugType:()=>{}},se=1,ce=()=>se++|0,le=class{constructor(){this._count=0,this._actualCount=0,this._s0=null,this._s1=null,this._s2=null,this._s3=null,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;n[e-4]=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),3+t.length}_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){if(e<4)return e===0?this._s0:e===1?this._s1:e===2?this._s2:e===3?this._s3:null;let t=this._overflow;return t===null?null:t[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?this._shrinkPhysicalSizeFrom(e):e>=this._count&&(this._count=e+1))}_shrinkPhysicalSizeFrom(e){if(e===this._count-1){if(this._count--,this._count>4){let e=this._overflow;for(;this._count>4&&e[this._count-5]===null;)this._count--}this._count===4&&this._s3===null&&(this._count=3,this._s2===null&&(this._count=2,this._s1===null&&(this._count=1,this._s0===null&&(this._count=0))))}}truncateFrom(e){e<=3&&(e<=3&&this._s3!==null&&(this._onItemRemoved(this._s3),this._s3=null,this._actualCount--),e<=2&&this._s2!==null&&(this._onItemRemoved(this._s2),this._s2=null,this._actualCount--),e<=1&&this._s1!==null&&(this._onItemRemoved(this._s1),this._s1=null,this._actualCount--),e<=0&&this._s0!==null&&(this._onItemRemoved(this._s0),this._s0=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){if(e(this._s0),t>1&&(e(this._s1),t>2&&(e(this._s2),t>3&&(e(this._s3),t>4)))){let t=this._overflow;for(let n=0,r=t.length;n<r;n++)e(t[n])}return}let n=0;if(this._s0!==null&&(e(this._s0),++n>=t)||this._s1!==null&&(e(this._s1),++n>=t)||this._s2!==null&&(e(this._s2),++n>=t)||this._s3!==null&&(e(this._s3),++n>=t))return;let r=this._overflow;if(r!==null)for(let i=0,a=r.length;i<a;i++){let a=r[i];if(a!=null&&(e(a),++n>=t))return}}compact(){let e=this._actualCount;if(e===this._count)return;if(e===0){this.clear();return}let t=0,n=this._count;for(let r=0;r<n;r++){let n=this.getAt(r);if(n!==null&&(r!==t&&(this._rawWrite(t,n),this._rawWrite(r,null)),t++,t===e))break}this._count=e,this._overflow!==null&&(t<=4?this._overflow=null:this._overflow.length=t-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()}},ue=class extends le{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!==null&&this._map.delete(n.node),t!==null&&this._map.set(t.node,e))}claimExisting(e,t){let n=this._count;if(n<=t)return!1;let r=null;if(r=t<4?t===0?this._s0:t===1?this._s1:t===2?this._s2:this._s3:this._overflow[t-4]??null,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);let i=-1,a=null,o=t+1;for(;o<4&&o<n;o++){let t=o===1?this._s1:o===2?this._s2:this._s3;if(t&&t.node===e&&t.unsub){i=o,a=t;break}}if(i===-1&&o<n){let t=this._overflow;for(let r=o-4,s=n-4;r<s;r++){let n=t[r];if(n&&n.node===e&&n.unsub){i=r+4,a=n;break}}}return i===-1?!1:(a.version=e.version,this._rawWrite(t,a),this._rawWrite(i,r),!0)}_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;this._s0?.unsub&&e.set(this._s0.node,0),this._s1?.unsub&&e.set(this._s1.node,1),this._s2?.unsub&&e.set(this._s2.node,2),this._s3?.unsub&&e.set(this._s3.node,3);let t=this._overflow;if(t!==null)for(let n=0,r=t.length;n<r;n++){let r=t[n];r?.unsub&&e.set(r.node,n+4)}return e}insertNew(e,t){let n=null;if(e<4)e===0?(n=this._s0,this._s0=t):e===1?(n=this._s1,this._s1=t):e===2?(n=this._s2,this._s2=t):(n=this._s3,this._s3=t);else{this._overflow===null&&(this._overflow=[]);let r=this._overflow;n=r[e-4]??null,r[e-4]=t}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)}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}},O=Symbol.for(`atom-effect/brand`),k={Atom:1,Writable:2,Computed:4,Effect:8};function de(e,t){return!e||typeof e!=`object`&&typeof e!=`function`?!1:!!(e[O]&t)}function fe(e){return de(e,k.Atom)}function pe(e){return de(e,k.Computed)}function me(e){return e instanceof Promise?!0:typeof e!=`object`||!e?!1: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){let n=this.fn,r=this.sub;if(n===void 0&&r===void 0)return;let i=A,a=i.current;if(a===null){n!==void 0&&n(e,t),r!==void 0&&r.execute();return}i.current=null;try{n!==void 0&&n(e,t),r!==void 0&&r.execute()}finally{i.current=a}}},A=new class{constructor(){this.current=null}run(e,t){if(this.current===e)return t();let n=this.current;this.current=e;try{if(!b)return t();let e=t();return 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 j(e){let t=A,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=v.UNINITIALIZED,this._notifying=0,this._hotIndex=-1,this.id=ce()&h,this._nextEpoch=void 0,this._slots=null,this._deps=null}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===null||typeof e.execute!=`function`))throw E(TypeError(`Invalid subscriber`),S,T.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);let n=this._slots;if(n===null&&(n=new le,this._slots=n),n.size>0){let r=!1;if(n._s0!==null&&(n._s0.fn===e||n._s0.sub===e)||n._s1!==null&&(n._s1.fn===e||n._s1.sub===e)||n._s2!==null&&(n._s2.fn===e||n._s2.sub===e)||n._s3!==null&&(n._s3.fn===e||n._s3.sub===e))r=!0;else{let i=n._overflow;if(i!==null){let n=i.length;if(t)for(let t=0;t<n;t++){let n=i[t];if(n!==null&&n?.fn===e){r=!0;break}}else for(let t=0;t<n;t++){let n=i[t];if(n!==null&&n?.sub===e){r=!0;break}}}}if(r)return b&&console.warn(`[atom-effect] Duplicate subscription ignored on node ${this.id}`),()=>{}}let r=new ge(t?e:void 0,t?void 0:e);return n.add(r),()=>this._unsubscribe(r)}_unsubscribe(e){let t=this._slots;t!==null&&(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{if(n._s0!==null)try{n._s0.notify(e,t)}catch(e){this._logNotifyError(e)}if(n._s1!==null)try{n._s1.notify(e,t)}catch(e){this._logNotifyError(e)}if(n._s2!==null)try{n._s2.notify(e,t)}catch(e){this._logNotifyError(e)}if(n._s3!==null)try{n._s3.notify(e,t)}catch(e){this._logNotifyError(e)}let r=n._overflow;if(r!==null)for(let n=0,i=r.length;n<i;n++){let i=r[n];if(i!==null)try{i?.notify(e,t)}catch(e){this._logNotifyError(e)}}}finally{--this._notifying===0&&n.compact()}}}_logNotifyError(e){console.error(E(e,S,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?(b&&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 M=new class{constructor(){this._bufferIndex=0,this._size=0,this._epoch=0,this._batchDepth=0,this._batchQueueSize=0,this._maxFlushIterations=m.MAX_FLUSH_ITERATIONS,this._isProcessing=!1,this._isFlushingSync=!1,this._buffer0=[],this._buffer1=[],this._batchQueue=[],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(b&&typeof e!=`function`&&(!e||typeof e.execute!=`function`))throw new ee(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._bufferIndex===0?this._buffer0:this._buffer1;n[this._size++]=e,this._isProcessing||this._flush()}_flush(){this._isProcessing||this._size===0&&this._batchQueueSize===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;let t=++this._epoch|0,n=this._batchQueue,r=this._bufferIndex===0?this._buffer0:this._buffer1,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=e===0?this._buffer0:this._buffer1,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 ee(`Error occurred during scheduler execution`,e))}}}_handleFlushOverflow(){let e=this._size+this._batchQueueSize;console.error(new ee(T.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations,e))),this._size=0,this._buffer0.length=0,this._buffer1.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){b&&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 ee(`Max iterations must be at least ${m.MIN_FLUSH_ITERATIONS}`);this._maxFlushIterations=e}};function Oe(e){if(b&&typeof e!=`function`)throw TypeError(T.BATCH_CALLBACK_MUST_BE_FUNCTION);M.startBatch();try{return e()}finally{M.endBatch()}}var ke=null;function Ae(e){return e?new Promise((t,n)=>{M.schedule(()=>{try{e(),t()}catch(e){n(e)}})}):ke||(ke=new Promise(e=>{M.schedule(()=>{ke=null,e()})}),ke)}var je=class extends _e{constructor(e,t){super(),this[O]=k.Atom|k.Writable,this._value=e,this._equal=t.equal??Object.is,t.sync&&(this.flags|=p.SYNC),b&&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 A.current?.addDependency(this),this._value}set value(e){let t=this._value;if(this._equal(t,e))return;this._value=e,this.version=be(this.version),b&&D.trackUpdate(this.id,D.getDebugName(this));let n=this.flags,r=p.NOTIFICATION_SCHEDULED;if((n&r)!==0)return;let i=this._slots;if(i===null||i.size===0)return;this._pendingOldValue=t;let a=n|r;if(this.flags=a,(a&p.SYNC)!==0&&!M.isBatching){this._notifying===0&&this._flushNotifications();return}M.schedule(this)}execute(){this._flushNotifications()}_flushNotifications(){let e=p.NOTIFICATION_SCHEDULED,t=p.DISPOSED,n=p.SYNC,r=e|t,i=this.flags;for(;(i&r)===e;){let t=this._pendingOldValue;this._pendingOldValue=void 0,this.flags=i&=~e;let r=this._value;if(this._equal(r,t)||this._notifySubscribers(r,t),i=this.flags,(i&n)===0||M.isBatching)break}}peek(){return this._value}dispose(){let e=this.flags,t=p.DISPOSED;(e&t)===0&&(this.flags=e|t,this._slots?.clear(),this._value=void 0,this._pendingOldValue=void 0,this._equal=Object.is)}_deepDirtyCheck(){return!1}};function Me(e,t={}){return new je(e,t)}var{IDLE:N,DIRTY:P,PENDING:F,RESOLVED:I,REJECTED:L,HAS_ERROR:Ne,RECOMPUTING:R,DISPOSED:Pe,IS_COMPUTED:z,FORCE_COMPUTE:Fe}=f,Ie=class extends _e{constructor(e,t={}){if(typeof e!=`function`)throw new C(T.COMPUTED_MUST_BE_FUNCTION);if(super(),this[O]=k.Atom|k.Computed,this._promiseId=0,this._trackEpoch=v.UNINITIALIZED,this._trackCount=0,this._error=null,this._deps=new ue,this._value=void 0,this.flags=z|P|N,this._equal=t.equal??Object.is,this._computation=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&P)!==0}get isRejected(){return(this.flags&L)!==0}get isRecomputing(){return(this.flags&R)!==0}get value(){let e=A.current;e!==null&&e.addDependency(this);let t=this.flags;if((t&(I|P|N|Pe|R))===I)return this._value;if((t&Pe)!==0)throw new C(T.COMPUTED_DISPOSED);if((t&R)!==0){let e=this._defaultValue;if(e!==ie)return e;throw new C(T.COMPUTED_CIRCULAR_DEPENDENCY)}if((t&(P|N))!==0){let e=this._deps;if((t&(N|Fe))!==0||e.size===0||this._isDirty()?this._recompute():this.flags&=~P,(this.flags&I)!==0)return this._value}let n=this._defaultValue,r=n!==ie;if((this.flags&F)!==0){if(r)return n;throw new C(T.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}if((this.flags&L)!==0){if(r)return n;throw this._error}return this._value}peek(){return this._value}get state(){let e=A.current;e!==null&&e.addDependency(this);let t=this.flags;return(t&I)===0?(t&F)===0?(t&L)===0?u.IDLE:u.REJECTED:u.PENDING:u.RESOLVED}get hasError(){let e=A.current;if(e!==null&&e.addDependency(this),(this.flags&(L|Ne))!==0)return!0;let t=this._deps;return t.hasComputeds?j(()=>{let e=t.size;for(let n=0;n<e;n++)if(t.getAt(n)?.node.hasError)return!0;return!1}):!1}get isValid(){return!this.hasError}get errors(){let e=A.current;e!==null&&e.addDependency(this);let t=this._error,n=this._deps;if(!n.hasComputeds)return t===null?x:Object.freeze([t]);let r=[];return t!==null&&r.push(t),j(()=>{let e=n.size;for(let t=0;t<e;t++){let e=n.getAt(t)?.node;e!==void 0&&(e.flags&z)!==0&&this._accumulateErrors(e,r)}}),r.length===0?x:Object.freeze(r)}_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!==void 0&&(n.flags&z)!==0&&this._accumulateErrors(n,t)}}get lastError(){let e=A.current;return e!==null&&e.addDependency(this),this._error}get isPending(){let e=A.current;return e!==null&&e.addDependency(this),(this.flags&F)!==0}get isResolved(){let e=A.current;return e!==null&&e.addDependency(this),(this.flags&I)!==0}invalidate(){this.flags|=Fe,this._markDirty()}dispose(){(this.flags&Pe)===0&&(this._deps.disposeAll(),this._slots!==null&&this._slots.clear(),this.flags=Pe|P|N,this._error=null,this._value=void 0,this._hotIndex=-1)}addDependency(e){let t=this._trackEpoch;if(e._lastSeenEpoch===t)return;e._lastSeenEpoch=t;let n=this._trackCount++,r=this._deps,i=null;if(n<4)i=n===0?r._s0:n===1?r._s1:n===2?r._s2:r._s3;else{let e=r._overflow;e!==null&&(i=e[n-4]??null)}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&z)!==0&&(r.hasComputeds=!0)}_recompute(){if((this.flags&R)!==0)return;this.flags=(this.flags|R)&~Fe,this._trackEpoch=ye(),this._trackCount=0,this._deps.prepareTracking(),this._hotIndex=-1;let e=!1;try{let t=A.run(this,this._computation);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){b&&console.warn(`[atom-effect] _commitDeps failed during error recovery:`,e)}this._handleError(t,T.COMPUTED_COMPUTATION_FAILED,!0)}finally{this._trackEpoch=v.UNINITIALIZED,this._trackCount=0,this.flags&=~R}}_handleAsyncComputation(e){this.flags=(this.flags|F)&~(N|P|I|L),this._notifySubscribers(void 0,void 0),this._promiseId=(this._promiseId+1)%_.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,C,t);if((!this.isRejected||this._error!==r)&&(this.version=be(this.version)),this._error=r,this.flags=this.flags&~(N|P|F|I)|L|Ne,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&I)===0||!this._equal(this._value,e))&&(this.version=be(this.version)),this._value=e,this._error=null,this.flags=(t|I)&~(N|P|F|L|Ne)}execute(){this._markDirty()}_markDirty(){let e=this.flags;(e&(R|P))===0&&(this.flags=e|P,D.trackUpdate(this.id,D.getDebugName(this)),this._notifySubscribers(void 0,void 0))}_deepDirtyCheck(){let e=this._deps,t=e.size,n=this._hotIndex;return j(()=>{if(n!==-1&&n<t){let t=e.getAt(n);if(t!==null&&this._checkLinkDirty(t))return!0}for(let r=0;r<t;r++){if(r===n)continue;let t=e.getAt(r);if(t!==null&&this._checkLinkDirty(t))return this._hotIndex=r,!0}return this._hotIndex=-1,!1})}_checkLinkDirty(e){let t=e.node;if((t.flags&z)!==0)try{t.value}catch{b&&console.warn(`[atom-effect] Dependency #${t.id} threw during check`)}return t.version!==e.version}};function Le(e,t={}){return new Ie(e,t)}var Re=class extends _e{constructor(e,t={}){super(),this[O]=k.Effect,this._currentEpoch=v.UNINITIALIZED,this._lastFlushEpoch=v.UNINITIALIZED,this._executionsInEpoch=0,this._executionCount=0,this._windowStart=0,this._windowCount=0,this._execId=0,this._trackCount=0,this._cleanup=null,this._deps=new ue,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._sync?this._notifyCallback=()=>this.execute():this._notifyCallback=()=>M.schedule(this),D.attachDebugInfo(this,`effect`,this.id,t.name)}run(){if(this.isDisposed)throw new w(T.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.isDisposed||(this.flags|=d.DISPOSED,this._execCleanup(),this._deps?.disposeAll())}addDependency(e){if((this.flags&d.EXECUTING)===0||e._lastSeenEpoch===this._currentEpoch)return;e._lastSeenEpoch=this._currentEpoch;let t=this._trackCount++,n=this._deps,r=e.version,i=null;if(t<4)i=t===0?n._s0:t===1?n._s1:t===2?n._s2:n._s3;else{let e=n._overflow;e!==null&&(i=e[t-4]??null)}i!==null&&i.node===e?i.version=r:n.claimExisting(e,t)||this._insertNewDependency(e,t,r),e.isComputed&&!n.hasComputeds&&(n.hasComputeds=!0)}_insertNewDependency(e,t,n){let r;try{r=new he(e,n,e.subscribe(this._notifyCallback))}catch(t){let i=E(t,w,T.EFFECT_EXECUTION_FAILED);if(console.error(i),this._onError)try{this._onError(i)}catch{}r=new he(e,n,void 0)}this._deps.insertNew(t,r)}execute(e=!1){let t=this.flags;if((t&(d.DISPOSED|d.EXECUTING))!==0)return;let n=this._deps;if(!e&&n.physicalSize>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=A.run(this,this._fn);n.truncateFrom(this._trackCount),r=!0,typeof e==`function`?this._cleanup=e:me(e)?this._handleAsyncResult(e):this._cleanup=null}catch(e){if(!r)try{n.truncateFrom(this._trackCount)}catch(e){b&&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.flags&d.DISPOSED)!==0){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))}_isDirty(){let e=this._deps,t=e.size;if(t===0)return!1;let n=this._hotIndex;if(n!==-1&&n<t){let t=e.getAt(n);if(t!==null){let e=t.node;if(!e.isComputed&&e.version!==t.version)return!0}}return this._deepDirtyCheck()}_deepDirtyCheck(){let e=this._deps,t=e.size,n=this._hotIndex,r=A.current;A.current=null;try{for(let r=0;r<t;r++){if(r===n)continue;let t=e.getAt(r);if(t===null)continue;let i=t.node;if(i.isComputed)try{i.value}catch{b&&console.warn(`[atom-effect] Dependency #${i.id} error in check`)}if(i.version!==t.version)return this._hotIndex=r,!0}return this._hotIndex=-1,!1}finally{A.current=r}}_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++,b&&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 w(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 w(`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,w,t);if(console.error(n),this._onError)try{this._onError(n)}catch(e){console.error(E(e,w,T.CALLBACK_ERROR_IN_ERROR_HANDLER))}}};function B(e,t={}){if(typeof e!=`function`)throw new w(T.EFFECT_MUST_BE_FUNCTION);let n=new Re(e,t);return n.execute(),n}function ze(e,t,n,r){if(n===t.length)return r;let i=t[n];if(i===`__proto__`||i===`constructor`||i===`prototype`)return e;let a=typeof e==`object`&&e?e:{},o=a[i],s=ze(o,t,n+1,r);if(Object.is(o,s))return e;if(Array.isArray(a)){let e=a.slice(),t=+i;return i.trim()!==``&&t>=0&&t%1==0?e[t]=s:e[i]=s,e}let c={...a};return c[i]=s,c}function Be(e,t){let n=e,r=t.length;for(let e=0;e<r;e++){if(n==null)return;let r=t[e];if(r===`__proto__`||r===`constructor`||r===`prototype`)return;n=n[r]}return n}function Ve(e,t){let n=t.includes(`.`)?t.split(`.`):[t],r=new Set;return{get value(){return Be(e.value,n)},set value(t){let r=e.peek(),i=ze(r,n,0,t);i!==r&&(e.value=i)},peek:()=>Be(e.peek(),n),subscribe(t){let i=Be(e.peek(),n),a=e.subscribe(e=>{let r=Be(e,n);if(!Object.is(r,i)){let e=i;i=r,t(r,e)}});return r.add(a),()=>{a(),r.delete(a)}},subscriberCount:()=>r.size,dispose:()=>{r.forEach(e=>e()),r.clear()},[O]:k.Atom|k.Writable}}var He=(e,t)=>Ve(e,t),Ue=e=>t=>Ve(e,t),We={ERRORS:{EFFECT_DISPOSE_ERROR:e=>`Dispose error${e?`: ${e}`:``}`}},Ge={PREFIX:`[atom-route]`,DEFAULTS:Object.freeze({mode:`hash`,basePath:``,autoBindLinks:!1,activeClass:`active`}),ERRORS:{NOT_FOUND:e=>`Route "${e}" not found`,TEMPLATE_NOT_FOUND:e=>`Template "${e}" not found`,TARGET_NOT_FOUND:e=>`Target "${e}" not found`,MALFORMED_URI:e=>`Malformed URI: ${e}`}},Ke={PREFIX:`[atom-binding]`,INPUT_DEFAULTS:Object.freeze({EVENT:`input`,DEBOUNCE:0}),VALID_INPUT_TAGS:[`input`,`select`,`textarea`],ERRORS:{INVALID_INPUT_ELEMENT:e=>`Invalid element <${e}> for val.`,MISSING_SOURCE:e=>`[${e}] source required.`,MISSING_CONDITION:e=>`[${e}] condition required.`,UPDATER_ERROR:(e,t)=>`Updater failed: "${e}"${t?` (static)`:``}`,CLEANUP_ERROR:e=>`Binding cleanup error${e?`: ${e}`:``}`,PARSE_ERROR:e=>`Parse error${e?`: ${e}`:``}`}},qe={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:e=>`Blocked CSS: "${e}".`,BLOCKED_EVENT_HANDLER:e=>`Blocked handler: "${e}".`,BLOCKED_PROTOCOL:e=>`Blocked protocol: "${e}".`,BLOCKED_PROP:e=>`Blocked prop: "${e}".`}},Je={PREFIX:`[atom-list]`,ERRORS:{DUPLICATE_KEY:(e,t)=>`Duplicate key "${e}" at index ${t}.`}},Ye={PREFIX:`[atom-mount]`,ERRORS:{ERROR:e=>`Mount error${e?` in <${e}>`:``}`,CLEANUP_ERROR:e=>`Cleanup error${e?` in <${e}>`:``}`}},Xe={DEFAULTS:Object.freeze({HIGHLIGHT_DURATION_MS:500})},V={ROUTE:Ge.PREFIX,BINDING:Ke.PREFIX,LIST:Je.PREFIX,MOUNT:Ye.PREFIX},H={ROUTE:Ge.ERRORS,SECURITY:qe.ERRORS,BINDING:Ke.ERRORS,LIST:Je.ERRORS,MOUNT:Ye.ERRORS,CORE:We.ERRORS},Ze=Ge.DEFAULTS,Qe=Ke.INPUT_DEFAULTS,$e=Xe.DEFAULTS,et=Ke.VALID_INPUT_TAGS;qe.URL_PROPS;var tt=qe.DANGEROUS_PROPS,nt=qe.DANGEROUS_PROTOCOL_PATTERN,rt=e=>e!==null&&(typeof e==`object`||typeof e==`function`)&&typeof e.then==`function`;function it(e){let{localName:t,id:n,className:r}=e,i=t;n&&(i+=`#${n}`);let a=typeof r==`string`?r:r?.baseVal;if(a){let e=a.trim().replace(/\s+/g,`.`);e&&(i+=`.${e}`)}let o=e.type;return o&&o!==`text`&&(i+=`.${o}`),i}var at=Object.prototype.hasOwnProperty;function ot(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;let n=e,r=t,i=Object.keys(n);if(i.length!==Object.keys(r).length)return!1;for(let e of i)if(!at.call(r,e)||!Object.is(n[e],r[e]))return!1;return!0}var st=`atom-debug-highlight`,ct=`data-atom-debug`,lt=typeof window<`u`,ut=new WeakMap,dt=new WeakMap,ft=!1;function pt(){if(ft||!lt)return;let e=document.createElement(`style`);e.setAttribute(ct,``),e.textContent=`
2
- [${ct}] { transition: outline ${$e.HIGHLIGHT_DURATION_MS/1e3}s ease-out; }
3
- .${st} { outline: 2px solid rgba(255, 68, 68, 0.8); outline-offset: 1px; }
4
- `.replace(/\s+/g,` `),document.head.appendChild(e),ft=!0}function mt(){let e=globalThis;return e.__ATOM_DEBUG__===void 0?e.process?.env?.NODE_ENV!==`production`&&e.process?.env?.NODE_ENV!==void 0:!!e.__ATOM_DEBUG__}var U={enabled:mt(),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: ${it(i)}.${n} =`,r),ht(i))}};function ht(e){let t=globalThis;if(!lt||typeof t.requestAnimationFrame!=`function`)return;pt();let n=dt.get(e),r=ut.get(e);n!==void 0&&t.cancelAnimationFrame(n),r!==void 0&&clearTimeout(r),e.hasAttribute(ct)||e.setAttribute(ct,``),dt.set(e,t.requestAnimationFrame(()=>{dt.delete(e),e.isConnected&&(e.classList.add(st),ut.set(e,setTimeout(()=>{e.classList.remove(st),ut.delete(e)},$e.HIGHLIGHT_DURATION_MS)))}))}var gt=()=>Ae();c.default.extend({atom:Me,computed:Le,effect:B,batch:Oe,untracked:j,isAtom:fe,isComputed:pe,nextTick:gt,atomLens:Ve,composeLens:He,lensFor:Ue,debug:U});var _t=!1,vt=`_aes-bound`,W=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){!_t&&typeof document<`u`&&document.body&&(_t=!0,bt(document.body));let t=this.records.get(e);return t||(t={},this.records.set(e,t),e.classList.add(vt)),t}addCleanup(e,t){let n=this.getOrCreateRecord(e);n.cleanups||=[],n.cleanups.push(t)}trackEffect(e,t){let n=it(e);this.addCleanup(e,()=>{try{t.dispose()}catch(e){U.error(V.BINDING,H.CORE.EFFECT_DISPOSE_ERROR(n),e)}})}trackCleanup(e,t){let n=it(e);this.addCleanup(e,()=>{try{t()}catch(e){U.error(V.BINDING,H.BINDING.CLEANUP_ERROR(n),e)}})}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(this.records.delete(t),t.classList.remove(vt),n){if(n.componentCleanup)try{n.componentCleanup()}catch(e){let n=it(t);U.error(V.MOUNT,H.MOUNT.CLEANUP_ERROR(n),e)}if(n.cleanups)for(let e of n.cleanups)e()}}cleanupDescendants(e){let t=e.querySelectorAll(`.${vt}`);for(let e=0,n=t.length;e<n;e++){let n=t[e];n&&this.cleanup(n)}}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=>{for(let t=0,n=e.length;t<n;t++){let n=e[t].removedNodes;for(let e=0,t=n.length;e<t;e++){let t=n[e];if(t.nodeType!==1||t.isConnected)continue;let r=t;W.isKept(r)||W.isIgnored(r)||W.cleanupTree(r)}}});t.observe(e,{childList:!0,subtree:!0}),yt.set(e,t)}function xt(){yt.forEach(e=>e.disconnect()),yt.clear()}var St=Symbol.for(`atom-effect-internal`),Ct=new WeakMap,G=null,wt=e=>{if(e[St])return e;let t=Ct.get(e);return t||(t=function(...t){return Oe(()=>e.apply(this,t))},t[St]=!0,Ct.set(e,t)),t},Tt=e=>Ct.get(e)??e;function Et(e){let t={};for(let n in e){let r=e[n];t[n]=typeof r==`function`?wt(r):r}return t}function Dt(e){let t={};for(let n in e){let r=e[n];t[n]=typeof r==`function`?Tt(r):r}return t}function Ot(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 kt(e){return function(...t){return Ot(t,Et,wt),e.apply(this,t)??this}}function At(){if(G!==null)return;G={on:c.default.fn.on,one:c.default.fn.one,off:c.default.fn.off,remove:c.default.fn.remove,empty:c.default.fn.empty,detach:c.default.fn.detach};let e=G;c.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&&(W.markIgnored(t),W.cleanupTree(t))}return e.remove.call(this,t)??this},c.default.fn.empty=function(){let t=this.length;for(let e=0;e<t;e++){let t=this[e];t?.hasChildNodes()&&W.cleanupDescendants(t)}return e.empty.call(this)??this},c.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&&W.keep(t)}return e.detach.call(this,t)??this},c.default.fn.on=kt(e.on),c.default.fn.one=kt(e.one),c.default.fn.off=function(...t){return Ot(t,Dt,Tt),e.off.apply(this,t)??this}}function jt(){G!==null&&(c.default.fn.on=G.on,c.default.fn.one=G.one,c.default.fn.off=G.off,c.default.fn.remove=G.remove,c.default.fn.empty=G.empty,c.default.fn.detach=G.detach,G=null)}var K=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}({}),Mt=0;function Nt(e){e[St]=!0}var Pt=class{constructor(e,t,n){this.$element=e,this.atom=t,this.options=n,this.namespace=`.atomBind-${++Mt}`,this.flags=K.None,this.handleFocus=()=>{this.flags|=K.Focused},this.handleCompositionStart=()=>{this.flags|=K.Composing},this.handleCompositionEnd=()=>{this.flags&=~K.Composing,this.syncToAtom()},this.handleBlur=()=>{let e=!!(this.flags&K.Composing);this.flags&=~(K.Focused|K.Composing),this.debounceTimer?(clearTimeout(this.debounceTimer),this.debounceTimer=void 0,this.syncToAtom()):e&&this.syncToAtom();let t=this.atom.peek();this.isDomUpToDate(t)||this.writeToDom(t,this.formatValue(t))},this.syncToDom=()=>{let e=this.atom.value;this.flags&K.Busy||j(()=>{if(!this.isDomUpToDate(e)){this.flags|=K.SyncingToDom;try{let t=this.formatValue(e);this.writeToDom(e,t),U.domUpdated(V.BINDING,this.$element,`val`,t)}finally{this.flags&=~K.SyncingToDom}}})};let r=e[0],i=r.tagName===`SELECT`&&r.multiple,a=r.tagName===`INPUT`||r.tagName===`TEXTAREA`,o=n.parse??(e=>e),s=n.equal??Object.is;i?(this.readValue=()=>e.val()||[],this.writeToDom=t=>{e.val(t)},this.areEqual=(e,t)=>s(e,t)?!0:Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),this.formatValue=n.format??(e=>(Array.isArray(e)?e:e?[String(e)]:[]).join(`,`))):(this.readValue=()=>o(r.value),this.writeToDom=(e,t)=>{if(a&&document.activeElement===r){let e=r;try{let{selectionStart:n,selectionEnd:r}=e;if(e.value=t,n!==null&&r!==null){let i=t.length;e.setSelectionRange(Math.min(n,i),Math.min(r,i))}}catch{e.value=t}}else r.value=t},this.areEqual=s,this.formatValue=n.format??(e=>String(e??``))),this.initializeEvents()}initializeEvents(){let e=this.namespace,t=this.options.debounce??0,n=()=>{this.flags&K.Composing||this.syncToAtom()},r=t>0?()=>{clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(n,t)}:n;[this.handleFocus,this.handleBlur,this.handleCompositionStart,this.handleCompositionEnd,r].forEach(Nt);let i=(this.options.event??Qe.EVENT).trim().split(/\s+/).map(t=>`${t}${e}`).join(` `);this.$element.on(`focus${e}`,this.handleFocus).on(`blur${e}`,this.handleBlur).on(`compositionstart${e}`,this.handleCompositionStart).on(`compositionend${e}`,this.handleCompositionEnd).on(i,r)}syncToAtom(){if(!(this.flags&K.Busy)){this.flags|=K.SyncingToAtom;try{let e=this.readValue();this.areEqual(this.atom.peek(),e)||(this.atom.value=e)}finally{this.flags&=~K.SyncingToAtom}}}isDomUpToDate(e){if(!this.areEqual(this.readValue(),e))return!1;if(this.flags&K.Focused)return!0;let t=this.$element[0];return this.formatValue(e)===t.value}cleanup(){this.$element.off(this.namespace),clearTimeout(this.debounceTimer)}};function Ft(e,t,n){let r=new Pt(e,t,n);return{reactiveEffect:B(r.syncToDom),cleanup:()=>r.cleanup()}}function It(e,t,n){let r=0,i=!1;return W.trackCleanup(e,()=>{i=!0}),a=>{let o=++r;if(!rt(a)){j(()=>{try{n(a),U.domUpdated(V.BINDING,e,t,a)}catch(e){U.error(V.BINDING,H.BINDING.UPDATER_ERROR(t,!0),e)}});return}a.then(a=>{o===r&&!i&&j(()=>{try{n(a),U.domUpdated(V.BINDING,e,`${t} (async)`,a)}catch(e){U.error(V.BINDING,H.BINDING.UPDATER_ERROR(t),e)}})}).catch(e=>{o===r&&!i&&U.error(V.BINDING,H.BINDING.UPDATER_ERROR(t),e)})}}function Lt(e,t,n,r){let i=It(e,r,n),a=fe(t);a||typeof t==`function`?W.trackEffect(e,B(()=>{i(a?t.value:t())},{name:r})):i(t)}function Rt(e,t,n,r){let i=It(e,r,n),a=Object.entries(t),o=!1;for(let e=0,t=a.length;e<t;e++){let t=a[e][1];if(fe(t)||typeof t==`function`){o=!0;break}}let s=()=>{let e=[],t={};for(let n=0,r=a.length;n<r;n++){let[r,i]=a[n],o=fe(i)?i.value:typeof i==`function`?i():i;rt(o)?e.push(o.then(e=>({key:r,val:e}))):t[r]=o}return e.length>0?Promise.all(e).then(e=>{for(let n=0,r=e.length;n<r;n++){let r=e[n];t[r.key]=r.val}return t}):t};o?W.trackEffect(e,B(()=>i(s()),{name:r})):i(s())}var zt=[`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`,`srcset`],Bt=[`script`,`iframe`,`object`,`embed`,`base`,`meta`,`applet`,`noscript`,`form`,`style`,`link`,`title`],Vt=[/expression\s*\(/i,/behavior\s*:/i,/-moz-binding\s*:/i,/@import/i,RegExp(`url\\s*\\(\\s*["']?\\s*${nt}\\s*:`,`i`),/data\s*:\s*(?!image\/)/i],Ht={colon:`:`,tab:` `,newline:`
5
- `},Ut=/&#x([0-9a-f]+);?|&#([0-9]+);?/gi,Wt=/&(colon|tab|newline);?/gi,Gt=/[\x00-\x1f\x7f]/g,Kt=/data\s*:\s*(?:text\/(?:html|javascript|vbscript|xml)|application\/(?:javascript|xhtml\+xml|xml|x-shockwave-flash)|image\/svg\+xml)/i,qt=RegExp(`(?:^|url\\s*\\(\\s*["']?)\\s*${nt}\\s*:`,`i`),Jt=new RegExp([`(<(${Bt.join(`|`)})\\b[^>]*>([\\s\\S]*?)<\\/\\2>|<(${Bt.join(`|`)})\\b[^>]*\\/?>)`,`\\bon\\w+\\s*=`,`${nt}\\s*:`,Kt.source].join(`|`),`i`),q={getAttributes:e=>Object.getOwnPropertyDescriptor(Element.prototype,`attributes`).get.call(e),setAttribute:(e,t,n)=>Element.prototype.setAttribute.call(e,t,n),removeAttribute:(e,t)=>Element.prototype.removeAttribute.call(e,t),replaceElement:(e,t)=>Element.prototype.replaceWith.call(e,t),getLocalName:e=>Object.getOwnPropertyDescriptor(Element.prototype,`localName`).get.call(e),getFirstChild:e=>Object.getOwnPropertyDescriptor(Node.prototype,`firstChild`).get.call(e)};function J(e){return typeof e==`string`?e.replace(Ut,(e,t,n)=>{let r=t?parseInt(t,16):parseInt(n,10);return r>=0&&r<=1114111?String.fromCodePoint(r):``}).replace(Wt,(e,t)=>Ht[t.toLowerCase()]??``).replace(Gt,``):``}function Yt(e){let t=e.replace(/\s+/g,``);return qt.test(t)||Kt.test(t)}function Xt(e){return e.split(`,`).map(e=>{let t=e.trim();if(!t)return e;let[n,...r]=t.split(/\s+/),i=J(n);return Yt(i)?[`data-unsafe-protocol:`,...r].join(` `):[i,...r].join(` `)}).join(`,`)}function Zt(e){return J(e).replace(/\/\*[\s\S]*?\*\//g,``)}function Qt(e){let t=Zt(e);return Vt.some(e=>e.test(t))}var $t={srcdoc:(e,t,n)=>{let r=J(n);q.setAttribute(e,t,Y(r))},srcset:(e,t,n)=>{q.setAttribute(e,t,Xt(n))},style:(e,t,n)=>{Qt(n)&&q.setAttribute(e,`style`,`data-unsafe-css:`)}};function en(e){let t=q.getAttributes(e);if(!t)return;let n=[];for(let r=t.length-1;r>=0;r--){let i=t[r],a=i.name,o=a.toLowerCase(),s=i.value;if(o.startsWith(`on`)){q.removeAttribute(e,a),n.push(a);continue}$t[o]?$t[o](e,a,s):zt.includes(o)&&Yt(J(s))&&q.setAttribute(e,a,`data-unsafe-protocol:`)}n.length>0&&q.setAttribute(e,`data-unsafe-attr`,n.join(`,`))}function tn(e){if(!Bt.includes(q.getLocalName(e)))return;let t=document.createElement(`span`),n=q.getAttributes(e);for(let e=0;e<n.length;e++){let r=n[e];r&&t.setAttribute(r.name,r.value)}en(t);let r=q.getFirstChild(e);for(;r;)t.appendChild(r),r=q.getFirstChild(e);q.replaceElement(e,t)}function nn(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),n=[],r=t.nextNode();for(;r;)n.push(r),q.getLocalName(r)===`template`&&nn(r.content),r=t.nextNode();for(let e of n)en(e),tn(e)}function Y(e){if(!e)return``;let t=document.createElement(`template`);return t.innerHTML=String(e),nn(t.content),t.innerHTML}var rn=(e,t)=>{let n=e.toLowerCase();if(!zt.includes(n))return!1;let r=J(t);return n===`srcdoc`?Jt.test(r):Yt(r)},an=e=>{let t=J(e).replace(/\/\*[\s\S]*?\*\//g,``);return Vt.some(e=>e.test(t))};function on(e){return e.includes(`-`)?e.replace(/-./g,e=>e[1].toUpperCase()):e}function sn(e,t){return e.toLowerCase().startsWith(`on`)?(console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_EVENT_HANDLER(e)}`),!1):t&&tt.includes(e)?(console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROP(e)}`),!1):!0}function cn(e,t,n){Lt(e,t,t=>{let r=n?n(t):String(t??``);e.textContent!==r&&(e.textContent=r)},`text`)}function ln(e,t){let n=null;Lt(e,t,t=>{let r=Y(t);n!==r&&(W.cleanupDescendants(e),e.innerHTML=r,n=r)},`html`)}function un(e,t){let n={},r=new Set;for(let e of Object.keys(t)){let t=e.trim();n[e]=t.includes(` `)?t.split(/\s+/).filter(Boolean):[t]}Rt(e,t,t=>{let i=new Set;for(let[e,r]of Object.entries(t))if(r)for(let t of n[e])i.add(t);for(let t of i)r.has(t)||e.classList.add(t);for(let t of r)i.has(t)||e.classList.remove(t);r=i},`class`)}function dn(e,t){let n=e.style,r={},i={},a={};for(let[e,n]of Object.entries(t)){let[t,a]=Array.isArray(n)?n:[n,``];r[e]=t,i[e]={camelCase:on(e),unit:a}}Rt(e,r,e=>{for(let[t,r]of Object.entries(e)){let e=i[t],o=e.unit?`${r}${e.unit}`:String(r);a[t]!==o&&(an(o)||(n[e.camelCase]=o),a[t]=o)}},`css`)}function fn(e,t){let n=Object.entries(t).filter(([e])=>sn(e,!1)),r=Object.fromEntries(n),i={},a={};for(let[t]of n)i[t]={isAria:t.toLowerCase().startsWith(`aria-`)},a[t]=e.getAttribute(t);Rt(e,r,t=>{for(let[n,r]of Object.entries(t)){let t=i[n],o=r;if(o==null||o===!1&&!t.isAria){a[n]!==null&&e.removeAttribute(n),a[n]=null;continue}let s=o===!0?t.isAria?`true`:n:String(o);if(rn(n,s)){console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(n)}`);continue}a[n]!==s&&(e.setAttribute(n,s),a[n]=s)}},`attr`)}function pn(e,t){let n=e,r=Object.entries(t).filter(([e])=>sn(e,!0)),i=Object.fromEntries(r),a={};Rt(e,i,e=>{for(let[t,r]of Object.entries(e))if(a[t]!==r){if(typeof r==`string`&&rn(t,r)){console.warn(`${V.BINDING} ${H.SECURITY.BLOCKED_PROTOCOL(t)}`);continue}n[t]=r,a[t]=r}},`prop`)}function mn(e,t,n){let r=e.style.display===`none`?``:e.style.display;Lt(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 hn(e,t,n={}){let r=e.tagName.toLowerCase();if(!et.includes(r)){console.warn(`${V.BINDING} ${H.BINDING.INVALID_INPUT_ELEMENT(r)}`);return}let{reactiveEffect:i,cleanup:a}=Ft((0,c.default)(e),t,n);W.trackEffect(e,i),W.trackCleanup(e,a)}function gn(e){e.type===`radio`&&e.name&&(e.form?(0,c.default)(e.form):(0,c.default)(document)).find(`input[type="radio"][name="${c.default.escapeSelector(e.name)}"]`).not(e).trigger(`change.atomRadioSync`)}function _n(e,t){if(!(e instanceof HTMLInputElement)){console.warn(`${V.BINDING} atomChecked called on non-input element`);return}let n=e,r=(0,c.default)(n),i=()=>{t.peek()!==n.checked&&(t.value=n.checked,gn(n))};i[St]=!0,r.on(`change change.atomRadioSync`,i),W.trackCleanup(n,()=>r.off(`change change.atomRadioSync`,i)),W.trackEffect(n,B(()=>{let e=!!t.value;j(()=>{n.checked!==e&&(n.checked=e,U.domUpdated(V.BINDING,n,`checked`,e),e&&gn(n))})}))}function vn(e,t){let n=(0,c.default)(e);n.on(t),W.trackCleanup(e,()=>n.off(t))}function yn(e,t,n){let r=(0,c.default)(e);r.on(t,n),W.trackCleanup(e,()=>r.off(t,n))}var bn=`input, select, textarea`,xn=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.init()}init(){this.bindElement(this.form),this.setupObserver()}bindElement(e){let t=e.matches?.(bn)?[e]:e.querySelectorAll?.(bn)||[];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&&W.cleanup(t),this.elementNames.has(t)&&r===n)return;let i=this.acquireField(n);this.elementNames.set(t,n),W.trackCleanup(t,()=>this.releaseField(t,n)),t instanceof HTMLInputElement&&(t.type===`radio`||t.type===`checkbox`)?this.bindToggle(t,i.atom,t.value,t.type===`checkbox`):hn(t,i.atom,this.options)}bindToggle(e,t,n,r){let i=()=>{let i=t.peek();if(r&&Array.isArray(i)){let r=new Set(i.map(String));e.checked?r.add(n):r.delete(n),t.value=Array.from(r)}else t.value=r?e.checked:n};i[St]=!0,(0,c.default)(e).on(`change`,i),W.trackCleanup(e,()=>(0,c.default)(e).off(`change`,i)),W.trackEffect(e,B(()=>{let i=t.value,a=r?Array.isArray(i)?i.some(e=>String(e)===n):!!i:String(i)===n;e.checked!==a&&(e.checked=a)}))}acquireField(e){let t=this.fieldMap.get(e);if(t)return t.refCount++,t;let n=e.replace(/\[(\w+)\]/g,`.$1`).replace(/^\./,``),r=Ve(this.atom,n),i=Object.create(r),{transform:a,onChange:o}=this.options;return Object.defineProperty(i,`value`,{get(){return r.value},set(t){let n=a?a(e,t):t;r.value=n,o&&j(()=>o(e,n))}}),t={atom:i,name:e,refCount: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);let r=n.atom;typeof r.dispose==`function`&&r.dispose(),this.fieldMap.delete(t)}W.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`]}),W.trackCleanup(this.form,()=>e.disconnect())}};function Sn(e,t,n={}){new xn(e,t,n)}function X(e,t){for(let n=0,r=e.length;n<r;n++){let r=e[n];r?.nodeType===1&&t(r)}return e}function Cn(e){if(!Array.isArray(e)||e.length!==2)return[e];let t=e[1];return typeof t==`function`||typeof t==`object`&&t&&!(`value`in t)&&!(`then`in t)?e:[e]}function wn(e,t,n,r=H.BINDING.MISSING_SOURCE(n)){return(typeof e==`string`?t===void 0?null:{[e]:t}:e)||(console.warn(`${V.BINDING} ${r}`),null)}c.default.fn.atomText=function(e,t){return X(this,n=>cn(n,e,t))},c.default.fn.atomHtml=function(e){return X(this,t=>ln(t,e))},c.default.fn.atomClass=function(e,t){let n=wn(e,t,`atomClass`,H.BINDING.MISSING_CONDITION(`atomClass`));return n?X(this,e=>un(e,n)):this},c.default.fn.atomCss=function(e,t,n){let r=wn(e,t!==void 0&&n?[t,n]:t,`atomCss`);return r?X(this,e=>dn(e,r)):this},c.default.fn.atomAttr=function(e,t){let n=wn(e,t,`atomAttr`);return n?X(this,e=>fn(e,n)):this},c.default.fn.atomProp=function(e,t){let n=wn(e,t,`atomProp`);return n?X(this,e=>pn(e,n)):this},c.default.fn.atomShow=function(e){return X(this,t=>mn(t,e,!1))},c.default.fn.atomHide=function(e){return X(this,t=>mn(t,e,!0))},c.default.fn.atomVal=function(e,t={}){return X(this,n=>hn(n,e,t))},c.default.fn.atomChecked=function(e){return X(this,t=>_n(t,e))},c.default.fn.atomForm=function(e,t={}){return X(this,n=>{n instanceof HTMLFormElement?Sn(n,e,t):U.warn(V.BINDING,`Skipping non-Form element for atomForm`)})},c.default.fn.atomOn=function(e,t){return X(this,n=>yn(n,e,t))};var Tn=[{key:`text`,run:(e,t)=>cn(e,...Cn(t))},{key:`html`,run:(e,t)=>ln(e,t)},{key:`class`,run:(e,t)=>un(e,t)},{key:`css`,run:(e,t)=>dn(e,t)},{key:`attr`,run:(e,t)=>fn(e,t)},{key:`prop`,run:(e,t)=>pn(e,t)},{key:`show`,run:(e,t)=>mn(e,t,!1)},{key:`hide`,run:(e,t)=>mn(e,t,!0)},{key:`val`,run:(e,t)=>hn(e,...Cn(t))},{key:`checked`,run:(e,t)=>_n(e,t)},{key:`form`,run:(e,t)=>{e instanceof HTMLFormElement&&Sn(e,...Cn(t))}},{key:`on`,run:(e,t)=>vn(e,t)}];c.default.fn.atomBind=function(e){let t=e,n=!1;for(let e=0,r=Tn.length;e<r;e++)if(t[Tn[e].key]!==void 0){n=!0;break}return n?X(this,e=>{for(let n=0,r=Tn.length;n<r;n++){let r=Tn[n],i=t[r.key];i!==void 0&&r.run(e,i)}}):this},c.default.fn.atomUnbind=function(){return X(this,e=>W.cleanupTree(e))};function En(e){return e instanceof Element?(0,c.default)(e):e}function Dn(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 On(e){if(e instanceof Element)W.cleanupTree(e);else for(let t=0,n=e.length;t<n;t++){let n=e[t];n instanceof Element&&W.cleanupTree(n)}}var kn=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}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))},r=this.onRemove?.(t);r instanceof Promise?r.then(n,n):n()}removeItem(e,t){Dn(t,null),this.removingKeys.add(e),this.scheduleRemoval(e,t)}dispose(){this.removingKeys.clear(),this.oldKeys=[],this.oldItems=[],this.oldNodes=[],this.keyToIndex.clear(),this.$emptyEl?.remove(),this.$container.off(`.atomList`)}},Z={Unchanged:0,Existing:1,New:2,ForceReplace:4};function An(e,t,n,r,i,a){let{oldKeys:o,oldItems:s,oldNodes:c,removingKeys:l,keyToIndex:u}=e,d=o.length,f=a||ot,p=0,m=d-1,h=n-1,g=new Set,_=Array(n),v=Array(n),y=Array(n),b=Array(n),x=Array(n),S=[];for(;p<=m&&p<=h;){let e=t[p],n=r(e,p);if(o[p]!==n||!f(s[p],e)||!c[p])break;u.set(n,p++)}for(;m>=p&&h>=p;){let e=t[h],n=r(e,h);if(o[m]!==n||!f(s[m],e)||!c[m])break;u.set(n,h--),m--}for(let e=0;e<p;e++){let n=o[e];_[e]=n,v[e]=t[e],y[e]=c[e],b[e]=Z.Unchanged,x[e]=e,g.add(n)}for(let e=d-1,r=n-1;r>h;r--,e--){let n=o[e];_[r]=n,v[r]=t[r],y[r]=c[e],b[r]=Z.Unchanged,x[r]=e,g.add(n)}let C=new Map;for(let e=p;e<=m;e++)C.set(o[e],e);for(let e=p;e<=h;e++){let n=t[e],a=r(n,e);if(_[e]=a,v[e]=n,u.set(a,e),g.has(a)){U.warn(V.LIST,H.LIST.DUPLICATE_KEY(a,e)),x[e]=-1;continue}g.add(a);let o=C.get(a),d=o!==void 0&&!l.has(a)?o:void 0;if(d===void 0){S.push({key:a,item:n,index:e}),x[e]=-1,b[e]=Z.New;continue}y[e]=c[d],!i&&!f(s[d],n)?(S.push({key:a,item:n,index:e}),b[e]=Z.ForceReplace):b[e]=Z.Existing,x[e]=d}return{newKeys:_,newKeySet:g,newItems:v,newNodes:y,newStates:b,newIndices:x,toRender:S,startIndex:p,oldEndIndex:m,newEndIndex:h}}function jn(e,t,n){if(!e)return;if(e instanceof Element){n.insertBefore(e,t);return}let r=e;for(let e=0,i=r.length;e<i;e++){let i=r[e];i&&n.insertBefore(i,t)}}function Mn(e,t,n,r){if(e.$emptyEl&&t>0&&(e.$emptyEl.remove(),e.$emptyEl=null),t!==0)return;let{oldKeys:i,oldNodes:a,onRemove:o}=e;if(!o)n.empty();else for(let t=0,n=i.length;t<n;t++){let n=i[t],r=a[t];r&&e.removeItem(n,En(r))}r&&!e.$emptyEl&&(e.$emptyEl=(0,c.default)(typeof r==`string`?c.default.parseHTML(Y(r)):r),e.$emptyEl.appendTo(n)),e.oldKeys=[],e.oldItems=[],e.oldNodes=[]}function Nn(e,t,n){let{toRender:r,newNodes:i,newStates:a}=e,o=r.length;if(o===0)return null;let s=Array(o),l=[],u=!0;for(let e=0;e<o;e++){let n=t.render(r[e].item,r[e].index);s[e]=n,typeof n==`string`?l.push(n):u=!1}let d=null;if(l.length>0&&(d=Pn(l)),n&&u&&d&&!t.bind&&!t.onAdd&&!t.events&&c.default.parseHTML(d.join(``)).length===o)return d;let f=0;for(let e=0;e<o;e++){let{key:t,index:n}=r[e],o=s[e],l=typeof o==`string`?(0,c.default)(c.default.parseHTML(d[f++])):(0,c.default)(o);if(Dn(l,String(t)),a[n]===Z.ForceReplace&&i[n]){let e=i[n];On(e);let t=En(e);t.first().before(l),t.remove()}i[n]=l.length===1?l[0]:l}return null}function Pn(e){if(e.length===1)return[Y(e[0])];let t=`<template data-atom-sep="s${Math.random().toString(36).slice(2)}"></template>`;return Y(e.join(t)).split(t)}function Fn(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,En(e.oldNodes[t]))}}function In(e,t,n,r,i){let{newKeys:a,newItems:o,newNodes:s,newStates:l,newIndices:u}=t,d=a.length;if(i){n.innerHTML=i.join(``);let e=n.firstElementChild;for(let t=0;t<d&&e;t++)e.setAttribute(`data-atom-key`,String(a[t])),s[t]=e,l[t]=Z.Existing,U.domUpdated(V.LIST,(0,c.default)(e),`list.add`,o[t]),e=e.nextElementSibling;return}if(e.oldKeys.length===0&&e.removingKeys.size===0){let e=document.createDocumentFragment();for(let t of s)if(t)if(t instanceof Element)e.appendChild(t);else{let n=t;for(let t=0;t<n.length;t++){let r=n[t];r&&e.appendChild(r)}}n.innerHTML=``,n.appendChild(e)}else{let e=null,t=1/0;for(let r=d-1;r>=0;r--){let i=u[r],a=s[r];if(!a)continue;let o=a instanceof Element?a:a[0];o&&(i!==-1&&i<t?t=i:jn(a,e,n),e=o)}}for(let t=0;t<d;t++){let n=l[t];if(n===Z.Unchanged)continue;let i=s[t];if(!i)continue;let c=En(i),u=o[t];n===Z.Existing?r.update?.(c,u,t):(r.bind?.(c,u,t),n===Z.New&&(r.onAdd?.(c),e.removingKeys.delete(a[t]),U.domUpdated(V.LIST,c,`list.add`,u)))}}var Ln=new WeakMap;function Rn(e,t){let n=typeof t.key==`function`?t.key:e=>e[t.key],r={bind:t.bind,update:t.update,onAdd:t.onAdd,onRemove:t.onRemove,events:t.events};for(let i=0,a=this.length;i<a;i++){let a=this[i],o=(0,c.default)(a),s=Ln.get(a);s&&(s.fx.dispose(),s.ctx.dispose());let l=new kn(o,it(a),t.onRemove),u=B(()=>{let i=e.value,s=i.length;j(()=>{if(Mn(l,s,o,t.empty),s===0)return;let e=l.oldKeys.length===0&&l.removingKeys.size===0;l.keyToIndex.clear();let c=An(l,i,s,n,t.update,t.isEqual),u=Nn(c,t,e);Fn(l,c),In(l,c,a,r,u),l.oldKeys=c.newKeys,l.oldItems=c.newItems,l.oldNodes=c.newNodes})});l.fx=u,t.events&&zn(l,o,t.events),W.trackEffect(a,u),Ln.set(a,{fx:u,ctx:l}),W.trackCleanup(a,()=>{l.dispose(),Ln.delete(a)})}return this}function zn(e,t,n){for(let r in n){if(!at.call(n,r))continue;let i=r.indexOf(` `),a=i===-1?r:r.slice(0,i),o=i===-1?`> *`:r.slice(i+1).trim(),s=n[r];t.on(`${a}.atomList`,o,function(t){let n=t.target.closest?.(`[data-atom-key]`),r=n?.getAttribute(`data-atom-key`);if(r==null)return;let i=r;if(!e.keyToIndex.has(r)){let t=Number(r);!Number.isNaN(t)&&e.keyToIndex.has(t)&&(i=t)}let a=e.keyToIndex.get(i);a!==void 0&&s.call(n,e.oldItems[a],a,t)})}}c.default.fn.atomList=Rn;var Bn=Object.freeze({});c.default.fn.atomMount=function(e,t){let n=t??Bn;return X(this,t=>{W.cleanupTree(t);let r=j(()=>Oe(()=>e((0,c.default)(t),n)));if(r){let e=typeof r==`function`?r:r.unmount;W.setComponentCleanup(t,e)}})},c.default.fn.atomUnmount=function(){return X(this,e=>W.cleanupTree(e))};var Q={normalize:e=>e.replace(/(^\/+|\/+$)/g,``),split:e=>{let[t,n]=e.split(`?`);return{route:Q.normalize(t||``),query:n}},isSameParams:(e,t)=>{if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>e[n]===t[n])}};function Vn(e){let t={};if(!e)return t;try{new URLSearchParams(e).forEach((e,n)=>{t[n]=e})}catch{}return t}var Hn=e=>{let t=e?`/${Q.normalize(e)}`:``,n=`${location.origin}${t}/`.replace(/\/+$/,`/`);return{getBrowserState:()=>{let e=location.pathname;return t&&e.startsWith(t)&&(e=e.substring(t.length)),{path:Q.normalize(e),query:Vn(location.search.substring(1)),url:location.pathname+location.search}},commit:e=>{let{route:t,query:r}=Q.split(e),i=new URL(t,n);r&&(i.search=r);let a=i.pathname+i.search;try{history.pushState(null,``,a)}catch{}return{path:Q.normalize(t),query:Vn(r||``),url:a}},revert:e=>{if(location.pathname+location.search!==e)try{history.replaceState(null,``,e)}catch{}},resolveAnchor:e=>{let n=e.pathname;return t&&n.startsWith(t)&&(n=n.substring(t.length)),Q.normalize(n)+e.search},setupListener:e=>(window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e))}},Un=()=>({getBrowserState:()=>{let e=location.hash,t=e.startsWith(`#`)?e.substring(1):e,{route:n,query:r}=Q.split(t);return{path:n,query:Vn(r||``),url:e}},commit:e=>{let{route:t,query:n}=Q.split(e),r=`#${n?`${t}?${n}`:t}`;return location.hash=r,{path:Q.normalize(t),query:Vn(n||``),url:r}},revert:e=>{location.hash!==e&&(location.hash=e)},resolveAnchor:e=>e.hash.startsWith(`#`)?Q.normalize(e.hash.substring(1)):``,setupListener:e=>(window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e))}),Wn=class{constructor(e){this.routes=[],Object.entries(e).forEach(([e,t])=>{let n=Q.normalize(e);if(!n.includes(`:`))this.routes.push({kind:`exact`,pattern:n,def:t});else{let e=[],r=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/:(\w+)/g,(t,n)=>(e.push(n),`([^/]+)`));this.routes.push({kind:`dynamic`,pattern:n,regex:RegExp(`^${r}$`),paramNames:e,def:t})}})}match(e){let t=Q.normalize(e);for(let e of this.routes)if(e.kind===`exact`){if(e.pattern===t)return{kind:`found`,route:e,params:{}}}else{let n=t.match(e.regex);if(n)return{kind:`found`,route:e,params:e.paramNames.reduce((e,t,r)=>{try{e[t]=decodeURIComponent(n[r+1]||``)}catch{e[t]=n[r+1]||``}return e},{})}}return{kind:`not-found`}}},Gn=class{constructor(e){this.isDestroyed=!1,this.previousPath=``,this.previousUrl=``,this.cleanups=[],this.routeCleanups=[],this.config=this.parseConfig(e),this.activeClass=this.config.activeClass;let t=this.config.target;typeof t==`string`||t instanceof HTMLElement?this.$target=(0,c.default)(t):this.$target=t,this.urlAdapter=this.config.mode===`history`?Hn(this.config.basePath):Un(),this.discoverRoutesFromDOM(),this.matcher=new Wn(this.config.routes);let n=this.urlAdapter.getBrowserState();this.previousUrl=n.url;let r=n.path||this.config.default;this.currentRouteAtom=Me(r),this.currentRoute=this.currentRouteAtom,this.queryParamsAtom=Me(n.query),this.queryParams=Le(()=>this.queryParamsAtom.value);let i=this.matcher.match(r),a=i.kind===`found`?i.params:{};this.paramsAtom=Me({...n.query,...a}),this.params=Le(()=>this.paramsAtom.value),this.setupLifecycle()}parseConfig(e){return{mode:Ze.mode,basePath:Ze.basePath,autoBindLinks:Ze.autoBindLinks,activeClass:Ze.activeClass,notFound:e.notFound||``,beforeTransition:e.beforeTransition||(()=>{}),afterTransition:e.afterTransition||(()=>{}),default:e.default||``,...e,routes:e.routes||{}}}setupLifecycle(){this.cleanups.push(this.urlAdapter.setupListener(()=>this.handleBrowserSync()));let e=B(()=>{let e=this.currentRouteAtom.value;this.queryParamsAtom.value,j(()=>{this.runRouteCleanups(),this.render(e)})});this.cleanups.push(()=>e.dispose()),this.config.autoBindLinks&&this.setupInterception(),this.$target[0]&&W.trackCleanup(this.$target[0],()=>this.destroy())}navigate(e){if(this.isDestroyed||!this.canLeave())return;let{route:t,query:n}=Q.split(e),r=t||this.config.default;if(!r)return;let i=n?`${r}?${n}`:r;Oe(()=>{let e=this.urlAdapter.commit(i);this.previousUrl=e.url,Q.isSameParams(this.queryParamsAtom.peek(),e.query)||(this.queryParamsAtom.value=e.query),this.currentRouteAtom.peek()!==e.path&&(this.currentRouteAtom.value=e.path)})}handleBrowserSync(){if(this.isDestroyed)return;let e=this.urlAdapter.getBrowserState();if(e.url===this.previousUrl)return;let t=e.path||this.config.default;if(this.currentRouteAtom.peek()!==t){if(!this.canLeave()){this.urlAdapter.revert(this.previousUrl);return}this.currentRouteAtom.value=t}this.queryParamsAtom.value=e.query,this.previousUrl=e.url}render(e){let t=this.matcher.match(e),n=t.kind===`found`?t.route.def:this.config.routes[this.config.notFound];if(!n){U.warn(V.ROUTE,H.ROUTE.NOT_FOUND(e));return}let r=t.kind===`found`?t.route.pattern:e,i=t.kind===`found`?t.params:{},a={...this.queryParamsAtom.peek(),...i};if(j(()=>this.config.beforeTransition(this.previousPath,r)),n.onEnter){let e=j(()=>n.onEnter(a,this));if(e===!1){this.urlAdapter.revert(this.previousUrl);return}e&&Object.assign(a,e)}Q.isSameParams(this.paramsAtom.peek(),a)||(this.paramsAtom.value=a),n.title&&(document.title=n.title),this.updateDom(n,r,a),j(()=>this.config.afterTransition(this.previousPath,r)),this.finalizeNavigation(r,a)}updateDom(e,t,n){let r=this.$target[0];if(!r)return;r.replaceChildren();let i=e=>this.routeCleanups.push(e);if(e.render)e.render(r,t,n,i,this);else if(e.template){let t=this.getTemplate(e.template);t&&(r.appendChild(t.content.cloneNode(!0)),e.onMount?.((0,c.default)(r).children(),i,this))}}discoverRoutesFromDOM(){document.querySelectorAll(`template[data-path]`).forEach(e=>{let t=Q.normalize(e.getAttribute(`data-path`)||``),n=e.getAttribute(`title`)||e.getAttribute(`data-title`),r=this.config.routes[t];r?n&&!r.title&&(r.title=n):(e.id||=`route-${Math.random().toString(36).substring(2,9)}`,this.config.routes[t]={template:`#${e.id}`,...n?{title:n}:{}}),e.hasAttribute(`data-default`)&&!this.config.default&&(this.config.default=t)})}setupInterception(){let e=e=>{let t=e.originalEvent;if(t&&(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||t.button!==0))return;let n=e.currentTarget;if(n.hasAttribute(`data-ignore`))return;let r=this.resolvePathFromElement(n);r&&this.shouldIntercept(r,n)&&(e.preventDefault(),this.navigate(r))};(0,c.default)(document).on(`click`,`a, [data-route]`,e),this.cleanups.push(()=>(0,c.default)(document).off(`click`,`a, [data-route]`,e)),this.setupActiveEffect()}setupActiveEffect(){let e=B(()=>{let e=this.currentRouteAtom.value,t=this.matcher.match(e),n=t.kind===`found`?t.route.pattern:``;j(()=>{document.querySelectorAll(`a, [data-route]`).forEach(t=>{let r=this.resolvePathFromElement(t,!0),i=r===e||r===n;t.classList.toggle(this.activeClass,i),i?t.setAttribute(`aria-current`,`page`):t.removeAttribute(`aria-current`)})})});this.cleanups.push(()=>e.dispose())}resolvePathFromElement(e,t=!1){let n=e.dataset.route||``;return!n&&e instanceof HTMLAnchorElement&&(n=this.urlAdapter.resolveAnchor(e)),t?Q.split(n).route:n}shouldIntercept(e,t){if(t instanceof HTMLAnchorElement&&(t.rel===`external`||t.target&&t.target!==`_self`||t.hasAttribute(`download`)||t.origin!==location.origin||(e.split(`/`).pop()||``).includes(`.`)&&this.matcher.match(Q.split(e).route).kind===`not-found`))return!1;let{route:n}=Q.split(e);return this.matcher.match(n).kind===`found`||!!this.config.notFound}canLeave(){let e=this.matcher.match(this.currentRouteAtom.peek()),t=e.kind===`found`?e.route.def:this.config.routes[this.config.notFound];return t?.onLeave?j(()=>t.onLeave(this))!==!1:!0}getTemplate(e){let t=document.querySelector(e);return t instanceof HTMLTemplateElement?t:null}runRouteCleanups(){this.routeCleanups.forEach(e=>{try{e()}catch{}}),this.routeCleanups=[]}finalizeNavigation(e,t){window.dispatchEvent(new CustomEvent(`route-change`,{detail:{from:this.previousPath,to:e,params:t}}));let n=this.$target[0];if(!n)return;let r=n.querySelector(`h1, [role="heading"]`),i=r instanceof HTMLElement?r:n;i.tabIndex=-1,i.focus(),this.previousPath=e}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.runRouteCleanups(),this.cleanups.forEach(e=>{try{e()}catch{}}),this.cleanups=[])}};function Kn(e){return new Gn(e)}c.default.extend({route:Kn});function qn(e,t){let n=typeof t.ajaxOptions==`object`?t.ajaxOptions:{},r=typeof t.ajaxOptions==`function`?t.ajaxOptions():{};return{...n,...r,url:e(),method:t.method||r.method||n.method,headers:{...n?.headers,...t.headers,...r.headers},success:void 0,error:void 0,complete:void 0}}function Jn(e,t){let n;if(e&&e.readyState!==void 0){let t=e;n=Error(`Network Error: ${t.statusText||`Unknown`} (${t.status})`),n.jqXHR=t}else n=e instanceof Error?e:Error(String(e??`Unknown error`));if(t)try{t(n)}catch{}throw n}function Yn(e,t){let n=typeof e==`string`?()=>e:e,r=null,i=Le(async()=>{r?.abort();let e=new AbortController;r=e;let{signal:i}=e,a=qn(n,t),o,s;try{o=c.default.ajax(a);let e=o;s=()=>e.abort(),i.addEventListener(`abort`,s),i.aborted&&e.abort();let n=await e;return t.transform?t.transform(n,e):n}catch(e){if(i.aborted){let e=Error(`AbortError`);throw e.name=`AbortError`,e}return Jn(e,t.onError)}finally{s&&i.removeEventListener(`abort`,s),r===e&&(r=null)}},{defaultValue:t.defaultValue,lazy:t.eager===!1,...t.name===void 0?{}:{name:t.name}}),a=i.dispose.bind(i);return i.dispose=()=>{r?.abort(),a()},Object.assign(i,{abort:()=>r?.abort()})}c.default.extend({atomFetch:Yn});function $(e,t){try{return new URL(e,t)}catch{return new URL(e,`http://localhost`)}}function Xn(e){let{pathname:t,search:n,hash:r}=e.location;return(t||`/`)+(n||``)+(r||``)}function Zn(e){return e.pathname+e.search}function Qn(e,t,n){let r=new DOMParser().parseFromString(e,`text/html`),i=r.querySelector(`title`)?.textContent?.trim()||null,a=t?r.querySelector(t):null,o=a?a.innerHTML:r.body?.innerHTML||e,s={};if(a)for(let{name:e,value:t}of Array.from(a.attributes))e!==`id`&&(s[e]=t);let c={},l=e=>r.querySelector(e)?.getAttribute(`content`),u=l(`meta[name="description"]`),d=l(`meta[name="keywords"]`),f=r.querySelector(`link[rel="canonical"]`)?.getAttribute(`href`);return u&&(c.description=u),d&&(c.keywords=d),f&&(c.canonical=f),{html:Y(o).trim(),title:i,attributes:s,redirectUrl:n?.getResponseHeader?.(`X-PJAX-URL`)||void 0,meta:c}}function $n(e,t){let n=e.document,r=n.head,i=(e,t,i,a=!1)=>{let o=r.querySelector(e);if(!t){o?.remove();return}let s=o||n.createElement(a?`link`:`meta`);o||(a?s.setAttribute(`rel`,`canonical`):s.setAttribute(`name`,i),r.appendChild(s));let c=a?`href`:`content`;s.getAttribute(c)!==t&&s.setAttribute(c,t)};i(`meta[name="description"]`,t?.description,`description`),i(`meta[name="keywords"]`,t?.keywords,`keywords`),i(`link[rel="canonical"]`,t?.canonical,`canonical`,!0)}function er(e,t){for(let n of Array.from(e.attributes)){let{name:r}=n;r!==`id`&&r!==`data-atom-nav-target`&&!(r in t)&&e.removeAttribute(r)}for(let[n,r]of Object.entries(t))e.getAttribute(n)!==r&&e.setAttribute(n,r)}function tr(e,t,n=!1){if(t){let r=e.document.getElementById(decodeURIComponent(t));if(r){r.scrollIntoView({behavior:`auto`,block:`start`});return}if(!n)return}e.scrollTo(0,0)}function nr(e){let{target:t,selector:n=`a[data-nav]`,headers:r={},syncTitle:i=!0}=e,a=e.window??window,o=(0,c.default)(t);o.attr(`data-atom-nav-target`,`true`);let s=Xn(a),l=Zn($(s,a.location.href)),u=c.default.atom({url:s,type:`init`},{name:`nav:state`}),d=c.default.atom(0,{name:`nav:hook-pending-count`}),f=c.default.atom({url:s,path:l},{name:`nav:rendered`}),p=c.default.computed(()=>{let{url:e,type:t}=u.value,n=$(e,a.location.href);return{url:e,pathAndSearch:Zn(n),hash:n.hash.slice(1),type:t}},{name:`nav:normalized`}),m=typeof t==`string`?t:o.attr(`id`)?`#${c.default.escapeSelector(o.attr(`id`))}`:void 0,h=c.default.atomFetch(()=>p.value.pathAndSearch,{name:`nav:content`,defaultValue:{html:``,title:null},headers:{"X-PJAX":`true`,...r},eager:!1,transform:(e,t)=>Qn(String(e),m,t)}),g=new AbortController,_=null;function v(){_?.abort(),h.abort?.();let e=new AbortController;return _=e,e}function y(t,n,r){c.default.untracked(()=>{let s=a.document;i&&t.title!==null&&s.title!==t.title&&(s.title=t.title),$n(a,t.meta),e.onUnmount?.(o,r),o.children().atomUnbind();let c=o[0];c&&t.attributes&&er(c,t.attributes),o.html(t.html),e.onMount?.(o,n)})}function b(){let{url:t,pathAndSearch:n,hash:r,type:i}=p.value,s=f.value;if(i===`init`&&n===s.path){r&&tr(a,r),e.onMount?.(o,t);return}if(h.hasError){let n=h.lastError;if(n instanceof Error&&n.name===`AbortError`)return;e.onError?.(n,t)!==!1&&a.location.assign(t);return}let l=h.value;if(!h.isResolved||h.isPending)return;let u=l.redirectUrl&&l.redirectUrl!==t,d=s.url,m=u?l.redirectUrl:t,g=u?$(m,a.location.href):null,_=g?Zn(g):n,v=_!==s.path;c.default.batch(()=>{u&&a.history.replaceState(null,``,m),(v||u)&&y(l,m,d);let{scrollToTop:t=!0}=e,n=$(f.value.url,a.location.href),o=!r&&n.hash!==``,s=i===`pop`;(r||!s&&(o||v&&t))&&tr(a,r,!s&&v&&t),f.value={url:m,path:_}})}let x=c.default.effect(()=>b(),{name:`nav:sync-effect`});a.document.addEventListener(`click`,e=>{let t=e.target.closest(n);if(!t)return;let r=t.dataset.target,i=o.attr(`id`),s=r&&i&&r===`#${i}`;if(r&&!s)return;let l=(0,c.default)(t).closest(`[data-atom-nav-target="true"]`)[0],u=l&&l!==o[0];if(!s&&u)return;let d=e;if(e.defaultPrevented||e.isDefaultPrevented?.()||e.originalEvent?.defaultPrevented||d.ctrlKey||d.metaKey||d.shiftKey||d.button>0)return;let f=t.getAttribute(`href`);if(f&&!f.startsWith(`#`)&&t.target!==`_blank`&&!t.hasAttribute(`download`)&&t.getAttribute(`rel`)!==`external`&&t.dataset.nav!==`false`&&(t.protocol===`http:`||t.protocol===`https:`))try{(t.origin??new URL(t.href,t.ownerDocument.location?.href??a.location.origin).origin)===a.location.origin&&(e.preventDefault(),S.navigate(t.href))}catch{}},{signal:g.signal}),a.addEventListener(`popstate`,()=>{v(),u.value={url:Xn(a),type:`pop`}},{signal:g.signal});let S={currentUrl:c.default.computed(()=>f.value.url,{name:`nav:public-url`}),isPending:c.default.computed(()=>h.isPending||d.value>0,{name:`nav:isPending`}),hasError:c.default.computed(()=>h.hasError,{name:`nav:hasError`}),async navigate(t,n={}){let{signal:r}=v();if(e.onBeforeLoad){d.value++;try{let n=await e.onBeforeLoad(t,r);if(r.aborted||n===!1)return}finally{d.value=Math.max(0,d.value-1)}}let i=a.document.baseURI??a.location.href,o=$(t,i);if(o.origin!==a.location.origin){a.location.assign(t);return}let s=Zn(o),l=Zn($(a.location.href,i)),f=s+o.hash;!(s===l&&o.hash===(a.location.hash||``))||n.replace?c.default.batch(()=>{let e=n.replace?`replaceState`:`pushState`;a.history[e](null,``,f),u.value={url:f,type:n.replace?`replace`:`push`}}):(t.includes(`#`)||o.hash)&&tr(a,o.hash.slice(1),!0)},destroy(){g.abort(),_?.abort(),x.dispose(),h.dispose(),o.removeAttr(`data-atom-nav-target`),[u,d,f,p,S.currentUrl,S.isPending,S.hasError].forEach(e=>e.dispose?.())}};return S}c.default.extend({atomNav:nr}),(0,c.default)(()=>{At(),document.body&&bt(document.body)});var rr=c.default;exports.default=rr,exports.disableAutoCleanup=xt,exports.disablejQueryOverrides=jt,exports.enableAutoCleanup=bt,exports.enablejQueryOverrides=At,exports.nextTick=gt,exports.registry=W;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var Ds=Object.create,vn=Object.defineProperty,Ls=Object.getOwnPropertyDescriptor,Ps=Object.getOwnPropertyNames,Us=Object.getPrototypeOf,Ms=Object.prototype.hasOwnProperty,Fs=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(var r=Ps(e),o=0,i=r.length,a;o<i;o++)a=r[o],!Ms.call(t,a)&&a!==n&&vn(t,a,{get:(c=>e[c]).bind(null,a),enumerable:!(s=Ls(e,a))||s.enumerable});return t},xs=(t,e,n)=>(n=t!=null?Ds(Us(t)):{},Fs(e||!t||!t.__esModule?vn(n,"default",{value:t,enumerable:!0}):n,t));let f=require("jquery");f=xs(f,1);var H={CORE:0,COMPUTED:8,ASYNC:16,PRIMITIVE:24},A={DISPOSED:1<<H.CORE+0,IS_COMPUTED:1<<H.CORE+1,DIRTY:1<<H.COMPUTED+0,RECOMPUTING:1<<H.COMPUTED+1,HAS_ERROR:1<<H.COMPUTED+2,FORCE_COMPUTE:1<<H.COMPUTED+3,IDLE:1<<H.ASYNC+0,PENDING:1<<H.ASYNC+1,RESOLVED:1<<H.ASYNC+2,REJECTED:1<<H.ASYNC+3,ATOM_SYNC:1<<H.PRIMITIVE+0,ATOM_NOTIFICATION_SCHEDULED:1<<H.PRIMITIVE+1,EFFECT_EXECUTING:1<<H.PRIMITIVE+4};Object.freeze({ASYNC_STATE:A.IDLE|A.PENDING|A.RESOLVED|A.REJECTED,COMPUTED_DIRTY_MASK:A.DIRTY|A.RECOMPUTING|A.FORCE_COMPUTE});var Gt=Object.freeze({IDLE:"idle",PENDING:"pending",RESOLVED:"resolved",REJECTED:"rejected"}),pt=Object.freeze({DISPOSED:A.DISPOSED,EXECUTING:A.EFFECT_EXECUTING}),wt=Object.freeze({DISPOSED:A.DISPOSED,IS_COMPUTED:A.IS_COMPUTED,DIRTY:A.DIRTY,IDLE:A.IDLE,PENDING:A.PENDING,RESOLVED:A.RESOLVED,REJECTED:A.REJECTED,RECOMPUTING:A.RECOMPUTING,HAS_ERROR:A.HAS_ERROR,FORCE_COMPUTE:A.FORCE_COMPUTE}),at=Object.freeze({DISPOSED:A.DISPOSED,SYNC:A.ATOM_SYNC,NOTIFICATION_SCHEDULED:A.ATOM_NOTIFICATION_SCHEDULED}),_t=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}),yn=1073741823,we=Object.freeze({WARN_INFINITE_LOOP:!0,EFFECT_FREQUENCY_WINDOW:1e3,LOOP_THRESHOLD:100}),$t=Object.freeze({UNINITIALIZED:-1,MIN:1}),js=()=>{try{return!!(typeof globalThis<"u"&&globalThis.__ATOM_DEBUG__||typeof sessionStorage<"u"&&sessionStorage.getItem("__ATOM_DEBUG__")==="true")}catch{return!1}},$s=()=>{try{return!1}catch{return!1}},Wt={node:typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production",bundler:typeof __DEV__<"u"&&!!__DEV__,esm:typeof process>"u"&&$s(),runtime:js()},q=Wt.node||Wt.bundler||Wt.esm||Wt.runtime,Hs=Object.freeze([]),Bs=Symbol.for("atom-effect.Option"),zs=Symbol.for("atom-effect.Result");Object.freeze({ok:!1,value:void 0,[Bs]:!0});Object.freeze({ok:!0,value:void 0,error:void 0,[zs]:!0});var Vs=[0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,-1],F=4,qs=15,bn=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 Vs[t&qs]}_rawWrite(t,e){if(t<F){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-F]=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 s=this._overflow,r=this._freeIndices;if(r?.length){const o=r.pop();return s[o]=t,o+F}return s.push(t),F-1+s.length}_rawSwap(t,e){if(t===e)return;const n=this.at(t),s=this.at(e);this._rawWrite(t,s),this._rawWrite(e,n)}get length(){return this._count}get size(){return this._actualCount}at(t){if(t<F)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-F]??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>F){const e=this._overflow;for(;this._count>F&&e[this._count-(F+1)]==null;)this._count--}this._count<=F&&(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<F?(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-F),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 s=0,r=n.length;s<r;s++)if(n[s]===t)return n[s]=null,this._actualCount--,this._shrinkPhysicalSizeFrom(s+F),this._freeIndices||(this._freeIndices=[]),this._freeIndices.push(s),!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 s=0,r=n.length;s<r;s++)if(n[s]===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 s=0,r=n.length;s<r;s++){const o=n[s];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 s=0,r=n.length;s<r;s++){const o=n[s];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 s=this._overflow;for(let r=0;r<e;r++){const o=this.at(r);if(o!==null&&(r!==n&&(this._rawWrite(n,o),this._rawWrite(r,null)),++n===t))break}this._count=t,s!==null&&(n<=F?this._overflow=null:s.length=n-F),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}};function Sn(t){return t instanceof Promise?!0:t===null||typeof t!="object"&&typeof t!="function"?!1:typeof t.then=="function"}var Xs=Object.prototype.hasOwnProperty;function Gs(t,e){if(t===e)return!0;if(t===null||e===null||typeof t!="object"||typeof e!="object")return!1;const n=t,s=e,r=Object.keys(n);if(r.length!==Object.keys(s).length)return!1;for(const o of r)if(!Xs.call(s,o)||!Object.is(n[o],s[o]))return!1;return!0}var vt=class extends Error{constructor(t,e=null,n=!0,s){super(t),this.cause=e,this.recoverable=n,this.code=s,this.name="AtomError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}getChain(){const t=[],e=new Set;let n=this;for(;n!=null&&!e.has(n);)t.push(n),e.add(n),n=n?.cause;return t}toJSON(t=new Set){return t.has(this)?{name:this.name,message:"[Circular Reference]",recoverable:this.recoverable,code:this.code}:(t.add(this),{name:this.name,message:this.message,code:this.code,recoverable:this.recoverable,stack:this.stack,cause:Cn(this.cause,t)})}static format(t,e,n){return`${t} (${e}): ${n}`}},Lt=class extends vt{constructor(...t){super(...t),this.name="ComputedError"}},Ct=class extends vt{constructor(t,e=null,n=!1,s){super(t,e,n,s),this.name="EffectError"}},$e=class extends vt{constructor(t,e=null,n=!1,s){super(t,e,n,s),this.name="SchedulerError"}},N={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:(t,e)=>`Maximum flush iterations (${t}) exceeded. ${e} 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 se(t,e,n){const s=Ws(t);return new e(vt.format(s.name,n,s.message),t,s.recoverable,s.code)}function Ws(t){return t instanceof vt?{name:t.name,message:t.message,recoverable:t.recoverable,code:t.code}:t instanceof Error?{name:t.name,message:t.message,recoverable:!0,code:t?.code}:{name:"Unexpected error",message:String(t),recoverable:!0,code:void 0}}function Cn(t,e){return t==null||typeof t!="object"?t:e.has(t)?"[Circular Reference]":t instanceof vt?t.toJSON(e):t instanceof Error?(e.add(t),{name:t.name,message:t.message,stack:t.stack,cause:Cn(t.cause,e)}):t}var ht=Symbol.for("atom-effect/brand"),k={Atom:1,Writable:2,Computed:4,Effect:8},Ie=Symbol("AtomEffect.NoDefaultValue"),Ys={[k.Atom]:"atom",[k.Computed]:"computed",[k.Effect]:"effect"},Ks=k.Atom|k.Computed|k.Effect,ge="[Atom Effect]",Dt=()=>{},Qs=class{constructor(){this.enabled=!0,this.warnInfiniteLoop=we.WARN_INFINITE_LOOP,this._updateCounts=new Map,this._registry=new Map,this.trackGraph=!1,this._finalizer=new FinalizationRegistry(t=>{this._registry.delete(t),this._updateCounts.delete(t)}),this._threshold=we.LOOP_THRESHOLD,this._cleanupScheduled=!1,this._failedEvaluations=new Set,this._failureCleanupScheduled=!1,this._resetUpdateCounts=()=>{this._updateCounts.clear(),this._cleanupScheduled=!1},this._resetFailedEvaluations=()=>{this._failedEvaluations.clear(),this._failureCleanupScheduled=!1}}warn(t,e){this.enabled&&t&&console.warn(`${ge} ${e}`)}registerNode(t){const e=t.id,n=this._getOrCreateMetadata(t,e);n.ref=new WeakRef(t),this._finalizer.register(t,e)}attachDebugInfo(t,e,n,s){if(!this.enabled||s===void 0&&!this.trackGraph)return;let r=this._registry.get(n);r?(s!==void 0&&(r.name=s),r.type=e):(r={name:s??`${e}_${n}`,type:e},this._registry.set(n,r)),this.registerNode(t)}trackUpdate(t,e){if(!this.enabled||!this.warnInfiniteLoop)return;const n=this._updateCounts,s=(n.get(t)||0)+1;n.set(t,s),s>this._threshold&&s===this._threshold+1&&console.warn(`${ge} Infinite loop detected for ${e??`dependency ${t}`}. Detected ${s} updates within a single execution scope, exceeding the threshold of ${this._threshold}.`),this._cleanupScheduled||(this._cleanupScheduled=!0,queueMicrotask(this._resetUpdateCounts))}trackEvaluationFailure(t){!this.enabled||this._failedEvaluations.has(t)||(this._failedEvaluations.add(t),console.warn(`${ge} Dependency #${t} evaluation failed during dirty check.`),this._failureCleanupScheduled||(this._failureCleanupScheduled=!0,queueMicrotask(this._resetFailedEvaluations)))}dumpGraph(){const t=this._registry;if(t.size===0)return[];const e=[],n=this._updateCounts;for(const[s,r]of t)this.trackGraph&&r.ref?.deref()===void 0||e.push({id:s,name:r.name,type:r.type,updateCount:n.get(s)??0});return e}getDebugName(t){if(!this.enabled||!t)return;const e=t.id;if(e===void 0)return;const n=this._registry.get(e);return n?n.name:`${this._getTypeFromBrand(t)??"unknown"}_${e}`}getDebugType(t){if(!this.enabled||!t)return;const e=t.id;if(e===void 0)return;const n=this._registry.get(e);return n?n.type:this._getTypeFromBrand(t)}_getOrCreateMetadata(t,e){let n=this._registry.get(e);if(!n){const s=this._getTypeFromBrand(t)??"unknown";n={name:`${s}_${e}`,type:s},this._registry.set(e,n)}return n}_getTypeFromBrand(t){const e=t[ht];return e!==void 0?Ys[e&Ks]:void 0}},et=q?new Qs:{enabled:!1,warnInfiniteLoop:!1,trackGraph:!1,warn:Dt,registerNode:Dt,attachDebugInfo:Dt,trackUpdate:Dt,dumpGraph:()=>[],getDebugName:()=>{},getDebugType:()=>{},trackEvaluationFailure:Dt},Js=1,Zs=()=>Js++,de={get:()=>{},set:()=>{},delete:()=>{}},Tn=class extends Map{};function An(){return{slots:new bn,map:de,hasComputeds:!1}}function Rn(t){t.hasComputeds=!1}function On(t,e,n){const{slots:s}=t;if(s.length<=n)return!1;const r=s.at(n);if(r?.node===e&&r.unsub)return r.version=e.version,!0;const o=tr(t,e,n);if(o===-1)return!1;const i=s.at(o);i.version=e.version;const a=s.at(n);return ke(t,n,i),ke(t,o,a),!0}function tr(t,e,n){const s=t.map.get(e);if(s!==void 0)return s>=n?s:-1;const r=t.slots;for(let o=n+1,i=r.length;o<i;o++){const a=r.at(o);if(a?.node===e&&a.unsub)return o}return-1}function wn(t,e,n){const s=t.slots.at(e);ke(t,e,n),s!==null&&er(t,s)}function ke(t,e,n){const s=t.slots.at(e);t.slots.setAt(e,n),s&&t.map.delete(s.node),n?.unsub&&(t.map===de&&(t.map=new Tn),t.map.set(n.node,e))}function er(t,e){const n=t.slots.push(e);return e.unsub&&(t.map===de&&(t.map=new Tn),t.map.set(e.node,n)),n}var nr={0:t=>t.node.version!==t.version,[wt.IS_COMPUTED]:t=>{const e=t.node;try{e.value}catch{q&&et.trackEvaluationFailure(e.id)}return e.version!==t.version}};function Ht(t){const e=t.slots,n=e.length;if(e.size===0)return!1;const s=nr;for(let r=0;r<n;r++){const o=e.at(r);if(o&&s[o.node.flags&wt.IS_COMPUTED](o))return!0}return!1}function sr(t){const e=t.slots,n=e.length;for(let s=0;s<n;s++){const r=e.at(s);if(!r)continue;const o=r.node;if(o.version!==r.version||(o.flags&wt.DIRTY)!==0)return!0}return!1}function He(t,e){const n=t.slots,s=n.length;for(let r=e;r<s;r++){const o=n.at(r);if(o){const i=o.unsub;if(i)try{i()}catch(a){q&&console.error("[atom-effect] Unsubscribe failed:",a)}}}n.truncateFrom(e),t.map=de}function In(t){He(t,0),t.hasComputeds=!1}function kn(t,e,n=void 0){return{node:t,version:e,unsub:n}}function tn(t=void 0,e=void 0){return{fn:t,sub:e}}function rr(t,e,n){if(t!==null)try{const{fn:s,sub:r}=t;s!==void 0&&s(e,n),r!==void 0&&r.execute()}catch(s){console.error("[atom-effect] Subscriber failed:",s)}}function or(){return{stack:[],current:null}}function Be(t,e){t.stack.push(e),t.current=e}function Nn(t){const e=t.stack;e.pop();const n=e.length;t.current=n>0?e[n-1]:null}function ze(t,e){const n=t.stack;n.length=e;const s=n.length;t.current=s>0?n[s-1]:null}function Dn(t,e,n){if(t.current===e)return n();Be(t,e);try{return n()}finally{Nn(t)}}function ir(t){t.stack.length=0,t.current=null}var I=or();function M(t){if(I.current===null)return t();Be(I,null);try{return t()}finally{Nn(I)}}var Ve=class{constructor(){this.flags=0,this.version=0,this._lastSeenEpoch=$t.UNINITIALIZED,this._nextEpoch=void 0,this.id=Zs()&yn,this._slots=null,this._deps=null}get isDisposed(){return(this.flags&wt.DISPOSED)!==0}get isComputed(){return(this.flags&wt.IS_COMPUTED)!==0}get isNotifying(){return this._slots?.isLocked??!1}_hasFlag(t){return(this.flags&t)!==0}get hasError(){return!1}subscribe(t){let e;if(typeof t=="function"?e=tn(t,void 0):t!=null&&typeof t.execute=="function"&&(e=tn(void 0,t)),!e)throw se(new TypeError("Invalid subscriber"),vt,N.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);let n=this._slots;if(n===null)this._slots=n=new bn;else if(this._hasSubscription(t))return q&&console.warn(`[atom-effect] Duplicate subscription ignored on node ${this.id}`),()=>{};return n.push(e),()=>this._unsubscribe(e)}_hasSubscription(t){const e=this._slots;return!e||e.size===0?!1:e.some(n=>n.fn===t||n.sub===t)}_unsubscribe(t){const e=this._slots;e!==null&&(e.remove(t),e.compact())}subscriberCount(){return this._slots?.size??0}_notifySubscribers(t,e){const n=this._slots;if(!n||n.size===0)return;const s=I.stack.length;Be(I,null),n.lock();try{n.forEach(r=>{rr(r,t,e)})}finally{ze(I,s),n.unlock()}}_isDirty(){return this._deps?Ht(this._deps):!1}_isShallowDirty(){return this._deps?sr(this._deps):!1}},Ln=t=>{const e=t+1&yn;return e===0?1:e};function Ne(t){return Ln(t)}var ar=0,ve=1,qe=2,pe=4,cr=qe|pe;function ur(){return{size:0,epoch:0,batchQueueSize:0,state:ar,batchDepth:0,maxFlushIterations:_t.MAX_FLUSH_ITERATIONS,sessionActive:!1,sessionEpoch:0,sessionExecutionCount:0,activeBuffer:[],standbyBuffer:[],batchBuffer:[],onOverflow:null}}function Pn(t,e){const n=t.batchQueueSize;if(n===0)return;const s=e(),r=t.batchBuffer,o=t.activeBuffer;let i=t.size;for(let a=0;a<n;a++){const c=r[a];c._nextEpoch!==s&&(c._nextEpoch=s,o[i++]=c),r[a]=void 0}t.size=i,t.batchQueueSize=0,r.length>_t.BATCH_QUEUE_SHRINK_THRESHOLD&&(r.length=0)}function Un(t,e,n,s){let r=0;const o=t.maxFlushIterations;for(;t.size>0||t.batchQueueSize>0;){if(++r>o){s(t);return}t.batchQueueSize>0&&Pn(t,e),t.size>0&&n(t)}}function Mn(t,e){const n=t.activeBuffer,s=t.size;t.activeBuffer=t.standbyBuffer,t.standbyBuffer=n,t.size=0,e();for(let r=0;r<s;r++){const o=n[r];n[r]=void 0;try{typeof o=="function"?o():o.execute()}catch(i){console.error(new $e("Error occurred during scheduler execution",i))}}}function Fn(t){const e=t.size+t.batchQueueSize;if(console.error(new $e(N.SCHEDULER_FLUSH_OVERFLOW(t.maxFlushIterations,e))),t.size=0,t.activeBuffer.length=0,t.standbyBuffer.length=0,t.batchQueueSize=0,t.batchBuffer.length=0,t.onOverflow)try{t.onOverflow(e)}catch{}}function mt(t){return t.epoch=Ln(t.epoch),t.epoch}function xn(t){return t.sessionActive?(q&&console.warn("startFlush() called during flush - ignored"),!1):(t.sessionActive=!0,t.sessionEpoch=mt(t),t.sessionExecutionCount=0,!0)}function jn(t){t.sessionActive=!1}function lr(t){if(!t.sessionActive)return 0;const e=++t.sessionExecutionCount;if(e<=_t.MAX_EXECUTIONS_PER_FLUSH)return e;throw new Error(`[atom-effect] Infinite loop detected: flush execution count exceeded ${_t.MAX_EXECUTIONS_PER_FLUSH}`)}function re(t,e){if(q&&typeof e!="function"&&(!e||typeof e.execute!="function"))throw new $e(N.SCHEDULER_CALLBACK_MUST_BE_FUNCTION);e._nextEpoch!==t.epoch&&(e._nextEpoch=t.epoch,(t.state&cr)===0?t.activeBuffer[t.size++]=e:t.batchBuffer[t.batchQueueSize++]=e,(t.state&ve)===0&&(t.state|=ve,queueMicrotask(()=>{try{if(t.size===0&&t.batchQueueSize===0)return;const n=xn(t);Un(t,()=>mt(t),s=>Mn(s,()=>mt(s)),s=>Fn(s)),n&&jn(t)}catch(n){throw ir(I),n}finally{t.state&=~ve}})))}function fr(t){if(t.size===0&&t.batchQueueSize===0)return;const e=t.state;t.state|=qe;const n=xn(t);try{Pn(t,()=>mt(t)),Un(t,()=>mt(t),s=>Mn(s,()=>mt(s)),s=>Fn(s))}finally{t.state=e,n&&jn(t)}}function hr(t){t.batchDepth++,t.state|=pe}function dr(t){if(t.batchDepth===0){q&&console.warn(N.SCHEDULER_END_BATCH_WITHOUT_START);return}--t.batchDepth===0&&(t.state&=~pe,(t.state&qe)===0&&fr(t))}function en(t){return(t.state&pe)!==0}var Y=ur(),$n=()=>mt(Y),pr=()=>Y.sessionEpoch,mr=()=>lr(Y);function It(t){if(q&&typeof t!="function")throw new TypeError(N.BATCH_CALLBACK_MUST_BE_FUNCTION);hr(Y);try{return t()}finally{dr(Y)}}var Yt=null;function _r(t){return t?new Promise((e,n)=>{re(Y,()=>{try{t(),e()}catch(s){n(s)}})}):Yt||(Yt=new Promise(e=>{re(Y,()=>{Yt=null,e()})}),Yt)}var Er=class extends Ve{constructor(t,e){super(),this[ht]=k.Atom|k.Writable,this._value=t,this._equal=e.equal??Object.is,e.sync&&(this.flags|=at.SYNC),et.attachDebugInfo(this,"atom",this.id,e.name)}get isNotificationScheduled(){return(this.flags&at.NOTIFICATION_SCHEDULED)!==0}get isSync(){return(this.flags&at.SYNC)!==0}get value(){return I.current?.addDependency(this),this._value}set value(t){if(this._equal(this._value,t))return;const e=this._value;this._value=t,this.version=Ne(this.version),q&&et.trackUpdate(this.id,et.getDebugName(this)),this._scheduleNotification(e)}_scheduleNotification(t){const e=this.flags,n=at.NOTIFICATION_SCHEDULED;(e&n)!==0||!this._slots?.length||(this._pendingOldValue=t,this.flags|=n,(e&at.SYNC)!==0&&!en(Y)?this.isNotifying||this._flushNotifications():re(Y,this))}execute(){this._flushNotifications()}_flushNotifications(){const t=at.NOTIFICATION_SCHEDULED,e=t|at.DISPOSED,n=(this.flags&at.SYNC)!==0&&!en(Y);for(;(this.flags&e)===t;){const s=this._pendingOldValue,r=this._value;if(this._pendingOldValue=void 0,this.flags&=~t,this._equal(r,s)||this._notifySubscribers(r,s),!n)break}}peek(){return this._value}dispose(){const t=at.DISPOSED;(this.flags&t)===0&&(this.flags|=t,this._slots?.clear(),this._value=void 0,this._pendingOldValue=void 0,this._equal=Object.is)}_deepDirtyCheck(){return!1}};function Pt(t,e={}){return new Er(t,e)}function Xe(t,e){return!t||typeof t!="object"&&typeof t!="function"?!1:!!(t[ht]&e)}function nt(t){return Xe(t,k.Atom)}function gr(t){return Xe(t,k.Writable)}function vr(t){return Xe(t,k.Computed)}function Ut(t,e=!1){const n={};for(let s=0;s<t.length;s++){const r=e?t[s].peek():t[s].value;r&&typeof r=="object"&&Object.assign(n,r)}return n}var{IDLE:Mt,DIRTY:ut,PENDING:Bt,RESOLVED:lt,REJECTED:Et,HAS_ERROR:Ge,RECOMPUTING:J,DISPOSED:Kt,IS_COMPUTED:nn,FORCE_COMPUTE:oe}=wt,Hn=Bt|Et,yr=Mt|oe,Bn=Et|Ge,ye=Mt|ut|Bt|lt|Et|Ge,Qt={TO_RECOMPUTING:{clear:oe,set:J},TO_RESOLVED:{clear:ye|J,set:lt},TO_PENDING:{clear:ye|J,set:Bt},TO_REJECTED:{clear:ye|J,set:Et|Ge}},Jt=(t,e)=>t&~e.clear|e.set;function br(t,e,n,s){if((t&lt)!==0)return e;const r=s!==Ie,o=t&Hn;if(o===0)return e;if(r)return s;throw o===Et?n??new Error("REJECTED without error"):new Lt(N.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}function Sr(t,e){const n=(t&Hn)!==0;return(t&yr)!==0||Ht(e)||!n&&e.slots.size===0}function sn(t,e){const n=[],s=new Set,r=o=>{if(s.has(o.id))return!1;if(s.add(o.id),(o.flags&Bn)!==0&&(n.push(o.lastError??new Error("Internal Inconsistency: MASK_ERROR flag set but error is null")),e))return!0;const i=o._deps;if(i?.hasComputeds)for(let a=0,c=i.slots.length;a<c;a++){const u=i.slots.at(a);if(u?.node.isComputed&&r(u.node))return!0}return!1};return r(t),n}var Cr=class extends Ve{constructor(t,e={}){if(typeof t!="function")throw new Lt(N.COMPUTED_MUST_BE_FUNCTION);if(super(),this[ht]=k.Atom|k.Computed,this._activeSessionId=0,this._sessionCounter=0,this._trackEpoch=$t.UNINITIALIZED,this._trackCount=0,this._error=null,this._deps=An(),this._value=void 0,this.flags=nn|ut|Mt,this._equal=e.equal??Object.is,this._computation=t,this._defaultValue="defaultValue"in e?e.defaultValue:Ie,this._onError=e.onError??null,et.attachDebugInfo(this,"computed",this.id,e.name),e.lazy===!1)try{this._recompute()}catch{}}get isDirty(){return(this.flags&ut)!==0}get isRejected(){return(this.flags&Et)!==0}get isRecomputing(){return(this.flags&J)!==0}get value(){if(I.current?.addDependency(this),this._isStable())return this._value;if(this._ensureNotDisposed(),(this.flags&J)!==0){if(this._defaultValue!==Ie)return this._defaultValue;throw new Lt(N.COMPUTED_CIRCULAR_DEPENDENCY)}return Sr(this.flags,this._deps)?this._recompute():this.flags&=~ut,br(this.flags,this._value,this._error,this._defaultValue)}_isStable(){const t=lt|ut|Mt|Kt|J;return(this.flags&t)===lt}_ensureNotDisposed(){if((this.flags&Kt)!==0)throw new Lt(N.COMPUTED_DISPOSED)}peek(){return this._value}get state(){I.current?.addDependency(this);const t=this.flags;return(t&lt)!==0?Gt.RESOLVED:(t&Bt)!==0?Gt.PENDING:(t&Et)!==0?Gt.REJECTED:Gt.IDLE}get hasError(){return I.current?.addDependency(this),(this.flags&Bn)!==0?!0:this._deps.hasComputeds?M(()=>sn(this,!0).length>0):!1}get isValid(){return!this.hasError}get errors(){return I.current?.addDependency(this),this._deps.hasComputeds?M(()=>Object.freeze(sn(this,!1))):this._error?Object.freeze([this._error]):Hs}get lastError(){return I.current?.addDependency(this),this._error}get isPending(){return I.current?.addDependency(this),(this.flags&Bt)!==0}get isResolved(){return I.current?.addDependency(this),(this.flags&lt)!==0}invalidate(){this.flags|=oe,this._markDirty()}dispose(){(this.flags&Kt)===0&&(In(this._deps),this._slots?.clear(),this.flags=Kt|ut|Mt,this._error=null,this._value=void 0)}addDependency(t){const e=this._trackEpoch;if(t._lastSeenEpoch===e)return;t._lastSeenEpoch=e;const n=this._trackCount++,s=this._deps,r=s.slots.at(n);r?.node===t?r.version=t.version:On(s,t,n)||wn(s,n,kn(t,t.version,t.subscribe(this))),(t.flags&nn)!==0&&(s.hasComputeds=!0)}_recompute(){if((this.flags&J)!==0)return;this.flags=Jt(this.flags,Qt.TO_RECOMPUTING);const t=I.stack.length;this._startTracking();let e,n=!1,s;try{try{e=Dn(I,this,this._computation)}catch(r){throw ze(I,t),r}}catch(r){n=!0,s=r}n?(this._commitDeps(),this._handleError(s,N.COMPUTED_COMPUTATION_FAILED,!1)):(this._commitDeps(),Sn(e)?this._handleAsyncComputation(e):this._finalizeResolution(e)),this._trackEpoch=$t.UNINITIALIZED,this._trackCount=0,this.flags&=~J}_startTracking(){this._trackEpoch=$n(),this._trackCount=0,Rn(this._deps)}_commitDeps(){try{He(this._deps,this._trackCount)}catch(t){q&&console.warn("[atom-effect] _commitDeps failed during error recovery:",t)}}_handleAsyncComputation(t){this.flags=Jt(this.flags,Qt.TO_PENDING),this._notifySubscribers(void 0,void 0);const e=++this._sessionCounter;this._activeSessionId=e,t.then(n=>{if(this._activeSessionId===e){if(this._isDirty())return this._markDirty();this._finalizeResolution(n),this._notifySubscribers(n,void 0)}},n=>{this._activeSessionId===e&&this._handleError(n,N.COMPUTED_ASYNC_COMPUTATION_FAILED)})}_handleError(t,e,n=!1){const s=se(t,Lt,e),r=this._error;if((!this.isRejected||r!==s)&&(this.version=Ne(this.version)),this._error=s,this.flags=Jt(this.flags,Qt.TO_REJECTED),this._onError)try{this._onError(s)}catch(o){console.error(N.CALLBACK_ERROR_IN_ERROR_HANDLER,o)}if(this._notifySubscribers(void 0,void 0),n)throw s}_finalizeResolution(t){((this.flags&lt)===0||!this._equal(this._value,t))&&(this.version=Ne(this.version)),this._value=t,this._error=null,this.flags=Jt(this.flags,Qt.TO_RESOLVED)}execute(){this._markDirty()}_markDirty(){const t=this.flags;(t&(J|ut))!==0||!(t&oe)&&!this._isShallowDirty()||(this.flags=t|ut,et.trackUpdate(this.id,et.getDebugName(this)),this._notifySubscribers(void 0,void 0))}_deepDirtyCheck(){return Ht(this._deps)}};function W(t,e={}){return new Cr(t,e)}function Tr(...t){return W(()=>Ut(t))}function Ar(){return{loopCount:0,lastFlushEpoch:$t.UNINITIALIZED,windowCount:0,windowStart:0,totalExecutions:0}}function Rr(t,e,n,s,r){t.lastFlushEpoch!==n&&(t.lastFlushEpoch=n,t.loopCount=0),++t.loopCount>e&&r("per-effect"),s()>_t.MAX_EXECUTIONS_PER_FLUSH&&r("global"),t.totalExecutions++}function Or(t,e,n){if(!Number.isFinite(e))return;const s=Date.now();if(s-t.windowStart>=we.EFFECT_FREQUENCY_WINDOW){t.windowStart=s,t.windowCount=1;return}++t.windowCount>e&&n()}var wr=class extends Ve{constructor(t,e={}){super(),this[ht]=k.Effect,this._trackEpoch=$t.UNINITIALIZED,this._trackCount=0,this._trackSessionId=0,this._budget=Ar(),this._deps=An(),this._cleanup=null,this._fn=t,this._onError=e.onError??null,this._sync=e.sync??!1,this._maxExecutions=e.maxExecutionsPerSecond??_t.MAX_EXECUTIONS_PER_SECOND,this._maxExecutionsPerFlush=e.maxExecutionsPerFlush??_t.MAX_EXECUTIONS_PER_EFFECT,this._notifyCallback=this._sync?()=>this.execute():()=>re(Y,this),et.attachDebugInfo(this,"effect",this.id,e.name)}run(){if(this.isDisposed)throw new Ct(N.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.isDisposed||(this.flags|=pt.DISPOSED,this._execCleanup(),this._deps&&In(this._deps))}get executionCount(){return this._budget.totalExecutions}get isExecuting(){return(this.flags&pt.EXECUTING)!==0}get isDisposed(){return(this.flags&pt.DISPOSED)!==0}execute(t=!1){if(!this._prepareExecution(t))return;this._execCleanup(),this._startTracking();const e=I.stack.length;let n,s=!1,r;try{try{n=Dn(I,this,this._fn)}catch(o){throw ze(I,e),o}}catch(o){s=!0,r=o}this._commitDeps(),s?this._handleExecutionError(r):this._handleResult(n),this.flags&=~pt.EXECUTING}_prepareExecution(t){return(this.flags&(pt.DISPOSED|pt.EXECUTING))!==0||!(t||this._deps.slots.length===0||this._isDirty())?!1:(this._validateBudget(),et.trackUpdate(this.id,et.getDebugName(this)),this.flags|=pt.EXECUTING,!0)}addDependency(t){if(!this.isExecuting||t._lastSeenEpoch===this._trackEpoch)return;t._lastSeenEpoch=this._trackEpoch;const e=this._trackCount++,n=this._deps,s=t.version,r=n.slots.at(e);r?.node===t?r.version=s:On(n,t,e)||this._insertNewDependency(t,e,s),t.isComputed&&!n.hasComputeds&&(n.hasComputeds=!0)}_insertNewDependency(t,e,n){const s=kn(t,n,t.subscribe(this._notifyCallback));wn(this._deps,e,s)}_startTracking(){this._trackEpoch=$n(),this._trackCount=0,Rn(this._deps)}_commitDeps(){try{He(this._deps,this._trackCount)}catch(t){q&&console.warn("[atom-effect] _commitDeps failed during error recovery:",t)}}_handleResult(t){typeof t=="function"?this._cleanup=t:Sn(t)?this._handleAsyncResult(t):this._cleanup=null}_handleAsyncResult(t){const e=++this._trackSessionId;t.then(n=>{if(this._trackSessionId!==e||this.isDisposed){if(typeof n=="function")try{n()}catch(s){this._handleExecutionError(s,N.EFFECT_CLEANUP_FAILED)}return}typeof n=="function"&&(this._cleanup=n)},n=>{this._trackSessionId===e&&this._handleExecutionError(n)})}_execCleanup(){const t=this._cleanup;if(t){this._cleanup=null;try{t()}catch(e){this._handleExecutionError(e,N.EFFECT_CLEANUP_FAILED)}}}_validateBudget(){Rr(this._budget,this._maxExecutionsPerFlush,pr(),mr,t=>this._abortExecution(t)),q&&Or(this._budget,this._maxExecutions,()=>{const t=new Ct(N.EFFECT_FREQUENCY_LIMIT_EXCEEDED);throw this.dispose(),this._handleExecutionError(t),t})}_abortExecution(t){const e=new Ct(t==="per-effect"?`Infinite loop detected (per-effect): executed ${this._budget.loopCount} times in current flush.`:"Infinite loop detected (global): exceeded total execution limit per flush.");throw this.dispose(),console.error(e),e}_handleExecutionError(t,e=N.EFFECT_EXECUTION_FAILED){const n=se(t,Ct,e);if(console.error(n),this._onError)try{this._onError(n)}catch(s){console.error(se(s,Ct,N.CALLBACK_ERROR_IN_ERROR_HANDLER))}}_isDirty(){return Ht(this._deps)}_deepDirtyCheck(){return Ht(this._deps)}};function st(t,e={}){if(typeof t!="function")throw new Ct(N.EFFECT_MUST_BE_FUNCTION);const n=new wr(t,e);return n.execute(),n}var zn=new Set(["__proto__","constructor","prototype"]);function Ir(t,e,n){if(Array.isArray(t)){const o=[...t];return o[e]=n,o}if(t instanceof Map){const o=new Map(t);return o.set(e,n),o}const s=Object.getPrototypeOf(t);if(s===Object.prototype||s===null)return{...t,[e]:n};const r=Object.create(s);return Object.assign(r,t),r[e]=n,r}function Vn(t,e,n,s){if(n===e.length)return s;const r=e[n];if(zn.has(r)||t==null||typeof t!="object")return t;const o=t instanceof Map?t.get(r):t[r],i=Vn(o,e,n+1,s);return Object.is(o,i)?t:Ir(t,r,i)}function kr(t,e){let n=t;const s=e.length;for(let r=0;r<s;r++){if(n==null)return;n instanceof Map?n=n.get(e[r]):n=n[e[r]]}return n}function We(t,e){const n=e.split("."),s=n.some(u=>zn.has(u)),r=new Set;let o=null,i;const a=u=>s?void 0:kr(u,n),c=()=>{const u=a(t.peek());if(!Object.is(u,i)){const l=i;i=u,r.forEach(h=>h(u,l))}};return{get value(){return a(t.value)},set value(u){if(s)return;const l=t.peek(),h=Vn(l,n,0,u);h!==l&&(t.value=h)},peek:()=>a(t.peek()),subscribe(u){return r.size===0&&(i=a(t.peek()),o=t.subscribe(c)),r.add(u),()=>{r.delete(u),r.size===0&&o&&(o(),o=null)}},subscriberCount:()=>r.size,dispose:()=>{o?.(),o=null,r.clear()},[ht]:k.Atom|k.Writable}}var Nr=(t,e)=>We(t,e),qn=t=>e=>We(t,e);function Xn(...t){let e;const n=new Set,s=[],r=()=>{const o=Ut(t,!0);if(!Gs(o,e)){const i=e;e=o;for(const a of n)a(o,i)}};return{get value(){return Ut(t)},set value(o){It(()=>{for(let i=0;i<t.length;i++)t[i].value=o})},peek:()=>Ut(t,!0),subscribe:o=>{if(n.size===0){e=Ut(t,!0);for(let i=0;i<t.length;i++)s.push(t[i].subscribe(r))}return n.add(o),()=>{if(n.delete(o),n.size===0){for(const i of s)i();s.length=0}}},subscriberCount:()=>n.size,dispose:()=>{for(const o of s)o();s.length=0,n.clear()},[ht]:k.Atom|k.Writable}}var Dr={ERRORS:{EFFECT_DISPOSE_ERROR:t=>`Dispose error${t?`: ${t}`:""}`}},bt={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}`}},y={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}`:""}`}},Rt={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}".`}},ie={PREFIX:"[atom-list]",ERRORS:{DUPLICATE_KEY:(t,e)=>`Duplicate key "${t}" at index ${e}.`}},rn={PREFIX:"[atom-mount]",ERRORS:{ERROR:t=>`Mount error${t?` in <${t}>`:""}`,CLEANUP_ERROR:t=>`Cleanup error${t?` in <${t}>`:""}`}},ft={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.`}},Lr={DEFAULTS:{HIGHLIGHT_DURATION_MS:500}},Gn=t=>t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function";function Ft(t){const{localName:e,id:n,className:s}=t;let r=e;n&&(r+=`#${n}`);const o=typeof s=="string"?s:s?.baseVal;if(o){const a=o.trim().replace(/\s+/g,".");a&&(r+=`.${a}`)}const i=t.type;return i&&i!=="text"&&(r+=`.${i}`),r}function Wn(t,e,n){if(typeof n=="object"&&n!==null&&!(n instanceof File)&&!(n instanceof Blob))for(const[s,r]of Object.entries(n))Wn(t,e?`${e}[${s}]`:s,r);else t.append(e,n instanceof Blob?n:String(n??""))}function Pr(t){return t.replace(/\[(\w+)\]/g,".$1").replace(/^\./,"")}var ae="data-atom-debug",Yn=typeof window<"u",be=new WeakMap,on=!1;function Ur(){if(on||!Yn)return;const t=`
2
+ [${ae}] { 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(ae,""),e.textContent=t,document.head.appendChild(e)}on=!0}function Mr(){const t=globalThis;return t.__ATOM_DEBUG__!=null?!!t.__ATOM_DEBUG__:t.process?.env?.NODE_ENV!=="production"&&t.process?.env?.NODE_ENV!=null}var Fr=Mr(),T={enabled:Fr,warn:(t,e,...n)=>console.warn(`${t} ${e}`,...n),error:(t,e,n)=>console.error(`${t} ${e}`,n),domUpdated(t,e,n,s){if(!this.enabled)return;const r="jquery"in e?e[0]:e;r?.nodeType===1&&r.isConnected&&(console.log(`${t} DOM updated: ${Ft(r)}.${n} =`,s),xr(r))}};function xr(t){if(!Yn||typeof t.animate!="function")return;Ur(),be.get(t)?.cancel(),t.hasAttribute(ae)||t.setAttribute(ae,"");const e=t.animate([{outline:"2px solid rgba(255, 68, 68, 0.9)",outlineOffset:"1px"},{outline:"0px solid transparent",outlineOffset:"1px"}],{duration:Lr.DEFAULTS.HIGHLIGHT_DURATION_MS,easing:"ease-out"});be.set(t,e),e.onfinish=()=>be.delete(t)}var jr=()=>_r();f.default.extend({atom:Pt,computed:W,effect:st,batch:It,untracked:M,isAtom:nt,isComputed:vr,nextTick:jr,atomLens:We,composeLens:Nr,lensFor:qn,mergeAtoms:Tr,mergeLenses:Xn,debug:T});var Kn=Symbol.for("atom-effect.Option"),De=Symbol.for("atom-effect.Result"),Se=Object.freeze({ok:!1,value:void 0,[Kn]:!0}),m={some:t=>({ok:!0,value:t,[Kn]:!0}),none:Se,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:m.some(n)},andThen:(t,e)=>t.ok?e(t.value):t,fromNullable:t=>t==null?Se:m.some(t),match:(t,e)=>t.ok?e.some(t.value):e.none(),filter:(t,e)=>t.ok&&e(t.value)?t:Se,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},$r=Object.freeze({ok:!0,value:void 0,error:void 0,[De]:!0});function Ce(t){return t instanceof Error?t:new Error(typeof t=="string"?t:String(t??"Unknown error"))}var C={ok:t=>t===void 0?$r:{ok:!0,value:t,error:void 0,[De]:!0},err:t=>({ok:!1,value:void 0,error:t,[De]:!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:C.ok(n)},mapErr:(t,e)=>t.ok?t:C.err(e(t.error)),andThen:(t,e)=>t.ok?e(t.value):t,tryCatch:t=>{try{return C.ok(t())}catch(e){return C.err(Ce(e))}},tryAsync:t=>{try{const e=t();return Promise.resolve(e).then(n=>C.ok(n),n=>C.err(Ce(n)))}catch(e){return Promise.resolve(C.err(Ce(e)))}},toOption:t=>t.ok?m.some(t.value):m.none},Hr=[0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,-1],x=4,Br=15,me=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 Hr[t&Br]}_rawWrite(t,e){if(t<x){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-x]=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 s=this._overflow,r=this._freeIndices;if(r?.length){const o=r.pop();return s[o]=t,o+x}return s.push(t),x-1+s.length}_rawSwap(t,e){if(t===e)return;const n=this.at(t),s=this.at(e);this._rawWrite(t,s),this._rawWrite(e,n)}get length(){return this._count}get size(){return this._actualCount}at(t){if(t<x)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-x]??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>x){const e=this._overflow;for(;this._count>x&&e[this._count-(x+1)]==null;)this._count--}this._count<=x&&(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<x?(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-x),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 s=0,r=n.length;s<r;s++)if(n[s]===t)return n[s]=null,this._actualCount--,this._shrinkPhysicalSizeFrom(s+x),this._freeIndices||(this._freeIndices=[]),this._freeIndices.push(s),!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 s=0,r=n.length;s<r;s++)if(n[s]===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 s=0,r=n.length;s<r;s++){const o=n[s];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 s=0,r=n.length;s<r;s++){const o=n[s];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 s=this._overflow;for(let r=0;r<e;r++){const o=this.at(r);if(o!==null&&(r!==n&&(this._rawWrite(n,o),this._rawWrite(r,null)),++n===t))break}this._count=t,s!==null&&(n<=x?this._overflow=null:s.length=n-x),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}},zr=Object.prototype.hasOwnProperty;function Le(t,e){if(t===e)return!0;if(t===null||e===null||typeof t!="object"||typeof e!="object")return!1;const n=t,s=e,r=Object.keys(n);if(r.length!==Object.keys(s).length)return!1;for(const o of r)if(!zr.call(s,o)||!Object.is(n[o],s[o]))return!1;return!0}var Qn=!0;function an(t){Qn=t}var Zt="_aes-bound",cn="_aes-has-shadow",Vr=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,cn)}getShadow(t){return m.unwrapOr(m.fromNullable(t.shadowRoot),m.toNullable(m.fromNullable(this.shadows.get(t))))}getOrCreateRecord(t){return Qn&&!this.autoCleanupScheduled&&typeof document<"u"&&document.body&&(this.autoCleanupScheduled=!0,_e(document.body)),m.unwrapOrElse(m.fromNullable(this.records.get(t)),()=>{const e={};return this.records.set(t,e),this.safeMark(t,Zt),e})}addCleanup(t,e){const n=this.getOrCreateRecord(t);n.tasks||(n.tasks=new me),n.tasks.push(e)}trackEffect(t,e){const n=Ft(t);this.addCleanup(t,()=>{const s=C.tryCatch(()=>e.dispose());s.ok||T.error(y.PREFIX,Dr.ERRORS.EFFECT_DISPOSE_ERROR(n),s.error)})}onCleanup(t,e){const n=Ft(t);this.addCleanup(t,()=>{const s=C.tryCatch(()=>e());s.ok||T.error(y.PREFIX,y.ERRORS.CLEANUP_ERROR(n),s.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=m.fromNullable(this.records.get(e));if(m.isSome(n)){const s=n.value;this.records.delete(e),e.classList.remove(Zt),m.match(m.fromNullable(s.teardown),{some:r=>{const o=C.tryCatch(()=>r());if(!o.ok){const i=Ft(e);T.error(rn.PREFIX,rn.ERRORS.CLEANUP_ERROR(i),o.error)}},none:()=>{}}),m.match(m.fromNullable(s.tasks),{some:r=>{r.forEach(o=>o()),r.dispose()},none:()=>{}})}else e.classList.remove(Zt)}cleanupDescendants(t){const e=t.querySelectorAll(`.${Zt}`);for(let s=0,r=e.length;s<r;s++){const o=e[s];o&&this.cleanup(o)}const n=t.querySelectorAll(`.${cn}`);for(let s=0,r=n.length;s<r;s++){const o=n[s],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)}},E=new Vr,kt=new Map;function _e(t){if(kt.has(t))return;const e=new MutationObserver(n=>{for(let s=0,r=n.length;s<r;s++){const o=n[s].removedNodes;for(let i=0,a=o.length;i<a;i++){const c=o[i];if(c.nodeType!==1||c.isConnected)continue;const u=c;E.isKept(u)||E.isIgnored(u)||E.cleanupTree(u)}}});e.observe(t,{childList:!0,subtree:!0}),kt.set(t,e)}function Jn(){kt.forEach(t=>t.disconnect()),kt.clear(),E.setAutoCleanupScheduled(!1)}function qr(t){const e=kt.get(t);e&&(e.disconnect(),kt.delete(t))}var Pe=Symbol.for("aej:hydrated"),ce=Symbol.for("aej:cleanup-enabled"),Zn="aej:context-request",zt=Symbol.for("atom-effect-internal"),Q=(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})({}),Xr=0;function Gr(t){t[zt]=!0}var un={multipleSelect:{read:t=>{if(!(t instanceof HTMLSelectElement))return[];const e=t.selectedOptions,n=[];for(let s=0,r=e.length;s<r;s++)n.push(e[s].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 s=0,r=t.length;s<r;s++)if(!Object.is(t[s],e[s]))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,s)=>{if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&document.activeElement===t){const r=t;try{const{selectionStart:o,selectionEnd:i}=r;if(r.value=s,o!==null&&i!==null){const a=s.length;r.setSelectionRange(Math.min(o,a),Math.min(i,a))}}catch{r.value=s}}else t.value=s},equal:(t,e,n)=>n(t,e),format:(t,e)=>e?e(t):String(t??"")}},Wr=class{constructor(t,e,n){this.atom=e,this.options=n,this.abortController=new AbortController,this.flags=Q.None,this.syncToDom=()=>{const a=this.atom.value;this.flags&Q.Busy||M(()=>{if(!this.isDomUpToDate(a)){this.flags|=Q.SyncingToDom;try{const c=this.formatValue(a);this.writeToDom(a,c),T.domUpdated(y.PREFIX,this.$element,"val",c)}catch(c){T.warn(y.PREFIX,"syncToDom failed:",c)}this.flags&=~Q.SyncingToDom}})},this.atom=e,this.options=n,this.$element=t,this.eventNamespace=`.atomBind-${++Xr}`;const s=t[0],r=s.tagName==="SELECT"&&s.multiple?un.multipleSelect:un.default,o=n.parse,i=n.equal??Object.is;this.readValue=()=>r.read(s,this.$element,o),this.writeToDom=(a,c)=>r.write(s,this.$element,a,c),this.areEqual=(a,c)=>r.equal(a,c,i),this.formatValue=a=>r.format(a,n.format),this.initializeEvents()}initializeEvents(){const t=this.eventNamespace,e=this.options.debounce??y.INPUT_DEFAULTS.debounce,n=c=>{(c&&"originalEvent"in c?c.originalEvent:c)?.isComposing||this.syncToAtom()},s=e>0?c=>{clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>n(c),e)}:n,r=()=>this.flags|=Q.Focused,o=()=>this.handleBlur();[r,o,s].forEach(Gr);const i=(this.options.event??y.INPUT_DEFAULTS.event).trim().split(/\s+/);let a="";for(let c=0,u=i.length;c<u;c++)a+=(c>0?" ":"")+i[c]+t;this.$element.on(`focus${t}`,r).on(`blur${t}`,o).on(a,s)}handleBlur(){this.flags&=~Q.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&Q.Busy)){this.flags|=Q.SyncingToAtom;try{const t=this.readValue();this.areEqual(this.atom.peek(),t)||(this.atom.value=t)}catch(t){T.warn(y.PREFIX,"syncToAtom failed:",t)}this.flags&=~Q.SyncingToAtom}}isDomUpToDate(t){if(!this.areEqual(this.readValue(),t))return!1;if(this.flags&Q.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 Yr(t,e,n){const s=new Wr(t,e,n);return{reactiveEffect:st(s.syncToDom),cleanup:()=>s.cleanup()}}function ts(t,e,n){let s=0,r=!1;return E.onCleanup(t,()=>{r=!0}),o=>{const i=++s;if(!Gn(o)){if(r||i!==s)return;M(()=>{try{n(o),T.domUpdated(y.PREFIX,t,e,o)}catch(a){T.error(y.PREFIX,y.ERRORS.UPDATER_ERROR(e,!0),a)}});return}o.then(a=>{r||i!==s||M(()=>{try{n(a),T.domUpdated(y.PREFIX,t,`${e} (async)`,a)}catch(c){T.error(y.PREFIX,y.ERRORS.UPDATER_ERROR(e,!1),c)}})},a=>{i===s&&!r&&T.error(y.PREFIX,y.ERRORS.UPDATER_ERROR(e),a)})}}function Ye(t,e,n,s){const r=ts(t,s,n),o=nt(e);o||typeof e=="function"?E.trackEffect(t,st(()=>{r(o?e.value:e())},{name:s})):r(e)}function Ee(t,e,n,s){const r=ts(t,s,n),o=Object.keys(e),i=o.length;let a=!1;for(let u=0;u<i;u++){const l=e[o[u]];if(nt(l)||typeof l=="function"){a=!0;break}}const c=()=>{const u={},l=[];for(let h=0;h<i;h++){const d=o[h],p=e[d];let _;nt(p)?_=p.value:typeof p=="function"?_=p():_=p,Gn(_)?l.push(_.then(v=>({key:d,value:v}))):u[d]=_}return l.length>0?Promise.all(l).then(h=>{for(let d=0,p=h.length;d<p;d++){const _=h[d];u[_.key]=_.value}return u}):u};a?E.trackEffect(t,st(()=>r(c()),{name:s})):r(c())}var es={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"]},xt={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"]},St={NUMERIC_ENTITY:/&#x([0-9a-f]+);?|&#([0-9]+);?/gi,NAMED_ENTITY:new RegExp(`&(${Object.keys(xt.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*${Rt.DANGEROUS_PROTOCOL_PATTERN}\\s*:`,"i"),CSS_CLEAN:/\/\*[\s\S]*?\*\//g},te=Function.prototype.call.bind(Function.prototype.call),Te=(t,e)=>Object.getOwnPropertyDescriptor(t,e)?.get,P={getAttributes:t=>{const e=Te(Element.prototype,"attributes");return Array.from(e?te(e,t):t.attributes)},setAttribute:(t,e,n)=>te(Element.prototype.setAttribute,t,e,n),removeAttribute:(t,e)=>te(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=Te(Element.prototype,"localName")??Te(Node.prototype,"nodeName");return(n?te(n,e):e.localName??"").toLowerCase()},createElement:t=>document.createElement(t)},Z={decodeEntities(t){return t.replace(St.NUMERIC_ENTITY,(e,n,s)=>{const r=n?parseInt(n,16):parseInt(s,10);return r>=0&&r<=1114111?String.fromCodePoint(r):""}).replace(St.NAMED_ENTITY,(e,n)=>xt.ENTITIES[n.toLowerCase()]??"")},normalize(t){return typeof t!="string"?"":this.decodeEntities(this.decodeEntities(t)).replace(St.CONTROL_CHARS,"")},isDangerousUri(t){const e=this.normalize(t).replace(/\s+/g,"");return St.PROTOCOL.test(e)||St.DATA_URI.test(e)},isDangerousCss(t){const e=this.normalize(t).replace(St.CSS_CLEAN,"").toLowerCase();if(["javascript:","expression(","-moz-binding"].some(s=>e.includes(s)))return!0;const n=e.match(/url\s*\(\s*["']?([^"')]*)["']?\s*\)/i)?.[1];return!!n&&this.isDangerousUri(n)}};function ns(t,e){const n=P.createElement("template"),s=document.createElement("div");return n.innerHTML=t,ss(n.content,e),s.innerHTML="",s.appendChild(n.content),s.innerHTML}var Kr=[{match:(t,e,n)=>t==="style",action:(t,e,n)=>{const s=n.split(";").map(r=>r.trim()).filter(r=>r&&!Z.isDangerousCss(r));P.setAttribute(t,e,s.length?`${s.join("; ")};`:"data-unsafe-css:")}},{match:t=>t==="srcdoc",action:(t,e,n,s)=>P.setAttribute(t,e,ns(n,s))},{match:t=>t==="srcset",action:(t,e,n)=>{const s=n.split(",").map(r=>{const o=r.trim();if(!o)return r;const[i,...a]=o.split(/\s+/);return Z.isDangerousUri(i)?["data-unsafe-protocol:",...a].join(" "):[Z.normalize(i),...a].join(" ")});P.setAttribute(t,e,s.join(", "))}},{match:(t,e,n)=>n.urlAttributes.includes(t)&&Z.isDangerousUri(e),action:(t,e)=>P.setAttribute(t,e,"data-unsafe-protocol:")},{match:(t,e,n)=>xt.SENSITIVE.includes(t)&&(e.startsWith("on")||Z.isDangerousUri(e))||xt.CLOBBER.ATTRS.includes(t)&&xt.CLOBBER.VALUES.includes(e.toLowerCase()),action:(t,e)=>P.removeAttribute(t,e)},{match:(t,e,n)=>t.startsWith("on"),action:(t,e)=>P.removeAttribute(t,e)},{match:(t,e,n)=>t.includes("javascript")||t.includes("expression")||Z.isDangerousUri(e)||e.includes("javascript")||e.includes("expression"),action:(t,e)=>P.removeAttribute(t,e)}];function ln(t,e){const n=P.getAttributes(t),s=n.filter(r=>r.name.toLowerCase().startsWith("on")).map(r=>r.name);for(const{name:r,value:o}of n){const i=r.toLowerCase();for(const a of Kr)if(a.match(i,o,e)){a.action(t,r,o,e);break}}s.length&&P.setAttribute(t,"data-unsafe-attr",s.join(","))}function Qr(t,e){if(t.nodeType===Node.TEXT_NODE){const r=t.textContent??"";if(e.blacklistedTags.some(o=>Z.normalize(r).toLowerCase().includes(`<${o}`))){const o=P.createElement("span");return o.textContent=r.replace(/</g,"[").replace(/>/g,"]"),P.replaceNode(t,o)?o:t}return t}if(t.nodeType!==Node.ELEMENT_NODE)return t;const n=t,s=P.getLocalName(n);if(ln(n,e),e.blacklistedTags.includes(s)){const r=P.createElement("span");if(P.getAttributes(n).forEach(o=>r.setAttribute(o.name,o.value)),ln(r,e),s==="style"&&Z.isDangerousCss(n.textContent??""))r.textContent="/* blocked */";else for(;n.firstChild;)r.appendChild(n.firstChild);return P.replaceNode(n,r)?r:n}return n}function ss(t,e){const n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);let s=t;for(;s;){const r=n.nextNode();Qr(s,e),s.nodeType===Node.ELEMENT_NODE&&P.getLocalName(s)==="template"&&ss(s.content,e),s=r}}function Vt(t,e=es){return t?ns(String(t),e):""}var rs=(t,e,n=es)=>{const s=t.toLowerCase();return(s==="srcdoc"||n.urlAttributes.includes(s))&&Z.isDangerousUri(e)},Jr=t=>Z.isDangerousCss(t);function Zr(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function os(t,e){return t.toLowerCase().startsWith("on")?(console.warn(`${y.PREFIX} ${Rt.ERRORS.BLOCKED_EVENT_HANDLER(t)}`),!1):e&&Rt.DANGEROUS_PROPS.includes(t)?(console.warn(`${y.PREFIX} ${Rt.ERRORS.BLOCKED_PROP(t)}`),!1):!0}function is(t,e,n){Ye(t,e,s=>{const r=m.unwrapOr(m.map(m.fromNullable(n),o=>o(s)),String(s??""));t.textContent!==r&&(t.textContent=r)},"text")}function as(t,e){let n=null;Ye(t,e,s=>{const r=Vt(s);n!==r&&(E.cleanupDescendants(t),t.innerHTML=r,n=r)},"html")}function cs(t,e){const n=new Map;Object.keys(e).forEach(s=>{const r=s.trim();n.set(s,r.includes(" ")?r.split(/\s+/).filter(Boolean):[r])}),Ee(t,e,s=>{const r=new Set;for(const[o,i]of Object.entries(s))i&&n.get(o)?.forEach(a=>r.add(a));Array.from(n.values()).flat().forEach(o=>{t.classList.toggle(o,r.has(o))})},"class")}function us(t,e){const{style:n}=t,s={},r={},o=new Map;Object.entries(e).forEach(([i,a])=>{const[c,u]=Array.isArray(a)?a:[a,""];s[i]=c,r[i]=u}),Ee(t,s,i=>{Object.entries(i).forEach(([a,c])=>{const u=r[a]??"",l=u?`${c}${u}`:String(c);o.get(a)!==l&&(Jr(l)||n.setProperty(Zr(a),l),o.set(a,l))})},"css")}function ls(t,e){const n=Object.entries(e).filter(([i])=>os(i,!1)),s=Object.fromEntries(n),r={},o={};for(const[i]of n)r[i]={isAria:i.toLowerCase().startsWith("aria-")},o[i]=t.getAttribute(i);Ee(t,s,i=>{for(const[a,c]of Object.entries(i)){const u=r[a];if(!u)continue;const l=m.unwrapOr(m.map(m.fromNullable(c),h=>h===!0?u.isAria?"true":a:h===!1?u.isAria?"false":null:String(h)),null);if(l!==null&&rs(a,l)){console.warn(`${y.PREFIX} ${Rt.ERRORS.BLOCKED_PROTOCOL(a)}`);continue}o[a]!==l&&(l===null?t.removeAttribute(a):t.setAttribute(a,l),o[a]=l)}},"attr")}function fs(t,e){const n=t,s=Object.entries(e).filter(([i])=>os(i,!0)),r=Object.fromEntries(s),o={};Ee(t,r,i=>{for(const[a,c]of Object.entries(i))if(o[a]!==c){if(typeof c=="string"&&rs(a,c)){console.warn(`${y.PREFIX} ${Rt.ERRORS.BLOCKED_PROTOCOL(a)}`);continue}n[a]=c,o[a]=c}},"prop")}function ue(t,e,n){let s=t.style.display==="none"?"":t.style.display;Ye(t,e,r=>{const o=n!==!!r,i=t.style.display;o?i==="none"&&(t.style.display=s):i!=="none"&&(s=i,t.style.display="none")},n?"hide":"show")}function Ke(t,e,n={}){const s=t.tagName.toLowerCase();if(!(y.VALID_INPUT_TAGS.includes(s)||s.includes("-"))){console.warn(`${y.PREFIX} ${y.ERRORS.INVALID_INPUT_ELEMENT(s)}`);return}const{reactiveEffect:r,cleanup:o}=Yr((0,f.default)(t),e,n);E.trackEffect(t,r),E.onCleanup(t,o)}function fn(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 hs(t,e){if(!(t instanceof HTMLInputElement)){console.warn(`${y.PREFIX} atomChecked called on non-input element`);return}const n=t,s=(0,f.default)(n),r=()=>{e.peek()!==n.checked&&(e.value=n.checked,fn(n))};r[zt]=!0,s.on("change change.atomRadioSync",r),E.onCleanup(n,()=>s.off("change change.atomRadioSync",r)),E.trackEffect(n,st(()=>{const o=!!e.value;M(()=>{n.checked!==o&&(n.checked=o,T.domUpdated(y.PREFIX,n,"checked",o),o&&fn(n))})}))}function to(t,e){const n=(0,f.default)(t);n.on(e),E.onCleanup(t,()=>n.off(e))}function eo(t,e,n){const s=(0,f.default)(t);s.on(e,n),E.onCleanup(t,()=>s.off(e,n))}var hn="input, select, textarea, [name]";function no(t,e,n,s){if(!s)return n;if(!Array.isArray(t))return e;const r=new Set,o=t.length;for(let i=0;i<o;i++)r.add(String(t[i]));return e?r.add(n):r.delete(n),Array.from(r)}function so(t,e,n){if(!n)return String(t)===e;if(!Array.isArray(t))return!!t;const s=t.length;for(let r=0;r<s;r++)if(String(t[r])===e)return!0;return!1}function ro(t,e,n){const{transform:s,onChange:r}=n,o=W(()=>e.value),i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(o),"value"),a={set(u){let l=u;try{l=s?s(t,u):u}catch(h){console.error(`[bindForm] Transform error in field "${t}":`,h)}if(e.value=l,r)try{M(()=>r(t,l))}catch(h){console.error(`[bindForm] onChange error in field "${t}":`,h)}},configurable:!0};i?.get&&(a.get=i.get),Object.defineProperty(o,"value",a);const c=o.dispose;return o.dispose=()=>{c.call(o);const u=e;typeof u.dispose=="function"&&u.dispose()},o}function oo(t,e,n,s){return st(()=>{try{const r=s(n.value);let o="";typeof r=="string"?o=r:r===!1&&(o="Invalid"),t.setCustomValidity?.(o)}catch(r){console.error(`Validation error in field "${e}":`,r),t.setCustomValidity?.("Validation failed")}})}function io(t,e,n,s){return st(()=>{const r=so(e.value,n,s);t.checked!==r&&(t.checked=r)})}var ao=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 n=this.form.elements,s=n.length;for(let r=0;r<s;r++)this.bindField(n[r]);return}if(t.matches?.(hn)){this.bindField(t);return}const e=t.querySelectorAll?.(hn);if(e){const n=e.length;for(let s=0;s<n;s++)this.bindField(e[s])}}bindField(t){const e=t,n=e.name||t.getAttribute("name");if(!n)return;const s=this.names.get(e);if(s===n)return;s!==void 0&&E.cleanup(e);const r=this.ensureField(n);this.names.set(e,n),E.onCleanup(e,()=>this.unbindField(e,n)),e instanceof HTMLInputElement&&(e.type==="radio"||e.type==="checkbox")?this.bindToggle(e,r.atom,e.value,e.type==="checkbox"):Ke(e,r.atom,this.options),this.applyValidation(e,n,r.atom)}applyValidation(t,e,n){const s=this.options.validation?.[e];s&&E.trackEffect(t,oo(t,e,n,s))}bindToggle(t,e,n,s){const r=()=>{e.value=no(e.peek(),t.checked,n,s)};r[zt]=!0,(0,f.default)(t).on("change",r),E.onCleanup(t,()=>(0,f.default)(t).off("change",r)),E.trackEffect(t,io(t,e,n,s))}ensureField(t){let e=this.entries.get(t);if(e)return e.refCount++,e;const n=Pr(t);return e={atom:ro(t,qn(this.atom)(n),this.options),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 s=n.atom;typeof s.dispose=="function"&&s.dispose(),this.entries.delete(e)}E.cleanup(t)}observe(){const t=new MutationObserver(e=>{const n=e.length;for(let s=0;s<n;s++){const r=e[s];if(r.type==="childList"){const o=r.addedNodes,i=o.length;for(let a=0;a<i;a++){const c=o[a];c.nodeType===1&&this.bindSubtree(c)}}else r.attributeName==="name"&&this.bindSubtree(r.target)}});t.observe(this.form,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["name"]}),E.onCleanup(this.form,()=>t.disconnect())}};function ds(t,e,n={}){const s=Array.isArray(e)?Xn(...e):e;E.cleanup(t),new ao(t,s,n)}function $(t,e){for(let n=0,s=t.length;n<s;n++){const r=t[n];r&&r.nodeType===Node.ELEMENT_NODE&&e(r)}return t}function Ae(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 ps(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 $(this,n=>is(n,t,e))};f.default.fn.atomHtml=function(t){return $(this,e=>as(e,t))};function Qe(t,e){return function(n,s){const r=ps(n,s);return r?$(this,o=>t(o,r)):(console.warn(`${y.PREFIX} ${e}`),this)}}f.default.fn.atomClass=Qe(cs,y.ERRORS.MISSING_CONDITION("atomClass"));f.default.fn.atomAttr=Qe(ls,y.ERRORS.MISSING_SOURCE("atomAttr"));f.default.fn.atomProp=Qe(fs,y.ERRORS.MISSING_SOURCE("atomProp"));f.default.fn.atomCss=function(t,e,n){const s=ps(t,e!==void 0&&n?[e,n]:e);return s?$(this,r=>us(r,s)):(console.warn(`${y.PREFIX} ${y.ERRORS.MISSING_SOURCE("atomCss")}`),this)};f.default.fn.atomShow=function(t){return $(this,e=>ue(e,t,!1))};f.default.fn.atomHide=function(t){return $(this,e=>ue(e,t,!0))};f.default.fn.atomVal=function(t,e={}){return $(this,n=>Ke(n,t,e))};f.default.fn.atomChecked=function(t){return $(this,e=>hs(e,t))};f.default.fn.atomForm=function(t,e={}){return $(this,n=>{n instanceof HTMLFormElement?ds(n,t,e):T.warn(y.PREFIX,"Skipping non-Form element for atomForm")})};f.default.fn.atomOn=function(t,e){return $(this,n=>eo(n,t,e))};var dn=[{key:"text",run:(t,e)=>is(t,...Ae(e))},{key:"html",run:(t,e)=>as(t,e)},{key:"class",run:(t,e)=>cs(t,e)},{key:"css",run:(t,e)=>us(t,e)},{key:"attr",run:(t,e)=>ls(t,e)},{key:"prop",run:(t,e)=>fs(t,e)},{key:"show",run:(t,e)=>ue(t,e,!1)},{key:"hide",run:(t,e)=>ue(t,e,!0)},{key:"val",run:(t,e)=>Ke(t,...Ae(e))},{key:"checked",run:(t,e)=>hs(t,e)},{key:"form",run:(t,e)=>{t instanceof HTMLFormElement&&ds(t,...Ae(e))}},{key:"on",run:(t,e)=>to(t,e)}];f.default.fn.atomBind=function(t){const e=t,n=[];for(let s=0,r=dn.length;s<r;s++){const o=dn[s];e[o.key]!==void 0&&n.push(o)}return n.length===0?this:$(this,s=>{for(let r=0,o=n.length;r<o;r++){const i=n[r];i.run(s,e[i.key])}})};f.default.fn.atomUnbind=function(){return $(this,t=>E.cleanupTree(t))};function Ot(t){return"nodeType"in t&&t.nodeType===1?(0,f.default)(t):t}function ms(t,e){if(!t)return;const n="data-atom-key";if("nodeType"in t){if(t.nodeType===1){const o=t;e===null?o.removeAttribute(n):o.getAttribute(n)!==e&&o.setAttribute(n,e)}return}const s=t,r=s.length|0;if(e===null)for(let o=0;o<r;o++){const i=s[o];i&&i.nodeType===1&&i.removeAttribute(n)}else for(let o=0;o<r;o++){const i=s[o];if(i&&i.nodeType===1){const a=i;a.getAttribute(n)!==e&&a.setAttribute(n,e)}}}function co(t){if(!t)return;if("nodeType"in t){t.nodeType===1&&E.cleanupTree(t);return}const e=t,n=e.length|0;for(let s=0;s<n;s++){const r=e[s];r&&r.nodeType===1&&E.cleanupTree(r)}}function uo(t,e,n){return{snapshots:[],removingKeys:new Set,$emptyEl:null,keyToIndex:new Map,$container:t,containerSelector:e,onRemove:n}}function lo(t,e){const n=t.keyToIndex,s=n.get(e);if(s!==void 0)return s;if(typeof e=="string"){const r=+e;if(!Number.isNaN(r))return n.get(r)}}function _s(t,e,n){ms(n,null),t.removingKeys.add(e),fo(t,e,n)}function fo(t,e,n){const s=t.onRemove?.(n);if(s instanceof Promise){const r=()=>pn(t,e,n);s.then(r,r)}else pn(t,e,n)}function pn(t,e,n){if(t.fx?.isDisposed)return;const s=n[0];s instanceof Element&&s.hasAttribute("data-atom-key")||(s?.isConnected&&n.remove(),t.removingKeys.delete(e))}function Es(t){t.removingKeys.clear(),t.snapshots.length=0,t.keyToIndex.clear(),t.$emptyEl?.remove(),t.$container.off(".atomList")}var B={Unchanged:0,Existing:1,New:2,ForceReplace:4};function ho(t,e,n,s,r,o){const{snapshots:i,removingKeys:a,keyToIndex:c}=t,u=i.length,l=new Map,h=o||Le;let d=0,p=u-1,_=n-1;const v=new Array(n),b=[];for(;d<=p&&d<=_;){const S=e[d],R=s(S,d),O=i[d],j=O.key,U=O.node;if(j!==R||!U||!h(O.item,S))break;v[d]={key:R,item:S,state:B.Unchanged,oldIndex:d,targetIndex:d,node:U},l.set(R,d),d++}for(;p>=d&&_>=d;){const S=e[_],R=s(S,_),O=i[p],j=O.key,U=O.node;if(j!==R||!U||!h(O.item,S))break;v[_]={key:R,item:S,state:B.Unchanged,oldIndex:p,targetIndex:_,node:U},l.set(R,_),p--,_--}const K=a.size>0;for(let S=d;S<=_;S++){const R=e[S],O=s(R,S);if(l.has(O)){T.warn(ie.PREFIX,ie.ERRORS.DUPLICATE_KEY(O,S)),v[S]={key:O,item:R,state:B.New,oldIndex:-1,targetIndex:S,node:void 0};continue}l.set(O,S);const j=c.get(O),U=j!==void 0&&(!K||!a.has(O))?j:-1;if(U===-1){const L={key:O,item:R,state:B.New,oldIndex:-1,targetIndex:S,node:void 0};v[S]=L,b.push(L);continue}const g=i[U],D=!r&&!h(g.item,R),w={key:O,item:R,state:D?B.ForceReplace:B.Existing,oldIndex:U,targetIndex:S,node:g.node};v[S]=w,D&&b.push(w)}return t.keyToIndex=l,{slots:v,toRender:b}}function po(t,e,n){if(t){if(t instanceof Element){n.insertBefore(t,e);return}for(let s=0,r=t.length;s<r;s++){const o=t[s];o&&n.insertBefore(o,e)}}}function mo(t,e,n,s){if(t.$emptyEl&&e>0&&(t.$emptyEl.remove(),t.$emptyEl=null),e!==0)return;const{onRemove:r,snapshots:o}=t;if(!r)n.empty();else{const i=o.length;for(let a=0;a<i;a++){const c=o[a];c.node&&_s(t,c.key,Ot(c.node))}}s&&!t.$emptyEl&&(t.$emptyEl=(0,f.default)(typeof s=="string"?f.default.parseHTML(Vt(s)):s),t.$emptyEl.appendTo(n)),t.keyToIndex.clear(),t.snapshots=[]}function _o(t,e,n){const{toRender:s}=t,r=s.length;if(r===0)return null;const o=new Array(r),i=[];let a=!0;for(let h=0;h<r;h++){const d=s[h],p=e.render(d.item,d.targetIndex);o[h]=p,typeof p=="string"?i.push(p):a=!1}let c=null;i.length>0&&(c=Eo(i));let u=null;if(a&&c){const h=f.default.parseHTML(c.join(""));if(h&&h.length===r){let d=!0;for(let p=0;p<r;p++)if(h[p].nodeType!==1){d=!1;break}if(d){if(n&&!e.events)return c;u=h}}}let l=0;for(let h=0;h<r;h++){const d=s[h],p=o[h];let _;if(u)_=(0,f.default)(u[h]);else{const b=typeof p=="string"?c[l++]:p;_=(0,f.default)(typeof b=="string"?f.default.parseHTML(b):b)}ms(_,String(d.key));const v=d.node;if(d.state===B.ForceReplace&&v){co(v);const b=Ot(v);b.first().before(_),b.remove()}d.node=_.length===1?_[0]:_}return null}function Eo(t){if(t.length===1)return[Vt(t[0])];const e=`<template data-atom-sep="s${Math.random().toString(36).slice(2)}"></template>`;return Vt(t.join(e)).split(e)}function go(t){const{snapshots:e,keyToIndex:n}=t;for(let s=0,r=e.length;s<r;s++){const o=e[s];o.node&&!n.has(o.key)&&_s(t,o.key,Ot(o.node))}}function vo(t,e,n,s,r){const{slots:o}=e,i=o.length;if(r){n.innerHTML=r.join("");let l=n.firstElementChild;const{bind:h,onAdd:d}=s;if(!h&&!d)for(let p=0;p<i&&l;p++){const _=o[p];l.setAttribute("data-atom-key",String(_.key)),_.node=l,_.state=B.Existing,l=l.nextElementSibling}else for(let p=0;p<i&&l;p++){const _=o[p],{key:v,item:b}=_;l.setAttribute("data-atom-key",String(v)),_.node=l,_.state=B.Existing;const K=(0,f.default)(l);h&&h(K,b,p),d&&(d(K),t.removingKeys.delete(v),T.domUpdated(ie.PREFIX,K,"list.add",b)),l=l.nextElementSibling}return}if(t.snapshots.length===0&&t.removingKeys.size===0){const l=document.createDocumentFragment();for(let h=0;h<i;h++){const d=o[h].node;if(d)if(d instanceof Element)l.appendChild(d);else for(let p=0,_=d.length;p<_;p++){const v=d[p];v&&l.appendChild(v)}}n.innerHTML="",n.appendChild(l)}else{let l=null,h=1/0;for(let d=i-1;d>=0;d--){const p=o[d],_=p.oldIndex,v=p.node;if(!v)continue;const b=v instanceof Element?v:v[0];b&&(_!==-1&&_<h?h=_:po(v,l,n),l=b)}}const{onAdd:a,bind:c,update:u}=s;for(let l=0;l<i;l++){const{state:h,node:d,item:p,key:_}=o[l];if(!(h===B.Unchanged||!d))switch(h){case B.Existing:u&&u(Ot(d),p,l);break;case B.New:{const v=Ot(d);c&&c(v,p,l),a&&(a(v),t.removingKeys.delete(_),T.domUpdated(ie.PREFIX,v,"list.add",p));break}case B.ForceReplace:c&&c(Ot(d),p,l);break}}}var Ue=new WeakMap;function yo(t,e,n){const{key:s,update:r,isEqual:o,empty:i,events:a,onRemove:c,bind:u,onAdd:l}=n,h=(0,f.default)(t),d=Ue.get(t);d&&(d.fx.dispose(),Es(d.ctx));const p=typeof s=="function"?s:S=>S[s],_={bind:u,update:r,onAdd:l,onRemove:c,events:a},v=So(a),b=uo(h,Ft(t),c),K=st(()=>{const S=e.value,R=S.length;M(()=>{if(mo(b,R,h,i),R===0)return;const O=b.snapshots.length===0&&b.removingKeys.size===0,j=ho(b,S,R,p,r,o),U=_o(j,n,O);go(b),vo(b,j,t,_,U),b.snapshots=j.slots.map(({key:g,item:D,node:w})=>({key:g,item:D,node:w}))})});return b.fx=K,v.length>0&&Co(b,h,v),{fx:K,ctx:b}}function bo(t,e){for(let n=0,s=this.length;n<s;n++){const r=this[n],{fx:o,ctx:i}=yo(r,t,e);Ue.set(r,{fx:o,ctx:i}),E.trackEffect(r,o),E.onCleanup(r,()=>{Es(i),Ue.delete(r)})}return this}function So(t){if(!t)return[];const e=Object.keys(t),n=e.length,s=new Array(n);for(let r=0;r<n;r++){const o=e[r],i=t[o],a=o.trim(),c=a.indexOf(" ");let u,l;c===-1?(u=a,l="> *"):(u=a.substring(0,c),l=a.substring(c+1).trim()||"> *"),s[r]={type:u,selector:l,callback:i}}return s}function Co(t,e,n){for(let s=0,r=n.length;s<r;s++){const{type:o,selector:i,callback:a}=n[s];e.on(`${o}.atomList`,i,function(c){const u=this.closest?.("[data-atom-key]");if(!u)return;const l=u.getAttribute("data-atom-key");if(l===null)return;const h=lo(t,l);h!==void 0&&a.call(u,t.snapshots[h].item,h,c)})}}f.default.fn.atomList=bo;var To=Object.freeze({});f.default.fn.atomMount=function(t,e){const n=e??To;return $(this,s=>{E.cleanupTree(s);const r=M(()=>It(()=>t((0,f.default)(s),n)));if(r){const o=typeof r=="function"?r:r.unmount;E.setTeardown(s,o)}})};f.default.fn.atomUnmount=function(){return $(this,t=>E.cleanupTree(t))};var Ao=new Set(["id","data-atom-nav-target"]),Ro=new Set(["id"]),Oo=new DOMParser,z=t=>{const e=t.length;if(e===0)return t;let n=0;for(;n<e&&t[n]==="/";)n++;let s=e;for(;s>n&&t[s-1]==="/";)s--;return n===0&&s===e?t:t.slice(n,s)},gt=t=>{const e=t.indexOf("?");return e===-1?{route:z(t),query:m.none}:{route:z(t.substring(0,e)),query:m.some(t.substring(e+1))}},le=t=>Object.fromEntries(new URLSearchParams(t)),fe=(t,e)=>C.tryCatch(()=>new URL(t,e)),Me=[{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 gs(t,e){const n=t.document,s=n.head;for(let r=0;r<Me.length;r++){const o=Me[r];if(!o)continue;const i=e?e[o.key]:void 0,a=s.querySelector(o.selector);if(i===void 0){a&&a.remove();continue}const c=a||s.appendChild(n.createElement(o.tag));if(!a){const u=o.staticAttrs;for(const l in u){const h=u[l];h!==void 0&&c.setAttribute(l,h)}}c.getAttribute(o.attr)!==i&&c.setAttribute(o.attr,i)}}function wo(t,e){const n=t.attributes;for(let s=n.length-1;s>=0;s--){const r=n[s];if(!r)continue;const o=r.name;!Ao.has(o)&&!(o in e)&&t.removeAttribute(o)}for(const s in e){const r=e[s];r!==void 0&&t.getAttribute(s)!==r&&t.setAttribute(s,r)}}function ne(t,e,n=!1){const s=decodeURIComponent(e||""),r=s?t.document.getElementById(s):null;r?r.scrollIntoView({behavior:"auto",block:"start"}):(!e||n)&&t.scrollTo(0,0)}function vs(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 Io=[{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,s=n.getAttribute("href");if(!s||s[0]==="#")return!0;const r=e.location;return n.origin!==r.origin||!/^https?:/.test(n.protocol)?!0:n.pathname===r.pathname&&n.search===r.search&&n.hash.startsWith("#")},result:!1}];function ys(t,e=window){for(const n of Io)if(n.match(t,e))return n.result;return!0}function mn(t,e){const n=fe(t,e);if(C.isErr(n))return{pathAndSearch:t,hash:""};const s=C.unwrap(n);return{pathAndSearch:s.pathname+s.search,hash:s.hash.slice(1)}}function ko(t){const{hash:e,type:n,isNewTarget:s,prevHash:r,scrollToTop:o}=t,i=n==="pop";return{shouldScroll:!!e||!i&&(!e&&r!==""||s&&o),resetScroll:!i&&s&&o}}function No(t){const e={};for(const n of Me){if(!n)continue;const s=t.querySelector(n.selector)?.getAttribute(n.attr);s&&(e[n.key]=s)}return e}function Do(t,e){const n=t.getAttribute("href")||t.getAttribute("xlink:href")||"";if(n.startsWith("#"))return z(n.substring(1));let s,r;if(t instanceof HTMLAnchorElement&&t.href)s=t.pathname,r=t.search;else{const o=fe(n,location.href.startsWith("http")?`${location.origin}/`:"http://localhost/");if(C.isErr(o))return"";const i=C.unwrap(o);s=i.pathname,r=i.search}if(s.startsWith("/")||(s=`/${s}`),e){const o=e.endsWith("/")?e:`${e}/`;(s.endsWith("/")?s:`${s}/`).startsWith(o)&&(s=s.substring(e.length))}return z(s)+r}function Lo(t){const{html:e,selector:n,redirectUrl:s}=t,r=Oo.parseFromString(e,"text/html"),o=r.querySelector("title"),i=o?o.textContent?.trim()??null:null,a=No(r),c=n?r.querySelector(n):null,u=c?c.innerHTML:r.body?.innerHTML??e,l={};if(c){const h=c.attributes;for(let d=0,p=h.length;d<p;d++){const _=h[d];_&&!Ro.has(_.name)&&(l[_.name]=_.value)}}return{html:u.trim(),title:i,attributes:l,redirectUrl:s,meta:a}}function Po(t){const{el:e,active:n,activeClass:s}=t;e.classList.toggle(s,n),n?e.setAttribute("aria-current","page"):e.removeAttribute("aria-current")}var At={selectors:"a, [data-route]",attributes:["href","data-route","xlink:href"]},Uo=class{constructor(){this.managers=new Map}register(t,e,n){const s=this.managers.get(t);s&&s.type!==e&&T.warn("[atom-navigation]",`Target collision detected! Element is already managed by ${s.type}. Mixing atomNav and $.route on the same container leads to unpredictable state.`),this.managers.set(t,{type:e,canLeave:n}),E.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}},he=new Uo,bs={get:t=>{let e=location.pathname;return t&&e.startsWith(t)&&(e=e.substring(t.length)),{path:z(e),query:le(location.search.substring(1)),url:location.pathname+location.search}},commit:(t,e)=>{const{route:n,query:s}=gt(t),r=new URL(n,`${location.origin}${e}/`.replace(/\/+$/,"/"));m.map(s,i=>r.search=i);const o=r.pathname+r.search;return C.tryCatch(()=>history.pushState(null,"",o)),{path:z(n),query:Object.fromEntries(r.searchParams),url:o}},revert:t=>{location.pathname+location.search!==t&&C.tryCatch(()=>history.replaceState(null,"",t))},resolveAnchor:(t,e)=>Do(t,e),setupListener:t=>(window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t))},Mo={get:()=>{const{route:t,query:e}=gt(location.hash.slice(1));return{path:t,query:le(m.unwrapOr(e,"")),url:location.hash}},commit:t=>{const{route:e,query:n}=gt(t),s=`#${m.isSome(n)?`${e}?${m.unwrap(n)}`:e}`;return location.hash=s,{path:z(e),query:le(m.unwrapOr(n,"")),url:s}},revert:t=>{location.hash!==t&&(location.hash=t)},resolveAnchor:(t,e)=>bs.resolveAnchor(t,e),setupListener:t=>(window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t))},Fo=(t,e)=>{const n=t==="history"?bs:Mo,s=e?`/${z(e)}`:"";return{get:()=>n.get(s),commit:r=>n.commit(r,s),revert:r=>n.revert(r),resolveAnchor:r=>n.resolveAnchor(r,s),setupListener:r=>n.setupListener(r)}},xo=typeof URLPattern<"u",ee=[{test:t=>!t.includes(":"),compile:(t,e)=>{const n=m.some({route:{pattern:t,def:e},params:{}});return{pattern:t,def:e,match:s=>s===t?n:m.none}}},{test:()=>xo,compile:(t,e)=>{const n=new URLPattern({pathname:`/${t}`});return{pattern:t,def:e,match:s=>{const r=n.exec({pathname:`/${s}`});if(!r)return m.none;const o={},i=r.pathname.groups;for(const a in i){const c=i[a];c!=null&&(o[a]=c)}return m.some({route:{pattern:t,def:e},params:o})}}}},{test:()=>!0,compile:(t,e)=>{const n=[],s=new RegExp(`^${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:(\w+)/g,(r,o)=>(n.push(o),"([^/]+)"))}$`);return{pattern:t,def:e,match:r=>{const o=r.match(s);if(!o)return m.none;const i={};for(let a=0,c=n.length;a<c;a++){const u=o[a+1]||"";if(u.indexOf("%")!==-1)try{i[n[a]]=decodeURIComponent(u);continue}catch{}i[n[a]]=u}return m.some({route:{pattern:t,def:e},params:i})}}}}];function jo(t,e){for(let n=0,s=ee.length;n<s;n++){const r=ee[n];if(r.test(t))return r.compile(t,e)}return ee[ee.length-1].compile(t,e)}function $o(t){const e=new Map,n=[];for(const s in t){const r=t[s];if(r===void 0)continue;const o=z(s),i=jo(o,r);o.includes(":")?n.push(i):e.set(o,i)}return{exact:e,dynamic:n}}function Ss(t,e){const n=t.exact.get(e);if(n)return n.match(e);for(let s=0,r=t.dynamic.length;s<r;s++){const o=t.dynamic[s].match(e);if(m.isSome(o))return o}return m.none}function Fe(t,e){return m.unwrapOr(m.map(Ss(t,e),n=>n.route.pattern),"")}function Cs(t,e,n,s){const r=z(e),o=Ss(t,r);if(m.isSome(o)){const i=m.unwrap(o);return{def:i.route.def,pattern:i.route.pattern,params:i.params,isMatch:!0}}return{def:s?n[s]:void 0,pattern:r,params:{},isMatch:!1}}function Re(t,e,n,s,r){const{def:o,pattern:i,params:a,isMatch:c}=Cs(t,n||e.default,e.routes,e.notFound),u={...s,...a};if(!o&&!c)return{success:!0,path:i,query:s,params:u,def:void 0};if(o?.onEnter){const l=M(()=>o.onEnter(u,r));if(l===!1)return{success:!1};l&&Object.assign(u,l)}return{success:!0,path:!n||n==="/"?i:n,query:s,params:u,def:o}}var Ho={render:(t,e,n,s,r,o)=>{e.render?.(t,n,s,r,o)},template:(t,e,n,s,r,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(),r,o))}};function Bo(t,e,n){return{$target:t,config:e,urlAdapter:n,cleanups:new me,previousPath:""}}function zo(t,e,n,s,r){const o=t.$target[0];if(!o)return;M(()=>t.config.beforeTransition(t.previousPath,n)),e.title&&(document.title=e.title),e.meta&&gs(window,e.meta),o.replaceChildren();const i=l=>t.cleanups.push(l),a=e.render?"render":e.template?"template":null,c=a?Ho[a]:null;c&&c(o,e,n,s,i,r),T.enabled&&typeof customElements<"u"&&o.querySelectorAll(":not(:defined)").forEach(l=>{const h=l.tagName.toLowerCase();h.includes("-")&&T.warn(ft.PREFIX,ft.ERRORS.NOT_REGISTERED(h))}),M(()=>t.config.afterTransition(t.previousPath,n)),window.dispatchEvent(new CustomEvent("route-change",{detail:{from:t.previousPath,to:n,params:s}}));const u=t.previousPath===""&&he.isNestedIn(o,"nav");if(!u){const l=o.querySelector('h1, [role="heading"]')||o;l.tabIndex=-1,l.focus()}t.previousPath=n,u||(location.hash?ne(window,location.hash.substring(1)):window.scrollTo(0,0))}function _n(t){t.cleanups.forEach(e=>C.tryCatch(e)),t.cleanups.clear()}function Vo(t,e,n,s){return{config:t,matcher:e,urlAdapter:n,activeClass:s,trackedLinks:new Set,pathCache:new WeakMap,activeStateCache:new WeakMap}}function qo(t,e){const n=(a,c=!1)=>{const u=a.getAttribute("data-route")||t.urlAdapter.resolveAnchor(a);return u?c?gt(u).route:u:""},s=W(()=>Fe(t.matcher,e.value)),r=(a,c,u)=>{const l=t.pathCache.get(a)||n(a,!0),h=l===c||l===u;t.activeStateCache.get(a)!==h&&(t.activeStateCache.set(a,h),Po({el:a,active:h,activeClass:t.activeClass}))},o=a=>{const c=n(a,!0);if(t.pathCache.set(a,c),t.trackedLinks.has(a)){r(a,e.peek(),s.peek());return}t.trackedLinks.add(a);const u=st(()=>{r(a,e.value,s.value)});E.onCleanup(a,()=>{t.trackedLinks.delete(a),u.dispose()})},i=()=>document.querySelectorAll(At.selectors).forEach(o);return t.linkObserver=new MutationObserver(a=>{for(const c of a)c.type==="childList"?c.addedNodes.forEach(u=>{if(u.nodeType===1){const l=u;l.matches(At.selectors)&&o(l),l.querySelectorAll(At.selectors).forEach(h=>o(h))}}):c.type==="attributes"&&o(c.target)}),t.linkObserver.observe(document.body||document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:At.attributes}),i(),{scan:i,resolvePath:n}}function Xo(){const t={};let e;return document.querySelectorAll("template[data-path]").forEach(n=>{const s=z(n.getAttribute("data-path")??""),r=n.getAttribute("title")??n.getAttribute("data-title");t[s]?r&&!t[s].title&&(t[s].title=r):(n.id||=`route-${Math.random().toString(36).slice(2,11)}`,t[s]={template:`#${n.id}`,...r?{title:r}:{}}),n.hasAttribute("data-default")&&(e=s)}),{routes:t,default:e}}function Go(t,e,n,s){const r=(i,a)=>a instanceof HTMLAnchorElement&&(i.split("/").pop()??"").includes(".")&&!Fe(e,gt(i).route)?!1:!!Fe(e,gt(i).route)||!!t.notFound,o=i=>{if(i.isDefaultPrevented()||!vs(i))return;const a=i.currentTarget;if(!ys(a))return;const c=n(a);c&&r(c,a)&&(i.preventDefault(),s(c))};return(0,f.default)(document).on("click",At.selectors,o),()=>(0,f.default)(document).off("click",At.selectors,o)}var Wo=class{constructor(t){this.stateAtom=Pt({isDestroyed:!1,isTransitioning:!1,previousUrl:"",currentDef:void 0}),this.cleanups=new me,this.context={currentRoute:W(()=>this.currentRouteAtom.value),queryParams:W(()=>this.queryParamsAtom.value),params:W(()=>this.paramsAtom.value),location:W(()=>({path:this.currentRouteAtom.value,query:this.queryParamsAtom.value,params:this.paramsAtom.value})),navigate:i=>this.navigate(i),destroy:()=>this.destroy()},this.config={mode:bt.DEFAULTS.mode,basePath:bt.DEFAULTS.basePath,autoBindLinks:bt.DEFAULTS.autoBindLinks,activeClass:bt.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=Fo(this.config.mode,this.config.basePath);const n=Xo();for(const i in n.routes){const a=n.routes[i];if(this.config.routes[i]){const c=this.config.routes[i];!c.title&&a.title&&(c.title=a.title),!c.template&&a.template&&(c.template=a.template)}else this.config.routes[i]=a}this.config.default===void 0&&(this.config.default=n.default??""),this.matcher=$o(this.config.routes),this.scanner=Vo(this.config,this.matcher,this.urlAdapter,this.config.activeClass),this.renderer=Bo(this.$target,this.config,this.urlAdapter);const s=this.urlAdapter.get();this.stateAtom.value={...this.stateAtom.peek(),previousUrl:s.url};const r=Re(this.matcher,this.config,z(s.path),s.query,this.context),o=r.success?r:{path:this.config.default,query:{},params:{}};this.currentRouteAtom=Pt(o.path),this.currentRoute=this.currentRouteAtom,this.queryParamsAtom=Pt(o.query),this.queryParams=W(()=>this.queryParamsAtom.value),this.paramsAtom=Pt(o.params),this.params=this.paramsAtom,this.location=W(()=>({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=st(()=>{const n=this.currentRouteAtom.value;M(()=>{_n(this.renderer),this.render(n)})});this.cleanups.push(()=>t.dispose());const{resolvePath:e}=qo(this.scanner,this.currentRoute);this.cleanups.push(()=>this.scanner.linkObserver?.disconnect()),this.config.autoBindLinks&&this.cleanups.push(Go(this.config,this.matcher,e,n=>this.navigate(n))),this.$target[0]&&(he.register(this.$target[0],"router",()=>this.canLeave()),E.onCleanup(this.$target[0],()=>this.destroy()))}updateState(t,e,n){It(()=>{Le(this.paramsAtom.peek(),n)||(this.paramsAtom.value=n),Le(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 s,r=e;if(typeof t=="string"){const{route:a,query:c}=gt(t);s=a||this.config.default,m.isSome(c)&&(r={...le(m.unwrap(c)),...e})}else s=t.path||this.currentRouteAtom.peek(),r={...t.query,...e};if(!s)return;const o=new URLSearchParams(r).toString(),i=o?`${s}?${o}`:s;this.stateAtom.value={...n,isTransitioning:!0};try{const a=this.urlAdapter.commit(i),c=Re(this.matcher,this.config,a.path,a.query,this.context);c.success?this.updateState(c.path,c.query,c.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=Re(this.matcher,this.config,z(e.path),e.query,this.context);It(()=>{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}=Cs(this.matcher,t,this.config.routes,this.config.notFound);if(!e){T.warn(bt.PREFIX,bt.ERRORS.NOT_FOUND(t));return}this.stateAtom.value={...this.stateAtom.peek(),currentDef:e,previousUrl:this.urlAdapter.get().url},zo(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?M(()=>t.onLeave(this.context))!==!1:!0}destroy(){const t=this.stateAtom.peek();t.isDestroyed||(this.stateAtom.value={...t,isDestroyed:!0},_n(this.renderer),this.cleanups.forEach(e=>C.tryCatch(e)),this.cleanups.dispose())}};function Yo(t){return new Wo(t)}f.default.extend({route:Yo});function Ko(t,e){const{ajaxOptions:n,method:s,headers:r}=e,o=typeof n=="object"?n:{},i=typeof n=="function"?n():{};return{...o,...i,url:t,method:s||i.method||o.method,headers:{...o.headers,...i.headers,...r},success:void 0,error:void 0,complete:void 0}}function En(t){if(t&&typeof t=="object"&&"readyState"in t){const e=t,n=e.statusText||(e.status===0?"Network Error":"Request Failed"),s=new Error(`Network Error: ${n} (${e.status})`);return s.jqXHR=e,s}return t instanceof Error?t:new Error(String(t??"Unknown error"))}function Qo(t,e){const n=typeof t=="string"?()=>t:t;let s=null;const o=W(async()=>{s?.abort();const a=new AbortController;s=a;let c;const u=()=>{c&&typeof c.abort=="function"&&c.abort()};a.signal.addEventListener("abort",u),a.signal.aborted&&u();try{let l;try{const d=Ko(n(),e);c=f.default.ajax(d);const p=await c;l=C.ok(p)}catch(d){l=C.err(En(d))}if(!l.ok){const d=l.error;if(a.signal.aborted){const p=new Error("AbortError");throw p.name="AbortError",p}if(e.onError){const p=C.tryCatch(()=>e.onError(d));p.ok||console.error("atomFetch: onError hook threw an error",p.error)}throw d}const h=l.value;try{const d=e.transform?e.transform(h,c):h;return d instanceof Promise?await d:d}catch(d){const p=En(d);throw e.onError&&C.tryCatch(()=>e.onError(p)),p}}finally{a.signal.removeEventListener("abort",u),s===a&&(s=null)}},{defaultValue:e.defaultValue,lazy:e.eager===!1,...e.name!==void 0?{name:e.name}:{}}),i=o.dispose.bind(o);return o.dispose=()=>{s?.abort(),i()},Object.assign(o,{abort:()=>s?.abort()})}f.default.extend({atomFetch:Qo});var Ts={push:{historyMethod:"pushState",isInitial:!1},replace:{historyMethod:"replaceState",isInitial:!1},init:{historyMethod:null,isInitial:!0},pop:{historyMethod:null,isInitial:!1}},Jo=[{key:"title",apply:(t,e,n,s)=>{const r=n;s.syncTitle&&r!==null&&t.document.title!==r&&(t.document.title=r)}},{key:"meta",apply:(t,e,n)=>gs(t,n)},{key:"attributes",apply:(t,e,n)=>{const s=e[0];s&&n&&wo(s,n)}},{key:"html",apply:(t,e,n)=>e.html(n)}];function Zo(t){const{$target:e,state:n,url:s,previousUrl:r,win:o,syncTitle:i,onMount:a,onUnmount:c}=t;f.default.untracked(()=>{c?.(e,r),e.children().atomUnbind();for(const u of Jo){const l=n[u.key];u.apply(o,e,l,{syncTitle:i})}a?.(e,s)})}function ti(t){const{url:e,type:n,win:s,state:r}=t,o=Ts[n];o.historyMethod&&f.default.batch(()=>{s.history[o.historyMethod](null,"",e),r.value={url:e,type:n}})}function ei(t){const{target:e,selector:n="a[data-nav]",headers:s={},syncTitle:r=!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),c=a.pathname+a.search+a.hash,u=a.pathname+a.search,l={intent:f.default.atom({url:c,type:"init"},{name:"nav:intent"}),rendered:f.default.atom({url:c,path:u},{name:"nav:rendered"}),fetchVersion:f.default.atom(0,{name:"nav:version"}),pendingHooks:f.default.atom(0,{name:"nav:hook-pending"})},h=m.unwrapOr(m.map(m.fromNullable(typeof e=="string"?e:i.attr("id")),g=>g.startsWith("#")?g:`#${f.default.escapeSelector(g)}`),void 0),d=f.default.computed(()=>{const{url:g,type:D}=l.intent.value,{pathAndSearch:w,hash:L}=mn(g,o.location.href);return{url:g,pathAndSearch:w,hash:L,type:D}},{name:"nav:normalized"}),p=f.default.atomFetch(()=>(l.fetchVersion.value,d.value.pathAndSearch),{name:"nav:content",defaultValue:{html:"",title:null},headers:{"X-PJAX":"true",...s},eager:!1,transform:(g,D)=>{const w=D?.getResponseHeader?.("X-PJAX-URL")??void 0,L=Lo({html:String(g),selector:h,redirectUrl:w});return{...L,html:Vt(L.html).trim()}}});let _=null;const v=new AbortController,b=()=>{_?.abort(),"abort"in p&&typeof p.abort=="function"&&p.abort();const g=new AbortController;return _=g,g},K=f.default.effect(()=>{const{url:g,pathAndSearch:D,hash:w,type:L}=d.value,V=f.default.untracked(()=>l.rendered.value),X=Ts[L];if(D===V.path){f.default.untracked(()=>{w&&ne(o,w),X.isInitial?(t.onMount?.(i,g),l.intent.value={...l.intent.peek(),type:"push"}):g!==V.url&&(l.rendered.value={...V,url:g})});return}const rt=p.value;if(p.hasError){const Nt=p.lastError;if(Nt instanceof Error&&Nt.name==="AbortError")return;(t.onError?.(Nt,g)??!0)!==!1&&o.location.assign(g);return}if(!p.isResolved||p.isPending)return;const dt=!!(rt.redirectUrl&&rt.redirectUrl!==g),Xt=V.url;let ot=dt?rt.redirectUrl:g;dt&&w&&!ot.includes("#")&&(ot+=`#${w}`);const{pathAndSearch:it}=mn(ot,o.location.href),yt=it!==V.path;f.default.batch(()=>{dt&&(o.history.replaceState(null,"",ot),l.intent.value={url:ot,type:"push"}),(yt||dt)&&Zo({$target:i,state:rt,url:ot,previousUrl:Xt,win:o,syncTitle:r,onMount:t.onMount,onUnmount:t.onUnmount});const{shouldScroll:Nt,resetScroll:Ns}=ko({hash:w,type:L,isNewTarget:yt,prevHash:C.unwrap(fe(V.url,o.location.href)).hash.slice(1),scrollToTop:t.scrollToTop??!0});Nt&&ne(o,w,Ns),l.rendered.value={url:ot,path:it}})},{name:"nav:sync-effect"}),S=()=>{b();const g=o.location;l.intent.value={url:g.pathname+g.search+g.hash,type:"pop"}};o.addEventListener("popstate",S,{signal:v.signal}),o.document.addEventListener("click",g=>{if(g.defaultPrevented)return;const D=g.target.closest(n);if(!D)return;const w=i.attr("id"),L=D.dataset.target,V=!!(L&&w&&L===`#${w}`);if(!(L&&!V)){if(!V){const X=(0,f.default)(D).closest('[data-atom-nav-target="true"]')[0];if(X&&X!==i[0])return}vs(g)&&ys(D,o)&&(g.preventDefault(),U.navigate(D.href))}},{signal:v.signal});const R=f.default.computed(()=>p.isPending||l.pendingHooks.value>0?"pending":p.hasError?"error":"idle",{name:"nav:status"}),O=f.default.computed(()=>R.value==="pending",{name:"nav:isPending"}),j=f.default.computed(()=>R.value==="error",{name:"nav:hasError"}),U={currentUrl:f.default.computed(()=>l.rendered.value.url,{name:"nav:public-url"}),isPending:O,hasError:j,async navigate(g,D={}){const{signal:w}=b(),L=D.replace?"replace":"push",V=fe(g,o.document.baseURI??o.location.href);if(C.isErr(V))return;const X=C.unwrap(V),rt=new URL(o.location.href),dt=X.pathname+X.search,Xt=dt===rt.pathname+rt.search,ot=[()=>X.origin!==rt.origin?(o.location.assign(g),!1):!0,()=>Xt&&X.hash===(rt.hash??"")&&L==="push"?(j.peek()?l.fetchVersion.value++:g.includes("#")&&ne(o,X.hash.slice(1),!0),!1):!0,()=>!Xt&&t.onBeforeLoad?(async()=>{l.pendingHooks.value++;try{const it=await t.onBeforeLoad(g,w);return!(w.aborted||it===!1)}finally{l.pendingHooks.value=Math.max(0,l.pendingHooks.value-1)}})():!0,()=>{const it=i[0];return!(it&&!he.canLeaveWithin(it))}];for(const it of ot){const yt=it();if(yt instanceof Promise){if(!await yt)return}else if(!yt)return}ti({url:dt+X.hash,type:L,win:o,state:l.intent})},destroy(){v.abort(),_?.abort(),K.dispose(),p.dispose(),i.removeAttr("data-atom-nav-target"),[l.intent,l.fetchVersion,l.pendingHooks,l.rendered,d,U.currentUrl,R,O,j].forEach(g=>g.dispose?.())}};return i[0]&&(he.register(i[0],"nav"),E.onCleanup(i[0],()=>U.destroy())),U}f.default.extend({atomNav:ei});var As=(t,e)=>e instanceof ShadowRoot?e:t.shadowRoot instanceof ShadowRoot?t.shadowRoot:null,ni=t=>nt(t)?t.value:typeof t=="function"?t():t,ct={dispatch(t,e,n){for(const[s,r]of Object.entries(e))n.push(f.default.effect(()=>{const o=ni(r),i=typeof r=="function"&&typeof o=="object"&&o!==null?o:{value:o};t.dispatchEvent(new CustomEvent(s,{detail:i,bubbles:!0,composed:!0}))}))},styles(t,e){return t.adoptedStyleSheets=[...t.adoptedStyleSheets,...e],e},aria(t,e,n){for(const[s,r]of Object.entries(e))n.push(f.default.effect(()=>{const o=r.value;t[s]=o!=null?String(o):null}))},hydrate(t,e,n,s){const{BIND:r,LEGACY_BIND:o}=ft.ATTRS,i=`[${r}],[${o}]`,a=c=>{const u=c;if(u[Pe])return;const l=c.getAttribute(r)||c.getAttribute(o),h=l?e[l]:null;h&&(n.push(f.default.effect(()=>{const d=String(h.value??"");c.textContent!==d&&(c.textContent=d)})),u[Pe]=!0,s.add(c))};this.observe(t,i,a,n)},parts(t,e,n){const s=ft.ATTRS.PART,r=o=>{const i=o.getAttribute(s),a=i?e[i]:null;a&&n.push(f.default.effect(()=>{const c=a.value;let u;typeof c=="string"?u=c:Array.isArray(c)?u=c.join(" "):typeof c=="object"&&c!==null?u=Object.entries(c).filter(([,l])=>l).map(([l])=>l).join(" "):u="",o.getAttribute("part")!==u&&o.setAttribute("part",u)}))};this.observe(t,`[${s}]`,r,n)},observe(t,e,n,s){t instanceof Element&&t.matches(e)&&n(t);const r=t.querySelectorAll(e);for(let i=0;i<r.length;i++)n(r[i]);const o=new MutationObserver(i=>{for(let a=0;a<i.length;a++){const c=i[a].addedNodes;for(let u=0;u<c.length;u++){const l=c[u];if(l instanceof Element){l.matches(e)&&n(l);const h=l.querySelectorAll(e);for(let d=0;d<h.length;d++)n(h[d])}}}});o.observe(t,{childList:!0,subtree:!0}),s.push(f.default.effect(()=>()=>o.disconnect()))},form(t,e,n,s,r){const o=n&&(nt(n)?n:n.val),i=n&&!nt(n)?n.state:null;r.push(f.default.effect(()=>{if(o){const a=o.value,c=i?i.value:null;if(typeof a=="object"&&a!==null&&!(a instanceof File)&&!(a instanceof Blob)){const u=new FormData;Wn(u,t.getAttribute("name")||"",a),e.setFormValue(u,c)}else e.setFormValue(a,c)}if(s){const a=o?o.value:void 0,c=nt(s)?s.value:s(a);typeof c=="string"?e.setValidity(c?{customError:!0}:{},c,t):e.setValidity(c,void 0,t)}}))},attributes(t){const e=()=>t.constructor.observedAttributes||[],n=()=>{const a=e(),c={};if(a.length>0)for(let u=0;u<a.length;u++){const l=a[u];c[l]=t.getAttribute(l)}else{const u=t.attributes;for(let l=0;l<u.length;l++){const h=u[l];c[h.name]=h.value}}return c},s=f.default.atom(n()),r=new MutationObserver(()=>{s.value=n()}),o={attributes:!0},i=e();return i.length>0&&(o.attributeFilter=i),r.observe(t,o),{atom:s,observer:r}},slots(t){const e=r=>{const o={};if(r){const i=r.querySelectorAll("slot");for(let a=0;a<i.length;a++){const c=i[a];o[c.name||""]=c.assignedNodes()}}return o},n=f.default.atom(e(t)),s=r=>{const o=r.target,i={...n.peek()};i[o.name||""]=o.assignedNodes(),n.value=i};return t&&(n.value=e(t),t.addEventListener("slotchange",s)),{atom:n,listener:s}}},si=class{constructor(t){this.host=t,this.root=m.none,this.isInitialized=!1,this.effects=new me,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[Pe]}),this.hydratedNodes.clear(),this.attributeObserver&&(this.attributeObserver.disconnect(),this.attributeObserver=null),this.attributeAtom=null,this.attributeLenses.clear();const t=As(this.host,m.toNullable(this.root));t&&this.slotListeners.forEach(n=>t.removeEventListener("slotchange",n)),this.slotListeners.clear(),this.slotsAtom=null,this.slotLenses.clear();const e=m.toNullable(this.root);if(e){this.appliedStyles.length>0&&(e instanceof ShadowRoot||e instanceof Document)&&(e.adoptedStyleSheets=e.adoptedStyleSheets.filter(s=>!this.appliedStyles.includes(s))),this.appliedStyles=[];const n=e;n[ce]&&(qr(e),n[ce]=!1)}this.root=m.none,this.isInitialized=!1}},qt=new WeakMap,Tt=new Map,ri=100;T.enabled&&typeof window<"u"&&(window.__AEJ_INTERNAL__={nodeStateMap:qt,sheetCache:Tt,version:"0.32.1"});var jt=new WeakMap,Je=t=>{let e=qt.get(t);return e||(e={},qt.set(t,e)),e},oi=typeof window<"u"&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype,ii=typeof window<"u"&&"attachInternals"in HTMLElement.prototype,ai=t=>{if(t instanceof CSSStyleSheet)return t;let e=Tt.get(t);if(!e){if(e=new CSSStyleSheet,e.replaceSync(t),Tt.size>=ri){const n=Tt.keys().next().value;n!==void 0&&Tt.delete(n)}Tt.set(t,e)}return e},tt=(()=>{const t=f.default.atom(0);let e=!1,n=null,s=0;const r=()=>{e||(e=!0,queueMicrotask(()=>{t.value++,e=!1}))},o=c=>{const u=jt.get(c);if(u){const l=qt.get(c)?.controller;l&&l.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}}),jt.delete(c),tt.release()}},i=()=>{n||typeof document>"u"||(n=new MutationObserver(c=>{let u=!1;for(let l=0;l<c.length;l++){const h=c[l];if(h.addedNodes.length>0){u=!0;for(let d=0;d<h.addedNodes.length;d++){const p=h.addedNodes[d];if(p instanceof HTMLElement){o(p);const _=p.querySelectorAll("*");for(let v=0;v<_.length;v++)o(_[v])}}}h.removedNodes.length>0&&(u=!0)}u&&r()}),n.observe(document.documentElement,{childList:!0,subtree:!0}))},a=()=>{n&&(n.disconnect(),n=null)};return{get version(){return t},bump:r,retain(){s++,s===1&&i()},release(){s--,s===0&&a()},discover(c,u){let l=m.none;const h=new CustomEvent(Zn,{detail:{key:u,callback:d=>{l=m.some(d)}},bubbles:!0,composed:!0});return c.dispatchEvent(h),l}}})();function ci(t,e){const n=i=>(i?tt.version.peek():tt.version.value,M(()=>tt.discover(t,e))),s=i=>{const a=n(i);if(m.isNone(a))return null;const c=m.unwrap(a);return nt(c)?i?c.peek():c.value:c};let r=null;const o=()=>(r||(r=f.default.computed(()=>s(!1))),r);return{get value(){return s(!1)},set value(i){const a=n(!0);if(m.isSome(a)){const c=m.unwrap(a);gr(c)&&(c.value=i)}},peek(){return s(!0)},subscribe:i=>{tt.retain();const a=o().subscribe(i);return()=>{a(),tt.release()}},subscriberCount:()=>r?r.subscriberCount():0,dispose:()=>{r&&(r.dispose(),r=null)},[ht]:k.Atom|k.Writable}}function ui(t){if(T.enabled&&typeof customElements<"u"){const i=t.tagName.toLowerCase();i.includes("-")&&!customElements.get(i)&&T.warn(ft.PREFIX,ft.ERRORS.NOT_REGISTERED(i))}const e=Je(t);if(e.controller)return e.controller;let n;if(ii)try{n=t.attachInternals()}catch{}const s=new si(t),r={host:t,get root(){return m.toNullable(s.root)},get internals(){return n},get attrs(){if(!s.attributeAtom){const{atom:i,observer:a}=ct.attributes(t);s.attributeAtom=i,s.attributeObserver=a}return i=>{let a=s.attributeLenses.get(i);return a||(a=f.default.atomLens(s.attributeAtom,i),s.attributeLenses.set(i,a)),a}},get slots(){if(!s.slotsAtom){const i=As(t,m.toNullable(s.root)),{atom:a,listener:c}=ct.slots(i);s.slotsAtom=a,i&&s.slotListeners.set("all",c)}return i=>{const a=i==="default"?"":i;let c=s.slotLenses.get(a);return c||(c=f.default.atomLens(s.slotsAtom,a),s.slotLenses.set(a,c)),c}},$:((i,a)=>{const c=a??m.toNullable(s.root)??t;return typeof i!="string"?(0,f.default)(i):c instanceof DocumentFragment?(0,f.default)(c.querySelectorAll(i)):(0,f.default)(i,c)}),provideAtom:(i,a)=>Rs(t,i,a),injectAtom:i=>Os(t,i),setup(i){if(s.isInitialized){const l=i instanceof Node?i:i?.shadowRoot;if(l&&l!==m.toNullable(s.root))throw new Error("Call teardown() first to change the root.");return}const a=i instanceof Node?{shadowRoot:i}:i??{},c=m.fromNullable(a.shadowRoot??t.shadowRoot);m.map(c,l=>{E.markHost(t),E.registerShadow(t,l)});const u=m.unwrapOr(c,t);if(s.root=m.some(u),u[ce]||(_e(u),u[ce]=!0),!s.slotsAtom){const l=m.toNullable(c),{atom:h,listener:d}=ct.slots(l);s.slotsAtom=h,l&&s.slotListeners.set("all",d)}a.dispatch&&ct.dispatch(t,a.dispatch,s.effects),a.bind&&ct.hydrate(u,a.bind,s.effects,s.hydratedNodes),a.styles&&oi&&(u instanceof ShadowRoot||u instanceof Document)&&(s.appliedStyles=ct.styles(u,a.styles.map(ai))),a.aria&&n&&ct.aria(n,a.aria,s.effects),a.parts&&ct.parts(u,a.parts,s.effects),(a.value||a.validation)&&n&&ct.form(t,n,a.value,a.validation,s.effects),s.isInitialized=!0},teardown(){const i=qt.get(t);i&&(i.providers?.clear(),i.providerEffects?.forEach(a=>a.dispose()),i.providerEffects?.clear(),i.injects?.clear()),jt.has(t)&&(jt.delete(t),tt.release()),tt.bump(),s.dispose(),E.cleanupTree(t)}},o=t.constructor;return(o.aejStyles||o.aejBind||o.aejAria||o.aejParts||o.aejDispatch||o.aejValue||o.aejValidation)&&(t.isConnected?r.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}}):(jt.set(t,o),tt.retain())),E.setTeardown(t,()=>r.teardown()),e.controller=r,r}function Rs(t,e,n){const s=t instanceof HTMLElement?[t]:typeof t=="string"?Array.from(document.querySelectorAll(t)):t.toArray();for(let r=0;r<s.length;r++){const o=s[r],i=Je(o);i.providers||(i.providers=new Map,o.addEventListener(Zn,c=>{const{key:u,callback:l}=c.detail;i.providers?.has(u)&&(c.stopPropagation(),l(i.providers.get(u)))})),i.providers.set(e,n);const a=typeof e=="symbol"?e.description:String(e);if(a){const c=`--aej-${a}`,u=l=>o.style.setProperty(c,String(l??""));nt(n)?(i.providerEffects||(i.providerEffects=new Map),i.providerEffects.get(e)?.dispose(),i.providerEffects.set(e,f.default.effect(()=>{u(n.value)}))):u(n)}}tt.bump()}function Os(t,e){const n=t instanceof HTMLElement?t:typeof t=="string"?document.querySelector(t):t[0];if(!n)return null;if(T.enabled&&typeof customElements<"u"){const o=n.tagName.toLowerCase();o.includes("-")&&!customElements.get(o)&&T.warn(ft.PREFIX,ft.ERRORS.NOT_REGISTERED(o))}const s=Je(n);s.injects||(s.injects=new Map);let r=s.injects.get(e);return r||(r=ci(n,e),s.injects.set(e,r)),r}f.default.extend({provideAtom:Rs,injectAtom:Os,useAtomComponent:ui});var xe=new WeakMap,G=null,je=t=>{if(t[zt])return t;const e=xe.get(t);if(e)return e;const n=function(...s){return It(()=>t.apply(this,s))};return n[zt]=!0,xe.set(t,n),n},ws=t=>xe.get(t)??t;function gn(t){const e={};for(const n in t){const s=t[n];e[n]=typeof s=="function"?je(s):s}return e}function li(t){const e={};for(const n in t){const s=t[n];e[n]=typeof s=="function"?ws(s):s}return e}function Oe(t,e,n){const s=t[0];if(s&&typeof s=="object")t[0]=e(s);else for(let r=1;r<t.length;r++)typeof t[r]=="function"&&(t[r]=n(t[r]))}function Is(t={}){if(G!==null)return;const{events:e=!0,lifecycle:n=!0}=t;G={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 s=G;n&&(f.default.fn.remove=function(r){const o=r?this.filter(r):this,i=o.length;for(let a=0;a<i;a++){const c=o[a];c&&(E.markIgnored(c),E.cleanupTree(c))}return s.remove.call(this,r)},f.default.fn.empty=function(){const r=this.length;for(let o=0;o<r;o++){const i=this[o];i?.hasChildNodes()&&E.cleanupDescendants(i)}return s.empty.call(this)},f.default.fn.detach=function(r){const o=r?this.filter(r):this,i=o.length;for(let a=0;a<i;a++){const c=o[a];c&&E.keep(c)}return s.detach.call(this,r)}),e&&(f.default.fn.on=function(...r){return Oe(r,gn,je),s.on.apply(this,r)},f.default.fn.one=function(...r){return Oe(r,gn,je),s.one.apply(this,r)},f.default.fn.off=function(...r){return Oe(r,li,ws),s.off.apply(this,r)})}function ks(){G!==null&&(f.default.fn.on=G.on,f.default.fn.one=G.one,f.default.fn.off=G.off,f.default.fn.remove=G.remove,f.default.fn.empty=G.empty,f.default.fn.detach=G.detach,G=null)}function Ze(t={}){const{patch:e=!0,autoCleanup:n=!0}=t;if(ks(),e!==!1&&Is(typeof e=="object"?e:{}),Jn(),n!==!1){an(!0);const s=typeof n=="object"?n.root:document.body;s&&(_e(s),E.setAutoCleanupScheduled(!0))}else an(!1)}(0,f.default)(()=>{window.AEJ_NO_AUTO_INIT||Ze()});function fi(t){t instanceof HTMLElement?E.cleanupTree(t):t.each((e,n)=>E.cleanupTree(n))}f.default.extend({initAEJ:Ze});var hi=f.default;exports.cleanup=fi;exports.default=hi;exports.disableAutoCleanup=Jn;exports.disablejQueryOverrides=ks;exports.enableAutoCleanup=_e;exports.enablejQueryOverrides=Is;exports.initAEJ=Ze;
9
+
6
10
  //# sourceMappingURL=index.cjs.map