@but212/atom-effect-jquery 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/atom-effect-jquery.min.js +1 -1
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +407 -386
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("jquery"),_t={IDLE:"idle",PENDING:"pending",RESOLVED:"resolved",REJECTED:"rejected"},F={DISPOSED:1,EXECUTING:8},Yt={DISPOSED:1,IS_COMPUTED:2,DIRTY:8,IDLE:16,PENDING:32,RESOLVED:64,REJECTED:128,RECOMPUTING:256,HAS_ERROR:512},H={DISPOSED:1,SYNC:8,NOTIFICATION_SCHEDULED:16},K={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},me={WARN_INFINITE_LOOP:!0},Ft=1073741823,R=typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"||typeof __DEV__<"u"&&!!__DEV__,ye=Object.freeze([]);class it extends Error{constructor(t,n=null,s=!0){super(t),this.cause=n,this.recoverable=s,this.name="AtomError"}}class z extends it{constructor(t,n=null){super(t,n,!0),this.name="ComputedError"}}class W extends it{constructor(t,n=null){super(t,n,!1),this.name="EffectError"}}class pt extends it{constructor(t,n=null){super(t,n,!1),this.name="SchedulerError"}}const jt=Symbol("AtomEffect.DebugName"),be=Symbol("AtomEffect.Id"),Ht=Symbol("AtomEffect.Type"),Ot=Symbol("AtomEffect.NoDefaultValue"),Ce=e=>"dependencies"in e&&Array.isArray(e.dependencies);function Kt(e,t,n){if(e===t)throw new z("Circular dependency detected: The computation refers to itself explicitly or implicitly.");if(!n.has(e.id)&&(n.add(e.id),Ce(e))){const s=e.dependencies;for(let i=0;i<s.length;i++){const o=s[i];o&&Kt(o,t,n)}}}const J={enabled:R,warnInfiniteLoop:me.WARN_INFINITE_LOOP,warn(e,t){R&&this.enabled&&e&&console.warn(`[Atom Effect] ${t}`)},checkCircular(e,t){if(e===t)throw new z("Direct circular dependency detected");R&&this.enabled&&Kt(e,t,new Set)},attachDebugInfo(e,t,n){if(!R||!this.enabled)return;const s=e;s[jt]=`${t}_${n}`,s[be]=n,s[Ht]=t},getDebugName:e=>e?.[jt],getDebugType:e=>e?.[Ht]};let Ie=1;const Se=()=>Ie++;function Jt(e,t,n){if(typeof t=="function"){const i=t;for(let o=0,r=n.length;o<r;o++){const c=n[o];if(c&&c.fn===i)return}n.push(new Nt(i,void 0));return}if("addDependency"in t){t.addDependency(e);return}const s=t;for(let i=0,o=n.length;i<o;i++){const r=n[i];if(r&&r.sub===s)return}n.push(new Nt(void 0,s))}function zt(e,t,n){const s=new Map;for(let i=0,o=t.length;i<o;i++){const r=t[i];r?.unsub&&s.set(r.node,r.unsub)}for(let i=0,o=e.length;i<o;i++){const r=e[i];if(!r)continue;const c=r.node,a=s.get(c);a!==void 0?(r.unsub=a,s.delete(c)):(J.checkCircular(c,n),r.unsub=c.subscribe(n))}for(const i of s.values())i()}class bt{constructor(t,n,s=void 0){this.node=t,this.version=n,this.unsub=s}}class Nt{constructor(t,n){this.fn=t,this.sub=n}}const S={COMPUTED_MUST_BE_FUNCTION:"Computed target must be a function",COMPUTED_ASYNC_PENDING_NO_DEFAULT:"Async computation pending with no default value",COMPUTED_COMPUTATION_FAILED:"Computation execution failed",COMPUTED_ASYNC_COMPUTATION_FAILED:"Async computation execution failed",COMPUTED_CIRCULAR_DEPENDENCY:"Circular dependency detected",COMPUTED_DISPOSED:"Attempted to access disposed computed",ATOM_SUBSCRIBER_MUST_BE_FUNCTION:"Subscriber must be a function or Subscriber object",ATOM_INDIVIDUAL_SUBSCRIBER_FAILED:"Subscriber execution failed",EFFECT_MUST_BE_FUNCTION:"Effect target must be a function",EFFECT_EXECUTION_FAILED:"Effect execution failed",EFFECT_CLEANUP_FAILED:"Effect cleanup failed",EFFECT_DISPOSED:"Attempted to run disposed effect",SCHEDULER_FLUSH_OVERFLOW:(e,t)=>`Maximum flush iterations (${e}) exceeded. ${t} jobs dropped. Possible infinite loop.`,CALLBACK_ERROR_IN_ERROR_HANDLER:"Exception encountered in onError handler",EFFECT_FREQUENCY_LIMIT_EXCEEDED:"Effect executed too frequently within 1 second. Suspected infinite loop."};function st(e,t,n){if(e instanceof it)return e;const s=e instanceof Error,i=s?e.message:String(e),o=s?e:void 0,r=`${s?e.constructor.name:"Unexpected error"} (${n}): ${i}`;return new t(r,o)}class Zt{constructor(){this.flags=0,this.version=0,this._lastSeenEpoch=-1,this.id=Se()&Ft}}class te extends Zt{subscribe(t){const n=typeof t=="function";if(!n&&(!t||typeof t.execute!="function"))throw st(new TypeError("Invalid subscriber"),it,S.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);const s=this._subscribers;for(let o=0,r=s.length;o<r;o++){const c=s[o];if(c&&(n?c.fn===t:c.sub===t))return R&&console.warn("Duplicate subscription ignored."),()=>{}}const i=new Nt(n?t:void 0,n?void 0:t);return s.push(i),()=>this._unsubscribe(i)}_unsubscribe(t){const n=this._subscribers,s=n.indexOf(t);if(s===-1)return;const i=n.pop();s<n.length&&i&&(n[s]=i)}subscriberCount(){return this._subscribers.length}_notifySubscribers(t,n){if(this._subscribers.length===0)return;const s=this._subscribers.slice(0),i=s.length;for(let o=0;o<i;o++){const r=s[o];if(r)try{r.fn?r.fn(t,n):r.sub&&r.sub.execute()}catch(c){this._handleNotifyError(c)}}}_handleNotifyError(t){console.error(st(t,it,S.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED))}}let At=0;const Pt=()=>(At=At+1&Ft||1,At),Rt=e=>e+1&Ft;let Mt=0,vt=!1,ee=0;const ve=()=>ee;function Vt(){return vt?(R&&console.warn("startFlush() called during flush - ignored"),!1):(vt=!0,ee=Pt(),Mt=0,!0)}const qt=()=>{vt=!1},we=()=>vt?++Mt:0;class ke{constructor(){this._queueBuffer=[[],[]],this._bufferIndex=0,this._size=0,this._epoch=0,this._isProcessing=!1,this._isBatching=!1,this._isFlushingSync=!1,this._batchDepth=0,this._batchQueue=[],this._batchQueueSize=0,this._maxFlushIterations=K.MAX_FLUSH_ITERATIONS,this.onOverflow=null,this._boundRunLoop=this._runLoop.bind(this)}get phase(){return this._isProcessing||this._isFlushingSync?2:this._isBatching?1:0}get queueSize(){return this._size}get isBatching(){return this._isBatching}schedule(t){if(R&&typeof t!="function")throw new pt("Scheduler callback must be a function");if(t._nextEpoch!==this._epoch){if(t._nextEpoch=this._epoch,this._isBatching||this._isFlushingSync){this._batchQueue[this._batchQueueSize++]=t;return}this._queueBuffer[this._bufferIndex][this._size++]=t,this._isProcessing||this._flush()}}_flush(){this._isProcessing||this._size===0||(this._isProcessing=!0,queueMicrotask(this._boundRunLoop))}_runLoop(){try{if(this._size===0)return;const t=Vt();this._drainQueue(),t&&qt()}finally{this._isProcessing=!1,this._size>0&&!this._isBatching&&this._flush()}}_flushSync(){this._isFlushingSync=!0;const t=Vt();try{this._mergeBatchQueue(),this._drainQueue()}finally{this._isFlushingSync=!1,t&&qt()}}_mergeBatchQueue(){if(this._batchQueueSize===0)return;const t=++this._epoch,n=this._batchQueue,s=this._queueBuffer[this._bufferIndex];let i=this._size;for(let o=0;o<this._batchQueueSize;o++){const r=n[o];r._nextEpoch!==t&&(r._nextEpoch=t,s[i++]=r)}this._size=i,this._batchQueueSize=0,n.length>K.BATCH_QUEUE_SHRINK_THRESHOLD&&(n.length=0)}_drainQueue(){let t=0;for(;this._size>0;){if(++t>this._maxFlushIterations){this._handleFlushOverflow();return}this._processQueue(),this._mergeBatchQueue()}}_processQueue(){const t=this._bufferIndex,n=this._queueBuffer[t],s=this._size;this._bufferIndex=t^1,this._size=0,this._epoch++;for(let i=0;i<s;i++)try{n[i]()}catch(o){console.error(new pt("Error occurred during scheduler execution",o))}n.length=0}_handleFlushOverflow(){const t=this._size+this._batchQueueSize;if(console.error(new pt(S.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations,t))),this._size=0,this._queueBuffer[this._bufferIndex].length=0,this._batchQueueSize=0,this.onOverflow)try{this.onOverflow(t)}catch{}}startBatch(){this._batchDepth++,this._isBatching=!0}endBatch(){if(this._batchDepth===0){R&&console.warn("endBatch() called without matching startBatch(). Ignoring.");return}--this._batchDepth===0&&(this._flushSync(),this._isBatching=!1)}setMaxFlushIterations(t){if(t<K.MIN_FLUSH_ITERATIONS)throw new pt(`Max flush iterations must be at least ${K.MIN_FLUSH_ITERATIONS}`);this._maxFlushIterations=t}}const lt=new ke,M={current:null,run(e,t){const n=this.current;this.current=e;try{return t()}finally{this.current=n}}};function ne(e){const t=M.current;if(t===null)return e();M.current=null;try{return e()}finally{M.current=t}}class Te extends te{constructor(t,n){super(),this._pendingOldValue=void 0,this._notifyTask=void 0,this._subscribers=[],this._value=t,n&&(this.flags|=H.SYNC),J.attachDebugInfo(this,"atom",this.id)}get value(){const t=M.current;return t&&Jt(this,t,this._subscribers),this._value}set value(t){const n=this._value;if(Object.is(n,t))return;this._value=t,this.version=Rt(this.version);const s=this.flags;if(!(this._subscribers.length===0||s&H.NOTIFICATION_SCHEDULED)){if(this._pendingOldValue=n,this.flags=s|H.NOTIFICATION_SCHEDULED,s&H.SYNC&&!lt.isBatching){this._flushNotifications();return}this._notifyTask||(this._notifyTask=()=>this._flushNotifications()),lt.schedule(this._notifyTask)}}_flushNotifications(){const t=this.flags;if(!(t&H.NOTIFICATION_SCHEDULED)||t&H.DISPOSED)return;const n=this._pendingOldValue;this._pendingOldValue=void 0,this.flags&=-17,this._notifySubscribers(this._value,n)}peek(){return this._value}dispose(){this.flags&H.DISPOSED||(this._subscribers.length=0,this.flags|=H.DISPOSED,this._value=void 0,this._pendingOldValue=void 0,this._notifyTask=void 0)}}function $t(e,t={}){return new Te(e,t.sync??!1)}class De{constructor(t=50,n=256,s=!1){this.limit=t,this.capacity=n,this.pool=[],this.stats=null,this.stats=R||s?{acquired:0,released:0,rejected:{frozen:0,tooLarge:0,poolFull:0}}:null}acquire(){return this.stats&&this.stats.acquired++,this.pool.pop()??[]}release(t,n){if(!(n&&t===n)){if(t.length>this.capacity){this.stats&&this.stats.rejected.tooLarge++;return}if(this.pool.length>=this.limit){this.stats&&this.stats.rejected.poolFull++;return}if(Object.isFrozen(t)){this.stats&&this.stats.rejected.frozen++;return}t.length=0,this.pool.push(t),this.stats&&this.stats.released++}}getStats(){if(!this.stats)return null;const{acquired:t,released:n,rejected:s}=this.stats,i=t-n-(s.frozen+s.tooLarge+s.poolFull);return{acquired:t,released:n,rejected:{...s},leaked:i,poolSize:this.pool.length}}reset(){this.pool.length=0,this.stats&&(this.stats={acquired:0,released:0,rejected:{frozen:0,tooLarge:0,poolFull:0}})}}const P=Object.freeze([]),V=new De;function Bt(e){return e!==null&&typeof e=="object"&&"value"in e&&typeof e.subscribe=="function"}function se(e){return Bt(e)&&typeof e.invalidate=="function"}function ie(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}const Oe=3,Ae=Number.MAX_SAFE_INTEGER-1,{IDLE:Et,DIRTY:nt,PENDING:Ct,RESOLVED:Y,REJECTED:at,HAS_ERROR:gt,RECOMPUTING:ct,DISPOSED:Lt,IS_COMPUTED:Le}=Yt;function xe(e){return e&Y?_t.RESOLVED:e&Ct?_t.PENDING:e&at?_t.REJECTED:_t.IDLE}class Ne extends te{constructor(t,n={}){if(typeof t!="function")throw new z(S.COMPUTED_MUST_BE_FUNCTION);super(),this._error=null,this._promiseId=0,this._subscribers=[],this._links=P,this._asyncStartAggregateVersion=0,this._asyncRetryCount=0,this._trackEpoch=-1,this._trackLinks=P,this._trackCount=0,this._value=void 0,this.flags=Le|nt|Et,this._equal=n.equal??Object.is,this._fn=t,this._defaultValue="defaultValue"in n?n.defaultValue:Ot,this._onError=n.onError??null;const s=n.maxAsyncRetries;if(this._maxAsyncRetries=s!=null&&s>=0?s:Oe,J.attachDebugInfo(this,"computed",this.id),n.lazy===!1)try{this._recompute()}catch{}}_track(){const t=M.current;t&&Jt(this,t,this._subscribers)}get value(){this._track();const t=this.flags;if((t&(Y|nt|Et))===Y)return this._value;if(t&Lt)throw new z(S.COMPUTED_DISPOSED);if(t&ct){if(this._defaultValue!==Ot)return this._defaultValue;throw new z(S.COMPUTED_CIRCULAR_DEPENDENCY)}if(t&(nt|Et)&&(this._recompute(),this.flags&Y))return this._value;const n=this._defaultValue,s=n!==Ot;if(this.flags&Ct){if(s)return n;throw new z(S.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}if(this.flags&at){if(this._error?.recoverable&&s)return n;throw this._error}return this._value}peek(){return this._value}get state(){return this._track(),xe(this.flags)}get hasError(){if(this._track(),this.flags&(at|gt))return!0;const t=this._links;for(let n=0,s=t.length;n<s;n++){const i=t[n]?.node;if(i&&i.flags>)return!0}return!1}get isValid(){return!this.hasError}get errors(){if(this._track(),!this.hasError)return ye;const t=[];this._error&&t.push(this._error);const n=this._links;for(let s=0,i=n.length;s<i;s++){const o=n[s].node;if(o.flags>){const r=o;if(r.errors){const c=r.errors;for(let a=0;a<c.length;a++){const h=c[a];h&&t.indexOf(h)===-1&&t.push(h)}}}}return Object.freeze(t)}get lastError(){return this._track(),this._error}get isPending(){return this._track(),(this.flags&Ct)!==0}get isResolved(){return this._track(),(this.flags&Y)!==0}invalidate(){this._markDirty()}dispose(){if(this.flags&Lt)return;const t=this._links;if(t!==P){for(let n=0,s=t.length;n<s;n++)t[n].unsub?.();V.release(t),this._links=P}this._subscribers.length=0,this.flags=Lt|nt|Et,this._error=null,this._value=void 0}addDependency(t){if(t._lastSeenEpoch!==this._trackEpoch){if(t._lastSeenEpoch=this._trackEpoch,this._trackCount<this._trackLinks.length){const n=this._trackLinks[this._trackCount];n.node=t,n.version=t.version}else this._trackLinks.push(new bt(t,t.version));this._trackCount++}}_recompute(){if(this.flags&ct)return;this.flags|=ct;const t=this._links;this._trackEpoch=Pt(),this._trackLinks=V.acquire(),this._trackCount=0;let n=!1;try{const s=M.run(this,this._fn);this._trackLinks.length=this._trackCount,zt(this._trackLinks,t,this),this._links=this._trackLinks,n=!0,ie(s)?this._handleAsyncComputation(s):this._finalizeResolution(s)}catch(s){if(!n)try{this._trackLinks.length=this._trackCount,zt(this._trackLinks,t,this),this._links=this._trackLinks,n=!0}catch(i){R&&console.warn("[atom-effect] _commitDeps failed during error recovery:",i)}this._handleError(s,S.COMPUTED_COMPUTATION_FAILED,!0)}finally{n&&t!==P?V.release(t):n||V.release(this._trackLinks),this._trackEpoch=-1,this._trackLinks=P,this._trackCount=0,this.flags&=~ct}}_handleAsyncComputation(t){this.flags=(this.flags|Ct)&-217,this._notifySubscribers(void 0,void 0),this._asyncStartAggregateVersion=this._captureVersionSnapshot(),this._asyncRetryCount=0,this._promiseId=(this._promiseId+1)%Ae;const n=this._promiseId;t.then(s=>{if(n===this._promiseId){if(this._captureVersionSnapshot()!==this._asyncStartAggregateVersion)return this._asyncRetryCount++<this._maxAsyncRetries?this._markDirty():this._handleError(new z(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`),S.COMPUTED_ASYNC_COMPUTATION_FAILED);this._finalizeResolution(s),this._notifySubscribers(s,void 0)}},s=>n===this._promiseId&&this._handleError(s,S.COMPUTED_ASYNC_COMPUTATION_FAILED))}_captureVersionSnapshot(){let t=0;const n=this._links;for(let s=0,i=n.length;s<i;s++)t+=n[s].node.version;return t}_handleError(t,n,s=!1){const i=st(t,z,n);if(!s&&!(this.flags&at)&&(this.version=Rt(this.version)),this._error=i,this.flags=this.flags&-121|at|gt,this._onError)try{this._onError(i)}catch(o){console.error(S.CALLBACK_ERROR_IN_ERROR_HANDLER,o)}if(s)throw i;this._notifySubscribers(void 0,void 0)}_finalizeResolution(t){(!(this.flags&Y)||!this._equal(this._value,t))&&(this.version=Rt(this.version)),this._value=t,this._error=null,this.flags=(this.flags|Y)&-697}execute(){this._markDirty()}_markDirty(){this.flags&(ct|nt)||(this.flags|=nt,this._notifySubscribers(void 0,void 0))}}function oe(e,t={}){return new Ne(e,t)}class Re extends Zt{constructor(t,n={}){super(),this._cleanup=null,this._links=P,this._nextLinks=null,this._prevLinks=null,this._currentEpoch=-1,this._lastFlushEpoch=-1,this._executionsInEpoch=0,this._executionCount=0,this._windowStart=0,this._windowCount=0,this._execId=0,this._fn=t,this._onError=n.onError??null,this._sync=n.sync??!1,this._maxExecutions=n.maxExecutionsPerSecond??K.MAX_EXECUTIONS_PER_SECOND,this._maxExecutionsPerFlush=n.maxExecutionsPerFlush??K.MAX_EXECUTIONS_PER_EFFECT,this._trackModifications=n.trackModifications??!1,J.attachDebugInfo(this,"effect",this.id)}run(){if(this.flags&F.DISPOSED)throw new W(S.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.flags&F.DISPOSED||(this.flags|=F.DISPOSED,this._execCleanup(),this._unsubLinks(this._links),this._links!==P&&V.release(this._links),this._links=P,this._executeTask=void 0)}addDependency(t){if(!(this.flags&F.EXECUTING)||t._lastSeenEpoch===this._currentEpoch)return;t._lastSeenEpoch=this._currentEpoch;const n=this._nextLinks,s=this._prevLinks;if(s)for(let i=0,o=s.length;i<o;i++){const r=s[i];if(r&&r.node===t&&r.unsub){n.push(new bt(t,t.version,r.unsub)),r.unsub=void 0;return}}try{const i=t.subscribe(()=>{if(this._trackModifications&&this.flags&F.EXECUTING&&(t._modifiedAtEpoch=this._currentEpoch),this._sync)return this.execute();this._executeTask||(this._executeTask=()=>this.execute()),lt.schedule(this._executeTask)});n.push(new bt(t,t.version,i))}catch(i){const o=st(i,W,S.EFFECT_EXECUTION_FAILED);if(console.error(o),this._onError)try{this._onError(o)}catch{}n.push(new bt(t,t.version,void 0))}}execute(t=!1){if(this.flags&(F.DISPOSED|F.EXECUTING)||!t&&this._links.length>0&&!this._isDirty())return;this._checkInfiniteLoops(),this.flags|=F.EXECUTING,this._execCleanup();const n=this._links;this._prevLinks=n!==P?n:null;const s=V.acquire();this._nextLinks=s,this._currentEpoch=Pt();let i=!1;try{const o=M.run(this,this._fn);if(this._links=s,i=!0,this._trackModifications&&J.enabled){const r=this._currentEpoch;for(let c=0,a=s.length;c<a;c++){const h=s[c].node;h._modifiedAtEpoch===r&&J.warn(!0,`Effect is reading a dependency (${J.getDebugName(h)||"unknown"}) that it just modified. Infinite loop may occur`)}}ie(o)?this._handleAsyncResult(o):this._cleanup=typeof o=="function"?o:null}catch(o){i=!0,this._handleExecutionError(o),this._cleanup=null}finally{this._finalizeDependencies(i,n,s),this.flags&=-9}}_handleAsyncResult(t){const n=++this._execId;t.then(s=>{if(n!==this._execId||this.flags&F.DISPOSED){if(typeof s=="function")try{s()}catch(i){this._handleExecutionError(i,S.EFFECT_CLEANUP_FAILED)}return}typeof s=="function"&&(this._cleanup=s)},s=>n===this._execId&&this._handleExecutionError(s))}_finalizeDependencies(t,n,s){if(this._nextLinks=null,t){const i=this._prevLinks;if(i)for(let o=0,r=i.length;o<r;o++)i[o]?.unsub?.();n!==P&&V.release(n)}else this._unsubLinks(s),V.release(s);this._prevLinks=null}_unsubLinks(t){for(let n=0,s=t.length;n<s;n++)t[n]?.unsub?.()}_isDirty(){const t=this._links,n=M.current;M.current=null;try{for(let s=0,i=t.length;s<i;s++){const o=t[s],r=o.node;if(r.flags&Yt.IS_COMPUTED)try{r.value}catch{return R&&console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`),!0}if(r.version!==o.version)return!0}return!1}finally{M.current=n}}_execCleanup(){if(this._cleanup){try{this._cleanup()}catch(t){this._handleExecutionError(t,S.EFFECT_CLEANUP_FAILED)}this._cleanup=null}}_checkInfiniteLoops(){const t=ve();if(this._lastFlushEpoch!==t&&(this._lastFlushEpoch=t,this._executionsInEpoch=0),++this._executionsInEpoch>this._maxExecutionsPerFlush&&this._throwInfiniteLoopError("per-effect"),we()>K.MAX_EXECUTIONS_PER_FLUSH&&this._throwInfiniteLoopError("global"),this._executionCount++,R&&Number.isFinite(this._maxExecutions)){const n=Date.now();if(n-this._windowStart>=1e3)this._windowStart=n,this._windowCount=1;else if(++this._windowCount>this._maxExecutions){const s=new W(S.EFFECT_FREQUENCY_LIMIT_EXCEEDED);throw this.dispose(),this._handleExecutionError(s),s}}}get isDisposed(){return(this.flags&F.DISPOSED)!==0}get executionCount(){return this._executionCount}get isExecuting(){return(this.flags&F.EXECUTING)!==0}_throwInfiniteLoopError(t){const n=new W(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Mt}`);throw this.dispose(),console.error(n),n}_handleExecutionError(t,n=S.EFFECT_EXECUTION_FAILED){const s=st(t,W,n);if(console.error(s),this._onError)try{this._onError(s)}catch(i){console.error(st(i,W,S.CALLBACK_ERROR_IN_ERROR_HANDLER))}}}function q(e,t={}){if(typeof e!="function")throw new W(S.EFFECT_MUST_BE_FUNCTION);const n=new Re(e,t);return n.execute(),n}function Tt(e){if(typeof e!="function")throw new TypeError("Batch callback must be a function");lt.startBatch();try{return e()}finally{lt.endBatch()}}function re(e){return Bt(e)||se(e)}function Dt(e){if(!e)return"unknown";const t="jquery"in e?e[0]:e;if(!t)return"unknown";const n=t.id;if(n&&typeof n=="string")return`#${n}`;const s=t.tagName.toLowerCase(),i=t.classList;if(i&&i.length>0){let o=s;for(let r=0,c=i.length;r<c;r++){const a=i[r];a&&(o+=`.${a}`)}return o}return s}function It(e){let t=String(e??"");t=t.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,""),t=t.replace(/<\?[\s\S]*?\?>/g,"");const n=/(<(script|iframe|object|embed|base|meta|applet|noscript)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript)\b[^>]*\/?>)/gim;let s;do s=t,t=t.replace(n,"");while(t!==s);const i=/(j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*:/gi;t=t.replace(i,"data-unsafe-protocol:");const o=/data\s*:\s*(?:text\/html|application\/javascript|text\/javascript|text\/vbscript|text\/xml|application\/xhtml\+xml)/gim;return t=t.replace(o,"data-unsafe-protocol:"),t=t.replace(/\bon\w+\s*=/gim,"data-unsafe-attr="),t=t.replace(/expression\s*\(/gim,"data-unsafe-css(").replace(/behavior\s*:/gim,"data-unsafe-css:"),t}const Ue=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset","background","cite","longdesc","profile","usemap","classid","codebase"]),Fe=/^\s*(?:javascript|vbscript)\s*:/i;function Pe(e,t){return Ue.has(e.toLowerCase())?Fe.test(t):!1}function Me(e){return e.toLowerCase().includes("url(")?/url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i.test(e):!1}function $e(e,t){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;const i=t;for(let o=0;o<n.length;o++){const r=n[o];if(e[r]!==i[r])return!1}return!0}function Be(e){const t=e.length;if(t===0)return new Int32Array(0);const n=new Int32Array(t),s=new Int32Array(t);let i=0;for(let r=0;r<t;r++){const c=e[r];if(c===void 0||c===-1)continue;const a=i>0?s[i-1]:void 0;if(i===0||a!==void 0&&(e[a]??-1)<c){n[r]=a??-1,s[i++]=r;continue}let h=0,p=i-1;for(;h<p;){const b=h+p>>>1,D=s[b];D!==void 0&&(e[D]??-1)<c?h=b+1:p=b}const C=s[h];C!==void 0&&c<(e[C]??Number.MAX_SAFE_INTEGER)&&(h>0&&(n[r]=s[h-1]??-1),s[h]=r)}const o=new Int32Array(i);if(i>0){let r=s[i-1];for(let c=i-1;c>=0&&r!==void 0&&r!==-1;c--)o[c]=r,r=n[r]}return o}function je(){if(typeof window<"u"){const e=window.__ATOM_DEBUG__;if(typeof e=="boolean")return e}return!1}let G=je();const y={get enabled(){return G},set enabled(e){G=e},log(e,...t){G&&console.log(`[atom-effect-jquery] ${e}:`,...t)},atomChanged(e,t,n){G&&console.log(`[atom-effect-jquery] Atom "${e??"anonymous"}" changed:`,t,"→",n)},domUpdated(e,t,n){G&&(console.log(`[atom-effect-jquery] DOM updated: ${Dt(e)}.${t} =`,n),ze(e))},cleanup(e){G&&console.log(`[atom-effect-jquery] Cleanup: ${e}`)},warn(...e){G&&console.warn("[atom-effect-jquery]",...e)}},Ut="atom-debug-highlight";let Xt=!1;function He(){if(Xt)return;Xt=!0;const e=document.createElement("style");e.textContent=`.${Ut}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline 0.5s ease-out}`,document.head.appendChild(e)}const xt=new WeakMap;function ze(e){const t="jquery"in e?e[0]:e;if(!t||!t.isConnected)return;He();const n=xt.get(t);n&&clearTimeout(n),t.classList.add(Ut),xt.set(t,setTimeout(()=>{t.classList.remove(Ut),xt.delete(t)},600))}function ce(e,t={}){return $t(e,t)}Object.defineProperty(ce,"debug",{get(){return y.enabled},set(e){y.enabled=e}});function Ve(){return new Promise(e=>setTimeout(e,0))}l.extend({atom:ce,computed:oe,effect:q,batch:Tt,untracked:ne,isAtom:Bt,isComputed:se,isReactive:re,nextTick:Ve});const mt="_aes-bound";class qe{records=new WeakMap;boundElements=new WeakSet;preservedNodes=new WeakSet;ignoredNodes=new WeakSet;keep(t){this.preservedNodes.add(t)}isKept(t){return this.preservedNodes.has(t)}markIgnored(t){this.ignoredNodes.add(t)}isIgnored(t){return this.ignoredNodes.has(t)}_getOrCreateRecord(t){let n=this.records.get(t);return n||(n={},this.records.set(t,n),this.boundElements.has(t)||(this.boundElements.add(t),t.classList.add(mt))),n}trackEffect(t,n){const s=this._getOrCreateRecord(t);s.effects||(s.effects=[]),s.effects.push(n)}trackCleanup(t,n){const s=this._getOrCreateRecord(t);s.cleanups||(s.cleanups=[]),s.cleanups.push(n)}hasBind(t){return this.boundElements.has(t)}cleanup(t){if(!this.boundElements.delete(t))return;const n=this.records.get(t);if(!n)return;this.records.delete(t),this.preservedNodes.delete(t),this.ignoredNodes.delete(t),t.classList.remove(mt),y.enabled&&y.cleanup(Dt(t));const s=n.effects;if(s)for(let o=0,r=s.length;o<r;o++)try{s[o]?.dispose()}catch(c){y.warn("Effect dispose error:",c)}const i=n.cleanups;if(i)for(let o=0,r=i.length;o<r;o++)try{i[o]?.()}catch(c){y.warn("Cleanup error:",c)}}cleanupDescendants(t){const n=t.querySelectorAll(`.${mt}`);for(let s=0,i=n.length;s<i;s++){const o=n[s];o&&this.boundElements.has(o)?this.cleanup(o):o&&o.classList.remove(mt)}}cleanupTree(t){this.cleanupDescendants(t),this.cleanup(t)}}const m=new qe;let ut=null;function ae(e=document.body){ut||(ut=new MutationObserver(t=>{for(let n=0,s=t.length;n<s;n++){const i=t[n]?.removedNodes;if(!i)continue;const o=i.length;if(o!==0)for(let r=0;r<o;r++){const c=i[r];c.nodeType===1&&(c.isConnected||m.isKept(c)||m.isIgnored(c)||m.cleanupTree(c))}}}),ut.observe(e,{childList:!0,subtree:!0}))}function Xe(){ut?.disconnect(),ut=null}function X(e,t,n,s){re(t)?m.trackEffect(e,q(()=>{const i=t.value;n(i),y.domUpdated(l(e),s,i)})):(n(t),y.enabled&&y.domUpdated(l(e),s,t))}var T=(e=>(e[e.None=0]="None",e[e.Focused=1]="Focused",e[e.Composing=2]="Composing",e[e.SyncingToAtom=4]="SyncingToAtom",e[e.SyncingToDom=8]="SyncingToDom",e[e.Busy=14]="Busy",e))(T||{});function ue(){return{timeoutId:null,flags:0}}function Qe(e,t,n={}){const{debounce:s,event:i="input",parse:o=I=>I,format:r=I=>String(I??""),equal:c=Object.is}=n,a=ue(),h=e[0],p=()=>{if(!(a.flags&T.Busy)){a.flags|=T.SyncingToAtom;try{const I=h.value,v=o(I);c(t.value,v)||(t.value=v)}finally{a.flags&=~T.SyncingToAtom}}},C=()=>{a.timeoutId&&(clearTimeout(a.timeoutId),a.timeoutId=null,p()),a.flags&=~T.Focused;const I=r(t.value);h.value!==I&&(h.value=I)},b=()=>{a.flags&T.Busy||(s?(a.timeoutId&&clearTimeout(a.timeoutId),a.timeoutId=setTimeout(p,s)):p())},D={compositionstart:()=>{a.flags|=T.Composing},compositionend:()=>{a.flags&=~T.Composing,p()},focus:()=>{a.flags|=T.Focused},blur:C,[i]:b,change:b};return e.on(D),{effect:()=>{const I=t.value,v=r(I),L=h.value;if(L!==v&&!(a.flags&T.Focused&&c(o(L),I))){a.flags|=T.SyncingToDom;try{if(a.flags&T.Focused){const{selectionStart:Z,selectionEnd:ot}=h;h.value=v;const j=v.length;h.setSelectionRange(Math.min(Z??0,j),Math.min(ot??0,j))}else h.value=v;y.domUpdated(e,"val",v)}finally{a.flags&=~T.SyncingToDom}}},cleanup:()=>{e.off(D),a.timeoutId&&clearTimeout(a.timeoutId)}}}const Qt=Object.create(null);function Ge(e){let t=Qt[e];return t||(t=e.includes("-")?e.replace(/-./g,n=>n[1].toUpperCase()):e,Qt[e]=t,t)}function $(e){let t=null;return{get $el(){return t||(t=l(e)),t},el:e,trackCleanup:n=>m.trackCleanup(e,n)}}function We(e,t){const n=e.el;X(n,t,s=>{const i=typeof s=="string"?s:String(s??"");n.textContent!==i&&(n.textContent=i)},"text")}function le(e,t){const n=e.el;X(n,t,s=>{const i=String(s??""),o=It(i);o!==i&&console.warn("[atomBind] Unsafe content neutralized during sanitization."),n.innerHTML!==o&&(n.innerHTML=o)},"html")}function he(e,t){for(const n in t)X(e.el,t[n],s=>{e.el.classList.toggle(n,!!s)},`class.${n}`)}function fe(e,t){const n=e.el,s=n.style;for(const i in t){const o=t[i];if(o===void 0)continue;const r=Ge(i),c=Array.isArray(o),a=c?o[0]:o,h=c?o[1]:"";X(n,a,p=>{const C=h?`${p}${h}`:String(p);if(Me(C)){console.warn(`[atomBind] Blocked dangerous value in "${i}" property.`);return}s[r]=C},`css.${i}`)}}function de(e,t){const n=e.el;for(const s in t){const i=s.charCodeAt(0);if((i===111||i===79)&&(s.charCodeAt(1)===110||s.charCodeAt(1)===78)){console.warn(`[atomBind] Blocked setting dangerous event handler attribute "${s}".`);continue}X(n,t[s],o=>{if(o==null||o===!1){n.removeAttribute(s);return}const r=o===!0?s:String(o);if(Pe(s,r)){console.warn(`[atomBind] Blocked dangerous protocol in "${s}" attribute.`);return}n.getAttribute(s)!==r&&n.setAttribute(s,r)},`attr.${s}`)}}const Ye=["innerHTML","outerHTML"];function _e(e,t){const n=e.el;for(const s in t){if(Ye.includes(s)){console.warn(`[atomBind] Blocked setting dangerous property "${s}". Use html binding for sanitized HTML.`);continue}X(e.el,t[s],i=>{n[s]!==i&&(n[s]=i)},`prop.${s}`)}}function wt(e,t,n,s){const i=e.el;X(i,t,o=>{const r=n?!o:!!o;i.style.display=r?"":"none",y.enabled&&y.domUpdated(i,s,o)},s)}function pe(e,t){const n=e.el.tagName.toLowerCase();if(n!=="input"&&n!=="select"&&n!=="textarea"){console.warn(`[atomBind] Val binding used on non-input element <${n}>.`);return}const s=Array.isArray(t),{effect:i,cleanup:o}=Qe(e.$el,s?t[0]:t,s?t[1]:{});m.trackEffect(e.el,q(i)),e.trackCleanup(o)}function Ee(e,t){const n=e.el,s=e.$el,i=ue(),o=()=>{if(i.flags&T.Busy)return;const c=n.checked;t.value!==c&&(t.value=c)};s.on("change",o),e.trackCleanup(()=>s.off("change",o));const r=q(()=>{i.flags|=T.SyncingToDom;const c=!!t.value;n.checked!==c&&(n.checked=c,y.enabled&&y.domUpdated(s,"checked",c)),i.flags&=~T.SyncingToDom});m.trackEffect(n,r)}function Ke(e,t){for(const n in t){const s=t[n];if(typeof s!="function")continue;const i=o=>{Tt(()=>s.call(e.el,l.Event(o.type,{originalEvent:o})))};e.el.addEventListener(n,i),e.trackCleanup(()=>e.el.removeEventListener(n,i))}}l.fn.atomBind=function(e){return this.each(function(){const t=$(this);e.text!==void 0&&We(t,e.text),e.html!==void 0&&le(t,e.html),e.class&&he(t,e.class),e.css&&fe(t,e.css),e.attr&&de(t,e.attr),e.prop&&_e(t,e.prop),e.show!==void 0&&wt(t,e.show,!1,"show"),e.hide!==void 0&&wt(t,e.hide,!0,"hide"),e.val!==void 0&&pe(t,e.val),e.checked!==void 0&&Ee(t,e.checked),e.on&&Ke(t,e.on)})};l.fn.atomText=function(e,t){return this.each(function(){const n=l(this);X(this,e,t?i=>n.text(t(i)):i=>n.text(String(i??"")),"text")})};l.fn.atomHtml=function(e){return this.each(function(){le($(this),e)})};l.fn.atomClass=function(e,t){return this.each(function(){he($(this),{[e]:t})})};l.fn.atomCss=function(e,t,n){return this.each(function(){fe($(this),{[e]:n?[t,n]:t})})};l.fn.atomAttr=function(e,t){return this.each(function(){de($(this),{[e]:t})})};l.fn.atomProp=function(e,t){return this.each(function(){_e($(this),{[e]:t})})};l.fn.atomShow=function(e){return this.each(function(){wt($(this),e,!1,"show")})};l.fn.atomHide=function(e){return this.each(function(){wt($(this),e,!0,"hide")})};l.fn.atomVal=function(e,t={}){return this.each(function(){pe($(this),t&&Object.keys(t).length>0?[e,t]:e)})};l.fn.atomChecked=function(e){return this.each(function(){Ee($(this),e)})};l.fn.atomOn=function(e,t){return this.each(function(){const n=l(this);n.on(e,t),m.trackCleanup(this,()=>n.off(e,t))})};l.fn.atomUnbind=function(){return this.each(function(){m.cleanupTree(this)})};l.fn.atomList=function(e,t){const{key:n,render:s,bind:i,update:o,onAdd:r,onRemove:c,empty:a}=t,h=typeof n=="function"?n:(p,C)=>p[n];return this.each(function(){const p=l(this),C=Dt(this),b=new Map,D=new Set;let O=[],A=null;const I=q(()=>{const v=e.value,L=v.length;if(L===0){if(a&&!A){const f=typeof a=="string"?It(a):a;A=l(f).appendTo(p)}}else A&&(A.remove(),A=null);if(L===0&&b.size===0){O=[];return}y.log("list",`${C} updating with ${L} items`);const Z=new Map,ot=O.length;for(let f=0;f<ot;f++)Z.set(O[f],f);const j=new Array(L),rt=new Set,ht=new Int32Array(L);for(let f=0;f<L;f++){const N=v[f],g=h(N,f);rt.has(g)&&console.warn(`[atomList] Duplicate key "${g}" at index ${f}.`),j[f]=g,rt.add(g),ht[f]=Z.get(g)??-1}if(b.size>0)for(const[f,N]of b){if(rt.has(f)||D.has(f))continue;const g=()=>{N.$el.remove(),N.$el[0]&&m.cleanup(N.$el[0]),D.delete(f),y.log("list",`${C} removed item:`,f)};if(b.delete(f),D.add(f),c){const w=c(N.$el);w instanceof Promise?w.then(g):g()}else g()}if(L===0){O=[];return}const ft=Be(ht);let U=ft.length-1,x=null;for(let f=L-1;f>=0;f--){const N=j[f],g=v[f],w=b.get(N);if(w){const B=w.item;w.item=g;const tt=w.$el[0];if(!tt)continue;if(o)o(w.$el,g,f),y.domUpdated(w.$el,"list.update",g);else if(B!==g&&!$e(B,g)){const u=s(g,f),d=typeof u=="string"?It(u):u,E=l(d),_=x===tt;w.$el.replaceWith(E),w.$el=E,i&&i(E,g,f),y.domUpdated(E,"list.render",g),_&&(x=E[0]||null)}if(U>=0&&ft[U]===f)U--;else{const u=w.$el[0];x?.isConnected?x!==u&&w.$el.insertBefore(x):w.$el.appendTo(p)}x=w.$el[0]||null}else{const B=s(g,f),tt=typeof B=="string"?It(B):B,u=l(tt);b.set(N,{$el:u,item:g}),x?.isConnected?u.insertBefore(x):u.appendTo(p),i&&i(u,g,f),r&&r(u),y.domUpdated(u,"list.add",g),x=u[0]||null}}O=j});m.trackEffect(this,I),m.trackCleanup(this,()=>{b.clear(),D.clear(),O=[],A?.remove()})})};const St=new WeakMap;l.fn.atomMount=function(e,t={}){return this.each(function(){const n=Dt(this),s=St.get(this);s&&(y.log("mount",`${n} unmounting existing component`),s()),y.log("mount",`${n} mounting component`);let i;try{i=e(l(this),t)}catch(r){console.error("[atom-effect-jquery] Mount error:",r);return}const o=()=>{if(St.delete(this)){if(y.log("mount",`${n} full cleanup`),typeof i=="function")try{i()}catch(r){console.error("[atom-effect-jquery] Cleanup error:",r)}m.cleanupTree(this)}};St.set(this,o),m.trackCleanup(this,o)})};l.fn.atomUnmount=function(){return this.each(function(){const e=St.get(this);e&&e()})};const yt="[$.route]";function Je(e){const{target:t,default:n,routes:s,notFound:i,mode:o="hash",basePath:r="",autoBindLinks:c=!1,activeClass:a="active",beforeTransition:h,afterTransition:p}=e,C=o==="history";let b=!1,D=null,O=C?window.location.pathname+window.location.search:window.location.hash;const A=[],I=new Set,v=l(t),L=()=>{if(C){let _=window.location.pathname;return r&&_.startsWith(r)&&(_=_.substring(r.length)),_.replace(/^\//,"")||n}const u=window.location.hash,d=u.indexOf("?");return(d===-1?u.substring(1):u.substring(1,d))||n},Z=()=>{let u;if(C){if(u=window.location.search.substring(1),!u)return{}}else{const _=window.location.hash,k=_.indexOf("?");if(k===-1)return{};u=_.substring(k+1)}const d=new URLSearchParams(u),E=Object.fromEntries(d);if(u.includes("%"))try{decodeURIComponent(u)}catch{console.warn(`${yt} Malformed URI component: ${u}`)}return E},ot=u=>{if(C){const d=`${r.replace(/\/$/,"")}/${u}`;history.pushState(null,"",d),O=d}else{const d=`#${u}`;O=d,window.location.hash=d}},j=()=>{C?history.replaceState(null,"",O):window.location.hash=O},rt=()=>C?window.location.pathname+window.location.search:window.location.hash,ht=u=>{let d=s[u];return!d&&i&&(d=s[i]),d||(console.warn(`${yt} Route "${u}" not found and no notFound route configured`),null)},ft=u=>{const d=document.querySelector(u);if(!d?.content)return console.warn(`${yt} Template "${u}" not found`),!1;const E=d.content.cloneNode(!0);return v.append(E),!0},U=$t(L()),x=u=>{if(b)return;const d=v[0];if(!d){console.warn(`${yt} Target element "${t}" not found`);return}const E=ht(u);if(!E)return;const _=Z();h&&h(D||u,u),v.empty();let k=_;if(E.onEnter){const Q=E.onEnter(_);Q!==void 0&&(k={..._,...Q})}E.render?E.render(d,u,k):E.template&&ft(E.template),p&&p(D||u,u),D=u},f=u=>{if(b)return;const d=U.value,E=s[d];E?.onLeave&&E.onLeave()===!1||(ot(u),U.value=u)},N=()=>{if(b)return;const u=rt();if(u===O)return;const d=L(),E=U.value;if(E!==d){const _=s[E];if(_?.onLeave&&_.onLeave()===!1){j();return}U.value=d}else x(d);O=u},g=()=>{if(!c)return;const u=_=>{_.preventDefault();const k=l(_.currentTarget).data("route");f(k)};l(document).on("click","[data-route]",u),A.push(()=>{l(document).off("click","[data-route]",u)});const d=_=>{if(I.has(_))return;const k=l(_),Q=k.data("route");I.add(_);const et=q(()=>{const dt=U.value===Q;k.toggleClass(a,dt),dt?k.attr("aria-current","page"):k.removeAttr("aria-current")});m.trackEffect(_,et),m.trackCleanup(_,()=>{I.delete(_)})};l("[data-route]").each(function(){d(this)});const E=new MutationObserver(_=>{for(const k of _)k.type==="childList"&&k.addedNodes.forEach(Q=>{if(Q.nodeType===1){const et=Q;et.matches?.("[data-route]")&&d(et),et.querySelectorAll&&et.querySelectorAll("[data-route]").forEach(dt=>d(dt))}})});E.observe(document.body,{childList:!0,subtree:!0}),A.push(()=>E.disconnect())},w=()=>{b||(b=!0,A.forEach(u=>u()),A.length=0,I.forEach(u=>m.cleanup(u)),I.clear())},B=C?"popstate":"hashchange";window.addEventListener(B,N),A.push(()=>window.removeEventListener(B,N));const tt=q(()=>{x(U.value)});return A.push(()=>tt.dispose()),g(),v[0]&&m.trackCleanup(v[0],w),{currentRoute:U,navigate:f,destroy:w}}l.extend({route:Je});const kt=new WeakMap;let Gt=!1;const Wt=e=>{let t=kt.get(e);return t||(t=function(...n){return Tt(()=>e.apply(this,n))},kt.set(e,t)),t};function ge(){if(Gt)return;Gt=!0;const e=l.fn.on,t=l.fn.off,n=l.fn.remove,s=l.fn.empty,i=l.fn.detach;l.fn.remove=function(o){const r=o?this.filter(o):this;for(let c=0,a=r.length;c<a;c++){const h=r[c];h&&(m.cleanupTree(h),m.markIgnored(h))}return n.call(this,o)},l.fn.empty=function(){for(let o=0,r=this.length;o<r;o++){const c=this[o];c&&m.cleanupDescendants(c)}return s.call(this)},l.fn.detach=function(o){const r=o?this.filter(o):this;for(let c=0,a=r.length;c<a;c++){const h=r[c];h&&m.keep(h)}return i.call(this,o)},l.fn.on=function(...o){const r=o[0];if(r&&typeof r=="object"){const c=r,a={};for(const h in c){const p=c[h];p&&(a[h]=Wt(p))}o[0]=a}else for(let c=o.length-1;c>=0;c--)if(typeof o[c]=="function"){o[c]=Wt(o[c]);break}return e.apply(this,o)},l.fn.off=function(...o){const r=o[0];if(r&&typeof r=="object"){const c=r,a={};for(const h in c){const p=c[h];p&&(a[h]=kt.get(p)||p)}o[0]=a}else for(let c=o.length-1;c>=0;c--)if(typeof o[c]=="function"){o[c]=kt.get(o[c])||o[c];break}return t.apply(this,o)}}l(()=>{ge(),ae(document.body)});exports.default=l;exports.atom=$t;exports.batch=Tt;exports.computed=oe;exports.disableAutoCleanup=Xe;exports.effect=q;exports.enableAutoCleanup=ae;exports.enablejQueryOverrides=ge;exports.registry=m;exports.untracked=ne;
|
|
1
|
+
"use strict";var Te=Object.defineProperty;var Oe=(e,t,n)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ct=(e,t,n)=>Oe(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("jquery"),_t={IDLE:"idle",PENDING:"pending",RESOLVED:"resolved",REJECTED:"rejected"},F={DISPOSED:1,EXECUTING:8},ie={DISPOSED:1,IS_COMPUTED:2,DIRTY:8,IDLE:16,PENDING:32,RESOLVED:64,REJECTED:128,RECOMPUTING:256,HAS_ERROR:512},z={DISPOSED:1,SYNC:8,NOTIFICATION_SCHEDULED:16},J={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},Ae={WARN_INFINITE_LOOP:!0},Ft=1073741823,R=typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"||typeof __DEV__<"u"&&!!__DEV__,Le=Object.freeze([]);class it extends Error{constructor(t,n=null,s=!0){super(t),this.cause=n,this.recoverable=s,this.name="AtomError"}}class H extends it{constructor(t,n=null){super(t,n,!0),this.name="ComputedError"}}class Y extends it{constructor(t,n=null){super(t,n,!1),this.name="EffectError"}}class pt extends it{constructor(t,n=null){super(t,n,!1),this.name="SchedulerError"}}const zt=Symbol("AtomEffect.DebugName"),xe=Symbol("AtomEffect.Id"),Ht=Symbol("AtomEffect.Type"),Ot=Symbol("AtomEffect.NoDefaultValue"),Ne=e=>"dependencies"in e&&Array.isArray(e.dependencies);function oe(e,t,n){if(e===t)throw new H("Circular dependency detected: The computation refers to itself explicitly or implicitly.");if(!n.has(e.id)&&(n.add(e.id),Ne(e))){const s=e.dependencies;for(let i=0;i<s.length;i++){const o=s[i];o&&oe(o,t,n)}}}const Z={enabled:R,warnInfiniteLoop:Ae.WARN_INFINITE_LOOP,warn(e,t){R&&this.enabled&&e&&console.warn(`[Atom Effect] ${t}`)},checkCircular(e,t){if(e===t)throw new H("Direct circular dependency detected");R&&this.enabled&&oe(e,t,new Set)},attachDebugInfo(e,t,n){if(!R||!this.enabled)return;const s=e;s[zt]=`${t}_${n}`,s[xe]=n,s[Ht]=t},getDebugName:e=>e?.[zt],getDebugType:e=>e?.[Ht]};let Re=1;const Ue=()=>Re++;function re(e,t,n){if(typeof t=="function"){const i=t;for(let o=0,r=n.length;o<r;o++){const c=n[o];if(c&&c.fn===i)return}n.push(new Nt(i,void 0));return}if("addDependency"in t){t.addDependency(e);return}const s=t;for(let i=0,o=n.length;i<o;i++){const r=n[i];if(r&&r.sub===s)return}n.push(new Nt(void 0,s))}function Vt(e,t,n){const s=new Map;for(let i=0,o=t.length;i<o;i++){const r=t[i];r?.unsub&&s.set(r.node,r.unsub)}for(let i=0,o=e.length;i<o;i++){const r=e[i];if(!r)continue;const c=r.node,a=s.get(c);a!==void 0?(r.unsub=a,s.delete(c)):(Z.checkCircular(c,n),r.unsub=c.subscribe(n))}for(const i of s.values())i()}class bt{constructor(t,n,s=void 0){this.node=t,this.version=n,this.unsub=s}}class Nt{constructor(t,n){this.fn=t,this.sub=n}}const S={COMPUTED_MUST_BE_FUNCTION:"Computed target must be a function",COMPUTED_ASYNC_PENDING_NO_DEFAULT:"Async computation pending with no default value",COMPUTED_COMPUTATION_FAILED:"Computation execution failed",COMPUTED_ASYNC_COMPUTATION_FAILED:"Async computation execution failed",COMPUTED_CIRCULAR_DEPENDENCY:"Circular dependency detected",COMPUTED_DISPOSED:"Attempted to access disposed computed",ATOM_SUBSCRIBER_MUST_BE_FUNCTION:"Subscriber must be a function or Subscriber object",ATOM_INDIVIDUAL_SUBSCRIBER_FAILED:"Subscriber execution failed",EFFECT_MUST_BE_FUNCTION:"Effect target must be a function",EFFECT_EXECUTION_FAILED:"Effect execution failed",EFFECT_CLEANUP_FAILED:"Effect cleanup failed",EFFECT_DISPOSED:"Attempted to run disposed effect",SCHEDULER_FLUSH_OVERFLOW:(e,t)=>`Maximum flush iterations (${e}) exceeded. ${t} jobs dropped. Possible infinite loop.`,CALLBACK_ERROR_IN_ERROR_HANDLER:"Exception encountered in onError handler",EFFECT_FREQUENCY_LIMIT_EXCEEDED:"Effect executed too frequently within 1 second. Suspected infinite loop."};function st(e,t,n){if(e instanceof it)return e;const s=e instanceof Error,i=s?e.message:String(e),o=s?e:void 0,r=`${s?e.constructor.name:"Unexpected error"} (${n}): ${i}`;return new t(r,o)}class ce{constructor(){this.flags=0,this.version=0,this._lastSeenEpoch=-1,this.id=Ue()&Ft}}class ae extends ce{subscribe(t){const n=typeof t=="function";if(!n&&(!t||typeof t.execute!="function"))throw st(new TypeError("Invalid subscriber"),it,S.ATOM_SUBSCRIBER_MUST_BE_FUNCTION);const s=this._subscribers;for(let o=0,r=s.length;o<r;o++){const c=s[o];if(c&&(n?c.fn===t:c.sub===t))return R&&console.warn("Duplicate subscription ignored."),()=>{}}const i=new Nt(n?t:void 0,n?void 0:t);return s.push(i),()=>this._unsubscribe(i)}_unsubscribe(t){const n=this._subscribers,s=n.indexOf(t);if(s===-1)return;const i=n.pop();s<n.length&&i&&(n[s]=i)}subscriberCount(){return this._subscribers.length}_notifySubscribers(t,n){if(this._subscribers.length===0)return;const s=this._subscribers.slice(0),i=s.length;for(let o=0;o<i;o++){const r=s[o];if(r)try{r.fn?r.fn(t,n):r.sub&&r.sub.execute()}catch(c){this._handleNotifyError(c)}}}_handleNotifyError(t){console.error(st(t,it,S.ATOM_INDIVIDUAL_SUBSCRIBER_FAILED))}}let At=0;const Pt=()=>(At=At+1&Ft||1,At),Rt=e=>e+1&Ft;let Mt=0,vt=!1,ue=0;const Fe=()=>ue;function qt(){return vt?(R&&console.warn("startFlush() called during flush - ignored"),!1):(vt=!0,ue=Pt(),Mt=0,!0)}const Xt=()=>{vt=!1},Pe=()=>vt?++Mt:0;class Me{constructor(){this._queueBuffer=[[],[]],this._bufferIndex=0,this._size=0,this._epoch=0,this._isProcessing=!1,this._isBatching=!1,this._isFlushingSync=!1,this._batchDepth=0,this._batchQueue=[],this._batchQueueSize=0,this._maxFlushIterations=J.MAX_FLUSH_ITERATIONS,this.onOverflow=null,this._boundRunLoop=this._runLoop.bind(this)}get phase(){return this._isProcessing||this._isFlushingSync?2:this._isBatching?1:0}get queueSize(){return this._size}get isBatching(){return this._isBatching}schedule(t){if(R&&typeof t!="function")throw new pt("Scheduler callback must be a function");if(t._nextEpoch!==this._epoch){if(t._nextEpoch=this._epoch,this._isBatching||this._isFlushingSync){this._batchQueue[this._batchQueueSize++]=t;return}this._queueBuffer[this._bufferIndex][this._size++]=t,this._isProcessing||this._flush()}}_flush(){this._isProcessing||this._size===0||(this._isProcessing=!0,queueMicrotask(this._boundRunLoop))}_runLoop(){try{if(this._size===0)return;const t=qt();this._drainQueue(),t&&Xt()}finally{this._isProcessing=!1,this._size>0&&!this._isBatching&&this._flush()}}_flushSync(){this._isFlushingSync=!0;const t=qt();try{this._mergeBatchQueue(),this._drainQueue()}finally{this._isFlushingSync=!1,t&&Xt()}}_mergeBatchQueue(){if(this._batchQueueSize===0)return;const t=++this._epoch,n=this._batchQueue,s=this._queueBuffer[this._bufferIndex];let i=this._size;for(let o=0;o<this._batchQueueSize;o++){const r=n[o];r._nextEpoch!==t&&(r._nextEpoch=t,s[i++]=r)}this._size=i,this._batchQueueSize=0,n.length>J.BATCH_QUEUE_SHRINK_THRESHOLD&&(n.length=0)}_drainQueue(){let t=0;for(;this._size>0;){if(++t>this._maxFlushIterations){this._handleFlushOverflow();return}this._processQueue(),this._mergeBatchQueue()}}_processQueue(){const t=this._bufferIndex,n=this._queueBuffer[t],s=this._size;this._bufferIndex=t^1,this._size=0,this._epoch++;for(let i=0;i<s;i++)try{n[i]()}catch(o){console.error(new pt("Error occurred during scheduler execution",o))}n.length=0}_handleFlushOverflow(){const t=this._size+this._batchQueueSize;if(console.error(new pt(S.SCHEDULER_FLUSH_OVERFLOW(this._maxFlushIterations,t))),this._size=0,this._queueBuffer[this._bufferIndex].length=0,this._batchQueueSize=0,this.onOverflow)try{this.onOverflow(t)}catch{}}startBatch(){this._batchDepth++,this._isBatching=!0}endBatch(){if(this._batchDepth===0){R&&console.warn("endBatch() called without matching startBatch(). Ignoring.");return}--this._batchDepth===0&&(this._flushSync(),this._isBatching=!1)}setMaxFlushIterations(t){if(t<J.MIN_FLUSH_ITERATIONS)throw new pt(`Max flush iterations must be at least ${J.MIN_FLUSH_ITERATIONS}`);this._maxFlushIterations=t}}const ht=new Me,$t=Symbol.for("atom-effect/atom"),le=Symbol.for("atom-effect/computed"),$e=Symbol.for("atom-effect/effect"),M={current:null,run(e,t){const n=this.current;this.current=e;try{return t()}finally{this.current=n}}};function he(e){const t=M.current;if(t===null)return e();M.current=null;try{return e()}finally{M.current=t}}var Qt,Gt;class Be extends(Gt=ae,Qt=$t,Gt){constructor(t,n){super(),this._pendingOldValue=void 0,this._notifyTask=void 0,this._subscribers=[],this[Qt]=!0,this._value=t,n&&(this.flags|=z.SYNC),Z.attachDebugInfo(this,"atom",this.id)}get value(){const t=M.current;return t&&re(this,t,this._subscribers),this._value}set value(t){const n=this._value;if(Object.is(n,t))return;this._value=t,this.version=Rt(this.version);const s=this.flags;if(!(this._subscribers.length===0||s&z.NOTIFICATION_SCHEDULED)){if(this._pendingOldValue=n,this.flags=s|z.NOTIFICATION_SCHEDULED,s&z.SYNC&&!ht.isBatching){this._flushNotifications();return}this._notifyTask||(this._notifyTask=()=>this._flushNotifications()),ht.schedule(this._notifyTask)}}_flushNotifications(){const t=this.flags;if(!(t&z.NOTIFICATION_SCHEDULED)||t&z.DISPOSED)return;const n=this._pendingOldValue;this._pendingOldValue=void 0,this.flags&=-17,this._notifySubscribers(this._value,n)}peek(){return this._value}dispose(){this.flags&z.DISPOSED||(this._subscribers.length=0,this.flags|=z.DISPOSED,this._value=void 0,this._pendingOldValue=void 0,this._notifyTask=void 0)}}function Bt(e,t={}){return new Be(e,t.sync??!1)}class je{constructor(t=50,n=256,s=!1){this.limit=t,this.capacity=n,this.pool=[],this.stats=null,this.stats=R||s?{acquired:0,released:0,rejected:{frozen:0,tooLarge:0,poolFull:0}}:null}acquire(){return this.stats&&this.stats.acquired++,this.pool.pop()??[]}release(t,n){if(!(n&&t===n)){if(t.length>this.capacity){this.stats&&this.stats.rejected.tooLarge++;return}if(this.pool.length>=this.limit){this.stats&&this.stats.rejected.poolFull++;return}if(Object.isFrozen(t)){this.stats&&this.stats.rejected.frozen++;return}t.length=0,this.pool.push(t),this.stats&&this.stats.released++}}getStats(){if(!this.stats)return null;const{acquired:t,released:n,rejected:s}=this.stats,i=t-n-(s.frozen+s.tooLarge+s.poolFull);return{acquired:t,released:n,rejected:{...s},leaked:i,poolSize:this.pool.length}}reset(){this.pool.length=0,this.stats&&(this.stats={acquired:0,released:0,rejected:{frozen:0,tooLarge:0,poolFull:0}})}}const P=Object.freeze([]),V=new je;function fe(e){return e!==null&&typeof e=="object"&&$t in e}function de(e){return e!==null&&typeof e=="object"&&le in e}function _e(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var Wt,Yt,Kt;const ze=3,He=Number.MAX_SAFE_INTEGER-1,{IDLE:Et,DIRTY:nt,PENDING:Ct,RESOLVED:K,REJECTED:ut,HAS_ERROR:gt,RECOMPUTING:at,DISPOSED:Lt,IS_COMPUTED:Ve}=ie;function qe(e){return e&K?_t.RESOLVED:e&Ct?_t.PENDING:e&ut?_t.REJECTED:_t.IDLE}class Xe extends(Kt=ae,Yt=$t,Wt=le,Kt){constructor(t,n={}){if(typeof t!="function")throw new H(S.COMPUTED_MUST_BE_FUNCTION);super(),this[Yt]=!0,this[Wt]=!0,this._error=null,this._promiseId=0,this._subscribers=[],this._links=P,this._asyncStartAggregateVersion=0,this._asyncRetryCount=0,this._trackEpoch=-1,this._trackLinks=P,this._trackCount=0,this._value=void 0,this.flags=Ve|nt|Et,this._equal=n.equal??Object.is,this._fn=t,this._defaultValue="defaultValue"in n?n.defaultValue:Ot,this._onError=n.onError??null;const s=n.maxAsyncRetries;if(this._maxAsyncRetries=s!=null&&s>=0?s:ze,Z.attachDebugInfo(this,"computed",this.id),n.lazy===!1)try{this._recompute()}catch{}}_track(){const t=M.current;t&&re(this,t,this._subscribers)}get value(){this._track();const t=this.flags;if((t&(K|nt|Et))===K)return this._value;if(t&Lt)throw new H(S.COMPUTED_DISPOSED);if(t&at){if(this._defaultValue!==Ot)return this._defaultValue;throw new H(S.COMPUTED_CIRCULAR_DEPENDENCY)}if(t&(nt|Et)&&(this._recompute(),this.flags&K))return this._value;const n=this._defaultValue,s=n!==Ot;if(this.flags&Ct){if(s)return n;throw new H(S.COMPUTED_ASYNC_PENDING_NO_DEFAULT)}if(this.flags&ut){if(this._error?.recoverable&&s)return n;throw this._error}return this._value}peek(){return this._value}get state(){return this._track(),qe(this.flags)}get hasError(){if(this._track(),this.flags&(ut|gt))return!0;const t=this._links;for(let n=0,s=t.length;n<s;n++){const i=t[n]?.node;if(i&&i.flags>)return!0}return!1}get isValid(){return!this.hasError}get errors(){if(this._track(),!this.hasError)return Le;const t=[];this._error&&t.push(this._error);const n=this._links;for(let s=0,i=n.length;s<i;s++){const o=n[s].node;if(o.flags>){const r=o;if(r.errors){const c=r.errors;for(let a=0;a<c.length;a++){const l=c[a];l&&t.indexOf(l)===-1&&t.push(l)}}}}return Object.freeze(t)}get lastError(){return this._track(),this._error}get isPending(){return this._track(),(this.flags&Ct)!==0}get isResolved(){return this._track(),(this.flags&K)!==0}invalidate(){this._markDirty()}dispose(){if(this.flags&Lt)return;const t=this._links;if(t!==P){for(let n=0,s=t.length;n<s;n++)t[n].unsub?.();V.release(t),this._links=P}this._subscribers.length=0,this.flags=Lt|nt|Et,this._error=null,this._value=void 0}addDependency(t){if(t._lastSeenEpoch!==this._trackEpoch){if(t._lastSeenEpoch=this._trackEpoch,this._trackCount<this._trackLinks.length){const n=this._trackLinks[this._trackCount];n.node=t,n.version=t.version}else this._trackLinks.push(new bt(t,t.version));this._trackCount++}}_recompute(){if(this.flags&at)return;this.flags|=at;const t=this._links;this._trackEpoch=Pt(),this._trackLinks=V.acquire(),this._trackCount=0;let n=!1;try{const s=M.run(this,this._fn);this._trackLinks.length=this._trackCount,Vt(this._trackLinks,t,this),this._links=this._trackLinks,n=!0,_e(s)?this._handleAsyncComputation(s):this._finalizeResolution(s)}catch(s){if(!n)try{this._trackLinks.length=this._trackCount,Vt(this._trackLinks,t,this),this._links=this._trackLinks,n=!0}catch(i){R&&console.warn("[atom-effect] _commitDeps failed during error recovery:",i)}this._handleError(s,S.COMPUTED_COMPUTATION_FAILED,!0)}finally{n&&t!==P?V.release(t):n||V.release(this._trackLinks),this._trackEpoch=-1,this._trackLinks=P,this._trackCount=0,this.flags&=~at}}_handleAsyncComputation(t){this.flags=(this.flags|Ct)&-217,this._notifySubscribers(void 0,void 0),this._asyncStartAggregateVersion=this._captureVersionSnapshot(),this._asyncRetryCount=0,this._promiseId=(this._promiseId+1)%He;const n=this._promiseId;t.then(s=>{if(n===this._promiseId){if(this._captureVersionSnapshot()!==this._asyncStartAggregateVersion)return this._asyncRetryCount++<this._maxAsyncRetries?this._markDirty():this._handleError(new H(`Async drift threshold exceeded after ${this._maxAsyncRetries} retries.`),S.COMPUTED_ASYNC_COMPUTATION_FAILED);this._finalizeResolution(s),this._notifySubscribers(s,void 0)}},s=>n===this._promiseId&&this._handleError(s,S.COMPUTED_ASYNC_COMPUTATION_FAILED))}_captureVersionSnapshot(){let t=0;const n=this._links;for(let s=0,i=n.length;s<i;s++)t=(t<<5)-t+n[s].node.version|0;return t}_handleError(t,n,s=!1){const i=st(t,H,n);if(!s&&!(this.flags&ut)&&(this.version=Rt(this.version)),this._error=i,this.flags=this.flags&-121|ut|gt,this._onError)try{this._onError(i)}catch(o){console.error(S.CALLBACK_ERROR_IN_ERROR_HANDLER,o)}if(s)throw i;this._notifySubscribers(void 0,void 0)}_finalizeResolution(t){(!(this.flags&K)||!this._equal(this._value,t))&&(this.version=Rt(this.version)),this._value=t,this._error=null,this.flags=(this.flags|K)&-697}execute(){this._markDirty()}_markDirty(){this.flags&(at|nt)||(this.flags|=nt,this._notifySubscribers(void 0,void 0))}}function jt(e,t={}){return new Xe(e,t)}var Jt,Zt;class Qe extends(Zt=ce,Jt=$e,Zt){constructor(t,n={}){super(),this[Jt]=!0,this._cleanup=null,this._links=P,this._nextLinks=null,this._prevLinks=null,this._currentEpoch=-1,this._lastFlushEpoch=-1,this._executionsInEpoch=0,this._executionCount=0,this._windowStart=0,this._windowCount=0,this._execId=0,this._fn=t,this._onError=n.onError??null,this._sync=n.sync??!1,this._maxExecutions=n.maxExecutionsPerSecond??J.MAX_EXECUTIONS_PER_SECOND,this._maxExecutionsPerFlush=n.maxExecutionsPerFlush??J.MAX_EXECUTIONS_PER_EFFECT,this._trackModifications=n.trackModifications??!1,Z.attachDebugInfo(this,"effect",this.id)}run(){if(this.flags&F.DISPOSED)throw new Y(S.EFFECT_DISPOSED);this.execute(!0)}dispose(){this.flags&F.DISPOSED||(this.flags|=F.DISPOSED,this._execCleanup(),this._unsubLinks(this._links),this._links!==P&&V.release(this._links),this._links=P,this._executeTask=void 0)}addDependency(t){if(!(this.flags&F.EXECUTING)||t._lastSeenEpoch===this._currentEpoch)return;t._lastSeenEpoch=this._currentEpoch;const n=this._nextLinks,s=this._prevLinks;if(s)for(let i=0,o=s.length;i<o;i++){const r=s[i];if(r&&r.node===t&&r.unsub){n.push(new bt(t,t.version,r.unsub)),r.unsub=void 0;return}}try{const i=t.subscribe(()=>{if(this._trackModifications&&this.flags&F.EXECUTING&&(t._modifiedAtEpoch=this._currentEpoch),this._sync)return this.execute();this._executeTask??=()=>this.execute(),ht.schedule(this._executeTask)});n.push(new bt(t,t.version,i))}catch(i){const o=st(i,Y,S.EFFECT_EXECUTION_FAILED);if(console.error(o),this._onError)try{this._onError(o)}catch{}n.push(new bt(t,t.version,void 0))}}execute(t=!1){if(this.flags&(F.DISPOSED|F.EXECUTING)||!t&&this._links.length>0&&!this._isDirty())return;this._checkInfiniteLoops(),this.flags|=F.EXECUTING,this._execCleanup();const n=this._links;this._prevLinks=n!==P?n:null;const s=V.acquire();this._nextLinks=s,this._currentEpoch=Pt();let i=!1;try{const o=M.run(this,this._fn);if(this._links=s,i=!0,this._trackModifications&&Z.enabled){const r=this._currentEpoch;for(let c=0,a=s.length;c<a;c++){const l=s[c].node;l._modifiedAtEpoch===r&&Z.warn(!0,`Effect is reading a dependency (${Z.getDebugName(l)||"unknown"}) that it just modified. Infinite loop may occur`)}}_e(o)?this._handleAsyncResult(o):this._cleanup=typeof o=="function"?o:null}catch(o){i=!0,this._handleExecutionError(o),this._cleanup=null}finally{this._finalizeDependencies(i,n,s),this.flags&=-9}}_handleAsyncResult(t){const n=++this._execId;t.then(s=>{if(n!==this._execId||this.flags&F.DISPOSED){if(typeof s=="function")try{s()}catch(i){this._handleExecutionError(i,S.EFFECT_CLEANUP_FAILED)}return}typeof s=="function"&&(this._cleanup=s)},s=>n===this._execId&&this._handleExecutionError(s))}_finalizeDependencies(t,n,s){if(this._nextLinks=null,t){const i=this._prevLinks;if(i)for(let o=0,r=i.length;o<r;o++)i[o]?.unsub?.();n!==P&&V.release(n)}else this._unsubLinks(s),V.release(s);this._prevLinks=null}_unsubLinks(t){for(let n=0,s=t.length;n<s;n++)t[n]?.unsub?.()}_isDirty(){const t=this._links,n=M.current;M.current=null;try{for(let s=0,i=t.length;s<i;s++){const o=t[s],r=o.node;if(r.flags&ie.IS_COMPUTED)try{r.value}catch{return R&&console.warn(`[atom-effect] Dependency #${r.id} threw during dirty check`),!0}if(r.version!==o.version)return!0}return!1}finally{M.current=n}}_execCleanup(){if(this._cleanup){try{this._cleanup()}catch(t){this._handleExecutionError(t,S.EFFECT_CLEANUP_FAILED)}this._cleanup=null}}_checkInfiniteLoops(){const t=Fe();if(this._lastFlushEpoch!==t&&(this._lastFlushEpoch=t,this._executionsInEpoch=0),++this._executionsInEpoch>this._maxExecutionsPerFlush&&this._throwInfiniteLoopError("per-effect"),Pe()>J.MAX_EXECUTIONS_PER_FLUSH&&this._throwInfiniteLoopError("global"),this._executionCount++,R&&Number.isFinite(this._maxExecutions)){const n=Date.now();if(n-this._windowStart>=1e3)this._windowStart=n,this._windowCount=1;else if(++this._windowCount>this._maxExecutions){const s=new Y(S.EFFECT_FREQUENCY_LIMIT_EXCEEDED);throw this.dispose(),this._handleExecutionError(s),s}}}get isDisposed(){return(this.flags&F.DISPOSED)!==0}get executionCount(){return this._executionCount}get isExecuting(){return(this.flags&F.EXECUTING)!==0}_throwInfiniteLoopError(t){const n=new Y(`Infinite loop detected (${t}): effect executed ${this._executionsInEpoch} times in current flush. Total executions in flush: ${Mt}`);throw this.dispose(),console.error(n),n}_handleExecutionError(t,n=S.EFFECT_EXECUTION_FAILED){const s=st(t,Y,n);if(console.error(s),this._onError)try{this._onError(s)}catch(i){console.error(st(i,Y,S.CALLBACK_ERROR_IN_ERROR_HANDLER))}}}function q(e,t={}){if(typeof e!="function")throw new Y(S.EFFECT_MUST_BE_FUNCTION);const n=new Qe(e,t);return n.execute(),n}function Dt(e){if(typeof e!="function")throw new TypeError("Batch callback must be a function");ht.startBatch();try{return e()}finally{ht.endBatch()}}function pe(e){return fe(e)||de(e)}function Tt(e){if(!e)return"unknown";const t="jquery"in e?e[0]:e;if(!t)return"unknown";const n=t.id;if(n&&typeof n=="string")return`#${n}`;const s=t.tagName.toLowerCase(),i=t.classList;if(i&&i.length>0){let o=s;for(let r=0,c=i.length;r<c;r++){const a=i[r];a&&(o+=`.${a}`)}return o}return s}function It(e){let t=String(e??"");t=t.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,""),t=t.replace(/<\?[\s\S]*?\?>/g,"");const n=/(<(script|iframe|object|embed|base|meta|applet|noscript)\b[^>]*>([\s\S]*?)<\/\2>|<(script|iframe|object|embed|base|meta|applet|noscript)\b[^>]*\/?>)/gim;let s;do s=t,t=t.replace(n,"");while(t!==s);const i=/(j\s*a\s*v\s*a\s*s\s*c\s*r\s*i\s*p\s*t|v\s*b\s*s\s*c\s*r\s*i\s*p\s*t)\s*:/gi;t=t.replace(i,"data-unsafe-protocol:");const o=/data\s*:\s*(?:text\/html|application\/javascript|text\/javascript|text\/vbscript|text\/xml|application\/xhtml\+xml)/gim;return t=t.replace(o,"data-unsafe-protocol:"),t=t.replace(/\bon\w+\s*=/gim,"data-unsafe-attr="),t=t.replace(/expression\s*\(/gim,"data-unsafe-css(").replace(/behavior\s*:/gim,"data-unsafe-css:"),t}const Ge=new Set(["href","src","action","formaction","xlink:href","data","poster","srcset","background","cite","longdesc","profile","usemap","classid","codebase"]),We=/^\s*(?:javascript|vbscript)\s*:/i;function Ye(e,t){return Ge.has(e.toLowerCase())?We.test(t):!1}function Ke(e){return e.toLowerCase().includes("url(")?/url\s*\(\s*(?:["']?\s*)?(?:javascript|vbscript)\s*:/i.test(e):!1}function Je(e,t){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;const i=t;for(let o=0;o<n.length;o++){const r=n[o];if(e[r]!==i[r])return!1}return!0}function Ze(e){const t=e.length;if(t===0)return new Int32Array(0);const n=new Int32Array(t),s=new Int32Array(t);let i=0;for(let r=0;r<t;r++){const c=e[r];if(c===void 0||c===-1)continue;const a=i>0?s[i-1]:void 0;if(i===0||a!==void 0&&(e[a]??-1)<c){n[r]=a??-1,s[i++]=r;continue}let l=0,p=i-1;for(;l<p;){const b=l+p>>>1,T=s[b];T!==void 0&&(e[T]??-1)<c?l=b+1:p=b}const C=s[l];C!==void 0&&c<(e[C]??Number.MAX_SAFE_INTEGER)&&(l>0&&(n[r]=s[l-1]??-1),s[l]=r)}const o=new Int32Array(i);if(i>0){let r=s[i-1];for(let c=i-1;c>=0&&r!==void 0&&r!==-1;c--)o[c]=r,r=n[r]}return o}function tn(){if(typeof window<"u"){const e=window.__ATOM_DEBUG__;if(typeof e=="boolean")return e}return!1}let W=tn();const y={get enabled(){return W},set enabled(e){W=e},log(e,...t){W&&console.log(`[atom-effect-jquery] ${e}:`,...t)},atomChanged(e,t,n){W&&console.log(`[atom-effect-jquery] Atom "${e??"anonymous"}" changed:`,t,"→",n)},domUpdated(e,t,n){W&&(console.log(`[atom-effect-jquery] DOM updated: ${Tt(e)}.${t} =`,n),nn(e))},cleanup(e){W&&console.log(`[atom-effect-jquery] Cleanup: ${e}`)},warn(...e){W&&console.warn("[atom-effect-jquery]",...e)}},Ut="atom-debug-highlight";let te=!1;function en(){if(te)return;te=!0;const e=document.createElement("style");e.textContent=`.${Ut}{outline:2px solid rgba(255,68,68,0.8);outline-offset:1px;transition:outline 0.5s ease-out}`,document.head.appendChild(e)}const xt=new WeakMap;function nn(e){const t="jquery"in e?e[0]:e;if(!t||!t.isConnected)return;en();const n=xt.get(t);n&&clearTimeout(n),t.classList.add(Ut),xt.set(t,setTimeout(()=>{t.classList.remove(Ut),xt.delete(t)},600))}function Ee(e,t={}){return Bt(e,t)}Object.defineProperty(Ee,"debug",{get(){return y.enabled},set(e){y.enabled=e}});function sn(){return new Promise(e=>setTimeout(e,0))}h.extend({atom:Ee,computed:jt,effect:q,batch:Dt,untracked:he,isAtom:fe,isComputed:de,isReactive:pe,nextTick:sn});const mt="_aes-bound";class on{constructor(){ct(this,"records",new WeakMap);ct(this,"boundElements",new WeakSet);ct(this,"preservedNodes",new WeakSet);ct(this,"ignoredNodes",new WeakSet)}keep(t){this.preservedNodes.add(t)}isKept(t){return this.preservedNodes.has(t)}markIgnored(t){this.ignoredNodes.add(t)}isIgnored(t){return this.ignoredNodes.has(t)}_getOrCreateRecord(t){let n=this.records.get(t);return n||(n={},this.records.set(t,n),this.boundElements.has(t)||(this.boundElements.add(t),t.classList.add(mt))),n}trackEffect(t,n){const s=this._getOrCreateRecord(t);s.effects??=[],s.effects.push(n)}trackCleanup(t,n){const s=this._getOrCreateRecord(t);s.cleanups??=[],s.cleanups.push(n)}hasBind(t){return this.boundElements.has(t)}cleanup(t){if(!this.boundElements.delete(t))return;const n=this.records.get(t);if(!n)return;this.records.delete(t),this.preservedNodes.delete(t),this.ignoredNodes.delete(t),t.classList.remove(mt),y.enabled&&y.cleanup(Tt(t));const s=n.effects;if(s)for(let o=0,r=s.length;o<r;o++)try{s[o]?.dispose()}catch(c){y.warn("Effect dispose error:",c)}const i=n.cleanups;if(i)for(let o=0,r=i.length;o<r;o++)try{i[o]?.()}catch(c){y.warn("Cleanup error:",c)}}cleanupDescendants(t){const n=t.querySelectorAll(`.${mt}`);for(let s=0,i=n.length;s<i;s++){const o=n[s];o&&this.boundElements.has(o)?this.cleanup(o):o&&o.classList.remove(mt)}}cleanupTree(t){this.cleanupDescendants(t),this.cleanup(t)}}const m=new on;let lt=null;function ge(e=document.body){lt||(lt=new MutationObserver(t=>{for(let n=0,s=t.length;n<s;n++){const i=t[n]?.removedNodes;if(!i)continue;const o=i.length;if(o!==0)for(let r=0;r<o;r++){const c=i[r];c.nodeType===1&&(c.isConnected||m.isKept(c)||m.isIgnored(c)||m.cleanupTree(c))}}}),lt.observe(e,{childList:!0,subtree:!0}))}function rn(){lt?.disconnect(),lt=null}function X(e,t,n,s){pe(t)?m.trackEffect(e,q(()=>{const i=t.value;n(i),y.domUpdated(h(e),s,i)})):(n(t),y.enabled&&y.domUpdated(h(e),s,t))}var k=(e=>(e[e.None=0]="None",e[e.Focused=1]="Focused",e[e.Composing=2]="Composing",e[e.SyncingToAtom=4]="SyncingToAtom",e[e.SyncingToDom=8]="SyncingToDom",e[e.Busy=14]="Busy",e))(k||{});function me(){return{timeoutId:null,flags:0}}function cn(e,t,n={}){const{debounce:s,event:i="input",parse:o=I=>I,format:r=I=>String(I??""),equal:c=Object.is}=n,a=me(),l=e[0],p=()=>{if(!(a.flags&k.Busy)){a.flags|=k.SyncingToAtom;try{const I=l.value,v=o(I);c(t.value,v)||(t.value=v)}finally{a.flags&=~k.SyncingToAtom}}},C=()=>{a.timeoutId&&(clearTimeout(a.timeoutId),a.timeoutId=null,p()),a.flags&=~k.Focused;const I=r(t.value);l.value!==I&&(l.value=I)},b=()=>{a.flags&k.Busy||(s?(a.timeoutId&&clearTimeout(a.timeoutId),a.timeoutId=setTimeout(p,s)):p())},T={compositionstart:()=>{a.flags|=k.Composing},compositionend:()=>{a.flags&=~k.Composing,p()},focus:()=>{a.flags|=k.Focused},blur:C,[i]:b,change:b};return e.on(T),{effect:()=>{const I=t.value,v=r(I),L=l.value;if(L!==v&&!(a.flags&k.Focused&&c(o(L),I))){a.flags|=k.SyncingToDom;try{if(a.flags&k.Focused){const{selectionStart:tt,selectionEnd:ot}=l;l.value=v;const j=v.length;l.setSelectionRange(Math.min(tt??0,j),Math.min(ot??0,j))}else l.value=v;y.domUpdated(e,"val",v)}finally{a.flags&=~k.SyncingToDom}}},cleanup:()=>{e.off(T),a.timeoutId&&clearTimeout(a.timeoutId)}}}const ee=Object.create(null);function an(e){let t=ee[e];return t||(t=e.includes("-")?e.replace(/-./g,n=>n[1].toUpperCase()):e,ee[e]=t,t)}function $(e){let t=null;return{get $el(){return t||(t=h(e)),t},el:e,trackCleanup:n=>m.trackCleanup(e,n)}}function un(e,t){const n=e.el;X(n,t,s=>{const i=typeof s=="string"?s:String(s??"");n.textContent!==i&&(n.textContent=i)},"text")}function ye(e,t){const n=e.el;X(n,t,s=>{const i=String(s??""),o=It(i);o!==i&&console.warn("[atomBind] Unsafe content neutralized during sanitization."),n.innerHTML!==o&&(n.innerHTML=o)},"html")}function be(e,t){for(const n in t)X(e.el,t[n],s=>{e.el.classList.toggle(n,!!s)},`class.${n}`)}function Ce(e,t){const n=e.el,s=n.style;for(const i in t){const o=t[i];if(o===void 0)continue;const r=an(i),c=Array.isArray(o),a=c?o[0]:o,l=c?o[1]:"";X(n,a,p=>{const C=l?`${p}${l}`:String(p);if(Ke(C)){console.warn(`[atomBind] Blocked dangerous value in "${i}" property.`);return}s[r]=C},`css.${i}`)}}function Ie(e,t){const n=e.el;for(const s in t){const i=s.charCodeAt(0);if((i===111||i===79)&&(s.charCodeAt(1)===110||s.charCodeAt(1)===78)){console.warn(`[atomBind] Blocked setting dangerous event handler attribute "${s}".`);continue}X(n,t[s],o=>{if(o==null||o===!1){n.removeAttribute(s);return}const r=o===!0?s:String(o);if(Ye(s,r)){console.warn(`[atomBind] Blocked dangerous protocol in "${s}" attribute.`);return}n.getAttribute(s)!==r&&n.setAttribute(s,r)},`attr.${s}`)}}const ln=["innerHTML","outerHTML"];function Se(e,t){const n=e.el;for(const s in t){if(ln.includes(s)){console.warn(`[atomBind] Blocked setting dangerous property "${s}". Use html binding for sanitized HTML.`);continue}X(e.el,t[s],i=>{n[s]!==i&&(n[s]=i)},`prop.${s}`)}}function wt(e,t,n,s){const i=e.el;X(i,t,o=>{const r=n?!o:!!o;i.style.display=r?"":"none",y.enabled&&y.domUpdated(i,s,o)},s)}function ve(e,t){const n=e.el.tagName.toLowerCase();if(n!=="input"&&n!=="select"&&n!=="textarea"){console.warn(`[atomBind] Val binding used on non-input element <${n}>.`);return}const s=Array.isArray(t),{effect:i,cleanup:o}=cn(e.$el,s?t[0]:t,s?t[1]:{});m.trackEffect(e.el,q(i)),e.trackCleanup(o)}function we(e,t){const n=e.el,s=e.$el,i=me(),o=()=>{if(i.flags&k.Busy)return;const c=n.checked;t.value!==c&&(t.value=c)};s.on("change",o),e.trackCleanup(()=>s.off("change",o));const r=q(()=>{i.flags|=k.SyncingToDom;const c=!!t.value;n.checked!==c&&(n.checked=c,y.enabled&&y.domUpdated(s,"checked",c)),i.flags&=~k.SyncingToDom});m.trackEffect(n,r)}function hn(e,t){for(const n in t){const s=t[n];if(typeof s!="function")continue;const i=o=>{Dt(()=>s.call(e.el,h.Event(o.type,{originalEvent:o})))};e.el.addEventListener(n,i),e.trackCleanup(()=>e.el.removeEventListener(n,i))}}h.fn.atomBind=function(e){return this.each(function(){const t=$(this);e.text!==void 0&&un(t,e.text),e.html!==void 0&&ye(t,e.html),e.class&&be(t,e.class),e.css&&Ce(t,e.css),e.attr&&Ie(t,e.attr),e.prop&&Se(t,e.prop),e.show!==void 0&&wt(t,e.show,!1,"show"),e.hide!==void 0&&wt(t,e.hide,!0,"hide"),e.val!==void 0&&ve(t,e.val),e.checked!==void 0&&we(t,e.checked),e.on&&hn(t,e.on)})};h.fn.atomText=function(e,t){return this.each(function(){const n=h(this);X(this,e,t?i=>n.text(t(i)):i=>n.text(String(i??"")),"text")})};h.fn.atomHtml=function(e){return this.each(function(){ye($(this),e)})};h.fn.atomClass=function(e,t){return this.each(function(){be($(this),{[e]:t})})};h.fn.atomCss=function(e,t,n){return this.each(function(){Ce($(this),{[e]:n?[t,n]:t})})};h.fn.atomAttr=function(e,t){return this.each(function(){Ie($(this),{[e]:t})})};h.fn.atomProp=function(e,t){return this.each(function(){Se($(this),{[e]:t})})};h.fn.atomShow=function(e){return this.each(function(){wt($(this),e,!1,"show")})};h.fn.atomHide=function(e){return this.each(function(){wt($(this),e,!0,"hide")})};h.fn.atomVal=function(e,t={}){return this.each(function(){ve($(this),t&&Object.keys(t).length>0?[e,t]:e)})};h.fn.atomChecked=function(e){return this.each(function(){we($(this),e)})};h.fn.atomOn=function(e,t){return this.each(function(){const n=h(this);n.on(e,t),m.trackCleanup(this,()=>n.off(e,t))})};h.fn.atomUnbind=function(){return this.each(function(){m.cleanupTree(this)})};h.fn.atomList=function(e,t){const{key:n,render:s,bind:i,update:o,onAdd:r,onRemove:c,empty:a}=t,l=typeof n=="function"?n:(p,C)=>p[n];return this.each(function(){const p=h(this),C=Tt(this),b=new Map,T=new Set;let O=[],A=null;const I=q(()=>{const v=e.value,L=v.length;if(L===0){if(a&&!A){const d=typeof a=="string"?It(a):a;A=h(d).appendTo(p)}}else A&&(A.remove(),A=null);if(L===0&&b.size===0){O=[];return}y.log("list",`${C} updating with ${L} items`);const tt=new Map,ot=O.length;for(let d=0;d<ot;d++)tt.set(O[d],d);const j=new Array(L),rt=new Set,ft=new Int32Array(L);for(let d=0;d<L;d++){const N=v[d],g=l(N,d);rt.has(g)&&console.warn(`[atomList] Duplicate key "${g}" at index ${d}.`),j[d]=g,rt.add(g),ft[d]=tt.get(g)??-1}if(b.size>0)for(const[d,N]of b){if(rt.has(d)||T.has(d))continue;const g=()=>{N.$el.remove(),N.$el[0]&&m.cleanup(N.$el[0]),T.delete(d),y.log("list",`${C} removed item:`,d)};if(b.delete(d),T.add(d),c){const w=c(N.$el);w instanceof Promise?w.then(g):g()}else g()}if(L===0){O=[];return}const dt=Ze(ft);let U=dt.length-1,x=null;for(let d=L-1;d>=0;d--){const N=j[d],g=v[d],w=b.get(N);if(w){const B=w.item;w.item=g;const et=w.$el[0];if(!et)continue;if(o)o(w.$el,g,d),y.domUpdated(w.$el,"list.update",g);else if(B!==g&&!Je(B,g)){const u=s(g,d),_=typeof u=="string"?It(u):u,E=h(_),f=x===et;w.$el.replaceWith(E),w.$el=E,i&&i(E,g,d),y.domUpdated(E,"list.render",g),f&&(x=E[0]||null)}if(U>=0&&dt[U]===d)U--;else{const u=w.$el[0];x?.isConnected?x!==u&&w.$el.insertBefore(x):w.$el.appendTo(p)}x=w.$el[0]||null}else{const B=s(g,d),et=typeof B=="string"?It(B):B,u=h(et);b.set(N,{$el:u,item:g}),x?.isConnected?u.insertBefore(x):u.appendTo(p),i&&i(u,g,d),r&&r(u),y.domUpdated(u,"list.add",g),x=u[0]||null}}O=j});m.trackEffect(this,I),m.trackCleanup(this,()=>{b.clear(),T.clear(),O=[],A?.remove()})})};const St=new WeakMap;h.fn.atomMount=function(e,t={}){return this.each(function(){const n=Tt(this),s=St.get(this);s&&(y.log("mount",`${n} unmounting existing component`),s()),y.log("mount",`${n} mounting component`);let i;try{i=e(h(this),t)}catch(r){console.error("[atom-effect-jquery] Mount error:",r);return}const o=()=>{if(St.delete(this)){if(y.log("mount",`${n} full cleanup`),typeof i=="function")try{i()}catch(r){console.error("[atom-effect-jquery] Cleanup error:",r)}m.cleanupTree(this)}};St.set(this,o),m.trackCleanup(this,o)})};h.fn.atomUnmount=function(){return this.each(function(){const e=St.get(this);e&&e()})};const yt="[$.route]";function fn(e){const{target:t,default:n,routes:s,notFound:i,mode:o="hash",basePath:r="",autoBindLinks:c=!1,activeClass:a="active",beforeTransition:l,afterTransition:p}=e,C=o==="history";let b=!1,T=null,O=C?window.location.pathname+window.location.search:window.location.hash;const A=[],I=new Set,v=h(t),L=()=>{if(C){let f=window.location.pathname;return r&&f.startsWith(r)&&(f=f.substring(r.length)),f.replace(/^\//,"")||n}const u=window.location.hash,_=u.indexOf("?");return(_===-1?u.substring(1):u.substring(1,_))||n},tt=()=>{let u;if(C){if(u=window.location.search.substring(1),!u)return{}}else{const f=window.location.hash,D=f.indexOf("?");if(D===-1)return{};u=f.substring(D+1)}const _=new URLSearchParams(u),E=Object.fromEntries(_);if(u.includes("%"))try{decodeURIComponent(u)}catch{console.warn(`${yt} Malformed URI component: ${u}`)}return E},ot=u=>{if(C){const _=`${r.replace(/\/$/,"")}/${u}`;history.pushState(null,"",_),O=_}else{const _=`#${u}`;O=_,window.location.hash=_}},j=()=>{C?history.replaceState(null,"",O):window.location.hash=O},rt=()=>C?window.location.pathname+window.location.search:window.location.hash,ft=u=>{let _=s[u];return!_&&i&&(_=s[i]),_||(console.warn(`${yt} Route "${u}" not found and no notFound route configured`),null)},dt=u=>{const _=document.querySelector(u);if(!_?.content)return console.warn(`${yt} Template "${u}" not found`),!1;const E=_.content.cloneNode(!0);return v.append(E),!0},U=Bt(L()),x=u=>{if(b)return;const _=v[0];if(!_){console.warn(`${yt} Target element "${t}" not found`);return}const E=ft(u);if(!E)return;const f=tt();l&&l(T||u,u),v.empty();let D=f;if(E.onEnter){const Q=E.onEnter(f);Q!==void 0&&(D={...f,...Q})}E.render?E.render(_,u,D):E.template&&dt(E.template),p&&p(T||u,u),T=u},d=u=>{if(b)return;const _=U.value,E=s[_];if(E?.onLeave&&E.onLeave()===!1)return;const f=u||n;ot(f),U.value=f},N=()=>{if(b)return;const u=rt();if(u===O)return;const _=L(),E=U.value;if(E!==_){const f=s[E];if(f?.onLeave&&f.onLeave()===!1){j();return}U.value=_}else x(_);O=u},g=()=>{if(!c)return;const u=f=>{f.preventDefault();const D=f.currentTarget.dataset.route;D!=null&&d(D)};h(document).on("click","[data-route]",u),A.push(()=>{h(document).off("click","[data-route]",u)});const _=f=>{if(I.has(f))return;const D=f.dataset.route;I.add(f);const Q=q(()=>{const G=U.value===D;f.classList.toggle(a,G),G?f.setAttribute("aria-current","page"):f.removeAttribute("aria-current")});m.trackEffect(f,Q),m.trackCleanup(f,()=>{I.delete(f)})};for(const f of document.querySelectorAll("[data-route]"))_(f);const E=new MutationObserver(f=>{for(const D of f)D.type==="childList"&&D.addedNodes.forEach(Q=>{if(Q.nodeType===1){const G=Q;G.matches?.("[data-route]")&&_(G),G.querySelectorAll&&G.querySelectorAll("[data-route]").forEach(De=>_(De))}})});E.observe(document.body,{childList:!0,subtree:!0}),A.push(()=>E.disconnect())},w=()=>{b||(b=!0,A.forEach(u=>u()),A.length=0,I.forEach(u=>m.cleanup(u)),I.clear())},B=C?"popstate":"hashchange";window.addEventListener(B,N),A.push(()=>window.removeEventListener(B,N));const et=q(()=>{x(U.value)});return A.push(()=>et.dispose()),g(),v[0]&&m.trackCleanup(v[0],w),{currentRoute:U,navigate:d,destroy:w}}h.extend({route:fn});function dn(e,t){const{defaultValue:n,transform:s,method:i,headers:o,ajaxOptions:r}=t,c=typeof e=="function"?e:()=>e;return jt(async()=>{const a=c(),l=await h.ajax({...r,url:a,method:i,headers:o});return s?s(l):l},{defaultValue:n,lazy:!1})}h.extend({atomFetch:dn});const kt=new WeakMap;let ne=!1;const se=e=>{let t=kt.get(e);return t||(t=function(...n){return Dt(()=>e.apply(this,n))},kt.set(e,t)),t};function ke(){if(ne)return;ne=!0;const e=h.fn.on,t=h.fn.off,n=h.fn.remove,s=h.fn.empty,i=h.fn.detach;h.fn.remove=function(o){const r=o?this.filter(o):this;for(let c=0,a=r.length;c<a;c++){const l=r[c];l&&(m.cleanupTree(l),m.markIgnored(l))}return n.call(this,o)},h.fn.empty=function(){for(let o=0,r=this.length;o<r;o++){const c=this[o];c&&m.cleanupDescendants(c)}return s.call(this)},h.fn.detach=function(o){const r=o?this.filter(o):this;for(let c=0,a=r.length;c<a;c++){const l=r[c];l&&m.keep(l)}return i.call(this,o)},h.fn.on=function(...o){const r=o[0];if(r&&typeof r=="object"){const c=r,a={};for(const l in c){const p=c[l];p&&(a[l]=se(p))}o[0]=a}else for(let c=o.length-1;c>=0;c--)if(typeof o[c]=="function"){o[c]=se(o[c]);break}return e.apply(this,o)},h.fn.off=function(...o){const r=o[0];if(r&&typeof r=="object"){const c=r,a={};for(const l in c){const p=c[l];p&&(a[l]=kt.get(p)||p)}o[0]=a}else for(let c=o.length-1;c>=0;c--)if(typeof o[c]=="function"){o[c]=kt.get(o[c])||o[c];break}return t.apply(this,o)}}h(()=>{ke(),ge(document.body)});exports.default=h;exports.atom=Bt;exports.batch=Dt;exports.computed=jt;exports.disableAutoCleanup=rn;exports.effect=q;exports.enableAutoCleanup=ge;exports.enablejQueryOverrides=ke;exports.registry=m;exports.untracked=he;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|