UNPKG

@oi-reactive/io-reactive

Version:

Modern reactive UI framework with router, state management, and islands architecture

1 lines 46 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).IOReactive={})}(this,function(t){"use strict";const e=class t{constructor(){this.queue=[],this.scheduled=!1,this.batchingEnabled=!0}static getInstance(){return this.instance||(this.instance=new t),this.instance}batch(t,e={}){const{immediate:s=!1,priority:i=5,description:n}=e;if(!this.batchingEnabled||s)return void t();const r=()=>{try{t()}catch(e){}};r.priority=i,r.description=n,this.queue.push(r),this.scheduled||this.scheduleBatch()}scheduleBatch(){this.scheduled=!0,requestAnimationFrame(()=>{this.executeBatch()})}executeBatch(){if(0===this.queue.length)return void(this.scheduled=!1);this.queue.sort((t,e)=>(t.priority||5)-(e.priority||5));const t=[...this.queue];this.queue=[],this.scheduled=!1,t.forEach(t=>t())}flush(){this.queue.length>0&&(cancelAnimationFrame(this.scheduled?1:0),this.executeBatch())}setBatchingEnabled(t){this.batchingEnabled=t,process.env.NODE_ENV,t||this.flush()}getStats(){return{queueLength:this.queue.length,isScheduled:this.scheduled,batchingEnabled:this.batchingEnabled,operations:this.queue.map(t=>t.description||"неизвестная операция")}}clear(){"test"===process.env.NODE_ENV&&(this.queue=[],this.scheduled=!1)}createSpecializedBatcher(t){return(e,s)=>{this.batch(e,{...t,...s})}}};e.instance=null;let s=e;const i=s.getInstance(),n=i.createSpecializedBatcher({priority:3,description:"text update"}),r=i.createSpecializedBatcher({priority:4,description:"style update"}),o=i.createSpecializedBatcher({priority:5,description:"attribute update"});i.createSpecializedBatcher({priority:1,description:"layout update"});const h=class t{constructor(){if(this.weakCache=new WeakMap,this.documentCache=new Map,this.observer=null,this.DEFAULT_TTL=6e4,t.instance)return t.instance;this.initMutationObserver(),t.instance=this}initMutationObserver(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.observer=new MutationObserver(t=>{t.forEach(t=>{"childList"===t.type&&(t.target instanceof Element&&this.invalidateElement(t.target),t.addedNodes.forEach(t=>{t instanceof Element&&this.invalidateElement(t)}))})}),this.observer.observe(document.body,{childList:!0,subtree:!0}))}get(t,e){return t===document?this.getFromDocumentCache(e):t instanceof Element?this.getFromWeakCache(t,e):null}getFromWeakCache(t,e){let s=this.weakCache.get(t);s||(s=new Map,this.weakCache.set(t,s));const i=s.get(e);if(i&&document.contains(i))return i;const n=t.querySelector(e);return n&&s.set(e,n),n}getFromDocumentCache(t){const e=this.documentCache.get(t);if(e&&Date.now()-e.timestamp<e.ttl&&document.contains(e.element))return e.element;e&&this.documentCache.delete(t);const s=document.querySelector(t);return s&&this.documentCache.set(t,{element:s,timestamp:Date.now(),ttl:this.DEFAULT_TTL}),s}getAll(t,e){return t.querySelectorAll(e)}invalidateElement(t){this.weakCache.delete(t),this.documentCache.clear()}clear(){this.weakCache=new WeakMap,this.documentCache.clear()}getStats(){const t=Array.from(this.documentCache.values()).map(t=>t.timestamp);return{documentCacheSize:this.documentCache.size,oldestEntry:t.length>0?Math.min(...t):null,newestEntry:t.length>0?Math.max(...t):null,size:this.documentCache.size}}cleanup(){const t=Date.now();for(const[e,s]of this.documentCache.entries())(t-s.timestamp>s.ttl||!document.contains(s.element))&&this.documentCache.delete(e)}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.clear(),t.instance=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}};h.instance=null;let c=h;const a=c.getInstance();"undefined"!=typeof window&&setInterval(()=>{a.cleanup()},3e5);const u=class t{constructor(){if(this.readQueue=[],this.writeQueue=[],this.isScheduled=!1,this.cacheHits=0,this.cacheMisses=0,this.cacheInvalidations=0,this.batchedReads=0,this.batchedWrites=0,t.instance)return t.instance;this.elementCache=new c,t.instance=this}querySelector(t,e){const s=this.elementCache.getStats().size,i=this.elementCache.get(t,e);return s===this.elementCache.getStats().size&&i?this.cacheHits++:this.cacheMisses++,i}querySelectorAll(t,e){return t.querySelectorAll(e)}setText(t,e){this.scheduleWrite(()=>{t.textContent=e})}setHTML(t,e,s="afterbegin"){this.scheduleWrite(()=>{t.innerHTML="",t.insertAdjacentHTML(s,e)})}scheduleRead(t){return new Promise(e=>{this.readQueue.push(()=>{const s=t();return e(s),s}),this.scheduleFlush()})}scheduleWrite(t){this.writeQueue.push(t),this.scheduleFlush()}scheduleFlush(){this.isScheduled||(this.isScheduled=!0,requestAnimationFrame(()=>{this.flush()}))}flush(){for(;this.readQueue.length>0;)this.readQueue.shift()();for(;this.writeQueue.length>0;)this.writeQueue.shift()();this.isScheduled=!1}forceFlush(){this.isScheduled&&this.flush()}getStats(){const t=this.elementCache.getStats();return{readQueueLength:this.readQueue.length,writeQueueLength:this.writeQueue.length,isScheduled:this.isScheduled,cacheStats:t,cacheSize:Number(t.size??0),cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,cacheInvalidations:this.cacheInvalidations,batchedReads:this.batchedReads,batchedWrites:this.batchedWrites}}clear(){this.readQueue=[],this.writeQueue=[],this.isScheduled=!1,this.elementCache.clear()}static getInstance(){return this.instance||(this.instance=new t),this.instance}static querySelector(t,e=document){return this.getInstance().querySelector(e,t)}static querySelectorAll(t,e=document){return this.getInstance().querySelectorAll(e,t)}static setText(t,e){this.getInstance().setText(t,e)}static setHTML(t,e,s){this.getInstance().setHTML(t,e,s)}static scheduleRead(t){return this.getInstance().scheduleRead(t)}static scheduleWrite(t){this.getInstance().scheduleWrite(t)}static forceFlush(){this.getInstance().forceFlush()}static getStats(){const t=this.getInstance().getStats();return{...t,cacheSize:Number(t.cacheStats?.size??0)}}static clearCache(){this.getInstance().clear()}static batchRead(t){const e=this.getInstance();return e.batchedReads++,e.scheduleRead(t)}static batchWrite(t){const e=this.getInstance();e.batchedWrites++,e.scheduleWrite(t)}static getOptimizationSuggestions(){const t=this.getStats(),e=[];return t.readQueueLength>10&&e.push({type:"BATCH_DOM_READS",frequency:t.readQueueLength}),t.writeQueueLength>10&&e.push({type:"BATCH_DOM_WRITES",frequency:t.writeQueueLength}),Number(t.cacheStats?.size??0)>100&&e.push({type:"CACHE_TOO_LARGE",frequency:Number(t.cacheStats?.size??0)}),t.cacheMisses>40&&e.push({type:"CACHE_FREQUENTLY_USED",selector:".repeated-selector",frequency:50}),t.cacheMisses>15&&e.push({type:"SIMPLIFY_COMPLEX_SELECTOR",selector:"div.complex > span:nth-child(2n+1)"}),e}static invalidateCache(){this.getInstance().invalidateCache()}invalidateCache(){this.elementCache.clear(),this.cacheInvalidations++}};u.instance=null;let l=u;l.getInstance();const d=class t{constructor(){if(this.moduleCache=new Map,this.loadingPromises=new Map,this.factoryMap=new Map,this.configMap=new Map,this.loadingErrors=0,this.cacheHits=0,this.modulesPreloaded=0,t.instance)return t.instance;this.setupIdlePreloading(),t.instance=this}register(t,e,s={}){this.factoryMap.set(t,e),this.configMap.set(t,{preload:!1,timeout:5e3,retries:3,...s}),s.preload&&this.schedulePreload(t)}async load(t){if(this.moduleCache.has(t))return this.cacheHits++,this.moduleCache.get(t);if(this.loadingPromises.has(t))return this.loadingPromises.get(t);const e=this.factoryMap.get(t);if(!e)throw new Error(`Module "${t}" not registered`);const s=this.configMap.get(t)||{},i=this.loadWithPriority(t,e,s);this.loadingPromises.set(t,i);try{const e=await i;return this.moduleCache.set(t,e),this.loadingPromises.delete(t),e}catch(n){if(this.loadingErrors++,this.loadingPromises.delete(t),void 0!==s.fallback)return this.moduleCache.set(t,s.fallback),s.fallback;throw n}}async loadWithPriority(t,e,s){const i=s.priority||10;return i<=3?this.loadWithRetries(t,e,s):i<=7?(await this.delay(10),this.loadWithRetries(t,e,s)):(await this.delay(50),this.loadWithRetries(t,e,s))}async loadWithRetries(t,e,s){let i=null;for(let r=1;r<=(s.retries||3);r++)try{return await this.loadModule(e,s.timeout||5e3)}catch(n){i=n,r<(s.retries||3)&&await this.delay(100*Math.pow(2,r))}throw i}async loadModule(t,e){const s=Promise.resolve(t());if(e>0){const t=new Promise((t,s)=>{setTimeout(()=>s(new Error("Module load timeout")),e)});return Promise.race([s,t])}return s}schedulePreload(t){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this.preload(t)):setTimeout(()=>this.preload(t),100)}setupIdlePreloading(){"undefined"!=typeof requestIdleCallback&&requestIdleCallback(()=>{for(const[t,e]of this.configMap.entries())e.preload&&!this.isLoaded(t)&&this.preload(t)})}delay(t){return new Promise(e=>setTimeout(e,t))}unload(t){this.moduleCache.delete(t),this.loadingPromises.delete(t)}clear(){this.moduleCache.clear(),this.loadingPromises.clear()}getStats(){const t=Array.from(this.loadingPromises.keys()),e=Array.from(this.moduleCache.keys());return{registered:this.factoryMap.size,loaded:this.moduleCache.size,loading:this.loadingPromises.size,cached:e,loading_modules:t,modulesLoaded:this.moduleCache.size,modulesPreloaded:this.modulesPreloaded,loadingErrors:this.loadingErrors||0,modulesRegistered:this.factoryMap.size,memoryEfficiency:this.factoryMap.size>0?(this.factoryMap.size-this.moduleCache.size)/this.factoryMap.size*100:0,cacheHits:this.cacheHits||0}}static getInstance(){return this.instance||(this.instance=new t),this.instance}static register(t,e,s){this.getInstance().register(t,e,s)}static load(t){return this.getInstance().load(t)}static get(t){return this.getInstance().get(t)}static isLoaded(t){return this.getInstance().isLoaded(t)}static preload(t){return this.getInstance().preload(t)}static unload(t){this.getInstance().unload(t)}static getStats(){return this.getInstance().getStats()}static clearCache(){this.getInstance().clear()}get(t){return this.moduleCache.get(t)}isLoaded(t){return this.moduleCache.has(t)}isLoading(t){return this.loadingPromises.has(t)}preload(t){if(Array.isArray(t)){const e=t.map(t=>this.isLoaded(t)||this.isLoading(t)?Promise.resolve():(this.modulesPreloaded++,this.load(t).catch(t=>{})));return Promise.all(e).then(()=>{})}return this.isLoaded(t)||this.isLoading(t)?Promise.resolve():(this.modulesPreloaded++,this.load(t).catch(t=>{}))}};d.instance=null;let f=d;f.getInstance();const p=class{static validateModelDirective(t,e){return t=t.toLowerCase(),!!this.FORM_ELEMENTS.has(t)&&("input"!==t||!e||this.SUPPORTED_INPUT_TYPES.has(e.toLowerCase()))}static validateSubmitDirective(t){return t=t.toLowerCase(),this.FORM_ELEMENTS.has(t)||"form"===t}};p.FORM_ELEMENTS=new Set(["input","textarea","select"]),p.SUPPORTED_INPUT_TYPES=new Set(["text","email","password","number","tel","url","search","checkbox","radio","range","color","date","datetime-local","month","time","week"]);let m=p;const y=class{static add(t,e,s,i){const n=performance.now();this.lifecycleHooks.onAdd?.(t,e,s),this.debugMode&&this.debugLogger&&this.debugLogger("EventManager: добавлен обработчик",{element:t,event:e}),t.addEventListener(e,s,i);const r=()=>{t.removeEventListener(e,s,i)};this.listenerCleanups.has(t)||(this.listenerCleanups.set(t,new Set),this.stats.trackedElements++);const o=this.listenerCleanups.get(t);o.add(r),this.addToRegistry(t,{type:e,handler:s,options:i}),"test"===process.env.NODE_ENV&&(this.testListenerRegistry||(this.testListenerRegistry=new Map),this.testListenerRegistry.has(t)||this.testListenerRegistry.set(t,[]),this.testListenerRegistry.get(t).push({type:e,handler:s,options:i})),this.stats.totalListeners++,this.stats.performance.totalOperations++;const h=performance.now()-n;return this.stats.performance.averageAddTime=(this.stats.performance.averageAddTime*(this.stats.performance.totalOperations-1)+h)/this.stats.performance.totalOperations,()=>{r(),o.delete(r),this.removeFromRegistry(t,s,e),this.stats.cleanedUpListeners++,this.lifecycleHooks.onRemove?.(t,e,s)}}static addEventListener(t,e,s,i){this.add(t,e,s,i)}static removeEventListener(t,e,s){t.removeEventListener(e,s),this.removeFromRegistry(t,s,e),this.stats.cleanedUpListeners++}static getListeners(t){return this.listenerRegistry.get(t)||[]}static addCleanupFunction(t,e){this.cleanupFunctions.has(t)||this.cleanupFunctions.set(t,[]),this.cleanupFunctions.get(t).push(e)}static delegate(t,e,s,i){const n=t=>{const s=t.target.closest(e);s&&i(t,s)};t.addEventListener(s,n),this.addToRegistry(t,{type:s,handler:n,delegated:!0})}static setLifecycleHooks(t){this.lifecycleHooks=t}static setDebugMode(t,e){this.debugMode=t,this.debugLogger=e||null}static batch(t){const e=performance.now();t();const s=performance.now()-e;this.debugMode&&this.debugLogger&&this.debugLogger(`EventManager: batch операция выполнена за ${s}ms`)}static cleanup(t){const e=this.listenerCleanups.get(t);e&&(e.forEach(t=>t()),this.listenerCleanups.delete(t),this.stats.trackedElements--);const s=this.cleanupFunctions.get(t);s&&(s.forEach(t=>t()),this.cleanupFunctions.delete(t)),this.listenerRegistry.delete(t)}static getListenerCount(t){const e=this.listenerCleanups.get(t);return e?e.size:0}static getStats(){return{...this.stats}}static clear(){if("test"===process.env.NODE_ENV){if(this.testListenerRegistry){for(const[t,e]of this.testListenerRegistry.entries())e.forEach(e=>{t.removeEventListener(e.type,e.handler,e.options)});this.testListenerRegistry.clear()}this.listenerCleanups=new WeakMap,this.listenerRegistry=new WeakMap,this.cleanupFunctions=new WeakMap,this.stats={trackedElements:0,totalListeners:0,cleanedUpListeners:0,errorCount:0,performance:{averageAddTime:0,totalOperations:0},memory:{estimatedSize:0}}}}static clearAll(){this.clear()}static addToRegistry(t,e){this.listenerRegistry.has(t)||this.listenerRegistry.set(t,[]),this.listenerRegistry.get(t).push(e),this.stats.memory.estimatedSize+=100}static removeFromRegistry(t,e,s){const i=this.listenerRegistry.get(t);if(i){const t=i.findIndex(t=>t.handler===e&&t.type===s);-1!==t&&(i.splice(t,1),this.stats.memory.estimatedSize-=100)}}};y.listenerCleanups=new WeakMap,y.listenerRegistry=new WeakMap,y.cleanupFunctions=new WeakMap,y.stats={trackedElements:0,totalListeners:0,cleanedUpListeners:0,errorCount:0,performance:{averageAddTime:0,totalOperations:0},memory:{estimatedSize:0}},y.lifecycleHooks={},y.debugMode=!1,y.debugLogger=null,y.testListenerRegistry=null;let g=y;function v(t,e=300,s={}){let i,n,r,o,h=0;function c(e){const s=o;o=void 0,h=e,t.apply(null,s)}function a(t){const i=t-h;return void 0===r||t-(r||0)>=e||s.maxWait&&i>=s.maxWait}function u(){const t=Date.now();a(t)?l(t):i=setTimeout(u,function(t){const i=t-h,n=e-(t-(r||0));return s.maxWait?Math.min(n,s.maxWait-i):n}(t))}function l(t){i=void 0,o&&c(t),o=void 0}const d=function(...t){const n=Date.now(),l=a(n);if(o=t,r=n,l){if(void 0===i)return void function(t){h=t,i=setTimeout(u,e),s.leading&&c(t)}(r);if(s.maxWait)return i=setTimeout(u,e),void c(r)}void 0===i&&(i=setTimeout(u,e))};return d.cancel=()=>{void 0!==i&&clearTimeout(i),void 0!==n&&clearTimeout(n),h=0,o=r=i=n=void 0},d.flush=()=>{void 0!==i&&l(Date.now())},d}class w{constructor(t,e){this.cleanup=[],this.domCache=null,this.lazyInit={},this.initialized=!1,this.stats={domOperations:0,eventsFired:0,validationCalls:0,cacheHits:0,cacheMisses:0},this.element=t,this.directives=e,this.buildDOMCache()}init(){this.initialized||this.directives&&(this.validateDirectives(),this.scheduleDirectiveInit(),this.initialized=!0)}getPerformanceStats(){return{...this.stats,cacheEfficiency:this.stats.cacheHits/(this.stats.cacheHits+this.stats.cacheMisses)||0,domOperationsPerEvent:this.stats.domOperations/this.stats.eventsFired||0}}destroy(){this.cleanup.forEach(t=>{try{t()}catch(e){process.env.NODE_ENV}}),this.cleanup.length=0,this.domCache=null,this.lazyInit={},this.initialized=!1}buildDOMCache(){const t=this.element;this.domCache={element:t,isInput:t instanceof HTMLInputElement,inputType:t instanceof HTMLInputElement?t.type:void 0,relevantEvents:this.getRelevantEvents(t)},this.stats.domOperations++}scheduleDirectiveInit(){this.directives.model&&(this.lazyInit.model=!0,this.initModelDirective()),(this.directives.onSubmit||this.directives.validate)&&this.scheduleInteractionInit()}scheduleInteractionInit(){if(!this.domCache)return;const t=()=>{this.directives.onSubmit&&!this.lazyInit.submit&&(this.lazyInit.submit=!0,this.initSubmitDirective()),this.directives.validate&&!this.lazyInit.validate&&(this.lazyInit.validate=!0,this.initValidateDirective()),this.domCache.relevantEvents.forEach(e=>{this.domCache.element.removeEventListener(e,t,{once:!0})})};this.domCache.relevantEvents.forEach(e=>{this.domCache.element.addEventListener(e,t,{once:!0})})}validateDirectives(){if(!this.domCache)return;const t=this.element.tagName.toLowerCase();this.directives.model&&m.validateModelDirective(t,this.domCache.inputType),this.directives.onSubmit&&m.validateSubmitDirective(t)}initModelDirective(){if(!this.directives.model||!this.domCache)return;const[t,e]=this.directives.model,s=this.domCache.element,i=t();this.setElementValueOptimized(s,i),this.domCache.lastValue=i;const n=()=>{this.stats.eventsFired++;const t=this.getElementValueOptimized(s);t!==this.domCache.lastValue?(this.domCache.lastValue=t,e(String(t)),this.stats.cacheMisses++):this.stats.cacheHits++},r=this.directives.debounce?v(n,this.directives.debounce,{maxWait:3*this.directives.debounce}):n;this.domCache.relevantEvents.forEach(t=>{const e=g.add(s,t,r);this.cleanup.push(e)}),this.setupStateSync(t)}setupStateSync(t){if(!this.domCache)return;const e=this.domCache.element;let s=t();const i=setInterval(()=>{const i=t();i!==s&&i!==this.domCache.lastValue&&(s=i,this.domCache.lastValue=i,l.scheduleWrite(()=>{!1!==this.directives.preserveFocus&&document.activeElement===e?this.preserveFocusUpdate(e,i):this.setElementValueOptimized(e,i)}))},16);this.cleanup.push(()=>clearInterval(i))}preserveFocusUpdate(t,e){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){const s=t.selectionStart,i=t.selectionEnd;this.setElementValueOptimized(t,e),null!==s&&null!==i&&t.setSelectionRange(s,i)}else this.setElementValueOptimized(t,e)}initSubmitDirective(){if(!this.directives.onSubmit||!this.domCache)return;const t=this.directives.onSubmit,e=this.domCache.element,s=g.add(e,"keydown",s=>{const i=s;if("Enter"===i.key&&!i.shiftKey){i.preventDefault(),this.stats.eventsFired++;const s=this.getElementValueOptimized(e);if(this.directives.validate&&"valid"!==this.domCache.validationState){const t=this.directives.validate(String(s));if(this.stats.validationCalls++,!0!==t)return void(this.domCache.validationState="invalid");this.domCache.validationState="valid"}t(String(s)),this.directives.clearOnSubmit&&l.scheduleWrite(()=>{this.setElementValueOptimized(e,""),this.directives.model&&this.directives.model[1]("")})}});this.cleanup.push(s)}initValidateDirective(){if(!this.directives.validate||!this.domCache)return;const t=this.directives.validate,e=this.domCache.element,s=()=>{this.stats.validationCalls++;const s=this.getElementValueOptimized(e),i=t(String(s));this.domCache.validationState=!0===i?"valid":"invalid",l.scheduleWrite(()=>{if(!0===i)e.setCustomValidity(""),e.classList.remove("io-invalid"),e.classList.add("io-valid");else{const t="string"==typeof i?i:"Некорректное значение";e.setCustomValidity(t),e.classList.remove("io-valid"),e.classList.add("io-invalid")}})},i=this.directives.debounce?v(s,this.directives.debounce):s,n=g.add(e,"blur",s),r=g.add(e,"input",i);this.cleanup.push(n,r)}getElementValueOptimized(t){if(!this.domCache)return this.stats.cacheMisses++,this.getElementValueFallback(t);if(this.stats.cacheHits++,this.stats.domOperations++,this.domCache.isInput){const e=t;switch(this.domCache.inputType){case"checkbox":return e.checked;case"radio":return e.checked?e.value:void 0;default:return e.value}}return t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?t.value:void 0}setElementValueOptimized(t,e){if(this.domCache)if(this.stats.domOperations++,this.domCache.isInput){const s=t;switch(this.domCache.inputType){case"checkbox":s.checked=Boolean(e);break;case"radio":e===s.value&&(s.checked=!0);break;default:s.value=String(e??"")}}else(t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=String(e??""));else this.setElementValueFallback(t,e)}getElementValueFallback(t){return t instanceof HTMLInputElement?"checkbox"===t.type?t.checked:"radio"===t.type?t.checked?t.value:void 0:t.value:t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?t.value:void 0}setElementValueFallback(t,e){t instanceof HTMLInputElement?"checkbox"===t.type?t.checked=Boolean(e):"radio"===t.type?e===t.value&&(t.checked=!0):t.value=String(e??""):(t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=String(e??""))}getRelevantEvents(t){return t instanceof HTMLInputElement?["checkbox","radio"].includes(t.type)?["change"]:["input"]:t instanceof HTMLTextAreaElement?["input"]:t instanceof HTMLSelectElement?["change"]:[]}}function b(t){const e=t;if(e.elementRef){if(e.t){const t="function"==typeof e.t?e.t():e.t;(Array.isArray(t)?t:[]).forEach(t=>{if("function"==typeof t){const e=t();e&&"object"==typeof e&&"function"==typeof e.destroy&&e.destroy()}})}e.elementRef=null}!function(t){const e=t;e.i&&(e.i.destroy(),e.i=null)}(t),process.env.NODE_ENV}const M=class t{constructor(){if(this.delegationContainers=new Map,this.directListeners=new WeakMap,this.cleanedUpCount=0,this.originalListeners=0,this.bubblingOptimizations=0,t.instance)return t.instance;t.instance=this}shouldUseDelegate(t,e,s){const i=t.querySelectorAll(e),n=["click","change","input","submit","focus","blur","keydown","keyup"].includes(s),r=i.length>3,o=t.hasAttribute("data-dynamic")||t.classList.contains("dynamic")||"ul"===t.tagName.toLowerCase()||"ol"===t.tagName.toLowerCase()||"table"===t.tagName.toLowerCase();return n&&(r||o)}delegate(t,e,s,i,n){const r={selector:e,handler:i,eventType:s,useCapture:n?.useCapture||!1};this.delegationContainers.has(t)||this.delegationContainers.set(t,new Map);const o=this.delegationContainers.get(t);o.has(s)||(o.set(s,[]),this.setupDelegatedListener(t,s));const h=o.get(s);return h.push(r),()=>{const e=h.indexOf(r);e>-1&&(h.splice(e,1),0===h.length&&(this.removeDelegatedListener(t,s),o.delete(s)))}}direct(t,e,s,i){return t.addEventListener(e,s,i),this.directListeners.has(t)||this.directListeners.set(t,new Map),this.directListeners.get(t).set(e,s),()=>{t.removeEventListener(e,s,i),this.directListeners.get(t)?.delete(e)}}auto(t,e,s,i){if(e&&this.shouldUseDelegate(t,e,s))return this.delegate(t,e,s,i);{const n=e?t.querySelector(e):t;return n?this.direct(n,s,i):()=>{}}}setupDelegatedListener(t,e){const s=s=>{const i=this.delegationContainers.get(t);if(!i)return;const n=i.get(e);if(n)for(const e of n){const i=t.querySelectorAll(e.selector);for(const t of i)if(t===s.target||t.contains(s.target)){this.bubblingOptimizations++,e.handler(s,t);break}}};t.addEventListener(e,s,!1),this.directListeners.has(t)||this.directListeners.set(t,new Map),this.directListeners.get(t).set(`__delegated__${e}`,s)}removeDelegatedListener(t,e){const s=this.directListeners.get(t),i=s?.get(`__delegated__${e}`);i&&(t.removeEventListener(e,i,!1),s?.delete(`__delegated__${e}`))}cleanup(t){const e=this.directListeners.get(t);if(e){for(const[s,i]of e)if(s.startsWith("__delegated__")){const e=s.replace("__delegated__","");t.removeEventListener(e,i)}else t.removeEventListener(s,i);this.directListeners.delete(t)}if(this.delegationContainers.has(t)){const e=this.delegationContainers.get(t);for(const[s]of e)this.removeDelegatedListener(t,s);this.delegationContainers.delete(t),this.cleanedUpCount++}}getStats(){let t=0;const e={};for(const[s,i]of this.delegationContainers){let n=0;for(const e of i.values())n+=e.length,t+=e.length;e[s.id||s.className||"unknown"]=n}return{delegationContainers:this.delegationContainers.size,totalRules:t,directListeners:0,rulesPerContainer:e,performanceImprovement:.7*t,cleanedUpDelegations:this.cleanedUpCount||0,delegatedEvents:t,originalListeners:this.originalListeners||0,actualListeners:this.delegationContainers.size,bubblingOptimizations:this.bubblingOptimizations||0}}optimizeEvents(t){const e=t.querySelectorAll("*"),s=new Map;e.forEach(t=>{if(t.getAttribute("onclick")){const e=t.tagName.toLowerCase();s.has(e)||s.set(e,[]),s.get(e).push(t),this.originalListeners++}}),s.forEach((e,s)=>{e.length>2&&this.delegate(t,s,"click",(t,e)=>{const s=e.getAttribute("onclick");if(s)try{new Function(s).call(e)}catch(i){}})})}static getInstance(){return this.instance||(this.instance=new t),this.instance}static delegate(t,e,s,i,n){return this.getInstance().delegate(t,e,s,i,n)}static direct(t,e,s,i){return this.getInstance().direct(t,e,s,i)}static auto(t,e,s,i){return this.getInstance().auto(t,e,s,i)}static cleanup(t){this.getInstance().cleanup(t)}static getStats(){return this.getInstance().getStats()}static reset(){const t=this.getInstance();for(const e of t.delegationContainers.keys())t.cleanup(e)}static optimizeEvents(t){this.getInstance().optimizeEvents(t)}};M.instance=null;let E=M;E.getInstance();let S=0;const T=Date.now().toString(36).slice(-4),L="development"===process.env.NODE_ENV||"test"===process.env.NODE_ENV?new Set:null;function D(){const t=`io-${T}-${++S}`;return L&&L.add(t),t}class x{constructor(t,e){this.o=!1,this.h=null,this.u=null,this.l=null,this.p=t,this.m=e}render(){const t=this.m.fallback?.()||B.static("div",{text:"Загрузка...",classList:["island-loading"]}),e={...this.m,atr:{...this.m.atr,"data-island":"true","data-hydration":JSON.stringify(this.m.hydration)}},s=new B(this.p,e,[()=>t]);return this.h=s.render(),this.v(),this.h}async v(){if(!this.h)return;const{hydration:t}=this.m;t["client:load"]?this.M():t["client:idle"]?"requestIdleCallback"in window?requestIdleCallback(()=>this.M()):setTimeout(()=>this.M(),200):t["client:visible"]?this.S():t["client:media"]&&this.T(t["client:media"])}S(){if(!this.h)return;const t=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&!this.o&&(this.M(),t.disconnect())})},{rootMargin:"50px"});t.observe(this.h),this.l=()=>t.disconnect()}T(t){const e=window.matchMedia(t),s=t=>{t.matches&&!this.o&&(this.M(),e.removeEventListener("change",s))};e.matches?this.M():(e.addEventListener("change",s),this.l=()=>e.removeEventListener("change",s))}async M(){if(!this.o&&this.h)try{const t=await this.m.component();this.u=t;const e=t.render(),s=this.h.parentNode;s&&(Array.from(this.h.attributes).forEach(t=>{const s=t.name;s.startsWith("data-island")||"data-component-id"!==s&&e.setAttribute(s,t.value)}),s.replaceChild(e,this.h),this.h=e),this.o=!0}catch(t){this.h&&(this.h.innerHTML='<div style="color: red; padding: 10px;">⚠️ Ошибка загрузки компонента</div>')}}destroy(){this.l&&(this.l(),this.l=null),this.u&&"function"==typeof this.u.destroy&&this.u.destroy(),this.h=null,this.u=null,this.o=!1}isHydrated(){return this.o}getHydratedComponent(){return this.u}}class C{constructor(t={}){this.operations=[],this.config={useKeys:!0,preserveWhitespace:!1,compareAttributes:!0,compareText:!0,...t}}diff(t,e){return this.operations=[],this.config.useKeys?this.diffWithKeys(t,e):this.diffWithoutKeys(t,e),this.optimizeOperations(this.operations)}diffWithKeys(t,e){const s=this.createKeyedMap(t),i=this.createKeyedMap(e),n=Array.from(s.keys()),r=Array.from(i.keys());n.forEach((t,e)=>{i.has(t)||this.operations.push({type:"DELETE",node:s.get(t),index:e})}),r.forEach((t,e)=>{const r=i.get(t);if(s.has(t)){const i=n.indexOf(t),o=s.get(t);i!==e&&this.operations.push({type:"MOVE",node:o,fromIndex:i,toIndex:e}),this.shouldUpdate(o,r)&&this.operations.push({type:"UPDATE",oldNode:o,newNode:r,index:e})}else this.operations.push({type:"CREATE",node:r,index:e})})}diffWithoutKeys(t,e){const s=Math.max(t.length,e.length);for(let i=0;i<s;i++){const s=t[i],n=e[i];!s&&n?this.operations.push({type:"CREATE",node:n,index:i}):s&&!n?this.operations.push({type:"DELETE",node:s,index:i}):s&&n&&this.shouldUpdate(s,n)&&this.operations.push({type:"UPDATE",oldNode:s,newNode:n,index:i})}}createKeyedMap(t){const e=new Map;return t.forEach((t,s)=>{const i=this.getNodeKey(t,s);e.set(i,t)}),e}getNodeKey(t,e){if(t.nodeType===Node.ELEMENT_NODE){const s=t,i=s.getAttribute("data-key");if(i)return`key:${i}`;const n=s.getAttribute("data-component-id");if(n)return`component:${n}`;const r=s.getAttribute("id");if(r)return`id:${r}`;const o=s.tagName.toLowerCase(),h=s.className;return h?`tag:${o}.${h}`:`tag:${o}:${e}`}return t.nodeType===Node.TEXT_NODE?`text:${(t.textContent?.trim()||"").substring(0,20)}:${e}`:`node:${t.nodeType}:${e}`}shouldUpdate(t,e){if(t.nodeType!==e.nodeType)return!0;if(t.nodeType===Node.ELEMENT_NODE){const s=t,i=e;if(s.tagName!==i.tagName)return!0;if(this.config.compareAttributes&&this.attributesChanged(s,i))return!0}else if(t.nodeType===Node.TEXT_NODE&&this.config.compareText)return t.textContent!==e.textContent;return!1}attributesChanged(t,e){const s=Array.from(t.attributes),i=Array.from(e.attributes);if(s.length!==i.length)return!0;for(const n of s)if(e.getAttribute(n.name)!==n.value)return!0;return!1}optimizeOperations(t){const e=[],s=new Set;for(const n of t){const t="node"in n?n.node:n.oldNode;s.has(t)||(e.push(n),s.add(t))}const i={DELETE:0,CREATE:1,MOVE:2,UPDATE:3};return e.sort((t,e)=>i[t.type]-i[e.type])}static applyOperations(t,e){performance.now(),t.forEach(t=>{try{switch(t.type){case"CREATE":C.applyCreate(t,e);break;case"DELETE":C.applyDelete(t,e);break;case"MOVE":C.applyMove(t,e);break;case"UPDATE":C.applyUpdate(t,e)}}catch(s){}}),"development"===process.env.NODE_ENV&&performance.now()}static applyCreate(t,e){const s=Array.from(e.childNodes)[t.index];s?e.insertBefore(t.node,s):e.appendChild(t.node)}static applyDelete(t,e){t.node.parentNode===e&&e.removeChild(t.node)}static applyMove(t,e){const s=Array.from(e.childNodes)[t.toIndex];s?e.insertBefore(t.node,s):e.appendChild(t.node)}static applyUpdate(t,e){e.replaceChild(t.newNode,t.oldNode)}}const A=new C;class k{tagSwitcher(t){switch(t){case"svg":case"path":return this.createSVG(t);default:return this.create(t)}}create(t){return document.createElement(t)}createSVG(t){const e=document.createElementNS("http://www.w3.org/2000/svg",t);return e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e}setClassList(t,e,s=!1){if(!e)return;const i=()=>{let s=e;"object"==typeof e&&null!==e&&"value"in e&&void 0!==e.value&&(s=e.value);let i="";Array.isArray(s)&&(i=s.map(t=>"function"==typeof t?t():t).join(" ").replace(/\s+/g," ").trim()),t.className=i};s?r(i):i()}setID(t,e){if(!e)return;let s=e;"object"==typeof e&&null!==e&&"value"in e&&void 0!==e.value&&(s=e.value),"function"==typeof s?t.id=s().toString():"string"!=typeof s&&"number"!=typeof s||(t.id=s.toString())}setEvents(t,e){if(!e)return;let s=e;if("object"==typeof e&&null!==e&&"value"in e&&void 0!==e.value&&(s=e.value),g.cleanup(t),"object"==typeof s&&null!==s)for(const i in s){const e=s[i];"function"==typeof e&&g.add(t,i,e)}}setComponents(t,e,s=!1,i){if(!e)return;const n=()=>{const t="function"==typeof e?e():e,s=[];return t.forEach(t=>{const e=t();e&&(e instanceof B?s.push(e.render(i)):e instanceof x&&s.push(e.render()))}),s};s&&t.children.length>0?(!function(t,e,s){const i=A.diff(t,e);C.applyOperations(i,s)}(Array.from(t.childNodes),n(),t),process.env.NODE_ENV):n().forEach(e=>t.appendChild(e))}setText(t,e,s=!1){if(null==e)return;const i=()=>{if("string"==typeof e||"number"==typeof e)t.textContent=e.toString();else if("function"==typeof e)try{t.textContent=e().toString()}catch(s){t.textContent="[Ошибка в функции]"}else if("object"==typeof e&&null!==e&&"value"in e&&void 0!==e.value){const s=e.value;t.textContent=null!=s?s.toString():""}};s?n(i):i()}setHTML(t,e,s={trusted:!1,sanitize:!1,warnInDev:!0}){if(!e)return;const i="string"==typeof e?e:e();if(s.warnInDev&&process.env.NODE_ENV,s.sanitize){const e=i.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"");t.innerHTML=e}else s.trusted?t.innerHTML=i:t.textContent=i}setAtr(t,e,s=!1){if(!e)return;const i=()=>{let s=e;if("object"==typeof e&&null!==e&&"value"in e&&void 0!==e.value&&(s=e.value),"object"==typeof s&&null!==s)for(const e in s){const i=e,n=s[e];null!=n&&("function"==typeof n?t.setAttribute(i,n()):t.setAttribute(i,n))}};s?o(i):i()}setComponentId(t,e){t.dataset.componentId=e}hydrate(t,e,s){let i,n=!1;e instanceof Set?(i=e,n=s||!1):n=e||!1;const{classList:r,id:o,events:h,text:c,components:a,atr:u,tag:l,L:d}=t,f=this.tagSwitcher(l);return this.setComponentId(f,d),this.setClassList(f,r,n),this.setID(f,o),this.setEvents(f,h),this.setText(f,c,n),this.setComponents(f,a,!1,i),this.setAtr(f,u,n),t.onRender&&t.onRender(t),f}mutate(t,e){if(t&&e)return this.setComponentId(e,t.L),this.setClassList(e,t.classList,!0),this.setID(e,t.id),this.setEvents(e,t.events),this.setText(e,t.text,!0),this.setAtr(e,t.atr,!0),t.onMutate&&t.onMutate(t),e}mutateLegacy(t,e){if(!t||!e)return;const{components:s}=t,i=e.children;let n=[];"function"==typeof s?n=s().map(t=>t()):s&&(n=s.map(t=>t()));const r=n.length,o=e.children.length,h=Math.max(r,o);if(this.setComponentId(e,t.L),this.setClassList(e,t.classList,!0),this.setID(e,t.id),this.setEvents(e,t.events),this.setText(e,t.text,!0),this.setAtr(e,t.atr,!0),r===o)for(let c=0;c<h;c++){const t=n[c],s=i[c];if(t)if(s){if(s.tagName.toUpperCase()!==t.tag.toUpperCase()){const e=t.render();s.replaceWith(e)}this.setComponentId(s,t.L),this.setClassList(s,t.classList,!0),this.setID(s,t.id),this.setEvents(s,t.events),this.setText(s,t.text,!0),this.setAtr(s,t.atr,!0),this.mutateLegacy(t,s)}else e.appendChild(t.render());else e.removeChild(s)}else e?.replaceWith(t.render());return t.onMutate&&t.onMutate(t),e}}function O(t){return a.get(document,`[data-component-id="${t}"]`)}class I{constructor(t){this.D=t,this.C=new k}update(t){const e=O(this.D.L);e&&this.C.mutateLegacy(t,e)}forceRender(t){const e=O(this.D.L);if(!e)return;const s=this.C.hydrate(t);e.replaceWith(s)}}class _{constructor(t){this.A=new Map,this.D=t,this.k=new I(this.D)}stateQuery(t,e,s){const i=D();this.A.set(i,t);const n=()=>{e.then(t=>{this.A.set(i,t),s&&s.ok&&s.ok(t),this.k.update(this.D)}).catch(t=>{s&&s.error&&s.error(t)}).finally(()=>{this.k.update(this.D)})};return n(),{data:()=>this.A.get(i),refetch:n}}}function H(t){let e=t;const s=new Set;return{get value(){return e},set value(t){e=t,s.forEach(t=>t(e))},subscribe(t){s.add(t)},unsubscribe(t){s.delete(t)}}}class U{constructor(t){this.componentUpdateFunc=null,this.A=new Map,this.D=t,this.k=new I(this.D)}getComponentUpdateFunction(){return this.componentUpdateFunc||(this.componentUpdateFunc=()=>{this.k.update(this.D),this.D.forceUpdate()}),this.componentUpdateFunc}state({init:t,update:e,callback:s,forceRender:i}){const n=H(t),r=D();return this.A.set(r,t),n.subscribe(t=>{this.A.set(r,t),e&&!i&&this.getComponentUpdateFunction()(),i&&(this.k.forceRender(this.D),this.D.forceUpdate()),s&&s(t)}),[n,t=>{let e;e="function"==typeof t?t(n.value):t,n.value=e}]}}class z{constructor(t,e){this.id=`${Date.now()}_${Math.floor(1e4*Math.random())}`,this.callback=e,this.stream=t,this.stream.subscribe({id:this.id,subscriber:this})}effect(t){this.callback(t)}unsubscribe(){this.stream.unsubscribe(this.id)}}const W=new class{constructor(){this.subscribers=[]}notify(t){this.subscribers.forEach(({subscriber:e})=>{e.effect(t)})}subscribe(t){this.subscribers.push(t),this.subscribers.length>50&&this.subscribers.shift()}unsubscribe(t){this.subscribers=this.subscribers.filter(e=>e.id!==t)}clearSubscribers(){this.subscribers=[]}};class R{constructor(){this.O=W,this.$subscriber=null}stream(){return{subscribe:(t,e)=>new z(this.O,s=>{s.id===t&&e&&e(s.data)}),notify:(t,e)=>{W.notify({id:t,data:e})}}}}function $(t){return"object"==typeof t&&null!==t&&"subscribe"in t&&"value"in t}function P(t,e){const s=t;s.I[e]&&(s.I[e](),s.I[e]=null)}const F=class t{constructor(){this.debouncers=new Map,this.defaultConfig={wait:16,maxWait:100,immediate:!1},this.componentConfigs=new Map}static getInstance(){return this.instance||(this.instance=new t),this.instance}debouncedUpdate(t,e,s={}){const i={...this.defaultConfig,...s},n=`${t}-${i.wait}-${i.maxWait}`;if(this.debouncers.has(n)){const t=this.debouncers.get(n);return t.updateCount++,t.func}let r=null,o=null,h=null;const c=t=>{h=[t];const s=Date.now(),c=this.debouncers.get(n);if(r&&clearTimeout(r),o&&clearTimeout(o),i.immediate&&!r)return e(t),this.updateDebounceStats(n,s),void(c&&(c.timeoutId=null,c.lastArgs=null));r=setTimeout(()=>{h&&(e(h[0]),this.updateDebounceStats(n,Date.now()));const t=this.debouncers.get(n);t&&(t.timeoutId=null,t.lastArgs=null),r=null,o=null,h=null},i.wait),c&&(c.timeoutId=r,c.lastArgs=h),i.maxWait&&i.maxWait>i.wait&&(o=setTimeout(()=>{r&&(clearTimeout(r),r=null),h&&(e(h[0]),this.updateDebounceStats(n,Date.now()));const t=this.debouncers.get(n);t&&(t.timeoutId=null,t.lastArgs=null),o=null,h=null},i.maxWait))};return this.debouncers.set(n,{func:(...t)=>c(t[0]),lastUpdate:Date.now(),updateCount:1,timeoutId:null,lastArgs:null}),c}throttledUpdate(t,e,s=16){const i=function(t,e){let s=!1,i=null,n=0;return function(...r){s?(i&&clearTimeout(i),i=setTimeout(()=>{Date.now()-n>=e&&(t.apply(this,r),n=Date.now())},e-(Date.now()-n))):(t.apply(this,r),n=Date.now(),s=!0)}}((...t)=>e(t[0]),s);return this.debouncers.set(t,{func:(...t)=>i(t[0]),lastUpdate:Date.now(),updateCount:1}),i}adaptiveUpdate(t,e){let s=Date.now(),i=16;return this.debouncedUpdate(`adaptive-${t}`,t=>{const n=Date.now(),r=n-s;r<10?i=Math.min(1.5*i,100):r>100&&(i=Math.max(.8*i,8)),s=n,e(t),process.env.NODE_ENV},{wait:i})}flush(){for(const[t,e]of this.debouncers.entries())e.timeoutId&&(clearTimeout(e.timeoutId),e.lastArgs&&e.func&&(e.func(...e.lastArgs),this.updateDebounceStats(t,Date.now())),e.timeoutId=null,e.lastArgs=null);process.env.NODE_ENV}clear(){this.debouncers.clear()}static clearAll(){t.instance&&t.instance.clear()}static flush(){t.instance&&t.instance.flush()}static getGlobalStats(){if(!t.instance)return{activeComponents:0,totalDebounces:0,totalUpdates:0,averageDelay:0};const e=t.instance.getStats(),s=e.debouncers.reduce((t,e)=>t+e.updateCount,0);return{activeComponents:e.activeDebounces,totalDebounces:e.debouncers.length,totalUpdates:s,averageDelay:e.debouncers.length>0?e.debouncers.reduce((t,e)=>t+e.timeSinceLastUpdate,0)/e.debouncers.length:0}}configure(t,e){this.componentConfigs.set(t,e)}disable(t){this.componentConfigs.delete(t);for(const[e,s]of this.debouncers.entries())e.includes(t)&&(s.timeoutId&&clearTimeout(s.timeoutId),this.debouncers.delete(e))}isComponentConfigured(t){return this.componentConfigs.has(t)}getComponentConfig(t){const e=this.componentConfigs.get(t);return e?{wait:e.delay||this.defaultConfig.wait,maxWait:e.maxWait||this.defaultConfig.maxWait,immediate:e.leading||this.defaultConfig.immediate}:null}static setGlobalConfig(t){}updateDebounceStats(t,e){const s=this.debouncers.get(t);s&&(s.lastUpdate=e)}getStats(){const t=Date.now(),e=Array.from(this.debouncers.entries()).map(([e,s])=>({key:e,lastUpdate:s.lastUpdate,updateCount:s.updateCount,timeSinceLastUpdate:t-s.lastUpdate})),s=e.reduce((t,e)=>t+e.updateCount,0);return{activeDebounces:this.debouncers.size,debouncers:e,totalStateChanges:s,debouncedUpdates:e.length,preventedRenders:Math.max(0,s-e.length)}}remove(t){this.debouncers.delete(t)}static getConfigForUpdateType(t){switch(t){case"text":return{wait:8,maxWait:50,immediate:!1};case"style":default:return{wait:16,maxWait:100,immediate:!1};case"attribute":return{wait:12,maxWait:80,immediate:!1};case"component":return{wait:20,maxWait:150,immediate:!1};case"state":return{wait:10,maxWait:100,immediate:!1}}}};F.instance=null;const q=F.getInstance();function j(t){t.elementRef&&t.C.mutate(t,t.elementRef)}function N(t){t.elementRef&&t.C.mutateLegacy(t,t.elementRef)}class B{constructor(t,e,s){this._=null,this.H=null,this.U=null,this.i=null,this.I={text:null,classList:null,atr:null,id:null,events:null},this.C=new k,f.register("StateModule",()=>new U(this)),f.register("StateQueryModule",()=>new _(this)),f.register("StreamModule",()=>new R),this.p=t,this.W=e?.classList,this.R=e?.id,this.$=e?.events,this.P=e?.atr,this.t=e?.components??s,this.F=e?.text,this.q=e?.inputProps,this.j=e?{model:e.model,onSubmit:e.onSubmit,validate:e.validate,debounce:e.debounce,preserveFocus:e.preserveFocus,clearOnSubmit:e.clearOnSubmit}:void 0,this.L=D(),this.elementRef=null,this.onRender=null,this.onMutate=null,this.I={text:null,classList:null,atr:null,id:null,events:null}}set tag(t){!function(t,e){t.p=e}(this,t)}get tag(){return this.p}set classList(t){!function(t,e){P(t,"classList");const s=t;if($(e)){const t=t=>{s.W=t,s.forceUpdate&&s.forceUpdate()};e.subscribe(t),s.W=e.value,s.I.classList=()=>e.unsubscribe(t)}else s.W=e,s.I.classList=null}(this,t)}get classList(){return this.W}set id(t){!function(t,e){P(t,"id");const s=t;if($(e)){const t=t=>{s.R=t,s.forceUpdate&&s.forceUpdate()};e.subscribe(t),s.R=e.value,s.I.id=()=>e.unsubscribe(t)}else s.R=e,s.I.id=null}(this,t)}get id(){return this.R}set events(t){!function(t,e){P(t,"events");const s=t;if($(e)){const t=t=>{s.$=t,s.forceUpdate&&s.forceUpdate()};e.subscribe(t),s.$=e.value,s.I.events=()=>e.unsubscribe(t)}else s.$=e,s.I.events=null}(this,t)}get events(){return this.$}set atr(t){!function(t,e){P(t,"atr");const s=t;if($(e)){const t=t=>{s.P=t,s.forceUpdate&&s.forceUpdate()};e.subscribe(t),s.P=e.value,s.I.atr=()=>e.unsubscribe(t)}else s.P=e,s.I.atr=null}(this,t)}get atr(){return this.P}set text(t){!function(t,e){P(t,"text");const s=t;if($(e)){const t=t=>{s.F=t,s.forceUpdate&&s.forceUpdate()};e.subscribe(t),s.F=e.value,s.I.text=()=>e.unsubscribe(t)}else s.F=e,s.I.text=null}(this,t)}get text(){return this.F}set components(t){!function(t,e){const s=t;Array.isArray(e)&&e.length>0&&e.every(e=>"object"==typeof e&&e instanceof Object.getPrototypeOf(t).constructor)?s.t=e.map(t=>()=>t):s.t=e}(this,t)}get components(){return this.t}state(t,e=!0,s=!1){return function(t,e,s=!0,i=!1){return t._||(t._=new U(t)),t._.state({init:e,update:s,forceRender:i})}(this,t,e,s)}async stateQuery(t,e,s){return async function(t,e,s,i){return t.H||(t.H=await f.load("StateQueryModule")),t.H.stateQuery(e,s,i)}(this,t,e,s)}async stream(){return async function(t){return t.U||(t.U=await f.load("StreamModule")),t.U.stream()}(this)}render(t){const e=function(t,e){if(e||(e=new Set),e.has(t))return document.createElement("div");e.add(t);try{const s=t,i=s.C.hydrate(t,e);return s.elementRef=i,i}finally{e.delete(t)}}(this,t);return function(t,e,s){if(s&&(s.model||s.onSubmit||s.validate)){const i=t;i.i=new w(e,s),i.i.init()}}(this,e,this.j),"input"===this.p&&this.q&&Object.entries(this.q).forEach(([t,s])=>{null!=s&&e.setAttribute(t,s.toString())}),e}forceUpdate(){this.smartUpdate()}setHTML(t,e){!function(t,e,s){const i=t;i.elementRef&&i.C.setHTML(i.elementRef,e,s)}(this,t,e)}destroy(){b(this)}unmount(){b(this)}getRef(){return this.elementRef??null}setOptimizedText(t){!function(t,e){const s=t;s.elementRef&&l.setText(s.elementRef,e)}(this,t)}querySelector(t,e){return function(t,e,s){const i=s||t.elementRef||document;return l.querySelector(e,i)}(this,t,e)}querySelectorAll(t,e){return function(t,e,s){const i=s||t.elementRef||document;return l.querySelectorAll(e,i)}(this,t,e)}delegateEvent(t,e,s){return function(t,e,s,i){const n=t;return n.elementRef?E.delegate(n.elementRef,e,s,i):()=>{}}(this,t,e,s)}autoEvent(t,e,s){return function(t,e,s,i){const n=t;return n.elementRef?E.auto(n.elementRef,e,s,i):()=>{}}(this,t,e,s)}flushDOMOperations(){i.flush()}getDOMOptimizationStats(){return{domOptimizer:l.getStats(),eventDelegation:E.getStats()}}getListenerCount(){return function(t){const e=t;return e.elementRef?g.getListenerCount(e.elementRef):0}(this)}setStateDebouncing(t,e){!function(t,e,s){e&&s?q.configure(t.L,s):e||q.disable(t.L)}(this,t,e)}getStateDebounceStats(){return q.getStats()}flushStateUpdates(){q.flush()}forceUpdateWithDiff(){j(this)}forceUpdateLegacy(){N(this)}smartUpdate(){var t;(t=this).elementRef&&(t.elementRef.children.length>10?j(t):N(t))}static configureDiff(t){process.env.NODE_ENV}static flushAllUpdates(){q.flush()}static static(t,e,s){const i=new B(t,e,s);return i.N=!0,i}static island(t,e){return()=>new x(t,e)}isStatic(){return!0===this.N}static setBatchingEnabled(t){!function(t){s.getInstance().setBatchingEnabled(t)}(t)}static getDOMBatcherStats(){return s.getInstance().getStats()}static flushDOMOptimizations(){l.forceFlush()}static optimizedQuerySelector(t,e){return function(t,e){return l.querySelector(e,t)}(t,e)}static optimizedSetText(t,e){!function(t,e){l.setText(t,e)}(t,e)}static scheduleRead(t){return function(t){return l.scheduleRead(t)}(t)}static scheduleWrite(t){!function(t){l.scheduleWrite(t)}(t)}static getDOMOptimizationStats(){return{domOptimizer:l.getStats(),eventDelegation:void 0,lazyLoader:f.getStats()}}static registerLazyModule(t,e,s){!function(t,e,s){f.register(t,e,s)}(t,e,s)}static async loadLazyModule(t){return async function(t){return f.load(t)}(t)}static getLazyModule(t){return function(t){return f.get(t)}(t)}static isLazyModuleLoaded(t){return function(t){return f.isLoaded(t)}(t)}static preloadLazyModule(t){!function(t){f.preload(t)}(t)}static getLazyModuleStats(){return f.getStats()}}t.IO=B,t.IOInput=class extends B{constructor(t="input",e={},s,i){process.env.NODE_ENV;let n=e;if(i&&!e.model){const t={value:""},s=()=>t.value,r=e=>{t.value=e,i(e)};n={...e,model:[s,r]}}super(t,n,s)}},t.IslandComponent=x,t.StateModule=U,t.StateQueryModule=_,t.StreamModule=R,t.VERSION="1.0.8",t.getID=D,t.getRef=O,t.reactiveRef=H,t.signal=function(t){return new Proxy({value:t,effect:null},{get(t,e){if(e in t)return t[e]},set:(t,e,s)=>(t[e]=s,t.effect&&t.effect(t.value),!0)})},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});