(function(N,$){typeof exports=="object"&&typeof module!="undefined"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(N=typeof globalThis!="undefined"?globalThis:N||self,$(N.ef={}))})(this,function(N){"use strict";const $="&",oe=$+$,Ze=new RegExp(`\\${$}[0-7]{1,3}`,"g"),Je=new RegExp(`\\${$}u\\[.*?\\]`,"g"),Xe=new RegExp(`\\${$}u.{0,4}`,"g"),ze=new RegExp(`\\${$}x.{0,2}`,"g"),Ye=new RegExp(`\\${$}`,"g"),et=new RegExp(`\\${$}b`,"g"),tt=new RegExp(`\\${$}t`,"g"),nt=new RegExp(`\\${$}n`,"g"),ot=new RegExp(`\\${$}v`,"g"),rt=new RegExp(`\\${$}f`,"g"),st=new RegExp(`\\${$}r`,"g"),ct=()=>{throw new SyntaxError("Octal escape sequences are not allowed in EFML.")},it=e=>{if(e=e.substr(3,e.length-4),e=parseInt(e,16),!e)throw new SyntaxError("Invalid Unicode escape sequence");try{return String.fromCodePoint(e)}catch(t){throw new SyntaxError("Undefined Unicode code-point")}},lt=e=>{if(e=e.substring(2),e=parseInt(e,16),!e)throw new SyntaxError("Invalid Unicode escape sequence");return String.fromCharCode(e)},ut=e=>{if(e=`00${e.substring(2)}`,e=parseInt(e,16),!e)throw new SyntaxError("Invalid hexadecimal escape sequence");return String.fromCharCode(e)},T=e=>{const t=e.split(oe),n=[];for(let o of t){const r=o.replace(Ze,ct).replace(Je,it).replace(Xe,lt).replace(ze,ut).replace(et,"\b").replace(tt," ").replace(nt,`
`).replace(ot,"\v").replace(rt,"\f").replace(st,"\r").replace(Ye,"");n.push(r)}return n.join($)},at=e=>e[e.length-1]===$,Ne=(e,t)=>{const n=e.split(t),o=[];let r=!1;for(let s of n)r?o[o.length-1]+=`${t}${s}`:o.push(s),r=at(s);return o},O=(e,t)=>{const n=e.split(oe),o=Ne(n.shift(),t);for(let r of n){const s=Ne(r,t);o[o.length-1]+=`${oe}${s.shift()}`,o.push(...s)}return o},ft=">#%@.-+|",pt=["$ctx","$refs","$data","$methods","$mount","$umount","$subscribe","$unsubscribe","$update","$dispatch","$emit","$on","$off","$destroy","__DIRECTMOUNT__"],ve=/\{\{.+?\}\}/g,dt=/^(\t*)( *).*/,ht=/#([^}]|}[^}])*$/,P=(e,t=-2)=>`Failed to parse eft template: ${e}. at line ${t+1}`,mt=e=>!e.replace(/\s/,""),$e=e=>["number","boolean","string"].indexOf(typeof e)>-1,ge=e=>{if(!e)return[e,!1];try{const t=JSON.parse(e);return["number","boolean"].indexOf(typeof t)===-1?[T(e),!0]:[t,!1]}catch(t){return[T(e),!0]}},bt=(e,t)=>{t.offset===null&&(t.offset=e.match(/\s*/)[0],t.offset&&(t.offsetReg=t.offset))},Et=(e,t,n)=>{if(t.offsetReg){let o=!1;if(e=e.replace(t.offsetReg,()=>(o=!0,"")),!o)throw new SyntaxError(P(`Expected indent to be grater than 0 and less than ${t.prevDepth+1}, but got -1`,n))}return e},yt=(e,t)=>{if(t.indentReg)return;const n=e.match(dt)[2];n&&(t.indentReg=new RegExp(n,"g"))},Nt=(e,t,n)=>{let o=0;t.indentReg&&(e=e.replace(/^\s*/,s=>s.replace(t.indentReg," ")));const r=e.replace(/^\t*/,s=>(o=s.length,""));if(/^\s/.test(r))throw new SyntaxError(P("Bad indent",n));return{depth:o,content:r}},vt=(e,t)=>{let n=e;for(let o=0;o{e=e.slice(2,e.length-2);const[t,...n]=O(e,"="),o=O(t.trim(),".").map(T),[r,s]=ge(n.join("=").trim());return $e(r)&&(s||!s&&r!=="")?[o,r]:[o]},Q=e=>{const t=e.split(ve);if(t.length===1)return ge(e)[0];const n=[];t.length===2&&!t[0]&&!t[1]?n.push(0):n.push(t.map(T));const o=e.match(ve);return o&&n.push(...o.map($t)),n},_e=(e,t)=>{t&&e.push(t)},we=e=>{const t=Q(e);if($e(t))return[`${t}`];const[n,...o]=t,r=[];for(let s=0;se.replace(/\./g," "),gt=e=>{const t={},[n,...o]=O(e.replace(ht,r=>(t.ref=r.slice(1),"")),".");return t.tag=T(n),t.class=Q(o.join(".")),typeof t.class=="string"?t.class=Oe(t.class).trim():t.class[0]&&(t.class[0]=t.class[0].map(Oe)),t},_t=e=>{const t=O(e,"=");return{name:t.shift().trim(),value:t.join("=").trim()}},wt=(e,t)=>{switch(t){case"stop":{e.s=1;break}case"stopImmediate":{e.i=1;break}case"prevent":{e.p=1;break}case"shift":{e.h=1;break}case"alt":{e.a=1;break}case"ctrl":{e.c=1;break}case"meta":{e.t=1;break}case"capture":{e.u=1;break}case"passive":{e.e=1,delete e.p;break}case"!passive":{e.e=0;break}case"once":{e.o=1;break}default:console.warn(`Unsupported event option '${t}' will be dropped.`)}},Ot=(e,t,n)=>{const o=parseInt(n,10);if(isNaN(o))return wt(e,T(n));t.push(o)},xe=e=>{const t={},n=[],[o,...r]=O(e,".");t.l=T(o);for(let s of r)Ot(t,n,s);return n.length>0&&(t.k=n),t},xt=e=>{const[t,...n]=O(e,":"),o=n.join(":"),r=T(t.trim());return o?[r,Q(o)]:[r]},Dt=e=>{const t=O(e,"="),n=t.shift().trim(),[o,r]=O(n,"@"),[s,c]=O(o,"!"),i=r&&xe(r);return{propPath:O(s,".").map(T),value:Q(t.join("=").trim()),updateOnly:c,syncTrigger:i}},Tt=e=>{const t=O(e,"=");return{name:T(t.shift().trim()),value:Q(t.join("=").trim())}},St=({line:e,ast:t,parsingInfo:n,i:o},r)=>{if(mt(e))return;bt(e,n);const s=Et(e,n,o);yt(s,n);let{depth:c,content:i}=Nt(s,n,o);if(i){const u=i[0],a=ft.indexOf(u)>=0;if(!a)return r?r({ast:t,depth:c,content:i,parsingInfo:n}):void 0;if(c<0||c-n.prevDepth>1||c-n.prevDepth===1&&n.prevType!=="tag")throw new SyntaxError(P(`Expected indent to be grater than 0 and less than ${n.prevDepth+1}, but got ${c}`,o));if(i=i.slice(1),!i&&a)throw new SyntaxError(P("Empty content",o));switch((c":{const p=gt(i),f=[{t:p.tag}];p.class&&(f[0].a={},f[0].a.class=p.class),p.ref&&(f[0].r=p.ref),n.currentNode.push(f),n.currentNode=f,n.prevType="tag";break}case"#":{const{name:p,value:f}=Tt(i);n.currentNode[0].a||(n.currentNode[0].a={}),n.currentNode[0].a[p]=f,n.prevType="attr";break}case"%":{const{propPath:p,value:f,updateOnly:h,syncTrigger:E}=Dt(i),m=[p,f];E?(m.push(E),h===""&&m.push(1)):h===""&&m.push(0,1),n.currentNode[0].p||(n.currentNode[0].p=[]),n.currentNode[0].p.push(m),n.prevType="prop";break}case"@":{const{name:p,value:f}=_t(i);n.currentNode[0].e||(n.currentNode[0].e=[]);const h=xe(p),[E,m]=xt(f);h.m=E,m&&(h.v=m),n.currentNode[0].e.push(h),n.prevType="event";break}case".":{n.currentNode.push(...we(i)),n.prevType="text";break}case"|":{n.currentNode.length>1&&(i=`
${i}`),n.currentNode.push(...we(i)),n.prevType="multiline-text";break}case"-":{if(pt.indexOf(i)!==-1)throw new SyntaxError(P(`Reserved name '${i}' should not be used`,o));n.currentNode.push({n:i,t:0}),n.prevType="node";break}case"+":{n.currentNode.push({n:i,t:1}),n.prevType="list";break}default:return}n.prevDepth=c}},re=(e,t)=>{if(!e)throw new TypeError(P("Template required, but nothing given"));const n=typeof e;if(n!=="string")throw new TypeError(P(`Expected a string, but got a(n) ${n}`));const o=e.split(/\r?\n/),r=[{t:0}],s={indentReg:null,prevDepth:0,offset:null,offsetReg:null,prevType:"comment",currentNode:r};for(let c=0;c(t||(t=re),t(e)),se=Array,x=se.prototype,d={copy(e){return x.slice.call(e,0)},empty(e){return e.length=0,e},equals(e,t){if(!se.isArray(t))return!1;if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0,o=e.length;n-1)return x.splice.call(e,n,1),t},reverse(e){return x.reverse.call(e)},shift(e){return x.shift.call(e)},slice(e,t,n){return x.slice.call(e,t,n)},sort(e,t){return x.sort.call(e,t)},splice(e,...t){return x.splice.call(e,...t)},unshift(e,...t){return x.unshift.apply(e,t)},isArray(e){return se.isArray(e)}},V=e=>d.isArray(e)?"array":typeof e,X=[];let A=0;const ce={first:null,last:null},ie={first:null,last:null},Ct=e=>X.push(e),De=(e,t)=>{t!==e.last&&(t.__next&&(t.__next.__prev=t.__prev),t.__prev&&(t.__prev.__next=t.__next),e.first?t===e.first&&(e.first=t.__next):e.first=t,e.last&&(e.last.__next=t,t.__prev=e.last),e.last=t,e.first.__prev=null,e.last.__next=null)},Te=e=>{let t=e.first;if(!t)return;const n=[];for(;t;){const o=t.__next;t.__prev=null,t.__next=null,n.push(t),t=o}e.first=null,e.last=null;for(let o of n)o()},le=(...e)=>{for(let t of e)De(ce,t)},S=e=>{De(ie,e)},Ft=()=>A>0,y=()=>(A+=1,A),b=e=>{if(!e&&(A-=1)>0)return A;for(A=1;ce.first;)Te(ce);for(;ie.first;)Te(ie);if(A=0,X.length){const t=d.copy(X);d.empty(X),setTimeout(()=>{for(let n of t)n()},0)}return A},Pt=e=>{y();try{b(e(y,b))}catch(t){return b(),t}},Se=(e,...t)=>{for(let n of t)for(let o in n)e[o]=n[o];return e},R=Object.assign||Se,At=({_path:e,handlers:t,subscribers:n,innerData:o})=>{for(let r of e)t[r]||(t[r]={}),n[r]||(n[r]={}),o[r]||(o[r]={}),t=t[r],n=n[r],o=o[r];return{handlerNode:t,subscriberNode:n,dataNode:o}},Rt=(e,t)=>{const n={};return Object.defineProperty(t,e,{get(){return n},set(o){y(),R(n,o),b()},configurable:!1,enumerable:!0}),n},kt=(e,t)=>e[t]||Rt(t,e),Mt=(e,t)=>e.reduce(kt,t),Bt=(e,t)=>{for(let n of e)t[n]||(t[n]={}),t=t[n];return t},Vt=({_path:e,_key:t,data:n,handlers:o,subscribers:r,innerData:s})=>{const c=Mt(e,n),{handlerNode:i,subscriberNode:u,dataNode:a}=At({_path:e,handlers:o,subscribers:r,innerData:s});let p=i[t],f=u[t];return f||(p=i[t]=[],f=u[t]=[]),Object.prototype.hasOwnProperty.call(a,t)||(a[t]=c[t]),{parentNode:c,handlerNode:p,subscriberNode:f,dataNode:a}},Lt=(e,t)=>{const n=e.split("."),o=n.pop();for(let r of n)t[r]||(t[r]={}),t=t[r];return t[o]},je=e=>e!==e;var D=()=>{};const Ce=(()=>{if(typeof console=="undefined"){if(typeof print=="undefined")return{log:D,info:D,warn:D,error:D};const t=(n,o)=>`[EF][${n}] ${o.join(" ")}`;return{log:(...n)=>print(t("LOG ",n)),info:(...n)=>print(t("INFO",n)),warn:(...n)=>print(t("WARN",n)),error:(...n)=>print(t("ERROR",n))}}const e="[EF] %s";return{log:console.log&&console.log.bind(console,e)||D,info:console.info&&console.info.bind(console,e)||D,warn:console.warn&&console.warn.bind(console,e)||D,error:console.error&&console.error.bind(console,e)||D}})(),Ut=(e,{parentNode:t,dataNode:n,handlerNode:o,subscriberNode:r,_key:s})=>{const{state:c}=e,i=()=>le(...o);let u=!1;Object.defineProperty(t,s,{get(){return n[s]},set(a){const p=n[s];if(!(u||p===a||je(p)&&je(a))){if(u=!0,n[s]=a,y(),le(i),r.length>0)try{for(const f of r)f({state:c,value:a,oldValue:p})}catch(f){Ce.error(`Error caught when executing subscribers:
`,f)}b(),u=!1}},enumerable:!0}),typeof n[s]!="undefined"&&le(i)},K=(e,{bind:t})=>{const n=d.copy(t[0]),o=n.pop(),{data:r,handlers:s,subscribers:c,innerData:i}=e,{parentNode:u,handlerNode:a,subscriberNode:p,dataNode:f}=Vt({_path:n,_key:o,data:r,handlers:s,subscribers:c,innerData:i}),h=Object.getOwnPropertyDescriptor(u,o);return(!h||!(h.get||h.set))&&Ut(e,{parentNode:u,dataNode:f,handlerNode:a,subscriberNode:p,_key:o}),t.length>1&&typeof f[o]=="undefined"&&(u[o]=t[1]),{dataNode:f,parentNode:u,handlerNode:a,subscriberNode:p,_key:o}},W=(e,t)=>e.constructor===t,qt=typeof document!="undefined"&&typeof Node!="undefined",k={BEFORE:"before",AFTER:"after",APPEND:"append",REPLACE:"replace"},_={},G="__ef_mount_point__",l={},Fe=[],Pe=[],Z=e=>{const t=Fe.pop()||l.document.createDocumentFragment();return e(t,()=>{Fe.push(t)})},z=e=>{const t=Pe.pop()||l.document.createTextNode("");return e(t,()=>{Pe.push(t)})},L=class{constructor(){this.$children=[],this.$safeZone=l.document.createDocumentFragment()}append(...e){l.append(this.$safeZone,...e),d.push(this.$children,...e)}appendTo(e){l.append(e,...this.$children)}addBefore(e){l.before(e,...this.$children)}removeChild(e){l.remove(e),d.remove(this.$children,e)}remove(){l.append(this.$safeZone,...this.$children)}get firstElement(){return this.$children[0]||null}},Ae=(e,t)=>{const{element:n,placeholder:o}=e.$ctx.nodeInfo;l.append(t,n,o)},Re=(e,t)=>{const{element:n,placeholder:o}=e.$ctx.nodeInfo;l.before(t,n,o)},ue=(e,t,n)=>{if(e.nodeType!==3)return;const o=e[G];if(!o)return;const{node:r}=o;if(r){if(y(),n)if(d.isArray(r))for(let s of r)Re(s,n);else Re(r,n);else if(d.isArray(r))for(let s of r)Ae(s,t);else Ae(r,t);b()}},ae=(e,t)=>{y();for(let n of t)l.isNodeInstance(n)?(e.appendChild(n),ue(n,e)):W(n,L)?n.appendTo(e):n instanceof _.EFBaseComponent&&n.$mount({target:e});b()},It=(e,t)=>{const n=e.parentNode;y();for(let o of t)l.isNodeInstance(o)?(n.insertBefore(o,e),ue(o,n,e)):W(o,L)?o.addBefore(e):o instanceof _.EFBaseComponent&&o.$mount({target:e,option:k.BEFORE});b()};l.isNodeInstance=e=>l.isNode?l.isNode(e):!!(e&&e.nodeType),l.before=(e,...t)=>{const n=e.parentNode,o=t[0];t.length===1&&l.isNodeInstance(o)&&(o.nodeType!==3||!o[G])?n.insertBefore(t[0],e):n.nodeType===11?It(e,t):Z((r,s)=>{y(),ae(r,t),z((c,i)=>{n.insertBefore(c,e),S(()=>{n.insertBefore(r,c),n.removeChild(c),i(),s()})}),b()})},l.after=(e,...t)=>e.nextSibling?l.before(e.nextSibling,...t):l.append(e.parentNode,...t),l.append=(e,...t)=>{if(l.isNodeInstance(e)){t.length===1&&l.isNodeInstance(t[0])?(e.appendChild(t[0]),ue(t[0],e)):e.nodeType===11?ae(e,t):(e.nodeType===1||e.nodeType===9)&&Z((n,o)=>{y(),ae(n,t),z((r,s)=>{e.appendChild(r),S(()=>{e.insertBefore(n,r),e.removeChild(r),s(),o()})}),b()});return}if(e instanceof _.EFBaseComponent){if(!d.isArray(e.children))return;e.children.push(...t);return}e.append(...t)},l.remove=e=>{l.isNodeInstance(e)?e.parentNode&&e.parentNode.removeChild(e):e instanceof _.EFBaseComponent?e.$umount():W(e,L)&&e.remove()};const ke=e=>{R(l,e);const t=l.document.createTextNode("");l.textNodeSupportsEvent=!!t.addEventListener,l.passiveSupported=!1,l.onceSupported=!1;try{const n=Object.create({},{passive:{get:()=>(l.passiveSupported=!0,l.passiveSupported)},once:{get:()=>(l.onceSupported=!0,l.onceSupported)}});l.document.addEventListener("__ef_event_option_test__",D,n),l.document.removeEventListener("__ef_event_option_test__",D,n)}catch(n){}};qt&&ke({document,Node});const fe=(e,t={})=>{const n=l.document.createEvent&&l.document.createEvent("CustomEvent")||new Event(e,t);return n.initEvent&&n.initEvent(e,t.bubbles,t.cancelable,t),n},J={xml:"http://www.w3.org/XML/1998/namespace",html:"http://www.w3.org/1999/xhtml",svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML",xlink:"http://www.w3.org/1999/xlink"},U=e=>{if(J[e])return J[e];throw new Error(`[EF] Namespace "${e}" has not been declared.`)},Ht=(e,t)=>{if(J[e])throw new Error(`[EF] Namespace "${e}" has already been declared as "${J[e]}".`);J[e]=t},pe=e=>{const t={};return n=>t[n]||(t[n]=e(n))},de=pe(e=>e.indexOf(":")>=0),he=pe(e=>e.split(":")),Qt=pe(e=>["foreignobject","desc","title"].indexOf(e.toLowerCase())>-1),me=e=>["number","boolean","string"].indexOf(typeof e)>-1,Kt=(e,t,n,o,r)=>{switch(e){case"string":{if(t===n&&o&&o.is&&typeof o.is=="string"){const{is:s}=o;return r?l.document.createElementNS(r,n,{is:s}):l.document.createElement(n,{is:s})}return r?l.document.createElementNS(r,n):l.document.createElement(n)}case"function":return new n;default:{if(n.tag&&(t=n.tag),n.is){const{is:s}=n;return r?l.document.createElementNS(r,t,{is:s}):l.document.createElement(t,{is:s})}return r?l.document.createElementNS(r,t):l.document.createElement(t)}}},Wt=(e,t,n,o,r,s,c)=>{const i=Kt(e,t,n,o,c);return r&&Object.defineProperty(s,r,{value:i,enumerable:!0}),i},Me=(e,t)=>{const n=e[t];return typeof n=="undefined"?"":n},be=(e,t,n)=>{if(d.isArray(t)){const[o,...r]=t;if(!o){const{dataNode:u,handlerNode:a,_key:p}=K(e,{bind:r[0]}),f=()=>n(Me(u,p));return a.push(f),f}const s=new Array(o.length+r.length),c=[];for(let u in o)s[u*2]=o[u];const i=()=>{for(let u of c)u();return n("".concat(...s))};return c.push(...r.map((u,a)=>{const{dataNode:p,handlerNode:f,_key:h}=K(e,{bind:u});return f.push(i),a=a*2+1,()=>{s[a]=Me(p,h)}})),i}return()=>t},Be=(e,t,n,{l:o,s:r,i:s,p:c,h:i,a:u,c:a,t:p,u:f,e:h,o:E,k:m})=>{const g=v=>!(!!i!=!!v.shiftKey||!!u!=!!v.altKey||!!a!=!!v.ctrlKey||!!p!=!!v.metaKey||m&&m.indexOf(v.which)===-1),w=v=>{r&&v.stopPropagation(),s&&v.stopImmediatePropagation()};let C={capture:!!f},I=v=>{w(v),c&&!h&&v.preventDefault(),n(v)},H=v=>{g(v)&&I(v)};if(h||E){const v=()=>{I=F=>{w(F),setTimeout(()=>n(F),0)},H=F=>{g(F)&&I(F)}},ee=()=>{const F=t&&"$off"||"removeEventListener";H=te=>{g(te)&&(e[F](o,H,C),I(te))}};l.passiveSupported||l.onceSupported?(h===0&&l.passiveSupported?C.passive=!1:h&&(l.passiveSupported?C.passive=!0:v()),E&&(l.onceSupported?C.once=!0:ee())):(h&&v(),E&&ee())}e[t&&"$on"||"addEventListener"](o,H,C)},Gt=(e,t,n,o,r,s,c,i)=>{const u=i&&"$on"||"addEventListener",{parentNode:a,_key:p}=K(e,{bind:c}),f=()=>{n.locked=!0,y(),a[p]=r[s],b(),n.locked=!1},h={capture:!0};if(t)Be(o,i,f,t);else if(s==="value")o[u]("input",f,h),o[u]("keyup",f,h),o[u]("change",f,h);else{const E=i&&"$dispatch"||"dispatchEvent";o[u]("change",()=>{if(o[E](fe("__ef_change_event__"),{bubbles:!1,cancelable:!1}),o.tagName==="INPUT"&&o.type==="radio"&&o.name!==""){const m=l.document.querySelectorAll(`input[name=${o.name}][type=radio]`);if(m){const g=d.copy(m);d.remove(g,o);for(let w of g)w.dispatchEvent(fe("__ef_change_event__"))}}},h),o[u]("__ef_change_event__",f)}},Zt=(e,{element:t,key:n,custom:o})=>{if(o)return r=>{t[n]=r};if(n==="class")return r=>{if(r=`${r}`.replace(/\s+/g," ").trim(),!r)return t.removeAttribute(n);t.setAttribute(n,r)};if(de(n)){const[r]=he(n),s=e.localNamespaces[r]||U(r);return c=>{if(c==="")return t.removeAttributeNS(s,n);t.setAttributeNS(s,n,c)}}return r=>{if(r==="")return t.removeAttribute(n);t.setAttribute(n,r)}},Jt=(e,t,n,o,r)=>{if(me(n)){if(r){n===""?t[o]=!0:t[o]=n;return}if(o==="is")return;if(de(o)){const[c]=he(o);if(c!=="xmlns"){const i=e.localNamespaces[c]||U(c);return t.setAttributeNS(i,o,n)}}return t.setAttribute(o,n)}const s=Zt(e,{element:t,key:o,custom:r});be(e,n,s)},Xt=(e,t,n,o,r,s,c)=>{const i=d.copy(o),u=i.pop();c&&i.unshift("$data");const a=Bt(i,t);if(me(n))a[u]=n;else{const p={locked:!1};let f=null;s?f=()=>{p.locked=!1}:f=h=>{!p.locked&&a[u]!==h&&(a[u]=h),p.locked=!1},be(e,n,f),(r||o.length===1&&(u==="value"||u==="checked")&&!n[0])&&Gt(e,r,p,t,a,u,n[1],c)}},zt=e=>e,Yt=(e,t,n,o)=>{const{m:r,v:s}=n,c=be(e,s,zt);Be(t,o,u=>{const a=c();e.methods[r]?e.methods[r]({e:u,event:u,value:a,state:e.state}):r&&(u.data=a,e.state.$emit(r,u))},n)},en=(e,t,n,o,r)=>{if(o)return[new L,"fragment"];const{t:s,a:c,p:i,e:u,r:a}=t,p=s,f=e.scope[s]||s,h=typeof f,E=Wt(h,p,f,c,a,e.refs,n);if(c)for(let m in c)Jt(e,E,c[m],m,r);if(i)for(let[m,g,w,C]of i)Xt(e,E,g,m,w,C,r);if(u)for(let m of u)Yt(e,E,m,r);return[E,h]},j={empty(){y();for(let e of d.copy(this))e.$destroy();b(),d.empty(this)},clear(){y();for(let e of d.copy(this))e.$umount();b(),d.empty(this)},pop(){if(this.length===0)return;const e=d.pop(this);return e.$umount(),e},push({ctx:e,key:t,aftAnchor:n},...o){if(!o.length)return;if(o=o.map(_.toEFComponent),y(),o.length===1){const s=o[0].$mount({parent:e.state,key:t});l.before(n,s)}else Z((s,c)=>{l.append(s,...o.map(i=>i.$mount({parent:e.state,key:t}))),z((i,u)=>{l.before(n,i),S(()=>{l.after(i,s),u(),c()})})});const r=d.push(this,...o);return b(),r},remove(e){if(this.indexOf(e)!==-1)return e.$umount(),e},reverse({ctx:e,key:t,anchor:n}){if(this.length===0)return this;const o=d.copy(this),r=[];y(),S(()=>l.after(n,...d.reverse(r)));for(let s of o)s.$umount(),d.push(r,s.$mount({parent:e.state,key:t}));return d.push(this,...d.reverse(o)),b(),this},shift(){if(this.length===0)return;const e=d.shift(this);return e.$umount(),e},sort({ctx:e,key:t,anchor:n},o){if(this.length===0)return this;const r=d.copy(d.sort(this,o)),s=[];y(),S(()=>l.after(n,...s));for(let c of r)c.$umount(),d.push(s,c.$mount({parent:e.state,key:t}));return d.push(this,...r),b(),this},splice({ctx:e,key:t,anchor:n},...o){if(this.length===0)return this;const[r,,...s]=o;o.length>2&&(o.length=2);const c=d.splice(this,...o);let i=r;i<0&&(i=this.length+r),i<0&&(i=0),y();for(let u of c)u.$umount();if(s.length)if(s.length===1){const u=_.toEFComponent(s[0]);u.$mount({parent:e.state,key:t});const a=u.$ctx.nodeInfo.placeholder;this[i]?l.before(this[i].$ctx.nodeInfo.firstElement,a):l.after(n,a),d.splice(this,i,0,u)}else z((u,a)=>{this[i]?l.before(this[i].$ctx.nodeInfo.firstElement,u):l.after(n,u),Z((p,f)=>{const h=s.map(E=>_.toEFComponent(E));l.append(p,...h.map(E=>E.$mount({parent:e.state,key:t}))),d.splice(this,i,0,...h),S(()=>{l.before(u,p),l.remove(u),a(),f()})})});return b(),c},unshift({ctx:e,key:t,anchor:n},...o){if(this.length===0)return this.push(...o).length;o=o.map(_.toEFComponent);const r=[];y(),S(()=>l.after(n,...r));for(let c of o)d.push(r,c.$mount({parent:e.state,key:t}));const s=d.unshift(this,...o);return b(),s}},tn=(e,t)=>(Object.defineProperties(e,{empty:{value:j.empty},clear:{value:j.clear},pop:{value:j.pop},push:{value:j.push.bind(e,t)},remove:{value:j.remove},reverse:{value:j.reverse.bind(e,t)},shift:{value:j.shift},sort:{value:j.sort.bind(e,t)},splice:{value:j.splice.bind(e,t)},unshift:{value:j.unshift.bind(e,t)}}),e),Ve=U("svg"),nn=U("math"),on=U("html"),Ee=Object.create(null),Tn=e=>{if(!e.$ctx)throw new Error("[EF] This component has been destroyed!")},rn=(e,t,n)=>{const o=l.document.createTextNode(""),{dataNode:r,handlerNode:s,_key:c}=K(e,{bind:t}),i=()=>{const u=r[c];if(typeof u=="undefined"){o.textContent="";return}o.textContent=u};s.push(i),n(o)},sn=[(e,t,n)=>{const{children:o}=e,r=o[t],{anchor:s,node:c}=r;c!==n&&(n=_.toEFComponent(n),y(),c&&(n===Ee?n=null:c.$umount()),r.node=n,n&&n.$mount({target:s,parent:e.state,option:k.AFTER,key:t}),b())},(e,t,n)=>{const{children:o}=e,{anchor:r,node:s}=o[t];d.equals(s,n)||(y(),s.length&&s.clear(),n&&(n=d.copy(n),Z((c,i)=>{for(let u of n)l.append(c,_.toEFComponent(u).$mount({parent:e.state,key:t}));d.push(s,...n),S(()=>{l.after(r,c),i()})})),b())}],cn=(e,t,n)=>{const o=sn[e];Object.defineProperty(n.prototype,t,{get(){return this.$ctx.children[t].node},set(r){const s=this.$ctx;o(s,t,r)},enumerable:!0})},ln=(e,t,n)=>{const{children:o}=e,r={anchor:n};o[t]=r,n[G]=r},un=(e,t,n,o)=>{const{children:r}=e;r[t]={node:tn([],{ctx:e,key:t,anchor:n,aftAnchor:o}),anchor:n,aftAnchor:o},n[G]=r[t]},an=(e,{apply:t,node:n,nodeType:o,namespace:r,create:s})=>{if(l.isNodeInstance(n)){t(n);return}switch(o){case"string":{t(l.document.createTextNode(n));break}case"array":{V(n[0])==="object"?t(s(e,{node:n,namespace:r})):rn(e,n,t);break}case"object":{const c=l.document.createTextNode("");if(t(c),n.t===0)ln(e,n.n,c);else{const i=l.document.createTextNode("");t(i),un(e,n.n,c,i)}break}}},Le=(e,{node:t,namespace:n})=>{const[o,...r]=t,s=n;let c=o.t,i=!1;const u=e.scope[c],a=c===0,p=Object.isPrototypeOf.call(_.EFBaseComponent,u||c);if(!a&&!p){if(u&&(typeof u=="string"?c=u:u.tag&&(c=u.tag,u.namespaceURI&&(n=u.namespaceURI))),de(c)){const[m,g]=he(c),w=e.localNamespaces[m];w?(n=w,i=!0):n=U(m),c=g}else if(o.a&&o.a.xmlns&&me(o.a.xmlns))n=o.a.xmlns;else if(!n)switch(c=c.toLowerCase(),c){case"svg":{n=Ve;break}case"math":{n=nn;break}}}n===on&&(n="");const[f,h]=en(e,o,n,a,p);let E=D;switch(h){case"string":case"object":{E=(...m)=>{l.append(f,...m)};break}case"function":{const{children:m}=f.$ctx;if(m.children){const g=m.children.anchor;g&&(E=(...w)=>{l.before(g,...w)})}else Array.isArray(f.children)&&(E=(...g)=>{f.children.push(...g)});break}case"fragment":{E=(...m)=>{f.append(...m)};break}}n&&n===Ve&&Qt(c)&&(n=""),i&&(n=s);for(let m of r)an(e,{apply:E,node:m,nodeType:V(m),namespace:n,create:Le});return f},fn=({base:e,key:t},{checkTrue:n,get:o,set:r})=>{if(o){if(!r)throw new Error("[EF] Setter must be defined when getter exists");return o}return n?function(){return n(e(this)[t],this)}:function(){return e(this)[t]}},pn=({base:e,key:t},{checkTrue:n,trueVal:o,falseVal:r,get:s,set:c})=>{if(c){if(!s)throw new Error("[EF] Getter must be defined when setter exists");return c}return n?function(i){const u=e(this),a=o,p=r;typeof o!="function"&&(o=()=>a),typeof r!="function"&&(r=()=>p),i?u[t]=o(this):u[t]=r(this)}:function(i){e(this)[t]=i}},dn=e=>e.$data,hn=e=>e?typeof e=="function"?e:(typeof e=="string"&&(e=e.split(".")),t=>{for(let n of e)t=t[n];return t}):dn,Ue=(e,t)=>{for(let n in t){const o=t[n],r=hn(o.base),s=o.key||n,c={base:r,key:s},i=fn(c,o),u=pn(c,o);Object.defineProperty(e.prototype,n,{get:i,set:u,enumerable:!0,configurable:!1})}return e},mn=(e,t,n)=>{const o=Lt(e,n);d.remove(o,t)},q=class{static initData(){}static initMethods(){}static initScope(){}static __defaultScope(){return{}}static init(e,t,n){const o=this.initData(e,t,n),r=this.initMethods(e,t,n),s=this.initScope(e,t,n);return{data:o,methods:r,scope:s}}constructor(e,t={}){const n=this.constructor,o={},r={},s={},c={},i={},u=e[0].t===0;let a=null,p=null,f=null;a=l.document.createTextNode(""),l.textNodeSupportsEvent?p=a:p=document.createElement("i");const h={placeholder:a,eventBus:p,parent:null,key:null},E=()=>{const B=a.parentNode;E.remove||!B?(l.remove(f),E.remove=!1):B&&(l.before(a,f),l.remove(a))},m={ast:e,mount:E,refs:r,data:s,handlers:c,subscribers:i,nodeInfo:h,children:o,state:this,isFragment:u,localNamespaces:n.__local_namespaces,self:this,constructor:n};Object.defineProperty(this,"$ctx",{value:m,enumerable:!1,configurable:!0});const g=[],w=(B,ne)=>{const Ge=[B,ne];return g.push(Ge),()=>{f?this.$unsubscribe(B,ne):d.remove(Ge)}},{data:C,methods:I,scope:H,beforeMount:Ke,afterMount:v,beforeUmount:ee,afterUmount:F,beforeDestroy:te,afterDestroy:xn,onCreated:We}=n.init(this,s,w);R(m,{innerData:C||{},methods:I||{},scope:R(n.__defaultScope(),H,t),beforeMount:Ke,afterMount:v,beforeUmount:ee,afterUmount:F,beforeDestroy:te,afterDestroy:xn}),f=Le(m,{node:e,namespace:""});let M=f;for(;!l.isNodeInstance(M);)W(M,L)?M=M.firstElement:M=M.$ctx.nodeInfo.element;h.element=f,h.firstElement=M;for(let[B,ne]of g)this.$subscribe(B,ne);We&&We()}get $data(){return this.$ctx.data}set $data(e){y(),R(this.$ctx.data,e),b()}get $methods(){return this.$ctx.methods}set $methods(e){this.$ctx.methods=e}get $refs(){return this.$ctx.refs}$mount({target:e,option:t,parent:n,key:o}){const{nodeInfo:r,mount:s,beforeMount:c,afterMount:i}=this.$ctx;let u=null;if(typeof e=="string"&&(e=document.querySelector(e),!e))throw new Error("Mount target not found!");c&&c(),y(),r.parent&&this.$umount(),n||(n=e),o||(o="__DIRECTMOUNT__"),r.parent=n,r.key=o,s.remove=!1,S(s);const a=r.placeholder;if(e){switch(t){case k.BEFORE:{l.before(e,a);break}case k.AFTER:{l.after(e,a);break}case k.REPLACE:{l.before(e,a),l.remove(e);break}case k.APPEND:default:l.append(e,a)}u=b()}else b(),u=a;return i&&i(),u}$umount(){const{nodeInfo:e,mount:t,beforeUmount:n,afterUmount:o}=this.$ctx,{parent:r,key:s}=e;e.parent=null,e.key=null,n&&n(),y(),r&&(s!=="__DIRECTMOUNT__"?r[s]&&(d.isArray(r[s])?d.remove(r[s],this):r[s]=Ee):W(r,L)&&r.$ctx.nodeInfo.element.removeChild(e.element)),t.remove=!0,S(t);const c=b();return o&&o(),c}$subscribe(e,t){const n=this.$ctx,o=e.split("."),{dataNode:r,subscriberNode:s,_key:c}=K(n,{bind:[o]});y();try{t({state:this,value:r[c]}),s.push(t)}catch(i){Ce.error(`Error caught when registering subscriber:
`,i)}b()}$unsubscribe(e,t){const{subscribers:n}=this.$ctx;mn(e,t,n)}$update(e){y(),Se(this,e),b()}$call(e,t={},...n){return this.$methods[e](R({},t,{state:this}),...n)}$dispatch(e){return this.$ctx.nodeInfo.eventBus.dispatchEvent(e)}$emit(e,t){return this.$dispatch(fe(e,t))}$on(e,t,n={}){return this.$ctx.nodeInfo.eventBus.addEventListener(e,t,n),()=>this.$off(e,t,n)}$off(e,t,n){return this.$ctx.nodeInfo.eventBus.removeEventListener(e,t,n)}$destroy(){const{children:e,beforeDestroy:t,afterDestroy:n}=this.$ctx;t&&t(),y(),this.$umount();for(let r in e)e[r].anchor[G]=null;for(let r in this)V(this[r])==="array"?this[r].clear():this[r]=null;delete this.$ctx;const o=b();return n&&n(),o}},bn=[{t:0}],ye=class extends q{constructor(...e){super(bn),this.$ctx.nodeInfo.element.append(...e),this.$ctx.elements=e}get $el(){return this.$ctx.elements}},En=class extends q{constructor(...e){super([{t:0},...e])}},yn=[{t:0},[["t"]]],Y=class extends q{constructor(e){y(),super(yn),this.text=e,b()}};Ue(Y,{text:{key:"t"}});const qe=e=>{if(e===null||typeof e=="undefined"||e instanceof q)return e;if(e!==Ee)return l.isNodeInstance(e)?new ye(e):typeof e=="string"?new Y(e):new Y(JSON.stringify(e))};_.EFBaseComponent=q,_.EFNodeWrapper=ye,_.toEFComponent=qe;const Nn=(e,t)=>class extends e{static __defaultScope(){const o=super.__defaultScope();return R(o,t)}},vn=(e,t)=>{for(let n in e)if(n.indexOf("xmlns:")===0){const[,o]=n.split(":");t.__local_namespaces[o]=e[n]}},Ie=(e,t)=>{const n=V(t);switch(n){case"array":{const[o,...r]=t;if(V(o)==="object"){e.__used_tags[o.t]=!0,o.a&&vn(o.a,e);for(let s of r)Ie(e,s)}break}case"object":{if(t.t>1)throw new TypeError(`[EF] Not a standard ef.js AST: Unknown mount point type '${t.t}'`);cn(t.t,t.n,e);break}case"string":break;default:throw new TypeError(`[EF] Not a standard ef.js AST: Unknown node type '${n}'`)}},$n=(e,t)=>{const n=class extends q{constructor(o,r){y(),super(e,r),o&&this.$update(o),b()}};return t&&Object.defineProperty(n,"name",{value:t}),Object.defineProperty(n.prototype,"constructor",{enumerable:!1}),Object.defineProperty(n,"__local_namespaces",{enumerable:!1,value:{}}),Object.defineProperty(n,"__used_tags",{enumerable:!1,value:{}}),Object.defineProperty(n,"__component_ast",{enumerable:!1,value:e}),Ie(n,e),n};let Cn="0.17.4",He=re;const Qe=e=>{const t=V(e);if(t==="string")e=jt(e,He);else if(t!=="array")throw new TypeError("Cannot create new component without proper template or AST!");return $n(e)},gn=e=>{He=e},_n=(e,...t)=>{const n=new Array(e.length+t.length);for(let o in e)n[o*2]=e[o];for(let o in t)n[o*2+1]=t[o];return"".concat(...n)},wn=(...e)=>Qe(_n(...e));let On="0.17.4";N.EFNodeWrapper=ye,N.EFTextFragment=Y,N.Fragment=En,N.bundle=Pt,N.create=Qe,N.declareNamespace=Ht,N.exec=b,N.inform=y,N.isPaused=Ft,N.mapAttrs=Ue,N.mountOptions=k,N.onNextRender=Ct,N.parseEft=re,N.scoped=Nn,N.setDOMImpl=ke,N.setParser=gn,N.t=wn,N.toEFComponent=qe,N.version=On});
//# sourceMappingURL=ef.min.js.map