jaxs 0.7.1 → 0.7.3

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