apprun 3.36.0 → 3.36.1
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/CHANGELOG.md +28 -0
- package/README.md +133 -20
- package/WHATSNEW.md +20 -12
- package/apprun-book.jpg +0 -0
- package/apprun.d.ts +5 -2
- package/cli/app.js +29 -0
- package/cli/index.html +13 -0
- package/{apprun-cli.js → cli/index.js} +8 -14
- package/dist/apprun-dev-tools.js +1 -2
- 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 +10 -6
- package/esm/app.js.map +1 -1
- package/esm/apprun-dev-tools.js +1 -7
- package/esm/apprun-dev-tools.js.map +1 -1
- package/esm/apprun.js +18 -4
- package/esm/apprun.js.map +1 -1
- package/esm/component.js +4 -0
- package/esm/component.js.map +1 -1
- package/esm/router.js +241 -18
- package/esm/router.js.map +1 -1
- package/esm/vdom-my-new.js +329 -0
- package/esm/vdom-my-new.js.map +1 -0
- package/esm/vdom-my-prop-attr.js +227 -0
- package/esm/vdom-my-prop-attr.js.map +1 -0
- package/esm/vdom-my.js +109 -143
- package/esm/vdom-my.js.map +1 -1
- package/esm/version.js +1 -1
- package/index.html +1 -1
- package/jest.config.js +2 -1
- package/jest.setup.js +29 -3
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.js.map +1 -1
- package/package.json +7 -7
- package/src/app.ts +11 -6
- package/src/apprun-dev-tools.tsx +1 -7
- package/src/apprun.ts +22 -4
- package/src/component.ts +4 -0
- package/src/router.ts +259 -15
- package/src/vdom-my-new.ts +311 -0
- package/src/vdom-my-prop-attr.ts +241 -0
- package/src/vdom-my.ts +109 -134
- package/src/version.ts +1 -1
- package/cli/export.js +0 -92
- package/cli/import.js +0 -68
- package/plan/plan-apprun-bugfixes.md +0 -207
package/dist/apprun-play.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!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={859:(t,e,n)=>{n.d(e,{A:()=>c,q:()=>s});var o=n(672);class s{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;if(!o||"function"!=typeof o)return console.error(`AppRun event handler for '${t}' is not a function:`,o),!1;if(s.delay)this.delay(t,o,e,s);else try{Object.keys(s).length>0?o.apply(this,[...e,s]):o.apply(this,e)}catch(e){console.error(`Error in event handler for '${t}':`,e)}return!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);try{Object.keys(o).length>0?e.apply(this,[...n,o]):e.apply(this,n)}catch(e){console.error(`Error in delayed event handler for '${t}':`,e)}}),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((n=>{const{fn:o,options:s}=n;if(!o||"function"!=typeof o)return console.error(`AppRun async event handler for '${t}' is not a function:`,o),Promise.resolve(null);try{return Object.keys(s).length>0?o.apply(this,[...e,s]):o.apply(this,e)}catch(e){return console.error(`Error in async event handler for '${t}':`,e),Promise.reject(e)}}));return Promise.all(o)}query(t,...e){return this.runAsync(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}}const r=o.C;let i;const a="undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};a.app&&a._AppRunVersions?i=a.app:(i=new s,a.app=i,a._AppRunVersions=r);const c=i},466:(t,e,n)=>{n.d(e,{Component:()=>p,app:()=>o.A});var o=n(859),s=n(320);const r=(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 r={};Array.from(this.attributes).forEach((t=>r[this._attrMap(t.name)]=t.value)),o.forEach((t=>{void 0!==this[t]&&(r[t]=this[t]),Object.defineProperty(this,t,{get:()=>r[t],set(e){this.attributeChangedCallback(t,r[t],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},r),{children:e})).mount(this._shadowRoot,n),this._component._props=r,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(r,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(".")}))}}},i=(t,e,n)=>{"undefined"!=typeof customElements&&customElements.define(t,r(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(741),l=n(634);const u=new Map;o.A.find("get-components")||o.A.on("get-components",(t=>t.components=u));const d=t=>t;class p{renderState(t,e=null){if(!this.view)return;let n=e||this.view(t);if(o.A.debug&&o.A.run("debug",{component:this,_:n?".":"-",state:t,vdom:n,el:this.element}),"object"!=typeof document)return;const s="string"==typeof this.element&&this.element?(0,l.oP)(this.element)||(0,l.bV)(this.element):this.element;if(!s)return void console.warn(`Component element not found: ${this.element}`);const r="_c";this.unload?s._component===this&&s.getAttribute(r)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),s.setAttribute(r,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:[r]}))):s.removeAttribute&&s.removeAttribute(r),s._component=this,!e&&n&&(n=(0,c.A)(n,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>o.A.render(s,n,this))):o.A.render(s,n,this)),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){const n=t;if(null==n?void 0:n[Symbol.asyncIterator])this.setState((async t=>{try{for(;;){const{value:n,done:o}=await t.next();if(o)break;this.setState(n,e)}}catch(t){console.error("Error in async iterator:",t)}})(n[Symbol.asyncIterator]()),e);else if((null==n?void 0:n[Symbol.iterator])&&"function"==typeof n.next)for(const t of n)this.setState(t,e);else if(t&&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.q,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 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]=d)),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.A.debug&&(u.get(t)?u.get(t).push(this):u.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.A.debug&&o.A.run("debug",{component:this,_:">",event:t,p:s,current_state:this.state,options:n});try{const r=e(this.state,...s);o.A.debug&&o.A.run("debug",{component:this,_:"<",event:t,p:s,newState:r,state:this.state,options:n}),this.setState(r,n)}catch(e){console.error(`Error in component action '${t}':`,e),o.A.debug&&o.A.run("debug",{component:this,_:"!",event:t,p:s,error:e,state:this.state,options:n})}}),n)):console.warn(`Component action for '${t}' is not a valid function:`,e)}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["."]=d),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.A.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.A.on(s,e,n):this._app.on(s,e,n)}runAsync(t,...e){const n=t.toString();return this.is_global_event(n)?o.A.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.A.off(e,n):this._app.off(e,n)}))}}p.__isAppRunComponent=!0;const h="//",f="///",m=t=>{if(o.A.lastUrl!==t)if(o.A.lastUrl=t,t||(t="#"),t.startsWith("#")){const[e,...n]=t.split("/");o.A.run(e,...n)||o.A.run(f,e,...n),o.A.run(h,e,...n)}else if(t.startsWith("/")){const[e,n,...s]=t.split("/");o.A.run("/"+n,...s)||o.A.run(f,"/"+n,...s),o.A.run(h,"/"+n,...s)}else o.A.run(t)||o.A.run(f,t),o.A.run(h,t)};var y=n(672);if(!o.A.start){o.A.version=y.a,o.A.h=o.A.createElement=s.createElement,o.A.render=s.render,o.A.Fragment=s.Fragment,o.A.webComponent=i,o.A.safeHTML=s.safeHTML,o.A.start=(t,e,n,o,s)=>{const r=Object.assign({render:!0,global_event:!0},s),i=new p(e,n,o);return s&&s.rendered&&(i.rendered=s.rendered),s&&s.mounted&&(i.mounted=s.mounted),i.start(t,r),i},o.A.once=o.A.once||((t,e,n={})=>{o.A.on(t,e,Object.assign(Object.assign({},n),{once:!0}))}),o.A.query=o.A.query||o.A.runAsync;const t=t=>{};if(o.A.on("debug",(e=>t)),o.A.on(h,t),o.A.on(f,t),o.A.route=m,o.A.on("route",(t=>o.A.route&&o.A.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{const t=document.body.hasAttribute("apprun-no-init")||o.A["no-init-route"]||!1,e=o.A.find("#")||o.A.find("#/")||!1;window.addEventListener("hashchange",(()=>m(location.hash))),window.addEventListener("popstate",(()=>m(location.pathname))),e?!t&&m(location.hash):(!t&&m(location.pathname),document.body.addEventListener("click",(t=>{const e=t.target;if(!e)return;const n="A"===e.tagName?e:e.closest("a");n&&n.origin===location.origin&&n.pathname&&(t.preventDefault(),history.pushState(null,"",n.pathname),m(n.pathname))})))})),"object"==typeof window){const t=window;t.Component=p,t._React=t.React,t.React=o.A,t.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)}},t.customElement=function(t,e){return function(n){return i(t,n,e),n}},t.safeHTML=s.safeHTML}o.A.use_render=(t,e=0)=>{o.A.render=0===e?(e,n)=>t(n,e):(e,n)=>t(e,n)},o.A.use_react=(t,e)=>{if(t&&e)if("function"==typeof t.createElement)if(t.Fragment)if(o.A.h=o.A.createElement=t.createElement,o.A.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+");o.A.render=(t,n)=>{t&&void 0!==n&&(t._root||(t._root=e.createRoot(t)),t._root.render(n))}}else{if(!e.render||"function"!=typeof e.render)return void console.error("AppRun use_react: ReactDOM.render not found in legacy React");o.A.render=(t,n)=>e.render(n,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")}}},741:(t,e,n)=>{n.d(e,{A:()=>c});var o=n(859),s=n(634);const r=(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)},a=(t,e)=>{if(Array.isArray(t))return t.map((t=>a(t,e)));{let{type:n,tag:c,props:l,children:u}=t;return c=c||n,u=u||(null==l?void 0:l.children),l&&Object.keys(l).forEach((t=>{t.startsWith("$")&&(((t,e,n,a)=>{if(t.startsWith("$on")){const n=e[t];if(t=t.substring(1),"boolean"==typeof n)e[t]=e=>a.run?a.run(t,e):o.A.run(t,e);else if("string"==typeof n)e[t]=t=>a.run?a.run(n,t):o.A.run(n,t);else if("function"==typeof n)e[t]=t=>a.setState(n(a.state,t));else if(Array.isArray(n)){const[s,...r]=n;"string"==typeof s?e[t]=t=>a.run?a.run(s,...r,t):o.A.run(s,...r,t):"function"==typeof s&&(e[t]=t=>a.setState(s(a.state,...r,t)))}}else if("$bind"===t){const o=e.type||"text",c="string"==typeof e[t]?e[t]:e.name;if("input"===n)switch(o){case"checkbox":e.checked=r(a,c),e.onclick=t=>{const e=(0,s.PB)(t);e&&i(a,c||e.name,e.checked)};break;case"radio":e.checked=r(a,c)===e.value,e.onclick=t=>{const e=(0,s.PB)(t);e&&i(a,c||e.name,e.value)};break;case"number":case"range":e.value=r(a,c),e.oninput=t=>{const e=(0,s.PB)(t);e&&i(a,c||e.name,Number(e.value))};break;default:e.value=r(a,c),e.oninput=t=>{const e=(0,s.PB)(t);e&&i(a,c||e.name,e.value)}}else"select"===n?(e.value=r(a,c),e.onchange=t=>{const e=(0,s.PB)(t);e&&!e.multiple&&i(a,c||e.name,e.value)}):"option"===n?(e.selected=r(a,c),e.onclick=t=>{const e=(0,s.PB)(t);e&&i(a,c||e.name,e.selected)}):"textarea"===n&&(e.innerHTML=r(a,c),e.oninput=t=>{const e=(0,s.PB)(t);e&&i(a,c||e.name,e.value)})}else o.A.run("$",{key:t,tag:n,props:e,component:a})})(t,l,c,e),delete l[t])})),u&&a(u,e),t}},c=a},634:(t,e,n)=>{function o(t){return(null==t?void 0:t.target)instanceof HTMLElement?t.target:null}function s(t,e=document){try{return e.querySelector(t)}catch(e){return console.warn(`Invalid selector: ${t}`,e),null}}function r(t){try{return document.getElementById(t)}catch(e){return console.warn(`Error getting element by id: ${t}`,e),null}}n.d(e,{PB:()=>o,bV:()=>s,oP:()=>r})},791:(t,e,n)=>{n.d(e,{FK:()=>s,cJ:()=>l,n:()=>a,t_:()=>p});var o=n(741);function s(t,...e){return i(e)}const r="_props";function i(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=i(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={},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)?d(t,e,o):d(t,[e],o)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,e=(0,o.A)(e,n),n)};function u(t,e,n){n=n||"svg"===e.tag,function(t,e){const n=t.nodeName,o=`${e.tag||""}`;return n.toUpperCase()===o.toUpperCase()}(t,e)?(d(t,e.children,n),m(t,e.props,n)):t.parentNode.replaceChild(f(e,n),t)}function d(t,e,n){var o;const s=(null===(o=t.childNodes)||void 0===o?void 0:o.length)||0,r=(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 o=new Map;for(let e=0;e<s;e++){const n=t.childNodes[e];n&&n.key&&o.set(n.key,n)}const i=document.createDocumentFragment();for(let t=0;t<r;t++){const s=e[t];if(null==s)continue;const r=s.props&&s.props.key;if(r&&o.has(r)){const t=o.get(r);u(t,s,n),i.appendChild(t),o.delete(r)}else i.appendChild(f(s,n))}for(;t.firstChild;)t.removeChild(t.firstChild);return void t.appendChild(i)}const i=Math.min(s,r);for(let o=0;o<i;o++){const s=e[o];if(null==s)continue;const r=t.childNodes[o];r&&("string"==typeof s?3===r.nodeType?r.nodeValue!==s&&(r.nodeValue=s):t.replaceChild(h(s),r):s instanceof HTMLElement||s instanceof SVGElement?t.replaceChild(s,r):s&&"object"==typeof s&&u(t.childNodes[o],s,n))}for(;t.childNodes.length>i;)t.removeChild(t.lastChild);if(r>i){const o=document.createDocumentFragment();for(let t=i;t<e.length;t++){const s=e[t];null!=s&&o.appendChild(f(s,n))}t.appendChild(o)}}const p=t=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",t),Array.from(e.children)};function h(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 f(t,e){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return h(t);if(!t||"object"!=typeof t||!t.tag||"function"==typeof t.tag)return h("object"==typeof t?JSON.stringify(t):String(null!=t?t:""));const n=(e=e||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return m(n,t.props,e),t.children&&t.children.forEach((t=>n.appendChild(f(t,e)))),n}function m(t,e,n){const o=t[r]||{};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[r]=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&&void 0!==s&&(c[s]=t,t.key=s)}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:r}=t;let i=`_${n}`,a=s&&s.id;a?i=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[i];if(l&&l instanceof o&&l.element)l.renderState(l.state);else{const t=document.createElement(c);l=e.__componentCache[i]=new o(Object.assign(Object.assign({},s),{children:r})).mount(t,{render:!0})}if(l.mounted){const t=l.mounted(s,r,l.state);void 0!==t&&l.setState(t)}return m(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}},320:(t,e,n)=>{n.d(e,{Fragment:()=>o.FK,createElement:()=>o.n,render:()=>o.cJ,safeHTML:()=>o.t_});var o=n(791)},672:(t,e,n)=>{n.d(e,{C:()=>s,a:()=>o});const o="3.36.0",s=`AppRun-${o}`}},e={};function n(o){var s=e[o];if(void 0!==s)return s.exports;var r=e[o]={exports:{}};return t[o](r,r.exports,n),r.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={};n.r(o);var s=n(466);const r=(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 r=null===(o=(e=s).contentWindow)||void 0===o?void 0:o.document;r&&(r.open(),t.indexOf("<html")>=0?r.write(t):r.write((t=>`<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <meta http-equiv="X-UA-Compatible" content="ie=edge">\n <script src="https://cdnjs.cloudflare.com/ajax/libs/custom-elements/1.1.2/custom-elements.min.js"><\/script>\n <title>AppRun Playground</title>\n <style>\n body {\n font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;\n margin: 2em;\n }\n </style>\n <script src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>\n <script src="https://unpkg.com/apprun/dist/apprun-html.js"><\/script>\n</head>\n<body>\n<script>\n Babel.registerPlugin("d", [Babel.availablePlugins["proposal-decorators"], {legacy: true}]);\n Babel.registerPlugin("c", [Babel.availablePlugins["proposal-class-properties"], {loose: true}]);\n Babel.registerPlugin("b", [Babel.availablePlugins["proposal-private-methods"], {loose: true}]);\n<\/script>\n<script type="text/babel" data-plugins="d, c, b">\n ${t}\n<\/script>\n</body>\n</html>`)(t)),r.close())};s(n),!o&&t&&"TEXTAREA"===t.nodeName&&("undefined"==typeof CodeMirror?t.onkeyup=()=>s(t.value):t.editor||(t.editor=CodeMirror.fromTextArea(t,{lineNumbers:!0,mode:"jsx"}),t.editor.on("change",(t=>s(t.getValue())))))};class i extends s.Component{constructor(){super(...arguments),this.view=t=>{const e=t["code-element-id"],n=this.element;let o,r;return o=e?document.getElementById(e):n.previousElementSibling||n.parentElement.previousElementSibling,r=(null==o?void 0:o.innerText)||(null==o?void 0:o.value)||t.code,this.state.code_area=o,this.state.code=r,r?s.app.h(s.app.Fragment,null,s.app.h("div",{class:"toolbox"},!t.hide_button&&s.app.h("a",{class:"button",$onclick:"show-popup"},"Try the Code"))):s.app.h("div",null,"AppRun Play cannot find code to run, please set code-element-id or code.")},this.rendered=({style:t,hide_src:e,code_area:n,code:o})=>{if(!o)return;if(!document.getElementById("play-popup")){document.body.insertAdjacentHTML("beforeend",'<div id="play-popup" class="overlay">\n<style id="apprun-play-style">\n.apprun-play .col {\n height: 100%;\n flex: 1;\n}\n.apprun-preview {\n width: 100%\n}\n.apprun-play .editor, .apprun-play .preview {\n display: inline-block;\n width: calc(100% - 20px);\n height: calc(100% - 10px);\n}\n\na.button {\n font-size: .8em;\n padding: 10px;\n cursor: pointer;\n color: var(--md-primary-bg-color);\n background: var(--md-primary-fg-color)\n}\na.button:hover {\n color: var(--md-primary-fg-color);\n background: var(--md-primary-bg-color)\n}\n\n.overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n visibility: hidden;\n opacity: 0;\n z-index: 999;\n}\n.overlay.show {\n visibility: visible;\n opacity: 1;\n}\n\n.popup {\n margin: 80px auto;\n padding: 20px;\n background: #fff;\n border-radius: 3px;\n position: relative;\n width: 90%;\n height: calc(100% - 150px);\n}\n\n.popup .close {\n position: absolute;\n top: 10px;\n right: 20px;\n font-size: 20px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n}\n.popup .close:hover {\n color: #06D85F;\n}\n.popup .content {\n height: 100%;\n overflow: hidden;\n display: flex;\n}\n\n.cm-s-default {\n height: 100%;\n font-size: small;\n line-height: 1.5em;\n z-index: 0;\n}\n</style>\n\n\t<div class="popup apprun-play">\n\t\t<a class="close" href="javascript:app.run(\'@close-popup\')">×</a>\n\t\t<div class="content">\n\t\t\t<div class="col">\n <textarea class="editor"></textarea>\n </div>\n <div class="col">\n <iframe class="preview"/>\n </div>\n </div>\n\t</div>\n</div>');const t=document.querySelector(".apprun-play .editor"),e=document.querySelector(".apprun-play .preview");t.value=o,r(t,e,o,!1)}const s=document.createElement("iframe");s.classList.add("apprun-preview"),s.style.cssText=t,this.element.before(s),e&&(n.style.display="none"),r(n,s,o,e)},this.update={"show-popup":({code:t})=>{var e;null===(e=document.querySelector(".apprun-play .editor").editor)||void 0===e||e.setValue(t),document.getElementById("play-popup").classList.add("show")},"@close-popup":()=>{document.getElementById("play-popup").classList.remove("show")}}}}return s.app.webComponent("apprun-play",i),o})()));
|
|
1
|
+
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apprun=e():n.apprun=e()}(this,(()=>(()=>{"use strict";var n={859:(n,e,t)=>{t.d(e,{A:()=>s,q:()=>l});var o=t(672);class l{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:o,options:l}=t;if(!o||"function"!=typeof o)return console.error(`AppRun event handler for '${n}' is not a function:`,o),!1;if(l.delay)this.delay(n,o,e,l);else try{Object.keys(l).length>0?o.apply(this,[...e,l]):o.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,Object.assign(Object.assign({},t),{once:!0}))}delay(n,e,t,o){o._t&&clearTimeout(o._t),o._t=setTimeout((()=>{clearTimeout(o._t);try{Object.keys(o).length>0?e.apply(this,[...t,o]):e.apply(this,t)}catch(e){console.error(`Error in delayed event handler for '${n}':`,e)}}),o.delay)}runAsync(n,...e){const t=this.getSubscribers(n,this._events);console.assert(t&&t.length>0,"No subscriber for event: "+n);const o=t.map((t=>{const{fn:o,options:l}=t;if(!o||"function"!=typeof o)return console.error(`AppRun async event handler for '${n}' is not a function:`,o),Promise.resolve(null);try{return Object.keys(l).length>0?o.apply(this,[...e,l]):o.apply(this,e)}catch(e){return console.error(`Error in async event handler for '${n}':`,e),Promise.reject(e)}}));return Promise.all(o)}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((o=>t.push(...e[o].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:n})})))))),t}}const r=o.C;let i;const a="undefined"!=typeof window?window:void 0!==t.g?t.g:"undefined"!=typeof self?self:{};a.app&&a._AppRunVersions?i=a.app:(i=new l,a.app=i,a._AppRunVersions=r);const s=i},466:(n,e,t)=>{t.d(e,{Component:()=>p,app:()=>o.A});var o=t(859),l=t(320);const r=(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 o=t.observedAttributes||[],l=o.reduce(((n,e)=>{const t=e.toLowerCase();return t!==e&&(n[t]=e),n}),{});this._attrMap=n=>l[n]||n;const r={};Array.from(this.attributes).forEach((n=>r[this._attrMap(n.name)]=n.value)),o.forEach((n=>{void 0!==this[n]&&(r[n]=this[n]),Object.defineProperty(this,n,{get:()=>r[n],set(e){this.attributeChangedCallback(n,r[n],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new n(Object.assign(Object.assign({},r),{children:e})).mount(this._shadowRoot,t),this._component._props=r,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const n=this._component.mounted(r,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(){var n,e,t,o;null===(e=null===(n=this._component)||void 0===n?void 0:n.unload)||void 0===e||e.call(n),null===(o=null===(t=this._component)||void 0===t?void 0:t.unmount)||void 0===o||o.call(t),this._component=null}attributeChangedCallback(n,t,o){if(this._component){const l=this._attrMap(n);this._component._props[l]=o,this._component.run("attributeChanged",l,t,o),o!==t&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}},i=(n,e,t)=>{"undefined"!=typeof customElements&&customElements.define(n,r(e,t))},a={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}};var s=t(741),u=t(634);const c=new Map;o.A.find("get-components")||o.A.on("get-components",(n=>n.components=c));const d=n=>n;class p{renderState(n,e=null){if(!this.view)return;let t=e||this.view(n);if(o.A.debug&&o.A.run("debug",{component:this,_:t?".":"-",state:n,vdom:t,el:this.element}),"object"!=typeof document)return;const l="string"==typeof this.element&&this.element?(0,u.oP)(this.element)||(0,u.bV)(this.element):this.element;if(!l)return void console.warn(`Component element not found: ${this.element}`);const r="_c";this.unload?l._component===this&&l.getAttribute(r)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),l.setAttribute(r,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:[r]}))):l.removeAttribute&&l.removeAttribute(r),l._component=this,!e&&t&&(t=(0,s.A)(t,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>o.A.render(l,t,this))):o.A.render(l,t,this)),this.rendered&&this.rendered(this.state)}setState(n,e={render:!0,history:!1}){const t=n;if(null==t?void 0:t[Symbol.asyncIterator])this.setState((async n=>{try{for(;;){const{value:t,done:o}=await n.next();if(o)break;this.setState(t,e)}}catch(n){console.error("Error in async iterator:",n)}})(t[Symbol.asyncIterator]()),e);else if((null==t?void 0:t[Symbol.iterator])&&"function"==typeof t.next)for(const n of t)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,t,l){this.state=n,this.view=e,this.update=t,this.options=l,this._app=new o.q,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,Object.assign({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){var t,l;return console.assert(!this.element,"Component already mounted."),this.options=e=Object.assign(Object.assign({},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]=d)),this.add_actions(),this.state=null!==(l=null!==(t=this.state)&&void 0!==t?t:this.model)&&void 0!==l?l:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),o.A.debug&&(c.get(n)?c.get(n).push(this):c.set(n,[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)=>{o.A.debug&&o.A.run("debug",{component:this,_:">",event:n,p:l,current_state:this.state,options:t});try{const r=e(this.state,...l);o.A.debug&&o.A.run("debug",{component:this,_:"<",event:n,p:l,newState:r,state:this.state,options:t}),this.setState(r,t)}catch(e){console.error(`Error in component action '${n}':`,e),o.A.debug&&o.A.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||{};a.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const t=a.getMetadata(e,this);n[t.name]=[this[t.key].bind(this),t.options]}}));const e={};Array.isArray(n)?n.forEach((n=>{const[t,o,l]=n;t.toString().split(",").forEach((n=>e[n.trim()]=[o,l]))})):Object.keys(n).forEach((t=>{const o=n[t];("function"==typeof o||Array.isArray(o))&&t.split(",").forEach((n=>e[n.trim()]=o))})),e["."]||(e["."]=d),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)?o.A.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)?o.A.on(l,e,t):this._app.on(l,e,t)}runAsync(n,...e){const t=n.toString();return this.is_global_event(t)?o.A.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(){var n;null===(n=this.observer)||void 0===n||n.disconnect(),this._actions.forEach((n=>{const{name:e,fn:t}=n;this.is_global_event(e)?o.A.off(e,t):this._app.off(e,t)}))}}function h(){const n=o.A.find("#");if(n&&n.length>0)return o.A.run("#"),void o.A.run(g,"#");const e=o.A.find("/");if(e&&e.length>0)return o.A.run("/"),void o.A.run(g,"/");const t=o.A.find("#/");if(t&&t.length>0)return o.A.run("#/"),void o.A.run(g,"#/");console.warn("No subscribers for event: "),o.A.run(m,""),o.A.run(g,"")}p.__isAppRunComponent=!0;const f=(n,...e)=>{if(!n||n===g||n===m)return;const t=o.A.find(n);t&&0!==t.length?o.A.run(n,...e):(console.warn(`No subscribers for event: ${n}`),o.A.run(m,n,...e)),o.A.run(g,n,...e)},g="//",m="///",y=n=>{o.A.lastUrl!==n&&(o.A.lastUrl=n,function(n){if(!n)return void h();n=function(n){return n&&"/"!==n&&"#"!==n&&"#/"!==n&&n.endsWith("/")?n.slice(0,-1):n}(n);const e=o.A.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 r=function(n,e){const t=[];for(let o=n.length;o>0;o--){const l=n.slice(0,o);let r="";switch(e){case"path":r="/"+l.join("/");break;case"hash":r="#"+l.join("/");break;case"hash-slash":r="#/"+l.join("/");break;case"non-prefixed":r=l.join("/")}t.push(r)}return t}(t,l),i=function(n,e){for(let t=0;t<n.length;t++){const l=n[t],r=o.A.find(l);if(r&&r.length>0){const o=n.length-t;return{eventName:l,parameters:e.slice(o)}}}return null}(r,t);if(i)f(i.eventName,...i.parameters);else if(r.length>0){const e=r[r.length-1];console.warn(`No subscribers for event: ${e}`),o.A.run(m,n),o.A.run(g,n)}else h()}(n))};var v=t(672);if(!o.A.start){o.A.version=v.a,o.A.h=o.A.createElement=l.createElement,o.A.render=l.render,o.A.Fragment=l.Fragment,o.A.webComponent=i,o.A.safeHTML=l.safeHTML,o.A.start=(n,e,t,o,l)=>{const r=Object.assign({render:!0,global_event:!0},l),i=new p(e,t,o);return l&&l.rendered&&(i.rendered=l.rendered),l&&l.mounted&&(i.mounted=l.mounted),i.start(n,r),i},o.A.once=o.A.once||((n,e,t={})=>{o.A.on(n,e,Object.assign(Object.assign({},t),{once:!0}))}),o.A.query=o.A.query||o.A.runAsync;const n=n=>{};if(o.A.on("/",n),o.A.on("debug",(e=>n)),o.A.on(g,n),o.A.on(m,n),o.A.route=y,o.A.on("route",(n=>o.A.route&&o.A.route(n))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{const n=document.body.hasAttribute("apprun-no-init")||o.A["no-init-route"]||!1,e=o.A.find("#")||o.A.find("#/")||!1;window.addEventListener("hashchange",(()=>y(location.hash))),window.addEventListener("popstate",(()=>y(location.pathname))),e?!n&&y(location.hash):(!n&&(()=>{const n=o.A.basePath||"";let e=location.pathname;n&&e.startsWith(n)&&(e=e.substring(n.length),e.startsWith("/")||(e="/"+e)),y(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=(o.A.basePath||"")+t.pathname;history.pushState(null,"",e),y(t.pathname)}})))})),"object"==typeof window){const n=window;n.Component=p,n._React=n.React,n.React=o.A,n.on=function(n,e={}){return function(t,o){const l=n?n.toString():o;a.defineMetadata(`apprun-update:${l}`,{name:l,key:o,options:e},t)}},n.customElement=function(n,e){return function(t){return i(n,t,e),t}},n.safeHTML=l.safeHTML}o.A.use_render=(n,e=0)=>{o.A.render=0===e?(e,t)=>n(t,e):(e,t)=>n(e,t)},o.A.use_react=(n,e)=>{if(n&&e)if("function"==typeof n.createElement)if(n.Fragment)if(o.A.h=o.A.createElement=n.createElement,o.A.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+");o.A.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");o.A.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")}}},741:(n,e,t)=>{t.d(e,{A:()=>s});var o=t(859),l=t(634);const r=(n,e)=>(e?n.state[e]:n.state)||"",i=(n,e,t)=>{if(e){const o=n.state||{};o[e]=t,n.setState(o)}else n.setState(t)},a=(n,e)=>{if(Array.isArray(n))return n.map((n=>a(n,e)));{let{type:t,tag:s,props:u,children:c}=n;return s=s||t,c=c||(null==u?void 0:u.children),u&&Object.keys(u).forEach((n=>{n.startsWith("$")&&(((n,e,t,a)=>{if(n.startsWith("$on")){const t=e[n];if(n=n.substring(1),"boolean"==typeof t)e[n]=e=>a.run?a.run(n,e):o.A.run(n,e);else if("string"==typeof t)e[n]=n=>a.run?a.run(t,n):o.A.run(t,n);else if("function"==typeof t)e[n]=n=>a.setState(t(a.state,n));else if(Array.isArray(t)){const[l,...r]=t;"string"==typeof l?e[n]=n=>a.run?a.run(l,...r,n):o.A.run(l,...r,n):"function"==typeof l&&(e[n]=n=>a.setState(l(a.state,...r,n)))}}else if("$bind"===n){const o=e.type||"text",s="string"==typeof e[n]?e[n]:e.name;if("input"===t)switch(o){case"checkbox":e.checked=r(a,s),e.onclick=n=>{const e=(0,l.PB)(n);e&&i(a,s||e.name,e.checked)};break;case"radio":e.checked=r(a,s)===e.value,e.onclick=n=>{const e=(0,l.PB)(n);e&&i(a,s||e.name,e.value)};break;case"number":case"range":e.value=r(a,s),e.oninput=n=>{const e=(0,l.PB)(n);e&&i(a,s||e.name,Number(e.value))};break;default:e.value=r(a,s),e.oninput=n=>{const e=(0,l.PB)(n);e&&i(a,s||e.name,e.value)}}else"select"===t?(e.value=r(a,s),e.onchange=n=>{const e=(0,l.PB)(n);e&&!e.multiple&&i(a,s||e.name,e.value)}):"option"===t?(e.selected=r(a,s),e.onclick=n=>{const e=(0,l.PB)(n);e&&i(a,s||e.name,e.selected)}):"textarea"===t&&(e.innerHTML=r(a,s),e.oninput=n=>{const e=(0,l.PB)(n);e&&i(a,s||e.name,e.value)})}else o.A.run("$",{key:n,tag:t,props:e,component:a})})(n,u,s,e),delete u[n])})),c&&a(c,e),n}},s=a},634:(n,e,t)=>{function o(n){return(null==n?void 0:n.target)instanceof HTMLElement?n.target:null}function l(n,e=document){try{return e.querySelector(n)}catch(e){return console.warn(`Invalid selector: ${n}`,e),null}}function r(n){try{return document.getElementById(n)}catch(e){return console.warn(`Error getting element by id: ${n}`,e),null}}t.d(e,{PB:()=>o,bV:()=>l,oP:()=>r})},593:(n,e,t)=>{t.d(e,{FK:()=>$,n:()=>Y,t_:()=>Q,cJ:()=>J});var o={};t.r(o),t.d(o,{boolean:()=>a,booleanish:()=>s,commaOrSpaceSeparated:()=>h,commaSeparated:()=>p,number:()=>c,overloadedBoolean:()=>u,spaceSeparated:()=>d});var l=t(741);class r{constructor(n,e){this.attribute=e,this.property=n}}r.prototype.attribute="",r.prototype.booleanish=!1,r.prototype.boolean=!1,r.prototype.commaOrSpaceSeparated=!1,r.prototype.commaSeparated=!1,r.prototype.defined=!1,r.prototype.mustUseProperty=!1,r.prototype.number=!1,r.prototype.overloadedBoolean=!1,r.prototype.property="",r.prototype.spaceSeparated=!1,r.prototype.space=void 0;let i=0;const a=f(),s=f(),u=f(),c=f(),d=f(),p=f(),h=f();function f(){return 2**++i}const g=Object.keys(o);class m extends r{constructor(n,e,t,l){let r=-1;if(super(n,e),y(this,"space",l),"number"==typeof t)for(;++r<g.length;){const n=g[r];y(this,g[r],(t&o[n])===o[n])}}}function y(n,e,t){t&&(n[e]=t)}function v(n){return n.toLowerCase()}m.prototype.defined=!0;const b=/[A-Z]/g,A=/-[a-z]/g,k=/^data[-\w.:]+$/i;function w(n){return"-"+n.toLowerCase()}function _(n){return n.charAt(1).toUpperCase()}class S{constructor(n,e,t){this.normal=e,this.property=n,t&&(this.space=t)}}function x(n,e){const t={},o={};for(const e of n)Object.assign(t,e.property),Object.assign(o,e.normal);return new S(t,o,e)}function C(n){const e={},t={};for(const[o,l]of Object.entries(n.properties)){const r=new m(o,n.transform(n.attributes||{},o),l,n.space);n.mustUseProperty&&n.mustUseProperty.includes(o)&&(r.mustUseProperty=!0),e[o]=r,t[v(o)]=o,t[v(r.attribute)]=o}return new S(e,t,n.space)}S.prototype.normal={},S.prototype.property={},S.prototype.space=void 0;const O=C({properties:{ariaActiveDescendant:null,ariaAtomic:s,ariaAutoComplete:null,ariaBusy:s,ariaChecked:s,ariaColCount:c,ariaColIndex:c,ariaColSpan:c,ariaControls:d,ariaCurrent:null,ariaDescribedBy:d,ariaDetails:null,ariaDisabled:s,ariaDropEffect:d,ariaErrorMessage:null,ariaExpanded:s,ariaFlowTo:d,ariaGrabbed:s,ariaHasPopup:null,ariaHidden:s,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:d,ariaLevel:c,ariaLive:null,ariaModal:s,ariaMultiLine:s,ariaMultiSelectable:s,ariaOrientation:null,ariaOwns:d,ariaPlaceholder:null,ariaPosInSet:c,ariaPressed:s,ariaReadOnly:s,ariaRelevant:null,ariaRequired:s,ariaRoleDescription:d,ariaRowCount:c,ariaRowIndex:c,ariaRowSpan:c,ariaSelected:s,ariaSetSize:c,ariaSort:null,ariaValueMax:c,ariaValueMin:c,ariaValueNow:c,ariaValueText:null,role:null},transform:(n,e)=>"role"===e?e:"aria-"+e.slice(4).toLowerCase()});function P(n,e){return e in n?n[e]:e}function E(n,e){return P(n,e.toLowerCase())}const M=C({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:p,acceptCharset:d,accessKey:d,action:null,allow:null,allowFullScreen:a,allowPaymentRequest:a,allowUserMedia:a,alt:null,as:null,async:a,autoCapitalize:null,autoComplete:d,autoFocus:a,autoPlay:a,blocking:d,capture:null,charSet:null,checked:a,cite:null,className:d,cols:c,colSpan:null,content:null,contentEditable:s,controls:a,controlsList:d,coords:c|p,crossOrigin:null,data:null,dateTime:null,decoding:null,default:a,defer:a,dir:null,dirName:null,disabled:a,download:u,draggable:s,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:a,formTarget:null,headers:d,height:c,hidden:u,high:c,href:null,hrefLang:null,htmlFor:d,httpEquiv:d,id:null,imageSizes:null,imageSrcSet:null,inert:a,inputMode:null,integrity:null,is:null,isMap:a,itemId:null,itemProp:d,itemRef:d,itemScope:a,itemType:d,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:a,low:c,manifest:null,max:null,maxLength:c,media:null,method:null,min:null,minLength:c,multiple:a,muted:a,name:null,nonce:null,noModule:a,noValidate:a,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:a,optimum:c,pattern:null,ping:d,placeholder:null,playsInline:a,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:a,referrerPolicy:null,rel:d,required:a,reversed:a,rows:c,rowSpan:c,sandbox:d,scope:null,scoped:a,seamless:a,selected:a,shadowRootClonable:a,shadowRootDelegatesFocus:a,shadowRootMode:null,shape:null,size:c,sizes:null,slot:null,span:c,spellCheck:s,src:null,srcDoc:null,srcLang:null,srcSet:null,start:c,step:null,style:null,tabIndex:c,target:null,title:null,translate:null,type:null,typeMustMatch:a,useMap:null,value:s,width:c,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:d,axis:null,background:null,bgColor:null,border:c,borderColor:null,bottomMargin:c,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:a,declare:a,event:null,face:null,frame:null,frameBorder:null,hSpace:c,leftMargin:c,link:null,longDesc:null,lowSrc:null,marginHeight:c,marginWidth:c,noResize:a,noHref:a,noShade:a,noWrap:a,object:null,profile:null,prompt:null,rev:null,rightMargin:c,rules:null,scheme:null,scrolling:s,standby:null,summary:null,text:null,topMargin:c,valueType:null,version:null,vAlign:null,vLink:null,vSpace:c,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:a,disableRemotePlayback:a,prefix:null,property:null,results:c,security:null,unselectable:null},space:"html",transform:E}),L=C({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:h,accentHeight:c,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:c,amplitude:c,arabicForm:null,ascent:c,attributeName:null,attributeType:null,azimuth:c,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:c,by:null,calcMode:null,capHeight:c,className:d,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:c,diffuseConstant:c,direction:null,display:null,dur:null,divisor:c,dominantBaseline:null,download:a,dx:null,dy:null,edgeMode:null,editable:null,elevation:c,enableBackground:null,end:null,event:null,exponent:c,externalResourcesRequired:null,fill:null,fillOpacity:c,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:p,g2:p,glyphName:p,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:c,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:c,horizOriginX:c,horizOriginY:c,id:null,ideographic:c,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:c,k:c,k1:c,k2:c,k3:c,k4:c,kernelMatrix:h,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:c,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:c,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:c,overlineThickness:c,paintOrder:null,panose1:null,path:null,pathLength:c,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:d,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:c,pointsAtY:c,pointsAtZ:c,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:h,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:h,rev:h,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:h,requiredFeatures:h,requiredFonts:h,requiredFormats:h,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:c,specularExponent:c,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:c,strikethroughThickness:c,string:null,stroke:null,strokeDashArray:h,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:c,strokeOpacity:c,strokeWidth:null,style:null,surfaceScale:c,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:h,tabIndex:c,tableValues:null,target:null,targetX:c,targetY:c,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:h,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:c,underlineThickness:c,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:c,values:null,vAlphabetic:c,vMathematical:c,vectorEffect:null,vHanging:c,vIdeographic:c,version:null,vertAdvY:c,vertOriginX:c,vertOriginY:c,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:c,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:P}),R=C({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()}),T=C({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:E}),j=C({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(n,e)=>"xml:"+e.slice(3).toLowerCase()}),D=x([O,M,R,T,j],"html"),B=x([O,L,R,T,j],"svg"),U="_props",N=new Map;function F(n,e,t){!function(n){return null!=n&&!1!==n&&""!==n&&(!0===n||("string"==typeof n?"false"!==n.toLowerCase()&&"0"!==n:Boolean(n)))}(t)?n.removeAttribute(e):n.setAttribute(e,e)}function I(n,e,t){try{n[e]=t}catch(o){z(n,e,t,!1)}}function z(n,e,t,o){if(null==t)return void n.removeAttribute(e);const l=String(t);if(o&&e.includes(":")){const[t]=e.split(":");"xlink"===t?n.setAttributeNS("http://www.w3.org/1999/xlink",e,l):n.setAttribute(e,l)}else n.setAttribute(e,l)}function H(n,e,t,o){if(l=n,i=e,document.activeElement===l?["value","selectionStart","selectionEnd","selectionDirection"].includes(i):"scrollTop"===i||"scrollLeft"===i||l instanceof HTMLMediaElement&&["currentTime","paused","playbackRate","volume"].includes(i))return;var l,i;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 o=(l=e.slice(5)).length<=1?l.toLowerCase():l.split("-").map(((n,e)=>0===e?n.toLowerCase():n.charAt(0).toUpperCase()+n.slice(1).toLowerCase())).join("");var l;null==t?delete n.dataset[o]:n.dataset[o]=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 I(n,e,t);if("INPUT"===n.tagName&&"checked"===e)return I(n,e,t),void F(n,e,t);const a=function(n,e){const t=`${n}:${e}`;let o=N.get(t);return void 0===o&&(o=function(n,e){const t=v(e);let o=e,l=r;if(t in n.normal)return n.property[n.normal[t]];if(t.length>4&&"data"===t.slice(0,4)&&k.test(e)){if("-"===e.charAt(4)){const n=e.slice(5).replace(A,_);o="data"+n.charAt(0).toUpperCase()+n.slice(1)}else{const n=e.slice(4);if(!A.test(n)){let t=n.replace(b,w);"-"!==t.charAt(0)&&(t="-"+t),e="data"+t}}l=m}return new l(o,e)}(e?B:D,n)||null,N.set(t,o)),o}(e,o);a?a.boolean||a.overloadedBoolean?F(n,a.attribute,t):a.mustUseProperty&&!o?I(n,a.property,t):z(n,a.attribute,t,o):e.startsWith("aria-")||"role"===e?z(n,e,t,o):e in n||void 0!==n[e]?I(n,e,t):z(n,e,t,o)}function W(n){return/^[a-zA-Z_:][\w\-:.]*$/.test(n)&&!n.includes("<")&&!n.includes(">")&&!n.includes('"')&&!n.includes("'")}function V(n,e,t){const o=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[U]||{},e);n[U]=e||{},function(n,e,t,o){for(const t in e)W(t)&&H(n,t,e[t],o);e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(n)))}(n,o,0,t)}function $(n,...e){return q(e)}function q(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 K={};let X=0;function Y(n,e,...t){const o=q(t);if("string"==typeof n)return{tag:n,props:e,children:o};if(Array.isArray(n))return n;if(void 0===n&&t)return o;if(Object.getPrototypeOf(n).__isAppRunComponent)return{tag:n,props:e,children:o};if("function"==typeof n)return n(e,o);throw new Error(`Unknown tag in vdom ${n}`)}const J=(n,e,t={})=>{null!=e&&!1!==e&&function(n,e,t={}){if(null==e||!1===e)return;if(e=tn(e,t),!n)return;const o="SVG"===n.nodeName;Array.isArray(e)?G(n,e,o):G(n,[e],o)}("string"==typeof n&&n?document.getElementById(n)||document.querySelector(n):n,e=(0,l.A)(e,t),t)};function Z(n,e,t){t=t||"svg"===e.tag,function(n,e){const t=n.nodeName,o=`${e.tag||""}`;return t.toUpperCase()===o.toUpperCase()}(n,e)?(G(n,e.children,t),V(n,e.props,t)):n.parentNode.replaceChild(en(e,t),n)}function G(n,e,t){var o,l;const r=(null===(o=n.childNodes)||void 0===o?void 0:o.length)||0,i=(null==e?void 0:e.length)||0,a=Math.min(r,i);for(let o=0;o<a;o++){const l=e[o],r=n.childNodes[o];if("string"==typeof l)r.textContent!==l&&(3===r.nodeType?r.nodeValue=l:n.replaceChild(nn(l),r));else if(l instanceof HTMLElement||l instanceof SVGElement)n.insertBefore(l,r);else{const e=l.props&&l.props.key;if(e)if(r.key===e)Z(n.childNodes[o],l,t);else{const i=K[e];i?(n.insertBefore(i,r),Z(n.childNodes[o],l,t)):n.replaceChild(en(l,t),r)}else Z(n.childNodes[o],l,t)}}let s=(null===(l=n.childNodes)||void 0===l?void 0:l.length)||0;for(;s>a;)n.removeChild(n.lastChild),s--;if(i>a){const o=document.createDocumentFragment();for(let n=a;n<e.length;n++)o.appendChild(en(e[n],t));n.appendChild(o)}}const Q=n=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",n),Array.from(e.children)};function nn(n){if(0===(null==n?void 0:n.indexOf("_html:"))){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",n.substring(6)),e}return document.createTextNode(null!=n?n:"")}function en(n,e){if(n instanceof HTMLElement||n instanceof SVGElement)return n;if("string"==typeof n)return nn(n);if(!n.tag||"function"==typeof n.tag)return nn(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 V(t,n.props,e),n.children&&n.children.forEach((n=>t.appendChild(en(n,e)))),n.props&&void 0!==n.props.key&&(t.key=n.props.key,K[n.props.key]=t,++X>=500&&(function(){if(!(Object.keys(K).length<=1e3))for(const[n,e]of Object.entries(K))e.isConnected||delete K[n]}(),X=0)),t}function tn(n,e,t=0){var o;if("string"==typeof n)return n;if(Array.isArray(n))return n.map((n=>tn(n,e,t++)));let l=n;if(n&&"function"==typeof n.tag&&Object.getPrototypeOf(n.tag).__isAppRunComponent&&(l=function(n,e,t){const{tag:o,props:l,children:r}=n;let i=`_${t}`,a=l&&l.id;a?i=a:a=`_${t}${Date.now()}`;let s="section";l&&l.as&&(s=l.as,delete l.as),e.__componentCache||(e.__componentCache={});let u=e.__componentCache[i];if(u&&u instanceof o&&u.element)u.renderState(u.state);else{const n=document.createElement(s);u=e.__componentCache[i]=new o(Object.assign(Object.assign({},l),{children:r})).mount(n,{render:!0})}if(u.mounted){const n=u.mounted(l,r,u.state);void 0!==n&&u.setState(n)}return V(u.element,l,!1),u.element}(n,e,t)),l&&Array.isArray(l.children)){const n=null===(o=l.props)||void 0===o?void 0:o._component;if(n){let e=0;l.children=l.children.map((t=>tn(t,n,e++)))}else l.children=l.children.map((n=>tn(n,e,t++)))}return l}},320:(n,e,t)=>{t.d(e,{Fragment:()=>o.FK,createElement:()=>o.n,render:()=>o.cJ,safeHTML:()=>o.t_});var o=t(593)},672:(n,e,t)=>{t.d(e,{C:()=>l,a:()=>o});const o="3.36.1",l=`AppRun-${o}`}},e={};function t(o){var l=e[o];if(void 0!==l)return l.exports;var r=e[o]={exports:{}};return n[o](r,r.exports,t),r.exports}t.d=(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),t.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),t.r=n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var o={};t.r(o);var l=t(466);const r=(n,e,t,o)=>{if(!e||!t)return;const l=n=>{var t,o;const l=e.cloneNode();null===(t=e.parentNode)||void 0===t||t.replaceChild(l,e);const r=null===(o=(e=l).contentWindow)||void 0===o?void 0:o.document;r&&(r.open(),n.indexOf("<html")>=0?r.write(n):r.write((n=>`<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <meta http-equiv="X-UA-Compatible" content="ie=edge">\n <script src="https://cdnjs.cloudflare.com/ajax/libs/custom-elements/1.1.2/custom-elements.min.js"><\/script>\n <title>AppRun Playground</title>\n <style>\n body {\n font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;\n margin: 2em;\n }\n </style>\n <script src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>\n <script src="https://unpkg.com/apprun/dist/apprun-html.js"><\/script>\n</head>\n<body>\n<script>\n Babel.registerPlugin("d", [Babel.availablePlugins["proposal-decorators"], {legacy: true}]);\n Babel.registerPlugin("c", [Babel.availablePlugins["proposal-class-properties"], {loose: true}]);\n Babel.registerPlugin("b", [Babel.availablePlugins["proposal-private-methods"], {loose: true}]);\n<\/script>\n<script type="text/babel" data-plugins="d, c, b">\n ${n}\n<\/script>\n</body>\n</html>`)(n)),r.close())};l(t),!o&&n&&"TEXTAREA"===n.nodeName&&("undefined"==typeof CodeMirror?n.onkeyup=()=>l(n.value):n.editor||(n.editor=CodeMirror.fromTextArea(n,{lineNumbers:!0,mode:"jsx"}),n.editor.on("change",(n=>l(n.getValue())))))};class i extends l.Component{constructor(){super(...arguments),this.view=n=>{const e=n["code-element-id"],t=this.element;let o,r;return o=e?document.getElementById(e):t.previousElementSibling||t.parentElement.previousElementSibling,r=(null==o?void 0:o.innerText)||(null==o?void 0:o.value)||n.code,this.state.code_area=o,this.state.code=r,r?l.app.h(l.app.Fragment,null,l.app.h("div",{class:"toolbox"},!n.hide_button&&l.app.h("a",{class:"button",$onclick:"show-popup"},"Try the Code"))):l.app.h("div",null,"AppRun Play cannot find code to run, please set code-element-id or code.")},this.rendered=({style:n,hide_src:e,code_area:t,code:o})=>{if(!o)return;if(!document.getElementById("play-popup")){document.body.insertAdjacentHTML("beforeend",'<div id="play-popup" class="overlay">\n<style id="apprun-play-style">\n.apprun-play .col {\n height: 100%;\n flex: 1;\n}\n.apprun-preview {\n width: 100%\n}\n.apprun-play .editor, .apprun-play .preview {\n display: inline-block;\n width: calc(100% - 20px);\n height: calc(100% - 10px);\n}\n\na.button {\n font-size: .8em;\n padding: 10px;\n cursor: pointer;\n color: var(--md-primary-bg-color);\n background: var(--md-primary-fg-color)\n}\na.button:hover {\n color: var(--md-primary-fg-color);\n background: var(--md-primary-bg-color)\n}\n\n.overlay {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n background: rgba(0, 0, 0, 0.7);\n visibility: hidden;\n opacity: 0;\n z-index: 999;\n}\n.overlay.show {\n visibility: visible;\n opacity: 1;\n}\n\n.popup {\n margin: 80px auto;\n padding: 20px;\n background: #fff;\n border-radius: 3px;\n position: relative;\n width: 90%;\n height: calc(100% - 150px);\n}\n\n.popup .close {\n position: absolute;\n top: 10px;\n right: 20px;\n font-size: 20px;\n font-weight: bold;\n text-decoration: none;\n color: #333;\n}\n.popup .close:hover {\n color: #06D85F;\n}\n.popup .content {\n height: 100%;\n overflow: hidden;\n display: flex;\n}\n\n.cm-s-default {\n height: 100%;\n font-size: small;\n line-height: 1.5em;\n z-index: 0;\n}\n</style>\n\n\t<div class="popup apprun-play">\n\t\t<a class="close" href="javascript:app.run(\'@close-popup\')">×</a>\n\t\t<div class="content">\n\t\t\t<div class="col">\n <textarea class="editor"></textarea>\n </div>\n <div class="col">\n <iframe class="preview"/>\n </div>\n </div>\n\t</div>\n</div>');const n=document.querySelector(".apprun-play .editor"),e=document.querySelector(".apprun-play .preview");n.value=o,r(n,e,o,!1)}const l=document.createElement("iframe");l.classList.add("apprun-preview"),l.style.cssText=n,this.element.before(l),e&&(t.style.display="none"),r(t,l,o,e)},this.update={"show-popup":({code:n})=>{var e;null===(e=document.querySelector(".apprun-play .editor").editor)||void 0===e||e.setValue(n),document.getElementById("play-popup").classList.add("show")},"@close-popup":()=>{document.getElementById("play-popup").classList.remove("show")}}}}return l.app.webComponent("apprun-play",i),o})()));
|
|
2
2
|
//# sourceMappingURL=apprun-play.js.map
|