apprun
Version:
JavaScript library that has Elm inspired architecture, event pub-sub and components
3 lines (2 loc) • 41.6 kB
JavaScript
const n="3.38.0",e=`AppRun-${n}`;class t{constructor(){this._events={}}on(n,e,t={}){this._events[n]=this._events[n]||[],this._events[n].push({fn:e,options:t})}off(n,e){const t=this._events[n]||[];this._events[n]=t.filter((n=>n.fn!==e))}find(n){return this._events[n]}run(n,...e){const t=this.getSubscribers(n,this._events);return console.assert(t&&t.length>0,"No subscriber for event: "+n),t.forEach((t=>{const{fn:l,options:o}=t;if(!l||"function"!=typeof l)return console.error(`AppRun event handler for '${n}' is not a function:`,l),!1;if(o.delay)this.delay(n,l,e,o);else try{Object.keys(o).length>0?l.apply(this,[...e,o]):l.apply(this,e)}catch(e){console.error(`Error in event handler for '${n}':`,e)}return!t.options.once})),t.length}once(n,e,t={}){this.on(n,e,{...t,once:!0})}delay(n,e,t,l){l._t&&clearTimeout(l._t),l._t=setTimeout((()=>{clearTimeout(l._t);try{Object.keys(l).length>0?e.apply(this,[...t,l]):e.apply(this,t)}catch(e){console.error(`Error in delayed event handler for '${n}':`,e)}}),l.delay)}runAsync(n,...e){const t=this.getSubscribers(n,this._events);console.assert(t&&t.length>0,"No subscriber for event: "+n);const l=t.map((t=>{const{fn:l,options:o}=t;if(!l||"function"!=typeof l)return console.error(`AppRun async event handler for '${n}' is not a function:`,l),Promise.resolve(null);try{return Object.keys(o).length>0?l.apply(this,[...e,o]):l.apply(this,e)}catch(e){return console.error(`Error in async event handler for '${n}':`,e),Promise.reject(e)}}));return Promise.all(l)}query(n,...e){return console.warn("app.query() is deprecated. Use app.runAsync() instead."),this.runAsync(n,...e)}getSubscribers(n,e){const t=e[n]||[];return e[n]=t.filter((n=>!n.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&n.startsWith(e.replace("*","")))).sort(((n,e)=>e.length-n.length)).forEach((l=>t.push(...e[l].map((e=>({...e,options:{...e.options,event:n}})))))),t}}const l=e;let o;const i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};i.app&&i._AppRunVersions?o=i.app:(o=new t,i.app=o,i._AppRunVersions=l);var r=o;function u(n){return n?.target instanceof HTMLElement?n.target:null}const a=n=>{if(!n)return[];const e=[];let t="",l=!1,o="";for(let i=0;i<n.length;i++){const r=n[i];"["!==r||l?"]"===r&&l?(o?t=t.slice(1,-1):/^\d+$/.test(t)&&(t=parseInt(t,10)),e.push(t),t="",l=!1,o=""):'"'!==r&&"'"!==r||!l?"."!==r||l?t+=r:t&&(e.push(t),t=""):(o?r===o&&(o=""):o=r,t+=r):(t&&(e.push(t),t=""),l=!0)}return t&&e.push(t),e},s=(n,e)=>{if(!e)return n.state||"";const t=a(e),l=((n,e)=>{let t=n;for(const n of e){if(null==t)return;t=t[n]}return t})(n.state,t);return void 0!==l?l:""},c=(n,e,t)=>{if(!e)return void n.setState(t);const l=a(e),o=((n,e,t)=>{if(0===e.length)return t;const l={...n};let o=l;for(let n=0;n<e.length-1;n++){const t=e[n],l=e[n+1];null==o[t]?o[t]="number"==typeof l?[]:{}:Array.isArray(o[t])?o[t]=[...o[t]]:"object"==typeof o[t]&&(o[t]={...o[t]}),o=o[t]}return o[e[e.length-1]]=t,l})(n.state||{},l,t);n.setState(o)},h=(n,e)=>{if(Array.isArray(n))return n.map((n=>h(n,e)));{let{type:t,tag:l,props:o,children:i}=n;return l=l||t,i=i||o?.children,o&&Object.keys(o).forEach((n=>{n.startsWith("$")&&(((n,e,t,l)=>{if(n.startsWith("$on")){const t=e[n];if(n=n.substring(1),"boolean"==typeof t)e[n]=e=>l.run?l.run(n,e):r.run(n,e);else if("string"==typeof t)e[n]=n=>l.run?l.run(t,n):r.run(t,n);else if("function"==typeof t)e[n]=n=>l.setState(t(l.state,n));else if(Array.isArray(t)){const[o,...i]=t;"string"==typeof o?e[n]=n=>l.run?l.run(o,...i,n):r.run(o,...i,n):"function"==typeof o&&(e[n]=n=>l.setState(o(l.state,...i,n)))}}else if("$bind"===n){const o=e.type||"text",i="string"==typeof e[n]?e[n]:e.name;if("input"===t)switch(o){case"checkbox":e.checked=s(l,i),e.onclick=n=>{const e=u(n);e&&c(l,i||e.name,e.checked)};break;case"radio":e.checked=s(l,i)===e.value,e.onclick=n=>{const e=u(n);e&&c(l,i||e.name,e.value)};break;case"number":case"range":e.value=s(l,i),e.oninput=n=>{const e=u(n);e&&c(l,i||e.name,Number(e.value))};break;default:e.value=s(l,i),e.oninput=n=>{const e=u(n);e&&c(l,i||e.name,e.value)}}else"select"===t?(e.value=s(l,i),e.onchange=n=>{const e=u(n);e&&!e.multiple&&c(l,i||e.name,e.value)}):"option"===t?(e.selected=s(l,i),e.onclick=n=>{const e=u(n);e&&c(l,i||e.name,e.selected)}):"textarea"===t&&(e.innerHTML=s(l,i),e.oninput=n=>{const e=u(n);e&&c(l,i||e.name,e.value)})}else r.run("$",{key:n,tag:t,props:e,component:l})})(n,o,l,e),delete o[n])})),i&&h(i,e),n}};class d{constructor(n,e,t){this.normal=e,this.property=n,t&&(this.space=t)}}function f(n,e){const t={},l={};for(const e of n)Object.assign(t,e.property),Object.assign(l,e.normal);return new d(t,l,e)}function p(n){return n.toLowerCase()}d.prototype.normal={},d.prototype.property={},d.prototype.space=void 0;class g{constructor(n,e){this.attribute=e,this.property=n}}g.prototype.attribute="",g.prototype.booleanish=!1,g.prototype.boolean=!1,g.prototype.commaOrSpaceSeparated=!1,g.prototype.commaSeparated=!1,g.prototype.defined=!1,g.prototype.mustUseProperty=!1,g.prototype.number=!1,g.prototype.overloadedBoolean=!1,g.prototype.property="",g.prototype.spaceSeparated=!1,g.prototype.space=void 0;let m=0;const y=x(),v=x(),b=x(),k=x(),w=x(),S=x(),C=x();function x(){return 2**++m}var O=Object.freeze({__proto__:null,boolean:y,booleanish:v,commaOrSpaceSeparated:C,commaSeparated:S,number:k,overloadedBoolean:b,spaceSeparated:w});const M=Object.keys(O);class P extends g{constructor(n,e,t,l){let o=-1;if(super(n,e),R(this,"space",l),"number"==typeof t)for(;++o<M.length;){const n=M[o];R(this,M[o],(t&O[n])===O[n])}}}function R(n,e,t){t&&(n[e]=t)}function D(n){const e={},t={};for(const[l,o]of Object.entries(n.properties)){const i=new P(l,n.transform(n.attributes||{},l),o,n.space);n.mustUseProperty&&n.mustUseProperty.includes(l)&&(i.mustUseProperty=!0),e[l]=i,t[p(l)]=l,t[p(i.attribute)]=l}return new d(e,t,n.space)}P.prototype.defined=!0;const A=D({properties:{ariaActiveDescendant:null,ariaAtomic:v,ariaAutoComplete:null,ariaBusy:v,ariaChecked:v,ariaColCount:k,ariaColIndex:k,ariaColSpan:k,ariaControls:w,ariaCurrent:null,ariaDescribedBy:w,ariaDetails:null,ariaDisabled:v,ariaDropEffect:w,ariaErrorMessage:null,ariaExpanded:v,ariaFlowTo:w,ariaGrabbed:v,ariaHasPopup:null,ariaHidden:v,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:w,ariaLevel:k,ariaLive:null,ariaModal:v,ariaMultiLine:v,ariaMultiSelectable:v,ariaOrientation:null,ariaOwns:w,ariaPlaceholder:null,ariaPosInSet:k,ariaPressed:v,ariaReadOnly:v,ariaRelevant:null,ariaRequired:v,ariaRoleDescription:w,ariaRowCount:k,ariaRowIndex:k,ariaRowSpan:k,ariaSelected:v,ariaSetSize:k,ariaSort:null,ariaValueMax:k,ariaValueMin:k,ariaValueNow:k,ariaValueText:null,role:null},transform:(n,e)=>"role"===e?e:"aria-"+e.slice(4).toLowerCase()});function L(n,e){return e in n?n[e]:e}function E(n,e){return L(n,e.toLowerCase())}const T=D({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:S,acceptCharset:w,accessKey:w,action:null,allow:null,allowFullScreen:y,allowPaymentRequest:y,allowUserMedia:y,alt:null,as:null,async:y,autoCapitalize:null,autoComplete:w,autoFocus:y,autoPlay:y,blocking:w,capture:null,charSet:null,checked:y,cite:null,className:w,cols:k,colSpan:null,content:null,contentEditable:v,controls:y,controlsList:w,coords:k|S,crossOrigin:null,data:null,dateTime:null,decoding:null,default:y,defer:y,dir:null,dirName:null,disabled:y,download:b,draggable:v,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:y,formTarget:null,headers:w,height:k,hidden:b,high:k,href:null,hrefLang:null,htmlFor:w,httpEquiv:w,id:null,imageSizes:null,imageSrcSet:null,inert:y,inputMode:null,integrity:null,is:null,isMap:y,itemId:null,itemProp:w,itemRef:w,itemScope:y,itemType:w,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:y,low:k,manifest:null,max:null,maxLength:k,media:null,method:null,min:null,minLength:k,multiple:y,muted:y,name:null,nonce:null,noModule:y,noValidate:y,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:y,optimum:k,pattern:null,ping:w,placeholder:null,playsInline:y,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:y,referrerPolicy:null,rel:w,required:y,reversed:y,rows:k,rowSpan:k,sandbox:w,scope:null,scoped:y,seamless:y,selected:y,shadowRootClonable:y,shadowRootDelegatesFocus:y,shadowRootMode:null,shape:null,size:k,sizes:null,slot:null,span:k,spellCheck:v,src:null,srcDoc:null,srcLang:null,srcSet:null,start:k,step:null,style:null,tabIndex:k,target:null,title:null,translate:null,type:null,typeMustMatch:y,useMap:null,value:v,width:k,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:w,axis:null,background:null,bgColor:null,border:k,borderColor:null,bottomMargin:k,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:y,declare:y,event:null,face:null,frame:null,frameBorder:null,hSpace:k,leftMargin:k,link:null,longDesc:null,lowSrc:null,marginHeight:k,marginWidth:k,noResize:y,noHref:y,noShade:y,noWrap:y,object:null,profile:null,prompt:null,rev:null,rightMargin:k,rules:null,scheme:null,scrolling:v,standby:null,summary:null,text:null,topMargin:k,valueType:null,version:null,vAlign:null,vLink:null,vSpace:k,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:y,disableRemotePlayback:y,prefix:null,property:null,results:k,security:null,unselectable:null},space:"html",transform:E}),j=D({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:C,accentHeight:k,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:k,amplitude:k,arabicForm:null,ascent:k,attributeName:null,attributeType:null,azimuth:k,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:k,by:null,calcMode:null,capHeight:k,className:w,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:k,diffuseConstant:k,direction:null,display:null,dur:null,divisor:k,dominantBaseline:null,download:y,dx:null,dy:null,edgeMode:null,editable:null,elevation:k,enableBackground:null,end:null,event:null,exponent:k,externalResourcesRequired:null,fill:null,fillOpacity:k,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:S,g2:S,glyphName:S,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:k,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:k,horizOriginX:k,horizOriginY:k,id:null,ideographic:k,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:k,k:k,k1:k,k2:k,k3:k,k4:k,kernelMatrix:C,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:k,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:k,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:k,overlineThickness:k,paintOrder:null,panose1:null,path:null,pathLength:k,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:w,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:k,pointsAtY:k,pointsAtZ:k,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:C,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:C,rev:C,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:C,requiredFeatures:C,requiredFonts:C,requiredFormats:C,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:k,specularExponent:k,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:k,strikethroughThickness:k,string:null,stroke:null,strokeDashArray:C,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:k,strokeOpacity:k,strokeWidth:null,style:null,surfaceScale:k,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:C,tabIndex:k,tableValues:null,target:null,targetX:k,targetY:k,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:C,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:k,underlineThickness:k,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:k,values:null,vAlphabetic:k,vMathematical:k,vectorEffect:null,vHanging:k,vIdeographic:k,version:null,vertAdvY:k,vertOriginX:k,vertOriginY:k,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:k,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:L}),U=D({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(n,e)=>"xlink:"+e.slice(5).toLowerCase()}),I=D({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:E}),$=D({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(n,e)=>"xml:"+e.slice(3).toLowerCase()}),z=/[A-Z]/g,B=/-[a-z]/g,H=/^data[-\w.:]+$/i;function F(n){return"-"+n.toLowerCase()}function _(n){return n.charAt(1).toUpperCase()}const N=f([A,T,U,I,$],"html"),V=f([A,j,U,I,$],"svg"),q="_props",W=new Map;function K(n,e){const t=`${n}:${e}`;let l=W.get(t);return void 0===l&&(l=function(n,e){const t=p(e);let l=e,o=g;if(t in n.normal)return n.property[n.normal[t]];if(t.length>4&&"data"===t.slice(0,4)&&H.test(e)){if("-"===e.charAt(4)){const n=e.slice(5).replace(B,_);l="data"+n.charAt(0).toUpperCase()+n.slice(1)}else{const n=e.slice(4);if(!B.test(n)){let t=n.replace(z,F);"-"!==t.charAt(0)&&(t="-"+t),e="data"+t}}o=P}return new o(l,e)}(e?V:N,n)||null,W.set(t,l)),l}function X(n,e,t){!function(n){if(null==n||!1===n||""===n)return!1;if(!0===n)return!0;if("string"==typeof n){return"false"!==n.toLowerCase()&&"0"!==n}return Boolean(n)}(t)?n.removeAttribute(e):n.setAttribute(e,e)}function Y(n,e,t){try{n[e]=t}catch(l){Z(n,e,t,!1)}}function Z(n,e,t,l){if(null==t)return void n.removeAttribute(e);const o=String(t);if(l&&e.includes(":")){const[t]=e.split(":");"xlink"===t?n.setAttributeNS("http://www.w3.org/1999/xlink",e,o):n.setAttribute(e,o)}else n.setAttribute(e,o)}function G(n,e,t,l){if(function(n,e){if(document.activeElement===n)return["selectionStart","selectionEnd","selectionDirection"].includes(e);if("scrollTop"===e||"scrollLeft"===e)return!0;if(n instanceof HTMLMediaElement&&["currentTime","paused","playbackRate","volume"].includes(e))return!0;return!1}(n,e))return;if("style"===e){if(n.style.cssText&&(n.style.cssText=""),"string"==typeof t)n.style.cssText=t;else if(t&&"object"==typeof t)for(const e in t)n.style[e]!==t[e]&&(n.style[e]=t[e]);return}if("key"===e)return void(null!=t&&(n.key=t));if(e.startsWith("data-"))return void function(n,e,t){const l=(o=e.slice(5)).length<=1?o.toLowerCase():o.split("-").map(((n,e)=>0===e?n.toLowerCase():n.charAt(0).toUpperCase()+n.slice(1).toLowerCase())).join("");var o;null==t?delete n.dataset[l]:n.dataset[l]=String(t)}(n,e,t);if(e.startsWith("on"))return void function(n,e,t){e.startsWith("on")&&(t&&"function"!=typeof t?"string"==typeof t&&(t?n.setAttribute(e,t):n.removeAttribute(e)):n[e]=t)}(n,e,t);if(!("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName&&"SELECT"!==n.tagName||"value"!==e&&"selected"!==e&&"selectedIndex"!==e))return void Y(n,e,t);if("INPUT"===n.tagName&&"checked"===e)return Y(n,e,t),void X(n,e,t);const o=K(e,l);o?o.boolean||o.overloadedBoolean?X(n,o.attribute,t):o.mustUseProperty&&!l?Y(n,o.property,t):Z(n,o.attribute,t,l):e.startsWith("aria-")||"role"===e?Z(n,e,t,l):e in n||void 0!==n[e]?Y(n,e,t):Z(n,e,t,l)}function J(n){return/^[a-zA-Z_:][\w\-:.]*$/.test(n)&&!n.includes("<")&&!n.includes(">")&&!n.includes('"')&&!n.includes("'")}function Q(n,e,t){const l=function(n,e){if(e&&(e.class=e.class||e.className,delete e.className),!n||0===Object.keys(n).length)return e||{};if(!e||0===Object.keys(e).length){const e={};return Object.keys(n).forEach((n=>e[n]=null)),e}const t={};return Object.keys(n).forEach((n=>{n in e||(t[n]=null)})),Object.keys(e).forEach((n=>t[n]=e[n])),t}(n[q]||{},e);n[q]=e||{},function(n,e,t,l){for(const t in e)J(t)&&G(n,t,e[t],l);e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(n)))}(n,l,0,t)}function nn(n,...e){return en(e)}function en(n){const e=[],t=n=>{null!=n&&""!==n&&!1!==n&&e.push("function"==typeof n||"object"==typeof n?n:`${n}`)};return n&&n.forEach((n=>{Array.isArray(n)?n.forEach((n=>t(n))):t(n)})),e}const tn={};let ln=0;const on=(n,e,t={})=>{if(null==e||!1===e)return;!function(n,e,t={}){if(null==e||!1===e)return;if(e=hn(e,t),!n)return;const l="SVG"===n.nodeName;Array.isArray(e)?un(n,e,l):un(n,[e],l)}("string"==typeof n&&n?document.getElementById(n)||document.querySelector(n):n,e=h(e,t),t)};function rn(n,e,t){t=t||"svg"===e.tag,function(n,e){const t=n.nodeName,l=`${e.tag||""}`;return t.toUpperCase()===l.toUpperCase()}(n,e)?(un(n,e.children,t),Q(n,e.props,t)):n.parentNode.replaceChild(cn(e,t),n)}function un(n,e,t){const l=n.childNodes?.length||0,o=e?.length||0,i=Math.min(l,o);for(let l=0;l<i;l++){const o=e[l],i=n.childNodes[l];if("string"==typeof o)i.textContent!==o&&(3===i.nodeType?i.nodeValue=o:n.replaceChild(sn(o),i));else if(o instanceof HTMLElement||o instanceof SVGElement)n.insertBefore(o,i);else{const e=o.props&&o.props.key;if(e)if(i.key===e)rn(n.childNodes[l],o,t);else{const r=tn[e];r?(n.insertBefore(r,i),rn(n.childNodes[l],o,t)):n.replaceChild(cn(o,t),i)}else rn(n.childNodes[l],o,t)}}let r=n.childNodes?.length||0;for(;r>i;)n.removeChild(n.lastChild),r--;if(o>i){const l=document.createDocumentFragment();for(let n=i;n<e.length;n++)l.appendChild(cn(e[n],t));n.appendChild(l)}}const an=n=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",n),Array.from(e.children)};function sn(n){if(0===n?.indexOf("_html:")){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",n.substring(6)),e}return document.createTextNode(n??"")}function cn(n,e){if(n instanceof HTMLElement||n instanceof SVGElement)return n;if("string"==typeof n)return sn(n);if(!n.tag||"function"==typeof n.tag)return sn(JSON.stringify(n));const t=(e=e||"svg"===n.tag)?document.createElementNS("http://www.w3.org/2000/svg",n.tag):document.createElement(n.tag);return Q(t,n.props,e),n.children&&n.children.forEach((n=>t.appendChild(cn(n,e)))),n.props&&void 0!==n.props.key&&(t.key=n.props.key,tn[n.props.key]=t,++ln>=500&&(!function(){if(!(Object.keys(tn).length<=1e3))for(const[n,e]of Object.entries(tn))e.isConnected||delete tn[n]}(),ln=0)),t}function hn(n,e,t=0){if("string"==typeof n)return n;if(Array.isArray(n))return n.map((n=>hn(n,e,t++)));let l=n;if(n&&"function"==typeof n.tag&&Object.getPrototypeOf(n.tag).t&&(l=function(n,e,t){const{tag:l,props:o,children:i}=n;let r=`_${t}`,u=o&&o.id;u?r=u:u=`_${t}${Date.now()}`;let a="section";o&&o.as&&(a=o.as,delete o.as),e.l||(e.l={});let s=e.l[r];if(s&&s instanceof l&&s.element)s.renderState(s.state);else{const n=document.createElement(a);s=e.l[r]=new l({...o,children:i}).mount(n,{render:!0})}if(s.mounted){const n=s.mounted(o,i,s.state);void 0!==n&&s.setState(n)}return Q(s.element,o,!1),s.element}(n,e,t)),l&&Array.isArray(l.children)){const n=l.props?._component;if(n){let e=0;l.children=l.children.map((t=>hn(t,n,e++)))}else l.children=l.children.map((n=>hn(n,e,t++)))}return l}const dn=(n,e={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(e.observedAttributes||[]).map((n=>n.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const t=e||{};this._shadowRoot=t.shadow?this.attachShadow({mode:"open"}):this;const l=t.observedAttributes||[],o=l.reduce(((n,e)=>{const t=e.toLowerCase();return t!==e&&(n[t]=e),n}),{});this._attrMap=n=>o[n]||n;const i={};Array.from(this.attributes).forEach((n=>i[this._attrMap(n.name)]=n.value)),l.forEach((n=>{void 0!==this[n]&&(i[n]=this[n]),Object.defineProperty(this,n,{get:()=>i[n],set(e){this.attributeChangedCallback(n,i[n],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new n({...i,children:e}).mount(this._shadowRoot,t),this._component._props=i,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const n=this._component.mounted(i,e,this._component.state);void 0!==n&&(this._component.state=n)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==t.render&&this._component.run(".")}))}}disconnectedCallback(){this._component?.unload?.(),this._component?.unmount?.(),this._component=null}attributeChangedCallback(n,t,l){if(this._component){const o=this._attrMap(n);this._component._props[o]=l,this._component.run("attributeChanged",o,t,l),l!==t&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var fn=(n,e,t)=>{"undefined"!=typeof customElements&&customElements.define(n,dn(e,t))};const pn={meta:new WeakMap,defineMetadata(n,e,t){this.meta.has(t)||this.meta.set(t,{}),this.meta.get(t)[n]=e},getMetadataKeys(n){return n=Object.getPrototypeOf(n),this.meta.get(n)?Object.keys(this.meta.get(n)):[]},getMetadata(n,e){return e=Object.getPrototypeOf(e),this.meta.get(e)?this.meta.get(e)[n]:null}};function gn(n,e={}){return(t,l,o)=>{const i=n?n.toString():l;return pn.defineMetadata(`apprun-update:${i}`,{name:i,key:l,options:e},t),o}}function mn(n,e={}){return function(t,l){const o=n?n.toString():l;pn.defineMetadata(`apprun-update:${o}`,{name:o,key:l,options:e},t)}}function yn(n,e){return function(t){return fn(n,t,e),t}}const vn=n=>n,bn=r;class kn{renderState(n,e=null){if(!this.view)return;let t=e||this.view(n);if(bn.debug&&bn.run("debug",{component:this,_:t?".":"-",state:n,vdom:t,el:this.element}),"object"!=typeof document)return;const l="string"==typeof this.element&&this.element?function(n){try{return document.getElementById(n)}catch(e){return console.warn(`Error getting element by id: ${n}`,e),null}}(this.element)||function(n,e=document){try{return e.querySelector(n)}catch(e){return console.warn(`Invalid selector: ${n}`,e),null}}(this.element):this.element;if(!l)return void console.warn(`Component element not found: ${this.element}`);const o="_c";this.unload?l._component===this&&l.getAttribute(o)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),l.setAttribute(o,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((n=>{n[0].oldValue!==this.tracking_id&&document.body.contains(l)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[o]}))):l.removeAttribute&&l.removeAttribute(o),l._component=this,!e&&t&&(t=h(t,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>bn.render(l,t,this))):bn.render(l,t,this)),this.rendered&&this.rendered(this.state)}setState(n,e={render:!0,history:!1}){const t=async n=>{try{for(;;){const{value:t,done:l}=await n.next();if(l)break;this.setState(t,e)}}catch(n){console.error("Error in async iterator:",n)}},l=n;if(l?.[Symbol.asyncIterator])this.setState(t(l[Symbol.asyncIterator]()),e);else if(l?.[Symbol.iterator]&&"function"==typeof l.next)for(const n of l)this.setState(n,e);else if(n&&n instanceof Promise)Promise.resolve(n).then((t=>{this.setState(t,e),this._state=n}));else{if(this._state=n,null==n)return;this.state=n,!1!==e.render&&(e.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(n))):this.renderState(n)),!1!==e.history&&this.enable_history&&(this._history=[...this._history,n],this._history_idx=this._history.length-1),"function"==typeof e.callback&&e.callback(this.state)}}constructor(n,e,l,o){this.state=n,this.view=e,this.update=l,this.options=o,this._app=new t,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(n=null,e)=>{if(this.mount(n,{render:!0,...e}),this.mounted&&"function"==typeof this.mounted){const n=this.mounted({},[],this.state);void 0!==n&&this.setState(n)}return this}}mount(n=null,e){return console.assert(!this.element,"Component already mounted."),this.options=e={...this.options,...e},this.element=n,this.global_event=e.global_event,this.enable_history=!!e.history,this.enable_history&&(this.on(e.history.prev||"history-prev",this._history_prev),this.on(e.history.next||"history-next",this._history_next)),e.route&&(this.update=this.update||{},this.update[e.route]||(this.update[e.route]=vn)),this.add_actions(),this.state=this.state??this.model??{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),bn.debug&&bn.find("debug-create-component")?.length&&bn.run("debug-create-component",this),this}is_global_event(n){return n&&(this.global_event||this._global_events.indexOf(n)>=0||n.startsWith("#")||n.startsWith("/")||n.startsWith("@"))}add_action(n,e,t={}){e&&"function"==typeof e?(t.global&&this._global_events.push(n),this.on(n,((...l)=>{bn.debug&&bn.run("debug",{component:this,_:">",event:n,p:l,current_state:this.state,options:t});try{const o=e(this.state,...l);bn.debug&&bn.run("debug",{component:this,_:"<",event:n,p:l,newState:o,state:this.state,options:t}),this.setState(o,t)}catch(e){console.error(`Error in component action '${n}':`,e),bn.debug&&bn.run("debug",{component:this,_:"!",event:n,p:l,error:e,state:this.state,options:t})}}),t)):console.warn(`Component action for '${n}' is not a valid function:`,e)}add_actions(){const n=this.update||{};pn.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const t=pn.getMetadata(e,this);n[t.name]=[this[t.key].bind(this),t.options]}}));const e={};Array.isArray(n)?n.forEach((n=>{const[t,l,o]=n;t.toString().split(",").forEach((n=>e[n.trim()]=[l,o]))})):Object.keys(n).forEach((t=>{const l=n[t];("function"==typeof l||Array.isArray(l))&&t.split(",").forEach((n=>e[n.trim()]=l))})),e["."]||(e["."]=vn),Object.keys(e).forEach((n=>{const t=e[n];"function"==typeof t?this.add_action(n,t):Array.isArray(t)&&this.add_action(n,t[0],t[1])}))}run(n,...e){if(this.state instanceof Promise)return Promise.resolve(this.state).then((t=>{this.state=t,this.run(n,...e)}));{const t=n.toString();return this.is_global_event(t)?bn.run(t,...e):this._app.run(t,...e)}}on(n,e,t){const l=n.toString();return this._actions.push({name:l,fn:e}),this.is_global_event(l)?bn.on(l,e,t):this._app.on(l,e,t)}runAsync(n,...e){const t=n.toString();return this.is_global_event(t)?bn.runAsync(t,...e):this._app.runAsync(t,...e)}query(n,...e){return console.warn("component.query() is deprecated. Use component.runAsync() instead."),this.runAsync(n,...e)}unmount(){this.observer?.disconnect(),this._actions.forEach((n=>{const{name:e,fn:t}=n;this.is_global_event(e)?bn.off(e,t):this._app.off(e,t)}))}}function wn(){const n=r.find("#");if(n&&n.length>0)return r.run("#"),void r.run(xn,"#");const e=r.find("/");if(e&&e.length>0)return r.run("/"),void r.run(xn,"/");const t=r.find("#/");if(t&&t.length>0)return r.run("#/"),void r.run(xn,"#/");console.warn("No subscribers for event: "),r.run(On,""),r.run(xn,"")}function Sn(n){if(!n)return void wn();n=function(n){return n&&"/"!==n&&"#"!==n&&"#/"!==n&&n.endsWith("/")?n.slice(0,-1):n}(n);const e=r.basePath;e&&(n=function(n,e){if(!e||"/"===e||""===e)return n;const t=e.startsWith("/")?e:"/"+e;if(n.startsWith(t)){const e=n.substring(t.length);return e.startsWith("/")?e:"/"+e}return n}(n,e));const t=function(n){return n?n.startsWith("#/")?n.substring(2).split("/"):n.startsWith("#")||n.startsWith("/")?n.substring(1).split("/"):n.split("/"):[]}(n);let l;!function(n){const e=n.filter(Boolean);e.length>11&&console.warn(`Deep route hierarchy detected: ${e.join("/")} (${e.length} levels)`)}(t),l=n.startsWith("#/")?"hash-slash":n.startsWith("#")?"hash":n.startsWith("/")?"path":"non-prefixed";const o=function(n,e){const t=[];for(let l=n.length;l>0;l--){const o=n.slice(0,l);let i="";switch(e){case"path":i="/"+o.join("/");break;case"hash":i="#"+o.join("/");break;case"hash-slash":i="#/"+o.join("/");break;case"non-prefixed":i=o.join("/")}t.push(i)}return t}(t,l),i=function(n,e){for(let t=0;t<n.length;t++){const l=n[t],o=r.find(l);if(o&&o.length>0){const o=n.length-t;return{eventName:l,parameters:e.slice(o)}}}return null}(o,t);if(i)Cn(i.eventName,...i.parameters);else if(o.length>0){const e=o[o.length-1];console.warn(`No subscribers for event: ${e}`),r.run(On,n),r.run(xn,n)}else wn()}kn.t=!0;const Cn=(n,...e)=>{if(!n||n===xn||n===On)return;const t=r.find(n);t&&0!==t.length?r.run(n,...e):(console.warn(`No subscribers for event: ${n}`),r.run(On,n,...e)),r.run(xn,n,...e)},xn="//",On="///",Mn=n=>{r.lastUrl!==n&&(r.lastUrl=n,Sn(n))};function Pn(n){return n&&"object"==typeof n&&"function"==typeof n.mount}function Rn(n){return"function"==typeof n&&n.prototype&&n.prototype.constructor===n&&(void 0!==n.prototype.mount||void 0!==n.prototype.state||void 0!==n.prototype.view)}function Dn(n){return"function"==typeof n&&!Rn(n)}async function An(n,e=3){let t=n,l=0;for(;Dn(t)&&l<e;)try{const n=await t();if(n===t)break;t=n,l++}catch(n){console.error(`Error executing component function: ${n}`);break}return t}const Ln=r;if(!Ln.start){Ln.version=n,Ln.h=Ln.createElement=function(n,e,...t){const l=en(t);if("string"==typeof n)return{tag:n,props:e,children:l};if(Array.isArray(n))return n;if(void 0===n&&t)return l;if(Object.getPrototypeOf(n).t)return{tag:n,props:e,children:l};if("function"==typeof n)return n(e,l);throw new Error(`Unknown tag in vdom ${n}`)},Ln.render=on,Ln.Fragment=nn,Ln.webComponent=fn,Ln.safeHTML=an,Ln.start=(n,e,t,l,o)=>{const i={render:!0,global_event:!0,...o},r=new kn(e,t,l);return o&&o.rendered&&(r.rendered=o.rendered),o&&o.mounted&&(r.mounted=o.mounted),r.start(n,i),r},Ln.query=Ln.query||Ln.runAsync;const e=n=>{};if(Ln.on("/",e),Ln.on("debug",(n=>e)),Ln.on(xn,e),Ln.on(On,e),Ln.route=Mn,Ln.on("route",(n=>Ln.route&&Ln.route(n))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{const n=document.body.hasAttribute("apprun-no-init")||Ln["no-init-route"]||!1,e=Ln.find("#")||Ln.find("#/")||!1;window.addEventListener("hashchange",(()=>Mn(location.hash))),window.addEventListener("popstate",(()=>Mn(location.pathname))),e?!n&&Mn(location.hash):(!n&&(()=>{const n=Ln.basePath||"";let e=location.pathname;n&&e.startsWith(n)&&(e=e.substring(n.length),e.startsWith("/")||(e="/"+e)),Mn(e)})(),document.body.addEventListener("click",(n=>{const e=n.target;if(!e)return;const t="A"===e.tagName?e:e.closest("a");if(t&&t.origin===location.origin&&t.pathname){n.preventDefault();const e=(Ln.basePath||"")+t.pathname;history.pushState(null,"",e),Mn(t.pathname)}})))})),"object"==typeof window){const n=window;n.Component=kn,n._React=n.React,n.React=Ln,n.on=mn,n.customElement=yn,n.safeHTML=an}Ln.use_render=(n,e=0)=>{Ln.render=0===e?(e,t)=>n(t,e):(e,t)=>n(e,t)},Ln.use_react=(n,e)=>{if(n&&e)if("function"==typeof n.createElement)if(n.Fragment)if(Ln.h=Ln.createElement=n.createElement,Ln.Fragment=n.Fragment,n.version&&n.version.startsWith("18")){if(!e.createRoot||"function"!=typeof e.createRoot)return void console.error("AppRun use_react: ReactDOM.createRoot not found in React 18+");Ln.render=(n,t)=>{n&&void 0!==t&&(n._root||(n._root=e.createRoot(n)),n._root.render(t))}}else{if(!e.render||"function"!=typeof e.render)return void console.error("AppRun use_react: ReactDOM.render not found in legacy React");Ln.render=(n,t)=>e.render(t,n)}else console.error("AppRun use_react: Invalid React object - Fragment not found");else console.error("AppRun use_react: Invalid React object - createElement method not found");else console.error("AppRun use_react: React and ReactDOM parameters are required")},Ln.addComponents=async(n,e)=>{for(const[t,l]of Object.entries(e))if(l&&t)if(Pn(l)){const e={route:t};l.mount(n,e)}else if(Rn(l)){const e={route:t};(new l).mount(n,e)}else if(Dn(l)){let e=await An(l);if(Pn(e)){const l={route:t};e.mount(n,l);continue}if(Rn(e)){const l={route:t};(new e).mount(n,l);continue}r.on(t,((...e)=>{const t=l(...e);if("string"!=typeof n||(n=document.querySelector(n)))return r.render(n,t);console.error(`Element not found: ${n}`)}))}else console.error("Invalid component: component must be a class, instance, or function that returns a class/instance");else console.error(`Invalid component configuration: component=${l}, route=${t}`)}}export{t as App,kn as Component,nn as Fragment,On as ROUTER_404_EVENT,xn as ROUTER_EVENT,Ln as app,yn as customElement,Ln as default,gn as event,mn as on,an as safeHTML,gn as update};
//# sourceMappingURL=apprun.esm.js.map