native-document 1.0.153 → 1.0.154
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn.js +0 -4
- package/dist/native-document.components.min.js +1410 -172
- package/dist/native-document.dev.js +3207 -2943
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/index.js +11 -7
- package/package.json +1 -1
- package/src/core/data/Observable.js +141 -0
- package/src/core/data/ObservableArray.js +1 -2
- package/src/core/data/ObservableItem.js +2 -0
- package/src/core/data/ObservableObject.js +10 -10
- package/src/core/data/observable-helpers/observable.is-to.js +1 -2
- package/src/core/data/observable-helpers/observable.prototypes.js +1 -2
- package/src/core/data/observable-helpers/array.js +0 -22
- package/src/core/data/observable-helpers/batch.js +0 -22
- package/src/core/data/observable-helpers/computed.js +0 -55
- package/src/core/data/observable-helpers/object.js +0 -48
|
@@ -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()}}const o=3,s=8,i=11,a=[];a[1]=!0,a[o]=!0,a[i]=!0,a[s]=!0;const l={isObservable:e=>e&&(e.__$isObservable||e.__$Observable),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=>l.isObservable(e)||l.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker,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&&a[e.nodeType],isDOMNode:e=>a[e.nodeType],isFragment:e=>e?.nodeType===i,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||e.__$Observable||e?.__$isNDElement||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement,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&&(l.isObject(e)&&Object.values(e).some(e=>l.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")}},u=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"]),c=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`)}}}();const h=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},p=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},d=(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=>d(e));if(l.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=d(e[t]));return n},f={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)},b=(e,t)=>{if(!f.has(e))return t;switch(typeof t){case"object":return f.getJson(e)??t;case"boolean":return f.getBool(e)??t;case"number":return f.getNumber(e)??t;default:return f.get(e,t)??t}},m=e=>{switch(typeof e){case"object":return f.setJson;case"boolean":return f.setBool;default:return f.set}};function y(e,t=null){e=l.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=l.isObject(e)?d(e):e))}Object.defineProperty(y.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),y.prototype.__$Observable=!0,y.prototype.__$isObservable=!0;const g=function(){};y.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},y.prototype.interceptMutations=function(e){return this.$mutationInterceptor=e,this},y.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},y.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)},y.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)},y.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},y.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},y.prototype.assocTrigger=function(){if(this.$firstListener=null,this.$watchers?.size&&this.$listeners?.length)return this.$firstListener=this.$listeners[0],this.trigger=0===this.$firstListener.length?this.$firstListener:this.triggerFirstListener,void(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=g},y.prototype.trigger=g;const v={action:"set"};function $(e,t=null){return new y(e,t)}y.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,this.trigger(v),this.$previousValue=null)},y.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)},y.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},y.prototype.set=y.prototype.$basicSet,y.prototype.val=function(){return this.$currentValue},y.prototype.disconnectAll=function(){this.$previousValue=null,this.$currentValue=null,this.$listeners=null,this.$watchers=null,this.trigger=g},y.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},y.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}c.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},y.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},y.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?l.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()},y.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()},y.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)},y.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},y.prototype.get=function(e){const t=this.$currentValue[e];return l.isObservable(t)?t.val():t},y.prototype.equals=function(e){return l.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},y.prototype.toBool=function(){return!!this.$currentValue},y.prototype.toggle=function(){this.set(!this.$currentValue)},y.prototype.reset=function(){if(!this.configs?.reset)return;const e=l.isObject(this.$initialValue)?d(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},y.prototype.toString=function(){return String(this.$currentValue)},y.prototype.valueOf=function(){return this.$currentValue},y.prototype.persist=function(e,t={}){let n=b(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=m(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this},y.prototype.clone=function(){let e=this.$currentValue;return e&&"object"==typeof e&&(e="function"==typeof e.clone?e.clone():structuredClone(e)),new y(e)};const w=$,S=$;$.useValueProperty=function(e="value"){Object.defineProperty(y.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},$.getById=function(e){const t=c.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},$.cleanup=function(e){e.cleanup()},$.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{c.cleanup()}),setInterval(()=>c.cleanObservables(r),n)};const C=(e,t)=>{for(const n in t){const r=t[n];if(r.__$Observable){if(r.__$isObservableChecker){let t=r.val();if("string"==typeof t){e.classes.toggle(t,!0),r.subscribe(n=>{e.classes.remove(t),e.classes.toggle(n,!0),t=n});continue}}e.classes.toggle(n,r.val()),r.subscribe(t=>e.classes.toggle(n,t))}else r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}},O=(e,t)=>{for(const n in t){const r=t[n],o=n.startsWith("--");r.__$Observable?o?(e.style.setProperty(n,r.val()),r.subscribe(t=>{!1!==t?e.style.setProperty(n,t):e.style.removeProperty(n)})):(e.style[n]=r.val(),r.subscribe(t=>{!1!==t?e.style[n]=t:e.style.removeProperty(n)})):o?e.style.setProperty(n,r):e.style[n]=r}},A=(e,t,n)=>{const r=n.__$isObservable,o=r?n.val():n;if(l.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)}},E=(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){C(e,o);continue}if("style"===r){O(e,o);continue}}u.has(r)?A(e,r,o):e.setAttribute(r,o)}}return e};let _=null;const N={createTextNode:()=>(_||(_=document.createTextNode(""),N.createTextNode=()=>_.cloneNode()),_.cloneNode()),createObservableNode:(e,t)=>{const n=N.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode:(e,t)=>{const n=N.createTextNode();return t.$hydrate(n),n},createStaticTextNode:(e,t)=>{let n=N.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement:e=>document.createElement(e).cloneNode(),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=N.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(),l.isElement(e))return e}while(e.toNdElement);return N.createStaticTextNode(null,e)},processAttributes:(e,t)=>{t&&E(e,t)},processAttributesDirect:E,processClassAttribute:C,processStyleAttribute:O};function x(e){const t=Reflect.construct(DocumentFragment,[],x),n=document.createComment((e||"")+" Anchor Sentinel"),r=document.createComment("Anchor Start : "+e),o=document.createComment("/ Anchor End "+e),s={};t.append(r,n,o);const i=new MutationObserver(()=>{n.parentNode===t||n.parentNode instanceof DocumentFragment||s.connected&&s.connected(n.parentNode)});return i.observe(document,{childList:!0,subtree:!0}),t.$sentinel=n,t.$start=r,t.$end=o,t.$observer=i,t.$events=s,t}function F(e,t=!1){const n=new x(e);n.onConnectedOnce(e=>{t&&function(e,t){e.remove=()=>{e.append.apply(e,t.childNodes)},e.getParent=()=>t,e.appendChild=e=>{e=l.isElement(e)?e:N.getChild(e),t.appendChild(e)},e.appendChildRaw=t.appendChild.bind(t),e.append=e.appendChild,e.appendRaw=e.appendChildRaw,e.insertAtStart=e=>{e=l.isElement(e)?e:N.getChild(e),t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)},e.insertAtStartRaw=e=>{t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)},e.appendElement=e.appendChild,e.removeChildren=()=>{t.textContent=""},e.replaceContent=function(e){const n=l.isElement(e)?e:N.getChild(e);t.replaceChildren(n)},e.replaceContentRaw=function(e){t.replaceChildren(e)},e.setContent=e.replaceContent,e.insertBefore=(e,n)=>{e=l.isElement(e)?e:N.getChild(e),t.insertBefore(e,n)},e.insertBeforeRaw=(e,n)=>{t.insertBefore(e,n)},e.appendChildBefore=e.insertBefore,e.appendChildBeforeRaw=e.insertBeforeRaw,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=n.$start,o=n.$end;n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild,n.nativeAppend=n.append;const s=t?()=>!0:e=>e.firstChild===r&&e.lastChild===o,i=(e,t,r)=>{e!==n?s(e)&&r===o?e.append(t,r):e.insertBefore(t,r):e.nativeInsertBefore(t,r)};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 n=o.parentNode;n?((e,t,n)=>{const r=l.isElement(t)?t:N.getChild(t);i(e,r,n)})(n,e,t=t??o):DebugManager.error("Anchor","Anchor : parent not found",e)},n.appendChildRaw=function(e,t=null){const n=o.parentNode;n?i(n,e,t=t??o):DebugManager.error("Anchor","Anchor : parent not found",e)},n.getParent=()=>o.parentNode,n.append=n.appendChild,n.appendRaw=n.appendChildRaw,n.insertAtStart=function(e){e=l.isElement(e)?e:N.getChild(e),n.insertAtStartRaw(e)},n.insertAtStartRaw=function(e){const t=r.parentNode;t!==n?t.insertBefore(e,r):t.nativeInsertBefore(e,r)},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.nativeAppend.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.delete=n.removeWithAnchors,n.replaceContent=function(e){const t=l.isElement(e)?e:N.getChild(e);n.replaceContentRaw(t)},n.replaceContentRaw=function(e){const t=o.parentNode;t&&(s(t)?t.replaceChildren(r,e,o):(n.removeChildren(),t.insertBefore(e,o)))},n.setContent=n.replaceContent,n.setContentRaw=n.replaceContentRaw,n.insertBefore=n.appendChild,n.insertBeforeRaw=n.appendChildRaw,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}x.prototype=Object.create(DocumentFragment.prototype),x.prototype.constructor=x,x.prototype.onConnected=function(e){return this.$events.connected=e,this},x.prototype.onConnectedOnce=function(e){this.$events.connected=t=>{e(t),this.$observer.disconnect(),this.$events.connectedOnce=null}},DocumentFragment.prototype.setAttribute=()=>{};const M={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,initObserver:()=>{M.observer||(M.observer=new MutationObserver(M.checkMutation),M.observer.observe(document.body,{childList:!0,subtree:!0}))},executeMountedCallback(e){const t=M.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=M.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(M.mountedSupposedSize>0)for(const e of t.addedNodes){if(M.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)M.executeMountedCallback(e)}if(M.unmountedSupposedSize>0)for(const e of t.removedNodes){if(M.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)M.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1;M.initObserver();let o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(M.mounted.delete(e),M.mountedSupposedSize--),r&&(M.unmounted.delete(e),M.unmountedSupposedSize--),o=null}};const s=(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=>{s("mounted",t),M.mounted.set(e,o),n||(M.mountedSupposedSize++,n=!0)},unmounted:t=>{s("unmounted",t),M.unmounted.set(e,o),r||(M.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)}}}};function T(e){this.$element=e,this.$attachements=null}T.prototype.__$isNDElement=!0,T.$getChild=e=>e,T.prototype.ghostDom=function(e){return this.$attachements||(this.$attachements=document.createDocumentFragment()),this.$attachements.appendChild(T.$getChild(e)),this},T.prototype.valueOf=function(){return this.$element},T.prototype.ref=function(e,t){return e[t]=this.$element,this},T.prototype.refSelf=function(e,t){return e[t]=this,this},T.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},T.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,D.delete(e),e=null,this};const D=new WeakMap;T.prototype.lifecycle=function(e){const t=this.$element;D.has(t)||D.set(t,M.watch(t));const n=D.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},T.prototype.mounted=function(e){return this.lifecycle({mounted:e})},T.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},T.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!M.beforeUnmount.has(n)){M.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=M.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return M.beforeUnmount.get(n).set(e,t),this},T.prototype.htmlElement=function(){return this.$element},T.prototype.node=T.prototype.htmlElement,T.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},T.prototype.openShadow=function(e=null){return this.shadow("open",e)},T.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},T.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const r=e[t];"function"==typeof r?this[t]=r.bind(this):n.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},T.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}"`);T.prototype[o]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),T.prototype[o]=s}else n.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return T};const k={configurable:!0,get(){return new T(this)}};Object.defineProperty(HTMLElement.prototype,"nd",k),Object.defineProperty(DocumentFragment.prototype,"nd",k),Object.defineProperty(T.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();T.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();T.prototype["onStop"+e]=function(e=null){return L(this.$element,t,e),this},T.prototype["onPreventStop"+e]=function(e=null){return I(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();T.prototype["onPrevent"+e]=function(e=null){return P(this.$element,t,e),this}}),T.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const P=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},L=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},I=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},R={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,...R}}});let j=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 V=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}},B=e=>e?e.toNdElement():N.createTextNode(),q=(e,t,n=null)=>{let{props:r,children:o=null}=V(t,n);return N.processAttributes(e,r),N.processChildren(o,e),e};function W(e,t=null){if(e){if(t){let n=null,r=(o,s)=>(n=document.createElement(e),r=(e,r)=>q(t(n.cloneNode()),e,r),q(t(n.cloneNode()),o,s));return(e,t)=>r(e,t)}let n=null,r=(t,o)=>(n=document.createElement(e),r=(e,t)=>q(n.cloneNode(),e,t),q(n.cloneNode(),t,o));return(e,t)=>r(e,t)}return(e,t="")=>{const n=F(t);return n.append(e),n}}function U(e){this.$hydrate=e}function H(e){this.$element=e,this.$classes=null,this.$styles=null,this.$attrs=null,this.$ndMethods=null}U.prototype.__$isTemplateBinding=!0,T.prototype.attach=function(e,t){if("function"==typeof t){const n=this.$element;return n.nodeCloner=n.nodeCloner||new H(n),n.nodeCloner.attach(e,t),n}return t.$hydrate(this.$element,e),this.$element},H.prototype.__$isNodeCloner=!0;const z=(e,t,n)=>{for(const r in t)e[r]=t[r].apply(null,n);return e};H.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),N.processClassAttribute(e,t)})}else e.push((e,n)=>{N.processClassAttribute(e,z(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),N.processStyleAttribute(e,t)})}else e.push((e,n)=>{N.processStyleAttribute(e,z(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),N.processAttributes(e,t)})}else e.push((e,n)=>{N.processAttributes(e,z(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}},H.prototype.cloneNode=function(e){return this.$element.cloneNode(!1)},H.prototype.attach=function(e,t){return this.$ndMethods=this.$ndMethods||{},this.$ndMethods[e]=t,this},H.prototype.text=function(e){return this.$content=e,"function"==typeof e?(this.cloneNode=t=>B(e.apply(null,t)),this):(this.cloneNode=t=>B(t[0][e]),this)},H.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 G(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=K(this);return t=e(o),t.nodeCloner||(t.nodeCloner=new H(t)),n(t),this.clone=t.dynamicCloneNode,t.dynamicCloneNode(r)};const r=(e,t)=>new U((n,r)=>{!function(e,t,n,r){n.nodeCloner=n.nodeCloner||new H(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 K=e=>new Proxy(e,{get:(e,t)=>t in e||"symbol"==typeof t?e[t]:e.value(t)});function J(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=F("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}function Y(e,t){this.observable=e,y.call(this),this.$mutation=t,e.subscribe(e=>{this.$updateWithMutation(e)}),this.$updateWithMutation(e.val())}DocumentFragment.prototype.__IS_FRAGMENT=!0,Function.prototype.args=function(...e){return this},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},Y.prototype=Object.create(y.prototype),Y.prototype.constructor=Y,Y.prototype.__$Observable=!0,Y.prototype.__$isObservableChecker=!0;const Q=Y;Q.prototype.constructor=Q,Y.prototype.$updateWithMutation=function(e){return e=this.$mutation(e),this.set(e)},T.$getChild=N.getChild,String.prototype.toNdElement=function(){return N.createStaticTextNode(null,this)},Number.prototype.toNdElement=function(){return N.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},y.prototype.toNdElement=function(){return N.createObservableNode(null,this)},Y.prototype.toNdElement=y.prototype.toNdElement,T.prototype.toNdElement=function(){const e=this.$element??this.$build?.()??this.build?.()??null;return this.$attachements?(this.$attachements.contains(this.$element)||this.$attachements.append(this.$element),this.$attachements):e},Array.prototype.toNdElement=function(){const e=document.createDocumentFragment();for(let t=0,n=this.length;t<n;t++){const n=N.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return N.getChild(this())},U.prototype.toNdElement=function(){return N.createHydratableNode(null,this)};const X=(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()});T.prototype.transitionOut=function(e){const t=e+"-exit",n=this.$element;return this.beforeUnmount("transition-exit",async function(){n.classes.add(t),await X(n),n.classes.remove(t)}),this},T.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),X(r).then(()=>{r.classes.remove(n)})})})}),this},T.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},T.prototype.animate=function(e){const t=this.$element;return t.classes.add(e),X(t).then(()=>{t.classes.remove(e)}),this},y.prototype.handleNdAttribute=function(e,t){u.has(t)?A(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)},Y.prototype.handleNdAttribute=y.prototype.handleNdAttribute,U.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const Z=function(e={}){let t=l.isString(e)?e.split(";").filter(Boolean):e;return{add(e,n){if(Array.isArray(t))t.push(e+": "+n);else if(l.isObject(e)){n=e;for(const e in n)t[e]=n[e]}else t[e]=n},value:()=>Array.isArray(t)?t.join(";").concat(";"):{...t}}},ee=function(e=[]){let t=l.isString(e)?e.split(" ").filter(Boolean):e;return{add(e,n=!0){if(l.isJson(e))for(const n in e)e[n]&&(t[n]=e[n]);else if(null!=n||e.__$Observable)if(Array.isArray(t)&&(t=t.reduce((e,t)=>(e[t]=!0,e),{})),e.__$Observable){const n=`obs-${Math.random().toString(36).substr(2,9)}`;t[n]=e}else t[e]=n;else Array.isArray(t)?t.push(e):t[e]=n},value:()=>Array.isArray(t)?t.join(" "):{...t}}},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=l.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function le(e,t){const n=e.filter(l.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>l.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 be(e,t=!0,r=""){return le([e,t,r],(e,[t,r,o])=>{if(!t)return!0;if(r)try{return new RegExp(t,o).test(String(e))}catch(e){return n.warn("Invalid regex pattern:",t,e),!1}return o&&""!==o?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function me(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(l.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(l.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}const ge=he,ve=pe,$e=de,we=fe,Se=ue,Ce=ce,Oe=me,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 _e=Ee;var Ne=Object.freeze({__proto__:null,all:Oe,and:me,any:Ae,between:function(e,t){return le([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:_e,createFilter:ae,createMultiSourceFilter:le,custom:function(e,...t){const n=t.filter(l.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>l.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:Se,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:$e,lte:we,match:be,neq:Ce,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 xe=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");y.call(this,e,t)};(xe.prototype=Object.create(y.prototype)).constructor=xe,xe.prototype.__$isObservableArray=!0,Object.defineProperty(xe.prototype,"length",{get(){return this.$currentValue.length}}),xe.prototype.$mutate=function(e,t,n){if(this.$mutationInterceptor){const n=this.$mutationInterceptor(t,{action:e});void 0!==t&&(t=n)}n(t)},["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{xe.prototype[e]=function(...t){return this.$mutate(e,t,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=>{xe.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}});const Fe={action:"clear"};xe.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$mutate("clear",[],()=>{this.$currentValue.length=0,this.trigger(Fe)}),!0},xe.prototype.at=function(e){return this.$currentValue[e]},xe.prototype.merge=function(e){this.$mutate("merge",e,e=>{this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})})},xe.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},xe.prototype.swap=function(e,t){return this.$mutate("swap",[e,t],([e,t])=>{const n=this.$currentValue,r=n.length;if(t<e){const n=e;e=t,t=n}if(r<e||r<t)return!1;const o=n[e],s=n[t];n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]})}),!0},xe.prototype.swapItems=function(e,t){const n=this.$currentValue.indexOf(e),r=this.$currentValue.indexOf(t);return this.swap(n,r)},xe.prototype.insertAfter=function(e,t){const n=this.$currentValue.indexOf(t);return this.splice(n+1,0,e)},xe.prototype.remove=function(e){let t=[];return this.$mutate("remove",[e],([e])=>{t=this.$currentValue.splice(e,1),0!==t.length&&this.trigger({action:"remove",args:[e],result:t[0]})}),t},xe.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},xe.prototype.empty=function(){return 0===this.$currentValue.length},xe.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},xe.prototype.where=function(e){"function"==typeof e&&(e={_:e});const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=l.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=$.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},xe.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},xe.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},xe.prototype.deepSubscribe=function(e){const t=h(()=>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)}},xe.prototype.sync=function(e){if(!e||!e.__$isObservableArray)throw new r("ObservableArray.sync : target must be an ObservableArray");e.set([...this.$currentValue]);const t=(t,n,r)=>{if(!r)return void e.set([...t]);const{action:o,args:s}=r;e[o].apply(e,s)};return this.subscribe(t),()=>this.unsubscribe(t)},xe.prototype.clone=function(){return new xe(this.resolve())},$.array=function(e=[],t=null){return new xe(e,t)},$.batch=function(e){const t=$(0),n=function(){if(l.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};const Me=function(e,t){y.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)})};Me.prototype=Object.create(y.prototype),Object.defineProperty(Me,"$value",{get(){return this.val()},set(e){this.set(e)}}),Me.prototype.__$isObservableObject=!0,Me.prototype.__isProxy__=!0,Me.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=>l.isJson(e)?$.json(e,t):l.isArray(e)?$.array(e,t):$(e,t));this.$observables[n]=$.array(e,t);continue}this.$observables[n]=$.array(r,t)}else l.isObservable(r)||l.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?$.object(r,t):$(r,t)}},Me.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(l.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>l.isObservable(e)?e.val():l.isProxy(e)?e.$value:e)),e[t]=r}else l.isProxy(n)?e[t]=n.$value:e[t]=n}return e},Me.prototype.$val=Me.prototype.val,Me.prototype.get=function(e){const t=this.$observables[e];return l.isObservable(t)?t.val():l.isProxy(t)?t.$value:t},Me.prototype.$get=Me.prototype.get,Me.prototype.set=function(e){const t=l.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(l.isObservable(o)){if(!l.isArray(i)){o.set(i);continue}const e=s.at(0);if(l.isObservable(e)||l.isProxy(e)){const t=i.map(t=>l.isProxy(e)?$.init(t,n):$(t,n));o.set(t);continue}o.set([...i]);continue}l.isProxy(o)?o.update(i):this[r]=i}},Me.prototype.$set=Me.prototype.set,Me.prototype.$updateWith=Me.prototype.set,Me.prototype.observables=function(){return Object.values(this.$observables)},Me.prototype.$observables=Me.prototype.observables,Me.prototype.keys=function(){return Object.keys(this.$observables)},Me.prototype.$keys=Me.prototype.keys,Me.prototype.clone=function(){return $.init(this.val(),this.configs)},Me.prototype.$clone=Me.prototype.clone,Me.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},Me.prototype.originalSubscribe=Me.prototype.subscribe,Me.prototype.subscribe=function(e){const t=this.observables(),n=h(()=>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)}},Me.prototype.configs=function(){return this.configs},Me.prototype.update=Me.prototype.set,$.init=function(e,t=null){return new Me(e,t)},$.arrayOfObject=function(e){return e.map(e=>$.object(e))},$.value=function(e){if(e?.__$isObservableArray){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e.at(n);t.push($.value(r))}return t}return e?.__$Observable?e.val():l.isProxy(e)?e.$value:e},y.prototype.resolve=function(){return $.value(this)},$.object=$.init,$.json=$.init,$.computed=function(e,t=[]){const n=new y(e()),o=h(()=>n.set(e(...t.map(e=>e.val()))));if(l.isFunction(t)){if(!l.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{l.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const Te=(e,t)=>$.computed(e,t),De=(e,t)=>e.transform(t);y.prototype.isEqualTo=function(e){return e?.__$Observable?Te((e,t)=>e===t,[this,e]):De(this,t=>t===e)},y.prototype.isNotEqualTo=function(e){return e?.__$Observable?Te((e,t)=>e!==t,[this,e]):De(this,t=>t!==e)},y.prototype.isGreaterThan=function(e){return e?.__$Observable?Te((e,t)=>e>t,[this,e]):De(this,t=>t>e)},y.prototype.isGreaterThanOrEqualTo=function(e){return e?.__$Observable?Te((e,t)=>e>=t,[this,e]):De(this,t=>t>=e)},y.prototype.isLessThan=function(e){return e?.__$Observable?Te((e,t)=>e<t,[this,e]):De(this,t=>t<e)},y.prototype.isLessThanOrEqualTo=function(e){return e?.__$Observable?Te((e,t)=>e<=t,[this,e]):De(this,t=>t<=e)},y.prototype.isBetween=function(e,t){return e.__$Observable&&t.__$Observable?Te((e,t,n)=>e>=t&&e<=n,[this,e,t]):e.__$Observable?Te((e,n)=>e>=n&&e<=t,[this,e]):t.__$Observable?Te((t,n)=>t>=e&&t<=n,[this,t]):De(this,n=>n>=e&&n<=t)},y.prototype.isNull=function(){return De(this,e=>null==e)},y.prototype.isTruthy=function(){return De(this,e=>!!e)},y.prototype.isFalsy=function(){return De(this,e=>!e)},y.prototype.isStartingWith=function(e){return e?.__$Observable?Te((e,t)=>String(e).startsWith(t),[this,e]):De(this,t=>String(t).startsWith(e))},y.prototype.isEndingWith=function(e){return e?.__$Observable?Te((e,t)=>String(e).endsWith(t),[this,e]):De(this,t=>String(t).endsWith(e))},y.prototype.isMatchingPattern=function(e){return e?.__$Observable?Te((e,t)=>new RegExp(t).test(String(e)),[this,e]):De(this,t=>e.test(String(t)))},y.prototype.isEmpty=function(){return De(this,e=>null==e||""===e||Array.isArray(e)&&0===e.length)},y.prototype.isNotEmpty=function(){return De(this,e=>null==e||""===e||Array.isArray(e)&&0!==e.length)},y.prototype.isIncludes=function(e){return e?.__$Observable?Te((e,t)=>Array.isArray(e)?e.includes(t):String(e).includes(String(t)),[this,e]):De(this,t=>Array.isArray(t)?t.includes(e):String(t).includes(String(e)))},y.prototype.isIncludedIn=function(e){return e?.__$Observable?Te((e,t)=>t.includes(e),[this,e]):De(this,t=>e.includes(t))},y.prototype.isOneOf=y.prototype.isIncludedIn,y.prototype.isHaving=function(e){return e?.__$Observable?Te((e,t)=>t in Object(e),[this,e]):De(this,t=>e in Object(t))},y.prototype.toUpperCase=function(){return De(this,e=>String(e).toUpperCase())},y.prototype.toLowerCase=function(){return De(this,e=>String(e).toLowerCase())},y.prototype.toTrimmed=function(){return De(this,e=>String(e).trim())},y.prototype.toBoolean=function(){return De(this,e=>!!e)},y.prototype.toLiteral=function(e,t="${v}"){return De(this,n=>e.replace(t,n))},y.prototype.toFormatted=y.prototype.toLiteral,y.prototype.toProperty=function(e){const t=e.split(".");return De(this,e=>{let n=e;for(const e of t){if(null==n)return;n=n[e]}return n})},y.prototype.toLength=function(){return De(this,e=>null==e?0:e.length)},y.prototype.toClamped=function(e,t){return e.__$Observable&&t.__$Observable?Te((e,t,n)=>Math.min(Math.max(e,t),n),[this,e,t]):e.__$Observable?Te((e,n)=>Math.min(Math.max(e,n),t),[this,e]):t.__$Observable?Te((t,n)=>Math.min(Math.max(t,e),n),[this,t]):De(this,n=>Math.min(Math.max(n,e),t))},y.prototype.toPercent=function(e){return e?.__$Observable?Te((e,t)=>0===t?0:e/t*100,[this,e]):De(this,t=>0===e?0:t/e*100)};const ke=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)?$.array(e,t):"object"==typeof e?$.object(e,t):$(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=$.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=ke();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,b(n,t)),o=m(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,b(n,t)),o=m(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{f.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.")}})},Pe=ke();Pe.create("locale",navigator.language.split("-")[0]||"en");const Le=e=>e;const Ie=new Set(["clear","push","unshift","replace"]),Re=e=>e;const je=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!l.isObservable(e))return"boolean"==typeof e?e?N.getChild(t):null:n.warn("ShowIf","ShowIf : condition must be an Observable or boolean / "+r,e);const s=F("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=N.getChild(t),l.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Ve=function(e,t,n=!0){if(!l.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=F("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=N.getChild(r),l.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(r){n&&s.delete(r),e.set([...s.keys()].at(-1)??""),delete t[r]}})},Be=function(e,t,n){if(!l.isObservable(e))throw new r("Toggle : condition must be an Observable");return Ve(e.toBoolean(),{true:t,false:n})},qe=W("div"),We=W("span"),Ue=W("label"),He=W("p"),ze=He,Ge=W("strong"),Ke=W("h1"),Je=W("h2"),Ye=W("h3"),Qe=W("h4"),Xe=W("h5"),Ze=W("h6"),et=W("br"),tt=W("a"),nt=W("pre"),rt=W("code"),ot=W("blockquote"),st=W("hr"),it=W("em"),at=W("small"),lt=W("mark"),ut=W("del"),ct=W("ins"),ht=W("sub"),pt=W("sup"),dt=W("abbr"),ft=W("cite"),bt=W("q"),mt=W("dl"),yt=W("dt"),gt=W("dd"),vt=W("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}),$t=W("input"),wt=W("textarea"),St=wt,Ct=W("select"),Ot=W("fieldset"),At=W("option"),Et=W("legend"),_t=W("datalist"),Nt=W("output"),xt=W("progress"),Ft=W("meter"),Mt=W("button"),Tt=W("main"),Dt=W("section"),kt=W("article"),Pt=W("aside"),Lt=W("nav"),It=W("figure"),Rt=W("figcaption"),jt=W("header"),Vt=W("footer"),Bt=W("img"),qt=function(e,t){return Bt({src:e,...t})},Wt=W("details"),Ut=W("summary"),Ht=W("dialog"),zt=W("menu"),Gt=W("ol"),Kt=W("ul"),Jt=W("li"),Yt=Jt,Qt=Gt,Xt=Kt,Zt=W("audio"),en=W("video"),tn=W("source"),nn=W("track"),rn=W("canvas"),on=W("svg"),sn=W("time"),an=W("data"),ln=W("address"),un=W("kbd"),cn=W("samp"),hn=W("var"),pn=W("wbr"),dn=W("caption"),fn=W("table"),bn=W("thead"),mn=W("tfoot"),yn=W("tbody"),gn=W("tr"),vn=gn,$n=W("th"),wn=$n,Sn=$n,Cn=W("td"),On=Cn;function An(e){let t=null,n=(r,o)=>(t=document.createElementNS("http://www.w3.org/2000/svg",e),n=(e,n)=>q(t.cloneNode(),e,n),q(t.cloneNode(),r,o));return(e,t)=>n(e,t)}const En=An("svg"),_n=An("circle"),Nn=An("rect"),xn=An("ellipse"),Fn=An("line"),Mn=An("polyline"),Tn=An("polygon"),Dn=An("path"),kn=An("text"),Pn=An("tspan"),Ln=An("textPath"),In=An("g"),Rn=An("defs"),jn=An("use"),Vn=An("symbol"),Bn=An("clipPath"),qn=An("mask"),Wn=An("marker"),Un=An("pattern"),Hn=An("image"),zn=An("foreignObject"),Gn=An("switch"),Kn=An("linearGradient"),Jn=An("radialGradient"),Yn=An("stop"),Qn=An("filter"),Xn=An("feBlend"),Zn=An("feColorMatrix"),er=An("feComposite"),tr=An("feFlood"),nr=An("feGaussianBlur"),rr=An("feMerge"),or=An("feMergeNode"),sr=An("feOffset"),ir=An("feTurbulence"),ar=An("feDisplacementMap"),lr=An("feDiffuseLighting"),ur=An("feSpecularLighting"),cr=An("feDistantLight"),hr=An("fePointLight"),pr=An("feSpotLight"),dr=An("feMorphology"),fr=An("feConvolveMatrix"),br=An("feComponentTransfer"),mr=An("feFuncR"),yr=An("feFuncG"),gr=An("feFuncB"),vr=An("feFuncA"),$r=An("animate"),wr=An("animateTransform"),Sr=An("animateMotion"),Cr=An("mpath"),Or=An("set"),Ar=An("desc"),Er=An("title"),_r=An("metadata"),Nr=An("view"),xr=An("style"),Fr=An("script"),Mr=W("");var Tr=Object.freeze({__proto__:null,Abbr:dt,Address:ln,Anchor:F,Article:kt,Aside:Pt,AsyncImg:function(e,t,n,o){const s=l.isObservable(e)?e.val():e,i=qt(t||s,n),a=new Image;return a.onload=()=>{l.isFunction(o)&&o(null,i),i.src=l.isObservable(e)?e.val():e},a.onerror=()=>{l.isFunction(o)&&o(new r("Image not found"))},l.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:Zt,BaseImage:Bt,Blockquote:ot,Br:et,Button:Mt,Canvas:rn,Caption:dn,Checkbox:e=>$t({type:"checkbox",...e}),Cite:ft,Code:rt,ColorInput:e=>$t({type:"color",...e}),Data:an,Datalist:_t,DateInput:e=>$t({type:"date",...e}),DateTimeInput:e=>$t({type:"datetime-local",...e}),Dd:gt,Del:ut,Details:Wt,Dialog:Ht,Div:qe,Dl:mt,Dt:yt,Em:it,EmailInput:e=>$t({type:"email",...e}),FieldSet:Ot,FigCaption:Rt,Figure:It,FileInput:e=>$t({type:"file",...e}),Footer:Vt,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){t=t||Le;const i=F("ForEach"),a=i.endElement();i.startElement();let u=new Map,c=null;const h=new Set,p=e=>{if(!s)for(const[t,n]of u.entries()){if(h.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),c&&c.delete(n.keyId)}},d=(e,s)=>{const i=((e,t,n)=>{if(l.isString(n)){const r=l.isObservable(e)?e.val():e,o=r?.[n];return l.isObservable(o)?o.val():o??t}return l.isFunction(n)?n(e,t):(l.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?$(s):null;let o=N.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=l.isObservable(e)?e.val():e;if(h.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=d(n[e],e);h.add(t)}else for(const e in n){const t=d(n[e],e);h.add(t)}if(0===h.size)return i.removeChildren(),p(),void c?.clear();p(t),c&&0!==c.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(h);Array.from(c);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 h){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),c?.clear(),c=new Set([...h])};return f(),l.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n={}){t=t||Re;const r=F("ForEach Array",n.isParentUniqueChild),o=r.endElement();let s=new Map,i=0;const a=t.length>=2,l=e=>{r.removeChildren(),f(e),i=0},u=e=>s.get(e)?.child,c=(e,t=!0)=>{const n=s.get(e);if(n){if(t){const t=n.child;t?.remove(),s.delete(e)}n.indexObserver?.cleanup()}},h=e=>{const n=N.getChild(t(e,null));return s.set(e,{child:n,indexObserver:null}),n};let p=(n,r)=>{const o=e.transform(e=>e.indexOf(n)),i=N.getChild(t(n,o));return s.set(n,{child:i,indexObserver:o}),i};e.__$Observable||(p=(e,n)=>{const r=N.getChild(t(e,n));return s.set(e,{child:r,indexObserver:null}),r});const d=(e,t)=>{const n=s.get(e);return n?(n.indexObserver?.set(t),n.child):h(e)};let f,b=h;f=a?n.shouldKeepItemsInCache?()=>{}:e=>{for(const[t,n]of s.entries())e&&e.includes(t)||c(t,!1)}:s.clear.bind(s);const m=(e,t)=>{const n=s.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()};let y=null;y=Array.isArray(e)?()=>{l(e),r.appendChildRaw(g.toFragment(e))}:()=>{const t=e.val();l(t),r.appendChildRaw(g.toFragment(t))};const g={toFragment:e=>{const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(b(e[n],i)),i++;return t},add:e=>{r.appendChildRaw(g.toFragment(e))},replace:e=>{l(e),r.appendChildRaw(g.toFragment(e))},set:y,reOrder:e=>{let t=null;const n=document.createDocumentFragment();for(const r of e)t=u(r),t&&n.appendChild(t);t=null,r.appendElementRaw(n)},removeOne:(e,t)=>{c(e,!0)},clear:l,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)),i++}r.appendChildRaw(o),o.replaceChildren()},unshift:e=>{r.insertAtStartRaw(g.toFragment(e))},splice:(t,n)=>{const[s,i,...a]=t;let l=null;const c=document.createDocumentFragment();if(n.length>0){let e=n[0];if(1===n.length)m(e,c);else if(n.length>1){const e=u(n[0]);l=e?.previousSibling;for(let e=0;e<n.length;e++)m(n[e],c)}}else{const t=s-1>=0?s-1:s,n=e.at(t);l=u(n)||o.previousSibling}c.replaceChildren(),a&&a.length&&l&&r.insertBeforeRaw(g.toFragment(a),l.nextSibling)},reverse:(e,t)=>{g.reOrder(t)},sort:(e,t)=>{g.reOrder(t)},remove:(e,t)=>{g.removeOne(t)},pop:(e,t)=>{g.removeOne(t)},shift:(e,t)=>{g.removeOne(t)},swap:(e,t)=>{const n=r.getParent();let o=u(t[0]),s=u(t[1]);if(!o||!s)return;const i=s.nextSibling;n.insertBefore(s,o),n.insertBefore(o,i),o=null,s=null}};g.merge=g.add,g.push=g.add;const v=(e,t,n={})=>{((e=null)=>{b=Ie.has(e)?a?p:h:s.size?d:a?p:h})(n.action),g[n.action]&&g[n.action](n.args,n.result)};return Array.isArray(e)?(v(0,0,{action:"set"}),r):(e.val().length&&v(e.val(),0,{action:"set"}),e.subscribe(v),r)},Form:vt,Fragment:Mr,H1:Ke,H2:Je,H3:Ye,H4:Qe,H5:Xe,H6:Ze,Header:jt,HiddenInput:e=>$t({type:"hidden",...e}),HideIf:function(e,t,n){const r=$(!e.val());return e.subscribe(e=>r.set(!e)),je(r,t,n)},HideIfNot:function(e,t,n){return je(e,t,n)},Hr:st,Img:qt,Input:$t,Ins:ct,Kbd:un,Label:Ue,LazyImg:function(e,t){return qt(e,{...t,loading:"lazy"})},Legend:Et,Li:Yt,Link:tt,ListItem:Jt,Main:Tt,Mark:lt,Match:Ve,Menu:zt,Meter:Ft,MonthInput:e=>$t({type:"month",...e}),NativeDocumentFragment:F,Nav:Lt,NumberInput:e=>$t({type:"number",...e}),Ol:Qt,Option:At,OrderedList:Gt,Output:Nt,P:He,Paragraph:ze,PasswordInput:e=>$t({type:"password",...e}),Pre:nt,Progress:xt,Quote:bt,Radio:e=>$t({type:"radio",...e}),RangeInput:e=>$t({type:"range",...e}),ReadonlyInput:e=>$t({readonly:!0,...e}),Samp:cn,SearchInput:e=>$t({type:"search",...e}),Section:Dt,Select:Ct,ShowIf:je,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!l.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return je(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!l.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return je(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)=>Mt(e,{type:"button",...t}),Small:at,Source:tn,Span:We,Strong:Ge,Sub:ht,SubmitButton:(e,t)=>Mt(e,{type:"submit",...t}),Summary:Ut,Sup:pt,Svg:on,SvgAnimate:$r,SvgAnimateMotion:Sr,SvgAnimateTransform:wr,SvgCircle:_n,SvgClipPath:Bn,SvgDefs:Rn,SvgDesc:Ar,SvgEllipse:xn,SvgFEBlend:Xn,SvgFEColorMatrix:Zn,SvgFEComponentTransfer:br,SvgFEComposite:er,SvgFEConvolveMatrix:fr,SvgFEDiffuseLighting:lr,SvgFEDisplacementMap:ar,SvgFEDistantLight:cr,SvgFEFlood:tr,SvgFEFuncA:vr,SvgFEFuncB:gr,SvgFEFuncG:yr,SvgFEFuncR:mr,SvgFEGaussianBlur:nr,SvgFEMerge:rr,SvgFEMergeNode:or,SvgFEMorphology:dr,SvgFEOffset:sr,SvgFEPointLight:hr,SvgFESpecularLighting:ur,SvgFESpotLight:pr,SvgFETurbulence:ir,SvgFilter:Qn,SvgForeignObject:zn,SvgG:In,SvgImage:Hn,SvgLine:Fn,SvgLinearGradient:Kn,SvgMPath:Cr,SvgMarker:Wn,SvgMask:qn,SvgMetadata:_r,SvgPath:Dn,SvgPattern:Un,SvgPolygon:Tn,SvgPolyline:Mn,SvgRadialGradient:Jn,SvgRect:Nn,SvgScript:Fr,SvgSet:Or,SvgStop:Yn,SvgStyle:xr,SvgSvg:En,SvgSwitch:Gn,SvgSymbol:Vn,SvgTSpan:Pn,SvgText:kn,SvgTextPath:Ln,SvgTitle:Er,SvgUse:jn,SvgView:Nr,Switch:Be,TBody:yn,TBodyCell:On,TFoot:mn,TFootCell:Sn,THead:bn,THeadCell:wn,TRow:vn,Table:fn,Td:Cn,TelInput:e=>$t({type:"tel",...e}),TextArea:wt,TextInput:St,Th:$n,Time:sn,TimeInput:e=>$t({type:"time",...e}),Tr:gn,Track:nn,Ul:Xt,UnorderedList:Kt,UrlInput:e=>$t({type:"url",...e}),Var:hn,Video:en,Wbr:pn,WeekInput:e=>$t({type:"week",...e}),When:function(e){if(!l.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,Be(e,t,n)),toNdElement:()=>Be(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=F("Portal "+n);return r.appendChild(N.getChild(e)),(t||document.body).appendChild(r),r}});const Dr={};function kr(e,t,n={}){e="/"+p(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=Dr[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},d=()=>{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="/"+p(e,"/");if(!d().exec(e))return!1;const t={};return d().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 Pr extends Error{constructor(e,t){super(e),this.context=t}}const Lr=(e,t)=>{const n=[];return e.forEach(e=>{n.push(p(e.suffix,"/"))}),n.push(p(t,"/")),n.join("/")},Ir=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Rr=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},jr=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Vr(){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 Br(){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 qr(){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 Wr(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 l.isAnchor(e)||(r=F(t),r.appendChild(e)),o.set(e,r),r},u=()=>{l.isAnchor(i)&&i.remove()},c=()=>{t.nodeValue="",u(),s&&s.remove()},h=e=>{let t=e;return l.isNDElement(e)&&(t=e.node()),t},p=function(e,n,o){const l=n.layout();if(l)return void((e,n,o,l)=>{let p=h(n);const d=r.get(p);if(d){if(d===s){const e=a(p,l);return u(),i=p,void e.replaceContent(p)}return c(),i=p,s=d,a(p,l).replaceContent(p),void t.appendChild(s)}c(),i=p;const f=a(p,l);s=N.getChild(e(f)),r.set(p,s),t.appendChild(s)})(l,e,0,o);let p=h(e);c(),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 p(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),p(i,t,s)};return e.subscribe(d),d(e.currentState()),t}const Ur="default";function Hr(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Vr.apply(this,[]);else if("history"===e.mode)Br.apply(this,[]);else{if("memory"!==e.mode)throw new Pr("Invalid router mode "+e.mode);qr.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 kr(Lr(o,e),n,{...s,middlewares:Ir(o,s?.middlewares||[]),name:s?.name?Rr(o,s.name):null,layout:s?.layout||jr(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!l.isFunction(n))throw new Pr("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 Pr(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if("string"==typeof e){const t=r[e];if(t)return{route:t,params:[],query:[],path:t.url({name:e})}}if(l.isJson(e)){const t=r[e.name];if(!t)throw new Pr(`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="/"+p(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Pr(`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(!l.isFunction(e))throw new Pr("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 zr(e,t){const{to:n,href:r,...o}=e;if(r){const e=Hr.get();return tt({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||Ur,a=Hr.get(i);if(!a)throw new Pr('Router not found "'+i+'" for link "'+s.name+'"');const l=a.generateUrl(s.name,s.params,s.query);return tt({...o,href:l},t).nd.onPreventClick(()=>{a.push(l)})}Hr.routers={},Hr.create=function(e,t){if(!l.isFunction(t))throw n.error("Router","Callback must be a function"),new Pr("Callback must be a function");const r=new Hr(e);return Hr.routers[e.name||Ur]=r,t(r),r.init(e.entry),r.mount=function(e){if(l.isString(e)){const t=document.querySelector(e);if(!t)throw new Pr(`Container not found for selector: ${e}`);e=t}else if(!l.isElement(e))throw new Pr("Container must be a string or an Element");return Wr(r,e)},r},Hr.get=function(e){const t=Hr.routers[e||Ur];if(!t)throw new Pr(`Router not found for name: ${e}`);return t},Hr.push=function(e,t=null){return Hr.get(t).push(e)},Hr.replace=function(e,t=null){return Hr.get(t).replace(e)},Hr.forward=function(e=null){return Hr.get(e).forward()},Hr.back=function(e=null){return Hr.get(e).back()},Hr.redirectTo=function(e,t=null,n=null){let r=e;const o=Hr.get(n);return o.resolve({name:e,params:t})&&(r={name:e,params:t}),o.push(r)},zr.blank=function(e,t){return tt({...e,target:"_blank"},t)};var Gr=Object.freeze({__proto__:null,Link:zr,RouteParamPatterns:Dr,Router:Hr});var Kr=Object.freeze({__proto__:null,memoize:e=>re(e),once:e=>ne(e),singleton:e=>te(e)}),Jr=Object.freeze({__proto__:null,Cache:Kr,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)}},classPropertyAccumulator:ee,cssPropertyAccumulator:Z,filters:Ne});return e.$=w,e.ElementCreator=N,e.HtmlElementWrapper=W,e.NDElement=T,e.Observable=$,e.PluginsManager=null,e.SingletonView=J,e.Store=Pe,e.StoreFactory=ke,e.TemplateCloner=G,e.Validator=l,e.autoMemoize=re,e.autoOnce=ne,e.classPropertyAccumulator=ee,e.createTextNode=B,e.cssPropertyAccumulator=Z,e.elements=Tr,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=V,e.obs=S,e.once=te,e.router=Gr,e.useCache=function(e){let t=null,n=r=>{t=new G(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 J(e)),t.render(n)}},e.utils=Jr,e.withValidation=j,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()}}const o=3,s=8,i=11,a=[];a[1]=!0,a[o]=!0,a[i]=!0,a[s]=!0;const l={isObservable:e=>e&&(e.__$isObservable||e.__$Observable),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=>l.isObservable(e)||l.isProxy(e),isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker,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&&a[e.nodeType],isDOMNode:e=>a[e.nodeType],isFragment:e=>e?.nodeType===i,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||e.__$Observable||e?.__$isNDElement||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement,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&&(l.isObject(e)&&Object.values(e).some(e=>l.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")}},u=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"]),c=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`)}}}();const h=function(e){let t=!1;return function(...n){t||(t=!0,Promise.resolve().then(()=>{e.apply(this,n),t=!1}))}},p=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},d=(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=>d(e));if(l.isObservable(e))return t&&t(e),e;const n={};for(const t in e)Object.hasOwn(e,t)&&(n[t]=d(e[t]));return n},f={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)},m=(e,t)=>{if(!f.has(e))return t;switch(typeof t){case"object":return f.getJson(e)??t;case"boolean":return f.getBool(e)??t;case"number":return f.getNumber(e)??t;default:return f.get(e,t)??t}},b=e=>{switch(typeof e){case"object":return f.setJson;case"boolean":return f.setBool;default:return f.set}};function y(e,t=null){e=l.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=l.isObject(e)?d(e):e))}Object.defineProperty(y.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),y.prototype.__$Observable=!0,y.prototype.__$isObservable=!0,y.computed=()=>{};const g=function(){};y.prototype.intercept=function(e){return this.$interceptor=e,this.set=this.$setWithInterceptor,this},y.prototype.interceptMutations=function(e){return this.$mutationInterceptor=e,this},y.prototype.triggerFirstListener=function(e){this.$firstListener(this.$currentValue,this.$previousValue,e)},y.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)},y.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)},y.prototype.triggerAll=function(e){this.triggerWatchers(e),this.triggerListeners(e)},y.prototype.triggerWatchersAndFirstListener=function(e){this.triggerWatchers(e),this.triggerFirstListener(e)},y.prototype.assocTrigger=function(){if(this.$firstListener=null,this.$watchers?.size&&this.$listeners?.length)return this.$firstListener=this.$listeners[0],this.trigger=0===this.$firstListener.length?this.$firstListener:this.triggerFirstListener,void(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=g},y.prototype.trigger=g;const v={action:"set"};function w(e){return e instanceof Date?e:new Date(e)}function $(e,t){const n=w(e),r=w(t);return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()}function S(e){const t=w(e);return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}function C(e,t){const n=l.isObservable(e);return{dependencies:n?e:null,callback:r=>t(r,n?e.val():e)}}function O(e,t){const n=e.filter(l.isObservable);return{dependencies:n.length>0?n:null,callback:n=>t(n,e.map(e=>l.isObservable(e)?e.val():e))}}function A(e){return C(e,(e,t)=>e===t)}function E(e){return C(e,(e,t)=>e!==t)}function _(e){return C(e,(e,t)=>e>t)}function x(e){return C(e,(e,t)=>e>=t)}function N(e){return C(e,(e,t)=>e<t)}function F(e){return C(e,(e,t)=>e<=t)}function D(e,t=!0,r=""){return O([e,t,r],(e,[t,r,o])=>{if(!t)return!0;if(r)try{return new RegExp(t,o).test(String(e))}catch(e){return n.warn("Invalid regex pattern:",t,e),!1}return o&&""!==o?String(e).includes(String(t)):String(e).toLowerCase().includes(String(t).toLowerCase())})}function M(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(l.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.every(e=>e.callback(t))}}function T(...e){const t=e.flatMap(e=>e.dependencies?Array.isArray(e.dependencies)?e.dependencies:[e.dependencies]:[]).filter(l.isObservable);return{dependencies:t.length>0?t:null,callback:t=>e.some(e=>e.callback(t))}}y.prototype.$updateWithNewValue=function(e){e=e?.__$isObservable?e.val():e,this.$currentValue!==e&&(this.$previousValue=this.$currentValue,this.$currentValue=e,this.trigger(v),this.$previousValue=null)},y.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)},y.prototype.$basicSet=function(e){let t="function"==typeof e?e(this.$currentValue):e;this.$updateWithNewValue(t)},y.prototype.set=y.prototype.$basicSet,y.prototype.val=function(){return this.$currentValue},y.prototype.disconnectAll=function(){this.$previousValue=null,this.$currentValue=null,this.$listeners=null,this.$watchers=null,this.trigger=g},y.prototype.onCleanup=function(e){this.$cleanupListeners=this.$cleanupListeners??[],this.$cleanupListeners.push(e)},y.prototype.cleanup=function(){if(this.$cleanupListeners){for(let e=0;e<this.$cleanupListeners.length;e++)this.$cleanupListeners[e]();this.$cleanupListeners=null}c.unregister(this.$memoryId),this.disconnectAll(),delete this.$value},y.prototype.subscribe=function(e){this.$listeners=this.$listeners??[],this.$listeners.push(e),this.assocTrigger()},y.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?l.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()},y.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()},y.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)},y.prototype.unsubscribe=function(e){if(!this.$listeners)return;const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},y.prototype.get=function(e){const t=this.$currentValue[e];return l.isObservable(t)?t.val():t},y.prototype.equals=function(e){return l.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},y.prototype.toBool=function(){return!!this.$currentValue},y.prototype.toggle=function(){this.set(!this.$currentValue)},y.prototype.reset=function(){if(!this.configs?.reset)return;const e=l.isObject(this.$initialValue)?d(this.$initialValue,e=>{e.reset()}):this.$initialValue;this.set(e)},y.prototype.toString=function(){return String(this.$currentValue)},y.prototype.valueOf=function(){return this.$currentValue},y.prototype.persist=function(e,t={}){let n=m(e,this.$currentValue);t.get&&(n=t.get(n)),this.set(n);const r=b(this.$currentValue);return this.subscribe(n=>{r(e,t.set?t.set(n):n)}),this},y.prototype.clone=function(){let e=this.$currentValue;return e&&"object"==typeof e&&(e="function"==typeof e.clone?e.clone():structuredClone(e)),new y(e)};const k=_,P=x,I=N,L=F,R=A,V=E,j=M,B=T;function W(e,t=!1){return C(e,(e,n)=>!!e&&(!n||(t?String(e).includes(String(n)):String(e).toLowerCase().includes(String(n).toLowerCase()))))}const q=W;var U=Object.freeze({__proto__:null,all:j,and:M,any:B,between:function(e,t){return O([e,t],(e,[t,n])=>e>=t&&e<=n)},contains:q,createFilter:C,createMultiSourceFilter:O,custom:function(e,...t){const n=t.filter(l.isObservable);return{dependencies:n.length>0?n:null,callback:n=>{const r=t.map(e=>l.isObservable(e)?e.val():e);return e(n,...r)}}},dateAfter:e=>C(e,(e,t)=>!(!e||!t)&&w(e)>w(t)),dateBefore:e=>C(e,(e,t)=>!(!e||!t)&&w(e)<w(t)),dateBetween:(e,t)=>O([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=w(e);return r>=w(t)&&r<=w(n)}),dateEquals:e=>C(e,(e,t)=>!(!e||!t)&&$(e,t)),dateTimeAfter:e=>C(e,(e,t)=>!(!e||!t)&&w(e)>w(t)),dateTimeBefore:e=>C(e,(e,t)=>!(!e||!t)&&w(e)<w(t)),dateTimeBetween:(e,t)=>O([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=w(e);return r>=w(t)&&r<=w(n)}),dateTimeEquals:e=>C(e,(e,t)=>!(!e||!t)&&w(e).getTime()===w(t).getTime()),endsWith:function(e,t=!1){return C(e,(e,n)=>!n||(t?String(e).endsWith(String(n)):String(e).toLowerCase().endsWith(String(n).toLowerCase())))},eq:R,equals:A,getSecondsOfDay:S,greaterThan:_,greaterThanOrEqual:x,gt:k,gte:P,inArray:function(e){return C(e,(e,t)=>t.includes(e))},includes:W,isEmpty:function(e=!0){return C(e,(e,t)=>{const n=!e||""===e||Array.isArray(e)&&0===e.length;return t?n:!n})},isNotEmpty:function(e=!0){return C(e,(e,t)=>{const n=!!e&&""!==e&&(!Array.isArray(e)||e.length>0);return t?n:!n})},isSameDay:$,lessThan:N,lessThanOrEqual:F,lt:I,lte:L,match:D,neq:V,not:function(e){return{dependencies:e.dependencies,callback:t=>!e.callback(t)}},notEquals:E,notIn:function(e){return C(e,(e,t)=>!t.includes(e))},or:T,startsWith:function(e,t=!1){return C(e,(e,n)=>!n||(t?String(e).startsWith(String(n)):String(e).toLowerCase().startsWith(String(n).toLowerCase())))},timeAfter:e=>C(e,(e,t)=>!(!e||!t)&&S(e)>S(t)),timeBefore:e=>C(e,(e,t)=>!(!e||!t)&&S(e)<S(t)),timeBetween:(e,t)=>O([e,t],(e,[t,n])=>{if(!e||!t||!n)return!1;const r=S(e);return r>=S(t)&&r<=S(n)}),timeEquals:e=>C(e,(e,t)=>{if(!e||!t)return!1;const n=w(e),r=w(t);return n.getHours()===r.getHours()&&n.getMinutes()===r.getMinutes()&&n.getSeconds()===r.getSeconds()}),toDate:w});const H=function(e,t=null){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");y.call(this,e,t)};(H.prototype=Object.create(y.prototype)).constructor=H,H.prototype.__$isObservableArray=!0,Object.defineProperty(H.prototype,"length",{get(){return this.$currentValue.length}}),H.prototype.$mutate=function(e,t,n){if(this.$mutationInterceptor){const n=this.$mutationInterceptor(t,{action:e});void 0!==t&&(t=n)}n(t)},["push","pop","shift","unshift","reverse","sort","splice"].forEach(e=>{H.prototype[e]=function(...t){return this.$mutate(e,t,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=>{H.prototype[e]=function(...t){return this.$currentValue[e].apply(this.$currentValue,t)}});const z={action:"clear"};H.prototype.clear=function(){if(0!==this.$currentValue.length)return this.$mutate("clear",[],()=>{this.$currentValue.length=0,this.trigger(z)}),!0},H.prototype.at=function(e){return this.$currentValue[e]},H.prototype.merge=function(e){this.$mutate("merge",e,e=>{this.$currentValue.push.apply(this.$currentValue,e),this.trigger({action:"merge",args:e})})},H.prototype.count=function(e){let t=0;return this.$currentValue.forEach((n,r)=>{e(n,r)&&t++}),t},H.prototype.swap=function(e,t){return this.$mutate("swap",[e,t],([e,t])=>{const n=this.$currentValue,r=n.length;if(t<e){const n=e;e=t,t=n}if(r<e||r<t)return!1;const o=n[e],s=n[t];n[e]=s,n[t]=o,this.trigger({action:"swap",args:[e,t],result:[o,s]})}),!0},H.prototype.swapItems=function(e,t){const n=this.$currentValue.indexOf(e),r=this.$currentValue.indexOf(t);return this.swap(n,r)},H.prototype.insertAfter=function(e,t){const n=this.$currentValue.indexOf(t);return this.splice(n+1,0,e)},H.prototype.remove=function(e){let t=[];return this.$mutate("remove",[e],([e])=>{t=this.$currentValue.splice(e,1),0!==t.length&&this.trigger({action:"remove",args:[e],result:t[0]})}),t},H.prototype.removeItem=function(e){const t=this.$currentValue.indexOf(e);return-1===t?[]:this.remove(t)},H.prototype.empty=function(){return 0===this.$currentValue.length},H.prototype.populateAndRender=function(e,t){this.trigger({action:"populate",args:[this.$currentValue,e,t]})},H.prototype.where=function(e){"function"==typeof e&&(e={_:e});const t=this,n=[t],r={};for(const[t,o]of Object.entries(e)){const e=l.isObservable(o)?D(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=new H([]),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},H.prototype.whereSome=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.some(e=>t.callback(n[e]))}})},H.prototype.whereEvery=function(e,t){return this.where({_:{dependencies:t.dependencies,callback:n=>e.every(e=>t.callback(n[e]))}})},H.prototype.deepSubscribe=function(e){const t=h(()=>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)}},H.prototype.sync=function(e){if(!e||!e.__$isObservableArray)throw new r("ObservableArray.sync : target must be an ObservableArray");e.set([...this.$currentValue]);const t=(t,n,r)=>{if(!r)return void e.set([...t]);const{action:o,args:s}=r;e[o].apply(e,s)};return this.subscribe(t),()=>this.unsubscribe(t)},H.prototype.clone=function(){return new H(this.resolve())};const G=function(e,t){y.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)})};G.prototype=Object.create(y.prototype),Object.defineProperty(G,"$value",{get(){return this.val()},set(e){this.set(e)}}),G.prototype.__$isObservableObject=!0,G.prototype.__isProxy__=!0,G.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=>l.isJson(e)?new G(e,t):l.isArray(e)?new H(e,t):new y(e,t));this.$observables[n]=new H(e,t);continue}this.$observables[n]=new H(r,t)}else l.isObservable(r)||l.isProxy(r)?this.$observables[n]=r:this.$observables[n]="object"==typeof r?new G(r,t):new y(r,t)}},G.prototype.val=function(){const e={};for(const t in this.$observables){const n=this.$observables[t];if(l.isObservable(n)){let r=n.val();Array.isArray(r)&&(r=r.map(e=>l.isObservable(e)?e.val():l.isProxy(e)?e.$value:e)),e[t]=r}else l.isProxy(n)?e[t]=n.$value:e[t]=n}return e},G.prototype.$val=G.prototype.val,G.prototype.get=function(e){const t=this.$observables[e];return l.isObservable(t)?t.val():l.isProxy(t)?t.$value:t},G.prototype.$get=G.prototype.get,G.prototype.set=function(e){const t=l.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(l.isObservable(o)){if(!l.isArray(i)){o.set(i);continue}const e=s.at(0);if(l.isObservable(e)||l.isProxy(e)){const t=i.map(t=>l.isProxy(e)?new G(t,n):y(t,n));o.set(t);continue}o.set([...i]);continue}l.isProxy(o)?o.update(i):this[r]=i}},G.prototype.$set=G.prototype.set,G.prototype.$updateWith=G.prototype.set,G.prototype.observables=function(){return Object.values(this.$observables)},G.prototype.$observables=G.prototype.observables,G.prototype.keys=function(){return Object.keys(this.$observables)},G.prototype.$keys=G.prototype.keys,G.prototype.clone=function(){return new G(this.val(),this.configs)},G.prototype.$clone=G.prototype.clone,G.prototype.reset=function(){for(const e in this.$observables)this.$observables[e].reset()},G.prototype.originalSubscribe=G.prototype.subscribe,G.prototype.subscribe=function(e){const t=this.observables(),n=h(()=>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)}},G.prototype.configs=function(){return this.configs},G.prototype.update=G.prototype.set;const K=(e,t)=>y.computed(e,t),J=(e,t)=>e.transform(t);y.prototype.isEqualTo=function(e){return e?.__$Observable?K((e,t)=>e===t,[this,e]):J(this,t=>t===e)},y.prototype.isNotEqualTo=function(e){return e?.__$Observable?K((e,t)=>e!==t,[this,e]):J(this,t=>t!==e)},y.prototype.isGreaterThan=function(e){return e?.__$Observable?K((e,t)=>e>t,[this,e]):J(this,t=>t>e)},y.prototype.isGreaterThanOrEqualTo=function(e){return e?.__$Observable?K((e,t)=>e>=t,[this,e]):J(this,t=>t>=e)},y.prototype.isLessThan=function(e){return e?.__$Observable?K((e,t)=>e<t,[this,e]):J(this,t=>t<e)},y.prototype.isLessThanOrEqualTo=function(e){return e?.__$Observable?K((e,t)=>e<=t,[this,e]):J(this,t=>t<=e)},y.prototype.isBetween=function(e,t){return e.__$Observable&&t.__$Observable?K((e,t,n)=>e>=t&&e<=n,[this,e,t]):e.__$Observable?K((e,n)=>e>=n&&e<=t,[this,e]):t.__$Observable?K((t,n)=>t>=e&&t<=n,[this,t]):J(this,n=>n>=e&&n<=t)},y.prototype.isNull=function(){return J(this,e=>null==e)},y.prototype.isTruthy=function(){return J(this,e=>!!e)},y.prototype.isFalsy=function(){return J(this,e=>!e)},y.prototype.isStartingWith=function(e){return e?.__$Observable?K((e,t)=>String(e).startsWith(t),[this,e]):J(this,t=>String(t).startsWith(e))},y.prototype.isEndingWith=function(e){return e?.__$Observable?K((e,t)=>String(e).endsWith(t),[this,e]):J(this,t=>String(t).endsWith(e))},y.prototype.isMatchingPattern=function(e){return e?.__$Observable?K((e,t)=>new RegExp(t).test(String(e)),[this,e]):J(this,t=>e.test(String(t)))},y.prototype.isEmpty=function(){return J(this,e=>null==e||""===e||Array.isArray(e)&&0===e.length)},y.prototype.isNotEmpty=function(){return J(this,e=>null==e||""===e||Array.isArray(e)&&0!==e.length)},y.prototype.isIncludes=function(e){return e?.__$Observable?K((e,t)=>Array.isArray(e)?e.includes(t):String(e).includes(String(t)),[this,e]):J(this,t=>Array.isArray(t)?t.includes(e):String(t).includes(String(e)))},y.prototype.isIncludedIn=function(e){return e?.__$Observable?K((e,t)=>t.includes(e),[this,e]):J(this,t=>e.includes(t))},y.prototype.isOneOf=y.prototype.isIncludedIn,y.prototype.isHaving=function(e){return e?.__$Observable?K((e,t)=>t in Object(e),[this,e]):J(this,t=>e in Object(t))},y.prototype.toUpperCase=function(){return J(this,e=>String(e).toUpperCase())},y.prototype.toLowerCase=function(){return J(this,e=>String(e).toLowerCase())},y.prototype.toTrimmed=function(){return J(this,e=>String(e).trim())},y.prototype.toBoolean=function(){return J(this,e=>!!e)},y.prototype.toLiteral=function(e,t="${v}"){return J(this,n=>e.replace(t,n))},y.prototype.toFormatted=y.prototype.toLiteral,y.prototype.toProperty=function(e){const t=e.split(".");return J(this,e=>{let n=e;for(const e of t){if(null==n)return;n=n[e]}return n})},y.prototype.toLength=function(){return J(this,e=>null==e?0:e.length)},y.prototype.toClamped=function(e,t){return e.__$Observable&&t.__$Observable?K((e,t,n)=>Math.min(Math.max(e,t),n),[this,e,t]):e.__$Observable?K((e,n)=>Math.min(Math.max(e,n),t),[this,e]):t.__$Observable?K((t,n)=>Math.min(Math.max(t,e),n),[this,t]):J(this,n=>Math.min(Math.max(n,e),t))},y.prototype.toPercent=function(e){return e?.__$Observable?K((e,t)=>0===t?0:e/t*100,[this,e]):J(this,t=>0===e?0:t/e*100)};const Y=function(e,t){this.$target=t,this.$observer=e};function Q(e,t){this.observable=e,y.call(this),this.$mutation=t,e.subscribe(e=>{this.$updateWithMutation(e)}),this.$updateWithMutation(e.val())}Y.prototype.__$Observable=!0,Y.prototype.__$isObservableWhen=!0,Y.prototype.subscribe=function(e){return this.$observer.on(this.$target,e)},Y.prototype.val=function(){return this.$observer.$currentValue===this.$target},Y.prototype.isMatch=Y.prototype.val,Y.prototype.isActive=Y.prototype.val,Q.prototype=Object.create(y.prototype),Q.prototype.constructor=Q,Q.prototype.__$Observable=!0,Q.prototype.__$isObservableChecker=!0;const X=Q;X.prototype.constructor=X,Q.prototype.$updateWithMutation=function(e){return e=this.$mutation(e),this.set(e)};const Z=(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),{})}},ee=(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)},te={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}=Z(e,t);return ee(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}=Z(e,t);return ee(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}=Z(e,t);return ee(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 ne(e,t=null){return new y(e,t)}y.prototype.when=function(e){return new Y(this,e)},y.prototype.check=function(e){return new Q(this,e)},y.prototype.transform=y.prototype.check,y.prototype.pluck=function(e){return new Q(this,t=>t[e])},y.prototype.is=function(e){return new Q(this,"function"==typeof e?e:t=>t===e)},y.prototype.select=y.prototype.check,y.prototype.format=function(e,t={}){const n=this;if("function"==typeof e)return new Q(n,e);const r=te[e],o=te.locale;return y.computed(()=>r(n.val(),o.val(),t),[n,o])};const re=ne,oe=ne;ne.useValueProperty=function(e="value"){Object.defineProperty(y.prototype,e,{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0})},ne.getById=function(e){const t=c.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},ne.cleanup=function(e){e.cleanup()},ne.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{c.cleanup()}),setInterval(()=>c.cleanObservables(r),n)},ne.array=function(e=[],t=null){return new H(e,t)},ne.batch=function(e){const t=ne(0),n=function(){if(l.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n},ne.computed=function(e,t=[]){const n=new y(e()),o=h(()=>n.set(e(...t.map(e=>e.val()))));if(l.isFunction(t)){if(!l.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{l.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n},y.computed=ne.computed,ne.init=function(e,t=null){return new G(e,t)},ne.arrayOfObject=function(e){return e.map(e=>ne.object(e))},ne.value=function(e){if(e?.__$isObservableArray){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e.at(n);t.push(ne.value(r))}return t}return e?.__$Observable?e.val():l.isProxy(e)?e.$value:e},y.prototype.resolve=function(){return ne.value(this)},ne.object=ne.init,ne.json=ne.init;const se=(e,t)=>{for(const n in t){const r=t[n];if(r.__$Observable){if(r.__$isObservableChecker){let t=r.val();if("string"==typeof t){e.classes.toggle(t,!0),r.subscribe(n=>{e.classes.remove(t),e.classes.toggle(n,!0),t=n});continue}}e.classes.toggle(n,r.val()),r.subscribe(t=>e.classes.toggle(n,t))}else r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}},ie=(e,t)=>{for(const n in t){const r=t[n],o=n.startsWith("--");r.__$Observable?o?(e.style.setProperty(n,r.val()),r.subscribe(t=>{!1!==t?e.style.setProperty(n,t):e.style.removeProperty(n)})):(e.style[n]=r.val(),r.subscribe(t=>{!1!==t?e.style[n]=t:e.style.removeProperty(n)})):o?e.style.setProperty(n,r):e.style[n]=r}},ae=(e,t,n)=>{const r=n.__$isObservable,o=r?n.val():n;if(l.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)}},le=(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){se(e,o);continue}if("style"===r){ie(e,o);continue}}u.has(r)?ae(e,r,o):e.setAttribute(r,o)}}return e};let ue=null;const ce={createTextNode:()=>(ue||(ue=document.createTextNode(""),ce.createTextNode=()=>ue.cloneNode()),ue.cloneNode()),createObservableNode:(e,t)=>{const n=ce.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode:(e,t)=>{const n=ce.createTextNode();return t.$hydrate(n),n},createStaticTextNode:(e,t)=>{let n=ce.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement:e=>document.createElement(e).cloneNode(),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=ce.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(),l.isElement(e))return e}while(e.toNdElement);return ce.createStaticTextNode(null,e)},processAttributes:(e,t)=>{t&&le(e,t)},processAttributesDirect:le,processClassAttribute:se,processStyleAttribute:ie};function he(e){const t=Reflect.construct(DocumentFragment,[],he),n=document.createComment((e||"")+" Anchor Sentinel"),r=document.createComment("Anchor Start : "+e),o=document.createComment("/ Anchor End "+e),s={};t.append(r,n,o);const i=new MutationObserver(()=>{n.parentNode===t||n.parentNode instanceof DocumentFragment||s.connected&&s.connected(n.parentNode)});return i.observe(document,{childList:!0,subtree:!0}),t.$sentinel=n,t.$start=r,t.$end=o,t.$observer=i,t.$events=s,t}function pe(e,t=!1){const n=new he(e);n.onConnectedOnce(e=>{t&&function(e,t){e.remove=()=>{e.append.apply(e,t.childNodes)},e.getParent=()=>t,e.appendChild=e=>{e=l.isElement(e)?e:ce.getChild(e),t.appendChild(e)},e.appendChildRaw=t.appendChild.bind(t),e.append=e.appendChild,e.appendRaw=e.appendChildRaw,e.insertAtStart=e=>{e=l.isElement(e)?e:ce.getChild(e),t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)},e.insertAtStartRaw=e=>{t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)},e.appendElement=e.appendChild,e.removeChildren=()=>{t.textContent=""},e.replaceContent=function(e){const n=l.isElement(e)?e:ce.getChild(e);t.replaceChildren(n)},e.replaceContentRaw=function(e){t.replaceChildren(e)},e.setContent=e.replaceContent,e.insertBefore=(e,n)=>{e=l.isElement(e)?e:ce.getChild(e),t.insertBefore(e,n)},e.insertBeforeRaw=(e,n)=>{t.insertBefore(e,n)},e.appendChildBefore=e.insertBefore,e.appendChildBeforeRaw=e.insertBeforeRaw,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=n.$start,o=n.$end;n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild,n.nativeAppend=n.append;const s=t?()=>!0:e=>e.firstChild===r&&e.lastChild===o,i=(e,t,r)=>{e!==n?s(e)&&r===o?e.append(t,r):e.insertBefore(t,r):e.nativeInsertBefore(t,r)};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 n=o.parentNode;n?((e,t,n)=>{const r=l.isElement(t)?t:ce.getChild(t);i(e,r,n)})(n,e,t=t??o):DebugManager.error("Anchor","Anchor : parent not found",e)},n.appendChildRaw=function(e,t=null){const n=o.parentNode;n?i(n,e,t=t??o):DebugManager.error("Anchor","Anchor : parent not found",e)},n.getParent=()=>o.parentNode,n.append=n.appendChild,n.appendRaw=n.appendChildRaw,n.insertAtStart=function(e){e=l.isElement(e)?e:ce.getChild(e),n.insertAtStartRaw(e)},n.insertAtStartRaw=function(e){const t=r.parentNode;t!==n?t.insertBefore(e,r):t.nativeInsertBefore(e,r)},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.nativeAppend.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.delete=n.removeWithAnchors,n.replaceContent=function(e){const t=l.isElement(e)?e:ce.getChild(e);n.replaceContentRaw(t)},n.replaceContentRaw=function(e){const t=o.parentNode;t&&(s(t)?t.replaceChildren(r,e,o):(n.removeChildren(),t.insertBefore(e,o)))},n.setContent=n.replaceContent,n.setContentRaw=n.replaceContentRaw,n.insertBefore=n.appendChild,n.insertBeforeRaw=n.appendChildRaw,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}he.prototype=Object.create(DocumentFragment.prototype),he.prototype.constructor=he,he.prototype.onConnected=function(e){return this.$events.connected=e,this},he.prototype.onConnectedOnce=function(e){this.$events.connected=t=>{e(t),this.$observer.disconnect(),this.$events.connectedOnce=null}},DocumentFragment.prototype.setAttribute=()=>{};const de={mounted:new WeakMap,beforeUnmount:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,initObserver:()=>{de.observer||(de.observer=new MutationObserver(de.checkMutation),de.observer.observe(document.body,{childList:!0,subtree:!0}))},executeMountedCallback(e){const t=de.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=de.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(de.mountedSupposedSize>0)for(const e of t.addedNodes){if(de.executeMountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-mounted]");for(const e of t)de.executeMountedCallback(e)}if(de.unmountedSupposedSize>0)for(const e of t.removedNodes){if(de.executeUnmountedCallback(e),!e.querySelectorAll)continue;const t=e.querySelectorAll("[data--nd-unmounted]");for(const e of t)de.executeUnmountedCallback(e)}}},watch:function(e,t=!1){let n=!1,r=!1;de.initObserver();let o={inDom:t,mounted:null,unmounted:null,disconnect:()=>{n&&(de.mounted.delete(e),de.mountedSupposedSize--),r&&(de.unmounted.delete(e),de.unmountedSupposedSize--),o=null}};const s=(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=>{s("mounted",t),de.mounted.set(e,o),n||(de.mountedSupposedSize++,n=!0)},unmounted:t=>{s("unmounted",t),de.unmounted.set(e,o),r||(de.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)}}}};function fe(e){this.$element=e,this.$attachements=null}fe.prototype.__$isNDElement=!0,fe.$getChild=e=>e,fe.prototype.ghostDom=function(e){return this.$attachements||(this.$attachements=document.createDocumentFragment()),this.$attachements.appendChild(fe.$getChild(e)),this},fe.prototype.valueOf=function(){return this.$element},fe.prototype.ref=function(e,t){return e[t]=this.$element,this},fe.prototype.refSelf=function(e,t){return e[t]=this,this},fe.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},fe.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,me.delete(e),e=null,this};const me=new WeakMap;fe.prototype.lifecycle=function(e){const t=this.$element;me.has(t)||me.set(t,de.watch(t));const n=me.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},fe.prototype.mounted=function(e){return this.lifecycle({mounted:e})},fe.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},fe.prototype.beforeUnmount=function(e,t){const n=this.$element;if(!de.beforeUnmount.has(n)){de.beforeUnmount.set(n,new Map);const e=n.remove.bind(n);let t=!1;n.remove=async()=>{if(!t){t=!0;try{const e=de.beforeUnmount.get(n);for(const t of e.values())await t.call(this,n)}finally{e(),t=!1}}}}return de.beforeUnmount.get(n).set(e,t),this},fe.prototype.htmlElement=function(){return this.$element},fe.prototype.node=fe.prototype.htmlElement,fe.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},fe.prototype.openShadow=function(e=null){return this.shadow("open",e)},fe.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},fe.prototype.with=function(e){if(!e||"object"!=typeof e)throw new r("extend() requires an object of methods");for(const t in e){const r=e[t];"function"==typeof r?this[t]=r.bind(this):n.warn(`⚠️ extends(): "${t}" is not a function, skipping`)}return this},fe.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}"`);fe.prototype[o]&&n.warn("NDElement.extend",`Overwriting existing prototype method "${o}"`),fe.prototype[o]=s}else n.warn("NDElement.extend",`"${o}" is not a function, skipping`)}return fe};const be={configurable:!0,get(){return new fe(this)}};Object.defineProperty(HTMLElement.prototype,"nd",be),Object.defineProperty(DocumentFragment.prototype,"nd",be),Object.defineProperty(fe.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();fe.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();fe.prototype["onStop"+e]=function(e=null){return ge(this.$element,t,e),this},fe.prototype["onPreventStop"+e]=function(e=null){return ve(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();fe.prototype["onPrevent"+e]=function(e=null){return ye(this.$element,t,e),this}}),fe.prototype.on=function(e,t,n){return this.$element.addEventListener(e.toLowerCase(),t,n),this};const ye=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},ge=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},ve=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},we={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,...we}}});let $e=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 Se=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}},Ce=e=>e?e.toNdElement():ce.createTextNode(),Oe=(e,t,n=null)=>{let{props:r,children:o=null}=Se(t,n);return ce.processAttributes(e,r),ce.processChildren(o,e),e};function Ae(e,t=null){if(e){if(t){let n=null,r=(o,s)=>(n=document.createElement(e),r=(e,r)=>Oe(t(n.cloneNode()),e,r),Oe(t(n.cloneNode()),o,s));return(e,t)=>r(e,t)}let n=null,r=(t,o)=>(n=document.createElement(e),r=(e,t)=>Oe(n.cloneNode(),e,t),Oe(n.cloneNode(),t,o));return(e,t)=>r(e,t)}return(e,t="")=>{const n=pe(t);return n.append(e),n}}function Ee(e){this.$hydrate=e}function _e(e){this.$element=e,this.$classes=null,this.$styles=null,this.$attrs=null,this.$ndMethods=null}Ee.prototype.__$isTemplateBinding=!0,fe.prototype.attach=function(e,t){if("function"==typeof t){const n=this.$element;return n.nodeCloner=n.nodeCloner||new _e(n),n.nodeCloner.attach(e,t),n}return t.$hydrate(this.$element,e),this.$element},_e.prototype.__$isNodeCloner=!0;const xe=(e,t,n)=>{for(const r in t)e[r]=t[r].apply(null,n);return e};_e.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),ce.processClassAttribute(e,t)})}else e.push((e,n)=>{ce.processClassAttribute(e,xe(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),ce.processStyleAttribute(e,t)})}else e.push((e,n)=>{ce.processStyleAttribute(e,xe(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),ce.processAttributes(e,t)})}else e.push((e,n)=>{ce.processAttributes(e,xe(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}},_e.prototype.cloneNode=function(e){return this.$element.cloneNode(!1)},_e.prototype.attach=function(e,t){return this.$ndMethods=this.$ndMethods||{},this.$ndMethods[e]=t,this},_e.prototype.text=function(e){return this.$content=e,"function"==typeof e?(this.cloneNode=t=>Ce(e.apply(null,t)),this):(this.cloneNode=t=>Ce(t[0][e]),this)},_e.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 Ne(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=Fe(this);return t=e(o),t.nodeCloner||(t.nodeCloner=new _e(t)),n(t),this.clone=t.dynamicCloneNode,t.dynamicCloneNode(r)};const r=(e,t)=>new Ee((n,r)=>{!function(e,t,n,r){n.nodeCloner=n.nodeCloner||new _e(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 Fe=e=>new Proxy(e,{get:(e,t)=>t in e||"symbol"==typeof t?e[t]:e.value(t)});function De(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=pe("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.errorBoundary=function(e){const t=(...n)=>{try{return this.apply(this,n)}catch(r){return e(r,{caller:t,args:n})}};return t},fe.$getChild=ce.getChild,String.prototype.toNdElement=function(){return ce.createStaticTextNode(null,this)},Number.prototype.toNdElement=function(){return ce.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},y.prototype.toNdElement=function(){return ce.createObservableNode(null,this)},Q.prototype.toNdElement=y.prototype.toNdElement,fe.prototype.toNdElement=function(){const e=this.$element??this.$build?.()??this.build?.()??null;return this.$attachements?(this.$attachements.contains(this.$element)||this.$attachements.append(this.$element),this.$attachements):e},Array.prototype.toNdElement=function(){const e=document.createDocumentFragment();for(let t=0,n=this.length;t<n;t++){const n=ce.getChild(this[t]);null!==n&&e.appendChild(n)}return e},Function.prototype.toNdElement=function(){return ce.getChild(this())},Ee.prototype.toNdElement=function(){return ce.createHydratableNode(null,this)};const Me=(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()});fe.prototype.transitionOut=function(e){const t=e+"-exit",n=this.$element;return this.beforeUnmount("transition-exit",async function(){n.classes.add(t),await Me(n),n.classes.remove(t)}),this},fe.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),Me(r).then(()=>{r.classes.remove(n)})})})}),this},fe.prototype.transition=function(e){return this.transitionIn(e),this.transitionOut(e),this},fe.prototype.animate=function(e){const t=this.$element;return t.classes.add(e),Me(t).then(()=>{t.classes.remove(e)}),this},y.prototype.handleNdAttribute=function(e,t){u.has(t)?ae(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)},Q.prototype.handleNdAttribute=y.prototype.handleNdAttribute,Ee.prototype.handleNdAttribute=function(e,t){this.$hydrate(e,t)};const Te=function(e={}){let t=l.isString(e)?e.split(";").filter(Boolean):e;return{add(e,n){if(Array.isArray(t))t.push(e+": "+n);else if(l.isObject(e)){n=e;for(const e in n)t[e]=n[e]}else t[e]=n},value:()=>Array.isArray(t)?t.join(";").concat(";"):{...t}}},ke=function(e=[]){let t=l.isString(e)?e.split(" ").filter(Boolean):e;return{add(e,n=!0){if(l.isJson(e))for(const n in e)e[n]&&(t[n]=e[n]);else if(null!=n||e.__$Observable)if(Array.isArray(t)&&(t=t.reduce((e,t)=>(e[t]=!0,e),{})),e.__$Observable){const n=`obs-${Math.random().toString(36).substr(2,9)}`;t[n]=e}else t[e]=n;else Array.isArray(t)?t.push(e):t[e]=n},value:()=>Array.isArray(t)?t.join(" "):{...t}}},Pe=e=>{let t=null;return(...n)=>(null!=t||(t=e(...n)),t)},Ie=e=>{let t=null;return new Proxy({},{get:(n,r)=>(t||(t=e()),t[r])})},Le=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}})},Re=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)?ne.array(e,t):"object"==typeof e?ne.object(e,t):ne(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=ne.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=Re();return t&&t(n),n},createPersistent(e,t,n){n=n||e;const r=this.create(e,m(n,t)),o=b(t);return r.subscribe(e=>o(n,e)),r},createPersistentResettable(e,t,n){n=n||e;const r=this.createResettable(e,m(n,t)),o=b(t);r.subscribe(e=>o(n,e));const s=r.reset.bind(r);return r.reset=()=>{f.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.")}})},Ve=Re();Ve.create("locale",navigator.language.split("-")[0]||"en");const je=e=>e;const Be=new Set(["clear","push","unshift","replace"]),We=e=>e;const qe=function(e,t,{comment:r=null,shouldKeepInCache:o=!0}={}){if(!l.isObservable(e))return"boolean"==typeof e?e?ce.getChild(t):null:n.warn("ShowIf","ShowIf : condition must be an Observable or boolean / "+r,e);const s=pe("Show if : "+(r||""));let i=null;const a=()=>(i&&o||(i=ce.getChild(t),l.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},Ue=function(e,t,n=!0){if(!l.isObservable(e))throw new r("Toggle : condition must be an Observable");const o=pe("Match"),s=new Map,i=function(e){if(n&&s.has(e))return s.get(e);let r=t[e];return r?(r=ce.getChild(r),l.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(r){n&&s.delete(r),e.set([...s.keys()].at(-1)??""),delete t[r]}})},He=function(e,t,n){if(!l.isObservable(e))throw new r("Toggle : condition must be an Observable");return Ue(e.toBoolean(),{true:t,false:n})},ze=Ae("div"),Ge=Ae("span"),Ke=Ae("label"),Je=Ae("p"),Ye=Je,Qe=Ae("strong"),Xe=Ae("h1"),Ze=Ae("h2"),et=Ae("h3"),tt=Ae("h4"),nt=Ae("h5"),rt=Ae("h6"),ot=Ae("br"),st=Ae("a"),it=Ae("pre"),at=Ae("code"),lt=Ae("blockquote"),ut=Ae("hr"),ct=Ae("em"),ht=Ae("small"),pt=Ae("mark"),dt=Ae("del"),ft=Ae("ins"),mt=Ae("sub"),bt=Ae("sup"),yt=Ae("abbr"),gt=Ae("cite"),vt=Ae("q"),wt=Ae("dl"),$t=Ae("dt"),St=Ae("dd"),Ct=Ae("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}),Ot=Ae("input"),At=Ae("textarea"),Et=At,_t=Ae("select"),xt=Ae("fieldset"),Nt=Ae("option"),Ft=Ae("legend"),Dt=Ae("datalist"),Mt=Ae("output"),Tt=Ae("progress"),kt=Ae("meter"),Pt=Ae("button"),It=Ae("main"),Lt=Ae("section"),Rt=Ae("article"),Vt=Ae("aside"),jt=Ae("nav"),Bt=Ae("figure"),Wt=Ae("figcaption"),qt=Ae("header"),Ut=Ae("footer"),Ht=Ae("img"),zt=function(e,t){return Ht({src:e,...t})},Gt=Ae("details"),Kt=Ae("summary"),Jt=Ae("dialog"),Yt=Ae("menu"),Qt=Ae("ol"),Xt=Ae("ul"),Zt=Ae("li"),en=Zt,tn=Qt,nn=Xt,rn=Ae("audio"),on=Ae("video"),sn=Ae("source"),an=Ae("track"),ln=Ae("canvas"),un=Ae("svg"),cn=Ae("time"),hn=Ae("data"),pn=Ae("address"),dn=Ae("kbd"),fn=Ae("samp"),mn=Ae("var"),bn=Ae("wbr"),yn=Ae("caption"),gn=Ae("table"),vn=Ae("thead"),wn=Ae("tfoot"),$n=Ae("tbody"),Sn=Ae("tr"),Cn=Sn,On=Ae("th"),An=On,En=On,_n=Ae("td"),xn=_n;function Nn(e){let t=null,n=(r,o)=>(t=document.createElementNS("http://www.w3.org/2000/svg",e),n=(e,n)=>Oe(t.cloneNode(),e,n),Oe(t.cloneNode(),r,o));return(e,t)=>n(e,t)}const Fn=Nn("svg"),Dn=Nn("circle"),Mn=Nn("rect"),Tn=Nn("ellipse"),kn=Nn("line"),Pn=Nn("polyline"),In=Nn("polygon"),Ln=Nn("path"),Rn=Nn("text"),Vn=Nn("tspan"),jn=Nn("textPath"),Bn=Nn("g"),Wn=Nn("defs"),qn=Nn("use"),Un=Nn("symbol"),Hn=Nn("clipPath"),zn=Nn("mask"),Gn=Nn("marker"),Kn=Nn("pattern"),Jn=Nn("image"),Yn=Nn("foreignObject"),Qn=Nn("switch"),Xn=Nn("linearGradient"),Zn=Nn("radialGradient"),er=Nn("stop"),tr=Nn("filter"),nr=Nn("feBlend"),rr=Nn("feColorMatrix"),or=Nn("feComposite"),sr=Nn("feFlood"),ir=Nn("feGaussianBlur"),ar=Nn("feMerge"),lr=Nn("feMergeNode"),ur=Nn("feOffset"),cr=Nn("feTurbulence"),hr=Nn("feDisplacementMap"),pr=Nn("feDiffuseLighting"),dr=Nn("feSpecularLighting"),fr=Nn("feDistantLight"),mr=Nn("fePointLight"),br=Nn("feSpotLight"),yr=Nn("feMorphology"),gr=Nn("feConvolveMatrix"),vr=Nn("feComponentTransfer"),wr=Nn("feFuncR"),$r=Nn("feFuncG"),Sr=Nn("feFuncB"),Cr=Nn("feFuncA"),Or=Nn("animate"),Ar=Nn("animateTransform"),Er=Nn("animateMotion"),_r=Nn("mpath"),xr=Nn("set"),Nr=Nn("desc"),Fr=Nn("title"),Dr=Nn("metadata"),Mr=Nn("view"),Tr=Nn("style"),kr=Nn("script"),Pr=Ae("");var Ir=Object.freeze({__proto__:null,Abbr:yt,Address:pn,Anchor:pe,Article:Rt,Aside:Vt,AsyncImg:function(e,t,n,o){const s=l.isObservable(e)?e.val():e,i=zt(t||s,n),a=new Image;return a.onload=()=>{l.isFunction(o)&&o(null,i),i.src=l.isObservable(e)?e.val():e},a.onerror=()=>{l.isFunction(o)&&o(new r("Image not found"))},l.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=s,i},Audio:rn,BaseImage:Ht,Blockquote:lt,Br:ot,Button:Pt,Canvas:ln,Caption:yn,Checkbox:e=>Ot({type:"checkbox",...e}),Cite:gt,Code:at,ColorInput:e=>Ot({type:"color",...e}),Data:hn,Datalist:Dt,DateInput:e=>Ot({type:"date",...e}),DateTimeInput:e=>Ot({type:"datetime-local",...e}),Dd:St,Del:dt,Details:Gt,Dialog:Jt,Div:ze,Dl:wt,Dt:$t,Em:ct,EmailInput:e=>Ot({type:"email",...e}),FieldSet:xt,FigCaption:Wt,Figure:Bt,FileInput:e=>Ot({type:"file",...e}),Footer:Ut,ForEach:function(e,t,o,{shouldKeepItemsInCache:s=!1}={}){t=t||je;const i=pe("ForEach"),a=i.endElement();i.startElement();let u=new Map,c=null;const h=new Set,p=e=>{if(!s)for(const[t,n]of u.entries()){if(h.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),c&&c.delete(n.keyId)}},d=(e,s)=>{const i=((e,t,n)=>{if(l.isString(n)){const r=l.isObservable(e)?e.val():e,o=r?.[n];return l.isObservable(o)?o.val():o??t}return l.isFunction(n)?n(e,t):(l.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?ne(s):null;let o=ce.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=l.isObservable(e)?e.val():e;if(h.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=d(n[e],e);h.add(t)}else for(const e in n){const t=d(n[e],e);h.add(t)}if(0===h.size)return i.removeChildren(),p(),void c?.clear();p(t),c&&0!==c.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(h);Array.from(c);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 h){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),c?.clear(),c=new Set([...h])};return f(),l.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n={}){t=t||We;const r=pe("ForEach Array",n.isParentUniqueChild),o=r.endElement();let s=new Map,i=0;const a=t.length>=2,l=e=>{r.removeChildren(),f(e),i=0},u=e=>s.get(e)?.child,c=(e,t=!0)=>{const n=s.get(e);if(n){if(t){const t=n.child;t?.remove(),s.delete(e)}n.indexObserver?.cleanup()}},h=e=>{const n=ce.getChild(t(e,null));return s.set(e,{child:n,indexObserver:null}),n};let p=(n,r)=>{const o=e.transform(e=>e.indexOf(n)),i=ce.getChild(t(n,o));return s.set(n,{child:i,indexObserver:o}),i};e.__$Observable||(p=(e,n)=>{const r=ce.getChild(t(e,n));return s.set(e,{child:r,indexObserver:null}),r});const d=(e,t)=>{const n=s.get(e);return n?(n.indexObserver?.set(t),n.child):h(e)};let f,m=h;f=a?n.shouldKeepItemsInCache?()=>{}:e=>{for(const[t,n]of s.entries())e&&e.includes(t)||c(t,!1)}:s.clear.bind(s);const b=(e,t)=>{const n=s.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()};let y=null;y=Array.isArray(e)?()=>{l(e),r.appendChildRaw(g.toFragment(e))}:()=>{const t=e.val();l(t),r.appendChildRaw(g.toFragment(t))};const g={toFragment:e=>{const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(m(e[n],i)),i++;return t},add:e=>{r.appendChildRaw(g.toFragment(e))},replace:e=>{l(e),r.appendChildRaw(g.toFragment(e))},set:y,reOrder:e=>{let t=null;const n=document.createDocumentFragment();for(const r of e)t=u(r),t&&n.appendChild(t);t=null,r.appendElementRaw(n)},removeOne:(e,t)=>{c(e,!0)},clear:l,populate:([e,t,n])=>{const o=document.createDocumentFragment();for(let r=0;r<t;r++){const t=n(r);e.push(t),o.append(m(t,r)),i++}r.appendChildRaw(o),o.replaceChildren()},unshift:e=>{r.insertAtStartRaw(g.toFragment(e))},splice:(t,n)=>{const[s,i,...a]=t;let l=null;const c=document.createDocumentFragment();if(n.length>0){let e=n[0];if(1===n.length)b(e,c);else if(n.length>1){const e=u(n[0]);l=e?.previousSibling;for(let e=0;e<n.length;e++)b(n[e],c)}}else{const t=s-1>=0?s-1:s,n=e.at(t);l=u(n)||o.previousSibling}c.replaceChildren(),a&&a.length&&l&&r.insertBeforeRaw(g.toFragment(a),l.nextSibling)},reverse:(e,t)=>{g.reOrder(t)},sort:(e,t)=>{g.reOrder(t)},remove:(e,t)=>{g.removeOne(t)},pop:(e,t)=>{g.removeOne(t)},shift:(e,t)=>{g.removeOne(t)},swap:(e,t)=>{const n=r.getParent();let o=u(t[0]),s=u(t[1]);if(!o||!s)return;const i=s.nextSibling;n.insertBefore(s,o),n.insertBefore(o,i),o=null,s=null}};g.merge=g.add,g.push=g.add;const v=(e,t,n={})=>{((e=null)=>{m=Be.has(e)?a?p:h:s.size?d:a?p:h})(n.action),g[n.action]&&g[n.action](n.args,n.result)};return Array.isArray(e)?(v(0,0,{action:"set"}),r):(e.val().length&&v(e.val(),0,{action:"set"}),e.subscribe(v),r)},Form:Ct,Fragment:Pr,H1:Xe,H2:Ze,H3:et,H4:tt,H5:nt,H6:rt,Header:qt,HiddenInput:e=>Ot({type:"hidden",...e}),HideIf:function(e,t,n){const r=ne(!e.val());return e.subscribe(e=>r.set(!e)),qe(r,t,n)},HideIfNot:function(e,t,n){return qe(e,t,n)},Hr:ut,Img:zt,Input:Ot,Ins:ft,Kbd:dn,Label:Ke,LazyImg:function(e,t){return zt(e,{...t,loading:"lazy"})},Legend:Ft,Li:en,Link:st,ListItem:Zt,Main:It,Mark:pt,Match:Ue,Menu:Yt,Meter:kt,MonthInput:e=>Ot({type:"month",...e}),NativeDocumentFragment:pe,Nav:jt,NumberInput:e=>Ot({type:"number",...e}),Ol:tn,Option:Nt,OrderedList:Qt,Output:Mt,P:Je,Paragraph:Ye,PasswordInput:e=>Ot({type:"password",...e}),Pre:it,Progress:Tt,Quote:vt,Radio:e=>Ot({type:"radio",...e}),RangeInput:e=>Ot({type:"range",...e}),ReadonlyInput:e=>Ot({readonly:!0,...e}),Samp:fn,SearchInput:e=>Ot({type:"search",...e}),Section:Lt,Select:_t,ShowIf:qe,ShowWhen:function(){if(2===arguments.length){const[e,t]=arguments;if(!l.isObservableWhenResult(e))throw new r("showWhen observer must be an ObservableWhenResult",{data:e,help:"Use observer.when(target) to create an ObservableWhenResult"});return qe(e,t)}if(3===arguments.length){const[e,t,n]=arguments;if(!l.isObservable(e))throw new r("showWhen observer must be an Observable",{data:e});return qe(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)=>Pt(e,{type:"button",...t}),Small:ht,Source:sn,Span:Ge,Strong:Qe,Sub:mt,SubmitButton:(e,t)=>Pt(e,{type:"submit",...t}),Summary:Kt,Sup:bt,Svg:un,SvgAnimate:Or,SvgAnimateMotion:Er,SvgAnimateTransform:Ar,SvgCircle:Dn,SvgClipPath:Hn,SvgDefs:Wn,SvgDesc:Nr,SvgEllipse:Tn,SvgFEBlend:nr,SvgFEColorMatrix:rr,SvgFEComponentTransfer:vr,SvgFEComposite:or,SvgFEConvolveMatrix:gr,SvgFEDiffuseLighting:pr,SvgFEDisplacementMap:hr,SvgFEDistantLight:fr,SvgFEFlood:sr,SvgFEFuncA:Cr,SvgFEFuncB:Sr,SvgFEFuncG:$r,SvgFEFuncR:wr,SvgFEGaussianBlur:ir,SvgFEMerge:ar,SvgFEMergeNode:lr,SvgFEMorphology:yr,SvgFEOffset:ur,SvgFEPointLight:mr,SvgFESpecularLighting:dr,SvgFESpotLight:br,SvgFETurbulence:cr,SvgFilter:tr,SvgForeignObject:Yn,SvgG:Bn,SvgImage:Jn,SvgLine:kn,SvgLinearGradient:Xn,SvgMPath:_r,SvgMarker:Gn,SvgMask:zn,SvgMetadata:Dr,SvgPath:Ln,SvgPattern:Kn,SvgPolygon:In,SvgPolyline:Pn,SvgRadialGradient:Zn,SvgRect:Mn,SvgScript:kr,SvgSet:xr,SvgStop:er,SvgStyle:Tr,SvgSvg:Fn,SvgSwitch:Qn,SvgSymbol:Un,SvgTSpan:Vn,SvgText:Rn,SvgTextPath:jn,SvgTitle:Fr,SvgUse:qn,SvgView:Mr,Switch:He,TBody:$n,TBodyCell:xn,TFoot:wn,TFootCell:En,THead:vn,THeadCell:An,TRow:Cn,Table:gn,Td:_n,TelInput:e=>Ot({type:"tel",...e}),TextArea:At,TextInput:Et,Th:On,Time:cn,TimeInput:e=>Ot({type:"time",...e}),Tr:Sn,Track:an,Ul:nn,UnorderedList:Xt,UrlInput:e=>Ot({type:"url",...e}),Var:mn,Video:on,Wbr:bn,WeekInput:e=>Ot({type:"week",...e}),When:function(e){if(!l.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,He(e,t,n)),toNdElement:()=>He(e,t,n)}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=pe("Portal "+n);return r.appendChild(ce.getChild(e)),(t||document.body).appendChild(r),r}});const Lr={};function Rr(e,t,n={}){e="/"+p(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=Lr[n]),r||(r="[^/]+"),r=r.replace("(","(?:"),{name:t,pattern:`(${r})`}},d=()=>{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="/"+p(e,"/");if(!d().exec(e))return!1;const t={};return d().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 Vr extends Error{constructor(e,t){super(e),this.context=t}}const jr=(e,t)=>{const n=[];return e.forEach(e=>{n.push(p(e.suffix,"/"))}),n.push(p(t,"/")),n.join("/")},Br=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Wr=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},qr=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Ur(){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 Hr(){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 zr(){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 Gr(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 l.isAnchor(e)||(r=pe(t),r.appendChild(e)),o.set(e,r),r},u=()=>{l.isAnchor(i)&&i.remove()},c=()=>{t.nodeValue="",u(),s&&s.remove()},h=e=>{let t=e;return l.isNDElement(e)&&(t=e.node()),t},p=function(e,n,o){const l=n.layout();if(l)return void((e,n,o,l)=>{let p=h(n);const d=r.get(p);if(d){if(d===s){const e=a(p,l);return u(),i=p,void e.replaceContent(p)}return c(),i=p,s=d,a(p,l).replaceContent(p),void t.appendChild(s)}c(),i=p;const f=a(p,l);s=ce.getChild(e(f)),r.set(p,s),t.appendChild(s)})(l,e,0,o);let p=h(e);c(),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 p(e,t)}const i=t.component()({params:r,query:o});n.set(s,i),p(i,t,s)};return e.subscribe(d),d(e.currentState()),t}const Kr="default";function Jr(e={}){const t=[],r={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Ur.apply(this,[]);else if("history"===e.mode)Hr.apply(this,[]);else{if("memory"!==e.mode)throw new Vr("Invalid router mode "+e.mode);zr.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 Rr(jr(o,e),n,{...s,middlewares:Br(o,s?.middlewares||[]),name:s?.name?Wr(o,s.name):null,layout:s?.layout||qr(o)});return t.push(i),i.name()&&(r[i.name()]=i),this},this.group=function(e,t,n){if(!l.isFunction(n))throw new Vr("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 Vr(`Route not found for name: ${e}`);return o.url({params:t,query:n})},this.resolve=function(e){if("string"==typeof e){const t=r[e];if(t)return{route:t,params:[],query:[],path:t.url({name:e})}}if(l.isJson(e)){const t=r[e.name];if(!t)throw new Vr(`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="/"+p(n,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Vr(`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(!l.isFunction(e))throw new Vr("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 Yr(e,t){const{to:n,href:r,...o}=e;if(r){const e=Jr.get();return st({...o,href:r},t).nd.onPreventClick(()=>{e.push(r)})}const s="string"==typeof n?{name:n}:n,i=s.router||Kr,a=Jr.get(i);if(!a)throw new Vr('Router not found "'+i+'" for link "'+s.name+'"');const l=a.generateUrl(s.name,s.params,s.query);return st({...o,href:l},t).nd.onPreventClick(()=>{a.push(l)})}Jr.routers={},Jr.create=function(e,t){if(!l.isFunction(t))throw n.error("Router","Callback must be a function"),new Vr("Callback must be a function");const r=new Jr(e);return Jr.routers[e.name||Kr]=r,t(r),r.init(e.entry),r.mount=function(e){if(l.isString(e)){const t=document.querySelector(e);if(!t)throw new Vr(`Container not found for selector: ${e}`);e=t}else if(!l.isElement(e))throw new Vr("Container must be a string or an Element");return Gr(r,e)},r},Jr.get=function(e){const t=Jr.routers[e||Kr];if(!t)throw new Vr(`Router not found for name: ${e}`);return t},Jr.push=function(e,t=null){return Jr.get(t).push(e)},Jr.replace=function(e,t=null){return Jr.get(t).replace(e)},Jr.forward=function(e=null){return Jr.get(e).forward()},Jr.back=function(e=null){return Jr.get(e).back()},Jr.redirectTo=function(e,t=null,n=null){let r=e;const o=Jr.get(n);return o.resolve({name:e,params:t})&&(r={name:e,params:t}),o.push(r)},Yr.blank=function(e,t){return st({...e,target:"_blank"},t)};var Qr=Object.freeze({__proto__:null,Link:Yr,RouteParamPatterns:Lr,Router:Jr});var Xr=Object.freeze({__proto__:null,memoize:e=>Le(e),once:e=>Ie(e),singleton:e=>Pe(e)}),Zr=Object.freeze({__proto__:null,Cache:Xr,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)}},classPropertyAccumulator:ke,cssPropertyAccumulator:Te,filters:U});return e.$=re,e.ElementCreator=ce,e.HtmlElementWrapper=Ae,e.NDElement=fe,e.Observable=ne,e.PluginsManager=null,e.SingletonView=De,e.Store=Ve,e.StoreFactory=Re,e.TemplateCloner=Ne,e.Validator=l,e.autoMemoize=Le,e.autoOnce=Ie,e.classPropertyAccumulator=ke,e.createTextNode=Ce,e.cssPropertyAccumulator=Te,e.elements=Ir,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=Se,e.obs=oe,e.once=Pe,e.router=Qr,e.useCache=function(e){let t=null,n=r=>{t=new Ne(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 De(e)),t.render(n)}},e.utils=Zr,e.withValidation=$e,e}({});
|
package/index.js
CHANGED
|
@@ -6,17 +6,21 @@ export { SingletonView, useSingleton } from './src/core/wrappers/SingletonView';
|
|
|
6
6
|
export { default as PluginsManager } from './src/core/utils/plugins-manager';
|
|
7
7
|
export { default as Validator } from './src/core/utils/validator';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import './src/core/utils/prototypes.js';
|
|
10
|
+
import './src/core/wrappers/prototypes/nd-element-extensions';
|
|
11
|
+
import './src/core/wrappers/prototypes/nd-element.transition.extensions';
|
|
12
|
+
import './src/core/wrappers/prototypes/attributes-extensions';
|
|
13
|
+
import './src/core/wrappers/prototypes/bind-class-extensions';
|
|
12
14
|
|
|
13
15
|
export * from './src/core/utils/property-accumulator';
|
|
14
16
|
export * from './src/core/utils/args-types';
|
|
15
17
|
export * from './src/core/utils/memoize';
|
|
16
18
|
export * from './src/core/data/Observable';
|
|
17
|
-
export * from './src/core/data/observable-helpers/
|
|
18
|
-
export * from './src/core/data/observable-helpers/batch';
|
|
19
|
-
export * from './src/core/data/observable-helpers/object';
|
|
20
|
-
export * from './src/core/data/observable-helpers/computed';
|
|
19
|
+
export * from './src/core/data/observable-helpers/observable.is-to';
|
|
21
20
|
export * from './src/core/data/Store';
|
|
22
21
|
|
|
22
|
+
import * as elements from './elements';
|
|
23
|
+
import * as router from './router';
|
|
24
|
+
import * as utils from './utils';
|
|
25
|
+
|
|
26
|
+
export { elements, router, utils };
|
package/package.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import ObservableItem from './ObservableItem';
|
|
2
2
|
import MemoryManager from "./MemoryManager";
|
|
3
3
|
import NativeDocumentError from "../../core/errors/NativeDocumentError";
|
|
4
|
+
import ObservableArray from "./ObservableArray";
|
|
5
|
+
import Validator from "../utils/validator";
|
|
6
|
+
import {nextTick} from "../utils/helpers";
|
|
7
|
+
import PluginsManager from "../utils/plugins-manager";
|
|
8
|
+
import {ObservableObject} from "./ObservableObject";
|
|
4
9
|
|
|
10
|
+
import "./observable-helpers/observable.is-to";
|
|
11
|
+
import './observable-helpers/observable.prototypes';
|
|
5
12
|
/**
|
|
6
13
|
*
|
|
7
14
|
* @param {*} value
|
|
@@ -72,3 +79,137 @@ Observable.autoCleanup = function(enable = false, options = {}) {
|
|
|
72
79
|
setInterval(() => MemoryManager.cleanObservables(threshold), interval);
|
|
73
80
|
};
|
|
74
81
|
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Creates an observable array with reactive array methods.
|
|
85
|
+
* All mutations trigger updates automatically.
|
|
86
|
+
*
|
|
87
|
+
* @param {Array} [target=[]] - Initial array value
|
|
88
|
+
* @param {Object|null} [configs=null] - Configuration options
|
|
89
|
+
* // @param {boolean} [configs.propagation=true] - Whether to propagate changes to parent observables
|
|
90
|
+
* // @param {boolean} [configs.deep=false] - Whether to make nested objects observable
|
|
91
|
+
* @param {boolean} [configs.reset=false] - Whether to store initial value for reset()
|
|
92
|
+
* @returns {ObservableArray} An observable array with reactive methods
|
|
93
|
+
* @example
|
|
94
|
+
* const items = Observable.array([1, 2, 3]);
|
|
95
|
+
* items.push(4); // Triggers update
|
|
96
|
+
* items.subscribe((arr) => console.log(arr));
|
|
97
|
+
*/
|
|
98
|
+
Observable.array = function(target = [], configs = null) {
|
|
99
|
+
return new ObservableArray(target, configs);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @param {Function} callback
|
|
105
|
+
* @returns {Function}
|
|
106
|
+
*/
|
|
107
|
+
Observable.batch = function(callback) {
|
|
108
|
+
const $observer = Observable(0);
|
|
109
|
+
const batch = function() {
|
|
110
|
+
if(Validator.isAsyncFunction(callback)) {
|
|
111
|
+
return (callback(...arguments)).then(() => {
|
|
112
|
+
$observer.trigger();
|
|
113
|
+
}).catch(error => { throw error; });
|
|
114
|
+
}
|
|
115
|
+
callback(...arguments);
|
|
116
|
+
$observer.trigger();
|
|
117
|
+
};
|
|
118
|
+
batch.$observer = $observer;
|
|
119
|
+
return batch;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Creates a computed observable that automatically updates when its dependencies change.
|
|
125
|
+
* The callback is re-executed whenever any dependency observable changes.
|
|
126
|
+
*
|
|
127
|
+
* @param {Function} callback - Function that returns the computed value
|
|
128
|
+
* @param {Array<ObservableItem|ObservableChecker|ObservableProxy>|Function} [dependencies=[]] - Array of observables to watch, or batch function
|
|
129
|
+
* @returns {ObservableItem} A new observable that updates automatically
|
|
130
|
+
* @example
|
|
131
|
+
* const firstName = Observable('John');
|
|
132
|
+
* const lastName = Observable('Doe');
|
|
133
|
+
* const fullName = Observable.computed(
|
|
134
|
+
* () => `${firstName.val()} ${lastName.val()}`,
|
|
135
|
+
* [firstName, lastName]
|
|
136
|
+
* );
|
|
137
|
+
*
|
|
138
|
+
* // With batch function
|
|
139
|
+
* const batch = Observable.batch(() => { ... });
|
|
140
|
+
* const computed = Observable.computed(() => { ... }, batch);
|
|
141
|
+
*/
|
|
142
|
+
Observable.computed = function(callback, dependencies = []) {
|
|
143
|
+
const initialValue = callback();
|
|
144
|
+
const observable = new ObservableItem(initialValue);
|
|
145
|
+
const getValues = () => dependencies.map((item) => item.val());
|
|
146
|
+
const updatedValue = nextTick(() => observable.set(callback(...getValues())));
|
|
147
|
+
if(process.env.NODE_ENV === 'development') {
|
|
148
|
+
PluginsManager.emit('CreateObservableComputed', observable, dependencies);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if(Validator.isFunction(dependencies)) {
|
|
152
|
+
if(!Validator.isObservable(dependencies.$observer)) {
|
|
153
|
+
throw new NativeDocumentError('Observable.computed : dependencies must be valid batch function');
|
|
154
|
+
}
|
|
155
|
+
dependencies.$observer.subscribe(updatedValue);
|
|
156
|
+
return observable;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
dependencies.forEach(dependency => {
|
|
160
|
+
if(Validator.isProxy(dependency)) {
|
|
161
|
+
dependency.$observables.forEach((observable) => {
|
|
162
|
+
observable.subscribe(updatedValue);
|
|
163
|
+
});
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
dependency.subscribe(updatedValue);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return observable;
|
|
170
|
+
};
|
|
171
|
+
ObservableItem.computed = Observable.computed;
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
Observable.init = function(initialValue, configs = null) {
|
|
175
|
+
return new ObservableObject(initialValue, configs)
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
*
|
|
180
|
+
* @param {any[]} data
|
|
181
|
+
* @return Proxy[]
|
|
182
|
+
*/
|
|
183
|
+
Observable.arrayOfObject = function(data) {
|
|
184
|
+
return data.map(item => Observable.object(item));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Get the value of an observable or an object of observables.
|
|
189
|
+
* @param {ObservableItem|Object<ObservableItem>} data
|
|
190
|
+
* @returns {{}|*|null}
|
|
191
|
+
*/
|
|
192
|
+
Observable.value = function(data) {
|
|
193
|
+
if(data?.__$isObservableArray) {
|
|
194
|
+
const result = [];
|
|
195
|
+
for(let i = 0, length = data.length; i < length; i++) {
|
|
196
|
+
const item = data.at(i);
|
|
197
|
+
result.push(Observable.value(item));
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
if(data?.__$Observable) {
|
|
202
|
+
return data.val();
|
|
203
|
+
}
|
|
204
|
+
if(Validator.isProxy(data)) {
|
|
205
|
+
return data.$value;
|
|
206
|
+
}
|
|
207
|
+
return data;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
ObservableItem.prototype.resolve = function () {
|
|
211
|
+
return Observable.value(this);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
Observable.object = Observable.init;
|
|
215
|
+
Observable.json = Observable.init;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {match} from "../utils/filters/index";
|
|
2
2
|
import Validator from "../utils/validator";
|
|
3
3
|
import ObservableItem from "./ObservableItem.js";
|
|
4
|
-
import {Observable} from "./Observable.js";
|
|
5
4
|
import PluginsManager from "../utils/plugins-manager.js";
|
|
6
5
|
import NativeDocumentError from "../errors/NativeDocumentError.js";
|
|
7
6
|
import {nextTick} from "../utils/helpers";
|
|
@@ -281,7 +280,7 @@ ObservableArray.prototype.where = function(predicates) {
|
|
|
281
280
|
}
|
|
282
281
|
}
|
|
283
282
|
|
|
284
|
-
const viewArray =
|
|
283
|
+
const viewArray = new ObservableArray([]);
|
|
285
284
|
|
|
286
285
|
const filters = Object.entries(filterCallbacks);
|
|
287
286
|
const updateView = () => {
|
|
@@ -50,6 +50,8 @@ Object.defineProperty(ObservableItem.prototype, '$value', {
|
|
|
50
50
|
|
|
51
51
|
ObservableItem.prototype.__$Observable = true;
|
|
52
52
|
ObservableItem.prototype.__$isObservable = true;
|
|
53
|
+
ObservableItem.computed = () => {};
|
|
54
|
+
|
|
53
55
|
const DEFAULT_OPERATIONS = {};
|
|
54
56
|
const noneTrigger = function() {};
|
|
55
57
|
|