magix
Version:
view manager framewrok
1 lines • 20.1 kB
JavaScript
/*!3.8.14 MIT kooboy_li@163.com*/let e=e=>Object.prototype.toString.call(e).slice(8,-1),t=t=>r=>e(r)==t,r=t("Object"),n=t("Array"),i=0,l="",o=[],a=window,f=void 0,s=document,d=s.documentElement.getAttribute,h=(e,t)=>d.call(e,t),u=a.setTimeout;function c(){}let $,p,m=JSON.stringify,g="\x1e",b="prototype",v="params",w=/[#?].*$/,y=/([^=&?\/#]+)=?([^&#?]*)/g,x=/(?!^)=|&/,k=e=>(e||"mx_")+i++,V=k(),S={rootId:k(),defaultView:V,error(e){throw e}},I=e=>"object"==typeof e?e:s.getElementById(e),T=e=>!e||"object"!=typeof e,C=(e,t,r,n)=>{let i,l,o,a=0;for(o in e)i=e[o],l=t[o],T(i)&&l===i||H(n,o)||(r[o]=1,a=1),t[o]=i;return a},E=(e,t,r)=>{if(e=I(e),t=I(t),e&&t&&!(r=e==t))try{r=16==(16&t.compareDocumentPosition(e))}catch(e){}return r},{assign:P,keys:j,hasOwnProperty:M}=Object,A=document.head,q=document.createElement("div"),O=(e,t)=>{t&&!O[e]&&(O[e]=1,q.innerHTML=`<style>${t}`,A.appendChild(q.firstChild))},U=e=>h(e,"id")||(e.$a=1,e.id=k()),_=(e,t,r,i,l)=>{for(l of(t=t||o,n(e)||(e=[e]),n(t)||(t=[t]),e))try{i=l&&l.apply(r,t)}catch(e){S.error(e)}return i},H=(e,t)=>e&&M.call(e,t),L=(e,t)=>{let r,n;if(T(t))(r=t+l)[0]==g&&H(e,r)&&(t=e[r]);else for(r in t)n=t[r],n=L(e,n),t[r]=n;return t},N=(e,t)=>t.f-e.f||t.t-e.t;function D(e,t,r,n){(n=this).c=[],n.b=t||5,n.x=n.b+(e||20),n.r=r}P(D[b],{get(e){let t=this.c[g+e];return t&&(t.f++,t.t=i++,t=t.v),t},each(e,t,r,n,i){for(i of(r=this).c)e(i.v,t,r)},set(e,t){let r=this,n=r.c,l=g+e,o=n[l],a=r.b;if(!o){if(n.length>=r.x)for(n.sort(N);a--;)(o=n.pop()).f>0&&r.del(o.o);o={o:e},n.push(o),n[l]=o}o.v=t,o.f=1,o.t=i++},del(e){e=g+e;let t=this.c,r=t[e],n=this.r;r&&(r.f=-1,r.v=l,delete t[e],n&&_(n,r.o))},has(e){return H(this.c,g+e)}});let R=(e,t)=>{if(e)if(V==e)p||(p=Jt.extend()),t(p);else{let r=[],i=0;n(e)||(e=[e]);let l=e=>n=>{r[e]=n.default,++i==r.length&&t(...r)},o=S.paths;for(let t,r,n,i=e.length;i--;)(r=(t=e[i]).indexOf("/"))>-1&&(n=t.slice(0,r),t=t.slice(r+1),t=(o[n]||`unset/${n}/path/`)+t),t.endsWith(".js")||(t+=".js"),import(t).then(l(i))}else t()};function Z(){}let B=(e,t,r,n,i)=>(Z[b]=t[b],i=new Z,P(i,r),P(e,n),i.constructor=e,e[b]=i,e),z=(e,t,r)=>{let n=s.createEvent("Events");n.initEvent(t,!0,!0);for(let e in r)n[e]=r[e];e.dispatchEvent(n)},F=(e,t)=>{if(!t||!e||1!==e.nodeType)return 0;return(e.webkitMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.matchesSelector).call(e,t)},J=e=>e._mx||(e._mx=k("e")),Q={},W=()=>!0,X=()=>!1,G={preventDefault:"isDefaultPrevented",stopPropagation:"isPropagationStopped"},K=(e,t,r,n)=>{let i=J(e),l=Q[i]||(Q[i]=[]),o={a:r&&r.i,b:n,c:t,d(t){t=(e=>{if(!e.isDefaultPrevented){for(let t in G){let r=G[t],n=e[t];e[t]=((...t)=>(e[r]=W,n&&n.apply(e,t))),e[r]=X}(void 0!==e.defaultPrevented?e.defaultPrevented:"returnValue"in e?!1===e.returnValue:e.getPreventDefault&&e.getPreventDefault())&&(e.isDefaultPrevented=W)}return e})(t),n.call(e,t,r)}};l.push(o),e.addEventListener(t,o.d,r&&r.m)},Y=(e,t)=>{e.eventTarget=t.e,_(t.f,e,t.v)},ee=(e,t,r,n,i)=>{n?((e,t,r,n)=>{let i=J(e),l=Q[i];if(l){let i;for(let e,o=l.length;o--;)if((e=l[o]).c==t&&e.b===n){let t=e.a;if(!r||r&&r.i==t){i=e,l.splice(o,1);break}}i&&e.removeEventListener(t,i.d,r&&r.m)}})(e,t,i,r):K(e,t,i,r)},te=e=>e;let re,ne=new D,ie=0,le=(e,t,r)=>{try{r=decodeURIComponent(r)}catch(e){}re[t]=r},oe=e=>{let t,r=ne.get(e);return r||(re={},t=e.replace(w,l),e==t&&x.test(t)&&(t=l),e.replace(t,l).replace(y,le),ne.set(e,r={a:t,b:re})),{path:r.a,params:{...r.b}}},ae=(e,t,r)=>{let n,i,o,a=[];for(i in t)n=t[i]+l,(!r||n||H(r,i))&&(n=encodeURIComponent(n),a.push(o=i+"="+n));return o&&(e+=(e&&(~e.indexOf("?")?"&":"?"))+a.join("&")),e},fe=(e,t)=>{let r,n={};if(e)for(r of e)n[t&&r?r[t]:r]=t?r:1+(0|n[r]);return n},se=new D,de=(e,t,r)=>(se.has(e)?r=se.get(e):(r=_(Function(`return ${e}`)),e.indexOf(g)>-1?L(t,r):se.set(e,r)),r),he={config:(e,t)=>(t=S,e&&(t=r(e)?P(t,e):t[e]),t),boot(e){P(S,e),R(S.ini,t=>{P(S,t,e),R(S.exts,()=>{Le.on("changed",Be),ve.on("changed",Be),ie=1,Oe()})})},toMap:fe,toTry:_,toUrl:ae,parseUrl:oe,mix:P,has:H,keys:j,inside:E,node:I,applyStyle:O,guid:k,use:R,Cache:D,fire:z,type:e,nodeId:U,guard:te},ue={fire(e,t,r,n){let i,o,a,f,s=this,d=s[g+e];if(t||(t={}),t.type=e,d)for(o=(i=d.length)-1;i--;)(f=d[a=n?i:o-i]).f?(f.x=1,_(f.f,t,s),f.x=l):f.x||(d.splice(a,1),o--);return(d=s[`on${e}`])&&_(d,t,s),r&&s.off(e),s},on(e,t){let r=g+e;return(this[r]||(this[r]=[])).push({f:t}),this},off(e,t){let r,n=g+e,i=this,o=i[n];if(t){if(o)for(r of o)if(r.f==t){r.f=l;break}}else delete i[n],delete i[`on${e}`];return i}};he.Event=ue;let ce={},$e={},pe={},me=0,ge=e=>{e=(e+l).split(",");for(let t of e)H($e,t)?$e[t]++:$e[t]=1;return e},be=e=>{let t,r;for(t of e)H($e,t)&&((r=--$e[t])||(delete $e[t],delete ce[t]))};let ve={get(e){let t=e?ce[e]:ce;return t},set(e,t){return me=C(e,ce,pe,t)||me,this},digest(e,t){if(e&&ve.set(e,t),me){0,me=0;let e=P({},pe);pe={},this.fire("changed",{keys:e})}},diff:()=>pe,clean:e=>({ctor(){e=ge(e),this.on("destroy",()=>be(e))}}),...ue};he.State=ve;let we,ye=new D,xe=new D,ke=a.location,Ve=0,Se={query:{},params:{},href:l},Ie=/(?:^.*\/\/[^\/]+|#.*$)/gi,Te=/^[^#]*#?!?/;function Ce(e,t){return this[v][e]||t!==f&&t||l}let Ee,Pe,je,Me,Ae,qe=(e,t)=>{e="#!"+e,t?ke.replace(e):ke.hash=e},Oe=()=>{let e,t,r=_e().srcHash;ee(a,"hashchange",(n,i,o)=>{t||(i=_e(),(e=i.srcHash)!=r&&(o=(()=>{n.p=1,r=e,t=l,qe(e),He()}),n={reject(){n.p=1,t=l,qe(r)},resolve:o,prevent(){t=1}},Le.fire("change",n),t||n.p||o()))}),ee(a,"beforeunload",(e,t,r)=>{if(e=e||a.event,t={},Le.fire("pageunload",t),r=t.msg)return e&&(e.returnValue=r),r}),He()},Ue=s.title,_e=e=>{e=e||ke.href;let t,n,i,o,a,f=ye.get(e);return f||(t=e.replace(Ie,l),n=e.replace(Te,l),f={get:Ce,href:e,srcQuery:t,srcHash:n,query:i=oe(t),hash:o=oe(n),params:a={...i[v],...o[v]}},ie&&(((e,t)=>{if(Ee||(Ee=S.routes||{},Pe=S.unmatchView,je=S.defaultView,Me=S.defaultPath||"/",Ae=S.rewrite),!e.view){let n=e.hash.path||Me;Ae&&(n=Ae(n,e[v],Ee)),t=Ee[n]||Pe||je,e.path=n,e.view=t,r(t)&&P(e,t)}})(f),ye.set(e,f))),f},He=()=>{let e=_e(),t=((e,t)=>{let r=e.href,n=t.href,i=r+g+n,l=xe.get(i);if(!l){let n,o;l={params:o={},force:!r};let a,f=e[v],s=t[v],d=j(f).concat(j(s)),h=e=>{let t=f[e],r=s[e];t!=r&&(o[e]={from:t,to:r},n=1)};for(a of d)h(a);f=e,s=t,o=l,h("path"),h("view"),xe.set(i,l={a:n,b:l})}return l})(Se,Se=e);return!Ve&&t.a&&((we=t.b).path&&(s.title=e.title||Ue),Le.fire("changed",we)),Ve=0,we},Le={parse:_e,diff:He,to(e,t,n,i){!t&&r(e)&&(t=e,e=l);let o=oe(e),a=o[v],f=o.path,s=Se.path,d=Se[v],h=Se.query[v];if(P(a,t),f)for(s in h)H(a,s)||(a[s]=l);else d&&(f=s,a={...d,...a});((e,t,r,n,i,l)=>{(e=ae(e,t,l))!=r.srcHash&&(Ve=i,qe(e,n))})(f,a,Se,n,i,h)},...ue};he.Router=Le;let Ne,De,Re=0,Ze=(e,t,r,n,i,l,o)=>{e&&e.$a!=Re&&(r=e.$v)&&r.$a>1&&((t?((e,t,r)=>{let n,i=e.$os;if(i)for(n of i)if(r=H(t,n))break;return r})(r,t):Ft(r))&&(o=r.$b()),o&&o.then||(o=Fe),o.then(()=>{for(l of e.children())Ze(ze[l],t)}))},Be=(e,t,r)=>{t=Xe(),(r=e.view)?t.mountView(r.to):(Re=i++,Ze(t,e.keys))},ze={},Fe={then:e=>e()},Je=e=>{if(!e.$b&&!e.$d&&e.$cc==e.$rc){e.$cr||(e.$cr=1,e.$ca=0,e.fire("created"));let{id:t,pId:r}=e,n=ze[r];n&&!H(n.$e,t)&&(n.$e[t]=1,n.$rc++,Je(n))}},Qe=(e,t)=>{if(!e.$ca&&e.$cr){e.$cr=0,e.$ca=1,e.fire("alter",t);let{id:r,pId:n}=e,i=ze[n];i&&H(i.$e,r)&&(i.$rc--,delete i.$e[r],Qe(i,t))}},We=(e,t,r,n)=>(n=(n=(n=ze[e])&&n.$v)?n.$d.$a:{},t.indexOf(g)>0&&L(n,r),n),Xe=e=>(Ne||($=s.body,e=S.rootId,I(e)||($.id=e),Ne=new et(e)),Ne),Ge=(e,t)=>{H(ze,e)||(ze[e]=t,et.fire("add",{vframe:t}),(e=I(e))&&(e.vframe=t))},Ke=(e,t,r)=>{for(t=e.$f;t.length;)(r=t.shift()).r||e.invoke(r.n,r.a),delete t[r.k]},Ye=[];function et(e,t,r){(r=this).id=e,r.$c={},r.$cc=0,r.$rc=0,r.$g=r.$g||1,r.$e={},r.$f=[],r.pId=t,Ge(e,r)}P(et,{all:()=>ze,get:e=>ze[e]},ue),P(et[b],ue,{mountView(e,t){let r,n,i,o,a,f=this,s=f.id,d=I(s),h=f.pId;!f.$h&&d&&(f.$h=1,f.$i=d.innerHTML),f.unmountView(),f.$b=0,r=oe(e||l),i=r.path,d&&i&&(f.path=e,o=r[v],We(h,e,o),f.$j=r.path,P(o,t),n=f.$g,R(i,e=>{if(n==f.$g){if(!e)return S.error(Error(`id:${s} cannot load:${i}`));a=zt(e),i=new e(s,f,o,d,a),f.$v=i,f.$a=Re,Dt(i),_(i.init,[o,{node:d,deep:!i.tmpl}],i),i.$b(),i.tmpl||(f.$h=0,i.$e||i.endUpdate())}}))},unmountView(){let e,t,r=this,{$v:n,id:i}=r;r.$f=[],n&&(De||(t=1,De={id:i}),r.$b=1,r.unmountZone(0,1),Qe(r,De),r.$v=0,n.$a>0&&(n.$a=0,delete lt[i],delete ot[i],n.fire("destroy",0,1,1),Ht(n,1),Dt(n,1),n.owner=0),n.$a--,(e=I(i))&&r.$h&&(e.innerHTML=r.$i),t&&(De=0)),r.$g++},mountVframe(e,t,r){let n,i=this,l=i.id,o=i.$c;return Qe(i,{id:e}),(n=ze[e])||(H(o,e)||(i.$n=0,i.$cc++),o[e]=e,(n=Ye.pop())?et.call(n,e,l):n=new et(e,l)),n.mountView(t,r),n},mountZone(e,t){let r,n,i=this,l=[],o=(e=>s.querySelectorAll(e))(`#${e=e||i.id} [mx-view]`);for(r of(i.$d=1,o))r.$b||(n=U(r),r.$b=1,l.push([n,h(r,"mx-view")]));for([n,r]of l)i.mountVframe(n,r);i.$d=0,t||Je(i)},unmountVframe(e,t){let r;if(e=e?this.$c[e]:this.id,r=ze[e]){let{$cr:n,pId:i}=r;r.unmountView(),((e,t,r)=>{(r=ze[e])&&(delete ze[e],et.fire("remove",{vframe:r,fcc:t}),(e=I(e))&&(e.$b=0,e.vframe=0,e.$a=0))})(e,n),r.id=r.pId=r.$c=r.$e=0,r.$h=0,r.off("alter"),r.off("created"),Ye.push(r),(r=ze[i])&&H(r.$c,e)&&(delete r.$c[e],r.$n=0,r.$cc--,t||Je(r))}},unmountZone(e,t){let r,n=this;for(r in n.$c)(!e||r!=e&&E(r,e))&&n.unmountVframe(r,1);t||Je(n)},parent(e,t){for(t=this,e=e>>>0||1;t&&e--;)t=ze[t.pId];return t},children(e){return(e=this).$n||(e.$n=j(e.$c))},invoke(e,t){let r,n,i,l,o,a=this.$f;return(n=this.$v)&&n.$e?r=(i=n[e])&&_(i,t,n):((l=a[o=g+e])&&(l.r=t===l.a),l={n:e,a:t,k:o},a.push(l),a[o]=l),r}}),he.Vframe=et;let tt=new D(30,10),rt=/(?:([\w\-]+)\x1e)?([^(]+)\(([\s\S]*)?\)/,nt={},it={},lt={},ot={},at=0,ft=(e,t)=>{let r,n,i,l,a,f,s=[],d=e,u=h(e,`mx-${t}`),c=[],p="#",m=0;if(u&&((a=tt.get(u))||(a={v:(a=u.match(rt)||o)[1],n:a[2],i:a[3]},tt.set(u,a)),a={...a,r:u}),a&&!a.v||it[t]){if((i=ot[n=d.$d])&&1==i[d.$e]&&(f=1,p=n),!f){for(c.push(d);d!=$&&(d=d.parentNode);){if(ze[n=d.id]||(i=ot[n=d.$d])&&1==i[d.$e]){p=n;break}c.push(d)}for(u of c)(n=ot[p])||(n=ot[p]={}),n[i=u.$e||(u.$e=++at)]=1,u.$d=p}d=e.id,ze[d]&&(m=p=d);do{if((r=ze[p])&&(f=r.$v)){if(l=(i=f.$so)[t])for(d=l.length;d--;)i={r:n=l[d],v:p,n:n},n?!m&&F(e,n)&&s.push(i):m&&s.unshift(i);if(f.tmpl&&!m){a&&!a.v&&(a.v=p);break}m=0}}while(r&&(p=r.pId))}return a&&s.push(a),s},st=e=>{let t,r,n,i,l,o,a,f,{target:s,type:d}=e,h=[];for(;s!=$;){if((t=ft(s,d)).length){h=[];for(let{v:r,r:h,n:u,i:c}of t){if(a!=r){if(a&&e.isPropagationStopped())break;a=r}(i=(n=ze[r])&&n.$v)?(o=i[l=u+g+d])&&(e.eventTarget=s,f=c?de(c,i.$d.$a):{},e[v]=f,_(o,e,i)):e.stopPropagation()}}if((r=lt[o=s.$d])&&(r=r[s.$e])&&r[d]||e.isPropagationStopped()){h.length&&h.push(o);break}a=s.id,ze[a]&&h.push(a),h.push(s),s=s.parentNode||$}if(o=h.length)for(r="#";o--;)(i=h[o]).nodeType?((t=lt[r])||(t=lt[r]={}),(f=t[a=i.$e||(i.$e=++at)])||(f=t[a]={}),f[d]=1):r=i},dt=(e,t,r)=>{let n=0|nt[e],i=r?-1:1;n&&r!==n||ee($,e,st,r),nt[e]=n+i,t&&(it[e]=(0|it[e])+i)},ht="http://www.w3.org/2000/svg",ut="http://www.w3.org/1998/Math/MathML",ct={option:[1,"<select multiple>"],thead:[1,"<table>"],col:[2,"<table><colgroup>"],tr:[2,"<table><tbody>"],td:[3,"<table><tbody><tr>"],area:[1,"<map>"],param:[1,"<object>"],g:[1,`<svg xmlns="${ht}">`],m:[1,`<math xmlns="${ut}">`],_:[0,""]},$t=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i;ct.optgroup=ct.option,ct.tbody=ct.tfoot=ct.colgroup=ct.caption=ct.thead,ct.th=ct.td;let pt=s.implementation.createHTMLDocument(l),mt=pt.createElement("base");mt.href=s.location.href,pt.head.appendChild(mt);let gt=(e,t)=>{if(1==t.nodeType){let r=U(t);e.unmountZone(r,1),e.$c[r]&&e.unmountVframe(r,1)}},bt={INPUT:["value","checked"],TEXTAREA:["value"],OPTION:["selected"]},vt=(e,t)=>(1==e.nodeType&&(e.$f?t=e.$g:((t=e.$a?l:h(e,"id"))||(t=h(e,"mxs")),t||(t=h(e,"mx-view"))&&(t=oe(t).path),e.$f=1,e.$g=t)),t),wt=(e,t,r,n,i)=>{let l,o,a,f,s,d=e.lastChild,h=t.firstChild,u=0,c={},$={};for(;d;)u++,(a=vt(d))&&(a=c[a]||(c[a]=[])).push(d),d=d.previousSibling;for(;h;)(a=vt(h))&&($[a]=($[a]||0)+1),h=h.nextSibling;for(h=t.firstChild,d=e.firstChild;h;)if(u--,l=h,h=h.nextSibling,(f=c[a=vt(l)])&&(f=f.pop())){for(;f!=d;)s=d.nextSibling,e.appendChild(d),d=s;d=f.nextSibling,$[a]&&$[a]--,yt(f,l,e,r,n,i)}else d?(a=vt(o=d))&&c[a]&&$[a]?(u++,r.c=1,r.n.push([8,e,l,o])):(d=d.nextSibling,yt(o,l,e,r,n,i)):(r.c=1,r.n.push([1,e,l]));for(o=e.lastChild;u-- >0;)gt(n,o),r.n.push([2,e,o]),o=o.previousSibling,r.c=1},yt=(e,t,r,n,i,o)=>{if(((e,t)=>{let r,n=e.nodeName,i=bt[n],l=0;if(i)for(r of i)e[r]!=t[r]&&(l=1,e[r]=t[r]);return l})(e,t)||1==e.nodeType&&e.hasAttribute("mxv")||!e.isEqualNode||!e.isEqualNode(t))if(e.nodeName===t.nodeName)if(1===e.nodeType){let r=h(t,"mxs");if(r&&r==h(e,"mxs"))return;let a,f,s,d,u,c,$,p=h(t,"mx-view"),m=t.innerHTML,g=h(t,"mxa"),b=!g||g!=h(e,"mxa"),w=ze[h(e,"id")],y=p&&oe(p);if(p&&w&&(!h(t,"id")||h(t,"id")==h(e,"id"))&&w.$j==y.path&&(d=w.$v)){if(c=m!=w.$i,$=p!=w.path,s=h(e,"mxv"),!c&&!$&&s)for(s of u=s.split(","))if("#"==s||H(o,s)){$=1;break}($||c)&&((s=d.$e&&d.$f)?(u=y[v],We(w.pId,p,u),w.$i=m,w.path=p,y={node:t,deep:!d.tmpl,attr:b,inner:c,query:$,keys:o},_(s,[u,y],d)&&n.v.push(d),a=y.deep):(f=1,a=1))}else a=1,f=w;f&&(n.c=1,w.unmountVframe(0,1)),b&&((e,t,r,n)=>{let i,o,a,f;delete e.$f;let s=e.attributes,d=t.attributes;for(o=s.length;o--;)i=s[o].name,t.hasAttribute(i)||("id"==i?n||r.d.push([e,l]):(r.c=1,e.removeAttribute(i)));for(o=d.length;o--;)a=(i=d[o]).name,f=i.value,h(e,a)!=f&&("id"==a?r.d.push([e,f]):(r.c=1,e.setAttribute(a,f)))})(e,t,n,w&&p),a&&wt(e,t,n,i,o)}else e.nodeValue!==t.nodeValue&&(n.c=1,e.nodeValue=t.nodeValue);else gt(i,e),n.c=1,n.n.push([4,r,t,e])},xt={"&":"amp","<":"lt",">":"gt",'"':"#34","'":"#39","`":"#96"},kt=/[&<>"'\`]/g,Vt=e=>""+(null==e?"":e),St=e=>`&${xt[e]};`,It=e=>Vt(e).replace(kt,St),Tt=(e,t,r,n)=>{for(n=e[g];--n;)if(e[r=g+n]===t)return r;return e[r=g+e[g]++]=t,r},Ct={"!":"%21","'":"%27","(":"%28",")":"%29","*":"%2A"},Et=e=>Ct[e],Pt=/[!')(*]/g,jt=e=>encodeURIComponent(Vt(e)).replace(Pt,Et),Mt=/[\\'"]/g,At=e=>Vt(e).replace(Mt,"\\$&"),qt=(e,t)=>{let r,n,i=e.$k,l=e.$c,o=e.$b,a=ze[o],f=a&&a.$v,d={d:[],v:[],n:[]},h=I(o),u=e.$d,c=e.$a,$=r=>{t.i<t.length?qt(e,t):(d=t.slice(),t.i=t.length=0,r&&f.fire("domready"),_(d))};if(t.i=t.length,e.$c=0,e.$k={},l&&f&&h&&f.$a>0&&(r=f.tmpl)&&f.$d==e){for(n of(f.fire("dompatch"),delete lt[o],delete ot[o],n=((e,t)=>{let r,n=pt.createElement("div"),i=t.namespaceURI;r=i==ht?"g":i==ut?"m":($t.exec(e)||[0,""])[1];let l=ct[r]||ct._;n.innerHTML=l[1]+e;let o=l[0];for(;o--;)n=n.lastChild;return n})(r(u,o,c,It,Vt,jt,Tt,At),h),wt(h,n,d,a,i),d.d))n[0].id=n[1];for(n of d.n)1==n[0]?n[1].appendChild(n[2]):2==n[0]?n[1].removeChild(n[2]):4==n[0]?n[1].replaceChild(n[2],n[3]):n[1].insertBefore(n[2],n[3]);for(n of(a.$d=r=d.c||!f.$e,d.v))n.$b();r&&f.endUpdate(o),d.c&&z(s,"htmlchanged",{vId:o}),$(1)}else $()};function Ot(e){let t=this;t.$b=e,t.$c=1,t.$d={vId:e},t.$a={[g]:1},t.$e=[],t.$k={}}P(Ot[b],{get(e,t){return t=this.$d,e&&(t=t[e]),t},set(e,t){let r=this;return r.$c=C(e,r.$d,r.$k,t)||r.$c,r},digest(e,t,r){let n=this.set(e,t),i=n.$e;r&&i.push(r),i.i||qt(n,i)},snapshot(){return this.$f=m(this.$d),this},altered(){let e=this;if(e.$f)return e.$f!=m(e.$d)},translate(e){return L(this.$d,e)},parse(e){return de(e,this.$a)}});let Ut=/^(\$?)([^<]*)<([^>]+)>(?:&(.+))?$/,_t=(e,t,r)=>(e.a?r=e:((r=function(e){_(r.a,e,this)}).a=[e],r.b=1),r.a=r.a.concat(t.a||t),r),Ht=(e,t)=>{let r,n,i=e.$r;for(r in i)n=i[r],(t||n.x)&&Lt(i,r,1)},Lt=(e,t,r,n)=>{let i,l,a=e[t];return a&&a!=n&&((i=(l=a.e).destroy)&&r&&_(i,o,l),delete e[t]),l},Nt=(e,t,r,n,i)=>{n=e[t],e[t]=e[r]=function(...e){if((i=this).$a>0)return i.$a++,i.fire("rendercall"),Ht(i),_(n,e,i)}},Dt=(e,t)=>{let r,{$eo:n,$so:i,$el:l,id:o}=e;for(r in n)dt(r,i[r],t);for(r of l)ee(r.e,r.n,Y,t,{i:o,v:e,f:r.f,m:r.m,e:r.e})},Rt={win:a,doc:s},Zt=(e,t,r)=>{let n,i,l,o,a={};for(i of e)for(n in i)l=i[n],o=a[n],"ctor"!=n?(Ut.test(n)&&(o?l=_t(o,l):l.b=1),a[n]=l):r.push(l);for(n in a)H(t,n)||(t[n]=a[n])};function Bt(...e){let t=this._||(this._=[]);return Zt(e,this[b],t),this}let zt=e=>{if(!e[g]){e[g]=[];let t,r,n,i,l,o,a,f,s,d,h,u=e[b],c={},$=[],p={};for(a in(r=u.mixins)&&Zt(r,u,e[g]),u)if(t=u[a],r=a.match(Ut)){if([,o,n,i,h]=r,d={},h)for(f of h=h.split(","))d[f]=!0;for(f of i=i.split(",")){if(l=Rt[n],s=1,o){if(l){$.push({f:t,e:l,n:f,m:d});continue}s=2,(l=p[f])||(l=p[f]=[]),l[n]||(l[n]=1,l.push(n))}c[f]=c[f]|s,(l=u[f=n+g+f])?l.b&&(t.b?u[f]=_t(t,l):H(u,a)&&(u[f]=t)):u[f]=t}}Nt(u,"render","$b"),u.$eo=c,u.$el=$,u.$so=p,u.$f=u.assign}return e[g]},Ft=e=>{let t,r,n,i=e.$l;if(i.f&&(i.p&&(t=we.path),!t&&i.k))for(r of(n=we[v],i.k))if(t=H(n,r))break;return t};function Jt(e,t,r,n,i){(i=this).owner=t,i.id=e,i.$l={k:[]},i.$r={},i.$a=1,i.updater=i.$d=new Ot(i.id),(e=Jt._)&&_(e,[r,{node:n,deep:!i.tmpl}],i)}P(Jt,{merge:Bt,extend:function e(t,r){let n=this,i=(t=t||{}).ctor,l=[];function o(e,t,r,i,a,f,s,d,h){n.call(s=this,e,t,r,i,a),f=o._,d=[r,{node:i,deep:!s.tmpl}],f&&_(f,d,s),(h=l.concat(a)).length&&_(h,d,s)}return i&&l.push(i),o.merge=Bt,o.extend=e,B(o,n,t,r)}}),P(Jt[b],ue,{init:c,beginUpdate(e,t){(t=this).$a>0&&t.$e&&t.owner.unmountZone(e,1)},endUpdate(e,t,r,n,i){(r=this).$a>0&&(e=e||r.id,t?i=t:(i=r.$e,r.$e=1),(n=r.owner).mountZone(e,t),i||u(r.wrapAsync(Ke),0,n))},wrapAsync(e,t){let r=this,n=r.$a;return(...i)=>{if(n>0&&n==r.$a)return e.apply(t||r,i)}},observeLocation(e,t){let n;(n=this.$l).f=1,r(e)&&(t=e.path,e=e[v]),n.p=t,e&&(n.k=(e+l).split(","))},observeState(e){this.$os=(e+l).split(",")},capture(e,t,r,n){return n=this.$r,t?(Lt(n,e,1,t),n[e]={e:t,x:r}):t=(n=n[e])&&n.e,t},release(e,t){return Lt(this.$r,e,t)},leaveTip(e,t){let r=this,n=i=>{let l="a",o="b";"change"!=i.type&&(l="b",o="a"),n[l]?(i.prevent(),i.reject()):t()&&(i.prevent(),n[o]=1,r.leaveConfirm(()=>{n[o]=0,i.resolve()},()=>{n[o]=0,i.reject()},e))},i=r=>{t()&&(r.msg=e)};Le.on("change",n),Le.on("pageunload",i),r.on("unload",n),r.on("destroy",()=>{Le.off("change",n),Le.off("pageunload",i)})},render:c}),he.View=Jt;let Qt=Date.now;function Wt(){this.id=k("b"),this.$={}}P(Wt[b],{get(t,r){let i,o=this.$;if(t){let e,r=n(t)?t.slice():(t+l).split(".");for(;(e=r.shift())&&o;)o=o[e];e&&(o=f)}return r!==f&&(i=e(r))!=e(o)&&(o=r),o},set(e,t){r(e)||(e={[e]:t}),P(this.$,e)}});function Xt(e,t,r){(r=this[e])&&(delete this[e],_(r,t,r.e))}let Gt=(e,t,r,n,i,l)=>{let o=[],a=null,f=0;return function(s,d){f++;let h,u,c=this,$=c.$b,p=$.k;if(o[s+1]=c,d?(a=d,h=1):l.has(p)||(p&&l.set(p,c),$.t=Qt(),(u=$.a)&&_(u,c,c),(u=$.x)&&t.clear(u),h=1),!r.$d){let t=f==n;t&&(r.$e=0,2==i&&(o[0]=a,_(e,o,r))),1==i&&_(e,[d||null,c,t,s],r)}h&&t.fire("end",{bag:c,error:d})}},Kt=(e,t,r,i,l)=>{if(e.$d)return e;if(e.$e)return e.enqueue(Kt.bind(e,e,t,r,i,l));e.$e=1,n(t)||(t=[t]);let o=e.constructor,a=0,f=o.$f,s=Gt(r,o,e,t.length,i,o.$c);for(let e of t)if(e){let t,r=o.get(e,l),n=r.e,i=n.$b.k,d=s.bind(n,a++);i&&f[i]?f[i].push(d):r.u?(i&&((t=[d]).e=n,f[i]=t,d=Xt.bind(f,i)),o.$s(n,d)):d()}return e};function Yt(){let e=this;e.id=k("s"),e.$g=[]}P(Yt[b],{all(e,t){return Kt(this,e,t,2)},save(e,t){return Kt(this,e,t,2,1)},one(e,t){return Kt(this,e,t,1)},enqueue(e){let t=this;return t.$d||(t.$g.push(e),t.dequeue(t.$h)),t},dequeue(...e){let t,r=this;r.$e||r.$d||(r.$e=1,u(()=>{r.$e=0,r.$d||(t=r.$g.shift())&&_(t,r.$h=e)},0))},destroy(e){(e=this).$d=1,e.$g=0}});let er=(e,t)=>[m(t),m(e)].join(g),tr=(e,t,r,n)=>{(n=e&&e.$b)&&t[n.n]&&r.del(n.k)},rr={add(e){let t,r=this.$b;for(t of(n(e)||(e=[e]),e))if(t){let{name:e,cache:n}=t;t.cache=0|n,r[e]=t}},create(e){let t=this.meta(e),n=0|e.cache||t.cache,i=new Wt;i.set(t),i.$b={n:t.name,a:t.after,x:t.cleans,k:n&&er(t,e)},r(e)&&i.set(e);let l=t.before;return l&&_(l,i,i),this.fire("begin",{bag:i}),i},meta(e){return this.$b[e.name||e]||e},get(e,t){let r,n,i=this;return t||(r=i.cached(e)),r||(r=i.create(e),n=1),{e:r,u:n}},clear(e){this.$c.each(tr,fe((e+l).split(",")))},cached(e){let t,r,n=this,i=n.$c,l=n.meta(e),o=0|e.cache||l.cache;if(o&&(r=er(l,e)),r){let e=n.$f[r];e?t=e.e:(t=i.get(r))&&Qt()-t.$b.t>o&&(i.del(r),t=0)}return t},...ue};Yt.extend=((e,t,r)=>{function n(){Yt.call(this)}return n.$s=e,n.$c=new D(t,r),n.$f={},n.$b={},B(n,Yt,null,rr)}),he.Service=Yt,P(c[b],ue),c.extend=function e(t,r){let n=this,i=t&&t.ctor;function l(...e){n.apply(this,e),i&&i.apply(this,e)}return l.extend=e,B(l,n,t,r)},he.Base=c;export default he