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