apprun 3.33.10 → 3.36.0
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/README.md +5 -0
- package/WHATSNEW.md +58 -3
- package/apprun.d.ts +6 -6
- package/dist/apprun-dev-tools.js +1 -1
- package/dist/apprun-dev-tools.js.map +1 -1
- package/dist/apprun-html.esm.js +7 -7
- package/dist/apprun-html.esm.js.map +1 -1
- package/dist/apprun-html.js +1 -1
- package/dist/apprun-html.js.map +1 -1
- package/dist/apprun-play-html.esm.js +7 -7
- package/dist/apprun-play-html.esm.js.map +1 -1
- package/dist/apprun-play.js +1 -1
- package/dist/apprun-play.js.map +1 -1
- package/dist/apprun.esm.js +1 -1
- package/dist/apprun.esm.js.map +1 -1
- package/dist/apprun.js +1 -1
- package/dist/apprun.js.map +1 -1
- package/esm/app.js +55 -11
- package/esm/app.js.map +1 -1
- package/esm/apprun-html.js +8 -4
- package/esm/apprun-html.js.map +1 -1
- package/esm/apprun.js +82 -28
- package/esm/apprun.js.map +1 -1
- package/esm/component.js +56 -19
- package/esm/component.js.map +1 -1
- package/esm/decorator.js +22 -5
- package/esm/decorator.js.map +1 -1
- package/esm/directive.js +64 -13
- package/esm/directive.js.map +1 -1
- package/esm/router.js +25 -4
- package/esm/router.js.map +1 -1
- package/esm/type-utils.js +91 -0
- package/esm/type-utils.js.map +1 -0
- package/esm/types.js +32 -11
- package/esm/types.js.map +1 -1
- package/esm/vdom-my.js +66 -43
- package/esm/vdom-my.js.map +1 -1
- package/esm/version.js +15 -0
- package/esm/version.js.map +1 -0
- package/esm/web-component.js +30 -10
- package/esm/web-component.js.map +1 -1
- package/index.html +1 -0
- package/jest.config.js +1 -7
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.js.map +1 -1
- package/package.json +1 -1
- package/plan/plan-apprun-bugfixes.md +207 -0
- package/src/app.ts +57 -15
- package/src/apprun-html.ts +8 -4
- package/src/apprun.ts +98 -33
- package/src/component.ts +58 -20
- package/src/decorator.ts +23 -6
- package/src/directive.ts +64 -13
- package/src/router.ts +25 -6
- package/src/type-utils.ts +130 -0
- package/src/types.ts +33 -12
- package/src/vdom-my.ts +75 -39
- package/src/version.ts +16 -0
- package/src/web-component.ts +31 -11
package/dist/apprun-html.esm.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
class t{constructor(){this._events={}}on(t,s,i={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:s,options:i})}off(t,s){const i=this._events[t]||[];this._events[t]=i.filter((t=>t.fn!==s))}find(t){return this._events[t]}run(t,...s){const i=this.getSubscribers(t,this._events);return console.assert(i&&i.length>0,"No subscriber for event: "+t),i.forEach((i=>{const{fn:e,options:n}=i;return n.delay?this.delay(t,e,s,n):Object.keys(n).length>0?e.apply(this,[...s,n]):e.apply(this,s),!i.options.once})),i.length}once(t,s,i={}){this.on(t,s,Object.assign(Object.assign({},i),{once:!0}))}delay(t,s,i,e){e._t&&clearTimeout(e._t),e._t=setTimeout((()=>{clearTimeout(e._t),Object.keys(e).length>0?s.apply(this,[...i,e]):s.apply(this,i)}),e.delay)}runAsync(t,...s){const i=this.getSubscribers(t,this._events);console.assert(i&&i.length>0,"No subscriber for event: "+t);const e=i.map((t=>{const{fn:i,options:e}=t;return Object.keys(e).length>0?i.apply(this,[...s,e]):i.apply(this,s)}));return Promise.all(e)}query(t,...s){return this.runAsync(t,...s)}getSubscribers(t,s){const i=s[t]||[];return s[t]=i.filter((t=>!t.options.once)),Object.keys(s).filter((s=>s.endsWith("*")&&t.startsWith(s.replace("*","")))).sort(((t,s)=>s.length-t.length)).forEach((e=>i.push(...s[e].map((s=>Object.assign(Object.assign({},s),{options:Object.assign(Object.assign({},s.options),{event:t})})))))),i}}let s;const i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};i.app&&i._AppRunVersions?s=i.app:(s=new t,i.app=s,i._AppRunVersions="AppRun-3");var e=s;const n=(t,s)=>(s?t.state[s]:t.state)||"",o=(t,s,i)=>{if(s){const e=t.state||{};e[s]=i,t.setState(e)}else t.setState(i)},r=(t,s)=>{if(Array.isArray(t))return t.map((t=>r(t,s)));{let{type:i,tag:h,props:c,children:l}=t;return h=h||i,l=l||(null==c?void 0:c.children),c&&Object.keys(c).forEach((t=>{t.startsWith("$")&&(((t,s,i,r)=>{if(t.startsWith("$on")){const i=s[t];if(t=t.substring(1),"boolean"==typeof i)s[t]=s=>r.run?r.run(t,s):e.run(t,s);else if("string"==typeof i)s[t]=t=>r.run?r.run(i,t):e.run(i,t);else if("function"==typeof i)s[t]=t=>r.setState(i(r.state,t));else if(Array.isArray(i)){const[n,...o]=i;"string"==typeof n?s[t]=t=>r.run?r.run(n,...o,t):e.run(n,...o,t):"function"==typeof n&&(s[t]=t=>r.setState(n(r.state,...o,t)))}}else if("$bind"===t){const e=s.type||"text",h="string"==typeof s[t]?s[t]:s.name;if("input"===i)switch(e){case"checkbox":s.checked=n(r,h),s.onclick=t=>o(r,h||t.target.name,t.target.checked);break;case"radio":s.checked=n(r,h)===s.value,s.onclick=t=>o(r,h||t.target.name,t.target.value);break;case"number":case"range":s.value=n(r,h),s.oninput=t=>o(r,h||t.target.name,Number(t.target.value));break;default:s.value=n(r,h),s.oninput=t=>o(r,h||t.target.name,t.target.value)}else"select"===i?(s.value=n(r,h),s.onchange=t=>{t.target.multiple||o(r,h||t.target.name,t.target.value)}):"option"===i?(s.selected=n(r,h),s.onclick=t=>o(r,h||t.target.name,t.target.selected)):"textarea"===i&&(s.innerHTML=n(r,h),s.oninput=t=>o(r,h||t.target.name,t.target.value))}else e.run("$",{key:t,tag:i,props:s,component:r})})(t,c,h,s),delete c[t])})),l&&r(l,s),t}};function h(t,...s){return l(s)}const c="_props";function l(t){const s=[],i=t=>{null!=t&&""!==t&&!1!==t&&s.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>i(t))):i(t)})),s}function u(t,s,...i){const e=l(i);if("string"==typeof t)return{tag:t,props:s,children:e};if(Array.isArray(t))return t;if(void 0===t&&i)return e;if(Object.getPrototypeOf(t).i)return{tag:t,props:s,children:e};if("function"==typeof t)return t(s,e);throw new Error(`Unknown tag in vdom ${t}`)}const a=new WeakMap,f=(t,s,i={})=>{if(null==s||!1===s)return;!function(t,s,i={}){if(null==s||!1===s)return;if(s=m(s,i),!t)return;const e="SVG"===t.nodeName;Array.isArray(s)?p(t,s,e):p(t,[s],e)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,s=r(s,i),i)};function d(t,s,i){3!==s._op&&(i=i||"svg"===s.tag,!function(t,s){const i=t.nodeName,e=`${s.tag||""}`;return i.toUpperCase()===e.toUpperCase()}(t,s)?t.parentNode.replaceChild(b(s,i),t):(!(2&s._op)&&p(t,s.children,i),!(1&s._op)&&w(t,s.props,i)))}function p(t,s,i){var e,n;const o=(null===(e=t.childNodes)||void 0===e?void 0:e.length)||0,r=(null==s?void 0:s.length)||0,h=Math.min(o,r);for(let e=0;e<h;e++){const n=s[e];if(3===n._op)continue;const o=t.childNodes[e];if("string"==typeof n)o.textContent!==n&&(3===o.nodeType?o.nodeValue=n:t.replaceChild(v(n),o));else if(n instanceof HTMLElement||n instanceof SVGElement)t.insertBefore(n,o);else{const s=n.props&&n.props.key;if(s)if(o.key===s)d(t.childNodes[e],n,i);else{const r=a[s];if(r){const s=r.nextSibling;t.insertBefore(r,o),s?t.insertBefore(o,s):t.appendChild(o),d(t.childNodes[e],n,i)}else t.replaceChild(b(n,i),o)}else d(t.childNodes[e],n,i)}}let c=(null===(n=t.childNodes)||void 0===n?void 0:n.length)||0;for(;c>h;)t.removeChild(t.lastChild),c--;if(r>h){const e=document.createDocumentFragment();for(let t=h;t<s.length;t++)e.appendChild(b(s[t],i));t.appendChild(e)}}const y=t=>{const s=document.createElement("section");return s.insertAdjacentHTML("afterbegin",t),Array.from(s.children)};function v(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const s=document.createElement("div");return s.insertAdjacentHTML("afterbegin",t.substring(6)),s}return document.createTextNode(null!=t?t:"")}function b(t,s){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return v(t);if(!t.tag||"function"==typeof t.tag)return v(JSON.stringify(t));const i=(s=s||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return w(i,t.props,s),t.children&&t.children.forEach((t=>i.appendChild(b(t,s)))),i}function w(t,s,i){const e=t[c]||{};s=function(t,s){s.class=s.class||s.className,delete s.className;const i={};return t&&Object.keys(t).forEach((t=>i[t]=null)),Object.keys(s).forEach((t=>i[t]=s[t])),i}(e,s||{}),t[c]=s;for(const e in s){const n=s[e];if(e.startsWith("data-")){const s=e.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[s]!==n&&(n||""===n?t.dataset[s]=n:delete t.dataset[s])}else if("style"===e)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof n)t.style.cssText=n;else for(const s in n)t.style[s]!==n[s]&&(t.style[s]=n[s]);else if(e.startsWith("xlink")){const s=e.replace("xlink","").toLowerCase();null==n||!1===n?t.removeAttributeNS("http://www.w3.org/1999/xlink",s):t.setAttributeNS("http://www.w3.org/1999/xlink",s,n)}else e.startsWith("on")?n&&"function"!=typeof n?"string"==typeof n&&(n?t.setAttribute(e,n):t.removeAttribute(e)):t[e]=n:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(e)||i?t.getAttribute(e)!==n&&(n?t.setAttribute(e,n):t.removeAttribute(e)):t[e]!==n&&(t[e]=n);"key"===e&&n&&(a[n]=t)}s&&"function"==typeof s.ref&&window.requestAnimationFrame((()=>s.ref(t)))}function m(t,s,i=0){var e;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>m(t,s,i++)));let n=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).i&&(n=function(t,s,i){const{tag:e,props:n,children:o}=t;let r=`_${i}`,h=n&&n.id;h?r=h:h=`_${i}${Date.now()}`;let c="section";n&&n.as&&(c=n.as,delete n.as),s.v||(s.v={});let l=s.v[r];if(l&&l instanceof e&&l.element)l.renderState(l.state);else{const t=document.createElement(c);l=s.v[r]=new e(Object.assign(Object.assign({},n),{children:o})).mount(t,{render:!0})}if(l.mounted){const t=l.mounted(n,o,l.state);void 0!==t&&l.setState(t)}return w(l.element,n,!1),l.element}(t,s,i)),n&&Array.isArray(n.children)){const t=null===(e=n.props)||void 0===e?void 0:e._component;if(t){let s=0;n.children=n.children.map((i=>m(i,t,s++)))}else n.children=n.children.map((t=>m(t,s,i++)))}return n}const g=(t,s={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(s.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const i=s||{};this._shadowRoot=i.shadow?this.attachShadow({mode:"open"}):this;const e=i.observedAttributes||[],n=e.reduce(((t,s)=>{const i=s.toLowerCase();return i!==s&&(t[i]=s),t}),{});this._attrMap=t=>n[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),e.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(s){this.attributeChangedCallback(t,o[t],s)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const s=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},o),{children:s})).mount(this._shadowRoot,i),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,s,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!==i.render&&this._component.run(".")}))}}disconnectedCallback(){var t,s,i,e;null===(s=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===s||s.call(t),null===(e=null===(i=this._component)||void 0===i?void 0:i.unmount)||void 0===e||e.call(i),this._component=null}attributeChangedCallback(t,i,e){if(this._component){const n=this._attrMap(t);this._component._props[n]=e,this._component.run("attributeChanged",n,i,e),e!==i&&!1!==s.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var $=(t,s,i)=>{"undefined"!=typeof customElements&&customElements.define(t,g(s,i))};const S={meta:new WeakMap,defineMetadata(t,s,i){this.meta.has(i)||this.meta.set(i,{}),this.meta.get(i)[t]=s},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,s){return s=Object.getPrototypeOf(s),this.meta.get(s)?this.meta.get(s)[t]:null}};function O(t,s={}){return(i,e,n)=>{const o=t?t.toString():e;return S.defineMetadata(`apprun-update:${o}`,{name:o,key:e,options:s},i),n}}function A(t,s={}){return function(i,e){const n=t?t.toString():e;S.defineMetadata(`apprun-update:${n}`,{name:n,key:e,options:s},i)}}function _(t,s){return function(i){return $(t,i,s),i}}const j=new Map;e.find("get-components")||e.on("get-components",(t=>t.components=j));const k=t=>t;class E{renderState(t,s=null){if(!this.view)return;let i=s||this.view(t);if(e.debug&&e.run("debug",{component:this,_:i?".":"-",state:t,vdom:i,el:this.element}),"object"!=typeof document)return;const n="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!n)return;const o="_c";this.unload?n._component===this&&n.getAttribute(o)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),n.setAttribute(o,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(n)||(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]}))):n.removeAttribute&&n.removeAttribute(o),n._component=this,!s&&i&&(i=r(i,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>e.render(n,i,this))):e.render(n,i,this)),this.rendered&&this.rendered(this.state)}setState(t,s={render:!0,history:!1}){const i=async t=>{try{for(;;){const{value:i,done:e}=await t.next();if(e)break;this.setState(i,s)}}catch(t){console.error("Error in async iterator:",t)}},e=t;if(null==e?void 0:e[Symbol.asyncIterator])this.setState(i(e[Symbol.asyncIterator]()),s);else if((null==e?void 0:e[Symbol.iterator])&&"function"==typeof e.next)for(const t of e)this.setState(t,s);else if(t&&t instanceof Promise)Promise.resolve(t).then((i=>{this.setState(i,s),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==s.render&&(s.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==s.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof s.callback&&s.callback(this.state)}}constructor(s,i,e,n){this.state=s,this.view=i,this.update=e,this.options=n,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=(t=null,s)=>{if(this.mount(t,Object.assign({render:!0},s)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,s){var i,n;return console.assert(!this.element,"Component already mounted."),this.options=s=Object.assign(Object.assign({},this.options),s),this.element=t,this.global_event=s.global_event,this.enable_history=!!s.history,this.enable_history&&(this.on(s.history.prev||"history-prev",this._history_prev),this.on(s.history.next||"history-next",this._history_next)),s.route&&(this.update=this.update||{},this.update[s.route]||(this.update[s.route]=k)),this.add_actions(),this.state=null!==(n=null!==(i=this.state)&&void 0!==i?i:this.model)&&void 0!==n?n:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!s.render,history:!0}),e.debug&&(j.get(t)?j.get(t).push(this):j.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,s,i={}){s&&"function"==typeof s&&(i.global&&this._global_events.push(t),this.on(t,((...n)=>{e.debug&&e.run("debug",{component:this,_:">",event:t,p:n,current_state:this.state,options:i});const o=s(this.state,...n);e.debug&&e.run("debug",{component:this,_:"<",event:t,p:n,newState:o,state:this.state,options:i}),this.setState(o,i)}),i))}add_actions(){const t=this.update||{};S.getMetadataKeys(this).forEach((s=>{if(s.startsWith("apprun-update:")){const i=S.getMetadata(s,this);t[i.name]=[this[i.key].bind(this),i.options]}}));const s={};Array.isArray(t)?t.forEach((t=>{const[i,e,n]=t;i.toString().split(",").forEach((t=>s[t.trim()]=[e,n]))})):Object.keys(t).forEach((i=>{const e=t[i];("function"==typeof e||Array.isArray(e))&&i.split(",").forEach((t=>s[t.trim()]=e))})),s["."]||(s["."]=k),Object.keys(s).forEach((t=>{const i=s[t];"function"==typeof i?this.add_action(t,i):Array.isArray(i)&&this.add_action(t,i[0],i[1])}))}run(t,...s){if(this.state instanceof Promise)return Promise.resolve(this.state).then((i=>{this.state=i,this.run(t,...s)}));{const i=t.toString();return this.is_global_event(i)?e.run(i,...s):this._app.run(i,...s)}}on(t,s,i){const n=t.toString();return this._actions.push({name:n,fn:s}),this.is_global_event(n)?e.on(n,s,i):this._app.on(n,s,i)}runAsync(t,...s){const i=t.toString();return this.is_global_event(i)?e.runAsync(i,...s):this._app.runAsync(i,...s)}query(t,...s){return this.runAsync(t,...s)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:s,fn:i}=t;this.is_global_event(s)?e.off(s,i):this._app.off(s,i)}))}}E.i=!0;const M="//",C="///",x=t=>{if(t||(t="#"),t.startsWith("#")){const[s,...i]=t.split("/");e.run(s,...i)||e.run(C,s,...i),e.run(M,s,...i)}else if(t.startsWith("/")){const[s,i,...n]=t.split("/");e.run("/"+i,...n)||e.run(C,"/"+i,...n),e.run(M,"/"+i,...n)}else e.run(t)||e.run(C,t),e.run(M,t)};if(!e.start){e.h=e.createElement=u,e.render=f,e.Fragment=h,e.webComponent=$,e.safeHTML=y,e.start=(t,s,i,e,n)=>{const o=Object.assign({render:!0,global_event:!0},n),r=new E(s,i,e);return n&&n.rendered&&(r.rendered=n.rendered),n&&n.mounted&&(r.mounted=n.mounted),r.start(t,o),r};const t=t=>{};e.on("$",t),e.on("debug",(s=>t)),e.on(M,t),e.on("#",t),e.route=x,e.on("route",(t=>e.route&&e.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{e.route===x&&(window.onpopstate=()=>x(location.hash),document.body.hasAttribute("apprun-no-init")||e["no-init-route"]||x(location.hash))})),"object"==typeof window&&(window.Component=E,window._React=window.React,window.React=e,window.on=A,window.customElement=_,window.safeHTML=y),e.use_render=(t,s=0)=>{e.render=0===s?(s,i)=>t(i,s):(s,i)=>t(s,i)},e.use_react=(t,s)=>{e.h=e.createElement=t.createElement,e.Fragment=t.Fragment,e.render=(t,i)=>s.render(i,t),t.version&&t.version.startsWith("18")&&(e.render=(t,i)=>{t&&i&&(t._root||(t._root=s.createRoot(t)),t._root.render(i))})},e.use_prettyLink=()=>{window.onload=()=>e.route(location.pathname),window.addEventListener("popstate",(()=>e.route(location.pathname))),document.body.addEventListener("click",(t=>{const s=t.target,i="A"===s.tagName?s:s.closest("a");i&&i.origin===location.origin&&(t.preventDefault(),history.pushState(null,"",i.pathname),e.route(i.pathname))}))}}
|
|
1
|
+
const t="3.36.0",e=`AppRun-${t}`;class s{constructor(){this._events={}}on(t,e,s={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:s})}off(t,e){const s=this._events[t]||[];this._events[t]=s.filter((t=>t.fn!==e))}find(t){return this._events[t]}run(t,...e){const s=this.getSubscribers(t,this._events);return console.assert(s&&s.length>0,"No subscriber for event: "+t),s.forEach((s=>{const{fn:i,options:n}=s;if(!i||"function"!=typeof i)return console.error(`AppRun event handler for '${t}' is not a function:`,i),!1;if(n.delay)this.delay(t,i,e,n);else try{Object.keys(n).length>0?i.apply(this,[...e,n]):i.apply(this,e)}catch(e){console.error(`Error in event handler for '${t}':`,e)}return!s.options.once})),s.length}once(t,e,s={}){this.on(t,e,Object.assign(Object.assign({},s),{once:!0}))}delay(t,e,s,i){i._t&&clearTimeout(i._t),i._t=setTimeout((()=>{clearTimeout(i._t);try{Object.keys(i).length>0?e.apply(this,[...s,i]):e.apply(this,s)}catch(e){console.error(`Error in delayed event handler for '${t}':`,e)}}),i.delay)}runAsync(t,...e){const s=this.getSubscribers(t,this._events);console.assert(s&&s.length>0,"No subscriber for event: "+t);const i=s.map((s=>{const{fn:i,options:n}=s;if(!i||"function"!=typeof i)return console.error(`AppRun async event handler for '${t}' is not a function:`,i),Promise.resolve(null);try{return Object.keys(n).length>0?i.apply(this,[...e,n]):i.apply(this,e)}catch(e){return console.error(`Error in async event handler for '${t}':`,e),Promise.reject(e)}}));return Promise.all(i)}query(t,...e){return this.runAsync(t,...e)}getSubscribers(t,e){const s=e[t]||[];return e[t]=s.filter((t=>!t.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&t.startsWith(e.replace("*","")))).sort(((t,e)=>e.length-t.length)).forEach((i=>s.push(...e[i].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:t})})))))),s}}const i=e;let n;const o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};o.app&&o._AppRunVersions?n=o.app:(n=new s,o.app=n,o._AppRunVersions=i);var r=n;function h(t){return(null==t?void 0:t.target)instanceof HTMLElement?t.target:null}const c=(t,e)=>(e?t.state[e]:t.state)||"",l=(t,e,s)=>{if(e){const i=t.state||{};i[e]=s,t.setState(i)}else t.setState(s)},u=(t,e)=>{if(Array.isArray(t))return t.map((t=>u(t,e)));{let{type:s,tag:i,props:n,children:o}=t;return i=i||s,o=o||(null==n?void 0:n.children),n&&Object.keys(n).forEach((t=>{t.startsWith("$")&&(((t,e,s,i)=>{if(t.startsWith("$on")){const s=e[t];if(t=t.substring(1),"boolean"==typeof s)e[t]=e=>i.run?i.run(t,e):r.run(t,e);else if("string"==typeof s)e[t]=t=>i.run?i.run(s,t):r.run(s,t);else if("function"==typeof s)e[t]=t=>i.setState(s(i.state,t));else if(Array.isArray(s)){const[n,...o]=s;"string"==typeof n?e[t]=t=>i.run?i.run(n,...o,t):r.run(n,...o,t):"function"==typeof n&&(e[t]=t=>i.setState(n(i.state,...o,t)))}}else if("$bind"===t){const n=e.type||"text",o="string"==typeof e[t]?e[t]:e.name;if("input"===s)switch(n){case"checkbox":e.checked=c(i,o),e.onclick=t=>{const e=h(t);e&&l(i,o||e.name,e.checked)};break;case"radio":e.checked=c(i,o)===e.value,e.onclick=t=>{const e=h(t);e&&l(i,o||e.name,e.value)};break;case"number":case"range":e.value=c(i,o),e.oninput=t=>{const e=h(t);e&&l(i,o||e.name,Number(e.value))};break;default:e.value=c(i,o),e.oninput=t=>{const e=h(t);e&&l(i,o||e.name,e.value)}}else"select"===s?(e.value=c(i,o),e.onchange=t=>{const e=h(t);e&&!e.multiple&&l(i,o||e.name,e.value)}):"option"===s?(e.selected=c(i,o),e.onclick=t=>{const e=h(t);e&&l(i,o||e.name,e.selected)}):"textarea"===s&&(e.innerHTML=c(i,o),e.oninput=t=>{const e=h(t);e&&l(i,o||e.name,e.value)})}else r.run("$",{key:t,tag:s,props:e,component:i})})(t,n,i,e),delete n[t])})),o&&u(o,e),t}};function a(t,...e){return d(e)}const f="_props";function d(t){const e=[],s=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=>s(t))):s(t)})),e}function p(t,e,...s){const i=d(s);if("string"==typeof t)return{tag:t,props:e,children:i};if(Array.isArray(t))return t;if(void 0===t&&s)return i;if(Object.getPrototypeOf(t).i)return{tag:t,props:e,children:i};if("function"==typeof t)return t(e,i);throw new Error(`Unknown tag in vdom ${t}`)}const y=(t,e,s={})=>{if(null==e||!1===e)return;!function(t,e,s={}){if(null==e||!1===e)return;if(e=S(e,s),!t)return;const i="SVG"===t.nodeName;Array.isArray(e)?b(t,e,i):b(t,[e],i)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,e=u(e,s),s)};function v(t,e,s){s=s||"svg"===e.tag,function(t,e){const s=t.nodeName,i=`${e.tag||""}`;return s.toUpperCase()===i.toUpperCase()}(t,e)?(b(t,e.children,s),$(t,e.props,s)):t.parentNode.replaceChild(w(e,s),t)}function b(t,e,s){var i;const n=(null===(i=t.childNodes)||void 0===i?void 0:i.length)||0,o=(null==e?void 0:e.length)||0;if(null==e?void 0:e.some((t=>t&&"object"==typeof t&&t.props&&void 0!==t.props.key))){const i=new Map;for(let e=0;e<n;e++){const s=t.childNodes[e];s&&s.key&&i.set(s.key,s)}const r=document.createDocumentFragment();for(let t=0;t<o;t++){const n=e[t];if(null==n)continue;const o=n.props&&n.props.key;if(o&&i.has(o)){const t=i.get(o);v(t,n,s),r.appendChild(t),i.delete(o)}else r.appendChild(w(n,s))}for(;t.firstChild;)t.removeChild(t.firstChild);return void t.appendChild(r)}const r=Math.min(n,o);for(let i=0;i<r;i++){const n=e[i];if(null==n)continue;const o=t.childNodes[i];o&&("string"==typeof n?3===o.nodeType?o.nodeValue!==n&&(o.nodeValue=n):t.replaceChild(g(n),o):n instanceof HTMLElement||n instanceof SVGElement?t.replaceChild(n,o):n&&"object"==typeof n&&v(t.childNodes[i],n,s))}for(;t.childNodes.length>r;)t.removeChild(t.lastChild);if(o>r){const i=document.createDocumentFragment();for(let t=r;t<e.length;t++){const n=e[t];null!=n&&i.appendChild(w(n,s))}t.appendChild(i)}}const m=t=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",t),Array.from(e.children)};function g(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 w(t,e){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return g(t);if(!t||"object"!=typeof t||!t.tag||"function"==typeof t.tag)return g("object"==typeof t?JSON.stringify(t):String(null!=t?t:""));const s=(e=e||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return $(s,t.props,e),t.children&&t.children.forEach((t=>s.appendChild(w(t,e)))),s}function $(t,e,s){const i=t[f]||{};e=function(t,e){e.class=e.class||e.className,delete e.className;const s={};return t&&Object.keys(t).forEach((t=>s[t]=null)),Object.keys(e).forEach((t=>s[t]=e[t])),s}(i,e||{}),t[f]=e;for(const i in e){const n=e[i];if(i.startsWith("data-")){const e=i.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[e]!==n&&(n||""===n?t.dataset[e]=n:delete t.dataset[e])}else if("style"===i)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof n)t.style.cssText=n;else for(const e in n)t.style[e]!==n[e]&&(t.style[e]=n[e]);else if(i.startsWith("xlink")){const e=i.replace("xlink","").toLowerCase();null==n||!1===n?t.removeAttributeNS("http://www.w3.org/1999/xlink",e):t.setAttributeNS("http://www.w3.org/1999/xlink",e,n)}else i.startsWith("on")?n&&"function"!=typeof n?"string"==typeof n&&(n?t.setAttribute(i,n):t.removeAttribute(i)):t[i]=n:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(i)||s?t.getAttribute(i)!==n&&(n?t.setAttribute(i,n):t.removeAttribute(i)):t[i]!==n&&(t[i]=n);"key"===i&&void 0!==n&&(t.key=n)}e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(t)))}function S(t,e,s=0){var i;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>S(t,e,s++)));let n=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).i&&(n=function(t,e,s){const{tag:i,props:n,children:o}=t;let r=`_${s}`,h=n&&n.id;h?r=h:h=`_${s}${Date.now()}`;let c="section";n&&n.as&&(c=n.as,delete n.as),e.v||(e.v={});let l=e.v[r];if(l&&l instanceof i&&l.element)l.renderState(l.state);else{const t=document.createElement(c);l=e.v[r]=new i(Object.assign(Object.assign({},n),{children:o})).mount(t,{render:!0})}if(l.mounted){const t=l.mounted(n,o,l.state);void 0!==t&&l.setState(t)}return $(l.element,n,!1),l.element}(t,e,s)),n&&Array.isArray(n.children)){const t=null===(i=n.props)||void 0===i?void 0:i._component;if(t){let e=0;n.children=n.children.map((s=>S(s,t,e++)))}else n.children=n.children.map((t=>S(t,e,s++)))}return n}const j=(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 s=e||{};this._shadowRoot=s.shadow?this.attachShadow({mode:"open"}):this;const i=s.observedAttributes||[],n=i.reduce(((t,e)=>{const s=e.toLowerCase();return s!==e&&(t[s]=e),t}),{});this._attrMap=t=>n[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),i.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(e){this.attributeChangedCallback(t,o[t],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},o),{children:e})).mount(this._shadowRoot,s),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,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!==s.render&&this._component.run(".")}))}}disconnectedCallback(){var t,e,s,i;null===(e=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===e||e.call(t),null===(i=null===(s=this._component)||void 0===s?void 0:s.unmount)||void 0===i||i.call(s),this._component=null}attributeChangedCallback(t,s,i){if(this._component){const n=this._attrMap(t);this._component._props[n]=i,this._component.run("attributeChanged",n,s,i),i!==s&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var A=(t,e,s)=>{"undefined"!=typeof customElements&&customElements.define(t,j(e,s))};const O={meta:new WeakMap,defineMetadata(t,e,s){this.meta.has(s)||this.meta.set(s,{}),this.meta.get(s)[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}};function _(t,e={}){return(s,i,n)=>{const o=t?t.toString():i;return O.defineMetadata(`apprun-update:${o}`,{name:o,key:i,options:e},s),n}}function E(t,e={}){return function(s,i){const n=t?t.toString():i;O.defineMetadata(`apprun-update:${n}`,{name:n,key:i,options:e},s)}}function M(t,e){return function(s){return A(t,s,e),s}}const k=new Map;r.find("get-components")||r.on("get-components",(t=>t.components=k));const C=t=>t;class R{renderState(t,e=null){if(!this.view)return;let s=e||this.view(t);if(r.debug&&r.run("debug",{component:this,_:s?".":"-",state:t,vdom:s,el:this.element}),"object"!=typeof document)return;const i="string"==typeof this.element&&this.element?function(t){try{return document.getElementById(t)}catch(e){return console.warn(`Error getting element by id: ${t}`,e),null}}(this.element)||function(t,e=document){try{return e.querySelector(t)}catch(e){return console.warn(`Invalid selector: ${t}`,e),null}}(this.element):this.element;if(!i)return void console.warn(`Component element not found: ${this.element}`);const n="_c";this.unload?i._component===this&&i.getAttribute(n)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),i.setAttribute(n,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(i)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[n]}))):i.removeAttribute&&i.removeAttribute(n),i._component=this,!e&&s&&(s=u(s,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>r.render(i,s,this))):r.render(i,s,this)),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){const s=async t=>{try{for(;;){const{value:s,done:i}=await t.next();if(i)break;this.setState(s,e)}}catch(t){console.error("Error in async iterator:",t)}},i=t;if(null==i?void 0:i[Symbol.asyncIterator])this.setState(s(i[Symbol.asyncIterator]()),e);else if((null==i?void 0:i[Symbol.iterator])&&"function"==typeof i.next)for(const t of i)this.setState(t,e);else if(t&&t instanceof Promise)Promise.resolve(t).then((s=>{this.setState(s,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,i,n){this.state=t,this.view=e,this.update=i,this.options=n,this._app=new s,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=(t=null,e)=>{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 s,i;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]=C)),this.add_actions(),this.state=null!==(i=null!==(s=this.state)&&void 0!==s?s:this.model)&&void 0!==i?i:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),r.debug&&(k.get(t)?k.get(t).push(this):k.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,s={}){e&&"function"==typeof e?(s.global&&this._global_events.push(t),this.on(t,((...i)=>{r.debug&&r.run("debug",{component:this,_:">",event:t,p:i,current_state:this.state,options:s});try{const n=e(this.state,...i);r.debug&&r.run("debug",{component:this,_:"<",event:t,p:i,newState:n,state:this.state,options:s}),this.setState(n,s)}catch(e){console.error(`Error in component action '${t}':`,e),r.debug&&r.run("debug",{component:this,_:"!",event:t,p:i,error:e,state:this.state,options:s})}}),s)):console.warn(`Component action for '${t}' is not a valid function:`,e)}add_actions(){const t=this.update||{};O.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const s=O.getMetadata(e,this);t[s.name]=[this[s.key].bind(this),s.options]}}));const e={};Array.isArray(t)?t.forEach((t=>{const[s,i,n]=t;s.toString().split(",").forEach((t=>e[t.trim()]=[i,n]))})):Object.keys(t).forEach((s=>{const i=t[s];("function"==typeof i||Array.isArray(i))&&s.split(",").forEach((t=>e[t.trim()]=i))})),e["."]||(e["."]=C),Object.keys(e).forEach((t=>{const s=e[t];"function"==typeof s?this.add_action(t,s):Array.isArray(s)&&this.add_action(t,s[0],s[1])}))}run(t,...e){if(this.state instanceof Promise)return Promise.resolve(this.state).then((s=>{this.state=s,this.run(t,...e)}));{const s=t.toString();return this.is_global_event(s)?r.run(s,...e):this._app.run(s,...e)}}on(t,e,s){const i=t.toString();return this._actions.push({name:i,fn:e}),this.is_global_event(i)?r.on(i,e,s):this._app.on(i,e,s)}runAsync(t,...e){const s=t.toString();return this.is_global_event(s)?r.runAsync(s,...e):this._app.runAsync(s,...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:s}=t;this.is_global_event(e)?r.off(e,s):this._app.off(e,s)}))}}R.i=!0;const x="//",P="///",T=t=>{if(r.lastUrl!==t)if(r.lastUrl=t,t||(t="#"),t.startsWith("#")){const[e,...s]=t.split("/");r.run(e,...s)||r.run(P,e,...s),r.run(x,e,...s)}else if(t.startsWith("/")){const[e,s,...i]=t.split("/");r.run("/"+s,...i)||r.run(P,"/"+s,...i),r.run(x,"/"+s,...i)}else r.run(t)||r.run(P,t),r.run(x,t)};if(!r.start){r.version=t,r.h=r.createElement=p,r.render=y,r.Fragment=a,r.webComponent=A,r.safeHTML=m,r.start=(t,e,s,i,n)=>{const o=Object.assign({render:!0,global_event:!0},n),r=new R(e,s,i);return n&&n.rendered&&(r.rendered=n.rendered),n&&n.mounted&&(r.mounted=n.mounted),r.start(t,o),r},r.once=r.once||((t,e,s={})=>{r.on(t,e,Object.assign(Object.assign({},s),{once:!0}))}),r.query=r.query||r.runAsync;const e=t=>{};if(r.on("debug",(t=>e)),r.on(x,e),r.on(P,e),r.route=T,r.on("route",(t=>r.route&&r.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{const t=document.body.hasAttribute("apprun-no-init")||r["no-init-route"]||!1,e=r.find("#")||r.find("#/")||!1;window.addEventListener("hashchange",(()=>T(location.hash))),window.addEventListener("popstate",(()=>T(location.pathname))),e?!t&&T(location.hash):(!t&&T(location.pathname),document.body.addEventListener("click",(t=>{const e=t.target;if(!e)return;const s="A"===e.tagName?e:e.closest("a");s&&s.origin===location.origin&&s.pathname&&(t.preventDefault(),history.pushState(null,"",s.pathname),T(s.pathname))})))})),"object"==typeof window){const t=window;t.Component=R,t._React=t.React,t.React=r,t.on=E,t.customElement=M,t.safeHTML=m}r.use_render=(t,e=0)=>{r.render=0===e?(e,s)=>t(s,e):(e,s)=>t(e,s)},r.use_react=(t,e)=>{if(t&&e)if("function"==typeof t.createElement)if(t.Fragment)if(r.h=r.createElement=t.createElement,r.Fragment=t.Fragment,t.version&&t.version.startsWith("18")){if(!e.createRoot||"function"!=typeof e.createRoot)return void console.error("AppRun use_react: ReactDOM.createRoot not found in React 18+");r.render=(t,s)=>{t&&void 0!==s&&(t._root||(t._root=e.createRoot(t)),t._root.render(s))}}else{if(!e.render||"function"!=typeof e.render)return void console.error("AppRun use_react: ReactDOM.render not found in legacy React");r.render=(t,s)=>e.render(s,t)}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")}}
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2019 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/const
|
|
6
|
+
*/const U=globalThis,N=U.ShadowRoot&&(void 0===U.ShadyCSS||U.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,D=Symbol(),L=new WeakMap;let I=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==D)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(N&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=L.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&L.set(e,t))}return t}toString(){return this.cssText}};const z=N?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new I("string"==typeof t?t:t+"",void 0,D))(e)})(t):t
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/,{is:
|
|
11
|
+
*/,{is:H,defineProperty:q,getOwnPropertyDescriptor:V,getOwnPropertyNames:W,getOwnPropertySymbols:F,getPrototypeOf:G}=Object,J=globalThis,B=J.trustedTypes,K=B?B.emptyScript:"",Z=J.reactiveElementPolyfillSupport,Q=(t,e)=>t,X={toAttribute(t,e){switch(e){case Boolean:t=t?K:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},Y=(t,e)=>!H(t,e),tt={attribute:!0,type:String,converter:X,reflect:!1,useDefault:!1,hasChanged:Y};Symbol.metadata??=Symbol("metadata"),J.litPropertyMetadata??=new WeakMap;let et=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=tt){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&q(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=V(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const o=i?.call(this);n?.call(this,e),this.requestUpdate(t,o,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??tt}static _$Ei(){if(this.hasOwnProperty(Q("elementProperties")))return;const t=G(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Q("properties"))){const t=this.properties,e=[...W(t),...F(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(z(t))}else void 0!==t&&e.push(z(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(N)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),i=U.litNonce;void 0!==i&&e.setAttribute("nonce",i),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(void 0!==i&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:X).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=s.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:X;this._$Em=i,this[i]=n.fromAttribute(e,t.type)??this._$Ej?.get(i)??null,this._$Em=null}}requestUpdate(t,e,s){if(void 0!==t){const i=this.constructor,n=this[t];if(s??=i.getPropertyOptions(t),!((s.hasChanged??Y)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==n||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t){const{wrapped:t}=s,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,s,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM()}updated(t){}firstUpdated(t){}};et.elementStyles=[],et.shadowRootOptions={mode:"open"},et[Q("elementProperties")]=new Map,et[Q("finalized")]=new Map,Z?.({ReactiveElement:et}),(J.reactiveElementVersions??=[]).push("2.1.0");
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
const
|
|
17
|
+
const st=globalThis,it=st.trustedTypes,nt=it?it.createPolicy("lit-html",{createHTML:t=>t}):void 0,ot="$lit$",rt=`lit$${Math.random().toFixed(9).slice(2)}$`,ht="?"+rt,ct=`<${ht}>`,lt=document,ut=()=>lt.createComment(""),at=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ft=Array.isArray,dt="[ \t\n\f\r]",pt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,yt=/-->/g,vt=/>/g,bt=RegExp(`>|${dt}(?:([^\\s"'>=/]+)(${dt}*=${dt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),mt=/'/g,gt=/"/g,wt=/^(?:script|style|textarea|title)$/i,$t=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),St=$t(1),jt=$t(2),At=Symbol.for("lit-noChange"),Ot=Symbol.for("lit-nothing"),_t=new WeakMap,Et=lt.createTreeWalker(lt,129);function Mt(t,e){if(!ft(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==nt?nt.createHTML(e):e}const kt=(t,e)=>{const s=t.length-1,i=[];let n,o=2===e?"<svg>":3===e?"<math>":"",r=pt;for(let e=0;e<s;e++){const s=t[e];let h,c,l=-1,u=0;for(;u<s.length&&(r.lastIndex=u,c=r.exec(s),null!==c);)u=r.lastIndex,r===pt?"!--"===c[1]?r=yt:void 0!==c[1]?r=vt:void 0!==c[2]?(wt.test(c[2])&&(n=RegExp("</"+c[2],"g")),r=bt):void 0!==c[3]&&(r=bt):r===bt?">"===c[0]?(r=n??pt,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,h=c[1],r=void 0===c[3]?bt:'"'===c[3]?gt:mt):r===gt||r===mt?r=bt:r===yt||r===vt?r=pt:(r=bt,n=void 0);const a=r===bt&&t[e+1].startsWith("/>")?" ":"";o+=r===pt?s+ct:l>=0?(i.push(h),s.slice(0,l)+ot+s.slice(l)+rt+a):s+rt+(-2===l?e:a)}return[Mt(t,o+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class Ct{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const r=t.length-1,h=this.parts,[c,l]=kt(t,e);if(this.el=Ct.createElement(c,s),Et.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=Et.nextNode())&&h.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(ot)){const e=l[o++],s=i.getAttribute(t).split(rt),r=/([.?@])?(.*)/.exec(e);h.push({type:1,index:n,name:r[2],strings:s,ctor:"."===r[1]?Ut:"?"===r[1]?Nt:"@"===r[1]?Dt:Tt}),i.removeAttribute(t)}else t.startsWith(rt)&&(h.push({type:6,index:n}),i.removeAttribute(t));if(wt.test(i.tagName)){const t=i.textContent.split(rt),e=t.length-1;if(e>0){i.textContent=it?it.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],ut()),Et.nextNode(),h.push({type:2,index:++n});i.append(t[e],ut())}}}else if(8===i.nodeType)if(i.data===ht)h.push({type:2,index:n});else{let t=-1;for(;-1!==(t=i.data.indexOf(rt,t+1));)h.push({type:7,index:n}),t+=rt.length-1}n++}}static createElement(t,e){const s=lt.createElement("template");return s.innerHTML=t,s}}function Rt(t,e,s=t,i){if(e===At)return e;let n=void 0!==i?s._$Co?.[i]:s._$Cl;const o=at(e)?void 0:e._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),void 0===o?n=void 0:(n=new o(t),n._$AT(t,s,i)),void 0!==i?(s._$Co??=[])[i]=n:s._$Cl=n),void 0!==n&&(e=Rt(t,n._$AS(t,e.values),n,i)),e}class xt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??lt).importNode(e,!0);Et.currentNode=i;let n=Et.nextNode(),o=0,r=0,h=s[0];for(;void 0!==h;){if(o===h.index){let e;2===h.type?e=new Pt(n,n.nextSibling,this,t):1===h.type?e=new h.ctor(n,h.name,h.strings,this,t):6===h.type&&(e=new Lt(n,this,t)),this._$AV.push(e),h=s[++r]}o!==h?.index&&(n=Et.nextNode(),o++)}return Et.currentNode=lt,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class Pt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=Ot,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Rt(this,t,e),at(t)?t===Ot||null==t||""===t?(this._$AH!==Ot&&this._$AR(),this._$AH=Ot):t!==this._$AH&&t!==At&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>ft(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Ot&&at(this._$AH)?this._$AA.nextSibling.data=t:this.T(lt.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Ct.createElement(Mt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new xt(i,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=_t.get(t.strings);return void 0===e&&_t.set(t.strings,e=new Ct(t)),e}k(t){ft(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new Pt(this.O(ut()),this.O(ut()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class Tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=Ot,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=Ot}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(void 0===n)t=Rt(this,t,e,0),o=!at(t)||t!==this._$AH&&t!==At,o&&(this._$AH=t);else{const i=t;let r,h;for(t=n[0],r=0;r<n.length-1;r++)h=Rt(this,i[s+r],e,r),h===At&&(h=this._$AH[r]),o||=!at(h)||h!==this._$AH[r],h===Ot?t=Ot:t!==Ot&&(t+=(h??"")+n[r+1]),this._$AH[r]=h}o&&!i&&this.j(t)}j(t){t===Ot?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ut extends Tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Ot?void 0:t}}class Nt extends Tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Ot)}}class Dt extends Tt{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=Rt(this,t,e,0)??Ot)===At)return;const s=this._$AH,i=t===Ot&&s!==Ot||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==Ot&&(s===Ot||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class Lt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Rt(this,t)}}const It=st.litHtmlPolyfillSupport;It?.(Ct,Pt),(st.litHtmlVersions??=[]).push("3.3.0");const zt=(t,e,s)=>{const i=s?.renderBefore??e;let n=i._$litPart$;if(void 0===n){const t=s?.renderBefore??null;i._$litPart$=n=new Pt(e.insertBefore(ut(),t),t,void 0,s??{})}return n._$AI(t),n
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/},
|
|
22
|
+
*/},Ht=globalThis;let qt=class extends et{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=zt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return At}};qt._$litElement$=!0,qt.finalized=!0,Ht.litElementHydrateSupport?.({LitElement:qt});const Vt=Ht.litElementPolyfillSupport;Vt?.({LitElement:qt}),(Ht.litElementVersions??=[]).push("4.2.0");
|
|
23
23
|
/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
27
|
*/
|
|
28
|
-
const
|
|
28
|
+
const Wt=2,Ft=5,Gt=t=>(...e)=>({_$litDirective$:t,values:e});class Jt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
29
29
|
/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/class
|
|
33
|
+
*/class Bt extends Jt{constructor(t){if(super(t),this.it=Ot,t.type!==Wt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===Ot||null==t)return this._t=void 0,this.it=t;if(t===At)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}Bt.directiveName="unsafeHTML",Bt.resultType=1;const Kt=Gt(Bt);function Zt(t,e,s){e&&("string"==typeof e?(t._$litPart$||t.replaceChildren(),zt(St`${Kt(e)}`,t)):e._$litType$?(t._$litPart$||t.replaceChildren(),zt(e,t)):(y(t,e,s),t._$litPart$=void 0))}const Qt=Gt(class extends Jt{constructor(t){if(super(t),t.type!==Ft)throw new Error("run() can only be used in event handlers")}update(t,e){const s=t.element,i=t.name,[n,...o]=e,h=()=>{let t=s,e=t._component;for(;!e&&t;)t=t.parentElement,e=t&&t._component;return console.assert(!!e,"Component not found."),e};return"string"==typeof n?s[`on${i}`]=t=>{const e=h();e?e.run(n,...o,t):r.run(n,...o,t)}:"function"==typeof n&&(s[`on${i}`]=t=>h().setState(n(h().state,...o,t))),this.render()}render(){return At}});if(r.createElement=p,r.render=Zt,r.Fragment=a,"object"==typeof window){const t=window;Xt=t,Yt={React:t._React||r,html:St,svg:jt,run:Qt},"object"==typeof Xt&&null!==Xt&&Object.keys(Yt).forEach((t=>{Xt[t]=Yt[t]}))}var Xt,Yt;export{R as Component,P as ROUTER_404_EVENT,x as ROUTER_EVENT,r as app,M as customElement,r as default,_ as event,St as html,E as on,Zt as render,Qt as run,m as safeHTML,jt as svg,_ as update};
|
|
34
34
|
//# sourceMappingURL=apprun-html.esm.js.map
|