/*! * Reacton.js v3.4.3 * (c) 2022-2023 | github.com/reacton-js * Released under the MIT License. */ "use strict";!function(){const s=/[A-Z]/g,w=new WeakMap,r=document.implementation.createHTMLDocument(),v={get(e,t){return e.hasOwnProperty(t)?e[t].value:e[t]},set(e,t,n){return e[t].value=n,!0}},b=Symbol(),N=new Set,$=new A,o=new CustomEvent("init-event",{bubbles:!0,composed:!0});function a(p){const g=(p.mode||"").toLowerCase();var e=(p.extends||"").toLowerCase(),t=p.name.replace(s,(e,t)=>(0t.querySelector(e),d=e=>t.querySelectorAll(e);var u=new p(r);const h=new Proxy(u,{get:(e,t,n)=>{if(t===b)return this;n=Reflect.get(e,t,n);if(e.hasOwnProperty(t))return f.node&&(a[t]||(a[t]=new Set),a[t].add(f.node)),m._nodes=a[t],f.obsers.has(n)?f.obsers.get(n):n&&"object"==typeof n?x.call(this,n,m):n;switch(t){case"$state":return h;case"$props":return r;case"$refs":return i;case"$host":return l;case"$":return c;case"$$":return d}return"symbol"==typeof t||t in e?n:this[t]},set:(e,t,n,s)=>!!Reflect.set(e,t,n,s)&&(a[t]&&_.call(this,a[t],p),!0)}),f=(Object.defineProperties(this,{$state:{get(){if("closed"!==g)return h}},$props:{get(){if("closed"!==g)return r}},$refs:{get(){if("closed"!==g)return i}},$host:{get(){if("closed"!==g)return l}},$:{get(){if("closed"!==g)return c}},$$:{get(){if("closed"!==g)return d}},$light:{value:t===this||!1},$shadow:{value:this.shadowRoot},$event:{value:A},$route:{value:L}}),{root:t,funcs:e,obsers:n,bools:s,events:o,object:u,state:h,refs:i}),m=(w.set(this,f),f.exec=function(){return new Function(`{ ${E} } = this`,"return function() { with (this) return eval(arguments[0]) }.bind(this)").call(w.get(this).state)}.call(this),new y(p,n));(m[b]=this).addEventListener("init-event",e=>{N.delete(e.detail),0===N.size&&(e.stopPropagation(),A($,"ok"))})}async connectedCallback(){var e=w.get(this),t=document.createElement("template");"string"==typeof p.template||void 0===p.template?t.innerHTML=p.template||"":"function"==typeof p.template?t.innerHTML=await p.template.call(e.state)||"":p.template instanceof DocumentFragment&&t.content.append(p.template.cloneNode(!0)),f.call(this,t.content),e.root.append(t.content),await(!p.connected||p.connected.call(e.state)),setTimeout(()=>{(o.detail=this).dispatchEvent(o)},0)}async disconnectedCallback(){await(!p.disconnected||p.disconnected.call(w.get(this).state))}async adoptedCallback(){await(!p.adopted||p.adopted.call(w.get(this).state))}attributeChangedCallback(...e){setTimeout(()=>!p.changed||p.changed.apply(w.get(this).state,e),0)}static get observedAttributes(){if(Array.isArray(p.attributes))return p.attributes}$entities(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}},e?{extends:e}:null)}Object.defineProperty(o,"detail",{writable:!0});const i=new Set(["push","pop","shift","unshift","splice","sort","reverse"]);class y{constructor(e,t){this._init=e,this._obsers=t}deleteProperty(e,t){return Array.isArray(e)?e.splice(t,1):delete e[t],this._nodes&&_.call(this[b],this._nodes,this._init),!0}apply(e,t,n){return"toString"===e.name?JSON.stringify(t,null," "):i.has(e.name)?(e.apply(this._target,n),this._nodes&&_.call(this[b],this._nodes,this._init),t):e.apply(t,n)}get(e,t,n){this._target=e;n=Reflect.get(e,t,n);return this._obsers.has(n)?this._obsers.get(n):e.hasOwnProperty(t)?n&&"object"==typeof n?x.call(this[b],n,this):n:"toString"===t||Array.isArray(e)&&i.has(t)?x.call(this[b],n,this):n}set(e,t,n,s){return!!Reflect.set(e,t,n,s)&&(this._nodes&&_.call(this[b],this._nodes,this._init),!0)}}function x(e,t){t=new Proxy(e,t);return w.get(this).obsers.set(e,t),t}const d=/(['"`])[^]*?\1/,u=/;|\b(?:of)|(?:in)\b/,h=/\b[A-Za-z_]\w*?\b/g;const E="$state, $props, $refs, $host, $, $$, $light, $shadow, $event, $route, $entities";const e=/{{([^{}]*?)}}/;function f(n,s){if(8===n.nodeType)return n.remove();if(3===n.nodeType)n.data.trim()?(r=e.exec(n.data))&&(0===r.index?(o=(t=w.get(this)).exec("() => "+r[1]),n.splitText(r[0].length),t.funcs.set(n,o),s||((t.node=n).data=o(),delete t.node)):n.splitText(r.index)):-1!==n.data.indexOf("\n")?n.data="\n":n.data.length&&(n.data=" ");else{if(2===n.nodeType&&(":"===n.nodeName[0]||"$"===n.nodeName[0]||"#"===n.nodeName[0])){var o=w.get(this),a=n.ownerElement;if(a.removeAttribute(n.nodeName),"#"===n.nodeName[0])o.refs[n.nodeName.slice(1)]=a;else{if("$for"===n.nodeName){s||(o.node=a);const l=new DocumentFragment;for(;a.firstChild;)l.append(a.firstChild);var t=o.exec(`(function*() { arguments[0] = yield function() { return eval(arguments[0]) }; while (true) { yield; for (var ${n.value}) arguments[0]() } })()`),r=t.next().value.bind(this.$state);t.next(()=>function(t,n){if(n.owner.childNodes[n.index])for(let e=0;e ((${s}) => event => ${t})(${s})`),o.funcs.set(r,e),a.setAttributeNode(r),e._on=i):(e=o.exec("event => "+t),a["on"+r.name.slice(2)]=e),a.hasAttribute(":is")&&(o.events.has(a)||o.events.set(a,{}),o.events.get(a)[i]=e)}else{t=o.exec("() => "+n.value);if(o.funcs.set(r,t),"boolean"==typeof a[i])s?(a.setAttributeNode(r),t._name=i):t()?a.setAttributeNode(r):a.removeAttribute(i),a.hasAttribute(":is")&&(o.bools.has(a)||o.bools.set(a,{}),o.bools.get(a)[i]=t),t._owner=a;else if(s||(r.value=t()),a.setAttributeNode(r),"is"===r.name)if(s){i=document.createElement("template");i.content.append(...a.childNodes),t._childs=i.content}else{for(let e=0;ep.call(this,e,n.funcs.get(e))),t.after&&t.after.call(n.state)}const m=document.createElement("template");function p(t,e,n){if(e._on)t[e._on]=e();else if(e.iterator){var s=w.get(this),o=s.exec,a=(s.exec=e.executor,e.index=0,e.owner=t,e.iterator.next(),e.index);for(let e=t.childNodes.length;e>a;e--)t.lastChild.remove();s.exec=o}else if("is"===t.name){for(var s=e(),r=(t.value=s,t.ownerElement),i=(m.innerHTML=`<${r.nodeName} is="${s}" />`,m.content.firstElementChild);r.attributes.length;)i.setAttributeNode(r.removeAttributeNode(r.attributes[0]));var o=w.get(this),l=o.bools.get(r);if(l){for(const d in l)l[d]._owner=i;o.bools.delete(r),o.bools.set(i,l)}var c=o.events.get(n||r);if(c){for(const u in c)i[u]=n?c[u]():c[u];o.events.delete(r),o.events.set(i,c)}e._childs instanceof DocumentFragment?(s=e._childs.cloneNode(!0),f.call(this,s),i.append(s)):i.append(...e._childs),r.replaceWith(i)}else e._owner?e()?e._name?e._owner.setAttribute(e._name,""):e._owner.setAttributeNode(t):e._owner.removeAttribute(t.nodeName):t.nodeValue=e()}function g(t,n){var e,s=w.get(this).funcs.get(n);if(s&&(s._on&&t.ownerElement?((e=t.ownerElement).removeAttribute(s._on),t=e):s._owner&&(s._owner=t.ownerElement||t),p.call(this,t,s,n.ownerElement)),n.attributes)for(var o of n.attributes)g.call(this,t.attributes[o.name]||t,o);for(let e=0;e`(?<${t}>\\w+)`)}/?$`),document.addEventListener.call(this,...e)}getEventRegs(){return s}}}c.has(t)||(c.add(t),window.addEventListener("popstate",e=>{T(t,location.href.replace(location.origin,""),e.state)})),e&&(e=e.replace(location.origin,""),history.pushState(n,"",e),T(t,e,n))}function T(e,t,n){var s=e.getEventRegs();for(const r in s){var o,a=s[r].exec(t);a&&((o=new CustomEvent(r)).url=new URL(location.href),o.params=a.groups,e.dispatchEvent(o,n))}}function C(e,n,s=0){if(C.clean&&("STYLE"===e.nodeName||"SCRIPT"===e.nodeName||"TEMPLATE"===e.nodeName||8===e.nodeType))return!1;let t,o;if(e.$state){t=r.createElement(e.nodeName);for(const a of e.attributes)t.setAttribute(a.name,a.value)}else t=e.cloneNode(!1);n.append(t),"SLOT"===t.nodeName?(o=e.assignedNodes({flatten:!0}),C.slots.push(t)):o=(e.$shadow||e).childNodes;for(let e=0,t=0;es.removeChild(e).innerHTML).join(""),n=new Function("exports",t+` return exports`)()||class{};Object.defineProperties(n,{name:{value:n.name&&"exports"!==n.name?n.name:e.classList[0]},template:{value:s}}),a(n)}else"function"==typeof e&&a(e)}window.Reacton=(...e)=>e.forEach(t),window.Reacton.event=A,window.Reacton.route=L,window.Reacton.ssr=function({node:n,slots:s,clean:o=!0}={}){return new Promise(t=>$.addEventListener("ok",()=>{var e=document.createElement("template");C.clean=o,C.slots=[],C(n||document.children[0],e.content),s||C.slots.forEach(e=>e.replaceWith(...e.childNodes)),t(n?e.innerHTML:` `+e.innerHTML)}))}}();