native-document 1.0.44 → 1.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var NativeDocumentDevTools=function(){"use strict";let e={};e={log(){},warn(){},error(){},disable(){}};var t=e;const n=function(){let e=0;const n=new Map;return{register(t){const r=++e;return n.set(r,new WeakRef(t)),r},unregister(e){n.delete(e)},getObservableById:e=>n.get(e)?.deref(),cleanup(){for(const[e,t]of n){const e=t.deref();e&&e.cleanup()}n.clear()},cleanObservables(e){if(n.size<e)return;let r=0;for(const[e,t]of n)t.deref()||(n.delete(e),r++);r>0&&t.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}();class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const i=function(){const e=new Map,n=new Map;return{list:()=>n,add(t,r){if(!t||"object"!=typeof t)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||t.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){t.$name=r,e.set(r,t),"function"==typeof t?.init&&t.init();for(const e in t)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");n.has(r)||n.set(r,new Set),n.get(r).add(t)}}},remove(t){if(!e.has(t))return;const r=e.get(t);"function"==typeof r.cleanup&&r.cleanup();for(const[e,t]of n.entries())t.has(r)&&t.delete(r),0===t.size&&n.delete(e);e.delete(t)},emit(e,...r){if(!n.has(e))return;const o=n.get(e);for(const n of o){const o=n["on"+e];if("function"==typeof o)try{o.call(n,...r)}catch(r){t.error("Plugin Manager",`Error in plugin ${n.$name} for event ${e}`,r)}}}}}();function s(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,i.emit("CreateObservable",this)}Object.defineProperty(s.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),s.prototype.__$isObservable=!0;const l={},a=function(){};s.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},s.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||l;for(let o=0,i=t.length;o<i;o++)t[o](r,n,e)};const u=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};s.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);u(t,!0)}if(e.has(t)){const n=e.get(t);u(n,!1)}},s.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},s.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},s.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=a},s.prototype.trigger=a,s.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,i.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,i.emit("ObservableAfterChange",this))},s.prototype.val=function(){return this.$currentValue},s.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)C.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=a},s.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},s.prototype.subscribe=function(e,n=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return t.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new r("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),i.emit("ObservableSubscribe",this,n),()=>{this.unsubscribe(e),this.assocTrigger(),i.emit("ObservableUnsubscribe",this)}},s.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!C.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},s.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},s.prototype.check=function(e){return new o(this,e)},s.prototype.get=s.prototype.check,s.prototype.when=function(e){return{$target:e,$observer:this}},s.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"},s.prototype.equals=function(e){return C.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},s.prototype.toBool=function(){return!!this.$currentValue},s.prototype.toggle=function(){this.set(!this.$currentValue)};const c={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(c.mountedSupposedSize>0)for(const e of t.addedNodes){const t=c.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(c.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=c.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{c.mounted.delete(e),c.unmounted.delete(e),c.mountedSupposedSize--,c.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,c.mounted.set(e,n),c.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,c.unmounted.set(e,n),c.unmountedSupposedSize++}}}};c.observer=new MutationObserver(c.checkMutation),c.observer.observe(document.body,{childList:!0,subtree:!0});const d=["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"];function p(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}p.prototype.__$isNDElement=!0,p.prototype.valueOf=function(){return this.$element},p.prototype.ref=function(e,t){return e[t]=this.$element,this},p.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},p.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},p.prototype.lifecycle=function(e){return this.$observer=this.$observer||c.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},p.prototype.mounted=function(e){return this.lifecycle({mounted:e})},p.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},p.prototype.htmlElement=function(){return this.$element},p.prototype.node=p.prototype.htmlElement,p.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},p.prototype.openShadow=function(e=null){return this.shadow("open",e)},p.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},p.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const h={},f=function(e,t,n){if(!e)return;if(!h[t]){const r=new WeakMap;return h[t]=r,void r.set(e,n)}const r=h[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);C.isArray(o)?o.push(n):r.set(e,[store[t],n])},b=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},g=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},m=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},v=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=h[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(C.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of d){const t=e.toLowerCase();p.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},p.prototype["onPrevent"+e]=function(e){return b(this.$element,t,e),this},p.prototype["onStop"+e]=function(e){return g(this.$element,t,e),this},p.prototype["onPreventStop"+e]=function(e){return m(this.$element,t,e),this},p.prototype["when"+e]=function(e){return f(this.$element,t,e),this},p.prototype["capture"+e]=function(e){return v(this.$element,t,e),this}}const y=1,$=3,w=8,O=11,C={isObservable:e=>e?.__$isObservable||e instanceof s||e instanceof o,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===y||e.nodeType===$||e.nodeType===O||e.nodeType===w),isFragment:e=>e?.nodeType===O,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof p,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&&(C.isObject(e)&&Object.values(e).some(e=>C.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")}},A=["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"];function S(e){return new s(e)}function x(e,t,n){e.classes.toggle(t,n)}function E(e,t,n){e.style[t]=n}function N(e,t,n){C.isBoolean(n)?e[t]=n:e[t]=n===e.value}function k(e,t,n,r){C.isBoolean(n)?r.set(e[t]):r.set(e.value)}function P(e,t){for(let n in t){const r=t[n];C.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(x.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,x.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function T(e,t){for(let n in t){const r=t[n];C.isObservable(r)?(e.style[n]=r.val(),r.subscribe(E.bind(null,e,n))):e.style[n]=r}}function D(e,t,n){const r=C.isObservable(n)?n.val():n;C.isBoolean(r)?e[t]=r:e[t]=r===e.value,C.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",k.bind(null,e,t,r)),n.subscribe(N.bind(null,e,t)))}function V(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}S.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},S.cleanup=function(e){e.cleanup()},S.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:r=6e4,threshold:o=100}=t;window.addEventListener("beforeunload",()=>{n.cleanup()}),setInterval(()=>n.cleanObservables(o),r)};const L=new Map;let j=null;const M={createTextNode:()=>(j||(j=document.createTextNode("")),j.cloneNode()),createObservableNode(e,t){const n=M.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=M.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=M.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(L.has(e))return L.get(e).cloneNode();const t=document.createElement(e);return L.set(e,t),t.cloneNode()}return new B("Fragment")},processChildren(e,t){if(null!==e){if(i.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}i.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(C.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,C.isString(e)))return M.createStaticTextNode(null,e);if(C.isElement(e))return e;if(C.isObservable(e))return M.createObservableNode(null,e);if(C.isNDElement(e))return e.$element??e.$build?.()??null;if(C.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return C.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?M.createHydratableNode(null,e):M.createStaticTextNode(null,e)},processAttributes(e,t){C.isFragment(e)||t&&function(e,t){if(!C.isObject(t))throw new r("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(C.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,C.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>C.isObservable(e));o=S.computed(()=>o.map(e=>C.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&C.isObject(o)?P(e,o):"style"===r&&C.isObject(o)?T(e,o):A.includes(r)?D(e,r,o):C.isObservable(o)?V(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(i.emit("Setup",e,t,n),e)};function B(e,n=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),i=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(i),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild;const s=e=>n||e.firstChild===o&&e.lastChild===i;return r.appendElement=function(e,t=null){const n=o.parentNode,s=t||i;n!==r?n?.insertBefore(e,s):n.nativeInsertBefore(e,s)},r.appendChild=function(e,n=null){const o=i.parentNode;o?function(e,t,n){const o=C.isElement(t)?t:M.getChild(t);e!==r?s(e)&&n===i?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)}(o,e,n=n??i):t.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(o,i);let t,n=o.nextSibling;const l=document.createDocumentFragment();for(;n&&n!==i;)t=n.nextSibling,l.append(n),n=t;l.replaceChildren()},r.remove=function(){if(i.parentNode===r)return;let e,t=o.nextSibling;for(;t&&t!==i;)e=t.nextSibling,r.nativeAppendChild(t),t=e},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),i.remove()},r.replaceContent=function(e){const t=i.parentNode;t&&(s(t)?t.replaceChildren(o,e,i):(r.removeChildren(),t.insertBefore(e,i)))},r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return i},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new p(this)}});const _={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,..._}}});function I(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!C.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=M.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&M.processAttributes(l,o),i&&M.processChildren(i,l),M.setup(l,o,t)}function F(e,t){return I.bind(null,e.toLowerCase(),t)}const z=F("div");F("span"),F("label"),F("p"),F("strong"),F("h1"),F("h2"),F("h3"),F("h4"),F("h5"),F("h6"),F("br"),F("a"),F("pre"),F("code"),F("blockquote"),F("hr"),F("em"),F("small"),F("mark"),F("del"),F("ins"),F("sub"),F("sup"),F("abbr"),F("cite"),F("q"),F("dl"),F("dt"),F("dd"),F("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}),F("input"),F("textarea"),F("select"),F("fieldset"),F("option"),F("legend"),F("datalist"),F("output"),F("progress"),F("meter");const W=F("button");F("main"),F("section"),F("article"),F("aside"),F("nav"),F("figure"),F("figcaption"),F("header"),F("footer"),F("img"),F("details"),F("summary"),F("dialog"),F("menu"),F("ol"),F("ul"),F("li"),F("audio"),F("video"),F("source"),F("track"),F("canvas"),F("svg"),F("time"),F("data"),F("address"),F("kbd"),F("samp"),F("var"),F("wbr"),F("caption"),F("table"),F("thead"),F("tfoot"),F("tbody"),F("tr"),F("th"),F("td"),F(""),Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new p(t.$element.cloneNode(!0))})),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return S.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return C.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return C.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!C.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return S.getById(n)}):this.valueOf()};const U=["push","pop","shift","unshift","reverse","sort","splice"];S.array=function(e){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");const t=S(e);i.emit("CreateObservableArray",t),U.forEach(e=>{t[e]=function(...n){const r=t.val()[e](...n);return t.trigger({action:e,args:n,result:r}),r}}),t.clear=function(){return t.val().length=0,t.trigger({action:"clear"}),!0},t.merge=function(e){t.$value.push(...e),t.trigger({action:"merge",args:e})},t.populateAndRender=function(e,n){t.trigger({action:"populate",args:[t.val(),e,n]})},t.removeItem=function(e){const n=t.val().indexOf(e);return t.remove(n)},t.remove=function(e){const n=t.val().splice(e,1);return 0===n.length?[]:(t.trigger({action:"remove",args:[e],result:n[0]}),n)},t.swap=function(e,n){const r=t.val(),o=r.length;if(o<e||o<n)return!1;if(n<e){const t=e;e=n,n=t}const i=r[e],s=r[n];return r[e]=s,r[n]=i,t.trigger({action:"swap",args:[e,n],result:[i,s]}),!0},t.length=function(){return t.val().length},t.count=e=>{let n=0;return t.val().forEach((t,r)=>{e(t,r)&&n++}),n},t.isEmpty=function(){return 0===t.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{t[e]=(...n)=>t.val()[e](...n)}),t},S.batch=function(e){const t=S(0),n=function(){if(C.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n},S.init=function(e){const t={};for(const n in e){const r=e[n];Array.isArray(r)?t[n]=S.array(r):t[n]=S(r)}const n=function(){const e={};for(const n in t){const r=t[n];C.isObservable(r)?e[n]=r.val():C.isProxy(r)?e[n]=r.$value:e[n]=r}return e},r=function(){return S.init(n())},o=function(e){S.update(i,e)},i=new Proxy(t,{get:(e,t)=>"__isProxy__"===t||("$value"===t?n():"$clone"===t?r:"$observables"===t?Object.values(e):"$updateWith"===t?o:void 0!==e[t]?e[t]:void 0),set:(e,t,n)=>void 0===e[t]||(C.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return i},S.arrayOfObject=function(e){return e.map(e=>S.object(e))},S.value=function(e){if(C.isObservable(e))return e.val();if(C.isProxy(e))return e.$value;if(C.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(S.value(r))}return t}return e},S.update=function(e,t){C.isProxy(t)&&(t=t.$value);for(const n in t){const r=e[n],o=t[n];if(C.isObservable(r)){if(C.isArray(o)){r.set([...o]);continue}r.set(o)}else C.isProxy(r)?S.update(r,o):e[n]=o}},S.object=S.init,S.json=S.init,S.computed=function(e,t=[]){const n=new s(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),C.isFunction(t)){if(!C.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{C.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const R={createdObservable:S(0)},H={name:"DevTools",onCreateObservable(e){R.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function q(){let e=!1;const t=z({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[z({class:"widget-label"},R.createdObservable),W({class:"widget-button"},"Full").nd.onClick(()=>{alert("Move to full-screen")})]);return t.nd.onStopMouseDown(()=>e=!0).onMouseUp(t=>e=!1),document.addEventListener("mousemove",n=>{e&&(t.style="left: "+n.clientX+"px; top: "+n.clientY+"px")}),t}return{config(){console.log("devtool init configuratzion")},init(){const e=z(z({class:"devtools-app-panel-wrapper pin-to-right"},[q,z({class:"devtools-app-panel"}),z("Gogo Panel")])).nd.closedShadow("\n .devtools-app-panel-wrapper {\n position: fixed;\n width: 0px;\n background: red;\n animate: .25s linear;\n }\n .devtools-app-panel-wrapper.pin-to-right {\n right: 0;\n top: 0;\n bottom: 0;\n }\n .devtools-app-panel-widget {\n position: fixed;\n background: rgba(0, 0, 0, 0.8);\n backdrop-filter: blur(5px);\n padding: 2px;\n width: 150px;\n height: 30px;\n border-radius: 5px;\n border: 1px solid black;\n z-index: 10000009;\n color: white;\n cursor: pointer;\n transform: translate(-50%, -50%);\n display: flex;\n justify-content: space-between;\n align-items: stretch;\n align-content: center;\n }\n .widget-button {\n width: 30px;\n padding: 2px;\n background: rgba(0, 0, 0, 0.8);\n border: 1px solid black;\n display: flex;\n justify-content: center;\n align-items: center;\n align-content: center;\n color: white;\n border-radius: 5px;\n cursor: pointer;\n font-size: .9rem;\n }\n .widget-label {\n font-weight: bold;\n font-size: 1.5rem;\n flex: 1;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n ");document.body.parentNode.appendChild(e.$element)},plugin:H}}();
1
+ var NativeDocumentDevTools=function(){"use strict";let e={};e={log(){},warn(){},error(){},disable(){}};var t=e;const n=function(){let e=0;const n=new Map;return{register(t){const r=++e;return n.set(r,new WeakRef(t)),r},unregister(e){n.delete(e)},getObservableById:e=>n.get(e)?.deref(),cleanup(){for(const[e,t]of n){const e=t.deref();e&&e.cleanup()}n.clear()},cleanObservables(e){if(n.size<e)return;let r=0;for(const[e,t]of n)t.deref()||(n.delete(e),r++);r>0&&t.log("Memory Auto Clean",`🧹 Cleaned ${r} orphaned observables`)}}}();class r extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function o(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}o.prototype.__$isObservableChecker=!0,o.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},o.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},o.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},o.prototype.set=function(e){return this.observable.set(e)},o.prototype.trigger=function(){return this.observable.trigger()},o.prototype.cleanup=function(){return this.observable.cleanup()};const i=function(){const e=new Map,n=new Map;return{list:()=>n,add(t,r){if(!t||"object"!=typeof t)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||t.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){t.$name=r,e.set(r,t),"function"==typeof t?.init&&t.init();for(const e in t)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");n.has(r)||n.set(r,new Set),n.get(r).add(t)}}},remove(t){if(!e.has(t))return;const r=e.get(t);"function"==typeof r.cleanup&&r.cleanup();for(const[e,t]of n.entries())t.has(r)&&t.delete(r),0===t.size&&n.delete(e);e.delete(t)},emit(e,...r){if(!n.has(e))return;const o=n.get(e);for(const n of o){const o=n["on"+e];if("function"==typeof o)try{o.call(n,...r)}catch(r){t.error("Plugin Manager",`Error in plugin ${n.$name} for event ${e}`,r)}}}}}();function s(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,i.emit("CreateObservable",this)}Object.defineProperty(s.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),s.prototype.__$isObservable=!0;const l={},a=function(){};s.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},s.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||l;for(let o=0,i=t.length;o<i;o++)t[o](r,n,e)};const u=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};s.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);u(t,!0)}if(e.has(t)){const n=e.get(t);u(n,!1)}},s.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},s.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},s.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=a},s.prototype.trigger=a,s.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,i.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,i.emit("ObservableAfterChange",this))},s.prototype.val=function(){return this.$currentValue},s.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)C.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=a},s.prototype.cleanup=function(){n.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},s.prototype.subscribe=function(e,n=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return t.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new r("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),i.emit("ObservableSubscribe",this,n),()=>{this.unsubscribe(e),this.assocTrigger(),i.emit("ObservableUnsubscribe",this)}},s.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!C.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},s.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},s.prototype.check=function(e){return new o(this,e)},s.prototype.get=function(e){const t=this.$currentValue[e];return C.isObservable(t)?t.val():t},s.prototype.when=function(e){return{$target:e,$observer:this}},s.prototype.toString=function(){return this.$memoryId||n.register(this),"{{#ObItem::("+this.$memoryId+")}}"},s.prototype.equals=function(e){return C.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},s.prototype.toBool=function(){return!!this.$currentValue},s.prototype.toggle=function(){this.set(!this.$currentValue)};const c={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(c.mountedSupposedSize>0)for(const e of t.addedNodes){const t=c.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(c.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=c.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{c.mounted.delete(e),c.unmounted.delete(e),c.mountedSupposedSize--,c.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,c.mounted.set(e,n),c.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,c.unmounted.set(e,n),c.unmountedSupposedSize++}}}};c.observer=new MutationObserver(c.checkMutation),c.observer.observe(document.body,{childList:!0,subtree:!0});const d=["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"];function p(e){this.$element=e,this.$observer=null,i.emit("NDElementCreated",e,this)}p.prototype.__$isNDElement=!0,p.prototype.valueOf=function(){return this.$element},p.prototype.ref=function(e,t){return e[t]=this.$element,this},p.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},p.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},p.prototype.lifecycle=function(e){return this.$observer=this.$observer||c.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},p.prototype.mounted=function(e){return this.lifecycle({mounted:e})},p.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},p.prototype.htmlElement=function(){return this.$element},p.prototype.node=p.prototype.htmlElement,p.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},p.prototype.openShadow=function(e=null){return this.shadow("open",e)},p.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},p.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const h={},f=function(e,t,n){if(!e)return;if(!h[t]){const r=new WeakMap;return h[t]=r,void r.set(e,n)}const r=h[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);C.isArray(o)?o.push(n):r.set(e,[store[t],n])},b=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},g=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},m=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},v=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=h[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(C.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of d){const t=e.toLowerCase();p.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},p.prototype["onPrevent"+e]=function(e){return b(this.$element,t,e),this},p.prototype["onStop"+e]=function(e){return g(this.$element,t,e),this},p.prototype["onPreventStop"+e]=function(e){return m(this.$element,t,e),this},p.prototype["when"+e]=function(e){return f(this.$element,t,e),this},p.prototype["capture"+e]=function(e){return v(this.$element,t,e),this}}const y=1,$=3,w=8,O=11,C={isObservable:e=>e?.__$isObservable||e instanceof s||e instanceof o,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof o,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isNumber:e=>"number"==typeof e,isBoolean:e=>"boolean"==typeof e,isFunction:e=>"function"==typeof e,isAsyncFunction:e=>"function"==typeof e&&"AsyncFunction"===e.constructor.name,isObject:e=>"object"==typeof e,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===y||e.nodeType===$||e.nodeType===O||e.nodeType===w),isFragment:e=>e?.nodeType===O,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof p,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&&(C.isObject(e)&&Object.values(e).some(e=>C.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")}},A=["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"];function x(e){return new s(e)}function S(e,t,n){e.classes.toggle(t,n)}function E(e,t,n){e.style[t]=n}function N(e,t,n){C.isBoolean(n)?e[t]=n:e[t]=n===e.value}function P(e,t,n,r){C.isBoolean(n)?r.set(e[t]):r.set(e.value)}function k(e,t){for(let n in t){const r=t[n];C.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(S.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,S.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function T(e,t){for(let n in t){const r=t[n];C.isObservable(r)?(e.style[n]=r.val(),r.subscribe(E.bind(null,e,n))):e.style[n]=r}}function D(e,t,n){const r=C.isObservable(n)?n.val():n;C.isBoolean(r)?e[t]=r:e[t]=r===e.value,C.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",P.bind(null,e,t,r,n)),n.subscribe(N.bind(null,e,t)))}function V(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}x.getById=function(e){const t=n.getObservableById(parseInt(e));if(!t)throw new r("Observable.getById : No observable found with id "+e);return t},x.cleanup=function(e){e.cleanup()},x.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:r=6e4,threshold:o=100}=t;window.addEventListener("beforeunload",()=>{n.cleanup()}),setInterval(()=>n.cleanObservables(o),r)};const j=new Map;let L=null;const M={createTextNode:()=>(L||(L=document.createTextNode("")),L.cloneNode()),createObservableNode(e,t){const n=M.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=M.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=M.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(j.has(e))return j.get(e).cloneNode();const t=document.createElement(e);return j.set(e,t),t.cloneNode()}return new B("Fragment")},processChildren(e,t){if(null!==e){if(i.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}i.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(C.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,C.isString(e)))return M.createStaticTextNode(null,e);if(C.isElement(e))return e;if(C.isObservable(e))return M.createObservableNode(null,e);if(C.isNDElement(e))return e.$element??e.$build?.()??null;if(C.$element)return C.$element;if(C.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return C.isFunction(e)?(i.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?M.createHydratableNode(null,e):M.createStaticTextNode(null,e)},processAttributes(e,t){C.isFragment(e)||t&&function(e,t){if(!C.isObject(t))throw new r("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(C.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,C.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>C.isObservable(e));o=x.computed(()=>o.map(e=>C.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&C.isObject(o)?k(e,o):"style"===r&&C.isObject(o)?T(e,o):A.includes(r)?D(e,r,o):C.isObservable(o)?V(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(i.emit("Setup",e,t,n),e)};function B(e,n=!1){const r=document.createDocumentFragment();r.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),i=document.createComment("/ Anchor End "+e);r.appendChild(o),r.appendChild(i),r.nativeInsertBefore=r.insertBefore,r.nativeAppendChild=r.appendChild;const s=e=>n||e.firstChild===o&&e.lastChild===i;return r.appendElement=function(e,t=null){const n=o.parentNode,s=t||i;n!==r?n?.insertBefore(e,s):n.nativeInsertBefore(e,s)},r.appendChild=function(e,n=null){const o=i.parentNode;o?function(e,t,n){const o=C.isElement(t)?t:M.getChild(t);e!==r?s(e)&&n===i?e.append(o,n):e.insertBefore(o,n):e.nativeInsertBefore(o,n)}(o,e,n=n??i):t.error("Anchor","Anchor : parent not found",e)},r.append=function(...e){return r.appendChild(e)},r.removeChildren=function(){const e=i.parentNode;if(e===r)return;if(s(e))return void e.replaceChildren(o,i);let t,n=o.nextSibling;const l=document.createDocumentFragment();for(;n&&n!==i;)t=n.nextSibling,l.append(n),n=t;l.replaceChildren()},r.remove=function(){if(i.parentNode===r)return;let e,t=o.nextSibling;for(;t&&t!==i;)e=t.nextSibling,r.nativeAppendChild(t),t=e},r.removeWithAnchors=function(){r.removeChildren(),o.remove(),i.remove()},r.replaceContent=function(e){const t=i.parentNode;t&&(s(t)?t.replaceChildren(o,e,i):(r.removeChildren(),t.insertBefore(e,i)))},r.insertBefore=function(e,t=null){r.appendChild(e,t)},r.endElement=function(){return i},r.startElement=function(){return o},r.restore=function(){r.appendChild(r)},r.clear=r.remove,r.detach=r.remove,r.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},r}Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new p(this)}});const _={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,..._}}});function I(e,t,n,r=null){let{props:o,children:i=null}=function(e,t=null){if(!C.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}}(n,r),s=M.createElement(e),l=t&&"function"==typeof t?t(s):s;return o&&M.processAttributes(l,o),i&&M.processChildren(i,l),M.setup(l,o,t)}function F(e,t){return I.bind(null,e.toLowerCase(),t)}const z=F("div");F("span"),F("label"),F("p"),F("strong"),F("h1"),F("h2"),F("h3"),F("h4"),F("h5"),F("h6"),F("br"),F("a"),F("pre"),F("code"),F("blockquote"),F("hr"),F("em"),F("small"),F("mark"),F("del"),F("ins"),F("sub"),F("sup"),F("abbr"),F("cite"),F("q"),F("dl"),F("dt"),F("dd"),F("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}),F("input"),F("textarea"),F("select"),F("fieldset"),F("option"),F("legend"),F("datalist"),F("output"),F("progress"),F("meter");const W=F("button");F("main"),F("section"),F("article"),F("aside"),F("nav"),F("figure"),F("figcaption"),F("header"),F("footer"),F("img"),F("details"),F("summary"),F("dialog"),F("menu"),F("ol"),F("ul"),F("li"),F("audio"),F("video"),F("source"),F("track"),F("canvas"),F("svg"),F("time"),F("data"),F("address"),F("kbd"),F("samp"),F("var"),F("wbr"),F("caption"),F("table"),F("thead"),F("tfoot"),F("tbody"),F("tr"),F("th"),F("td"),F(""),Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new p(t.$element.cloneNode(!0))})),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return x.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return C.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return C.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!C.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return x.getById(n)}):this.valueOf()};const U=["push","pop","shift","unshift","reverse","sort","splice"];x.array=function(e,{propagation:t=!1,deep:n=!1}={}){if(!Array.isArray(e))throw new r("Observable.array : target must be an array");const o=x(e);i.emit("CreateObservableArray",o),U.forEach(e=>{o[e]=function(...t){const n=o.val()[e](...t);return o.trigger({action:e,args:t,result:n}),n}}),o.clear=function(){return o.val().length=0,o.trigger({action:"clear"}),!0},o.merge=function(e){o.$value.push(...e),o.trigger({action:"merge",args:e})},o.populateAndRender=function(e,t){o.trigger({action:"populate",args:[o.val(),e,t]})},o.removeItem=function(e){const t=o.val().indexOf(e);return o.remove(t)},o.remove=function(e){const t=o.val().splice(e,1);return 0===t.length?[]:(o.trigger({action:"remove",args:[e],result:t[0]}),t)},o.swap=function(e,t){const n=o.val(),r=n.length;if(r<e||r<t)return!1;if(t<e){const n=e;e=t,t=n}const i=n[e],s=n[t];return n[e]=s,n[t]=i,o.trigger({action:"swap",args:[e,t],result:[i,s]}),!0},o.length=function(){return o.val().length},o.count=e=>{let t=0;return o.val().forEach((n,r)=>{e(n,r)&&t++}),t},o.isEmpty=function(){return 0===o.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{o[e]=(...t)=>o.val()[e](...t)}),o},x.batch=function(e){const t=x(0),n=function(){if(C.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};x.init=function(e,{propagation:t=!1,deep:n=!0}={}){const r={};for(const o in e){const i=e[o];if(Array.isArray(i)){if(n){r[o]=i.map(e=>C.isJson(e)?x.json(e,{propagation:t,deep:n}):C.isArray(e)?x.array(e,{propagation:t,deep:n}):x(e));continue}r[o]=x.array(i,{propagation:t})}else C.isObservable(i)||C.isProxy(i)?r[o]=i:r[o]=x(i)}const o=()=>function(e){const t={};for(const n in e){const r=e[n];if(C.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>C.isObservable(e)?e.val():C.isProxy(e)?e.$value:e)),t[n]=e}else C.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(r),i=()=>x.init(o(),{propagation:t,deep:n}),s=e=>{x.update(a,e)},l=e=>function(e,t){const n=e[t];return C.isObservable(n)?n.val():C.isProxy(n)?n.$value:n}(r,e),a=new Proxy(r,{get:(t,n)=>"__isProxy__"===n||("$value"===n?o():"$clone"===n?i:"$keys"===n?Object.keys(e):"$observables"===n?Object.values(t):"$updateWith"===n||"$set"===n?s:"$get"===n?l:void 0!==t[n]?t[n]:void 0),set:(e,t,n)=>void 0===e[t]||(C.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return a},x.arrayOfObject=function(e){return e.map(e=>x.object(e))},x.value=function(e){if(C.isObservable(e))return e.val();if(C.isProxy(e))return e.$value;if(C.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(x.value(r))}return t}return e},x.update=function(e,t){const n=C.isProxy(t)?t.$value:t;for(const r in n){const o=e[r],i=t[r],s=n[r];if(C.isObservable(o)){if(C.isArray(s)){if(C.isObservable(i[0])||C.isProxy(i[0])){const e=s.map(e=>C.isObservable(i[0])?x(e):x.init(i[0]));o.set(e);continue}o.set([...s]);continue}o.set(s)}else C.isProxy(o)?x.update(o,s):e[r]=s}},x.object=x.init,x.json=x.init,x.computed=function(e,t=[]){const n=new s(e()),o=()=>n.set(e());if(i.emit("CreateObservableComputed",n,t),C.isFunction(t)){if(!C.isObservable(t.$observer))throw new r("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(o),n}return t.forEach(e=>{C.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(o)}):e.subscribe(o)}),n};const R={createdObservable:x(0)},H={name:"DevTools",onCreateObservable(e){R.createdObservable.set(e=>++e),console.log("Création Capturé",e)}};function q(){let e=!1;const t=z({class:"devtools-app-panel-widget",style:"left: 50%; top: 95%"},[z({class:"widget-label"},R.createdObservable),W({class:"widget-button"},"Full").nd.onClick(()=>{alert("Move to full-screen")})]);return t.nd.onStopMouseDown(()=>e=!0).onMouseUp(t=>e=!1),document.addEventListener("mousemove",n=>{e&&(t.style="left: "+n.clientX+"px; top: "+n.clientY+"px")}),t}return{config(){console.log("devtool init configuratzion")},init(){const e=z(z({class:"devtools-app-panel-wrapper pin-to-right"},[q,z({class:"devtools-app-panel"}),z("Gogo Panel")])).nd.closedShadow("\n .devtools-app-panel-wrapper {\n position: fixed;\n width: 0px;\n background: red;\n animate: .25s linear;\n }\n .devtools-app-panel-wrapper.pin-to-right {\n right: 0;\n top: 0;\n bottom: 0;\n }\n .devtools-app-panel-widget {\n position: fixed;\n background: rgba(0, 0, 0, 0.8);\n backdrop-filter: blur(5px);\n padding: 2px;\n width: 150px;\n height: 30px;\n border-radius: 5px;\n border: 1px solid black;\n z-index: 10000009;\n color: white;\n cursor: pointer;\n transform: translate(-50%, -50%);\n display: flex;\n justify-content: space-between;\n align-items: stretch;\n align-content: center;\n }\n .widget-button {\n width: 30px;\n padding: 2px;\n background: rgba(0, 0, 0, 0.8);\n border: 1px solid black;\n display: flex;\n justify-content: center;\n align-items: center;\n align-content: center;\n color: white;\n border-radius: 5px;\n cursor: pointer;\n font-size: .9rem;\n }\n .widget-label {\n font-weight: bold;\n font-size: 1.5rem;\n flex: 1;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n ");document.body.parentNode.appendChild(e.$element)},plugin:H}}();
@@ -1 +1 @@
1
- var NativeDocument=function(t){"use strict";let n={};n={log(){},warn(){},error(){},disable(){}};var r=n;const o=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 n=0;for(const[e,r]of t)r.deref()||(t.delete(e),n++);n>0&&r.log("Memory Auto Clean",`🧹 Cleaned ${n} orphaned observables`)}}}();class s extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function i(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}i.prototype.__$isObservableChecker=!0,i.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},i.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},i.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},i.prototype.set=function(e){return this.observable.set(e)},i.prototype.trigger=function(){return this.observable.trigger()},i.prototype.cleanup=function(){return this.observable.cleanup()};const a=function(){const e=new Map,t=new Map;return{list:()=>t,add(n,r){if(!n||"object"!=typeof n)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||n.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){n.$name=r,e.set(r,n),"function"==typeof n?.init&&n.init();for(const e in n)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");t.has(r)||t.set(r,new Set),t.get(r).add(n)}}},remove(n){if(!e.has(n))return;const r=e.get(n);"function"==typeof r.cleanup&&r.cleanup();for(const[e,n]of t.entries())n.has(r)&&n.delete(r),0===n.size&&t.delete(e);e.delete(n)},emit(e,...n){if(!t.has(e))return;const o=t.get(e);for(const t of o){const o=t["on"+e];if("function"==typeof o)try{o.call(t,...n)}catch(n){r.error("Plugin Manager",`Error in plugin ${t.$name} for event ${e}`,n)}}}}}();function u(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,a.emit("CreateObservable",this)}Object.defineProperty(u.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),u.prototype.__$isObservable=!0;const l={},c=function(){};u.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},u.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||l;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)};const h=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};u.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);h(t,!0)}if(e.has(t)){const n=e.get(t);h(n,!1)}},u.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},u.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},u.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=c},u.prototype.trigger=c,u.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,a.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,a.emit("ObservableAfterChange",this))},u.prototype.val=function(){return this.$currentValue},u.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)I.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=c},u.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},u.prototype.subscribe=function(e,t=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return r.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new s("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),a.emit("ObservableSubscribe",this,t),()=>{this.unsubscribe(e),this.assocTrigger(),a.emit("ObservableUnsubscribe",this)}},u.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!I.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},u.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},u.prototype.check=function(e){return new i(this,e)},u.prototype.get=u.prototype.check,u.prototype.when=function(e){return{$target:e,$observer:this}},u.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"},u.prototype.equals=function(e){return I.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},u.prototype.toBool=function(){return!!this.$currentValue},u.prototype.toggle=function(){this.set(!this.$currentValue)};const d=(e,t,n)=>{if(I.isFunction(n))return n(e,t);if(I.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return I.isObject(e)?e[n]?.val?.()??e[n]??t:e},p=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},f={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(f.mountedSupposedSize>0)for(const e of t.addedNodes){const t=f.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(f.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=f.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{f.mounted.delete(e),f.unmounted.delete(e),f.mountedSupposedSize--,f.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,f.mounted.set(e,n),f.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,f.unmounted.set(e,n),f.unmountedSupposedSize++}}}};f.observer=new MutationObserver(f.checkMutation),f.observer.observe(document.body,{childList:!0,subtree:!0});const m=["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"];function b(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}b.prototype.__$isNDElement=!0,b.prototype.valueOf=function(){return this.$element},b.prototype.ref=function(e,t){return e[t]=this.$element,this},b.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},b.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},b.prototype.lifecycle=function(e){return this.$observer=this.$observer||f.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},b.prototype.mounted=function(e){return this.lifecycle({mounted:e})},b.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},b.prototype.htmlElement=function(){return this.$element},b.prototype.node=b.prototype.htmlElement,b.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},b.prototype.openShadow=function(e=null){return this.shadow("open",e)},b.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},b.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const g={},v=function(e,t,n){if(!e)return;if(!g[t]){const r=new WeakMap;return g[t]=r,void r.set(e,n)}const r=g[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);I.isArray(o)?o.push(n):r.set(e,[store[t],n])},y=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},w=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},C=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},$=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=g[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(I.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of m){const t=e.toLowerCase();b.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},b.prototype["onPrevent"+e]=function(e){return y(this.$element,t,e),this},b.prototype["onStop"+e]=function(e){return w(this.$element,t,e),this},b.prototype["onPreventStop"+e]=function(e){return C(this.$element,t,e),this},b.prototype["when"+e]=function(e){return v(this.$element,t,e),this},b.prototype["capture"+e]=function(e){return $(this.$element,t,e),this}}const O=1,S=3,A=8,E=11,I={isObservable:e=>e?.__$isObservable||e instanceof u||e instanceof i,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof i,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,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===O||e.nodeType===S||e.nodeType===E||e.nodeType===A),isFragment:e=>e?.nodeType===E,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof b,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 s(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(I.isObject(e)&&Object.values(e).some(e=>I.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new s("Event callback must be a function")}};var x=Object.freeze({__proto__:null,default:I});function k(e,t=!1){const n=document.createDocumentFragment();n.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);n.appendChild(o),n.appendChild(s),n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild;const i=e=>t||e.firstChild===o&&e.lastChild===s;return n.appendElement=function(e,t=null){const r=o.parentNode,i=t||s;r!==n?r?.insertBefore(e,i):r.nativeInsertBefore(e,i)},n.appendChild=function(e,t=null){const o=s.parentNode;o?function(e,t,r){const o=I.isElement(t)?t:V.getChild(t);e!==n?i(e)&&r===s?e.append(o,r):e.insertBefore(o,r):e.nativeInsertBefore(o,r)}(o,e,t=t??s):r.error("Anchor","Anchor : parent not found",e)},n.append=function(...e){return n.appendChild(e)},n.removeChildren=function(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(o,s);let t,r=o.nextSibling;const a=document.createDocumentFragment();for(;r&&r!==s;)t=r.nextSibling,a.append(r),r=t;a.replaceChildren()},n.remove=function(){if(s.parentNode===n)return;let e,t=o.nextSibling;for(;t&&t!==s;)e=t.nextSibling,n.nativeAppendChild(t),t=e},n.removeWithAnchors=function(){n.removeChildren(),o.remove(),s.remove()},n.replaceContent=function(e){const t=s.parentNode;t&&(i(t)?t.replaceChildren(o,e,s):(n.removeChildren(),t.insertBefore(e,s)))},n.insertBefore=function(e,t=null){n.appendChild(e,t)},n.endElement=function(){return s},n.startElement=function(){return o},n.restore=function(){n.appendChild(n)},n.clear=n.remove,n.detach=n.remove,n.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},n}const N=["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"];function F(e){return new u(e)}function T(e,t,n){e.classes.toggle(t,n)}function P(e,t,n){e.style[t]=n}function D(e,t,n){I.isBoolean(n)?e[t]=n:e[t]=n===e.value}function L(e,t,n,r){I.isBoolean(n)?r.set(e[t]):r.set(e.value)}function B(e,t){for(let n in t){const r=t[n];I.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(T.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,T.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function M(e,t){for(let n in t){const r=t[n];I.isObservable(r)?(e.style[n]=r.val(),r.subscribe(P.bind(null,e,n))):e.style[n]=r}}function R(e,t,n){const r=I.isObservable(n)?n.val():n;I.isBoolean(r)?e[t]=r:e[t]=r===e.value,I.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",L.bind(null,e,t,r)),n.subscribe(D.bind(null,e,t)))}function _(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}F.getById=function(e){const t=o.getObservableById(parseInt(e));if(!t)throw new s("Observable.getById : No observable found with id "+e);return t},F.cleanup=function(e){e.cleanup()},F.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{o.cleanup()}),setInterval(()=>o.cleanObservables(r),n)};const j=new Map;let q=null;const V={createTextNode:()=>(q||(q=document.createTextNode("")),q.cloneNode()),createObservableNode(e,t){const n=V.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=V.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=V.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(j.has(e))return j.get(e).cloneNode();const t=document.createElement(e);return j.set(e,t),t.cloneNode()}return new k("Fragment")},processChildren(e,t){if(null!==e){if(a.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}a.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(I.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,I.isString(e)))return V.createStaticTextNode(null,e);if(I.isElement(e))return e;if(I.isObservable(e))return V.createObservableNode(null,e);if(I.isNDElement(e))return e.$element??e.$build?.()??null;if(I.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return I.isFunction(e)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?V.createHydratableNode(null,e):V.createStaticTextNode(null,e)},processAttributes(e,t){I.isFragment(e)||t&&function(e,t){if(I.validateAttributes(t),!I.isObject(t))throw new s("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(I.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,I.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>I.isObservable(e));o=F.computed(()=>o.map(e=>I.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&I.isObject(o)?B(e,o):"style"===r&&I.isObject(o)?M(e,o):N.includes(r)?R(e,r,o):I.isObservable(o)?_(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(a.emit("Setup",e,t,n),e)};Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new b(this)}});const H={getClasses(){return this.$element.className?.split(" ").filter(Boolean)},add(e){const t=this.getClasses();t.indexOf(e)>=0||(t.push(e),this.$element.className=t.join(" "))},remove(e){const t=this.getClasses(),n=t.indexOf(e);n<0||(t.splice(n,1),this.$element.className=t.join(" "))},toggle(e,t=void 0){const n=this.getClasses(),r=n.indexOf(e);if(r>=0){if(!0===t)return;n.splice(r,1)}else{if(!1===t)return;n.push(e)}this.$element.className=n.join(" ")},contains(e){return this.getClasses().indexOf(e)>=0}};Object.defineProperty(HTMLElement.prototype,"classes",{configurable:!0,get(){return{$element:this,...H}}});let W=e=>e;t.ArgTypes={},t.ArgTypes={string:()=>!0,number:()=>!0,boolean:()=>!0,observable:()=>!0,element:()=>!0,function:()=>!0,object:()=>!0,objectNotNull:()=>!0,children:()=>!0,attributes:()=>!0,optional:()=>!0,oneOf:()=>!0};const z=function(e,t=null){if(!I.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},U=function(e){return I.isObservable(e)?V.createObservableNode(null,e):V.createStaticTextNode(null,e)};function K(e,t,n,r=null){let{props:o,children:s=null}=z(n,r),i=V.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&V.processAttributes(a,o),s&&V.processChildren(s,a),V.setup(a,o,t)}function J(e,t){return K.bind(null,e.toLowerCase(),t)}const Q=new WeakMap;function Z(e){let t=null,n=!1;const r=(e,t)=>{const n=Q.get(e);if(3===e.nodeType)return n&&n.value?n.value(t):e.cloneNode(!0);const o=e.cloneNode(e.fullCloneNode);if(n&&(((e,t,n)=>{let r=null;if(t.attributes){r=r||{};for(const e in t.attributes)r[e]=t.attributes[e](...n)}if(t.classes){r=r||{},r.class={};for(const e in t.classes)r.class[e]=t.classes[e](...n)}if(t.styles){r=r||{},r.style={};for(const e in t.styles)r.style[e]=t.styles[e](...n)}r&&V.processAttributes(e,r)})(o,n,t),function(e,t,n){if(!t.attach)return null;t.attach(e,...n)}(o,n,t)),e.fullCloneNode)return o;const s=e.childNodes;for(let e=0,n=s.length;e<n;e++){const n=s[e],i=r(n,t);o.appendChild(i)}return o};this.clone=o=>{if(!t&&(t=e(this),!n)){const e=t.cloneNode(!0);return e.fullCloneNode=!0,e}return n?r(t,o):t.cloneNode(!0)};const o=(e,t)=>({$hydrate:(r,o)=>{n=!0,function(e,t,n,r){Q.has(n)||Q.set(n,{});const o=Q.get(n);"value"!==t?"attach"!==t?(o[t]=o[t]||{},o[t][r]=e):o.attach=e:o.value=e}(e,t,r,o)}});this.style=e=>o(e,"styles"),this.class=e=>o(e,"classes"),this.property=e=>this.value(e),this.value=e=>o("function"!=typeof e?function(t){const n=t[0];return U(n[e])}:function(t){return U(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}function G(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=new k("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new b(t.$element.cloneNode(!0))})),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return F.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return I.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return I.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!I.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return F.getById(n)}):this.valueOf()};const X=["push","pop","shift","unshift","reverse","sort","splice"];F.array=function(e){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");const t=F(e);a.emit("CreateObservableArray",t),X.forEach(e=>{t[e]=function(...n){const r=t.val()[e](...n);return t.trigger({action:e,args:n,result:r}),r}}),t.clear=function(){return t.val().length=0,t.trigger({action:"clear"}),!0},t.merge=function(e){t.$value.push(...e),t.trigger({action:"merge",args:e})},t.populateAndRender=function(e,n){t.trigger({action:"populate",args:[t.val(),e,n]})},t.removeItem=function(e){const n=t.val().indexOf(e);return t.remove(n)},t.remove=function(e){const n=t.val().splice(e,1);return 0===n.length?[]:(t.trigger({action:"remove",args:[e],result:n[0]}),n)},t.swap=function(e,n){const r=t.val(),o=r.length;if(o<e||o<n)return!1;if(n<e){const t=e;e=n,n=t}const s=r[e],i=r[n];return r[e]=i,r[n]=s,t.trigger({action:"swap",args:[e,n],result:[s,i]}),!0},t.length=function(){return t.val().length},t.count=e=>{let n=0;return t.val().forEach((t,r)=>{e(t,r)&&n++}),n},t.isEmpty=function(){return 0===t.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{t[e]=(...n)=>t.val()[e](...n)}),t},F.batch=function(e){const t=F(0),n=function(){if(I.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n},F.init=function(e){const t={};for(const n in e){const r=e[n];Array.isArray(r)?t[n]=F.array(r):t[n]=F(r)}const n=function(){const e={};for(const n in t){const r=t[n];I.isObservable(r)?e[n]=r.val():I.isProxy(r)?e[n]=r.$value:e[n]=r}return e},r=function(){return F.init(n())},o=function(e){F.update(s,e)},s=new Proxy(t,{get:(e,t)=>"__isProxy__"===t||("$value"===t?n():"$clone"===t?r:"$observables"===t?Object.values(e):"$updateWith"===t?o:void 0!==e[t]?e[t]:void 0),set:(e,t,n)=>void 0===e[t]||(I.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return s},F.arrayOfObject=function(e){return e.map(e=>F.object(e))},F.value=function(e){if(I.isObservable(e))return e.val();if(I.isProxy(e))return e.$value;if(I.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(F.value(r))}return t}return e},F.update=function(e,t){I.isProxy(t)&&(t=t.$value);for(const n in t){const r=e[n],o=t[n];if(I.isObservable(r)){if(I.isArray(o)){r.set([...o]);continue}r.set(o)}else I.isProxy(r)?F.update(r,o):e[n]=o}},F.object=F.init,F.json=F.init,F.computed=function(e,t=[]){const n=new u(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),I.isFunction(t)){if(!I.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{I.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const Y=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=F(n.val()),s=n.subscribe(e=>o.set(e)),i=o.subscribe(e=>n.set(e));return o.destroy=()=>{s(),i(),o.cleanup()},r.add(o),o},follow(e){return this.use(e)},create(t,n){const r=F(n);return e.set(t,{observer:r,subscribers:new Set}),r},get(t){const n=e.get(t);return n?n.observer:null},getWithSubscribers:t=>e.get(t),delete(t){const n=e.get(t);n&&(n.observer.cleanup(),n.subscribers.forEach(e=>e.destroy()),n.observer.clear())}}}();const ee=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!I.isObservable(e))return r.warn("ShowIf","ShowIf : condition must be an Observable / "+n,e);const s=new k("Show if : "+(n||""));let i=null;const a=()=>(i&&o||(i=V.getChild(t),I.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},te=function(e,t,n=!0){if(!I.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=new k("Match"),o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=V.getChild(r),I.isFragment(r)&&(r=Array.from(r.children)),n&&o.set(e,r),r):null},a=e.val(),u=i(a);return u&&r.appendChild(u),e.subscribe(e=>{const t=i(e);r.remove(),t&&r.appendChild(t)}),r},ne=function(e,t,n){if(!I.isObservable(e))throw new s("Toggle : condition must be an Observable");return te(e,{true:t,false:n})},re=J("div"),oe=J("span"),se=J("label"),ie=J("p"),ae=ie,ue=J("strong"),le=J("h1"),ce=J("h2"),he=J("h3"),de=J("h4"),pe=J("h5"),fe=J("h6"),me=J("br"),be=J("a"),ge=J("pre"),ve=J("code"),ye=J("blockquote"),we=J("hr"),Ce=J("em"),$e=J("small"),Oe=J("mark"),Se=J("del"),Ae=J("ins"),Ee=J("sub"),Ie=J("sup"),xe=J("abbr"),ke=J("cite"),Ne=J("q"),Fe=J("dl"),Te=J("dt"),Pe=J("dd"),De=J("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}),Le=J("input"),Be=J("textarea"),Me=Be,Re=J("select"),_e=J("fieldset"),je=J("option"),qe=J("legend"),Ve=J("datalist"),He=J("output"),We=J("progress"),ze=J("meter"),Ue=J("button"),Ke=J("main"),Je=J("section"),Qe=J("article"),Ze=J("aside"),Ge=J("nav"),Xe=J("figure"),Ye=J("figcaption"),et=J("header"),tt=J("footer"),nt=J("img"),rt=function(e,t){return nt({src:e,...t})},ot=J("details"),st=J("summary"),it=J("dialog"),at=J("menu"),ut=J("ol"),lt=J("ul"),ct=J("li"),ht=ct,dt=ut,pt=lt,ft=J("audio"),mt=J("video"),bt=J("source"),gt=J("track"),vt=J("canvas"),yt=J("svg"),wt=J("time"),Ct=J("data"),$t=J("address"),Ot=J("kbd"),St=J("samp"),At=J("var"),Et=J("wbr"),It=J("caption"),xt=J("table"),kt=J("thead"),Nt=J("tfoot"),Ft=J("tbody"),Tt=J("tr"),Pt=Tt,Dt=J("th"),Lt=Dt,Bt=Dt,Mt=J("td"),Rt=Mt,_t=J("");var jt=Object.freeze({__proto__:null,Abbr:xe,Address:$t,Anchor:k,Article:Qe,Aside:Ze,AsyncImg:function(e,t,n,r){const o=I.isObservable(e)?e.val():e,i=rt(t||o,n),a=new Image;return a.onload=()=>{I.isFunction(r)&&r(null,i),i.src=I.isObservable(e)?e.val():e},a.onerror=()=>{I.isFunction(r)&&r(new s("Image not found"))},I.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=o,i},Audio:ft,BaseImage:nt,Blockquote:ye,Br:me,Button:Ue,Canvas:vt,Caption:It,Checkbox:e=>Le({type:"checkbox",...e}),Cite:ke,Code:ve,ColorInput:e=>Le({type:"color",...e}),Data:Ct,Datalist:Ve,DateInput:e=>Le({type:"date",...e}),DateTimeInput:e=>Le({type:"datetime-local",...e}),Dd:Pe,Del:Se,Details:ot,Dialog:it,Div:re,Dl:Fe,Dt:Te,Em:Ce,EmailInput:e=>Le({type:"email",...e}),FieldSet:_e,FigCaption:Ye,Figure:Xe,FileInput:e=>Le({type:"file",...e}),Footer:tt,ForEach:function(e,t,n,{shouldKeepItemsInCache:o=!1}={}){const i=new k("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,h=e=>{if(!o)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&e.removeChild(r),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},p=(e,o)=>{const i=d(e,o,n);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(o),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?F(o):null;let r=V.getChild(t(e,n));if(!r||I.isFragment(r))throw new s("ForEachArray child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(r),indexObserver:n})}catch(e){throw r.error("ForEach",`Error creating element for key ${i}`,e),e}return i},f=()=>{const t=a.parentNode;if(!t)return;const n=I.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=p(n[e],e);c.add(t)}else for(const e in n){const t=p(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),h(),void l?.clear();h(t),l&&0!==l.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(l);for(const n in t){const r=t[n],o=u.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),l?.clear(),l=new Set([...c])};return f(),I.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n,r={}){const o=new k("ForEach Array"),i=o.endElement(),a=o.startElement();let u=new Map,l=0;const c=t.length>=2,h=new WeakMap,p=()=>{o.removeChildren(),g(),l=0},f=(e,t)=>h.has(e)?h.get(e):d(e,t,n),m=e=>y(f(e)),b=(e,t=!0)=>{if(e){if(t){const t=e.child;t?.remove(),u.delete(e.keyId)}e.indexObserver?.deref()?.cleanup()}},g=()=>{if(!r.shouldKeepItemsInCache)if(c){for(const[e,t]of u.entries())b(t,!1);u.clear()}else u.clear()},v=(e,n)=>{const r=f(e,n);if(u.has(r)){const e=u.get(r);e.indexObserver?.deref()?.set(n);const t=e.child;if(t)return t;u.delete(r)}const o=c?F(n):null;let i=V.getChild(t(e,o));if(!i||I.isFragment(i))throw new s("ForEachArray child can't be null or undefined!");return u.set(r,{keyId:r,child:i,indexObserver:o?new WeakRef(o):null}),h.set(e,r),i},y=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(b(t,!1),null)},w=function(e,t){const n=u.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},C={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(v(e[t],l)),l++;return n},add(e,t=2){const n=C.toFragment(e);setTimeout(()=>{o.appendElement(n)},t)},replace(e){p(),C.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=m(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{b(u.get(e),t)})(f(e,t),!0)},clear:p,merge(e){C.add(e)},push(e){let t=0;r.pushDelay&&(t=r.pushDelay(e)??0),C.add(e,t)},populate([e,t,n]){const r=document.createDocumentFragment();for(let o=0;o<t;o++){const t=n(o);e.push(t),r.append(v(t,o)),l++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore(C.toFragment(e),a.nextSibling)},splice(e,t){const[n,r,...s]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=f(t[0],n);if(1===t.length)w(e,u);else if(t.length>1){const r=y(e);a=r?.previousSibling;for(let e=0;e<t.length;e++){const r=f(t[e],n+e);w(r,u)}}}else a=i;u.replaceChildren(),s&&s.length&&a&&o.insertBefore(C.toFragment(s),a.nextSibling)},reverse(e,t){C.reOrder(t)},sort(e,t){C.reOrder(t)},remove(e,t){C.removeOne(t)},pop(e,t){C.removeOne(t)},shift(e,t){C.removeOne(t)},swap(e,t){const n=i.parentNode;let r=m(t[0]),o=m(t[1]);if(!r||!o)return;const s=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,s),r=null,o=null}},$=(e,t,n)=>{if("clear"!==n.action&&e.length){if(n?.action)C[n.action]&&C[n.action](n.args,n.result);else{if(0===l)return void C.add(e);C.replace(e)}((e,t=0)=>{if(!c)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=u.get(f(e[r],r));t&&(t.indexObserver?.deref()?.set(n),n++)}})(e,0)}else{if(0===l)return;p()}};return e.val().length&&$(e.val(),0,{action:null}),I.isObservable(e)&&e.subscribe($),o},Form:De,Fragment:_t,H1:le,H2:ce,H3:he,H4:de,H5:pe,H6:fe,Header:et,HiddenInput:e=>Le({type:"hidden",...e}),HideIf:function(e,t,n){const r=F(!e.val());return e.subscribe(e=>r.set(!e)),ee(r,t,n)},HideIfNot:function(e,t,n){return ee(e,t,n)},Hr:we,Img:rt,Input:Le,Ins:Ae,Kbd:Ot,Label:se,LazyImg:function(e,t){return rt(e,{...t,loading:"lazy"})},Legend:qe,Li:ht,Link:be,ListItem:ct,Main:Ke,Mark:Oe,Match:te,Menu:at,Meter:ze,MonthInput:e=>Le({type:"month",...e}),NativeDocumentFragment:k,Nav:Ge,NumberInput:e=>Le({type:"number",...e}),Ol:dt,Option:je,OrderedList:ut,Output:He,P:ie,Paragraph:ae,PasswordInput:e=>Le({type:"password",...e}),Pre:ge,Progress:We,Quote:Ne,Radio:e=>Le({type:"radio",...e}),RangeInput:e=>Le({type:"range",...e}),ReadonlyInput:e=>Le({readonly:!0,...e}),Samp:St,SearchInput:e=>Le({type:"search",...e}),Section:Je,Select:Re,ShowIf:ee,SimpleButton:(e,t)=>Ue(e,{type:"button",...t}),Small:$e,Source:bt,Span:oe,Strong:ue,Sub:Ee,SubmitButton:(e,t)=>Ue(e,{type:"submit",...t}),Summary:st,Sup:Ie,Svg:yt,Switch:ne,TBody:Ft,TBodyCell:Rt,TFoot:Nt,TFootCell:Bt,THead:kt,THeadCell:Lt,TRow:Pt,Table:xt,Td:Mt,TelInput:e=>Le({type:"tel",...e}),TextArea:Be,TextInput:Me,Th:Dt,Time:wt,TimeInput:e=>Le({type:"time",...e}),Tr:Tt,Track:gt,Ul:pt,UnorderedList:lt,UrlInput:e=>Le({type:"url",...e}),Var:At,Video:mt,Wbr:Et,WeekInput:e=>Le({type:"week",...e}),When:function(e){if(!I.isObservable(e))throw new s("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,ne(e,t,n))}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=k("Portal "+n);return r.appendChild(V.getChild(e)),(t||document.body).appendChild(r),r}});const qt={};function Vt(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||{},u=n.layout||null,l={},c=[],h=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=qt[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?(l[n.name]=n.pattern,c.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(e){e="/"+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 Ht extends Error{constructor(e,t){super(e),this.context=t}}const Wt=(e,t)=>{const n=[];return e.forEach(e=>{n.push(p(e.suffix,"/"))}),n.push(p(t,"/")),n.join("/")},zt=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},Ut=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Kt=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Jt(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function Qt(){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){r.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:n,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:n},t.name()||n,n),this.handleRouteChange(t,o,{},n)}catch(e){r.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){r.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:n,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,n,o,s)}}function Zt(){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)}}const Gt="default";function Xt(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Jt.apply(this,[]);else if("history"===e.mode)Qt.apply(this,[]);else{if("memory"!==e.mode)throw new Ht("Invalid router mode "+e.mode);Zt.apply(this,[])}const a=function(e,t){for(const n of s)try{n(e),t&&t(e)}catch(e){r.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,r,s){const i=new Vt(Wt(o,e),r,{...s,middlewares:zt(o,s?.middlewares||[]),name:s?.name?Ut(o,s.name):null,layout:s?.layout||Kt(o)});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!I.isFunction(n))throw new Ht("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},r={}){const o=n[e];if(!o)throw new Ht(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(I.isJson(e)){const t=n[e.name];if(!t)throw new Ht(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[r,o]=e.split("?"),s="/"+p(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new Ht(`Route not found for url: ${r}`);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(!I.isFunction(e))throw new Ht("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const u={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||u,l)};return o[s](u,l)}}function Yt(e,t){const{to:n,href:r,...o}=e,s=n||r;if(I.isString(s)){const e=Xt.get();return be({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||Gt,a=Xt.get(i);if(!a)throw new Ht('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return be({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Xt.routers={},Xt.create=function(t,n){if(!I.isFunction(n))throw r.error("Router","Callback must be a function",e),new Ht("Callback must be a function");const o=new Xt(t);return Xt.routers[t.name||Gt]=o,n(o),o.init(t.entry),o.mount=function(e){if(I.isString(e)){const t=document.querySelector(e);if(!t)throw new Ht(`Container not found for selector: ${e}`);e=t}else if(!I.isElement(e))throw new Ht("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e,n){t.innerHTML="";const r=n.layout();r?t.appendChild(r(e)):t.appendChild(e)},o=function(e){if(!e.route)return;const{route:t,params:o,query:s,path:i}=e;if(n.has(i)){const e=n.get(i);return void r(e,t)}const a=t.component()({params:o,query:s});n.set(i,a),r(a,t)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},Xt.get=function(e){const t=Xt.routers[e||Gt];if(!t)throw new Ht(`Router not found for name: ${e}`);return t},Xt.push=function(e,t=null){return Xt.get(t).push(e)},Xt.replace=function(e,t=null){return Xt.get(t).replace(e)},Xt.forward=function(e=null){return Xt.get(e).forward()},Xt.back=function(e=null){return Xt.get(e).back()},Yt.blank=function(e,t){return be({...e,target:"_blank"},t)};var en=Object.freeze({__proto__:null,Link:Yt,RouteParamPatterns:qt,Router:Xt});return t.ElementCreator=V,t.HtmlElementWrapper=J,t.NDElement=b,t.Observable=F,t.PluginsManager=a,t.SingletonView=G,t.Store=Y,t.TemplateCloner=Z,t.Validator=x,t.classPropertyAccumulator=function(e=[]){let t=I.isString(e)?e.split(" ").filter(Boolean):e;const n=I.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=U,t.cssPropertyAccumulator=function(e={}){let t=I.isString(e)?e.split(";").filter(Boolean):e;const n=I.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=jt,t.normalizeComponentArgs=z,t.router=en,t.useCache=function(e){let t=null;const n=function(n){return t||(t=new Z(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},t.useSingleton=function(e){let t=null;return function(...n){return t||(t=new G(e)),t.render(n)}},t.withValidation=W,t}({});
1
+ var NativeDocument=function(t){"use strict";let n={};n={log(){},warn(){},error(){},disable(){}};var r=n;const o=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 n=0;for(const[e,r]of t)r.deref()||(t.delete(e),n++);n>0&&r.log("Memory Auto Clean",`🧹 Cleaned ${n} orphaned observables`)}}}();class s extends Error{constructor(e,t={}){super(e),this.name="NativeDocumentError",this.context=t,this.timestamp=(new Date).toISOString()}}function i(e,t){this.observable=e,this.checker=t,this.unSubscriptions=[]}i.prototype.__$isObservableChecker=!0,i.prototype.subscribe=function(e){const t=this.observable.subscribe(t=>{e&&e(this.checker(t))});return this.unSubscriptions.push(t),t},i.prototype.check=function(e){return this.observable.check(()=>e(this.val()))},i.prototype.val=function(){return this.checker&&this.checker(this.observable.val())},i.prototype.set=function(e){return this.observable.set(e)},i.prototype.trigger=function(){return this.observable.trigger()},i.prototype.cleanup=function(){return this.observable.cleanup()};const a=function(){const e=new Map,t=new Map;return{list:()=>t,add(n,r){if(!n||"object"!=typeof n)throw new Error(`Plugin ${r} must be an object`);if(!(r=r||n.name)||"string"!=typeof r)throw new Error("Please, provide a valid plugin name");if(!e.has(r)){n.$name=r,e.set(r,n),"function"==typeof n?.init&&n.init();for(const e in n)if(/^on[A-Z]/.test(e)){const r=e.replace(/^on/,"");t.has(r)||t.set(r,new Set),t.get(r).add(n)}}},remove(n){if(!e.has(n))return;const r=e.get(n);"function"==typeof r.cleanup&&r.cleanup();for(const[e,n]of t.entries())n.has(r)&&n.delete(r),0===n.size&&t.delete(e);e.delete(n)},emit(e,...n){if(!t.has(e))return;const o=t.get(e);for(const t of o){const o=t["on"+e];if("function"==typeof o)try{o.call(t,...n)}catch(n){r.error("Plugin Manager",`Error in plugin ${t.$name} for event ${e}`,n)}}}}}();function u(e){this.$previousValue=null,this.$currentValue=e,this.$isCleanedUp=!1,this.$listeners=null,this.$watchers=null,this.$memoryId=null,a.emit("CreateObservable",this)}Object.defineProperty(u.prototype,"$value",{get(){return this.$currentValue},set(e){this.set(e)},configurable:!0}),u.prototype.__$isObservable=!0;const l={},c=function(){};u.prototype.triggerFirstListener=function(e){this.$listeners[0](this.$currentValue,this.$previousValue,e||{})},u.prototype.triggerListeners=function(e){const t=this.$listeners,n=this.$previousValue,r=this.$currentValue;e=e||l;for(let o=0,s=t.length;o<s;o++)t[o](r,n,e)};const h=function(e,t){"function"!=typeof e?e.set?e.set(t):e.forEach(e=>{e.set?e.set(t):e(t)}):e(t)};u.prototype.triggerWatchers=function(){if(!this.$watchers)return;const e=this.$watchers,t=this.$previousValue,n=this.$currentValue;if(e.has(n)){const t=e.get(n);h(t,!0)}if(e.has(t)){const n=e.get(t);h(n,!1)}},u.prototype.triggerAll=function(e){this.triggerListeners(e),this.triggerWatchers()},u.prototype.triggerWatchersAndFirstListener=function(e){this.triggerListeners(e),this.triggerWatchers()},u.prototype.assocTrigger=function(){this.$watchers?.size&&this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerWatchersAndFirstListener:this.triggerAll:this.$listeners?.length?this.trigger=1===this.$listeners.length?this.triggerFirstListener:this.triggerListeners:this.$watchers?.size?this.trigger=this.triggerWatchers:this.trigger=c},u.prototype.trigger=c,u.prototype.set=function(e){const t="function"==typeof e?e(this.$currentValue):e;this.$currentValue!==t&&(this.$previousValue=this.$currentValue,this.$currentValue=t,a.emit("ObservableBeforeChange",this),this.trigger(),this.$previousValue=null,a.emit("ObservableAfterChange",this))},u.prototype.val=function(){return this.$currentValue},u.prototype.disconnectAll=function(){if(this.$listeners?.splice(0),this.$previousValue=null,this.$currentValue=null,this.$watchers)for(const[e,t]of this.$watchers)x.isArray(t)&&t.splice(0);this.$watchers?.clear(),this.$listeners=null,this.$watchers=null,this.trigger=c},u.prototype.cleanup=function(){o.unregister(this.$memoryId),this.disconnectAll(),this.$isCleanedUp=!0,delete this.$value},u.prototype.subscribe=function(e,t=null){if(this.$listeners=this.$listeners??[],this.$isCleanedUp)return r.warn("Observable subscription","⚠️ Attempted to subscribe to a cleaned up observable."),()=>{};if("function"!=typeof e)throw new s("Callback must be a function");return this.$listeners.push(e),this.assocTrigger(),a.emit("ObservableSubscribe",this,t),()=>{this.unsubscribe(e),this.assocTrigger(),a.emit("ObservableUnsubscribe",this)}},u.prototype.on=function(e,t){this.$watchers=this.$watchers??new Map;let n=this.$watchers.get(e);if(n){if(!x.isArray(n))return n=[n],void this.$watchers.set(e,n);n.push(t)}else this.$watchers.set(e,t);return this.assocTrigger(),()=>{const r=n.indexOf(t);n?.splice(r,1),1===n.size?this.$watchers.set(e,n[0]):0===n.size&&(this.$watchers?.delete(e),n=null),this.assocTrigger()}},u.prototype.unsubscribe=function(e){const t=this.$listeners.indexOf(e);t>-1&&this.$listeners.splice(t,1),this.assocTrigger()},u.prototype.check=function(e){return new i(this,e)},u.prototype.get=function(e){const t=this.$currentValue[e];return x.isObservable(t)?t.val():t},u.prototype.when=function(e){return{$target:e,$observer:this}},u.prototype.toString=function(){return this.$memoryId||o.register(this),"{{#ObItem::("+this.$memoryId+")}}"},u.prototype.equals=function(e){return x.isObservable(e)?this.$currentValue===e.$currentValue:this.$currentValue===e},u.prototype.toBool=function(){return!!this.$currentValue},u.prototype.toggle=function(){this.set(!this.$currentValue)};const d=(e,t,n)=>{if(x.isFunction(n))return n(e,t);if(x.isObservable(e)){const r=e.val();return r&&n?r[n]:t}return x.isObject(e)?e[n]?.val?.()??e[n]??t:e},p=function(e,t){return e.replace(new RegExp(`^[${t}]+|[${t}]+$`,"g"),"")},f={mounted:new WeakMap,mountedSupposedSize:0,unmounted:new WeakMap,unmountedSupposedSize:0,observer:null,checkMutation:function(e){for(const t of e){if(f.mountedSupposedSize>0)for(const e of t.addedNodes){const t=f.mounted.get(e);t&&(t.inDom=!0,t.mounted&&t.mounted(e))}if(f.unmountedSupposedSize>0)for(const e of t.removedNodes){const t=f.unmounted.get(e);t&&(t.inDom=!1,t.unmounted&&!0===t.unmounted(e)&&(t.disconnect(),e.nd?.remove()))}}},watch:function(e,t=!1){let n={inDom:t,mounted:null,unmounted:null,disconnect:()=>{f.mounted.delete(e),f.unmounted.delete(e),f.mountedSupposedSize--,f.unmountedSupposedSize--,n=null}};return{disconnect:n.disconnect,mounted:t=>{n.mounted=t,f.mounted.set(e,n),f.mountedSupposedSize++},unmounted:t=>{n.unmounted=t,f.unmounted.set(e,n),f.unmountedSupposedSize++}}}};f.observer=new MutationObserver(f.checkMutation),f.observer.observe(document.body,{childList:!0,subtree:!0});const m=["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"];function b(e){this.$element=e,this.$observer=null,a.emit("NDElementCreated",e,this)}b.prototype.__$isNDElement=!0,b.prototype.valueOf=function(){return this.$element},b.prototype.ref=function(e,t){return e[t]=this.$element,this},b.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},b.prototype.remove=function(){let e=this.$element;return e.nd.unmountChildren(),e.$ndProx=null,delete e.nd?.on?.prevent,delete e.nd?.on,delete e.nd,e=null,this},b.prototype.lifecycle=function(e){return this.$observer=this.$observer||f.watch(this.$element),e.mounted&&this.$observer.mounted(e.mounted),e.unmounted&&this.$observer.unmounted(e.unmounted),this},b.prototype.mounted=function(e){return this.lifecycle({mounted:e})},b.prototype.unmounted=function(e){return this.lifecycle({unmounted:e})},b.prototype.htmlElement=function(){return this.$element},b.prototype.node=b.prototype.htmlElement,b.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},b.prototype.openShadow=function(e=null){return this.shadow("open",e)},b.prototype.closedShadow=function(e=null){return this.shadow("closed",e)},b.prototype.attach=function(e){return e.$hydrate(this.$element),this.$element};const g={},v=function(e,t,n){if(!e)return;if(!g[t]){const r=new WeakMap;return g[t]=r,void r.set(e,n)}const r=g[t];if(!r.has(e))return void r.set(e,n);const o=r.get(e);x.isArray(o)?o.push(n):r.set(e,[store[t],n])},y=function(e,t,n){return e.addEventListener(t,t=>{t.preventDefault(),n&&n.call(e,t)}),this},w=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),n&&n.call(e,t)}),this},$=function(e,t,n){return e.addEventListener(t,t=>{t.stopPropagation(),t.preventDefault(),n&&n.call(e,t)}),this},C=function(e,t,n){return n?(e.addEventListener(t,n),this):(function(e,t){e.addEventListener(t,n=>{const r=g[t];if(!r)return;let o=n.target;for(;o&&o!==e;){const e=r.get(o);if(e){if(x.isFunction(e))e.call(o,n);else for(let t=0;t<e.length;t++)e[t].call(o,n);return}o=o.parentElement}})}(e,t),this)};for(const e of m){const t=e.toLowerCase();b.prototype["on"+e]=function(e){return this.$element.addEventListener(t,e),this},b.prototype["onPrevent"+e]=function(e){return y(this.$element,t,e),this},b.prototype["onStop"+e]=function(e){return w(this.$element,t,e),this},b.prototype["onPreventStop"+e]=function(e){return $(this.$element,t,e),this},b.prototype["when"+e]=function(e){return v(this.$element,t,e),this},b.prototype["capture"+e]=function(e){return C(this.$element,t,e),this}}const O=1,S=3,A=8,E=11,x={isObservable:e=>e?.__$isObservable||e instanceof u||e instanceof i,isProxy:e=>e?.__isProxy__,isAnchor:e=>e?.__Anchor__,isObservableChecker:e=>e?.__$isObservableChecker||e instanceof i,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,isJson:e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"Object"===e.constructor.name,isElement:e=>e&&(e.nodeType===O||e.nodeType===S||e.nodeType===E||e.nodeType===A),isFragment:e=>e?.nodeType===E,isStringOrObservable(e){return this.isString(e)||this.isObservable(e)},isValidChild(e){return null===e||this.isElement(e)||this.isObservable(e)||this.isNDElement(e)||["string","number","boolean"].includes(typeof e)},isNDElement:e=>e?.__$isNDElement||e instanceof b,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 s(`Invalid children detected: ${t.map(e=>typeof e).join(", ")}`);return e},containsObservables:e=>!!e&&(x.isObject(e)&&Object.values(e).some(e=>x.isObservable(e))),containsObservableReference:e=>!(!e||"string"!=typeof e)&&/\{\{#ObItem::\([0-9]+\)\}\}/.test(e),validateAttributes(e){},validateEventCallback(e){if("function"!=typeof e)throw new s("Event callback must be a function")}};function I(e,t=!1){const n=document.createDocumentFragment();n.__Anchor__=!0;const o=document.createComment("Anchor Start : "+e),s=document.createComment("/ Anchor End "+e);n.appendChild(o),n.appendChild(s),n.nativeInsertBefore=n.insertBefore,n.nativeAppendChild=n.appendChild;const i=e=>t||e.firstChild===o&&e.lastChild===s;return n.appendElement=function(e,t=null){const r=o.parentNode,i=t||s;r!==n?r?.insertBefore(e,i):r.nativeInsertBefore(e,i)},n.appendChild=function(e,t=null){const o=s.parentNode;o?function(e,t,r){const o=x.isElement(t)?t:_.getChild(t);e!==n?i(e)&&r===s?e.append(o,r):e.insertBefore(o,r):e.nativeInsertBefore(o,r)}(o,e,t=t??s):r.error("Anchor","Anchor : parent not found",e)},n.append=function(...e){return n.appendChild(e)},n.removeChildren=function(){const e=s.parentNode;if(e===n)return;if(i(e))return void e.replaceChildren(o,s);let t,r=o.nextSibling;const a=document.createDocumentFragment();for(;r&&r!==s;)t=r.nextSibling,a.append(r),r=t;a.replaceChildren()},n.remove=function(){if(s.parentNode===n)return;let e,t=o.nextSibling;for(;t&&t!==s;)e=t.nextSibling,n.nativeAppendChild(t),t=e},n.removeWithAnchors=function(){n.removeChildren(),o.remove(),s.remove()},n.replaceContent=function(e){const t=s.parentNode;t&&(i(t)?t.replaceChildren(o,e,s):(n.removeChildren(),t.insertBefore(e,s)))},n.insertBefore=function(e,t=null){n.appendChild(e,t)},n.endElement=function(){return s},n.startElement=function(){return o},n.restore=function(){n.appendChild(n)},n.clear=n.remove,n.detach=n.remove,n.getByIndex=function(e){let t=o;for(let n=0;n<=e;n++){if(!t.nextSibling)return null;t=t.nextSibling}return t!==o?t:null},n}const k=["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"];function N(e){return new u(e)}function F(e,t,n){e.classes.toggle(t,n)}function T(e,t,n){e.style[t]=n}function P(e,t,n){x.isBoolean(n)?e[t]=n:e[t]=n===e.value}function D(e,t,n,r){x.isBoolean(n)?r.set(e[t]):r.set(e.value)}function L(e,t){for(let n in t){const r=t[n];x.isObservable(r)?(e.classes.toggle(n,r.val()),r.subscribe(F.bind(null,e,n))):r.$observer?(e.classes.toggle(n,r.$observer.val()===r.$target),r.$observer.on(r.$target,F.bind(null,e,n))):r.$hydrate?r.$hydrate(e,n):e.classes.toggle(n,r)}t=null}function B(e,t){for(let n in t){const r=t[n];x.isObservable(r)?(e.style[n]=r.val(),r.subscribe(T.bind(null,e,n))):e.style[n]=r}}function M(e,t,n){const r=x.isObservable(n)?n.val():n;x.isBoolean(r)?e[t]=r:e[t]=r===e.value,x.isObservable(n)&&(["checked"].includes(t)&&e.addEventListener("input",D.bind(null,e,t,r,n)),n.subscribe(P.bind(null,e,t)))}function R(e,t,n){const r=n=>{"value"!==t?e.setAttribute(t,n):e.value=n};r(n.val()),n.subscribe(r),"value"===t&&e.addEventListener("input",()=>n.set(e.value))}N.getById=function(e){const t=o.getObservableById(parseInt(e));if(!t)throw new s("Observable.getById : No observable found with id "+e);return t},N.cleanup=function(e){e.cleanup()},N.autoCleanup=function(e=!1,t={}){if(!e)return;const{interval:n=6e4,threshold:r=100}=t;window.addEventListener("beforeunload",()=>{o.cleanup()}),setInterval(()=>o.cleanObservables(r),n)};const j=new Map;let V=null;const _={createTextNode:()=>(V||(V=document.createTextNode("")),V.cloneNode()),createObservableNode(e,t){const n=_.createTextNode();return t.subscribe(e=>n.nodeValue=e),n.nodeValue=t.val(),e&&e.appendChild(n),n},createHydratableNode(e,t){const n=_.createTextNode();return t.$hydrate(n),n},createStaticTextNode(e,t){let n=_.createTextNode();return n.nodeValue=t,e&&e.appendChild(n),n},createElement(e){if(e){if(j.has(e))return j.get(e).cloneNode();const t=document.createElement(e);return j.set(e,t),t.cloneNode()}return new I("Fragment")},processChildren(e,t){if(null!==e){if(a.emit("BeforeProcessChildren",t),Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let r=this.getChild(e[n]);null!==r&&t.appendChild(r)}else{let n=this.getChild(e);n&&t.appendChild(n)}a.emit("AfterProcessChildren",t)}},getChild(e){if(null===e)return null;if(x.isString(e)&&(e=e.resolveObservableTemplate?e.resolveObservableTemplate():e,x.isString(e)))return _.createStaticTextNode(null,e);if(x.isElement(e))return e;if(x.isObservable(e))return _.createObservableNode(null,e);if(x.isNDElement(e))return e.$element??e.$build?.()??null;if(x.$element)return x.$element;if(x.isArray(e)){const t=document.createDocumentFragment();for(let n=0,r=e.length;n<r;n++)t.appendChild(this.getChild(e[n]));return t}return x.isFunction(e)?(a.emit("BeforeProcessComponent",e),this.getChild(e())):e?.$hydrate?_.createHydratableNode(null,e):_.createStaticTextNode(null,e)},processAttributes(e,t){x.isFragment(e)||t&&function(e,t){if(x.validateAttributes(t),!x.isObject(t))throw new s("Attributes must be an object");for(let n in t){const r=n.toLowerCase();let o=t[r];if(null!=o){if(x.isString(o)){if(o=o.resolveObservableTemplate?o.resolveObservableTemplate():o,x.isString(o)){e.setAttribute(r,o);continue}const t=o.filter(e=>x.isObservable(e));o=N.computed(()=>o.map(e=>x.isObservable(e)?e.val():e).join(" ")||" ",t)}"class"===r&&x.isObject(o)?L(e,o):"style"===r&&x.isObject(o)?B(e,o):k.includes(r)?M(e,r,o):x.isObservable(o)?R(e,r,o):o.$hydrate?o.$hydrate(e,r):e.setAttribute(r,o)}}}(e,t)},setup:(e,t,n)=>(a.emit("Setup",e,t,n),e)};Object.defineProperty(HTMLElement.prototype,"nd",{configurable:!0,get(){return new b(this)}});const q={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,...q}}});let H=e=>e;t.ArgTypes={},t.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 W=function(e,t=null){if(!x.isJson(e)||e?.$hydrate){const n=t;t=e,e=n}return{props:e,children:t}},z=function(e){return x.isObservable(e)?_.createObservableNode(null,e):_.createStaticTextNode(null,e)};function U(e,t,n,r=null){let{props:o,children:s=null}=W(n,r),i=_.createElement(e),a=t&&"function"==typeof t?t(i):i;return o&&_.processAttributes(a,o),s&&_.processChildren(s,a),_.setup(a,o,t)}function K(e,t){return U.bind(null,e.toLowerCase(),t)}const J=new WeakMap;function Q(e){let t=null,n=!1;const r=(e,t)=>{const n=J.get(e);if(3===e.nodeType)return n&&n.value?n.value(t):e.cloneNode(!0);const o=e.cloneNode(e.fullCloneNode);if(n&&(((e,t,n)=>{let r=null;if(t.attributes){r=r||{};for(const e in t.attributes)r[e]=t.attributes[e](...n)}if(t.classes){r=r||{},r.class={};for(const e in t.classes)r.class[e]=t.classes[e](...n)}if(t.styles){r=r||{},r.style={};for(const e in t.styles)r.style[e]=t.styles[e](...n)}r&&_.processAttributes(e,r)})(o,n,t),function(e,t,n){if(!t.attach)return null;t.attach(e,...n)}(o,n,t)),e.fullCloneNode)return o;const s=e.childNodes;for(let e=0,n=s.length;e<n;e++){const n=s[e],i=r(n,t);o.appendChild(i)}return o};this.clone=o=>{if(!t&&(t=e(this),!n)){const e=t.cloneNode(!0);return e.fullCloneNode=!0,e}return n?r(t,o):t.cloneNode(!0)};const o=(e,t)=>({$hydrate:(r,o)=>{n=!0,function(e,t,n,r){J.has(n)||J.set(n,{});const o=J.get(n);"value"!==t?"attach"!==t?(o[t]=o[t]||{},o[t][r]=e):o.attach=e:o.value=e}(e,t,r,o)}});this.style=e=>o(e,"styles"),this.class=e=>o(e,"classes"),this.property=e=>this.value(e),this.value=e=>o("function"!=typeof e?function(t){const n=t[0];return z(n[e])}:function(t){return z(e(...t))},"value"),this.attr=e=>o(e,"attributes"),this.attach=e=>o(e,"attach")}function Z(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=new I("Component "+e);return n[e]=function(...e){r.removeChildren(),t?r.appendChild(t(...e)):r.append(e)},r}}Function.prototype.args=function(...e){return this},Function.prototype.cached=function(...e){let t=null,n=function(){return t};return()=>(t||(t=this.apply(this,e),t.cloneNode?n=function(){return t.cloneNode(!0)}:t.$element&&(n=function(){return new b(t.$element.cloneNode(!0))})),n())},Function.prototype.errorBoundary=function(e){return(...t)=>{try{return this.apply(this,t)}catch(t){return e(t)}}},String.prototype.use=function(e){const t=this;return N.computed(()=>t.replace(/\$\{(.*?)}/g,(t,n)=>{const r=e[n];return x.isObservable(r)?r.val():r}),Object.values(e))},String.prototype.resolveObservableTemplate=function(){return x.containsObservableReference(this)?this.split(/(\{\{#ObItem::\([0-9]+\)\}\})/g).filter(Boolean).map(e=>{if(!x.containsObservableReference(e))return e;const[t,n]=e.match(/\{\{#ObItem::\(([0-9]+)\)\}\}/);return N.getById(n)}):this.valueOf()};const G=["push","pop","shift","unshift","reverse","sort","splice"];N.array=function(e,{propagation:t=!1,deep:n=!1}={}){if(!Array.isArray(e))throw new s("Observable.array : target must be an array");const r=N(e);a.emit("CreateObservableArray",r),G.forEach(e=>{r[e]=function(...t){const n=r.val()[e](...t);return r.trigger({action:e,args:t,result:n}),n}}),r.clear=function(){return r.val().length=0,r.trigger({action:"clear"}),!0},r.merge=function(e){r.$value.push(...e),r.trigger({action:"merge",args:e})},r.populateAndRender=function(e,t){r.trigger({action:"populate",args:[r.val(),e,t]})},r.removeItem=function(e){const t=r.val().indexOf(e);return r.remove(t)},r.remove=function(e){const t=r.val().splice(e,1);return 0===t.length?[]:(r.trigger({action:"remove",args:[e],result:t[0]}),t)},r.swap=function(e,t){const n=r.val(),o=n.length;if(o<e||o<t)return!1;if(t<e){const n=e;e=t,t=n}const s=n[e],i=n[t];return n[e]=i,n[t]=s,r.trigger({action:"swap",args:[e,t],result:[s,i]}),!0},r.length=function(){return r.val().length},r.count=e=>{let t=0;return r.val().forEach((n,r)=>{e(n,r)&&t++}),t},r.isEmpty=function(){return 0===r.val().length};return["map","filter","reduce","some","every","find","findIndex","concat","includes","indexOf"].forEach(e=>{r[e]=(...t)=>r.val()[e](...t)}),r},N.batch=function(e){const t=N(0),n=function(){if(x.isAsyncFunction(e))return e(...arguments).then(()=>{t.trigger()}).catch(e=>{throw e});e(...arguments),t.trigger()};return n.$observer=t,n};N.init=function(e,{propagation:t=!1,deep:n=!0}={}){const r={};for(const o in e){const s=e[o];if(Array.isArray(s)){if(n){r[o]=s.map(e=>x.isJson(e)?N.json(e,{propagation:t,deep:n}):x.isArray(e)?N.array(e,{propagation:t,deep:n}):N(e));continue}r[o]=N.array(s,{propagation:t})}else x.isObservable(s)||x.isProxy(s)?r[o]=s:r[o]=N(s)}const o=()=>function(e){const t={};for(const n in e){const r=e[n];if(x.isObservable(r)){let e=r.val();Array.isArray(e)&&(e=e.map(e=>x.isObservable(e)?e.val():x.isProxy(e)?e.$value:e)),t[n]=e}else x.isProxy(r)?t[n]=r.$value:t[n]=r}return t}(r),s=()=>N.init(o(),{propagation:t,deep:n}),i=e=>{N.update(u,e)},a=e=>function(e,t){const n=e[t];return x.isObservable(n)?n.val():x.isProxy(n)?n.$value:n}(r,e),u=new Proxy(r,{get:(t,n)=>"__isProxy__"===n||("$value"===n?o():"$clone"===n?s:"$keys"===n?Object.keys(e):"$observables"===n?Object.values(t):"$updateWith"===n||"$set"===n?i:"$get"===n?a:void 0!==t[n]?t[n]:void 0),set:(e,t,n)=>void 0===e[t]||(x.isObservable(n)?e[t].set(n.val()):e[t].set(n),!0)});return u},N.arrayOfObject=function(e){return e.map(e=>N.object(e))},N.value=function(e){if(x.isObservable(e))return e.val();if(x.isProxy(e))return e.$value;if(x.isArray(e)){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(N.value(r))}return t}return e},N.update=function(e,t){const n=x.isProxy(t)?t.$value:t;for(const r in n){const o=e[r],s=t[r],i=n[r];if(x.isObservable(o)){if(x.isArray(i)){if(x.isObservable(s[0])||x.isProxy(s[0])){const e=i.map(e=>x.isObservable(s[0])?N(e):N.init(s[0]));o.set(e);continue}o.set([...i]);continue}o.set(i)}else x.isProxy(o)?N.update(o,i):e[r]=i}},N.object=N.init,N.json=N.init,N.computed=function(e,t=[]){const n=new u(e()),r=()=>n.set(e());if(a.emit("CreateObservableComputed",n,t),x.isFunction(t)){if(!x.isObservable(t.$observer))throw new s("Observable.computed : dependencies must be valid batch function");return t.$observer.subscribe(r),n}return t.forEach(e=>{x.isProxy(e)?e.$observables.forEach(e=>{e.subscribe(r)}):e.subscribe(r)}),n};const X=function(){const e=new Map;return{use(t){const{observer:n,subscribers:r}=e.get(t),o=N(n.val()),s=n.subscribe(e=>o.set(e)),i=o.subscribe(e=>n.set(e));return o.destroy=()=>{s(),i(),o.cleanup()},r.add(o),o},follow(e){return this.use(e)},create(t,n){const r=N(n);return e.set(t,{observer:r,subscribers:new Set}),r},get(t){const n=e.get(t);return n?n.observer:null},getWithSubscribers:t=>e.get(t),delete(t){const n=e.get(t);n&&(n.observer.cleanup(),n.subscribers.forEach(e=>e.destroy()),n.observer.clear())}}}();const Y=function(e,t,{comment:n=null,shouldKeepInCache:o=!0}={}){if(!x.isObservable(e))return r.warn("ShowIf","ShowIf : condition must be an Observable / "+n,e);const s=new I("Show if : "+(n||""));let i=null;const a=()=>(i&&o||(i=_.getChild(t),x.isFragment(i)&&(i=Array.from(i.childNodes))),i);return e.val()&&s.appendChild(a()),e.subscribe(e=>{e?s.appendChild(a()):s.remove()}),s},ee=function(e,t,n=!0){if(!x.isObservable(e))throw new s("Toggle : condition must be an Observable");const r=new I("Match"),o=new Map,i=function(e){if(n&&o.has(e))return o.get(e);let r=t[e];return r?(r=_.getChild(r),x.isFragment(r)&&(r=Array.from(r.children)),n&&o.set(e,r),r):null},a=e.val(),u=i(a);return u&&r.appendChild(u),e.subscribe(e=>{const t=i(e);r.remove(),t&&r.appendChild(t)}),r},te=function(e,t,n){if(!x.isObservable(e))throw new s("Toggle : condition must be an Observable");return ee(e,{true:t,false:n})},ne=K("div"),re=K("span"),oe=K("label"),se=K("p"),ie=se,ae=K("strong"),ue=K("h1"),le=K("h2"),ce=K("h3"),he=K("h4"),de=K("h5"),pe=K("h6"),fe=K("br"),me=K("a"),be=K("pre"),ge=K("code"),ve=K("blockquote"),ye=K("hr"),we=K("em"),$e=K("small"),Ce=K("mark"),Oe=K("del"),Se=K("ins"),Ae=K("sub"),Ee=K("sup"),xe=K("abbr"),Ie=K("cite"),ke=K("q"),Ne=K("dl"),Fe=K("dt"),Te=K("dd"),Pe=K("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}),De=K("input"),Le=K("textarea"),Be=Le,Me=K("select"),Re=K("fieldset"),je=K("option"),Ve=K("legend"),_e=K("datalist"),qe=K("output"),He=K("progress"),We=K("meter"),ze=K("button"),Ue=K("main"),Ke=K("section"),Je=K("article"),Qe=K("aside"),Ze=K("nav"),Ge=K("figure"),Xe=K("figcaption"),Ye=K("header"),et=K("footer"),tt=K("img"),nt=function(e,t){return tt({src:e,...t})},rt=K("details"),ot=K("summary"),st=K("dialog"),it=K("menu"),at=K("ol"),ut=K("ul"),lt=K("li"),ct=lt,ht=at,dt=ut,pt=K("audio"),ft=K("video"),mt=K("source"),bt=K("track"),gt=K("canvas"),vt=K("svg"),yt=K("time"),wt=K("data"),$t=K("address"),Ct=K("kbd"),Ot=K("samp"),St=K("var"),At=K("wbr"),Et=K("caption"),xt=K("table"),It=K("thead"),kt=K("tfoot"),Nt=K("tbody"),Ft=K("tr"),Tt=Ft,Pt=K("th"),Dt=Pt,Lt=Pt,Bt=K("td"),Mt=Bt,Rt=K("");var jt=Object.freeze({__proto__:null,Abbr:xe,Address:$t,Anchor:I,Article:Je,Aside:Qe,AsyncImg:function(e,t,n,r){const o=x.isObservable(e)?e.val():e,i=nt(t||o,n),a=new Image;return a.onload=()=>{x.isFunction(r)&&r(null,i),i.src=x.isObservable(e)?e.val():e},a.onerror=()=>{x.isFunction(r)&&r(new s("Image not found"))},x.isObservable(e)&&e.subscribe(e=>{a.src=e}),a.src=o,i},Audio:pt,BaseImage:tt,Blockquote:ve,Br:fe,Button:ze,Canvas:gt,Caption:Et,Checkbox:e=>De({type:"checkbox",...e}),Cite:Ie,Code:ge,ColorInput:e=>De({type:"color",...e}),Data:wt,Datalist:_e,DateInput:e=>De({type:"date",...e}),DateTimeInput:e=>De({type:"datetime-local",...e}),Dd:Te,Del:Oe,Details:rt,Dialog:st,Div:ne,Dl:Ne,Dt:Fe,Em:we,EmailInput:e=>De({type:"email",...e}),FieldSet:Re,FigCaption:Xe,Figure:Ge,FileInput:e=>De({type:"file",...e}),Footer:et,ForEach:function(e,t,n,{shouldKeepItemsInCache:o=!1}={}){const i=new I("ForEach"),a=i.endElement();i.startElement();let u=new Map,l=null;const c=new Set,h=e=>{if(!o)for(const[t,n]of u.entries()){if(c.has(t))continue;const r=n.child?.deref();e&&r&&e.removeChild(r),n.indexObserver?.cleanup(),n.child=null,n.indexObserver=null,u.delete(n.keyId),l&&l.delete(n.keyId)}},p=(e,o)=>{const i=d(e,o,n);if(u.has(i)){const e=u.get(i);if(e.indexObserver?.set(o),e.isNew=!1,e.child?.deref())return i;u.delete(i)}try{const n=t.length>=2?N(o):null;let r=_.getChild(t(e,n));if(!r||x.isFragment(r))throw new s("ForEachArray child can't be null or undefined!");u.set(i,{keyId:i,isNew:!0,child:new WeakRef(r),indexObserver:n})}catch(e){throw r.error("ForEach",`Error creating element for key ${i}`,e),e}return i},f=()=>{const t=a.parentNode;if(!t)return;const n=x.isObservable(e)?e.val():e;if(c.clear(),Array.isArray(n))for(let e=0,t=n.length;e<t;e++){const t=p(n[e],e);c.add(t)}else for(const e in n){const t=p(n[e],e);c.add(t)}if(0===c.size)return i.removeChildren(),h(),void l?.clear();h(t),l&&0!==l.size?(()=>{let e=document.createDocumentFragment();const t=Array.from(c);Array.from(l);for(const n in t){const r=t[n],o=u.get(r);if(!o)continue;const s=o.child.deref();s&&e.appendChild(s)}i.replaceContent(e)})():(e=>{const t=document.createDocumentFragment();for(const e of c){const n=u.get(e);if(!n)continue;const r=n.child?.deref();r&&t.appendChild(r)}e.insertBefore(t,a)})(t),l?.clear(),l=new Set([...c])};return f(),x.isObservable(e)&&e.subscribe(f),i},ForEachArray:function(e,t,n,r={}){const o=new I("ForEach Array"),i=o.endElement(),a=o.startElement();let u=new Map,l=0;const c=t.length>=2,h=new WeakMap,p=()=>{o.removeChildren(),g(),l=0},f=(e,t)=>h.has(e)?h.get(e):d(e,t,n),m=e=>y(f(e)),b=(e,t=!0)=>{if(e){if(t){const t=e.child;t?.remove(),u.delete(e.keyId)}e.indexObserver?.deref()?.cleanup()}},g=()=>{if(!r.shouldKeepItemsInCache)if(c){for(const[e,t]of u.entries())b(t,!1);u.clear()}else u.clear()},v=(e,n)=>{const r=f(e,n);if(u.has(r)){const e=u.get(r);e.indexObserver?.deref()?.set(n);const t=e.child;if(t)return t;u.delete(r)}const o=c?N(n):null;let i=_.getChild(t(e,o));if(!i||x.isFragment(i))throw new s("ForEachArray child can't be null or undefined!");return u.set(r,{keyId:r,child:i,indexObserver:o?new WeakRef(o):null}),h.set(e,r),i},y=function(e){const t=u.get(e);if(!t)return null;const n=t.child;return n||(b(t,!1),null)},w=function(e,t){const n=u.get(e);if(!n)return null;const r=n.child;if(!r)return null;t?t.appendChild(r):r.remove()},$={toFragment(e,t=0){const n=document.createDocumentFragment();for(let t=0,r=e.length;t<r;t++)n.appendChild(v(e[t],l)),l++;return n},add(e,t=2){const n=$.toFragment(e);setTimeout(()=>{o.appendElement(n)},t)},replace(e){p(),$.add(e)},reOrder(e){let t=null;const n=document.createDocumentFragment();for(const r of e)t=m(r),t&&n.appendChild(t);t=null,o.appendElement(n,i)},removeOne(e,t){((e,t=!0)=>{b(u.get(e),t)})(f(e,t),!0)},clear:p,merge(e){$.add(e)},push(e){let t=0;r.pushDelay&&(t=r.pushDelay(e)??0),$.add(e,t)},populate([e,t,n]){const r=document.createDocumentFragment();for(let o=0;o<t;o++){const t=n(o);e.push(t),r.append(v(t,o)),l++}o.appendChild(r),r.replaceChildren()},unshift(e){o.insertBefore($.toFragment(e),a.nextSibling)},splice(e,t){const[n,r,...s]=e;let a=null;const u=document.createDocumentFragment();if(t.length>0){let e=f(t[0],n);if(1===t.length)w(e,u);else if(t.length>1){const r=y(e);a=r?.previousSibling;for(let e=0;e<t.length;e++){const r=f(t[e],n+e);w(r,u)}}}else a=i;u.replaceChildren(),s&&s.length&&a&&o.insertBefore($.toFragment(s),a.nextSibling)},reverse(e,t){$.reOrder(t)},sort(e,t){$.reOrder(t)},remove(e,t){$.removeOne(t)},pop(e,t){$.removeOne(t)},shift(e,t){$.removeOne(t)},swap(e,t){const n=i.parentNode;let r=m(t[0]),o=m(t[1]);if(!r||!o)return;const s=o.nextSibling;n.insertBefore(o,r),n.insertBefore(r,s),r=null,o=null}},C=(e,t,n)=>{if("clear"!==n.action&&e.length){if(n?.action)$[n.action]&&$[n.action](n.args,n.result);else{if(0===l)return void $.add(e);$.replace(e)}((e,t=0)=>{if(!c)return;let n=t;for(let r=t,o=e?.length;r<o;r++){const t=u.get(f(e[r],r));t&&(t.indexObserver?.deref()?.set(n),n++)}})(e,0)}else{if(0===l)return;p()}};return e.val().length&&C(e.val(),0,{action:null}),x.isObservable(e)&&e.subscribe(C),o},Form:Pe,Fragment:Rt,H1:ue,H2:le,H3:ce,H4:he,H5:de,H6:pe,Header:Ye,HiddenInput:e=>De({type:"hidden",...e}),HideIf:function(e,t,n){const r=N(!e.val());return e.subscribe(e=>r.set(!e)),Y(r,t,n)},HideIfNot:function(e,t,n){return Y(e,t,n)},Hr:ye,Img:nt,Input:De,Ins:Se,Kbd:Ct,Label:oe,LazyImg:function(e,t){return nt(e,{...t,loading:"lazy"})},Legend:Ve,Li:ct,Link:me,ListItem:lt,Main:Ue,Mark:Ce,Match:ee,Menu:it,Meter:We,MonthInput:e=>De({type:"month",...e}),NativeDocumentFragment:I,Nav:Ze,NumberInput:e=>De({type:"number",...e}),Ol:ht,Option:je,OrderedList:at,Output:qe,P:se,Paragraph:ie,PasswordInput:e=>De({type:"password",...e}),Pre:be,Progress:He,Quote:ke,Radio:e=>De({type:"radio",...e}),RangeInput:e=>De({type:"range",...e}),ReadonlyInput:e=>De({readonly:!0,...e}),Samp:Ot,SearchInput:e=>De({type:"search",...e}),Section:Ke,Select:Me,ShowIf:Y,SimpleButton:(e,t)=>ze(e,{type:"button",...t}),Small:$e,Source:mt,Span:re,Strong:ae,Sub:Ae,SubmitButton:(e,t)=>ze(e,{type:"submit",...t}),Summary:ot,Sup:Ee,Svg:vt,Switch:te,TBody:Nt,TBodyCell:Mt,TFoot:kt,TFootCell:Lt,THead:It,THeadCell:Dt,TRow:Tt,Table:xt,Td:Bt,TelInput:e=>De({type:"tel",...e}),TextArea:Le,TextInput:Be,Th:Pt,Time:yt,TimeInput:e=>De({type:"time",...e}),Tr:Ft,Track:bt,Ul:dt,UnorderedList:ut,UrlInput:e=>De({type:"url",...e}),Var:St,Video:ft,Wbr:At,WeekInput:e=>De({type:"week",...e}),When:function(e){if(!x.isObservable(e))throw new s("When : condition must be an Observable");let t=null,n=null;return{show(e){return t=e,this},otherwise:r=>(n=r,te(e,t,n))}},createPortal:function(e,{parent:t,name:n="unnamed"}={}){const r=I("Portal "+n);return r.appendChild(_.getChild(e)),(t||document.body).appendChild(r),r}});const Vt={};function _t(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||{},u=n.layout||null,l={},c=[],h=e=>{if(!e)return null;const[t,n]=e.split(":");let r=a[t];return!r&&n&&(r=Vt[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?(l[n.name]=n.pattern,c.push(n.name),n.pattern):e});return r=new RegExp("^"+t+"$"),r};this.name=()=>o,this.component=()=>t,this.middlewares=()=>s,this.shouldRebuild=()=>i,this.path=()=>e,this.layout=()=>u,this.match=function(e){e="/"+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 qt extends Error{constructor(e,t){super(e),this.context=t}}const Ht=(e,t)=>{const n=[];return e.forEach(e=>{n.push(p(e.suffix,"/"))}),n.push(p(t,"/")),n.join("/")},Wt=(e,t)=>{const n=[];return e.forEach(e=>{e.options.middlewares&&n.push(...e.options.middlewares)}),t&&n.push(...t),n},zt=(e,t)=>{const n=[];return e.forEach(e=>{e.options?.name&&n.push(e.options.name)}),t&&n.push(t),n.join(".")},Ut=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.options?.layout)return e[t].options.layout;return null};function Kt(){const e=[];let t=0;const n=n=>{const o=t+n;if(!e[o])return;t=o;const{route:s,params:i,query:a,path:u}=e[o];r(u)},r=e=>{window.location.replace(`${window.location.pathname}${window.location.search}#${e}`)},o=()=>window.location.hash.slice(1);this.push=function(n){const{route:s,params:i,query:a,path:u}=this.resolve(n);u!==o()&&(e.splice(t+1),e.push({route:s,params:i,query:a,path:u}),t++,r(u))},this.replace=function(n){const{route:r,params:s,query:i,path:a}=this.resolve(n);a!==o()&&(e[t]={route:r,params:s,query:i,path:a})},this.forward=function(){return t<e.length-1&&n(1)},this.back=function(){return t>0&&n(-1)},this.init=function(n){window.addEventListener("hashchange",()=>{const{route:e,params:t,query:n,path:r}=this.resolve(o());this.handleRouteChange(e,t,n,r)});const{route:r,params:s,query:i,path:a}=this.resolve(n||o());e.push({route:r,params:s,query:i,path:a}),t=0,this.handleRouteChange(r,s,i,a)}}function Jt(){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){r.error("HistoryRouter","Error in pushState",e)}},this.replace=function(e){const{route:t,path:n,params:o}=this.resolve(e);try{window.history.replaceState({name:t.name(),params:o,path:n},t.name()||n,n),this.handleRouteChange(t,o,{},n)}catch(e){r.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){r.error("HistoryRouter","Error in popstate event",e)}});const{route:t,params:n,query:o,path:s}=this.resolve(e||window.location.pathname+window.location.search);this.handleRouteChange(t,n,o,s)}}function Qt(){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)}}const Zt="default";function Gt(e={}){const t=[],n={},o=[],s=[],i={route:null,params:null,query:null,path:null,hash:null};if("hash"===e.mode)Kt.apply(this,[]);else if("history"===e.mode)Jt.apply(this,[]);else{if("memory"!==e.mode)throw new qt("Invalid router mode "+e.mode);Qt.apply(this,[])}const a=function(e,t){for(const n of s)try{n(e),t&&t(e)}catch(e){r.warn("Route Listener","Error in listener:",e)}};this.routes=()=>[...t],this.currentState=()=>({...i}),this.add=function(e,r,s){const i=new _t(Ht(o,e),r,{...s,middlewares:Wt(o,s?.middlewares||[]),name:s?.name?zt(o,s.name):null,layout:s?.layout||Ut(o)});return t.push(i),i.name()&&(n[i.name()]=i),this},this.group=function(e,t,n){if(!x.isFunction(n))throw new qt("Callback must be a function");return o.push({suffix:e,options:t}),n(),o.pop(),this},this.generateUrl=function(e,t={},r={}){const o=n[e];if(!o)throw new qt(`Route not found for name: ${e}`);return o.url({params:t,query:r})},this.resolve=function(e){if(x.isJson(e)){const t=n[e.name];if(!t)throw new qt(`Route not found for name: ${e.name}`);return{route:t,params:e.params,query:e.query,path:t.url({...e})}}const[r,o]=e.split("?"),s="/"+p(r,"/");let i,a=null;for(const e of t)if(i=e.match(s),i){a=e;break}if(!a)throw new qt(`Route not found for url: ${r}`);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(!x.isFunction(e))throw new qt("Listener must be a function");return s.push(e),()=>{s.splice(s.indexOf(e),1)}},this.handleRouteChange=function(e,t,n,r){i.route=e,i.params=t,i.query=n,i.path=r;const o=[...e.middlewares(),a];let s=0;const u={...i},l=e=>{if(s++,!(s>=o.length))return o[s](e||u,l)};return o[s](u,l)}}function Xt(e,t){const{to:n,href:r,...o}=e,s=n||r;if(x.isString(s)){const e=Gt.get();return me({...o,href:s},t).nd.onPreventClick(()=>{e.push(s)})}const i=s.router||Zt,a=Gt.get(i);if(!a)throw new qt('Router not found "'+i+'" for link "'+s.name+'"');const u=a.generateUrl(s.name,s.params,s.query);return me({...o,href:u},t).nd.onPreventClick(()=>{a.push(u)})}Gt.routers={},Gt.create=function(t,n){if(!x.isFunction(n))throw r.error("Router","Callback must be a function",e),new qt("Callback must be a function");const o=new Gt(t);return Gt.routers[t.name||Zt]=o,n(o),o.init(t.entry),o.mount=function(e){if(x.isString(e)){const t=document.querySelector(e);if(!t)throw new qt(`Container not found for selector: ${e}`);e=t}else if(!x.isElement(e))throw new qt("Container must be a string or an Element");return function(e,t){const n=new Map,r=function(e,n){t.innerHTML="";const r=n.layout();r?t.appendChild(r(e)):t.appendChild(e)},o=function(e){if(!e.route)return;const{route:t,params:o,query:s,path:i}=e;if(n.has(i)){const e=n.get(i);return void r(e,t)}const a=t.component()({params:o,query:s});n.set(i,a),r(a,t)};return e.subscribe(o),o(e.currentState()),t}(o,e)},o},Gt.get=function(e){const t=Gt.routers[e||Zt];if(!t)throw new qt(`Router not found for name: ${e}`);return t},Gt.push=function(e,t=null){return Gt.get(t).push(e)},Gt.replace=function(e,t=null){return Gt.get(t).replace(e)},Gt.forward=function(e=null){return Gt.get(e).forward()},Gt.back=function(e=null){return Gt.get(e).back()},Xt.blank=function(e,t){return me({...e,target:"_blank"},t)};var Yt=Object.freeze({__proto__:null,Link:Xt,RouteParamPatterns:Vt,Router:Gt});return t.ElementCreator=_,t.HtmlElementWrapper=K,t.NDElement=b,t.Observable=N,t.PluginsManager=a,t.SingletonView=Z,t.Store=X,t.TemplateCloner=Q,t.Validator=x,t.classPropertyAccumulator=function(e=[]){let t=x.isString(e)?e.split(" ").filter(Boolean):e;const n=x.isArray(t);return{add(e,r=!0){n?t.push(e):t[e]=r},value:()=>n?t.join(" "):{...t}}},t.createTextNode=z,t.cssPropertyAccumulator=function(e={}){let t=x.isString(e)?e.split(";").filter(Boolean):e;const n=x.isArray(t);return{add(e,r){n?t.push(e+" : "+r):t[e]=r},value:()=>n?t.join(";").concat(";"):{...t}}},t.elements=jt,t.normalizeComponentArgs=W,t.router=Yt,t.useCache=function(e){let t=null;const n=function(n){return t||(t=new Q(e)),t.clone(n)};return e.length<2?function(...e){return n(e)}:function(e,t,...r){return n([e,t,...r])}},t.useSingleton=function(e){let t=null;return function(...n){return t||(t=new Z(e)),t.render(n)}},t.withValidation=H,t}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -228,7 +228,11 @@ ObservableItem.prototype.unsubscribe = function(callback) {
228
228
  ObservableItem.prototype.check = function(callback) {
229
229
  return new ObservableChecker(this, callback)
230
230
  };
231
- ObservableItem.prototype.get = ObservableItem.prototype.check;
231
+
232
+ ObservableItem.prototype.get = function(key) {
233
+ const item = this.$currentValue[key];
234
+ return Validator.isObservable(item) ? item.val() : item;
235
+ };
232
236
 
233
237
  ObservableItem.prototype.when = function(value) {
234
238
  return {$target: value, $observer: this};
@@ -10,7 +10,7 @@ const methods = ['push', 'pop', 'shift', 'unshift', 'reverse', 'sort', 'splice']
10
10
  * @param {Array} target
11
11
  * @returns {ObservableItem}
12
12
  */
13
- Observable.array = function(target) {
13
+ Observable.array = function(target, { propagation = false, deep = false } = {}) {
14
14
  if(!Array.isArray(target)) {
15
15
  throw new NativeDocumentError('Observable.array : target must be an array');
16
16
  }
@@ -2,43 +2,89 @@ import Validator from "../../utils/validator";
2
2
  import {Observable} from "../Observable";
3
3
  import ObservableItem from "../ObservableItem";
4
4
 
5
+
6
+
7
+ const ObservableObjectValue = function(data) {
8
+ const result = {};
9
+ for(const key in data) {
10
+ const dataItem = data[key];
11
+ if(Validator.isObservable(dataItem)) {
12
+ let value = dataItem.val();
13
+ if(Array.isArray(value)) {
14
+ value = value.map(item => {
15
+ if(Validator.isObservable(item)) {
16
+ return item.val();
17
+ }
18
+ if(Validator.isProxy(item)) {
19
+ return item.$value;
20
+ }
21
+ return item;
22
+ });
23
+ }
24
+ result[key] = value;
25
+ } else if(Validator.isProxy(dataItem)) {
26
+ result[key] = dataItem.$value;
27
+ } else {
28
+ result[key] = dataItem;
29
+ }
30
+ }
31
+ return result;
32
+ };
33
+
34
+ const ObservableGet = function(target, property) {
35
+ const item = target[property];
36
+ if(Validator.isObservable(item)) {
37
+ return item.val();
38
+ }
39
+ if(Validator.isProxy(item)) {
40
+ return item.$value;
41
+ }
42
+ return item;
43
+ };
44
+
5
45
  /**
6
46
  *
7
47
  * @param {Object} initialValue
48
+ * @param {{propagation: boolean, deep: boolean}} configs
8
49
  * @returns {Proxy}
9
50
  */
10
- Observable.init = function(initialValue) {
51
+ Observable.init = function(initialValue, { propagation= false, deep = true } = {}) {
11
52
  const data = {};
12
53
  for(const key in initialValue) {
13
54
  const itemValue = initialValue[key];
14
55
  if(Array.isArray(itemValue)) {
15
- data[key] = Observable.array(itemValue);
56
+ if(deep) {
57
+ data[key] = itemValue.map(item => {
58
+ if(Validator.isJson(item)) {
59
+ return Observable.json(item, { propagation, deep });
60
+ }
61
+ if(Validator.isArray(item)) {
62
+ return Observable.array(item, { propagation, deep });
63
+ }
64
+ return Observable(item);
65
+ });
66
+ continue;
67
+ }
68
+ data[key] = Observable.array(itemValue, { propagation });
69
+ continue;
70
+ }
71
+ if(Validator.isObservable(itemValue) || Validator.isProxy(itemValue)) {
72
+ data[key] = itemValue;
16
73
  continue;
17
74
  }
18
75
  data[key] = Observable(itemValue);
19
76
  }
20
77
 
21
- const $val = function() {
22
- const result = {};
23
- for(const key in data) {
24
- const dataItem = data[key];
25
- if(Validator.isObservable(dataItem)) {
26
- result[key] = dataItem.val();
27
- } else if(Validator.isProxy(dataItem)) {
28
- result[key] = dataItem.$value;
29
- } else {
30
- result[key] = dataItem;
31
- }
32
- }
33
- return result;
34
- };
35
- const $clone = function() {
36
- return Observable.init($val());
37
- };
38
- const $updateWith = function(values) {
78
+ const $val = () => ObservableObjectValue(data);
79
+
80
+ const $clone = () => Observable.init($val(), { propagation, deep });
81
+
82
+ const $updateWith = (values) => {
39
83
  Observable.update(proxy, values);
40
84
  };
41
85
 
86
+ const $get = (key) => ObservableGet(data, key);
87
+
42
88
  const proxy = new Proxy(data, {
43
89
  get(target, property) {
44
90
  if(property === '__isProxy__') {
@@ -50,12 +96,18 @@ Observable.init = function(initialValue) {
50
96
  if(property === '$clone') {
51
97
  return $clone;
52
98
  }
99
+ if(property === '$keys') {
100
+ return Object.keys(initialValue);
101
+ }
53
102
  if(property === '$observables') {
54
103
  return Object.values(target);
55
104
  }
56
- if(property === '$updateWith') {
105
+ if(property === '$set' || property === '$updateWith') {
57
106
  return $updateWith;
58
107
  }
108
+ if(property === '$get') {
109
+ return $get;
110
+ }
59
111
  if(target[property] !== undefined) {
60
112
  return target[property];
61
113
  }
@@ -108,16 +160,26 @@ Observable.value = function(data) {
108
160
  };
109
161
 
110
162
 
111
- Observable.update = function($target, data) {
112
- if(Validator.isProxy(data)) {
113
- data = data.$value;
114
- }
163
+ Observable.update = function($target, newData) {
164
+ const data = Validator.isProxy(newData) ? newData.$value : newData;
165
+
115
166
  for(const key in data) {
116
167
  const targetItem = $target[key];
168
+ const newValueOrigin = newData[key];
117
169
  const newValue = data[key];
118
170
 
119
171
  if(Validator.isObservable(targetItem)) {
120
172
  if(Validator.isArray(newValue)) {
173
+ if(Validator.isObservable(newValueOrigin[0]) || Validator.isProxy(newValueOrigin[0])) {
174
+ const newValues = newValue.map(item => {
175
+ if(Validator.isObservable(newValueOrigin[0])) {
176
+ return Observable(item);
177
+ }
178
+ return Observable.init(newValueOrigin[0]);
179
+ });
180
+ targetItem.set(newValues);
181
+ continue;
182
+ }
121
183
  targetItem.set([...newValue]);
122
184
  continue;
123
185
  }
@@ -84,7 +84,7 @@ function bindBooleanAttribute(element, attributeName, value) {
84
84
  }
85
85
  if(Validator.isObservable(value)) {
86
86
  if(['checked'].includes(attributeName)) {
87
- element.addEventListener('input', updateObserverFromInput.bind(null, element, attributeName, defaultValue));
87
+ element.addEventListener('input', updateObserverFromInput.bind(null, element, attributeName, defaultValue, value));
88
88
  }
89
89
  value.subscribe(updateInputFromObserver.bind(null, element, attributeName));
90
90
  }
@@ -2,6 +2,7 @@ import Anchor from "../elements/anchor";
2
2
  import Validator from "../utils/validator";
3
3
  import AttributesWrapper from "./AttributesWrapper";
4
4
  import PluginsManager from "../utils/plugins-manager";
5
+ import validator from "../utils/validator";
5
6
 
6
7
  const $nodeCache = new Map();
7
8
  let $textNodeCache = null;
@@ -109,6 +110,9 @@ export const ElementCreator = {
109
110
  if(Validator.isNDElement(child)) {
110
111
  return child.$element ?? child.$build?.() ?? null;
111
112
  }
113
+ if(validator.$element) {
114
+ return validator.$element;
115
+ }
112
116
  if(Validator.isArray(child)) {
113
117
  const fragment = document.createDocumentFragment();
114
118
  for(let i = 0, length = child.length; i < length; i++) {