native-document 1.0.117 → 1.0.119

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.
@@ -1 +1 @@
1
- var NativeDocument=function(e){"use strict";let t={};t={log(){},warn(){},error(){},disable(){}};var n=t;class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const s={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=s.mounted.get(e);if(t&&(t.inDom=!0,t.mounted))if(Array.isArray(t.mounted))for(const n of t.mounted)n(e);else t.mounted(e)},executeUnmountedCallback(e){const t=s.unmounted.get(e);if(!t)return;if(t.inDom=!1,!t.unmounted)return;let n=!1;if(Array.isArray(t.unmounted))for(const r of t.unmounted)!0===r(e)&&(n=!0);else n=!0===t.unmounted(e);n&&(t.disconnect(),e.nd?.remove())},checkMutation:function(e){for(const t of e){if(s.mountedSupposedSize>0)for(const e of t.addedNodes){if(s.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)s.executeMountedCallback(e)}if(s.unmountedSupposedSize>0)for(const e of t.removedNodes){if(s.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)s.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1,o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(s.mounted.delete(e),s.mountedSupposedSize--),r&&(s.unmounted.delete(e),s.unmountedSupposedSize--),o=null}};const i=(e,t)=>{o[e]?Array.isArray(o[e])?o[e].push(t):o[e]=[o[e],t]:o[e]=t};return{disconnect:()=>o?.disconnect(),mounted:t=>{i("mounted",t),s.mounted.set(e,o),n||(s.mountedSupposedSize++,n=!0)},unmounted:t=>{i("unmounted",t),s.unmounted.set(e,o),r||(s.unmountedSupposedSize++,r=!0)},off:(e,t)=>{((e,t)=>{if(o?.[e]){if(Array.isArray(o[e])){const n=o[e].indexOf(t);return n>-1&&o[e].splice(n,1),1===o[e].length&&(o[e]=o[e][0]),void(0===o[e].length&&(o[e]=null))}o[e]=null}})(e,t)}}}};s.observer=new MutationObserver(s.checkMutation),s.observer.observe(document.body,{childList:!0,subtree:!0});function i(e){this.$element=e}i.prototype.__$isNDElement=!0,i.prototype.valueOf=function(){return this.$element},i.prototype.ref=function(e,t){return e[t]=this.$element,this},i.prototype.refSelf=function(e,t){return e[t]=new i(this.$element),this},i.prototype.unmountChildren=function(){let e=this.$element;for(let t=0,n=e.children.length;t<n;t++){let n=e.children[t];n.$ndProx||n.nd?.remove(),n=null}return e=null,this},i.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,a.delete(e),e=null,this};const a=new WeakMap;i.prototype.lifecycle=function(e){const t=this.$element;a.has(t)||a.set(t,s.watch(t));const n=a.get(t);return e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),n.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),n.unmounted(e.unmounted)),this},i.prototype.mounted=function(e){return this.lifecycle({mounted:e})},i.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},i.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!s.beforeUnmount.has(n)){s.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=s.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return s.beforeUnmount.get(n).set(e,t),this},i.prototype.htmlElement=function(){return this.$element},i.prototype.node=i.prototype.htmlElement,i.prototype.shadow=function(e,t=null){const n=this.$element,r=Array.from(n.childNodes),o=n.attachShadow({mode:e});if(t){const e=document.createElement("style");e.textContent=t,o.appendChild(e)}return n.append=o.append.bind(o),n.appendChild=o.appendChild.bind(o),o.append(...r),this},i.prototype.openShadow=function(e=null){return this.shadow("open",e)},i.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},i.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},i.extend=function(e){if(!e||"object"!=typeof e)throw new r("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new r("NDElement.extend() requires an object, not an array");const t=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const o in e){if(!Object.hasOwn(e,o))continue;const s=e[o];if("function"==typeof s){if(t.has(o))throw n.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);i.prototype[o]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),i.prototype[o]=s}else n.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return i};const u=3,l=8,c=11,h=[];h[1]=!0,h[u]=!0,h[c]=!0,h[l]=!0;const p={isObservable:e=>e?.__$isObservable,isTemplateBinding:e=>e?.__$isTemplateBinding,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isObservableOrProxy:e=>p.isObservable(e)||p.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>!("object"!=typeof e||null===e||Array.isArray(e)||"Object"!==e.constructor.name),isElement:e=>e&&h[e.nodeType],isDOMNode:e=>h[e.nodeType],isFragment:e=>e?.nodeType===c,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof i,isValidChildren(e){Array.isArray(e)||(e=[e]);return 0===e.filter(e=>!this.isValidChild(e)).length},validateChildren(e){Array.isArray(e)||(e=[e]);const t=e.filter(e=>!this.isValidChild(e));if(t.length>0)throw new r(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(p.isObject(e)&&Object.values(e).some(e=>p.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new r("Event callback must be a function")}},d=new Set(["checked","selected","disabled","readonly","required","autofocus","multiple","autocomplete","hidden","contenteditable","spellcheck","translate","draggable","async","defer","autoplay","controls","loop","muted","download","reversed","open","default","formnovalidate","novalidate","scoped","itemscope","allowfullscreen","allowpaymentrequest","playsinline"]),f=function(){let e=0;const t=new Map;return{register(n){const r=++e;return t.set(r,new WeakRef(n)),r},unregister(e){t.delete(e)},getObservableById:e=>t.get(e)?.deref(),cleanup(){for(const[e,n]of t){const e=n.deref();e&&e.cleanup()}t.clear()},cleanObservables(e){if(t.size<e)return;let r=0;for(const[e,n]of t)n.deref()||(t.delete(e),r++);r>0&&n.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}(),m=function(e,t){this.$target=t,this.$observer=e};m.prototype.__$isObservableWhen=!0,m.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},m.prototype.val=function(){return this.$observer.$currentValue===this.$target},m.prototype.isMatch=m.prototype.val,m.prototype.isActive=m.prototype.val;const b=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},y=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},g=(e,t)=>{try{if(void 0!==window.structuredClone)return window.structuredClone(e)}catch(e){}if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>g(e));if(p.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=g(e[t]));return n},v={getJson(e){let t=localStorage.getItem(e);try{return JSON.parse(t)}catch(t){throw new r("invalid_json:"+e)}},getNumber(e){return Number(this.get(e))},getBool(e){const t=this.get(e);return"true"===t||"1"===t},setJson(e,t){localStorage.setItem(e,JSON.stringify(t))},setBool(e,t){localStorage.setItem(e,t?"true":"false")},get:(e,t=null)=>localStorage.getItem(e)||t,set:(e,t)=>localStorage.setItem(e,t),remove(e){localStorage.removeItem(e)},has:e=>null!=localStorage.getItem(e)},w=(e,t)=>{if(!v.has(e))return t;switch(typeof t){case"object":return v.getJson(e)??t;case"boolean":return v.getBool(e)??t;case"number":return v.getNumber(e)??t;default:return v.get(e,t)??t}},$=e=>{switch(typeof e){case"object":return v.setJson;case"boolean":return v.setBool;default:return v.set}},S=function(){const e=new Map,t=new Map,o=(t,o)=>{const s=e.get(o);if(!s)throw n.error("Store",`Store.${t}('${o}') : store not found. Did you call Store.create('${o}') first?`),new r(`Store.${t}('${o}') : store not found.`);return s},s=(e,t={})=>Array.isArray(e)?D.array(e,t):"object"==typeof e?D.object(e,t):D(e,t);return new Proxy({create(t,o){if(e.has(t))throw n.warn("Store",`Store.create('${t}') : a store with this name already exists. Use Store.get('${t}') to retrieve it.`),new r(`Store.create('${t}') : a store with this name already exists.`);const i=s(o);return e.set(t,{observer:i,subscribers:new Set,resettable:!1,composed:!1}),i},createResettable(t,o){if(e.has(t))throw n.warn("Store",`Store.createResettable('${t}') : a store with this name already exists.`),new r(`Store.createResettable('${t}') : a store with this name already exists.`);const i=s(o,{reset:!0});return e.set(t,{observer:i,subscribers:new Set,resettable:!0,composed:!1}),i},createComposed(t,o,s){if(e.has(t))throw n.warn("Store",`Store.createComposed('${t}') : a store with this name already exists.`),new r(`Store.createComposed('${t}') : a store with this name already exists.`);if("function"!=typeof o)throw new r(`Store.createComposed('${t}') : computation must be a function.`);if(!Array.isArray(s)||0===s.length)throw new r(`Store.createComposed('${t}') : dependencies must be a non-empty array of store names.`);const i=s.map(o=>{if("string"!=typeof o)return o;const s=e.get(o);if(!s)throw n.error("Store",`Store.createComposed('${t}') : dependency '${o}' not found. Create it first.`),new r(`Store.createComposed('${t}') : dependency store '${o}' not found.`);return s.observer}),a=D.computed(o,i);return e.set(t,{observer:a,subscribers:new Set,resettable:!1,composed:!0}),a},has:t=>e.has(t),reset(e){const t=o("reset",e);if(t.composed)throw n.error("Store",`Store.reset('${e}') : composed stores cannot be reset. Their value is derived from dependencies.`),new r(`Store.reset('${e}') : composed stores cannot be reset.`);if(!t.resettable)throw n.error("Store",`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`),new r(`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`);t.observer.reset()},use(e){const t=o("use",e);if(t.composed)throw n.error("Store",`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`),new r(`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`);const{observer:i,subscribers:a}=t,u=s(i.val()),l=e=>u.set(e),c=e=>i.set(e);return i.subscribe(l),u.subscribe(c),u.destroy=()=>{i.unsubscribe(l),u.unsubscribe(c),a.delete(u),u.cleanup()},u.dispose=u.destroy,a.add(u),u},follow(e){const{observer:t,subscribers:i}=o("follow",e),a=s(t.val()),u=e=>a.set(e);return t.subscribe(u),((e,t,o)=>{const s=e=>()=>{throw n.error("Store",`Store.${o}('${t}') is read-only. '${e}()' is not allowed.`),new r(`Store.${o}('${t}') is read-only.`)};e.set=s("set"),e.toggle=s("toggle"),e.reset=s("reset")})(a,e,"follow"),a.destroy=()=>{t.unsubscribe(u),i.delete(a),a.cleanup()},a.dispose=a.destroy,i.add(a),a},get(t){const r=e.get(t);return r?r.observer:(n.warn("Store",`Store.get('${t}') : store not found.`),null)},getWithSubscribers:t=>e.get(t)??null,delete(t){const r=e.get(t);r?(r.subscribers.forEach(e=>e.destroy()),r.subscribers.clear(),r.observer.cleanup(),e.delete(t)):n.warn("Store",`Store.delete('${t}') : store not found, nothing to delete.`)},group(e,t){"function"==typeof e&&(t=e,e="anonymous");const n=S();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,w(n,t)),o=$(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,w(n,t)),o=$(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{v.remove(n),s()},r}},{get(e,n){if("symbol"==typeof n||n.startsWith("$")||n in e)return e[n];if(e.has(n)){if(t.has(n))return t.get(n);const r=e.follow(n);return t.set(n,r),r}},set(e,t,o){throw n.error("Store",`Forbidden: You cannot overwrite the store key '${String(t)}'. Use .use('${String(t)}').set(value) instead.`),new r("Store structure is immutable. Use .set() on the observable.")},deleteProperty(e,t){throw new r("Store keys cannot be deleted.")}})},C=S();C.create("locale",navigator.language.split("-")[0]||"en");const O=(e,t)=>{const n=new Date(e);return{d:n,parts:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(n).reduce((e,{type:t,value:n})=>(e[t]=n,e),{})}},A=(e,t,n)=>{const r=e=>String(e).padStart(2,"0");return e.replace("YYYY",n.year).replace("YY",n.year.slice(-2)).replace("MMMM",n.month).replace("MMM",n.month.slice(0,3)).replace("MM",r(t.getMonth()+1)).replace("DD",r(t.getDate())).replace("D",t.getDate()).replace("HH",n.hour).replace("mm",n.minute).replace("ss",n.second)},E={currency:(e,t,{currency:n="XOF",notation:r,minimumFractionDigits:o,maximumFractionDigits:s}={})=>new Intl.NumberFormat(t,{style:"currency",currency:n,notation:r,minimumFractionDigits:o,maximumFractionDigits:s}).format(e),number:(e,t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}={})=>new Intl.NumberFormat(t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}).format(e),percent:(e,t,{decimals:n=1}={})=>new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:n}).format(e),date:(e,t,{format:n,dateStyle:r="long"}={})=>{if(n){const{d:r,parts:o}=O(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r}).format(new Date(e))},time:(e,t,{format:n,hour:r="2-digit",minute:o="2-digit",second:s}={})=>{if(n){const{d:r,parts:o}=O(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{hour:r,minute:o,second:s}).format(new Date(e))},datetime:(e,t,{format:n,dateStyle:r="long",hour:o="2-digit",minute:s="2-digit",second:i}={})=>{if(n){const{d:r,parts:o}=O(e,t);return A(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r,hour:o,minute:s,second:i}).format(new Date(e))},relative:(e,t,{unit:n="day",numeric:r="auto"}={})=>{const o=Math.round((e-Date.now())/864e5);return new Intl.RelativeTimeFormat(t,{numeric:r}).format(o,n)},plural:(e,t,{singular:n,plural:r}={})=>`${e} ${"one"===new Intl.PluralRules(t).select(e)?n:r}`};function N(e,t=null){e=p.isObservable(e)?e.val():e,this.$previousValue=null,this.$currentValue=e,this.$firstListener=null,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=p.isObject(e)?g(e):e))}Object.defineProperty(N.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),N.prototype.__$isObservable=!0;const x=function(){};function D(e,t=null){return new N(e,t)}N.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},N.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},N.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)},N.prototype.triggerWatchers=function(e){const t=this.$watchers,n=this.$previousValue,r=this.$currentValue,o=t.get(r),s=t.get(n);o&&o(!0,n,e),s&&s(!1,r,e)},N.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},N.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},N.prototype.assocTrigger=function(){this.$firstListener=null,this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?1===this.$listeners.length?(this.$firstListener=this.$listeners[0],this.trigger=this.triggerFirstListener):this.trigger=this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=x},N.prototype.trigger=x,N.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,this.trigger(),this.$previousValue=null)},N.prototype.$setWithInterceptor=function(e){let t="function"==typeof e?e(this.$currentValue):e;const n=this.$interceptor(t,this.$currentValue);void 0!==n&&(t=n),this.$updateWithNewValue(t)},N.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},N.prototype.set=N.prototype.$basicSet,N.prototype.val=function(){return this.$currentValue},N.prototype.disconnectAll=function(){this.$previousValue=null,this.$currentValue=null,this.$listeners=null,this.$watchers=null,this.trigger=x},N.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},N.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}f.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},N.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},N.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);t.__$isObservable&&(t=t.set.bind(t)),n?p.isArray(n.list)?n.list.push(t):(n=[n,t],t=e=>{for(let t=0,r=n.length;t<r;t++)n[t](e)},t.list=n,this.$watchers.set(e,t)):(n=t,this.$watchers.set(e,t)),this.assocTrigger()},N.prototype.off=function(e,t){if(!this.$watchers)return;const n=this.$watchers.get(e);if(!n)return;if(!t||!Array.isArray(n.list))return this.$watchers?.delete(e),void this.assocTrigger();const r=n.indexOf(t);n?.splice(r,1),1===n.length?this.$watchers.set(e,n[0]):0===n.length&&this.$watchers?.delete(e),this.assocTrigger()},N.prototype.once=function(e,t){const n="function"==typeof e?e:t=>t===e,r=e=>{n(e)&&(this.unsubscribe(r),t(e))};this.subscribe(r)},N.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},N.prototype.check=function(e){return new o(this,e)},N.prototype.transform=N.prototype.check,N.prototype.pluck=N.prototype.check,N.prototype.is=N.prototype.check,N.prototype.select=N.prototype.check,N.prototype.get=function(e){const t=this.$currentValue[e];return p.isObservable(t)?t.val():t},N.prototype.when=function(e){return new m(this,e)},N.prototype.equals=function(e){return p.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},N.prototype.toBool=function(){return!!this.$currentValue},N.prototype.toggle=function(){this.set(!this.$currentValue)},N.prototype.reset=function(){if(!this.configs?.reset)return;const e=p.isObject(this.$initialValue)?g(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},N.prototype.toString=function(){return String(this.$currentValue)},N.prototype.valueOf=function(){return this.$currentValue},N.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new o(n,e);const r=E[e],s=E.locale;return D.computed(()=>r(n.val(),s.val(),t),[n,s])},N.prototype.persist=function(e,t={}){let n=w(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=$(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this};const k=D,T=D;D.useValueProperty=function(e="value"){Object.defineProperty(N.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},D.getById=function(e){const t=f.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},D.cleanup=function(e){e.cleanup()},D.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{f.cleanup()}),setInterval(()=>f.cleanObservables(r),n)};const F=(e,t)=>{for(const n in t){const r=t[n];r.__$isObservable?(e.classes.toggle(n,r.val()),r.subscribe(t=>e.classes.toggle(n,t))):r.__$isObservableWhen?(e.classes.toggle(n,r.isActive()),r.subscribe(t=>e.classes.toggle(n,t))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null},I=(e,t)=>{for(const n in t){const r=t[n];r.__$isObservable?(e.style[n]=r.val(),r.subscribe(t=>e.style[n]=t)):e.style[n]=r}},_=(e,t,n)=>{const r=n.__$isObservable,o=r?n.val():n;if(p.isBoolean(o)?e[t]=o:e[t]=o===e.value,r){if("checked"===t)return"boolean"==typeof o?e.addEventListener("input",()=>n.set(e[t])):e.addEventListener("input",()=>n.set(e.value)),void n.subscribe(n=>e[t]=n);n.subscribe(n=>e[t]=n===e.value)}},M=(e,t)=>{for(const n in t){const r=n.toLowerCase();let o=t[n];if(null!=o)if(o.handleNdAttribute)o.handleNdAttribute(e,r,o);else{if("object"==typeof o){if("class"===r){F(e,o);continue}if("style"===r){I(e,o);continue}}d.has(r)?_(e,r,o):e.setAttribute(r,o)}}return e};function P(e){this.$hydrate=e}P.prototype.__$isTemplateBinding=!0,String.prototype.toNdElement=function(){return j.createStaticTextNode(null,this)},Element.prototype.toNdElement=function(){return this},Text.prototype.toNdElement=function(){return this},Comment.prototype.toNdElement=function(){return this},Document.prototype.toNdElement=function(){return this},DocumentFragment.prototype.toNdElement=function(){return this},N.prototype.toNdElement=function(){return j.createObservableNode(null,this)},o.prototype.toNdElement=N.prototype.toNdElement,i.prototype.toNdElement=function(){return this.$element??this.$build?.()??this.build?.()??null},Array.prototype.toNdElement=function(){const e=document.createDocumentFragment();for(let t=0,n=this.length;t<n;t++){const n=j.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return j.getChild(this())},P.prototype.toNdElement=function(){return j.createHydratableNode(null,this)};const V=(e,t=1e3)=>new Promise(n=>{let r=!1;const o=t=>{t&&t.target!==e||r||(r=!0,e.removeEventListener("transitionend",o),e.removeEventListener("animationend",o),clearTimeout(s),n())};e.addEventListener("transitionend",o),e.addEventListener("animationend",o);const s=setTimeout(o,t),i=window.getComputedStyle(e),a="0s"!==i.transitionDuration,u="0s"!==i.animationDuration;a||u||o()});i.prototype.transitionOut=function(e){const t=e+"-exit",n=this.$element;return this.beforeUnmount("transition-exit",async function(){n.classes.add(t),await V(n),n.classes.remove(t)}),this},i.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to",r=this.$element;return r.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.classes.remove(t),r.classes.add(n),V(r).then(()=>{r.classes.remove(n)})})})}),this},i.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},i.prototype.animate=function(e){const t=this.$element;return t.classes.add(e),V(t).then(()=>{t.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},N.prototype.handleNdAttribute=function(e,t){d.has(t)?_(e,t,this):((e,t,n)=>{const r="value"===t?t=>e.value=t:n=>e.setAttribute(t,n);if(n.subscribe(r),"value"===t)return e.value=n.val(),void e.addEventListener("input",()=>n.set(e.value));e.setAttribute(t,n.val())})(e,t,this)},P.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};let L=null;const j={createTextNode:()=>(L||(L=document.createTextNode(""),j.createTextNode=()=>L.cloneNode()),L.cloneNode()),createObservableNode:(e,t)=>{const n=j.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode:(e,t)=>{const n=j.createTextNode();return t.$hydrate(n),n},createStaticTextNode:(e,t)=>{let n=j.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement:e=>document.createElement(e).cloneNode(),createFragment:e=>R("Fragment"),bindTextNode:(e,t)=>{if(t?.__$isObservable)return t.subscribe(t=>e.nodeValue=t),void(e.nodeValue=t.val());e.nodeValue=t},processChildren:(e,t)=>{if(null===e)return;let n=j.getChild(e);n&&t.appendChild(n)},async safeRemove(e){await e.remove()},getChild:e=>{if(null==e)return null;if(e.toNdElement)do{if(e=e.toNdElement(),p.isElement(e))return e}while(e.toNdElement);return j.createStaticTextNode(null,e)},processAttributes:(e,t)=>{t&&M(e,t)},processAttributesDirect:M,processClassAttribute:F,processStyleAttribute:I};function R(e,t=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(s),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild,r.nativeAppend=r.append;const i=t?()=>!0:e=>e.firstChild===o&&e.lastChild===s;return r.appendElement=function(e,t=null){const n=o.parentNode,i=t||s;n!==r?n?.insertBefore(e,i):n.nativeInsertBefore(e,i)},r.appendChild=function(e,t=null){const o=s.parentNode;o?function(e,t,n){const o=p.isElement(t)?t:j.getChild(t);e!==r?i(e)&&n===s?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)}(o,e,t=t??s):n.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=s.parentNode;if(e===r)return;if(i(e))return void e.replaceChildren(o,s);let t,n=o.nextSibling;for(;n&&n!==s;)t=n.nextSibling,n.remove(),n=t},r.remove=function(){const e=s.parentNode;if(e===r)return;if(i(e))return void e.replaceChildren(o,s);let t,n=o.nextSibling;for(;n&&n!==s;)t=n.nextSibling,r.nativeAppend(n),n=t},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),s.remove()},r.replaceContent=function(e){const t=p.isElement(e)?e:j.getChild(e),n=s.parentNode;n&&(i(n)?n.replaceChildren(o,t,s):(r.removeChildren(),n.insertBefore(t,s)))},r.setContent=r.replaceContent,r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return s},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}DocumentFragment.prototype.setAttribute=()=>{};const q={configurable:!0,get(){return new i(this)}};Object.defineProperty(HTMLElement.prototype,"nd",q),Object.defineProperty(DocumentFragment.prototype,"nd",q),Object.defineProperty(i.prototype,"nd",{configurable:!0,get:function(){return this}}),["Click","DblClick","MouseDown","MouseEnter","MouseLeave","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Blur","Change","Focus","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","AfterPrint","BeforePrint","BeforeUnload","Error","HashChange","Load","Offline","Online","PageHide","PageShow","Resize","Scroll","Unload","Abort","CanPlay","CanPlayThrough","DurationChange","Emptied","Ended","LoadedData","LoadedMetadata","LoadStart","Pause","Play","Playing","Progress","RateChange","Seeked","Seeking","Stalled","Suspend","TimeUpdate","VolumeChange","Waiting","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["on"+e]=function(e=null){return this.$element.addEventListener(t,e),this}}),["Click","DblClick","MouseDown","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Change","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","BeforeUnload","HashChange","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onStop"+e]=function(e=null){return B(this.$element,t,e),this},i.prototype["onPreventStop"+e]=function(e=null){return U(this.$element,t,e),this}}),["Click","DblClick","MouseDown","MouseUp","Wheel","KeyDown","KeyPress","Invalid","Reset","Submit","DragOver","Drop","BeforeUnload","TouchCancel","TouchEnd","TouchMove","TouchStart","Copy","Cut","Paste","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onPrevent"+e]=function(e=null){return W(this.$element,t,e),this}}),i.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const W=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},B=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},U=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},H={getClasses(){return this.$element.className?.split(" ").filter(Boolean)},add(e){const t=this.getClasses();t.indexOf(e)>=0||(t.push(e),this.$element.className=t.join(" "))},remove(e){const t=this.getClasses(),n=t.indexOf(e);n<0||(t.splice(n,1),this.$element.className=t.join(" "))},toggle(e,t=void 0){const n=this.getClasses(),r=n.indexOf(e);if(r>=0){if(!0===t)return;n.splice(r,1)}else{if(!1===t)return;n.push(e)}this.$element.className=n.join(" ")},contains(e){return this.getClasses().indexOf(e)>=0}};Object.defineProperty(HTMLElement.prototype,"classes",{configurable:!0,get(){return{$element:this,...H}}});let z=e=>e;e.ArgTypes={},e.ArgTypes={string:()=>!0,number:()=>!0,boolean:()=>!0,observable:()=>!0,element:()=>!0,function:()=>!0,object:()=>!0,objectNotNull:()=>!0,children:()=>!0,attributes:()=>!0,optional:()=>!0,oneOf:()=>!0};const K=function(e,t=null){return e&&t?{props:e,children:t}:"object"!=typeof e||Array.isArray(e)||null===e||"Object"!==e.constructor.name||e.$hydrate?{props:t,children:e}:{props:e,children:t}},J=e=>p.isObservable(e)?j.createObservableNode(null,e):j.createStaticTextNode(null,e),Y=(e,t,n=null)=>{let{props:r,children:o=null}=K(t,n);return j.processAttributes(e,r),j.processChildren(o,e),e};function G(e,t=null){if(e){if(t){let n=null,r=(o,s)=>(n=document.createElement(e),r=(e,r)=>Y(t(n.cloneNode()),e,r),Y(t(n.cloneNode()),o,s));return(e,t)=>r(e,t)}let n=null,r=(t,o)=>(n=document.createElement(e),r=(e,t)=>Y(n.cloneNode(),e,t),Y(n.cloneNode(),t,o));return(e,t)=>r(e,t)}return()=>R("")}function Q(e){this.$element=e,this.$classes=null,this.$styles=null,this.$attrs=null,this.$ndMethods=null}i.prototype.attach=function(e,t){if("function"==typeof t){const n=this.$element;return n.nodeCloner=n.nodeCloner||new Q(n),n.nodeCloner.attach(e,t),n}return t.$hydrate(this.$element,e),this.$element},Q.prototype.__$isNodeCloner=!0;const X=(e,t,n)=>{for(const r in t)e[r]=t[r].apply(null,n);return e};Q.prototype.resolve=function(){if(this.$content)return;const e=[];if(this.$ndMethods&&e.push((e,t)=>{for(const n in this.$ndMethods)e.nd[n](this.$ndMethods[n].bind(e,...t))}),this.$classes){const t={};e.push((e,n)=>{j.processClassAttribute(e,X(t,this.$classes,n))})}if(this.$styles){const t={};e.push((e,n)=>{j.processStyleAttribute(e,X(t,this.$styles,n))})}if(this.$attrs){const t={};e.push((e,n)=>{j.processAttributes(e,X(t,this.$attrs,n))})}const t=e.length,n=this.$element;this.cloneNode=r=>{const o=n.cloneNode(!1);for(let n=0;n<t;n++)e[n](o,r);return o}},Q.prototype.cloneNode=function(e){return this.$element.cloneNode(!1)},Q.prototype.attach=function(e,t){return this.$ndMethods=this.$ndMethods||{},this.$ndMethods[e]=t,this},Q.prototype.text=function(e){return this.$content=e,"function"==typeof e?(this.cloneNode=t=>J(e.apply(null,t)),this):(this.cloneNode=t=>J(t[0][e]),this)},Q.prototype.attr=function(e,t){return"class"===e?(this.$classes=this.$classes||{},this.$classes[t.property]=t.value,this):"style"===e?(this.$styles=this.$styles||{},this.$styles[t.property]=t.value,this):(this.$attrs=this.$attrs||{},this.$attrs[e]=t.value,this)};function Z(e){let t=null;const n=e=>{const t=e.childNodes;let r=!!e.nodeCloner;const o=t.length;for(let e=0;e<o;e++){const o=t[e];o.nodeCloner&&(r=!0);n(o)&&(r=!0)}return r?e.nodeCloner?(e.nodeCloner.resolve(),e.dynamicCloneNode=n=>{const r=e.nodeCloner.cloneNode(n);for(let e=0;e<o;e++){const o=t[e].dynamicCloneNode(n);r.appendChild(o)}return r}):e.dynamicCloneNode=n=>{const r=e.cloneNode();for(let e=0;e<o;e++){const o=t[e].dynamicCloneNode(n);r.appendChild(o)}return r}:e.dynamicCloneNode=e.cloneNode.bind(e,!0),r};this.clone=r=>{const o=ee(this);return t=e(o),t.nodeCloner||(t.nodeCloner=new Q(t)),n(t),this.clone=t.dynamicCloneNode,t.dynamicCloneNode(r)};const r=(e,t)=>new P((n,r)=>{!function(e,t,n,r){n.nodeCloner=n.nodeCloner||new Q(n),"value"!==t?"attach"!==t?n.nodeCloner.attr(t,{property:r,value:e}):n.nodeCloner.attach(r,e):n.nodeCloner.text(e)}(e,t,n,r)});this.style=e=>r(e,"style"),this.class=e=>r(e,"class"),this.property=e=>this.value(e),this.value=e=>r(e,"value"),this.text=this.value,this.attr=e=>r(e,"attributes"),this.attach=e=>r(e,"attach"),this.callback=this.attach}const ee=e=>new Proxy(e,{get:(e,t)=>t in e||"symbol"==typeof t?e[t]:e.value(t)});function te(e){let t=null,n=null;this.render=r=>{if(t||(t=e(this)),!n)return t;for(const e in n){(0,n[e])(...r)}return t},this.createSection=(e,t)=>{n=n||{};const r=R("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}DocumentFragment.prototype.__IS_FRAGMENT=!0,Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new i(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){const t=(...n)=>{try{return this.apply(this,n)}catch(r){return e(r,{caller:t,args:n})}};return t},String.prototype.use=function(e){const t=this;return D.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return p.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return p.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!p.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return D.getById(n)}):this.valueOf()};const ne=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},re=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},oe=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{const o=t.get(r);if(o)return o;if(e.length>0)return(...n)=>{const o=e(...n,r);return t.set(r,o),o};const s=e(r);return t.set(r,s),s}})};function se(e){return e instanceof Date?e:new Date(e)}function ie(e,t){const n=se(e),r=se(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function ae(e){const t=se(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function ue(e,t){const n=p.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function le(e,t){const n=e.filter(p.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>p.isObservable(e)?e.val():e))}}function ce(e){return ue(e,(e,t)=>e===t)}function he(e){return ue(e,(e,t)=>e!==t)}function pe(e){return ue(e,(e,t)=>e>t)}function de(e){return ue(e,(e,t)=>e>=t)}function fe(e){return ue(e,(e,t)=>e<t)}function me(e){return ue(e,(e,t)=>e<=t)}function be(e,t=!0,n=""){return le([e,t,n],(e,[t,n,r])=>{if(!t)return!0;if(n)try{return new RegExp(t,r).test(String(e))}catch(e){return console.warn("Invalid regex pattern:",t,e),!1}return r&&""!==r?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function ye(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(p.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ge(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(p.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const ve=pe,we=de,$e=fe,Se=me,Ce=ce,Oe=he,Ae=ye,Ee=ge;function Ne(e,t=!1){return ue(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const xe=Ne;var De=Object.freeze({__proto__:null,all:Ae,and:ye,any:Ee,between:function(e,t){return le([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:xe,createFilter:ue,createMultiSourceFilter:le,custom:function(e,...t){const n=t.filter(p.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>p.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>ue(e,(e,t)=>!(!e||!t)&&se(e)>se(t)),dateBefore:e=>ue(e,(e,t)=>!(!e||!t)&&se(e)<se(t)),dateBetween:(e,t)=>le([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=se(e);return r>=se(t)&&r<=se(n)}),dateEquals:e=>ue(e,(e,t)=>!(!e||!t)&&ie(e,t)),dateTimeAfter:e=>ue(e,(e,t)=>!(!e||!t)&&se(e)>se(t)),dateTimeBefore:e=>ue(e,(e,t)=>!(!e||!t)&&se(e)<se(t)),dateTimeBetween:(e,t)=>le([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=se(e);return r>=se(t)&&r<=se(n)}),dateTimeEquals:e=>ue(e,(e,t)=>!(!e||!t)&&se(e).getTime()===se(t).getTime()),endsWith:function(e,t=!1){return ue(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:Ce,equals:ce,getSecondsOfDay:ae,greaterThan:pe,greaterThanOrEqual:de,gt:ve,gte:we,inArray:function(e){return ue(e,(e,t)=>t.includes(e))},includes:Ne,isEmpty:function(e=!0){return ue(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return ue(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:ie,lessThan:fe,lessThanOrEqual:me,lt:$e,lte:Se,match:be,neq:Oe,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:he,notIn:function(e){return ue(e,(e,t)=>!t.includes(e))},or:ge,startsWith:function(e,t=!1){return ue(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>ue(e,(e,t)=>!(!e||!t)&&ae(e)>ae(t)),timeBefore:e=>ue(e,(e,t)=>!(!e||!t)&&ae(e)<ae(t)),timeBetween:(e,t)=>le([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ae(e);return r>=ae(t)&&r<=ae(n)}),timeEquals:e=>ue(e,(e,t)=>{if(!e||!t)return!1;const n=se(e),r=se(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:se});const ke=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");N.call(this,e,t)};(ke.prototype=Object.create(N.prototype)).constructor=ke,ke.prototype.__$isObservableArray=!0,Object.defineProperty(ke.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{ke.prototype[e]=function(...t){const n=this.$currentValue[e].apply(this.$currentValue,t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{ke.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),ke.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},ke.prototype.at=function(e){return this.$currentValue[e]},ke.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},ke.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},ke.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},ke.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},ke.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},ke.prototype.isEmpty=function(){return 0===this.$currentValue.length},ke.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},ke.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=p.isObservable(o)?be(o,!1):o;if(e&&"object"==typeof e&&"callback"in e){if(r[t]=e.callback,e.dependencies){const t=Array.isArray(e.dependencies)?e.dependencies:[e.dependencies];n.push.apply(n,t)}}else r[t]="function"==typeof e?e:t=>t===e}const o=D.array(),s=Object.entries(r),i=()=>{const e=t.val().filter(e=>{for(const[t,n]of s)if("_"===t){if(!n(e))return!1}else if(!n(e[t]))return!1;return!0});o.set(e)};return n.forEach(e=>e.subscribe(i)),i(),o},ke.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},ke.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},ke.prototype.deepSubscribe=function(e){const t=b(()=>e(this.val())),n=new WeakMap,r=e=>{n.has(e)||(e?.__$isObservableArray?n.set(e,e.deepSubscribe(t)):e?.__$isObservable&&(e.subscribe(t),n.set(e,()=>e.unsubscribe(t))))},o=e=>{const t=n.get(e);t&&(t(),n.delete(e))};return this.$currentValue.forEach(r),this.subscribe(t),this.subscribe((e,t,n)=>{switch(n?.action){case"push":case"unshift":case"merge":n.args.forEach(r);break;case"splice":{const[e,t,...s]=n.args;n.result?.forEach(o),s.forEach(r);break}case"remove":o(n.result);break;case"clear":this.$currentValue.forEach(o)}}),()=>{this.$currentValue.forEach(o)}},D.array=function(e=[],t=null){return new ke(e,t)},D.batch=function(e){const t=D(0),n=function(){if(p.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const Te=function(e,t){N.call(this,e),this.$observables={},this.configs=t,this.$load(e);for(const t in e)Object.hasOwn(this,t)||Object.defineProperty(this,t,{get:()=>this.$observables[t],set:e=>this.$observables[t].set(e)})};Te.prototype=Object.create(N.prototype),Object.defineProperty(Te,"$value",{get(){return this.val()},set(e){this.set(e)}}),Te.prototype.__$isObservableObject=!0,Te.prototype.__isProxy__=!0,Te.prototype.$load=function(e){const t=this.configs;for(const n in e){const r=e[n];if(Array.isArray(r)){if(!1!==t?.deep){const e=r.map(e=>p.isJson(e)?D.json(e,t):p.isArray(e)?D.array(e,t):D(e,t));this.$observables[n]=D.array(e,t);continue}this.$observables[n]=D.array(r,t)}else p.isObservable(r)||p.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?D.object(r,t):D(r,t)}},Te.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(p.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>p.isObservable(e)?e.val():p.isProxy(e)?e.$value:e)),e[t]=r}else p.isProxy(n)?e[t]=n.$value:e[t]=n}return e},Te.prototype.$val=Te.prototype.val,Te.prototype.get=function(e){const t=this.$observables[e];return p.isObservable(t)?t.val():p.isProxy(t)?t.$value:t},Te.prototype.$get=Te.prototype.get,Te.prototype.set=function(e){const t=p.isProxy(e)?e.$value:e,n=this.configs;for(const r in t){const o=this.$observables[r],s=e[r],i=t[r];if(p.isObservable(o)){if(!p.isArray(i)){o.set(i);continue}const e=s.at(0);if(p.isObservable(e)||p.isProxy(e)){const t=i.map(t=>p.isProxy(e)?D.init(t,n):D(t,n));o.set(t);continue}o.set([...i]);continue}p.isProxy(o)?o.update(i):this[r]=i}},Te.prototype.$set=Te.prototype.set,Te.prototype.$updateWith=Te.prototype.set,Te.prototype.observables=function(){return Object.values(this.$observables)},Te.prototype.$observables=Te.prototype.observables,Te.prototype.keys=function(){return Object.keys(this.$observables)},Te.prototype.$keys=Te.prototype.keys,Te.prototype.clone=function(){return D.init(this.val(),this.configs)},Te.prototype.$clone=Te.prototype.clone,Te.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},Te.prototype.originalSubscribe=Te.prototype.subscribe,Te.prototype.subscribe=function(e){const t=this.observables(),n=b(()=>this.trigger());this.originalSubscribe(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];r.__$isObservableArray?r.deepSubscribe(n):r.subscribe(n)}},Te.prototype.configs=function(){return this.configs},Te.prototype.update=Te.prototype.set,D.init=function(e,t=null){return new Te(e,t)},D.arrayOfObject=function(e){return e.map(e=>D.object(e))},D.value=function(e){if(p.isObservable(e))return e.val();if(p.isProxy(e))return e.$value;if(p.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(D.value(r))}return t}return e},D.object=D.init,D.json=D.init,D.computed=function(e,t=[]){const n=new N(e()),o=b(()=>n.set(e()));if(p.isFunction(t)){if(!p.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{p.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Fe=new Set(["clear","push","unshift","replace"]);const Ie=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!p.isObservable(e)&&!p.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=R("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=j.getChild(t),p.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},_e=function(e,t,n=!0){if(!p.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=R("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=j.getChild(r),p.isFragment(r)&&(r=Array.from(r.children)),n&&s.set(e,r),r):null},a=e.val(),u=i(a);return u&&o.appendChild(u),e.subscribe(e=>{const t=i(e);o.remove(),t&&o.appendChild(t)}),o.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&s.delete(e),delete t[e]}})},Me=function(e,t,n){if(!p.isObservable(e))throw new r("Toggle : condition must be an Observable");return _e(e,{true:t,false:n})},Pe=G("div"),Ve=G("span"),Le=G("label"),je=G("p"),Re=je,qe=G("strong"),We=G("h1"),Be=G("h2"),Ue=G("h3"),He=G("h4"),ze=G("h5"),Ke=G("h6"),Je=G("br"),Ye=G("a"),Ge=G("pre"),Qe=G("code"),Xe=G("blockquote"),Ze=G("hr"),et=G("em"),tt=G("small"),nt=G("mark"),rt=G("del"),ot=G("ins"),st=G("sub"),it=G("sup"),at=G("abbr"),ut=G("cite"),lt=G("q"),ct=G("dl"),ht=G("dt"),pt=G("dd"),dt=G("form",function(e){return e.submit=function(t){return"function"==typeof t?(e.onSubmit(e=>{e.preventDefault(),t(e)}),e):(this.setAttribute("action",t),e)},e.multipartFormData=function(){return this.setAttribute("enctype","multipart/form-data"),e},e.post=function(t){return this.setAttribute("method","post"),this.setAttribute("action",t),e},e.get=function(e){this.setAttribute("method","get"),this.setAttribute("action",e)},e}),ft=G("input"),mt=G("textarea"),bt=mt,yt=G("select"),gt=G("fieldset"),vt=G("option"),wt=G("legend"),$t=G("datalist"),St=G("output"),Ct=G("progress"),Ot=G("meter"),At=G("button"),Et=G("main"),Nt=G("section"),xt=G("article"),Dt=G("aside"),kt=G("nav"),Tt=G("figure"),Ft=G("figcaption"),It=G("header"),_t=G("footer"),Mt=G("img"),Pt=function(e,t){return Mt({src:e,...t})},Vt=G("details"),Lt=G("summary"),jt=G("dialog"),Rt=G("menu"),qt=G("ol"),Wt=G("ul"),Bt=G("li"),Ut=Bt,Ht=qt,zt=Wt,Kt=G("audio"),Jt=G("video"),Yt=G("source"),Gt=G("track"),Qt=G("canvas"),Xt=G("svg"),Zt=G("time"),en=G("data"),tn=G("address"),nn=G("kbd"),rn=G("samp"),on=G("var"),sn=G("wbr"),an=G("caption"),un=G("table"),ln=G("thead"),cn=G("tfoot"),hn=G("tbody"),pn=G("tr"),dn=pn,fn=G("th"),mn=fn,bn=fn,yn=G("td"),gn=yn,vn=G("");var wn=Object.freeze({__proto__:null,Abbr:at,Address:tn,Anchor:R,Article:xt,Aside:Dt,AsyncImg:function(e,t,n,o){const s=p.isObservable(e)?e.val():e,i=Pt(t||s,n),a=new Image;return a.onload=()=>{p.isFunction(o)&&o(null,i),i.src=p.isObservable(e)?e.val():e},a.onerror=()=>{p.isFunction(o)&&o(new r("Image not found"))},p.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Kt,BaseImage:Mt,Blockquote:Xe,Br:Je,Button:At,Canvas:Qt,Caption:an,Checkbox:e=>ft({type:"checkbox",...e}),Cite:ut,Code:Qe,ColorInput:e=>ft({type:"color",...e}),Data:en,Datalist:$t,DateInput:e=>ft({type:"date",...e}),DateTimeInput:e=>ft({type:"datetime-local",...e}),Dd:pt,Del:rt,Details:Vt,Dialog:jt,Div:Pe,Dl:ct,Dt:ht,Em:et,EmailInput:e=>ft({type:"email",...e}),FieldSet:gt,FigCaption:Ft,Figure:Tt,FileInput:e=>ft({type:"file",...e}),Footer:_t,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){const i=R("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,h=e=>{if(!s)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&r.remove(),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},d=(e,s)=>{const i=((e,t,n)=>{if(p.isString(n)){const r=p.isObservable(e)?e.val():e,o=r?.[n];return p.isObservable(o)?o.val():o??t}return p.isFunction(n)?n(e,t):(p.isObservable(e)?e.val():e)??t})(e,s,o);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(s),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?D(s):null;let o=j.getChild(t(e,n));if(!o)throw new r("ForEach child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(o),indexObserver:n})}catch(e){throw n.error("ForEach",`Error creating element for key ${i}`,e),e}return i},f=()=>{const t=a.parentNode;if(!t)return;const n=p.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=d(n[e],e);c.add(t)}else for(const e in n){const t=d(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),h(),void l?.clear();h(t),l&&0!==l.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(l);for(const n in t){const r=t[n],o=u.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),l?.clear(),l=new Set([...c])};return f(),p.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n={}){const r=R("ForEach Array",n.isParentUniqueChild),o=r.endElement(),s=r.startElement();let i=new Map,a=0;const u=t.length>=2,l=e=>{r.removeChildren(),y(e),a=0},c=e=>i.get(e)?.child,h=(e,t=!0)=>{const n=i.get(e);if(n){if(t){const t=n.child;t?.remove(),i.delete(e)}n.indexObserver?.cleanup()}},d=e=>{const n=j.getChild(t(e,null));return i.set(e,{child:n,indexObserver:null}),n},f=(e,n)=>{const r=D(n),o=j.getChild(t(e,r));return i.set(e,{child:o,indexObserver:r}),o},m=(e,t)=>{const n=i.get(e);return n?(n.indexObserver?.set(t),n.child):d(e)};let b=d;const y=e=>{if(u){if(!n.shouldKeepItemsInCache)for(const[t,n]of i.entries())e&&e.includes(t)||h(t,!1)}else i.clear()},g=(e,t)=>{const n=i.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},v={toFragment(e){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(b(e[n],a)),a++;return t},add(e){r.appendElement(v.toFragment(e))},replace(e){l(e),v.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=c(r),t&&n.appendChild(t);t=null,r.appendElement(n,o)},removeOne(e,t){h(e,!0)},clear:l,merge(e){v.add(e)},push(e){let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),v.add(e,t)},populate([e,t,n]){const o=document.createDocumentFragment();for(let r=0;r<t;r++){const t=n(r);e.push(t),o.append(b(t,r)),a++}r.appendChild(o),o.replaceChildren()},unshift(e){r.insertBefore(v.toFragment(e),s.nextSibling)},splice(e,t){const[n,s,...i]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)g(e,u);else if(t.length>1){const e=c(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)g(t[e],u)}}else a=o;u.replaceChildren(),i&&i.length&&a&&r.insertBefore(v.toFragment(i),a.nextSibling)},reverse(e,t){v.reOrder(t)},sort(e,t){v.reOrder(t)},remove(e,t){v.removeOne(t)},pop(e,t){v.removeOne(t)},shift(e,t){v.removeOne(t)},swap(e,t){const n=o.parentNode;let r=c(t[0]),s=c(t[1]);if(!r||!s)return;const i=s.nextSibling;n.insertBefore(s,r),n.insertBefore(r,i),r=null,s=null}},w=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(((e=null)=>{b=Fe.has(e)?u?f:d:i.size?m:u?f:d})(n?.action),n?.action)v[n.action]&&v[n.action](n.args,n.result);else{if(0===a)return void v.add(e);v.replace(e)}((e,t=0)=>{if(!u)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=i.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===a)return;l()}};return e.val().length&&w(e.val(),0,{action:null}),p.isObservable(e)&&e.subscribe(w),r},Form:dt,Fragment:vn,H1:We,H2:Be,H3:Ue,H4:He,H5:ze,H6:Ke,Header:It,HiddenInput:e=>ft({type:"hidden",...e}),HideIf:function(e,t,n){const r=D(!e.val());return e.subscribe(e=>r.set(!e)),Ie(r,t,n)},HideIfNot:function(e,t,n){return Ie(e,t,n)},Hr:Ze,Img:Pt,Input:ft,Ins:ot,Kbd:nn,Label:Le,LazyImg:function(e,t){return Pt(e,{...t,loading:"lazy"})},Legend:wt,Li:Ut,Link:Ye,ListItem:Bt,Main:Et,Mark:nt,Match:_e,Menu:Rt,Meter:Ot,MonthInput:e=>ft({type:"month",...e}),NativeDocumentFragment:R,Nav:kt,NumberInput:e=>ft({type:"number",...e}),Ol:Ht,Option:vt,OrderedList:qt,Output:St,P:je,Paragraph:Re,PasswordInput:e=>ft({type:"password",...e}),Pre:Ge,Progress:Ct,Quote:lt,Radio:e=>ft({type:"radio",...e}),RangeInput:e=>ft({type:"range",...e}),ReadonlyInput:e=>ft({readonly:!0,...e}),Samp:rn,SearchInput:e=>ft({type:"search",...e}),Section:Nt,Select:yt,ShowIf:Ie,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!p.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return Ie(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!p.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return Ie(e.when(t),n)}throw new r("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>At(e,{type:"button",...t}),Small:tt,Source:Yt,Span:Ve,Strong:qe,Sub:st,SubmitButton:(e,t)=>At(e,{type:"submit",...t}),Summary:Lt,Sup:it,Svg:Xt,Switch:Me,TBody:hn,TBodyCell:gn,TFoot:cn,TFootCell:bn,THead:ln,THeadCell:mn,TRow:dn,Table:un,Td:yn,TelInput:e=>ft({type:"tel",...e}),TextArea:mt,TextInput:bt,Th:fn,Time:Zt,TimeInput:e=>ft({type:"time",...e}),Tr:pn,Track:Gt,Ul:zt,UnorderedList:Wt,UrlInput:e=>ft({type:"url",...e}),Var:on,Video:Jt,Wbr:sn,WeekInput:e=>ft({type:"week",...e}),When:function(e){if(!p.isObservable(e))throw new r("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,Me(e,t,n)),toNdElement:()=>Me(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=R("Portal "+n);return r.appendChild(j.getChild(e)),(t||document.body).appendChild(r),r}});const $n={};function Sn(e,t,n={}){e="/"+y(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},u=n.layout||null,l={},c=[],h=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=$n[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},p=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=h(t);return n&&n.pattern?(l[n.name]=n.pattern,c.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(e){e="/"+y(e,"/");if(!p().exec(e))return!1;const t={};return p().exec(e).forEach((e,n)=>{if(n<1)return;const r=c[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=h(n);if(t.params&&t.params[r.name])return t.params[r.name];throw new Error(`Missing parameter '${r.name}'`)}),r="object"==typeof t.query?new URLSearchParams(t.query).toString():null;return(t.basePath?t.basePath:"")+(r?`${n}?${r}`:n)}}class Cn extends Error{constructor(e,t){super(e),this.context=t}}const On=(e,t)=>{const n=[];return e.forEach(e=>{n.push(y(e.suffix,"/"))}),n.push(y(t,"/")),n.join("/")},An=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},En=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Nn=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function xn(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function Dn(){this.push=function(e){try{const{route:t,path:n,params:r,query:o}=this.resolve(e);if(window.history.state&&window.history.state.path===n)return;window.history.pushState({name:t.name(),params:r,path:n},t.name()||n,n),this.handleRouteChange(t,r,o,n)}catch(e){n.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:r,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:r},t.name()||r,r),this.handleRouteChange(t,o,{},r)}catch(e){n.error("HistoryRouter","Error in replaceState",e)}},this.forward=function(){window.history.forward()},this.back=function(){window.history.back()},this.init=function(e){window.addEventListener("popstate",e=>{try{if(!e.state||!e.state.path)return;const t=e.state.path,{route:n,params:r,query:o,path:s}=this.resolve(t);if(!n)return;this.handleRouteChange(n,r,o,s)}catch(e){n.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:r,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,r,o,s)}}function kn(){const e=[];let t=0;const n=n=>{const r=t+n;if(!e[r])return;t=r;const{route:o,params:s,query:i,path:a}=e[r];this.handleRouteChange(o,s,i,a)};this.push=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]&&e[t].path===i||(e.splice(t+1),e.push({route:r,params:o,query:s,path:i}),t++,this.handleRouteChange(r,o,s,i))},this.replace=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]={route:r,params:o,query:s,path:i},this.handleRouteChange(r,o,s,i)},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){const r=n||window.location.pathname+window.location.search,{route:o,params:s,query:i,path:a}=this.resolve(r);e.push({route:o,params:s,query:i,path:a}),t=0,this.handleRouteChange(o,s,i,a)}}function Tn(e,t){const n=new Map,r=new WeakMap,o=new WeakMap;let s=null,i=null;const a=(e,t)=>{const n=o.get(e);if(n)return n;let r=e;return p.isAnchor(e)||(r=R(t),r.appendChild(e)),o.set(e,r),r},u=()=>{p.isAnchor(i)&&i.remove()},l=()=>{t.nodeValue="",u(),s&&s.remove()},c=e=>{let t=e;return p.isNDElement(e)&&(t=e.node()),t},h=function(e,n,o){const h=n.layout();if(h)return void((e,n,o,i)=>{let h=c(n);const p=r.get(h);if(p){if(p===s){const e=a(h,i);return u(),void e.replaceContent(h)}return l(),s=p,a(h,i).replaceContent(h),void t.appendChild(s)}l();const d=a(h,i);s=j.getChild(e(d)),r.set(h,s),t.appendChild(s)})(h,e,0,o);let p=c(e);l(),t.appendChild(p),i=e},d=function(e){if(!e.route)return;const{route:t,params:r,query:o,path:s}=e;if(n.has(s)){const e=n.get(s);return void h(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),h(i,t,s)};return e.subscribe(d),d(e.currentState()),t}const Fn="default";function In(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)xn.apply(this,[]);else if("history"===e.mode)Dn.apply(this,[]);else{if("memory"!==e.mode)throw new Cn("Invalid router mode "+e.mode);kn.apply(this,[])}const a=function(e,t){for(const r of s)try{r(e),t&&t(e)}catch(e){n.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,n,s){const i=new Sn(On(o,e),n,{...s,middlewares:An(o,s?.middlewares||[]),name:s?.name?En(o,s.name):null,layout:s?.layout||Nn(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!p.isFunction(n))throw new Cn("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},n={}){const o=r[e];if(!o)throw new Cn(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(p.isJson(e)){const t=r[e.name];if(!t)throw new Cn(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[n,o]=e.split("?"),s="/"+y(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Cn(`Route not found for url: ${n}`);const u={};if(o){const e=new URLSearchParams(o).entries();for(const[t,n]of e)u[t]=n}return{route:a,params:i,query:u,path:e}},this.subscribe=function(e){if(!p.isFunction(e))throw new Cn("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const u={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||u,l)};return o[s](u,l)}}function _n(e,t){const{to:n,href:r,...o}=e;if(r){const e=In.get();return Ye({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||Fn,a=In.get(i);if(!a)throw new Cn('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return Ye({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}In.routers={},In.create=function(e,t){if(!p.isFunction(t))throw n.error("Router","Callback must be a function"),new Cn("Callback must be a function");const r=new In(e);return In.routers[e.name||Fn]=r,t(r),r.init(e.entry),r.mount=function(e){if(p.isString(e)){const t=document.querySelector(e);if(!t)throw new Cn(`Container not found for selector: ${e}`);e=t}else if(!p.isElement(e))throw new Cn("Container must be a string or an Element");return Tn(r,e)},r},In.get=function(e){const t=In.routers[e||Fn];if(!t)throw new Cn(`Router not found for name: ${e}`);return t},In.push=function(e,t=null){return In.get(t).push(e)},In.replace=function(e,t=null){return In.get(t).replace(e)},In.forward=function(e=null){return In.get(e).forward()},In.back=function(e=null){return In.get(e).back()},In.redirectTo=function(e,t=null,n=null){let r=e;const o=In.get(n);return o.resolve({name:e,params:t})&&(r={name:e,params:t}),console.log(r),o.push(r)},_n.blank=function(e,t){return Ye({...e,target:"_blank"},t)};var Mn=Object.freeze({__proto__:null,Link:_n,RouteParamPatterns:$n,Router:In});var Pn=Object.freeze({__proto__:null,memoize:e=>oe(e),once:e=>re(e),singleton:e=>ne(e)}),Vn=Object.freeze({__proto__:null,Cache:Pn,NativeFetch:function(e){const t={request:[],response:[]};this.interceptors={response:e=>{t.response.push(e)},request:e=>{t.request.push(e)}},this.fetch=async function(n,r,o={},s={}){if(s.formData){const e=new FormData;for(const t in o)e.append(t,o[t]);o=e}r.startsWith("http")||(r=(e.endsWith("/")?e:e+"/")+r);let i={method:n,headers:{...s.headers||{}}};if(o)if(o instanceof FormData)i.body=o;else if("GET"!==n)i.headers["Content-Type"]="application/json",i.body=JSON.stringify(o);else{const e=new URLSearchParams(o).toString();e&&(r=r+(r.includes("?")?"&":"?")+e)}for(const e of t.request)i=await e(i,r)||i;let a=await fetch(r,i);for(const e of t.response)a=await e(a,r)||a;const u=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok){const e=new Error(u?.message||a.statusText);throw e.status=a.status,e.data=u,e}return u},this.post=function(e,t={},n={}){return this.fetch("POST",e,t,n)},this.put=function(e,t={},n={}){return this.fetch("PUT",e,t,n)},this.delete=function(e,t={},n={}){return this.fetch("DELETE",e,t,n)},this.get=function(e,t={},n={}){return this.fetch("GET",e,t,n)}},filters:De});return e.$=k,e.ElementCreator=j,e.HtmlElementWrapper=G,e.NDElement=i,e.Observable=D,e.PluginsManager=null,e.SingletonView=te,e.Store=C,e.StoreFactory=S,e.TemplateCloner=Z,e.Validator=p,e.autoMemoize=oe,e.autoOnce=re,e.classPropertyAccumulator=function(e=[]){let t=p.isString(e)?e.split(" ").filter(Boolean):e;const n=p.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=J,e.cssPropertyAccumulator=function(e={}){let t=p.isString(e)?e.split(";").filter(Boolean):e;const n=p.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=wn,e.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n,s=t.get(r);if(s)return s;const i=e(...o);return t.set(r,i),i}},e.normalizeComponentArgs=K,e.obs=T,e.once=ne,e.router=Mn,e.useCache=function(e){let t=null,n=r=>{t=new Z(e);const o=t.clone(r);return n=t.clone,o};return e.length<2?(...e)=>n(e):(e,t,...r)=>n([e,t,...r])},e.useSingleton=function(e){let t=null;return function(...n){return t||(t=new te(e)),t.render(n)}},e.utils=Vn,e.withValidation=z,e}({});
1
+ var NativeDocument=function(e){"use strict";let t={};t={log(){},warn(){},error(){},disable(){}};var n=t;class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const s={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,executeMountedCallback(e){const t=s.mounted.get(e);if(t&&(t.inDom=!0,t.mounted))if(Array.isArray(t.mounted))for(const n of t.mounted)n(e);else t.mounted(e)},executeUnmountedCallback(e){const t=s.unmounted.get(e);if(!t)return;if(t.inDom=!1,!t.unmounted)return;let n=!1;if(Array.isArray(t.unmounted))for(const r of t.unmounted)!0===r(e)&&(n=!0);else n=!0===t.unmounted(e);n&&(t.disconnect(),e.nd?.remove())},checkMutation:function(e){for(const t of e){if(s.mountedSupposedSize>0)for(const e of t.addedNodes){if(s.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)s.executeMountedCallback(e)}if(s.unmountedSupposedSize>0)for(const e of t.removedNodes){if(s.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)s.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1,o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(s.mounted.delete(e),s.mountedSupposedSize--),r&&(s.unmounted.delete(e),s.unmountedSupposedSize--),o=null}};const i=(e,t)=>{o[e]?Array.isArray(o[e])?o[e].push(t):o[e]=[o[e],t]:o[e]=t};return{disconnect:()=>o?.disconnect(),mounted:t=>{i("mounted",t),s.mounted.set(e,o),n||(s.mountedSupposedSize++,n=!0)},unmounted:t=>{i("unmounted",t),s.unmounted.set(e,o),r||(s.unmountedSupposedSize++,r=!0)},off:(e,t)=>{((e,t)=>{if(o?.[e]){if(Array.isArray(o[e])){const n=o[e].indexOf(t);return n>-1&&o[e].splice(n,1),1===o[e].length&&(o[e]=o[e][0]),void(0===o[e].length&&(o[e]=null))}o[e]=null}})(e,t)}}}};s.observer=new MutationObserver(s.checkMutation),s.observer.observe(document.body,{childList:!0,subtree:!0});function i(e){this.$element=e}i.prototype.__$isNDElement=!0,i.prototype.valueOf=function(){return this.$element},i.prototype.ref=function(e,t){return e[t]=this.$element,this},i.prototype.refSelf=function(e,t){return e[t]=new i(this.$element),this},i.prototype.unmountChildren=function(){let e=this.$element;for(let t=0,n=e.children.length;t<n;t++){let n=e.children[t];n.$ndProx||n.nd?.remove(),n=null}return e=null,this},i.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,a.delete(e),e=null,this};const a=new WeakMap;i.prototype.lifecycle=function(e){const t=this.$element;a.has(t)||a.set(t,s.watch(t));const n=a.get(t);return e.mounted&&(this.$element.setAttribute("data--nd-mounted","1"),n.mounted(e.mounted)),e.unmounted&&(this.$element.setAttribute("data--nd-unmounted","1"),n.unmounted(e.unmounted)),this},i.prototype.mounted=function(e){return this.lifecycle({mounted:e})},i.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},i.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!s.beforeUnmount.has(n)){s.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=s.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return s.beforeUnmount.get(n).set(e,t),this},i.prototype.htmlElement=function(){return this.$element},i.prototype.node=i.prototype.htmlElement,i.prototype.shadow=function(e,t=null){const n=this.$element,r=Array.from(n.childNodes),o=n.attachShadow({mode:e});if(t){const e=document.createElement("style");e.textContent=t,o.appendChild(e)}return n.append=o.append.bind(o),n.appendChild=o.appendChild.bind(o),o.append(...r),this},i.prototype.openShadow=function(e=null){return this.shadow("open",e)},i.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},i.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const n=e[t];"function"==typeof n?this[t]=n.bind(this):console.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},i.extend=function(e){if(!e||"object"!=typeof e)throw new r("NDElement.extend() requires an object of methods");if(Array.isArray(e))throw new r("NDElement.extend() requires an object, not an array");const t=new Set(["constructor","valueOf","$element","$observer","ref","remove","cleanup","with","extend","attach","lifecycle","mounted","unmounted","unmountChildren"]);for(const o in e){if(!Object.hasOwn(e,o))continue;const s=e[o];if("function"==typeof s){if(t.has(o))throw n.error("NDElement.extend",`Cannot override protected method "${o}"`),new r(`Cannot override protected method "${o}"`);i.prototype[o]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),i.prototype[o]=s}else n.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return i};const l=3,u=8,c=11,h=[];h[1]=!0,h[l]=!0,h[c]=!0,h[u]=!0;const p={isObservable:e=>e?.__$isObservable,isTemplateBinding:e=>e?.__$isTemplateBinding,isObservableWhenResult:e=>e&&(e.__$isObservableWhen||"object"==typeof e&&"$target"in e&&"$observer"in e),isArrayObservable:e=>e?.__$isObservableArray,isProxy:e=>e?.__isProxy__,isObservableOrProxy:e=>p.isObservable(e)||p.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e&&null!==e,isJson:e=>!("object"!=typeof e||null===e||Array.isArray(e)||"Object"!==e.constructor.name),isElement:e=>e&&h[e.nodeType],isDOMNode:e=>h[e.nodeType],isFragment:e=>e?.nodeType===c,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof i,isValidChildren(e){Array.isArray(e)||(e=[e]);return 0===e.filter(e=>!this.isValidChild(e)).length},validateChildren(e){Array.isArray(e)||(e=[e]);const t=e.filter(e=>!this.isValidChild(e));if(t.length>0)throw new r(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(p.isObject(e)&&Object.values(e).some(e=>p.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new r("Event callback must be a function")}},d=new Set(["checked","selected","disabled","readonly","required","autofocus","multiple","autocomplete","hidden","contenteditable","spellcheck","translate","draggable","async","defer","autoplay","controls","loop","muted","download","reversed","open","default","formnovalidate","novalidate","scoped","itemscope","allowfullscreen","allowpaymentrequest","playsinline"]),f=function(){let e=0;const t=new Map;return{register(n){const r=++e;return t.set(r,new WeakRef(n)),r},unregister(e){t.delete(e)},getObservableById:e=>t.get(e)?.deref(),cleanup(){for(const[e,n]of t){const e=n.deref();e&&e.cleanup()}t.clear()},cleanObservables(e){if(t.size<e)return;let r=0;for(const[e,n]of t)n.deref()||(t.delete(e),r++);r>0&&n.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}(),m=function(e,t){this.$target=t,this.$observer=e};m.prototype.__$isObservableWhen=!0,m.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},m.prototype.val=function(){return this.$observer.$currentValue===this.$target},m.prototype.isMatch=m.prototype.val,m.prototype.isActive=m.prototype.val;const b=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},y=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},g=(e,t)=>{try{if(void 0!==window.structuredClone)return window.structuredClone(e)}catch(e){}if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(e=>g(e));if(p.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=g(e[t]));return n},v=(e,t)=>{const n=new Date(e);return{d:n,parts:new Intl.DateTimeFormat(t,{year:"numeric",month:"long",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(n).reduce((e,{type:t,value:n})=>(e[t]=n,e),{})}},w=(e,t,n)=>{const r=e=>String(e).padStart(2,"0");return e.replace("YYYY",n.year).replace("YY",n.year.slice(-2)).replace("MMMM",n.month).replace("MMM",n.month.slice(0,3)).replace("MM",r(t.getMonth()+1)).replace("DD",r(t.getDate())).replace("D",t.getDate()).replace("HH",n.hour).replace("mm",n.minute).replace("ss",n.second)},$={currency:(e,t,{currency:n="XOF",notation:r,minimumFractionDigits:o,maximumFractionDigits:s}={})=>new Intl.NumberFormat(t,{style:"currency",currency:n,notation:r,minimumFractionDigits:o,maximumFractionDigits:s}).format(e),number:(e,t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}={})=>new Intl.NumberFormat(t,{notation:n,minimumFractionDigits:r,maximumFractionDigits:o}).format(e),percent:(e,t,{decimals:n=1}={})=>new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:n}).format(e),date:(e,t,{format:n,dateStyle:r="long"}={})=>{if(n){const{d:r,parts:o}=v(e,t);return w(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r}).format(new Date(e))},time:(e,t,{format:n,hour:r="2-digit",minute:o="2-digit",second:s}={})=>{if(n){const{d:r,parts:o}=v(e,t);return w(n,r,o)}return new Intl.DateTimeFormat(t,{hour:r,minute:o,second:s}).format(new Date(e))},datetime:(e,t,{format:n,dateStyle:r="long",hour:o="2-digit",minute:s="2-digit",second:i}={})=>{if(n){const{d:r,parts:o}=v(e,t);return w(n,r,o)}return new Intl.DateTimeFormat(t,{dateStyle:r,hour:o,minute:s,second:i}).format(new Date(e))},relative:(e,t,{unit:n="day",numeric:r="auto"}={})=>{const o=Math.round((e-Date.now())/864e5);return new Intl.RelativeTimeFormat(t,{numeric:r}).format(o,n)},plural:(e,t,{singular:n,plural:r}={})=>`${e} ${"one"===new Intl.PluralRules(t).select(e)?n:r}`},C={getJson(e){let t=localStorage.getItem(e);try{return JSON.parse(t)}catch(t){throw new r("invalid_json:"+e)}},getNumber(e){return Number(this.get(e))},getBool(e){const t=this.get(e);return"true"===t||"1"===t},setJson(e,t){localStorage.setItem(e,JSON.stringify(t))},setBool(e,t){localStorage.setItem(e,t?"true":"false")},get:(e,t=null)=>localStorage.getItem(e)||t,set:(e,t)=>localStorage.setItem(e,t),remove(e){localStorage.removeItem(e)},has:e=>null!=localStorage.getItem(e)},S=(e,t)=>{if(!C.has(e))return t;switch(typeof t){case"object":return C.getJson(e)??t;case"boolean":return C.getBool(e)??t;case"number":return C.getNumber(e)??t;default:return C.get(e,t)??t}},O=e=>{switch(typeof e){case"object":return C.setJson;case"boolean":return C.setBool;default:return C.set}};function A(e,t=null){e=p.isObservable(e)?e.val():e,this.$previousValue=null,this.$currentValue=e,this.$firstListener=null,this.$listeners=null,this.$watchers=null,this.$memoryId=null,t&&(this.configs=t,t.reset&&(this.$initialValue=p.isObject(e)?g(e):e))}Object.defineProperty(A.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),A.prototype.__$isObservable=!0;const E=function(){};function N(e,t=null){return new A(e,t)}A.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},A.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},A.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)},A.prototype.triggerWatchers=function(e){const t=this.$watchers,n=this.$previousValue,r=this.$currentValue,o=t.get(r),s=t.get(n);o&&o(!0,n,e),s&&s(!1,r,e)},A.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},A.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},A.prototype.assocTrigger=function(){this.$firstListener=null,this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?1===this.$listeners.length?(this.$firstListener=this.$listeners[0],this.trigger=0===this.$firstListener.length?this.$firstListener:this.triggerFirstListener):this.trigger=this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=E},A.prototype.trigger=E,A.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,this.trigger(),this.$previousValue=null)},A.prototype.$setWithInterceptor=function(e){let t="function"==typeof e?e(this.$currentValue):e;const n=this.$interceptor(t,this.$currentValue);void 0!==n&&(t=n),this.$updateWithNewValue(t)},A.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},A.prototype.set=A.prototype.$basicSet,A.prototype.val=function(){return this.$currentValue},A.prototype.disconnectAll=function(){this.$previousValue=null,this.$currentValue=null,this.$listeners=null,this.$watchers=null,this.trigger=E},A.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},A.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}f.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},A.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},A.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);t.__$isObservable&&(t=t.set.bind(t)),n?p.isArray(n.list)?n.list.push(t):(n=[n,t],t=e=>{for(let t=0,r=n.length;t<r;t++)n[t](e)},t.list=n,this.$watchers.set(e,t)):(n=t,this.$watchers.set(e,t)),this.assocTrigger()},A.prototype.off=function(e,t){if(!this.$watchers)return;const n=this.$watchers.get(e);if(!n)return;if(!t||!Array.isArray(n.list))return this.$watchers?.delete(e),void this.assocTrigger();const r=n.indexOf(t);n?.splice(r,1),1===n.length?this.$watchers.set(e,n[0]):0===n.length&&this.$watchers?.delete(e),this.assocTrigger()},A.prototype.once=function(e,t){const n="function"==typeof e?e:t=>t===e,r=e=>{n(e)&&(this.unsubscribe(r),t(e))};this.subscribe(r)},A.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},A.prototype.check=function(e){return new o(this,e)},A.prototype.transform=A.prototype.check,A.prototype.pluck=A.prototype.check,A.prototype.is=A.prototype.check,A.prototype.select=A.prototype.check,A.prototype.get=function(e){const t=this.$currentValue[e];return p.isObservable(t)?t.val():t},A.prototype.when=function(e){return new m(this,e)},A.prototype.equals=function(e){return p.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},A.prototype.toBool=function(){return!!this.$currentValue},A.prototype.toggle=function(){this.set(!this.$currentValue)},A.prototype.reset=function(){if(!this.configs?.reset)return;const e=p.isObject(this.$initialValue)?g(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},A.prototype.toString=function(){return String(this.$currentValue)},A.prototype.valueOf=function(){return this.$currentValue},A.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new o(n,e);const r=$[e],s=$.locale;return N.computed(()=>r(n.val(),s.val(),t),[n,s])},A.prototype.persist=function(e,t={}){let n=S(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=O(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this};const x=N,D=N;N.useValueProperty=function(e="value"){Object.defineProperty(A.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},N.getById=function(e){const t=f.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},N.cleanup=function(e){e.cleanup()},N.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{f.cleanup()}),setInterval(()=>f.cleanObservables(r),n)};const k=(e,t)=>{for(const n in t){const r=t[n];r.__$isObservable?(e.classes.toggle(n,r.val()),r.subscribe(t=>e.classes.toggle(n,t))):r.__$isObservableWhen?(e.classes.toggle(n,r.isActive()),r.subscribe(t=>e.classes.toggle(n,t))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}},T=(e,t)=>{for(const n in t){const r=t[n];r.__$isObservable?(e.style[n]=r.val(),r.subscribe(t=>e.style[n]=t)):e.style[n]=r}},F=(e,t,n)=>{const r=n.__$isObservable,o=r?n.val():n;if(p.isBoolean(o)?e[t]=o:e[t]=o===e.value,r){if("checked"===t)return"boolean"==typeof o?e.addEventListener("input",()=>n.set(e[t])):e.addEventListener("input",()=>n.set(e.value)),void n.subscribe(n=>e[t]=n);n.subscribe(n=>e[t]=n===e.value)}},I=(e,t)=>{for(const n in t){const r=n.toLowerCase();let o=t[n];if(null!=o)if(o.handleNdAttribute)o.handleNdAttribute(e,r,o);else{if("object"==typeof o){if("class"===r){k(e,o);continue}if("style"===r){T(e,o);continue}}d.has(r)?F(e,r,o):e.setAttribute(r,o)}}return e};function M(e){this.$hydrate=e}M.prototype.__$isTemplateBinding=!0,String.prototype.toNdElement=function(){return L.createStaticTextNode(null,this)},Number.prototype.toNdElement=function(){return L.createStaticTextNode(null,this.toString())},Element.prototype.toNdElement=function(){return this},Text.prototype.toNdElement=function(){return this},Comment.prototype.toNdElement=function(){return this},Document.prototype.toNdElement=function(){return this},DocumentFragment.prototype.toNdElement=function(){return this},A.prototype.toNdElement=function(){return L.createObservableNode(null,this)},o.prototype.toNdElement=A.prototype.toNdElement,i.prototype.toNdElement=function(){return this.$element??this.$build?.()??this.build?.()??null},Array.prototype.toNdElement=function(){const e=document.createDocumentFragment();for(let t=0,n=this.length;t<n;t++){const n=L.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return L.getChild(this())},M.prototype.toNdElement=function(){return L.createHydratableNode(null,this)};const _=(e,t=1e3)=>new Promise(n=>{let r=!1;const o=t=>{t&&t.target!==e||r||(r=!0,e.removeEventListener("transitionend",o),e.removeEventListener("animationend",o),clearTimeout(s),n())};e.addEventListener("transitionend",o),e.addEventListener("animationend",o);const s=setTimeout(o,t),i=window.getComputedStyle(e),a="0s"!==i.transitionDuration,l="0s"!==i.animationDuration;a||l||o()});i.prototype.transitionOut=function(e){const t=e+"-exit",n=this.$element;return this.beforeUnmount("transition-exit",async function(){n.classes.add(t),await _(n),n.classes.remove(t)}),this},i.prototype.transitionIn=function(e){const t=e+"-enter-from",n=e+"-enter-to",r=this.$element;return r.classes.add(t),this.mounted(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.classes.remove(t),r.classes.add(n),_(r).then(()=>{r.classes.remove(n)})})})}),this},i.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},i.prototype.animate=function(e){const t=this.$element;return t.classes.add(e),_(t).then(()=>{t.classes.remove(e)}),this},String.prototype.handleNdAttribute=function(e,t){e.setAttribute(t,this)},A.prototype.handleNdAttribute=function(e,t){d.has(t)?F(e,t,this):((e,t,n)=>{const r="value"===t?t=>e.value=t:n=>e.setAttribute(t,n);if(n.subscribe(r),"value"===t)return e.value=n.val(),void e.addEventListener("input",()=>n.set(e.value));e.setAttribute(t,n.val())})(e,t,this)},M.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};let P=null;const L={createTextNode:()=>(P||(P=document.createTextNode(""),L.createTextNode=()=>P.cloneNode()),P.cloneNode()),createObservableNode:(e,t)=>{const n=L.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode:(e,t)=>{const n=L.createTextNode();return t.$hydrate(n),n},createStaticTextNode:(e,t)=>{let n=L.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement:e=>document.createElement(e).cloneNode(),createFragment:e=>j("Fragment"),bindTextNode:(e,t)=>{if(t?.__$isObservable)return t.subscribe(t=>e.nodeValue=t),void(e.nodeValue=t.val());e.nodeValue=t},processChildren:(e,t)=>{if(null===e)return;let n=L.getChild(e);n&&t.appendChild(n)},async safeRemove(e){await e.remove()},getChild:e=>{if(null==e)return null;if(e.toNdElement)do{if(e=e.toNdElement(),p.isElement(e))return e}while(e.toNdElement);return L.createStaticTextNode(null,e)},processAttributes:(e,t)=>{t&&I(e,t)},processAttributesDirect:I,processClassAttribute:k,processStyleAttribute:T};function V(e){const t=Reflect.construct(DocumentFragment,[],V),n=document.createComment((e||"")+" Anchor Sentinel"),r={};t.appendChild(n);const o=new MutationObserver(()=>{n.parentNode===t||n.parentNode instanceof DocumentFragment||r.connected&&r.connected(n.parentNode)});return o.observe(document,{childList:!0,subtree:!0}),t.$sentinel=n,t.$observer=o,t.$events=r,t}function j(e,t=!1){const n=new V(e);n.onConnectedOnce(e=>{t&&(console.log("Lets overwrite some functions with parent ",e),function(e,t){e.remove=()=>{e.append.apply(e,t.childNodes)},e.appendChild=e=>{e=p.isElement(e)?e:L.getChild(e),t.appendChild(e)},e.appendElement=e.appendChild,e.removeChildren=()=>{t.replaceChildren()},e.replaceContent=function(e){const n=p.isElement(e)?e:L.getChild(e);t.replaceChildren(n)},e.setContent=e.replaceContent,e.insertBefore=(e,n)=>{e=p.isElement(e)?e:L.getChild(e),t.insertBefore(e,n)},e.appendChildBefore=e.insertBefore,e.clear=e.remove,e.detach=e.remove,e.replaceChildren=function(){t.replaceChildren(...arguments)},e.getByIndex=e=>t.childNodes[e]}(n,e))}),n.__Anchor__=!0;const r=document.createComment("Anchor Start : "+e),o=document.createComment("/ Anchor End "+e);n.appendChild(r),n.appendChild(o),n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild,n.nativeAppend=n.append;const s=t?()=>!0:e=>e.firstChild===r&&e.lastChild===o;return n.appendElement=function(e){const t=r.parentNode;t!==n?t.insertBefore(e,o):t.nativeInsertBefore(e,o)},n.appendChild=function(e,t=null){const r=o.parentNode;r?function(e,t,r){const i=p.isElement(t)?t:L.getChild(t);e!==n?s(e)&&r===o?e.append(i,r):e.insertBefore(i,r):e.nativeInsertBefore(i,r)}(r,e,t=t??o):DebugManager.error("Anchor","Anchor : parent not found",e)},n.append=function(){return n.appendChild(Array.from(arguments))},n.removeChildren=function(){const e=o.parentNode;if(e===n)return;if(s(e))return void e.replaceChildren(r,o);let t,i=r.nextSibling;for(;i&&i!==o;)t=i.nextSibling,i.remove(),i=t},n.remove=function(){const e=o.parentNode;if(e===n)return;if(s(e))return n.append.apply(n,e.childNodes),void e.replaceChildren(r,o);let t,i=r.nextSibling;for(;i&&i!==o;)t=i.nextSibling,n.nativeAppend(i),i=t},n.removeWithAnchors=function(){n.removeChildren(),r.remove(),o.remove()},n.replaceContent=function(e){const t=p.isElement(e)?e:L.getChild(e),i=o.parentNode;i&&(s(i)?i.replaceChildren(r,t,o):(n.removeChildren(),i.insertBefore(t,o)))},n.setContent=n.replaceContent,n.insertBefore=function(e,t=null){n.appendChild(e,t)},n.endElement=function(){return o},n.startElement=function(){return r},n.restore=function(){n.appendChild(n)},n.clear=n.remove,n.detach=n.remove,n.getByIndex=function(e){let t=r;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==r?t:null},n}V.prototype=Object.create(DocumentFragment.prototype),V.prototype.constructor=V,V.prototype.onConnected=function(e){return this.$events.connected=e,this},V.prototype.onConnectedOnce=function(e){this.$events.connected=t=>{e(t),this.$observer.disconnect(),this.$events.connectedOnce=null}},DocumentFragment.prototype.setAttribute=()=>{};const R={configurable:!0,get(){return new i(this)}};Object.defineProperty(HTMLElement.prototype,"nd",R),Object.defineProperty(DocumentFragment.prototype,"nd",R),Object.defineProperty(i.prototype,"nd",{configurable:!0,get:function(){return this}}),["Click","DblClick","MouseDown","MouseEnter","MouseLeave","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Blur","Change","Focus","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","AfterPrint","BeforePrint","BeforeUnload","Error","HashChange","Load","Offline","Online","PageHide","PageShow","Resize","Scroll","Unload","Abort","CanPlay","CanPlayThrough","DurationChange","Emptied","Ended","LoadedData","LoadedMetadata","LoadStart","Pause","Play","Playing","Progress","RateChange","Seeked","Seeking","Stalled","Suspend","TimeUpdate","VolumeChange","Waiting","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["on"+e]=function(e=null){return this.$element.addEventListener(t,e),this}}),["Click","DblClick","MouseDown","MouseMove","MouseOut","MouseOver","MouseUp","Wheel","KeyDown","KeyPress","KeyUp","Change","Input","Invalid","Reset","Search","Select","Submit","Drag","DragEnd","DragEnter","DragLeave","DragOver","DragStart","Drop","BeforeUnload","HashChange","TouchCancel","TouchEnd","TouchMove","TouchStart","AnimationEnd","AnimationIteration","AnimationStart","TransitionEnd","Copy","Cut","Paste","FocusIn","FocusOut","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onStop"+e]=function(e=null){return B(this.$element,t,e),this},i.prototype["onPreventStop"+e]=function(e=null){return W(this.$element,t,e),this}}),["Click","DblClick","MouseDown","MouseUp","Wheel","KeyDown","KeyPress","Invalid","Reset","Submit","DragOver","Drop","BeforeUnload","TouchCancel","TouchEnd","TouchMove","TouchStart","Copy","Cut","Paste","ContextMenu"].forEach(e=>{const t=e.toLowerCase();i.prototype["onPrevent"+e]=function(e=null){return q(this.$element,t,e),this}}),i.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const q=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},B=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},W=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},U={getClasses(){return this.$element.className?.split(" ").filter(Boolean)},add(e){const t=this.getClasses();t.indexOf(e)>=0||(t.push(e),this.$element.className=t.join(" "))},remove(e){const t=this.getClasses(),n=t.indexOf(e);n<0||(t.splice(n,1),this.$element.className=t.join(" "))},toggle(e,t=void 0){const n=this.getClasses(),r=n.indexOf(e);if(r>=0){if(!0===t)return;n.splice(r,1)}else{if(!1===t)return;n.push(e)}this.$element.className=n.join(" ")},contains(e){return this.getClasses().indexOf(e)>=0}};Object.defineProperty(HTMLElement.prototype,"classes",{configurable:!0,get(){return{$element:this,...U}}});let H=e=>e;e.ArgTypes={},e.ArgTypes={string:()=>!0,number:()=>!0,boolean:()=>!0,observable:()=>!0,element:()=>!0,function:()=>!0,object:()=>!0,objectNotNull:()=>!0,children:()=>!0,attributes:()=>!0,optional:()=>!0,oneOf:()=>!0};const z=function(e,t=null){return e&&t?{props:e,children:t}:"object"!=typeof e||Array.isArray(e)||null===e||"Object"!==e.constructor.name||e.$hydrate?{props:t,children:e}:{props:e,children:t}},K=e=>e?e.toNdElement():L.createTextNode(),J=(e,t,n=null)=>{let{props:r,children:o=null}=z(t,n);return L.processAttributes(e,r),L.processChildren(o,e),e};function Y(e,t=null){if(e){if(t){let n=null,r=(o,s)=>(n=document.createElement(e),r=(e,r)=>J(t(n.cloneNode()),e,r),J(t(n.cloneNode()),o,s));return(e,t)=>r(e,t)}let n=null,r=(t,o)=>(n=document.createElement(e),r=(e,t)=>J(n.cloneNode(),e,t),J(n.cloneNode(),t,o));return(e,t)=>r(e,t)}return()=>j("")}function G(e){this.$element=e,this.$classes=null,this.$styles=null,this.$attrs=null,this.$ndMethods=null}i.prototype.attach=function(e,t){if("function"==typeof t){const n=this.$element;return n.nodeCloner=n.nodeCloner||new G(n),n.nodeCloner.attach(e,t),n}return t.$hydrate(this.$element,e),this.$element},G.prototype.__$isNodeCloner=!0;const Q=(e,t,n)=>{for(const r in t)e[r]=t[r].apply(null,n);return e};G.prototype.resolve=function(){if(this.$content)return;const e=[];if(this.$ndMethods){const t=Object.keys(this.$ndMethods);if(1===t.length){const n=t[0],r=this.$ndMethods[n];e.push((e,t)=>{e.nd[n](r.bind(e,...t))})}else e.push((e,t)=>{const n=e.nd;for(const r in this.$ndMethods)n[r](this.$ndMethods[r].bind(e,...t))})}if(this.$classes){const t={},n=Object.keys(this.$classes);if(1===n.length){const r=n[0],o=this.$classes[r];e.push((e,n)=>{t[r]=o.apply(null,n),L.processClassAttribute(e,t)})}else e.push((e,n)=>{L.processClassAttribute(e,Q(t,this.$classes,n))})}if(this.$styles){const t={},n=Object.keys(this.$styles);if(1===n.length){const r=n[0],o=this.$styles[r];e.push((e,n)=>{t[r]=o.apply(null,n),L.processStyleAttribute(e,t)})}else e.push((e,n)=>{L.processStyleAttribute(e,Q(t,this.$styles,n))})}if(this.$attrs){const t={},n=Object.keys(this.$attrs);if(1===n.length){const r=n[0],o=this.$attrs[r];e.push((e,n)=>{t[r]=o.apply(null,n),L.processAttributes(e,t)})}else e.push((e,n)=>{L.processAttributes(e,Q(t,this.$attrs,n))})}const t=e.length,n=this.$element;this.cloneNode=r=>{const o=n.cloneNode(!1);for(let n=0;n<t;n++)e[n](o,r);return o}},G.prototype.cloneNode=function(e){return this.$element.cloneNode(!1)},G.prototype.attach=function(e,t){return this.$ndMethods=this.$ndMethods||{},this.$ndMethods[e]=t,this},G.prototype.text=function(e){return this.$content=e,"function"==typeof e?(this.cloneNode=t=>K(e.apply(null,t)),this):(this.cloneNode=t=>K(t[0][e]),this)},G.prototype.attr=function(e,t){return"class"===e?(this.$classes=this.$classes||{},this.$classes[t.property]=t.value,this):"style"===e?(this.$styles=this.$styles||{},this.$styles[t.property]=t.value,this):(this.$attrs=this.$attrs||{},this.$attrs[e]=t.value,this)};function X(e){let t=null;const n=e=>{const t=e.childNodes;let r=!!e.nodeCloner;const o=t.length;for(let e=0;e<o;e++){const o=t[e];o.nodeCloner&&(r=!0);n(o)&&(r=!0)}return r?e.nodeCloner?(e.nodeCloner.resolve(),e.dynamicCloneNode=n=>{const r=e.nodeCloner.cloneNode(n);for(let e=0;e<o;e++)r.appendChild(t[e].dynamicCloneNode(n));return r}):e.dynamicCloneNode=n=>{const r=e.cloneNode();for(let e=0;e<o;e++)r.appendChild(t[e].dynamicCloneNode(n));return r}:e.dynamicCloneNode=e.cloneNode.bind(e,!0),r};this.clone=r=>{const o=Z(this);return t=e(o),t.nodeCloner||(t.nodeCloner=new G(t)),n(t),this.clone=t.dynamicCloneNode,t.dynamicCloneNode(r)};const r=(e,t)=>new M((n,r)=>{!function(e,t,n,r){n.nodeCloner=n.nodeCloner||new G(n),"value"!==t?"attach"!==t?n.nodeCloner.attr(t,{property:r,value:e}):n.nodeCloner.attach(r,e):n.nodeCloner.text(e)}(e,t,n,r)});this.style=e=>r(e,"style"),this.class=e=>r(e,"class"),this.property=e=>this.value(e),this.value=e=>r(e,"value"),this.text=this.value,this.attr=e=>r(e,"attributes"),this.attach=e=>r(e,"attach"),this.callback=this.attach}const Z=e=>new Proxy(e,{get:(e,t)=>t in e||"symbol"==typeof t?e[t]:e.value(t)});function ee(e){let t=null,n=null;this.render=r=>{if(t||(t=e(this)),!n)return t;for(const e in n){(0,n[e])(...r)}return t},this.createSection=(e,t)=>{n=n||{};const r=j("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}DocumentFragment.prototype.__IS_FRAGMENT=!0,Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t,n=()=>t;return()=>(t||(t=this.apply(this,e),t.cloneNode?n=()=>t.cloneNode(!0):t.$element&&(n=()=>new i(t.$element.cloneNode(!0)))),n())},Function.prototype.errorBoundary=function(e){const t=(...n)=>{try{return this.apply(this,n)}catch(r){return e(r,{caller:t,args:n})}};return t},String.prototype.use=function(e){const t=this;return N.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return p.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return p.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!p.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return N.getById(n)}):this.valueOf()};const te=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},ne=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},re=e=>{const t=new Map;return new Proxy({},{get:(n,r)=>{const o=t.get(r);if(o)return o;if(e.length>0)return(...n)=>{const o=e(...n,r);return t.set(r,o),o};const s=e(r);return t.set(r,s),s}})};function oe(e){return e instanceof Date?e:new Date(e)}function se(e,t){const n=oe(e),r=oe(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function ie(e){const t=oe(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function ae(e,t){const n=p.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function le(e,t){const n=e.filter(p.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>p.isObservable(e)?e.val():e))}}function ue(e){return ae(e,(e,t)=>e===t)}function ce(e){return ae(e,(e,t)=>e!==t)}function he(e){return ae(e,(e,t)=>e>t)}function pe(e){return ae(e,(e,t)=>e>=t)}function de(e){return ae(e,(e,t)=>e<t)}function fe(e){return ae(e,(e,t)=>e<=t)}function me(e,t=!0,n=""){return le([e,t,n],(e,[t,n,r])=>{if(!t)return!0;if(n)try{return new RegExp(t,r).test(String(e))}catch(e){return console.warn("Invalid regex pattern:",t,e),!1}return r&&""!==r?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function be(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(p.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function ye(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(p.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const ge=he,ve=pe,we=de,$e=fe,Ce=ue,Se=ce,Oe=be,Ae=ye;function Ee(e,t=!1){return ae(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const Ne=Ee;var xe=Object.freeze({__proto__:null,all:Oe,and:be,any:Ae,between:function(e,t){return le([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:Ne,createFilter:ae,createMultiSourceFilter:le,custom:function(e,...t){const n=t.filter(p.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>p.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateBetween:(e,t)=>le([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateEquals:e=>ae(e,(e,t)=>!(!e||!t)&&se(e,t)),dateTimeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)>oe(t)),dateTimeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e)<oe(t)),dateTimeBetween:(e,t)=>le([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=oe(e);return r>=oe(t)&&r<=oe(n)}),dateTimeEquals:e=>ae(e,(e,t)=>!(!e||!t)&&oe(e).getTime()===oe(t).getTime()),endsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:Ce,equals:ue,getSecondsOfDay:ie,greaterThan:he,greaterThanOrEqual:pe,gt:ge,gte:ve,inArray:function(e){return ae(e,(e,t)=>t.includes(e))},includes:Ee,isEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return ae(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:se,lessThan:de,lessThanOrEqual:fe,lt:we,lte:$e,match:me,neq:Se,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:ce,notIn:function(e){return ae(e,(e,t)=>!t.includes(e))},or:ye,startsWith:function(e,t=!1){return ae(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)>ie(t)),timeBefore:e=>ae(e,(e,t)=>!(!e||!t)&&ie(e)<ie(t)),timeBetween:(e,t)=>le([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=ie(e);return r>=ie(t)&&r<=ie(n)}),timeEquals:e=>ae(e,(e,t)=>{if(!e||!t)return!1;const n=oe(e),r=oe(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:oe});const De=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");A.call(this,e,t)};(De.prototype=Object.create(A.prototype)).constructor=De,De.prototype.__$isObservableArray=!0,Object.defineProperty(De.prototype,"length",{get(){return this.$currentValue.length}}),["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{De.prototype[e]=function(...t){const n=this.$currentValue[e].apply(this.$currentValue,t);return this.trigger({action:e,args:t,result:n}),n}}),["map","forEach","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{De.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}}),De.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$currentValue.length=0,this.trigger({action:"clear"}),!0},De.prototype.at=function(e){return this.$currentValue[e]},De.prototype.merge=function(e){this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})},De.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},De.prototype.swap=function(e,t){const n=this.$currentValue,r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const o=n[e],s=n[t];return n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]}),!0},De.prototype.remove=function(e){const t=this.$currentValue.splice(e,1);return 0===t.length?[]:(this.trigger({action:"remove",args:[e],result:t[0]}),t)},De.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},De.prototype.isEmpty=function(){return 0===this.$currentValue.length},De.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},De.prototype.where=function(e){const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=p.isObservable(o)?me(o,!1):o;if(e&&"object"==typeof e&&"callback"in e){if(r[t]=e.callback,e.dependencies){const t=Array.isArray(e.dependencies)?e.dependencies:[e.dependencies];n.push.apply(n,t)}}else r[t]="function"==typeof e?e:t=>t===e}const o=N.array(),s=Object.entries(r),i=()=>{const e=t.val().filter(e=>{for(const[t,n]of s)if("_"===t){if(!n(e))return!1}else if(!n(e[t]))return!1;return!0});o.set(e)};return n.forEach(e=>e.subscribe(i)),i(),o},De.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},De.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},De.prototype.deepSubscribe=function(e){const t=b(()=>e(this.val())),n=new WeakMap,r=e=>{n.has(e)||(e?.__$isObservableArray?n.set(e,e.deepSubscribe(t)):e?.__$isObservable&&(e.subscribe(t),n.set(e,()=>e.unsubscribe(t))))},o=e=>{const t=n.get(e);t&&(t(),n.delete(e))};return this.$currentValue.forEach(r),this.subscribe(t),this.subscribe((e,t,n)=>{switch(n?.action){case"push":case"unshift":case"merge":n.args.forEach(r);break;case"splice":{const[e,t,...s]=n.args;n.result?.forEach(o),s.forEach(r);break}case"remove":o(n.result);break;case"clear":this.$currentValue.forEach(o)}}),()=>{this.$currentValue.forEach(o)}},N.array=function(e=[],t=null){return new De(e,t)},N.batch=function(e){const t=N(0),n=function(){if(p.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const ke=function(e,t){A.call(this,e),this.$observables={},this.configs=t,this.$load(e);for(const t in e)Object.hasOwn(this,t)||Object.defineProperty(this,t,{get:()=>this.$observables[t],set:e=>this.$observables[t].set(e)})};ke.prototype=Object.create(A.prototype),Object.defineProperty(ke,"$value",{get(){return this.val()},set(e){this.set(e)}}),ke.prototype.__$isObservableObject=!0,ke.prototype.__isProxy__=!0,ke.prototype.$load=function(e){const t=this.configs;for(const n in e){const r=e[n];if(Array.isArray(r)){if(!1!==t?.deep){const e=r.map(e=>p.isJson(e)?N.json(e,t):p.isArray(e)?N.array(e,t):N(e,t));this.$observables[n]=N.array(e,t);continue}this.$observables[n]=N.array(r,t)}else p.isObservable(r)||p.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?N.object(r,t):N(r,t)}},ke.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(p.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>p.isObservable(e)?e.val():p.isProxy(e)?e.$value:e)),e[t]=r}else p.isProxy(n)?e[t]=n.$value:e[t]=n}return e},ke.prototype.$val=ke.prototype.val,ke.prototype.get=function(e){const t=this.$observables[e];return p.isObservable(t)?t.val():p.isProxy(t)?t.$value:t},ke.prototype.$get=ke.prototype.get,ke.prototype.set=function(e){const t=p.isProxy(e)?e.$value:e,n=this.configs;for(const r in t){const o=this.$observables[r],s=e[r],i=t[r];if(p.isObservable(o)){if(!p.isArray(i)){o.set(i);continue}const e=s.at(0);if(p.isObservable(e)||p.isProxy(e)){const t=i.map(t=>p.isProxy(e)?N.init(t,n):N(t,n));o.set(t);continue}o.set([...i]);continue}p.isProxy(o)?o.update(i):this[r]=i}},ke.prototype.$set=ke.prototype.set,ke.prototype.$updateWith=ke.prototype.set,ke.prototype.observables=function(){return Object.values(this.$observables)},ke.prototype.$observables=ke.prototype.observables,ke.prototype.keys=function(){return Object.keys(this.$observables)},ke.prototype.$keys=ke.prototype.keys,ke.prototype.clone=function(){return N.init(this.val(),this.configs)},ke.prototype.$clone=ke.prototype.clone,ke.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},ke.prototype.originalSubscribe=ke.prototype.subscribe,ke.prototype.subscribe=function(e){const t=this.observables(),n=b(()=>this.trigger());this.originalSubscribe(e);for(let e=0,r=t.length;e<r;e++){const r=t[e];r.__$isObservableArray?r.deepSubscribe(n):r.subscribe(n)}},ke.prototype.configs=function(){return this.configs},ke.prototype.update=ke.prototype.set,N.init=function(e,t=null){return new ke(e,t)},N.arrayOfObject=function(e){return e.map(e=>N.object(e))},N.value=function(e){if(p.isObservable(e))return e.val();if(p.isProxy(e))return e.$value;if(p.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(N.value(r))}return t}return e},N.object=N.init,N.json=N.init,N.computed=function(e,t=[]){const n=new A(e()),o=b(()=>n.set(e()));if(p.isFunction(t)){if(!p.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{p.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Te=function(){const e=new Map,t=new Map,o=(t,o)=>{const s=e.get(o);if(!s)throw n.error("Store",`Store.${t}('${o}') : store not found. Did you call Store.create('${o}') first?`),new r(`Store.${t}('${o}') : store not found.`);return s},s=(e,t={})=>Array.isArray(e)?N.array(e,t):"object"==typeof e?N.object(e,t):N(e,t);return new Proxy({create(t,o){if(e.has(t))throw n.warn("Store",`Store.create('${t}') : a store with this name already exists. Use Store.get('${t}') to retrieve it.`),new r(`Store.create('${t}') : a store with this name already exists.`);const i=s(o);return e.set(t,{observer:i,subscribers:new Set,resettable:!1,composed:!1}),i},createResettable(t,o){if(e.has(t))throw n.warn("Store",`Store.createResettable('${t}') : a store with this name already exists.`),new r(`Store.createResettable('${t}') : a store with this name already exists.`);const i=s(o,{reset:!0});return e.set(t,{observer:i,subscribers:new Set,resettable:!0,composed:!1}),i},createComposed(t,o,s){if(e.has(t))throw n.warn("Store",`Store.createComposed('${t}') : a store with this name already exists.`),new r(`Store.createComposed('${t}') : a store with this name already exists.`);if("function"!=typeof o)throw new r(`Store.createComposed('${t}') : computation must be a function.`);if(!Array.isArray(s)||0===s.length)throw new r(`Store.createComposed('${t}') : dependencies must be a non-empty array of store names.`);const i=s.map(o=>{if("string"!=typeof o)return o;const s=e.get(o);if(!s)throw n.error("Store",`Store.createComposed('${t}') : dependency '${o}' not found. Create it first.`),new r(`Store.createComposed('${t}') : dependency store '${o}' not found.`);return s.observer}),a=N.computed(o,i);return e.set(t,{observer:a,subscribers:new Set,resettable:!1,composed:!0}),a},has:t=>e.has(t),reset(e){const t=o("reset",e);if(t.composed)throw n.error("Store",`Store.reset('${e}') : composed stores cannot be reset. Their value is derived from dependencies.`),new r(`Store.reset('${e}') : composed stores cannot be reset.`);if(!t.resettable)throw n.error("Store",`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`),new r(`Store.reset('${e}') : this store is not resettable. Use Store.createResettable('${e}', value) instead of Store.create().`);t.observer.reset()},use(e){const t=o("use",e);if(t.composed)throw n.error("Store",`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`),new r(`Store.use('${e}') : composed stores are read-only. Use Store.follow('${e}') instead.`);const{observer:i,subscribers:a}=t,l=s(i.val()),u=e=>l.set(e),c=e=>i.set(e);return i.subscribe(u),l.subscribe(c),l.destroy=()=>{i.unsubscribe(u),l.unsubscribe(c),a.delete(l),l.cleanup()},l.dispose=l.destroy,a.add(l),l},follow(e){const{observer:t,subscribers:i}=o("follow",e),a=s(t.val()),l=e=>a.set(e);return t.subscribe(l),((e,t,o)=>{const s=e=>()=>{throw n.error("Store",`Store.${o}('${t}') is read-only. '${e}()' is not allowed.`),new r(`Store.${o}('${t}') is read-only.`)};e.set=s("set"),e.toggle=s("toggle"),e.reset=s("reset")})(a,e,"follow"),a.destroy=()=>{t.unsubscribe(l),i.delete(a),a.cleanup()},a.dispose=a.destroy,i.add(a),a},get(t){const r=e.get(t);return r?r.observer:(n.warn("Store",`Store.get('${t}') : store not found.`),null)},getWithSubscribers:t=>e.get(t)??null,delete(t){const r=e.get(t);r?(r.subscribers.forEach(e=>e.destroy()),r.subscribers.clear(),r.observer.cleanup(),e.delete(t)):n.warn("Store",`Store.delete('${t}') : store not found, nothing to delete.`)},group(e,t){"function"==typeof e&&(t=e,e="anonymous");const n=Te();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,S(n,t)),o=O(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,S(n,t)),o=O(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{C.remove(n),s()},r}},{get(e,n){if("symbol"==typeof n||n.startsWith("$")||n in e)return e[n];if(e.has(n)){if(t.has(n))return t.get(n);const r=e.follow(n);return t.set(n,r),r}},set(e,t,o){throw n.error("Store",`Forbidden: You cannot overwrite the store key '${String(t)}'. Use .use('${String(t)}').set(value) instead.`),new r("Store structure is immutable. Use .set() on the observable.")},deleteProperty(e,t){throw new r("Store keys cannot be deleted.")}})},Fe=Te();Fe.create("locale",navigator.language.split("-")[0]||"en");const Ie=new Set(["clear","push","unshift","replace"]);const Me=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!p.isObservable(e)&&!p.isObservableWhenResult(e))return n.warn("ShowIf","ShowIf : condition must be an Observable / "+r,e);const s=j("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=L.getChild(t),p.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},_e=function(e,t,n=!0){if(!p.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=j("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=L.getChild(r),p.isFragment(r)&&(r=Array.from(r.children)),n&&s.set(e,r),r):null},a=e.val(),l=i(a);return l&&o.appendChild(l),e.subscribe(e=>{const t=i(e);o.remove(),t&&o.appendChild(t)}),o.nd.with({add(n,r,o=!1){t[n]=r,o&&e.set(n)},remove(e){n&&s.delete(e),delete t[e]}})},Pe=function(e,t,n){if(!p.isObservable(e))throw new r("Toggle : condition must be an Observable");return _e(e,{true:t,false:n})},Le=Y("div"),Ve=Y("span"),je=Y("label"),Re=Y("p"),qe=Re,Be=Y("strong"),We=Y("h1"),Ue=Y("h2"),He=Y("h3"),ze=Y("h4"),Ke=Y("h5"),Je=Y("h6"),Ye=Y("br"),Ge=Y("a"),Qe=Y("pre"),Xe=Y("code"),Ze=Y("blockquote"),et=Y("hr"),tt=Y("em"),nt=Y("small"),rt=Y("mark"),ot=Y("del"),st=Y("ins"),it=Y("sub"),at=Y("sup"),lt=Y("abbr"),ut=Y("cite"),ct=Y("q"),ht=Y("dl"),pt=Y("dt"),dt=Y("dd"),ft=Y("form",function(e){return e.submit=function(t){return"function"==typeof t?(e.onSubmit(e=>{e.preventDefault(),t(e)}),e):(this.setAttribute("action",t),e)},e.multipartFormData=function(){return this.setAttribute("enctype","multipart/form-data"),e},e.post=function(t){return this.setAttribute("method","post"),this.setAttribute("action",t),e},e.get=function(e){this.setAttribute("method","get"),this.setAttribute("action",e)},e}),mt=Y("input"),bt=Y("textarea"),yt=bt,gt=Y("select"),vt=Y("fieldset"),wt=Y("option"),$t=Y("legend"),Ct=Y("datalist"),St=Y("output"),Ot=Y("progress"),At=Y("meter"),Et=Y("button"),Nt=Y("main"),xt=Y("section"),Dt=Y("article"),kt=Y("aside"),Tt=Y("nav"),Ft=Y("figure"),It=Y("figcaption"),Mt=Y("header"),_t=Y("footer"),Pt=Y("img"),Lt=function(e,t){return Pt({src:e,...t})},Vt=Y("details"),jt=Y("summary"),Rt=Y("dialog"),qt=Y("menu"),Bt=Y("ol"),Wt=Y("ul"),Ut=Y("li"),Ht=Ut,zt=Bt,Kt=Wt,Jt=Y("audio"),Yt=Y("video"),Gt=Y("source"),Qt=Y("track"),Xt=Y("canvas"),Zt=Y("svg"),en=Y("time"),tn=Y("data"),nn=Y("address"),rn=Y("kbd"),on=Y("samp"),sn=Y("var"),an=Y("wbr"),ln=Y("caption"),un=Y("table"),cn=Y("thead"),hn=Y("tfoot"),pn=Y("tbody"),dn=Y("tr"),fn=dn,mn=Y("th"),bn=mn,yn=mn,gn=Y("td"),vn=gn,wn=Y("");var $n=Object.freeze({__proto__:null,Abbr:lt,Address:nn,Anchor:j,Article:Dt,Aside:kt,AsyncImg:function(e,t,n,o){const s=p.isObservable(e)?e.val():e,i=Lt(t||s,n),a=new Image;return a.onload=()=>{p.isFunction(o)&&o(null,i),i.src=p.isObservable(e)?e.val():e},a.onerror=()=>{p.isFunction(o)&&o(new r("Image not found"))},p.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Jt,BaseImage:Pt,Blockquote:Ze,Br:Ye,Button:Et,Canvas:Xt,Caption:ln,Checkbox:e=>mt({type:"checkbox",...e}),Cite:ut,Code:Xe,ColorInput:e=>mt({type:"color",...e}),Data:tn,Datalist:Ct,DateInput:e=>mt({type:"date",...e}),DateTimeInput:e=>mt({type:"datetime-local",...e}),Dd:dt,Del:ot,Details:Vt,Dialog:Rt,Div:Le,Dl:ht,Dt:pt,Em:tt,EmailInput:e=>mt({type:"email",...e}),FieldSet:vt,FigCaption:It,Figure:Ft,FileInput:e=>mt({type:"file",...e}),Footer:_t,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){const i=j("ForEach"),a=i.endElement();i.startElement();let l=new Map,u=null;const c=new Set,h=e=>{if(!s)for(const[t,n]of l.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&r.remove(),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,l.delete(n.keyId),u&&u.delete(n.keyId)}},d=(e,s)=>{const i=((e,t,n)=>{if(p.isString(n)){const r=p.isObservable(e)?e.val():e,o=r?.[n];return p.isObservable(o)?o.val():o??t}return p.isFunction(n)?n(e,t):(p.isObservable(e)?e.val():e)??t})(e,s,o);if(l.has(i)){const e=l.get(i);if(e.indexObserver?.set(s),e.isNew=!1,e.child?.deref())return i;l.delete(i)}try{const n=t.length>=2?N(s):null;let o=L.getChild(t(e,n));if(!o)throw new r("ForEach child can't be null or undefined!");l.set(i,{keyId:i,isNew:!0,child:new WeakRef(o),indexObserver:n})}catch(e){throw n.error("ForEach",`Error creating element for key ${i}`,e),e}return i},f=()=>{const t=a.parentNode;if(!t)return;const n=p.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=d(n[e],e);c.add(t)}else for(const e in n){const t=d(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),h(),void u?.clear();h(t),u&&0!==u.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(u);for(const n in t){const r=t[n],o=l.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=l.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),u?.clear(),u=new Set([...c])};return f(),p.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n={}){const r=j("ForEach Array",n.isParentUniqueChild),o=r.endElement(),s=r.startElement();let i=new Map,a=0;const l=t.length>=2,u=e=>{r.removeChildren(),b(e),a=0},c=e=>i.get(e)?.child,h=(e,t=!0)=>{const n=i.get(e);if(n){if(t){const t=n.child;t?.remove(),i.delete(e)}n.indexObserver?.cleanup()}},d=e=>{const n=L.getChild(t(e,null));return i.set(e,{child:n,indexObserver:null}),n},f=(e,n)=>{const r=N(n),o=L.getChild(t(e,r));return i.set(e,{child:o,indexObserver:r}),o},m=(e,t)=>{const n=i.get(e);return n?(n.indexObserver?.set(t),n.child):d(e)};let b,y=d;b=l?n.shouldKeepItemsInCache?()=>{}:e=>{for(const[t,n]of i.entries())e&&e.includes(t)||h(t,!1)}:i.clear.bind(i);const g=(e,t)=>{const n=i.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},v={toFragment:e=>{const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(y(e[n],a)),a++;return t},add:e=>{r.appendElement(v.toFragment(e))},replace:e=>{u(e),v.add(e)},reOrder:e=>{let t=null;const n=document.createDocumentFragment();for(const r of e)t=c(r),t&&n.appendChild(t);t=null,r.appendElement(n,o)},removeOne:(e,t)=>{h(e,!0)},clear:u,merge:e=>{v.add(e)},push:e=>{let t=0;n.pushDelay&&(t=n.pushDelay(e)??0),v.add(e,t)},populate:([e,t,n])=>{const o=document.createDocumentFragment();for(let r=0;r<t;r++){const t=n(r);e.push(t),o.append(y(t,r)),a++}r.appendChild(o),o.replaceChildren()},unshift:e=>{r.insertBefore(v.toFragment(e),s.nextSibling)},splice:(e,t)=>{const[n,s,...i]=e;let a=null;const l=document.createDocumentFragment();if(t.length>0){let e=t[0];if(1===t.length)g(e,l);else if(t.length>1){const e=c(t[0]);a=e?.previousSibling;for(let e=0;e<t.length;e++)g(t[e],l)}}else a=o;l.replaceChildren(),i&&i.length&&a&&r.insertBefore(v.toFragment(i),a.nextSibling)},reverse:(e,t)=>{v.reOrder(t)},sort:(e,t)=>{v.reOrder(t)},remove:(e,t)=>{v.removeOne(t)},pop:(e,t)=>{v.removeOne(t)},shift:(e,t)=>{v.removeOne(t)},swap:(e,t)=>{const n=o.parentNode;let r=c(t[0]),s=c(t[1]);if(!r||!s)return;const i=s.nextSibling;n.insertBefore(s,r),n.insertBefore(r,i),r=null,s=null}},w=(e,t,n)=>{if("clear"!==n?.action&&e.length){if(((e=null)=>{y=Ie.has(e)?l?f:d:i.size?m:l?f:d})(n?.action),n?.action)v[n.action]&&v[n.action](n.args,n.result);else{if(0===a)return void v.add(e);v.replace(e)}((e,t=0)=>{if(!l)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=i.get(e[r]);t&&(t.indexObserver?.set(n),n++)}})(e,0)}else{if(0===a)return;u()}};return e.val().length&&w(e.val(),0,{action:null}),p.isObservable(e)&&e.subscribe(w),r},Form:ft,Fragment:wn,H1:We,H2:Ue,H3:He,H4:ze,H5:Ke,H6:Je,Header:Mt,HiddenInput:e=>mt({type:"hidden",...e}),HideIf:function(e,t,n){const r=N(!e.val());return e.subscribe(e=>r.set(!e)),Me(r,t,n)},HideIfNot:function(e,t,n){return Me(e,t,n)},Hr:et,Img:Lt,Input:mt,Ins:st,Kbd:rn,Label:je,LazyImg:function(e,t){return Lt(e,{...t,loading:"lazy"})},Legend:$t,Li:Ht,Link:Ge,ListItem:Ut,Main:Nt,Mark:rt,Match:_e,Menu:qt,Meter:At,MonthInput:e=>mt({type:"month",...e}),NativeDocumentFragment:j,Nav:Tt,NumberInput:e=>mt({type:"number",...e}),Ol:zt,Option:wt,OrderedList:Bt,Output:St,P:Re,Paragraph:qe,PasswordInput:e=>mt({type:"password",...e}),Pre:Qe,Progress:Ot,Quote:ct,Radio:e=>mt({type:"radio",...e}),RangeInput:e=>mt({type:"range",...e}),ReadonlyInput:e=>mt({readonly:!0,...e}),Samp:on,SearchInput:e=>mt({type:"search",...e}),Section:xt,Select:gt,ShowIf:Me,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!p.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return Me(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!p.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return Me(e.when(t),n)}throw new r("showWhen must have 2 or 3 arguments",{data:["showWhen(observer, target, view)","showWhen(observerWhenResult, view)"]})},SimpleButton:(e,t)=>Et(e,{type:"button",...t}),Small:nt,Source:Gt,Span:Ve,Strong:Be,Sub:it,SubmitButton:(e,t)=>Et(e,{type:"submit",...t}),Summary:jt,Sup:at,Svg:Zt,Switch:Pe,TBody:pn,TBodyCell:vn,TFoot:hn,TFootCell:yn,THead:cn,THeadCell:bn,TRow:fn,Table:un,Td:gn,TelInput:e=>mt({type:"tel",...e}),TextArea:bt,TextInput:yt,Th:mn,Time:en,TimeInput:e=>mt({type:"time",...e}),Tr:dn,Track:Qt,Ul:Kt,UnorderedList:Wt,UrlInput:e=>mt({type:"url",...e}),Var:sn,Video:Yt,Wbr:an,WeekInput:e=>mt({type:"week",...e}),When:function(e){if(!p.isObservable(e))throw new r("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,Pe(e,t,n)),toNdElement:()=>Pe(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=j("Portal "+n);return r.appendChild(L.getChild(e)),(t||document.body).appendChild(r),r}});const Cn={};function Sn(e,t,n={}){e="/"+y(e,"/").replace(/\/+/,"/");let r=null,o=n.name||null;const s=n.middlewares||[],i=n.shouldRebuild||!1,a=n.with||{},l=n.layout||null,u={},c=[],h=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=Cn[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},p=()=>{if(r)return r;const t=e.replace(/\{(.*?)}/gi,(e,t)=>{const n=h(t);return n&&n.pattern?(u[n.name]=n.pattern,c.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>l,this.match=function(e){e="/"+y(e,"/");if(!p().exec(e))return!1;const t={};return p().exec(e).forEach((e,n)=>{if(n<1)return;const r=c[n-1];t[r]=e}),t},this.url=function(t){const n=e.replace(/\{(.*?)}/gi,(e,n)=>{const r=h(n);if(t.params&&t.params[r.name])return t.params[r.name];throw new Error(`Missing parameter '${r.name}'`)}),r="object"==typeof t.query?new URLSearchParams(t.query).toString():null;return(t.basePath?t.basePath:"")+(r?`${n}?${r}`:n)}}class On extends Error{constructor(e,t){super(e),this.context=t}}const An=(e,t)=>{const n=[];return e.forEach(e=>{n.push(y(e.suffix,"/"))}),n.push(y(t,"/")),n.join("/")},En=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Nn=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},xn=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Dn(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:l}=e[o];r(l)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:l}=this.resolve(n);l!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:l}),t++,r(l))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function kn(){this.push=function(e){try{const{route:t,path:n,params:r,query:o}=this.resolve(e);if(window.history.state&&window.history.state.path===n)return;window.history.pushState({name:t.name(),params:r,path:n},t.name()||n,n),this.handleRouteChange(t,r,o,n)}catch(e){n.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:r,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:r},t.name()||r,r),this.handleRouteChange(t,o,{},r)}catch(e){n.error("HistoryRouter","Error in replaceState",e)}},this.forward=function(){window.history.forward()},this.back=function(){window.history.back()},this.init=function(e){window.addEventListener("popstate",e=>{try{if(!e.state||!e.state.path)return;const t=e.state.path,{route:n,params:r,query:o,path:s}=this.resolve(t);if(!n)return;this.handleRouteChange(n,r,o,s)}catch(e){n.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:r,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,r,o,s)}}function Tn(){const e=[];let t=0;const n=n=>{const r=t+n;if(!e[r])return;t=r;const{route:o,params:s,query:i,path:a}=e[r];this.handleRouteChange(o,s,i,a)};this.push=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]&&e[t].path===i||(e.splice(t+1),e.push({route:r,params:o,query:s,path:i}),t++,this.handleRouteChange(r,o,s,i))},this.replace=function(n){const{route:r,params:o,query:s,path:i}=this.resolve(n);e[t]={route:r,params:o,query:s,path:i},this.handleRouteChange(r,o,s,i)},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){const r=n||window.location.pathname+window.location.search,{route:o,params:s,query:i,path:a}=this.resolve(r);e.push({route:o,params:s,query:i,path:a}),t=0,this.handleRouteChange(o,s,i,a)}}function Fn(e,t){const n=new Map,r=new WeakMap,o=new WeakMap;let s=null,i=null;const a=(e,t)=>{const n=o.get(e);if(n)return n;let r=e;return p.isAnchor(e)||(r=j(t),r.appendChild(e)),o.set(e,r),r},l=()=>{p.isAnchor(i)&&i.remove()},u=()=>{t.nodeValue="",l(),s&&s.remove()},c=e=>{let t=e;return p.isNDElement(e)&&(t=e.node()),t},h=function(e,n,o){const h=n.layout();if(h)return void((e,n,o,i)=>{let h=c(n);const p=r.get(h);if(p){if(p===s){const e=a(h,i);return l(),void e.replaceContent(h)}return u(),s=p,a(h,i).replaceContent(h),void t.appendChild(s)}u();const d=a(h,i);s=L.getChild(e(d)),r.set(h,s),t.appendChild(s)})(h,e,0,o);let p=c(e);u(),t.appendChild(p),i=e},d=function(e){if(!e.route)return;const{route:t,params:r,query:o,path:s}=e;if(n.has(s)){const e=n.get(s);return void h(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),h(i,t,s)};return e.subscribe(d),d(e.currentState()),t}const In="default";function Mn(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Dn.apply(this,[]);else if("history"===e.mode)kn.apply(this,[]);else{if("memory"!==e.mode)throw new On("Invalid router mode "+e.mode);Tn.apply(this,[])}const a=function(e,t){for(const r of s)try{r(e),t&&t(e)}catch(e){n.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,n,s){const i=new Sn(An(o,e),n,{...s,middlewares:En(o,s?.middlewares||[]),name:s?.name?Nn(o,s.name):null,layout:s?.layout||xn(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!p.isFunction(n))throw new On("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},n={}){const o=r[e];if(!o)throw new On(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if(p.isJson(e)){const t=r[e.name];if(!t)throw new On(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[n,o]=e.split("?"),s="/"+y(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new On(`Route not found for url: ${n}`);const l={};if(o){const e=new URLSearchParams(o).entries();for(const[t,n]of e)l[t]=n}return{route:a,params:i,query:l,path:e}},this.subscribe=function(e){if(!p.isFunction(e))throw new On("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const l={...i},u=e=>{if(s++,!(s>=o.length))return o[s](e||l,u)};return o[s](l,u)}}function _n(e,t){const{to:n,href:r,...o}=e;if(r){const e=Mn.get();return Ge({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||In,a=Mn.get(i);if(!a)throw new On('Router not found "'+i+'" for link "'+s.name+'"');const l=a.generateUrl(s.name,s.params,s.query);return Ge({...o,href:l},t).nd.onPreventClick(()=>{a.push(l)})}Mn.routers={},Mn.create=function(e,t){if(!p.isFunction(t))throw n.error("Router","Callback must be a function"),new On("Callback must be a function");const r=new Mn(e);return Mn.routers[e.name||In]=r,t(r),r.init(e.entry),r.mount=function(e){if(p.isString(e)){const t=document.querySelector(e);if(!t)throw new On(`Container not found for selector: ${e}`);e=t}else if(!p.isElement(e))throw new On("Container must be a string or an Element");return Fn(r,e)},r},Mn.get=function(e){const t=Mn.routers[e||In];if(!t)throw new On(`Router not found for name: ${e}`);return t},Mn.push=function(e,t=null){return Mn.get(t).push(e)},Mn.replace=function(e,t=null){return Mn.get(t).replace(e)},Mn.forward=function(e=null){return Mn.get(e).forward()},Mn.back=function(e=null){return Mn.get(e).back()},Mn.redirectTo=function(e,t=null,n=null){let r=e;const o=Mn.get(n);return o.resolve({name:e,params:t})&&(r={name:e,params:t}),console.log(r),o.push(r)},_n.blank=function(e,t){return Ge({...e,target:"_blank"},t)};var Pn=Object.freeze({__proto__:null,Link:_n,RouteParamPatterns:Cn,Router:Mn});var Ln=Object.freeze({__proto__:null,memoize:e=>re(e),once:e=>ne(e),singleton:e=>te(e)}),Vn=Object.freeze({__proto__:null,Cache:Ln,NativeFetch:function(e){const t={request:[],response:[]};this.interceptors={response:e=>{t.response.push(e)},request:e=>{t.request.push(e)}},this.fetch=async function(n,r,o={},s={}){if(s.formData){const e=new FormData;for(const t in o)e.append(t,o[t]);o=e}r.startsWith("http")||(r=(e.endsWith("/")?e:e+"/")+r);let i={method:n,headers:{...s.headers||{}}};if(o)if(o instanceof FormData)i.body=o;else if("GET"!==n)i.headers["Content-Type"]="application/json",i.body=JSON.stringify(o);else{const e=new URLSearchParams(o).toString();e&&(r=r+(r.includes("?")?"&":"?")+e)}for(const e of t.request)i=await e(i,r)||i;let a=await fetch(r,i);for(const e of t.response)a=await e(a,r)||a;const l=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok){const e=new Error(l?.message||a.statusText);throw e.status=a.status,e.data=l,e}return l},this.post=function(e,t={},n={}){return this.fetch("POST",e,t,n)},this.put=function(e,t={},n={}){return this.fetch("PUT",e,t,n)},this.delete=function(e,t={},n={}){return this.fetch("DELETE",e,t,n)},this.get=function(e,t={},n={}){return this.fetch("GET",e,t,n)}},filters:xe});return e.$=x,e.ElementCreator=L,e.HtmlElementWrapper=Y,e.NDElement=i,e.Observable=N,e.PluginsManager=null,e.SingletonView=ee,e.Store=Fe,e.StoreFactory=Te,e.TemplateCloner=X,e.Validator=p,e.autoMemoize=re,e.autoOnce=ne,e.classPropertyAccumulator=function(e=[]){let t=p.isString(e)?e.split(" ").filter(Boolean):e;const n=p.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},e.createTextNode=K,e.cssPropertyAccumulator=function(e={}){let t=p.isString(e)?e.split(";").filter(Boolean):e;const n=p.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},e.elements=$n,e.memoize=e=>{const t=new Map;return(...n)=>{const[r,...o]=n,s=t.get(r);if(s)return s;const i=e(...o);return t.set(r,i),i}},e.normalizeComponentArgs=z,e.obs=D,e.once=te,e.router=Pn,e.useCache=function(e){let t=null,n=r=>{t=new X(e);const o=t.clone(r);return n=t.clone,o};return e.length<2?(...e)=>n(e):(e,t,...r)=>n([e,t,...r])},e.useSingleton=function(e){let t=null;return function(...n){return t||(t=new ee(e)),t.render(n)}},e.utils=Vn,e.withValidation=H,e}({});
@@ -55,7 +55,7 @@ const timer = Div("Timer: 0")
55
55
  ```javascript
56
56
  const focusInput = Input({ placeholder: "Auto-focused" })
57
57
  .nd.mounted(element => {
58
- Òelement.focus();
58
+ element.focus();
59
59
  });
60
60
  ```
61
61
 
package/elements.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import './index.def';
2
- import Anchor from "./src/core/elements/anchor";
3
- export { createPortal } from "./src/core/elements/anchor";
2
+ import Anchor from "./src/core/elements/anchor/anchor";
3
+ export { createPortal } from "./src/core/elements/anchor/anchor";
4
4
  export * from './src/core/elements/index';
5
5
 
6
6
  export { Anchor, Anchor as NativeDocumentFragment };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.117",
3
+ "version": "1.0.119",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -6,7 +6,6 @@ import PluginsManager from "../../core/utils/plugins-manager";
6
6
  import Validator from "../../core/utils/validator";
7
7
  import {ObservableWhen} from "./ObservableWhen";
8
8
  import {deepClone} from "../utils/helpers";
9
- import {Store} from "./Store";
10
9
  import { Formatters} from "../utils/formatters";
11
10
  import {Observable} from "./Observable";
12
11
  import {$getFromStorage, $saveToStorage} from "../utils/localstorage";
@@ -121,7 +120,7 @@ ObservableItem.prototype.assocTrigger = function() {
121
120
  if(this.$listeners?.length) {
122
121
  if(this.$listeners.length === 1) {
123
122
  this.$firstListener = this.$listeners[0];
124
- this.trigger = this.triggerFirstListener
123
+ this.trigger = this.$firstListener.length === 0 ? this.$firstListener : this.triggerFirstListener
125
124
  }
126
125
  else {
127
126
  this.trigger = this.triggerListeners;
@@ -0,0 +1,41 @@
1
+
2
+
3
+
4
+ export default function AnchorWithSentinel(name) {
5
+ const instance = Reflect.construct(DocumentFragment, [], AnchorWithSentinel);
6
+ const sentinel = document.createComment((name || '') + ' Anchor Sentinel');
7
+ const events = {};
8
+
9
+ instance.appendChild(sentinel);
10
+
11
+ const observer = new MutationObserver(() => {
12
+ if (sentinel.parentNode !== instance && !(sentinel.parentNode instanceof DocumentFragment)) {
13
+ events.connected && events.connected(sentinel.parentNode);
14
+ }
15
+ });
16
+
17
+ observer.observe(document, { childList: true, subtree: true });
18
+
19
+
20
+ instance.$sentinel = sentinel;
21
+ instance.$observer = observer;
22
+ instance.$events = events;
23
+
24
+ return instance;
25
+ }
26
+
27
+ AnchorWithSentinel.prototype = Object.create(DocumentFragment.prototype);
28
+ AnchorWithSentinel.prototype.constructor = AnchorWithSentinel;
29
+
30
+ AnchorWithSentinel.prototype.onConnected = function(callback) {
31
+ this.$events.connected = callback;
32
+ return this;
33
+ };
34
+
35
+ AnchorWithSentinel.prototype.onConnectedOnce = function(callback) {
36
+ this.$events.connected = (parent) => {
37
+ callback(parent);
38
+ this.$observer.disconnect();
39
+ this.$events.connectedOnce = null;
40
+ };
41
+ };
@@ -1,10 +1,25 @@
1
- import Validator from "../utils/validator";
2
- import DebugManager from "../utils/debug-manager";
3
- import {ElementCreator} from "../wrappers/ElementCreator";
4
-
1
+ import Validator from "../../utils/validator";
2
+ import {ElementCreator} from "../../wrappers/ElementCreator";
3
+ import AnchorWithSentinel from "./anchor-with-sentinel";
4
+ import oneChildAnchorOverwriting from "./one-child-anchor-overwriting";
5
5
 
6
6
  export default function Anchor(name, isUniqueChild = false) {
7
- const anchorFragment = document.createDocumentFragment();
7
+ const anchorFragment = new AnchorWithSentinel(name);
8
+
9
+ /**
10
+ * State :
11
+ * 1. Not injected in the DOM
12
+ * 2. Injected in the DOM and should be the only child of parent
13
+ * 3. Injected in the DOM and the parent may have other children
14
+ */
15
+
16
+ anchorFragment.onConnectedOnce((parent) => {
17
+ if(isUniqueChild) {
18
+ console.log('Lets overwrite some functions with parent ', parent);
19
+ oneChildAnchorOverwriting(anchorFragment, parent);
20
+ }
21
+ });
22
+
8
23
  anchorFragment.__Anchor__ = true;
9
24
 
10
25
  const anchorStart = document.createComment('Anchor Start : '+name);
@@ -18,8 +33,7 @@ export default function Anchor(name, isUniqueChild = false) {
18
33
  anchorFragment.nativeAppend = anchorFragment.append;
19
34
 
20
35
  const isParentUniqueChild = isUniqueChild
21
- ? () => true
22
- : (parent) => (parent.firstChild === anchorStart && parent.lastChild === anchorEnd)
36
+ ? () => true: (parent) => (parent.firstChild === anchorStart && parent.lastChild === anchorEnd)
23
37
 
24
38
  const insertBefore = function(parent, child, target) {
25
39
  const childElement = Validator.isElement(child) ? child : ElementCreator.getChild(child);
@@ -34,14 +48,13 @@ export default function Anchor(name, isUniqueChild = false) {
34
48
  parent.insertBefore(childElement, target);
35
49
  };
36
50
 
37
- anchorFragment.appendElement = function(child, before = null) {
51
+ anchorFragment.appendElement = function(child) {
38
52
  const parentNode = anchorStart.parentNode;
39
- const targetBefore = before || anchorEnd;
40
53
  if(parentNode === anchorFragment) {
41
- parentNode.nativeInsertBefore(child, targetBefore);
54
+ parentNode.nativeInsertBefore(child, anchorEnd);
42
55
  return;
43
56
  }
44
- parentNode?.insertBefore(child, targetBefore);
57
+ parentNode.insertBefore(child, anchorEnd);
45
58
  };
46
59
 
47
60
  anchorFragment.appendChild = function(child, before = null) {
@@ -54,8 +67,8 @@ export default function Anchor(name, isUniqueChild = false) {
54
67
  insertBefore(parent, child, before);
55
68
  };
56
69
 
57
- anchorFragment.append = function(...args ) {
58
- return anchorFragment.appendChild(args);
70
+ anchorFragment.append = function() {
71
+ return anchorFragment.appendChild(Array.from(arguments));
59
72
  };
60
73
 
61
74
  anchorFragment.removeChildren = function() {
@@ -82,6 +95,7 @@ export default function Anchor(name, isUniqueChild = false) {
82
95
  return;
83
96
  }
84
97
  if(isParentUniqueChild(parent)) {
98
+ anchorFragment.append.apply(anchorFragment, parent.childNodes);
85
99
  parent.replaceChildren(anchorStart, anchorEnd);
86
100
  return;
87
101
  }
@@ -126,9 +140,11 @@ export default function Anchor(name, isUniqueChild = false) {
126
140
  anchorFragment.startElement = function() {
127
141
  return anchorStart;
128
142
  };
143
+
129
144
  anchorFragment.restore = function() {
130
145
  anchorFragment.appendChild(anchorFragment);
131
146
  };
147
+
132
148
  anchorFragment.clear = anchorFragment.remove;
133
149
  anchorFragment.detach = anchorFragment.remove;
134
150
 
@@ -0,0 +1,44 @@
1
+ import {Validator} from "../../../../index";
2
+ import {ElementCreator} from "../../wrappers/ElementCreator";
3
+
4
+
5
+ export default function oneChildAnchorOverwriting(anchor, parent) {
6
+
7
+ anchor.remove = () => {
8
+ anchor.append.apply(anchor, parent.childNodes);
9
+ };
10
+
11
+ anchor.appendChild = (child) => {
12
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
13
+ parent.appendChild(child);
14
+ };
15
+
16
+ anchor.appendElement = anchor.appendChild;
17
+
18
+ anchor.removeChildren = () => {
19
+ parent.replaceChildren();
20
+ };
21
+
22
+ anchor.replaceContent = function(content) {
23
+ const child = Validator.isElement(content) ? content : ElementCreator.getChild(content);
24
+ parent.replaceChildren(child);
25
+ };
26
+ anchor.setContent = anchor.replaceContent;
27
+
28
+ anchor.insertBefore = (child, anchor) => {
29
+ child = Validator.isElement(child) ? child : ElementCreator.getChild(child);
30
+ parent.insertBefore(child, anchor);
31
+ };
32
+ anchor.appendChildBefore = anchor.insertBefore;
33
+
34
+ anchor.clear = anchor.remove;
35
+ anchor.detach = anchor.remove;
36
+
37
+ anchor.replaceChildren = function() {
38
+ parent.replaceChildren(...arguments);
39
+ };
40
+
41
+ anchor.getByIndex = (index) => {
42
+ return parent.childNodes[index];
43
+ };
44
+ }