@joker.front/core 1.3.87 → 1.3.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.es.js CHANGED
@@ -1 +1 @@
1
- import{EXPRESSHANDLERTAG as e,createFuntionBody as t,AST as n,RENDER_HANDLER as s,createComponent as i,createCommand as o}from"@joker.front/ast";export{AST,EXPRESSHANDLERTAG,RENDER_HANDLER,createCodeFunction,createCommand,createComment,createComponent,createElement,createFuntionBody,createText}from"@joker.front/ast";const r=new Map,a=new Map,h=new Map;let d={recordRender:(e,t)=>{a.set(e,t)},recordComponent:(e,t)=>{h.set(e,t)},record:(e,t)=>{void 0===r.get(e)&&r.set(e,new Set),r.get(e).add(t),t.$on("destroy",()=>{r.get(e)?.delete(t)})},reload:(e,t)=>{let n=h.get(e);if(!n)return;n.component=t;let s=r.get(e);if(!s)return;let i=Array.from(s);s.clear(),i.forEach(e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof z.Component&&t[z.PARSERKEY]&&t[z.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[z.PARSERKEY].reload()}}})},rerender:(e,t)=>{let n=a.get(e);n&&(n.render=t),r.get(e)?.forEach(e=>{e.$render(t)})}};function c(e){return null!==e&&"object"==typeof e}function l(e,t){Object.getOwnPropertyNames(e).forEach(n=>{t(n,e[n])})}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function f(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let n=Object.keys(e);for(let s of n){let n=e[s];t[s]="object"==typeof n?f(n):n}return t}function p(e,t,n){if(e===t)return!0;let s=c(e),i=c(t);if(s&&i){if(u(e)&&u(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let s of n)if(e[s]!==t[s])return!1;return!0}return e===t}return!s&&!i&&String(e)===String(t)}function m(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),e}function y(e,t){let n=e.findIndex(e=>t(e));return n>-1&&e.splice(n,1),e}function v(e){return!e||""===e.trim()}function g(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join(t)}let E=(...e)=>{},b="warn";const w=["silent","error","warn","info"];function N(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function $(e,t,n,s){w.indexOf(e)<=w.indexOf(b)&&(void 0===s?console[e](`${N()} [${t}]:`,n):console[e](`${N()} [${t}]:`,n,s))}let R=function(e,t,n){$("warn",e,t,n)},C=function(e,t,n){$("error",e,t,n)};const x={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function A(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,(e,t)=>x[t]||"")}class O{static target;watchers=new Map;depend(e){O.target?.addDep(this,e)}addWatcher(e,t){let n=this.watchers.get(e)||[];n.push(t),this.watchers.set(e,n)}removeWatcher(e,t){const n=this.watchers.get(e);n&&m(n,t)}notify(e){const t=this.watchers.get(e);if(t){y(t,e=>e.isDestroy);[...t].forEach(e=>{e.isDestroy||e.update()})}}}const S=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),P=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),T=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function D(e){try{return null!=e&&c(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof F==!1&&e instanceof Ue==!1&&e instanceof _e==!1&&(Array.isArray(e)||u(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(G in e)&&!(I in e)&&!(Ge in e)}catch{return!1}}function k(e){if(_(e))return e;if(e&&e.hasOwnProperty(P)){let t=Reflect.get(e,P);if(t)return t}let t=new O,n=!0,s=new Proxy(e,{get(e,n,s){if(e instanceof Set||e instanceof Map){if("add"===n){let s=Reflect.get(e,n);return n=>{D(n)&&(n=K(n));let i=s.call(e,n);return L(t,"size"),L(t,T),i}}if("set"===n){let s=Reflect.get(e,n);return(n,i)=>{D(i)&&(i=K(i));let o=s.call(e,n,i);return L(t,"size"),L(t,T),o}}if("delete"===n||"clear"===n){let s=Reflect.get(e,n);return i=>{let o=s.call(e,i);return("clear"===n||o)&&(L(t,"size"),L(t,T)),o}}let s=Reflect.get(e,n);if("function"==typeof s)return s.bind(e)}if(n===P)return;if(n===S)return t;if(n===T)return;let i=Reflect.get(e,n);return n===Symbol.toStringTag||!1===function(e,t){return t in e}(e,n)&&"length"!==n&&"size"!==n||(t.depend(n),D(i)&&_(i)?.depend(T)),i},set(e,s,i){if(n)return Reflect.set(e,s,i),!0;D(i)&&(i=K(i));let o=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,s),r=Reflect.get(e,s)!==i;return Reflect.set(e,s,i),(r||"length"===s&&Array.isArray(e))&&L(t,s),Array.isArray(e)?"length"===s&&L(t,T):o&&L(t,T),!0},deleteProperty:(e,n)=>(Reflect.deleteProperty(e,n),!1===Array.isArray(e)&&L(t,T),!0)});!function(e,t,n,s){Object.defineProperty(e,t,{value:n,enumerable:s,writable:!0,configurable:!0})}(e,P,s,!1);for(let t in e){let n=e[t];D(n)&&!_(n)&&(s[t]=k(e[t]))}return n=!1,s}function _(e){if(c(e))return Reflect.get(e,S)}function K(e,t=!1){if(!1===D(e))throw new Error("The provided data is not of the correct type. It must be an array or an object.");return k(t?f(e):e)}function W(e,t,n){let s=n;D(n)&&(s=K(n));let i=new O;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(i.depend(t),_(s)?.depend(T),s),set:e=>{e!==s&&(D(e)&&(e=K(e)),s=e,L(i,t))}})}const I=Symbol.for("JOKER_SHALLOW_OBSERVER");class V{data;[I]=!0;dep=new O;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(T),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,L(this.dep,T))}}let M=!1,j=new Map;function L(e,t){if(!1===M)e.notify(t);else{let n=j.get(e);void 0===n&&(n=[],j.set(e,n)),n.includes(t)||n.push(t)}}function Y(e){M=!0;try{e()}catch(e){return M=!1,j.clear(),void C("Data Hijacking","Encountered a blocking error while collecting changes for data hijacking composite responses. No action will be taken. Please investigate.",e)}M=!1,function(e){const t=[],n=[];e.forEach((e,n)=>{e.forEach(e=>{t.push(...n.watchers.get(e)||[])})}),t.forEach(e=>{n.includes(e)||(!e.isDestroy&&e.update(),n.push(e))})}(j),j.clear()}function B(e){return void 0!==_(e)}const H="Data Observation",J=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class F{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,n,s){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=s,void 0===e)throw new Error("Cannot observe changes on undefined");if(void 0===n)this.getter=e=>e;else if("function"==typeof n)this.getter=n;else{const e=function(e){if(/[^\w.$]/.test(e))return;const t=e.split(".");return function(e){let n=e;return t.forEach(e=>{n&&(n=n[e])}),n}}(n);if(void 0===e)throw new Error(`${n} failed to parse. Unable to interpret the expression. Please check the expOrFn parameter or use the function mode instead.`);this.getter=e}void 0===this.getter&&C(H,"Failed to create getter",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;O.target=this;const e="function"==typeof this.ob?this.ob():this.ob;let t;try{t=this.getter.call(e,e)}catch(e){throw C(H,"Failed to retrieve value. Executed method: "+this.getter.toString()),e}return O.target=void 0,this.clearnDeps(),t}addDep(e,t){let n=this.runRelations.get(e);if(void 0===n||!n.includes(t)){n=n||[],n.push(t),this.runRelations.set(e,n);const s=this.relations.get(e);void 0!==s&&s.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;const e=this.getValue();if(e===J)return;const t=this.value;if(this.forceCallBack||e!==t||c(e)){this.value=e;const n=e!==t&&function(e,t){return Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e,t):p(e,t)}(e,t);if(n&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,n,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach((e,t)=>{for(const n of e)t.removeWatcher(n,this)}),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0,this.updateCallBack=void 0}clearnDeps(){this.relations.forEach((e,t)=>{const n=this.runRelations.get(t);for(const s of e)n&&n.includes(s)||t.removeWatcher(s,this)}),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}var q;!function(e){let t=new Map;e.bind=function(e){return{to:n=>{if(t.has(e))throw new Error(`TagId:${e.toString()} already has an implementation bound. Do not bind again.`);t.set(e,n)}}},e.get=function(e,...n){const s=t.get(e);if(s)return new s(...n)}}(q||(q={}));const G=Symbol.for("JOKER_VNODE_TAG");var z;!function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[G]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let n=this.parent;for(;n;){if(!0===e(n))return n;if(!0===t?.(n))break;n=n.parent}}find(e,t,n,s,i){let o=i??[];if(s??=this.childrens,s)for(let i of s){(!0!==e(i)||(o.push(i),n))&&(!0!==t?.(i)&&i.childrens&&this.find(e,t,n,i.childrens,o))}return o}contains(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return!0;if(n.childrens&&n.childrens.length&&this.contains(e,n.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return n;if(n.childrens&&n.childrens.length){let t=this.first(e,n.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;scopedId;constructor(e,t,n){super(t),this.html=e,this.notShadow=n}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=n=>{for(let s of n){if(s instanceof e.Element)return s;if(s.childrens){let e=t(s.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],n=s=>{for(let i of s)i instanceof e.Element||i instanceof e.Html?t.push(i):i.childrens&&n(i.childrens)};return n(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(z||(z={}));const Q="DOM Rendering",U=["script","style","textarea","pre"];let X=0;const Z=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];var ee;function te(e,t,n){return`${e}-${t}-${n}`}function ne(e,t,n,s){e._assistEventCache??=[],e._assistEventCache.push([t,n]),document.body.addEventListener(t,n,s)}function se(e,t,n){e._assistEventCache&&t&&n?(y(e._assistEventCache,e=>e[0]===t&&e[1]===n),document.body.removeEventListener(t,n)):(e._assistEventCache?.forEach(e=>{document.body.removeEventListener(e[0],e[1])}),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}!function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof z.Component)if(e.parent)if(e.output){const t=e.output,n=he(e)||t.parentNode;n&&n.insertBefore(this.elements,t)}else C(Q,"Component mount found no DOM target node",e);else C(Q,"Mounting child component with no parent",e);else C(Q,"Mount only supports Element or VNode.Node",e)}appendNode(e,t){if(this.renderNode(e),e.output){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(const s of n)this.appendNodeChildren(e,s,e.parent,t);return}C(Q,"No output found for node, cannot mount",e)}updateNode(e,t){if(e instanceof z.Element)for(const t in e.attributes){const n=e.attributes[t];this.setAttribute(e.output,t,n)}else e instanceof z.Text?e.parent&&e.parent instanceof z.Element&&U.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=A(e.text||""):e instanceof z.Html?e.notShadow?(e.output.innerHTML=e.html,e.scopedId&&fe(e.output,e.scopedId)):e.output.root.innerHTML=e.html:C(Q,`Node does not support ${t} update`,e)}removeNode(e,t){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];n?.forEach(e=>e?.remove()),t||(e instanceof z.Element&&se(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,n,s){e.output&&this.transitionFrame(e,t,"enter",n,s)}elementToLeave(e,t,n,s){e.output&&this.transitionFrame(e,t,"leave",n,s)}triggerEvent(e,t,n){const s=[];for(const i of e.events){const[o,r]=i;if(o===t){const t=r.modifiers?.includes("self"),a=r.modifiers?.includes("outside");if(t||a){R(Q,"Event modifiers 'self' and 'outside' not supported in components",e);continue}const h=n.event;if((h instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(o)||h instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(o))&&!1===oe(h,r.modifiers))continue;if(r.callBack(n),r.modifiers?.includes("prevent")&&n.preventDefault(),r.modifiers?.includes("once")&&s.push(i),r.modifiers?.includes("stop"))return n.stopPropagation(),!1}}s.length&&s.forEach(t=>m(e.events,t))}transitionFrame(e,t,n,s,i){re(e,te(t,n,"from")),s||="transition";const o=e.output.__TRANSITION_EVNETID__=X++;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!e.output)return;re(e,te(t,n,"active")),ae(e,te(t,n,"from")),re(e,te(t,n,"to"));const r=function(e,t){const n=window.getComputedStyle(e),s=e=>(n[e]||"").split(", ");if("transition"===t){const e=s("transitionDelay"),t=s("transitionDuration"),n=de(e,t);if(n>0)return{timeout:n,count:t.length}}else if("animation"===t){const e=s("animationDelay"),t=s("animationDuration"),n=de(e,t);if(n>0)return{timeout:n,count:t.length}}}(e.output,s);if(!r)return void i?.();let a=0;const h=()=>{ae(e,te(t,n,"to")),ae(e,te(t,n,"active")),e.output&&(e.output.removeEventListener(`${s}end`,d),o===e.output.__TRANSITION_EVNETID__&&i?.())},d=t=>{t.target===e.output&&++a>=r.count&&h()};setTimeout(()=>{a<r.count&&h()},r.timeout+1),e.output?.addEventListener(`${s}end`,d)})})}renderNode(e){if(!e.output)if(e instanceof z.Text)e.parent&&e.parent instanceof z.Element&&U.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(A(e.text||""));else if(e instanceof z.Html)if(e.notShadow){const t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.scopedId&&(t.setAttribute("data-scoped-"+e.scopedId,""),fe(t,e.scopedId)),e.output=t}else{const t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof z.Element){let t;const n=e.tagName.toLowerCase();"svg"===n||Z.includes(n)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(const n in e.attributes)this.setAttribute(t,n,e.attributes[n]);t.JOKER_NODE=e,e.output=t,e.events.some(e=>"click"===e[0]&&e[1].modifiers?.includes("outside"))?setTimeout(()=>{this.initElementEvents(t,e)}):this.initElementEvents(t,e)}else e instanceof z.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(const[n,s]of t.events){const i=s.modifiers?.includes("self");let o=s.modifiers?.includes("outside");i&&o&&(R(Q,"Event modifiers 'self' and 'outside' cannot coexist, using 'self'",t),o=!1);const r=a=>{if(!(t.sleep||i&&a.target!==e)){if(o){if(a.target===e||e.contains(a.target))return;if(!1===document.contains(a.target))return;if(t.contains(e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(a.target)))return!0}(a instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(n)||a instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(n))&&!1===oe(a,s.modifiers)||(s.callBack({eventName:n,event:a,target:t,preventDefault:()=>a.preventDefault(),stopPropagation:()=>a.stopPropagation(),data:void 0}),s.modifiers?.includes("prevent")&&a.preventDefault(),s.modifiers?.includes("stop")&&a.stopPropagation(),s.modifiers?.includes("once")&&(o?se(t,n,r):e.removeEventListener(n,r)))}};let a;s.modifiers?.includes("passive")&&(a={passive:!0}),o?ne(t,n,r,a):e.addEventListener(n,r,a)}}parserHtml(e){const t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof z.Component||e instanceof z.Condition||e instanceof z.List||e instanceof z.ListItem||e instanceof z.RenderSection}appendNodeChildren(e,t,n,s){let i=he(e);if(i)i.appendChild(t);else if(void 0===n)this.elements?.appendChild(t);else if(n)if(n instanceof z.Root){const e=n.parent;if(e&&e instanceof z.Component&&e.output){const n=e.output,s=n?.parentNode;if(s)return void s.insertBefore(t,n)}this.elements?.appendChild(t)}else if(n instanceof z.Element){const e=n.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(n)){const i=n.output?.parentNode;if(void 0!==s&&n.childrens?.length&&i){const o=s-1;if(o<0){const n=le(e);return void(n&&i.contains(n.output)?n.output.after(t):i.insertBefore(t,i.firstChild))}{const e=n.childrens[o];if(e){const n=e.output;if(n)return void n.after(t)}}}i&&i.insertBefore(t,n.output)}else C(Q,"Node does not support nested children",{node:e,parent:n})}setAttribute(e,t,n){if(e)if("boolean"!=typeof n){if("class"===t){if(n){n=pe(n).join(" ")}}else if("style"===t&&c(n)){e.removeAttribute("style");for(const t in n){let s=!1;void 0!==n[t]&&!1!==n[t]||(s=!0);const i=String(n[t]);v(i)&&(s=!0),s||(e.style[t]=i)}return}n=(n??"").toString().trim(),"class"===t&&(n=n.split(/\s/).filter(e=>e.trim()).join(" ")),"value"===t&&"value"in e?e.value=n:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n):e.setAttribute(t,n)}else n?e.setAttribute(t,""):e.removeAttribute(t)}}}(ee||(ee={}));const ie={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function oe(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(const n in ie)if(t?.includes(ie[n])&&e.key.toLowerCase()!==n)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function re(e,t){e.output&&e.output.classList.add(t)}function ae(e,t){e.output&&e.output.classList.remove(t)}function he(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof z.Element)return t.output;if("string"==typeof t){ee.ROOT_CONTAINER&&(t="body"===t?ee.ROOT_CONTAINER:`${ee.ROOT_CONTAINER} ${t}`);const e=document.querySelector(t);if(e)return e}R(Q,"Unsupported appendTo type",{appendTo:t,node:e})}}}function de(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map((t,n)=>ce(t)+ce(e[n])))}function ce(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function le(e,t){let n=e.prev;for(;n;){if(n instanceof z.ListItem==!1)return n;n=n.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof z.Element)return;const e=le(t,!0);if(e)return e;t=t.parent}}}class ue extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}function fe(e,t){const n=e.childNodes;for(let e=0;e<n.length;e++){const s=n[e];if(1===s.nodeType){const e=s;e.setAttribute("data-scoped-"+t,""),fe(e,t)}}}function pe(e,t){const n=t||[];if("string"==typeof e){const t=e.trim();t&&!n.includes(t)&&n.push(t)}else Array.isArray(e)?e.forEach(e=>pe(e,n)):null!==e&&"object"==typeof e&&Object.entries(e).forEach(([e,t])=>{if(t){const t=e.trim();t&&!n.includes(t)&&n.push(t)}});return n}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",ue);const me={};function ye(e){for(const t in e)me[t]=e[t]}const ve="Global",ge="Render Core";function Ee(t,n){try{return new Function(e,ve,`return ${t};`)}catch(e){throw new Error(`An unknown error occurred while creating the expression execution method. \nmessage: ${e.message} \n${n?.()||t}`)}}class be{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,n,s){this.ast=e,this.ob=t,this.parent=n,this.ext=s}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(!this.isDestroy)if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof z.Element||this.node instanceof z.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&m(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,()=>{t()}))return m(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[z.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0,this.ast=void 0,this.ob=void 0,this.ext=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):m(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[z.PARSERKEY]&&(t[z.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[z.PARSERKEY]=this,this.node instanceof z.Element&&this.ob[qe]?this.node.attributes["data-scoped-"+this.ob[qe]]=void 0:this.node instanceof z.Html&&this.ob[qe]&&(this.node.scopedId=this.ob[qe]),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t,n){try{return Ee(e,n).call(t,t,me)}catch(s){C(ge,`Expression error:${s.message}\n`+(n?.()||e),{ob:t}),console.error(s)}}runExpressWithWatcher(e,t,n,s,i){if(this.isDestroy)return;let o="string"==typeof e?Ee(e,i):e,r=new F(()=>{if(this.isDestroy||t[Je])return J;try{return o.call(t,t,me)}catch(n){return C(ge,`Expression error:${n.message}\n${i?.()||e}`,{ob:t,express:e,node:this.node}),console.error(n),J}},n,void 0,s);return this.addWatch(r),r.value===J?void 0:r.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach(e=>{e.destroy()}),this.watchers.length=0}}class we extends be{parser(){this.node=new z.Text(this.ast.text,this.parent),this.appendNode()}}class Ne extends be{parser(){this.node=new z.Comment(this.ast.text,this.parent),this.appendNode()}}class $e extends be{parser(){if(this.node=new z.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){v(this.ast.condition)&&C("Conditional Command",`The current conditional command ${this.ast.kind} has no judgment condition, please check`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[z.PARSERKEY];t&&t instanceof $e&&t.renderConditionChildren()}}this.reloadAllCondition()}},!1,()=>this.ast._code);this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob,()=>{this.ast._code}),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof z.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof $e&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof $e&&t.renderConditionChildren(),e=e.next}}}class Re extends be{parser(){this.node=new z.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,n=Object.create(this.ob),s=!!this.runExpressWithWatcher(function(t,n,s){try{return new Function(e,`${e}.${t}=${n}; return ${s};`)}catch{throw new Error(`Dependency collection for the For loop command expression execution encountered an unknown error. Details: letKey: ${t}, keyVal: ${n}, condition: ${s}`)}}(t.letKey,t.defaultKeyVal,t.condition),n,()=>{this.clearWatchers(),this.renderChildrens()},!0,()=>this.ast._code),i=0;for(;s;){let e=Object.create(this.ob);W(e,t.letKey,n[t.letKey]);let o=i++;this.renderItem(e,o),this.runExpressWithWatcher(()=>n[t.letKey],n,async(n,s,i,r)=>{await Promise.resolve(),r.isDestroy||(e[t.letKey]=n,i||this.updateListItemOb(e,o))},!0,()=>this.ast._code),this.runExpress(t.step,n,()=>{this.ast._code}),s=!!this.runExpress(t.condition,n,()=>this.ast._code)}this.destroyOldChildrens(i)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,()=>{this.clearWatchers(),this.renderChildrens()},!1,()=>this.ast._code),n=0;if(t&&(Array.isArray(t)||u(t)))for(let s in t){let i=Object.create(this.ob),o=Array.isArray(t)?Number(s):s;e.indexKey&&W(i,e.indexKey,o),e.itemKey&&W(i,e.itemKey,t[s]);let r=n++;this.renderItem(i,r,e.indexKey),e.itemKey&&this.runExpressWithWatcher(()=>t[o],t,async(n,s,a,h)=>{await Promise.resolve(),h.isDestroy||o in t&&(i[e.itemKey]=n,a||this.updateListItemOb(i,r))},!0,()=>this.ast._code)}this.destroyOldChildrens(n)}findIndexByIndex(e,t,n){let s=-1;if(this.node)for(let i=t;i<this.node.childrens.length;i++)if(this.checkObEqual(e,this.node.childrens[i]?.ob,n?[n]:void 0)){s=i;break}return s}renderItem(e,t,n){if(!this.ast.childrens?.length||!this.node)return;let s=this.node.childrens?.[t];if(s){if(this.checkObEqual(e,s.ob,n?[n]:void 0))return void(n&&s.ob[n]!==e[n]&&(s.ob[n]=e[n]));let i=this.findIndexByIndex(e,t+1,n);if(i>-1){if(t+1===i)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();else for(let e=0;e<i-t-1;e++)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();return this.renderItem(e,t,n)}return new Ce(this.ast,e,this.node,this.ext).init(t)}return new Ce(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let n=this.node.childrens?.[t];l(e,(e,t)=>{n.ob[e]!==t&&(n.ob[e]=t)})}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[z.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,n){let s=!0;return void 0!==t&&(l(e,(e,i)=>{n?.includes(e)||t?.[e]===i||(s=!1)}),s)}}class Ce extends be{parser(e){this.node=new z.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class xe extends be{parser(){if(v(this.ast.cmdName))throw C("Template Directive","Error occurred while converting AST to VNode: Directive name not found",this.ast),new Error("Error converting AST to VNode: Directive name not found");let e;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?e=this.ast.param:this.ast.cmdName.startsWith(ve+".")?e=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(e=`${t(this.ast.cmdName)}(${this.ast.param})`),e){let t=this.runExpressWithWatcher(`[${e}]`,this.ob,e=>{this.changeValue(e?.[0])},!1,()=>this.ast._code);return t||=[],"Html"===this.ast.cmdName?this.node=new z.Html(Ae(t[0]),this.parent,t[1]):this.node=new z.Text(Ae(t[0]),this.parent),void this.appendNode()}throw new Error("Command not found: "+this.ast.cmdName)}changeValue(e){this.node&&(this.node instanceof z.Html?this.node.html=Ae(e):this.node.text=Ae(e),this.ext.render?.updateNode(this.node))}}function Ae(e){return null==e||"function"==typeof e?"":e.toString()}const Oe="default";class Se extends be{parser(){let e=this.transformParam();this.node=new z.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach((e,t)=>{W(this.node.ob,e,this.node.params[t])})):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,e=>{let t=e?.[0]||Oe;if("string"==typeof t&&t!==this.node.id)throw new Error("The section ID cannot be dynamically changed");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])})},!0,()=>this.ast._code);return{id:e?.[0]||Oe,params:e?.slice(1)||[]}}return{id:Oe,params:[]}}}const Pe="Component Parsing";function Te(e,t){return!!t.components[e]||!!et(e)}class De extends be{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new z.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally(()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)})}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):R(Pe,"Reload operation is not supported for the current component",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)},!0,()=>{if(e.value)return`express:${e.value} \nfrom <${"tagName"in this.ast?this.ast.tagName:"Component"} ${e.name}="${e.value}" ... /> `});this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(v(e.value)){R(Pe,"The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=K(this.node.propValues)}initEvent(){this.ast.events.forEach(e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:E}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code} \nfrom: <${"tagName"in this.ast?this.ast.tagName:"Component"} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t.call(this.ext.ob,n,...s)}}]):C(Pe,`The callback method (${e.functionName}) specified for the ${e.name} event in the ${"tagName"in this.ast?this.ast.tagName:""} element was not found. Please check.`)})}async renderChildren(){return new Promise(async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||et(this.ast.tagName);if(void 0===e)return void C(Pe,`Failed to render component. Private or global component named '${this.ast.tagName}' not found.`);if(Ge in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let n=this,s=function(){n.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",()=>{this.node?.component.$off("beforeDestroy",s),e(void 0)}),this.node.component.$on("beforeDestroy",s),this.node.component.$mount(this.node),!this.node)return;let i=this.node?.component;i.isKeepAlive&&(this.ast.node=this.node)})}getSections(){let t={},s=[];return this.ast.childrens.forEach(t=>{if(t.type===n.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let i=t,o=t.childrens.some(e=>e.type===n.NodeType.COMMAND&&"section"===e.cmdName),r=i.condition.startsWith(e+".$sections");if(r){return this.runExpress(i.condition,this.ob,()=>i._code)?void s.push(...t.childrens):void 0}if(o&&"if"===i.kind&&!r)return void R(Pe,"While parsing the section, it was found that this section is wrapped in a conditional statement. This conditional statement only supports if judgments using $sections. It has been excluded.")}s.push(t)}),s.forEach(e=>{if(e.type===n.NodeType.COMMAND&&"section"===e.cmdName){let n=e,s=n.id||Oe;/^(\'|\")(.*?)((\'|\"))$/.test(s)&&(s=s.slice(1,-1)),t[s]=t[s]||{asts:[],ob:this.ob,params:n.paramKeys,parser:this.ext},t[s].asts.push(...e.childrens||[])}else t[Oe]=t[Oe]||{asts:[],ob:this.ob,parser:this.ext},t[Oe].asts.push(e)}),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0)}}class ke extends be{parser(){this.node=new z.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},n=this.runExpressWithWatcher(e.express,this.ob,e=>{t(e)},!1,()=>{if(e.value)return`express:${e.value} \nfrom <${this.ast.tagName} ${e.name}="${e.value}" ... /> `});this.node.attributes[e.name]=this.transformAttrVal(n)}else this.node.attributes[e.name]=e.value;else{if(v(e.value)){R("Element","The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`The callback method (${e.functionName}) specified for the ${e.name} event in the ${this.ast.tagName} element was not found. Please check.`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{if(void 0===t)return;let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code}\nfrom <${this.ast.tagName} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t&&t.call(this.ext.ob,n,...s)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class _e{asts;ob;root=new z.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,n){this.asts=e,this.ob=t,this.root.component=t,this.render=q.get(ee.IRENDERIOCTAGID)??new ee.DomRender,n&&n instanceof z.Node&&(this.root.parent=n,n.childrens??=[],n.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(e,t,s){if(0!==this.asts.length)for(let i of e)if(i.type===n.NodeType.TEXT)new we(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.COMMENT)new Ne(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.COMPONENT)new De(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.ELEMENT){let e=i;Te(e.tagName,s??this.ob)?new De(e,s??this.ob,t,this).init():new ke(e,s??this.ob,t,this).init()}else if(i.type===n.NodeType.COMMAND){let e=i;switch(e.cmdName){case"if":case"elseif":case"else":new $e(e,s??this.ob,t,this).init();break;case"for":new Re(e,s??this.ob,t,this).init();break;case"RenderSection":new Se(e,s??this.ob,t,this).init();break;case"section":break;default:new xe(e,s??this.ob,t,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&m(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){m(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,n,s){this.nodeWatcherEvents[e]?.forEach(e=>{e(t,n,s)})}sleep(e){let t=e||this.root;t.childrens?.forEach(e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,()=>{t()})||t()}),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach(e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")}),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):m(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[z.PARSERKEY]&&e[z.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=q.get(ee.IRENDERIOCTAGID)??new ee.DomRender,this.asts=e}nodeTransition(e,t,n,s,i){if(e&&e.parent?.childrens&&(e instanceof z.Element||e instanceof z.Component)){let o=function(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(n??=o?.name,i??=o?.type,!n)return!1;let r=Ke(e);if(r)return"enter"===t?this.render.elementToEnter(r,n,i,()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),s?.()}):this.render.elementToLeave(r,n,i,()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),s?.()}),!0;R("Render Core","Incomplete data found when executing node animation, please check")}return!1}}function Ke(e){if(e instanceof z.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof z.Element?t:Ke(t)}function We(e,t,n){if(void 0===t)return;const s=Array.isArray(n)?n:[n];for(const e of s){if(e===Array&&Array.isArray(t))return t;if(typeof t===e.name.toLowerCase())return t}switch(s[0]){case Number:const e=Number(t);if(!isNaN(e))return e;break;case String:return String(t)}throw new Error(`The type of ${e.toString()} in props does not match the constrained type`)}function Ie(e,t,n){let s,i,o;if("symbol"!=typeof t&&(s=g(t)),t in e?i=e[t]:s&&(i=e[s]),n&&(t in n?o=n[t]:s&&s in n&&(o=n[s])),void 0!==o){if(u(o)&&("type"in o||"required"in o||"default"in o||"validate"in o)){const e=o;if(e.required&&void 0===i)throw new Error(`props key:${t.toString()} is required, please check`);if(e.type&&(i=We(t,i,e.type)),e.validate&&!1===e.validate(i))throw new Error(`Validation failed for props key ${t.toString()}`);i=i??e.default}else i=Ve(o)?We(t,i,o):i??o;return i}return i}function Ve(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||!!Array.isArray(e)&&Ve(e[0])}function Me(e,t){if(!e.constructor)return!1;let n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return n&&n.get}const je="Component",Le=Symbol.for("JOKER_PROPS_DATA_KEY"),Ye=Symbol.for("JOKER_PROPS_DATA_PROXY"),Be=Symbol.for("JOKER_PRIVATE_WATCHERS"),He=Symbol.for("JOKER_EVENT_DATA_KEY"),Je=Symbol.for("JOKER_IS_DESTROY"),Fe=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),qe=Symbol.for("JOKER_SCOPE_ID"),Ge=Symbol.for("JOKER_COMPONENT_TAG"),ze=Symbol();let Qe=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class Ue{$sections;isKeepAlive;static[Ge]=!0;[qe];model={};template;$root;isSleeped=!1;components={};propsOption;[Le]={};[Fe];[Ye];[Be]=[];[He]=new Map;[Je]=!1;[ze]=!1;constructor(e,t={},n){this.$sections=t,this.isKeepAlive=n,this[Le]=e||{}}get props(){if(void 0===this[Ye]){let e=this;this[Ye]=new Proxy(e[Le],{get:(t,n)=>Ie(e[Le],n,e.propsOption),set(){throw new Error("props parameters are not allowed to be changed, only one-way data transfer is allowed")}})}return this[Ye]}$mount(e){if(!1===this[ze]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach(n=>{!1!==Qe.includes(n)||Me(t,n)||"function"!=typeof t[n]||t[n].prototype?.hasOwnProperty("constructor")||e.push(n)}),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[ze]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[Fe]&&this.$root?(this[Fe].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&nt(this.$rootVNode),this):(C(je,"When attempting to wake up the current component, it was found that the rendering handler has been destroyed. The wake-up operation cannot proceed.",[this,this.$root]),this);this.isSleeped=!1,this.model=K(this.model);let t=this.created(),n=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[Je]||(await this.mounted(),this[Je]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then(()=>{this[Je]||n()}):n(),this}$nextUpdatedRender(e){if(this[Je])return;let t=[...this[Fe]?.promiseQueue||[]],n=this.$rootVNode?.find(e=>e instanceof z.Component);if(n?.forEach(e=>{e?.component&&t.push(...e.component[Fe]?.promiseQueue||[])}),t.length)return Promise.all(t).finally(()=>{this[Je]||e?.()});this[Je]||e?.()}$nodeTransition(e,t,n,s,i){if(this.$root&&!this[Je]){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void R(je,`Node with ref=${e} not found when executing node animation`);e=t}this[Fe]?.nodeTransition(e,t,n,s,i)}}$destroy(e){if(!e&&this.isKeepAlive)return this[Fe]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&tt(this.$rootVNode));this[Je]=!0;for(let e of this[Be])e.destroy();this[Be].length=0,this[Fe]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[Fe]?.destroy(),this[Fe]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[He].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[Ye]=void 0,this[Le]={},this.destroyed()}get $refs(){return this[Fe]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,n){"function"==typeof t&&(n=t,t=void 0),t??=e,n??=e=>e,this.model[t]=n(this.props[e]),this.$watch(()=>this.props[e],()=>{this.model[t]=n?.(this.props[e])})}get $rootVNode(){return this[Fe]?.root}$watchNode(e,t){if(this[Fe])return this[Fe]?.addNodeWatcher(e,t),()=>{this[Fe]?.removeNodeWatcher(e,t)};R(je,"Component is not yet mounted. Node observation and monitoring cannot be performed.")}$watch(e,t,n){let s=new F(()=>{if(this[Je]){for(let e of this[Be])e.destroy();return J}return e()},(e,n)=>{this[Je]||t(e,n)},void 0,n);return this[Be].push(s),[s.value,()=>{s.destroy(),m(this[Be],s)}]}$on(e,t){let n=this[He].get(e);void 0===n&&(n=new Set,this[He].set(e,n)),!1===n?.has(t)&&n.add(t)}$off(e,t){let n=this[He].get(e);n&&(t?n.delete(t):n.clear())}get $listeners(){let e={};for(let t in this[He])e[t]||=[],e[t].push(...Array.from(this[He].get(t)||[]));if(this.$root&&this.$root instanceof z.Component)for(let t of this.$root.events){let n=t[0];e[n]||=[],e[n].push(t[1].callBack)}return e}$trigger(e,t,n){if(!this.$root)return;let s={eventName:e,stopPropagation:n?.stopPropagation??(()=>{}),preventDefault:n?.preventDefault??(()=>{}),data:t,target:n?.target??this.$rootVNode,event:n?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof z.Component&&!1===this[Fe]?.render.triggerEvent(this.$rootVNode.parent,e,s))return;let i=this[He].get(e);i?.size&&[...i].forEach(e=>{e(s)});let o=this[He].get("*");o?.size&&[...o].forEach(e=>{e(s)})}$render(e,t){e??=this.template,this.template="function"==typeof e?e(s):e,this.$root&&(this.template??=[],this[Fe]?.reSetAsts(this.template,t),this[Fe]??=new _e(this.template,this,this.$root),this[Fe].parser(),this.$root&&this[Fe].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Xe={};function Ze(e,t){if("string"==typeof e)t&&(Xe[e]=t);else for(let t in e)Xe[t]=e[t]}function et(e){return Xe[e]}function tt(e){e.childrens?.forEach(e=>{e instanceof z.Component&&e.component?.sleeped(),tt(e)})}function nt(e){e.childrens?.forEach(e=>{e instanceof z.Component&&e.component?.wakeup(),nt(e)})}class st extends Ue{template=[];cache=new Map;async mounted(){this.$watch(()=>this.props.name,async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)}),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach(t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch(()=>this.props[t],()=>{this.propsVaule[t]=this.props[t]}))}),this.propsVaule=K(e))}filterProps(e){if("string"!=typeof e)return!1;let t=g(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(e){if(!e)return void this.$render([],this.isKeepAlive);let t;if(this.isKeepAlive){let t=this.cache.get(e);if(t)return void this.$render([i(t,{"transition-name":this.props["transition-name"]})],!0)}let n=this.$rootVNode?.parent?.[z.PARSERKEY]?.ob.components,s=n?.[e];void 0===s&&(s=et(e)),s?(Ge in s||(s=(await s()).default),t=new s(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),t.$on("*",e=>{this.$trigger(e.eventName,e.data,e)}),this.isKeepAlive&&this.cache.set(e,t),this.$render([i(t,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):R("component",`Component ${e} not found`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach(e=>{e.$destroy(!0)}),this.cache.clear()}}class it extends Ue{template=function(){return[o("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}Ze({template:it,component:st});class ot{eventDatas=new Map;on(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const s={callBack:t};return n.push(s),()=>{n&&m(n,s)}}once(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const s={callBack:t,once:!0};return n.push(s),()=>{n&&m(n,s)}}off(e,t){if(void 0!==e)if(t){const n=this.eventDatas.get(e),s=n?.find(e=>e.callBack===t);s&&m(n,s)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let n=[...this.eventDatas.get(e)||[]];if(n.push(...this.eventDatas.get("*")||[]),n&&n.length){let s=0,i=0,o=!1;for(;n[s];){const r=n[s],a=await r.callBack({stopPropagation:()=>o=!0,callTimes:i,eventName:e},t);if(r.once?m(n,r):s++,!1===a||o)return!1}}}}export{J as BREAK_WATCH_UPDATE,Ue as Component,st as ComponentContainer,O as Dep,ot as EventBus,q as IContainer,Je as IS_DESTROY,Ge as JOKER_COMPONENT_TAG,G as JOKER_VNODE_TAG,S as OBJECTPROXY_DEPID,Fe as PARSER_TEMPLATE_TARGET,_e as ParserTemplate,ee as Render,qe as SCOPE_ID,V as ShallowObserver,it as Template,z as VNode,F as Watcher,me as __GLONAL_FUNTIONS__,d as __JOKER_HMR_RUNTIME,Y as combinedReply,W as defineObserverProperty,et as getGlobalComponent,B as isObserverData,K as observer,Ze as registerGlobalComponent,ye as registerGlobalFunction};
1
+ import{EXPRESSHANDLERTAG as e,createFuntionBody as t,AST as n,RENDER_HANDLER as s,createComponent as i,createCommand as o}from"@joker.front/ast";export{AST,EXPRESSHANDLERTAG,RENDER_HANDLER,createCodeFunction,createCommand,createComment,createComponent,createElement,createFuntionBody,createText}from"@joker.front/ast";const r=new Map,a=new Map,h=new Map;let d={recordRender:(e,t)=>{a.set(e,t)},recordComponent:(e,t)=>{h.set(e,t)},record:(e,t)=>{void 0===r.get(e)&&r.set(e,new Set),r.get(e).add(t),t.$on("destroy",()=>{r.get(e)?.delete(t)})},reload:(e,t)=>{let n=h.get(e);if(!n)return;n.component=t;let s=r.get(e);if(!s)return;let i=Array.from(s);s.clear(),i.forEach(e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof z.Component&&t[z.PARSERKEY]&&t[z.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[z.PARSERKEY].reload()}}})},rerender:(e,t)=>{let n=a.get(e);n&&(n.render=t),r.get(e)?.forEach(e=>{e.$render(t)})}};function c(e){return null!==e&&"object"==typeof e}function l(e,t){Object.getOwnPropertyNames(e).forEach(n=>{t(n,e[n])})}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}function f(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let n=Object.keys(e);for(let s of n){let n=e[s];t[s]="object"==typeof n?f(n):n}return t}function p(e,t,n){if(e===t)return!0;let s=c(e),i=c(t);if(s&&i){if(u(e)&&u(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let s of n)if(e[s]!==t[s])return!1;return!0}return e===t}return!s&&!i&&String(e)===String(t)}function m(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),e}function y(e,t){let n=e.findIndex(e=>t(e));return n>-1&&e.splice(n,1),e}function v(e){return!e||""===e.trim()}function g(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join(t)}let E=(...e)=>{},b="warn";const w=["silent","error","warn","info"];function N(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function $(e,t,n,s){w.indexOf(e)<=w.indexOf(b)&&(void 0===s?console[e](`${N()} [${t}]:`,n):console[e](`${N()} [${t}]:`,n,s))}let R=function(e,t,n){$("warn",e,t,n)},C=function(e,t,n){$("error",e,t,n)};const x={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function A(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,(e,t)=>x[t]||"")}class O{static target;watchers=new Map;depend(e){O.target?.addDep(this,e)}addWatcher(e,t){let n=this.watchers.get(e)||[];n.push(t),this.watchers.set(e,n)}removeWatcher(e,t){const n=this.watchers.get(e);n&&m(n,t)}notify(e){const t=this.watchers.get(e);if(t){y(t,e=>e.isDestroy);[...t].forEach(e=>{e.isDestroy||e.update()})}}}const S=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),P=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),T=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function D(e){try{return null!=e&&c(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof F==!1&&e instanceof Ue==!1&&e instanceof _e==!1&&(Array.isArray(e)||u(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(G in e)&&!(I in e)&&!(Ge in e)}catch{return!1}}function k(e){if(_(e))return e;if(e&&e.hasOwnProperty(P)){let t=Reflect.get(e,P);if(t)return t}let t=new O,n=!0,s=new Proxy(e,{get(e,n,s){if(e instanceof Set||e instanceof Map){if("add"===n){let s=Reflect.get(e,n);return n=>{D(n)&&(n=K(n));let i=s.call(e,n);return L(t,"size"),L(t,T),i}}if("set"===n){let s=Reflect.get(e,n);return(n,i)=>{D(i)&&(i=K(i));let o=s.call(e,n,i);return L(t,"size"),L(t,T),o}}if("delete"===n||"clear"===n){let s=Reflect.get(e,n);return i=>{let o=s.call(e,i);return("clear"===n||o)&&(L(t,"size"),L(t,T)),o}}let s=Reflect.get(e,n);if("function"==typeof s)return s.bind(e)}if(n===P)return;if(n===S)return t;if(n===T)return;let i=Reflect.get(e,n);return n===Symbol.toStringTag||!1===function(e,t){return t in e}(e,n)&&"length"!==n&&"size"!==n||(t.depend(n),D(i)&&_(i)?.depend(T)),i},set(e,s,i){if(n)return Reflect.set(e,s,i),!0;D(i)&&(i=K(i));let o=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,s),r=Reflect.get(e,s)!==i;return Reflect.set(e,s,i),(r||"length"===s&&Array.isArray(e))&&L(t,s),Array.isArray(e)?"length"===s&&L(t,T):o&&L(t,T),!0},deleteProperty:(e,n)=>(Reflect.deleteProperty(e,n),!1===Array.isArray(e)&&L(t,T),!0)});!function(e,t,n,s){Object.defineProperty(e,t,{value:n,enumerable:s,writable:!0,configurable:!0})}(e,P,s,!1);for(let t in e){let n=e[t];D(n)&&!_(n)&&(s[t]=k(e[t]))}return n=!1,s}function _(e){if(c(e))return Reflect.get(e,S)}function K(e,t=!1){if(!1===D(e))throw new Error("The provided data is not of the correct type. It must be an array or an object.");return k(t?f(e):e)}function W(e,t,n){let s=n;D(n)&&(s=K(n));let i=new O;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(i.depend(t),_(s)?.depend(T),s),set:e=>{e!==s&&(D(e)&&(e=K(e)),s=e,L(i,t))}})}const I=Symbol.for("JOKER_SHALLOW_OBSERVER");class V{data;[I]=!0;dep=new O;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(T),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,L(this.dep,T))}}let M=!1,j=new Map;function L(e,t){if(!1===M)e.notify(t);else{let n=j.get(e);void 0===n&&(n=[],j.set(e,n)),n.includes(t)||n.push(t)}}function Y(e){M=!0;try{e()}catch(e){return M=!1,j.clear(),void C("Data Hijacking","Encountered a blocking error while collecting changes for data hijacking composite responses. No action will be taken. Please investigate.",e)}M=!1,function(e){const t=[],n=[];e.forEach((e,n)=>{e.forEach(e=>{t.push(...n.watchers.get(e)||[])})}),t.forEach(e=>{n.includes(e)||(!e.isDestroy&&e.update(),n.push(e))})}(j),j.clear()}function B(e){return void 0!==_(e)}const H="Data Observation",J=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class F{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,n,s){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=s,void 0===e)throw new Error("Cannot observe changes on undefined");if(void 0===n)this.getter=e=>e;else if("function"==typeof n)this.getter=n;else{const e=function(e){if(/[^\w.$]/.test(e))return;const t=e.split(".");return function(e){let n=e;return t.forEach(e=>{n&&(n=n[e])}),n}}(n);if(void 0===e)throw new Error(`${n} failed to parse. Unable to interpret the expression. Please check the expOrFn parameter or use the function mode instead.`);this.getter=e}void 0===this.getter&&C(H,"Failed to create getter",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;O.target=this;const e="function"==typeof this.ob?this.ob():this.ob;let t;try{t=this.getter.call(e,e)}catch(e){throw C(H,"Failed to retrieve value. Executed method: "+this.getter.toString()),e}return O.target=void 0,this.clearnDeps(),t}addDep(e,t){let n=this.runRelations.get(e);if(void 0===n||!n.includes(t)){n=n||[],n.push(t),this.runRelations.set(e,n);const s=this.relations.get(e);void 0!==s&&s.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;const e=this.getValue();if(e===J)return;const t=this.value;if(this.forceCallBack||e!==t||c(e)){this.value=e;const n=e!==t&&function(e,t){return Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e,t):p(e,t)}(e,t);if(n&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,n,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach((e,t)=>{for(const n of e)t.removeWatcher(n,this)}),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0,this.updateCallBack=void 0}clearnDeps(){this.relations.forEach((e,t)=>{const n=this.runRelations.get(t);for(const s of e)n&&n.includes(s)||t.removeWatcher(s,this)}),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}var q;!function(e){let t=new Map;e.bind=function(e){return{to:n=>{if(t.has(e))throw new Error(`TagId:${e.toString()} already has an implementation bound. Do not bind again.`);t.set(e,n)}}},e.get=function(e,...n){const s=t.get(e);if(s)return new s(...n)}}(q||(q={}));const G=Symbol.for("JOKER_VNODE_TAG");var z;!function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[G]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let n=this.parent;for(;n;){if(!0===e(n))return n;if(!0===t?.(n))break;n=n.parent}}find(e,t,n,s,i){let o=i??[];if(s??=this.childrens,s)for(let i of s){(!0!==e(i)||(o.push(i),n))&&(!0!==t?.(i)&&i.childrens&&this.find(e,t,n,i.childrens,o))}return o}contains(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return!0;if(n.childrens&&n.childrens.length&&this.contains(e,n.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return n;if(n.childrens&&n.childrens.length){let t=this.first(e,n.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;scopedId;constructor(e,t,n){super(t),this.html=e,this.notShadow=n}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=n=>{for(let s of n){if(s instanceof e.Element)return s;if(s.childrens){let e=t(s.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],n=s=>{for(let i of s)i instanceof e.Element||i instanceof e.Html?t.push(i):i.childrens&&n(i.childrens)};return n(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(z||(z={}));const Q="DOM Rendering",U=["script","style","textarea","pre"];let X=0;const Z=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];var ee;function te(e,t,n){return`${e}-${t}-${n}`}function ne(e,t,n,s){e._assistEventCache??=[],e._assistEventCache.push([t,n]),document.body.addEventListener(t,n,s)}function se(e,t,n){e._assistEventCache&&t&&n?(y(e._assistEventCache,e=>e[0]===t&&e[1]===n),document.body.removeEventListener(t,n)):(e._assistEventCache?.forEach(e=>{document.body.removeEventListener(e[0],e[1])}),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}!function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof z.Component)if(e.parent)if(e.output){const t=e.output,n=he(e)||t.parentNode;n&&n.insertBefore(this.elements,t)}else C(Q,"Component mount found no DOM target node",e);else C(Q,"Mounting child component with no parent",e);else C(Q,"Mount only supports Element or VNode.Node",e)}appendNode(e,t){if(this.renderNode(e),e.output){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(const s of n)this.appendNodeChildren(e,s,e.parent,t);return}C(Q,"No output found for node, cannot mount",e)}updateNode(e,t){if(e instanceof z.Element)for(const t in e.attributes){const n=e.attributes[t];this.setAttribute(e.output,t,n)}else e instanceof z.Text?e.parent&&e.parent instanceof z.Element&&U.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=A(e.text||""):e instanceof z.Html?e.notShadow?(e.output.innerHTML=e.html,e.scopedId&&fe(e.output,e.scopedId)):e.output.root.innerHTML=e.html:C(Q,`Node does not support ${t} update`,e)}removeNode(e,t){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];n?.forEach(e=>e?.remove()),t||(e instanceof z.Element&&se(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,n,s){e.output&&this.transitionFrame(e,t,"enter",n,s)}elementToLeave(e,t,n,s){e.output&&this.transitionFrame(e,t,"leave",n,s)}triggerEvent(e,t,n){const s=[];for(const i of e.events){const[o,r]=i;if(o===t){const t=r.modifiers?.includes("self"),a=r.modifiers?.includes("outside");if(t||a){R(Q,"Event modifiers 'self' and 'outside' not supported in components",e);continue}const h=n.event;if((h instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(o)||h instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(o))&&!1===oe(h,r.modifiers))continue;if(r.callBack(n),r.modifiers?.includes("prevent")&&n.preventDefault(),r.modifiers?.includes("once")&&s.push(i),r.modifiers?.includes("stop"))return n.stopPropagation(),!1}}s.length&&s.forEach(t=>m(e.events,t))}transitionFrame(e,t,n,s,i){re(e,te(t,n,"from")),s||="transition";const o=e.output.__TRANSITION_EVNETID__=X++;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!e.output)return;re(e,te(t,n,"active")),ae(e,te(t,n,"from")),re(e,te(t,n,"to"));const r=function(e,t){const n=window.getComputedStyle(e),s=e=>(n[e]||"").split(", ");if("transition"===t){const e=s("transitionDelay"),t=s("transitionDuration"),n=de(e,t);if(n>0)return{timeout:n,count:t.length}}else if("animation"===t){const e=s("animationDelay"),t=s("animationDuration"),n=de(e,t);if(n>0)return{timeout:n,count:t.length}}}(e.output,s);if(!r)return void i?.();let a=0;const h=()=>{ae(e,te(t,n,"to")),ae(e,te(t,n,"active")),e.output&&(e.output.removeEventListener(`${s}end`,d),o===e.output.__TRANSITION_EVNETID__&&i?.())},d=t=>{t.target===e.output&&++a>=r.count&&h()};setTimeout(()=>{a<r.count&&h()},r.timeout+1),e.output?.addEventListener(`${s}end`,d)})})}renderNode(e){if(!e.output)if(e instanceof z.Text)e.parent&&e.parent instanceof z.Element&&U.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(A(e.text||""));else if(e instanceof z.Html)if(e.notShadow){const t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.scopedId&&(t.setAttribute("data-scoped-"+e.scopedId,""),fe(t,e.scopedId)),e.output=t}else{const t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof z.Element){let t;const n=e.tagName.toLowerCase();"svg"===n||Z.includes(n)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(const n in e.attributes)this.setAttribute(t,n,e.attributes[n]);t.JOKER_NODE=e,e.output=t,e.events.some(e=>"click"===e[0]&&e[1].modifiers?.includes("outside"))?setTimeout(()=>{this.initElementEvents(t,e)}):this.initElementEvents(t,e)}else e instanceof z.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(const[n,s]of t.events){const i=s.modifiers?.includes("self");let o=s.modifiers?.includes("outside");i&&o&&(R(Q,"Event modifiers 'self' and 'outside' cannot coexist, using 'self'",t),o=!1);const r=a=>{if(!(t.sleep||i&&a.target!==e)){if(o){if(a.target===e||e.contains(a.target))return;if(!1===document.contains(a.target))return;if(t.contains(e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(a.target)))return!0}(a instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(n)||a instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(n))&&!1===oe(a,s.modifiers)||(s.callBack({eventName:n,event:a,target:t,preventDefault:()=>a.preventDefault(),stopPropagation:()=>a.stopPropagation(),data:void 0}),s.modifiers?.includes("prevent")&&a.preventDefault(),s.modifiers?.includes("stop")&&a.stopPropagation(),s.modifiers?.includes("once")&&(o?se(t,n,r):e.removeEventListener(n,r)))}};let a;s.modifiers?.includes("passive")&&(a={passive:!0}),o?ne(t,n,r,a):e.addEventListener(n,r,a)}}parserHtml(e){const t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof z.Component||e instanceof z.Condition||e instanceof z.List||e instanceof z.ListItem||e instanceof z.RenderSection}appendNodeChildren(e,t,n,s){let i=he(e);if(i)i.appendChild(t);else if(void 0===n)this.elements?.appendChild(t);else if(n)if(n instanceof z.Root){const e=n.parent;if(e&&e instanceof z.Component&&e.output){const n=e.output,s=n?.parentNode;if(s)return void s.insertBefore(t,n)}this.elements?.appendChild(t)}else if(n instanceof z.Element){const e=n.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(n)){const i=n.output?.parentNode;if(void 0!==s&&n.childrens?.length&&i){const o=s-1;if(o<0){const n=le(e);return void(n&&i.contains(n.output)?n.output.after(t):i.insertBefore(t,i.firstChild))}{const e=n.childrens[o];if(e){const n=e.output;if(n)return void n.after(t)}}}i&&i.insertBefore(t,n.output)}else C(Q,"Node does not support nested children",{node:e,parent:n})}setAttribute(e,t,n){if(e)if("boolean"!=typeof n){if("class"===t){if(n){n=pe(n).join(" ")}}else if("style"===t&&c(n)){e.removeAttribute("style");for(const t in n){let s=!1;void 0!==n[t]&&!1!==n[t]||(s=!0);const i=String(n[t]);v(i)&&(s=!0),s||(e.style[t]=i)}return}n=(n??"").toString().trim(),"class"===t&&(n=n.split(/\s/).filter(e=>e.trim()).join(" ")),"value"===t&&"value"in e?e.value=n:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n):e.setAttribute(t,n)}else n?e.setAttribute(t,""):e.removeAttribute(t)}}}(ee||(ee={}));const ie={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function oe(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(const n in ie)if(t?.includes(ie[n])&&e.key.toLowerCase()!==n)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function re(e,t){e.output&&e.output.classList.add(t)}function ae(e,t){e.output&&e.output.classList.remove(t)}function he(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof z.Element)return t.output;if("string"==typeof t){ee.ROOT_CONTAINER&&(t="body"===t?ee.ROOT_CONTAINER:`${ee.ROOT_CONTAINER} ${t}`);const e=document.querySelector(t);if(e)return e}R(Q,"Unsupported appendTo type",{appendTo:t,node:e})}}}function de(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map((t,n)=>ce(t)+ce(e[n])))}function ce(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function le(e,t){let n=e.prev;for(;n;){if(n instanceof z.ListItem==!1)return n;n=n.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof z.Element)return;const e=le(t,!0);if(e)return e;t=t.parent}}}class ue extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}function fe(e,t){const n=e.childNodes;for(let e=0;e<n.length;e++){const s=n[e];if(1===s.nodeType){const e=s;e.setAttribute("data-scoped-"+t,""),fe(e,t)}}}function pe(e,t){const n=t||[];if("string"==typeof e){const t=e.trim();t&&!n.includes(t)&&n.push(t)}else Array.isArray(e)?e.forEach(e=>pe(e,n)):null!==e&&"object"==typeof e&&Object.entries(e).forEach(([e,t])=>{if(t){const t=e.trim();t&&!n.includes(t)&&n.push(t)}});return n}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",ue);const me={};function ye(e){for(const t in e)me[t]=e[t]}const ve="Global",ge="Render Core";function Ee(t,n){try{return new Function(e,ve,`return ${t};`)}catch(e){throw new Error(`An unknown error occurred while creating the expression execution method. \nmessage: ${e.message} \n${n?.()||t}`)}}class be{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,n,s){this.ast=e,this.ob=t,this.parent=n,this.ext=s}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(!this.isDestroy)if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof z.Element||this.node instanceof z.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&m(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,()=>{t()}))return m(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[z.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0,this.ast=void 0,this.ob=void 0,this.ext=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):m(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[z.PARSERKEY]&&(t[z.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[z.PARSERKEY]=this,this.node instanceof z.Element&&this.ob[qe]?this.node.attributes["data-scoped-"+this.ob[qe]]=void 0:this.node instanceof z.Html&&this.ob[qe]&&(this.node.scopedId=this.ob[qe]),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t,n){try{return Ee(e,n).call(t,t,me)}catch(s){C(ge,`Expression error:${s.message}\n`+(n?.()||e),{ob:t}),console.error(s)}}runExpressWithWatcher(e,t,n,s,i){if(this.isDestroy)return;let o="string"==typeof e?Ee(e,i):e,r=new F(()=>{if(this.isDestroy||t[Je])return J;try{return o.call(t,t,me)}catch(n){return C(ge,`Expression error:${n.message}\n${i?.()||e}`,{ob:t,express:e,node:this.node}),console.error(n),J}},n,void 0,s);return this.addWatch(r),r.value===J?void 0:r.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach(e=>{e.destroy()}),this.watchers.length=0}}class we extends be{parser(){this.node=new z.Text(this.ast.text,this.parent),this.appendNode()}}class Ne extends be{parser(){this.node=new z.Comment(this.ast.text,this.parent),this.appendNode()}}class $e extends be{parser(){if(this.node=new z.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){v(this.ast.condition)&&C("Conditional Command",`The current conditional command ${this.ast.kind} has no judgment condition, please check`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[z.PARSERKEY];t&&t instanceof $e&&t.renderConditionChildren()}}this.reloadAllCondition()}},!1,()=>this.ast._code);this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob,()=>{this.ast._code}),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof z.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof $e&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof z.Condition&&"if"!==e.cmdName;){let t=e[z.PARSERKEY];t&&t instanceof $e&&t.renderConditionChildren(),e=e.next}}}class Re extends be{parser(){this.node=new z.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,n=Object.create(this.ob),s=!!this.runExpressWithWatcher(function(t,n,s){try{return new Function(e,`${e}.${t}=${n}; return ${s};`)}catch{throw new Error(`Dependency collection for the For loop command expression execution encountered an unknown error. Details: letKey: ${t}, keyVal: ${n}, condition: ${s}`)}}(t.letKey,t.defaultKeyVal,t.condition),n,()=>{this.clearWatchers(),this.renderChildrens()},!0,()=>this.ast._code),i=0;for(;s;){let e=Object.create(this.ob);W(e,t.letKey,n[t.letKey]);let o=i++;this.renderItem(e,o),this.runExpressWithWatcher(()=>n[t.letKey],n,async(n,s,i,r)=>{await Promise.resolve(),r.isDestroy||(e[t.letKey]=n,i||this.updateListItemOb(e,o))},!0,()=>this.ast._code),this.runExpress(t.step,n,()=>{this.ast._code}),s=!!this.runExpress(t.condition,n,()=>this.ast._code)}this.destroyOldChildrens(i)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,()=>{this.clearWatchers(),this.renderChildrens()},!1,()=>this.ast._code),n=0;if(t&&(Array.isArray(t)||u(t)))for(let s in t){let i=Object.create(this.ob),o=Array.isArray(t)?Number(s):s;e.indexKey&&W(i,e.indexKey,o),e.itemKey&&W(i,e.itemKey,t[s]);let r=n++;this.renderItem(i,r,e.indexKey),e.itemKey&&this.runExpressWithWatcher(()=>t[o],t,async(n,s,a,h)=>{await Promise.resolve(),h.isDestroy||o in t&&(i[e.itemKey]=n,a||this.updateListItemOb(i,r))},!0,()=>this.ast._code)}this.destroyOldChildrens(n)}findIndexByIndex(e,t,n){let s=-1;if(this.node)for(let i=t;i<this.node.childrens.length;i++)if(this.checkObEqual(e,this.node.childrens[i]?.ob,n?[n]:void 0)){s=i;break}return s}renderItem(e,t,n){if(!this.ast.childrens?.length||!this.node)return;let s=this.node.childrens?.[t];if(s){if(this.checkObEqual(e,s.ob,n?[n]:void 0))return void(n&&s.ob[n]!==e[n]&&(s.ob[n]=e[n]));let i=this.findIndexByIndex(e,t+1,n);if(i>-1){if(t+1===i)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();else for(let e=0;e<i-t-1;e++)this.node.childrens?.[t]?.[z.PARSERKEY]?.destroy();return this.renderItem(e,t,n)}return new Ce(this.ast,e,this.node,this.ext).init(t)}return new Ce(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let n=this.node.childrens?.[t];l(e,(e,t)=>{n.ob[e]!==t&&(n.ob[e]=t)})}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[z.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,n){let s=!0;return void 0!==t&&(l(e,(e,i)=>{n?.includes(e)||t?.[e]===i||(s=!1)}),s)}}class Ce extends be{parser(e){this.node=new z.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class xe extends be{parser(){if(v(this.ast.cmdName))throw C("Template Directive","Error occurred while converting AST to VNode: Directive name not found",this.ast),new Error("Error converting AST to VNode: Directive name not found");let e;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?e=this.ast.param:this.ast.cmdName.startsWith(ve+".")?e=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(e=`${t(this.ast.cmdName)}(${this.ast.param})`),e){let t=this.runExpressWithWatcher(`[${e}]`,this.ob,e=>{this.changeValue(e?.[0])},!1,()=>this.ast._code);return t||=[],"Html"===this.ast.cmdName?this.node=new z.Html(Ae(t[0]),this.parent,t[1]):this.node=new z.Text(Ae(t[0]),this.parent),void this.appendNode()}throw new Error("Command not found: "+this.ast.cmdName)}changeValue(e){this.node&&(this.node instanceof z.Html?this.node.html=Ae(e):this.node.text=Ae(e),this.ext.render?.updateNode(this.node))}}function Ae(e){return null==e||"function"==typeof e?"":e.toString()}const Oe="default";class Se extends be{parser(){let e=this.transformParam();this.node=new z.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach((e,t)=>{W(this.node.ob,e,this.node.params[t])})):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,e=>{let t=e?.[0]||Oe;if("string"==typeof t&&t!==this.node.id)throw new Error("The section ID cannot be dynamically changed");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])})},!0,()=>this.ast._code);return{id:e?.[0]||Oe,params:e?.slice(1)||[]}}return{id:Oe,params:[]}}}const Pe="Component Parsing";function Te(e,t){return!!t.components[e]||!!et(e)}class De extends be{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new z.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally(()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)})}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):R(Pe,"Reload operation is not supported for the current component",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)},!0,()=>{if(e.value)return`express:${e.value} \nfrom <${"tagName"in this.ast?this.ast.tagName:"Component"} ${e.name}="${e.value}" ... /> `});this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(v(e.value)){R(Pe,"The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=K(this.node.propValues)}initEvent(){this.ast.events.forEach(e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:E}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code} \nfrom: <${"tagName"in this.ast?this.ast.tagName:"Component"} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t.call(this.ext.ob,n,...s)}}]):C(Pe,`The callback method (${e.functionName}) specified for the ${e.name} event in the ${"tagName"in this.ast?this.ast.tagName:""} element was not found. Please check.`)})}async renderChildren(){return new Promise(async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||et(this.ast.tagName);if(void 0===e)return void C(Pe,`Failed to render component. Private or global component named '${this.ast.tagName}' not found.`);if(Ge in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let n=this,s=function(){n.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",()=>{this.node?.component.$off("beforeDestroy",s),e(void 0)}),this.node.component.$on("beforeDestroy",s),this.node.component.$mount(this.node),!this.node)return;let i=this.node?.component;i.isKeepAlive&&(this.ast.node=this.node)})}getSections(){let t={},s=[];return this.ast.childrens.forEach(t=>{if(t.type===n.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let i=t,o=t.childrens.some(e=>e.type===n.NodeType.COMMAND&&"section"===e.cmdName),r=i.condition.startsWith(e+".$sections");if(r){return this.runExpress(i.condition,this.ob,()=>i._code)?void s.push(...t.childrens):void 0}if(o&&"if"===i.kind&&!r)return void R(Pe,"While parsing the section, it was found that this section is wrapped in a conditional statement. This conditional statement only supports if judgments using $sections. It has been excluded.")}s.push(t)}),s.forEach(e=>{if(e.type===n.NodeType.COMMAND&&"section"===e.cmdName){let n=e,s=n.id||Oe;/^(\'|\")(.*?)((\'|\"))$/.test(s)&&(s=s.slice(1,-1)),t[s]=t[s]||{asts:[],ob:this.ob,params:n.paramKeys,parser:this.ext},t[s].asts.push(...e.childrens||[])}else t[Oe]=t[Oe]||{asts:[],ob:this.ob,parser:this.ext},t[Oe].asts.push(e)}),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),this.node?.component[Je]||(!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0))}}class ke extends be{parser(){this.node=new z.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},n=this.runExpressWithWatcher(e.express,this.ob,e=>{t(e)},!1,()=>{if(e.value)return`express:${e.value} \nfrom <${this.ast.tagName} ${e.name}="${e.value}" ... /> `});this.node.attributes[e.name]=this.transformAttrVal(n)}else this.node.attributes[e.name]=e.value;else{if(v(e.value)){R("Element","The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`The callback method (${e.functionName}) specified for the ${e.name} event in the ${this.ast.tagName} element was not found. Please check.`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{if(void 0===t)return;let s=[];e.functionParam&&(s=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code}\nfrom <${this.ast.tagName} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t&&t.call(this.ext.ob,n,...s)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class _e{asts;ob;root=new z.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,n){this.asts=e,this.ob=t,this.root.component=t,this.render=q.get(ee.IRENDERIOCTAGID)??new ee.DomRender,n&&n instanceof z.Node&&(this.root.parent=n,n.childrens??=[],n.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(e,t,s){if(0!==this.asts.length)for(let i of e)if(i.type===n.NodeType.TEXT)new we(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.COMMENT)new Ne(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.COMPONENT)new De(i,s??this.ob,t,this).init();else if(i.type===n.NodeType.ELEMENT){let e=i;Te(e.tagName,s??this.ob)?new De(e,s??this.ob,t,this).init():new ke(e,s??this.ob,t,this).init()}else if(i.type===n.NodeType.COMMAND){let e=i;switch(e.cmdName){case"if":case"elseif":case"else":new $e(e,s??this.ob,t,this).init();break;case"for":new Re(e,s??this.ob,t,this).init();break;case"RenderSection":new Se(e,s??this.ob,t,this).init();break;case"section":break;default:new xe(e,s??this.ob,t,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&m(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){m(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,n,s){this.nodeWatcherEvents[e]?.forEach(e=>{e(t,n,s)})}sleep(e){let t=e||this.root;t.childrens?.forEach(e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,()=>{t()})||t()}),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach(e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")}),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[z.PARSERKEY]?t[z.PARSERKEY].destroy(e):m(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[z.PARSERKEY]&&e[z.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=q.get(ee.IRENDERIOCTAGID)??new ee.DomRender,this.asts=e}nodeTransition(e,t,n,s,i){if(e&&e.parent?.childrens&&(e instanceof z.Element||e instanceof z.Component)){let o=function(e){if(e instanceof z.Element||e instanceof z.Component){let t=e instanceof z.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(n??=o?.name,i??=o?.type,!n)return!1;let r=Ke(e);if(r)return"enter"===t?this.render.elementToEnter(r,n,i,()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),s?.()}):this.render.elementToLeave(r,n,i,()=>{let t=e[z.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),s?.()}),!0;R("Render Core","Incomplete data found when executing node animation, please check")}return!1}}function Ke(e){if(e instanceof z.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof z.Element?t:Ke(t)}function We(e,t,n){if(void 0===t)return;const s=Array.isArray(n)?n:[n];for(const e of s){if(e===Array&&Array.isArray(t))return t;if(typeof t===e.name.toLowerCase())return t}switch(s[0]){case Number:const e=Number(t);if(!isNaN(e))return e;break;case String:return String(t)}throw new Error(`The type of ${e.toString()} in props does not match the constrained type`)}function Ie(e,t,n){let s,i,o;if("symbol"!=typeof t&&(s=g(t)),t in e?i=e[t]:s&&(i=e[s]),n&&(t in n?o=n[t]:s&&s in n&&(o=n[s])),void 0!==o){if(u(o)&&("type"in o||"required"in o||"default"in o||"validate"in o)){const e=o;if(e.required&&void 0===i)throw new Error(`props key:${t.toString()} is required, please check`);if(e.type&&(i=We(t,i,e.type)),e.validate&&!1===e.validate(i))throw new Error(`Validation failed for props key ${t.toString()}`);i=i??e.default}else i=Ve(o)?We(t,i,o):i??o;return i}return i}function Ve(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||!!Array.isArray(e)&&Ve(e[0])}function Me(e,t){if(!e.constructor)return!1;let n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return n&&n.get}const je="Component",Le=Symbol.for("JOKER_PROPS_DATA_KEY"),Ye=Symbol.for("JOKER_PROPS_DATA_PROXY"),Be=Symbol.for("JOKER_PRIVATE_WATCHERS"),He=Symbol.for("JOKER_EVENT_DATA_KEY"),Je=Symbol.for("JOKER_IS_DESTROY"),Fe=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),qe=Symbol.for("JOKER_SCOPE_ID"),Ge=Symbol.for("JOKER_COMPONENT_TAG"),ze=Symbol();let Qe=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class Ue{$sections;isKeepAlive;static[Ge]=!0;[qe];model={};template;$root;isSleeped=!1;components={};propsOption;[Le]={};[Fe];[Ye];[Be]=[];[He]=new Map;[Je]=!1;[ze]=!1;constructor(e,t={},n){this.$sections=t,this.isKeepAlive=n,this[Le]=e||{}}get props(){if(void 0===this[Ye]){let e=this;this[Ye]=new Proxy(e[Le],{get:(t,n)=>Ie(e[Le],n,e.propsOption),set(){throw new Error("props parameters are not allowed to be changed, only one-way data transfer is allowed")}})}return this[Ye]}$mount(e){if(!1===this[ze]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach(n=>{!1!==Qe.includes(n)||Me(t,n)||"function"!=typeof t[n]||t[n].prototype?.hasOwnProperty("constructor")||e.push(n)}),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[ze]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[Fe]&&this.$root?(this[Fe].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&nt(this.$rootVNode),this):(C(je,"When attempting to wake up the current component, it was found that the rendering handler has been destroyed. The wake-up operation cannot proceed.",[this,this.$root]),this);this.isSleeped=!1,this.model=K(this.model);let t=this.created(),n=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[Je]||(await this.mounted(),this[Je]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then(()=>{this[Je]||n()}):n(),this}$nextUpdatedRender(e){if(this[Je])return;let t=[...this[Fe]?.promiseQueue||[]],n=this.$rootVNode?.find(e=>e instanceof z.Component);if(n?.forEach(e=>{e?.component&&t.push(...e.component[Fe]?.promiseQueue||[])}),t.length)return Promise.all(t).finally(()=>{this[Je]||e?.()});this[Je]||e?.()}$nodeTransition(e,t,n,s,i){if(this.$root&&!this[Je]){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void R(je,`Node with ref=${e} not found when executing node animation`);e=t}this[Fe]?.nodeTransition(e,t,n,s,i)}}$destroy(e){if(!e&&this.isKeepAlive)return this[Fe]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&tt(this.$rootVNode));this[Je]=!0;for(let e of this[Be])e.destroy();this[Be].length=0,this[Fe]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[Fe]?.destroy(),this[Fe]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[He].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[Ye]=void 0,this[Le]={},this.destroyed()}get $refs(){return this[Fe]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,n){"function"==typeof t&&(n=t,t=void 0),t??=e,n??=e=>e,this.model[t]=n(this.props[e]),this.$watch(()=>this.props[e],()=>{this.model[t]=n?.(this.props[e])})}get $rootVNode(){return this[Fe]?.root}$watchNode(e,t){if(this[Fe])return this[Fe]?.addNodeWatcher(e,t),()=>{this[Fe]?.removeNodeWatcher(e,t)};R(je,"Component is not yet mounted. Node observation and monitoring cannot be performed.")}$watch(e,t,n){let s=new F(()=>{if(this[Je]){for(let e of this[Be])e.destroy();return J}return e()},(e,n)=>{this[Je]||t(e,n)},void 0,n);return this[Be].push(s),[s.value,()=>{s.destroy(),m(this[Be],s)}]}$on(e,t){let n=this[He].get(e);void 0===n&&(n=new Set,this[He].set(e,n)),!1===n?.has(t)&&n.add(t)}$off(e,t){let n=this[He].get(e);n&&(t?n.delete(t):n.clear())}get $listeners(){let e={};for(let t in this[He])e[t]||=[],e[t].push(...Array.from(this[He].get(t)||[]));if(this.$root&&this.$root instanceof z.Component)for(let t of this.$root.events){let n=t[0];e[n]||=[],e[n].push(t[1].callBack)}return e}$trigger(e,t,n){if(!this.$root)return;let s={eventName:e,stopPropagation:n?.stopPropagation??(()=>{}),preventDefault:n?.preventDefault??(()=>{}),data:t,target:n?.target??this.$rootVNode,event:n?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof z.Component&&!1===this[Fe]?.render.triggerEvent(this.$rootVNode.parent,e,s))return;let i=this[He].get(e);i?.size&&[...i].forEach(e=>{e(s)});let o=this[He].get("*");o?.size&&[...o].forEach(e=>{e(s)})}$render(e,t){e??=this.template,this.template="function"==typeof e?e(s):e,this.$root&&(this.template??=[],this[Fe]?.reSetAsts(this.template,t),this[Fe]??=new _e(this.template,this,this.$root),this[Fe].parser(),this.$root&&this[Fe].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Xe={};function Ze(e,t){if("string"==typeof e)t&&(Xe[e]=t);else for(let t in e)Xe[t]=e[t]}function et(e){return Xe[e]}function tt(e){e.childrens?.forEach(e=>{e instanceof z.Component&&e.component?.sleeped(),tt(e)})}function nt(e){e.childrens?.forEach(e=>{e instanceof z.Component&&e.component?.wakeup(),nt(e)})}class st extends Ue{template=[];cache=new Map;async mounted(){this.$watch(()=>this.props.name,async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)}),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach(t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch(()=>this.props[t],()=>{this.propsVaule[t]=this.props[t]}))}),this.propsVaule=K(e))}filterProps(e){if("string"!=typeof e)return!1;let t=g(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(e){if(!e)return void this.$render([],this.isKeepAlive);let t;if(this.isKeepAlive){let t=this.cache.get(e);if(t)return void this.$render([i(t,{"transition-name":this.props["transition-name"]})],!0)}let n=this.$rootVNode?.parent?.[z.PARSERKEY]?.ob.components,s=n?.[e];void 0===s&&(s=et(e)),s?(Ge in s||(s=(await s()).default),t=new s(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),t.$on("*",e=>{this.$trigger(e.eventName,e.data,e)}),this.isKeepAlive&&this.cache.set(e,t),this.$render([i(t,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):R("component",`Component ${e} not found`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach(e=>{e.$destroy(!0)}),this.cache.clear()}}class it extends Ue{template=function(){return[o("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}Ze({template:it,component:st});class ot{eventDatas=new Map;on(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const s={callBack:t};return n.push(s),()=>{n&&m(n,s)}}once(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const s={callBack:t,once:!0};return n.push(s),()=>{n&&m(n,s)}}off(e,t){if(void 0!==e)if(t){const n=this.eventDatas.get(e),s=n?.find(e=>e.callBack===t);s&&m(n,s)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let n=[...this.eventDatas.get(e)||[]];if(n.push(...this.eventDatas.get("*")||[]),n&&n.length){let s=0,i=0,o=!1;for(;n[s];){const r=n[s],a=await r.callBack({stopPropagation:()=>o=!0,callTimes:i,eventName:e},t);if(r.once?m(n,r):s++,!1===a||o)return!1}}}}export{J as BREAK_WATCH_UPDATE,Ue as Component,st as ComponentContainer,O as Dep,ot as EventBus,q as IContainer,Je as IS_DESTROY,Ge as JOKER_COMPONENT_TAG,G as JOKER_VNODE_TAG,S as OBJECTPROXY_DEPID,Fe as PARSER_TEMPLATE_TARGET,_e as ParserTemplate,ee as Render,qe as SCOPE_ID,V as ShallowObserver,it as Template,z as VNode,F as Watcher,me as __GLONAL_FUNTIONS__,d as __JOKER_HMR_RUNTIME,Y as combinedReply,W as defineObserverProperty,et as getGlobalComponent,B as isObserverData,K as observer,Ze as registerGlobalComponent,ye as registerGlobalFunction};
package/dist/bundle.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@joker.front/ast");const t=new Map,n=new Map,o=new Map;let s={recordRender:(e,t)=>{n.set(e,t)},recordComponent:(e,t)=>{o.set(e,t)},record:(e,n)=>{void 0===t.get(e)&&t.set(e,new Set),t.get(e).add(n),n.$on("destroy",()=>{t.get(e)?.delete(n)})},reload:(e,n)=>{let s=o.get(e);if(!s)return;s.component=n;let i=t.get(e);if(!i)return;let r=Array.from(i);i.clear(),r.forEach(e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof exports.VNode.Component&&t[exports.VNode.PARSERKEY]&&t[exports.VNode.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[exports.VNode.PARSERKEY].reload()}}})},rerender:(e,o)=>{let s=n.get(e);s&&(s.render=o),t.get(e)?.forEach(e=>{e.$render(o)})}};function i(e){return null!==e&&"object"==typeof e}function r(e,t){Object.getOwnPropertyNames(e).forEach(n=>{t(n,e[n])})}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}function d(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let n=Object.keys(e);for(let o of n){let n=e[o];t[o]="object"==typeof n?d(n):n}return t}function h(e,t,n){if(e===t)return!0;let o=i(e),s=i(t);if(o&&s){if(a(e)&&a(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(e[o]!==t[o])return!1;return!0}return e===t}return!o&&!s&&String(e)===String(t)}function c(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),e}function l(e,t){let n=e.findIndex(e=>t(e));return n>-1&&e.splice(n,1),e}function p(e){return!e||""===e.trim()}function u(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join(t)}let f=(...e)=>{},m="warn";const y=["silent","error","warn","info"];function E(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function N(e,t,n,o){y.indexOf(e)<=y.indexOf(m)&&(void 0===o?console[e](`${E()} [${t}]:`,n):console[e](`${E()} [${t}]:`,n,o))}let g=function(e,t,n){N("warn",e,t,n)},v=function(e,t,n){N("error",e,t,n)};const x={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function b(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,(e,t)=>x[t]||"")}class w{static target;watchers=new Map;depend(e){w.target?.addDep(this,e)}addWatcher(e,t){let n=this.watchers.get(e)||[];n.push(t),this.watchers.set(e,n)}removeWatcher(e,t){const n=this.watchers.get(e);n&&c(n,t)}notify(e){const t=this.watchers.get(e);if(t){l(t,e=>e.isDestroy);[...t].forEach(e=>{e.isDestroy||e.update()})}}}const R=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),A=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),C=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function $(e){try{return null!=e&&i(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof I==!1&&e instanceof je==!1&&e instanceof be==!1&&(Array.isArray(e)||a(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(j in e)&&!(P in e)&&!(Ke in e)}catch{return!1}}function O(e){if(S(e))return e;if(e&&e.hasOwnProperty(A)){let t=Reflect.get(e,A);if(t)return t}let t=new w,n=!0,o=new Proxy(e,{get(e,n,o){if(e instanceof Set||e instanceof Map){if("add"===n){let o=Reflect.get(e,n);return n=>{$(n)&&(n=T(n));let s=o.call(e,n);return k(t,"size"),k(t,C),s}}if("set"===n){let o=Reflect.get(e,n);return(n,s)=>{$(s)&&(s=T(s));let i=o.call(e,n,s);return k(t,"size"),k(t,C),i}}if("delete"===n||"clear"===n){let o=Reflect.get(e,n);return s=>{let i=o.call(e,s);return("clear"===n||i)&&(k(t,"size"),k(t,C)),i}}let o=Reflect.get(e,n);if("function"==typeof o)return o.bind(e)}if(n===A)return;if(n===R)return t;if(n===C)return;let s=Reflect.get(e,n);return n===Symbol.toStringTag||!1===function(e,t){return t in e}(e,n)&&"length"!==n&&"size"!==n||(t.depend(n),$(s)&&S(s)?.depend(C)),s},set(e,o,s){if(n)return Reflect.set(e,o,s),!0;$(s)&&(s=T(s));let i=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,o),r=Reflect.get(e,o)!==s;return Reflect.set(e,o,s),(r||"length"===o&&Array.isArray(e))&&k(t,o),Array.isArray(e)?"length"===o&&k(t,C):i&&k(t,C),!0},deleteProperty:(e,n)=>(Reflect.deleteProperty(e,n),!1===Array.isArray(e)&&k(t,C),!0)});!function(e,t,n,o){Object.defineProperty(e,t,{value:n,enumerable:o,writable:!0,configurable:!0})}(e,A,o,!1);for(let t in e){let n=e[t];$(n)&&!S(n)&&(o[t]=O(e[t]))}return n=!1,o}function S(e){if(i(e))return Reflect.get(e,R)}function T(e,t=!1){if(!1===$(e))throw new Error("The provided data is not of the correct type. It must be an array or an object.");return O(t?d(e):e)}function V(e,t,n){let o=n;$(n)&&(o=T(n));let s=new w;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(s.depend(t),S(o)?.depend(C),o),set:e=>{e!==o&&($(e)&&(e=T(e)),o=e,k(s,t))}})}const P=Symbol.for("JOKER_SHALLOW_OBSERVER");let D=!1,_=new Map;function k(e,t){if(!1===D)e.notify(t);else{let n=_.get(e);void 0===n&&(n=[],_.set(e,n)),n.includes(t)||n.push(t)}}const K="Data Observation",W=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class I{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,n,o){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=o,void 0===e)throw new Error("Cannot observe changes on undefined");if(void 0===n)this.getter=e=>e;else if("function"==typeof n)this.getter=n;else{const e=function(e){if(/[^\w.$]/.test(e))return;const t=e.split(".");return function(e){let n=e;return t.forEach(e=>{n&&(n=n[e])}),n}}(n);if(void 0===e)throw new Error(`${n} failed to parse. Unable to interpret the expression. Please check the expOrFn parameter or use the function mode instead.`);this.getter=e}void 0===this.getter&&v(K,"Failed to create getter",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;w.target=this;const e="function"==typeof this.ob?this.ob():this.ob;let t;try{t=this.getter.call(e,e)}catch(e){throw v(K,"Failed to retrieve value. Executed method: "+this.getter.toString()),e}return w.target=void 0,this.clearnDeps(),t}addDep(e,t){let n=this.runRelations.get(e);if(void 0===n||!n.includes(t)){n=n||[],n.push(t),this.runRelations.set(e,n);const o=this.relations.get(e);void 0!==o&&o.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;const e=this.getValue();if(e===W)return;const t=this.value;if(this.forceCallBack||e!==t||i(e)){this.value=e;const n=e!==t&&function(e,t){return Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e,t):h(e,t)}(e,t);if(n&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,n,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach((e,t)=>{for(const n of e)t.removeWatcher(n,this)}),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0,this.updateCallBack=void 0}clearnDeps(){this.relations.forEach((e,t)=>{const n=this.runRelations.get(t);for(const o of e)n&&n.includes(o)||t.removeWatcher(o,this)}),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}exports.IContainer=void 0,function(e){let t=new Map;e.bind=function(e){return{to:n=>{if(t.has(e))throw new Error(`TagId:${e.toString()} already has an implementation bound. Do not bind again.`);t.set(e,n)}}},e.get=function(e,...n){const o=t.get(e);if(o)return new o(...n)}}(exports.IContainer||(exports.IContainer={}));const j=Symbol.for("JOKER_VNODE_TAG");exports.VNode=void 0,function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[j]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let n=this.parent;for(;n;){if(!0===e(n))return n;if(!0===t?.(n))break;n=n.parent}}find(e,t,n,o,s){let i=s??[];if(o??=this.childrens,o)for(let s of o){(!0!==e(s)||(i.push(s),n))&&(!0!==t?.(s)&&s.childrens&&this.find(e,t,n,s.childrens,i))}return i}contains(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return!0;if(n.childrens&&n.childrens.length&&this.contains(e,n.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return n;if(n.childrens&&n.childrens.length){let t=this.first(e,n.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;scopedId;constructor(e,t,n){super(t),this.html=e,this.notShadow=n}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=n=>{for(let o of n){if(o instanceof e.Element)return o;if(o.childrens){let e=t(o.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],n=o=>{for(let s of o)s instanceof e.Element||s instanceof e.Html?t.push(s):s.childrens&&n(s.childrens)};return n(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(exports.VNode||(exports.VNode={}));const L="DOM Rendering",M=["script","style","textarea","pre"];let H=0;const B=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];function Y(e,t,n){return`${e}-${t}-${n}`}function J(e,t,n,o){e._assistEventCache??=[],e._assistEventCache.push([t,n]),document.body.addEventListener(t,n,o)}function G(e,t,n){e._assistEventCache&&t&&n?(l(e._assistEventCache,e=>e[0]===t&&e[1]===n),document.body.removeEventListener(t,n)):(e._assistEventCache?.forEach(e=>{document.body.removeEventListener(e[0],e[1])}),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}exports.Render=void 0,function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof exports.VNode.Component)if(e.parent)if(e.output){const t=e.output,n=z(e)||t.parentNode;n&&n.insertBefore(this.elements,t)}else v(L,"Component mount found no DOM target node",e);else v(L,"Mounting child component with no parent",e);else v(L,"Mount only supports Element or VNode.Node",e)}appendNode(e,t){if(this.renderNode(e),e.output){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(const o of n)this.appendNodeChildren(e,o,e.parent,t);return}v(L,"No output found for node, cannot mount",e)}updateNode(e,t){if(e instanceof exports.VNode.Element)for(const t in e.attributes){const n=e.attributes[t];this.setAttribute(e.output,t,n)}else e instanceof exports.VNode.Text?e.parent&&e.parent instanceof exports.VNode.Element&&M.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=b(e.text||""):e instanceof exports.VNode.Html?e.notShadow?(e.output.innerHTML=e.html,e.scopedId&&ne(e.output,e.scopedId)):e.output.root.innerHTML=e.html:v(L,`Node does not support ${t} update`,e)}removeNode(e,t){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];n?.forEach(e=>e?.remove()),t||(e instanceof exports.VNode.Element&&G(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,n,o){e.output&&this.transitionFrame(e,t,"enter",n,o)}elementToLeave(e,t,n,o){e.output&&this.transitionFrame(e,t,"leave",n,o)}triggerEvent(e,t,n){const o=[];for(const s of e.events){const[i,r]=s;if(i===t){const t=r.modifiers?.includes("self"),a=r.modifiers?.includes("outside");if(t||a){g(L,"Event modifiers 'self' and 'outside' not supported in components",e);continue}const d=n.event;if((d instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(i)||d instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(i))&&!1===q(d,r.modifiers))continue;if(r.callBack(n),r.modifiers?.includes("prevent")&&n.preventDefault(),r.modifiers?.includes("once")&&o.push(s),r.modifiers?.includes("stop"))return n.stopPropagation(),!1}}o.length&&o.forEach(t=>c(e.events,t))}transitionFrame(e,t,n,o,s){X(e,Y(t,n,"from")),o||="transition";const i=e.output.__TRANSITION_EVNETID__=H++;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!e.output)return;X(e,Y(t,n,"active")),U(e,Y(t,n,"from")),X(e,Y(t,n,"to"));const r=function(e,t){const n=window.getComputedStyle(e),o=e=>(n[e]||"").split(", ");if("transition"===t){const e=o("transitionDelay"),t=o("transitionDuration"),n=Q(e,t);if(n>0)return{timeout:n,count:t.length}}else if("animation"===t){const e=o("animationDelay"),t=o("animationDuration"),n=Q(e,t);if(n>0)return{timeout:n,count:t.length}}}(e.output,o);if(!r)return void s?.();let a=0;const d=()=>{U(e,Y(t,n,"to")),U(e,Y(t,n,"active")),e.output&&(e.output.removeEventListener(`${o}end`,h),i===e.output.__TRANSITION_EVNETID__&&s?.())},h=t=>{t.target===e.output&&++a>=r.count&&d()};setTimeout(()=>{a<r.count&&d()},r.timeout+1),e.output?.addEventListener(`${o}end`,h)})})}renderNode(e){if(!e.output)if(e instanceof exports.VNode.Text)e.parent&&e.parent instanceof exports.VNode.Element&&M.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(b(e.text||""));else if(e instanceof exports.VNode.Html)if(e.notShadow){const t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.scopedId&&(t.setAttribute("data-scoped-"+e.scopedId,""),ne(t,e.scopedId)),e.output=t}else{const t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof exports.VNode.Element){let t;const n=e.tagName.toLowerCase();"svg"===n||B.includes(n)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(const n in e.attributes)this.setAttribute(t,n,e.attributes[n]);t.JOKER_NODE=e,e.output=t,e.events.some(e=>"click"===e[0]&&e[1].modifiers?.includes("outside"))?setTimeout(()=>{this.initElementEvents(t,e)}):this.initElementEvents(t,e)}else e instanceof exports.VNode.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(const[n,o]of t.events){const s=o.modifiers?.includes("self");let i=o.modifiers?.includes("outside");s&&i&&(g(L,"Event modifiers 'self' and 'outside' cannot coexist, using 'self'",t),i=!1);const r=a=>{if(!(t.sleep||s&&a.target!==e)){if(i){if(a.target===e||e.contains(a.target))return;if(!1===document.contains(a.target))return;if(t.contains(e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(a.target)))return!0}(a instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(n)||a instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(n))&&!1===q(a,o.modifiers)||(o.callBack({eventName:n,event:a,target:t,preventDefault:()=>a.preventDefault(),stopPropagation:()=>a.stopPropagation(),data:void 0}),o.modifiers?.includes("prevent")&&a.preventDefault(),o.modifiers?.includes("stop")&&a.stopPropagation(),o.modifiers?.includes("once")&&(i?G(t,n,r):e.removeEventListener(n,r)))}};let a;o.modifiers?.includes("passive")&&(a={passive:!0}),i?J(t,n,r,a):e.addEventListener(n,r,a)}}parserHtml(e){const t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof exports.VNode.Component||e instanceof exports.VNode.Condition||e instanceof exports.VNode.List||e instanceof exports.VNode.ListItem||e instanceof exports.VNode.RenderSection}appendNodeChildren(e,t,n,o){let s=z(e);if(s)s.appendChild(t);else if(void 0===n)this.elements?.appendChild(t);else if(n)if(n instanceof exports.VNode.Root){const e=n.parent;if(e&&e instanceof exports.VNode.Component&&e.output){const n=e.output,o=n?.parentNode;if(o)return void o.insertBefore(t,n)}this.elements?.appendChild(t)}else if(n instanceof exports.VNode.Element){const e=n.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(n)){const s=n.output?.parentNode;if(void 0!==o&&n.childrens?.length&&s){const i=o-1;if(i<0){const n=ee(e);return void(n&&s.contains(n.output)?n.output.after(t):s.insertBefore(t,s.firstChild))}{const e=n.childrens[i];if(e){const n=e.output;if(n)return void n.after(t)}}}s&&s.insertBefore(t,n.output)}else v(L,"Node does not support nested children",{node:e,parent:n})}setAttribute(e,t,n){if(e)if("boolean"!=typeof n){if("class"===t){if(n){n=oe(n).join(" ")}}else if("style"===t&&i(n)){e.removeAttribute("style");for(const t in n){let o=!1;void 0!==n[t]&&!1!==n[t]||(o=!0);const s=String(n[t]);p(s)&&(o=!0),o||(e.style[t]=s)}return}n=(n??"").toString().trim(),"class"===t&&(n=n.split(/\s/).filter(e=>e.trim()).join(" ")),"value"===t&&"value"in e?e.value=n:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n):e.setAttribute(t,n)}else n?e.setAttribute(t,""):e.removeAttribute(t)}}}(exports.Render||(exports.Render={}));const F={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function q(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(const n in F)if(t?.includes(F[n])&&e.key.toLowerCase()!==n)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function X(e,t){e.output&&e.output.classList.add(t)}function U(e,t){e.output&&e.output.classList.remove(t)}function z(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof exports.VNode.Element)return t.output;if("string"==typeof t){exports.Render.ROOT_CONTAINER&&(t="body"===t?exports.Render.ROOT_CONTAINER:`${exports.Render.ROOT_CONTAINER} ${t}`);const e=document.querySelector(t);if(e)return e}g(L,"Unsupported appendTo type",{appendTo:t,node:e})}}}function Q(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map((t,n)=>Z(t)+Z(e[n])))}function Z(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function ee(e,t){let n=e.prev;for(;n;){if(n instanceof exports.VNode.ListItem==!1)return n;n=n.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof exports.VNode.Element)return;const e=ee(t,!0);if(e)return e;t=t.parent}}}class te extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}function ne(e,t){const n=e.childNodes;for(let e=0;e<n.length;e++){const o=n[e];if(1===o.nodeType){const e=o;e.setAttribute("data-scoped-"+t,""),ne(e,t)}}}function oe(e,t){const n=t||[];if("string"==typeof e){const t=e.trim();t&&!n.includes(t)&&n.push(t)}else Array.isArray(e)?e.forEach(e=>oe(e,n)):null!==e&&"object"==typeof e&&Object.entries(e).forEach(([e,t])=>{if(t){const t=e.trim();t&&!n.includes(t)&&n.push(t)}});return n}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",te);const se={};const ie="Global",re="Render Core";function ae(t,n){try{return new Function(e.EXPRESSHANDLERTAG,ie,`return ${t};`)}catch(e){throw new Error(`An unknown error occurred while creating the expression execution method. \nmessage: ${e.message} \n${n?.()||t}`)}}class de{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,n,o){this.ast=e,this.ob=t,this.parent=n,this.ext=o}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(!this.isDestroy)if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof exports.VNode.Element||this.node instanceof exports.VNode.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&c(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,()=>{t()}))return c(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[exports.VNode.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0,this.ast=void 0,this.ob=void 0,this.ext=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):c(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[exports.VNode.PARSERKEY]&&(t[exports.VNode.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[exports.VNode.PARSERKEY]=this,this.node instanceof exports.VNode.Element&&this.ob[ke]?this.node.attributes["data-scoped-"+this.ob[ke]]=void 0:this.node instanceof exports.VNode.Html&&this.ob[ke]&&(this.node.scopedId=this.ob[ke]),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t,n){try{return ae(e,n).call(t,t,se)}catch(o){v(re,`Expression error:${o.message}\n`+(n?.()||e),{ob:t}),console.error(o)}}runExpressWithWatcher(e,t,n,o,s){if(this.isDestroy)return;let i="string"==typeof e?ae(e,s):e,r=new I(()=>{if(this.isDestroy||t[De])return W;try{return i.call(t,t,se)}catch(n){return v(re,`Expression error:${n.message}\n${s?.()||e}`,{ob:t,express:e,node:this.node}),console.error(n),W}},n,void 0,o);return this.addWatch(r),r.value===W?void 0:r.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach(e=>{e.destroy()}),this.watchers.length=0}}class he extends de{parser(){this.node=new exports.VNode.Text(this.ast.text,this.parent),this.appendNode()}}class ce extends de{parser(){this.node=new exports.VNode.Comment(this.ast.text,this.parent),this.appendNode()}}class le extends de{parser(){if(this.node=new exports.VNode.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){p(this.ast.condition)&&v("Conditional Command",`The current conditional command ${this.ast.kind} has no judgment condition, please check`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[exports.VNode.PARSERKEY];t&&t instanceof le&&t.renderConditionChildren()}}this.reloadAllCondition()}},!1,()=>this.ast._code);this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob,()=>{this.ast._code}),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof exports.VNode.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof le&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof le&&t.renderConditionChildren(),e=e.next}}}class pe extends de{parser(){this.node=new exports.VNode.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,n=Object.create(this.ob),o=!!this.runExpressWithWatcher(function(t,n,o){try{return new Function(e.EXPRESSHANDLERTAG,`${e.EXPRESSHANDLERTAG}.${t}=${n}; return ${o};`)}catch{throw new Error(`Dependency collection for the For loop command expression execution encountered an unknown error. Details: letKey: ${t}, keyVal: ${n}, condition: ${o}`)}}(t.letKey,t.defaultKeyVal,t.condition),n,()=>{this.clearWatchers(),this.renderChildrens()},!0,()=>this.ast._code),s=0;for(;o;){let e=Object.create(this.ob);V(e,t.letKey,n[t.letKey]);let i=s++;this.renderItem(e,i),this.runExpressWithWatcher(()=>n[t.letKey],n,async(n,o,s,r)=>{await Promise.resolve(),r.isDestroy||(e[t.letKey]=n,s||this.updateListItemOb(e,i))},!0,()=>this.ast._code),this.runExpress(t.step,n,()=>{this.ast._code}),o=!!this.runExpress(t.condition,n,()=>this.ast._code)}this.destroyOldChildrens(s)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,()=>{this.clearWatchers(),this.renderChildrens()},!1,()=>this.ast._code),n=0;if(t&&(Array.isArray(t)||a(t)))for(let o in t){let s=Object.create(this.ob),i=Array.isArray(t)?Number(o):o;e.indexKey&&V(s,e.indexKey,i),e.itemKey&&V(s,e.itemKey,t[o]);let r=n++;this.renderItem(s,r,e.indexKey),e.itemKey&&this.runExpressWithWatcher(()=>t[i],t,async(n,o,a,d)=>{await Promise.resolve(),d.isDestroy||i in t&&(s[e.itemKey]=n,a||this.updateListItemOb(s,r))},!0,()=>this.ast._code)}this.destroyOldChildrens(n)}findIndexByIndex(e,t,n){let o=-1;if(this.node)for(let s=t;s<this.node.childrens.length;s++)if(this.checkObEqual(e,this.node.childrens[s]?.ob,n?[n]:void 0)){o=s;break}return o}renderItem(e,t,n){if(!this.ast.childrens?.length||!this.node)return;let o=this.node.childrens?.[t];if(o){if(this.checkObEqual(e,o.ob,n?[n]:void 0))return void(n&&o.ob[n]!==e[n]&&(o.ob[n]=e[n]));let s=this.findIndexByIndex(e,t+1,n);if(s>-1){if(t+1===s)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();else for(let e=0;e<s-t-1;e++)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();return this.renderItem(e,t,n)}return new ue(this.ast,e,this.node,this.ext).init(t)}return new ue(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let n=this.node.childrens?.[t];r(e,(e,t)=>{n.ob[e]!==t&&(n.ob[e]=t)})}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[exports.VNode.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,n){let o=!0;return void 0!==t&&(r(e,(e,s)=>{n?.includes(e)||t?.[e]===s||(o=!1)}),o)}}class ue extends de{parser(e){this.node=new exports.VNode.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class fe extends de{parser(){if(p(this.ast.cmdName))throw v("Template Directive","Error occurred while converting AST to VNode: Directive name not found",this.ast),new Error("Error converting AST to VNode: Directive name not found");let t;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?t=this.ast.param:this.ast.cmdName.startsWith(ie+".")?t=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(t=`${e.createFuntionBody(this.ast.cmdName)}(${this.ast.param})`),t){let e=this.runExpressWithWatcher(`[${t}]`,this.ob,e=>{this.changeValue(e?.[0])},!1,()=>this.ast._code);return e||=[],"Html"===this.ast.cmdName?this.node=new exports.VNode.Html(me(e[0]),this.parent,e[1]):this.node=new exports.VNode.Text(me(e[0]),this.parent),void this.appendNode()}throw new Error("Command not found: "+this.ast.cmdName)}changeValue(e){this.node&&(this.node instanceof exports.VNode.Html?this.node.html=me(e):this.node.text=me(e),this.ext.render?.updateNode(this.node))}}function me(e){return null==e||"function"==typeof e?"":e.toString()}const ye="default";class Ee extends de{parser(){let e=this.transformParam();this.node=new exports.VNode.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach((e,t)=>{V(this.node.ob,e,this.node.params[t])})):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,e=>{let t=e?.[0]||ye;if("string"==typeof t&&t!==this.node.id)throw new Error("The section ID cannot be dynamically changed");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])})},!0,()=>this.ast._code);return{id:e?.[0]||ye,params:e?.slice(1)||[]}}return{id:ye,params:[]}}}const Ne="Component Parsing";function ge(e,t){return!!t.components[e]||!!He(e)}class ve extends de{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new exports.VNode.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally(()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)})}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):g(Ne,"Reload operation is not supported for the current component",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)},!0,()=>{if(e.value)return`express:${e.value} \nfrom <${"tagName"in this.ast?this.ast.tagName:"Component"} ${e.name}="${e.value}" ... /> `});this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(p(e.value)){g(Ne,"The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=T(this.node.propValues)}initEvent(){this.ast.events.forEach(e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:f}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{let o=[];e.functionParam&&(o=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code} \nfrom: <${"tagName"in this.ast?this.ast.tagName:"Component"} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t.call(this.ext.ob,n,...o)}}]):v(Ne,`The callback method (${e.functionName}) specified for the ${e.name} event in the ${"tagName"in this.ast?this.ast.tagName:""} element was not found. Please check.`)})}async renderChildren(){return new Promise(async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||He(this.ast.tagName);if(void 0===e)return void v(Ne,`Failed to render component. Private or global component named '${this.ast.tagName}' not found.`);if(Ke in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let n=this,o=function(){n.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",()=>{this.node?.component.$off("beforeDestroy",o),e(void 0)}),this.node.component.$on("beforeDestroy",o),this.node.component.$mount(this.node),!this.node)return;let s=this.node?.component;s.isKeepAlive&&(this.ast.node=this.node)})}getSections(){let t={},n=[];return this.ast.childrens.forEach(t=>{if(t.type===e.AST.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let o=t,s=t.childrens.some(t=>t.type===e.AST.NodeType.COMMAND&&"section"===t.cmdName),i=o.condition.startsWith(e.EXPRESSHANDLERTAG+".$sections");if(i){return this.runExpress(o.condition,this.ob,()=>o._code)?void n.push(...t.childrens):void 0}if(s&&"if"===o.kind&&!i)return void g(Ne,"While parsing the section, it was found that this section is wrapped in a conditional statement. This conditional statement only supports if judgments using $sections. It has been excluded.")}n.push(t)}),n.forEach(n=>{if(n.type===e.AST.NodeType.COMMAND&&"section"===n.cmdName){let e=n,o=e.id||ye;/^(\'|\")(.*?)((\'|\"))$/.test(o)&&(o=o.slice(1,-1)),t[o]=t[o]||{asts:[],ob:this.ob,params:e.paramKeys,parser:this.ext},t[o].asts.push(...n.childrens||[])}else t[ye]=t[ye]||{asts:[],ob:this.ob,parser:this.ext},t[ye].asts.push(n)}),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0)}}class xe extends de{parser(){this.node=new exports.VNode.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},n=this.runExpressWithWatcher(e.express,this.ob,e=>{t(e)},!1,()=>{if(e.value)return`express:${e.value} \nfrom <${this.ast.tagName} ${e.name}="${e.value}" ... /> `});this.node.attributes[e.name]=this.transformAttrVal(n)}else this.node.attributes[e.name]=e.value;else{if(p(e.value)){g("Element","The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`The callback method (${e.functionName}) specified for the ${e.name} event in the ${this.ast.tagName} element was not found. Please check.`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{if(void 0===t)return;let o=[];e.functionParam&&(o=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code}\nfrom <${this.ast.tagName} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t&&t.call(this.ext.ob,n,...o)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class be{asts;ob;root=new exports.VNode.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,n){this.asts=e,this.ob=t,this.root.component=t,this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,n&&n instanceof exports.VNode.Node&&(this.root.parent=n,n.childrens??=[],n.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(t,n,o){if(0!==this.asts.length)for(let s of t)if(s.type===e.AST.NodeType.TEXT)new he(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.COMMENT)new ce(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.COMPONENT)new ve(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.ELEMENT){let e=s;ge(e.tagName,o??this.ob)?new ve(e,o??this.ob,n,this).init():new xe(e,o??this.ob,n,this).init()}else if(s.type===e.AST.NodeType.COMMAND){let e=s;switch(e.cmdName){case"if":case"elseif":case"else":new le(e,o??this.ob,n,this).init();break;case"for":new pe(e,o??this.ob,n,this).init();break;case"RenderSection":new Ee(e,o??this.ob,n,this).init();break;case"section":break;default:new fe(e,o??this.ob,n,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&c(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){c(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,n,o){this.nodeWatcherEvents[e]?.forEach(e=>{e(t,n,o)})}sleep(e){let t=e||this.root;t.childrens?.forEach(e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,()=>{t()})||t()}),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach(e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")}),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):c(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[exports.VNode.PARSERKEY]&&e[exports.VNode.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,this.asts=e}nodeTransition(e,t,n,o,s){if(e&&e.parent?.childrens&&(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component)){let i=function(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(n??=i?.name,s??=i?.type,!n)return!1;let r=we(e);if(r)return"enter"===t?this.render.elementToEnter(r,n,s,()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),o?.()}):this.render.elementToLeave(r,n,s,()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),o?.()}),!0;g("Render Core","Incomplete data found when executing node animation, please check")}return!1}}function we(e){if(e instanceof exports.VNode.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof exports.VNode.Element?t:we(t)}function Re(e,t,n){if(void 0===t)return;const o=Array.isArray(n)?n:[n];for(const e of o){if(e===Array&&Array.isArray(t))return t;if(typeof t===e.name.toLowerCase())return t}switch(o[0]){case Number:const e=Number(t);if(!isNaN(e))return e;break;case String:return String(t)}throw new Error(`The type of ${e.toString()} in props does not match the constrained type`)}function Ae(e,t,n){let o,s,i;if("symbol"!=typeof t&&(o=u(t)),t in e?s=e[t]:o&&(s=e[o]),n&&(t in n?i=n[t]:o&&o in n&&(i=n[o])),void 0!==i){if(a(i)&&("type"in i||"required"in i||"default"in i||"validate"in i)){const e=i;if(e.required&&void 0===s)throw new Error(`props key:${t.toString()} is required, please check`);if(e.type&&(s=Re(t,s,e.type)),e.validate&&!1===e.validate(s))throw new Error(`Validation failed for props key ${t.toString()}`);s=s??e.default}else s=Ce(i)?Re(t,s,i):s??i;return s}return s}function Ce(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||!!Array.isArray(e)&&Ce(e[0])}function $e(e,t){if(!e.constructor)return!1;let n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return n&&n.get}const Oe="Component",Se=Symbol.for("JOKER_PROPS_DATA_KEY"),Te=Symbol.for("JOKER_PROPS_DATA_PROXY"),Ve=Symbol.for("JOKER_PRIVATE_WATCHERS"),Pe=Symbol.for("JOKER_EVENT_DATA_KEY"),De=Symbol.for("JOKER_IS_DESTROY"),_e=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),ke=Symbol.for("JOKER_SCOPE_ID"),Ke=Symbol.for("JOKER_COMPONENT_TAG"),We=Symbol();let Ie=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class je{$sections;isKeepAlive;static[Ke]=!0;[ke];model={};template;$root;isSleeped=!1;components={};propsOption;[Se]={};[_e];[Te];[Ve]=[];[Pe]=new Map;[De]=!1;[We]=!1;constructor(e,t={},n){this.$sections=t,this.isKeepAlive=n,this[Se]=e||{}}get props(){if(void 0===this[Te]){let e=this;this[Te]=new Proxy(e[Se],{get:(t,n)=>Ae(e[Se],n,e.propsOption),set(){throw new Error("props parameters are not allowed to be changed, only one-way data transfer is allowed")}})}return this[Te]}$mount(e){if(!1===this[We]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach(n=>{!1!==Ie.includes(n)||$e(t,n)||"function"!=typeof t[n]||t[n].prototype?.hasOwnProperty("constructor")||e.push(n)}),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[We]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[_e]&&this.$root?(this[_e].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&Ye(this.$rootVNode),this):(v(Oe,"When attempting to wake up the current component, it was found that the rendering handler has been destroyed. The wake-up operation cannot proceed.",[this,this.$root]),this);this.isSleeped=!1,this.model=T(this.model);let t=this.created(),n=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[De]||(await this.mounted(),this[De]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then(()=>{this[De]||n()}):n(),this}$nextUpdatedRender(e){if(this[De])return;let t=[...this[_e]?.promiseQueue||[]],n=this.$rootVNode?.find(e=>e instanceof exports.VNode.Component);if(n?.forEach(e=>{e?.component&&t.push(...e.component[_e]?.promiseQueue||[])}),t.length)return Promise.all(t).finally(()=>{this[De]||e?.()});this[De]||e?.()}$nodeTransition(e,t,n,o,s){if(this.$root&&!this[De]){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void g(Oe,`Node with ref=${e} not found when executing node animation`);e=t}this[_e]?.nodeTransition(e,t,n,o,s)}}$destroy(e){if(!e&&this.isKeepAlive)return this[_e]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&Be(this.$rootVNode));this[De]=!0;for(let e of this[Ve])e.destroy();this[Ve].length=0,this[_e]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[_e]?.destroy(),this[_e]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[Pe].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[Te]=void 0,this[Se]={},this.destroyed()}get $refs(){return this[_e]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,n){"function"==typeof t&&(n=t,t=void 0),t??=e,n??=e=>e,this.model[t]=n(this.props[e]),this.$watch(()=>this.props[e],()=>{this.model[t]=n?.(this.props[e])})}get $rootVNode(){return this[_e]?.root}$watchNode(e,t){if(this[_e])return this[_e]?.addNodeWatcher(e,t),()=>{this[_e]?.removeNodeWatcher(e,t)};g(Oe,"Component is not yet mounted. Node observation and monitoring cannot be performed.")}$watch(e,t,n){let o=new I(()=>{if(this[De]){for(let e of this[Ve])e.destroy();return W}return e()},(e,n)=>{this[De]||t(e,n)},void 0,n);return this[Ve].push(o),[o.value,()=>{o.destroy(),c(this[Ve],o)}]}$on(e,t){let n=this[Pe].get(e);void 0===n&&(n=new Set,this[Pe].set(e,n)),!1===n?.has(t)&&n.add(t)}$off(e,t){let n=this[Pe].get(e);n&&(t?n.delete(t):n.clear())}get $listeners(){let e={};for(let t in this[Pe])e[t]||=[],e[t].push(...Array.from(this[Pe].get(t)||[]));if(this.$root&&this.$root instanceof exports.VNode.Component)for(let t of this.$root.events){let n=t[0];e[n]||=[],e[n].push(t[1].callBack)}return e}$trigger(e,t,n){if(!this.$root)return;let o={eventName:e,stopPropagation:n?.stopPropagation??(()=>{}),preventDefault:n?.preventDefault??(()=>{}),data:t,target:n?.target??this.$rootVNode,event:n?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof exports.VNode.Component&&!1===this[_e]?.render.triggerEvent(this.$rootVNode.parent,e,o))return;let s=this[Pe].get(e);s?.size&&[...s].forEach(e=>{e(o)});let i=this[Pe].get("*");i?.size&&[...i].forEach(e=>{e(o)})}$render(t,n){t??=this.template,this.template="function"==typeof t?t(e.RENDER_HANDLER):t,this.$root&&(this.template??=[],this[_e]?.reSetAsts(this.template,n),this[_e]??=new be(this.template,this,this.$root),this[_e].parser(),this.$root&&this[_e].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Le={};function Me(e,t){if("string"==typeof e)t&&(Le[e]=t);else for(let t in e)Le[t]=e[t]}function He(e){return Le[e]}function Be(e){e.childrens?.forEach(e=>{e instanceof exports.VNode.Component&&e.component?.sleeped(),Be(e)})}function Ye(e){e.childrens?.forEach(e=>{e instanceof exports.VNode.Component&&e.component?.wakeup(),Ye(e)})}class Je extends je{template=[];cache=new Map;async mounted(){this.$watch(()=>this.props.name,async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)}),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach(t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch(()=>this.props[t],()=>{this.propsVaule[t]=this.props[t]}))}),this.propsVaule=T(e))}filterProps(e){if("string"!=typeof e)return!1;let t=u(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(t){if(!t)return void this.$render([],this.isKeepAlive);let n;if(this.isKeepAlive){let n=this.cache.get(t);if(n)return void this.$render([e.createComponent(n,{"transition-name":this.props["transition-name"]})],!0)}let o=this.$rootVNode?.parent?.[exports.VNode.PARSERKEY]?.ob.components,s=o?.[t];void 0===s&&(s=He(t)),s?(Ke in s||(s=(await s()).default),n=new s(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),n.$on("*",e=>{this.$trigger(e.eventName,e.data,e)}),this.isKeepAlive&&this.cache.set(t,n),this.$render([e.createComponent(n,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):g("component",`Component ${t} not found`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach(e=>{e.$destroy(!0)}),this.cache.clear()}}class Ge extends je{template=function(){return[e.createCommand("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}Me({template:Ge,component:Je});Object.defineProperty(exports,"AST",{enumerable:!0,get:function(){return e.AST}}),Object.defineProperty(exports,"EXPRESSHANDLERTAG",{enumerable:!0,get:function(){return e.EXPRESSHANDLERTAG}}),Object.defineProperty(exports,"RENDER_HANDLER",{enumerable:!0,get:function(){return e.RENDER_HANDLER}}),Object.defineProperty(exports,"createCodeFunction",{enumerable:!0,get:function(){return e.createCodeFunction}}),Object.defineProperty(exports,"createCommand",{enumerable:!0,get:function(){return e.createCommand}}),Object.defineProperty(exports,"createComment",{enumerable:!0,get:function(){return e.createComment}}),Object.defineProperty(exports,"createComponent",{enumerable:!0,get:function(){return e.createComponent}}),Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return e.createElement}}),Object.defineProperty(exports,"createFuntionBody",{enumerable:!0,get:function(){return e.createFuntionBody}}),Object.defineProperty(exports,"createText",{enumerable:!0,get:function(){return e.createText}}),exports.BREAK_WATCH_UPDATE=W,exports.Component=je,exports.ComponentContainer=Je,exports.Dep=w,exports.EventBus=class{eventDatas=new Map;on(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const o={callBack:t};return n.push(o),()=>{n&&c(n,o)}}once(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const o={callBack:t,once:!0};return n.push(o),()=>{n&&c(n,o)}}off(e,t){if(void 0!==e)if(t){const n=this.eventDatas.get(e),o=n?.find(e=>e.callBack===t);o&&c(n,o)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let n=[...this.eventDatas.get(e)||[]];if(n.push(...this.eventDatas.get("*")||[]),n&&n.length){let o=0,s=0,i=!1;for(;n[o];){const r=n[o],a=await r.callBack({stopPropagation:()=>i=!0,callTimes:s,eventName:e},t);if(r.once?c(n,r):o++,!1===a||i)return!1}}}},exports.IS_DESTROY=De,exports.JOKER_COMPONENT_TAG=Ke,exports.JOKER_VNODE_TAG=j,exports.OBJECTPROXY_DEPID=R,exports.PARSER_TEMPLATE_TARGET=_e,exports.ParserTemplate=be,exports.SCOPE_ID=ke,exports.ShallowObserver=class{data;[P]=!0;dep=new w;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(C),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,k(this.dep,C))}},exports.Template=Ge,exports.Watcher=I,exports.__GLONAL_FUNTIONS__=se,exports.__JOKER_HMR_RUNTIME=s,exports.combinedReply=function(e){D=!0;try{e()}catch(e){return D=!1,_.clear(),void v("Data Hijacking","Encountered a blocking error while collecting changes for data hijacking composite responses. No action will be taken. Please investigate.",e)}D=!1,function(e){const t=[],n=[];e.forEach((e,n)=>{e.forEach(e=>{t.push(...n.watchers.get(e)||[])})}),t.forEach(e=>{n.includes(e)||(!e.isDestroy&&e.update(),n.push(e))})}(_),_.clear()},exports.defineObserverProperty=V,exports.getGlobalComponent=He,exports.isObserverData=function(e){return void 0!==S(e)},exports.observer=T,exports.registerGlobalComponent=Me,exports.registerGlobalFunction=function(e){for(const t in e)se[t]=e[t]};
1
+ "use strict";var e=require("@joker.front/ast");const t=new Map,n=new Map,o=new Map;let s={recordRender:(e,t)=>{n.set(e,t)},recordComponent:(e,t)=>{o.set(e,t)},record:(e,n)=>{void 0===t.get(e)&&t.set(e,new Set),t.get(e).add(n),n.$on("destroy",()=>{t.get(e)?.delete(n)})},reload:(e,n)=>{let s=o.get(e);if(!s)return;s.component=n;let i=t.get(e);if(!i)return;let r=Array.from(i);i.clear(),r.forEach(e=>{if(e.$root){if(!e.$rootVNode?.parent)return window.onbeforeunload=null,void location.reload();{let t=e.$rootVNode.parent;if(!(t instanceof exports.VNode.Component&&t[exports.VNode.PARSERKEY]&&t[exports.VNode.PARSERKEY].canReload))return window.onbeforeunload=null,void location.reload();t[exports.VNode.PARSERKEY].reload()}}})},rerender:(e,o)=>{let s=n.get(e);s&&(s.render=o),t.get(e)?.forEach(e=>{e.$render(o)})}};function i(e){return null!==e&&"object"==typeof e}function r(e,t){Object.getOwnPropertyNames(e).forEach(n=>{t(n,e[n])})}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}function d(e){if(null===e)return e;if("object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};let n=Object.keys(e);for(let o of n){let n=e[o];t[o]="object"==typeof n?d(n):n}return t}function h(e,t,n){if(e===t)return!0;let o=i(e),s=i(t);if(o&&s){if(a(e)&&a(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(e[o]!==t[o])return!1;return!0}return e===t}return!o&&!s&&String(e)===String(t)}function c(e,t){let n=e.indexOf(t);return n>-1&&e.splice(n,1),e}function l(e,t){let n=e.findIndex(e=>t(e));return n>-1&&e.splice(n,1),e}function p(e){return!e||""===e.trim()}function u(e,t="-"){return(e=e||"").split(/(?=[A-Z])/).map(e=>e.toLowerCase()).join(t)}let f=(...e)=>{},m="warn";const y=["silent","error","warn","info"];function E(){let e=new Date;function t(e,t=2){return e.toString().padStart(t,"0")}return t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+":"+t(e.getMilliseconds(),3)}function N(e,t,n,o){y.indexOf(e)<=y.indexOf(m)&&(void 0===o?console[e](`${E()} [${t}]:`,n):console[e](`${E()} [${t}]:`,n,o))}let g=function(e,t,n){N("warn",e,t,n)},v=function(e,t,n){N("error",e,t,n)};const x={lt:"<",gt:">",nbsp:" ",amp:"&",quot:'"',"#39":"'"};function b(e){return e.replace(/&(lt|gt|nbsp|amp|quot|#39);/gi,(e,t)=>x[t]||"")}class w{static target;watchers=new Map;depend(e){w.target?.addDep(this,e)}addWatcher(e,t){let n=this.watchers.get(e)||[];n.push(t),this.watchers.set(e,n)}removeWatcher(e,t){const n=this.watchers.get(e);n&&c(n,t)}notify(e){const t=this.watchers.get(e);if(t){l(t,e=>e.isDestroy);[...t].forEach(e=>{e.isDestroy||e.update()})}}}const R=Symbol.for("__JOKER_OBJECT_PROXY_DEP_ID__"),A=Symbol.for("__JOKER_OBJECT_PROXY_DATA_KEY__"),C=Symbol.for("__JOKER_OBJECTPROXY_DEPLEVE_ID__");function $(e){try{return null!=e&&i(e)&&e!==window.parent&&e instanceof Window==!1&&e instanceof I==!1&&e instanceof je==!1&&e instanceof be==!1&&(Array.isArray(e)||a(e)||e instanceof Set||e instanceof Map)&&!Object.isFrozen(e)&&!(e instanceof Element)&&!(j in e)&&!(P in e)&&!(Ke in e)}catch{return!1}}function O(e){if(S(e))return e;if(e&&e.hasOwnProperty(A)){let t=Reflect.get(e,A);if(t)return t}let t=new w,n=!0,o=new Proxy(e,{get(e,n,o){if(e instanceof Set||e instanceof Map){if("add"===n){let o=Reflect.get(e,n);return n=>{$(n)&&(n=T(n));let s=o.call(e,n);return k(t,"size"),k(t,C),s}}if("set"===n){let o=Reflect.get(e,n);return(n,s)=>{$(s)&&(s=T(s));let i=o.call(e,n,s);return k(t,"size"),k(t,C),i}}if("delete"===n||"clear"===n){let o=Reflect.get(e,n);return s=>{let i=o.call(e,s);return("clear"===n||i)&&(k(t,"size"),k(t,C)),i}}let o=Reflect.get(e,n);if("function"==typeof o)return o.bind(e)}if(n===A)return;if(n===R)return t;if(n===C)return;let s=Reflect.get(e,n);return n===Symbol.toStringTag||!1===function(e,t){return t in e}(e,n)&&"length"!==n&&"size"!==n||(t.depend(n),$(s)&&S(s)?.depend(C)),s},set(e,o,s){if(n)return Reflect.set(e,o,s),!0;$(s)&&(s=T(s));let i=!1===function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(e,o),r=Reflect.get(e,o)!==s;return Reflect.set(e,o,s),(r||"length"===o&&Array.isArray(e))&&k(t,o),Array.isArray(e)?"length"===o&&k(t,C):i&&k(t,C),!0},deleteProperty:(e,n)=>(Reflect.deleteProperty(e,n),!1===Array.isArray(e)&&k(t,C),!0)});!function(e,t,n,o){Object.defineProperty(e,t,{value:n,enumerable:o,writable:!0,configurable:!0})}(e,A,o,!1);for(let t in e){let n=e[t];$(n)&&!S(n)&&(o[t]=O(e[t]))}return n=!1,o}function S(e){if(i(e))return Reflect.get(e,R)}function T(e,t=!1){if(!1===$(e))throw new Error("The provided data is not of the correct type. It must be an array or an object.");return O(t?d(e):e)}function V(e,t,n){let o=n;$(n)&&(o=T(n));let s=new w;Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:()=>(s.depend(t),S(o)?.depend(C),o),set:e=>{e!==o&&($(e)&&(e=T(e)),o=e,k(s,t))}})}const P=Symbol.for("JOKER_SHALLOW_OBSERVER");let D=!1,_=new Map;function k(e,t){if(!1===D)e.notify(t);else{let n=_.get(e);void 0===n&&(n=[],_.set(e,n)),n.includes(t)||n.push(t)}}const K="Data Observation",W=Symbol.for("JOKER_BREAK_WATCH_UPDATE");class I{ob;updateCallBack;forceCallBack;getter;value;isDestroy=!1;updating=!1;runRelations=new Map;relations=new Map;constructor(e,t,n,o){if(this.ob=e,this.updateCallBack=t,this.forceCallBack=o,void 0===e)throw new Error("Cannot observe changes on undefined");if(void 0===n)this.getter=e=>e;else if("function"==typeof n)this.getter=n;else{const e=function(e){if(/[^\w.$]/.test(e))return;const t=e.split(".");return function(e){let n=e;return t.forEach(e=>{n&&(n=n[e])}),n}}(n);if(void 0===e)throw new Error(`${n} failed to parse. Unable to interpret the expression. Please check the expOrFn parameter or use the function mode instead.`);this.getter=e}void 0===this.getter&&v(K,"Failed to create getter",arguments),this.value=this.getValue()}getValue(){if(void 0===this.getter)return;w.target=this;const e="function"==typeof this.ob?this.ob():this.ob;let t;try{t=this.getter.call(e,e)}catch(e){throw v(K,"Failed to retrieve value. Executed method: "+this.getter.toString()),e}return w.target=void 0,this.clearnDeps(),t}addDep(e,t){let n=this.runRelations.get(e);if(void 0===n||!n.includes(t)){n=n||[],n.push(t),this.runRelations.set(e,n);const o=this.relations.get(e);void 0!==o&&o.includes(t)||e.addWatcher(t,this)}}update(){if(this.updating)return;const e=this.getValue();if(e===W)return;const t=this.value;if(this.forceCallBack||e!==t||i(e)){this.value=e;const n=e!==t&&function(e,t){return Array.isArray(e)&&Array.isArray(t)?function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(e,t):h(e,t)}(e,t);if(n&&!this.forceCallBack)return;this.updating=!0;try{this.updateCallBack(e,t,n,this)}catch(e){throw e}finally{this.updating=!1}}}destroy(){this.relations.forEach((e,t)=>{for(const n of e)t.removeWatcher(n,this)}),this.isDestroy=!0,this.relations.clear(),this.runRelations.clear(),this.ob=void 0,this.value=void 0,this.getter=void 0,this.updateCallBack=void 0}clearnDeps(){this.relations.forEach((e,t)=>{const n=this.runRelations.get(t);for(const o of e)n&&n.includes(o)||t.removeWatcher(o,this)}),this.relations.clear(),this.relations=this.runRelations,this.runRelations=new Map}}exports.IContainer=void 0,function(e){let t=new Map;e.bind=function(e){return{to:n=>{if(t.has(e))throw new Error(`TagId:${e.toString()} already has an implementation bound. Do not bind again.`);t.set(e,n)}}},e.get=function(e,...n){const o=t.get(e);if(o)return new o(...n)}}(exports.IContainer||(exports.IContainer={}));const j=Symbol.for("JOKER_VNODE_TAG");exports.VNode=void 0,function(e){e.PARSERKEY=Symbol.for("JOKER_PARSER_KEY");class t{parent;[j]=!0;static;output;[e.PARSERKEY];childrens;ref;sleep=!1;constructor(e){this.parent=e}get prev(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)-1]}get next(){if(this.parent)return this.parent.childrens?.[this.parent.childrens?.indexOf(this)+1]}closest(e,t){if(!0===e(this))return this;let n=this.parent;for(;n;){if(!0===e(n))return n;if(!0===t?.(n))break;n=n.parent}}find(e,t,n,o,s){let i=s??[];if(o??=this.childrens,o)for(let s of o){(!0!==e(s)||(i.push(s),n))&&(!0!==t?.(s)&&s.childrens&&this.find(e,t,n,s.childrens,i))}return i}contains(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return!0;if(n.childrens&&n.childrens.length&&this.contains(e,n.childrens))return!0}return!1}first(e,t){if(t??=this.childrens,t)for(let n of t){if(!0===e(n))return n;if(n.childrens&&n.childrens.length){let t=this.first(e,n.childrens);if(t)return t}}}}e.Node=t;e.Root=class extends t{childrens=[];component;constructor(){super()}};e.Text=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Html=class extends t{html;notShadow;static=!0;scopedId;constructor(e,t,n){super(t),this.html=e,this.notShadow=n}};e.Comment=class extends t{text;static=!0;constructor(e,t){super(t),this.text=e}};e.Element=class extends t{tagName;static=!0;attributes={};childrens=[];events=[];_assistEventCache;constructor(e,t){super(t),this.tagName=e}};e.Component=class extends t{name;component;events=[];propValues={};keepalive;get firstElement(){if(this.childrens){let t=n=>{for(let o of n){if(o instanceof e.Element)return o;if(o.childrens){let e=t(o.childrens);if(e)return e}}};return t(this.childrens)}}get rootElements(){if(this.childrens){let t=[],n=o=>{for(let s of o)s instanceof e.Element||s instanceof e.Html?t.push(s):s.childrens&&n(s.childrens)};return n(this.childrens),t}return[]}};e.Condition=class extends t{cmdName;result=!1;childrens=[];isShow=!1;constructor(e,t){super(t),this.cmdName=e}};e.List=class extends t{childrens=[]};e.ListItem=class extends t{ob;childrens=[];constructor(e,t){super(t),this.ob=e}};e.RenderSection=class extends t{id="unknown";params=[];section;childrens=[];ob;constructor(e,t){super(t),"string"==typeof e?this.id=e:this.section=e}}}(exports.VNode||(exports.VNode={}));const L="DOM Rendering",M=["script","style","textarea","pre"];let H=0;const B=["svg","defs","use","rect","circle","ellipse","line","polyline","polygon","path","text","g"];function Y(e,t,n){return`${e}-${t}-${n}`}function J(e,t,n,o){e._assistEventCache??=[],e._assistEventCache.push([t,n]),document.body.addEventListener(t,n,o)}function G(e,t,n){e._assistEventCache&&t&&n?(l(e._assistEventCache,e=>e[0]===t&&e[1]===n),document.body.removeEventListener(t,n)):(e._assistEventCache?.forEach(e=>{document.body.removeEventListener(e[0],e[1])}),e._assistEventCache&&(e._assistEventCache.length=0),e._assistEventCache=void 0)}exports.Render=void 0,function(e){e.IRENDERIOCTAGID=Symbol.for("JOKER_IRENDERIOC_TAGID"),e.ROOT_CONTAINER="";e.DomRender=class{elements;constructor(){this.elements=document.createDocumentFragment()}mount(e){if(e instanceof Element)e.appendChild(this.elements);else if(e instanceof exports.VNode.Component)if(e.parent)if(e.output){const t=e.output,n=z(e)||t.parentNode;n&&n.insertBefore(this.elements,t)}else v(L,"Component mount found no DOM target node",e);else v(L,"Mounting child component with no parent",e);else v(L,"Mount only supports Element or VNode.Node",e)}appendNode(e,t){if(this.renderNode(e),e.output){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];for(const o of n)this.appendNodeChildren(e,o,e.parent,t);return}v(L,"No output found for node, cannot mount",e)}updateNode(e,t){if(e instanceof exports.VNode.Element)for(const t in e.attributes){const n=e.attributes[t];this.setAttribute(e.output,t,n)}else e instanceof exports.VNode.Text?e.parent&&e.parent instanceof exports.VNode.Element&&M.includes(e.parent.tagName)?(this.removeNode(e),this.appendNode(e)):e.output.textContent=b(e.text||""):e instanceof exports.VNode.Html?e.notShadow?(e.output.innerHTML=e.html,e.scopedId&&ne(e.output,e.scopedId)):e.output.root.innerHTML=e.html:v(L,`Node does not support ${t} update`,e)}removeNode(e,t){const n=e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output];n?.forEach(e=>e?.remove()),t||(e instanceof exports.VNode.Element&&G(e),e.output=void 0)}destroy(){this.elements=void 0}elementToEnter(e,t,n,o){e.output&&this.transitionFrame(e,t,"enter",n,o)}elementToLeave(e,t,n,o){e.output&&this.transitionFrame(e,t,"leave",n,o)}triggerEvent(e,t,n){const o=[];for(const s of e.events){const[i,r]=s;if(i===t){const t=r.modifiers?.includes("self"),a=r.modifiers?.includes("outside");if(t||a){g(L,"Event modifiers 'self' and 'outside' not supported in components",e);continue}const d=n.event;if((d instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(i)||d instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(i))&&!1===q(d,r.modifiers))continue;if(r.callBack(n),r.modifiers?.includes("prevent")&&n.preventDefault(),r.modifiers?.includes("once")&&o.push(s),r.modifiers?.includes("stop"))return n.stopPropagation(),!1}}o.length&&o.forEach(t=>c(e.events,t))}transitionFrame(e,t,n,o,s){X(e,Y(t,n,"from")),o||="transition";const i=e.output.__TRANSITION_EVNETID__=H++;requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(!e.output)return;X(e,Y(t,n,"active")),U(e,Y(t,n,"from")),X(e,Y(t,n,"to"));const r=function(e,t){const n=window.getComputedStyle(e),o=e=>(n[e]||"").split(", ");if("transition"===t){const e=o("transitionDelay"),t=o("transitionDuration"),n=Q(e,t);if(n>0)return{timeout:n,count:t.length}}else if("animation"===t){const e=o("animationDelay"),t=o("animationDuration"),n=Q(e,t);if(n>0)return{timeout:n,count:t.length}}}(e.output,o);if(!r)return void s?.();let a=0;const d=()=>{U(e,Y(t,n,"to")),U(e,Y(t,n,"active")),e.output&&(e.output.removeEventListener(`${o}end`,h),i===e.output.__TRANSITION_EVNETID__&&s?.())},h=t=>{t.target===e.output&&++a>=r.count&&d()};setTimeout(()=>{a<r.count&&d()},r.timeout+1),e.output?.addEventListener(`${o}end`,h)})})}renderNode(e){if(!e.output)if(e instanceof exports.VNode.Text)e.parent&&e.parent instanceof exports.VNode.Element&&M.includes(e.parent.tagName)?e.output=this.parserHtml(e.text):e.output=document.createTextNode(b(e.text||""));else if(e instanceof exports.VNode.Html)if(e.notShadow){const t=document.createElement("joker-html-container");t.JOKER_NODE=e,t.innerHTML=e.html,e.scopedId&&(t.setAttribute("data-scoped-"+e.scopedId,""),ne(t,e.scopedId)),e.output=t}else{const t=document.createElement("joker-html-shadow");t.JOKER_NODE=e,t.style.lineHeight="1",t.root.innerHTML=e.html,e.output=t}else if(e instanceof exports.VNode.Element){let t;const n=e.tagName.toLowerCase();"svg"===n||B.includes(n)||e.parent?.inSvg?(e.inSvg=!0,t=document.createElementNS("http://www.w3.org/2000/svg",e.tagName)):t=document.createElement(e.tagName);for(const n in e.attributes)this.setAttribute(t,n,e.attributes[n]);t.JOKER_NODE=e,e.output=t,e.events.some(e=>"click"===e[0]&&e[1].modifiers?.includes("outside"))?setTimeout(()=>{this.initElementEvents(t,e)}):this.initElementEvents(t,e)}else e instanceof exports.VNode.Comment?e.output=document.createComment(e.text):e.output=document.createTextNode("")}initElementEvents(e,t){for(const[n,o]of t.events){const s=o.modifiers?.includes("self");let i=o.modifiers?.includes("outside");s&&i&&(g(L,"Event modifiers 'self' and 'outside' cannot coexist, using 'self'",t),i=!1);const r=a=>{if(!(t.sleep||s&&a.target!==e)){if(i){if(a.target===e||e.contains(a.target))return;if(!1===document.contains(a.target))return;if(t.contains(e=>(e.output instanceof HTMLCollection||e.output instanceof NodeList||Array.isArray(e.output)?Array.from(e.output):[e.output]).includes(a.target)))return!0}(a instanceof KeyboardEvent&&["keydown","keypress","keyup"].includes(n)||a instanceof MouseEvent&&["click","dbclick","mouseup","mousedown"].includes(n))&&!1===q(a,o.modifiers)||(o.callBack({eventName:n,event:a,target:t,preventDefault:()=>a.preventDefault(),stopPropagation:()=>a.stopPropagation(),data:void 0}),o.modifiers?.includes("prevent")&&a.preventDefault(),o.modifiers?.includes("stop")&&a.stopPropagation(),o.modifiers?.includes("once")&&(i?G(t,n,r):e.removeEventListener(n,r)))}};let a;o.modifiers?.includes("passive")&&(a={passive:!0}),i?J(t,n,r,a):e.addEventListener(n,r,a)}}parserHtml(e){const t=document.createElement("div");return t.innerHTML=e,t.childNodes}isCommandGroup(e){return e instanceof exports.VNode.Component||e instanceof exports.VNode.Condition||e instanceof exports.VNode.List||e instanceof exports.VNode.ListItem||e instanceof exports.VNode.RenderSection}appendNodeChildren(e,t,n,o){let s=z(e);if(s)s.appendChild(t);else if(void 0===n)this.elements?.appendChild(t);else if(n)if(n instanceof exports.VNode.Root){const e=n.parent;if(e&&e instanceof exports.VNode.Component&&e.output){const n=e.output,o=n?.parentNode;if(o)return void o.insertBefore(t,n)}this.elements?.appendChild(t)}else if(n instanceof exports.VNode.Element){const e=n.output;if(void 0===e)return;e.appendChild(t)}else if(this.isCommandGroup(n)){const s=n.output?.parentNode;if(void 0!==o&&n.childrens?.length&&s){const i=o-1;if(i<0){const n=ee(e);return void(n&&s.contains(n.output)?n.output.after(t):s.insertBefore(t,s.firstChild))}{const e=n.childrens[i];if(e){const n=e.output;if(n)return void n.after(t)}}}s&&s.insertBefore(t,n.output)}else v(L,"Node does not support nested children",{node:e,parent:n})}setAttribute(e,t,n){if(e)if("boolean"!=typeof n){if("class"===t){if(n){n=oe(n).join(" ")}}else if("style"===t&&i(n)){e.removeAttribute("style");for(const t in n){let o=!1;void 0!==n[t]&&!1!==n[t]||(o=!0);const s=String(n[t]);p(s)&&(o=!0),o||(e.style[t]=s)}return}n=(n??"").toString().trim(),"class"===t&&(n=n.split(/\s/).filter(e=>e.trim()).join(" ")),"value"===t&&"value"in e?e.value=n:"xlink:href"===t?e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n):e.setAttribute(t,n)}else n?e.setAttribute(t,""):e.removeAttribute(t)}}}(exports.Render||(exports.Render={}));const F={enter:"enter",backspace:"delete",tab:"tab",arrowup:"up",arrowdown:"down",arrowleft:"left",arrowright:"right",escape:"esc"," ":"space"};function q(e,t){if(e instanceof KeyboardEvent){if(void 0===e.key)return!1;for(const n in F)if(t?.includes(F[n])&&e.key.toLowerCase()!==n)return!1}else{if(t?.includes("left")&&0!==e.button)return!1;if(t?.includes("right")&&2!==e.button)return!1;if(t?.includes("middle")&&1!==e.button)return!1}return(!t?.includes("ctrl")||!1!==e.ctrlKey)&&((!t?.includes("alt")||!1!==e.altKey)&&(!t?.includes("shift")||!1!==e.shiftKey))}function X(e,t){e.output&&e.output.classList.add(t)}function U(e,t){e.output&&e.output.classList.remove(t)}function z(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Component?e.propValues["append-to"]:e.attributes["append-to"];if(t){if(t instanceof exports.VNode.Element)return t.output;if("string"==typeof t){exports.Render.ROOT_CONTAINER&&(t="body"===t?exports.Render.ROOT_CONTAINER:`${exports.Render.ROOT_CONTAINER} ${t}`);const e=document.querySelector(t);if(e)return e}g(L,"Unsupported appendTo type",{appendTo:t,node:e})}}}function Q(e,t){for(;e.length<t.length;)e.concat(e);return Math.max(...t.map((t,n)=>Z(t)+Z(e[n])))}function Z(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function ee(e,t){let n=e.prev;for(;n;){if(n instanceof exports.VNode.ListItem==!1)return n;n=n.prev}if(!t){let t=e.parent;for(;t;){if(t instanceof exports.VNode.Element)return;const e=ee(t,!0);if(e)return e;t=t.parent}}}class te extends HTMLElement{root;constructor(){super(),this.root=this.attachShadow({mode:"open"})}}function ne(e,t){const n=e.childNodes;for(let e=0;e<n.length;e++){const o=n[e];if(1===o.nodeType){const e=o;e.setAttribute("data-scoped-"+t,""),ne(e,t)}}}function oe(e,t){const n=t||[];if("string"==typeof e){const t=e.trim();t&&!n.includes(t)&&n.push(t)}else Array.isArray(e)?e.forEach(e=>oe(e,n)):null!==e&&"object"==typeof e&&Object.entries(e).forEach(([e,t])=>{if(t){const t=e.trim();t&&!n.includes(t)&&n.push(t)}});return n}!customElements.get("joker-html-shadow")&&customElements.define("joker-html-shadow",te);const se={};const ie="Global",re="Render Core";function ae(t,n){try{return new Function(e.EXPRESSHANDLERTAG,ie,`return ${t};`)}catch(e){throw new Error(`An unknown error occurred while creating the expression execution method. \nmessage: ${e.message} \n${n?.()||t}`)}}class de{ast;ob;parent;ext;ref="";watchers=[];node;isDestroy=!1;constructor(e,t,n,o){this.ast=e,this.ob=t,this.parent=n,this.ext=o}init(e){this.parser(e),this.afterParser()}beforeDestroy(e){}destroy(e){if(!this.isDestroy)if(this.isDestroy=!0,this.clearWatchers(),this.parent.childrens&&this.node){(this.node instanceof exports.VNode.Element||this.node instanceof exports.VNode.Component)&&this.ext.removeRef(this.node);let t=()=>{this.parent&&this.node&&(this.beforeDestroy(e),this.destroyChildrens(e),this.node&&(this.ext.render?.removeNode(this.node),this.parent.childrens&&c(this.parent.childrens,this.node),this.notifyNodeWatcher("remove"),this.destroyOtherData()))};if(this.ext.nodeTransition(this.node,"leave",void 0,()=>{t()}))return c(this.parent.childrens,this.node),void this.destroyChildrensWatcher(this.node);t()}else this.destroyOtherData()}destroyWathcers(){this.clearWatchers(),this.destroyChildrensWatcher(this.node)}destroyOtherData(){this.node&&(this.node[exports.VNode.PARSERKEY]=void 0),this.node=void 0,this.parent=void 0,this.ast=void 0,this.ob=void 0,this.ext=void 0}destroyChildrens(e){for(;this.node?.childrens?.length;){let t=this.node.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):c(this.node.childrens,t)}}destroyChildrensWatcher(e){if(e?.childrens?.length)for(let t of e?.childrens)t[exports.VNode.PARSERKEY]&&(t[exports.VNode.PARSERKEY].clearWatchers(),this.destroyChildrensWatcher(t))}appendNode(e){this.parent?.childrens&&this.node&&!this.isDestroy&&(this.node[exports.VNode.PARSERKEY]=this,this.node instanceof exports.VNode.Element&&this.ob[ke]?this.node.attributes["data-scoped-"+this.ob[ke]]=void 0:this.node instanceof exports.VNode.Html&&this.ob[ke]&&(this.node.scopedId=this.ob[ke]),this.ext.render?.appendNode(this.node,e),void 0===e?this.parent.childrens.push(this.node):this.parent.childrens.splice(e,0,this.node),this.notifyNodeWatcher("append"))}afterParser(){this.ext.nodeTransition(this.node,"enter")}notifyNodeWatcher(e,t){this.ext.notifyNodeWatcher(this.ref,this.node,e,t)}runExpress(e,t,n){try{return ae(e,n).call(t,t,se)}catch(o){v(re,`Expression error:${o.message}\n`+(n?.()||e),{ob:t}),console.error(o)}}runExpressWithWatcher(e,t,n,o,s){if(this.isDestroy)return;let i="string"==typeof e?ae(e,s):e,r=new I(()=>{if(this.isDestroy||t[De])return W;try{return i.call(t,t,se)}catch(n){return v(re,`Expression error:${n.message}\n${s?.()||e}`,{ob:t,express:e,node:this.node}),console.error(n),W}},n,void 0,o);return this.addWatch(r),r.value===W?void 0:r.value}addWatch(e){!1===this.watchers.includes(e)&&this.watchers.push(e)}clearWatchers(){this.watchers.forEach(e=>{e.destroy()}),this.watchers.length=0}}class he extends de{parser(){this.node=new exports.VNode.Text(this.ast.text,this.parent),this.appendNode()}}class ce extends de{parser(){this.node=new exports.VNode.Comment(this.ast.text,this.parent),this.appendNode()}}class le extends de{parser(){if(this.node=new exports.VNode.Condition(this.ast.kind,this.parent),"else"!==this.ast.kind){p(this.ast.condition)&&v("Conditional Command",`The current conditional command ${this.ast.kind} has no judgment condition, please check`);let e=this.runExpressWithWatcher(this.ast.condition,this.ob,e=>{let t=!!e;if(this.node?.result!==t){if(this.node.result=t,!1===t&&this.node?.isShow)this.destroyChildrens(!0);else if(t&&!this.node?.isShow){let e=this.getElseNode();if(e&&e.isShow&&e.childrens?.length){let t=e[exports.VNode.PARSERKEY];t&&t instanceof le&&t.renderConditionChildren()}}this.reloadAllCondition()}},!1,()=>this.ast._code);this.node.result=!!e}this.appendNode(),this.renderConditionChildren()}renderId;getElseNode(){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){if("else"===e.cmdName)return e;e=e.next}}renderConditionChildren(){let e=!1;return this.getPrevIfResult()?e=!1:"else"===this.ast.kind?e=!0:(this.node.result=!!this.runExpress(this.ast.condition,this.ob,()=>{this.ast._code}),this.node.result&&(e=!0)),e!==this.node.isShow&&(this.node.isShow=e,this.destroyChildrens(!0),e&&this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob),!0)}getPrevIfResult(){if("if"===this.ast.kind)return!1;let e=this.node?.prev;for(;e&&e instanceof exports.VNode.Condition;){if(e.result)return!0;if("if"===e.cmdName)break;e=e.prev}return!1}reloadAllCondition(){if(this.renderConditionChildren()){let e=this.node?.next;for(;e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof le&&t.renderConditionChildren(),e=e.next}}let e=this.node?.next;for(this.node?.result||this.destroyChildrens(!0);e&&e instanceof exports.VNode.Condition&&"if"!==e.cmdName;){let t=e[exports.VNode.PARSERKEY];t&&t instanceof le&&t.renderConditionChildren(),e=e.next}}}class pe extends de{parser(){this.node=new exports.VNode.List(this.parent),this.appendNode(),this.renderChildrens()}renderChildrens(){switch(this.ast.keyType){case"condition":this.renderConditionChildrens();break;case"in":case"of":this.renderInOrOfChildrens()}}renderConditionChildrens(){let t=this.ast.param,n=Object.create(this.ob),o=!!this.runExpressWithWatcher(function(t,n,o){try{return new Function(e.EXPRESSHANDLERTAG,`${e.EXPRESSHANDLERTAG}.${t}=${n}; return ${o};`)}catch{throw new Error(`Dependency collection for the For loop command expression execution encountered an unknown error. Details: letKey: ${t}, keyVal: ${n}, condition: ${o}`)}}(t.letKey,t.defaultKeyVal,t.condition),n,()=>{this.clearWatchers(),this.renderChildrens()},!0,()=>this.ast._code),s=0;for(;o;){let e=Object.create(this.ob);V(e,t.letKey,n[t.letKey]);let i=s++;this.renderItem(e,i),this.runExpressWithWatcher(()=>n[t.letKey],n,async(n,o,s,r)=>{await Promise.resolve(),r.isDestroy||(e[t.letKey]=n,s||this.updateListItemOb(e,i))},!0,()=>this.ast._code),this.runExpress(t.step,n,()=>{this.ast._code}),o=!!this.runExpress(t.condition,n,()=>this.ast._code)}this.destroyOldChildrens(s)}renderInOrOfChildrens(){let e=this.ast.param,t=this.runExpressWithWatcher(e.dataKey,this.ob,()=>{this.clearWatchers(),this.renderChildrens()},!1,()=>this.ast._code),n=0;if(t&&(Array.isArray(t)||a(t)))for(let o in t){let s=Object.create(this.ob),i=Array.isArray(t)?Number(o):o;e.indexKey&&V(s,e.indexKey,i),e.itemKey&&V(s,e.itemKey,t[o]);let r=n++;this.renderItem(s,r,e.indexKey),e.itemKey&&this.runExpressWithWatcher(()=>t[i],t,async(n,o,a,d)=>{await Promise.resolve(),d.isDestroy||i in t&&(s[e.itemKey]=n,a||this.updateListItemOb(s,r))},!0,()=>this.ast._code)}this.destroyOldChildrens(n)}findIndexByIndex(e,t,n){let o=-1;if(this.node)for(let s=t;s<this.node.childrens.length;s++)if(this.checkObEqual(e,this.node.childrens[s]?.ob,n?[n]:void 0)){o=s;break}return o}renderItem(e,t,n){if(!this.ast.childrens?.length||!this.node)return;let o=this.node.childrens?.[t];if(o){if(this.checkObEqual(e,o.ob,n?[n]:void 0))return void(n&&o.ob[n]!==e[n]&&(o.ob[n]=e[n]));let s=this.findIndexByIndex(e,t+1,n);if(s>-1){if(t+1===s)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();else for(let e=0;e<s-t-1;e++)this.node.childrens?.[t]?.[exports.VNode.PARSERKEY]?.destroy();return this.renderItem(e,t,n)}return new ue(this.ast,e,this.node,this.ext).init(t)}return new ue(this.ast,e,this.node,this.ext).init()}updateListItemOb(e,t){if(!this.ast.childrens?.length||!this.node)return;let n=this.node.childrens?.[t];r(e,(e,t)=>{n.ob[e]!==t&&(n.ob[e]=t)})}destroyOldChildrens(e){if(this.node)for(;this.node.childrens.length>e;){let e=this.node.childrens.pop();if(!e)break;e[exports.VNode.PARSERKEY]?.destroy(!1)}}checkObEqual(e,t,n){let o=!0;return void 0!==t&&(r(e,(e,s)=>{n?.includes(e)||t?.[e]===s||(o=!1)}),o)}}class ue extends de{parser(e){this.node=new exports.VNode.ListItem(this.ob,this.parent),this.appendNode(e),this.ast.childrens&&this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}}class fe extends de{parser(){if(p(this.ast.cmdName))throw v("Template Directive","Error occurred while converting AST to VNode: Directive name not found",this.ast),new Error("Error converting AST to VNode: Directive name not found");let t;if("Html"===this.ast.cmdName||"Text"===this.ast.cmdName?t=this.ast.param:this.ast.cmdName.startsWith(ie+".")?t=`${this.ast.cmdName}(${this.ast.param})`:this.ast.cmdName in this.ob&&"function"==typeof this.ob[this.ast.cmdName]&&(t=`${e.createFuntionBody(this.ast.cmdName)}(${this.ast.param})`),t){let e=this.runExpressWithWatcher(`[${t}]`,this.ob,e=>{this.changeValue(e?.[0])},!1,()=>this.ast._code);return e||=[],"Html"===this.ast.cmdName?this.node=new exports.VNode.Html(me(e[0]),this.parent,e[1]):this.node=new exports.VNode.Text(me(e[0]),this.parent),void this.appendNode()}throw new Error("Command not found: "+this.ast.cmdName)}changeValue(e){this.node&&(this.node instanceof exports.VNode.Html?this.node.html=me(e):this.node.text=me(e),this.ext.render?.updateNode(this.node))}}function me(e){return null==e||"function"==typeof e?"":e.toString()}const ye="default";class Ee extends de{parser(){let e=this.transformParam();this.node=new exports.VNode.RenderSection(e.id,this.parent),this.node.params=e.params,this.node.section??=this.ob.$sections?.[e.id],this.appendNode(),this.node.section&&(this.node.section.params?(this.node.ob=Object.create(this.node.section.ob||this.ob),this.node.section.params?.forEach((e,t)=>{V(this.node.ob,e,this.node.params[t])})):this.node.ob=this.node.section.ob||this.ob,(this.node.section.parser||this.ext).parserNodes(this.node.section.asts,this.node,this.node.ob))}transformParam(){if(this.ast.param){let e=this.runExpressWithWatcher(`[${this.ast.param}]`,this.ob,e=>{let t=e?.[0]||ye;if("string"==typeof t&&t!==this.node.id)throw new Error("The section ID cannot be dynamically changed");this.node.params=e.slice(1),this.node?.ob&&this.node.section&&this.node.section.params?.forEach((e,t)=>{this.node?.ob&&this.node.ob[e]!==this.node.params[t]&&(this.node.ob[e]=this.node.params[t])})},!0,()=>this.ast._code);return{id:e?.[0]||ye,params:e?.slice(1)||[]}}return{id:ye,params:[]}}}const Ne="Component Parsing";function ge(e,t){return!!t.components[e]||!!He(e)}class ve extends de{loadPromise;parser(){if(this.ast.node)return this.node=this.ast.node,this.node.parent=this.parent,this.initPropData(),void(this.node&&(this.appendNode(),this.node.component?.$mount(this.node)));this.node=new exports.VNode.Component(this.parent),this.initPropData(),this.appendNode(),this.initEvent(),this.loadPromise=this.renderChildren(),this.ext.promiseQueue.add(this.loadPromise),this.loadPromise.finally(()=>{this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0)})}get canReload(){return"tagName"in this.ast||"function"==typeof this.ast.component}reload(){this.canReload?(this.beforeDestroy(),this.renderChildren()):g(Ne,"Reload operation is not supported for the current component",this.node)}initPropData(){for(let e of this.ast.attributes)if("ref"!==e.name)if("keep-alive"===e.name&&"false"!==e.value&&(this.node.keepalive=!0),e.express){let t=this.runExpressWithWatcher(e.express,this.ob,t=>{this.node.propValues[e.name]=t,this.notifyNodeWatcher("update",e.name)},!0,()=>{if(e.value)return`express:${e.value} \nfrom <${"tagName"in this.ast?this.ast.tagName:"Component"} ${e.name}="${e.value}" ... /> `});this.node.propValues[e.name]=t}else this.node.propValues[e.name]=e.value;else{if(p(e.value)){g(Ne,"The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}this.node.propValues=T(this.node.propValues)}initEvent(){this.ast.events.forEach(e=>{let t=e.functionName?this.ob[e.functionName]:void 0;void 0===e.functionName?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:f}]):t&&"function"==typeof t?this.node.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{let o=[];e.functionParam&&(o=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code} \nfrom: <${"tagName"in this.ast?this.ast.tagName:"Component"} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t.call(this.ext.ob,n,...o)}}]):v(Ne,`The callback method (${e.functionName}) specified for the ${e.name} event in the ${"tagName"in this.ast?this.ast.tagName:""} element was not found. Please check.`)})}async renderChildren(){return new Promise(async(e,t)=>{if("tagName"in this.ast){let e=this.ob.components[this.ast.tagName]||He(this.ast.tagName);if(void 0===e)return void v(Ne,`Failed to render component. Private or global component named '${this.ast.tagName}' not found.`);if(Ke in e||(e=(await e()).default),!this.node)return;{let t=this.getSections();this.node.name=this.ast.tagName,this.node.component=new e(this.node?.propValues,t,this.node?.keepalive)}}else if("function"==typeof this.ast.component){let e=this.getSections();this.node.component=new this.ast.component(this.node?.propValues,e,this.node?.keepalive)}else this.node.component=this.ast.component;if(!this.node)return;!this.node.name&&"name"in this.node.component&&this.node.component.name&&"string"==typeof this.node.component.name&&(this.node.name=this.node.component.name);let n=this,o=function(){n.loadPromise&&e(void 0)};if(this.node.component.$on("mounted",()=>{this.node?.component.$off("beforeDestroy",o),e(void 0)}),this.node.component.$on("beforeDestroy",o),this.node.component.$mount(this.node),!this.node)return;let s=this.node?.component;s.isKeepAlive&&(this.ast.node=this.node)})}getSections(){let t={},n=[];return this.ast.childrens.forEach(t=>{if(t.type===e.AST.NodeType.COMMAND&&"if"===t.cmdName&&t.childrens){let o=t,s=t.childrens.some(t=>t.type===e.AST.NodeType.COMMAND&&"section"===t.cmdName),i=o.condition.startsWith(e.EXPRESSHANDLERTAG+".$sections");if(i){return this.runExpress(o.condition,this.ob,()=>o._code)?void n.push(...t.childrens):void 0}if(s&&"if"===o.kind&&!i)return void g(Ne,"While parsing the section, it was found that this section is wrapped in a conditional statement. This conditional statement only supports if judgments using $sections. It has been excluded.")}n.push(t)}),n.forEach(n=>{if(n.type===e.AST.NodeType.COMMAND&&"section"===n.cmdName){let e=n,o=e.id||ye;/^(\'|\")(.*?)((\'|\"))$/.test(o)&&(o=o.slice(1,-1)),t[o]=t[o]||{asts:[],ob:this.ob,params:e.paramKeys,parser:this.ext},t[o].asts.push(...n.childrens||[])}else t[ye]=t[ye]||{asts:[],ob:this.ob,parser:this.ext},t[ye].asts.push(n)}),t}beforeDestroy(e){this.loadPromise&&(this.ext.promiseQueue.delete(this.loadPromise),this.loadPromise=void 0),this.node?.component[De]||(!0===e&&this.node?.component?.isKeepAlive?this.node?.component?.$destroy():(this.node?.component?.$destroy(!0),this.ast.node=void 0))}}class xe extends de{parser(){this.node=new exports.VNode.Element(this.ast.tagName,this.parent),this.initAttributes(),this.initEvents(),this.appendNode(),this.ext.parserNodes(this.ast.childrens,this.node,this.ob)}initAttributes(){for(let e of this.ast.attributes)if("ref"!==e.name)if(e.express){let t=t=>{this.node&&(this.node.attributes[e.name]=this.transformAttrVal(t),this.ext.render?.updateNode(this.node,e.name),this.notifyNodeWatcher("update",e.name))},n=this.runExpressWithWatcher(e.express,this.ob,e=>{t(e)},!1,()=>{if(e.value)return`express:${e.value} \nfrom <${this.ast.tagName} ${e.name}="${e.value}" ... /> `});this.node.attributes[e.name]=this.transformAttrVal(n)}else this.node.attributes[e.name]=e.value;else{if(p(e.value)){g("Element","The 'ref' value of the element cannot be empty");continue}this.ref=e.value,this.ext.addRef(e.value,this.node)}}initEvents(){for(let e of this.ast.events){let t=e.functionName?this.ob[e.functionName]:void 0;if(!(void 0===e.functionName||t&&"function"==typeof t))throw new Error(`The callback method (${e.functionName}) specified for the ${e.name} event in the ${this.ast.tagName} element was not found. Please check.`);this.node?.events.push([e.name,{modifiers:e.modifiers,callBack:n=>{if(void 0===t)return;let o=[];e.functionParam&&(o=this.runExpress(`[${e.functionParam}]`,this.ob,()=>{if(e._code){let t=e.modifiers?.join(".");return`express:${e._code}\nfrom <${this.ast.tagName} @${e.name}${t?"."+t:""}="${e._code}" ... /> `}})),t&&t.call(this.ext.ob,n,...o)}}])}}transformAttrVal(e){return void 0!==e&&("string"==typeof e||"boolean"==typeof e||"function"!=typeof e&&Object.prototype.toString()?e:void 0)}}class be{asts;ob;root=new exports.VNode.Root;refs={};sleeped=!1;promiseQueue=new Set;nodeWatcherEvents={};render;constructor(e,t,n){this.asts=e,this.ob=t,this.root.component=t,this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,n&&n instanceof exports.VNode.Node&&(this.root.parent=n,n.childrens??=[],n.childrens.push(this.root))}parser(){this.parserNodes(this.asts,this.root)}mount(e){this.sleeped&&this.weakup(),this.render?.mount(e)}parserNodes(t,n,o){if(0!==this.asts.length)for(let s of t)if(s.type===e.AST.NodeType.TEXT)new he(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.COMMENT)new ce(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.COMPONENT)new ve(s,o??this.ob,n,this).init();else if(s.type===e.AST.NodeType.ELEMENT){let e=s;ge(e.tagName,o??this.ob)?new ve(e,o??this.ob,n,this).init():new xe(e,o??this.ob,n,this).init()}else if(s.type===e.AST.NodeType.COMMAND){let e=s;switch(e.cmdName){case"if":case"elseif":case"else":new le(e,o??this.ob,n,this).init();break;case"for":new pe(e,o??this.ob,n,this).init();break;case"RenderSection":new Ee(e,o??this.ob,n,this).init();break;case"section":break;default:new fe(e,o??this.ob,n,this).init()}}}addRef(e,t){this.refs[e]=this.refs[e]||[],this.refs[e].push(t),t.ref=e}removeRef(e){for(let t in this.refs)this.refs[t].includes(e)&&c(this.refs[t],e)}addNodeWatcher(e,t){this.nodeWatcherEvents[e]=this.nodeWatcherEvents[e]||[],this.nodeWatcherEvents[e].push(t)}removeNodeWatcher(e,t){c(this.nodeWatcherEvents[e]||[],t)}notifyNodeWatcher(e,t,n,o){this.nodeWatcherEvents[e]?.forEach(e=>{e(t,n,o)})}sleep(e){let t=e||this.root;t.childrens?.forEach(e=>{let t=()=>{e.childrens&&this.sleep(e),e.sleep=!0,this.render?.removeNode(e,!0)};this.nodeTransition(e,"leave",void 0,()=>{t()})||t()}),void 0===e&&(this.sleeped=!0)}weakup(e){let t=e||this.root;t.childrens?.forEach(e=>{e.sleep=!1,this.render?.appendNode(e),e.childrens&&this.weakup(e),this.nodeTransition(e,"enter")}),void 0===e&&(this.sleeped=!1)}destroy(e){for(;this.root.childrens.length;){let t=this.root.childrens[0];t[exports.VNode.PARSERKEY]?t[exports.VNode.PARSERKEY].destroy(e):c(this.root.childrens,t)}this.render.destroy(),this.refs={},this.root.childrens.length=0,this.nodeWatcherEvents={},this.asts.length=0}destroyWathcers(){for(let e of this.root.childrens)e[exports.VNode.PARSERKEY]&&e[exports.VNode.PARSERKEY].destroyWathcers()}reSetAsts(e,t){this.destroy(t),this.render=exports.IContainer.get(exports.Render.IRENDERIOCTAGID)??new exports.Render.DomRender,this.asts=e}nodeTransition(e,t,n,o,s){if(e&&e.parent?.childrens&&(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component)){let i=function(e){if(e instanceof exports.VNode.Element||e instanceof exports.VNode.Component){let t=e instanceof exports.VNode.Element?e.attributes:e.propValues;return{name:t["transition-name"],type:t["transition-type"]}}}(e);if(n??=i?.name,s??=i?.type,!n)return!1;let r=we(e);if(r)return"enter"===t?this.render.elementToEnter(r,n,s,()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-enter"),o?.()}):this.render.elementToLeave(r,n,s,()=>{let t=e[exports.VNode.PARSERKEY];t&&t.ref&&this.notifyNodeWatcher(t.ref,e,"after-leave"),o?.()}),!0;g("Render Core","Incomplete data found when executing node animation, please check")}return!1}}function we(e){if(e instanceof exports.VNode.Element)return e;if(e.childrens&&e.childrens.length)for(let t of e.childrens)return t instanceof exports.VNode.Element?t:we(t)}function Re(e,t,n){if(void 0===t)return;const o=Array.isArray(n)?n:[n];for(const e of o){if(e===Array&&Array.isArray(t))return t;if(typeof t===e.name.toLowerCase())return t}switch(o[0]){case Number:const e=Number(t);if(!isNaN(e))return e;break;case String:return String(t)}throw new Error(`The type of ${e.toString()} in props does not match the constrained type`)}function Ae(e,t,n){let o,s,i;if("symbol"!=typeof t&&(o=u(t)),t in e?s=e[t]:o&&(s=e[o]),n&&(t in n?i=n[t]:o&&o in n&&(i=n[o])),void 0!==i){if(a(i)&&("type"in i||"required"in i||"default"in i||"validate"in i)){const e=i;if(e.required&&void 0===s)throw new Error(`props key:${t.toString()} is required, please check`);if(e.type&&(s=Re(t,s,e.type)),e.validate&&!1===e.validate(s))throw new Error(`Validation failed for props key ${t.toString()}`);s=s??e.default}else s=Ce(i)?Re(t,s,i):s??i;return s}return s}function Ce(e){return!![String,Array,Number,Object,Function,Boolean].includes(e)||!!Array.isArray(e)&&Ce(e[0])}function $e(e,t){if(!e.constructor)return!1;let n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);return n&&n.get}const Oe="Component",Se=Symbol.for("JOKER_PROPS_DATA_KEY"),Te=Symbol.for("JOKER_PROPS_DATA_PROXY"),Ve=Symbol.for("JOKER_PRIVATE_WATCHERS"),Pe=Symbol.for("JOKER_EVENT_DATA_KEY"),De=Symbol.for("JOKER_IS_DESTROY"),_e=Symbol.for("JOKER_PARSER_TEMPLATE_TARGET"),ke=Symbol.for("JOKER_SCOPE_ID"),Ke=Symbol.for("JOKER_COMPONENT_TAG"),We=Symbol();let Ie=["constructor","$mount","$nodeTransition","$destroy","$getRef","$getRefs","$syncProp","$watchNode","$watch","$on","$off","$trigger","$render","created","mounted","beforeDestroy","sleeped","wakeup","destroyed"];class je{$sections;isKeepAlive;static[Ke]=!0;[ke];model={};template;$root;isSleeped=!1;components={};propsOption;[Se]={};[_e];[Te];[Ve]=[];[Pe]=new Map;[De]=!1;[We]=!1;constructor(e,t={},n){this.$sections=t,this.isKeepAlive=n,this[Se]=e||{}}get props(){if(void 0===this[Te]){let e=this;this[Te]=new Proxy(e[Se],{get:(t,n)=>Ae(e[Se],n,e.propsOption),set(){throw new Error("props parameters are not allowed to be changed, only one-way data transfer is allowed")}})}return this[Te]}$mount(e){if(!1===this[We]){let e=()=>{let e=[],t=Object.getPrototypeOf(this);for(;null!==t&&t!==Object.prototype;)Object.getOwnPropertyNames(t).forEach(n=>{!1!==Ie.includes(n)||$e(t,n)||"function"!=typeof t[n]||t[n].prototype?.hasOwnProperty("constructor")||e.push(n)}),t=Object.getPrototypeOf(t);return e};for(let t of e())this[t]=this[t].bind(this);this[We]=!0}if(this.$root=e,this.isKeepAlive&&this.isSleeped)return this.isSleeped=!1,this[_e]&&this.$root?(this[_e].mount(this.$root),this.wakeup(),this.$trigger("wakeup"),this.$rootVNode&&Ye(this.$rootVNode),this):(v(Oe,"When attempting to wake up the current component, it was found that the rendering handler has been destroyed. The wake-up operation cannot proceed.",[this,this.$root]),this);this.isSleeped=!1,this.model=T(this.model);let t=this.created(),n=async()=>{this.$trigger("created"),this.template&&this.$render(),await this.$nextUpdatedRender(),this[De]||(await this.mounted(),this[De]||this.$trigger("mounted"))};return t&&t instanceof Promise?t.then(()=>{this[De]||n()}):n(),this}$nextUpdatedRender(e){if(this[De])return;let t=[...this[_e]?.promiseQueue||[]],n=this.$rootVNode?.find(e=>e instanceof exports.VNode.Component);if(n?.forEach(e=>{e?.component&&t.push(...e.component[_e]?.promiseQueue||[])}),t.length)return Promise.all(t).finally(()=>{this[De]||e?.()});this[De]||e?.()}$nodeTransition(e,t,n,o,s){if(this.$root&&!this[De]){if("string"==typeof e){let t=this.$getRef(e);if(!t)return void g(Oe,`Node with ref=${e} not found when executing node animation`);e=t}this[_e]?.nodeTransition(e,t,n,o,s)}}$destroy(e){if(!e&&this.isKeepAlive)return this[_e]?.sleep(),this.isSleeped=!0,this.sleeped(),this.$trigger("sleeped"),void(this.$rootVNode&&Be(this.$rootVNode));this[De]=!0;for(let e of this[Ve])e.destroy();this[Ve].length=0,this[_e]?.destroyWathcers(),this.beforeDestroy(),this.$trigger("beforeDestroy"),this[_e]?.destroy(),this[_e]=void 0,this.template&&Array.isArray(this.template)&&(this.template.length=0),this.$trigger("destroy"),this[Pe].clear(),this.$root=void 0,this.isSleeped=!1,this.$sections={},this[Te]=void 0,this[Se]={},this.destroyed()}get $refs(){return this[_e]?.refs||{}}$getRef(e){return this.$refs[e]?.[0]}$getRefs(e){return this.$refs[e]}$syncProp(e,t,n){"function"==typeof t&&(n=t,t=void 0),t??=e,n??=e=>e,this.model[t]=n(this.props[e]),this.$watch(()=>this.props[e],()=>{this.model[t]=n?.(this.props[e])})}get $rootVNode(){return this[_e]?.root}$watchNode(e,t){if(this[_e])return this[_e]?.addNodeWatcher(e,t),()=>{this[_e]?.removeNodeWatcher(e,t)};g(Oe,"Component is not yet mounted. Node observation and monitoring cannot be performed.")}$watch(e,t,n){let o=new I(()=>{if(this[De]){for(let e of this[Ve])e.destroy();return W}return e()},(e,n)=>{this[De]||t(e,n)},void 0,n);return this[Ve].push(o),[o.value,()=>{o.destroy(),c(this[Ve],o)}]}$on(e,t){let n=this[Pe].get(e);void 0===n&&(n=new Set,this[Pe].set(e,n)),!1===n?.has(t)&&n.add(t)}$off(e,t){let n=this[Pe].get(e);n&&(t?n.delete(t):n.clear())}get $listeners(){let e={};for(let t in this[Pe])e[t]||=[],e[t].push(...Array.from(this[Pe].get(t)||[]));if(this.$root&&this.$root instanceof exports.VNode.Component)for(let t of this.$root.events){let n=t[0];e[n]||=[],e[n].push(t[1].callBack)}return e}$trigger(e,t,n){if(!this.$root)return;let o={eventName:e,stopPropagation:n?.stopPropagation??(()=>{}),preventDefault:n?.preventDefault??(()=>{}),data:t,target:n?.target??this.$rootVNode,event:n?.event};if(this.$rootVNode&&this.$rootVNode.parent&&this.$rootVNode.parent instanceof exports.VNode.Component&&!1===this[_e]?.render.triggerEvent(this.$rootVNode.parent,e,o))return;let s=this[Pe].get(e);s?.size&&[...s].forEach(e=>{e(o)});let i=this[Pe].get("*");i?.size&&[...i].forEach(e=>{e(o)})}$render(t,n){t??=this.template,this.template="function"==typeof t?t(e.RENDER_HANDLER):t,this.$root&&(this.template??=[],this[_e]?.reSetAsts(this.template,n),this[_e]??=new be(this.template,this,this.$root),this[_e].parser(),this.$root&&this[_e].mount(this.$root))}created(){}mounted(){}beforeDestroy(){}sleeped(){}wakeup(){}destroyed(){}}const Le={};function Me(e,t){if("string"==typeof e)t&&(Le[e]=t);else for(let t in e)Le[t]=e[t]}function He(e){return Le[e]}function Be(e){e.childrens?.forEach(e=>{e instanceof exports.VNode.Component&&e.component?.sleeped(),Be(e)})}function Ye(e){e.childrens?.forEach(e=>{e instanceof exports.VNode.Component&&e.component?.wakeup(),Ye(e)})}class Je extends je{template=[];cache=new Map;async mounted(){this.$watch(()=>this.props.name,async e=>{this.$render([],!0),await Promise.resolve(),this.$root&&this.loadComponent(e)}),await this.loadComponent(this.props.name)}propsVaule;created(){this.initProps()}initProps(){let e={};this.props.props||(Object.keys(this.props).forEach(t=>{!1!==this.filterProps(t)&&(e[t]=this.props[t],this.$watch(()=>this.props[t],()=>{this.propsVaule[t]=this.props[t]}))}),this.propsVaule=T(e))}filterProps(e){if("string"!=typeof e)return!1;let t=u(e);return"transition-name"!==t&&"name"!==t&&"keep-alive"!==t&&"ref"!==t&&void 0}async loadComponent(t){if(!t)return void this.$render([],this.isKeepAlive);let n;if(this.isKeepAlive){let n=this.cache.get(t);if(n)return void this.$render([e.createComponent(n,{"transition-name":this.props["transition-name"]})],!0)}let o=this.$rootVNode?.parent?.[exports.VNode.PARSERKEY]?.ob.components,s=o?.[t];void 0===s&&(s=He(t)),s?(Ke in s||(s=(await s()).default),n=new s(this.props.props||this.propsVaule,this.$sections,this.isKeepAlive),n.$on("*",e=>{this.$trigger(e.eventName,e.data,e)}),this.isKeepAlive&&this.cache.set(t,n),this.$render([e.createComponent(n,{"transition-name":this.props["transition-name"]})],this.isKeepAlive)):g("component",`Component ${t} not found`)}beforeDestroy(){this.removeCache()}removeCache(e){if(e){let t=this.cache.get(e);this.cache.delete(e),t&&t.$destroy(!0)}else this.cache.forEach(e=>{e.$destroy(!0)}),this.cache.clear()}}class Ge extends je{template=function(){return[e.createCommand("RenderSection")]};async mounted(){await this.$nextUpdatedRender()}}Me({template:Ge,component:Je});Object.defineProperty(exports,"AST",{enumerable:!0,get:function(){return e.AST}}),Object.defineProperty(exports,"EXPRESSHANDLERTAG",{enumerable:!0,get:function(){return e.EXPRESSHANDLERTAG}}),Object.defineProperty(exports,"RENDER_HANDLER",{enumerable:!0,get:function(){return e.RENDER_HANDLER}}),Object.defineProperty(exports,"createCodeFunction",{enumerable:!0,get:function(){return e.createCodeFunction}}),Object.defineProperty(exports,"createCommand",{enumerable:!0,get:function(){return e.createCommand}}),Object.defineProperty(exports,"createComment",{enumerable:!0,get:function(){return e.createComment}}),Object.defineProperty(exports,"createComponent",{enumerable:!0,get:function(){return e.createComponent}}),Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return e.createElement}}),Object.defineProperty(exports,"createFuntionBody",{enumerable:!0,get:function(){return e.createFuntionBody}}),Object.defineProperty(exports,"createText",{enumerable:!0,get:function(){return e.createText}}),exports.BREAK_WATCH_UPDATE=W,exports.Component=je,exports.ComponentContainer=Je,exports.Dep=w,exports.EventBus=class{eventDatas=new Map;on(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const o={callBack:t};return n.push(o),()=>{n&&c(n,o)}}once(e,t){let n=this.eventDatas.get(e);void 0===n&&(n=[],this.eventDatas.set(e,n));const o={callBack:t,once:!0};return n.push(o),()=>{n&&c(n,o)}}off(e,t){if(void 0!==e)if(t){const n=this.eventDatas.get(e),o=n?.find(e=>e.callBack===t);o&&c(n,o)}else this.eventDatas.delete(e);else this.eventDatas.clear()}async trigger(e,t){let n=[...this.eventDatas.get(e)||[]];if(n.push(...this.eventDatas.get("*")||[]),n&&n.length){let o=0,s=0,i=!1;for(;n[o];){const r=n[o],a=await r.callBack({stopPropagation:()=>i=!0,callTimes:s,eventName:e},t);if(r.once?c(n,r):o++,!1===a||i)return!1}}}},exports.IS_DESTROY=De,exports.JOKER_COMPONENT_TAG=Ke,exports.JOKER_VNODE_TAG=j,exports.OBJECTPROXY_DEPID=R,exports.PARSER_TEMPLATE_TARGET=_e,exports.ParserTemplate=be,exports.SCOPE_ID=ke,exports.ShallowObserver=class{data;[P]=!0;dep=new w;constructor(e){this.data=e}isChanged=!1;get value(){return this.dep.depend(C),this.data}set value(e){!1===Object.is(e,this.data)&&(this.isChanged=!0,this.data=e,k(this.dep,C))}},exports.Template=Ge,exports.Watcher=I,exports.__GLONAL_FUNTIONS__=se,exports.__JOKER_HMR_RUNTIME=s,exports.combinedReply=function(e){D=!0;try{e()}catch(e){return D=!1,_.clear(),void v("Data Hijacking","Encountered a blocking error while collecting changes for data hijacking composite responses. No action will be taken. Please investigate.",e)}D=!1,function(e){const t=[],n=[];e.forEach((e,n)=>{e.forEach(e=>{t.push(...n.watchers.get(e)||[])})}),t.forEach(e=>{n.includes(e)||(!e.isDestroy&&e.update(),n.push(e))})}(_),_.clear()},exports.defineObserverProperty=V,exports.getGlobalComponent=He,exports.isObserverData=function(e){return void 0!==S(e)},exports.observer=T,exports.registerGlobalComponent=Me,exports.registerGlobalFunction=function(e){for(const t in e)se[t]=e[t]};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joker.front/core",
3
- "version": "1.3.87",
3
+ "version": "1.3.88",
4
4
  "description": "",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.es.js",