jaxs 0.6.0 → 0.6.2

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/jaxs.umd.cjs CHANGED
@@ -1 +1,1157 @@
1
- (function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.jaxs={}))})(this,function(p){"use strict";const f=(e,t)=>t.createElement(e),ot=(e,t)=>{for(const s in t){if(s==="__self")continue;const n=t[s].toString();if(s==="value"){const r=e;r.value!==n&&(r.value=n)}else e.setAttribute(s,n)}},it=(e,t,s)=>{const n={};for(const r in t){const o=t[r],a=l=>s(o,l);e.addEventListener(r,a),n[r]={domEvent:r,busEvent:o,listener:a}}e.eventMaps=n},ut=(e,t,s,n)=>{const r=f(e,n.document);return ot(r,t),it(r,s,n.publish),r},g="http://www.w3.org/2000/svg",at={animate:!0,animateMotion:!0,animateTransform:!0,circle:!0,clipPath:!0,defs:!0,desc:!0,ellipse:!0,feBlend:!0,feColorMatrix:!0,feComponentTransfer:!0,feComposite:!0,feConvolveMatrix:!0,feDiffuseLighting:!0,feDisplacementMap:!0,feDistantLight:!0,feDropShadow:!0,feFlood:!0,feFuncA:!0,feFuncB:!0,feFuncG:!0,feFuncR:!0,feGaussianBlur:!0,feImage:!0,feMerge:!0,feMergeNode:!0,feMorphology:!0,feOffset:!0,fePointLight:!0,feSpecularLighting:!0,feSpotLight:!0,feTile:!0,feTurbulence:!0,filter:!0,foreignObject:!0,g:!0,image:!0,line:!0,linearGradient:!0,marker:!0,mask:!0,metadata:!0,mpath:!0,path:!0,pattern:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,script:!0,set:!0,stop:!0,style:!0,svg:!0,switch:!0,symbol:!0,text:!0,textPath:!0,title:!0,tspan:!0,use:!0,view:!0},ct=(e,t)=>!!(at[e]||e==="a"&&t===g),lt=(e,t,s)=>{const n=s.createElementNS(g,e);for(const r in t)r==="__self"||r==="xmlns"||n.setAttributeNS(null,r,t[r].toString());return n},ht=e=>e.namespaceURI===g,dt=(e,t)=>t.createTextNode(e);class pt{constructor(t){this.value=t.toString()}render(t){const s=dt(this.value,t.document);return s.__jsx="TextNode",[s]}}const mt=e=>typeof e=="string"||typeof e=="number",ft=e=>new pt(e),bt=e=>mt(e)?ft(e):e,vt=e=>gt(e).map(bt).flat(),gt=e=>Array.isArray(e)?e.flat():e?[e]:[],S=(e,t={})=>e||t.children||[],yt=(e,t="")=>{const s={},n={};for(const r in e){const o=e[r];if(r.match(/^on.+/i)){const a=r.slice(2).toLowerCase();n[a]=o?o.toString():""}else{if(o===!1)continue;r==="__source"?s.__source=e.__source:s[r]=Et(r,o,t)}}return{attributes:s,events:n}},Et=(e,t,s="")=>t==null?s:t.toString(),xt=(e,t)=>{const s=e||{},n=S(t,s);return s.children=s.children||n,s},N=(e,t,s,n=[])=>e.reduce(At(t,s),n).flat(),At=(e,t)=>(s,n)=>n?Array.isArray(n)?N(n,e,t,s):(n.render(e,t).forEach(r=>s.push(r)),s):s;class j{constructor(t){this.collection=vt(t)}render(t,s){this.parentElement=s;const n=this.generateDom(t);return this.attachToParent(n),n}generateDom(t){return N(this.collection,t,this.parentElement)}attachToParent(t){if(this.parentElement===void 0)return;const s=this.parentElement;t.forEach(n=>s.appendChild(n))}}class _t{constructor(t,s){this.type=t,this.attributes=s}generate(){return this.attributes.key||this.sourceKey()||this.createKeyFromAttributes()}sourceKey(){if(this.attributes.__source){const{fileName:t,lineNumber:s,columnNumber:n}=this.attributes.__source;return`${t}:${s}:${n}`}}createKeyFromAttributes(){const t=this.attributes.id?`#${this.attributes.id}`:"",s=this.attributes.type?`[type=${this.attributes.type}]`:"",n=this.attributes.name?`[name=${this.attributes.name}]`:"";return`${this.type}${t}${s}${n}`}}class wt{constructor(t,s,n=[]){this.type=t;const{events:r,attributes:o}=yt(s);this.events=r,this.attributes=o,this.isSvg=ct(this.type,this.attributes.xmlns),this.children=new j(n)}render(t){const s=this.generateDom(t);return s?(this.children.render(t,s),[s]):[]}generateDom(t){return this.isSvg?this.generateSvgDom(t):this.generateHtmlDom(t)}generateHtmlDom(t){const s=ut(this.type,this.attributes,this.events,t);return s.__jsx=this.jsxKey(),s}generateSvgDom(t){const s=lt(this.type,this.attributes,t.document);return s.__jsx=this.jsxKey(),s}jsxKey(){return new _t(this.type,this.attributes).generate()}}const O=(e,t,...s)=>typeof e=="string"?new wt(e,t,s):e(xt(t,s));O.fragment=(e,t)=>{const s=S(t,e);return new j(s)};class St{constructor(t,s,n){this.template=t,this.selector=s,this.renderKit=n,this.dom=[]}renderAndAttach(t){this.parentElement=this.getParentElement(),this.dom=this.render({...t,parent:this.parentElement}),this.parentElement&&this.attach()}render(t){return this.template.render(t)}attach(){this.parentElement&&(this.parentElement.innerHTML=""),this.dom.forEach(t=>{this.parentElement&&this.parentElement.appendChild(t)})}getParentElement(){return this.renderKit.document.querySelector(this.selector)}}const Nt=(e,t,s)=>{const n=new St(e,t,s);return n.renderAndAttach(s),n},M="go-to-href",b="navigation:location-change",T="navigation:route-change",jt=Object.freeze(Object.defineProperty({__proto__:null,linkNavigationEvent:M,locationChangeEvent:b,routeChangeEvent:T},Symbol.toStringTag,{value:"Module"})),k=e=>{e.createRecord("route",{host:"",path:"",query:{}})},$=e=>{const t=e.closest("[href]");return t&&t.getAttribute("href")||""},P=(e,{publish:t,window:s})=>{s.history.pushState(null,"",e),t(b,null)},D=(e,t)=>{if(!e||!e.target)return;e.preventDefault();const s=$(e.target);P(s,t)},L=e=>e.replace(/^\?/,"").split("&").reduce((t,s)=>{if(!s)return t;const n=s.split("=");return t[n[0]]=n[1],t},{}),F=(e,t)=>{const{state:s,publish:n,window:r}=t,{host:o,pathname:a,search:l}=r.location,u=a,d=L(l),c={host:o,path:u,query:d};s.store("route").update(c),n(T,c)},B=e=>{const{subscribe:t}=e;t(M,D)},z=e=>{const{publish:t,subscribe:s,state:n,window:r}=e;k(n),r.addEventListener("popstate",()=>t(b,null)),s(b,F)},V=e=>{setTimeout(()=>e.publish(b,null),0)},K=e=>{z(e),B(e),V(e)},Ot=Object.freeze(Object.defineProperty({__proto__:null,publishLocation:V,startNavigation:K,subscribeToHistoryChange:z,subscribeToNavigation:B},Symbol.toStringTag,{value:"Module"}));class R{constructor({window:t,document:s,publish:n,subscribe:r,bus:o,state:a,renderKit:l}){this.window=t,this.document=s,this.publish=n,this.subscribe=r,this.bus=o,this.state=a,this.renderKit=l,this.roots=[]}render(t,s){const n=Nt(t,s,this.renderKit);return this.roots.push(n),n}startNavigation(){K(this)}}const Mt=Object.freeze(Object.defineProperty({__proto__:null,App:R},Symbol.toStringTag,{value:"Module"}));class U{constructor(){this.lookup={}}add(t,s,n){this.ensureArrayFor(t);const r={listener:s,index:n,matcher:t};return this.lookup[t].push(r),()=>this.remove(r)}remove(t){this.lookup[t.matcher]&&(this.lookup[t.matcher]=this.lookup[t.matcher].reduce((s,n)=>(n!==t&&s.push(n),s),[]))}matches(t){return this.lookup[t]||[]}ensureArrayFor(t){this.lookup[t]||(this.lookup[t]=[])}}class q{constructor(){this.lookup=[]}add(t,s,n){const r={listener:s,index:n,matcher:t};return this.lookup.push(r),()=>this.remove(r)}remove(t){this.lookup=this.lookup.reduce((s,n)=>(n!==t&&s.push(n),s),[])}matches(t){return this.lookup.filter(s=>s.matcher.test(t))}}class I{constructor(){this.exactSubscriptions=new U,this.fuzzySubscriptions=new q,this.currentIndex=0}subscribe(t,s){let n;return typeof t=="string"?n=this.exactSubscriptions.add(t,s,this.currentIndex):n=this.fuzzySubscriptions.add(t,s,this.currentIndex),this.currentIndex+=1,n}publish(t,s){[...this.exactSubscriptions.matches(t),...this.fuzzySubscriptions.matches(t)].sort((r,o)=>r.index-o.index).forEach(r=>{r.listener(s,this.listenerOptions(t))})}addListenerOptions(t){this.options=t}listenerOptions(t){return{eventName:t,...this.options,publish:this.publish.bind(this)}}}const J=()=>{const e=new I;return{bus:e,publish:(n,r)=>e.publish(n,r),subscribe:(n,r)=>e.subscribe(n,r)}},Tt=Object.freeze(Object.defineProperty({__proto__:null,ExactSubscriptions:U,FuzzySubscriptions:q,JaxsBus:I,createBus:J},Symbol.toStringTag,{value:"Module"})),v=e=>Array.isArray(e),y=e=>e!==null&&!v(e)&&typeof e=="object",kt=(e,t)=>e===t,$t=(e,t)=>Object.keys(e).length===Object.keys(t).length,Pt=(e,t)=>!(y(e)&&y(t))||!$t(e,t)?!1:Object.keys(e).every(s=>{const n=e[s],r=t[s];return E(n,r)}),Dt=(e,t)=>!(v(e)&&v(t))||e.length!==t.length?!1:e.every((s,n)=>{const r=t[n];return E(s,r)}),E=(e,t)=>y(e)?Pt(e,t):v(e)?Dt(e,t):kt(e,t);class x{constructor(t){this.name=t.name,this.parent=t.parent,this._value=t.value,this.initialValue=structuredClone(t.value)}get value(){return this._value}set value(t){throw new Error("Cannot set value directly. Use an updater!")}reset(){this._value=this.initialValue}update(t){if(typeof t=="function"){const s=this.getUpdatedValue(t);this.updateValue(s)}else this.updateValue(t)}updateValue(t){E(this._value,t)||(this._value=t,this.parent.notify(this.name))}getUpdatedValue(t){return t(this.value)}}class A{constructor(t){this.store=t}update(t){this.store.update(t)}reset(){this.store.update(this.store.initialValue)}get value(){return this.store.value}}class H extends A{toggle(){const t=!this.value;this.update(t)}setTrue(){this.update(!0)}setFalse(){this.update(!1)}}const Lt=e=>new H(e);class G extends A{push(t){const s=[...this.value,t];this.update(s)}pop(){const t=[...this.value],s=t.pop();return this.update(t),s}unshift(t){const s=[t,...this.value];this.update(s)}shift(){const t=[...this.value],s=t.shift();return this.update(t),s}addSorter(t,s){this[t]=()=>{this.sortBy(s)}}sortBy(t){const s=[...this.value];s.sort(t),this.update(s)}insertAt(t,s){const n=[...this.value];n.splice(t,0,s),this.update(n)}remove(t){const s=this.value.reduce((n,r)=>(r!==t&&n.push(r),n),[]);this.update(s)}removeBy(t){const s=this.value.reduce((n,r)=>(t(r)||n.push(r),n),[]);this.update(s)}}const Ft=e=>new G(e);class C extends A{updateAttribute(t,s){const n={...this.value};n[t]=s,this.update(n)}resetAttribute(t){const s={...this.value},n=this.store.initialValue[t];s[t]=n,this.update(s)}}const Bt={object:e=>new C(e),list:Ft,boolean:Lt},_="state";class Q{constructor(t){this.publisher=t,this.stores={},this.eventNamePrefix=_,this.notifications=new Set,this.inTransaction=!1}create(t,s){const n=new x({name:t,parent:this,value:s});return this.stores[t]=n,n}createBoolean(t,s){const n=this.create(t,s);return n.updater=new H(n),n}createRecord(t,s){const n=this.create(t,s);return n.updater=new C(n),n}createList(t,s){const n=this.create(t,s);return n.updater=new G(n),n}store(t){return this.stores[t]||new x({name:t,parent:this,value:void 0})}get(t){return this.store(t).value}getAll(t){return t.reduce((s,n)=>(s[n]=this.get(n),s),{})}notify(t){this.inTransaction?this.notifications.add(t):this.publish(t)}update(t,s){this.store(t).update(s)}transaction(t){this.inTransaction=!0,t(this.stores),this.inTransaction=!1,this.publishAll()}publishAll(){this.notifications.forEach(t=>{this.publish(t)}),this.notifications.clear()}publish(t){this.publisher(this.event(t),{state:this,store:this.store(t)})}event(t){return`${this.eventNamePrefix}:${t}`}}const W=e=>new Q(e),zt=Object.freeze(Object.defineProperty({__proto__:null,State:Q,Store:x,createState:W,eventName:_,updaters:Bt},Symbol.toStringTag,{value:"Module"}));class Vt{constructor(t){this.setupDomEnvironment(t)}setup(){return this.setupBus(),this.setupState(),this.addBusOptions(),this.setRenderKit(),new R({window:this.window,document:this.document,publish:this.publish,subscribe:this.subscribe,bus:this.bus,state:this.state,renderKit:this.renderKit})}setupDomEnvironment(t){t.window?(this.window=t.window,this.document=this.window.document):t.document?(this.window=t.document.defaultView,this.document=t.document):(this.window=window,this.document=document)}setupBus(){const{publish:t,subscribe:s,bus:n}=J();this.publish=t,this.subscribe=s,this.bus=n}setupState(){this.state=W(this.publish)}addBusOptions(){this.bus.addListenerOptions({state:this.state,document:this.document,window:this.window})}setRenderKit(){this.renderKit={publish:this.publish,subscribe:this.subscribe,state:this.state,document:this.document,window:this.window}}}const Kt=(e={})=>{const s=new Vt(e).setup();return s.startNavigation(),s};var i=(e=>(e[e.removeNode=0]="removeNode",e[e.insertNode=1]="insertNode",e[e.replaceNode=2]="replaceNode",e[e.removeAttribute=3]="removeAttribute",e[e.addAttribute=4]="addAttribute",e[e.updateAttribute=5]="updateAttribute",e[e.removeEvent=6]="removeEvent",e[e.addEvent=7]="addEvent",e[e.updateEvent=8]="updateEvent",e[e.changeValue=9]="changeValue",e[e.changeText=10]="changeText",e))(i||{});const Rt=Object.freeze(Object.defineProperty({__proto__:null,ChangeInstructionTypes:i},Symbol.toStringTag,{value:"Module"})),Ut=(e,t)=>({source:e,target:t,type:i.changeText,data:{}}),qt=(e,t)=>({source:e,target:t,type:i.replaceNode,data:{}}),It=(e,t,s)=>({source:e,target:t,data:s,type:i.removeAttribute}),Jt=(e,t,s)=>({source:e,target:t,data:s,type:i.addAttribute}),Ht=(e,t,s)=>({source:e,target:t,data:s,type:i.updateAttribute}),Gt=(e,t,s)=>({source:e,target:t,data:s,type:i.removeEvent}),Ct=(e,t,s)=>({source:e,target:t,data:s,type:i.addEvent}),Qt=(e,t,s)=>({source:e,target:t,data:s,type:i.updateEvent}),X=e=>({source:e,target:e,type:i.removeNode,data:{}}),w=(e,t)=>({target:e,source:e,type:i.insertNode,data:t}),Wt=(e,t,s)=>({source:e,target:t,type:i.changeValue,data:s}),Xt=(e,t)=>e.type>t.type?1:e.type<t.type?-1:0,Y={index:-1};class Yt{constructor(){this.map={}}populate(t){t.forEach((s,n)=>{const r=s.__jsx;r&&(this.map[r]=this.map[r]||[],this.map[r].push({element:s,index:n}))})}pullMatch(t){const s=t&&t.__jsx;return!s||!(this.map[s]&&this.map[s].length)?Y:this.map[s].shift()}clear(t){const s=t&&t.__jsx;if(!(s&&this.map[s]&&this.map[s].length))return;const n=this.map[s];this.map[s]=n.reduce((r,o)=>(o.element!==t&&r.push(o),r),[])}check(t){const s=t&&t.__jsx;return s&&this.map[s]?this.map[s].length>0:!1}remaining(){return Object.values(this.map).flat()}}const Z=e=>{const t=new Yt;return t.populate(e),t},tt=(e,t,s=!1)=>{const n=[],r=e.attributes,o=r.length,a=t.attributes,l=a.length;let u,d,c;for(u=0;u<o;u++){c=null;const h=r.item(u);if(h){for(d=0;d<l;d++){const m=a.item(d);if(m&&h.name==m.name){c=m;break}}c?h.value!==c.value&&n.push(Ht(e,t,{name:h.name,value:c.value,isSvg:s})):n.push(It(e,t,{name:h.name,isSvg:s}))}}for(u=0;u<l;u++){c=null;const h=a.item(u);if(h){for(d=0;d<o;d++){const m=r.item(d);if(m&&m.name==h.name){c=m;break}}c||n.push(Jt(e,t,{name:h.name,value:h.value,isSvg:s}))}}return n},Zt=(e,t)=>{const s=[],n=e.eventMaps,r=t.eventMaps,o=Object.keys(n),a=Object.keys(r);return o.forEach(l=>{const u=n[l],d=r[l];d?d.busEvent!==u.busEvent&&s.push(Qt(e,t,{name:l,targetValue:d.listener,sourceValue:u.listener})):s.push(Gt(e,t,{name:u.domEvent,value:u.listener}))}),a.forEach(l=>{const u=n[l],d=r[l];u||s.push(Ct(e,t,{name:d.domEvent,value:d.listener}))}),s},te=e=>e.tagName!=="INPUT",ee=(e,t)=>e.value===t.value,se=(e,t)=>{if(te(e)||ee(e,t))return[];const s=e,n=t;return[Wt(s,n,{name:"value",value:n.value})]},ne=(e,t)=>{const s=tt(e,t),n=Zt(e,t),r=se(e,t);return s.concat(n).concat(r)},re=(e,t)=>tt(e,t,!0),oe=(e,t)=>e.textContent!==t.textContent?[Ut(e,t)]:[],ie=(e,t,s)=>{let n=[];if(e.nodeType===1&&ht(e)){const r=e,o=t,a=re(r,o),l=s(r.childNodes,o.childNodes,r);n=a.concat(l)}else if(e.nodeType===1){const r=e,o=t,a=ne(r,o),l=s(r.childNodes,o.childNodes,r);n=a.concat(l)}else e.nodeType===3&&(n=oe(e,t));return n},et=(e,t,s)=>{const n=[],r=ue(e,t),o=Z(e),a=Z(t),l=[];let u=0;for(;u<r;u++){const c=e[u],h=t[u];if(h&&a.check(h)){const m=o.pullMatch(h);a.clear(h),m.element?(m.index!==u&&n.push(w(m.element,{parent:s,index:u})),l.push({source:m.element,target:h})):c?a.check(c)?n.push(w(h,{parent:s,index:u})):(o.clear(c),n.push(qt(c,h))):n.push(w(h,{parent:s,index:u}))}else c&&o.pullMatch(c).element&&n.push(X(c))}o.remaining().forEach(({element:c})=>{n.push(X(c))});const d=l.reduce((c,{source:h,target:m})=>c.concat(ie(h,m,et)),[]);return n.concat(d).sort(Xt)},ue=(e,t)=>{const s=e.length,n=t.length;return s>n?s:n},ae=(e,t,s)=>{const n=et(e,t,s);return n.forEach(r=>{ce(r)}),n},ce=e=>{(xe[e.type]||le)(e)},le=e=>{},he=e=>{const{source:t,target:s}=e;t.nodeValue=s.textContent},de=e=>{const{source:t}=e;t.remove()},pe=e=>{const{target:t,data:s}=e,{parent:n,index:r}=s,o=n.childNodes[r];o?o&&o!==t&&n.insertBefore(t,o):n.appendChild(t)},me=e=>{const{source:t,target:s}=e;t.replaceWith(s)},fe=e=>{const{source:t,data:s}=e,{name:n,isSvg:r}=s;r?t.removeAttributeNS(null,n):t.removeAttribute(n)},st=e=>{const{source:t,data:s}=e,{name:n,value:r,isSvg:o}=s;o?t.setAttributeNS(null,n,r):t.setAttribute(n,r)},be=e=>{st(e)},ve=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.removeEventListener(n,r)},ge=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.addEventListener(n,r)},ye=e=>{const t=e.data,s=e.source,{name:n,sourceValue:r,targetValue:o}=t;s.removeEventListener(n,r),s.addEventListener(n,o)},Ee=e=>{const t=e.data,s=e.source,{value:n}=t;s.value=n},xe={[i.changeText]:he,[i.removeNode]:de,[i.insertNode]:pe,[i.replaceNode]:me,[i.removeAttribute]:fe,[i.addAttribute]:st,[i.updateAttribute]:be,[i.removeEvent]:ve,[i.addEvent]:ge,[i.updateEvent]:ye,[i.changeValue]:Ee},Ae=(e,t,s)=>{const n=[...t];return e.forEach(r=>{_e(r,n,s)}),n},_e=(e,t,s)=>{const n=je[e.type];n&&n(e,t,s)},we=(e,t)=>{const{source:s}=e,n=t.indexOf(s);n>=0&&t.splice(n,1)},Se=(e,t,s)=>{const{target:n}=e,r=e.data,{index:o,parent:a}=r;s===a&&t.splice(o,0,n)},Ne=(e,t)=>{const{target:s,source:n}=e,r=t.indexOf(n);r>=0&&(t[r]=s)},je={[i.removeNode]:we,[i.insertNode]:Se,[i.replaceNode]:Ne};class Oe{constructor({Template:t,subscriptions:s,attributes:n,viewModel:r}){this.Template=t,this.viewModel=r,this.attributes=n,this.subscriptions=s,this.dom=[],this.parentElement=null}render(t){return this.parentElement=t.parent,this.renderKit=t,this.subscribeForRerender(),this.dom=this.generateDom(t),this.dom}generateDom(t){const s={...this.attributes,...this.viewModel(t.state.getAll(this.subscriptions))},n=this.Template(s);return n?n.render(t):[]}rerender(){if(!this.parentElement&&this.dom[0]){const n=this.dom[0].parentElement;this.parentElement=n}const t=this.generateDom(this.renderKit),s=ae(this.dom,t,this.parentElement);this.dom=Ae(s,this.dom,this.parentElement)}subscribeForRerender(){const{subscribe:t}=this.renderKit;this.subscriptions.forEach(s=>{t(this.eventName(s),()=>this.rerender())})}eventName(t){return`${_}:${t}`}}const Me=e=>e,nt=({Template:e,viewModel:t,subscriptions:s})=>(s=s||[],t=t||Me,n=>new Oe({Template:e,viewModel:t,subscriptions:s,attributes:n})),Te=Object.freeze(Object.defineProperty({__proto__:null,createRouteState:k,events:jt,extractQueryParams:L,findHref:$,navigate:P,onLinkClick:D,onLocationChange:F,start:Ot},Symbol.toStringTag,{value:"Module"})),ke=e=>({path:t})=>t===e,$e=()=>!0,rt=e=>({route:t})=>{const s=e.find(n=>n.match(t));return s&&s.Partial},Pe=Object.freeze(Object.defineProperty({__proto__:null,buildRouter:rt,catchAll:$e,exactPathMatch:ke},Symbol.toStringTag,{value:"Module"})),De=()=>({render:(e,t)=>[]}),Le=e=>{const t=rt(e);return nt({Template:({route:n})=>(t({route:n})||De)(),subscriptions:["route"]})};p.JaxsTypes=Rt,p.appBuilding=Mt,p.bind=nt,p.createApp=Kt,p.jsx=O,p.messageBus=Tt,p.navigation=Te,p.routedView=Le,p.routing=Pe,p.state=zt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
1
+ ;(function (p, f) {
2
+ typeof exports == 'object' && typeof module < 'u'
3
+ ? f(exports)
4
+ : typeof define == 'function' && define.amd
5
+ ? define(['exports'], f)
6
+ : ((p = typeof globalThis < 'u' ? globalThis : p || self),
7
+ f((p.jaxs = {})))
8
+ })(this, function (p) {
9
+ 'use strict'
10
+ const f = (e, t) => t.createElement(e),
11
+ nt = (e, t) => {
12
+ for (const s in t) {
13
+ if (s === '__self') continue
14
+ const n = t[s].toString()
15
+ if (s === 'value') {
16
+ const r = e
17
+ r.value !== n && (r.value = n)
18
+ } else e.setAttribute(s, n)
19
+ }
20
+ },
21
+ rt = (e, t, s) => {
22
+ const n = {}
23
+ for (const r in t) {
24
+ const o = t[r],
25
+ a = (l) => s(o, l)
26
+ e.addEventListener(r, a),
27
+ (n[r] = { domEvent: r, busEvent: o, listener: a })
28
+ }
29
+ e.eventMaps = n
30
+ },
31
+ ot = (e, t, s, n) => {
32
+ const r = f(e, n.document)
33
+ return nt(r, t), rt(r, s, n.publish), r
34
+ },
35
+ g = 'http://www.w3.org/2000/svg',
36
+ it = {
37
+ animate: !0,
38
+ animateMotion: !0,
39
+ animateTransform: !0,
40
+ circle: !0,
41
+ clipPath: !0,
42
+ defs: !0,
43
+ desc: !0,
44
+ ellipse: !0,
45
+ feBlend: !0,
46
+ feColorMatrix: !0,
47
+ feComponentTransfer: !0,
48
+ feComposite: !0,
49
+ feConvolveMatrix: !0,
50
+ feDiffuseLighting: !0,
51
+ feDisplacementMap: !0,
52
+ feDistantLight: !0,
53
+ feDropShadow: !0,
54
+ feFlood: !0,
55
+ feFuncA: !0,
56
+ feFuncB: !0,
57
+ feFuncG: !0,
58
+ feFuncR: !0,
59
+ feGaussianBlur: !0,
60
+ feImage: !0,
61
+ feMerge: !0,
62
+ feMergeNode: !0,
63
+ feMorphology: !0,
64
+ feOffset: !0,
65
+ fePointLight: !0,
66
+ feSpecularLighting: !0,
67
+ feSpotLight: !0,
68
+ feTile: !0,
69
+ feTurbulence: !0,
70
+ filter: !0,
71
+ foreignObject: !0,
72
+ g: !0,
73
+ image: !0,
74
+ line: !0,
75
+ linearGradient: !0,
76
+ marker: !0,
77
+ mask: !0,
78
+ metadata: !0,
79
+ mpath: !0,
80
+ path: !0,
81
+ pattern: !0,
82
+ polygon: !0,
83
+ polyline: !0,
84
+ radialGradient: !0,
85
+ rect: !0,
86
+ script: !0,
87
+ set: !0,
88
+ stop: !0,
89
+ style: !0,
90
+ svg: !0,
91
+ switch: !0,
92
+ symbol: !0,
93
+ text: !0,
94
+ textPath: !0,
95
+ title: !0,
96
+ tspan: !0,
97
+ use: !0,
98
+ view: !0,
99
+ },
100
+ ut = (e, t) => !!(it[e] || (e === 'a' && t === g)),
101
+ at = (e, t, s) => {
102
+ const n = s.createElementNS(g, e)
103
+ for (const r in t)
104
+ r === '__self' ||
105
+ r === 'xmlns' ||
106
+ n.setAttributeNS(null, r, t[r].toString())
107
+ return n
108
+ },
109
+ ct = (e) => e.namespaceURI === g,
110
+ lt = (e, t) => t.createTextNode(e)
111
+ class ht {
112
+ constructor(t) {
113
+ this.value = t.toString()
114
+ }
115
+ render(t) {
116
+ const s = lt(this.value, t.document)
117
+ return (s.__jsx = 'TextNode'), [s]
118
+ }
119
+ }
120
+ const dt = (e) => typeof e == 'string' || typeof e == 'number',
121
+ pt = (e) => new ht(e),
122
+ mt = (e) => (dt(e) ? pt(e) : e),
123
+ ft = (e) => bt(e).map(mt).flat(),
124
+ bt = (e) => (Array.isArray(e) ? e.flat() : e ? [e] : []),
125
+ N = (e, t = {}) => e || t.children || [],
126
+ vt = (e, t = '') => {
127
+ const s = {},
128
+ n = {}
129
+ for (const r in e) {
130
+ const o = e[r]
131
+ if (r.match(/^on.+/i)) {
132
+ const a = r.slice(2).toLowerCase()
133
+ n[a] = o ? o.toString() : ''
134
+ } else {
135
+ if (o === !1) continue
136
+ r === '__source' ? (s.__source = e.__source) : (s[r] = gt(r, o, t))
137
+ }
138
+ }
139
+ return { attributes: s, events: n }
140
+ },
141
+ gt = (e, t, s = '') => (t == null ? s : t.toString()),
142
+ yt = (e, t) => {
143
+ const s = e || {},
144
+ n = N(t, s)
145
+ return (s.children = s.children || n), s
146
+ },
147
+ j = (e, t, s, n = []) => e.reduce(Et(t, s), n).flat(),
148
+ Et = (e, t) => (s, n) =>
149
+ n
150
+ ? Array.isArray(n)
151
+ ? j(n, e, t, s)
152
+ : (n.render(e, t).forEach((r) => s.push(r)), s)
153
+ : s
154
+ class O {
155
+ constructor(t) {
156
+ this.collection = ft(t)
157
+ }
158
+ render(t, s) {
159
+ this.parentElement = s
160
+ const n = this.generateDom(t)
161
+ return this.attachToParent(n), n
162
+ }
163
+ generateDom(t) {
164
+ return j(this.collection, t, this.parentElement)
165
+ }
166
+ attachToParent(t) {
167
+ if (this.parentElement === void 0) return
168
+ const s = this.parentElement
169
+ t.forEach((n) => s.appendChild(n))
170
+ }
171
+ }
172
+ class xt {
173
+ constructor(t, s) {
174
+ ;(this.type = t), (this.attributes = s)
175
+ }
176
+ generate() {
177
+ return (
178
+ this.attributes.key ||
179
+ this.sourceKey() ||
180
+ this.createKeyFromAttributes()
181
+ )
182
+ }
183
+ sourceKey() {
184
+ if (this.attributes.__source) {
185
+ const {
186
+ fileName: t,
187
+ lineNumber: s,
188
+ columnNumber: n,
189
+ } = this.attributes.__source
190
+ return `${t}:${s}:${n}`
191
+ }
192
+ }
193
+ createKeyFromAttributes() {
194
+ const t = this.attributes.id ? `#${this.attributes.id}` : '',
195
+ s = this.attributes.type ? `[type=${this.attributes.type}]` : '',
196
+ n = this.attributes.name ? `[name=${this.attributes.name}]` : ''
197
+ return `${this.type}${t}${s}${n}`
198
+ }
199
+ }
200
+ class At {
201
+ constructor(t, s, n = []) {
202
+ this.type = t
203
+ const { events: r, attributes: o } = vt(s)
204
+ ;(this.events = r),
205
+ (this.attributes = o),
206
+ (this.isSvg = ut(this.type, this.attributes.xmlns)),
207
+ (this.children = new O(n))
208
+ }
209
+ render(t) {
210
+ const s = this.generateDom(t)
211
+ return s ? (this.children.render(t, s), [s]) : []
212
+ }
213
+ generateDom(t) {
214
+ return this.isSvg ? this.generateSvgDom(t) : this.generateHtmlDom(t)
215
+ }
216
+ generateHtmlDom(t) {
217
+ const s = ot(this.type, this.attributes, this.events, t)
218
+ return (s.__jsx = this.jsxKey()), s
219
+ }
220
+ generateSvgDom(t) {
221
+ const s = at(this.type, this.attributes, t.document)
222
+ return (s.__jsx = this.jsxKey()), s
223
+ }
224
+ jsxKey() {
225
+ return new xt(this.type, this.attributes).generate()
226
+ }
227
+ }
228
+ const M = (e, t, ...s) =>
229
+ typeof e == 'string' ? new At(e, t, s) : e(yt(t, s))
230
+ M.fragment = (e, t) => {
231
+ const s = N(t, e)
232
+ return new O(s)
233
+ }
234
+ class _t {
235
+ constructor(t, s, n) {
236
+ ;(this.template = t),
237
+ (this.selector = s),
238
+ (this.renderKit = n),
239
+ (this.dom = [])
240
+ }
241
+ renderAndAttach(t) {
242
+ ;(this.parentElement = this.getParentElement()),
243
+ (this.dom = this.render({ ...t, parent: this.parentElement })),
244
+ this.parentElement && this.attach()
245
+ }
246
+ render(t) {
247
+ return this.template.render(t)
248
+ }
249
+ attach() {
250
+ this.parentElement && (this.parentElement.innerHTML = ''),
251
+ this.dom.forEach((t) => {
252
+ this.parentElement && this.parentElement.appendChild(t)
253
+ })
254
+ }
255
+ getParentElement() {
256
+ return this.renderKit.document.querySelector(this.selector)
257
+ }
258
+ }
259
+ const wt = (e, t, s) => {
260
+ const n = new _t(e, t, s)
261
+ return n.renderAndAttach(s), n
262
+ },
263
+ T = 'go-to-href',
264
+ k = 'go-to',
265
+ b = 'navigation:location-change',
266
+ $ = 'navigation:route-change',
267
+ St = Object.freeze(
268
+ Object.defineProperty(
269
+ {
270
+ __proto__: null,
271
+ linkNavigationEvent: T,
272
+ locationChangeEvent: b,
273
+ navigationEvent: k,
274
+ routeChangeEvent: $,
275
+ },
276
+ Symbol.toStringTag,
277
+ { value: 'Module' },
278
+ ),
279
+ ),
280
+ P = (e) => {
281
+ e.create('route', { host: '', path: '', query: {} })
282
+ },
283
+ D = (e) => {
284
+ const t = e.closest('[href]')
285
+ return (t && t.getAttribute('href')) || ''
286
+ },
287
+ y = (e, { publish: t, window: s }) => {
288
+ s.history.pushState(null, '', e), t(b, null)
289
+ },
290
+ F = (e, t) => {
291
+ if (!e || !e.target) return
292
+ e.preventDefault()
293
+ const s = D(e.target)
294
+ y(s, t)
295
+ },
296
+ L = (e) =>
297
+ e
298
+ .replace(/^\?/, '')
299
+ .split('&')
300
+ .reduce((t, s) => {
301
+ if (!s) return t
302
+ const n = s.split('=')
303
+ return (t[n[0]] = n[1]), t
304
+ }, {}),
305
+ z = (e, t) => {
306
+ const { state: s, publish: n, window: r } = t,
307
+ { host: o, pathname: a, search: l } = r.location,
308
+ u = a,
309
+ d = L(l),
310
+ c = { host: o, path: u, query: d }
311
+ s.store('route').update(c), n($, c)
312
+ },
313
+ B = (e) => {
314
+ const { subscribe: t } = e
315
+ t(T, F),
316
+ t(k, (s, n) => {
317
+ y(s, n)
318
+ })
319
+ },
320
+ V = (e) => {
321
+ const { publish: t, subscribe: s, state: n, window: r } = e
322
+ P(n), r.addEventListener('popstate', () => t(b, null)), s(b, z)
323
+ },
324
+ K = (e) => {
325
+ setTimeout(() => e.publish(b, null), 0)
326
+ },
327
+ R = (e) => {
328
+ V(e), B(e), K(e)
329
+ },
330
+ Nt = Object.freeze(
331
+ Object.defineProperty(
332
+ {
333
+ __proto__: null,
334
+ publishLocation: K,
335
+ startNavigation: R,
336
+ subscribeToHistoryChange: V,
337
+ subscribeToNavigation: B,
338
+ },
339
+ Symbol.toStringTag,
340
+ { value: 'Module' },
341
+ ),
342
+ )
343
+ class U {
344
+ constructor({
345
+ window: t,
346
+ document: s,
347
+ publish: n,
348
+ subscribe: r,
349
+ bus: o,
350
+ state: a,
351
+ renderKit: l,
352
+ }) {
353
+ ;(this.window = t),
354
+ (this.document = s),
355
+ (this.publish = n),
356
+ (this.subscribe = r),
357
+ (this.bus = o),
358
+ (this.state = a),
359
+ (this.renderKit = l),
360
+ (this.roots = [])
361
+ }
362
+ render(t, s) {
363
+ const n = wt(t, s, this.renderKit)
364
+ return this.roots.push(n), n
365
+ }
366
+ startNavigation() {
367
+ R(this)
368
+ }
369
+ }
370
+ const jt = Object.freeze(
371
+ Object.defineProperty({ __proto__: null, App: U }, Symbol.toStringTag, {
372
+ value: 'Module',
373
+ }),
374
+ )
375
+ class q {
376
+ constructor() {
377
+ this.lookup = {}
378
+ }
379
+ add(t, s, n) {
380
+ this.ensureArrayFor(t)
381
+ const r = { listener: s, index: n, matcher: t }
382
+ return this.lookup[t].push(r), () => this.remove(r)
383
+ }
384
+ remove(t) {
385
+ this.lookup[t.matcher] &&
386
+ (this.lookup[t.matcher] = this.lookup[t.matcher].reduce(
387
+ (s, n) => (n !== t && s.push(n), s),
388
+ [],
389
+ ))
390
+ }
391
+ matches(t) {
392
+ return this.lookup[t] || []
393
+ }
394
+ ensureArrayFor(t) {
395
+ this.lookup[t] || (this.lookup[t] = [])
396
+ }
397
+ }
398
+ class I {
399
+ constructor() {
400
+ this.lookup = []
401
+ }
402
+ add(t, s, n) {
403
+ const r = { listener: s, index: n, matcher: t }
404
+ return this.lookup.push(r), () => this.remove(r)
405
+ }
406
+ remove(t) {
407
+ this.lookup = this.lookup.reduce((s, n) => (n !== t && s.push(n), s), [])
408
+ }
409
+ matches(t) {
410
+ return this.lookup.filter((s) => s.matcher.test(t))
411
+ }
412
+ }
413
+ class J {
414
+ constructor() {
415
+ ;(this.exactSubscriptions = new q()),
416
+ (this.fuzzySubscriptions = new I()),
417
+ (this.currentIndex = 0)
418
+ }
419
+ subscribe(t, s) {
420
+ let n
421
+ return (
422
+ typeof t == 'string'
423
+ ? (n = this.exactSubscriptions.add(t, s, this.currentIndex))
424
+ : (n = this.fuzzySubscriptions.add(t, s, this.currentIndex)),
425
+ (this.currentIndex += 1),
426
+ n
427
+ )
428
+ }
429
+ publish(t, s) {
430
+ ;[
431
+ ...this.exactSubscriptions.matches(t),
432
+ ...this.fuzzySubscriptions.matches(t),
433
+ ]
434
+ .sort((r, o) => r.index - o.index)
435
+ .forEach((r) => {
436
+ r.listener(s, this.listenerOptions(t))
437
+ })
438
+ }
439
+ addListenerOptions(t) {
440
+ this.options = t
441
+ }
442
+ listenerOptions(t) {
443
+ return { eventName: t, ...this.options, publish: this.publish.bind(this) }
444
+ }
445
+ }
446
+ const H = () => {
447
+ const e = new J()
448
+ return {
449
+ bus: e,
450
+ publish: (n, r) => e.publish(n, r),
451
+ subscribe: (n, r) => e.subscribe(n, r),
452
+ }
453
+ },
454
+ Ot = Object.freeze(
455
+ Object.defineProperty(
456
+ {
457
+ __proto__: null,
458
+ ExactSubscriptions: q,
459
+ FuzzySubscriptions: I,
460
+ JaxsBus: J,
461
+ createBus: H,
462
+ },
463
+ Symbol.toStringTag,
464
+ { value: 'Module' },
465
+ ),
466
+ ),
467
+ v = (e) => Array.isArray(e),
468
+ E = (e) => e !== null && !v(e) && typeof e == 'object',
469
+ Mt = (e, t) => e === t,
470
+ Tt = (e, t) => Object.keys(e).length === Object.keys(t).length,
471
+ kt = (e, t) =>
472
+ !(E(e) && E(t)) || !Tt(e, t)
473
+ ? !1
474
+ : Object.keys(e).every((s) => {
475
+ const n = e[s],
476
+ r = t[s]
477
+ return x(n, r)
478
+ }),
479
+ $t = (e, t) =>
480
+ !(v(e) && v(t)) || e.length !== t.length
481
+ ? !1
482
+ : e.every((s, n) => {
483
+ const r = t[n]
484
+ return x(s, r)
485
+ }),
486
+ x = (e, t) => (E(e) ? kt(e, t) : v(e) ? $t(e, t) : Mt(e, t))
487
+ class A {
488
+ constructor(t) {
489
+ ;(this.name = t.name),
490
+ (this.parent = t.parent),
491
+ (this._value = t.value),
492
+ (this.initialValue = structuredClone(t.value))
493
+ }
494
+ get value() {
495
+ return this._value
496
+ }
497
+ set value(t) {
498
+ throw new Error('Cannot set value directly. Use an updater!')
499
+ }
500
+ reset() {
501
+ this._value = this.initialValue
502
+ }
503
+ update(t) {
504
+ if (typeof t == 'function') {
505
+ const s = this.getUpdatedValue(t)
506
+ this.updateValue(s)
507
+ } else this.updateValue(t)
508
+ }
509
+ updateValue(t) {
510
+ x(this._value, t) || ((this._value = t), this.parent.notify(this.name))
511
+ }
512
+ getUpdatedValue(t) {
513
+ return t(this.value)
514
+ }
515
+ }
516
+ class _ {
517
+ constructor(t) {
518
+ this.store = t
519
+ }
520
+ update(t) {
521
+ this.store.update(t)
522
+ }
523
+ reset() {
524
+ this.store.update(this.store.initialValue)
525
+ }
526
+ get value() {
527
+ return this.store.value
528
+ }
529
+ }
530
+ class Pt extends _ {
531
+ updateAttribute(t, s) {
532
+ const n = { ...this.value }
533
+ ;(n[t] = s), this.update(n)
534
+ }
535
+ resetAttribute(t) {
536
+ const s = { ...this.value },
537
+ n = this.store.initialValue[t]
538
+ ;(s[t] = n), this.update(s)
539
+ }
540
+ }
541
+ const Dt = (e) => new Pt(e)
542
+ class Ft extends _ {
543
+ push(t) {
544
+ const s = [...this.value, t]
545
+ this.update(s)
546
+ }
547
+ pop() {
548
+ const t = [...this.value],
549
+ s = t.pop()
550
+ return this.update(t), s
551
+ }
552
+ unshift(t) {
553
+ const s = [t, ...this.value]
554
+ this.update(s)
555
+ }
556
+ shift() {
557
+ const t = [...this.value],
558
+ s = t.shift()
559
+ return this.update(t), s
560
+ }
561
+ addSorter(t, s) {
562
+ this[t] = () => {
563
+ this.sortBy(s)
564
+ }
565
+ }
566
+ sortBy(t) {
567
+ const s = [...this.value]
568
+ s.sort(t), this.update(s)
569
+ }
570
+ insertAt(t, s) {
571
+ const n = [...this.value]
572
+ n.splice(t, 0, s), this.update(n)
573
+ }
574
+ remove(t) {
575
+ const s = this.value.reduce((n, r) => (r !== t && n.push(r), n), [])
576
+ this.update(s)
577
+ }
578
+ removeBy(t) {
579
+ const s = this.value.reduce((n, r) => (t(r) || n.push(r), n), [])
580
+ this.update(s)
581
+ }
582
+ }
583
+ const Lt = (e) => new Ft(e)
584
+ class zt extends _ {
585
+ toggle() {
586
+ const t = !this.value
587
+ this.update(t)
588
+ }
589
+ setTrue() {
590
+ this.update(!0)
591
+ }
592
+ setFalse() {
593
+ this.update(!1)
594
+ }
595
+ }
596
+ const Bt = { object: Dt, list: Lt, boolean: (e) => new zt(e) },
597
+ w = 'state'
598
+ class G {
599
+ constructor(t) {
600
+ ;(this.publisher = t),
601
+ (this.stores = {}),
602
+ (this.eventNamePrefix = w),
603
+ (this.notifications = new Set()),
604
+ (this.inTransaction = !1)
605
+ }
606
+ create(t, s) {
607
+ const n = new A({ name: t, parent: this, value: s })
608
+ return (this.stores[t] = n), n
609
+ }
610
+ store(t) {
611
+ return this.stores[t] || new A({ name: t, parent: this, value: void 0 })
612
+ }
613
+ get(t) {
614
+ return this.store(t).value
615
+ }
616
+ getAll(t) {
617
+ return t.reduce((s, n) => ((s[n] = this.get(n)), s), {})
618
+ }
619
+ notify(t) {
620
+ this.inTransaction ? this.notifications.add(t) : this.publish(t)
621
+ }
622
+ update(t, s) {
623
+ this.store(t).update(s)
624
+ }
625
+ transaction(t) {
626
+ ;(this.inTransaction = !0),
627
+ t(this.stores),
628
+ (this.inTransaction = !1),
629
+ this.publishAll()
630
+ }
631
+ publishAll() {
632
+ this.notifications.forEach((t) => {
633
+ this.publish(t)
634
+ }),
635
+ this.notifications.clear()
636
+ }
637
+ publish(t) {
638
+ this.publisher(this.event(t), { state: this, store: this.store(t) })
639
+ }
640
+ event(t) {
641
+ return `${this.eventNamePrefix}:${t}`
642
+ }
643
+ }
644
+ const C = (e) => new G(e),
645
+ Vt = Object.freeze(
646
+ Object.defineProperty(
647
+ {
648
+ __proto__: null,
649
+ State: G,
650
+ Store: A,
651
+ createState: C,
652
+ eventName: w,
653
+ updaters: Bt,
654
+ },
655
+ Symbol.toStringTag,
656
+ { value: 'Module' },
657
+ ),
658
+ )
659
+ class Kt {
660
+ constructor(t) {
661
+ this.setupDomEnvironment(t)
662
+ }
663
+ setup() {
664
+ return (
665
+ this.setupBus(),
666
+ this.setupState(),
667
+ this.addBusOptions(),
668
+ this.setRenderKit(),
669
+ new U({
670
+ window: this.window,
671
+ document: this.document,
672
+ publish: this.publish,
673
+ subscribe: this.subscribe,
674
+ bus: this.bus,
675
+ state: this.state,
676
+ renderKit: this.renderKit,
677
+ })
678
+ )
679
+ }
680
+ setupDomEnvironment(t) {
681
+ t.window
682
+ ? ((this.window = t.window), (this.document = this.window.document))
683
+ : t.document
684
+ ? ((this.window = t.document.defaultView),
685
+ (this.document = t.document))
686
+ : ((this.window = window), (this.document = document))
687
+ }
688
+ setupBus() {
689
+ const { publish: t, subscribe: s, bus: n } = H()
690
+ ;(this.publish = t), (this.subscribe = s), (this.bus = n)
691
+ }
692
+ setupState() {
693
+ this.state = C(this.publish)
694
+ }
695
+ addBusOptions() {
696
+ this.bus.addListenerOptions({
697
+ state: this.state,
698
+ document: this.document,
699
+ window: this.window,
700
+ })
701
+ }
702
+ setRenderKit() {
703
+ this.renderKit = {
704
+ publish: this.publish,
705
+ subscribe: this.subscribe,
706
+ state: this.state,
707
+ document: this.document,
708
+ window: this.window,
709
+ }
710
+ }
711
+ }
712
+ const Rt = (e = {}) => {
713
+ const s = new Kt(e).setup()
714
+ return s.startNavigation(), s
715
+ }
716
+ var i = ((e) => (
717
+ (e[(e.removeNode = 0)] = 'removeNode'),
718
+ (e[(e.insertNode = 1)] = 'insertNode'),
719
+ (e[(e.replaceNode = 2)] = 'replaceNode'),
720
+ (e[(e.removeAttribute = 3)] = 'removeAttribute'),
721
+ (e[(e.addAttribute = 4)] = 'addAttribute'),
722
+ (e[(e.updateAttribute = 5)] = 'updateAttribute'),
723
+ (e[(e.removeEvent = 6)] = 'removeEvent'),
724
+ (e[(e.addEvent = 7)] = 'addEvent'),
725
+ (e[(e.updateEvent = 8)] = 'updateEvent'),
726
+ (e[(e.changeValue = 9)] = 'changeValue'),
727
+ (e[(e.changeText = 10)] = 'changeText'),
728
+ e
729
+ ))(i || {})
730
+ const Ut = Object.freeze(
731
+ Object.defineProperty(
732
+ { __proto__: null, ChangeInstructionTypes: i },
733
+ Symbol.toStringTag,
734
+ { value: 'Module' },
735
+ ),
736
+ ),
737
+ qt = (e, t) => ({ source: e, target: t, type: i.changeText, data: {} }),
738
+ It = (e, t) => ({ source: e, target: t, type: i.replaceNode, data: {} }),
739
+ Jt = (e, t, s) => ({
740
+ source: e,
741
+ target: t,
742
+ data: s,
743
+ type: i.removeAttribute,
744
+ }),
745
+ Ht = (e, t, s) => ({ source: e, target: t, data: s, type: i.addAttribute }),
746
+ Gt = (e, t, s) => ({
747
+ source: e,
748
+ target: t,
749
+ data: s,
750
+ type: i.updateAttribute,
751
+ }),
752
+ Ct = (e, t, s) => ({ source: e, target: t, data: s, type: i.removeEvent }),
753
+ Qt = (e, t, s) => ({ source: e, target: t, data: s, type: i.addEvent }),
754
+ Wt = (e, t, s) => ({ source: e, target: t, data: s, type: i.updateEvent }),
755
+ Q = (e) => ({ source: e, target: e, type: i.removeNode, data: {} }),
756
+ S = (e, t) => ({ target: e, source: e, type: i.insertNode, data: t }),
757
+ Xt = (e, t, s) => ({ source: e, target: t, type: i.changeValue, data: s }),
758
+ Yt = (e, t) => (e.type > t.type ? 1 : e.type < t.type ? -1 : 0),
759
+ W = { index: -1 }
760
+ class Zt {
761
+ constructor() {
762
+ this.map = {}
763
+ }
764
+ populate(t) {
765
+ t.forEach((s, n) => {
766
+ const r = s.__jsx
767
+ r &&
768
+ ((this.map[r] = this.map[r] || []),
769
+ this.map[r].push({ element: s, index: n }))
770
+ })
771
+ }
772
+ pullMatch(t) {
773
+ const s = t && t.__jsx
774
+ return !s || !(this.map[s] && this.map[s].length)
775
+ ? W
776
+ : this.map[s].shift()
777
+ }
778
+ clear(t) {
779
+ const s = t && t.__jsx
780
+ if (!(s && this.map[s] && this.map[s].length)) return
781
+ const n = this.map[s]
782
+ this.map[s] = n.reduce((r, o) => (o.element !== t && r.push(o), r), [])
783
+ }
784
+ check(t) {
785
+ const s = t && t.__jsx
786
+ return s && this.map[s] ? this.map[s].length > 0 : !1
787
+ }
788
+ remaining() {
789
+ return Object.values(this.map).flat()
790
+ }
791
+ }
792
+ const X = (e) => {
793
+ const t = new Zt()
794
+ return t.populate(e), t
795
+ },
796
+ Y = (e, t, s = !1) => {
797
+ const n = [],
798
+ r = e.attributes,
799
+ o = r.length,
800
+ a = t.attributes,
801
+ l = a.length
802
+ let u, d, c
803
+ for (u = 0; u < o; u++) {
804
+ c = null
805
+ const h = r.item(u)
806
+ if (h) {
807
+ for (d = 0; d < l; d++) {
808
+ const m = a.item(d)
809
+ if (m && h.name == m.name) {
810
+ c = m
811
+ break
812
+ }
813
+ }
814
+ c
815
+ ? h.value !== c.value &&
816
+ n.push(Gt(e, t, { name: h.name, value: c.value, isSvg: s }))
817
+ : n.push(Jt(e, t, { name: h.name, isSvg: s }))
818
+ }
819
+ }
820
+ for (u = 0; u < l; u++) {
821
+ c = null
822
+ const h = a.item(u)
823
+ if (h) {
824
+ for (d = 0; d < o; d++) {
825
+ const m = r.item(d)
826
+ if (m && m.name == h.name) {
827
+ c = m
828
+ break
829
+ }
830
+ }
831
+ c || n.push(Ht(e, t, { name: h.name, value: h.value, isSvg: s }))
832
+ }
833
+ }
834
+ return n
835
+ },
836
+ te = (e, t) => {
837
+ const s = [],
838
+ n = e.eventMaps,
839
+ r = t.eventMaps,
840
+ o = Object.keys(n),
841
+ a = Object.keys(r)
842
+ return (
843
+ o.forEach((l) => {
844
+ const u = n[l],
845
+ d = r[l]
846
+ d
847
+ ? d.busEvent !== u.busEvent &&
848
+ s.push(
849
+ Wt(e, t, {
850
+ name: l,
851
+ targetValue: d.listener,
852
+ sourceValue: u.listener,
853
+ }),
854
+ )
855
+ : s.push(Ct(e, t, { name: u.domEvent, value: u.listener }))
856
+ }),
857
+ a.forEach((l) => {
858
+ const u = n[l],
859
+ d = r[l]
860
+ u || s.push(Qt(e, t, { name: d.domEvent, value: d.listener }))
861
+ }),
862
+ s
863
+ )
864
+ },
865
+ ee = (e) => e.tagName !== 'INPUT',
866
+ se = (e, t) => e.value === t.value,
867
+ ne = (e, t) => {
868
+ if (ee(e) || se(e, t)) return []
869
+ const s = e,
870
+ n = t
871
+ return [Xt(s, n, { name: 'value', value: n.value })]
872
+ },
873
+ re = (e, t) => {
874
+ const s = Y(e, t),
875
+ n = te(e, t),
876
+ r = ne(e, t)
877
+ return s.concat(n).concat(r)
878
+ },
879
+ oe = (e, t) => Y(e, t, !0),
880
+ ie = (e, t) => (e.textContent !== t.textContent ? [qt(e, t)] : []),
881
+ ue = (e, t, s) => {
882
+ let n = []
883
+ if (e.nodeType === 1 && ct(e)) {
884
+ const r = e,
885
+ o = t,
886
+ a = oe(r, o),
887
+ l = s(r.childNodes, o.childNodes, r)
888
+ n = a.concat(l)
889
+ } else if (e.nodeType === 1) {
890
+ const r = e,
891
+ o = t,
892
+ a = re(r, o),
893
+ l = s(r.childNodes, o.childNodes, r)
894
+ n = a.concat(l)
895
+ } else e.nodeType === 3 && (n = ie(e, t))
896
+ return n
897
+ },
898
+ Z = (e, t, s) => {
899
+ const n = [],
900
+ r = ae(e, t),
901
+ o = X(e),
902
+ a = X(t),
903
+ l = []
904
+ let u = 0
905
+ for (; u < r; u++) {
906
+ const c = e[u],
907
+ h = t[u]
908
+ if (h && a.check(h)) {
909
+ const m = o.pullMatch(h)
910
+ a.clear(h),
911
+ m.element
912
+ ? (m.index !== u && n.push(S(m.element, { parent: s, index: u })),
913
+ l.push({ source: m.element, target: h }))
914
+ : c
915
+ ? a.check(c)
916
+ ? n.push(S(h, { parent: s, index: u }))
917
+ : (o.clear(c), n.push(It(c, h)))
918
+ : n.push(S(h, { parent: s, index: u }))
919
+ } else c && o.pullMatch(c).element && n.push(Q(c))
920
+ }
921
+ o.remaining().forEach(({ element: c }) => {
922
+ n.push(Q(c))
923
+ })
924
+ const d = l.reduce(
925
+ (c, { source: h, target: m }) => c.concat(ue(h, m, Z)),
926
+ [],
927
+ )
928
+ return n.concat(d).sort(Yt)
929
+ },
930
+ ae = (e, t) => {
931
+ const s = e.length,
932
+ n = t.length
933
+ return s > n ? s : n
934
+ },
935
+ ce = (e, t, s) => {
936
+ const n = Z(e, t, s)
937
+ return (
938
+ n.forEach((r) => {
939
+ le(r)
940
+ }),
941
+ n
942
+ )
943
+ },
944
+ le = (e) => {
945
+ ;(Ae[e.type] || he)(e)
946
+ },
947
+ he = (e) => {},
948
+ de = (e) => {
949
+ const { source: t, target: s } = e
950
+ t.nodeValue = s.textContent
951
+ },
952
+ pe = (e) => {
953
+ const { source: t } = e
954
+ t.remove()
955
+ },
956
+ me = (e) => {
957
+ const { target: t, data: s } = e,
958
+ { parent: n, index: r } = s,
959
+ o = n.childNodes[r]
960
+ o ? o && o !== t && n.insertBefore(t, o) : n.appendChild(t)
961
+ },
962
+ fe = (e) => {
963
+ const { source: t, target: s } = e
964
+ t.replaceWith(s)
965
+ },
966
+ be = (e) => {
967
+ const { source: t, data: s } = e,
968
+ { name: n, isSvg: r } = s
969
+ r ? t.removeAttributeNS(null, n) : t.removeAttribute(n)
970
+ },
971
+ tt = (e) => {
972
+ const { source: t, data: s } = e,
973
+ { name: n, value: r, isSvg: o } = s
974
+ o ? t.setAttributeNS(null, n, r) : t.setAttribute(n, r)
975
+ },
976
+ ve = (e) => {
977
+ tt(e)
978
+ },
979
+ ge = (e) => {
980
+ const t = e.data,
981
+ s = e.source,
982
+ { name: n, value: r } = t
983
+ s.removeEventListener(n, r)
984
+ },
985
+ ye = (e) => {
986
+ const t = e.data,
987
+ s = e.source,
988
+ { name: n, value: r } = t
989
+ s.addEventListener(n, r)
990
+ },
991
+ Ee = (e) => {
992
+ const t = e.data,
993
+ s = e.source,
994
+ { name: n, sourceValue: r, targetValue: o } = t
995
+ s.removeEventListener(n, r), s.addEventListener(n, o)
996
+ },
997
+ xe = (e) => {
998
+ const t = e.data,
999
+ s = e.source,
1000
+ { value: n } = t
1001
+ s.value = n
1002
+ },
1003
+ Ae = {
1004
+ [i.changeText]: de,
1005
+ [i.removeNode]: pe,
1006
+ [i.insertNode]: me,
1007
+ [i.replaceNode]: fe,
1008
+ [i.removeAttribute]: be,
1009
+ [i.addAttribute]: tt,
1010
+ [i.updateAttribute]: ve,
1011
+ [i.removeEvent]: ge,
1012
+ [i.addEvent]: ye,
1013
+ [i.updateEvent]: Ee,
1014
+ [i.changeValue]: xe,
1015
+ },
1016
+ _e = (e, t, s) => {
1017
+ const n = [...t]
1018
+ return (
1019
+ e.forEach((r) => {
1020
+ we(r, n, s)
1021
+ }),
1022
+ n
1023
+ )
1024
+ },
1025
+ we = (e, t, s) => {
1026
+ const n = Oe[e.type]
1027
+ n && n(e, t, s)
1028
+ },
1029
+ Se = (e, t) => {
1030
+ const { source: s } = e,
1031
+ n = t.indexOf(s)
1032
+ n >= 0 && t.splice(n, 1)
1033
+ },
1034
+ Ne = (e, t, s) => {
1035
+ const { target: n } = e,
1036
+ r = e.data,
1037
+ { index: o, parent: a } = r
1038
+ s === a && t.splice(o, 0, n)
1039
+ },
1040
+ je = (e, t) => {
1041
+ const { target: s, source: n } = e,
1042
+ r = t.indexOf(n)
1043
+ r >= 0 && (t[r] = s)
1044
+ },
1045
+ Oe = { [i.removeNode]: Se, [i.insertNode]: Ne, [i.replaceNode]: je }
1046
+ class Me {
1047
+ constructor({
1048
+ Template: t,
1049
+ subscriptions: s,
1050
+ attributes: n,
1051
+ viewModel: r,
1052
+ }) {
1053
+ ;(this.Template = t),
1054
+ (this.viewModel = r),
1055
+ (this.attributes = n),
1056
+ (this.subscriptions = s),
1057
+ (this.dom = []),
1058
+ (this.parentElement = null)
1059
+ }
1060
+ render(t) {
1061
+ return (
1062
+ (this.parentElement = t.parent),
1063
+ (this.renderKit = t),
1064
+ this.subscribeForRerender(),
1065
+ (this.dom = this.generateDom(t)),
1066
+ this.dom
1067
+ )
1068
+ }
1069
+ generateDom(t) {
1070
+ const s = {
1071
+ ...this.attributes,
1072
+ ...this.viewModel(t.state.getAll(this.subscriptions)),
1073
+ },
1074
+ n = this.Template(s)
1075
+ return n ? n.render(t) : []
1076
+ }
1077
+ rerender() {
1078
+ if (!this.parentElement && this.dom[0]) {
1079
+ const n = this.dom[0].parentElement
1080
+ this.parentElement = n
1081
+ }
1082
+ const t = this.generateDom(this.renderKit),
1083
+ s = ce(this.dom, t, this.parentElement)
1084
+ this.dom = _e(s, this.dom, this.parentElement)
1085
+ }
1086
+ subscribeForRerender() {
1087
+ const { subscribe: t } = this.renderKit
1088
+ this.subscriptions.forEach((s) => {
1089
+ t(this.eventName(s), () => this.rerender())
1090
+ })
1091
+ }
1092
+ eventName(t) {
1093
+ return `${w}:${t}`
1094
+ }
1095
+ }
1096
+ const Te = (e) => e,
1097
+ et = ({ Template: e, viewModel: t, subscriptions: s }) => (
1098
+ (s = s || []),
1099
+ (t = t || Te),
1100
+ (n) =>
1101
+ new Me({ Template: e, viewModel: t, subscriptions: s, attributes: n })
1102
+ ),
1103
+ ke = Object.freeze(
1104
+ Object.defineProperty(
1105
+ {
1106
+ __proto__: null,
1107
+ createRouteState: P,
1108
+ events: St,
1109
+ extractQueryParams: L,
1110
+ findHref: D,
1111
+ navigate: y,
1112
+ onLinkClick: F,
1113
+ onLocationChange: z,
1114
+ start: Nt,
1115
+ },
1116
+ Symbol.toStringTag,
1117
+ { value: 'Module' },
1118
+ ),
1119
+ ),
1120
+ $e =
1121
+ (e) =>
1122
+ ({ path: t }) =>
1123
+ t === e,
1124
+ Pe = () => !0,
1125
+ st =
1126
+ (e) =>
1127
+ ({ route: t }) => {
1128
+ const s = e.find((n) => n.match(t))
1129
+ return s && s.Partial
1130
+ },
1131
+ De = Object.freeze(
1132
+ Object.defineProperty(
1133
+ { __proto__: null, buildRouter: st, catchAll: Pe, exactPathMatch: $e },
1134
+ Symbol.toStringTag,
1135
+ { value: 'Module' },
1136
+ ),
1137
+ ),
1138
+ Fe = () => ({ render: (e, t) => [] }),
1139
+ Le = (e) => {
1140
+ const t = st(e)
1141
+ return et({
1142
+ Template: ({ route: n }) => (t({ route: n }) || Fe)(),
1143
+ subscriptions: ['route'],
1144
+ })
1145
+ }
1146
+ ;(p.JaxsTypes = Ut),
1147
+ (p.appBuilding = jt),
1148
+ (p.bind = et),
1149
+ (p.createApp = Rt),
1150
+ (p.jsx = M),
1151
+ (p.messageBus = Ot),
1152
+ (p.navigation = ke),
1153
+ (p.routedView = Le),
1154
+ (p.routing = De),
1155
+ (p.state = Vt),
1156
+ Object.defineProperty(p, Symbol.toStringTag, { value: 'Module' })
1157
+ })