!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apprun=e():t.apprun=e()}(this,(()=>(()=>{"use strict";var t={752:(t,e,n)=>{n.d(e,{Z:()=>r,g:()=>o});class o{constructor(){this._events={}}on(t,e,n={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:n})}off(t,e){const n=this._events[t]||[];this._events[t]=n.filter((t=>t.fn!==e))}find(t){return this._events[t]}run(t,...e){const n=this.getSubscribers(t,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+t),n.forEach((n=>{const{fn:o,options:s}=n;return s.delay?this.delay(t,o,e,s):Object.keys(s).length>0?o.apply(this,[...e,s]):o.apply(this,e),!n.options.once})),n.length}once(t,e,n={}){this.on(t,e,Object.assign(Object.assign({},n),{once:!0}))}delay(t,e,n,o){o._t&&clearTimeout(o._t),o._t=setTimeout((()=>{clearTimeout(o._t),Object.keys(o).length>0?e.apply(this,[...n,o]):e.apply(this,n)}),o.delay)}runAsync(t,...e){const n=this.getSubscribers(t,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+t);const o=n.map((t=>{const{fn:n,options:o}=t;return Object.keys(o).length>0?n.apply(this,[...e,o]):n.apply(this,e)}));return Promise.all(o)}query(t,...e){return this.query(t,...e)}getSubscribers(t,e){const n=e[t]||[];return e[t]=n.filter((t=>!t.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&t.startsWith(e.replace("*","")))).sort(((t,e)=>e.length-t.length)).forEach((o=>n.push(...e[o].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:t})})))))),n}}let s;const i="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g;i.app&&i._AppRunVersions?s=i.app:(s=new o,i.app=s,i._AppRunVersions="AppRun-3");const r=s},37:(t,e,n)=>{n.d(e,{Component:()=>u,app:()=>o.Z});var o=n(752),s=n(559);const i=(t,e={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(e.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const n=e||{};this._shadowRoot=n.shadow?this.attachShadow({mode:"open"}):this;const o=n.observedAttributes||[],s=o.reduce(((t,e)=>{const n=e.toLowerCase();return n!==e&&(t[n]=e),t}),{});this._attrMap=t=>s[t]||t;const i={};Array.from(this.attributes).forEach((t=>i[this._attrMap(t.name)]=t.value)),o.forEach((t=>{void 0!==this[t]&&(i[t]=this[t]),Object.defineProperty(this,t,{get:()=>i[t],set(e){this.attributeChangedCallback(t,i[t],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(e.forEach((t=>t.parentElement.removeChild(t))),this._component=new t(Object.assign(Object.assign({},i),{children:e})).mount(this._shadowRoot,n),this._component._props=i,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(i,e,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==n.render&&this._component.run(".")}))}}disconnectedCallback(){var t,e,n,o;null===(e=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===e||e.call(t),null===(o=null===(n=this._component)||void 0===n?void 0:n.unmount)||void 0===o||o.call(n),this._component=null}attributeChangedCallback(t,n,o){if(this._component){const s=this._attrMap(t);this._component._props[s]=o,this._component.run("attributeChanged",s,n,o),o!==n&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}},r=(t,e,n)=>{"undefined"!=typeof customElements&&customElements.define(t,i(e,n))},a={meta:new WeakMap,defineMetadata(t,e,n){this.meta.has(n)||this.meta.set(n,{}),this.meta.get(n)[t]=e},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,e){return e=Object.getPrototypeOf(e),this.meta.get(e)?this.meta.get(e)[t]:null}};var c=n(334);const l=new Map;o.Z.find("get-components")||o.Z.on("get-components",(t=>t.components=l));const p=t=>t;class u{renderState(t,e=null){if(!this.view)return;let n=e||this.view(t);if(o.Z.debug&&o.Z.run("debug",{component:this,_:n?".":"-",state:t,vdom:n,el:this.element}),"object"!=typeof document)return;const s="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(s){const t="_c";this.unload?s._component===this&&s.getAttribute(t)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),s.setAttribute(t,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(s)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[t]}))):s.removeAttribute&&s.removeAttribute(t),s._component=this}!e&&n&&(n=(0,c.Z)(n,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>o.Z.render(s,n,this))):o.Z.render(s,n,this)),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){if(t instanceof Promise)Promise.resolve(t).then((n=>{this.setState(n,e),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==e.render&&(e.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==e.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof e.callback&&e.callback(this.state)}}constructor(t,e,n,s){this.state=t,this.view=e,this.update=n,this.options=s,this._app=new o.g,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{if(this.mount(t,Object.assign({render:!0},e)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,e){var n,s;return console.assert(!this.element,"Component already mounted."),this.options=e=Object.assign(Object.assign({},this.options),e),this.element=t,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]=p)),this.add_actions(),this.state=null!==(s=null!==(n=this.state)&&void 0!==n?n:this.model)&&void 0!==s?s:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),o.Z.debug&&(l.get(t)?l.get(t).push(this):l.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,e,n={}){e&&"function"==typeof e&&(n.global&&this._global_events.push(t),this.on(t,((...s)=>{o.Z.debug&&o.Z.run("debug",{component:this,_:">",event:t,p:s,current_state:this.state,options:n});const i=e(this.state,...s);o.Z.debug&&o.Z.run("debug",{component:this,_:"<",event:t,p:s,newState:i,state:this.state,options:n}),this.setState(i,n)}),n))}add_actions(){const t=this.update||{};a.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const n=a.getMetadata(e,this);t[n.name]=[this[n.key].bind(this),n.options]}}));const e={};Array.isArray(t)?t.forEach((t=>{const[n,o,s]=t;n.toString().split(",").forEach((t=>e[t.trim()]=[o,s]))})):Object.keys(t).forEach((n=>{const o=t[n];("function"==typeof o||Array.isArray(o))&&n.split(",").forEach((t=>e[t.trim()]=o))})),e["."]||(e["."]=p),Object.keys(e).forEach((t=>{const n=e[t];"function"==typeof n?this.add_action(t,n):Array.isArray(n)&&this.add_action(t,n[0],n[1])}))}run(t,...e){if(this.state instanceof Promise)return Promise.resolve(this.state).then((n=>{this.state=n,this.run(t,...e)}));{const n=t.toString();return this.is_global_event(n)?o.Z.run(n,...e):this._app.run(n,...e)}}on(t,e,n){const s=t.toString();return this._actions.push({name:s,fn:e}),this.is_global_event(s)?o.Z.on(s,e,n):this._app.on(s,e,n)}runAsync(t,...e){const n=t.toString();return this.is_global_event(n)?o.Z.runAsync(n,...e):this._app.runAsync(n,...e)}query(t,...e){return this.runAsync(t,...e)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:e,fn:n}=t;this.is_global_event(e)?o.Z.off(e,n):this._app.off(e,n)}))}}u.__isAppRunComponent=!0;const h="//",d="///",m=t=>{if(t||(t="#"),t.startsWith("#")){const[e,...n]=t.split("/");o.Z.run(e,...n)||o.Z.run(d,e,...n),o.Z.run(h,e,...n)}else if(t.startsWith("/")){const[e,n,...s]=t.split("/");o.Z.run("/"+n,...s)||o.Z.run(d,"/"+n,...s),o.Z.run(h,"/"+n,...s)}else o.Z.run(t)||o.Z.run(d,t),o.Z.run(h,t)};o.Z.h=o.Z.createElement=s.az,o.Z.render=s.yj,o.Z.Fragment=s.HY,o.Z.webComponent=r,o.Z.safeHTML=s.eV,o.Z.start=(t,e,n,o,s)=>{const i=Object.assign({render:!0,global_event:!0},s),r=new u(e,n,o);return s&&s.rendered&&(r.rendered=s.rendered),s&&s.mounted&&(r.mounted=s.mounted),r.start(t,i),r};const f=t=>{};o.Z.on("$",f),o.Z.on("debug",(t=>f)),o.Z.on(h,f),o.Z.on("#",f),o.Z.route=m,o.Z.on("route",(t=>o.Z.route&&o.Z.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{o.Z.route===m&&(window.onpopstate=()=>m(location.hash),document.body.hasAttribute("apprun-no-init")||o.Z["no-init-route"]||m(location.hash))})),"object"==typeof window&&(window.Component=u,window._React=window.React,window.React=o.Z,window.on=function(t,e={}){return function(n,o){const s=t?t.toString():o;a.defineMetadata(`apprun-update:${s}`,{name:s,key:o,options:e},n)}},window.customElement=function(t,e){return function(n){return r(t,n,e),n}},window.safeHTML=s.eV)},334:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(752);const s=(t,e)=>(e?t.state[e]:t.state)||"",i=(t,e,n)=>{if(e){const o=t.state||{};o[e]=n,t.setState(o)}else t.setState(n)},r=(t,e)=>{if(Array.isArray(t))return t.map((t=>r(t,e)));{let{tag:n,props:a,children:c}=t;return n?(a&&Object.keys(a).forEach((t=>{t.startsWith("$")&&(((t,e,n,r)=>{if(t.startsWith("$on")){const n=e[t];if(t=t.substring(1),"boolean"==typeof n)e[t]=e=>r.run?r.run(t,e):o.Z.run(t,e);else if("string"==typeof n)e[t]=t=>r.run?r.run(n,t):o.Z.run(n,t);else if("function"==typeof n)e[t]=t=>r.setState(n(r.state,t));else if(Array.isArray(n)){const[s,...i]=n;"string"==typeof s?e[t]=t=>r.run?r.run(s,...i,t):o.Z.run(s,...i,t):"function"==typeof s&&(e[t]=t=>r.setState(s(r.state,...i,t)))}}else if("$bind"===t){const o=e.type||"text",a="string"==typeof e[t]?e[t]:e.name;if("input"===n)switch(o){case"checkbox":e.checked=s(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.checked);break;case"radio":e.checked=s(r,a)===e.value,e.onclick=t=>i(r,a||t.target.name,t.target.value);break;case"number":case"range":e.value=s(r,a),e.oninput=t=>i(r,a||t.target.name,Number(t.target.value));break;default:e.value=s(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value)}else"select"===n?(e.value=s(r,a),e.onchange=t=>{t.target.multiple||i(r,a||t.target.name,t.target.value)}):"option"===n?(e.selected=s(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.selected)):"textarea"===n&&(e.innerHTML=s(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value))}else o.Z.run("$",{key:t,tag:n,props:e,component:r})})(t,a,n,e),delete a[t])})),c&&(c=r(c,e)),{tag:n,props:a,children:c}):t}},a=r},559:(t,e,n)=>{n.d(e,{HY:()=>s,az:()=>a,eV:()=>h,yj:()=>l});var o=n(334);function s(t,...e){return r(e)}const i="_props";function r(t){const e=[],n=t=>{null!=t&&""!==t&&!1!==t&&e.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>n(t))):n(t)})),e}function a(t,e,...n){const o=r(n);if("string"==typeof t)return{tag:t,props:e,children:o};if(Array.isArray(t))return t;if(void 0===t&&n)return o;if(Object.getPrototypeOf(t).__isAppRunComponent)return{tag:t,props:e,children:o};if("function"==typeof t)return t(e,o);throw new Error(`Unknown tag in vdom ${t}`)}const c=new WeakMap,l=(t,e,n={})=>{null!=e&&!1!==e&&function(t,e,n={}){if(null==e||!1===e)return;if(e=y(e,n),!t)return;const o="SVG"===t.nodeName;Array.isArray(e)?u(t,e,o):u(t,[e],o)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,e=(0,o.Z)(e,n),n)};function p(t,e,n){3!==e._op&&(n=n||"svg"===e.tag,function(t,e){const n=t.nodeName,o=`${e.tag||""}`;return n.toUpperCase()===o.toUpperCase()}(t,e)?(!(2&e._op)&&u(t,e.children,n),!(1&e._op)&&f(t,e.props,n)):t.parentNode.replaceChild(m(e,n),t))}function u(t,e,n){var o,s;const i=(null===(o=t.childNodes)||void 0===o?void 0:o.length)||0,r=(null==e?void 0:e.length)||0,a=Math.min(i,r);for(let o=0;oa;)t.removeChild(t.lastChild),l--;if(r>a){const o=document.createDocumentFragment();for(let t=a;t{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",t),Array.from(e.children)};function d(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",t.substring(6)),e}return document.createTextNode(null!=t?t:"")}function m(t,e){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return d(t);if(!t.tag||"function"==typeof t.tag)return d(JSON.stringify(t));const n=(e=e||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return f(n,t.props,e),t.children&&t.children.forEach((t=>n.appendChild(m(t,e)))),n}function f(t,e,n){const o=t[i]||{};e=function(t,e){e.class=e.class||e.className,delete e.className;const n={};return t&&Object.keys(t).forEach((t=>n[t]=null)),e&&Object.keys(e).forEach((t=>n[t]=e[t])),n}(o,e||{}),t[i]=e;for(const o in e){const s=e[o];if(o.startsWith("data-")){const e=o.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[e]!==s&&(s||""===s?t.dataset[e]=s:delete t.dataset[e])}else if("style"===o)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof s)t.style.cssText=s;else for(const e in s)t.style[e]!==s[e]&&(t.style[e]=s[e]);else if(o.startsWith("xlink")){const e=o.replace("xlink","").toLowerCase();null==s||!1===s?t.removeAttributeNS("http://www.w3.org/1999/xlink",e):t.setAttributeNS("http://www.w3.org/1999/xlink",e,s)}else o.startsWith("on")?s&&"function"!=typeof s?"string"==typeof s&&(s?t.setAttribute(o,s):t.removeAttribute(o)):t[o]=s:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(o)||n?t.getAttribute(o)!==s&&(s?t.setAttribute(o,s):t.removeAttribute(o)):t[o]!==s&&(t[o]=s);"key"===o&&s&&(c[s]=t)}e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(t)))}function y(t,e,n=0){var o;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>y(t,e,n++)));let s=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).__isAppRunComponent&&(s=function(t,e,n){const{tag:o,props:s,children:i}=t;let r=`_${n}`,a=s&&s.id;a?r=a:a=`_${n}${Date.now()}`;let c="section";s&&s.as&&(c=s.as,delete s.as),e.__componentCache||(e.__componentCache={});let l=e.__componentCache[r];if(l&&l instanceof o&&l.element)l.renderState(l.state);else{const t=document.createElement(c);l=e.__componentCache[r]=new o(Object.assign(Object.assign({},s),{children:i})).mount(t,{render:!0})}if(l.mounted){const t=l.mounted(s,i,l.state);void 0!==t&&l.setState(t)}return f(l.element,s,!1),l.element}(t,e,n)),s&&Array.isArray(s.children)){const t=null===(o=s.props)||void 0===o?void 0:o._component;if(t){let e=0;s.children=s.children.map((n=>y(n,t,e++)))}else s.children=s.children.map((t=>y(t,e,n++)))}return s}}},e={};function n(o){var s=e[o];if(void 0!==s)return s.exports;var i=e[o]={exports:{}};return t[o](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{n.r(o);var t=n(37);const e=(t,e,n,o)=>{if(!e||!n)return;const s=t=>{var n,o;const s=e.cloneNode();null===(n=e.parentNode)||void 0===n||n.replaceChild(s,e);const i=null===(o=(e=s).contentWindow)||void 0===o?void 0:o.document;i&&(i.open(),t.indexOf("=0?i.write(t):i.write((t=>`\n\n\n \n \n \n