UNPKG

magix

Version:

view manager framewrok

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